@foxy.io/elements 1.44.0 → 1.45.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-i18n-editor.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +1 -1
- package/dist/cdn/foxy-reports-table.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-store-card.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-f00cd094.js → shared-05e997ae.js} +1 -1
- package/dist/cdn/{shared-d0c1664e.js → shared-0abec247.js} +1 -1
- package/dist/cdn/{shared-9b599205.js → shared-0b3dbac6.js} +1 -1
- package/dist/cdn/{shared-15a7e329.js → shared-1b04321a.js} +1 -1
- package/dist/cdn/{shared-cee1c6f1.js → shared-4e279e77.js} +1 -1
- package/dist/cdn/{shared-e6559d84.js → shared-4e4766ee.js} +1 -1
- package/dist/cdn/{shared-d525b69b.js → shared-4f36f302.js} +1 -1
- package/dist/cdn/{shared-c4df3a2a.js → shared-52053d0d.js} +1 -1
- package/dist/cdn/{shared-57b7386e.js → shared-6783fe5e.js} +1 -1
- package/dist/cdn/{shared-da95bb48.js → shared-69074dae.js} +1 -1
- package/dist/cdn/{shared-da4f539a.js → shared-7933d898.js} +1 -1
- package/dist/cdn/{shared-8f2da12b.js → shared-7f4e3256.js} +1 -1
- package/dist/cdn/{shared-8a83a6eb.js → shared-8ba28691.js} +1 -1
- package/dist/cdn/{shared-b56949d3.js → shared-8ba4b5bf.js} +1 -1
- package/dist/cdn/{shared-b4a3d776.js → shared-8bda01cf.js} +1 -1
- package/dist/cdn/{shared-6c2a7d2f.js → shared-92c211bd.js} +1 -1
- package/dist/cdn/shared-9585cf5b.js +1 -0
- package/dist/cdn/{shared-64c855e5.js → shared-ada2d315.js} +1 -1
- package/dist/cdn/{shared-5b93d193.js → shared-adfed461.js} +1 -1
- package/dist/cdn/{shared-438e41ab.js → shared-b148b310.js} +1 -1
- package/dist/cdn/{shared-090ee4eb.js → shared-b7401886.js} +1 -1
- package/dist/cdn/{shared-264fb8a2.js → shared-ba0d1f31.js} +1 -1
- package/dist/cdn/{shared-a1f181bf.js → shared-bc89d3fb.js} +1 -1
- package/dist/cdn/{shared-8ee6bff5.js → shared-c84bb30e.js} +1 -1
- package/dist/cdn/{shared-af39ffd8.js → shared-d674d2ce.js} +1 -1
- package/dist/cdn/{shared-597fffaa.js → shared-df92d411.js} +1 -1
- package/dist/cdn/{shared-73c199ae.js → shared-f58068b0.js} +1 -1
- package/dist/cdn/translations/admin-subscription-form/en.json +2 -0
- package/dist/cdn/translations/cart-form/en.json +2 -0
- package/dist/cdn/translations/coupon-card/en.json +9 -9
- package/dist/cdn/translations/coupon-form/en.json +10 -8
- package/dist/cdn/translations/discount-builder/en.json +3 -1
- package/dist/cdn/translations/experimental-add-to-cart-builder/en.json +15 -5
- package/dist/cdn/translations/item-category-form/en.json +2 -0
- package/dist/cdn/translations/item-form/en.json +2 -0
- package/dist/cdn/translations/store-form/en.json +16 -4
- package/dist/cdn/translations/transaction/en.json +2 -0
- package/dist/elements/public/DiscountBuilder/DiscountBuilder.js +1 -1
- package/dist/elements/public/DiscountBuilder/DiscountBuilder.js.map +1 -1
- package/dist/elements/public/ExperimentalAddToCartBuilder/ExperimentalAddToCartBuilder.js +174 -149
- package/dist/elements/public/ExperimentalAddToCartBuilder/ExperimentalAddToCartBuilder.js.map +1 -1
- package/dist/elements/public/NucleonElement/NucleonElement.js +11 -6
- package/dist/elements/public/NucleonElement/NucleonElement.js.map +1 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js +0 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map +1 -1
- package/dist/elements/public/StoreForm/StoreForm.js +6 -6
- package/dist/elements/public/StoreForm/StoreForm.js.map +1 -1
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/InternalUserInvitationFormAsyncAction.js +0 -2
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/InternalUserInvitationFormAsyncAction.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-02dd05dd.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-1d03ea56.js";import"./shared-ac44a3a5.js";import{I as e}from"./shared-
|
|
1
|
+
import"./shared-1d03ea56.js";import"./shared-ac44a3a5.js";import{I as e}from"./shared-92c211bd.js";import{x as t}from"./shared-387d7254.js";import{c as r,h as a,s as o}from"./shared-ba5c42c7.js";import{_ as l}from"./shared-7fec42f2.js";import{i as s}from"./shared-53e42a77.js";import{c as i}from"./shared-4e709717.js";let n;function m(e){var t,r,a;const o=null!==(t=null==e?void 0:e.separator)&&void 0!==t?t:"-",l=null!==(r=null==e?void 0:e.charset)&&void 0!==r?r:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=null!==(a=null==e?void 0:e.length)&&void 0!==a?a:18;let i="";for(let e=0;e<s;e++)o&&e>0&&e%6==0&&(i+=o),i+=l[Math.floor(Math.random()*l.length)];return i}t("vaadin-password-field",r(n||(n=(e=>e)`:host([theme~=summary-item])::before{display:none}:host([theme~=summary-item]) .vaadin-text-field-container{display:grid;grid-template-columns:auto auto;grid-template-rows:repeat(3,min-content);gap:0 var(--lumo-space-m)}:host([theme~=summary-item]) [part=label]{font:normal var(--lumo-font-size-m) var(--lumo-font-family);color:var(--lumo-body-text-color)!important;grid-row:1;-webkit-text-fill-color:var(--lumo-body-text-color)!important}:host([theme~=summary-item]) [part=helper-text]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-secondary-text-color)!important;grid-row:2}:host([theme~=summary-item]) [part=helper-text]::before{display:none}:host([theme~=summary-item]) [part=error-message]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-error-text-color);grid-row:3}:host([theme~=summary-item]) [part=error-message],:host([theme~=summary-item]) [part=helper-text],:host([theme~=summary-item]) [part=label]{line-height:var(--lumo-line-height-xs);grid-column:1;padding:0}:host([theme~=summary-item]) [part=input-field]{grid-column:2;grid-row:1;padding:0;background:0 0;align-self:start;height:1em;--lumo-icon-size-m:1rem}:host([theme~=summary-item]) [part=input-field]::after,:host([theme~=summary-item][readonly]) [part=input-field] slot[name=suffix]{display:none}:host([theme~=summary-item]) [part=value]{line-height:var(--lumo-line-height-xs);text-align:right;min-height:auto;padding:0;margin-right:var(--lumo-space-xs);-webkit-mask-image:none}:host([theme~=summary-item][readonly]) [part=value]{margin-right:0}`)));let d,h,u,p=e=>e;customElements.define("foxy-internal-password-control",class extends e{constructor(){super(...arguments),this.generatorOptions=null,this.showGenerator=!1,this.layout=null}static get properties(){return l(l({},super.properties),{},{generatorOptions:{type:Object,attribute:"generator-options"},showGenerator:{type:Boolean,attribute:"show-generator"},layout:{}})}renderControl(){var e;return a(d||(d=p` <vaadin-password-field error-message="${0}" helper-text="${0}" placeholder="${0}" label="${0}" theme="${0}" class="w-full" ?disabled="${0}" ?readonly="${0}" .checkValidity="${0}" .value="${0}" @keydown="${0}" @input="${0}"> ${0} </vaadin-password-field> `),s(this._errorMessage),this.helperText,this.placeholder,this.label,s(null!==(e=this.layout)&&void 0!==e?e:void 0),this.disabled,this.readonly,this._checkValidity,this._value,(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}),(e=>{const t=e.currentTarget;this._value=t.value}),this.showGenerator?this.__renderGenerator():"")}get _value(){var e;return null!==(e=super._value)&&void 0!==e?e:""}set _value(e){super._value=e}__renderGenerator(){return a(h||(h=p` <div data-testid="generator" class="${0}" slot="suffix" @click="${0}"> ${0} </div> `),i({"w-s h-s flex items-center justify-center cursor-default transition-colors":!0,"text-contrast-60 hover-text-contrast-80":!this.disabled&&!this.readonly,"text-contrast-20":this.disabled||this.readonly}),(()=>{var e,t,r,a;let o,l=!1,s=0;do{o=m(null!==(e=this.generatorOptions)&&void 0!==e?e:void 0),l=null===(a=null===(r=null===(t=this.generatorOptions)||void 0===t?void 0:t.checkStrength)||void 0===r?void 0:r.call(t,o))||void 0===a||a,s++}while(!l&&s<100);if(!l)throw new Error("Failed to generate a strong password.");this._value=o;const i=this.renderRoot.querySelector("vaadin-password-field");null==i||i._setPasswordVisible(!0)}),o(u||(u=p`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.15em; height: 1.15em"><path d="M15.98 1.804a1 1 0 00-1.96 0l-.24 1.192a1 1 0 01-.784.785l-1.192.238a1 1 0 000 1.962l1.192.238a1 1 0 01.785.785l.238 1.192a1 1 0 001.962 0l.238-1.192a1 1 0 01.785-.785l1.192-.238a1 1 0 000-1.962l-1.192-.238a1 1 0 01-.785-.785l-.238-1.192zM6.949 5.684a1 1 0 00-1.898 0l-.683 2.051a1 1 0 01-.633.633l-2.051.683a1 1 0 000 1.898l2.051.684a1 1 0 01.633.632l.683 2.051a1 1 0 001.898 0l.683-2.051a1 1 0 01.633-.633l2.051-.683a1 1 0 000-1.898l-2.051-.683a1 1 0 01-.633-.633L6.95 5.684zM13.949 13.684a1 1 0 00-1.898 0l-.184.551a1 1 0 01-.632.633l-.551.183a1 1 0 000 1.898l.551.183a1 1 0 01.633.633l.183.551a1 1 0 001.898 0l.184-.551a1 1 0 01.632-.633l.551-.183a1 1 0 000-1.898l-.551-.184a1 1 0 01-.633-.632l-.183-.551z" /></svg>`)))}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./shared-a6cf5b1f.js";import{h as t,P as e}from"./shared-3bc9eaf7.js";import{F as i,t as o}from"./shared-3db3f3c3.js";import{T as n,a,E as s}from"./shared-46efbc40.js";import"./shared-297155d9.js";import{O as r}from"./shared-1abfcf87.js";import"./shared-24998349.js";import"./shared-
|
|
1
|
+
import"./shared-a6cf5b1f.js";import{h as t,P as e}from"./shared-3bc9eaf7.js";import{F as i,t as o}from"./shared-3db3f3c3.js";import{T as n,a,E as s}from"./shared-46efbc40.js";import"./shared-297155d9.js";import{O as r}from"./shared-1abfcf87.js";import"./shared-24998349.js";import"./shared-b148b310.js";import"./foxy-collection-page.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./foxy-pagination.js";import"./shared-64210e53.js";import{I as l}from"./shared-92c211bd.js";import"./shared-25a9d87d.js";import{x as d}from"./shared-387d7254.js";import{c,h,r as m}from"./shared-ba5c42c7.js";import{_ as u}from"./shared-7fec42f2.js";import{i as p}from"./shared-53e42a77.js";import{c as _}from"./shared-4e709717.js";const f=t`<dom-module id="lumo-notification-card" theme-for="vaadin-notification-card">
|
|
2
2
|
<template>
|
|
3
3
|
<style>
|
|
4
4
|
:host {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./shared-7fec42f2.js";import{h as t}from"./shared-ba5c42c7.js";import{C as l}from"./shared-c782b9fa.js";import"./foxy-nucleon-element.js";import{R as s,T as a,a as i}from"./shared-387d7254.js";import{c as r}from"./shared-4e709717.js";import{N as d}from"./shared-
|
|
1
|
+
import{_ as e}from"./shared-7fec42f2.js";import{h as t}from"./shared-ba5c42c7.js";import{C as l}from"./shared-c782b9fa.js";import"./foxy-nucleon-element.js";import{R as s,T as a,a as i}from"./shared-387d7254.js";import{c as r}from"./shared-4e709717.js";import{N as d}from"./shared-69074dae.js";let n,o,h,c,m,u=e=>e;const b=l(s(a(i(d))));class p extends b{constructor(){super(...arguments),this.columns=[]}static get properties(){return e(e({},super.properties),{},{columns:{attribute:!1}})}render(){var e,l;const s=this.columns.some((e=>!!e.header));return t(n||(n=u` <div data-testid="wrapper" aria-busy="${0}" aria-live="polite" class="relative font-lumo text-m"> <table class="table-fixed w-full" data-testid="table"> <thead class="${0}"> <tr> ${0} </tr> </thead> <tbody class="divide-y divide-contrast-10"> ${0} </tbody> </table> ${0} </div> ${0} `),this.in("busy"),s?"border-b border-contrast-10":"sr-only",this.columns.map(((e,l)=>{var s;return t(o||(o=u` <th class="${0}"> ${0} </th> `),r({"truncate h-l text-tertiary text-m text-left font-medium":!0,"text-right":l===this.columns.length-1,"hidden sm-table-cell":"sm"===e.hideBelow,"hidden md-table-cell":"md"===e.hideBelow,"hidden lg-table-cell":"lg"===e.hideBelow,"hidden xl-table-cell":"xl"===e.hideBelow}),null===(s=e.header)||void 0===s?void 0:s.call(e,{html:t,lang:this.lang,data:this.data,ns:this.ns}))})),this.__rows.map((e=>{var l;return t(h||(h=u` <tr class="h-l"> ${0} </tr> `),null===(l=this.columns)||void 0===l?void 0:l.map(((l,s)=>{var a;return t(c||(c=u` <td class="${0}"> ${0} </td> `),r({"text-right":s===this.columns.length-1,"hidden sm-table-cell":"sm"===l.hideBelow,"hidden md-table-cell":"md"===l.hideBelow,"hidden lg-table-cell":"lg"===l.hideBelow,"hidden xl-table-cell":"xl"===l.hideBelow,"truncate h-l text-body":!0}),e?null===(a=l.cell)||void 0===a?void 0:a.call(l,{html:t,lang:this.lang,data:e,ns:this.ns}):"")})))})),this.in({idle:"snapshot"})?"":t(m||(m=u` <div class="absolute inset-0 flex items-center justify-center"> <foxy-spinner data-testid="spinner" layout="vertical" state="${0}" class="p-m bg-base shadow-xs rounded-t-l rounded-b-l" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> `),this.in("busy")?"busy":this.in("idle")?"empty":"error",this.lang,this.ns,null!==(l=null===(e=customElements.get("foxy-spinner"))||void 0===e?void 0:e.defaultNS)&&void 0!==l?l:""),this.renderTemplateOrSlot())}get __rows(){var e,t,l;const s=Object.values(null!==(t=null===(e=this.data)||void 0===e?void 0:e._embedded)&&void 0!==t?t:{}).reduce(((e,t)=>[...e,...t]),[]);let a;if(0===s.length)try{const e=new URL(null!==(l=this.href)&&void 0!==l?l:"").searchParams.get("limit"),t=parseInt(null!=e?e:"");a=isNaN(t)?20:t}catch(e){a=20}else a=s.length;return new Array(a).fill(null).map(((e,t)=>{var l;return null!==(l=s[t])&&void 0!==l?l:e}))}}export{p as T};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"allunits_price_amount_discount_summary": "{{adjustment}}
|
|
2
|
+
"allunits_price_amount_discount_summary": "{{adjustment}}[currency] each after {{from}}",
|
|
3
3
|
"allunits_price_percentage_discount_summary": "{{adjustment, percent}} after {{from}}",
|
|
4
|
-
"allunits_quantity_amount_discount_summary": "{{adjustment}}
|
|
4
|
+
"allunits_quantity_amount_discount_summary": "{{adjustment}}[currency] each on orders of {{from}}+",
|
|
5
5
|
"allunits_quantity_percentage_discount_summary": "{{adjustment, percent}} on orders of {{from}}+",
|
|
6
6
|
"date_range_any": "Ongoing",
|
|
7
7
|
"date_range_complete": "{{start, date}} – {{end, date}}",
|
|
8
8
|
"date_range_from": "From {{start, date}}",
|
|
9
9
|
"date_range_until": "Until {{end, date}}",
|
|
10
10
|
"discount_summary": "{{params, discount}}",
|
|
11
|
-
"incremental_price_amount_discount_summary": "{{adjustment}}
|
|
11
|
+
"incremental_price_amount_discount_summary": "{{adjustment}}[currency] each on orders of {{from}}+",
|
|
12
12
|
"incremental_price_percentage_discount_summary": "{{adjustment, percent}} on orders of {{from}}+",
|
|
13
|
-
"incremental_quantity_amount_discount_summary": "{{adjustment}}
|
|
13
|
+
"incremental_quantity_amount_discount_summary": "{{adjustment}}[currency] each on items {{from}}+",
|
|
14
14
|
"incremental_quantity_percentage_discount_summary": "{{adjustment, percent}} on items {{from}}+",
|
|
15
15
|
"ordinal_few": "rd",
|
|
16
16
|
"ordinal_many": "th",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"ordinal_other": "th",
|
|
19
19
|
"ordinal_two": "nd",
|
|
20
20
|
"ordinal_zero": "th",
|
|
21
|
-
"repeat_price_amount_discount_summary": "for each {{from}}, {{adjustment}}
|
|
21
|
+
"repeat_price_amount_discount_summary": "for each {{from}}, {{adjustment}}[currency] on the next item",
|
|
22
22
|
"repeat_price_percentage_discount_summary": "for each {{from}}, {{adjustment, percent}} on the next item",
|
|
23
|
-
"repeat_quantity_amount_discount_summary": "{{adjustment}}
|
|
23
|
+
"repeat_quantity_amount_discount_summary": "{{adjustment}}[currency] on each {{from, ordinal}} item",
|
|
24
24
|
"repeat_quantity_percentage_discount_summary": "{{adjustment, percent}} on each {{from, ordinal}} item",
|
|
25
|
-
"single_price_amount_discount_summary": "{{adjustment}}
|
|
25
|
+
"single_price_amount_discount_summary": "{{adjustment}}[currency] after {{from}}",
|
|
26
26
|
"single_price_percentage_discount_summary": "{{adjustment, percent}} after {{from}}",
|
|
27
|
-
"single_quantity_amount_discount_summary": "{{adjustment}}
|
|
27
|
+
"single_quantity_amount_discount_summary": "{{adjustment}}[currency] after {{from}} item(s)",
|
|
28
28
|
"single_quantity_percentage_discount_summary": "{{adjustment, percent}} after {{from}} item(s)",
|
|
29
29
|
"uses_count": "{{count}} uses",
|
|
30
30
|
"uses_to_total_count": "{{count}}/{{total}} uses",
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"loading_empty": "No data",
|
|
34
34
|
"loading_error": "Unknown error"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -145,25 +145,27 @@
|
|
|
145
145
|
"tier_repeat": "price of next item",
|
|
146
146
|
"tier_single": "order total",
|
|
147
147
|
"tier_then": "then",
|
|
148
|
+
"units_amount": "currency",
|
|
149
|
+
"units_percentage": "percent",
|
|
148
150
|
"quantity": "quantity",
|
|
149
151
|
"total": "total",
|
|
150
152
|
"reduce": "reduce",
|
|
151
153
|
"increase": "increase"
|
|
152
154
|
},
|
|
153
|
-
"allunits_price_amount_discount_summary": "{{adjustment}}
|
|
155
|
+
"allunits_price_amount_discount_summary": "{{adjustment}}[currency] each after {{from}}",
|
|
154
156
|
"allunits_price_percentage_discount_summary": "{{adjustment, percent}} after {{from}}",
|
|
155
|
-
"allunits_quantity_amount_discount_summary": "{{adjustment}}
|
|
157
|
+
"allunits_quantity_amount_discount_summary": "{{adjustment}}[currency] each on orders of {{from}}+",
|
|
156
158
|
"allunits_quantity_percentage_discount_summary": "{{adjustment, percent}} on orders of {{from}}+",
|
|
157
|
-
"incremental_price_amount_discount_summary": "{{adjustment}}
|
|
159
|
+
"incremental_price_amount_discount_summary": "{{adjustment}}[currency] each on orders of {{from}}+",
|
|
158
160
|
"incremental_price_percentage_discount_summary": "{{adjustment, percent}} on orders of {{from}}+",
|
|
159
|
-
"incremental_quantity_amount_discount_summary": "{{adjustment}}
|
|
161
|
+
"incremental_quantity_amount_discount_summary": "{{adjustment}}[currency] each on items {{from}}+",
|
|
160
162
|
"incremental_quantity_percentage_discount_summary": "{{adjustment, percent}} on items {{from}}+",
|
|
161
|
-
"repeat_price_amount_discount_summary": "for each {{from}}, {{adjustment}}
|
|
163
|
+
"repeat_price_amount_discount_summary": "for each {{from}}, {{adjustment}}[currency] on the next item",
|
|
162
164
|
"repeat_price_percentage_discount_summary": "for each {{from}}, {{adjustment, percent}} on the next item",
|
|
163
|
-
"repeat_quantity_amount_discount_summary": "{{adjustment}}
|
|
164
|
-
"single_price_amount_discount_summary": "{{adjustment}}
|
|
165
|
+
"repeat_quantity_amount_discount_summary": "{{adjustment}}[currency] on each {{from, ordinal}} item",
|
|
166
|
+
"single_price_amount_discount_summary": "{{adjustment}}[currency] after {{from}}",
|
|
165
167
|
"single_price_percentage_discount_summary": "{{adjustment, percent}} after {{from}}",
|
|
166
|
-
"single_quantity_amount_discount_summary": "{{adjustment}}
|
|
168
|
+
"single_quantity_amount_discount_summary": "{{adjustment}}[currency] after {{from}} items",
|
|
167
169
|
"single_quantity_percentage_discount_summary": "{{adjustment, percent}} after {{from}} items",
|
|
168
170
|
"repeat_quantity_percentage_discount_summary": "{{adjustment, percent}} on each {{from, ordinal}} item",
|
|
169
171
|
"discount_summary": "Applied discount: {{params, discount}}.",
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
"tier_repeat": "price of next item",
|
|
8
8
|
"tier_single": "order total",
|
|
9
9
|
"tier_then": "then",
|
|
10
|
+
"units_amount": "currency",
|
|
11
|
+
"units_percentage": "percent",
|
|
10
12
|
"quantity": "quantity",
|
|
11
13
|
"total": "total",
|
|
12
14
|
"reduce": "reduce",
|
|
13
15
|
"increase": "increase"
|
|
14
|
-
}
|
|
16
|
+
}
|
|
@@ -230,6 +230,8 @@
|
|
|
230
230
|
"tier_repeat": "price of next item",
|
|
231
231
|
"tier_single": "order total",
|
|
232
232
|
"tier_then": "then",
|
|
233
|
+
"units_amount": "currency",
|
|
234
|
+
"units_percentage": "percent",
|
|
233
235
|
"quantity": "quantity",
|
|
234
236
|
"total": "total",
|
|
235
237
|
"reduce": "reduce",
|
|
@@ -540,7 +542,16 @@
|
|
|
540
542
|
"helper_text": "",
|
|
541
543
|
"direct_link": "Direct link",
|
|
542
544
|
"empty": "Modify the item parameters to see the add-to-cart link.",
|
|
543
|
-
"unavailable":
|
|
545
|
+
"unavailable": {
|
|
546
|
+
"loading_extra_data_needed": "Creating direct link...",
|
|
547
|
+
"error_special_characters_present": "At the moment we don't support signed direct links with item parameters that contain the following characters: #, &, %, =.",
|
|
548
|
+
"error_price_configurable": "Direct link is not available when one or more items have configurable price.",
|
|
549
|
+
"error_duplicate_custom_option_names": "Direct link is not available when one or more items have configurable custom options.",
|
|
550
|
+
"paused_code_required": "Direct link will be available once you provide an SKU for each item.",
|
|
551
|
+
"error_option_value_configurable": "Direct link is not available when one or more items have a custom option with a configurable value.",
|
|
552
|
+
"error_html_entities_present": "At the moment we don't support signed links with item parameters that contain HTML entities.",
|
|
553
|
+
"error_double_quotes_present": "At the moment we don't support signed links with item parameters that contain double quotes."
|
|
554
|
+
},
|
|
544
555
|
"copy-to-clipboard": {
|
|
545
556
|
"failed_to_copy": "Failed to copy",
|
|
546
557
|
"click_to_copy": "Copy to clipboard",
|
|
@@ -559,11 +570,10 @@
|
|
|
559
570
|
"submit_caption_cart": "Add to cart",
|
|
560
571
|
"submit_caption_checkout": "Purchase",
|
|
561
572
|
"unavailable": {
|
|
562
|
-
"
|
|
563
|
-
"loading_paused": "Preview paused",
|
|
573
|
+
"loading_extra_data_needed": "Loading direct link...",
|
|
564
574
|
"paused_code_required": "Preview and add-to-cart code will be available once you provide an SKU for each item.",
|
|
565
|
-
"error_html_entities_present": "
|
|
566
|
-
"error_double_quotes_present": "
|
|
575
|
+
"error_html_entities_present": "At the moment we don't support signed forms with item parameters that contain HTML entities.",
|
|
576
|
+
"error_double_quotes_present": "At the moment we don't support signed forms with item parameters that contain double quotes."
|
|
567
577
|
},
|
|
568
578
|
"spinner": {
|
|
569
579
|
"loading_busy": "Signing",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"store_domain_reserved": "Selected domain is reserved for internal use. Please choose another domain.",
|
|
22
22
|
"store_domain_exists": "Selected domain is already in use by another store. Please choose another domain."
|
|
23
23
|
},
|
|
24
|
-
"essentials": {
|
|
24
|
+
"essentials-group-one": {
|
|
25
25
|
"label": "Essentials",
|
|
26
26
|
"helper_text": "",
|
|
27
27
|
"store-name": {
|
|
@@ -53,13 +53,21 @@
|
|
|
53
53
|
"helper_text": "",
|
|
54
54
|
"v8n_required": "Please enter the URL of your online store",
|
|
55
55
|
"v8n_too_long": "Please use a URL that is 300 characters or less"
|
|
56
|
-
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"essentials-group-two": {
|
|
59
|
+
"label": "",
|
|
60
|
+
"helper_text": "",
|
|
57
61
|
"is-maintenance-mode": {
|
|
58
62
|
"label": "Maintenance mode",
|
|
59
63
|
"helper_text": "When enabled, your customers can't make purchases or use the checkout page in any way. Once you're done making changes, disable this mode to continue getting orders.",
|
|
60
64
|
"checked": "On",
|
|
61
65
|
"unchecked": "Off"
|
|
62
|
-
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"essentials-group-three": {
|
|
69
|
+
"label": "",
|
|
70
|
+
"helper_text": "",
|
|
63
71
|
"store-email": {
|
|
64
72
|
"label": "Emails for billing and communication with Foxy",
|
|
65
73
|
"placeholder": "Enter an email and press Enter",
|
|
@@ -68,7 +76,11 @@
|
|
|
68
76
|
"delete": "Delete",
|
|
69
77
|
"v8n_required": "Please enter at least one email",
|
|
70
78
|
"v8n_too_long": "All emails for this store must fit within 300 characters when comma-separated"
|
|
71
|
-
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"essentials-group-four": {
|
|
82
|
+
"label": "",
|
|
83
|
+
"helper_text": "",
|
|
72
84
|
"timezone": {
|
|
73
85
|
"label": "Time zone",
|
|
74
86
|
"placeholder": "Select",
|
|
@@ -312,7 +312,7 @@ export class DiscountBuilder extends Base {
|
|
|
312
312
|
|
|
313
313
|
${this.__renderSwitch({
|
|
314
314
|
value: params.units === 'percentage' ? 0 : 1,
|
|
315
|
-
options: ['
|
|
315
|
+
options: ['units_percentage', 'units_amount'],
|
|
316
316
|
onChange: i => params.onChange({ units: i ? 'amount' : 'percentage' }),
|
|
317
317
|
})}
|
|
318
318
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscountBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/DiscountBuilder/DiscountBuilder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAwC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,0BAA0B,EAAE,4DAAyD;AAE9F,MAAM,EAAE,GAAG,kBAAkB,CAAC;AAC9B,MAAM,IAAI,GAAG,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAEnG;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,IAAI;IAAzC;;QAQE;;;;;;;;;;;WAWG;QACH,UAAK,GAAkB,IAAI,CAAC;IAkU9B,CAAC;IArVC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAA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ACf,uEAAuE,EAAE,IAAI;gBAC7E,oEAAoE,EAClE,CAAC,IAAI,CAAC,QAAQ;gBAChB,8BAA8B,EAAE,IAAI,CAAC,QAAQ;aAC9C,CAAC;4BACU,IAAI,CAAC,QAAQ;0BACf,IAAI,CAAC,QAAQ;yBACd,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE;;;;aAInC;YACH,CAAC,CAAC,EAAE;;KAET,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n DiscountType,\n ParsedValue,\n RulesTierParams,\n RulesTierSelectParams,\n RulesTierSwitchParams,\n RulesTierFieldParams,\n} from './types';\n\nimport { html, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { operatorGreaterThanOrEqual } from '../QueryBuilder/icons/operatorGreaterThanOrEqual';\n\nconst NS = 'discount-builder';\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)));\n\n/**\n * Visual builder for discount URL parameters in coupons and more.\n * Learn more about discounts here: [Foxy Wiki](https://wiki.foxycart.com/v/2.0/coupons_and_discounts).\n *\n * @element foxy-discount-builder\n * @since 1.17.0\n */\nexport class DiscountBuilder extends Base {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n value: { type: String },\n };\n }\n\n /**\n * Discount URL parameter.\n *\n * Note that if you set this value, it **must be encoded** for the\n * builder to work correctly. You can use either `encodeURIComponent` or `URLSearchParams` like so:\n *\n * ```ts\n * discountBuilder.value = new URLSearchParams([\n * ['discount_amount_percentage', 'Test{allunits|1-2|3-4}']\n * ]).toString();\n * ```\n */\n value: string | null = null;\n\n get parsedValue(): ParsedValue {\n let details = '';\n let name = '';\n let type: DiscountType = 'quantity_amount';\n\n try {\n const [[key, value]] = Array.from(new URLSearchParams(this.value ?? '').entries());\n\n const parsedType = key.substring('discount_'.length);\n const allowedTypes = [\n 'price_amount',\n 'price_percentage',\n 'quantity_amount',\n 'quantity_percentage',\n ];\n\n if (allowedTypes.includes(parsedType)) {\n type = parsedType as DiscountType;\n }\n\n const detailsStart = value.indexOf('{');\n const detailsEnd = value.lastIndexOf('}');\n\n if (detailsStart !== -1 && detailsEnd !== -1) {\n details = value.substring(detailsStart + 1, detailsEnd);\n name = value.substring(0, detailsStart);\n }\n } catch {\n // ignore and use the defaults\n }\n\n if (name.length === 0) name = 'Discount';\n\n return { type, name, details };\n }\n\n set parsedValue({ name, type, details }: ParsedValue) {\n this.value = new URLSearchParams([[`discount_${type}`, `${name}{${details}}`]]).toString();\n }\n\n render(): TemplateResult {\n const details = this.parsedValue.details;\n const tiers = details.split('|').filter(v => !!v.trim());\n const method = (/[-+]/.test(tiers[0]) ? null : tiers.shift()) ?? 'single';\n const renderedTiers = method === 'repeat' ? [tiers[0]] : [...tiers, undefined];\n\n const type = this.parsedValue.type;\n const [source, units] = type.split('_');\n\n return html`\n <div class=\"space-y-s\">\n ${repeat(renderedTiers, (tier, tierIndex) => {\n const onChange = (changedParams: Partial<RulesTierParams>) => {\n const newMethod = changedParams.method ?? method;\n const newSource = changedParams.source ?? source;\n const newUnits = changedParams.units ?? units;\n const newTier = changedParams.tier;\n const newTiers = [...tiers];\n\n if (newTier) {\n const newTierIndex = tier ? tierIndex : newTiers.length;\n const oldTiersCount = tier ? 1 : 0;\n newTiers.splice(newTierIndex, oldTiersCount, newTier);\n }\n\n this.parsedValue = {\n ...this.parsedValue,\n type: `${newSource}_${newUnits}` as DiscountType,\n details: `${newMethod}|${newTiers.join('|')}`,\n };\n\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n const onDelete = () => {\n const newTiers = tiers.filter((_, i) => i !== tierIndex);\n const newDetails = `${method}|${newTiers.join('|')}`;\n\n this.parsedValue = { ...this.parsedValue, details: newDetails };\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n return this.__renderTier({ source, method, units, tier, onChange, onDelete });\n })}\n </div>\n `;\n }\n\n private __renderSelect({ label, value, options, onChange }: RulesTierSelectParams) {\n const isInteractive = !this.disabled && !this.readonly;\n\n return html`\n <label\n class=${classMap({\n 'h-xs whitespace-nowrap block ring-primary-50 rounded-s pl-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n >\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n\n <span class=\"relative leading-none font-medium flex items-center h-full\">\n <span class=\"truncate\">${this.t(options[value])}</span>\n <iron-icon class=\"icon-inline text-xl ml-xs\" icon=\"icons:expand-more\"></iron-icon>\n\n <select\n data-testclass=\"interactive editable\"\n class=\"opacity-0 absolute inset-0 w-full focus-outline-none\"\n ?disabled=${!isInteractive}\n @change=${(evt: Event) => {\n const select = evt.currentTarget as HTMLSelectElement;\n onChange(select.options[select.selectedIndex].value);\n }}\n >\n ${Object.entries(options).map(([optionValue, optionKey]) => {\n return html`\n <option value=${optionValue} ?selected=${optionValue === value}>\n ${this.t(optionKey)}\n </option>\n `;\n })}\n </select>\n </span>\n </label>\n `;\n }\n\n private __renderSwitch({ value, options, onChange }: RulesTierSwitchParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const name = `switch-${Math.floor(Math.random() * Math.pow(10, 10))}`;\n const dotStyle = 'width: 0.4rem; height: 0.4rem';\n\n return html`\n <div\n class=${classMap({\n 'h-xs px-xs space-x-xs flex items-center rounded-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'ring-primary-50 cursor-pointer bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n @click=${(evt: Event) => {\n if (!isInteractive) return;\n\n const target = evt.currentTarget as HTMLDivElement;\n const firstInput = target.querySelector('input') as HTMLInputElement;\n\n firstInput.focus();\n onChange(value === 0 ? 1 : 0);\n }}\n >\n <div class=\"leading-none font-medium px-xs pointer-events-none\">\n ${options.map((option, optionIndex) => {\n return html`\n <label>\n <foxy-i18n\n class=${classMap({ 'sr-only': optionIndex !== value })}\n infer=\"\"\n key=${option}\n >\n </foxy-i18n>\n\n <input\n data-testclass=\"interactive editable\"\n class=\"sr-only\"\n value=${option}\n name=${name}\n type=\"radio\"\n ?disabled=${!isInteractive}\n ?checked=${optionIndex === value}\n @change=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n if (input.checked) onChange(optionIndex);\n }}\n />\n </label>\n `;\n })}\n </div>\n\n <div class=\"flex justify-evenly h-full ${value ? 'flex-col-reverse' : 'flex-col'}\">\n <div style=${dotStyle} class=\"bg-current rounded-full\"></div>\n <div style=${dotStyle} class=\"border border-current rounded-full\"></div>\n </div>\n </div>\n `;\n }\n\n private __renderField({ value, label, onChange }: RulesTierFieldParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const length = value.toString().length;\n const factor = length <= 2 ? 1 : 2.5;\n\n return html`\n <label>\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n <input\n data-testclass=\"interactive editable\"\n style=\"width: calc(var(--lumo-size-xl) * ${factor})\"\n class=${classMap({\n 'transition-colors border p-xs h-xs font-medium text-m rounded-s': true,\n 'ring-primary-50 text-body bg-contrast-10': isInteractive,\n 'hover-bg-contrast-20': isInteractive,\n 'focus-outline-none focus-ring-2': isInteractive,\n 'text-disabled bg-contrast-5': this.disabled,\n 'text-secondary': this.readonly && !this.disabled,\n 'border-transparent border-solid': !this.readonly,\n 'border-dashed border-contrast-30': this.readonly,\n })}\n type=\"number\"\n lang=${this.lang}\n min=\"0\"\n ?disabled=${!isInteractive}\n .value=${value}\n @input=${(evt: InputEvent) => {\n const input = evt.currentTarget as HTMLInputElement;\n onChange(input.value || '0');\n }}\n />\n </label>\n `;\n }\n\n private __renderTier(params: RulesTierParams) {\n const tier = params.tier ?? '0-0';\n const sign = tier.includes('+') ? '+' : '-';\n const [from, adjustment] = tier.split(/[-+]/).map(v => parseFloat(v));\n\n return html`\n <div\n data-testclass=\"rules:tier\"\n aria-label=${this.t('tier')}\n class=\"flex items-start justify-between rounded bg-contrast-5\"\n >\n <div\n class=${classMap({\n 'transition-colors flex flex-wrap items-center gap-s p-s': true,\n 'text-tertiary': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n >\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_if\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['total', 'quantity'],\n value: params.source === 'price' ? 0 : 1,\n onChange: i => params.onChange({ source: i ? 'quantity' : 'price' }),\n })}\n\n <div class=\"h-s w-s\">${operatorGreaterThanOrEqual}</div>\n\n ${this.__renderField({\n label: 'from',\n value: String(from),\n onChange: v => params.onChange({ tier: `${v}${sign}${adjustment}` }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_then\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['reduce', 'increase'],\n value: sign === '-' ? 0 : 1,\n onChange: i => params.onChange({ tier: `${from}${i ? '+' : '-'}${adjustment}` }),\n })}\n\n <!---->\n\n ${this.__renderSelect({\n options: {\n incremental: 'tier_incremental',\n allunits: 'tier_allunits',\n repeat: 'tier_repeat',\n single: 'tier_single',\n },\n value: params.method,\n label: 'target',\n onChange: v => params.onChange({ method: v }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_by\"></foxy-i18n>\n\n ${this.__renderField({\n label: 'adjustment',\n value: String(adjustment),\n onChange: v => params.onChange({ tier: `${from}${sign}${v}` }),\n })}\n\n <!---->\n\n ${this.__renderSwitch({\n value: params.units === 'percentage' ? 0 : 1,\n options: ['%', '¤'],\n onChange: i => params.onChange({ units: i ? 'amount' : 'percentage' }),\n })}\n </div>\n\n ${params.tier\n ? html`\n <button\n data-testclass=\"interactive\"\n aria-label=${this.t('delete')}\n class=${classMap({\n 'w-s h-s m-s flex-shrink-0 rounded-s transition-colors ring-primary-50': true,\n 'text-tertiary hover-text-secondary focus-outline-none focus-ring-2':\n !this.disabled,\n 'text-disabled cursor-default': this.disabled,\n })}\n ?disabled=${this.disabled}\n ?hidden=${this.readonly}\n @click=${() => params.onDelete()}\n >\n <iron-icon icon=\"lumo:cross\"></iron-icon>\n </button>\n `\n : ''}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DiscountBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/DiscountBuilder/DiscountBuilder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAwC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,0BAA0B,EAAE,4DAAyD;AAE9F,MAAM,EAAE,GAAG,kBAAkB,CAAC;AAC9B,MAAM,IAAI,GAAG,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAEnG;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,IAAI;IAAzC;;QAQE;;;;;;;;;;;WAWG;QACH,UAAK,GAAkB,IAAI,CAAC;IAkU9B,CAAC;IArVC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,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AQ,CAAC;gBACf,uEAAuE,EAAE,IAAI;gBAC7E,oEAAoE,EAClE,CAAC,IAAI,CAAC,QAAQ;gBAChB,8BAA8B,EAAE,IAAI,CAAC,QAAQ;aAC9C,CAAC;4BACU,IAAI,CAAC,QAAQ;0BACf,IAAI,CAAC,QAAQ;yBACd,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE;;;;aAInC;YACH,CAAC,CAAC,EAAE;;KAET,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n DiscountType,\n ParsedValue,\n RulesTierParams,\n RulesTierSelectParams,\n RulesTierSwitchParams,\n RulesTierFieldParams,\n} from './types';\n\nimport { html, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { operatorGreaterThanOrEqual } from '../QueryBuilder/icons/operatorGreaterThanOrEqual';\n\nconst NS = 'discount-builder';\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)));\n\n/**\n * Visual builder for discount URL parameters in coupons and more.\n * Learn more about discounts here: [Foxy Wiki](https://wiki.foxycart.com/v/2.0/coupons_and_discounts).\n *\n * @element foxy-discount-builder\n * @since 1.17.0\n */\nexport class DiscountBuilder extends Base {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n value: { type: String },\n };\n }\n\n /**\n * Discount URL parameter.\n *\n * Note that if you set this value, it **must be encoded** for the\n * builder to work correctly. You can use either `encodeURIComponent` or `URLSearchParams` like so:\n *\n * ```ts\n * discountBuilder.value = new URLSearchParams([\n * ['discount_amount_percentage', 'Test{allunits|1-2|3-4}']\n * ]).toString();\n * ```\n */\n value: string | null = null;\n\n get parsedValue(): ParsedValue {\n let details = '';\n let name = '';\n let type: DiscountType = 'quantity_amount';\n\n try {\n const [[key, value]] = Array.from(new URLSearchParams(this.value ?? '').entries());\n\n const parsedType = key.substring('discount_'.length);\n const allowedTypes = [\n 'price_amount',\n 'price_percentage',\n 'quantity_amount',\n 'quantity_percentage',\n ];\n\n if (allowedTypes.includes(parsedType)) {\n type = parsedType as DiscountType;\n }\n\n const detailsStart = value.indexOf('{');\n const detailsEnd = value.lastIndexOf('}');\n\n if (detailsStart !== -1 && detailsEnd !== -1) {\n details = value.substring(detailsStart + 1, detailsEnd);\n name = value.substring(0, detailsStart);\n }\n } catch {\n // ignore and use the defaults\n }\n\n if (name.length === 0) name = 'Discount';\n\n return { type, name, details };\n }\n\n set parsedValue({ name, type, details }: ParsedValue) {\n this.value = new URLSearchParams([[`discount_${type}`, `${name}{${details}}`]]).toString();\n }\n\n render(): TemplateResult {\n const details = this.parsedValue.details;\n const tiers = details.split('|').filter(v => !!v.trim());\n const method = (/[-+]/.test(tiers[0]) ? null : tiers.shift()) ?? 'single';\n const renderedTiers = method === 'repeat' ? [tiers[0]] : [...tiers, undefined];\n\n const type = this.parsedValue.type;\n const [source, units] = type.split('_');\n\n return html`\n <div class=\"space-y-s\">\n ${repeat(renderedTiers, (tier, tierIndex) => {\n const onChange = (changedParams: Partial<RulesTierParams>) => {\n const newMethod = changedParams.method ?? method;\n const newSource = changedParams.source ?? source;\n const newUnits = changedParams.units ?? units;\n const newTier = changedParams.tier;\n const newTiers = [...tiers];\n\n if (newTier) {\n const newTierIndex = tier ? tierIndex : newTiers.length;\n const oldTiersCount = tier ? 1 : 0;\n newTiers.splice(newTierIndex, oldTiersCount, newTier);\n }\n\n this.parsedValue = {\n ...this.parsedValue,\n type: `${newSource}_${newUnits}` as DiscountType,\n details: `${newMethod}|${newTiers.join('|')}`,\n };\n\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n const onDelete = () => {\n const newTiers = tiers.filter((_, i) => i !== tierIndex);\n const newDetails = `${method}|${newTiers.join('|')}`;\n\n this.parsedValue = { ...this.parsedValue, details: newDetails };\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n return this.__renderTier({ source, method, units, tier, onChange, onDelete });\n })}\n </div>\n `;\n }\n\n private __renderSelect({ label, value, options, onChange }: RulesTierSelectParams) {\n const isInteractive = !this.disabled && !this.readonly;\n\n return html`\n <label\n class=${classMap({\n 'h-xs whitespace-nowrap block ring-primary-50 rounded-s pl-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n >\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n\n <span class=\"relative leading-none font-medium flex items-center h-full\">\n <span class=\"truncate\">${this.t(options[value])}</span>\n <iron-icon class=\"icon-inline text-xl ml-xs\" icon=\"icons:expand-more\"></iron-icon>\n\n <select\n data-testclass=\"interactive editable\"\n class=\"opacity-0 absolute inset-0 w-full focus-outline-none\"\n ?disabled=${!isInteractive}\n @change=${(evt: Event) => {\n const select = evt.currentTarget as HTMLSelectElement;\n onChange(select.options[select.selectedIndex].value);\n }}\n >\n ${Object.entries(options).map(([optionValue, optionKey]) => {\n return html`\n <option value=${optionValue} ?selected=${optionValue === value}>\n ${this.t(optionKey)}\n </option>\n `;\n })}\n </select>\n </span>\n </label>\n `;\n }\n\n private __renderSwitch({ value, options, onChange }: RulesTierSwitchParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const name = `switch-${Math.floor(Math.random() * Math.pow(10, 10))}`;\n const dotStyle = 'width: 0.4rem; height: 0.4rem';\n\n return html`\n <div\n class=${classMap({\n 'h-xs px-xs space-x-xs flex items-center rounded-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'ring-primary-50 cursor-pointer bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n @click=${(evt: Event) => {\n if (!isInteractive) return;\n\n const target = evt.currentTarget as HTMLDivElement;\n const firstInput = target.querySelector('input') as HTMLInputElement;\n\n firstInput.focus();\n onChange(value === 0 ? 1 : 0);\n }}\n >\n <div class=\"leading-none font-medium px-xs pointer-events-none\">\n ${options.map((option, optionIndex) => {\n return html`\n <label>\n <foxy-i18n\n class=${classMap({ 'sr-only': optionIndex !== value })}\n infer=\"\"\n key=${option}\n >\n </foxy-i18n>\n\n <input\n data-testclass=\"interactive editable\"\n class=\"sr-only\"\n value=${option}\n name=${name}\n type=\"radio\"\n ?disabled=${!isInteractive}\n ?checked=${optionIndex === value}\n @change=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n if (input.checked) onChange(optionIndex);\n }}\n />\n </label>\n `;\n })}\n </div>\n\n <div class=\"flex justify-evenly h-full ${value ? 'flex-col-reverse' : 'flex-col'}\">\n <div style=${dotStyle} class=\"bg-current rounded-full\"></div>\n <div style=${dotStyle} class=\"border border-current rounded-full\"></div>\n </div>\n </div>\n `;\n }\n\n private __renderField({ value, label, onChange }: RulesTierFieldParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const length = value.toString().length;\n const factor = length <= 2 ? 1 : 2.5;\n\n return html`\n <label>\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n <input\n data-testclass=\"interactive editable\"\n style=\"width: calc(var(--lumo-size-xl) * ${factor})\"\n class=${classMap({\n 'transition-colors border p-xs h-xs font-medium text-m rounded-s': true,\n 'ring-primary-50 text-body bg-contrast-10': isInteractive,\n 'hover-bg-contrast-20': isInteractive,\n 'focus-outline-none focus-ring-2': isInteractive,\n 'text-disabled bg-contrast-5': this.disabled,\n 'text-secondary': this.readonly && !this.disabled,\n 'border-transparent border-solid': !this.readonly,\n 'border-dashed border-contrast-30': this.readonly,\n })}\n type=\"number\"\n lang=${this.lang}\n min=\"0\"\n ?disabled=${!isInteractive}\n .value=${value}\n @input=${(evt: InputEvent) => {\n const input = evt.currentTarget as HTMLInputElement;\n onChange(input.value || '0');\n }}\n />\n </label>\n `;\n }\n\n private __renderTier(params: RulesTierParams) {\n const tier = params.tier ?? '0-0';\n const sign = tier.includes('+') ? '+' : '-';\n const [from, adjustment] = tier.split(/[-+]/).map(v => parseFloat(v));\n\n return html`\n <div\n data-testclass=\"rules:tier\"\n aria-label=${this.t('tier')}\n class=\"flex items-start justify-between rounded bg-contrast-5\"\n >\n <div\n class=${classMap({\n 'transition-colors flex flex-wrap items-center gap-s p-s': true,\n 'text-tertiary': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n >\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_if\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['total', 'quantity'],\n value: params.source === 'price' ? 0 : 1,\n onChange: i => params.onChange({ source: i ? 'quantity' : 'price' }),\n })}\n\n <div class=\"h-s w-s\">${operatorGreaterThanOrEqual}</div>\n\n ${this.__renderField({\n label: 'from',\n value: String(from),\n onChange: v => params.onChange({ tier: `${v}${sign}${adjustment}` }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_then\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['reduce', 'increase'],\n value: sign === '-' ? 0 : 1,\n onChange: i => params.onChange({ tier: `${from}${i ? '+' : '-'}${adjustment}` }),\n })}\n\n <!---->\n\n ${this.__renderSelect({\n options: {\n incremental: 'tier_incremental',\n allunits: 'tier_allunits',\n repeat: 'tier_repeat',\n single: 'tier_single',\n },\n value: params.method,\n label: 'target',\n onChange: v => params.onChange({ method: v }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_by\"></foxy-i18n>\n\n ${this.__renderField({\n label: 'adjustment',\n value: String(adjustment),\n onChange: v => params.onChange({ tier: `${from}${sign}${v}` }),\n })}\n\n <!---->\n\n ${this.__renderSwitch({\n value: params.units === 'percentage' ? 0 : 1,\n options: ['units_percentage', 'units_amount'],\n onChange: i => params.onChange({ units: i ? 'amount' : 'percentage' }),\n })}\n </div>\n\n ${params.tier\n ? html`\n <button\n data-testclass=\"interactive\"\n aria-label=${this.t('delete')}\n class=${classMap({\n 'w-s h-s m-s flex-shrink-0 rounded-s transition-colors ring-primary-50': true,\n 'text-tertiary hover-text-secondary focus-outline-none focus-ring-2':\n !this.disabled,\n 'text-disabled cursor-default': this.disabled,\n })}\n ?disabled=${this.disabled}\n ?hidden=${this.readonly}\n @click=${() => params.onDelete()}\n >\n <iron-icon icon=\"lumo:cross\"></iron-icon>\n </button>\n `\n : ''}\n </div>\n `;\n }\n}\n"]}
|