@foxy.io/elements 1.43.0-beta.1 → 1.43.0-beta.2
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-coupon-form.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/shared-210abb90.js +64 -0
- package/dist/elements/public/Donation/Donation.d.ts +10 -0
- package/dist/elements/public/Donation/Donation.js +2 -0
- package/dist/elements/public/Donation/Donation.js.map +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.d.ts +2 -0
- package/dist/elements/public/QueryBuilder/QueryBuilder.js +4 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/Input.d.ts +1 -0
- package/dist/elements/public/QueryBuilder/components/Input.js +14 -3
- package/dist/elements/public/QueryBuilder/components/Input.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/RangeValue.js +2 -0
- package/dist/elements/public/QueryBuilder/components/RangeValue.js.map +1 -1
- package/dist/elements/public/TaxForm/TaxForm.js +5 -4
- package/dist/elements/public/TaxForm/TaxForm.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-b6f53f3b.js +0 -64
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-dd303282.js";import"./shared-9dc36194.js";import"./shared-44b46fef.js";import{I as e}from"./shared-cc4b3b42.js";import{p as t,s as r}from"./shared-b6f53f3b.js";import{_ as o,B as s}from"./shared-cb58dfcd.js";import{O as i,T as n}from"./shared-8874ec69.js";import{h as a,c as l,s as d}from"./shared-ba5c42c7.js";import"./shared-2f5cc0e2.js";import{R as c,a as u}from"./shared-aa6dab90.js";import{c as m}from"./shared-4e709717.js";import{r as p}from"./shared-5fd5805c.js";import"./shared-f7bfb29e.js";import"./shared-d68c6616.js";import"./shared-94716ec1.js";import"./shared-66201dc5.js";import"./shared-41208627.js";import{I as f}from"./shared-ffd5932d.js";import"./foxy-generate-codes-form.js";import"./foxy-item-category-card.js";import"./foxy-coupon-codes-form.js";import"./foxy-coupon-code-card.js";import"./foxy-coupon-code-form.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-form.js";import"./foxy-attribute-card.js";import"./foxy-copy-to-clipboard.js";import"./foxy-discount-builder.js";import{i as h}from"./shared-53e42a77.js";import"./shared-0d0585dc.js";import"./shared-9c010e0a.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-1cd02e50.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-dc4d2996.js";import"./shared-e6a1eef8.js";import"./shared-e2d3c014.js";import"./shared-2aa23b5f.js";import"./shared-343d1fd7.js";import"./shared-5afb584d.js";import"./shared-f83207fb.js";import"./shared-5592ec6e.js";import"./shared-cd96ff03.js";import"./shared-5e4a03d1.js";import"./shared-7594e563.js";import"./shared-0aedd809.js";import"./shared-5ef40e86.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-6033e09d.js";import"./shared-d7d949bc.js";import"./shared-8a0bd046.js";import"./shared-9342ca50.js";import"./shared-7fd51889.js";import"./shared-a4216b50.js";import"./shared-c502de27.js";import"./shared-5f8c01f8.js";import"./shared-5212ef4f.js";import"./shared-678beccf.js";import"./foxy-form-dialog.js";import"./shared-2f8e53c0.js";import"./shared-c31c50e2.js";import"./shared-9171c265.js";import"./shared-8ea2bbcc.js";import"./shared-d0aed1c1.js";import"./shared-63c32024.js";import"./shared-79d0699c.js";import"./shared-264e8301.js";import"./shared-6962f117.js";import"./shared-43e2c3f6.js";import"./shared-bab2ea2c.js";import"./shared-2cb397e4.js";import"./shared-70e6f32c.js";import"./shared-b1435a0a.js";import"./shared-bb6d7b97.js";import"./shared-894c69f8.js";import"./shared-656a46f7.js";import"./foxy-swipe-actions.js";import"./foxy-transaction-card.js";import"./shared-274dec57.js";let y,_,x,b,v=e=>e;customElements.define("foxy-internal-query-builder-control",class extends e{constructor(){super(...arguments),this.disableZoom=!1,this.disableOr=!1,this.operators=Object.values(i)}static get properties(){return o(o({},super.properties),{},{disableZoom:{type:Boolean,attribute:"disable-zoom"},disableOr:{type:Boolean,attribute:"disable-or"},operators:{type:Array}})}renderControl(){const{label:e,helperText:t,_errorMessage:r}=this,o=r&&!this.disabled&&!this.readonly;return a(y||(y=v` <section class="grid gap-s leading-xs"> <div ?hidden="${0}"> ${0} ${0} </div> <div class="bg-contrast-5 rounded" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> <foxy-query-builder infer="query-builder" style="--lumo-border-radius:var(--lumo-border-radius-s);--lumo-border-radius-l:var(--lumo-border-radius-s)" .operators="${0}" .value="${0}" ?disable-zoom="${0}" ?disable-or="${0}" @change="${0}"> </foxy-query-builder> </div> ${0} </section> `),!e&&!t,e?a(_||(_=v`<p class="text-l font-medium">${0}</p>`),e):"",t?a(x||(x=v`<p class="text-s text-secondary">${0}</p>`),t):"",this.operators,this._value,this.disableZoom,this.disableOr,(e=>{var t;const r=e.currentTarget;this._value=null!==(t=r.value)&&void 0!==t?t:""}),o?a(b||(b=v`<p class="text-s text-error">${0}</p>`),r):"")}});let g,j,$,w,C,k,A,V,R,S,q=e=>e;class O extends(c(e)){static get styles(){return[super.styles,l(g||(g=q`.gap-1px{gap:1px}.grid-vertical{grid-template:auto/var(--lumo-size-m) 1fr}:host([sm]) .sm-grid-horizontal{grid-template:auto/var(--lumo-size-m) 1fr var(--lumo-size-m) 1fr}`))]}renderControl(){const e=a(j||(j=q` <div class="flex items-center h-s"> <div class="w-m text-center leading-none uppercase font-medium text-xs text-contrast-20"> <foxy-i18n infer="" key="or"></foxy-i18n> </div> <div class="flex-1 border-t border-contrast-10"></div> <div class="w-m ml-s flex-shrink-0"></div> </div> `));return a($||($=q` <div class="mb-s" ?hidden="${0}"> <p class="font-medium text-body text-l" ?hidden="${0}">${0}</p> <p class="text-s text-secondary" ?hidden="${0}">${0}</p> </div> <div class="rounded bg-contrast-5" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} </div> <p class="text-s text-error mt-s" ?hidden="${0}"> ${0} </p> `),!this.label&&!this.helperText,!this.label,this.label,!this.helperText,this.helperText,p([...Object.entries(this._value||{}),null],((e,t)=>String(t)),((t,r)=>null===t?[r>0?e:"",this.__renderRule({onChange:({key:e,items:t})=>{var r;this._value=o(o({},this._value),{},{[e]:[...null!==(r=this._value[e])&&void 0!==r?r:[],...t]})}})]:[r>0?e:"",this.__renderRule({rule:{key:t[0],items:t[1]},onChange:e=>{var r,o;const s={},i=Object.keys(this._value);for(let n=0;n<i.length;n++){const a=i[n];if(a===t[0])if(e.key===a)s[a]=e.items;else{const t=null!==(r=this._value[e.key])&&void 0!==r?r:[];n>i.indexOf(e.key)?s[e.key]=[...t,...e.items]:(s[e.key]=[...e.items,...t],i.splice(i.indexOf(e.key),1))}else s[a]=null!==(o=this._value[a])&&void 0!==o?o:[]}this._value=s},onDelete:()=>{const e=o({},this._value);delete e[t[0]],this._value=e}})])),!this._errorMessage||this.disabled||this.readonly,this._errorMessage)}get _value(){var e;return null!==(e=super._value)&&void 0!==e?e:{}}set _value(e){super._value=e}__renderRule({rule:e,onDelete:t,onChange:r}){var o,s;const i=null!==(o=null==e?void 0:e.items)&&void 0!==o?o:[];return a(w||(w=q` <div class="flex items-center space-x-s" aria-label="${0}"> <div class="flex-1 bg-base rounded-s overflow-hidden border border-contrast-10"> <div class="bg-contrast-10"> <div class="grid gap-1px grid-vertical sm-grid-horizontal"> <div class="bg-base"> <div aria-hidden="true" class="${0}"> ${0} </div> </div> <div class="bg-base"> ${0} </div> <div class="bg-base"> <div class="${0}"> <div aria-hidden="true"> ${0} </div> </div> </div> <div class="bg-base"> <div class="bg-contrast-10 grid grid-cols-1 gap-1px"> ${0} </div> </div> </div> </div> </div> <div class="flex -mr-s self-start flex-col sm-flex-row flex-shrink-0 items-center border-t border-b border-transparent divide-y divide-transparent" ?hidden="${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> ${0} </button> </div> </div> `),this.t("rule"),m({"text-tertiary":!this.readonly&&!this.disabled,"text-disabled":this.readonly||this.disabled,"w-m h-m":!0}),d(C||(C=q`<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 8C12.48 8 8 12.48 8 18C8 23.52 12.48 28 18 28C23.52 28 28 23.52 28 18C28 12.48 23.52 8 18 8ZM18 26C13.59 26 10 22.41 10 18C10 13.59 13.59 10 18 10C22.41 10 26 13.59 26 18C26 22.41 22.41 26 18 26Z" class="fill-current"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.49 17.38C19.92 16.16 19.66 14.74 18.68 13.76C17.57 12.65 15.89 12.46 14.58 13.17L16.93 15.52L15.52 16.93L13.17 14.58C12.46 15.9 12.65 17.57 13.76 18.68C14.74 19.66 16.16 19.92 17.38 19.49L20.79 22.9C20.99 23.1 21.3 23.1 21.5 22.9L22.9 21.5C23.1 21.3 23.1 20.99 22.9 20.79L19.49 17.38Z" class="fill-current"/></svg>`)),this.__renderInput({value:null!==(s=null==e?void 0:e.key)&&void 0!==s?s:"",label:this.t("option_name"),onChange:e=>{void 0===e?null==t||t():r({key:e,items:i})}}),m({"flex items-center justify-center w-m h-m transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50":!0,"cursor-default text-tertiary":!(this.disabled||this.readonly),"text-disabled cursor-default":this.disabled||this.readonly}),d(k||(k=q`<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.5 9.8C11.0088 9.8 9.8 11.0088 9.8 12.5V23.5C9.8 24.9912 11.0088 26.2 12.5 26.2H14C14.6627 26.2 15.2 25.6627 15.2 25C15.2 24.3373 14.6627 23.8 14 23.8H13.5C12.782 23.8 12.2 23.218 12.2 22.5V13.5C12.2 12.782 12.782 12.2 13.5 12.2H14C14.6627 12.2 15.2 11.6627 15.2 11C15.2 10.3373 14.6627 9.8 14 9.8H12.5Z" class="fill-current"/><path d="M22 9.8C21.3373 9.8 20.8 10.3373 20.8 11C20.8 11.6627 21.3373 12.2 22 12.2H22.5C23.218 12.2 23.8 12.782 23.8 13.5V22.5C23.8 23.218 23.218 23.8 22.5 23.8H22C21.3373 23.8 20.8 24.3373 20.8 25C20.8 25.6627 21.3373 26.2 22 26.2H23.5C24.9912 26.2 26.2 24.9912 26.2 23.5V12.5C26.2 11.0088 24.9912 9.8 23.5 9.8H22Z" class="fill-current"/></svg>`)),p(this.readonly?i:[...i,null],((e,t)=>t),((t,o)=>a(A||(A=q` <div class="bg-base"> ${0} </div> `),this.__renderInput({value:null!=t?t:"",label:t?String(o+1):this.t("add_value"),onChange:s=>{const n=[...i];s?null===t?n.push(s):n[o]=s:n.splice(o,1),e&&r({key:e.key,items:n})}})))),this.readonly||0===Object.keys(this._value).length,this.t("delete"),m({"box-content flex items-center justify-center":!0,"w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!this.disabled,"cursor-default text-disabled":this.disabled,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!e}),this.disabled||this.readonly||!e,(()=>null==t?void 0:t()),d(V||(V=q`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="text-l" style="width: 1.25em; height: 1.25em"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12H9m12 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>`)))}__renderInput(e){return a(R||(R=q` <label class="relative flex items-center cursor-text group text-tertiary"> <div class="relative flex-1 min-w-0 overflow-hidden"> <input placeholder="${0}" class="${0}" .value="${0}" ?disabled="${0}" @keydown="${0}" @change="${0}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} </label> `),e.label,m({"bg-base relative flex h-m px-s font-medium w-full":!0,"text-body":!this.disabled&&!this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly,"flex max-w-full whitespace-nowrap":!0,"focus-outline-none":!0}),e.value,this.disabled||this.readonly,(t=>{const r=t.currentTarget;"Backspace"!==t.key||r.value||e.onChange()}),(t=>{t.currentTarget.value||e.onChange()}),(t=>{const r=t.currentTarget;e.onChange(r.value)}),m({"font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s":!0,"inline-block":!!e.value,"sr-only":!e.value,"text-body":!this.disabled&&!this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly}),this.t(e.label),this.disabled||this.readonly?"":a(S||(S=q` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}}customElements.define("foxy-internal-array-map-control",O);let T,H,L,I,M,B=e=>e;customElements.define("foxy-internal-coupon-form-rules-control",class extends e{renderControl(){var e,t;const r=this.nucleon,o=null!==(e=null==r?void 0:r.form.coupon_discount_details)&&void 0!==e?e:"",s=null!==(t=null==r?void 0:r.form.coupon_discount_type)&&void 0!==t?t:"quantity_amount",i=this.helperText,n=this.__renderRulesDescription(),l=this._errorMessage;return a(T||(T=B` <section> <div class="mb-s" ?hidden="${0}"> <p class="flex items-center justify-between space-x-m"> <span class="font-medium flex-1 text-l">${0}</span> <span class="min-w-0">${0}</span> </p> <p class="text-s text-secondary">${0}</p> </div> <foxy-discount-builder infer="discount-builder" .parsedValue="${0}" @change="${0}"> </foxy-discount-builder> ${0} ${0} </section> `),!this.label&&!i&&!n,this.label,this.__renderPreset(),i,{details:o,type:s,name:"Rules"},(e=>{const t=e.currentTarget.parsedValue,r=this.nucleon;null==r||r.edit({coupon_discount_details:t.details,coupon_discount_type:t.type})}),n?a(H||(H=B`<p class="text-s text-secondary mt-s">${0}</p>`),n):"",!l||this.disabled||this.readonly?"":a(L||(L=B`<p class="mt-s text-s leading-xs text-error">${0}</p>`),this._errorMessage))}__renderRulesDescription(){var e,t;const r=this.nucleon,o=null!==(e=null==r?void 0:r.form.coupon_discount_type)&&void 0!==e?e:"quantity_amount",s=null!==(t=null==r?void 0:r.form.coupon_discount_details)&&void 0!==t?t:"";return s?this.t("discount_summary",{params:{details:s,type:o,ns:this.ns}}):null}__renderPreset(){const e=this.nucleon,t=null==e?void 0:e.form.coupon_discount_details,r=null==e?void 0:e.form.coupon_discount_type,s=[{type:"quantity_amount",details:"allunits|2-2"},{type:"quantity_percentage",details:"allunits|5-10|10-20"},{type:"quantity_amount",details:"incremental|3-5"},{type:"quantity_percentage",details:"incremental|11-10|51-15|101-20"},{type:"quantity_percentage",details:"repeat|2-100"},{type:"quantity_percentage",details:"repeat|4-50"},{type:"quantity_amount",details:"single|5-10"},{type:"price_percentage",details:"single|99.99-10"}],i=s.find((e=>e.details===t&&e.type===r));return a(I||(I=B` <label data-testid="rules:preset" class="${0}"> <foxy-i18n class="sr-only" infer="" key="preset"></foxy-i18n> <span class="relative font-medium flex items-center"> <span class="truncate"> ${0} </span> <iron-icon class="icon-inline text-xl ml-xs -mr-xs" icon="icons:expand-more"></iron-icon> <select data-testclass="interactive editable" data-testid="rules:preset:select" class="opacity-0 absolute inset-0 focus-outline-none" ?disabled="${0}" @change="${0}"> ${0} <option value="custom" ?selected="${0}"> ${0} </option> </select> </span> </label> `),m({"whitespace-nowrap block ring-primary-50 rounded px-xs -mx-xs transition-colors":!0,"text-body hover-text-primary focus-within-ring-2":!this.disabled&&!this.readonly,"text-secondary":this.readonly,"text-disabled":this.disabled}),i?this.t("discount_summary",{params:o(o({},i),{},{ns:this.ns})}):this.t("custom_discount"),this.disabled||this.readonly,(e=>{var t,r;const o=e.currentTarget,i=s[o.selectedIndex],n=this.nucleon;null==n||n.edit({coupon_discount_details:null!==(t=null==i?void 0:i.details)&&void 0!==t?t:"",coupon_discount_type:null!==(r=null==i?void 0:i.type)&&void 0!==r?r:"quantity_amount"})}),s.map((e=>a(M||(M=B` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.details,e===i,this.t("discount_summary",{params:o(o({},e),{},{ns:this.ns})})))),!i&&!!t&&!!r,this.t("custom_discount"))}});let Z,z,P=e=>e;const D=c(u(f,"coupon-form"));class G extends D{constructor(){var e;super(...arguments),e=this,this.getTransactionPageHref=null,this.__customerAttributeRestrictionsOperators=[i.Not,i.In],this.__customerAttributeRestrictionsGetValue=()=>{var e;const o=t(null!==(e=this.form.customer_attribute_restrictions)&&void 0!==e?e:"").filter((e=>Array.isArray(e)||"string"==typeof e.name)).map((e=>{if(Array.isArray(e))return e.filter((({name:e})=>"string"==typeof e)).map((({name:e,operator:t,value:r})=>({path:e,operator:t,value:r})));return{operator:e.operator,value:e.value,path:e.name}}));return r(o,!0)},this.__customerAttributeRestrictionsSetValue=e=>{const o=t(e).map((e=>{if(Array.isArray(e))return e.map((({path:e,operator:t,value:r})=>({name:e,path:"attributes",operator:t,value:r})));return{operator:e.operator,value:e.value,path:"attributes",name:e.path}}));this.edit({customer_attribute_restrictions:r(o,!0)})},this.__customerSubscriptionRestrictionsGetValue=()=>{var e;const t=null===(e=this.form.customer_subscription_restrictions)||void 0===e?void 0:e.split(",").map((e=>e.trim())).filter(((e,t,r)=>!!e&&r.indexOf(e)===t)).map((e=>({value:e})));return null!=t?t:[]},this.__customerSubscriptionRestrictionsSetValue=e=>{this.edit({customer_subscription_restrictions:e.map((({value:e})=>e.trim())).filter(((e,t,r)=>!!e&&r.indexOf(e)===t)).join()}),this.edit({customer_auto_apply:!!this.form.customer_subscription_restrictions||!!this.form.customer_attribute_restrictions})},this.__productCodeRestrictionsGetValue=()=>{var e;return null===(e=this.form.product_code_restrictions)||void 0===e?void 0:e.split(",").filter((e=>!!e.trim())).map((e=>({value:e,label:e.startsWith("-")?this.t("product-code-restrictions.label_block",{value:e.substring(1)}):this.t("product-code-restrictions.label_allow",{value:e})})))},this.__productCodeRestrictionsSetValue=e=>{this.edit({product_code_restrictions:e.map((({value:e,unit:t})=>"block"===t?`-${e}`:e)).filter(((e,t,r)=>!!e&&r.indexOf(e)===t)).join(",")})},this.__storeLoaderId="storeLoader",this.__codesFilters=[{label:"code",path:"code",type:n.String},{label:"used_codes",path:"number_of_uses_to_date",type:n.Number},{label:"date_created",path:"date_created",type:n.Date},{label:"date_modified",path:"date_modified",type:n.Date}],this.__couponCodesActions=[{theme:"contrast",state:"idle",text:"copy_button_text",onClick:async function(t){e.__couponCodesActions[0].state="busy",e.__couponCodesActions=[...e.__couponCodesActions];try{await navigator.clipboard.writeText(t.code),e.__couponCodesActions[0].state="end"}catch(t){e.__couponCodesActions[0].state="error"}finally{e.__couponCodesActions=[...e.__couponCodesActions],setTimeout((()=>{e.__couponCodesActions[0].state="idle",e.__couponCodesActions=[...e.__couponCodesActions]}),1e3)}}}]}static get properties(){return o(o({},super.properties),{},{getTransactionPageHref:{attribute:!1},__couponCodesActions:{type:Array}})}static get v8n(){return[({name:e})=>!!e||"name:v8n_required",({name:e})=>!e||e.length<=50||"name:v8n_too_long",({inclusive_tax_rate:e})=>!e||e>=0||"inclusive-tax-rate:v8n_too_small",({inclusive_tax_rate:e})=>!e||e<=1||"inclusive-tax-rate:v8n_too_big",({number_of_uses_allowed:e})=>!e||e>=0||"number-of-uses-allowed:v8n_too_small",({coupon_discount_details:e})=>!!e||"rules:v8n_required",({coupon_discount_details:e})=>!e||e.length<=200||"rules:v8n_too_long",({item_option_restrictions:e})=>!e||JSON.stringify(e).length<=6e3||"item-option-restrictions:v8n_too_long",({product_code_restrictions:e})=>!e||e.length<=5e3||"product-code-restrictions:v8n_too_long",({customer_attribute_restrictions:e})=>!e||e.length<=2e3||"customer-attribute-restrictions:v8n_too_long",({number_of_uses_allowed_per_code:e})=>!e||e>=0||"number-of-uses-allowed-per-code:v8n_too_small",({customer_subscription_restrictions:e})=>!e||e.length<=200||"customer-subscription-restrictions:v8n_too_long",({number_of_uses_allowed_per_customer:e})=>!e||e>=0||"number-of-uses-allowed-per-customer:v8n_too_small"]}get hiddenSelector(){const e=[super.hiddenSelector.toString()];return this.data?e.push("coupon-codes-stub","category-restrictions-stub","attributes-stub"):e.push("coupon-codes","category-restrictions","attributes"),new s(e.join(" ").trim())}get headerSubtitleOptions(){return o(o({},super.headerSubtitleOptions),{},{id:this.headerCopyIdValue})}renderHeaderActions(e){return a(Z||(Z=P` <foxy-internal-bulk-add-action-control parent="${0}" infer="generate" form="foxy-generate-codes-form" .related="${0}"> </foxy-internal-bulk-add-action-control> <foxy-internal-bulk-add-action-control parent="${0}" infer="import" form="foxy-coupon-codes-form" .related="${0}"> </foxy-internal-bulk-add-action-control> ${0} `),e._links["fx:generate_codes"].href,[e._links["fx:coupon_codes"].href],e._links["fx:coupon_codes"].href,[e._links["fx:coupon_codes"].href],super.renderHeaderActions(e))}renderBody(){var e,t,r,o,s,i,n,l;let d;try{const r=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:coupon_codes"].href)&&void 0!==t?t:"");r.searchParams.set("order","date_created desc"),d=r.toString()}catch(e){d=void 0}return a(z||(z=P` ${0} <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="name"></foxy-internal-text-control> </foxy-internal-summary-control> <foxy-internal-coupon-form-rules-control infer="rules"> </foxy-internal-coupon-form-rules-control> <foxy-internal-summary-control infer="coupon-codes-stub"> <p class="text-disabled"><foxy-i18n infer="" key="text"></foxy-i18n></p> </foxy-internal-summary-control> <foxy-internal-async-list-control first="${0}" limit="5" infer="coupon-codes" item="foxy-coupon-code-card" form="foxy-coupon-code-form" alert .formProps="${0}" .actions="${0}" .filters="${0}"> </foxy-internal-async-list-control> <foxy-internal-editable-list-control infer="product-code-restrictions" .getValue="${0}" .setValue="${0}" .units="${0}"> </foxy-internal-editable-list-control> <foxy-internal-array-map-control infer="item-option-restrictions"> </foxy-internal-array-map-control> <foxy-internal-query-builder-control infer="customer-attribute-restrictions" disable-zoom disable-or .operators="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-query-builder-control> <foxy-internal-editable-list-control infer="customer-subscription-restrictions" .getValue="${0}" .setValue="${0}"> </foxy-internal-editable-list-control> <foxy-internal-summary-control infer="auto-apply"> <foxy-internal-switch-control infer="customer-auto-apply"></foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="category-restrictions-stub"> <p class="text-disabled"><foxy-i18n infer="" key="text"></foxy-i18n></p> </foxy-internal-summary-control> <foxy-internal-async-resource-link-list-control foreign-key-for-uri="item_category_uri" foreign-key-for-id="item_category_id" own-key-for-uri="coupon_uri" own-uri="${0}" embed-key="fx:coupon_item_categories" options-href="${0}" links-href="${0}" infer="category-restrictions" limit="5" item="foxy-item-category-card"> </foxy-internal-async-resource-link-list-control> <foxy-internal-summary-control infer="uses"> <foxy-internal-number-control layout="summary-item" infer="number-of-uses-allowed" step="1" min="0"> </foxy-internal-number-control> <foxy-internal-number-control layout="summary-item" infer="number-of-uses-allowed-per-customer" step="1" min="0"> </foxy-internal-number-control> <foxy-internal-number-control layout="summary-item" infer="number-of-uses-allowed-per-code" step="1" min="0"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="timeframe"> <foxy-internal-date-control layout="summary-item" infer="start-date"> </foxy-internal-date-control> <foxy-internal-date-control layout="summary-item" infer="end-date"> </foxy-internal-date-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="taxes"> <foxy-internal-number-control layout="summary-item" infer="inclusive-tax-rate" min="0" max="1"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="options"> <foxy-internal-switch-control infer="multiple-codes-allowed"></foxy-internal-switch-control> <foxy-internal-switch-control infer="combinable"></foxy-internal-switch-control> <foxy-internal-switch-control infer="exclude-category-discounts"> </foxy-internal-switch-control> <foxy-internal-switch-control infer="exclude-line-item-discounts"> </foxy-internal-switch-control> <foxy-internal-switch-control infer="is-taxable"></foxy-internal-switch-control> <foxy-internal-switch-control infer="shared-codes-allowed"></foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="attributes-stub"> <p class="text-disabled"><foxy-i18n infer="" key="text"></foxy-i18n></p> </foxy-internal-summary-control> <foxy-internal-async-list-control first="${0}" limit="5" infer="attributes" item="foxy-attribute-card" form="foxy-attribute-form" alert> </foxy-internal-async-list-control> ${0} <foxy-nucleon infer="" class="hidden" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),d,{".getTransactionPageHref":this.getTransactionPageHref},this.__couponCodesActions,this.__codesFilters,this.__productCodeRestrictionsGetValue,this.__productCodeRestrictionsSetValue,[{label:this.t("product-code-restrictions.unit_allow"),value:"allow"},{label:this.t("product-code-restrictions.unit_block"),value:"block"}],this.__customerAttributeRestrictionsOperators,this.__customerAttributeRestrictionsGetValue,this.__customerAttributeRestrictionsSetValue,this.__customerSubscriptionRestrictionsGetValue,this.__customerSubscriptionRestrictionsSetValue,h(null===(r=this.data)||void 0===r?void 0:r._links.self.href),h(null===(s=null===(o=this.__storeLoader)||void 0===o?void 0:o.data)||void 0===s?void 0:s._links["fx:item_categories"].href),h(null===(i=this.data)||void 0===i?void 0:i._links["fx:coupon_item_categories"].href),h(null===(n=this.data)||void 0===n?void 0:n._links["fx:attributes"].href),super.renderBody(),h(null===(l=this.data)||void 0===l?void 0:l._links["fx:store"].href),this.__storeLoaderId,(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}}customElements.define("foxy-coupon-form",G);export{G as CouponForm};
|
|
1
|
+
import"./shared-dd303282.js";import"./shared-9dc36194.js";import"./shared-44b46fef.js";import{I as e}from"./shared-cc4b3b42.js";import{p as t,s as r}from"./shared-210abb90.js";import{_ as o,B as s}from"./shared-cb58dfcd.js";import{O as i,T as n}from"./shared-8874ec69.js";import{h as a,c as l,s as d}from"./shared-ba5c42c7.js";import"./shared-2f5cc0e2.js";import{R as c,a as u}from"./shared-aa6dab90.js";import{c as m}from"./shared-4e709717.js";import{r as p}from"./shared-5fd5805c.js";import"./shared-f7bfb29e.js";import"./shared-d68c6616.js";import"./shared-94716ec1.js";import"./shared-66201dc5.js";import"./shared-41208627.js";import{I as f}from"./shared-ffd5932d.js";import"./foxy-generate-codes-form.js";import"./foxy-item-category-card.js";import"./foxy-coupon-codes-form.js";import"./foxy-coupon-code-card.js";import"./foxy-coupon-code-form.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-form.js";import"./foxy-attribute-card.js";import"./foxy-copy-to-clipboard.js";import"./foxy-discount-builder.js";import{i as h}from"./shared-53e42a77.js";import"./shared-0d0585dc.js";import"./shared-9c010e0a.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-1cd02e50.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-dc4d2996.js";import"./shared-e6a1eef8.js";import"./shared-e2d3c014.js";import"./shared-2aa23b5f.js";import"./shared-343d1fd7.js";import"./shared-5afb584d.js";import"./shared-f83207fb.js";import"./shared-5592ec6e.js";import"./shared-cd96ff03.js";import"./shared-5e4a03d1.js";import"./shared-7594e563.js";import"./shared-0aedd809.js";import"./shared-5ef40e86.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-6033e09d.js";import"./shared-d7d949bc.js";import"./shared-8a0bd046.js";import"./shared-9342ca50.js";import"./shared-7fd51889.js";import"./shared-a4216b50.js";import"./shared-c502de27.js";import"./shared-5f8c01f8.js";import"./shared-5212ef4f.js";import"./shared-678beccf.js";import"./foxy-form-dialog.js";import"./shared-2f8e53c0.js";import"./shared-c31c50e2.js";import"./shared-9171c265.js";import"./shared-8ea2bbcc.js";import"./shared-d0aed1c1.js";import"./shared-63c32024.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./shared-264e8301.js";import"./shared-6962f117.js";import"./shared-bab2ea2c.js";import"./shared-2cb397e4.js";import"./shared-70e6f32c.js";import"./shared-b1435a0a.js";import"./shared-bb6d7b97.js";import"./shared-894c69f8.js";import"./shared-656a46f7.js";import"./foxy-swipe-actions.js";import"./foxy-transaction-card.js";import"./shared-274dec57.js";let y,_,x,b,v=e=>e;customElements.define("foxy-internal-query-builder-control",class extends e{constructor(){super(...arguments),this.disableZoom=!1,this.disableOr=!1,this.operators=Object.values(i)}static get properties(){return o(o({},super.properties),{},{disableZoom:{type:Boolean,attribute:"disable-zoom"},disableOr:{type:Boolean,attribute:"disable-or"},operators:{type:Array}})}renderControl(){const{label:e,helperText:t,_errorMessage:r}=this,o=r&&!this.disabled&&!this.readonly;return a(y||(y=v` <section class="grid gap-s leading-xs"> <div ?hidden="${0}"> ${0} ${0} </div> <div class="bg-contrast-5 rounded" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> <foxy-query-builder infer="query-builder" style="--lumo-border-radius:var(--lumo-border-radius-s);--lumo-border-radius-l:var(--lumo-border-radius-s)" .operators="${0}" .value="${0}" ?disable-zoom="${0}" ?disable-or="${0}" @change="${0}"> </foxy-query-builder> </div> ${0} </section> `),!e&&!t,e?a(_||(_=v`<p class="text-l font-medium">${0}</p>`),e):"",t?a(x||(x=v`<p class="text-s text-secondary">${0}</p>`),t):"",this.operators,this._value,this.disableZoom,this.disableOr,(e=>{var t;const r=e.currentTarget;this._value=null!==(t=r.value)&&void 0!==t?t:""}),o?a(b||(b=v`<p class="text-s text-error">${0}</p>`),r):"")}});let g,j,$,w,C,k,A,V,R,S,q=e=>e;class O extends(c(e)){static get styles(){return[super.styles,l(g||(g=q`.gap-1px{gap:1px}.grid-vertical{grid-template:auto/var(--lumo-size-m) 1fr}:host([sm]) .sm-grid-horizontal{grid-template:auto/var(--lumo-size-m) 1fr var(--lumo-size-m) 1fr}`))]}renderControl(){const e=a(j||(j=q` <div class="flex items-center h-s"> <div class="w-m text-center leading-none uppercase font-medium text-xs text-contrast-20"> <foxy-i18n infer="" key="or"></foxy-i18n> </div> <div class="flex-1 border-t border-contrast-10"></div> <div class="w-m ml-s flex-shrink-0"></div> </div> `));return a($||($=q` <div class="mb-s" ?hidden="${0}"> <p class="font-medium text-body text-l" ?hidden="${0}">${0}</p> <p class="text-s text-secondary" ?hidden="${0}">${0}</p> </div> <div class="rounded bg-contrast-5" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} </div> <p class="text-s text-error mt-s" ?hidden="${0}"> ${0} </p> `),!this.label&&!this.helperText,!this.label,this.label,!this.helperText,this.helperText,p([...Object.entries(this._value||{}),null],((e,t)=>String(t)),((t,r)=>null===t?[r>0?e:"",this.__renderRule({onChange:({key:e,items:t})=>{var r;this._value=o(o({},this._value),{},{[e]:[...null!==(r=this._value[e])&&void 0!==r?r:[],...t]})}})]:[r>0?e:"",this.__renderRule({rule:{key:t[0],items:t[1]},onChange:e=>{var r,o;const s={},i=Object.keys(this._value);for(let n=0;n<i.length;n++){const a=i[n];if(a===t[0])if(e.key===a)s[a]=e.items;else{const t=null!==(r=this._value[e.key])&&void 0!==r?r:[];n>i.indexOf(e.key)?s[e.key]=[...t,...e.items]:(s[e.key]=[...e.items,...t],i.splice(i.indexOf(e.key),1))}else s[a]=null!==(o=this._value[a])&&void 0!==o?o:[]}this._value=s},onDelete:()=>{const e=o({},this._value);delete e[t[0]],this._value=e}})])),!this._errorMessage||this.disabled||this.readonly,this._errorMessage)}get _value(){var e;return null!==(e=super._value)&&void 0!==e?e:{}}set _value(e){super._value=e}__renderRule({rule:e,onDelete:t,onChange:r}){var o,s;const i=null!==(o=null==e?void 0:e.items)&&void 0!==o?o:[];return a(w||(w=q` <div class="flex items-center space-x-s" aria-label="${0}"> <div class="flex-1 bg-base rounded-s overflow-hidden border border-contrast-10"> <div class="bg-contrast-10"> <div class="grid gap-1px grid-vertical sm-grid-horizontal"> <div class="bg-base"> <div aria-hidden="true" class="${0}"> ${0} </div> </div> <div class="bg-base"> ${0} </div> <div class="bg-base"> <div class="${0}"> <div aria-hidden="true"> ${0} </div> </div> </div> <div class="bg-base"> <div class="bg-contrast-10 grid grid-cols-1 gap-1px"> ${0} </div> </div> </div> </div> </div> <div class="flex -mr-s self-start flex-col sm-flex-row flex-shrink-0 items-center border-t border-b border-transparent divide-y divide-transparent" ?hidden="${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> ${0} </button> </div> </div> `),this.t("rule"),m({"text-tertiary":!this.readonly&&!this.disabled,"text-disabled":this.readonly||this.disabled,"w-m h-m":!0}),d(C||(C=q`<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 8C12.48 8 8 12.48 8 18C8 23.52 12.48 28 18 28C23.52 28 28 23.52 28 18C28 12.48 23.52 8 18 8ZM18 26C13.59 26 10 22.41 10 18C10 13.59 13.59 10 18 10C22.41 10 26 13.59 26 18C26 22.41 22.41 26 18 26Z" class="fill-current"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.49 17.38C19.92 16.16 19.66 14.74 18.68 13.76C17.57 12.65 15.89 12.46 14.58 13.17L16.93 15.52L15.52 16.93L13.17 14.58C12.46 15.9 12.65 17.57 13.76 18.68C14.74 19.66 16.16 19.92 17.38 19.49L20.79 22.9C20.99 23.1 21.3 23.1 21.5 22.9L22.9 21.5C23.1 21.3 23.1 20.99 22.9 20.79L19.49 17.38Z" class="fill-current"/></svg>`)),this.__renderInput({value:null!==(s=null==e?void 0:e.key)&&void 0!==s?s:"",label:this.t("option_name"),onChange:e=>{void 0===e?null==t||t():r({key:e,items:i})}}),m({"flex items-center justify-center w-m h-m transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50":!0,"cursor-default text-tertiary":!(this.disabled||this.readonly),"text-disabled cursor-default":this.disabled||this.readonly}),d(k||(k=q`<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.5 9.8C11.0088 9.8 9.8 11.0088 9.8 12.5V23.5C9.8 24.9912 11.0088 26.2 12.5 26.2H14C14.6627 26.2 15.2 25.6627 15.2 25C15.2 24.3373 14.6627 23.8 14 23.8H13.5C12.782 23.8 12.2 23.218 12.2 22.5V13.5C12.2 12.782 12.782 12.2 13.5 12.2H14C14.6627 12.2 15.2 11.6627 15.2 11C15.2 10.3373 14.6627 9.8 14 9.8H12.5Z" class="fill-current"/><path d="M22 9.8C21.3373 9.8 20.8 10.3373 20.8 11C20.8 11.6627 21.3373 12.2 22 12.2H22.5C23.218 12.2 23.8 12.782 23.8 13.5V22.5C23.8 23.218 23.218 23.8 22.5 23.8H22C21.3373 23.8 20.8 24.3373 20.8 25C20.8 25.6627 21.3373 26.2 22 26.2H23.5C24.9912 26.2 26.2 24.9912 26.2 23.5V12.5C26.2 11.0088 24.9912 9.8 23.5 9.8H22Z" class="fill-current"/></svg>`)),p(this.readonly?i:[...i,null],((e,t)=>t),((t,o)=>a(A||(A=q` <div class="bg-base"> ${0} </div> `),this.__renderInput({value:null!=t?t:"",label:t?String(o+1):this.t("add_value"),onChange:s=>{const n=[...i];s?null===t?n.push(s):n[o]=s:n.splice(o,1),e&&r({key:e.key,items:n})}})))),this.readonly||0===Object.keys(this._value).length,this.t("delete"),m({"box-content flex items-center justify-center":!0,"w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!this.disabled,"cursor-default text-disabled":this.disabled,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!e}),this.disabled||this.readonly||!e,(()=>null==t?void 0:t()),d(V||(V=q`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="text-l" style="width: 1.25em; height: 1.25em"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12H9m12 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>`)))}__renderInput(e){return a(R||(R=q` <label class="relative flex items-center cursor-text group text-tertiary"> <div class="relative flex-1 min-w-0 overflow-hidden"> <input placeholder="${0}" class="${0}" .value="${0}" ?disabled="${0}" @keydown="${0}" @change="${0}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} </label> `),e.label,m({"bg-base relative flex h-m px-s font-medium w-full":!0,"text-body":!this.disabled&&!this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly,"flex max-w-full whitespace-nowrap":!0,"focus-outline-none":!0}),e.value,this.disabled||this.readonly,(t=>{const r=t.currentTarget;"Backspace"!==t.key||r.value||e.onChange()}),(t=>{t.currentTarget.value||e.onChange()}),(t=>{const r=t.currentTarget;e.onChange(r.value)}),m({"font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s":!0,"inline-block":!!e.value,"sr-only":!e.value,"text-body":!this.disabled&&!this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly}),this.t(e.label),this.disabled||this.readonly?"":a(S||(S=q` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}}customElements.define("foxy-internal-array-map-control",O);let T,H,L,I,M,B=e=>e;customElements.define("foxy-internal-coupon-form-rules-control",class extends e{renderControl(){var e,t;const r=this.nucleon,o=null!==(e=null==r?void 0:r.form.coupon_discount_details)&&void 0!==e?e:"",s=null!==(t=null==r?void 0:r.form.coupon_discount_type)&&void 0!==t?t:"quantity_amount",i=this.helperText,n=this.__renderRulesDescription(),l=this._errorMessage;return a(T||(T=B` <section> <div class="mb-s" ?hidden="${0}"> <p class="flex items-center justify-between space-x-m"> <span class="font-medium flex-1 text-l">${0}</span> <span class="min-w-0">${0}</span> </p> <p class="text-s text-secondary">${0}</p> </div> <foxy-discount-builder infer="discount-builder" .parsedValue="${0}" @change="${0}"> </foxy-discount-builder> ${0} ${0} </section> `),!this.label&&!i&&!n,this.label,this.__renderPreset(),i,{details:o,type:s,name:"Rules"},(e=>{const t=e.currentTarget.parsedValue,r=this.nucleon;null==r||r.edit({coupon_discount_details:t.details,coupon_discount_type:t.type})}),n?a(H||(H=B`<p class="text-s text-secondary mt-s">${0}</p>`),n):"",!l||this.disabled||this.readonly?"":a(L||(L=B`<p class="mt-s text-s leading-xs text-error">${0}</p>`),this._errorMessage))}__renderRulesDescription(){var e,t;const r=this.nucleon,o=null!==(e=null==r?void 0:r.form.coupon_discount_type)&&void 0!==e?e:"quantity_amount",s=null!==(t=null==r?void 0:r.form.coupon_discount_details)&&void 0!==t?t:"";return s?this.t("discount_summary",{params:{details:s,type:o,ns:this.ns}}):null}__renderPreset(){const e=this.nucleon,t=null==e?void 0:e.form.coupon_discount_details,r=null==e?void 0:e.form.coupon_discount_type,s=[{type:"quantity_amount",details:"allunits|2-2"},{type:"quantity_percentage",details:"allunits|5-10|10-20"},{type:"quantity_amount",details:"incremental|3-5"},{type:"quantity_percentage",details:"incremental|11-10|51-15|101-20"},{type:"quantity_percentage",details:"repeat|2-100"},{type:"quantity_percentage",details:"repeat|4-50"},{type:"quantity_amount",details:"single|5-10"},{type:"price_percentage",details:"single|99.99-10"}],i=s.find((e=>e.details===t&&e.type===r));return a(I||(I=B` <label data-testid="rules:preset" class="${0}"> <foxy-i18n class="sr-only" infer="" key="preset"></foxy-i18n> <span class="relative font-medium flex items-center"> <span class="truncate"> ${0} </span> <iron-icon class="icon-inline text-xl ml-xs -mr-xs" icon="icons:expand-more"></iron-icon> <select data-testclass="interactive editable" data-testid="rules:preset:select" class="opacity-0 absolute inset-0 focus-outline-none" ?disabled="${0}" @change="${0}"> ${0} <option value="custom" ?selected="${0}"> ${0} </option> </select> </span> </label> `),m({"whitespace-nowrap block ring-primary-50 rounded px-xs -mx-xs transition-colors":!0,"text-body hover-text-primary focus-within-ring-2":!this.disabled&&!this.readonly,"text-secondary":this.readonly,"text-disabled":this.disabled}),i?this.t("discount_summary",{params:o(o({},i),{},{ns:this.ns})}):this.t("custom_discount"),this.disabled||this.readonly,(e=>{var t,r;const o=e.currentTarget,i=s[o.selectedIndex],n=this.nucleon;null==n||n.edit({coupon_discount_details:null!==(t=null==i?void 0:i.details)&&void 0!==t?t:"",coupon_discount_type:null!==(r=null==i?void 0:i.type)&&void 0!==r?r:"quantity_amount"})}),s.map((e=>a(M||(M=B` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.details,e===i,this.t("discount_summary",{params:o(o({},e),{},{ns:this.ns})})))),!i&&!!t&&!!r,this.t("custom_discount"))}});let Z,z,P=e=>e;const D=c(u(f,"coupon-form"));class G extends D{constructor(){var e;super(...arguments),e=this,this.getTransactionPageHref=null,this.__customerAttributeRestrictionsOperators=[i.Not,i.In],this.__customerAttributeRestrictionsGetValue=()=>{var e;const o=t(null!==(e=this.form.customer_attribute_restrictions)&&void 0!==e?e:"").filter((e=>Array.isArray(e)||"string"==typeof e.name)).map((e=>{if(Array.isArray(e))return e.filter((({name:e})=>"string"==typeof e)).map((({name:e,operator:t,value:r})=>({path:e,operator:t,value:r})));return{operator:e.operator,value:e.value,path:e.name}}));return r(o,!0)},this.__customerAttributeRestrictionsSetValue=e=>{const o=t(e).map((e=>{if(Array.isArray(e))return e.map((({path:e,operator:t,value:r})=>({name:e,path:"attributes",operator:t,value:r})));return{operator:e.operator,value:e.value,path:"attributes",name:e.path}}));this.edit({customer_attribute_restrictions:r(o,!0)})},this.__customerSubscriptionRestrictionsGetValue=()=>{var e;const t=null===(e=this.form.customer_subscription_restrictions)||void 0===e?void 0:e.split(",").map((e=>e.trim())).filter(((e,t,r)=>!!e&&r.indexOf(e)===t)).map((e=>({value:e})));return null!=t?t:[]},this.__customerSubscriptionRestrictionsSetValue=e=>{this.edit({customer_subscription_restrictions:e.map((({value:e})=>e.trim())).filter(((e,t,r)=>!!e&&r.indexOf(e)===t)).join()}),this.edit({customer_auto_apply:!!this.form.customer_subscription_restrictions||!!this.form.customer_attribute_restrictions})},this.__productCodeRestrictionsGetValue=()=>{var e;return null===(e=this.form.product_code_restrictions)||void 0===e?void 0:e.split(",").filter((e=>!!e.trim())).map((e=>({value:e,label:e.startsWith("-")?this.t("product-code-restrictions.label_block",{value:e.substring(1)}):this.t("product-code-restrictions.label_allow",{value:e})})))},this.__productCodeRestrictionsSetValue=e=>{this.edit({product_code_restrictions:e.map((({value:e,unit:t})=>"block"===t?`-${e}`:e)).filter(((e,t,r)=>!!e&&r.indexOf(e)===t)).join(",")})},this.__storeLoaderId="storeLoader",this.__codesFilters=[{label:"code",path:"code",type:n.String},{label:"used_codes",path:"number_of_uses_to_date",type:n.Number},{label:"date_created",path:"date_created",type:n.Date},{label:"date_modified",path:"date_modified",type:n.Date}],this.__couponCodesActions=[{theme:"contrast",state:"idle",text:"copy_button_text",onClick:async function(t){e.__couponCodesActions[0].state="busy",e.__couponCodesActions=[...e.__couponCodesActions];try{await navigator.clipboard.writeText(t.code),e.__couponCodesActions[0].state="end"}catch(t){e.__couponCodesActions[0].state="error"}finally{e.__couponCodesActions=[...e.__couponCodesActions],setTimeout((()=>{e.__couponCodesActions[0].state="idle",e.__couponCodesActions=[...e.__couponCodesActions]}),1e3)}}}]}static get properties(){return o(o({},super.properties),{},{getTransactionPageHref:{attribute:!1},__couponCodesActions:{type:Array}})}static get v8n(){return[({name:e})=>!!e||"name:v8n_required",({name:e})=>!e||e.length<=50||"name:v8n_too_long",({inclusive_tax_rate:e})=>!e||e>=0||"inclusive-tax-rate:v8n_too_small",({inclusive_tax_rate:e})=>!e||e<=1||"inclusive-tax-rate:v8n_too_big",({number_of_uses_allowed:e})=>!e||e>=0||"number-of-uses-allowed:v8n_too_small",({coupon_discount_details:e})=>!!e||"rules:v8n_required",({coupon_discount_details:e})=>!e||e.length<=200||"rules:v8n_too_long",({item_option_restrictions:e})=>!e||JSON.stringify(e).length<=6e3||"item-option-restrictions:v8n_too_long",({product_code_restrictions:e})=>!e||e.length<=5e3||"product-code-restrictions:v8n_too_long",({customer_attribute_restrictions:e})=>!e||e.length<=2e3||"customer-attribute-restrictions:v8n_too_long",({number_of_uses_allowed_per_code:e})=>!e||e>=0||"number-of-uses-allowed-per-code:v8n_too_small",({customer_subscription_restrictions:e})=>!e||e.length<=200||"customer-subscription-restrictions:v8n_too_long",({number_of_uses_allowed_per_customer:e})=>!e||e>=0||"number-of-uses-allowed-per-customer:v8n_too_small"]}get hiddenSelector(){const e=[super.hiddenSelector.toString()];return this.data?e.push("coupon-codes-stub","category-restrictions-stub","attributes-stub"):e.push("coupon-codes","category-restrictions","attributes"),new s(e.join(" ").trim())}get headerSubtitleOptions(){return o(o({},super.headerSubtitleOptions),{},{id:this.headerCopyIdValue})}renderHeaderActions(e){return a(Z||(Z=P` <foxy-internal-bulk-add-action-control parent="${0}" infer="generate" form="foxy-generate-codes-form" .related="${0}"> </foxy-internal-bulk-add-action-control> <foxy-internal-bulk-add-action-control parent="${0}" infer="import" form="foxy-coupon-codes-form" .related="${0}"> </foxy-internal-bulk-add-action-control> ${0} `),e._links["fx:generate_codes"].href,[e._links["fx:coupon_codes"].href],e._links["fx:coupon_codes"].href,[e._links["fx:coupon_codes"].href],super.renderHeaderActions(e))}renderBody(){var e,t,r,o,s,i,n,l;let d;try{const r=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:coupon_codes"].href)&&void 0!==t?t:"");r.searchParams.set("order","date_created desc"),d=r.toString()}catch(e){d=void 0}return a(z||(z=P` ${0} <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="name"></foxy-internal-text-control> </foxy-internal-summary-control> <foxy-internal-coupon-form-rules-control infer="rules"> </foxy-internal-coupon-form-rules-control> <foxy-internal-summary-control infer="coupon-codes-stub"> <p class="text-disabled"><foxy-i18n infer="" key="text"></foxy-i18n></p> </foxy-internal-summary-control> <foxy-internal-async-list-control first="${0}" limit="5" infer="coupon-codes" item="foxy-coupon-code-card" form="foxy-coupon-code-form" alert .formProps="${0}" .actions="${0}" .filters="${0}"> </foxy-internal-async-list-control> <foxy-internal-editable-list-control infer="product-code-restrictions" .getValue="${0}" .setValue="${0}" .units="${0}"> </foxy-internal-editable-list-control> <foxy-internal-array-map-control infer="item-option-restrictions"> </foxy-internal-array-map-control> <foxy-internal-query-builder-control infer="customer-attribute-restrictions" disable-zoom disable-or .operators="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-query-builder-control> <foxy-internal-editable-list-control infer="customer-subscription-restrictions" .getValue="${0}" .setValue="${0}"> </foxy-internal-editable-list-control> <foxy-internal-summary-control infer="auto-apply"> <foxy-internal-switch-control infer="customer-auto-apply"></foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="category-restrictions-stub"> <p class="text-disabled"><foxy-i18n infer="" key="text"></foxy-i18n></p> </foxy-internal-summary-control> <foxy-internal-async-resource-link-list-control foreign-key-for-uri="item_category_uri" foreign-key-for-id="item_category_id" own-key-for-uri="coupon_uri" own-uri="${0}" embed-key="fx:coupon_item_categories" options-href="${0}" links-href="${0}" infer="category-restrictions" limit="5" item="foxy-item-category-card"> </foxy-internal-async-resource-link-list-control> <foxy-internal-summary-control infer="uses"> <foxy-internal-number-control layout="summary-item" infer="number-of-uses-allowed" step="1" min="0"> </foxy-internal-number-control> <foxy-internal-number-control layout="summary-item" infer="number-of-uses-allowed-per-customer" step="1" min="0"> </foxy-internal-number-control> <foxy-internal-number-control layout="summary-item" infer="number-of-uses-allowed-per-code" step="1" min="0"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="timeframe"> <foxy-internal-date-control layout="summary-item" infer="start-date"> </foxy-internal-date-control> <foxy-internal-date-control layout="summary-item" infer="end-date"> </foxy-internal-date-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="taxes"> <foxy-internal-number-control layout="summary-item" infer="inclusive-tax-rate" min="0" max="1"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="options"> <foxy-internal-switch-control infer="multiple-codes-allowed"></foxy-internal-switch-control> <foxy-internal-switch-control infer="combinable"></foxy-internal-switch-control> <foxy-internal-switch-control infer="exclude-category-discounts"> </foxy-internal-switch-control> <foxy-internal-switch-control infer="exclude-line-item-discounts"> </foxy-internal-switch-control> <foxy-internal-switch-control infer="is-taxable"></foxy-internal-switch-control> <foxy-internal-switch-control infer="shared-codes-allowed"></foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="attributes-stub"> <p class="text-disabled"><foxy-i18n infer="" key="text"></foxy-i18n></p> </foxy-internal-summary-control> <foxy-internal-async-list-control first="${0}" limit="5" infer="attributes" item="foxy-attribute-card" form="foxy-attribute-form" alert> </foxy-internal-async-list-control> ${0} <foxy-nucleon infer="" class="hidden" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),d,{".getTransactionPageHref":this.getTransactionPageHref},this.__couponCodesActions,this.__codesFilters,this.__productCodeRestrictionsGetValue,this.__productCodeRestrictionsSetValue,[{label:this.t("product-code-restrictions.unit_allow"),value:"allow"},{label:this.t("product-code-restrictions.unit_block"),value:"block"}],this.__customerAttributeRestrictionsOperators,this.__customerAttributeRestrictionsGetValue,this.__customerAttributeRestrictionsSetValue,this.__customerSubscriptionRestrictionsGetValue,this.__customerSubscriptionRestrictionsSetValue,h(null===(r=this.data)||void 0===r?void 0:r._links.self.href),h(null===(s=null===(o=this.__storeLoader)||void 0===o?void 0:o.data)||void 0===s?void 0:s._links["fx:item_categories"].href),h(null===(i=this.data)||void 0===i?void 0:i._links["fx:coupon_item_categories"].href),h(null===(n=this.data)||void 0===n?void 0:n._links["fx:attributes"].href),super.renderBody(),h(null===(l=this.data)||void 0===l?void 0:l._links["fx:store"].href),this.__storeLoaderId,(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}}customElements.define("foxy-coupon-form",G);export{G as CouponForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as t}from"./shared-cb58dfcd.js";import"./shared-1cd02e50.js";import"./shared-e88763ec.js";import"./shared-c502de27.js";import{L as e,c as s,h as i}from"./shared-ba5c42c7.js";import{T as r,y as n}from"./shared-aa6dab90.js";import{p as a}from"./shared-2f5cc0e2.js";import"./shared-dc4d2996.js";import"./shared-9c010e0a.js";import"./shared-8ea2bbcc.js";import{c as o}from"./shared-4e709717.js";import{b as c,C as h,I as d}from"./shared-74d599dc.js";import"./shared-c31c50e2.js";import{E as l}from"./shared-2828fcbf.js";import{G as m}from"./shared-4b393539.js";import"./shared-a4216b50.js";import"./shared-8a0bd046.js";import"./shared-5f8c01f8.js";import"./shared-fed829c2.js";import"./shared-9342ca50.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-343d1fd7.js";import"./shared-2aa23b5f.js";import"./shared-e6a1eef8.js";import"./shared-678beccf.js";import"./shared-2cb397e4.js";import"./shared-8f009bbb.js";import"./shared-d7d949bc.js";import"./shared-7fd51889.js";import"./shared-53e476fd.js";import"./shared-5ef40e86.js";import"./shared-4dd24dda.js";import"./shared-6962f117.js";import"./shared-5592ec6e.js";import"./shared-5afb584d.js";import"./shared-53e42a77.js";class u extends CustomEvent{constructor(t){super("change",{detail:t})}}let p,y,g=t=>t;class f extends(r(e)){constructor(){super(...arguments),this.readonly=!1,this.disabled=!1,this.checked=!1}static get properties(){return t(t({},super.properties),{},{readonly:{type:Boolean},disabled:{type:Boolean},checked:{type:Boolean}})}static get styles(){return[super.styles,s(p||(p=g`:host{--check-size:1.125rem}label{margin:calc(((1rem * var(--lumo-line-height-s)) - var(--check-size))/ -2) 0}label>:first-child{height:calc(1rem * var(--lumo-line-height-s))}.ml-xxl{margin-left:calc(var(--lumo-space-m) + var(--check-size))}.check{height:var(--check-size);width:var(--check-size)}`))]}render(){return i(y||(y=g` <label class="${0}"> <div class="flex items-center"> <div class="${0}"> <iron-icon icon="lumo:checkmark" class="${0}"> </iron-icon> <input type="checkbox" class="sr-only" .checked="${0}" ?disabled="${0}" data-testid="input" @change="${0}"> </div> </div> <div class="flex-1 font-lumo leading-s ml-m"> <slot></slot> </div> </label> <div class="${0}"> <slot name="content"></slot> </div> `),o({"flex items-start group transition-colors":!0,"cursor-default":this.disabled||this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly,"cursor-pointer":!this.disabled}),o({"flex-shrink-0 check transition-colors rounded-s border":!0,"focus-within-shadow-outline":!0,"bg-primary text-primary-contrast":!this.readonly&&this.checked,"border-dashed border-contrast-30":this.readonly,"border-transparent":!this.readonly,"opacity-50":this.disabled,"text-secondary bg-contrast-20":!this.readonly&&!this.checked,"group-hover-bg-contrast-30":!this.readonly&&!this.checked}),o({"block w-full h-full transition-transform transform":!0,"scale-100":this.checked,"scale-0":!this.checked}),this.checked,this.disabled,(t=>{if(this.readonly)return t.preventDefault();t.stopPropagation(),this.checked=!this.checked,this.dispatchEvent(new u(this.checked))}),o({"font-lumo ml-xxl transition-colors":!0,"text-disabled":this.disabled}))}}class b extends CustomEvent{constructor(t){super("change",{detail:t})}}class x extends CustomEvent{constructor(){super("submit",{cancelable:!0})}}let $,v,_,j,k,q,S,
|
|
1
|
+
import{_ as t}from"./shared-cb58dfcd.js";import"./shared-1cd02e50.js";import"./shared-e88763ec.js";import"./shared-c502de27.js";import{L as e,c as s,h as i}from"./shared-ba5c42c7.js";import{T as r,y as n}from"./shared-aa6dab90.js";import{p as a}from"./shared-2f5cc0e2.js";import"./shared-dc4d2996.js";import"./shared-9c010e0a.js";import"./shared-8ea2bbcc.js";import{c as o}from"./shared-4e709717.js";import{b as c,C as h,I as d}from"./shared-74d599dc.js";import"./shared-c31c50e2.js";import{E as l}from"./shared-2828fcbf.js";import{G as m}from"./shared-4b393539.js";import"./shared-a4216b50.js";import"./shared-8a0bd046.js";import"./shared-5f8c01f8.js";import"./shared-fed829c2.js";import"./shared-9342ca50.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-343d1fd7.js";import"./shared-2aa23b5f.js";import"./shared-e6a1eef8.js";import"./shared-678beccf.js";import"./shared-2cb397e4.js";import"./shared-8f009bbb.js";import"./shared-d7d949bc.js";import"./shared-7fd51889.js";import"./shared-53e476fd.js";import"./shared-5ef40e86.js";import"./shared-4dd24dda.js";import"./shared-6962f117.js";import"./shared-5592ec6e.js";import"./shared-5afb584d.js";import"./shared-53e42a77.js";class u extends CustomEvent{constructor(t){super("change",{detail:t})}}let p,y,g=t=>t;class f extends(r(e)){constructor(){super(...arguments),this.readonly=!1,this.disabled=!1,this.checked=!1}static get properties(){return t(t({},super.properties),{},{readonly:{type:Boolean},disabled:{type:Boolean},checked:{type:Boolean}})}static get styles(){return[super.styles,s(p||(p=g`:host{--check-size:1.125rem}label{margin:calc(((1rem * var(--lumo-line-height-s)) - var(--check-size))/ -2) 0}label>:first-child{height:calc(1rem * var(--lumo-line-height-s))}.ml-xxl{margin-left:calc(var(--lumo-space-m) + var(--check-size))}.check{height:var(--check-size);width:var(--check-size)}`))]}render(){return i(y||(y=g` <label class="${0}"> <div class="flex items-center"> <div class="${0}"> <iron-icon icon="lumo:checkmark" class="${0}"> </iron-icon> <input type="checkbox" class="sr-only" .checked="${0}" ?disabled="${0}" data-testid="input" @change="${0}"> </div> </div> <div class="flex-1 font-lumo leading-s ml-m"> <slot></slot> </div> </label> <div class="${0}"> <slot name="content"></slot> </div> `),o({"flex items-start group transition-colors":!0,"cursor-default":this.disabled||this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly,"cursor-pointer":!this.disabled}),o({"flex-shrink-0 check transition-colors rounded-s border":!0,"focus-within-shadow-outline":!0,"bg-primary text-primary-contrast":!this.readonly&&this.checked,"border-dashed border-contrast-30":this.readonly,"border-transparent":!this.readonly,"opacity-50":this.disabled,"text-secondary bg-contrast-20":!this.readonly&&!this.checked,"group-hover-bg-contrast-30":!this.readonly&&!this.checked}),o({"block w-full h-full transition-transform transform":!0,"scale-100":this.checked,"scale-0":!this.checked}),this.checked,this.disabled,(t=>{if(this.readonly)return t.preventDefault();t.stopPropagation(),this.checked=!this.checked,this.dispatchEvent(new u(this.checked))}),o({"font-lumo ml-xxl transition-colors":!0,"text-disabled":this.disabled}))}}class b extends CustomEvent{constructor(t){super("change",{detail:t})}}class x extends CustomEvent{constructor(){super("submit",{cancelable:!0})}}let $,v,_,j,k,q,w,S,A=t=>t;class E extends n{constructor(){super("donation"),this.currency=null,this.amount=null,this.store=null,this.name=null,this.custom=null,this.amounts=null,this.frequency=null,this.frequencies=null,this.designation=null,this.designations=null,this.comment=null,this.anonymity=!1,this.anonymous=!1,this.image=null,this.code=null,this.url=null,this.cart="checkout",this.target="_top"}static get scopedElements(){return{"vaadin-text-area":customElements.get("vaadin-text-area"),"x-error-screen":l,"vaadin-button":customElements.get("vaadin-button"),"x-dropdown":c,"x-checkbox":f,"x-choice":h,"x-group":m,"x-i18n":d}}static get properties(){return t(t({},super.properties),{},{currency:{type:String},custom:{type:Array},amount:{type:Number},amounts:{type:Array},frequency:{type:String},frequencies:{type:Array},designation:{type:Array},designations:{type:Array},comment:{type:String},anonymity:{reflect:!0,type:Boolean},anonymous:{reflect:!0,type:Boolean},image:{type:String},store:{type:String},name:{type:String},code:{type:String},url:{type:String},cart:{type:String},target:{type:String},empty:{type:String}})}static get events(){return{change:b,submit:x}}submit(){this.dispatchEvent(new x)&&this.__form.submit()}render(){var t,e;if(!(this.currency&&this.amount&&this.store&&this.name))return i($||($=A` <x-error-screen data-testid="error" type="setup_needed" class="relative"></x-error-screen> `));const s=this.store.includes(".")?this.store:`${this.store}.foxycart.com`;return i(v||(v=A` <form target="${0}" class="sr-only" method="POST" action="https://${0}/cart" data-testid="form"> ${0} </form> <section> ${0} </section> <section> ${0} </section> <section> ${0} </section> <section> ${0} <div class="flex flex-wrap -m-s"> ${0} <div class="flex-1 p-s"> <vaadin-button class="w-full" theme="primary" data-testid="submit" @click="${0}"> <x-i18n .opts="${0}" lang="${0}" key="${0}" ns="${0}"> </x-i18n> </vaadin-button> </div> </div> </section> `),this.target,s,[...this.__data.entries()].map((([t,e])=>i(_||(_=A`<input type="hidden" name="${0}" value="${0}">`),t,e))),this.amounts&&this.amounts.length>0?i(j||(j=A` <x-group frame> <x-i18n ns="${0}" lang="${0}" key="amount" slot="header"></x-i18n> <x-choice ?custom="${0}" .getText="${0}" .items="${0}" .value="${0}" type="number" lang="${0}" min="1" ns="${0}" data-testid="amount" @change="${0}"> </x-choice> </x-group> <slot name="amount" class="block my-m"></slot> `),this.ns,this.lang,!!(null===(t=this.custom)||void 0===t?void 0:t.includes("amount")),(t=>this.__translateAmount(parseFloat(t))),this.amounts.map(String),this.amount.toString(),this.lang,this.ns,(t=>{const e=parseFloat(t.detail);this.amount=isNaN(e)?1:e})):"",this.designations&&this.designations.length>0?i(k||(k=A` <x-dropdown .label="${0}" .items="${0}" .value="${0}" data-testid="designation" @change="${0}"> </x-dropdown> <slot name="designation" class="block my-m"></slot> `),this._t("designation").toString(),this.designations,Array.isArray(this.designation)?"${this.designation[0]}: ${this.designation[1]}":this.designation,(t=>{this.designation=t.detail})):"","string"==typeof this.comment?i(q||(q=A` <vaadin-text-area placeholder="${0}" value="${0}" label="${0}" class="w-full" data-testid="comment" @input="${0}"> </vaadin-text-area> <slot name="comment" class="block my-m"></slot> `),this._t("comment_placeholder").toString(),this.comment,this._t("comment_label").toString(),(t=>{t.stopPropagation(),this.comment=t.target.value})):"",this.anonymity?i(w||(w=A` <x-checkbox class="my-m" data-testid="anonymity" ?checked="${0}" @change="${0}"> ${0} </x-checkbox> `),this.anonymous,(t=>this.anonymous=t.detail),this._t("anonymous")):"",this.frequencies&&this.frequencies.length>0?i(S||(S=A` <div class="flex-1 p-s"> <x-dropdown .value="${0}" .items="${0}" .getText="${0}" data-testid="frequency" @change="${0}"> </x-dropdown> </div> `),this.frequency,this.frequencies,this.__translateFrequency.bind(this),(t=>{this.frequency=t.detail})):"",(()=>this.submit()),{amount:this.__translateAmount(this.amount),frequency:this.frequency?this.__translateFrequency(this.frequency):""},this.lang,this.frequency&&!(null===(e=this.frequencies)||void 0===e?void 0:e.length)?"donate_recurrently":"donate",this.ns)}updated(){this.dispatchEvent(new b(this.__data))}get __data(){const t=new FormData;return"string"==typeof this.designation&&t.set("Designation",this.designation.trim()),"number"==typeof this.amount&&"string"==typeof this.currency&&t.set("price",`${this.amount.toFixed(2)}${this.currency}`),this.frequency&&t.set("sub_frequency",this.frequency),"string"==typeof this.comment&&t.set("Comment",this.comment.trim()),"string"==typeof this.image&&t.set("image",this.image),"string"==typeof this.code&&t.set("code",this.code),"string"==typeof this.name&&t.set("name",this.name.trim()),"string"==typeof this.url&&t.set("url",this.url),"string"==typeof this.cart&&t.set("cart",this.cart),this.empty&&t.set("empty",this.empty),this.anonymous&&t.set("Anonymous","true"),window.FC&&t.set(window.FC.settings.session_name,window.FC.settings.session_id),t.set("quantity","1"),t}get __form(){return this.shadowRoot.querySelector("form")}__translateFrequency(t){if(!t||t.match(/^\s*$/))return this._t("frequency_once");if(".5m"===t)return this._t("frequency_0_5m");const{count:e,units:s}=a(t);return this._t("frequency",{units:this._t(s,{count:e}),count:e})}__translateAmount(t){return t.toLocaleString(this.lang,{minimumFractionDigits:0,currency:this.currency,style:"currency"})}}customElements.define("foxy-donation",E);export{E as Donation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./shared-cc4b3b42.js";import"./shared-1cd02e50.js";import"./shared-2f5cc0e2.js";import{h as t}from"./shared-ba5c42c7.js";import"./shared-66201dc5.js";import{I as r}from"./shared-ffd5932d.js";import"./shared-
|
|
1
|
+
import{a as e}from"./shared-cc4b3b42.js";import"./shared-1cd02e50.js";import"./shared-2f5cc0e2.js";import{h as t}from"./shared-ba5c42c7.js";import"./shared-66201dc5.js";import{I as r}from"./shared-ffd5932d.js";import"./shared-210abb90.js";import{_ as s,B as a}from"./shared-cb58dfcd.js";import{a as i}from"./shared-aa6dab90.js";import{d as o,e as n}from"./shared-eb963ba3.js";import"./shared-5212ef4f.js";import"./shared-5afb584d.js";import"./shared-53e42a77.js";import"./shared-2aa23b5f.js";import"./shared-f83207fb.js";import"./shared-5592ec6e.js";import"./shared-343d1fd7.js";import"./shared-cd96ff03.js";import"./shared-5e4a03d1.js";import"./shared-7594e563.js";import"./shared-0aedd809.js";import"./shared-5ef40e86.js";import"./shared-9c010e0a.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-c502de27.js";import"./shared-5f8c01f8.js";import"./shared-9342ca50.js";import"./shared-a4216b50.js";import"./shared-4e709717.js";import"./shared-d0aed1c1.js";import"./shared-2f8e53c0.js";import"./shared-c31c50e2.js";import"./foxy-copy-to-clipboard.js";import"./shared-9171c265.js";import"./shared-dc4d2996.js";import"./shared-e6a1eef8.js";import"./shared-8ea2bbcc.js";import"./shared-e2d3c014.js";import"./foxy-spinner.js";import"./shared-bab2ea2c.js";import"./shared-8874ec69.js";import"./shared-63c32024.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./shared-5fd5805c.js";let d,l,h=e=>e;customElements.define("foxy-internal-filter-attribute-form-action-control",class extends e{renderControl(){const e=this.nucleon,r=null==e?void 0:e.in({idle:{snapshot:"dirty"}}),s=!!(null==e?void 0:e.data);return t(d||(d=h` <div class="grid grid-cols-2 gap-m"> ${0} <vaadin-button theme="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <foxy-i18n infer="" key="${0}"> </foxy-i18n> </vaadin-button> </div> `),s&&r?t(l||(l=h` <vaadin-button theme="contrast" ?disabled="${0}" @click="${0}"> <foxy-i18n infer="" key="reset"></foxy-i18n> </vaadin-button> `),this.disabled,(()=>null==e?void 0:e.undo())):"",s?r?"secondary":"error":"success",s&&r?"":"col-span-2",this.disabled,(()=>!s||r?null==e?void 0:e.submit():null==e?void 0:e.delete()),s?r?"update":"delete":"create")}});let c,m=e=>e;const u=i(r,"filter-attribute-form");class f extends u{constructor(){super(...arguments),this.defaults=null,this.pathname=null,this.options=[],this.__filterNameGetValue=()=>{const e=this.constructor;return this.__getValueParam(e.filterNameKey)},this.__filterNameSetValue=e=>{const t=this.constructor;this.__setValueParam(t.filterNameKey,e)}}static get properties(){return s(s({},super.properties),{},{defaults:{},pathname:{},options:{type:Array}})}get hiddenSelector(){const e=[],t=this.constructor,r=this.__getValueParam(t.filterQueryKey),s=!!this.data,i=!!this.form.value;return s||e.push("filter-name"),i&&(r||s)||e.push("action"),new a(`${e.join(" ")} ${super.hiddenSelector}`.trim())}renderBody(){const e=this.constructor;return t(c||(c=m` <foxy-query-builder infer="filter-query" .options="${0}" .value="${0}" @change="${0}"> </foxy-query-builder> <foxy-internal-text-control infer="filter-name" .getValue="${0}" .setValue="${0}"> </foxy-internal-text-control> <foxy-internal-filter-attribute-form-action-control infer="action"> </foxy-internal-filter-attribute-form-action-control> `),this.options,this.__getValueParam(e.filterQueryKey),this.__handleFilterQueryChange,this.__filterNameGetValue,this.__filterNameSetValue)}updated(e){var t;if(super.updated(e),"string"==typeof this.form.value){const e=new URL(o(this.form.value),"https://example.com");e.pathname=null!==(t=this.pathname)&&void 0!==t?t:"";const r=n(e.toString().substring(e.origin.length));r!==this.form.value&&this.edit({value:r})}}submit(){const e=this.constructor;this.edit({visibility:e.attributeVisibility,name:e.attributeName}),super.submit()}__getValueParam(e){var t,r,s;try{const a=this.constructor;let i=null!==(r=new URL(o(null!==(t=this.form.value)&&void 0!==t?t:""),"https://example.com").searchParams.get(e))&&void 0!==r?r:"";if(e===a.filterQueryKey&&(this.in({idle:{snapshot:"clean"}})||this.in({idle:{template:"clean"}})))try{const e=new URLSearchParams(i),t=new URLSearchParams(null!==(s=this.defaults)&&void 0!==s?s:"");e.forEach(((e,r)=>t.set(r,e))),i=t.toString()}catch(e){}return i}catch(e){return""}}__setValueParam(e,t){var r;try{const s=new URL(o(null!==(r=this.form.value)&&void 0!==r?r:""),"https://example.com");s.searchParams.set(e,t),this.edit({value:n(s.toString().substring(s.origin.length))})}catch(e){}}__handleFilterQueryChange(e){var t;const r=this.constructor,s=e.currentTarget;this.__setValueParam(r.filterQueryKey,null!==(t=s.value)&&void 0!==t?t:"")}}f.attributeVisibility="restricted",f.filterQueryKey="filter_query",f.attributeName="foxy-admin-bookmark",f.filterNameKey="filter_name",customElements.define("foxy-filter-attribute-form",f);export{f as FilterAttributeForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-e2d3c014.js";import"./shared-dc4d2996.js";export{Q as QueryBuilder}from"./shared-
|
|
1
|
+
import"./shared-e2d3c014.js";import"./shared-dc4d2996.js";export{Q as QueryBuilder}from"./shared-210abb90.js";import"./shared-567ba8ae.js";import"./shared-aa6dab90.js";import"./shared-cb58dfcd.js";import"./shared-ba5c42c7.js";import"./shared-e6a1eef8.js";import"./shared-8874ec69.js";import"./shared-63c32024.js";import"./shared-4e709717.js";import"./shared-53e42a77.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./shared-5fd5805c.js";import"./shared-2aa23b5f.js";import"./shared-5afb584d.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-dd303282.js";import"./shared-656a46f7.js";import"./shared-f7bfb29e.js";import"./shared-6033e09d.js";import"./shared-d68c6616.js";import"./shared-94716ec1.js";import"./shared-66201dc5.js";import{I as e}from"./shared-ffd5932d.js";import"./foxy-native-integration-card.js";import"./foxy-item-category-card.js";import"./foxy-nucleon-element.js";import{_ as t,B as r}from"./shared-cb58dfcd.js";import{a as i}from"./shared-aa6dab90.js";import{i as o}from"./shared-53e42a77.js";import{h as n}from"./shared-ba5c42c7.js";import"./shared-0d0585dc.js";import"./shared-9c010e0a.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-1cd02e50.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-dc4d2996.js";import"./shared-e6a1eef8.js";import"./shared-e2d3c014.js";import"./shared-2f5cc0e2.js";import"./shared-343d1fd7.js";import"./shared-2aa23b5f.js";import"./shared-5afb584d.js";import"./shared-f83207fb.js";import"./shared-5592ec6e.js";import"./shared-cd96ff03.js";import"./shared-5e4a03d1.js";import"./shared-7594e563.js";import"./shared-0aedd809.js";import"./shared-5ef40e86.js";import"./shared-5fd5805c.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-cc4b3b42.js";import"./shared-5212ef4f.js";import"./shared-678beccf.js";import"./shared-9342ca50.js";import"./shared-a4216b50.js";import"./shared-c502de27.js";import"./shared-5f8c01f8.js";import"./shared-4e709717.js";import"./shared-d7d949bc.js";import"./shared-8a0bd046.js";import"./shared-7fd51889.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-2f8e53c0.js";import"./shared-c31c50e2.js";import"./shared-9171c265.js";import"./shared-8ea2bbcc.js";import"./shared-d0aed1c1.js";import"./foxy-copy-to-clipboard.js";import"./shared-bab2ea2c.js";import"./shared-894c69f8.js";import"./shared-bb6d7b97.js";import"./shared-b1435a0a.js";let s,a=e=>e;const l=i(e,"tax-form"),d=["US","CA","AT","BE","BG","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IM","IT","LT","LU","LV","MC","MT","NL","PL","PT","RO","SE","SI","SK"],c=[...d,"AU"];class u extends l{constructor(){super(...arguments),this.nativeIntegrations=null,this.itemCategories=null,this.countries=null,this.regions=null,this.__countrySetValue=e=>{this.edit({country:e,region:"",city:""}),this.edit({apply_to_shipping:this.__isApplyToShippingHidden})},this.__regionSetValue=e=>{this.edit({region:e,city:""})},this.__typeSetValue=e=>{this.edit({type:e,country:"",region:"",city:"",service_provider:"custom_tax_endpoint"===e?"custom_tax":"",apply_to_shipping:!1,use_origin_rates:!1,exempt_all_customer_tax_ids:!1,is_live:!1,rate:0})},this.__typeOptions=JSON.stringify([{label:"option_custom_tax_endpoint",value:"custom_tax_endpoint"},{label:"option_global",value:"global"},{label:"option_union",value:"union"},{label:"option_country",value:"country"},{label:"option_region",value:"region"},{label:"option_local",value:"local"}])}static get properties(){return t(t({},super.properties),{},{nativeIntegrations:{attribute:"native-integrations"},itemCategories:{attribute:"item-categories"},countries:{},regions:{}})}static get v8n(){return[({name:e})=>!!e||"name:v8n_required",({name:e})=>!e||e.length<=30||"name:v8n_too_long",({country:e,type:t})=>"country"!==t||!!e||"country:v8n_required",({country:e,type:t})=>"region"!==t||!!e||"country:v8n_required",({country:e,use_origin_rates:t})=>!t||!!e||"country:v8n_required",({region:e,type:t})=>"region"!=t||!!e||"region:v8n_required",({region:e})=>!e||e.length<=20||"region:v8n_too_long",({city:e})=>!e||e.length<=50||"city:v8n_too_long",({city:e,type:t})=>"local"!=t||!!e||"city:v8n_required",({rate:e,type:t,is_live:r})=>void 0===e||e>0||"custom_tax_endpoint"===t||void 0===t||r||"rate:v8n_invalid"]}get readonlySelector(){const e=[super.readonlySelector.toString()];return e.unshift("native-integrations"),new r(e.join(" ").trim())}get hiddenSelector(){var e,t,i;const o=[super.hiddenSelector.toString()],n=this.form.type;"global"===n||"custom_tax_endpoint"===n?(o.unshift("group-one:is-live","group-one:service-provider"),"custom_tax_endpoint"===n&&o.unshift("group-one:rate")):this.form.is_live?o.unshift("group-one:rate"):o.unshift("group-one:service-provider"),void 0===this.__nativeIntegrationsUrl&&o.unshift("native-integrations"),this.__isCountryHidden&&o.unshift("group-three:country"),this.__isRegionHidden&&o.unshift("group-three:region-select","group-three:region-input"),this.__isCityHidden&&o.unshift("group-three:city"),this.__isApplyToShippingHidden&&o.unshift("group-two:apply-to-shipping"),this.__isUseOriginRatesHidden&&o.unshift("group-two:use-origin-rates"),this.__isExemptAllCustomerTaxIdsHidden&&o.unshift("group-two:exempt-all-customer-tax-ids");const s=Object.values(null!==(i=null===(t=null===(e=this.__regionsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values)&&void 0!==i?i:{});return o.unshift("group-three:region-"+(s.length?"input":"select")),this.data&&this.itemCategories||o.unshift("item-categories"),new r(o.join(" ").trim())}renderBody(){var e,t,r,i,l,d,c,u,p,m;const h=Object.values(null!==(r=null===(t=null===(e=this.__countriesLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values)&&void 0!==r?r:{}).map((e=>({rawLabel:e.default,value:e.cc2}))),f=Object.values(null!==(d=null===(l=null===(i=this.__regionsLoader)||void 0===i?void 0:i.data)||void 0===l?void 0:l.values)&&void 0!==d?d:{}).map((e=>({rawLabel:e.default,value:e.code})));return n(s||(s=a` ${0} <foxy-internal-summary-control infer="group-one"> <foxy-internal-text-control layout="summary-item" infer="name"></foxy-internal-text-control> <foxy-internal-select-control options="${0}" layout="summary-item" infer="type" .setValue="${0}"> </foxy-internal-select-control> <foxy-internal-switch-control infer="is-live"></foxy-internal-switch-control> <foxy-internal-select-control options="${0}" layout="summary-item" infer="service-provider"> </foxy-internal-select-control> <foxy-internal-number-control layout="summary-item" suffix="%" infer="rate" min="0"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-async-list-control infer="native-integrations" first="${0}" item="foxy-native-integration-card"> </foxy-internal-async-list-control> <foxy-internal-summary-control infer="group-two"> <foxy-internal-switch-control infer="exempt-all-customer-tax-ids"> </foxy-internal-switch-control> <foxy-internal-switch-control infer="apply-to-shipping"></foxy-internal-switch-control> <foxy-internal-switch-control infer="use-origin-rates"></foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="group-three"> <foxy-internal-select-control options="${0}" layout="summary-item" infer="country" .setValue="${0}"> </foxy-internal-select-control> <foxy-internal-select-control property="region" options="${0}" layout="summary-item" infer="region-select" .setValue="${0}"> </foxy-internal-select-control> <foxy-internal-text-control property="region" layout="summary-item" infer="region-input" .setValue="${0}"> </foxy-internal-text-control> <foxy-internal-text-control layout="summary-item" infer="city"></foxy-internal-text-control> </foxy-internal-summary-control> <foxy-internal-async-resource-link-list-control foreign-key-for-uri="item_category_uri" foreign-key-for-id="item_category_id" own-key-for-uri="tax_uri" own-uri="${0}" options-href="${0}" links-href="${0}" embed-key="fx:tax_item_categories" infer="item-categories" limit="5" item="foxy-item-category-card"> </foxy-internal-async-resource-link-list-control> ${0} <foxy-nucleon infer="" class="hidden" href="${0}" id="countriesLoader" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" class="hidden" href="${0}" id="regionsLoader" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),this.__typeOptions,this.__typeSetValue,JSON.stringify(this.__serviceProviderOptions),o(this.__nativeIntegrationsUrl),JSON.stringify(h),this.__countrySetValue,JSON.stringify(f),this.__regionSetValue,this.__regionSetValue,o(null===(c=this.data)||void 0===c?void 0:c._links.self.href),o(null!==(u=this.itemCategories)&&void 0!==u?u:void 0),o(null===(p=this.data)||void 0===p?void 0:p._links["fx:tax_item_categories"].href),super.renderBody(),o(null!==(m=this.countries)&&void 0!==m?m:void 0),(()=>this.requestUpdate()),o(this.__regionsUrl),(()=>this.requestUpdate()))}get __serviceProviderOptions(){const e=[{label:"option_avalara",value:"avalara"},{label:"option_onesource",value:"onesource"}];return"union"!==this.form.type&&this.form.country&&!d.includes(this.form.country)||e.unshift({label:"option_default",value:""}),"union"!==this.form.type&&this.form.country&&!c.includes(this.form.country)||e.push({label:"option_taxjar",value:"taxjar"}),e}get __nativeIntegrationsUrl(){var e;try{const t=new URL(null!==(e=this.nativeIntegrations)&&void 0!==e?e:""),r=this.form.service_provider;if(r)return t.searchParams.set("provider",r),t.toString()}catch(e){}}get __regionsUrl(){var e;try{const t=new URL(null!==(e=this.regions)&&void 0!==e?e:""),r=this.form.country;return r&&t.searchParams.set("country_code",r),t.toString()}catch(e){}}get __countriesLoader(){return this.renderRoot.querySelector("#countriesLoader")}get __regionsLoader(){return this.renderRoot.querySelector("#regionsLoader")}get __isExemptAllCustomerTaxIdsHidden(){const e=this.form.type;if("custom_tax_endpoint"===e)return!0;if("country"===e||"region"===e||"local"===e)return!!this.form.is_live;const t=this.form.service_provider;return!t||"onesource"===t||"avalara"===t||"taxjar"===t}get __isApplyToShippingHidden(){const e=this.form.type;return!e||"custom_tax_endpoint"===e||"union"!==e&&(!("country"!==e||!this.form.is_live)||(!("region"!==e||!this.form.is_live)||!!this.form.is_live&&d.includes(this.form.country)))}get __isUseOriginRatesHidden(){return"union"!==this.form.type||!this.form.is_live||!!this.form.service_provider}get __isCountryHidden(){return"union"===this.form.type?(!this.form.service_provider||this.form.is_live)&&!this.form.use_origin_rates:!["country","region","local"].includes(this.form.type)}get __isRegionHidden(){return"local"!==this.form.type&&"region"!==this.form.type}get __isCityHidden(){return"local"!==this.form.type}}customElements.define("foxy-tax-form",u);export{u as TaxForm};
|
|
1
|
+
import"./shared-dd303282.js";import"./shared-656a46f7.js";import"./shared-f7bfb29e.js";import"./shared-6033e09d.js";import"./shared-d68c6616.js";import"./shared-94716ec1.js";import"./shared-66201dc5.js";import{I as e}from"./shared-ffd5932d.js";import"./foxy-native-integration-card.js";import"./foxy-item-category-card.js";import"./foxy-nucleon-element.js";import{_ as t,B as r}from"./shared-cb58dfcd.js";import{a as i}from"./shared-aa6dab90.js";import{i as o}from"./shared-53e42a77.js";import{h as n}from"./shared-ba5c42c7.js";import"./shared-0d0585dc.js";import"./shared-9c010e0a.js";import"./shared-567ba8ae.js";import"./shared-ad60e8d1.js";import"./shared-1cd02e50.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-dc4d2996.js";import"./shared-e6a1eef8.js";import"./shared-e2d3c014.js";import"./shared-2f5cc0e2.js";import"./shared-343d1fd7.js";import"./shared-2aa23b5f.js";import"./shared-5afb584d.js";import"./shared-f83207fb.js";import"./shared-5592ec6e.js";import"./shared-cd96ff03.js";import"./shared-5e4a03d1.js";import"./shared-7594e563.js";import"./shared-0aedd809.js";import"./shared-5ef40e86.js";import"./shared-5fd5805c.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-cc4b3b42.js";import"./shared-5212ef4f.js";import"./shared-678beccf.js";import"./shared-9342ca50.js";import"./shared-a4216b50.js";import"./shared-c502de27.js";import"./shared-5f8c01f8.js";import"./shared-4e709717.js";import"./shared-d7d949bc.js";import"./shared-8a0bd046.js";import"./shared-7fd51889.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-2f8e53c0.js";import"./shared-c31c50e2.js";import"./shared-9171c265.js";import"./shared-8ea2bbcc.js";import"./shared-d0aed1c1.js";import"./foxy-copy-to-clipboard.js";import"./shared-bab2ea2c.js";import"./shared-894c69f8.js";import"./shared-bb6d7b97.js";import"./shared-b1435a0a.js";let s,a=e=>e;const l=i(e,"tax-form"),d=["US","CA","AT","BE","BG","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IM","IT","LT","LU","LV","MC","MT","NL","PL","PT","RO","SE","SI","SK"],c=[...d,"AU"];class u extends l{constructor(){super(...arguments),this.nativeIntegrations=null,this.itemCategories=null,this.countries=null,this.regions=null,this.__countrySetValue=e=>{this.edit({country:e,region:"",city:""}),this.edit({apply_to_shipping:this.__isApplyToShippingHidden})},this.__regionSetValue=e=>{this.edit({region:e,city:""})},this.__typeSetValue=e=>{this.edit({type:e,country:"",region:"",city:"",service_provider:"custom_tax_endpoint"===e?"custom_tax":"",apply_to_shipping:!1,use_origin_rates:!1,exempt_all_customer_tax_ids:!1,is_live:!1,rate:0})},this.__typeOptions=JSON.stringify([{label:"option_custom_tax_endpoint",value:"custom_tax_endpoint"},{label:"option_global",value:"global"},{label:"option_union",value:"union"},{label:"option_country",value:"country"},{label:"option_region",value:"region"},{label:"option_local",value:"local"}])}static get properties(){return t(t({},super.properties),{},{nativeIntegrations:{attribute:"native-integrations"},itemCategories:{attribute:"item-categories"},countries:{},regions:{}})}static get v8n(){return[({name:e})=>!!e||"name:v8n_required",({name:e})=>!e||e.length<=30||"name:v8n_too_long",({country:e,type:t})=>"country"!==t||!!e||"country:v8n_required",({country:e,type:t})=>"region"!==t||!!e||"country:v8n_required",({country:e,use_origin_rates:t})=>!t||!!e||"country:v8n_required",({region:e,type:t})=>"region"!=t||!!e||"region:v8n_required",({region:e})=>!e||e.length<=20||"region:v8n_too_long",({city:e})=>!e||e.length<=50||"city:v8n_too_long",({city:e,type:t})=>"local"!=t||!!e||"city:v8n_required",({rate:e,type:t,is_live:r})=>void 0===e||e>0||"custom_tax_endpoint"===t||void 0===t||r||"rate:v8n_invalid"]}get readonlySelector(){const e=[super.readonlySelector.toString()];return e.unshift("native-integrations"),new r(e.join(" ").trim())}get hiddenSelector(){var e,t,i;const o=[super.hiddenSelector.toString()],n=this.form.type;"global"===n||"custom_tax_endpoint"===n?(o.unshift("group-one:is-live","group-one:service-provider"),"custom_tax_endpoint"===n&&o.unshift("group-one:rate")):this.form.is_live?o.unshift("group-one:rate"):o.unshift("group-one:service-provider"),void 0===this.__nativeIntegrationsUrl&&o.unshift("native-integrations"),this.__isCountryHidden&&o.unshift("group-three:country"),this.__isRegionHidden&&o.unshift("group-three:region-select","group-three:region-input"),this.__isCityHidden&&o.unshift("group-three:city"),this.__isApplyToShippingHidden&&o.unshift("group-two:apply-to-shipping"),this.__isUseOriginRatesHidden&&o.unshift("group-two:use-origin-rates"),this.__isExemptAllCustomerTaxIdsHidden&&o.unshift("group-two:exempt-all-customer-tax-ids");const s=Object.values(null!==(i=null===(t=null===(e=this.__regionsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values)&&void 0!==i?i:{});return o.unshift("group-three:region-"+(s.length?"input":"select")),this.data&&this.itemCategories||o.unshift("item-categories"),new r(o.join(" ").trim())}renderBody(){var e,t,r,i,l,d,c,u,p,m;const h=Object.values(null!==(r=null===(t=null===(e=this.__countriesLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values)&&void 0!==r?r:{}).map((e=>({rawLabel:e.default,value:e.cc2}))),f=Object.values(null!==(d=null===(l=null===(i=this.__regionsLoader)||void 0===i?void 0:i.data)||void 0===l?void 0:l.values)&&void 0!==d?d:{}).map((e=>({rawLabel:e.default,value:e.code})));return n(s||(s=a` ${0} <foxy-internal-summary-control infer="group-one"> <foxy-internal-text-control layout="summary-item" infer="name"></foxy-internal-text-control> <foxy-internal-select-control options="${0}" layout="summary-item" infer="type" .setValue="${0}"> </foxy-internal-select-control> <foxy-internal-switch-control infer="is-live"></foxy-internal-switch-control> <foxy-internal-select-control options="${0}" layout="summary-item" infer="service-provider"> </foxy-internal-select-control> <foxy-internal-number-control layout="summary-item" suffix="%" infer="rate" min="0"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-async-list-control infer="native-integrations" first="${0}" item="foxy-native-integration-card"> </foxy-internal-async-list-control> <foxy-internal-summary-control infer="group-two"> <foxy-internal-switch-control infer="exempt-all-customer-tax-ids"> </foxy-internal-switch-control> <foxy-internal-switch-control infer="apply-to-shipping"></foxy-internal-switch-control> <foxy-internal-switch-control infer="use-origin-rates"></foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="group-three"> <foxy-internal-select-control options="${0}" layout="summary-item" infer="country" .setValue="${0}"> </foxy-internal-select-control> <foxy-internal-select-control property="region" options="${0}" layout="summary-item" infer="region-select" .setValue="${0}"> </foxy-internal-select-control> <foxy-internal-text-control property="region" layout="summary-item" infer="region-input" .setValue="${0}"> </foxy-internal-text-control> <foxy-internal-text-control layout="summary-item" infer="city"></foxy-internal-text-control> </foxy-internal-summary-control> <foxy-internal-async-resource-link-list-control foreign-key-for-uri="item_category_uri" foreign-key-for-id="item_category_id" own-key-for-uri="tax_uri" own-uri="${0}" options-href="${0}" links-href="${0}" embed-key="fx:tax_item_categories" infer="item-categories" limit="5" item="foxy-item-category-card"> </foxy-internal-async-resource-link-list-control> ${0} <foxy-nucleon infer="" class="hidden" href="${0}" id="countriesLoader" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" class="hidden" href="${0}" id="regionsLoader" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),this.__typeOptions,this.__typeSetValue,JSON.stringify(this.__serviceProviderOptions),o(this.__nativeIntegrationsUrl),JSON.stringify(h),this.__countrySetValue,JSON.stringify(f),this.__regionSetValue,this.__regionSetValue,o(null===(c=this.data)||void 0===c?void 0:c._links.self.href),o(null!==(u=this.itemCategories)&&void 0!==u?u:void 0),o(null===(p=this.data)||void 0===p?void 0:p._links["fx:tax_item_categories"].href),super.renderBody(),o(null!==(m=this.countries)&&void 0!==m?m:void 0),(()=>this.requestUpdate()),o(this.__regionsUrl),(()=>this.requestUpdate()))}get __serviceProviderOptions(){const e=[{label:"option_avalara",value:"avalara"},{label:"option_onesource",value:"onesource"}];return"union"!==this.form.type&&this.form.country&&!d.includes(this.form.country)||e.unshift({label:"option_default",value:""}),"union"!==this.form.type&&this.form.country&&!c.includes(this.form.country)||e.push({label:"option_taxjar",value:"taxjar"}),e}get __nativeIntegrationsUrl(){var e;try{const t=new URL(null!==(e=this.nativeIntegrations)&&void 0!==e?e:""),r=this.form.service_provider;if(r)return t.searchParams.set("provider",r),t.toString()}catch(e){}}get __regionsUrl(){var e;try{const t=new URL(null!==(e=this.regions)&&void 0!==e?e:""),r=this.form.country;return r&&t.searchParams.set("country_code",r),t.toString()}catch(e){}}get __countriesLoader(){return this.renderRoot.querySelector("#countriesLoader")}get __regionsLoader(){return this.renderRoot.querySelector("#regionsLoader")}get __isExemptAllCustomerTaxIdsHidden(){const e=this.form.service_provider,t=this.form.type;return"custom_tax_endpoint"===t||("country"===t||"region"===t||"local"===t||"union"===t)&&(!!this.form.is_live&&("onesource"===e||"avalara"===e))}get __isApplyToShippingHidden(){const e=this.form.type;return!e||"custom_tax_endpoint"===e||"union"!==e&&(!("country"!==e||!this.form.is_live)||(!("region"!==e||!this.form.is_live)||!!this.form.is_live&&d.includes(this.form.country)))}get __isUseOriginRatesHidden(){return"union"!==this.form.type||!this.form.is_live||!!this.form.service_provider}get __isCountryHidden(){return"union"===this.form.type?(!this.form.service_provider||this.form.is_live)&&!this.form.use_origin_rates:!["country","region","local"].includes(this.form.type)}get __isRegionHidden(){return"local"!==this.form.type&&"region"!==this.form.type}get __isCityHidden(){return"local"!==this.form.type}}customElements.define("foxy-tax-form",u);export{u as TaxForm};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import"./shared-e2d3c014.js";import"./shared-dc4d2996.js";import{_ as e}from"./shared-cb58dfcd.js";import{s as l,h as t,c as a,L as s}from"./shared-ba5c42c7.js";import{T as n,O as o}from"./shared-8874ec69.js";import{o as r}from"./shared-63c32024.js";import{c as i}from"./shared-4e709717.js";import{i as d}from"./shared-53e42a77.js";import{a as u}from"./shared-79d0699c.js";import{p as c}from"./shared-43e2c3f6.js";import{r as v}from"./shared-5fd5805c.js";import{R as p,T as b,a as h}from"./shared-aa6dab90.js";import{I as f}from"./shared-2aa23b5f.js";import{C as g}from"./shared-5afb584d.js";let m;const C=l(m||(m=(e=>e)`
|
|
2
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M26.4 14.7399C26.4 15.2922 25.9523 15.7399 25.4 15.7399H10.6C10.0477 15.7399 9.60001 15.2922 9.60001 14.7399V14.2C9.60001 13.6477 10.0477 13.2 10.6 13.2H25.4C25.9523 13.2 26.4 13.6477 26.4 14.2V14.7399ZM26.4 21.8C26.4 22.3523 25.9523 22.8 25.4 22.8H10.6C10.0477 22.8 9.60001 22.3523 9.60001 21.8V21.2601C9.60001 20.7078 10.0477 20.2601 10.6 20.2601H25.4C25.9523 20.2601 26.4 20.7078 26.4 21.2601V21.8Z" class="fill-current"/>
|
|
4
|
+
</svg>
|
|
5
|
+
`));let y;const x=l(y||(y=(e=>e)`
|
|
6
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7
|
+
<path d="M12.8656 14.6695C12.3425 14.4581 12 13.9503 12 13.386C12 12.3748 13.0489 11.7048 13.9663 12.1299L23.8937 16.7295C24.5323 17.0254 24.941 17.6652 24.941 18.369C24.941 19.0735 24.5316 19.7137 23.8921 20.0092L13.971 24.5938C13.0509 25.019 12 24.347 12 23.3334C12 22.7709 12.3394 22.264 12.8594 22.0496L21.341 18.3046L12.8656 14.6695Z" class="fill-current"/>
|
|
8
|
+
</svg>
|
|
9
|
+
`));let w;const V=l(w||(w=(e=>e)`
|
|
10
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
11
|
+
<path d="M12.5 9.8C11.0088 9.8 9.8 11.0088 9.8 12.5V23.5C9.8 24.9912 11.0088 26.2 12.5 26.2H14C14.6627 26.2 15.2 25.6627 15.2 25C15.2 24.3373 14.6627 23.8 14 23.8H13.5C12.782 23.8 12.2 23.218 12.2 22.5V13.5C12.2 12.782 12.782 12.2 13.5 12.2H14C14.6627 12.2 15.2 11.6627 15.2 11C15.2 10.3373 14.6627 9.8 14 9.8H12.5Z" class="fill-current"/>
|
|
12
|
+
<path d="M22 9.8C21.3373 9.8 20.8 10.3373 20.8 11C20.8 11.6627 21.3373 12.2 22 12.2H22.5C23.218 12.2 23.8 12.782 23.8 13.5V22.5C23.8 23.218 23.218 23.8 22.5 23.8H22C21.3373 23.8 20.8 24.3373 20.8 25C20.8 25.6627 21.3373 26.2 22 26.2H23.5C24.9912 26.2 26.2 24.9912 26.2 23.5V12.5C26.2 11.0088 24.9912 9.8 23.5 9.8H22Z" class="fill-current"/>
|
|
13
|
+
</svg>
|
|
14
|
+
`));let $;const H=l($||($=(e=>e)`
|
|
15
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.05 23.58L20.04 23.59L17.64 21.19L18.7 20.13L20.05 21.48L22.54 19L23.6 20.06L20.06 23.6L20.05 23.58ZM18 8C12.5 8 8 12.5 8 18C8 23.5 12.5 28 18 28C23.5 28 28 23.5 28 18C28 12.5 23.5 8 18 8ZM13.34 12.28L14.75 13.69L16.16 12.28L17.22 13.34L15.81 14.75L17.22 16.16L16.16 17.22L14.75 15.81L13.34 17.22L12.28 16.16L13.69 14.75L12.28 13.34L13.34 12.28ZM18 26C15.8 26 13.8 25.1 12.3 23.7L23.7 12.3C25.1 13.8 26 15.8 26 18C26 22.4 22.4 26 18 26Z" class="fill-current"/>
|
|
17
|
+
</svg>
|
|
18
|
+
`));let L;const M=l(L||(L=(e=>e)`
|
|
19
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
20
|
+
<path d="M22.8754 22.054C23.3985 22.2655 23.741 22.7733 23.741 23.3375C23.741 24.3487 22.6922 25.0187 21.7747 24.5936L11.8473 19.994C11.2087 19.6981 10.8 19.0583 10.8 18.3545C10.8 17.65 11.2094 17.0098 11.8489 16.7143L21.7701 12.1297C22.6902 11.7045 23.741 12.3765 23.741 13.3902C23.741 13.9526 23.4017 14.4596 22.8816 14.6739L14.4 18.4189L22.8754 22.054Z" class="fill-current"/>
|
|
21
|
+
</svg>
|
|
22
|
+
`));let Z;const O=l(Z||(Z=(e=>e)`
|
|
23
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
24
|
+
<path d="M22.8754 19.654C23.3985 19.8655 23.741 20.3733 23.741 20.9375C23.741 21.9487 22.6922 22.6187 21.7747 22.1936L11.8473 17.594C11.2087 17.2981 10.8 16.6584 10.8 15.9545C10.8 15.25 11.2094 14.6098 11.8489 14.3143L21.7701 9.72971C22.6902 9.30453 23.741 9.97655 23.741 10.9902C23.741 11.5527 23.4017 12.0596 22.8816 12.2739L14.4 16.0189L22.8754 19.654Z" class="fill-current"/>
|
|
25
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.9169 20.9941C11.2134 20.3281 11.9937 20.0286 12.6597 20.3251L22.8548 24.8643C23.5208 25.1608 23.8203 25.9411 23.5238 26.6071C23.2273 27.2731 22.447 27.5726 21.781 27.2761L11.5859 22.7369C10.9199 22.4404 10.6204 21.6601 10.9169 20.9941Z" class="fill-current"/>
|
|
26
|
+
</svg>
|
|
27
|
+
`));let j;const I=l(j||(j=(e=>e)`
|
|
28
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.0049 7.11C24.6649 7.49107 24.8911 8.33507 24.51 8.99511L13.1621 28.6503C12.781 29.3103 11.937 29.5365 11.277 29.1554C10.6169 28.7743 10.3908 27.9303 10.7719 27.2703L22.1198 7.61511C22.5009 6.95507 23.3448 6.72892 24.0049 7.11Z" class="fill-current"/>
|
|
30
|
+
<path d="M17.5097 13.2H10.8C10.1373 13.2 9.60001 13.7373 9.60001 14.4V14.5399C9.60001 15.2026 10.1373 15.7399 10.8 15.7399H16.0433L17.5097 13.2Z" class="fill-current"/>
|
|
31
|
+
<path d="M13.4336 20.2601H10.8C10.1373 20.2601 9.60001 20.7973 9.60001 21.4601V21.6C9.60001 22.2627 10.1373 22.8 10.8 22.8H11.9671L13.4336 20.2601Z" class="fill-current"/>
|
|
32
|
+
<path d="M17.9254 22.8H25.2C25.8627 22.8 26.4 22.2627 26.4 21.6V21.4601C26.4 20.7973 25.8627 20.2601 25.2 20.2601H19.3918L17.9254 22.8Z" class="fill-current"/>
|
|
33
|
+
<path d="M22.0015 15.7399H25.2C25.8627 15.7399 26.4 15.2026 26.4 14.5399V14.4C26.4 13.7373 25.8627 13.2 25.2 13.2H23.468L22.0015 15.7399Z" class="fill-current"/>
|
|
34
|
+
</svg>
|
|
35
|
+
`));let N;const A=l(N||(N=(e=>e)`
|
|
36
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
37
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 8C12.48 8 8 12.48 8 18C8 23.52 12.48 28 18 28C23.52 28 28 23.52 28 18C28 12.48 23.52 8 18 8ZM18 26C13.59 26 10 22.41 10 18C10 13.59 13.59 10 18 10C22.41 10 26 13.59 26 18C26 22.41 22.41 26 18 26Z" class="fill-current"/>
|
|
38
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.49 17.38C19.92 16.16 19.66 14.74 18.68 13.76C17.57 12.65 15.89 12.46 14.58 13.17L16.93 15.52L15.52 16.93L13.17 14.58C12.46 15.9 12.65 17.57 13.76 18.68C14.74 19.66 16.16 19.92 17.38 19.49L20.79 22.9C20.99 23.1 21.3 23.1 21.5 22.9L22.9 21.5C23.1 21.3 23.1 20.99 22.9 20.79L19.49 17.38Z" class="fill-current"/>
|
|
39
|
+
</svg>
|
|
40
|
+
`));let B;const T=l(B||(B=(e=>e)`
|
|
41
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
42
|
+
<path d="M10 13V15C10 15.55 9.55 16 9 16H8V20H9C9.55 20 10 20.45 10 21V23C10 24.65 11.35 26 13 26H16V24H13C12.45 24 12 23.55 12 23V21C12 19.7 11.16 18.58 10 18.17V17.83C11.16 17.42 12 16.3 12 15V13C12 12.45 12.45 12 13 12H16V10H13C11.35 10 10 11.35 10 13Z" class="fill-current"/>
|
|
43
|
+
<path d="M27 16C26.45 16 26 15.55 26 15V13C26 11.35 24.65 10 23 10H20V12H23C23.55 12 24 12.45 24 13V15C24 16.3 24.84 17.42 26 17.83V18.17C24.84 18.58 24 19.69 24 21V23C24 23.55 23.55 24 23 24H20V26H23C24.65 26 26 24.65 26 23V21C26 20.45 26.45 20 27 20H28V16H27Z" class="fill-current"/>
|
|
44
|
+
</svg>
|
|
45
|
+
`));let _;const D=l(_||(_=(e=>e)`
|
|
46
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
+
<path d="M23.8333 17.0588H22.0833V11.7647H20.3333V10H23.8333V17.0588Z" class="fill-current"/>
|
|
48
|
+
<path d="M15.6667 10H12.1667C11.525 10 11 10.5294 11 11.1765V15.8824C11 16.5294 11.525 17.0588 12.1667 17.0588H15.6667C16.3083 17.0588 16.8333 16.5294 16.8333 15.8824V11.1765C16.8333 10.5294 16.3083 10 15.6667 10ZM15.0833 15.2941H12.75V11.7647H15.0833V15.2941Z" class="fill-current"/>
|
|
49
|
+
<path d="M15.6667 26.4706H13.9167V21.1765H12.1667V19.4118H15.6667V26.4706Z" class="fill-current"/>
|
|
50
|
+
<path d="M23.8333 19.4118H20.3333C19.6917 19.4118 19.1667 19.9412 19.1667 20.5882V25.2941C19.1667 25.9412 19.6917 26.4706 20.3333 26.4706H23.8333C24.475 26.4706 25 25.9412 25 25.2941V20.5882C25 19.9412 24.475 19.4118 23.8333 19.4118ZM23.25 24.7059H20.9167V21.1765H23.25V24.7059Z" class="fill-current"/>
|
|
51
|
+
</svg>
|
|
52
|
+
`));let z;const R=l(z||(z=(e=>e)`
|
|
53
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
54
|
+
<path d="M25 10H24V8H22V10H14V8H12V10H11C9.89 10 9.01 10.9 9.01 12L9 26C9 27.1 9.89 28 11 28H25C26.1 28 27 27.1 27 26V12C27 10.9 26.1 10 25 10ZM25 26H11V16H25V26ZM25 14H11V12H25V14ZM23 19H18V24H23V19Z" class="fill-current"/>
|
|
55
|
+
</svg>
|
|
56
|
+
`));let S;const k=l(S||(S=(e=>e)`
|
|
57
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
58
|
+
<path d="M26.5 16L27 14H23L24 10H22L21 14H17L18 10H16L15 14H11L10.5 16H14.5L13.5 20H9.5L9 22H13L12 26H14L15 22H19L18 26H20L21 22H25L25.5 20H21.5L22.5 16H26.5ZM19.5 20H15.5L16.5 16H20.5L19.5 20Z" class="fill-current"/>
|
|
59
|
+
</svg>
|
|
60
|
+
`));let E;const U=l(E||(E=(e=>e)`
|
|
61
|
+
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
62
|
+
<path d="M11 11V14H16.5V26H19.5V14H25V11H11Z" class="fill-current"/>
|
|
63
|
+
</svg>
|
|
64
|
+
`));let q,G,W,P,F,Q=e=>e;function J(e){var l,a,s;const n=null===(a=null===(l=e.list)||void 0===l?void 0:l.every((l=>l.value!==e.value)))||void 0===a||a;return t(q||(q=Q` <label class="${0}"> <div class="relative flex-1 min-w-0 overflow-hidden"> <select class="${0}" ?disabled="${0}" @change="${0}"> ${0} ${0} </select> </div> ${0} </label> `),i({"flex items-center transition-colors group text-tertiary":!0,"cursor-pointer hover-bg-contrast-5":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),i({"bg-transparent relative appearance-none flex h-m px-s":!0,"font-medium w-full max-w-full whitespace-nowrap focus-outline-none":!0,"text-tertiary":n&&!e.disabled,"text-body":!n&&!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":!n&&e.readonly,"cursor-pointer":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),e.disabled||e.readonly,(l=>{const t=l.currentTarget,a=t.options[t.options.selectedIndex].value;e.onChange(a)}),n?t(G||(G=Q` <option value="" disabled="disabled" ?selected="${0}">${0}</option> `),n,e.t(e.label)):"",null===(s=e.list)||void 0===s?void 0:s.map((({label:l,value:a})=>t(W||(W=Q` <option value="${0}" ?selected="${0}"> ${0} </option> `),a,a===e.value,e.t(l)))),n?"":t(P||(P=Q` <span class="${0}"> ${0} </span> ${0} `),i({"font-tnum text-xs font-medium border mr-s px-xs rounded-s border-current inline-block":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.clearable&&!e.readonly?t(F||(F=Q` <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="icon-inline text-l" icon="icons:remove-circle-outline"> </iron-icon> </button> `),e.t("delete"),i({"w-s h-s mr-xs flex items-center justify-center transition-colors rounded-full":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"hover-bg-contrast-5 hover-text-error text-body":!e.disabled,"text-disabled":e.disabled}),e.disabled,(()=>e.onChange(""))):""))}let K,X,Y,ee,le,te=e=>e;function ae(e){var l;const a=`${null!==(l=e.id)&&void 0!==l?l:String(Math.floor(Math.random()*Math.pow(10,8)))}-list`,s=!!e.displayValue;let n=e.value;if("date"===e.type){const l=new Date(e.value);n=isNaN(l.getTime())?"":u(l)}const o="date"!==e.type||!n&&e.dateHours?e.type:"datetime-local",r="date"===e.type?n||!e.dateHours?"9999-12-31T23:59":"9999-12-31":void 0;return t(K||(K=te` <label class="relative flex items-center cursor-text group text-tertiary"> <div class="relative flex-1 min-w-0 overflow-hidden"> ${0} <input placeholder="${0}" class="${0}" list="${0}" type="${0}" max="${0}" .value="${0}" ?disabled="${0}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} ${0} </label> `),s?t(X||(X=te` <div aria-hidden="true" class="${0}"> <div class="truncate">${0}</div> </div> `),i({"absolute inset-0 h-m px-s font-medium flex items-center":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.displayValue)):"",n||"date"===e.type?"":e.t(e.label),i({"bg-base relative flex h-m px-s font-medium w-full":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly,"flex max-w-full whitespace-nowrap":!0,"focus-outline-none":!0,"opacity-0 focus-opacity-100":s}),d(e.list?a:void 0),o,d(r),n,e.disabled||e.readonly,(l=>{const t=l.currentTarget;let a=t.value;try{if("date"===e.type){const l=n?new Date(t.value):c(t.value);e.dateHours&&!n&&l.setHours(...e.dateHours),isNaN(l.getTime())||(a=l.toISOString())}}catch(e){}e.onChange(a)}),i({"font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s":!0,"inline-block":!!n||"date"===e.type,"sr-only":!n&&"date"!==e.type,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.list?t(Y||(Y=te` <datalist id="${0}"> ${0} </datalist> `),a,e.list.map((({label:l,value:a})=>t(ee||(ee=te`<option value="${0}">${0}</option>`),a,e.t(l))))):"",e.disabled||e.readonly?"":t(le||(le=te` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}let se,ne,oe=e=>e;let re,ie=e=>e;function de({parsedValue:l,disabled:t,readonly:a,options:s,option:n,t:o,onChange:r}){return ae({displayValue:null==n?void 0:n.label,disabled:t,readonly:a,value:l.path,label:"field",list:s.map((l=>e(e({},l),{},{value:l.path}))),type:"text",id:"path",t:o,onChange:e=>r({operator:null,value:"",path:e})})}let ue,ce=e=>e;let ve,pe,be=e=>e;function he(l){var a,s;const{parsedValue:d,isFullSize:u,isNested:c,readonly:p,disabled:b,options:h,t:f,onConvert:g,onDelete:m,onChange:y}=l,w=null!==(a=h.find((e=>e.path===d.path)))&&void 0!==a?a:null,$=null!==(s=null==w?void 0:w.type)&&void 0!==s?s:n.Any,L=d.operator,Z={parsedValue:d,operators:l.operators,disabled:b,readonly:p,options:h,option:w,t:f,onChange:y},j={[n.Attribute]:T,[n.Boolean]:D,[n.Number]:k,[n.String]:U,[n.Date]:R,[n.Any]:A};return t(ve||(ve=be` <div class="flex items-center space-x-s" aria-label="${0}"> <div class="${0}"> <div class="bg-contrast-10"> <div class="grid gap-1px grid-vertical sm-grid-horizontal"> <div class="bg-base" title="${0}"> <div class="${0}" aria-hidden="true"> ${0} </div> </div> <div class="bg-base"> ${0} </div> <div class="bg-base">${0}</div> <div class="bg-base"> ${0} </div> </div> </div> </div> <div class="${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:remove-circle-outline"> </iron-icon> </button> <button aria-label="${0}" class="${0}" ?disabled="${0}" ?hidden="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:add-circle-outline"> </iron-icon> </button> </div> </div> `),f("query_builder_rule"),i({"flex-1 bg-base rounded overflow-hidden border":!0,"border-contrast-10":!c&&!p,"border-contrast-50":!!c||p,"border-dashed":p,"border-solid":!p}),f(`type_${$}`),i({"w-m h-m":!0,"text-tertiary":!p&&!b,"text-disabled":p||b}),w?j[$]:A,d.path&&($===n.Attribute||d.name)?t(pe||(pe=be` <div class="bg-contrast-10 grid gap-1px grid-cols-1 sm-grid-cols-2"> <div class="bg-base">${0}</div> <div class="bg-base">${0}</div> </div> `),de(Z),function(l){var t;return ae({disabled:l.disabled,readonly:l.readonly,value:null!==(t=l.parsedValue.name)&&void 0!==t?t:"",label:"name",type:"text",t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{name:t}))})}(Z)):de(Z),function(l){const a=l.parsedValue.operator,s={[o.GreaterThan]:x,[o.GreaterThanOrEqual]:r,[o.In]:V,[o.IsDefined]:H,[o.LessThan]:M,[o.LessThanOrEqual]:O,[o.Not]:I},d={[n.Attribute]:[o.In,o.Not,o.IsDefined],[n.Boolean]:[],[n.String]:[o.In,o.Not],[n.Number]:[o.In,o.Not,o.GreaterThan,o.LessThan,o.GreaterThanOrEqual,o.LessThanOrEqual],[n.Date]:[o.In,o.Not],[n.Any]:Object.values(o)},u=(l.option?d[l.option.type]:l.parsedValue.name?Object.values(o):Object.values(o).filter((e=>e!==o.IsDefined))).filter((e=>l.operators.includes(e))),c=l.disabled||l.readonly||0===u.length||!l.parsedValue.path;return t(re||(re=ie` <button title="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div aria-hidden="true">${0}</div> </button> `),l.t(`operator_${null!=a?a:"equal"}`),i({"flex items-center justify-center w-m h-m transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50":!0,"text-body hover-bg-contrast-5":!c&&u.length>1,"cursor-default text-tertiary":!c&&u.length<=1,"text-disabled cursor-default":c}),c||u.length<=1,(()=>{var t;const s=a?u.indexOf(a):-1,n=null!==(t=u[s+1])&&void 0!==t?t:null;l.onChange(e(e({},l.parsedValue),{},{operator:n,value:l.parsedValue.value}))}),a?s[a]:C)}(Z),L===o.In?function(l){var a,s,o,r;const i=(null===(a=l.option)||void 0===a?void 0:a.list)?J:ae,d=l.parsedValue.value.split(","),u=null!==(o=null===(s=l.option)||void 0===s?void 0:s.type)&&void 0!==o?o:n.Any,c=u===n.Number?"number":u===n.Date?"date":"text",p=null===(r=l.option)||void 0===r?void 0:r.list,b=[...d.filter((e=>!!e))];return l.readonly||b.push(null),t(se||(se=oe` <div class="bg-contrast-10 grid grid-cols-1 gap-1px"> ${0} </div> `),v(b,((e,l)=>l),((a,s)=>{var n;return t(ne||(ne=oe` <div class="bg-base"> ${0} </div> `),i({type:c,list:p,t:l.t,value:null!=a?a:"",label:a?String(s+1):"add_value",disabled:l.disabled,readonly:l.readonly,clearable:!0,displayValue:null===(n=null==p?void 0:p.find((e=>e.value===a)))||void 0===n?void 0:n.label,onChange:t=>{t?d[s]=t:d.splice(s,1),l.onChange(e(e({},l.parsedValue),{},{value:d.join(",")}))}}))})))}(Z):L===o.IsDefined?function(l){return J({readonly:l.readonly,disabled:l.disabled,value:l.parsedValue.value,label:"value",list:[{label:"is_defined_true",value:"true"},{label:"is_defined_false",value:"false"}],t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{value:t}))})}(Z):$===n.Boolean?function(l){var t,a,s,n,o,r;const{parsedValue:i,option:d,readonly:u,disabled:c,t:v,onChange:p}=l,b=null!==(s=null===(a=null===(t=null==d?void 0:d.list)||void 0===t?void 0:t.find((e=>"false"===e.value)))||void 0===a?void 0:a.label)&&void 0!==s?s:"false",h=[{label:null!==(r=null===(o=null===(n=null==d?void 0:d.list)||void 0===n?void 0:n.find((e=>"true"===e.value)))||void 0===o?void 0:o.label)&&void 0!==r?r:"true",value:"true"},{label:b,value:"false"}];return J({disabled:c,readonly:u,value:i.value,label:"value",list:h,t:v,onChange:l=>p(e(e({},i),{},{value:l}))})}(Z):null===L&&[n.Number,n.Date].includes($)?function(l){var a,s,o;const{t:r,parsedValue:i,option:d,readonly:u,disabled:c,onChange:v}=l,p=i.value.split(".."),b=p.length>=1?p[0]:"",h=p.length>=2?p[1]:"",f=(null==d?void 0:d.list)?J:ae,g=null!==(a=null==d?void 0:d.type)&&void 0!==a?a:n.Any,m=g===n.Number?"number":g===n.Date?"date":"text",C=null==d?void 0:d.list;return t(ue||(ue=ce` <div class="grid bg-contrast-10 gap-1px grid-cols-1 grid-rows-2 sm-grid-cols-2 sm-grid-rows-1"> <div class="bg-base"> ${0} </div> <div class="bg-base"> ${0} </div> </div> `),f({displayValue:null===(s=null==C?void 0:C.find((e=>e.value===b)))||void 0===s?void 0:s.label,dateHours:[0,0,0,0],readonly:u,disabled:c,value:b,label:"range_from",type:m,list:C,t:r,onChange:l=>v(e(e({},i),{},{value:`${l}..${h}`}))}),f({displayValue:null===(o=null==C?void 0:C.find((e=>e.value===h)))||void 0===o?void 0:o.label,dateHours:[23,59,59,999],readonly:u,disabled:c,label:"range_to",value:h,type:m,list:C,t:r,onChange:l=>v(e(e({},i),{},{value:`${b}..${l}`}))}))}(Z):function(l){var t,a,s,o;const{t:r,option:i,parsedValue:d,readonly:u,disabled:c,onChange:v}=l,p=(null==i?void 0:i.list)?J:ae,b=null!==(t=null==i?void 0:i.type)&&void 0!==t?t:n.Any;return p({displayValue:null===(s=null===(a=null==i?void 0:i.list)||void 0===a?void 0:a.find((e=>e.value===d.value)))||void 0===s?void 0:s.label,readonly:u,disabled:c||!d.path,value:null!==(o=d.value)&&void 0!==o?o:"",label:"value",type:b===n.Number?"number":b===n.Date?"date":"text",list:null==i?void 0:i.list,t:r,onChange:l=>v(e(e({},d),{},{value:l}))})}(Z),i({"-mr-s self-start flex-col sm-flex-row flex-shrink-0 items-center":!0,"border-t border-b border-transparent divide-y divide-transparent":!0,hidden:!!u||p,flex:!u}),f("delete"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!d.path}),b||p||!d.path,m,f("add_or_clause"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-success hover-bg-contrast-5":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!d.path||!!c||l.disableOr}),b||p||!d.path||!!c||l.disableOr,l.disableOr,g)}let fe,ge,me,Ce,ye=e=>e;function xe(l){const a=l.parsedValues.some((e=>Array.isArray(e))),s=t(fe||(fe=ye`<div class="${0}"></div>`),a?"h-xs":"mt-s"),n=t(ge||(ge=ye` <div class="flex items-center h-s"> <div class="w-m text-center leading-none uppercase font-medium text-xs text-contrast-30"> ${0} </div> <div class="flex-1 border-t border-contrast-20"></div> <div class="w-m ml-s flex-shrink-0"></div> <div class="hidden sm-block w-m flex-shrink-0"></div> </div> `),l.t("or"));return t(me||(me=ye` <div aria-label="${0}"> ${0} </div> `),l.t("query_builder_group"),v([...l.parsedValues,null],((e,l)=>String(l)),((a,o)=>{const r=o>0?l.isNested?n:s:"";return null===a?[r,he({operators:l.operators,disableOr:l.disableOr,isFullSize:!l.isNested&&0===l.parsedValues.length,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,parsedValue:{path:"",operator:null,value:""},t:l.t,onChange:e=>l.onChange([...l.parsedValues,e])})]:Array.isArray(a)?[r,t(Ce||(Ce=ye` <div class="bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s"> ${0} </div> `),xe({parsedValues:a,disableOr:l.disableOr,operators:l.operators,isNested:!0,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues],a=e;t[o]=e.length>1?a:a[0],l.onChange(t)}}))]:[r,he({parsedValue:a,disableOr:l.disableOr,operators:l.operators,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues];t[o]=e,l.onChange(t)},onDelete:()=>{const e=l.parsedValues.filter(((e,l)=>l!==o));l.onChange(e)},onConvert:()=>{const t=[...l.parsedValues];t[o]=[a,e(e({},a),{},{operator:null,value:""})],l.onChange(t)}})]})))}function we(e){var l;const t=e.indexOf("="),a=decodeURIComponent(e.substring(0,t)),s=decodeURIComponent(e.substring(t+1)),n=null!==(l=Object.values(o).find((e=>a.endsWith(`:${e}`))))&&void 0!==l?l:null;let r,i=a.substring(0,n?a.lastIndexOf(":"):void 0);const d=a.lastIndexOf("[");return i.endsWith("]")&&-1!==d&&(r=i.substring(d+1,i.length-1),i=i.substring(0,d),i.endsWith(":name")&&(i=i.substring(0,i.length-5))),{name:r,path:i,value:s,operator:n}}function Ve(e){return e.split("&").filter((e=>!!e)).map((e=>{const[l,t]=e.split("=").map(decodeURIComponent);return(null==t?void 0:t.includes("|"))?`${encodeURIComponent(l)}=${t}`.split("|").map((e=>we(e))):we(e)}))}function $e(e){let l=e.path;return e.name&&(l+=`:name[${e.name}]`),e.operator&&(l+=`:${e.operator}`),l=`${encodeURIComponent(l)}=${encodeURIComponent(e.value)}`,"="===l?"":l}function He(e,l=!1){const t=e.reduce(((e,l)=>{if(Array.isArray(l)){let t=l[0].path;l[0].name&&(t+=`:name[${l[0].name}]`),l[0].operator&&(t+=`:${l[0].operator}`);const a=[l[0].value,...l.slice(1).map((e=>decodeURIComponent($e(e))))];e.push(`${encodeURIComponent(t)}=${encodeURIComponent(a.join("|"))}`)}else"zoom"!==l.path&&e.push($e(l));return e}),[]);if(!l){const l=Le(e).join(",");l&&t.push(`zoom=${encodeURIComponent(l)}`)}return t.join("&")}function Le(e){return e.map((e=>{if(Array.isArray(e))return Le(e);if(e.name)return[e.path];const l=e.path.split(":");return l.slice(0,l.length-1)})).flat().sort(((e,l)=>l.length-e.length)).filter(((e,l,t)=>t.every(((t,a)=>(a>=l||t!==e)&&!t.startsWith(`${e}:`)))))}let Me;const Ze=a(Me||(Me=(e=>e)`.gap-1px{gap:1px}.grid-vertical{grid-template:auto/var(--lumo-size-m) 1fr}:host([sm]) .sm-grid-horizontal{grid-template:auto/var(--lumo-size-m) 1fr var(--lumo-size-m) 1fr}`)),Oe=g(p(b(h(f(s),"query-builder"))));class je extends Oe{constructor(){super(...arguments),this.reservedPaths=["zoom","limit","offset","order","fields"],this.disableZoom=!1,this.disableOr=!1,this.operators=Object.values(o),this.options=null,this.value=null}static get properties(){return e(e({},super.properties),{},{reservedPaths:{type:Array,attribute:"reserved-paths"},disableZoom:{type:Boolean,attribute:"disable-zoom"},disableOr:{type:Boolean,attribute:"disable-or"},operators:{type:Array},options:{type:Array},value:{type:String}})}static get styles(){return[super.styles,Ze]}render(){var e,l,t;const a=new Set(this.reservedPaths),s=[],n=[];return Ve(null!==(e=this.value)&&void 0!==e?e:"").forEach((e=>{Array.isArray(e)||!a.has(e.path)?n.push(e):s.push(e)})),xe({parsedValues:n,disableOr:this.disableOr,operators:null!==(l=this.operators)&&void 0!==l?l:[],disabled:this.disabled,readonly:this.readonly,options:null!==(t=this.options)&&void 0!==t?t:[],t:this.t.bind(this),onChange:e=>{this.value=He([...e,...s],this.disableZoom),this.dispatchEvent(new je.ChangeEvent("change"))}})}}je.ChangeEvent=class extends CustomEvent{},je.Operator=o,je.Type=n,customElements.define("foxy-query-builder",je);export{je as Q,Ve as p,He as s};
|
|
@@ -6,6 +6,16 @@ import { TemplateResult } from 'lit-html';
|
|
|
6
6
|
import { Translatable } from '../../../mixins/translatable';
|
|
7
7
|
import { DonationChangeEvent } from './DonationChangeEvent';
|
|
8
8
|
import { DonationSubmitEvent } from './DonationSubmitEvent';
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
FC?: {
|
|
12
|
+
settings: {
|
|
13
|
+
session_name: string;
|
|
14
|
+
session_id: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
interface DonationEventsMap {
|
|
10
20
|
change: typeof DonationChangeEvent;
|
|
11
21
|
submit: typeof DonationSubmitEvent;
|
|
@@ -383,6 +383,8 @@ export class Donation extends Translatable {
|
|
|
383
383
|
data.set('empty', this.empty);
|
|
384
384
|
if (this.anonymous)
|
|
385
385
|
data.set('Anonymous', 'true');
|
|
386
|
+
if (window.FC)
|
|
387
|
+
data.set(window.FC.settings.session_name, window.FC.settings.session_id);
|
|
386
388
|
data.set('quantity', '1');
|
|
387
389
|
return data;
|
|
388
390
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Donation.js","sourceRoot":"","sources":["../../../../src/elements/public/Donation/Donation.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4CAA4C,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AK;SACN,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE;YACtC,qBAAqB,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAS;YACxB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport '@vaadin/vaadin-button';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { PropertyDeclarations } from 'lit-element';\nimport { html, TemplateResult } from 'lit-html';\nimport { Translatable } from '../../../mixins/translatable';\nimport { parseDuration } from '../../../utils/parse-duration';\nimport { CheckboxChangeEvent, ChoiceChangeEvent, DropdownChangeEvent } from '../../private/events';\nimport { Checkbox, Choice, Dropdown, ErrorScreen, Group, I18N } from '../../private/index';\nimport { DonationChangeEvent } from './DonationChangeEvent';\nimport { DonationSubmitEvent } from './DonationSubmitEvent';\n\ninterface DonationEventsMap {\n change: typeof DonationChangeEvent;\n submit: typeof DonationSubmitEvent;\n}\n\n/**\n * A custom element providing customizable donation forms.\n *\n * @fires Donation#change - Instance of `Donation.events.change`. Emitted after user input triggers a change in the form data.\n * @fires Donation#submit - Instance of `Donation.events.submit`. Emitted when the form is submitted. Cancelling this event will stop the submission.\n *\n * @slot amount - Space below the amount selector, if it's visible.\n * @slot designation - Space below the designation selector, if it's visible.\n * @slot comment - Space below the comment field, if it's visible.\n *\n * @element foxy-donation\n * @since 0.3.0\n */\nexport class Donation extends Translatable {\n /** @readonly */\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-error-screen': ErrorScreen,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-dropdown': Dropdown,\n 'x-checkbox': Checkbox,\n 'x-choice': Choice,\n 'x-group': Group,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n currency: { type: String },\n custom: { type: Array },\n amount: { type: Number },\n amounts: { type: Array },\n frequency: { type: String },\n frequencies: { type: Array },\n designation: { type: Array },\n designations: { type: Array },\n comment: { type: String },\n anonymity: { reflect: true, type: Boolean },\n anonymous: { reflect: true, type: Boolean },\n image: { type: String },\n store: { type: String },\n name: { type: String },\n code: { type: String },\n url: { type: String },\n cart: { type: String },\n target: { type: String },\n empty: { type: String },\n };\n }\n\n /** @readonly */\n public static get events(): DonationEventsMap {\n return {\n change: DonationChangeEvent,\n submit: DonationSubmitEvent,\n };\n }\n\n /**\n * **Required** 3-letter lowercase currency code.\n *\n * **Example:** `\"usd\"`\n */\n public currency: null | string = null;\n\n /**\n * **Required** donation amount in specified currency. When more than one amount option\n * is available, this field will contain the selected amount. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `25`\n */\n public amount: null | number = null;\n\n /**\n * **Required** store domain. This is usually the part after before `.foxycart.com`\n * and after `https://`, e.g. the `foxy-demo` bit of `https://foxy-demo.foxycart.com`.\n * Custom domains like `my.domain.example.com` are also supported since v1.6.1.\n *\n * **Example:** `\"foxy-demo\"`\n */\n public store: null | string = null;\n\n /**\n * **Required** product name for this donation. This will show up in the cart when this form is submitted.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"One-time donation\"`\n */\n public name: null | string = null;\n\n /**\n * Optional parts of the form including a custom (\"other\") option.\n * Adding `amount` to this array will enable custom amount.\n *\n * **Example:** `[\"amount\"]`\n */\n public custom: null | 'amount'[] = null;\n\n /**\n * Optional donation amount variants. If this property is set, the form will render\n * the amount selection interface. If this array includes the value of the `amount` property,\n * it will be pre-selected in the form.\n *\n * **Example:** `[25, 50, 75]`\n */\n public amounts: null | number[] = null;\n\n /**\n * Optional donation frequency string encoded as count (integer) + units (one\n * of: `d` for days, `w` for weeks, `m` for months, `y` for years). A special\n * value for twice a month is also supported: `.5m`. If set, the form will\n * create a subscription with the specified frequency in the cart. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `\"1m\"`\n */\n public frequency: null | string = null;\n\n /**\n * Optional donation frequency variants in the same format as `frequency`. If this property is set,\n * the form will render the frequency selection interface. If this array includes\n * the value of the `frequency` property, it will be pre-selected in the form.\n *\n * **Example:** `[\"7d\", \".5m\", \"1y\"]`\n */\n public frequencies: null | string[] = null;\n\n /**\n * Optional donation designation(s). The form will serialize and pass this value to the cart\n * on submission. This value is deliberately not limited to the predefined options:\n * whatever you set it to will show up in the cart.\n *\n * **Example:** `\"Medical Care\"`\n * **Example:** `[\"Medical Care\", \"Daily Meals\"]`\n */\n public designation: null | string = null;\n\n /**\n * Optional donation designation(s) variants. If this property is set,\n * the form will render the designation selection interface: multiple choice\n * if `designation` is an array and a single choice otherwise. All values overlapping\n * with the `designation` property will be pre-selected in the form.\n *\n * **Example:** `[\"Medical Care\", \"Daily Meals\", \"Area of Greatest Need\"]`\n */\n public designations: null | string[] = null;\n\n /**\n * Optional comment accompanying the donation. If set (even to an empty string),\n * the form will render a comment field. The value of this property will be updated\n * as the customer enters their message and will be added to the order as a custom field in the end.\n *\n * **Example:** `\"\"`\n */\n public comment: null | string = null;\n\n /**\n * Optional switch controlling visibility of the anonymity checkbox. If set to `true`, the form\n * will render the checkbox. All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymity = false;\n\n /**\n * Optional switch marking this donation as anonymous via a custom field when set to `true`. When\n * the anonymity checkbox is rendered, also checks or unchecks it depending on the value.\n * All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymous = false;\n\n /**\n * Optional product image URL (absolute path). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://picsum.photos/320\"`\n */\n public image: null | string = null;\n\n /**\n * Optional product code for this donation. This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public code: null | string = null;\n\n /**\n * Optional product URL for this donation. Accepts a full URL to the product page, starting\n * with `http://` or `https://`, or a relative path to the produt from the store's\n * domain (as configured in the store settings). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://example.com/my-product\"`\n */\n public url: null | string = null;\n\n /**\n * Optional cart\n * If set to 'add' will add items to the cart and, on submit, user is redirected to the cart.\n * If set to 'checkout', the default, on submit user is redirected to checkout directly\n */\n public cart = 'checkout';\n\n /**\n * Optional empty\n * If set to 'true' clears the contents of the cart prior to adding the donation to the cart\n * If set to 'reset' clears the contents of the cart and cookies prior to adding the donation to the cart\n */\n public empty?: string;\n\n /**\n * Optional target to display the form response.\n */\n public target = '_top';\n\n public constructor() {\n super('donation');\n }\n\n /** Submits the form, emitting a cancelable `submit` event. */\n public submit(): void {\n /* istanbul ignore if */\n if (this.dispatchEvent(new DonationSubmitEvent())) this.__form.submit();\n }\n\n public render(): TemplateResult {\n if (!this.currency || !this.amount || !this.store || !this.name) {\n return html`\n <x-error-screen data-testid=\"error\" type=\"setup_needed\" class=\"relative\"></x-error-screen>\n `;\n }\n\n const domain = this.store.includes('.') ? this.store : `${this.store}.foxycart.com`;\n\n return html`\n <form\n target=\"${this.target}\"\n class=\"sr-only\"\n method=\"POST\"\n action=\"https://${domain}/cart\"\n data-testid=\"form\"\n >\n ${[...this.__data.entries()].map(\n ([name, value]) => html`<input type=\"hidden\" name=${name} value=${value} />`\n )}\n </form>\n\n <section>\n ${this.amounts && this.amounts.length > 0\n ? html`\n <x-group frame>\n <x-i18n ns=${this.ns} lang=${this.lang} key=\"amount\" slot=\"header\"></x-i18n>\n <x-choice\n ?custom=${!!this.custom?.includes('amount')}\n .getText=${(v: string) => this.__translateAmount(parseFloat(v))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"number\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseFloat(evt.detail as string);\n this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;\n }}\n >\n </x-choice>\n </x-group>\n\n <slot name=\"amount\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.designations && this.designations.length > 0\n ? html`\n <x-dropdown\n .label=${this._t('designation').toString()}\n .items=${this.designations}\n .value=${Array.isArray(this.designation)\n ? '${this.designation[0]}: ${this.designation[1]}'\n : this.designation}\n data-testid=\"designation\"\n @change=${(evt: DropdownChangeEvent) => {\n this.designation = evt.detail as string;\n }}\n >\n </x-dropdown>\n\n <slot name=\"designation\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${typeof this.comment === 'string'\n ? html`\n <vaadin-text-area\n placeholder=${this._t('comment_placeholder').toString()}\n value=${this.comment!}\n label=${this._t('comment_label').toString()}\n class=\"w-full\"\n data-testid=\"comment\"\n @input=${(evt: InputEvent) => {\n evt.stopPropagation();\n this.comment = (evt.target as HTMLTextAreaElement).value;\n }}\n >\n </vaadin-text-area>\n\n <slot name=\"comment\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.anonymity\n ? html`\n <x-checkbox\n class=\"my-m\"\n data-testid=\"anonymity\"\n ?checked=${this.anonymous}\n @change=${(evt: CheckboxChangeEvent) => (this.anonymous = evt.detail)}\n >\n ${this._t('anonymous')}\n </x-checkbox>\n `\n : ''}\n\n <div class=\"flex flex-wrap -m-s\">\n ${this.frequencies && this.frequencies.length > 0\n ? html`\n <div class=\"flex-1 p-s\">\n <x-dropdown\n .value=${this.frequency}\n .items=${this.frequencies}\n .getText=${this.__translateFrequency.bind(this)}\n data-testid=\"frequency\"\n @change=${(evt: DropdownChangeEvent) => {\n this.frequency = evt.detail as string;\n }}\n >\n </x-dropdown>\n </div>\n `\n : ''}\n\n <div class=\"flex-1 p-s\">\n <vaadin-button\n class=\"w-full\"\n theme=\"primary\"\n data-testid=\"submit\"\n @click=${() => this.submit()}\n >\n <x-i18n\n .opts=${{\n amount: this.__translateAmount(this.amount),\n frequency: this.frequency ? this.__translateFrequency(this.frequency) : '',\n }}\n lang=${this.lang}\n key=${this.frequency && !this.frequencies?.length ? 'donate_recurrently' : 'donate'}\n ns=${this.ns}\n >\n </x-i18n>\n </vaadin-button>\n </div>\n </div>\n </section>\n `;\n }\n\n public updated(): void {\n this.dispatchEvent(new DonationChangeEvent(this.__data));\n }\n\n private get __data() {\n const data = new FormData();\n\n if (typeof this.designation === 'string') {\n data.set('Designation', this.designation.trim());\n }\n\n if (typeof this.amount === 'number' && typeof this.currency === 'string') {\n data.set('price', `${this.amount.toFixed(2)}${this.currency}`);\n }\n\n if (this.frequency) data.set('sub_frequency', this.frequency);\n if (typeof this.comment === 'string') data.set('Comment', this.comment.trim());\n if (typeof this.image === 'string') data.set('image', this.image);\n if (typeof this.code === 'string') data.set('code', this.code);\n if (typeof this.name === 'string') data.set('name', this.name.trim());\n if (typeof this.url === 'string') data.set('url', this.url);\n if (typeof this.cart === 'string') data.set('cart', this.cart);\n if (this.empty) data.set('empty', this.empty);\n if (this.anonymous) data.set('Anonymous', 'true');\n\n data.set('quantity', '1');\n\n return data;\n }\n\n private get __form(): HTMLFormElement {\n return this.shadowRoot!.querySelector('form')!;\n }\n\n private __translateFrequency(frequency: string) {\n if (!frequency || frequency.match(/^\\s*$/)) return this._t('frequency_once');\n if (frequency === '.5m') return this._t('frequency_0_5m');\n\n const { count, units } = parseDuration(frequency);\n return this._t('frequency', {\n units: this._t(units, { count }),\n count,\n });\n }\n\n private __translateAmount(amount: number) {\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 0,\n currency: this.currency!,\n style: 'currency',\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Donation.js","sourceRoot":"","sources":["../../../../src/elements/public/Donation/Donation.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;A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E,KAAK,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE;YAC1B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;YAChC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE;YACtC,qBAAqB,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAS;YACxB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport '@vaadin/vaadin-button';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { PropertyDeclarations } from 'lit-element';\nimport { html, TemplateResult } from 'lit-html';\nimport { Translatable } from '../../../mixins/translatable';\nimport { parseDuration } from '../../../utils/parse-duration';\nimport { CheckboxChangeEvent, ChoiceChangeEvent, DropdownChangeEvent } from '../../private/events';\nimport { Checkbox, Choice, Dropdown, ErrorScreen, Group, I18N } from '../../private/index';\nimport { DonationChangeEvent } from './DonationChangeEvent';\nimport { DonationSubmitEvent } from './DonationSubmitEvent';\n\ndeclare global {\n interface Window {\n FC?: {\n settings: {\n session_name: string;\n session_id: string;\n };\n };\n }\n}\n\ninterface DonationEventsMap {\n change: typeof DonationChangeEvent;\n submit: typeof DonationSubmitEvent;\n}\n\n/**\n * A custom element providing customizable donation forms.\n *\n * @fires Donation#change - Instance of `Donation.events.change`. Emitted after user input triggers a change in the form data.\n * @fires Donation#submit - Instance of `Donation.events.submit`. Emitted when the form is submitted. Cancelling this event will stop the submission.\n *\n * @slot amount - Space below the amount selector, if it's visible.\n * @slot designation - Space below the designation selector, if it's visible.\n * @slot comment - Space below the comment field, if it's visible.\n *\n * @element foxy-donation\n * @since 0.3.0\n */\nexport class Donation extends Translatable {\n /** @readonly */\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-error-screen': ErrorScreen,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-dropdown': Dropdown,\n 'x-checkbox': Checkbox,\n 'x-choice': Choice,\n 'x-group': Group,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n currency: { type: String },\n custom: { type: Array },\n amount: { type: Number },\n amounts: { type: Array },\n frequency: { type: String },\n frequencies: { type: Array },\n designation: { type: Array },\n designations: { type: Array },\n comment: { type: String },\n anonymity: { reflect: true, type: Boolean },\n anonymous: { reflect: true, type: Boolean },\n image: { type: String },\n store: { type: String },\n name: { type: String },\n code: { type: String },\n url: { type: String },\n cart: { type: String },\n target: { type: String },\n empty: { type: String },\n };\n }\n\n /** @readonly */\n public static get events(): DonationEventsMap {\n return {\n change: DonationChangeEvent,\n submit: DonationSubmitEvent,\n };\n }\n\n /**\n * **Required** 3-letter lowercase currency code.\n *\n * **Example:** `\"usd\"`\n */\n public currency: null | string = null;\n\n /**\n * **Required** donation amount in specified currency. When more than one amount option\n * is available, this field will contain the selected amount. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `25`\n */\n public amount: null | number = null;\n\n /**\n * **Required** store domain. This is usually the part after before `.foxycart.com`\n * and after `https://`, e.g. the `foxy-demo` bit of `https://foxy-demo.foxycart.com`.\n * Custom domains like `my.domain.example.com` are also supported since v1.6.1.\n *\n * **Example:** `\"foxy-demo\"`\n */\n public store: null | string = null;\n\n /**\n * **Required** product name for this donation. This will show up in the cart when this form is submitted.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"One-time donation\"`\n */\n public name: null | string = null;\n\n /**\n * Optional parts of the form including a custom (\"other\") option.\n * Adding `amount` to this array will enable custom amount.\n *\n * **Example:** `[\"amount\"]`\n */\n public custom: null | 'amount'[] = null;\n\n /**\n * Optional donation amount variants. If this property is set, the form will render\n * the amount selection interface. If this array includes the value of the `amount` property,\n * it will be pre-selected in the form.\n *\n * **Example:** `[25, 50, 75]`\n */\n public amounts: null | number[] = null;\n\n /**\n * Optional donation frequency string encoded as count (integer) + units (one\n * of: `d` for days, `w` for weeks, `m` for months, `y` for years). A special\n * value for twice a month is also supported: `.5m`. If set, the form will\n * create a subscription with the specified frequency in the cart. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `\"1m\"`\n */\n public frequency: null | string = null;\n\n /**\n * Optional donation frequency variants in the same format as `frequency`. If this property is set,\n * the form will render the frequency selection interface. If this array includes\n * the value of the `frequency` property, it will be pre-selected in the form.\n *\n * **Example:** `[\"7d\", \".5m\", \"1y\"]`\n */\n public frequencies: null | string[] = null;\n\n /**\n * Optional donation designation(s). The form will serialize and pass this value to the cart\n * on submission. This value is deliberately not limited to the predefined options:\n * whatever you set it to will show up in the cart.\n *\n * **Example:** `\"Medical Care\"`\n * **Example:** `[\"Medical Care\", \"Daily Meals\"]`\n */\n public designation: null | string = null;\n\n /**\n * Optional donation designation(s) variants. If this property is set,\n * the form will render the designation selection interface: multiple choice\n * if `designation` is an array and a single choice otherwise. All values overlapping\n * with the `designation` property will be pre-selected in the form.\n *\n * **Example:** `[\"Medical Care\", \"Daily Meals\", \"Area of Greatest Need\"]`\n */\n public designations: null | string[] = null;\n\n /**\n * Optional comment accompanying the donation. If set (even to an empty string),\n * the form will render a comment field. The value of this property will be updated\n * as the customer enters their message and will be added to the order as a custom field in the end.\n *\n * **Example:** `\"\"`\n */\n public comment: null | string = null;\n\n /**\n * Optional switch controlling visibility of the anonymity checkbox. If set to `true`, the form\n * will render the checkbox. All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymity = false;\n\n /**\n * Optional switch marking this donation as anonymous via a custom field when set to `true`. When\n * the anonymity checkbox is rendered, also checks or unchecks it depending on the value.\n * All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymous = false;\n\n /**\n * Optional product image URL (absolute path). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://picsum.photos/320\"`\n */\n public image: null | string = null;\n\n /**\n * Optional product code for this donation. This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public code: null | string = null;\n\n /**\n * Optional product URL for this donation. Accepts a full URL to the product page, starting\n * with `http://` or `https://`, or a relative path to the produt from the store's\n * domain (as configured in the store settings). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://example.com/my-product\"`\n */\n public url: null | string = null;\n\n /**\n * Optional cart\n * If set to 'add' will add items to the cart and, on submit, user is redirected to the cart.\n * If set to 'checkout', the default, on submit user is redirected to checkout directly\n */\n public cart = 'checkout';\n\n /**\n * Optional empty\n * If set to 'true' clears the contents of the cart prior to adding the donation to the cart\n * If set to 'reset' clears the contents of the cart and cookies prior to adding the donation to the cart\n */\n public empty?: string;\n\n /**\n * Optional target to display the form response.\n */\n public target = '_top';\n\n public constructor() {\n super('donation');\n }\n\n /** Submits the form, emitting a cancelable `submit` event. */\n public submit(): void {\n /* istanbul ignore if */\n if (this.dispatchEvent(new DonationSubmitEvent())) this.__form.submit();\n }\n\n public render(): TemplateResult {\n if (!this.currency || !this.amount || !this.store || !this.name) {\n return html`\n <x-error-screen data-testid=\"error\" type=\"setup_needed\" class=\"relative\"></x-error-screen>\n `;\n }\n\n const domain = this.store.includes('.') ? this.store : `${this.store}.foxycart.com`;\n\n return html`\n <form\n target=\"${this.target}\"\n class=\"sr-only\"\n method=\"POST\"\n action=\"https://${domain}/cart\"\n data-testid=\"form\"\n >\n ${[...this.__data.entries()].map(\n ([name, value]) => html`<input type=\"hidden\" name=${name} value=${value} />`\n )}\n </form>\n\n <section>\n ${this.amounts && this.amounts.length > 0\n ? html`\n <x-group frame>\n <x-i18n ns=${this.ns} lang=${this.lang} key=\"amount\" slot=\"header\"></x-i18n>\n <x-choice\n ?custom=${!!this.custom?.includes('amount')}\n .getText=${(v: string) => this.__translateAmount(parseFloat(v))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"number\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseFloat(evt.detail as string);\n this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;\n }}\n >\n </x-choice>\n </x-group>\n\n <slot name=\"amount\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.designations && this.designations.length > 0\n ? html`\n <x-dropdown\n .label=${this._t('designation').toString()}\n .items=${this.designations}\n .value=${Array.isArray(this.designation)\n ? '${this.designation[0]}: ${this.designation[1]}'\n : this.designation}\n data-testid=\"designation\"\n @change=${(evt: DropdownChangeEvent) => {\n this.designation = evt.detail as string;\n }}\n >\n </x-dropdown>\n\n <slot name=\"designation\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${typeof this.comment === 'string'\n ? html`\n <vaadin-text-area\n placeholder=${this._t('comment_placeholder').toString()}\n value=${this.comment!}\n label=${this._t('comment_label').toString()}\n class=\"w-full\"\n data-testid=\"comment\"\n @input=${(evt: InputEvent) => {\n evt.stopPropagation();\n this.comment = (evt.target as HTMLTextAreaElement).value;\n }}\n >\n </vaadin-text-area>\n\n <slot name=\"comment\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.anonymity\n ? html`\n <x-checkbox\n class=\"my-m\"\n data-testid=\"anonymity\"\n ?checked=${this.anonymous}\n @change=${(evt: CheckboxChangeEvent) => (this.anonymous = evt.detail)}\n >\n ${this._t('anonymous')}\n </x-checkbox>\n `\n : ''}\n\n <div class=\"flex flex-wrap -m-s\">\n ${this.frequencies && this.frequencies.length > 0\n ? html`\n <div class=\"flex-1 p-s\">\n <x-dropdown\n .value=${this.frequency}\n .items=${this.frequencies}\n .getText=${this.__translateFrequency.bind(this)}\n data-testid=\"frequency\"\n @change=${(evt: DropdownChangeEvent) => {\n this.frequency = evt.detail as string;\n }}\n >\n </x-dropdown>\n </div>\n `\n : ''}\n\n <div class=\"flex-1 p-s\">\n <vaadin-button\n class=\"w-full\"\n theme=\"primary\"\n data-testid=\"submit\"\n @click=${() => this.submit()}\n >\n <x-i18n\n .opts=${{\n amount: this.__translateAmount(this.amount),\n frequency: this.frequency ? this.__translateFrequency(this.frequency) : '',\n }}\n lang=${this.lang}\n key=${this.frequency && !this.frequencies?.length ? 'donate_recurrently' : 'donate'}\n ns=${this.ns}\n >\n </x-i18n>\n </vaadin-button>\n </div>\n </div>\n </section>\n `;\n }\n\n public updated(): void {\n this.dispatchEvent(new DonationChangeEvent(this.__data));\n }\n\n private get __data() {\n const data = new FormData();\n\n if (typeof this.designation === 'string') {\n data.set('Designation', this.designation.trim());\n }\n\n if (typeof this.amount === 'number' && typeof this.currency === 'string') {\n data.set('price', `${this.amount.toFixed(2)}${this.currency}`);\n }\n\n if (this.frequency) data.set('sub_frequency', this.frequency);\n if (typeof this.comment === 'string') data.set('Comment', this.comment.trim());\n if (typeof this.image === 'string') data.set('image', this.image);\n if (typeof this.code === 'string') data.set('code', this.code);\n if (typeof this.name === 'string') data.set('name', this.name.trim());\n if (typeof this.url === 'string') data.set('url', this.url);\n if (typeof this.cart === 'string') data.set('cart', this.cart);\n if (this.empty) data.set('empty', this.empty);\n if (this.anonymous) data.set('Anonymous', 'true');\n if (window.FC) data.set(window.FC.settings.session_name, window.FC.settings.session_id);\n\n data.set('quantity', '1');\n\n return data;\n }\n\n private get __form(): HTMLFormElement {\n return this.shadowRoot!.querySelector('form')!;\n }\n\n private __translateFrequency(frequency: string) {\n if (!frequency || frequency.match(/^\\s*$/)) return this._t('frequency_once');\n if (frequency === '.5m') return this._t('frequency_0_5m');\n\n const { count, units } = parseDuration(frequency);\n return this._t('frequency', {\n units: this._t(units, { count }),\n count,\n });\n }\n\n private __translateAmount(amount: number) {\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 0,\n currency: this.currency!,\n style: 'currency',\n });\n }\n}\n"]}
|
|
@@ -51,6 +51,8 @@ declare class QueryBuilder extends Base {
|
|
|
51
51
|
static readonly Type: typeof Type;
|
|
52
52
|
static get properties(): PropertyDeclarations;
|
|
53
53
|
static get styles(): CSSResultArray;
|
|
54
|
+
/** List of reserved paths that should not be visible. */
|
|
55
|
+
reservedPaths: string[];
|
|
54
56
|
/** If true, doesn't add `zoom` query parameter for complex paths. */
|
|
55
57
|
disableZoom: boolean;
|
|
56
58
|
/** If true, hides the UI for the "OR" operator in queries. */
|
|
@@ -22,6 +22,8 @@ const Base = ConfigurableMixin(ResponsiveMixin(ThemeableMixin(TranslatableMixin(
|
|
|
22
22
|
class QueryBuilder extends Base {
|
|
23
23
|
constructor() {
|
|
24
24
|
super(...arguments);
|
|
25
|
+
/** List of reserved paths that should not be visible. */
|
|
26
|
+
this.reservedPaths = ['zoom', 'limit', 'offset', 'order', 'fields'];
|
|
25
27
|
/** If true, doesn't add `zoom` query parameter for complex paths. */
|
|
26
28
|
this.disableZoom = false;
|
|
27
29
|
/** If true, hides the UI for the "OR" operator in queries. */
|
|
@@ -36,6 +38,7 @@ class QueryBuilder extends Base {
|
|
|
36
38
|
static get properties() {
|
|
37
39
|
return {
|
|
38
40
|
...super.properties,
|
|
41
|
+
reservedPaths: { type: Array, attribute: 'reserved-paths' },
|
|
39
42
|
disableZoom: { type: Boolean, attribute: 'disable-zoom' },
|
|
40
43
|
disableOr: { type: Boolean, attribute: 'disable-or' },
|
|
41
44
|
operators: { type: Array },
|
|
@@ -48,7 +51,7 @@ class QueryBuilder extends Base {
|
|
|
48
51
|
}
|
|
49
52
|
render() {
|
|
50
53
|
var _a, _b, _c;
|
|
51
|
-
const reservedPaths = new Set(
|
|
54
|
+
const reservedPaths = new Set(this.reservedPaths);
|
|
52
55
|
const hiddenValues = [];
|
|
53
56
|
const visibleValues = [];
|
|
54
57
|
parse((_a = this.value) !== null && _a !== void 0 ? _a : '').forEach(value => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAwC,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAe,QAAQ,EAAU,IAAI,EAAE,mBAAgB;AAE9D,OAAO,EAAE,KAAK,EAAE,8BAA2B;AAC3C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,KAAK,EAAE,yBAAsB;AACtC,OAAO,EAAE,SAAS,EAAE,6BAA0B;AAC9C,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAClC,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,iBAAiB,CAC5B,eAAe,CAAC,cAAc,CAAC,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CACpF,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,YAAa,SAAQ,IAAI;IAA/B;;
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAwC,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAe,QAAQ,EAAU,IAAI,EAAE,mBAAgB;AAE9D,OAAO,EAAE,KAAK,EAAE,8BAA2B;AAC3C,OAAO,EAAE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EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;gBACzE,IAAI,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7D,CAAC;SACF,CAAC,CAAC;IACL,CAAC;;AAlED,uEAAuE;AACvD,wBAAW,GAAG,KAAM,SAAQ,WAAiB;CAAG,CAAC;AAEjE,2DAA2D;AAC3C,qBAAQ,GAAG,QAAQ,CAAC;AAEpC,6DAA6D;AAC7C,iBAAI,GAAG,IAAI,CAAC;AA8D9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { CSSResultArray, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport { ParsedValue, Operator, Option, Type } from './types';\n\nimport { Group } from './components/Group';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { parse } from './utils/parse';\nimport { stringify } from './utils/stringify';\nimport { styles } from './styles';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\n\nconst NS = 'query-builder';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)))\n);\n\n/**\n * UI component for creating Foxy hAPI filters visually. Compatible with\n * Backend API, Customer API or any other API using the same format as described\n * in our [docs](https://api.foxy.io/docs/cheat-sheet).\n *\n * @element foxy-query-builder\n * @since 1.12.0\n */\nclass QueryBuilder extends Base {\n /** QueryBuilder dispatches this event on itself when value changes. */\n static readonly ChangeEvent = class extends CustomEvent<void> {};\n\n /** Operator dictionary for use in autocomplete options. */\n static readonly Operator = Operator;\n\n /** Field type dictionary for use in autocomplete options. */\n static readonly Type = Type;\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n reservedPaths: { type: Array, attribute: 'reserved-paths' },\n disableZoom: { type: Boolean, attribute: 'disable-zoom' },\n disableOr: { type: Boolean, attribute: 'disable-or' },\n operators: { type: Array },\n options: { type: Array },\n value: { type: String },\n };\n }\n\n static get styles(): CSSResultArray {\n return [super.styles, styles];\n }\n\n /** List of reserved paths that should not be visible. */\n reservedPaths: string[] = ['zoom', 'limit', 'offset', 'order', 'fields'];\n\n /** If true, doesn't add `zoom` query parameter for complex paths. */\n disableZoom = false;\n\n /** If true, hides the UI for the \"OR\" operator in queries. */\n disableOr = false;\n\n /** List of operators available in the builder UI. */\n operators: Operator[] = Object.values(Operator);\n\n /** Autocomplete suggestions. */\n options: Option[] | null = null;\n\n /** Current value as hAPI filter string. */\n value: string | null = null;\n\n render(): TemplateResult {\n const reservedPaths = new Set(this.reservedPaths);\n const hiddenValues: (ParsedValue | ParsedValue[])[] = [];\n const visibleValues: (ParsedValue | ParsedValue[])[] = [];\n\n parse(this.value ?? '').forEach(value => {\n const isVisible = Array.isArray(value) || !reservedPaths.has(value.path);\n isVisible ? visibleValues.push(value) : hiddenValues.push(value);\n });\n\n return Group({\n parsedValues: visibleValues,\n disableOr: this.disableOr,\n operators: this.operators ?? [],\n disabled: this.disabled,\n readonly: this.readonly,\n options: this.options ?? [],\n t: this.t.bind(this),\n onChange: newValue => {\n this.value = stringify([...newValue, ...hiddenValues], this.disableZoom);\n this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));\n },\n });\n }\n}\n\nexport { QueryBuilder };\n"]}
|
|
@@ -2,6 +2,7 @@ import { html } from 'lit-html';
|
|
|
2
2
|
import { classMap } from "../../../../utils/class-map.js";
|
|
3
3
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
4
|
import { serializeDateTime } from "../../../../utils/serialize-date.js";
|
|
5
|
+
import { parseDate } from "../../../../utils/parse-date.js";
|
|
5
6
|
export function Input(params) {
|
|
6
7
|
var _a;
|
|
7
8
|
const id = (_a = params.id) !== null && _a !== void 0 ? _a : String(Math.floor(Math.random() * Math.pow(10, 8)));
|
|
@@ -12,6 +13,14 @@ export function Input(params) {
|
|
|
12
13
|
const date = new Date(params.value);
|
|
13
14
|
normalizedValue = isNaN(date.getTime()) ? '' : serializeDateTime(date);
|
|
14
15
|
}
|
|
16
|
+
const inputType = params.type === 'date' && (normalizedValue || !params.dateHours)
|
|
17
|
+
? 'datetime-local'
|
|
18
|
+
: params.type;
|
|
19
|
+
const inputMax = params.type === 'date'
|
|
20
|
+
? normalizedValue || !params.dateHours
|
|
21
|
+
? '9999-12-31T23:59'
|
|
22
|
+
: '9999-12-31'
|
|
23
|
+
: void 0;
|
|
15
24
|
return html `
|
|
16
25
|
<label class="relative flex items-center cursor-text group text-tertiary">
|
|
17
26
|
<div class="relative flex-1 min-w-0 overflow-hidden">
|
|
@@ -43,8 +52,8 @@ export function Input(params) {
|
|
|
43
52
|
'opacity-0 focus-opacity-100': hasDisplayValue,
|
|
44
53
|
})}
|
|
45
54
|
list=${ifDefined(params.list ? listId : undefined)}
|
|
46
|
-
type=${
|
|
47
|
-
max=${ifDefined(
|
|
55
|
+
type=${inputType}
|
|
56
|
+
max=${ifDefined(inputMax)}
|
|
48
57
|
.value=${normalizedValue}
|
|
49
58
|
?disabled=${params.disabled || params.readonly}
|
|
50
59
|
@input=${(evt) => {
|
|
@@ -52,7 +61,9 @@ export function Input(params) {
|
|
|
52
61
|
let newValue = input.value;
|
|
53
62
|
try {
|
|
54
63
|
if (params.type === 'date') {
|
|
55
|
-
const newDate = new Date(input.value);
|
|
64
|
+
const newDate = normalizedValue ? new Date(input.value) : parseDate(input.value);
|
|
65
|
+
if (params.dateHours && !normalizedValue)
|
|
66
|
+
newDate.setHours(...params.dateHours);
|
|
56
67
|
if (!isNaN(newDate.getTime()))
|
|
57
68
|
newValue = newDate.toISOString();
|
|
58
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/Input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD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,EAAE,EAAE,CAAC,IAAI,CAAA,iBAAiB,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAC/E;;WAEJ;QACH,CAAC,CAAC,EAAE;QACJ,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ;QAClC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,IAAI,CAAA;;;;WAIH;;GAER,CAAC;AACJ,CAAC","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { I18n } from '../../I18n/I18n';\nimport { classMap } from '../../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { serializeDateTime } from '../../../../utils/serialize-date';\nimport { parseDate } from '../../../../utils/parse-date';\n\nexport type InputParams = {\n t: I18n['t'];\n id?: string;\n list?: { label: string; value: string }[];\n dateHours?: [number, number, number, number];\n type: string;\n label: string;\n value: string;\n disabled: boolean;\n readonly: boolean;\n displayValue?: string;\n onChange: (newValue: string) => void;\n};\n\nexport function Input(params: InputParams): TemplateResult {\n const id = params.id ?? String(Math.floor(Math.random() * Math.pow(10, 8)));\n const listId = `${id}-list`;\n const hasDisplayValue = !!params.displayValue;\n\n let normalizedValue = params.value;\n\n if (params.type === 'date') {\n const date = new Date(params.value);\n normalizedValue = isNaN(date.getTime()) ? '' : serializeDateTime(date);\n }\n\n const inputType =\n params.type === 'date' && (normalizedValue || !params.dateHours)\n ? 'datetime-local'\n : params.type;\n\n const inputMax =\n params.type === 'date'\n ? normalizedValue || !params.dateHours\n ? '9999-12-31T23:59'\n : '9999-12-31'\n : void 0;\n\n return html`\n <label class=\"relative flex items-center cursor-text group text-tertiary\">\n <div class=\"relative flex-1 min-w-0 overflow-hidden\">\n ${hasDisplayValue\n ? html`\n <div\n aria-hidden=\"true\"\n class=${classMap({\n 'absolute inset-0 h-m px-s font-medium flex items-center': true,\n 'text-body': !params.disabled && !params.readonly,\n 'text-disabled': params.disabled,\n 'text-secondary': params.readonly,\n })}\n >\n <div class=\"truncate\">${params.t(params.displayValue!)}</div>\n </div>\n `\n : ''}\n\n <input\n placeholder=${normalizedValue || params.type === 'date' ? '' : params.t(params.label)}\n class=${classMap({\n 'bg-base relative flex h-m px-s font-medium w-full': true,\n 'text-body': !params.disabled && !params.readonly,\n 'text-disabled': params.disabled,\n 'text-secondary': params.readonly,\n 'flex max-w-full whitespace-nowrap': true, // ugh safari\n 'focus-outline-none': true,\n 'opacity-0 focus-opacity-100': hasDisplayValue,\n })}\n list=${ifDefined(params.list ? listId : undefined)}\n type=${inputType}\n max=${ifDefined(inputMax)}\n .value=${normalizedValue}\n ?disabled=${params.disabled || params.readonly}\n @input=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n let newValue = input.value;\n\n try {\n if (params.type === 'date') {\n const newDate = normalizedValue ? new Date(input.value) : parseDate(input.value)!;\n if (params.dateHours && !normalizedValue) newDate.setHours(...params.dateHours);\n if (!isNaN(newDate.getTime())) newValue = newDate.toISOString();\n }\n } catch {\n // ignore\n }\n\n params.onChange(newValue);\n }}\n />\n </div>\n\n <span\n class=${classMap({\n 'font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s': true,\n 'inline-block': !!normalizedValue || params.type === 'date',\n 'sr-only': !normalizedValue && params.type !== 'date',\n 'text-body': !params.disabled && !params.readonly,\n 'text-disabled': params.disabled,\n 'text-secondary': params.readonly,\n })}\n >\n ${params.t(params.label)}\n </span>\n\n ${params.list\n ? html`\n <datalist id=${listId}>\n ${params.list.map(\n ({ label, value }) => html`<option value=${value}>${params.t(label)}</option>`\n )}\n </datalist>\n `\n : ''}\n ${params.disabled || params.readonly\n ? ''\n : html`\n <div\n class=\"absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none\"\n ></div>\n `}\n </label>\n `;\n}\n"]}
|
|
@@ -17,6 +17,7 @@ export function RangeValue(params) {
|
|
|
17
17
|
<div class="bg-base">
|
|
18
18
|
${Field({
|
|
19
19
|
displayValue: (_b = list === null || list === void 0 ? void 0 : list.find(v => v.value === from)) === null || _b === void 0 ? void 0 : _b.label,
|
|
20
|
+
dateHours: [0, 0, 0, 0],
|
|
20
21
|
readonly,
|
|
21
22
|
disabled,
|
|
22
23
|
value: from,
|
|
@@ -31,6 +32,7 @@ export function RangeValue(params) {
|
|
|
31
32
|
<div class="bg-base">
|
|
32
33
|
${Field({
|
|
33
34
|
displayValue: (_c = list === null || list === void 0 ? void 0 : list.find(v => v.value === to)) === null || _c === void 0 ? void 0 : _c.label,
|
|
35
|
+
dateHours: [23, 59, 59, 999],
|
|
34
36
|
readonly,
|
|
35
37
|
disabled,
|
|
36
38
|
label: 'range_to',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeValue.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/RangeValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,IAAI,EAAE,oBAAiB;AACrD,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAWlC,MAAM,UAAU,UAAU,CAAC,MAAwB;;IACjD,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACxE,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEvD,MAAM,KAAK,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,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AAC,QAAQ,CAAC,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,GAAG,IAAI,KAAK,QAAQ,EAAE,EAAE,CAAC;KAClF,CAAC;;;GAGP,CAAC;AACJ,CAAC","sourcesContent":["import { Option, ParsedValue, Type } from '../types';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { I18n } from '../../I18n/I18n';\nimport { Input } from './Input';\nimport { Select } from './Select';\n\nexport type RangeValueParams = {\n parsedValue: ParsedValue;\n readonly: boolean;\n disabled: boolean;\n option: Option | null;\n t: I18n['t'];\n onChange: (newValue: ParsedValue) => void;\n};\n\nexport function RangeValue(params: RangeValueParams): TemplateResult {\n const { t, parsedValue, option, readonly, disabled, onChange } = params;\n const splitValue = parsedValue.value.split('..');\n const from = splitValue.length >= 1 ? splitValue[0] : '';\n const to = splitValue.length >= 2 ? splitValue[1] : '';\n\n const Field = option?.list ? Select : Input;\n const optionType = option?.type ?? Type.Any;\n const type = optionType === Type.Number ? 'number' : optionType === Type.Date ? 'date' : 'text';\n const list = option?.list;\n\n return html`\n <div class=\"grid bg-contrast-10 gap-1px grid-cols-1 grid-rows-2 sm-grid-cols-2 sm-grid-rows-1\">\n <div class=\"bg-base\">\n ${Field({\n displayValue: list?.find(v => v.value === from)?.label,\n readonly,\n disabled,\n value: from,\n label: 'range_from',\n type: type,\n list: list,\n t: t,\n onChange: newValue => onChange({ ...parsedValue, value: `${newValue}..${to}` }),\n })}\n </div>\n\n <div class=\"bg-base\">\n ${Field({\n displayValue: list?.find(v => v.value === to)?.label,\n readonly,\n disabled,\n label: 'range_to',\n value: to,\n type: type,\n list: list,\n t: t,\n onChange: newValue => onChange({ ...parsedValue, value: `${from}..${newValue}` }),\n })}\n </div>\n </div>\n `;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RangeValue.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/RangeValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,IAAI,EAAE,oBAAiB;AACrD,OAA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AC,KAAK,KAAK,IAAI,2CAAG,KAAK;QACtD,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACvB,QAAQ;QACR,QAAQ;QACR,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,IAAI;QACV,CAAC,EAAE,CAAC;QACJ,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,GAAG,QAAQ,KAAK,EAAE,EAAE,EAAE,CAAC;KAChF,CAAC;;;;UAIA,KAAK,CAAC;QACN,YAAY,QAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,2CAAG,KAAK;QACpD,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;QAC5B,QAAQ;QACR,QAAQ;QACR,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,IAAI;QACV,CAAC,EAAE,CAAC;QACJ,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,GAAG,IAAI,KAAK,QAAQ,EAAE,EAAE,CAAC;KAClF,CAAC;;;GAGP,CAAC;AACJ,CAAC","sourcesContent":["import { Option, ParsedValue, Type } from '../types';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { I18n } from '../../I18n/I18n';\nimport { Input } from './Input';\nimport { Select } from './Select';\n\nexport type RangeValueParams = {\n parsedValue: ParsedValue;\n readonly: boolean;\n disabled: boolean;\n option: Option | null;\n t: I18n['t'];\n onChange: (newValue: ParsedValue) => void;\n};\n\nexport function RangeValue(params: RangeValueParams): TemplateResult {\n const { t, parsedValue, option, readonly, disabled, onChange } = params;\n const splitValue = parsedValue.value.split('..');\n const from = splitValue.length >= 1 ? splitValue[0] : '';\n const to = splitValue.length >= 2 ? splitValue[1] : '';\n\n const Field = option?.list ? Select : Input;\n const optionType = option?.type ?? Type.Any;\n const type = optionType === Type.Number ? 'number' : optionType === Type.Date ? 'date' : 'text';\n const list = option?.list;\n\n return html`\n <div class=\"grid bg-contrast-10 gap-1px grid-cols-1 grid-rows-2 sm-grid-cols-2 sm-grid-rows-1\">\n <div class=\"bg-base\">\n ${Field({\n displayValue: list?.find(v => v.value === from)?.label,\n dateHours: [0, 0, 0, 0],\n readonly,\n disabled,\n value: from,\n label: 'range_from',\n type: type,\n list: list,\n t: t,\n onChange: newValue => onChange({ ...parsedValue, value: `${newValue}..${to}` }),\n })}\n </div>\n\n <div class=\"bg-base\">\n ${Field({\n displayValue: list?.find(v => v.value === to)?.label,\n dateHours: [23, 59, 59, 999],\n readonly,\n disabled,\n label: 'range_to',\n value: to,\n type: type,\n list: list,\n t: t,\n onChange: newValue => onChange({ ...parsedValue, value: `${from}..${newValue}` }),\n })}\n </div>\n </div>\n `;\n}\n"]}
|
|
@@ -293,13 +293,14 @@ export class TaxForm extends Base {
|
|
|
293
293
|
return this.renderRoot.querySelector('#regionsLoader');
|
|
294
294
|
}
|
|
295
295
|
get __isExemptAllCustomerTaxIdsHidden() {
|
|
296
|
+
const provider = this.form.service_provider;
|
|
296
297
|
const type = this.form.type;
|
|
297
298
|
if (type === 'custom_tax_endpoint')
|
|
298
299
|
return true;
|
|
299
|
-
if (type === 'country' || type === 'region' || type === 'local')
|
|
300
|
-
return !!this.form.is_live;
|
|
301
|
-
|
|
302
|
-
return
|
|
300
|
+
if (type === 'country' || type === 'region' || type === 'local' || type === 'union') {
|
|
301
|
+
return !!this.form.is_live && (provider === 'onesource' || provider === 'avalara');
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
303
304
|
}
|
|
304
305
|
get __isApplyToShippingHidden() {
|
|
305
306
|
const type = this.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AgB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IACnE,CAAC;IAED,IAAY,cAAc;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;IACpC,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'tax-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n// prettier-ignore\nconst defaultLiveRateCountries: (string | undefined)[] = ['US', 'CA', 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IM', 'IT', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'];\nconst taxJarLiveRateCountries = [...defaultLiveRateCountries, 'AU'];\n\n/**\n * Form element for creating or editing taxes (`fx:tax`).\n *\n * @element foxy-tax-form\n * @since 1.13.0\n */\nexport class TaxForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n nativeIntegrations: { attribute: 'native-integrations' },\n itemCategories: { attribute: 'item-categories' },\n countries: {},\n regions: {},\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ name: v }) => !!v || 'name:v8n_required',\n ({ name: v }) => !v || v.length <= 30 || 'name:v8n_too_long',\n ({ country: c, type: t }) => t !== 'country' || !!c || 'country:v8n_required',\n ({ country: c, type: t }) => t !== 'region' || !!c || 'country:v8n_required',\n ({ country: c, use_origin_rates: r }) => !r || !!c || 'country:v8n_required',\n ({ region: v, type: t }) => t != 'region' || !!v || 'region:v8n_required',\n ({ region: v }) => !v || v.length <= 20 || 'region:v8n_too_long',\n ({ city: v }) => !v || v.length <= 50 || 'city:v8n_too_long',\n ({ city: c, type: t }) => t != 'local' || !!c || 'city:v8n_required',\n ({ rate: v, type, is_live }) => {\n return (\n v === void 0 ||\n v > 0 ||\n // @ts-expect-error SDK types are not up to date.\n type === 'custom_tax_endpoint' ||\n type === void 0 ||\n is_live ||\n 'rate:v8n_invalid'\n );\n },\n ];\n }\n\n /** URL of the `fx:native_integrations` collection for the store. */\n nativeIntegrations: string | null = null;\n\n /** URL of the `fx:item_categories` collection for the store. */\n itemCategories: string | null = null;\n\n /** URL of the `fx:countries` property helper resource. */\n countries: string | null = null;\n\n /** URL of the `fx:regions` property helper resource. */\n regions: string | null = null;\n\n private __countrySetValue = (newValue: string) => {\n this.edit({ country: newValue, region: '', city: '' });\n this.edit({ apply_to_shipping: this.__isApplyToShippingHidden });\n };\n\n private __regionSetValue = (newValue: string) => {\n this.edit({ region: newValue, city: '' });\n };\n\n private __typeSetValue = (newValue: Data['type']) => {\n this.edit({\n type: newValue,\n country: '',\n region: '',\n city: '',\n // @ts-expect-error SDK types are not up to date.\n service_provider: newValue === 'custom_tax_endpoint' ? 'custom_tax' : '',\n apply_to_shipping: false,\n use_origin_rates: false,\n exempt_all_customer_tax_ids: false,\n is_live: false,\n rate: 0,\n });\n };\n\n private readonly __typeOptions = JSON.stringify([\n { label: 'option_custom_tax_endpoint', value: 'custom_tax_endpoint' },\n { label: 'option_global', value: 'global' },\n { label: 'option_union', value: 'union' },\n { label: 'option_country', value: 'country' },\n { label: 'option_region', value: 'region' },\n { label: 'option_local', value: 'local' },\n ]);\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.readonlySelector.toString()];\n alwaysMatch.unshift('native-integrations');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n const type = this.form.type as string | undefined;\n\n if (type === 'global' || type === 'custom_tax_endpoint') {\n alwaysMatch.unshift('group-one:is-live', 'group-one:service-provider');\n if (type === 'custom_tax_endpoint') alwaysMatch.unshift('group-one:rate');\n } else {\n if (this.form.is_live) {\n alwaysMatch.unshift('group-one:rate');\n } else {\n alwaysMatch.unshift('group-one:service-provider');\n }\n }\n\n if (this.__nativeIntegrationsUrl === void 0) alwaysMatch.unshift('native-integrations');\n if (this.__isCountryHidden) alwaysMatch.unshift('group-three:country');\n if (this.__isRegionHidden) {\n alwaysMatch.unshift('group-three:region-select', 'group-three:region-input');\n }\n\n if (this.__isCityHidden) alwaysMatch.unshift('group-three:city');\n if (this.__isApplyToShippingHidden) alwaysMatch.unshift('group-two:apply-to-shipping');\n if (this.__isUseOriginRatesHidden) alwaysMatch.unshift('group-two:use-origin-rates');\n if (this.__isExemptAllCustomerTaxIdsHidden) {\n alwaysMatch.unshift('group-two:exempt-all-customer-tax-ids');\n }\n\n const regions = Object.values(this.__regionsLoader?.data?.values ?? {});\n alwaysMatch.unshift(`group-three:region-${regions.length ? 'input' : 'select'}`);\n\n if (!this.data || !this.itemCategories) alwaysMatch.unshift('item-categories');\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n const countries = Object.values(this.__countriesLoader?.data?.values ?? {});\n const countryOptions = countries.map(c => ({ rawLabel: c.default, value: c.cc2 }));\n\n const regions = Object.values(this.__regionsLoader?.data?.values ?? {});\n const regionOptions = regions.map(r => ({ rawLabel: r.default, value: r.code }));\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"group-one\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"name\"></foxy-internal-text-control>\n\n <foxy-internal-select-control\n options=${this.__typeOptions}\n layout=\"summary-item\"\n infer=\"type\"\n .setValue=${this.__typeSetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-switch-control infer=\"is-live\"></foxy-internal-switch-control>\n\n <foxy-internal-select-control\n options=${JSON.stringify(this.__serviceProviderOptions)}\n layout=\"summary-item\"\n infer=\"service-provider\"\n >\n </foxy-internal-select-control>\n\n <foxy-internal-number-control layout=\"summary-item\" suffix=\"%\" infer=\"rate\" min=\"0\">\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"native-integrations\"\n first=${ifDefined(this.__nativeIntegrationsUrl)}\n item=\"foxy-native-integration-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-summary-control infer=\"group-two\">\n <foxy-internal-switch-control infer=\"exempt-all-customer-tax-ids\">\n </foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"apply-to-shipping\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"use-origin-rates\"></foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"group-three\">\n <foxy-internal-select-control\n options=${JSON.stringify(countryOptions)}\n layout=\"summary-item\"\n infer=\"country\"\n .setValue=${this.__countrySetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-select-control\n property=\"region\"\n options=${JSON.stringify(regionOptions)}\n layout=\"summary-item\"\n infer=\"region-select\"\n .setValue=${this.__regionSetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-text-control\n property=\"region\"\n layout=\"summary-item\"\n infer=\"region-input\"\n .setValue=${this.__regionSetValue}\n >\n </foxy-internal-text-control>\n\n <foxy-internal-text-control layout=\"summary-item\" infer=\"city\"></foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-resource-link-list-control\n foreign-key-for-uri=\"item_category_uri\"\n foreign-key-for-id=\"item_category_id\"\n own-key-for-uri=\"tax_uri\"\n own-uri=${ifDefined(this.data?._links.self.href)}\n options-href=${ifDefined(this.itemCategories ?? undefined)}\n links-href=${ifDefined(this.data?._links['fx:tax_item_categories'].href)}\n embed-key=\"fx:tax_item_categories\"\n infer=\"item-categories\"\n limit=\"5\"\n item=\"foxy-item-category-card\"\n >\n </foxy-internal-async-resource-link-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n infer=\"\"\n class=\"hidden\"\n href=${ifDefined(this.countries ?? void 0)}\n id=\"countriesLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n class=\"hidden\"\n href=${ifDefined(this.__regionsUrl)}\n id=\"regionsLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __serviceProviderOptions() {\n const options = [\n { label: 'option_avalara', value: 'avalara' },\n { label: 'option_onesource', value: 'onesource' },\n ];\n\n if (\n this.form.type === 'union' ||\n !this.form.country ||\n defaultLiveRateCountries.includes(this.form.country)\n ) {\n options.unshift({ label: 'option_default', value: '' });\n }\n\n if (\n this.form.type === 'union' ||\n !this.form.country ||\n taxJarLiveRateCountries.includes(this.form.country)\n ) {\n options.push({ label: 'option_taxjar', value: 'taxjar' });\n }\n\n return options;\n }\n\n private get __nativeIntegrationsUrl() {\n try {\n const url = new URL(this.nativeIntegrations ?? '');\n const provider = this.form.service_provider;\n if (provider) {\n url.searchParams.set('provider', provider);\n return url.toString();\n }\n } catch {\n // do nothing\n }\n }\n\n private get __regionsUrl() {\n try {\n const regionsURL = new URL(this.regions ?? '');\n const country = this.form.country;\n if (country) regionsURL.searchParams.set('country_code', country);\n return regionsURL.toString();\n } catch {\n // do nothing\n }\n }\n\n private get __countriesLoader() {\n type Loader = NucleonElement<Resource<Rels.Countries>>;\n return this.renderRoot.querySelector<Loader>('#countriesLoader');\n }\n\n private get __regionsLoader() {\n type Loader = NucleonElement<Resource<Rels.Regions>>;\n return this.renderRoot.querySelector<Loader>('#regionsLoader');\n }\n\n private get __isExemptAllCustomerTaxIdsHidden() {\n const type = this.form.type as string | undefined;\n if (type === 'custom_tax_endpoint') return true;\n if (type === 'country' || type === 'region' || type === 'local') return !!this.form.is_live;\n\n const provider = this.form.service_provider as string | undefined;\n return !provider || provider === 'onesource' || provider === 'avalara' || provider === 'taxjar';\n }\n\n private get __isApplyToShippingHidden() {\n const type = this.form.type as string | undefined;\n\n if (!type || type === 'custom_tax_endpoint') return true;\n if (type === 'union') return false;\n if (type === 'country' && this.form.is_live) return true;\n if (type === 'region' && this.form.is_live) return true;\n\n return !!this.form.is_live && defaultLiveRateCountries.includes(this.form.country);\n }\n\n private get __isUseOriginRatesHidden() {\n return this.form.type !== 'union' || !this.form.is_live || !!this.form.service_provider;\n }\n\n private get __isCountryHidden() {\n if (this.form.type === 'union') {\n return (!this.form.service_provider || this.form.is_live) && !this.form.use_origin_rates;\n } else {\n return !(['country', 'region', 'local'] as unknown[]).includes(this.form.type);\n }\n }\n\n private get __isRegionHidden() {\n return this.form.type !== 'local' && this.form.type !== 'region';\n }\n\n private get __isCityHidden() {\n return this.form.type !== 'local';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TaxForm.js","sourceRoot":"","sources":["../../../../src/elements/public/TaxForm/TaxForm.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,UAAU,CAAC;AACtB,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD,kBAAkB;AAClB,MAAM,wBAAwB,GAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,E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,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrF,CAAC;IAED,IAAY,wBAAwB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAC1F,CAAC;IAED,IAAY,iBAAiB;QAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;YAC9B,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;SAC1F;aAAM;YACL,OAAO,CAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAChF;IACH,CAAC;IAED,IAAY,gBAAgB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IACnE,CAAC;IAED,IAAY,cAAc;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;IACpC,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'tax-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n// prettier-ignore\nconst defaultLiveRateCountries: (string | undefined)[] = ['US', 'CA', 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IM', 'IT', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'];\nconst taxJarLiveRateCountries = [...defaultLiveRateCountries, 'AU'];\n\n/**\n * Form element for creating or editing taxes (`fx:tax`).\n *\n * @element foxy-tax-form\n * @since 1.13.0\n */\nexport class TaxForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n nativeIntegrations: { attribute: 'native-integrations' },\n itemCategories: { attribute: 'item-categories' },\n countries: {},\n regions: {},\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ name: v }) => !!v || 'name:v8n_required',\n ({ name: v }) => !v || v.length <= 30 || 'name:v8n_too_long',\n ({ country: c, type: t }) => t !== 'country' || !!c || 'country:v8n_required',\n ({ country: c, type: t }) => t !== 'region' || !!c || 'country:v8n_required',\n ({ country: c, use_origin_rates: r }) => !r || !!c || 'country:v8n_required',\n ({ region: v, type: t }) => t != 'region' || !!v || 'region:v8n_required',\n ({ region: v }) => !v || v.length <= 20 || 'region:v8n_too_long',\n ({ city: v }) => !v || v.length <= 50 || 'city:v8n_too_long',\n ({ city: c, type: t }) => t != 'local' || !!c || 'city:v8n_required',\n ({ rate: v, type, is_live }) => {\n return (\n v === void 0 ||\n v > 0 ||\n // @ts-expect-error SDK types are not up to date.\n type === 'custom_tax_endpoint' ||\n type === void 0 ||\n is_live ||\n 'rate:v8n_invalid'\n );\n },\n ];\n }\n\n /** URL of the `fx:native_integrations` collection for the store. */\n nativeIntegrations: string | null = null;\n\n /** URL of the `fx:item_categories` collection for the store. */\n itemCategories: string | null = null;\n\n /** URL of the `fx:countries` property helper resource. */\n countries: string | null = null;\n\n /** URL of the `fx:regions` property helper resource. */\n regions: string | null = null;\n\n private __countrySetValue = (newValue: string) => {\n this.edit({ country: newValue, region: '', city: '' });\n this.edit({ apply_to_shipping: this.__isApplyToShippingHidden });\n };\n\n private __regionSetValue = (newValue: string) => {\n this.edit({ region: newValue, city: '' });\n };\n\n private __typeSetValue = (newValue: Data['type']) => {\n this.edit({\n type: newValue,\n country: '',\n region: '',\n city: '',\n // @ts-expect-error SDK types are not up to date.\n service_provider: newValue === 'custom_tax_endpoint' ? 'custom_tax' : '',\n apply_to_shipping: false,\n use_origin_rates: false,\n exempt_all_customer_tax_ids: false,\n is_live: false,\n rate: 0,\n });\n };\n\n private readonly __typeOptions = JSON.stringify([\n { label: 'option_custom_tax_endpoint', value: 'custom_tax_endpoint' },\n { label: 'option_global', value: 'global' },\n { label: 'option_union', value: 'union' },\n { label: 'option_country', value: 'country' },\n { label: 'option_region', value: 'region' },\n { label: 'option_local', value: 'local' },\n ]);\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.readonlySelector.toString()];\n alwaysMatch.unshift('native-integrations');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n const type = this.form.type as string | undefined;\n\n if (type === 'global' || type === 'custom_tax_endpoint') {\n alwaysMatch.unshift('group-one:is-live', 'group-one:service-provider');\n if (type === 'custom_tax_endpoint') alwaysMatch.unshift('group-one:rate');\n } else {\n if (this.form.is_live) {\n alwaysMatch.unshift('group-one:rate');\n } else {\n alwaysMatch.unshift('group-one:service-provider');\n }\n }\n\n if (this.__nativeIntegrationsUrl === void 0) alwaysMatch.unshift('native-integrations');\n if (this.__isCountryHidden) alwaysMatch.unshift('group-three:country');\n if (this.__isRegionHidden) {\n alwaysMatch.unshift('group-three:region-select', 'group-three:region-input');\n }\n\n if (this.__isCityHidden) alwaysMatch.unshift('group-three:city');\n if (this.__isApplyToShippingHidden) alwaysMatch.unshift('group-two:apply-to-shipping');\n if (this.__isUseOriginRatesHidden) alwaysMatch.unshift('group-two:use-origin-rates');\n if (this.__isExemptAllCustomerTaxIdsHidden) {\n alwaysMatch.unshift('group-two:exempt-all-customer-tax-ids');\n }\n\n const regions = Object.values(this.__regionsLoader?.data?.values ?? {});\n alwaysMatch.unshift(`group-three:region-${regions.length ? 'input' : 'select'}`);\n\n if (!this.data || !this.itemCategories) alwaysMatch.unshift('item-categories');\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n const countries = Object.values(this.__countriesLoader?.data?.values ?? {});\n const countryOptions = countries.map(c => ({ rawLabel: c.default, value: c.cc2 }));\n\n const regions = Object.values(this.__regionsLoader?.data?.values ?? {});\n const regionOptions = regions.map(r => ({ rawLabel: r.default, value: r.code }));\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"group-one\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"name\"></foxy-internal-text-control>\n\n <foxy-internal-select-control\n options=${this.__typeOptions}\n layout=\"summary-item\"\n infer=\"type\"\n .setValue=${this.__typeSetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-switch-control infer=\"is-live\"></foxy-internal-switch-control>\n\n <foxy-internal-select-control\n options=${JSON.stringify(this.__serviceProviderOptions)}\n layout=\"summary-item\"\n infer=\"service-provider\"\n >\n </foxy-internal-select-control>\n\n <foxy-internal-number-control layout=\"summary-item\" suffix=\"%\" infer=\"rate\" min=\"0\">\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"native-integrations\"\n first=${ifDefined(this.__nativeIntegrationsUrl)}\n item=\"foxy-native-integration-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-summary-control infer=\"group-two\">\n <foxy-internal-switch-control infer=\"exempt-all-customer-tax-ids\">\n </foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"apply-to-shipping\"></foxy-internal-switch-control>\n <foxy-internal-switch-control infer=\"use-origin-rates\"></foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"group-three\">\n <foxy-internal-select-control\n options=${JSON.stringify(countryOptions)}\n layout=\"summary-item\"\n infer=\"country\"\n .setValue=${this.__countrySetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-select-control\n property=\"region\"\n options=${JSON.stringify(regionOptions)}\n layout=\"summary-item\"\n infer=\"region-select\"\n .setValue=${this.__regionSetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-text-control\n property=\"region\"\n layout=\"summary-item\"\n infer=\"region-input\"\n .setValue=${this.__regionSetValue}\n >\n </foxy-internal-text-control>\n\n <foxy-internal-text-control layout=\"summary-item\" infer=\"city\"></foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-resource-link-list-control\n foreign-key-for-uri=\"item_category_uri\"\n foreign-key-for-id=\"item_category_id\"\n own-key-for-uri=\"tax_uri\"\n own-uri=${ifDefined(this.data?._links.self.href)}\n options-href=${ifDefined(this.itemCategories ?? undefined)}\n links-href=${ifDefined(this.data?._links['fx:tax_item_categories'].href)}\n embed-key=\"fx:tax_item_categories\"\n infer=\"item-categories\"\n limit=\"5\"\n item=\"foxy-item-category-card\"\n >\n </foxy-internal-async-resource-link-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n infer=\"\"\n class=\"hidden\"\n href=${ifDefined(this.countries ?? void 0)}\n id=\"countriesLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n class=\"hidden\"\n href=${ifDefined(this.__regionsUrl)}\n id=\"regionsLoader\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __serviceProviderOptions() {\n const options = [\n { label: 'option_avalara', value: 'avalara' },\n { label: 'option_onesource', value: 'onesource' },\n ];\n\n if (\n this.form.type === 'union' ||\n !this.form.country ||\n defaultLiveRateCountries.includes(this.form.country)\n ) {\n options.unshift({ label: 'option_default', value: '' });\n }\n\n if (\n this.form.type === 'union' ||\n !this.form.country ||\n taxJarLiveRateCountries.includes(this.form.country)\n ) {\n options.push({ label: 'option_taxjar', value: 'taxjar' });\n }\n\n return options;\n }\n\n private get __nativeIntegrationsUrl() {\n try {\n const url = new URL(this.nativeIntegrations ?? '');\n const provider = this.form.service_provider;\n if (provider) {\n url.searchParams.set('provider', provider);\n return url.toString();\n }\n } catch {\n // do nothing\n }\n }\n\n private get __regionsUrl() {\n try {\n const regionsURL = new URL(this.regions ?? '');\n const country = this.form.country;\n if (country) regionsURL.searchParams.set('country_code', country);\n return regionsURL.toString();\n } catch {\n // do nothing\n }\n }\n\n private get __countriesLoader() {\n type Loader = NucleonElement<Resource<Rels.Countries>>;\n return this.renderRoot.querySelector<Loader>('#countriesLoader');\n }\n\n private get __regionsLoader() {\n type Loader = NucleonElement<Resource<Rels.Regions>>;\n return this.renderRoot.querySelector<Loader>('#regionsLoader');\n }\n\n private get __isExemptAllCustomerTaxIdsHidden() {\n const provider = this.form.service_provider as string | undefined;\n const type = this.form.type as string | undefined;\n\n if (type === 'custom_tax_endpoint') return true;\n if (type === 'country' || type === 'region' || type === 'local' || type === 'union') {\n return !!this.form.is_live && (provider === 'onesource' || provider === 'avalara');\n }\n\n return false;\n }\n\n private get __isApplyToShippingHidden() {\n const type = this.form.type as string | undefined;\n\n if (!type || type === 'custom_tax_endpoint') return true;\n if (type === 'union') return false;\n if (type === 'country' && this.form.is_live) return true;\n if (type === 'region' && this.form.is_live) return true;\n\n return !!this.form.is_live && defaultLiveRateCountries.includes(this.form.country);\n }\n\n private get __isUseOriginRatesHidden() {\n return this.form.type !== 'union' || !this.form.is_live || !!this.form.service_provider;\n }\n\n private get __isCountryHidden() {\n if (this.form.type === 'union') {\n return (!this.form.service_provider || this.form.is_live) && !this.form.use_origin_rates;\n } else {\n return !(['country', 'region', 'local'] as unknown[]).includes(this.form.type);\n }\n }\n\n private get __isRegionHidden() {\n return this.form.type !== 'local' && this.form.type !== 'region';\n }\n\n private get __isCityHidden() {\n return this.form.type !== 'local';\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import"./shared-e2d3c014.js";import"./shared-dc4d2996.js";import{_ as e}from"./shared-cb58dfcd.js";import{s as l,h as t,c as a,L as s}from"./shared-ba5c42c7.js";import{T as n,O as o}from"./shared-8874ec69.js";import{o as r}from"./shared-63c32024.js";import{c as i}from"./shared-4e709717.js";import{i as d}from"./shared-53e42a77.js";import{a as u}from"./shared-79d0699c.js";import{r as c}from"./shared-5fd5805c.js";import{R as v,T as p,a as b}from"./shared-aa6dab90.js";import{I as h}from"./shared-2aa23b5f.js";import{C as f}from"./shared-5afb584d.js";let g;const m=l(g||(g=(e=>e)`
|
|
2
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<path d="M26.4 14.7399C26.4 15.2922 25.9523 15.7399 25.4 15.7399H10.6C10.0477 15.7399 9.60001 15.2922 9.60001 14.7399V14.2C9.60001 13.6477 10.0477 13.2 10.6 13.2H25.4C25.9523 13.2 26.4 13.6477 26.4 14.2V14.7399ZM26.4 21.8C26.4 22.3523 25.9523 22.8 25.4 22.8H10.6C10.0477 22.8 9.60001 22.3523 9.60001 21.8V21.2601C9.60001 20.7078 10.0477 20.2601 10.6 20.2601H25.4C25.9523 20.2601 26.4 20.7078 26.4 21.2601V21.8Z" class="fill-current"/>
|
|
4
|
-
</svg>
|
|
5
|
-
`));let C;const y=l(C||(C=(e=>e)`
|
|
6
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7
|
-
<path d="M12.8656 14.6695C12.3425 14.4581 12 13.9503 12 13.386C12 12.3748 13.0489 11.7048 13.9663 12.1299L23.8937 16.7295C24.5323 17.0254 24.941 17.6652 24.941 18.369C24.941 19.0735 24.5316 19.7137 23.8921 20.0092L13.971 24.5938C13.0509 25.019 12 24.347 12 23.3334C12 22.7709 12.3394 22.264 12.8594 22.0496L21.341 18.3046L12.8656 14.6695Z" class="fill-current"/>
|
|
8
|
-
</svg>
|
|
9
|
-
`));let x;const w=l(x||(x=(e=>e)`
|
|
10
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
11
|
-
<path d="M12.5 9.8C11.0088 9.8 9.8 11.0088 9.8 12.5V23.5C9.8 24.9912 11.0088 26.2 12.5 26.2H14C14.6627 26.2 15.2 25.6627 15.2 25C15.2 24.3373 14.6627 23.8 14 23.8H13.5C12.782 23.8 12.2 23.218 12.2 22.5V13.5C12.2 12.782 12.782 12.2 13.5 12.2H14C14.6627 12.2 15.2 11.6627 15.2 11C15.2 10.3373 14.6627 9.8 14 9.8H12.5Z" class="fill-current"/>
|
|
12
|
-
<path d="M22 9.8C21.3373 9.8 20.8 10.3373 20.8 11C20.8 11.6627 21.3373 12.2 22 12.2H22.5C23.218 12.2 23.8 12.782 23.8 13.5V22.5C23.8 23.218 23.218 23.8 22.5 23.8H22C21.3373 23.8 20.8 24.3373 20.8 25C20.8 25.6627 21.3373 26.2 22 26.2H23.5C24.9912 26.2 26.2 24.9912 26.2 23.5V12.5C26.2 11.0088 24.9912 9.8 23.5 9.8H22Z" class="fill-current"/>
|
|
13
|
-
</svg>
|
|
14
|
-
`));let V;const $=l(V||(V=(e=>e)`
|
|
15
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.05 23.58L20.04 23.59L17.64 21.19L18.7 20.13L20.05 21.48L22.54 19L23.6 20.06L20.06 23.6L20.05 23.58ZM18 8C12.5 8 8 12.5 8 18C8 23.5 12.5 28 18 28C23.5 28 28 23.5 28 18C28 12.5 23.5 8 18 8ZM13.34 12.28L14.75 13.69L16.16 12.28L17.22 13.34L15.81 14.75L17.22 16.16L16.16 17.22L14.75 15.81L13.34 17.22L12.28 16.16L13.69 14.75L12.28 13.34L13.34 12.28ZM18 26C15.8 26 13.8 25.1 12.3 23.7L23.7 12.3C25.1 13.8 26 15.8 26 18C26 22.4 22.4 26 18 26Z" class="fill-current"/>
|
|
17
|
-
</svg>
|
|
18
|
-
`));let H;const L=l(H||(H=(e=>e)`
|
|
19
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
20
|
-
<path d="M22.8754 22.054C23.3985 22.2655 23.741 22.7733 23.741 23.3375C23.741 24.3487 22.6922 25.0187 21.7747 24.5936L11.8473 19.994C11.2087 19.6981 10.8 19.0583 10.8 18.3545C10.8 17.65 11.2094 17.0098 11.8489 16.7143L21.7701 12.1297C22.6902 11.7045 23.741 12.3765 23.741 13.3902C23.741 13.9526 23.4017 14.4596 22.8816 14.6739L14.4 18.4189L22.8754 22.054Z" class="fill-current"/>
|
|
21
|
-
</svg>
|
|
22
|
-
`));let M;const Z=l(M||(M=(e=>e)`
|
|
23
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
24
|
-
<path d="M22.8754 19.654C23.3985 19.8655 23.741 20.3733 23.741 20.9375C23.741 21.9487 22.6922 22.6187 21.7747 22.1936L11.8473 17.594C11.2087 17.2981 10.8 16.6584 10.8 15.9545C10.8 15.25 11.2094 14.6098 11.8489 14.3143L21.7701 9.72971C22.6902 9.30453 23.741 9.97655 23.741 10.9902C23.741 11.5527 23.4017 12.0596 22.8816 12.2739L14.4 16.0189L22.8754 19.654Z" class="fill-current"/>
|
|
25
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.9169 20.9941C11.2134 20.3281 11.9937 20.0286 12.6597 20.3251L22.8548 24.8643C23.5208 25.1608 23.8203 25.9411 23.5238 26.6071C23.2273 27.2731 22.447 27.5726 21.781 27.2761L11.5859 22.7369C10.9199 22.4404 10.6204 21.6601 10.9169 20.9941Z" class="fill-current"/>
|
|
26
|
-
</svg>
|
|
27
|
-
`));let O;const I=l(O||(O=(e=>e)`
|
|
28
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.0049 7.11C24.6649 7.49107 24.8911 8.33507 24.51 8.99511L13.1621 28.6503C12.781 29.3103 11.937 29.5365 11.277 29.1554C10.6169 28.7743 10.3908 27.9303 10.7719 27.2703L22.1198 7.61511C22.5009 6.95507 23.3448 6.72892 24.0049 7.11Z" class="fill-current"/>
|
|
30
|
-
<path d="M17.5097 13.2H10.8C10.1373 13.2 9.60001 13.7373 9.60001 14.4V14.5399C9.60001 15.2026 10.1373 15.7399 10.8 15.7399H16.0433L17.5097 13.2Z" class="fill-current"/>
|
|
31
|
-
<path d="M13.4336 20.2601H10.8C10.1373 20.2601 9.60001 20.7973 9.60001 21.4601V21.6C9.60001 22.2627 10.1373 22.8 10.8 22.8H11.9671L13.4336 20.2601Z" class="fill-current"/>
|
|
32
|
-
<path d="M17.9254 22.8H25.2C25.8627 22.8 26.4 22.2627 26.4 21.6V21.4601C26.4 20.7973 25.8627 20.2601 25.2 20.2601H19.3918L17.9254 22.8Z" class="fill-current"/>
|
|
33
|
-
<path d="M22.0015 15.7399H25.2C25.8627 15.7399 26.4 15.2026 26.4 14.5399V14.4C26.4 13.7373 25.8627 13.2 25.2 13.2H23.468L22.0015 15.7399Z" class="fill-current"/>
|
|
34
|
-
</svg>
|
|
35
|
-
`));let j;const N=l(j||(j=(e=>e)`
|
|
36
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
37
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 8C12.48 8 8 12.48 8 18C8 23.52 12.48 28 18 28C23.52 28 28 23.52 28 18C28 12.48 23.52 8 18 8ZM18 26C13.59 26 10 22.41 10 18C10 13.59 13.59 10 18 10C22.41 10 26 13.59 26 18C26 22.41 22.41 26 18 26Z" class="fill-current"/>
|
|
38
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.49 17.38C19.92 16.16 19.66 14.74 18.68 13.76C17.57 12.65 15.89 12.46 14.58 13.17L16.93 15.52L15.52 16.93L13.17 14.58C12.46 15.9 12.65 17.57 13.76 18.68C14.74 19.66 16.16 19.92 17.38 19.49L20.79 22.9C20.99 23.1 21.3 23.1 21.5 22.9L22.9 21.5C23.1 21.3 23.1 20.99 22.9 20.79L19.49 17.38Z" class="fill-current"/>
|
|
39
|
-
</svg>
|
|
40
|
-
`));let A;const B=l(A||(A=(e=>e)`
|
|
41
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
42
|
-
<path d="M10 13V15C10 15.55 9.55 16 9 16H8V20H9C9.55 20 10 20.45 10 21V23C10 24.65 11.35 26 13 26H16V24H13C12.45 24 12 23.55 12 23V21C12 19.7 11.16 18.58 10 18.17V17.83C11.16 17.42 12 16.3 12 15V13C12 12.45 12.45 12 13 12H16V10H13C11.35 10 10 11.35 10 13Z" class="fill-current"/>
|
|
43
|
-
<path d="M27 16C26.45 16 26 15.55 26 15V13C26 11.35 24.65 10 23 10H20V12H23C23.55 12 24 12.45 24 13V15C24 16.3 24.84 17.42 26 17.83V18.17C24.84 18.58 24 19.69 24 21V23C24 23.55 23.55 24 23 24H20V26H23C24.65 26 26 24.65 26 23V21C26 20.45 26.45 20 27 20H28V16H27Z" class="fill-current"/>
|
|
44
|
-
</svg>
|
|
45
|
-
`));let T;const _=l(T||(T=(e=>e)`
|
|
46
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
-
<path d="M23.8333 17.0588H22.0833V11.7647H20.3333V10H23.8333V17.0588Z" class="fill-current"/>
|
|
48
|
-
<path d="M15.6667 10H12.1667C11.525 10 11 10.5294 11 11.1765V15.8824C11 16.5294 11.525 17.0588 12.1667 17.0588H15.6667C16.3083 17.0588 16.8333 16.5294 16.8333 15.8824V11.1765C16.8333 10.5294 16.3083 10 15.6667 10ZM15.0833 15.2941H12.75V11.7647H15.0833V15.2941Z" class="fill-current"/>
|
|
49
|
-
<path d="M15.6667 26.4706H13.9167V21.1765H12.1667V19.4118H15.6667V26.4706Z" class="fill-current"/>
|
|
50
|
-
<path d="M23.8333 19.4118H20.3333C19.6917 19.4118 19.1667 19.9412 19.1667 20.5882V25.2941C19.1667 25.9412 19.6917 26.4706 20.3333 26.4706H23.8333C24.475 26.4706 25 25.9412 25 25.2941V20.5882C25 19.9412 24.475 19.4118 23.8333 19.4118ZM23.25 24.7059H20.9167V21.1765H23.25V24.7059Z" class="fill-current"/>
|
|
51
|
-
</svg>
|
|
52
|
-
`));let D;const z=l(D||(D=(e=>e)`
|
|
53
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
54
|
-
<path d="M25 10H24V8H22V10H14V8H12V10H11C9.89 10 9.01 10.9 9.01 12L9 26C9 27.1 9.89 28 11 28H25C26.1 28 27 27.1 27 26V12C27 10.9 26.1 10 25 10ZM25 26H11V16H25V26ZM25 14H11V12H25V14ZM23 19H18V24H23V19Z" class="fill-current"/>
|
|
55
|
-
</svg>
|
|
56
|
-
`));let R;const S=l(R||(R=(e=>e)`
|
|
57
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
58
|
-
<path d="M26.5 16L27 14H23L24 10H22L21 14H17L18 10H16L15 14H11L10.5 16H14.5L13.5 20H9.5L9 22H13L12 26H14L15 22H19L18 26H20L21 22H25L25.5 20H21.5L22.5 16H26.5ZM19.5 20H15.5L16.5 16H20.5L19.5 20Z" class="fill-current"/>
|
|
59
|
-
</svg>
|
|
60
|
-
`));let k;const E=l(k||(k=(e=>e)`
|
|
61
|
-
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
62
|
-
<path d="M11 11V14H16.5V26H19.5V14H25V11H11Z" class="fill-current"/>
|
|
63
|
-
</svg>
|
|
64
|
-
`));let U,q,G,W,F,Q=e=>e;function J(e){var l,a,s;const n=null===(a=null===(l=e.list)||void 0===l?void 0:l.every((l=>l.value!==e.value)))||void 0===a||a;return t(U||(U=Q` <label class="${0}"> <div class="relative flex-1 min-w-0 overflow-hidden"> <select class="${0}" ?disabled="${0}" @change="${0}"> ${0} ${0} </select> </div> ${0} </label> `),i({"flex items-center transition-colors group text-tertiary":!0,"cursor-pointer hover-bg-contrast-5":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),i({"bg-transparent relative appearance-none flex h-m px-s":!0,"font-medium w-full max-w-full whitespace-nowrap focus-outline-none":!0,"text-tertiary":n&&!e.disabled,"text-body":!n&&!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":!n&&e.readonly,"cursor-pointer":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),e.disabled||e.readonly,(l=>{const t=l.currentTarget,a=t.options[t.options.selectedIndex].value;e.onChange(a)}),n?t(q||(q=Q` <option value="" disabled="disabled" ?selected="${0}">${0}</option> `),n,e.t(e.label)):"",null===(s=e.list)||void 0===s?void 0:s.map((({label:l,value:a})=>t(G||(G=Q` <option value="${0}" ?selected="${0}"> ${0} </option> `),a,a===e.value,e.t(l)))),n?"":t(W||(W=Q` <span class="${0}"> ${0} </span> ${0} `),i({"font-tnum text-xs font-medium border mr-s px-xs rounded-s border-current inline-block":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.clearable&&!e.readonly?t(F||(F=Q` <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="icon-inline text-l" icon="icons:remove-circle-outline"> </iron-icon> </button> `),e.t("delete"),i({"w-s h-s mr-xs flex items-center justify-center transition-colors rounded-full":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"hover-bg-contrast-5 hover-text-error text-body":!e.disabled,"text-disabled":e.disabled}),e.disabled,(()=>e.onChange(""))):""))}let K,P,X,Y,ee,le=e=>e;function te(e){var l;const a=`${null!==(l=e.id)&&void 0!==l?l:String(Math.floor(Math.random()*Math.pow(10,8)))}-list`,s=!!e.displayValue;let n=e.value;if("date"===e.type){const l=new Date(e.value);n=isNaN(l.getTime())?"":u(l)}return t(K||(K=le` <label class="relative flex items-center cursor-text group text-tertiary"> <div class="relative flex-1 min-w-0 overflow-hidden"> ${0} <input placeholder="${0}" class="${0}" list="${0}" type="${0}" max="${0}" .value="${0}" ?disabled="${0}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} ${0} </label> `),s?t(P||(P=le` <div aria-hidden="true" class="${0}"> <div class="truncate">${0}</div> </div> `),i({"absolute inset-0 h-m px-s font-medium flex items-center":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.displayValue)):"",n||"date"===e.type?"":e.t(e.label),i({"bg-base relative flex h-m px-s font-medium w-full":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly,"flex max-w-full whitespace-nowrap":!0,"focus-outline-none":!0,"opacity-0 focus-opacity-100":s}),d(e.list?a:void 0),"date"===e.type?"datetime-local":e.type,d("date"===e.type?"9999-12-31T23:59":""),n,e.disabled||e.readonly,(l=>{const t=l.currentTarget;let a=t.value;try{if("date"===e.type){const e=new Date(t.value);isNaN(e.getTime())||(a=e.toISOString())}}catch(e){}e.onChange(a)}),i({"font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s":!0,"inline-block":!!n||"date"===e.type,"sr-only":!n&&"date"!==e.type,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.list?t(X||(X=le` <datalist id="${0}"> ${0} </datalist> `),a,e.list.map((({label:l,value:a})=>t(Y||(Y=le`<option value="${0}">${0}</option>`),a,e.t(l))))):"",e.disabled||e.readonly?"":t(ee||(ee=le` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}let ae,se,ne=e=>e;let oe,re=e=>e;function ie({parsedValue:l,disabled:t,readonly:a,options:s,option:n,t:o,onChange:r}){return te({displayValue:null==n?void 0:n.label,disabled:t,readonly:a,value:l.path,label:"field",list:s.map((l=>e(e({},l),{},{value:l.path}))),type:"text",id:"path",t:o,onChange:e=>r({operator:null,value:"",path:e})})}let de,ue=e=>e;let ce,ve,pe=e=>e;function be(l){var a,s;const{parsedValue:d,isFullSize:u,isNested:v,readonly:p,disabled:b,options:h,t:f,onConvert:g,onDelete:C,onChange:x}=l,V=null!==(a=h.find((e=>e.path===d.path)))&&void 0!==a?a:null,H=null!==(s=null==V?void 0:V.type)&&void 0!==s?s:n.Any,M=d.operator,O={parsedValue:d,operators:l.operators,disabled:b,readonly:p,options:h,option:V,t:f,onChange:x},j={[n.Attribute]:B,[n.Boolean]:_,[n.Number]:S,[n.String]:E,[n.Date]:z,[n.Any]:N};return t(ce||(ce=pe` <div class="flex items-center space-x-s" aria-label="${0}"> <div class="${0}"> <div class="bg-contrast-10"> <div class="grid gap-1px grid-vertical sm-grid-horizontal"> <div class="bg-base" title="${0}"> <div class="${0}" aria-hidden="true"> ${0} </div> </div> <div class="bg-base"> ${0} </div> <div class="bg-base">${0}</div> <div class="bg-base"> ${0} </div> </div> </div> </div> <div class="${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:remove-circle-outline"> </iron-icon> </button> <button aria-label="${0}" class="${0}" ?disabled="${0}" ?hidden="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:add-circle-outline"> </iron-icon> </button> </div> </div> `),f("query_builder_rule"),i({"flex-1 bg-base rounded overflow-hidden border":!0,"border-contrast-10":!v&&!p,"border-contrast-50":!!v||p,"border-dashed":p,"border-solid":!p}),f(`type_${H}`),i({"w-m h-m":!0,"text-tertiary":!p&&!b,"text-disabled":p||b}),V?j[H]:N,d.path&&(H===n.Attribute||d.name)?t(ve||(ve=pe` <div class="bg-contrast-10 grid gap-1px grid-cols-1 sm-grid-cols-2"> <div class="bg-base">${0}</div> <div class="bg-base">${0}</div> </div> `),ie(O),function(l){var t;return te({disabled:l.disabled,readonly:l.readonly,value:null!==(t=l.parsedValue.name)&&void 0!==t?t:"",label:"name",type:"text",t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{name:t}))})}(O)):ie(O),function(l){const a=l.parsedValue.operator,s={[o.GreaterThan]:y,[o.GreaterThanOrEqual]:r,[o.In]:w,[o.IsDefined]:$,[o.LessThan]:L,[o.LessThanOrEqual]:Z,[o.Not]:I},d={[n.Attribute]:[o.In,o.Not,o.IsDefined],[n.Boolean]:[],[n.String]:[o.In,o.Not],[n.Number]:[o.In,o.Not,o.GreaterThan,o.LessThan,o.GreaterThanOrEqual,o.LessThanOrEqual],[n.Date]:[o.In,o.Not],[n.Any]:Object.values(o)},u=(l.option?d[l.option.type]:l.parsedValue.name?Object.values(o):Object.values(o).filter((e=>e!==o.IsDefined))).filter((e=>l.operators.includes(e))),c=l.disabled||l.readonly||0===u.length||!l.parsedValue.path;return t(oe||(oe=re` <button title="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div aria-hidden="true">${0}</div> </button> `),l.t(`operator_${null!=a?a:"equal"}`),i({"flex items-center justify-center w-m h-m transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50":!0,"text-body hover-bg-contrast-5":!c&&u.length>1,"cursor-default text-tertiary":!c&&u.length<=1,"text-disabled cursor-default":c}),c||u.length<=1,(()=>{var t;const s=a?u.indexOf(a):-1,n=null!==(t=u[s+1])&&void 0!==t?t:null;l.onChange(e(e({},l.parsedValue),{},{operator:n,value:l.parsedValue.value}))}),a?s[a]:m)}(O),M===o.In?function(l){var a,s,o,r;const i=(null===(a=l.option)||void 0===a?void 0:a.list)?J:te,d=l.parsedValue.value.split(","),u=null!==(o=null===(s=l.option)||void 0===s?void 0:s.type)&&void 0!==o?o:n.Any,v=u===n.Number?"number":u===n.Date?"date":"text",p=null===(r=l.option)||void 0===r?void 0:r.list,b=[...d.filter((e=>!!e))];return l.readonly||b.push(null),t(ae||(ae=ne` <div class="bg-contrast-10 grid grid-cols-1 gap-1px"> ${0} </div> `),c(b,((e,l)=>l),((a,s)=>{var n;return t(se||(se=ne` <div class="bg-base"> ${0} </div> `),i({type:v,list:p,t:l.t,value:null!=a?a:"",label:a?String(s+1):"add_value",disabled:l.disabled,readonly:l.readonly,clearable:!0,displayValue:null===(n=null==p?void 0:p.find((e=>e.value===a)))||void 0===n?void 0:n.label,onChange:t=>{t?d[s]=t:d.splice(s,1),l.onChange(e(e({},l.parsedValue),{},{value:d.join(",")}))}}))})))}(O):M===o.IsDefined?function(l){return J({readonly:l.readonly,disabled:l.disabled,value:l.parsedValue.value,label:"value",list:[{label:"is_defined_true",value:"true"},{label:"is_defined_false",value:"false"}],t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{value:t}))})}(O):H===n.Boolean?function(l){var t,a,s,n,o,r;const{parsedValue:i,option:d,readonly:u,disabled:c,t:v,onChange:p}=l,b=null!==(s=null===(a=null===(t=null==d?void 0:d.list)||void 0===t?void 0:t.find((e=>"false"===e.value)))||void 0===a?void 0:a.label)&&void 0!==s?s:"false",h=[{label:null!==(r=null===(o=null===(n=null==d?void 0:d.list)||void 0===n?void 0:n.find((e=>"true"===e.value)))||void 0===o?void 0:o.label)&&void 0!==r?r:"true",value:"true"},{label:b,value:"false"}];return J({disabled:c,readonly:u,value:i.value,label:"value",list:h,t:v,onChange:l=>p(e(e({},i),{},{value:l}))})}(O):null===M&&[n.Number,n.Date].includes(H)?function(l){var a,s,o;const{t:r,parsedValue:i,option:d,readonly:u,disabled:c,onChange:v}=l,p=i.value.split(".."),b=p.length>=1?p[0]:"",h=p.length>=2?p[1]:"",f=(null==d?void 0:d.list)?J:te,g=null!==(a=null==d?void 0:d.type)&&void 0!==a?a:n.Any,m=g===n.Number?"number":g===n.Date?"date":"text",C=null==d?void 0:d.list;return t(de||(de=ue` <div class="grid bg-contrast-10 gap-1px grid-cols-1 grid-rows-2 sm-grid-cols-2 sm-grid-rows-1"> <div class="bg-base"> ${0} </div> <div class="bg-base"> ${0} </div> </div> `),f({displayValue:null===(s=null==C?void 0:C.find((e=>e.value===b)))||void 0===s?void 0:s.label,readonly:u,disabled:c,value:b,label:"range_from",type:m,list:C,t:r,onChange:l=>v(e(e({},i),{},{value:`${l}..${h}`}))}),f({displayValue:null===(o=null==C?void 0:C.find((e=>e.value===h)))||void 0===o?void 0:o.label,readonly:u,disabled:c,label:"range_to",value:h,type:m,list:C,t:r,onChange:l=>v(e(e({},i),{},{value:`${b}..${l}`}))}))}(O):function(l){var t,a,s,o;const{t:r,option:i,parsedValue:d,readonly:u,disabled:c,onChange:v}=l,p=(null==i?void 0:i.list)?J:te,b=null!==(t=null==i?void 0:i.type)&&void 0!==t?t:n.Any;return p({displayValue:null===(s=null===(a=null==i?void 0:i.list)||void 0===a?void 0:a.find((e=>e.value===d.value)))||void 0===s?void 0:s.label,readonly:u,disabled:c||!d.path,value:null!==(o=d.value)&&void 0!==o?o:"",label:"value",type:b===n.Number?"number":b===n.Date?"date":"text",list:null==i?void 0:i.list,t:r,onChange:l=>v(e(e({},d),{},{value:l}))})}(O),i({"-mr-s self-start flex-col sm-flex-row flex-shrink-0 items-center":!0,"border-t border-b border-transparent divide-y divide-transparent":!0,hidden:!!u||p,flex:!u}),f("delete"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!d.path}),b||p||!d.path,C,f("add_or_clause"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-success hover-bg-contrast-5":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!d.path||!!v||l.disableOr}),b||p||!d.path||!!v||l.disableOr,l.disableOr,g)}let he,fe,ge,me,Ce=e=>e;function ye(l){const a=l.parsedValues.some((e=>Array.isArray(e))),s=t(he||(he=Ce`<div class="${0}"></div>`),a?"h-xs":"mt-s"),n=t(fe||(fe=Ce` <div class="flex items-center h-s"> <div class="w-m text-center leading-none uppercase font-medium text-xs text-contrast-30"> ${0} </div> <div class="flex-1 border-t border-contrast-20"></div> <div class="w-m ml-s flex-shrink-0"></div> <div class="hidden sm-block w-m flex-shrink-0"></div> </div> `),l.t("or"));return t(ge||(ge=Ce` <div aria-label="${0}"> ${0} </div> `),l.t("query_builder_group"),c([...l.parsedValues,null],((e,l)=>String(l)),((a,o)=>{const r=o>0?l.isNested?n:s:"";return null===a?[r,be({operators:l.operators,disableOr:l.disableOr,isFullSize:!l.isNested&&0===l.parsedValues.length,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,parsedValue:{path:"",operator:null,value:""},t:l.t,onChange:e=>l.onChange([...l.parsedValues,e])})]:Array.isArray(a)?[r,t(me||(me=Ce` <div class="bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s"> ${0} </div> `),ye({parsedValues:a,disableOr:l.disableOr,operators:l.operators,isNested:!0,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues],a=e;t[o]=e.length>1?a:a[0],l.onChange(t)}}))]:[r,be({parsedValue:a,disableOr:l.disableOr,operators:l.operators,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues];t[o]=e,l.onChange(t)},onDelete:()=>{const e=l.parsedValues.filter(((e,l)=>l!==o));l.onChange(e)},onConvert:()=>{const t=[...l.parsedValues];t[o]=[a,e(e({},a),{},{operator:null,value:""})],l.onChange(t)}})]})))}function xe(e){var l;const t=e.indexOf("="),a=decodeURIComponent(e.substring(0,t)),s=decodeURIComponent(e.substring(t+1)),n=null!==(l=Object.values(o).find((e=>a.endsWith(`:${e}`))))&&void 0!==l?l:null;let r,i=a.substring(0,n?a.lastIndexOf(":"):void 0);const d=a.lastIndexOf("[");return i.endsWith("]")&&-1!==d&&(r=i.substring(d+1,i.length-1),i=i.substring(0,d),i.endsWith(":name")&&(i=i.substring(0,i.length-5))),{name:r,path:i,value:s,operator:n}}function we(e){return e.split("&").filter((e=>!!e)).map((e=>{const[l,t]=e.split("=").map(decodeURIComponent);return(null==t?void 0:t.includes("|"))?`${encodeURIComponent(l)}=${t}`.split("|").map((e=>xe(e))):xe(e)}))}function Ve(e){let l=e.path;return e.name&&(l+=`:name[${e.name}]`),e.operator&&(l+=`:${e.operator}`),l=`${encodeURIComponent(l)}=${encodeURIComponent(e.value)}`,"="===l?"":l}function $e(e,l=!1){const t=e.reduce(((e,l)=>{if(Array.isArray(l)){let t=l[0].path;l[0].name&&(t+=`:name[${l[0].name}]`),l[0].operator&&(t+=`:${l[0].operator}`);const a=[l[0].value,...l.slice(1).map((e=>decodeURIComponent(Ve(e))))];e.push(`${encodeURIComponent(t)}=${encodeURIComponent(a.join("|"))}`)}else"zoom"!==l.path&&e.push(Ve(l));return e}),[]);if(!l){const l=He(e).join(",");l&&t.push(`zoom=${encodeURIComponent(l)}`)}return t.join("&")}function He(e){return e.map((e=>{if(Array.isArray(e))return He(e);if(e.name)return[e.path];const l=e.path.split(":");return l.slice(0,l.length-1)})).flat().sort(((e,l)=>l.length-e.length)).filter(((e,l,t)=>t.every(((t,a)=>(a>=l||t!==e)&&!t.startsWith(`${e}:`)))))}let Le;const Me=a(Le||(Le=(e=>e)`.gap-1px{gap:1px}.grid-vertical{grid-template:auto/var(--lumo-size-m) 1fr}:host([sm]) .sm-grid-horizontal{grid-template:auto/var(--lumo-size-m) 1fr var(--lumo-size-m) 1fr}`)),Ze=f(v(p(b(h(s),"query-builder"))));class Oe extends Ze{constructor(){super(...arguments),this.disableZoom=!1,this.disableOr=!1,this.operators=Object.values(o),this.options=null,this.value=null}static get properties(){return e(e({},super.properties),{},{disableZoom:{type:Boolean,attribute:"disable-zoom"},disableOr:{type:Boolean,attribute:"disable-or"},operators:{type:Array},options:{type:Array},value:{type:String}})}static get styles(){return[super.styles,Me]}render(){var e,l,t;const a=new Set(["zoom","limit","offset","order","fields"]),s=[],n=[];return we(null!==(e=this.value)&&void 0!==e?e:"").forEach((e=>{Array.isArray(e)||!a.has(e.path)?n.push(e):s.push(e)})),ye({parsedValues:n,disableOr:this.disableOr,operators:null!==(l=this.operators)&&void 0!==l?l:[],disabled:this.disabled,readonly:this.readonly,options:null!==(t=this.options)&&void 0!==t?t:[],t:this.t.bind(this),onChange:e=>{this.value=$e([...e,...s],this.disableZoom),this.dispatchEvent(new Oe.ChangeEvent("change"))}})}}Oe.ChangeEvent=class extends CustomEvent{},Oe.Operator=o,Oe.Type=n,customElements.define("foxy-query-builder",Oe);export{Oe as Q,we as p,$e as s};
|