@foxy.io/elements 1.52.0 → 1.53.0-beta.1
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-cart-form.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/shared-ba230a1b.js +1 -0
- package/dist/cdn/shared-dd722e70.js +40 -0
- package/dist/elements/public/QueryBuilder/QueryBuilder.d.ts +3 -3
- package/dist/elements/public/QueryBuilder/QueryBuilder.js +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/AdvancedGroup.d.ts +2 -2
- package/dist/elements/public/QueryBuilder/components/AdvancedGroup.js +4 -0
- package/dist/elements/public/QueryBuilder/components/AdvancedGroup.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/AdvancedOperatorToggle.js +3 -3
- package/dist/elements/public/QueryBuilder/components/AdvancedOperatorToggle.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleGroup.js +2 -0
- package/dist/elements/public/QueryBuilder/components/SimpleGroup.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleInput.js +7 -1
- package/dist/elements/public/QueryBuilder/components/SimpleInput.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleNameValuePairRule.d.ts +2 -0
- package/dist/elements/public/QueryBuilder/components/SimpleNameValuePairRule.js +78 -0
- package/dist/elements/public/QueryBuilder/components/SimpleNameValuePairRule.js.map +1 -0
- package/dist/elements/public/QueryBuilder/types.d.ts +5 -0
- package/dist/elements/public/QueryBuilder/types.js +1 -0
- package/dist/elements/public/QueryBuilder/types.js.map +1 -1
- package/package.json +2 -2
- package/dist/cdn/shared-79dd8c55.js +0 -40
- package/dist/cdn/shared-8874ec69.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./shared-1dfc1e37.js";import"./shared-61ddd174.js";import"./shared-da31cee5.js";import"./shared-6bb9a580.js";import"./shared-54f824d8.js";import"./shared-c57aac01.js";import{I as e}from"./shared-4da1f187.js";import"./foxy-applied-coupon-code-card.js";import"./foxy-applied-coupon-code-form.js";import"./foxy-custom-field-card.js";import"./foxy-custom-field-form.js";import"./foxy-template-set-card.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./foxy-item-form.js";import"./shared-9b35fe34.js";import{a as t,I as r}from"./shared-ec6a369a.js";import{_ as o,B as i}from"./shared-8f9014ff.js";import{c as s}from"./shared-4e709717.js";import{h as n,c as a}from"./shared-ba5c42c7.js";import"./shared-515003f6.js";import{R as l,a as d}from"./shared-887ac0b0.js";import{i as c}from"./shared-53e42a77.js";import"./foxy-update-payment-method-form.js";import{U as u}from"./shared-cd96ff03.js";import{s as m}from"./shared-53e476fd.js";import"./shared-3426159a.js";import{g as p}from"./shared-bab2ea2c.js";import{T as _}from"./shared-bbd07437.js";import{T as f}from"./shared-
|
|
1
|
+
import"./shared-1dfc1e37.js";import"./shared-61ddd174.js";import"./shared-da31cee5.js";import"./shared-6bb9a580.js";import"./shared-54f824d8.js";import"./shared-c57aac01.js";import{I as e}from"./shared-4da1f187.js";import"./foxy-applied-coupon-code-card.js";import"./foxy-applied-coupon-code-form.js";import"./foxy-custom-field-card.js";import"./foxy-custom-field-form.js";import"./foxy-template-set-card.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./foxy-item-form.js";import"./shared-9b35fe34.js";import{a as t,I as r}from"./shared-ec6a369a.js";import{_ as o,B as i}from"./shared-8f9014ff.js";import{c as s}from"./shared-4e709717.js";import{h as n,c as a}from"./shared-ba5c42c7.js";import"./shared-515003f6.js";import{R as l,a as d}from"./shared-887ac0b0.js";import{i as c}from"./shared-53e42a77.js";import"./foxy-update-payment-method-form.js";import{U as u}from"./shared-cd96ff03.js";import{s as m}from"./shared-53e476fd.js";import"./shared-3426159a.js";import{g as p}from"./shared-bab2ea2c.js";import{T as _}from"./shared-bbd07437.js";import{T as f}from"./shared-ba230a1b.js";import"./foxy-copy-to-clipboard.js";import"./shared-9687ab7b.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-99c53365.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-0f92b865.js";import"./shared-19073761.js";import"./shared-41c9c53f.js";import"./shared-930e68b7.js";import"./foxy-form-dialog.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-69c98b7b.js";import"./shared-2b39e4d4.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-65094878.js";import"./shared-a20ef119.js";import"./shared-b5e048f5.js";import"./shared-9a3bf65c.js";import"./shared-7892fd3f.js";import"./shared-a5d6db21.js";import"./shared-a0baefff.js";import"./shared-f8e360e6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-5fd5805c.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-fda3270b.js";import"./shared-8df8e77c.js";import"./shared-5212ef4f.js";import"./shared-d0aed1c1.js";import"./shared-b2f675d4.js";import"./shared-2559d303.js";import"./shared-17c9e095.js";import"./shared-d2b3205f.js";import"./shared-b1fa9899.js";import"./shared-c84333db.js";import"./shared-5ad5e258.js";import"./shared-b0ff4acd.js";import"./shared-a0309d5f.js";import"./shared-9109ae93.js";import"./shared-377cce47.js";import"./shared-b948488a.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-category-card.js";import"./foxy-discount-builder.js";import"./shared-63c32024.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./foxy-payment-card-embed.js";import"./shared-80950330.js";import"./shared-7f7d6ceb.js";import"./shared-11de7969.js";let h,y,v=e=>e;customElements.define("foxy-internal-cart-form-create-session-action",class extends t{constructor(){super(...arguments),this.__loader=null}static get properties(){return o(o({},super.properties),{},{__loader:{attribute:!1}})}renderControl(){var e,t;const r=null===(e=this.__loader)||void 0===e?void 0:e.state,o=null===(t=this.__loader)||void 0===t?void 0:t.result;return o?n(h||(h=v` <a target="_blank" class="rounded font-medium transition-colors text-body focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n infer="" key="state_idle"></foxy-i18n> </a> `),o):n(y||(y=v` <div class="${0}"> <foxy-i18n infer="" key="${0}"> </foxy-i18n> </div> `),s({"transition-colors font-medium rounded":!0,"text-tertiary":"fail"!==r,"text-error":"fail"===r}),"fail"===r?"state_fail":"state_busy")}updated(e){var t;super.updated(e);const r=this.nucleon,o=null==r?void 0:r.data,i=null!==(t=null==o?void 0:o._links["fx:create_session"].href)&&void 0!==t?t:null;this.__reloadSessionHref(i)}async __reloadSessionHref(e){var t;if((null===(t=this.__loader)||void 0===t?void 0:t.href)===e)return;const r=this.nucleon;if(r)if(e){const t={result:null,state:"busy",href:e},o=new r.constructor.API(this);this.__loader=t;try{const r=await o.fetch(e,{method:"POST"});if(!r.ok)throw new Error;t.result=(await r.json()).cart_link,t.state="idle"}catch(e){t.state="fail"}finally{this.requestUpdate()}}else this.__loader=null}});let g;const x=a(g||(g=(e=>e)`
|
|
2
2
|
#dialog{
|
|
3
3
|
width:100dvw;
|
|
4
4
|
max-height:calc(100dvh - var(--lumo-space-m));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-e6804126.js";import"./shared-49558171.js";import"./shared-d9f83737.js";import{I as e}from"./shared-ec6a369a.js";import{p as t,s as r}from"./shared-79dd8c55.js";import{_ as o,B as s}from"./shared-8f9014ff.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-9b35fe34.js";import{R as c,a as u}from"./shared-887ac0b0.js";import{c as m}from"./shared-4e709717.js";import{r as p}from"./shared-5fd5805c.js";import"./shared-da31cee5.js";import"./shared-6bb9a580.js";import"./shared-fda3270b.js";import"./shared-c57aac01.js";import"./shared-9109ae93.js";import{I as f}from"./shared-4da1f187.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-65094878.js";import"./shared-99c53365.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-515003f6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-19073761.js";import"./shared-930e68b7.js";import"./shared-41c9c53f.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-54f824d8.js";import"./shared-a20ef119.js";import"./shared-b5e048f5.js";import"./shared-9a3bf65c.js";import"./shared-7892fd3f.js";import"./shared-a5d6db21.js";import"./shared-a0baefff.js";import"./shared-f8e360e6.js";import"./shared-5212ef4f.js";import"./shared-8df8e77c.js";import"./foxy-form-dialog.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-9687ab7b.js";import"./shared-0f92b865.js";import"./shared-d0aed1c1.js";import"./shared-63c32024.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./shared-377cce47.js";import"./shared-b948488a.js";import"./shared-bab2ea2c.js";import"./shared-17c9e095.js";import"./shared-bbd07437.js";import"./shared-b2f675d4.js";import"./shared-3426159a.js";import"./shared-61ddd174.js";import"./foxy-swipe-actions.js";import"./foxy-admin-transaction-card.js";import"./shared-d2b3205f.js";let y,_,b,x,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(b||(b=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(x||(x=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(",").map((e=>e.trim())).filter((e=>e.length>0)).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:"option_code",path:"code",type:n.String},{label:"option_number_of_uses_to_date",path:"number_of_uses_to_date",type:n.Number},{label:"option_date_created",path:"date_created",type:n.Date},{label:"option_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-e6804126.js";import"./shared-49558171.js";import"./shared-d9f83737.js";import{I as e}from"./shared-ec6a369a.js";import{p as t,s as r}from"./shared-dd722e70.js";import{_ as o,B as s}from"./shared-8f9014ff.js";import{O as i,T as n}from"./shared-ba230a1b.js";import{h as a,c as l,s as d}from"./shared-ba5c42c7.js";import"./shared-9b35fe34.js";import{R as c,a as u}from"./shared-887ac0b0.js";import{c as m}from"./shared-4e709717.js";import{r as p}from"./shared-5fd5805c.js";import"./shared-da31cee5.js";import"./shared-6bb9a580.js";import"./shared-fda3270b.js";import"./shared-c57aac01.js";import"./shared-9109ae93.js";import{I as f}from"./shared-4da1f187.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-65094878.js";import"./shared-99c53365.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-515003f6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-19073761.js";import"./shared-930e68b7.js";import"./shared-41c9c53f.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-54f824d8.js";import"./shared-a20ef119.js";import"./shared-b5e048f5.js";import"./shared-9a3bf65c.js";import"./shared-7892fd3f.js";import"./shared-a5d6db21.js";import"./shared-a0baefff.js";import"./shared-f8e360e6.js";import"./shared-5212ef4f.js";import"./shared-8df8e77c.js";import"./foxy-form-dialog.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-9687ab7b.js";import"./shared-0f92b865.js";import"./shared-d0aed1c1.js";import"./shared-63c32024.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./shared-377cce47.js";import"./shared-b948488a.js";import"./shared-bab2ea2c.js";import"./shared-17c9e095.js";import"./shared-bbd07437.js";import"./shared-b2f675d4.js";import"./shared-3426159a.js";import"./shared-61ddd174.js";import"./foxy-swipe-actions.js";import"./foxy-admin-transaction-card.js";import"./shared-d2b3205f.js";let y,_,b,x,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(b||(b=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(x||(x=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(",").map((e=>e.trim())).filter((e=>e.length>0)).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:"option_code",path:"code",type:n.String},{label:"option_number_of_uses_to_date",path:"number_of_uses_to_date",type:n.Number},{label:"option_date_created",path:"date_created",type:n.Date},{label:"option_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"./shared-515003f6.js";import{I as t}from"./shared-4da1f187.js";import"./shared-
|
|
1
|
+
import"./shared-515003f6.js";import{I as t}from"./shared-4da1f187.js";import"./shared-dd722e70.js";import"./shared-9b35fe34.js";import{_ as e}from"./shared-8f9014ff.js";import{a as r}from"./shared-887ac0b0.js";import{d as s,e as i}from"./shared-c84333db.js";import{i as a}from"./shared-53e42a77.js";import{h as o}from"./shared-ba5c42c7.js";import"./shared-99c53365.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-ec6a369a.js";import"./shared-5212ef4f.js";import"./shared-41c9c53f.js";import"./shared-930e68b7.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-4e709717.js";import"./foxy-copy-to-clipboard.js";import"./shared-9687ab7b.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-0f92b865.js";import"./shared-19073761.js";import"./foxy-spinner.js";import"./shared-bab2ea2c.js";import"./shared-da31cee5.js";import"./shared-ba230a1b.js";import"./shared-63c32024.js";import"./shared-5fd5805c.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";let d,n,l,h,m,u=t=>t;const c=r(t,"filter-attribute-form");class f extends c{constructor(){super(...arguments),this.defaults=null,this.pathname=null,this.docsHref=null,this.options=[],this.__filterNameGetValue=()=>{const t=this.constructor;return this.__getValueParam(t.filterNameKey)},this.__filterNameSetValue=t=>{const e=this.constructor;this.__setValueParam(e.filterNameKey,t)}}static get properties(){return e(e({},super.properties),{},{defaults:{},pathname:{},docsHref:{attribute:"docs-href"},options:{type:Array}})}renderBody(){var t;const e=this.constructor,r=this.__getValueParam(e.filterQueryKey),s=!!this.form.value,i=!!this.data,c=this.in({idle:{snapshot:"dirty"}})||this.in({idle:{template:"dirty"}});return o(d||(d=u` <div class="flex gap-s"> ${0} ${0} ${0} </div> <foxy-query-builder docs-href="${0}" options="${0}" infer="filter-query" value="${0}" disable-zoom @change="${0}"> </foxy-query-builder> `),this.data?o(n||(n=u` <div class="flex-1 rounded bg-contrast-5 transition-colors hover-bg-contrast-10 focus-within-bg-contrast-10 focus-within-ring-2 focus-within-ring-primary-50"> <input placeholder="${0}" aria-label="${0}" style="padding:0 calc(.625 * var(--lumo-font-size-m) + (var(--lumo-border-radius)/ 4) - 1px)" class="block w-full h-full appearance-none bg-transparent text-xl font-medium focus-outline-none" .value="${0}" @keydown="${0}" @input="${0}"> </div> `),this.t("filter-name.placeholder"),this.t("filter-name.label"),this.__filterNameGetValue(),(t=>{"Enter"===t.key&&(t.preventDefault(),this.submit())}),(t=>{this.__filterNameSetValue(t.target.value)})):o(l||(l=u` <foxy-i18n class="text-xl flex-1 font-medium" infer="header" key="title"></foxy-i18n> `)),c?o(h||(h=u` <vaadin-button theme="secondary contrast" style="${0}" ?disabled="${0}" @click="${0}"> <foxy-i18n infer="action" class="px-s" key="reset"></foxy-i18n> </vaadin-button> `),a(i?void 0:"--lumo-button-size: auto"),this.disabled,(()=>this.undo())):"",s&&(r||i)?o(m||(m=u` <vaadin-button theme="${0}" style="${0}" ?disabled="${0}" @click="${0}"> <foxy-i18n infer="action" class="px-s" key="${0}"> </foxy-i18n> </vaadin-button> `),i?c?"secondary":"error":"success",a(i?void 0:"--lumo-button-size: auto"),this.disabled,(()=>!i||c?this.submit():this.delete()),i?c?"update":"delete":"create"):"",a(null!==(t=this.docsHref)&&void 0!==t?t:void 0),JSON.stringify(this.options),r,this.__handleFilterQueryChange)}updated(t){var e;if(super.updated(t),"string"==typeof this.form.value){const t=new URL(s(this.form.value),"https://example.com");t.pathname=null!==(e=this.pathname)&&void 0!==e?e:"";const r=i(t.toString().substring(t.origin.length));r!==this.form.value&&this.edit({value:r})}}submit(){const t=this.constructor;this.edit({visibility:t.attributeVisibility,name:t.attributeName}),super.submit()}__getValueParam(t){var e,r,i;try{const a=this.constructor;let o=null!==(r=new URL(s(null!==(e=this.form.value)&&void 0!==e?e:""),"https://example.com").searchParams.get(t))&&void 0!==r?r:"";if(t===a.filterQueryKey&&(this.in({idle:{snapshot:"clean"}})||this.in({idle:{template:"clean"}})))try{const t=new URLSearchParams(o),e=new URLSearchParams(null!==(i=this.defaults)&&void 0!==i?i:"");t.forEach(((t,r)=>e.set(r,t))),o=e.toString()}catch(t){}return o}catch(t){return""}}__setValueParam(t,e){var r;try{const a=new URL(s(null!==(r=this.form.value)&&void 0!==r?r:""),"https://example.com");a.searchParams.set(t,e),this.edit({value:i(a.toString().substring(a.origin.length))})}catch(t){}}__handleFilterQueryChange(t){var e;const r=this.constructor,s=t.currentTarget;this.__setValueParam(r.filterQueryKey,null!==(e=s.value)&&void 0!==e?e:""),this.requestUpdate()}}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-1dfc1e37.js";import"./shared-61ddd174.js";import"./shared-da31cee5.js";import"./shared-fda3270b.js";import"./shared-9109ae93.js";import"./shared-c57aac01.js";import{I as e}from"./shared-4da1f187.js";import"./foxy-gift-card-code-log-card.js";import"./foxy-nucleon-element.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import{_ as t,B as r}from"./shared-8f9014ff.js";import{g as o}from"./shared-bab2ea2c.js";import{a as s}from"./shared-887ac0b0.js";import{T as a}from"./shared-
|
|
1
|
+
import"./shared-1dfc1e37.js";import"./shared-61ddd174.js";import"./shared-da31cee5.js";import"./shared-fda3270b.js";import"./shared-9109ae93.js";import"./shared-c57aac01.js";import{I as e}from"./shared-4da1f187.js";import"./foxy-gift-card-code-log-card.js";import"./foxy-nucleon-element.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import{_ as t,B as r}from"./shared-8f9014ff.js";import{g as o}from"./shared-bab2ea2c.js";import{a as s}from"./shared-887ac0b0.js";import{T as a}from"./shared-ba230a1b.js";import{i}from"./shared-53e42a77.js";import{h as d}from"./shared-ba5c42c7.js";import"./shared-515003f6.js";import"./shared-99c53365.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-ec6a369a.js";import"./shared-5212ef4f.js";import"./shared-9b35fe34.js";import"./shared-930e68b7.js";import"./shared-41c9c53f.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./foxy-copy-to-clipboard.js";import"./shared-9687ab7b.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-0f92b865.js";import"./shared-19073761.js";import"./shared-4e709717.js";import"./foxy-form-dialog.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-53e476fd.js";import"./shared-65094878.js";import"./shared-a20ef119.js";import"./shared-b5e048f5.js";import"./shared-9a3bf65c.js";import"./shared-7892fd3f.js";import"./shared-a5d6db21.js";import"./shared-a0baefff.js";import"./shared-f8e360e6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-5fd5805c.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-54f824d8.js";import"./shared-8df8e77c.js";import"./shared-377cce47.js";import"./shared-b948488a.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./shared-d0aed1c1.js";import"./shared-3426159a.js";import"./shared-b2f675d4.js";import"./shared-b1fa9899.js";import"./shared-c84333db.js";let n,l=e=>e;const m=s(e,"gift-card-code-form");class c extends m{constructor(){super(...arguments),this.getTransactionPageHref=null,this.getCustomerHref=e=>`https://api.foxycart.com/customers/${e}`,this.__cartItemGetItemUrl=(e,t)=>{var r;let o=null;try{const e=null==t?void 0:t._links["fx:transaction"].href;e&&(o=null===(r=this.getTransactionPageHref)||void 0===r?void 0:r.call(this,e))}catch(e){console.log(e)}return null!=o?o:null},this.__customerExtendFilter=e=>{e.has("is_anonymous")||e.set("is_anonymous","false|is_anonymous=true")},this.__customerGetValue=()=>{var e,t,r;const o=this.form.customer_id,s=null===o;return"number"==typeof o?this.getCustomerHref(o):s||null===(r=null===(t=null===(e=this.data)||void 0===e?void 0:e._links)||void 0===t?void 0:t["fx:customer"])||void 0===r?void 0:r.href},this.__customerSetValue=e=>{const t=o(e);this.edit({customer_id:"number"==typeof t?t:null})},this.__customerFilters=[{type:a.String,path:"id",label:"filters.id"},{type:a.String,path:"tax_id",label:"filters.tax_id"},{type:a.String,path:"email",label:"filters.email"},{type:a.String,path:"first_name",label:"filters.first_name"},{type:a.String,path:"last_name",label:"filters.last_name"},{type:a.Boolean,path:"is_anonymous",label:"filters.is_anonymous",list:[{label:"filters.is_anonymous_true",value:"true"},{label:"filters.is_anonymous_false",value:"false"}]},{type:a.Date,path:"last_login_date",label:"filters.last_login_date"},{type:a.Date,path:"date_created",label:"filters.date_created"},{type:a.Date,path:"date_modified",label:"filters.date_modified"}],this.__storeLoaderId="storeLoader"}static get properties(){return t(t({},super.properties),{},{getTransactionPageHref:{attribute:!1},getCustomerHref:{attribute:!1}})}static get v8n(){return[({code:e})=>!!e||"code:v8n_required",({code:e})=>!e||e.length<=50||"code:v8n_too_long",({code:e})=>!(null==e?void 0:e.includes(" "))||"code:v8n_has_spaces",({current_balance:e})=>"number"==typeof e||"current-balance:v8n_required"]}get readonlySelector(){const e=[super.readonlySelector.toString(),"cart-item"];return new r(e.join(" ").trim())}get hiddenSelector(){const e=[super.hiddenSelector.toString()];return this.href||e.push("customer","cart-item","logs"),new r(e.join(" ").trim())}renderBody(){var e,t,r,o,s,a,m,c;let f;try{const o=new URL(null!==(r=null===(t=null===(e=this.data)||void 0===e?void 0:e._links)||void 0===t?void 0:t["fx:provisioned_by_transaction_detail_id"].href)&&void 0!==r?r:"");o.searchParams.set("zoom","item_options"),f=o.toString()}catch(e){f=void 0}return d(n||(n=l` ${0} <foxy-internal-summary-control infer="settings"> <foxy-internal-text-control layout="summary-item" infer="code"></foxy-internal-text-control> <foxy-internal-number-control layout="summary-item" infer="current-balance"> </foxy-internal-number-control> <foxy-internal-date-control layout="summary-item" format="iso-long" infer="end-date"> </foxy-internal-date-control> </foxy-internal-summary-control> <foxy-internal-resource-picker-control infer="customer" first="${0}" item="foxy-customer-card" .extendFilter="${0}" .getValue="${0}" .setValue="${0}" .filters="${0}"> </foxy-internal-resource-picker-control> <foxy-internal-resource-picker-control infer="cart-item" item="foxy-item-card" .getItemUrl="${0}" .getValue="${0}"> </foxy-internal-resource-picker-control> <foxy-internal-async-list-control infer="logs" first="${0}" limit="5" item="foxy-gift-card-code-log-card"> </foxy-internal-async-list-control> ${0} <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),i(null===(s=null===(o=this.__storeLoader)||void 0===o?void 0:o.data)||void 0===s?void 0:s._links["fx:customers"].href),this.__customerExtendFilter,this.__customerGetValue,this.__customerSetValue,this.__customerFilters,this.__cartItemGetItemUrl,(()=>f),i(null===(m=null===(a=this.data)||void 0===a?void 0:a._links)||void 0===m?void 0:m["fx:gift_card_code_logs"].href),super.renderBody(),i(null===(c=this.data)||void 0===c?void 0:c._links["fx:store"].href),this.__storeLoaderId,(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}}customElements.define("foxy-gift-card-code-form",c);export{c as GiftCardCodeForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-e6804126.js";import"./shared-49558171.js";import"./shared-d9f83737.js";import"./shared-61ddd174.js";import"./shared-b0ff4acd.js";import"./shared-da31cee5.js";import"./shared-54f824d8.js";import"./shared-6bb9a580.js";import"./shared-fda3270b.js";import"./shared-c57aac01.js";import{I as e}from"./shared-4da1f187.js";import"./foxy-generate-codes-form.js";import"./foxy-gift-card-codes-form.js";import"./foxy-item-category-card.js";import"./foxy-gift-card-code-card.js";import"./foxy-gift-card-code-form.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import{_ as t,B as r}from"./shared-8f9014ff.js";import{T as i}from"./shared-8874ec69.js";import{h as o}from"./shared-ba5c42c7.js";import{R as a,a as s}from"./shared-887ac0b0.js";import{i as n}from"./shared-53e42a77.js";import"./shared-65094878.js";import"./shared-99c53365.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-515003f6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-19073761.js";import"./shared-9b35fe34.js";import"./shared-930e68b7.js";import"./shared-41c9c53f.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-5fd5805c.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-ec6a369a.js";import"./shared-5212ef4f.js";import"./shared-8df8e77c.js";import"./shared-9a3bf65c.js";import"./shared-a5d6db21.js";import"./shared-a0baefff.js";import"./shared-f8e360e6.js";import"./shared-4e709717.js";import"./shared-a20ef119.js";import"./shared-b5e048f5.js";import"./shared-7892fd3f.js";import"./foxy-form-dialog.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-9687ab7b.js";import"./shared-0f92b865.js";import"./shared-d0aed1c1.js";import"./foxy-swipe-actions.js";import"./shared-a0309d5f.js";import"./foxy-copy-to-clipboard.js";import"./shared-bab2ea2c.js";import"./shared-17c9e095.js";import"./shared-bbd07437.js";import"./shared-b2f675d4.js";import"./shared-3426159a.js";import"./shared-1dfc1e37.js";import"./shared-9109ae93.js";import"./shared-377cce47.js";import"./shared-b948488a.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./foxy-gift-card-code-log-card.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-b1fa9899.js";import"./shared-c84333db.js";import"./shared-d2b3205f.js";const d=["aed","afn","all","amd","ang","aoa","ars","aud","awg","azn","bam","bbd","bdt","bgn","bhd","bif","bmd","bnd","bob","brl","bsd","btc","btn","bwp","byn","bzd","cad","cdf","chf","clf","clp","cnh","cny","cop","crc","cuc","cup","cve","czk","djf","dkk","dop","dzd","egp","ern","etb","eur","fjd","fkp","gbp","gel","ggp","ghs","gip","gmd","gnf","gtq","gyd","hkd","hnl","hrk","htg","huf","idr","ils","imp","inr","iqd","irr","isk","jep","jmd","jod","jpy","kes","kgs","khr","kmf","kpw","krw","kwd","kyd","kzt","lak","lbp","lkr","lrd","lsl","lyd","mad","mdl","mga","mkd","mmk","mnt","mop","mru","mur","mvr","mwk","mxn","myr","mzn","nad","ngn","nio","nok","npr","nzd","omr","pab","pen","pgk","php","pkr","pln","pyg","qar","ron","rsd","rub","rwf","sar","sbd","scr","sdg","sek","sgd","shp","sll","sos","srd","ssp","std","stn","svc","syp","szl","thb","tjs","tmt","tnd","top","try","ttd","twd","tzs","uah","ugx","usd","uyu","uzs","vef","ves","vnd","vuv","wst","xaf","xag","xau","xcd","xdr","xof","xpd","xpf","xpt","yer","zar","zmw","zwl"];let l,c,f=e=>e;const m=a(s(e,"gift-card-form"));class p extends m{constructor(){var e;super(...arguments),e=this,this.getTransactionPageHref=null,this.getCustomerHref=e=>`https://api.foxycart.com/customers/${e}`,this.codesFilter=null,this.__provisioningMaxBalanceValueGetter=()=>{var e;return null===(e=this.form.provisioning_config)||void 0===e?void 0:e.initial_balance_max},this.__provisioningMaxBalanceValueSetter=e=>{var t,r;const i=null!==(r=null===(t=this.form.provisioning_config)||void 0===t?void 0:t.initial_balance_min)&&void 0!==r?r:e;this.edit({provisioning_config:{allow_autoprovisioning:!0,initial_balance_min:i>e?e:i,initial_balance_max:e}})},this.__provisioningMinBalanceValueGetter=()=>{var e;return null===(e=this.form.provisioning_config)||void 0===e?void 0:e.initial_balance_min},this.__provisioningMinBalanceValueSetter=e=>{var t,r;const i=null!==(r=null===(t=this.form.provisioning_config)||void 0===t?void 0:t.initial_balance_max)&&void 0!==r?r:e;this.edit({provisioning_config:{allow_autoprovisioning:!0,initial_balance_min:e,initial_balance_max:i<e?e:i}})},this.__provisioningToggleValueGetter=()=>{var e;return!!(null===(e=this.form.provisioning_config)||void 0===e?void 0:e.allow_autoprovisioning)},this.__provisioningToggleValueSetter=e=>{var t,r,i,o;e?this.edit({provisioning_config:{allow_autoprovisioning:!0,initial_balance_min:null!==(r=null===(t=this.form.provisioning_config)||void 0===t?void 0:t.initial_balance_min)&&void 0!==r?r:0,initial_balance_max:null!==(o=null===(i=this.form.provisioning_config)||void 0===i?void 0:i.initial_balance_max)&&void 0!==o?o:0}}):this.edit({provisioning_config:null})},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.__currencyCodeGetValue=()=>{var e;return null===(e=this.form.currency_code)||void 0===e?void 0:e.toLowerCase()},this.__storeLoaderId="storeLoader",this.__codesFilters=[{label:"option_code",path:"code",type:i.String},{label:"option_current_balance",path:"current_balance",type:i.Number},{label:"option_end_date",path:"end_date",type:i.Date},{label:"option_date_created",path:"date_created",type:i.Date},{label:"option_date_modified",path:"date_modified",type:i.Date}],this.__codesActions=[{theme:"contrast",state:"idle",text:"copy_button_text",onClick:async function(t){e.__codesActions[0].state="busy",e.__codesActions=[...e.__codesActions];try{await navigator.clipboard.writeText(t.code),e.__codesActions[0].state="end"}catch(t){e.__codesActions[0].state="error"}finally{e.__codesActions=[...e.__codesActions],setTimeout((()=>{e.__codesActions[0].state="idle",e.__codesActions=[...e.__codesActions]}),1e3)}}}]}static get properties(){return t(t({},super.properties),{},{getTransactionPageHref:{attribute:!1},getCustomerHref:{attribute:!1},codesFilter:{attribute:"codes-filter"}})}static get v8n(){return[({name:e})=>!!e||"name:v8n_required",({name:e})=>!e||e.length<=50||"name:v8n_too_long",e=>{var t;if(null===(t=e.provisioning_config)||void 0===t?void 0:t.allow_autoprovisioning){if(!e.sku)return"sku:v8n_required";if(e.sku.length>200)return"sku:v8n_too_long"}return!0},e=>{var t;const r=null===(t=e.provisioning_config)||void 0===t?void 0:t.initial_balance_min;return!("number"==typeof r&&r<0)||"min-balance:v8n_negative"},e=>{var t;const r=null===(t=e.provisioning_config)||void 0===t?void 0:t.initial_balance_max;return!("number"==typeof r&&r<0)||"max-balance:v8n_negative"},({product_code_restrictions:e})=>!e||e.length<=5e3||"product-code-restrictions:v8n_too_long"]}get hiddenSelector(){var e;const t=[super.hiddenSelector.toString()];return this.data||t.push("codes","category-restrictions","attributes"),(null===(e=this.form.provisioning_config)||void 0===e?void 0:e.allow_autoprovisioning)||t.push("provisioning:sku","provisioning:min-balance","provisioning:max-balance"),new r(t.join(" ").trim())}get headerSubtitleOptions(){return{id:this.headerCopyIdValue}}renderHeaderActions(e){return o(l||(l=f` <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-gift-card-codes-form" .related="${0}"> </foxy-internal-bulk-add-action-control> ${0} `),e._links["fx:generate_codes"].href,[e._links["fx:gift_card_codes"].href],e._links["fx:gift_card_codes"].href,[e._links["fx:gift_card_codes"].href],super.renderHeaderActions(e))}renderBody(){var e,t,r,i,a,s,l,m,p,u,_;let h;try{const r=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:gift_card_codes"].href)&&void 0!==t?t:"");r.searchParams.set("order","date_created desc"),h=r.toString()}catch(e){h=void 0}return o(c||(c=f` ${0} <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="name"> </foxy-internal-text-control> <foxy-internal-select-control property="currency_code" layout="summary-item" infer="currency" .getValue="${0}" .options="${0}"> </foxy-internal-select-control> <foxy-internal-frequency-control property="expires_after" layout="summary-item" infer="expires"> </foxy-internal-frequency-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="provisioning"> <foxy-internal-switch-control infer="toggle" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> <foxy-internal-text-control layout="summary-item" infer="sku"></foxy-internal-text-control> <foxy-internal-number-control layout="summary-item" suffix="${0}" infer="min-balance" min="0" .getValue="${0}" .setValue="${0}"> </foxy-internal-number-control> <foxy-internal-number-control layout="summary-item" suffix="${0}" infer="max-balance" min="0" .getValue="${0}" .setValue="${0}"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-async-list-control filter="${0}" first="${0}" limit="5" infer="codes" item="foxy-gift-card-code-card" form="foxy-gift-card-code-form" alert .actions="${0}" .filters="${0}" .formProps="${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-async-resource-link-list-control foreign-key-for-uri="item_category_uri" foreign-key-for-id="item_category_id" own-key-for-uri="gift_card_uri" options-href="${0}" links-href="${0}" embed-key="fx:gift_card_item_categories" own-uri="${0}" infer="category-restrictions" limit="5" item="foxy-item-category-card"> </foxy-internal-async-resource-link-list-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(),this.__currencyCodeGetValue,d.map((e=>({label:this.t(`general.currency.code_${e}`),value:e}))),this.__provisioningToggleValueGetter,this.__provisioningToggleValueSetter,n(null===(r=this.form.currency_code)||void 0===r?void 0:r.toUpperCase()),this.__provisioningMinBalanceValueGetter,this.__provisioningMinBalanceValueSetter,n(null===(i=this.form.currency_code)||void 0===i?void 0:i.toUpperCase()),this.__provisioningMaxBalanceValueGetter,this.__provisioningMaxBalanceValueSetter,n(null!==(a=this.codesFilter)&&void 0!==a?a:void 0),h,this.__codesActions,this.__codesFilters,{".getTransactionPageHref":this.getTransactionPageHref,".getCustomerHref":this.getCustomerHref},this.__productCodeRestrictionsGetValue,this.__productCodeRestrictionsSetValue,[{label:this.t("product-code-restrictions.unit_allow"),value:"allow"},{label:this.t("product-code-restrictions.unit_block"),value:"block"}],n(null===(l=null===(s=this.__storeLoader)||void 0===s?void 0:s.data)||void 0===l?void 0:l._links["fx:item_categories"].href),n(null===(m=this.data)||void 0===m?void 0:m._links["fx:gift_card_item_categories"].href),n(null===(p=this.data)||void 0===p?void 0:p._links.self.href),n(null===(u=this.data)||void 0===u?void 0:u._links["fx:attributes"].href),super.renderBody(),n(null===(_=this.data)||void 0===_?void 0:_._links["fx:store"].href),this.__storeLoaderId,(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}}customElements.define("foxy-gift-card-form",p);export{p as GiftCardForm};
|
|
1
|
+
import"./shared-e6804126.js";import"./shared-49558171.js";import"./shared-d9f83737.js";import"./shared-61ddd174.js";import"./shared-b0ff4acd.js";import"./shared-da31cee5.js";import"./shared-54f824d8.js";import"./shared-6bb9a580.js";import"./shared-fda3270b.js";import"./shared-c57aac01.js";import{I as e}from"./shared-4da1f187.js";import"./foxy-generate-codes-form.js";import"./foxy-gift-card-codes-form.js";import"./foxy-item-category-card.js";import"./foxy-gift-card-code-card.js";import"./foxy-gift-card-code-form.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import{_ as t,B as r}from"./shared-8f9014ff.js";import{T as i}from"./shared-ba230a1b.js";import{h as o}from"./shared-ba5c42c7.js";import{R as a,a as s}from"./shared-887ac0b0.js";import{i as n}from"./shared-53e42a77.js";import"./shared-65094878.js";import"./shared-99c53365.js";import"./shared-0fd68dc0.js";import"./shared-8d8975d5.js";import"./shared-515003f6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-db623837.js";import"./shared-6cdfb858.js";import"./shared-19073761.js";import"./shared-9b35fe34.js";import"./shared-930e68b7.js";import"./shared-41c9c53f.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-5fd5805c.js";import"./shared-53e476fd.js";import"./foxy-pagination.js";import"./shared-ec6a369a.js";import"./shared-5212ef4f.js";import"./shared-8df8e77c.js";import"./shared-9a3bf65c.js";import"./shared-a5d6db21.js";import"./shared-a0baefff.js";import"./shared-f8e360e6.js";import"./shared-4e709717.js";import"./shared-a20ef119.js";import"./shared-b5e048f5.js";import"./shared-7892fd3f.js";import"./foxy-form-dialog.js";import"./shared-609c9693.js";import"./shared-058530fc.js";import"./shared-9687ab7b.js";import"./shared-0f92b865.js";import"./shared-d0aed1c1.js";import"./foxy-swipe-actions.js";import"./shared-a0309d5f.js";import"./foxy-copy-to-clipboard.js";import"./shared-bab2ea2c.js";import"./shared-17c9e095.js";import"./shared-bbd07437.js";import"./shared-b2f675d4.js";import"./shared-3426159a.js";import"./shared-1dfc1e37.js";import"./shared-9109ae93.js";import"./shared-377cce47.js";import"./shared-b948488a.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./foxy-gift-card-code-log-card.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-b1fa9899.js";import"./shared-c84333db.js";import"./shared-d2b3205f.js";const d=["aed","afn","all","amd","ang","aoa","ars","aud","awg","azn","bam","bbd","bdt","bgn","bhd","bif","bmd","bnd","bob","brl","bsd","btc","btn","bwp","byn","bzd","cad","cdf","chf","clf","clp","cnh","cny","cop","crc","cuc","cup","cve","czk","djf","dkk","dop","dzd","egp","ern","etb","eur","fjd","fkp","gbp","gel","ggp","ghs","gip","gmd","gnf","gtq","gyd","hkd","hnl","hrk","htg","huf","idr","ils","imp","inr","iqd","irr","isk","jep","jmd","jod","jpy","kes","kgs","khr","kmf","kpw","krw","kwd","kyd","kzt","lak","lbp","lkr","lrd","lsl","lyd","mad","mdl","mga","mkd","mmk","mnt","mop","mru","mur","mvr","mwk","mxn","myr","mzn","nad","ngn","nio","nok","npr","nzd","omr","pab","pen","pgk","php","pkr","pln","pyg","qar","ron","rsd","rub","rwf","sar","sbd","scr","sdg","sek","sgd","shp","sll","sos","srd","ssp","std","stn","svc","syp","szl","thb","tjs","tmt","tnd","top","try","ttd","twd","tzs","uah","ugx","usd","uyu","uzs","vef","ves","vnd","vuv","wst","xaf","xag","xau","xcd","xdr","xof","xpd","xpf","xpt","yer","zar","zmw","zwl"];let l,c,f=e=>e;const m=a(s(e,"gift-card-form"));class p extends m{constructor(){var e;super(...arguments),e=this,this.getTransactionPageHref=null,this.getCustomerHref=e=>`https://api.foxycart.com/customers/${e}`,this.codesFilter=null,this.__provisioningMaxBalanceValueGetter=()=>{var e;return null===(e=this.form.provisioning_config)||void 0===e?void 0:e.initial_balance_max},this.__provisioningMaxBalanceValueSetter=e=>{var t,r;const i=null!==(r=null===(t=this.form.provisioning_config)||void 0===t?void 0:t.initial_balance_min)&&void 0!==r?r:e;this.edit({provisioning_config:{allow_autoprovisioning:!0,initial_balance_min:i>e?e:i,initial_balance_max:e}})},this.__provisioningMinBalanceValueGetter=()=>{var e;return null===(e=this.form.provisioning_config)||void 0===e?void 0:e.initial_balance_min},this.__provisioningMinBalanceValueSetter=e=>{var t,r;const i=null!==(r=null===(t=this.form.provisioning_config)||void 0===t?void 0:t.initial_balance_max)&&void 0!==r?r:e;this.edit({provisioning_config:{allow_autoprovisioning:!0,initial_balance_min:e,initial_balance_max:i<e?e:i}})},this.__provisioningToggleValueGetter=()=>{var e;return!!(null===(e=this.form.provisioning_config)||void 0===e?void 0:e.allow_autoprovisioning)},this.__provisioningToggleValueSetter=e=>{var t,r,i,o;e?this.edit({provisioning_config:{allow_autoprovisioning:!0,initial_balance_min:null!==(r=null===(t=this.form.provisioning_config)||void 0===t?void 0:t.initial_balance_min)&&void 0!==r?r:0,initial_balance_max:null!==(o=null===(i=this.form.provisioning_config)||void 0===i?void 0:i.initial_balance_max)&&void 0!==o?o:0}}):this.edit({provisioning_config:null})},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.__currencyCodeGetValue=()=>{var e;return null===(e=this.form.currency_code)||void 0===e?void 0:e.toLowerCase()},this.__storeLoaderId="storeLoader",this.__codesFilters=[{label:"option_code",path:"code",type:i.String},{label:"option_current_balance",path:"current_balance",type:i.Number},{label:"option_end_date",path:"end_date",type:i.Date},{label:"option_date_created",path:"date_created",type:i.Date},{label:"option_date_modified",path:"date_modified",type:i.Date}],this.__codesActions=[{theme:"contrast",state:"idle",text:"copy_button_text",onClick:async function(t){e.__codesActions[0].state="busy",e.__codesActions=[...e.__codesActions];try{await navigator.clipboard.writeText(t.code),e.__codesActions[0].state="end"}catch(t){e.__codesActions[0].state="error"}finally{e.__codesActions=[...e.__codesActions],setTimeout((()=>{e.__codesActions[0].state="idle",e.__codesActions=[...e.__codesActions]}),1e3)}}}]}static get properties(){return t(t({},super.properties),{},{getTransactionPageHref:{attribute:!1},getCustomerHref:{attribute:!1},codesFilter:{attribute:"codes-filter"}})}static get v8n(){return[({name:e})=>!!e||"name:v8n_required",({name:e})=>!e||e.length<=50||"name:v8n_too_long",e=>{var t;if(null===(t=e.provisioning_config)||void 0===t?void 0:t.allow_autoprovisioning){if(!e.sku)return"sku:v8n_required";if(e.sku.length>200)return"sku:v8n_too_long"}return!0},e=>{var t;const r=null===(t=e.provisioning_config)||void 0===t?void 0:t.initial_balance_min;return!("number"==typeof r&&r<0)||"min-balance:v8n_negative"},e=>{var t;const r=null===(t=e.provisioning_config)||void 0===t?void 0:t.initial_balance_max;return!("number"==typeof r&&r<0)||"max-balance:v8n_negative"},({product_code_restrictions:e})=>!e||e.length<=5e3||"product-code-restrictions:v8n_too_long"]}get hiddenSelector(){var e;const t=[super.hiddenSelector.toString()];return this.data||t.push("codes","category-restrictions","attributes"),(null===(e=this.form.provisioning_config)||void 0===e?void 0:e.allow_autoprovisioning)||t.push("provisioning:sku","provisioning:min-balance","provisioning:max-balance"),new r(t.join(" ").trim())}get headerSubtitleOptions(){return{id:this.headerCopyIdValue}}renderHeaderActions(e){return o(l||(l=f` <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-gift-card-codes-form" .related="${0}"> </foxy-internal-bulk-add-action-control> ${0} `),e._links["fx:generate_codes"].href,[e._links["fx:gift_card_codes"].href],e._links["fx:gift_card_codes"].href,[e._links["fx:gift_card_codes"].href],super.renderHeaderActions(e))}renderBody(){var e,t,r,i,a,s,l,m,p,u,_;let h;try{const r=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:gift_card_codes"].href)&&void 0!==t?t:"");r.searchParams.set("order","date_created desc"),h=r.toString()}catch(e){h=void 0}return o(c||(c=f` ${0} <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="name"> </foxy-internal-text-control> <foxy-internal-select-control property="currency_code" layout="summary-item" infer="currency" .getValue="${0}" .options="${0}"> </foxy-internal-select-control> <foxy-internal-frequency-control property="expires_after" layout="summary-item" infer="expires"> </foxy-internal-frequency-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="provisioning"> <foxy-internal-switch-control infer="toggle" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> <foxy-internal-text-control layout="summary-item" infer="sku"></foxy-internal-text-control> <foxy-internal-number-control layout="summary-item" suffix="${0}" infer="min-balance" min="0" .getValue="${0}" .setValue="${0}"> </foxy-internal-number-control> <foxy-internal-number-control layout="summary-item" suffix="${0}" infer="max-balance" min="0" .getValue="${0}" .setValue="${0}"> </foxy-internal-number-control> </foxy-internal-summary-control> <foxy-internal-async-list-control filter="${0}" first="${0}" limit="5" infer="codes" item="foxy-gift-card-code-card" form="foxy-gift-card-code-form" alert .actions="${0}" .filters="${0}" .formProps="${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-async-resource-link-list-control foreign-key-for-uri="item_category_uri" foreign-key-for-id="item_category_id" own-key-for-uri="gift_card_uri" options-href="${0}" links-href="${0}" embed-key="fx:gift_card_item_categories" own-uri="${0}" infer="category-restrictions" limit="5" item="foxy-item-category-card"> </foxy-internal-async-resource-link-list-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(),this.__currencyCodeGetValue,d.map((e=>({label:this.t(`general.currency.code_${e}`),value:e}))),this.__provisioningToggleValueGetter,this.__provisioningToggleValueSetter,n(null===(r=this.form.currency_code)||void 0===r?void 0:r.toUpperCase()),this.__provisioningMinBalanceValueGetter,this.__provisioningMinBalanceValueSetter,n(null===(i=this.form.currency_code)||void 0===i?void 0:i.toUpperCase()),this.__provisioningMaxBalanceValueGetter,this.__provisioningMaxBalanceValueSetter,n(null!==(a=this.codesFilter)&&void 0!==a?a:void 0),h,this.__codesActions,this.__codesFilters,{".getTransactionPageHref":this.getTransactionPageHref,".getCustomerHref":this.getCustomerHref},this.__productCodeRestrictionsGetValue,this.__productCodeRestrictionsSetValue,[{label:this.t("product-code-restrictions.unit_allow"),value:"allow"},{label:this.t("product-code-restrictions.unit_block"),value:"block"}],n(null===(l=null===(s=this.__storeLoader)||void 0===s?void 0:s.data)||void 0===l?void 0:l._links["fx:item_categories"].href),n(null===(m=this.data)||void 0===m?void 0:m._links["fx:gift_card_item_categories"].href),n(null===(p=this.data)||void 0===p?void 0:p._links.self.href),n(null===(u=this.data)||void 0===u?void 0:u._links["fx:attributes"].href),super.renderBody(),n(null===(_=this.data)||void 0===_?void 0:_._links["fx:store"].href),this.__storeLoaderId,(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}}customElements.define("foxy-gift-card-form",p);export{p as GiftCardForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-19073761.js";import"./shared-db623837.js";import"./shared-da31cee5.js";import"./shared-9b35fe34.js";export{Q as QueryBuilder}from"./shared-
|
|
1
|
+
import"./shared-19073761.js";import"./shared-db623837.js";import"./shared-da31cee5.js";import"./shared-9b35fe34.js";export{Q as QueryBuilder}from"./shared-dd722e70.js";import"./shared-0fd68dc0.js";import"./shared-887ac0b0.js";import"./shared-8f9014ff.js";import"./shared-ba5c42c7.js";import"./shared-6cdfb858.js";import"./shared-ec6a369a.js";import"./shared-5212ef4f.js";import"./shared-41c9c53f.js";import"./shared-53e42a77.js";import"./shared-930e68b7.js";import"./shared-2b39e4d4.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-ba230a1b.js";import"./shared-63c32024.js";import"./shared-4e709717.js";import"./shared-5fd5805c.js";import"./shared-2061be9a.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a,e;!function(a){a.NameValuePair="name_value_pair",a.Attribute="attribute",a.Boolean="boolean",a.String="string",a.Number="number",a.Date="date",a.Any="any"}(a||(a={})),function(a){a.LessThanOrEqual="lessthanorequal",a.LessThan="lessthan",a.GreaterThanOrEqual="greaterthanorequal",a.GreaterThan="greaterthan",a.IsDefined="isdefined",a.Not="not",a.In="in"}(e||(e={}));export{e as O,a as T};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import"./shared-19073761.js";import"./shared-db623837.js";import"./shared-da31cee5.js";import"./shared-9b35fe34.js";import{_ as e}from"./shared-8f9014ff.js";import{R as l,T as a,a as n}from"./shared-887ac0b0.js";import{C as t}from"./shared-41c9c53f.js";import{s as o,h as r,c as s,L as i}from"./shared-ba5c42c7.js";import{I as u}from"./shared-930e68b7.js";import{O as d,T as v}from"./shared-ba230a1b.js";import{o as c}from"./shared-63c32024.js";import{c as p}from"./shared-4e709717.js";import{r as h}from"./shared-5fd5805c.js";import{i as f}from"./shared-53e42a77.js";import{s as b}from"./shared-2061be9a.js";import{p as g}from"./shared-e650caf3.js";let y;const m=o(y||(y=(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 x;const C=o(x||(x=(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 $;const _=o($||($=(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 w;const L=o(w||(w=(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 q;const M=o(q||(q=(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 k;const A=o(k||(k=(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 S=o(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 H;const j=o(H||(H=(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 D,V=e=>e;let Z,I,T=e=>e;function N(e){return r(Z||(Z=T` <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}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} </label> `),e.t(e.label),p({"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}),e.value,e.disabled||e.readonly,(e=>"|"===e.key&&e.preventDefault()),(l=>{const a=l.currentTarget;e.onChange(a.value.replace(/\|/gi,""))}),p({"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":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.disabled||e.readonly?"":r(I||(I=T` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}let z,B,E=e=>e;function G(l){var a,n;const{isFullSize:t,isNested:o,disableOr:s,readonly:i,disabled:u,rule:v}=l,{t:h,onConvert:f,onDelete:b,onChange:g}=l;return r(z||(z=E` <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"> <div aria-hidden="true" class="${0}"> ${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> `),h("query_builder_rule"),p({"flex-1 bg-base rounded overflow-hidden border":!0,"border-contrast-10":!o&&!i,"border-contrast-50":!!o||i,"border-dashed":i,"border-solid":!i}),p({"text-tertiary":!i&&!u,"text-disabled":i||u,"w-m h-m":!0}),j,v.path&&v.name?r(B||(B=E` <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> `),N(e(e({},l),{},{value:v.path,label:"field",onChange:e=>{g({operator:null,value:"",path:e})}})),N(e(e({},l),{},{value:null!==(a=v.name)&&void 0!==a?a:"",label:"name",onChange:l=>g(e(e({},v),{},{name:l}))}))):N(e(e({},l),{},{value:v.path,label:"field",onChange:e=>g({operator:null,value:"",path:e})})),function(l){const{rule:a,operators:n,disabled:t,readonly:o,t:s,onChange:i}=l,{operator:u,value:v,path:h,name:f}=a,b={[d.GreaterThan]:C,[d.GreaterThanOrEqual]:c,[d.In]:_,[d.IsDefined]:L,[d.LessThan]:M,[d.LessThanOrEqual]:A,[d.Not]:S},g=Object.values(d).filter((e=>n.includes(e)&&(!!f||e!==d.IsDefined))),y=t||o||!g.length||!h;return r(D||(D=V` <button title="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div aria-hidden="true">${0}</div> </button> `),s(`operator_${null!=u?u:"equal"}`),p({"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":!y&&g.length>0,"cursor-default text-tertiary":!y&&0===g.length,"text-disabled cursor-default":y}),y||0===g.length,(()=>{var l;const n=u?g.indexOf(u):-1,t=null!==(l=g[n+1])&&void 0!==l?l:null;i(e(e({},a),{},{operator:t,value:v}))}),u?b[u]:m)}(l),N(e(e({},l),{},{disabled:u||!v.path,value:null!==(n=v.value)&&void 0!==n?n:"",label:"value",onChange:l=>g(e(e({},v),{},{value:l}))})),p({"-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:!!t||i,flex:!t}),h("delete"),p({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!u,"cursor-default text-disabled":u,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!v.path}),u||i||!v.path,b,h("add_or_clause"),p({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-success hover-bg-contrast-5":!u,"cursor-default text-disabled":u,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!v.path||!!o||s}),u||i||!v.path||!!o||s,s,f)}let P,R,W,F,U=e=>e;function Q(l){const a=l.rules.some((e=>Array.isArray(e))),n=r(P||(P=U`<div class="${0}"></div>`),a?"h-xs":"mt-s"),t=r(R||(R=U` <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 r(W||(W=U` <div aria-label="${0}"> ${0} </div> `),l.t("query_builder_group"),h([...l.rules,null],((e,l)=>String(l)),((a,o)=>{const s=o>0?l.isNested?t:n:"";return null===a?[s,G(e(e({},l),{},{rule:{path:"",operator:null,value:""},operators:l.operators.filter((e=>"string"==typeof e)),isFullSize:!l.isNested&&0===l.rules.length,onChange:e=>l.onChange([...l.rules,e])}))]:Array.isArray(a)?[s,r(F||(F=U` <div class="bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s"> ${0} </div> `),Q(e(e({},l),{},{rules:a,isNested:!0,onChange:e=>{const a=[...l.rules],n=e;a[o]=e.length>1?n:n[0],l.onChange(a)}})))]:[s,G(e(e({},l),{},{rule:a,operators:l.operators.filter((e=>!("object"==typeof e)||e.paths.includes(a.path))).map((e=>"object"==typeof e?e.type:e)),onChange:e=>{const a=[...l.rules];a[o]=e,l.onChange(a)},onDelete:()=>{const e=l.rules.filter(((e,l)=>l!==o));l.onChange(e)},onConvert:()=>{const n=[...l.rules];n[o]=[a,e(e({},a),{},{operator:null,value:""})],l.onChange(n)}}))]})))}let J,K,X,Y,ee,le,ae=e=>e;function ne(e){const{t:l,disabled:a,readonly:n,current:t,options:s,onChange:i}=e;return r(J||(J=ae` <div class="${0}"> ${0} ${0} </div> `),p({"relative flex items-center gap-xs leading-m px-xs -m-xs rounded-s transition-colors":!0,"focus-within-ring-2 focus-within-ring-primary-50":!0,"text-contrast":!a&&!n,"hover-text-contrast-80":!a&&!n,"text-disabled":a,"text-contrast-80":n,"font-medium":!n}),"label"in t?r(K||(K=ae`<foxy-i18n infer="" key="${0}"></foxy-i18n>`),t.label):r(X||(X=ae`<span>${0}</span>`),t.rawLabel),n?"":r(Y||(Y=ae` ${0} <select class="${0}" ?disabled="${0}" @change="${0}"> ${0} </select> `),o(ee||(ee=ae`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex-shrink-0" style="width: 1em; height: 1em; transform: scale(1.25)"><path fill-rule="evenodd" d="M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z" clip-rule="evenodd" /></svg>`)),p({"absolute inset-0 opacity-0 focus-outline-none":!0,"cursor-pointer":!a,"cursor-default":a}),a,(e=>i(e.target.value)),s.map((e=>r(le||(le=ae` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.value,e.value===t.value,"label"in e?l(e.label):e.rawLabel)))))}let te,oe,re,se=e=>e;const ie=new WeakMap;function ue(e){const{disabled:l,readonly:a,layout:n,label:t,value:o,type:s,min:i,t:u,onChange:d}=e;return r(te||(te=se` <label class="flex-shrink-0 flex items-center gap-s relative" style="min-width:${0}rem;max-width:50%"> <foxy-i18n infer="" class="${0}" key="${0}"> </foxy-i18n> <span class="${0}" ?hidden="${0}">${0}</span> ${0} </label> `),"number"===s?"4":"date"===s?"6":"8",p({"sr-only":"fixed"!==n}),t,p({"relative block whitespace-pre text-m":!0,"px-s py-xs -my-xs font-medium opacity-0":!a,"text-contrast-80":a}),"auto-grow"!==n&&!a,o||r(oe||(oe=se`<foxy-i18n infer="" key="value_empty"></foxy-i18n>`)),a?"":r(re||(re=se` <input placeholder="${0}" class="${0}" ?disabled="${0}" type="${0}" min="${0}" .value="${0}" @keydown="${0}" @input="${0}"> `),u("value_empty"),p({"appearance-none transition-all text-body text-m font-medium rounded-s":!0,"bg-base px-s py-xs -my-xs":!0,"opacity-50":l,"absolute inset-0":"auto-grow"===n,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0}),l,f(s),f(i),o,(e=>"|"===e.key&&e.preventDefault()),(e=>{const l=e.currentTarget,a=l.value.replace(/\|/gi,""),n=ie.get(l);n&&clearTimeout(n);const t=setTimeout((()=>d(a)),500);ie.set(l,t)})))}let de,ve=e=>e;const ce=e=>{var l;const{operator:a,value:n,name:t}=null!==(l=e.rule)&&void 0!==l?l:{},{disabled:o,readonly:s,t:i}=e,u=d.Not,v=p({"text-disabled":o,"text-contrast-80":s}),c=null===a?"*"===n?null:"equal":a===u?u:null;return r(de||(de=ve` <foxy-i18n class="${0}" infer="" key="name"></foxy-i18n> ${0} <foxy-i18n class="${0}" infer="" key="value"></foxy-i18n> ${0} ${0} `),v,ue({layout:"auto-grow",value:t||"",label:"name",type:"text",disabled:o,readonly:s,t:i,onChange:l=>{if(!l)return e.onChange(null);n?e.onChange({name:l}):e.onChange({name:l,operator:null,value:"*"})}}),v,ne({current:{label:c?`operator_${c}`:"value_any",value:null!=c?c:"any"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:u}],disabled:o,readonly:s,t:i,onChange:l=>{if("any"!==l)return e.onChange({operator:"equal"===l?null:l,value:"equal"===l&&"*"===n?"":null!=n?n:"",name:null!=t?t:""});e.onChange(t?{operator:null,value:"*"}:null)}}),void 0===n||null===a&&"*"===n?"":ue({layout:"auto-grow",label:"value",value:n||"",type:"text",disabled:o,readonly:s,t:i,onChange:l=>e.onChange({value:l})}))};let pe,he=e=>e;const fe=e=>{var l;const{operator:a,value:n,name:t}=null!==(l=e.rule)&&void 0!==l?l:{},{disabled:o,readonly:s,t:i}=e,u=d.Not,v=p({"text-disabled":o,"text-contrast-80":s}),c=null===a?"equal":a===u?u:null;return r(pe||(pe=he` <foxy-i18n class="${0}" infer="" key="name"></foxy-i18n> ${0} <foxy-i18n class="${0}" infer="" key="value"></foxy-i18n> ${0} ${0} `),v,ue({layout:"auto-grow",value:t||"",label:"name",type:"text",disabled:o,readonly:s,t:i,onChange:l=>{if(!l)return e.onChange(null);n?e.onChange({name:l}):e.onChange({name:l,operator:d.IsDefined,value:"true"})}}),v,ne({current:{label:c?`operator_${c}`:"value_any",value:null!=c?c:"any"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:u}],disabled:o,readonly:s,t:i,onChange:l=>{if("any"!==l)return e.onChange({operator:"equal"===l?null:l,value:a===d.IsDefined?"":null!=n?n:"",name:null!=t?t:""});e.onChange(t?{operator:d.IsDefined,value:"true"}:null)}}),void 0===n||a===d.IsDefined?"":ue({layout:"auto-grow",label:"value",value:n||"",type:"text",disabled:o,readonly:s,t:i,onChange:l=>e.onChange({value:l})}))},be=l=>{var a;const n=[{label:"value_any",value:"any"},{label:`${l.option.label}_true`,value:"true"},{label:`${l.option.label}_false`,value:"false"}];return ne(e(e({},l),{},{onChange:e=>l.onChange("any"===e?null:{value:e}),current:null!==(a=n.find((e=>{var a;return e.value===(null===(a=l.rule)||void 0===a?void 0:a.value)})))&&void 0!==a?a:n[0],options:n}))};let ge,ye,me=e=>e;const xe=e=>{const{disabled:l,readonly:a,option:n,rule:t,t:o,onChange:s}=e,{min:i,label:u}=n,v=null==t?void 0:t.operator,c=null==t?void 0:t.value.includes(".."),p=null!=v?v:c?"range":"equal",h=void 0===v?"value_any":"range"===p?"range":`operator_${p}`;return r(ge||(ge=me` ${0} ${0} `),ne({disabled:l,readonly:a,current:{label:h,value:void 0===v?"any":p},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not},{label:"operator_lessthanorequal",value:d.LessThanOrEqual},{label:"operator_lessthan",value:d.LessThan},{label:"operator_greaterthanorequal",value:d.GreaterThanOrEqual},{label:"operator_greaterthan",value:d.GreaterThan},{label:"range",value:"range"}],t:o,onChange:e=>{var l,a,o,r;if("any"===e)return s(null);if("range"===e){const e=parseFloat(null!==(l=null==t?void 0:t.value)&&void 0!==l?l:"");return isNaN(e)?s({operator:null,value:"..",invalid:!0}):s({operator:null,value:`${e}..${e+10}`})}const i=null!==(r=null!==(a=null==t?void 0:t.value)&&void 0!==a?a:null===(o=n.min)||void 0===o?void 0:o.toString())&&void 0!==r?r:"",u=i.includes("..")&&"range"!==e;return s({operator:"equal"===e?null:e,invalid:!i,value:u?i.split("..")[0]:i})}}),void 0===(null==t?void 0:t.value)?"":c?r(ye||(ye=me` <foxy-i18n infer="" key="range_from"></foxy-i18n> ${0} <foxy-i18n infer="" key="range_to"></foxy-i18n> ${0} `),ue({disabled:l,readonly:a,layout:"auto-grow",label:"range_from",value:null==t?void 0:t.value.split("..")[0],type:"number",min:i,t:o,onChange:e=>{var l;const a=null!==(l=null==t?void 0:t.value.split("..")[1])&&void 0!==l?l:"";s({value:`${e}..${a}`,invalid:!e||!a})}}),ue({disabled:l,readonly:a,layout:"auto-grow",label:"range_to",value:null==t?void 0:t.value.split("..")[1],type:"number",min:i,t:o,onChange:e=>{const l=null==t?void 0:t.value.split("..")[0];s({value:`${l}..${e}`,invalid:!l||!e})}})):ue({disabled:l,readonly:a,layout:"auto-grow",label:u,value:(null==t?void 0:t.value)||"",type:"number",min:i,t:o,onChange:e=>s({value:e,invalid:!e})}))};let Ce,$e=e=>e;const _e=e=>{const{disabled:l,readonly:a,option:n,rule:t,t:o,onChange:s}=e,{operator:i}=null!=t?t:{},{label:u}=n;return r(Ce||(Ce=$e` ${0} ${0} `),ne({disabled:l,readonly:a,current:{label:void 0===i?"value_any":`operator_${null!=i?i:"equal"}`,value:void 0===i?"any":null!=i?i:"equal"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not}],t:o,onChange:e=>{var l;return s("any"===e?null:{operator:"equal"===e?null:e,value:null!==(l=null==t?void 0:t.value)&&void 0!==l?l:""})}}),void 0===(null==t?void 0:t.value)?"":ue({disabled:l,readonly:a,layout:"auto-grow",label:u,value:(null==t?void 0:t.value)||"",t:o,onChange:e=>s({value:e})}))};let we,Le,qe=e=>e;const Me=e=>{var l;const{operator:a,value:n}=null!==(l=e.rule)&&void 0!==l?l:{},{min:t,label:o}=e.option,{disabled:s,readonly:i,t:u,onChange:v}=e,c=null==n?void 0:n.includes(".."),p=null!=a?a:c?"range":"equal",h=void 0===a?"value_any":"range"===p?"range":`operator_${p}`;return r(we||(we=qe` ${0} ${0} `),ne({disabled:s,readonly:i,t:u,current:{label:h,value:void 0===a?"any":p},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not},{label:"operator_lessthanorequal",value:d.LessThanOrEqual},{label:"operator_lessthan",value:d.LessThan},{label:"operator_greaterthanorequal",value:d.GreaterThanOrEqual},{label:"operator_greaterthan",value:d.GreaterThan},{label:"range",value:"range"}],onChange:e=>{if("any"===e)return v(null);if("range"===e){const e=new Date(null!=n?n:(new Date).toISOString()),l=new Date(e);e.setMonth(e.getMonth()-1),e.setHours(0,0,0,0),l.setHours(23,59,59,999);const a=e.toISOString(),t=l.toISOString();return v({operator:null,value:`${a}..${t}`})}const l=null!=n?n:(new Date).toISOString(),a=l.includes("..")&&"range"!==e;return v({operator:"equal"===e?null:e,value:a?l.split("..")[0]:l})}}),void 0===n?"":c?r(Le||(Le=qe` ${0} ${0} `),ue({disabled:s,readonly:i,layout:"fixed",label:"range_from",value:b(new Date(n.split("..")[0])),type:"date",min:t,t:u,onChange:e=>{var l,a;const t=null!==(l=g(e))&&void 0!==l?l:new Date,o=new Date(null!==(a=n.split("..")[1])&&void 0!==a?a:Date.now());t.setHours(0,0,0,0),o.setHours(23,59,59,999),v({value:`${t.toISOString()}..${o.toISOString()}`})}}),ue({disabled:s,readonly:i,layout:"fixed",label:"range_to",value:b(new Date(n.split("..")[1])),type:"date",min:t,t:u,onChange:e=>{var l,a;const t=new Date(null!==(l=n.split("..")[0])&&void 0!==l?l:Date.now()),o=null!==(a=g(e))&&void 0!==a?a:new Date;t.setHours(0,0,0,0),o.setHours(23,59,59,999),v({value:`${t.toISOString()}..${o.toISOString()}`})}})):ue({disabled:s,readonly:i,label:o,value:b(new Date(null!=n?n:Date.now())),type:"date",min:t,t:u,onChange:e=>{var l;v({value:(null!==(l=g(e))&&void 0!==l?l:new Date).toISOString()})}}))};let ke,Ae=e=>e;const Oe=e=>{const{disabled:l,readonly:a,option:n,rule:t,t:o,onChange:s}=e,{list:i}=n,u=null==i?void 0:i.find((e=>e.value===(null==t?void 0:t.value))),v=null==t?void 0:t.operator;return r(ke||(ke=Ae` ${0} ${0} `),ne({disabled:l,readonly:a,current:{label:void 0===v?"value_any":`operator_${null!=v?v:"equal"}`,value:void 0===v?"any":null!=v?v:"equal"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not}],t:o,onChange:e=>{var l,a,n;return s("any"===e?null:{operator:"equal"===e?null:e,value:null!==(n=null!==(l=null==t?void 0:t.value)&&void 0!==l?l:null===(a=null==i?void 0:i[0])||void 0===a?void 0:a.value)&&void 0!==n?n:""})}}),void 0===(null==t?void 0:t.value)?"":ne({disabled:l,readonly:a,current:null!=u?u:{label:"value_any",value:""},options:null!=i?i:[],t:o,onChange:e=>s({value:e})}))};let Se,He,je=e=>e;function De(e){const l=new Set,a=e=>{let a;if("string"==typeof e.name)a=e.path;else{const l=e.path.lastIndexOf(":");if(-1===l)return;a=e.path.substring(0,l)}a.length>0&&l.add(a)};for(const l of e)if(Array.isArray(l))for(const e of l)a(e);else a(l);return Array.from(l).join()}function Ve(e){let l=e.path;return e.name&&(l+=`:name[${e.name}]`),e.operator&&(l+=`:${e.operator}`),[l,e.value]}function Ze(e,l=!1){const a=new URLSearchParams;for(const l of e)if(Array.isArray(l)){const[e,...n]=l.map(Ve);if(e&&e[0]){const l=[e[1],...n.map((e=>e.join("=")))];a.append(e[0],l.join("|"))}}else{const[e,n]=Ve(l);e&&a.append(e,n)}if(!l){const l=De(e);l?a.set("zoom",l):a.delete("zoom")}return a.toString()}let Ie;const Te=s(Ie||(Ie=(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}input::-webkit-contacts-auto-fill-button{visibility:hidden;display:none!important;pointer-events:none;position:absolute;right:0}input::-webkit-inner-spin-button,input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input{-moz-appearance:textfield}foxy-internal-summary-control[layout=details][count]:not([open]){--lumo-contrast-5pct:var(--lumo-primary-color-10pct);color:var(--lumo-primary-text-color)}`));function Ne(e,l){var a;const n=null!==(a=Object.values(d).find((l=>e.endsWith(`:${l}`))))&&void 0!==a?a:null;let t,o=e.substring(0,n?e.lastIndexOf(":"):void 0);const r=e.lastIndexOf("[");return o.endsWith("]")&&-1!==r&&(t=o.substring(r+1,o.length-1),o=o.substring(0,r),o.endsWith(":name")&&(o=o.substring(0,o.length-5))),{name:t,path:o,value:l,operator:n}}function ze(e){const l=new URLSearchParams(e),a=[];for(const[e,n]of l.entries())n.includes("|")?a.push(n.split("|").map(((l,a)=>0===a?Ne(e,l):Ne(...l.split("="))))):a.push(Ne(e,n));return a}let Be,Ee,Ge=e=>e;const Pe=t(l(a(n(u(i),"query-builder"))));class Re extends Pe{constructor(){super(...arguments),this.reservedPaths=["zoom","limit","offset","order","fields"],this.disableZoom=!1,this.disableOr=!1,this.operators=Object.values(d),this.docsHref=null,this.options=null,this.__isAdvancedMode=!1,this.__reportedValue=null,this.__displayedValue=null}static zoom(e){return De(ze(e))}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},docsHref:{attribute:"docs-href"},options:{type:Array},value:{noAccessor:!0},__reportedValue:{attribute:!1},__displayedValue:{attribute:!1},__isAdvancedMode:{attribute:!1}})}static get styles(){return[super.styles,Te]}get value(){return this.__reportedValue}set value(e){this.__reportedValue=e,this.__displayedValue=e}render(){var l,a,n,t,o,s;const i=this.__isSimpleModeSupported,u=ze(null!==(l=this.__displayedValue)&&void 0!==l?l:""),d=null!==(a=this.operators)&&void 0!==a?a:[],c=null!==(n=this.options)&&void 0!==n?n:[],h=this.t.bind(this),b=e=>{this.__displayedValue=Ze(e,this.disableZoom);e.every((e=>Array.isArray(e)?e.every((e=>!e.invalid)):!e.invalid))&&(this.__reportedValue=this.__displayedValue,this.dispatchEvent(new Re.ChangeEvent("change")))};return i||this.__isAdvancedMode||(this.__isAdvancedMode=!0),r(Be||(Be=Ge` <div class="space-y-m"> <div class="grid grid-cols-2 gap-xs p-xs bg-contrast-5 rounded" ?hidden="${0}"> <label class="${0}"> <foxy-i18n infer="" key="mode_simple${0}"> </foxy-i18n> <input class="sr-only" type="radio" name="mode" ?disabled="${0}" ?checked="${0}" @change="${0}"> </label> <label class="${0}"> <foxy-i18n infer="" key="mode_advanced"></foxy-i18n> <input class="sr-only" type="radio" name="mode" ?checked="${0}" @change="${0}"> </label> </div> ${0} </div> `),!(null===(t=this.options)||void 0===t?void 0:t.length),p({"p-xs rounded-s text-center font-medium transition-colors":!0,"bg-base ring-1 ring-contrast-5":!this.__isAdvancedMode&&i,"hover-bg-contrast-5":this.__isAdvancedMode&&i,"focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50":!0,"cursor-pointer":i,"text-disabled":!i}),i?"":"_unsupported",!i,!this.__isAdvancedMode,(()=>this.__isAdvancedMode=!1),p({"p-xs rounded-s text-center font-medium cursor-pointer transition-colors":!0,"bg-base ring-1 ring-contrast-5":this.__isAdvancedMode,"hover-bg-contrast-5":!this.__isAdvancedMode,"focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50":!0}),this.__isAdvancedMode,(()=>this.__isAdvancedMode=!0),this.__isAdvancedMode||!i?r(Ee||(Ee=Ge` <p class="leading-s text-tertiary" ?hidden="${0}"> <foxy-i18n infer="" key="advanced_mode_notice"></foxy-i18n> <a target="_blank" class="cursor-pointer rounded-s text-secondary font-medium hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}" rel="nofollow noreferrer noopener"> <foxy-i18n infer="" key="api_reference_link"></foxy-i18n> </a> </p> ${0} `),null===this.docsHref,f(null!==(o=this.docsHref)&&void 0!==o?o:void 0),Q({disableOr:this.disableOr,disabled:this.disabled,readonly:this.readonly,rules:u,operators:d,onChange:b,options:c,t:h})):null===(s=this.__simpleModeOptions)||void 0===s?void 0:s.map((l=>function(l){var a;const{options:n,layout:t,rules:o,name:s,disabled:i,readonly:u,t:d,onChange:c}=l,h=n.filter((e=>o.find((l=>l.path===e.path)))),b=o.find((e=>"order"===e.path)),g=null===(a=null==b?void 0:b.value)||void 0===a?void 0:a.split(",").map((e=>{const[l,a="asc"]=decodeURIComponent(e).split(" ");return{path:l.trim(),order:a.trim()}}));return r(Se||(Se=je` <foxy-internal-summary-control aria-label="${0}" helper-text="" layout="${0}" label="${0}" count="${0}" infer=""> ${0} </foxy-internal-summary-control> `),l.t("query_builder_group"),f(t),t&&s?d(s):"",f(h.length||void 0),n.map((l=>{var a;const{type:n,label:t,list:s,path:h}=l,f={[v.NameValuePair]:ce,[v.Attribute]:fe,[v.Boolean]:be,[v.String]:_e,[v.Number]:xe,[v.Date]:Me,[v.Any]:_e},b=s?Oe:f[n],y=null===(a=null==g?void 0:g.find((e=>e.path===h)))||void 0===a?void 0:a.order,m=o.find((e=>e.path===h)),x=!!m||!!y;return r(He||(He=je` <div aria-label="${0}" class="${0}"> <foxy-i18n infer="" key="${0}"></foxy-i18n> <span class="transform scale-150 mr-auto ${0}">•</span> ${0} ${0} </div> `),d("query_builder_rule"),p({"flex flex-wrap items-center justify-end gap-s":!0,"bg-primary-10 text-primary":x}),t,x?"":"opacity-0",b({disabled:i,readonly:u,option:l,rule:m,t:d,onChange:l=>{if(l&&m)return Object.assign(m,l),c(o);if(l){const a={path:h,value:"",operator:null};return c([...o,e(e({},a),l)])}return c(o.filter((e=>e.path!==h)))}}),n===v.Date||n===v.Number?ne({disabled:i,readonly:u,t:d,current:{label:`order_${null!=y?y:"none"}${y?`_${n}`:""}`,value:null!=y?y:"none"},options:[{label:"order_none",value:"none"},{label:`order_asc_${n}`,value:"asc"},{label:`order_desc_${n}`,value:"desc"}],onChange:e=>{const l=(null!=g?g:[]).filter((e=>e.path!==h)).concat([{path:h,order:e}]).filter((e=>"none"!==e.order)).map((e=>`${e.path} ${e.order}`)).join(),a=o.filter((e=>"order"!==e.path));l&&a.push({path:"order",value:l,operator:null}),c(a)}}):"")})))}(e(e({},l),{},{disabled:this.disabled,readonly:this.readonly,rules:u,onChange:b,t:h})))))}get __isSimpleModeSupported(){var e;if(null===this.options)return!1;if(0===this.options.length)return!1;const l=ze(null!==(e=this.__displayedValue)&&void 0!==e?e:"");return 0===l.length||l.every((e=>{var l;return!Array.isArray(e)&&(e.operator!==d.In&&((e.operator!==d.IsDefined||"true"===e.value)&&!(!this.reservedPaths.includes(e.path)&&!(null===(l=this.options)||void 0===l?void 0:l.find((l=>l.path===e.path))))))}))}get __simpleModeOptions(){var l;return null===(l=this.options)||void 0===l?void 0:l.reduce(((l,a)=>{const n=l.find((e=>{var l;return e.name===(null===(l=a.group)||void 0===l?void 0:l.name)}));return n?n.options.push(a):l.push(e(e({},a.group),{},{options:[a]})),l}),[])}}Re.ChangeEvent=class extends CustomEvent{},Re.Operator=d,Re.Type=v,customElements.define("foxy-query-builder",Re);export{Re as Q,ze as p,Ze as s};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
|
-
import type { Option } from './types';
|
|
2
|
+
import type { Option, ConditionalOperator } from './types';
|
|
3
3
|
import { LitElement } from 'lit-element';
|
|
4
4
|
import { Operator, Type } from './types';
|
|
5
5
|
declare const Base: typeof LitElement & import("lit-element").Constructor<import("../../../mixins/inferrable").InferrableMixinHost> & {
|
|
@@ -61,8 +61,8 @@ export declare class QueryBuilder extends Base {
|
|
|
61
61
|
disableZoom: boolean;
|
|
62
62
|
/** If true, hides the UI for the "OR" operator in queries in the Advanced Mode. */
|
|
63
63
|
disableOr: boolean;
|
|
64
|
-
/** List of operators available in the builder UI. */
|
|
65
|
-
operators: Operator[];
|
|
64
|
+
/** List of operators available in the builder UI. When an operator is an object, it specifies the operator type and the paths it applies to. */
|
|
65
|
+
operators: (Operator | ConditionalOperator)[];
|
|
66
66
|
/** When provided, will display a documentation link in the Advanced Mode. */
|
|
67
67
|
docsHref: string | null;
|
|
68
68
|
/** Filter options in Simple Mode and autocomplete suggestions in Advanced Mode. */
|
|
@@ -32,7 +32,7 @@ export class QueryBuilder extends Base {
|
|
|
32
32
|
this.disableZoom = false;
|
|
33
33
|
/** If true, hides the UI for the "OR" operator in queries in the Advanced Mode. */
|
|
34
34
|
this.disableOr = false;
|
|
35
|
-
/** List of operators available in the builder UI. */
|
|
35
|
+
/** List of operators available in the builder UI. When an operator is an object, it specifies the operator type and the paths it applies to. */
|
|
36
36
|
this.operators = Object.values(Operator);
|
|
37
37
|
/** When provided, will display a documentation link in the Advanced Mode. */
|
|
38
38
|
this.docsHref = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAgB;AACzC,OAAO,EAAE,aAAa,EAAE,sCAAmC;AAC3D,OAAO,EAAE,WAAW,EAAE,oCAAiC;AACvD,OAAO,EAAE,SAAS,EAAE,6BAA0B;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAClC,OAAO,EAAE,KAAK,EAAE,yBAAsB;AACtC,OAAO,EAAE,IAAI,E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ertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Rule, Option } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { Operator, Type } from './types';\nimport { AdvancedGroup } from './components/AdvancedGroup';\nimport { SimpleGroup } from './components/SimpleGroup';\nimport { stringify } from './utils/stringify';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { styles } from './styles';\nimport { parse } from './utils/parse';\nimport { zoom } from './utils/zoom';\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 */\nexport class 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 /** Returns zoom value for a filter query. */\n static zoom(value: string): string {\n return zoom(parse(value));\n }\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 docsHref: { attribute: 'docs-href' },\n options: { type: Array },\n value: { noAccessor: true },\n __reportedValue: { attribute: false },\n __displayedValue: { attribute: false },\n __isAdvancedMode: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [super.styles, styles];\n }\n\n /** Simple Mode will not show controls for these paths unless explicitly specified in options. */\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 in the Advanced Mode. */\n disableOr = false;\n\n /** List of operators available in the builder UI. */\n operators: Operator[] = Object.values(Operator);\n\n /** When provided, will display a documentation link in the Advanced Mode. */\n docsHref: string | null = null;\n\n /** Filter options in Simple Mode and autocomplete suggestions in Advanced Mode. */\n options: Option[] | null = null;\n\n private __isAdvancedMode = false;\n\n private __reportedValue: string | null = null;\n\n private __displayedValue: string | null = null;\n\n get value(): string | null {\n return this.__reportedValue;\n }\n\n set value(newValue: string | null) {\n this.__reportedValue = newValue;\n this.__displayedValue = newValue;\n }\n\n render(): TemplateResult {\n const isSimpleModeSupported = this.__isSimpleModeSupported;\n const parsedValue = parse(this.__displayedValue ?? '');\n const operators = this.operators ?? [];\n const options = this.options ?? [];\n const t = this.t.bind(this);\n\n const onChange = (newParsedValue: (Rule | Rule[])[]) => {\n this.__displayedValue = stringify(newParsedValue, this.disableZoom);\n\n const isValid = newParsedValue.every(ruleOrGroup => {\n if (Array.isArray(ruleOrGroup)) {\n return ruleOrGroup.every(rule => !rule.invalid);\n } else {\n return !ruleOrGroup.invalid;\n }\n });\n\n if (isValid) {\n this.__reportedValue = this.__displayedValue;\n this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));\n }\n };\n\n // This will trigger a re-render but is necessary to stay in the advanced mode once the support\n // for simple mode is available again.\n if (!isSimpleModeSupported && !this.__isAdvancedMode) this.__isAdvancedMode = true;\n\n return html`\n <div class=\"space-y-m\">\n <div\n class=\"grid grid-cols-2 gap-xs p-xs bg-contrast-5 rounded\"\n ?hidden=${!this.options?.length}\n >\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': !this.__isAdvancedMode && isSimpleModeSupported,\n 'hover-bg-contrast-5': this.__isAdvancedMode && isSimpleModeSupported,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n 'cursor-pointer': isSimpleModeSupported,\n 'text-disabled': !isSimpleModeSupported,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_simple${isSimpleModeSupported ? '' : '_unsupported'}\">\n </foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?disabled=${!isSimpleModeSupported}\n ?checked=${!this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = false)}\n />\n </label>\n\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium cursor-pointer transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': this.__isAdvancedMode,\n 'hover-bg-contrast-5': !this.__isAdvancedMode,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_advanced\"></foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?checked=${this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = true)}\n />\n </label>\n </div>\n\n ${this.__isAdvancedMode || !isSimpleModeSupported\n ? html`\n <p class=\"leading-s text-tertiary\" ?hidden=${this.docsHref === null}>\n <foxy-i18n infer=\"\" key=\"advanced_mode_notice\"></foxy-i18n>\n <a\n target=\"_blank\"\n class=\"cursor-pointer rounded-s text-secondary font-medium hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=${ifDefined(this.docsHref ?? void 0)}\n rel=\"nofollow noreferrer noopener\"\n >\n <foxy-i18n infer=\"\" key=\"api_reference_link\"></foxy-i18n>\n </a>\n </p>\n\n ${AdvancedGroup({\n disableOr: this.disableOr,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue,\n operators,\n onChange,\n options,\n t,\n })}\n `\n : this.__simpleModeOptions?.map(group => {\n return SimpleGroup({\n ...group,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue as Rule[],\n onChange,\n t,\n });\n })}\n </div>\n `;\n }\n\n private get __isSimpleModeSupported() {\n if (this.options === null) return false;\n if (this.options.length === 0) return false;\n\n const parsedValue = parse(this.__displayedValue ?? '');\n if (parsedValue.length === 0) return true;\n\n return parsedValue.every(entry => {\n if (Array.isArray(entry)) return false;\n if (entry.operator === Operator.In) return false;\n if (entry.operator === Operator.IsDefined && entry.value !== 'true') return false;\n return !!(\n this.reservedPaths.includes(entry.path) ||\n this.options?.find(option => option.path === entry.path)\n );\n });\n }\n\n private get __simpleModeOptions() {\n return this.options?.reduce((result, option) => {\n const group = result.find(group => group.name === option.group?.name);\n\n if (group) {\n group.options.push(option);\n } else {\n result.push({ ...option.group, options: [option] });\n }\n\n return result;\n }, [] as { name?: string; layout?: string; options: Option[] }[]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAgB;AACzC,OAAO,EAAE,aAAa,EAAE,sCAAmC;AAC3D,OAAO,EAAE,WAAW,EAAE,oCAAiC;AACvD,OAAO,EAAE,SAAS,EAAE,6BAA0B;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAClC,OAAO,EAAE,KAAK,EAAE,yBAA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CAAC","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Rule, Option, ConditionalOperator } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { Operator, Type } from './types';\nimport { AdvancedGroup } from './components/AdvancedGroup';\nimport { SimpleGroup } from './components/SimpleGroup';\nimport { stringify } from './utils/stringify';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { styles } from './styles';\nimport { parse } from './utils/parse';\nimport { zoom } from './utils/zoom';\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 */\nexport class 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 /** Returns zoom value for a filter query. */\n static zoom(value: string): string {\n return zoom(parse(value));\n }\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 docsHref: { attribute: 'docs-href' },\n options: { type: Array },\n value: { noAccessor: true },\n __reportedValue: { attribute: false },\n __displayedValue: { attribute: false },\n __isAdvancedMode: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [super.styles, styles];\n }\n\n /** Simple Mode will not show controls for these paths unless explicitly specified in options. */\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 in the Advanced Mode. */\n disableOr = false;\n\n /** List of operators available in the builder UI. When an operator is an object, it specifies the operator type and the paths it applies to. */\n operators: (Operator | ConditionalOperator)[] = Object.values(Operator);\n\n /** When provided, will display a documentation link in the Advanced Mode. */\n docsHref: string | null = null;\n\n /** Filter options in Simple Mode and autocomplete suggestions in Advanced Mode. */\n options: Option[] | null = null;\n\n private __isAdvancedMode = false;\n\n private __reportedValue: string | null = null;\n\n private __displayedValue: string | null = null;\n\n get value(): string | null {\n return this.__reportedValue;\n }\n\n set value(newValue: string | null) {\n this.__reportedValue = newValue;\n this.__displayedValue = newValue;\n }\n\n render(): TemplateResult {\n const isSimpleModeSupported = this.__isSimpleModeSupported;\n const parsedValue = parse(this.__displayedValue ?? '');\n const operators = this.operators ?? [];\n const options = this.options ?? [];\n const t = this.t.bind(this);\n\n const onChange = (newParsedValue: (Rule | Rule[])[]) => {\n this.__displayedValue = stringify(newParsedValue, this.disableZoom);\n\n const isValid = newParsedValue.every(ruleOrGroup => {\n if (Array.isArray(ruleOrGroup)) {\n return ruleOrGroup.every(rule => !rule.invalid);\n } else {\n return !ruleOrGroup.invalid;\n }\n });\n\n if (isValid) {\n this.__reportedValue = this.__displayedValue;\n this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));\n }\n };\n\n // This will trigger a re-render but is necessary to stay in the advanced mode once the support\n // for simple mode is available again.\n if (!isSimpleModeSupported && !this.__isAdvancedMode) this.__isAdvancedMode = true;\n\n return html`\n <div class=\"space-y-m\">\n <div\n class=\"grid grid-cols-2 gap-xs p-xs bg-contrast-5 rounded\"\n ?hidden=${!this.options?.length}\n >\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': !this.__isAdvancedMode && isSimpleModeSupported,\n 'hover-bg-contrast-5': this.__isAdvancedMode && isSimpleModeSupported,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n 'cursor-pointer': isSimpleModeSupported,\n 'text-disabled': !isSimpleModeSupported,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_simple${isSimpleModeSupported ? '' : '_unsupported'}\">\n </foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?disabled=${!isSimpleModeSupported}\n ?checked=${!this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = false)}\n />\n </label>\n\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium cursor-pointer transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': this.__isAdvancedMode,\n 'hover-bg-contrast-5': !this.__isAdvancedMode,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_advanced\"></foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?checked=${this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = true)}\n />\n </label>\n </div>\n\n ${this.__isAdvancedMode || !isSimpleModeSupported\n ? html`\n <p class=\"leading-s text-tertiary\" ?hidden=${this.docsHref === null}>\n <foxy-i18n infer=\"\" key=\"advanced_mode_notice\"></foxy-i18n>\n <a\n target=\"_blank\"\n class=\"cursor-pointer rounded-s text-secondary font-medium hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=${ifDefined(this.docsHref ?? void 0)}\n rel=\"nofollow noreferrer noopener\"\n >\n <foxy-i18n infer=\"\" key=\"api_reference_link\"></foxy-i18n>\n </a>\n </p>\n\n ${AdvancedGroup({\n disableOr: this.disableOr,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue,\n operators,\n onChange,\n options,\n t,\n })}\n `\n : this.__simpleModeOptions?.map(group => {\n return SimpleGroup({\n ...group,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue as Rule[],\n onChange,\n t,\n });\n })}\n </div>\n `;\n }\n\n private get __isSimpleModeSupported() {\n if (this.options === null) return false;\n if (this.options.length === 0) return false;\n\n const parsedValue = parse(this.__displayedValue ?? '');\n if (parsedValue.length === 0) return true;\n\n return parsedValue.every(entry => {\n if (Array.isArray(entry)) return false;\n if (entry.operator === Operator.In) return false;\n if (entry.operator === Operator.IsDefined && entry.value !== 'true') return false;\n return !!(\n this.reservedPaths.includes(entry.path) ||\n this.options?.find(option => option.path === entry.path)\n );\n });\n }\n\n private get __simpleModeOptions() {\n return this.options?.reduce((result, option) => {\n const group = result.find(group => group.name === option.group?.name);\n\n if (group) {\n group.options.push(option);\n } else {\n result.push({ ...option.group, options: [option] });\n }\n\n return result;\n }, [] as { name?: string; layout?: string; options: Option[] }[]);\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Operator, Option, Rule } from '../types';
|
|
1
|
+
import type { ConditionalOperator, Operator, Option, Rule } from '../types';
|
|
2
2
|
import type { TemplateResult } from 'lit-html';
|
|
3
3
|
import type { I18n } from '../../I18n/I18n';
|
|
4
4
|
declare type Params = {
|
|
5
|
-
operators: Operator[];
|
|
5
|
+
operators: (Operator | ConditionalOperator)[];
|
|
6
6
|
disableOr: boolean;
|
|
7
7
|
isNested?: boolean;
|
|
8
8
|
disabled: boolean;
|
|
@@ -25,6 +25,7 @@ export function AdvancedGroup(params) {
|
|
|
25
25
|
AdvancedRule({
|
|
26
26
|
...params,
|
|
27
27
|
rule: { path: '', operator: null, value: '' },
|
|
28
|
+
operators: params.operators.filter(v => typeof v === 'string'),
|
|
28
29
|
isFullSize: !params.isNested && params.rules.length === 0,
|
|
29
30
|
onChange: newValue => params.onChange([...params.rules, newValue]),
|
|
30
31
|
}),
|
|
@@ -55,6 +56,9 @@ export function AdvancedGroup(params) {
|
|
|
55
56
|
AdvancedRule({
|
|
56
57
|
...params,
|
|
57
58
|
rule: rule,
|
|
59
|
+
operators: params.operators
|
|
60
|
+
.filter(v => !(typeof v === 'object') || v.paths.includes(rule.path))
|
|
61
|
+
.map(v => (typeof v === 'object' ? v.type : v)),
|
|
58
62
|
onChange: newValue => {
|
|
59
63
|
const newRules = [...params.rules];
|
|
60
64
|
newRules[ruleIndex] = newValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdvancedGroup.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/AdvancedGroup.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAchC,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,IAAI,CAAA,cAAc,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC;IAC/E,MAAM,SAAS,GAAG,IAAI,CAAA;;;UAGd,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;;;;;;;GAOrB,CAAC;IAEF,OAAO,IAAI,CAAA;sBACS,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC;QAC7C,MAAM,CACN,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EACvB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EACtC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAClB,MAAM,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC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AAQ,CAAC,EAAE;oBACnB,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;oBACnC,QAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;oBAC/B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5B,CAAC;gBACD,QAAQ,EAAE,GAAG,EAAE;oBACb,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;oBAChE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5B,CAAC;gBACD,SAAS,EAAE,GAAG,EAAE;oBACd,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;oBACnC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;oBACrE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5B,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC,CACF;;GAEJ,CAAC;AACJ,CAAC","sourcesContent":["import type { Operator, Option, Rule } from '../types';\nimport type { TemplateResult } from 'lit-html';\nimport type { I18n } from '../../I18n/I18n';\n\nimport { AdvancedRule } from './AdvancedRule';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { html } from 'lit-html';\n\ntype Params = {\n operators: Operator[];\n disableOr: boolean;\n isNested?: boolean;\n disabled: boolean;\n readonly: boolean;\n options: Option[];\n rules: (Rule | Rule[])[];\n t: I18n['t'];\n onChange: (newValue: (Rule | Rule[])[]) => void;\n};\n\nexport function AdvancedGroup(params: Params): TemplateResult {\n const hasNestedRules = params.rules.some(v => Array.isArray(v));\n const andDivider = html`<div class=${hasNestedRules ? 'h-xs' : 'mt-s'}></div>`;\n const orDivider = html`\n <div class=\"flex items-center h-s\">\n <div class=\"w-m text-center leading-none uppercase font-medium text-xs text-contrast-30\">\n ${params.t('or')}\n </div>\n\n <div class=\"flex-1 border-t border-contrast-20\"></div>\n <div class=\"w-m ml-s flex-shrink-0\"></div>\n <div class=\"hidden sm-block w-m flex-shrink-0\"></div>\n </div>\n `;\n\n return html`\n <div aria-label=${params.t('query_builder_group')}>\n ${repeat(\n [...params.rules, null],\n (rule, ruleIndex) => String(ruleIndex),\n (rule, ruleIndex) => {\n const divider = ruleIndex > 0 ? (params.isNested ? orDivider : andDivider) : '';\n\n if (rule === null) {\n return [\n divider,\n AdvancedRule({\n ...params,\n rule: { path: '', operator: null, value: '' },\n isFullSize: !params.isNested && params.rules.length === 0,\n onChange: newValue => params.onChange([...params.rules, newValue]),\n }),\n ];\n }\n\n if (Array.isArray(rule)) {\n return [\n divider,\n html`\n <div class=\"bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s\">\n ${AdvancedGroup({\n ...params,\n rules: rule,\n isNested: true,\n onChange: newRule => {\n const newValue = [...params.rules];\n const typedNewRule = newRule as Rule[];\n newValue[ruleIndex] = newRule.length > 1 ? typedNewRule : typedNewRule[0];\n params.onChange(newValue);\n },\n })}\n </div>\n `,\n ];\n }\n\n return [\n divider,\n AdvancedRule({\n ...params,\n rule: rule,\n onChange: newValue => {\n const newRules = [...params.rules];\n newRules[ruleIndex] = newValue;\n params.onChange(newRules);\n },\n onDelete: () => {\n const newRules = params.rules.filter((_, i) => i !== ruleIndex);\n params.onChange(newRules);\n },\n onConvert: () => {\n const newRules = [...params.rules];\n newRules[ruleIndex] = [rule, { ...rule, operator: null, value: '' }];\n params.onChange(newRules);\n },\n }),\n ];\n }\n )}\n </div>\n `;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AdvancedGroup.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/AdvancedGroup.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,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AAC;gBACjD,QAAQ,EAAE,QAAQ,CAAC,EAAE;oBACnB,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;oBACnC,QAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;oBAC/B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5B,CAAC;gBACD,QAAQ,EAAE,GAAG,EAAE;oBACb,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;oBAChE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5B,CAAC;gBACD,SAAS,EAAE,GAAG,EAAE;oBACd,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;oBACnC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;oBACrE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5B,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC,CACF;;GAEJ,CAAC;AACJ,CAAC","sourcesContent":["import type { ConditionalOperator, Operator, Option, Rule } from '../types';\nimport type { TemplateResult } from 'lit-html';\nimport type { I18n } from '../../I18n/I18n';\n\nimport { AdvancedRule } from './AdvancedRule';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { html } from 'lit-html';\n\ntype Params = {\n operators: (Operator | ConditionalOperator)[];\n disableOr: boolean;\n isNested?: boolean;\n disabled: boolean;\n readonly: boolean;\n options: Option[];\n rules: (Rule | Rule[])[];\n t: I18n['t'];\n onChange: (newValue: (Rule | Rule[])[]) => void;\n};\n\nexport function AdvancedGroup(params: Params): TemplateResult {\n const hasNestedRules = params.rules.some(v => Array.isArray(v));\n const andDivider = html`<div class=${hasNestedRules ? 'h-xs' : 'mt-s'}></div>`;\n const orDivider = html`\n <div class=\"flex items-center h-s\">\n <div class=\"w-m text-center leading-none uppercase font-medium text-xs text-contrast-30\">\n ${params.t('or')}\n </div>\n\n <div class=\"flex-1 border-t border-contrast-20\"></div>\n <div class=\"w-m ml-s flex-shrink-0\"></div>\n <div class=\"hidden sm-block w-m flex-shrink-0\"></div>\n </div>\n `;\n\n return html`\n <div aria-label=${params.t('query_builder_group')}>\n ${repeat(\n [...params.rules, null],\n (rule, ruleIndex) => String(ruleIndex),\n (rule, ruleIndex) => {\n const divider = ruleIndex > 0 ? (params.isNested ? orDivider : andDivider) : '';\n\n if (rule === null) {\n return [\n divider,\n AdvancedRule({\n ...params,\n rule: { path: '', operator: null, value: '' },\n operators: params.operators.filter(v => typeof v === 'string') as Operator[],\n isFullSize: !params.isNested && params.rules.length === 0,\n onChange: newValue => params.onChange([...params.rules, newValue]),\n }),\n ];\n }\n\n if (Array.isArray(rule)) {\n return [\n divider,\n html`\n <div class=\"bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s\">\n ${AdvancedGroup({\n ...params,\n rules: rule,\n isNested: true,\n onChange: newRule => {\n const newValue = [...params.rules];\n const typedNewRule = newRule as Rule[];\n newValue[ruleIndex] = newRule.length > 1 ? typedNewRule : typedNewRule[0];\n params.onChange(newValue);\n },\n })}\n </div>\n `,\n ];\n }\n\n return [\n divider,\n AdvancedRule({\n ...params,\n rule: rule,\n operators: params.operators\n .filter(v => !(typeof v === 'object') || v.paths.includes(rule.path))\n .map(v => (typeof v === 'object' ? v.type : v)),\n onChange: newValue => {\n const newRules = [...params.rules];\n newRules[ruleIndex] = newValue;\n params.onChange(newRules);\n },\n onDelete: () => {\n const newRules = params.rules.filter((_, i) => i !== ruleIndex);\n params.onChange(newRules);\n },\n onConvert: () => {\n const newRules = [...params.rules];\n newRules[ruleIndex] = [rule, { ...rule, operator: null, value: '' }];\n params.onChange(newRules);\n },\n }),\n ];\n }\n )}\n </div>\n `;\n}\n"]}
|
|
@@ -22,11 +22,11 @@ export function AdvancedOperatorToggle(params) {
|
|
|
22
22
|
class=${classMap({
|
|
23
23
|
'flex items-center justify-center w-m h-m transition-colors': true,
|
|
24
24
|
'focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50': true,
|
|
25
|
-
'text-body hover-bg-contrast-5': !isDisabled && availableOperators.length >
|
|
26
|
-
'cursor-default text-tertiary': !isDisabled && availableOperators.length
|
|
25
|
+
'text-body hover-bg-contrast-5': !isDisabled && availableOperators.length > 0,
|
|
26
|
+
'cursor-default text-tertiary': !isDisabled && availableOperators.length === 0,
|
|
27
27
|
'text-disabled cursor-default': isDisabled,
|
|
28
28
|
})}
|
|
29
|
-
?disabled=${isDisabled || availableOperators.length
|
|
29
|
+
?disabled=${isDisabled || availableOperators.length === 0}
|
|
30
30
|
@click=${() => {
|
|
31
31
|
var _a;
|
|
32
32
|
const newOperatorIndex = operator ? availableOperators.indexOf(operator) : -1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdvancedOperatorToggle.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/AdvancedOperatorToggle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,0BAAuB;AAExC,OAAO,EAAE,QAAQ,EAAE,uCAAoC;AACvD,OAAO,EAAE,QAAQ,EAAE,oBAAiB;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAWhC,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACpE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAE7C,MAAM,cAAc,GAAsC;QACxD,CAAC,QAAQ,CAAC,WAAW,CAAC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AAI,CAAA;;cAEC,CAAC,CAAC,YAAY,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,EAAE,CAAC;cACpC,QAAQ,CAAC;QACf,4DAA4D,EAAE,IAAI;QAClE,wEAAwE,EAAE,IAAI;QAC9E,+BAA+B,EAAE,CAAC,UAAU,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC;QAC7E,8BAA8B,EAAE,CAAC,UAAU,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC;QAC9E,8BAA8B,EAAE,UAAU;KAC3C,CAAC;kBACU,UAAU,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC;eAChD,GAAG,EAAE;;QACZ,MAAM,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9E,MAAM,WAAW,SAAG,kBAAkB,CAAC,gBAAgB,GAAG,CAAC,CAAC,mCAAI,IAAI,CAAC;QACrE,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;;gCAEyB,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa;;GAEtF,CAAC;AACJ,CAAC","sourcesContent":["import type { SVGTemplateResult, TemplateResult } from 'lit-html';\nimport type { Rule } from '../types';\nimport type { I18n } from '../../I18n/I18n';\n\nimport * as icons from '../icons/index';\n\nimport { classMap } from '../../../../utils/class-map';\nimport { Operator } from '../types';\nimport { html } from 'lit-html';\n\ntype Params = {\n operators: Operator[];\n readonly: boolean;\n disabled: boolean;\n rule: Rule;\n t: I18n['t'];\n onChange: (newValue: Rule) => void;\n};\n\nexport function AdvancedOperatorToggle(params: Params): TemplateResult {\n const { rule, operators, disabled, readonly, t, onChange } = params;\n const { operator, value, path, name } = rule;\n\n const operatorToIcon: Record<string, SVGTemplateResult> = {\n [Operator.GreaterThan]: icons.operatorGreaterThan,\n [Operator.GreaterThanOrEqual]: icons.operatorGreaterThanOrEqual,\n [Operator.In]: icons.operatorIn,\n [Operator.IsDefined]: icons.operatorIsDefined,\n [Operator.LessThan]: icons.operatorLessThan,\n [Operator.LessThanOrEqual]: icons.operatorLessThanOrEqual,\n [Operator.Not]: icons.operatorNot,\n };\n\n const availableOperators = Object.values(Operator).filter(\n v => operators.includes(v) && (name ? true : v !== Operator.IsDefined)\n );\n\n const isDisabled = disabled || readonly || !availableOperators.length || !path;\n\n return html`\n <button\n title=${t(`operator_${operator ?? 'equal'}`)}\n class=${classMap({\n 'flex items-center justify-center w-m h-m transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50': true,\n 'text-body hover-bg-contrast-5': !isDisabled && availableOperators.length > 0,\n 'cursor-default text-tertiary': !isDisabled && availableOperators.length === 0,\n 'text-disabled cursor-default': isDisabled,\n })}\n ?disabled=${isDisabled || availableOperators.length === 0}\n @click=${() => {\n const newOperatorIndex = operator ? availableOperators.indexOf(operator) : -1;\n const newOperator = availableOperators[newOperatorIndex + 1] ?? null;\n onChange({ ...rule, operator: newOperator, value: value });\n }}\n >\n <div aria-hidden=\"true\">${operator ? operatorToIcon[operator] : icons.operatorEqual}</div>\n </button>\n `;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SimpleNameValuePairRule } from "./SimpleNameValuePairRule.js";
|
|
1
2
|
import { SimpleAttributeRule } from "./SimpleAttributeRule.js";
|
|
2
3
|
import { SimpleBooleanRule } from "./SimpleBooleanRule.js";
|
|
3
4
|
import { SimpleNumberRule } from "./SimpleNumberRule.js";
|
|
@@ -31,6 +32,7 @@ export function SimpleGroup(params) {
|
|
|
31
32
|
var _a;
|
|
32
33
|
const { type, label, list, path } = option;
|
|
33
34
|
const controlsRenderers = {
|
|
35
|
+
[Type.NameValuePair]: SimpleNameValuePairRule,
|
|
34
36
|
[Type.Attribute]: SimpleAttributeRule,
|
|
35
37
|
[Type.Boolean]: SimpleBooleanRule,
|
|
36
38
|
[Type.String]: SimpleStringRule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleGroup.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/SimpleGroup.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AACxD,OAAO,EAAE,gBAAgB,EAAE,8BAA2B;AACtD,OAAO,EAAE,gBAAgB,EAAE,8BAA2B;AACtD,OAAO,EAAE,cAAc,EAAE,4BAAyB;AAClD,OAAO,EAAE,cAAc,EAAE,4BAAyB;AAClD,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,uCAAoC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,oBAAiB;AAahC,MAAM,UAAU,WAAW,CAAC,MAAc;;IACxC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAEjF,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChF,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IACtD,MAAM,eAAe,SAAG,SAAS,aAAT,SAAS,uBAAT,SAAS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Q,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;qBACxE;oBAED,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACrB,CAAC;aACF,CAAC;YACJ,CAAC,CAAC,EAAE;;SAET,CAAC;IACJ,CAAC,CAAC;;GAEL,CAAC;AACJ,CAAC","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { Option, Rule } from '../types';\n\nimport { SimpleAttributeRule } from './SimpleAttributeRule';\nimport { SimpleBooleanRule } from './SimpleBooleanRule';\nimport { SimpleNumberRule } from './SimpleNumberRule';\nimport { SimpleStringRule } from './SimpleStringRule';\nimport { SimpleDateRule } from './SimpleDateRule';\nimport { SimpleListRule } from './SimpleListRule';\nimport { SimpleSelect } from './SimpleSelect';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../../utils/class-map';\nimport { html } from 'lit-html';\nimport { Type } from '../types';\n\ntype Params = {\n disabled: boolean;\n readonly: boolean;\n options: Option[];\n layout?: string;\n rules: Rule[];\n name?: string;\n t: (key: string) => string;\n onChange: (newParsedValue: Rule[]) => void;\n};\n\nexport function SimpleGroup(params: Params): TemplateResult {\n const { options, layout, rules, name, disabled, readonly, t, onChange } = params;\n\n const editedOptions = options.filter(v => rules.find(vv => vv.path === v.path));\n const orderRule = rules.find(v => v.path === 'order');\n const parsedOrderRule = orderRule?.value?.split(',').map(v => {\n const [path, order = 'asc'] = decodeURIComponent(v).split(' ');\n return { path: path.trim(), order: order.trim() };\n });\n\n return html`\n <foxy-internal-summary-control\n aria-label=${params.t('query_builder_group')}\n helper-text=\"\"\n layout=${ifDefined(layout)}\n label=${layout && name ? t(name) : ''}\n count=${ifDefined(editedOptions.length || void 0)}\n infer=\"\"\n >\n ${options.map(option => {\n const { type, label, list, path } = option;\n\n const controlsRenderers = {\n [Type.Attribute]: SimpleAttributeRule,\n [Type.Boolean]: SimpleBooleanRule,\n [Type.String]: SimpleStringRule,\n [Type.Number]: SimpleNumberRule,\n [Type.Date]: SimpleDateRule,\n [Type.Any]: SimpleStringRule,\n } as const;\n\n const Control = list ? SimpleListRule : controlsRenderers[type];\n const order = parsedOrderRule?.find(v => v.path === path)?.order;\n const rule = rules.find(rule => rule.path === path);\n const isDirty = !!rule || !!order;\n\n return html`\n <div\n aria-label=${t('query_builder_rule')}\n class=${classMap({\n 'flex flex-wrap items-center justify-end gap-s': true,\n 'bg-primary-10 text-primary': isDirty,\n })}\n >\n <foxy-i18n infer=\"\" key=${label}></foxy-i18n>\n <span class=\"transform scale-150 mr-auto ${isDirty ? '' : 'opacity-0'}\">•</span>\n ${Control({\n disabled,\n readonly,\n option,\n rule,\n t,\n onChange: newParsedValue => {\n if (newParsedValue && rule) {\n Object.assign(rule, newParsedValue);\n return onChange(rules);\n } else if (newParsedValue) {\n const defaults = { path: path, value: '', operator: null };\n return onChange([...rules, { ...defaults, ...newParsedValue }]);\n } else {\n return onChange(rules.filter(v => v.path !== path));\n }\n },\n })}\n ${type === Type.Date || type === Type.Number\n ? SimpleSelect({\n disabled,\n readonly,\n t,\n current: {\n label: `order_${order ?? 'none'}${order ? `_${type}` : ''}`,\n value: order ?? 'none',\n },\n options: [\n { label: 'order_none', value: 'none' },\n { label: `order_asc_${type}`, value: 'asc' },\n { label: `order_desc_${type}`, value: 'desc' },\n ],\n onChange: newSelection => {\n const newParsedOrderRule = (parsedOrderRule ?? [])\n .filter(v => v.path !== path)\n .concat([{ path, order: newSelection }]);\n\n const newOrderValue = newParsedOrderRule\n .filter(v => v.order !== 'none')\n .map(v => `${v.path} ${v.order}`)\n .join();\n\n const newRules = rules.filter(v => v.path !== 'order');\n if (newOrderValue) {\n newRules.push({ path: 'order', value: newOrderValue, operator: null });\n }\n\n onChange(newRules);\n },\n })\n : ''}\n </div>\n `;\n })}\n </foxy-internal-summary-control>\n `;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SimpleGroup.js","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E,IAAI,EAAE,CAAC,CAAC;qBACxE;oBAED,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACrB,CAAC;aACF,CAAC;YACJ,CAAC,CAAC,EAAE;;SAET,CAAC;IACJ,CAAC,CAAC;;GAEL,CAAC;AACJ,CAAC","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { Option, Rule } from '../types';\n\nimport { SimpleNameValuePairRule } from './SimpleNameValuePairRule';\nimport { SimpleAttributeRule } from './SimpleAttributeRule';\nimport { SimpleBooleanRule } from './SimpleBooleanRule';\nimport { SimpleNumberRule } from './SimpleNumberRule';\nimport { SimpleStringRule } from './SimpleStringRule';\nimport { SimpleDateRule } from './SimpleDateRule';\nimport { SimpleListRule } from './SimpleListRule';\nimport { SimpleSelect } from './SimpleSelect';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../../utils/class-map';\nimport { html } from 'lit-html';\nimport { Type } from '../types';\n\ntype Params = {\n disabled: boolean;\n readonly: boolean;\n options: Option[];\n layout?: string;\n rules: Rule[];\n name?: string;\n t: (key: string) => string;\n onChange: (newParsedValue: Rule[]) => void;\n};\n\nexport function SimpleGroup(params: Params): TemplateResult {\n const { options, layout, rules, name, disabled, readonly, t, onChange } = params;\n\n const editedOptions = options.filter(v => rules.find(vv => vv.path === v.path));\n const orderRule = rules.find(v => v.path === 'order');\n const parsedOrderRule = orderRule?.value?.split(',').map(v => {\n const [path, order = 'asc'] = decodeURIComponent(v).split(' ');\n return { path: path.trim(), order: order.trim() };\n });\n\n return html`\n <foxy-internal-summary-control\n aria-label=${params.t('query_builder_group')}\n helper-text=\"\"\n layout=${ifDefined(layout)}\n label=${layout && name ? t(name) : ''}\n count=${ifDefined(editedOptions.length || void 0)}\n infer=\"\"\n >\n ${options.map(option => {\n const { type, label, list, path } = option;\n\n const controlsRenderers = {\n [Type.NameValuePair]: SimpleNameValuePairRule,\n [Type.Attribute]: SimpleAttributeRule,\n [Type.Boolean]: SimpleBooleanRule,\n [Type.String]: SimpleStringRule,\n [Type.Number]: SimpleNumberRule,\n [Type.Date]: SimpleDateRule,\n [Type.Any]: SimpleStringRule,\n } as const;\n\n const Control = list ? SimpleListRule : controlsRenderers[type];\n const order = parsedOrderRule?.find(v => v.path === path)?.order;\n const rule = rules.find(rule => rule.path === path);\n const isDirty = !!rule || !!order;\n\n return html`\n <div\n aria-label=${t('query_builder_rule')}\n class=${classMap({\n 'flex flex-wrap items-center justify-end gap-s': true,\n 'bg-primary-10 text-primary': isDirty,\n })}\n >\n <foxy-i18n infer=\"\" key=${label}></foxy-i18n>\n <span class=\"transform scale-150 mr-auto ${isDirty ? '' : 'opacity-0'}\">•</span>\n ${Control({\n disabled,\n readonly,\n option,\n rule,\n t,\n onChange: newParsedValue => {\n if (newParsedValue && rule) {\n Object.assign(rule, newParsedValue);\n return onChange(rules);\n } else if (newParsedValue) {\n const defaults = { path: path, value: '', operator: null };\n return onChange([...rules, { ...defaults, ...newParsedValue }]);\n } else {\n return onChange(rules.filter(v => v.path !== path));\n }\n },\n })}\n ${type === Type.Date || type === Type.Number\n ? SimpleSelect({\n disabled,\n readonly,\n t,\n current: {\n label: `order_${order ?? 'none'}${order ? `_${type}` : ''}`,\n value: order ?? 'none',\n },\n options: [\n { label: 'order_none', value: 'none' },\n { label: `order_asc_${type}`, value: 'asc' },\n { label: `order_desc_${type}`, value: 'desc' },\n ],\n onChange: newSelection => {\n const newParsedOrderRule = (parsedOrderRule ?? [])\n .filter(v => v.path !== path)\n .concat([{ path, order: newSelection }]);\n\n const newOrderValue = newParsedOrderRule\n .filter(v => v.order !== 'none')\n .map(v => `${v.path} ${v.order}`)\n .join();\n\n const newRules = rules.filter(v => v.path !== 'order');\n if (newOrderValue) {\n newRules.push({ path: 'order', value: newOrderValue, operator: null });\n }\n\n onChange(newRules);\n },\n })\n : ''}\n </div>\n `;\n })}\n </foxy-internal-summary-control>\n `;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
2
2
|
import { classMap } from "../../../../utils/class-map.js";
|
|
3
3
|
import { html } from 'lit-html';
|
|
4
|
+
const debounceTimers = new WeakMap();
|
|
4
5
|
export function SimpleInput(params) {
|
|
5
6
|
const { disabled, readonly, layout, label, value, type, min, t, onChange } = params;
|
|
6
7
|
return html `
|
|
@@ -40,7 +41,12 @@ export function SimpleInput(params) {
|
|
|
40
41
|
@keydown=${(evt) => evt.key === '|' && evt.preventDefault()}
|
|
41
42
|
@input=${(evt) => {
|
|
42
43
|
const input = evt.currentTarget;
|
|
43
|
-
|
|
44
|
+
const newValue = input.value.replace(/\|/gi, '');
|
|
45
|
+
const existingTimer = debounceTimers.get(input);
|
|
46
|
+
if (existingTimer)
|
|
47
|
+
clearTimeout(existingTimer);
|
|
48
|
+
const timer = setTimeout(() => onChange(newValue), 500);
|
|
49
|
+
debounceTimers.set(input, timer);
|
|
44
50
|
}}
|
|
45
51
|
/>
|
|
46
52
|
`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleInput.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/SimpleInput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,uCAAoC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"SimpleInput.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/SimpleInput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,uCAAoC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,cAAc,GAAG,IAAI,OAAO,EAAoC,CAAC;AAcvE,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,EAAE,QAAQ,E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a,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,aAAa;gBAAE,YAAY,CAAC,aAAa,CAAC,CAAC;YAE/C,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;YACxD,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnC,CAAC;;WAEJ;;GAER,CAAC;AACJ,CAAC","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { I18n } from '../../I18n/I18n';\n\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../../utils/class-map';\nimport { html } from 'lit-html';\n\nconst debounceTimers = new WeakMap<HTMLInputElement, NodeJS.Timeout>();\n\ntype Params = {\n disabled: boolean;\n readonly: boolean;\n layout?: 'auto-grow' | 'fixed';\n value: string;\n label: string;\n type?: string;\n min?: string | number;\n t: I18n['t'];\n onChange: (newValue: string) => void;\n};\n\nexport function SimpleInput(params: Params): TemplateResult {\n const { disabled, readonly, layout, label, value, type, min, t, onChange } = params;\n\n return html`\n <label\n class=\"flex-shrink-0 flex items-center gap-s relative\"\n style=\"min-width: ${type === 'number' ? '4' : type === 'date' ? '6' : '8'}rem; max-width: 50%\"\n >\n <foxy-i18n infer=\"\" class=${classMap({ 'sr-only': layout !== 'fixed' })} key=${label}>\n </foxy-i18n>\n\n <span\n class=${classMap({\n 'relative block whitespace-pre text-m': true,\n 'px-s py-xs -my-xs font-medium opacity-0': !readonly,\n 'text-contrast-80': readonly,\n })}\n ?hidden=${layout !== 'auto-grow' && !readonly}\n >${value || html`<foxy-i18n infer=\"\" key=\"value_empty\"></foxy-i18n>`}</span\n >\n\n ${readonly\n ? ''\n : html`\n <input\n placeholder=${t('value_empty')}\n class=${classMap({\n 'appearance-none transition-all text-body text-m font-medium rounded-s': true,\n 'bg-base px-s py-xs -my-xs': true,\n 'opacity-50': disabled,\n 'absolute inset-0': layout === 'auto-grow',\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n })}\n ?disabled=${disabled}\n type=${ifDefined(type)}\n min=${ifDefined(min)}\n .value=${value}\n @keydown=${(evt: KeyboardEvent) => evt.key === '|' && evt.preventDefault()}\n @input=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n const newValue = input.value.replace(/\\|/gi, '');\n\n const existingTimer = debounceTimers.get(input);\n if (existingTimer) clearTimeout(existingTimer);\n\n const timer = setTimeout(() => onChange(newValue), 500);\n debounceTimers.set(input, timer);\n }}\n />\n `}\n </label>\n `;\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { SimpleSelect } from "./SimpleSelect.js";
|
|
2
|
+
import { SimpleInput } from "./SimpleInput.js";
|
|
3
|
+
import { Operator } from "../types.js";
|
|
4
|
+
import { classMap } from "../../../../utils/class-map.js";
|
|
5
|
+
import { html } from 'lit-html';
|
|
6
|
+
export const SimpleNameValuePairRule = params => {
|
|
7
|
+
var _a;
|
|
8
|
+
const { operator, value, name } = (_a = params.rule) !== null && _a !== void 0 ? _a : {};
|
|
9
|
+
const { disabled, readonly, t } = params;
|
|
10
|
+
const not = Operator.Not;
|
|
11
|
+
const labelClass = classMap({ 'text-disabled': disabled, 'text-contrast-80': readonly });
|
|
12
|
+
const displayedOperator = operator === null ? (value === '*' ? null : 'equal') : operator === not ? not : null;
|
|
13
|
+
return html `
|
|
14
|
+
<foxy-i18n class=${labelClass} infer="" key="name"></foxy-i18n>
|
|
15
|
+
|
|
16
|
+
${SimpleInput({
|
|
17
|
+
layout: 'auto-grow',
|
|
18
|
+
value: name || '',
|
|
19
|
+
label: 'name',
|
|
20
|
+
type: 'text',
|
|
21
|
+
disabled,
|
|
22
|
+
readonly,
|
|
23
|
+
t,
|
|
24
|
+
onChange: newValue => {
|
|
25
|
+
if (!newValue)
|
|
26
|
+
return params.onChange(null);
|
|
27
|
+
if (value) {
|
|
28
|
+
params.onChange({ name: newValue });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
params.onChange({ name: newValue, operator: null, value: '*' });
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
})}
|
|
35
|
+
|
|
36
|
+
<foxy-i18n class=${labelClass} infer="" key="value"></foxy-i18n>
|
|
37
|
+
|
|
38
|
+
${SimpleSelect({
|
|
39
|
+
current: {
|
|
40
|
+
label: displayedOperator ? `operator_${displayedOperator}` : 'value_any',
|
|
41
|
+
value: displayedOperator !== null && displayedOperator !== void 0 ? displayedOperator : 'any',
|
|
42
|
+
},
|
|
43
|
+
options: [
|
|
44
|
+
{ label: 'value_any', value: 'any' },
|
|
45
|
+
{ label: 'operator_equal', value: 'equal' },
|
|
46
|
+
{ label: 'operator_not', value: not },
|
|
47
|
+
],
|
|
48
|
+
disabled,
|
|
49
|
+
readonly,
|
|
50
|
+
t,
|
|
51
|
+
onChange: newValue => {
|
|
52
|
+
if (newValue === 'any') {
|
|
53
|
+
params.onChange(name ? { operator: null, value: '*' } : null);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return params.onChange({
|
|
57
|
+
operator: newValue === 'equal' ? null : newValue,
|
|
58
|
+
value: newValue === 'equal' && value === '*' ? '' : value !== null && value !== void 0 ? value : '',
|
|
59
|
+
name: name !== null && name !== void 0 ? name : '',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
})}
|
|
64
|
+
${value === undefined || (operator === null && value === '*')
|
|
65
|
+
? ''
|
|
66
|
+
: SimpleInput({
|
|
67
|
+
layout: 'auto-grow',
|
|
68
|
+
label: 'value',
|
|
69
|
+
value: value || '',
|
|
70
|
+
type: 'text',
|
|
71
|
+
disabled,
|
|
72
|
+
readonly,
|
|
73
|
+
t,
|
|
74
|
+
onChange: newValue => params.onChange({ value: newValue }),
|
|
75
|
+
})}
|
|
76
|
+
`;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=SimpleNameValuePairRule.js.map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AAE,CAAC,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE;oBAC/D,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE;iBACjB,CAAC,CAAC;aACJ;QACH,CAAC;KACF,CAAC;MACA,KAAK,KAAK,SAAS,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,KAAK,GAAG,CAAC;QAC3D,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,WAAW,CAAC;YACV,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,EAAE,MAAM;YACZ,QAAQ;YACR,QAAQ;YACR,CAAC;YACD,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;SAC3D,CAAC;GACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SimpleRuleComponent } from '../types';\n\nimport { SimpleSelect } from './SimpleSelect';\nimport { SimpleInput } from './SimpleInput';\nimport { Operator } from '../types';\nimport { classMap } from '../../../../utils/class-map';\nimport { html } from 'lit-html';\n\nexport const SimpleNameValuePairRule: SimpleRuleComponent = params => {\n const { operator, value, name } = params.rule ?? {};\n const { disabled, readonly, t } = params;\n\n const not = Operator.Not;\n const labelClass = classMap({ 'text-disabled': disabled, 'text-contrast-80': readonly });\n const displayedOperator =\n operator === null ? (value === '*' ? null : 'equal') : operator === not ? not : null;\n\n return html`\n <foxy-i18n class=${labelClass} infer=\"\" key=\"name\"></foxy-i18n>\n\n ${SimpleInput({\n layout: 'auto-grow',\n value: name || '',\n label: 'name',\n type: 'text',\n disabled,\n readonly,\n t,\n onChange: newValue => {\n if (!newValue) return params.onChange(null);\n if (value) {\n params.onChange({ name: newValue });\n } else {\n params.onChange({ name: newValue, operator: null, value: '*' });\n }\n },\n })}\n\n <foxy-i18n class=${labelClass} infer=\"\" key=\"value\"></foxy-i18n>\n\n ${SimpleSelect({\n current: {\n label: displayedOperator ? `operator_${displayedOperator}` : 'value_any',\n value: displayedOperator ?? 'any',\n },\n options: [\n { label: 'value_any', value: 'any' },\n { label: 'operator_equal', value: 'equal' },\n { label: 'operator_not', value: not },\n ],\n disabled,\n readonly,\n t,\n onChange: newValue => {\n if (newValue === 'any') {\n params.onChange(name ? { operator: null, value: '*' } : null);\n } else {\n return params.onChange({\n operator: newValue === 'equal' ? null : (newValue as Operator),\n value: newValue === 'equal' && value === '*' ? '' : value ?? '',\n name: name ?? '',\n });\n }\n },\n })}\n ${value === undefined || (operator === null && value === '*')\n ? ''\n : SimpleInput({\n layout: 'auto-grow',\n label: 'value',\n value: value || '',\n type: 'text',\n disabled,\n readonly,\n t,\n onChange: newValue => params.onChange({ value: newValue }),\n })}\n `;\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TemplateResult } from 'lit-html';
|
|
2
2
|
import type { I18n } from '../I18n/I18n';
|
|
3
3
|
export declare enum Type {
|
|
4
|
+
NameValuePair = "name_value_pair",
|
|
4
5
|
Attribute = "attribute",
|
|
5
6
|
Boolean = "boolean",
|
|
6
7
|
String = "string",
|
|
@@ -49,3 +50,7 @@ export declare type SimpleRuleComponent = (params: {
|
|
|
49
50
|
t: I18n['t'];
|
|
50
51
|
onChange: (newValue: Partial<Omit<Rule, 'path'>> | null) => void;
|
|
51
52
|
}) => TemplateResult;
|
|
53
|
+
export declare type ConditionalOperator = {
|
|
54
|
+
type: Operator;
|
|
55
|
+
paths: string[];
|
|
56
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,IAQX;AARD,WAAY,IAAI;IACd,yCAAiC,CAAA;IACjC,+BAAuB,CAAA;IACvB,2BAAmB,CAAA;IACnB,yBAAiB,CAAA;IACjB,yBAAiB,CAAA;IACjB,qBAAa,CAAA;IACb,mBAAW,CAAA;AACb,CAAC,EARW,IAAI,KAAJ,IAAI,QAQf;AAED,MAAM,CAAN,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,+CAAmC,CAAA;IACnC,iCAAqB,CAAA;IACrB,qDAAyC,CAAA;IACzC,uCAA2B,CAAA;IAC3B,mCAAuB,CAAA;IACvB,uBAAW,CAAA;IACX,qBAAS,CAAA;AACX,CAAC,EARW,QAAQ,KAAR,QAAQ,QAQnB","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { I18n } from '../I18n/I18n';\n\nexport enum Type {\n NameValuePair = 'name_value_pair',\n Attribute = 'attribute',\n Boolean = 'boolean',\n String = 'string',\n Number = 'number',\n Date = 'date',\n Any = 'any',\n}\n\nexport enum Operator {\n LessThanOrEqual = 'lessthanorequal',\n LessThan = 'lessthan',\n GreaterThanOrEqual = 'greaterthanorequal',\n GreaterThan = 'greaterthan',\n IsDefined = 'isdefined',\n Not = 'not',\n In = 'in',\n}\n\nexport type Option = {\n group?: { name: string; layout?: string };\n label: string;\n list?: ({ value: string } & ({ label: string } | { rawLabel: string }))[];\n path: string;\n type: Type;\n min?: number | string;\n};\n\nexport type Rule = {\n operator: Operator | null;\n invalid?: boolean;\n value: string;\n name?: string;\n path: string;\n};\n\nexport type SimpleRuleComponent = (params: {\n disabled: boolean;\n readonly: boolean;\n option: Option;\n rule: Rule | undefined;\n t: I18n['t'];\n onChange: (newValue: Partial<Omit<Rule, 'path'>> | null) => void;\n}) => TemplateResult;\n\nexport type ConditionalOperator = { type: Operator; paths: string[] };\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxy.io/elements",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.53.0-beta.1",
|
|
5
5
|
"description": "E-commerce web components by Foxy.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prepack": "npm run lint && rimraf dist && node ./.build/compile-for-npm.js && rollup -c"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@foxy.io/sdk": "^1.16.
|
|
30
|
+
"@foxy.io/sdk": "^1.16.2",
|
|
31
31
|
"@open-wc/lit-helpers": "^0.3.12",
|
|
32
32
|
"@open-wc/scoped-elements": "^1.2.1",
|
|
33
33
|
"@polymer/iron-icons": "^3.0.1",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import"./shared-19073761.js";import"./shared-db623837.js";import"./shared-da31cee5.js";import"./shared-9b35fe34.js";import{_ as e}from"./shared-8f9014ff.js";import{R as l,T as a,a as n}from"./shared-887ac0b0.js";import{C as t}from"./shared-41c9c53f.js";import{s as r,h as o,c as s,L as i}from"./shared-ba5c42c7.js";import{I as u}from"./shared-930e68b7.js";import{O as d,T as v}from"./shared-8874ec69.js";import{o as c}from"./shared-63c32024.js";import{c as p}from"./shared-4e709717.js";import{r as h}from"./shared-5fd5805c.js";import{i as f}from"./shared-53e42a77.js";import{s as b}from"./shared-2061be9a.js";import{p as g}from"./shared-e650caf3.js";let y;const m=r(y||(y=(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 x;const $=r(x||(x=(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 C;const _=r(C||(C=(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 w;const L=r(w||(w=(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 M;const q=r(M||(M=(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 k;const A=r(k||(k=(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 S=r(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 H;const D=r(H||(H=(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 j,Z=e=>e;let V,I,T=e=>e;function N(e){return o(V||(V=T` <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}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} </label> `),e.t(e.label),p({"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}),e.value,e.disabled||e.readonly,(e=>"|"===e.key&&e.preventDefault()),(l=>{const a=l.currentTarget;e.onChange(a.value.replace(/\|/gi,""))}),p({"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":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.disabled||e.readonly?"":o(I||(I=T` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}let z,B,E=e=>e;function G(l){var a,n;const{isFullSize:t,isNested:r,disableOr:s,readonly:i,disabled:u,rule:v}=l,{t:h,onConvert:f,onDelete:b,onChange:g}=l;return o(z||(z=E` <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"> <div aria-hidden="true" class="${0}"> ${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> `),h("query_builder_rule"),p({"flex-1 bg-base rounded overflow-hidden border":!0,"border-contrast-10":!r&&!i,"border-contrast-50":!!r||i,"border-dashed":i,"border-solid":!i}),p({"text-tertiary":!i&&!u,"text-disabled":i||u,"w-m h-m":!0}),D,v.path&&v.name?o(B||(B=E` <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> `),N(e(e({},l),{},{value:v.path,label:"field",onChange:e=>{g({operator:null,value:"",path:e})}})),N(e(e({},l),{},{value:null!==(a=v.name)&&void 0!==a?a:"",label:"name",onChange:l=>g(e(e({},v),{},{name:l}))}))):N(e(e({},l),{},{value:v.path,label:"field",onChange:e=>g({operator:null,value:"",path:e})})),function(l){const{rule:a,operators:n,disabled:t,readonly:r,t:s,onChange:i}=l,{operator:u,value:v,path:h,name:f}=a,b={[d.GreaterThan]:$,[d.GreaterThanOrEqual]:c,[d.In]:_,[d.IsDefined]:L,[d.LessThan]:q,[d.LessThanOrEqual]:A,[d.Not]:S},g=Object.values(d).filter((e=>n.includes(e)&&(!!f||e!==d.IsDefined))),y=t||r||!g.length||!h;return o(j||(j=Z` <button title="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div aria-hidden="true">${0}</div> </button> `),s(`operator_${null!=u?u:"equal"}`),p({"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":!y&&g.length>1,"cursor-default text-tertiary":!y&&g.length<=1,"text-disabled cursor-default":y}),y||g.length<=1,(()=>{var l;const n=u?g.indexOf(u):-1,t=null!==(l=g[n+1])&&void 0!==l?l:null;i(e(e({},a),{},{operator:t,value:v}))}),u?b[u]:m)}(l),N(e(e({},l),{},{disabled:u||!v.path,value:null!==(n=v.value)&&void 0!==n?n:"",label:"value",onChange:l=>g(e(e({},v),{},{value:l}))})),p({"-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:!!t||i,flex:!t}),h("delete"),p({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!u,"cursor-default text-disabled":u,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!v.path}),u||i||!v.path,b,h("add_or_clause"),p({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-success hover-bg-contrast-5":!u,"cursor-default text-disabled":u,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0 pointer-events-none":!v.path||!!r||s}),u||i||!v.path||!!r||s,s,f)}let P,R,F,U,W=e=>e;function Q(l){const a=l.rules.some((e=>Array.isArray(e))),n=o(P||(P=W`<div class="${0}"></div>`),a?"h-xs":"mt-s"),t=o(R||(R=W` <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 o(F||(F=W` <div aria-label="${0}"> ${0} </div> `),l.t("query_builder_group"),h([...l.rules,null],((e,l)=>String(l)),((a,r)=>{const s=r>0?l.isNested?t:n:"";return null===a?[s,G(e(e({},l),{},{rule:{path:"",operator:null,value:""},isFullSize:!l.isNested&&0===l.rules.length,onChange:e=>l.onChange([...l.rules,e])}))]:Array.isArray(a)?[s,o(U||(U=W` <div class="bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s"> ${0} </div> `),Q(e(e({},l),{},{rules:a,isNested:!0,onChange:e=>{const a=[...l.rules],n=e;a[r]=e.length>1?n:n[0],l.onChange(a)}})))]:[s,G(e(e({},l),{},{rule:a,onChange:e=>{const a=[...l.rules];a[r]=e,l.onChange(a)},onDelete:()=>{const e=l.rules.filter(((e,l)=>l!==r));l.onChange(e)},onConvert:()=>{const n=[...l.rules];n[r]=[a,e(e({},a),{},{operator:null,value:""})],l.onChange(n)}}))]})))}let J,K,X,Y,ee,le,ae=e=>e;function ne(e){const{t:l,disabled:a,readonly:n,current:t,options:s,onChange:i}=e;return o(J||(J=ae` <div class="${0}"> ${0} ${0} </div> `),p({"relative flex items-center gap-xs leading-m px-xs -m-xs rounded-s transition-colors":!0,"focus-within-ring-2 focus-within-ring-primary-50":!0,"text-contrast":!a&&!n,"hover-text-contrast-80":!a&&!n,"text-disabled":a,"text-contrast-80":n,"font-medium":!n}),"label"in t?o(K||(K=ae`<foxy-i18n infer="" key="${0}"></foxy-i18n>`),t.label):o(X||(X=ae`<span>${0}</span>`),t.rawLabel),n?"":o(Y||(Y=ae` ${0} <select class="${0}" ?disabled="${0}" @change="${0}"> ${0} </select> `),r(ee||(ee=ae`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex-shrink-0" style="width: 1em; height: 1em; transform: scale(1.25)"><path fill-rule="evenodd" d="M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z" clip-rule="evenodd" /></svg>`)),p({"absolute inset-0 opacity-0 focus-outline-none":!0,"cursor-pointer":!a,"cursor-default":a}),a,(e=>i(e.target.value)),s.map((e=>o(le||(le=ae` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.value,e.value===t.value,"label"in e?l(e.label):e.rawLabel)))))}let te,re,oe,se=e=>e;function ie(e){const{disabled:l,readonly:a,layout:n,label:t,value:r,type:s,min:i,t:u,onChange:d}=e;return o(te||(te=se` <label class="flex-shrink-0 flex items-center gap-s relative" style="min-width:${0}rem;max-width:50%"> <foxy-i18n infer="" class="${0}" key="${0}"> </foxy-i18n> <span class="${0}" ?hidden="${0}">${0}</span> ${0} </label> `),"number"===s?"4":"date"===s?"6":"8",p({"sr-only":"fixed"!==n}),t,p({"relative block whitespace-pre text-m":!0,"px-s py-xs -my-xs font-medium opacity-0":!a,"text-contrast-80":a}),"auto-grow"!==n&&!a,r||o(re||(re=se`<foxy-i18n infer="" key="value_empty"></foxy-i18n>`)),a?"":o(oe||(oe=se` <input placeholder="${0}" class="${0}" ?disabled="${0}" type="${0}" min="${0}" .value="${0}" @keydown="${0}" @input="${0}"> `),u("value_empty"),p({"appearance-none transition-all text-body text-m font-medium rounded-s":!0,"bg-base px-s py-xs -my-xs":!0,"opacity-50":l,"absolute inset-0":"auto-grow"===n,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0}),l,f(s),f(i),r,(e=>"|"===e.key&&e.preventDefault()),(e=>{const l=e.currentTarget;d(l.value.replace(/\|/gi,""))})))}let ue,de=e=>e;const ve=e=>{var l;const{operator:a,value:n,name:t}=null!==(l=e.rule)&&void 0!==l?l:{},{disabled:r,readonly:s,t:i}=e,u=d.Not,v=p({"text-disabled":r,"text-contrast-80":s}),c=null===a?"equal":a===u?u:null;return o(ue||(ue=de` <foxy-i18n class="${0}" infer="" key="name"></foxy-i18n> ${0} <foxy-i18n class="${0}" infer="" key="value"></foxy-i18n> ${0} ${0} `),v,ie({layout:"auto-grow",value:t||"",label:"name",type:"text",disabled:r,readonly:s,t:i,onChange:l=>{if(!l)return e.onChange(null);n?e.onChange({name:l}):e.onChange({name:l,operator:d.IsDefined,value:"true"})}}),v,ne({current:{label:c?`operator_${c}`:"value_any",value:null!=c?c:"any"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:u}],disabled:r,readonly:s,t:i,onChange:l=>{if("any"!==l)return e.onChange({operator:"equal"===l?null:l,value:a===d.IsDefined?"":null!=n?n:"",name:null!=t?t:""});e.onChange(t?{operator:d.IsDefined,value:"true"}:null)}}),void 0===n||a===d.IsDefined?"":ie({layout:"auto-grow",label:"value",value:n||"",type:"text",disabled:r,readonly:s,t:i,onChange:l=>e.onChange({value:l})}))},ce=l=>{var a;const n=[{label:"value_any",value:"any"},{label:`${l.option.label}_true`,value:"true"},{label:`${l.option.label}_false`,value:"false"}];return ne(e(e({},l),{},{onChange:e=>l.onChange("any"===e?null:{value:e}),current:null!==(a=n.find((e=>{var a;return e.value===(null===(a=l.rule)||void 0===a?void 0:a.value)})))&&void 0!==a?a:n[0],options:n}))};let pe,he,fe=e=>e;const be=e=>{const{disabled:l,readonly:a,option:n,rule:t,t:r,onChange:s}=e,{min:i,label:u}=n,v=null==t?void 0:t.operator,c=null==t?void 0:t.value.includes(".."),p=null!=v?v:c?"range":"equal",h=void 0===v?"value_any":"range"===p?"range":`operator_${p}`;return o(pe||(pe=fe` ${0} ${0} `),ne({disabled:l,readonly:a,current:{label:h,value:void 0===v?"any":p},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not},{label:"operator_lessthanorequal",value:d.LessThanOrEqual},{label:"operator_lessthan",value:d.LessThan},{label:"operator_greaterthanorequal",value:d.GreaterThanOrEqual},{label:"operator_greaterthan",value:d.GreaterThan},{label:"range",value:"range"}],t:r,onChange:e=>{var l,a,r,o;if("any"===e)return s(null);if("range"===e){const e=parseFloat(null!==(l=null==t?void 0:t.value)&&void 0!==l?l:"");return isNaN(e)?s({operator:null,value:"..",invalid:!0}):s({operator:null,value:`${e}..${e+10}`})}const i=null!==(o=null!==(a=null==t?void 0:t.value)&&void 0!==a?a:null===(r=n.min)||void 0===r?void 0:r.toString())&&void 0!==o?o:"",u=i.includes("..")&&"range"!==e;return s({operator:"equal"===e?null:e,invalid:!i,value:u?i.split("..")[0]:i})}}),void 0===(null==t?void 0:t.value)?"":c?o(he||(he=fe` <foxy-i18n infer="" key="range_from"></foxy-i18n> ${0} <foxy-i18n infer="" key="range_to"></foxy-i18n> ${0} `),ie({disabled:l,readonly:a,layout:"auto-grow",label:"range_from",value:null==t?void 0:t.value.split("..")[0],type:"number",min:i,t:r,onChange:e=>{var l;const a=null!==(l=null==t?void 0:t.value.split("..")[1])&&void 0!==l?l:"";s({value:`${e}..${a}`,invalid:!e||!a})}}),ie({disabled:l,readonly:a,layout:"auto-grow",label:"range_to",value:null==t?void 0:t.value.split("..")[1],type:"number",min:i,t:r,onChange:e=>{const l=null==t?void 0:t.value.split("..")[0];s({value:`${l}..${e}`,invalid:!l||!e})}})):ie({disabled:l,readonly:a,layout:"auto-grow",label:u,value:(null==t?void 0:t.value)||"",type:"number",min:i,t:r,onChange:e=>s({value:e,invalid:!e})}))};let ge,ye=e=>e;const me=e=>{const{disabled:l,readonly:a,option:n,rule:t,t:r,onChange:s}=e,{operator:i}=null!=t?t:{},{label:u}=n;return o(ge||(ge=ye` ${0} ${0} `),ne({disabled:l,readonly:a,current:{label:void 0===i?"value_any":`operator_${null!=i?i:"equal"}`,value:void 0===i?"any":null!=i?i:"equal"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not}],t:r,onChange:e=>{var l;return s("any"===e?null:{operator:"equal"===e?null:e,value:null!==(l=null==t?void 0:t.value)&&void 0!==l?l:""})}}),void 0===(null==t?void 0:t.value)?"":ie({disabled:l,readonly:a,layout:"auto-grow",label:u,value:(null==t?void 0:t.value)||"",t:r,onChange:e=>s({value:e})}))};let xe,$e,Ce=e=>e;const _e=e=>{var l;const{operator:a,value:n}=null!==(l=e.rule)&&void 0!==l?l:{},{min:t,label:r}=e.option,{disabled:s,readonly:i,t:u,onChange:v}=e,c=null==n?void 0:n.includes(".."),p=null!=a?a:c?"range":"equal",h=void 0===a?"value_any":"range"===p?"range":`operator_${p}`;return o(xe||(xe=Ce` ${0} ${0} `),ne({disabled:s,readonly:i,t:u,current:{label:h,value:void 0===a?"any":p},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not},{label:"operator_lessthanorequal",value:d.LessThanOrEqual},{label:"operator_lessthan",value:d.LessThan},{label:"operator_greaterthanorequal",value:d.GreaterThanOrEqual},{label:"operator_greaterthan",value:d.GreaterThan},{label:"range",value:"range"}],onChange:e=>{if("any"===e)return v(null);if("range"===e){const e=new Date(null!=n?n:(new Date).toISOString()),l=new Date(e);e.setMonth(e.getMonth()-1),e.setHours(0,0,0,0),l.setHours(23,59,59,999);const a=e.toISOString(),t=l.toISOString();return v({operator:null,value:`${a}..${t}`})}const l=null!=n?n:(new Date).toISOString(),a=l.includes("..")&&"range"!==e;return v({operator:"equal"===e?null:e,value:a?l.split("..")[0]:l})}}),void 0===n?"":c?o($e||($e=Ce` ${0} ${0} `),ie({disabled:s,readonly:i,layout:"fixed",label:"range_from",value:b(new Date(n.split("..")[0])),type:"date",min:t,t:u,onChange:e=>{var l,a;const t=null!==(l=g(e))&&void 0!==l?l:new Date,r=new Date(null!==(a=n.split("..")[1])&&void 0!==a?a:Date.now());t.setHours(0,0,0,0),r.setHours(23,59,59,999),v({value:`${t.toISOString()}..${r.toISOString()}`})}}),ie({disabled:s,readonly:i,layout:"fixed",label:"range_to",value:b(new Date(n.split("..")[1])),type:"date",min:t,t:u,onChange:e=>{var l,a;const t=new Date(null!==(l=n.split("..")[0])&&void 0!==l?l:Date.now()),r=null!==(a=g(e))&&void 0!==a?a:new Date;t.setHours(0,0,0,0),r.setHours(23,59,59,999),v({value:`${t.toISOString()}..${r.toISOString()}`})}})):ie({disabled:s,readonly:i,label:r,value:b(new Date(null!=n?n:Date.now())),type:"date",min:t,t:u,onChange:e=>{var l;v({value:(null!==(l=g(e))&&void 0!==l?l:new Date).toISOString()})}}))};let we,Le=e=>e;const Me=e=>{const{disabled:l,readonly:a,option:n,rule:t,t:r,onChange:s}=e,{list:i}=n,u=null==i?void 0:i.find((e=>e.value===(null==t?void 0:t.value))),v=null==t?void 0:t.operator;return o(we||(we=Le` ${0} ${0} `),ne({disabled:l,readonly:a,current:{label:void 0===v?"value_any":`operator_${null!=v?v:"equal"}`,value:void 0===v?"any":null!=v?v:"equal"},options:[{label:"value_any",value:"any"},{label:"operator_equal",value:"equal"},{label:"operator_not",value:d.Not}],t:r,onChange:e=>{var l,a,n;return s("any"===e?null:{operator:"equal"===e?null:e,value:null!==(n=null!==(l=null==t?void 0:t.value)&&void 0!==l?l:null===(a=null==i?void 0:i[0])||void 0===a?void 0:a.value)&&void 0!==n?n:""})}}),void 0===(null==t?void 0:t.value)?"":ne({disabled:l,readonly:a,current:null!=u?u:{label:"value_any",value:""},options:null!=i?i:[],t:r,onChange:e=>s({value:e})}))};let qe,ke,Ae=e=>e;function Oe(e){const l=new Set,a=e=>{let a;if("string"==typeof e.name)a=e.path;else{const l=e.path.lastIndexOf(":");if(-1===l)return;a=e.path.substring(0,l)}a.length>0&&l.add(a)};for(const l of e)if(Array.isArray(l))for(const e of l)a(e);else a(l);return Array.from(l).join()}function Se(e){let l=e.path;return e.name&&(l+=`:name[${e.name}]`),e.operator&&(l+=`:${e.operator}`),[l,e.value]}function He(e,l=!1){const a=new URLSearchParams;for(const l of e)if(Array.isArray(l)){const[e,...n]=l.map(Se);if(e&&e[0]){const l=[e[1],...n.map((e=>e.join("=")))];a.append(e[0],l.join("|"))}}else{const[e,n]=Se(l);e&&a.append(e,n)}if(!l){const l=Oe(e);l?a.set("zoom",l):a.delete("zoom")}return a.toString()}let De;const je=s(De||(De=(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}input::-webkit-contacts-auto-fill-button{visibility:hidden;display:none!important;pointer-events:none;position:absolute;right:0}input::-webkit-inner-spin-button,input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input{-moz-appearance:textfield}foxy-internal-summary-control[layout=details][count]:not([open]){--lumo-contrast-5pct:var(--lumo-primary-color-10pct);color:var(--lumo-primary-text-color)}`));function Ze(e,l){var a;const n=null!==(a=Object.values(d).find((l=>e.endsWith(`:${l}`))))&&void 0!==a?a:null;let t,r=e.substring(0,n?e.lastIndexOf(":"):void 0);const o=e.lastIndexOf("[");return r.endsWith("]")&&-1!==o&&(t=r.substring(o+1,r.length-1),r=r.substring(0,o),r.endsWith(":name")&&(r=r.substring(0,r.length-5))),{name:t,path:r,value:l,operator:n}}function Ve(e){const l=new URLSearchParams(e),a=[];for(const[e,n]of l.entries())n.includes("|")?a.push(n.split("|").map(((l,a)=>0===a?Ze(e,l):Ze(...l.split("="))))):a.push(Ze(e,n));return a}let Ie,Te,Ne=e=>e;const ze=t(l(a(n(u(i),"query-builder"))));class Be extends ze{constructor(){super(...arguments),this.reservedPaths=["zoom","limit","offset","order","fields"],this.disableZoom=!1,this.disableOr=!1,this.operators=Object.values(d),this.docsHref=null,this.options=null,this.__isAdvancedMode=!1,this.__reportedValue=null,this.__displayedValue=null}static zoom(e){return Oe(Ve(e))}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},docsHref:{attribute:"docs-href"},options:{type:Array},value:{noAccessor:!0},__reportedValue:{attribute:!1},__displayedValue:{attribute:!1},__isAdvancedMode:{attribute:!1}})}static get styles(){return[super.styles,je]}get value(){return this.__reportedValue}set value(e){this.__reportedValue=e,this.__displayedValue=e}render(){var l,a,n,t,r,s;const i=this.__isSimpleModeSupported,u=Ve(null!==(l=this.__displayedValue)&&void 0!==l?l:""),d=null!==(a=this.operators)&&void 0!==a?a:[],c=null!==(n=this.options)&&void 0!==n?n:[],h=this.t.bind(this),b=e=>{this.__displayedValue=He(e,this.disableZoom);e.every((e=>Array.isArray(e)?e.every((e=>!e.invalid)):!e.invalid))&&(this.__reportedValue=this.__displayedValue,this.dispatchEvent(new Be.ChangeEvent("change")))};return i||this.__isAdvancedMode||(this.__isAdvancedMode=!0),o(Ie||(Ie=Ne` <div class="space-y-m"> <div class="grid grid-cols-2 gap-xs p-xs bg-contrast-5 rounded" ?hidden="${0}"> <label class="${0}"> <foxy-i18n infer="" key="mode_simple${0}"> </foxy-i18n> <input class="sr-only" type="radio" name="mode" ?disabled="${0}" ?checked="${0}" @change="${0}"> </label> <label class="${0}"> <foxy-i18n infer="" key="mode_advanced"></foxy-i18n> <input class="sr-only" type="radio" name="mode" ?checked="${0}" @change="${0}"> </label> </div> ${0} </div> `),!(null===(t=this.options)||void 0===t?void 0:t.length),p({"p-xs rounded-s text-center font-medium transition-colors":!0,"bg-base ring-1 ring-contrast-5":!this.__isAdvancedMode&&i,"hover-bg-contrast-5":this.__isAdvancedMode&&i,"focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50":!0,"cursor-pointer":i,"text-disabled":!i}),i?"":"_unsupported",!i,!this.__isAdvancedMode,(()=>this.__isAdvancedMode=!1),p({"p-xs rounded-s text-center font-medium cursor-pointer transition-colors":!0,"bg-base ring-1 ring-contrast-5":this.__isAdvancedMode,"hover-bg-contrast-5":!this.__isAdvancedMode,"focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50":!0}),this.__isAdvancedMode,(()=>this.__isAdvancedMode=!0),this.__isAdvancedMode||!i?o(Te||(Te=Ne` <p class="leading-s text-tertiary" ?hidden="${0}"> <foxy-i18n infer="" key="advanced_mode_notice"></foxy-i18n> <a target="_blank" class="cursor-pointer rounded-s text-secondary font-medium hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}" rel="nofollow noreferrer noopener"> <foxy-i18n infer="" key="api_reference_link"></foxy-i18n> </a> </p> ${0} `),null===this.docsHref,f(null!==(r=this.docsHref)&&void 0!==r?r:void 0),Q({disableOr:this.disableOr,disabled:this.disabled,readonly:this.readonly,rules:u,operators:d,onChange:b,options:c,t:h})):null===(s=this.__simpleModeOptions)||void 0===s?void 0:s.map((l=>function(l){var a;const{options:n,layout:t,rules:r,name:s,disabled:i,readonly:u,t:d,onChange:c}=l,h=n.filter((e=>r.find((l=>l.path===e.path)))),b=r.find((e=>"order"===e.path)),g=null===(a=null==b?void 0:b.value)||void 0===a?void 0:a.split(",").map((e=>{const[l,a="asc"]=decodeURIComponent(e).split(" ");return{path:l.trim(),order:a.trim()}}));return o(qe||(qe=Ae` <foxy-internal-summary-control aria-label="${0}" helper-text="" layout="${0}" label="${0}" count="${0}" infer=""> ${0} </foxy-internal-summary-control> `),l.t("query_builder_group"),f(t),t&&s?d(s):"",f(h.length||void 0),n.map((l=>{var a;const{type:n,label:t,list:s,path:h}=l,f={[v.Attribute]:ve,[v.Boolean]:ce,[v.String]:me,[v.Number]:be,[v.Date]:_e,[v.Any]:me},b=s?Me:f[n],y=null===(a=null==g?void 0:g.find((e=>e.path===h)))||void 0===a?void 0:a.order,m=r.find((e=>e.path===h)),x=!!m||!!y;return o(ke||(ke=Ae` <div aria-label="${0}" class="${0}"> <foxy-i18n infer="" key="${0}"></foxy-i18n> <span class="transform scale-150 mr-auto ${0}">•</span> ${0} ${0} </div> `),d("query_builder_rule"),p({"flex flex-wrap items-center justify-end gap-s":!0,"bg-primary-10 text-primary":x}),t,x?"":"opacity-0",b({disabled:i,readonly:u,option:l,rule:m,t:d,onChange:l=>{if(l&&m)return Object.assign(m,l),c(r);if(l){const a={path:h,value:"",operator:null};return c([...r,e(e({},a),l)])}return c(r.filter((e=>e.path!==h)))}}),n===v.Date||n===v.Number?ne({disabled:i,readonly:u,t:d,current:{label:`order_${null!=y?y:"none"}${y?`_${n}`:""}`,value:null!=y?y:"none"},options:[{label:"order_none",value:"none"},{label:`order_asc_${n}`,value:"asc"},{label:`order_desc_${n}`,value:"desc"}],onChange:e=>{const l=(null!=g?g:[]).filter((e=>e.path!==h)).concat([{path:h,order:e}]).filter((e=>"none"!==e.order)).map((e=>`${e.path} ${e.order}`)).join(),a=r.filter((e=>"order"!==e.path));l&&a.push({path:"order",value:l,operator:null}),c(a)}}):"")})))}(e(e({},l),{},{disabled:this.disabled,readonly:this.readonly,rules:u,onChange:b,t:h})))))}get __isSimpleModeSupported(){var e;if(null===this.options)return!1;if(0===this.options.length)return!1;const l=Ve(null!==(e=this.__displayedValue)&&void 0!==e?e:"");return 0===l.length||l.every((e=>{var l;return!Array.isArray(e)&&(e.operator!==d.In&&((e.operator!==d.IsDefined||"true"===e.value)&&!(!this.reservedPaths.includes(e.path)&&!(null===(l=this.options)||void 0===l?void 0:l.find((l=>l.path===e.path))))))}))}get __simpleModeOptions(){var l;return null===(l=this.options)||void 0===l?void 0:l.reduce(((l,a)=>{const n=l.find((e=>{var l;return e.name===(null===(l=a.group)||void 0===l?void 0:l.name)}));return n?n.options.push(a):l.push(e(e({},a.group),{},{options:[a]})),l}),[])}}Be.ChangeEvent=class extends CustomEvent{},Be.Operator=d,Be.Type=v,customElements.define("foxy-query-builder",Be);export{Be as Q,Ve as p,He as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e,a;!function(e){e.Attribute="attribute",e.Boolean="boolean",e.String="string",e.Number="number",e.Date="date",e.Any="any"}(e||(e={})),function(e){e.LessThanOrEqual="lessthanorequal",e.LessThan="lessthan",e.GreaterThanOrEqual="greaterthanorequal",e.GreaterThan="greaterthan",e.IsDefined="isdefined",e.Not="not",e.In="in"}(a||(a={}));export{a as O,e as T};
|