@foxy.io/elements 1.35.0 → 1.36.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-copy-to-clipboard.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-settings.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-donation.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-form-dialog.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-i18n.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-items-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-embed.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-payments-api.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +15 -15
- 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-spinner.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-4bcb2368.js → shared-0053cf93.js} +1 -1
- package/dist/cdn/{shared-3149ab8d.js → shared-01bb183b.js} +1 -1
- package/dist/cdn/{shared-a4d773a3.js → shared-03355bd1.js} +1 -1
- package/dist/cdn/{shared-6cb26d12.js → shared-0b00883f.js} +1 -1
- package/dist/cdn/{shared-6b06d5c1.js → shared-0b1b1c14.js} +1 -1
- package/dist/cdn/{shared-d9f38239.js → shared-0d8e7067.js} +1 -1
- package/dist/cdn/{shared-2256b8b1.js → shared-10b54c49.js} +1 -1
- package/dist/cdn/{shared-84ada96e.js → shared-133fc37b.js} +1 -1
- package/dist/cdn/{shared-0e59bad9.js → shared-1482d5dd.js} +1 -1
- package/dist/cdn/{shared-db92bb31.js → shared-1a49f70b.js} +1 -1
- package/dist/cdn/shared-1c07cd7f.js +1 -0
- package/dist/cdn/{shared-602ed877.js → shared-22dd6cbe.js} +1 -1
- package/dist/cdn/{shared-7439665e.js → shared-2503aefc.js} +1 -1
- package/dist/cdn/{shared-bf7baab5.js → shared-25893d83.js} +1 -1
- package/dist/cdn/{shared-56271b15.js → shared-2879b67f.js} +1 -1
- package/dist/cdn/{shared-2b25aedd.js → shared-2d11750b.js} +1 -1
- package/dist/cdn/{shared-f0a38941.js → shared-2e8361e1.js} +1 -1
- package/dist/cdn/{shared-831f5042.js → shared-3aaf64e6.js} +1 -1
- package/dist/cdn/{shared-059d1e79.js → shared-40e4854e.js} +1 -1
- package/dist/cdn/{shared-303cf36c.js → shared-42bb9e8e.js} +1 -1
- package/dist/cdn/{shared-a81a1cc3.js → shared-43e551f2.js} +1 -1
- package/dist/cdn/{shared-19ebb715.js → shared-4666b6aa.js} +5 -5
- package/dist/cdn/{shared-2868b35f.js → shared-48970bb4.js} +1 -1
- package/dist/cdn/{shared-e14930ce.js → shared-4c90701b.js} +1 -1
- package/dist/cdn/{shared-35a2aabc.js → shared-4cf87721.js} +1 -1
- package/dist/cdn/{shared-2565fed8.js → shared-4e8a5b95.js} +1 -1
- package/dist/cdn/{shared-afa402dc.js → shared-528b3bdb.js} +1 -1
- package/dist/cdn/{shared-481eb635.js → shared-5f1a4329.js} +1 -1
- package/dist/cdn/{shared-8d92dd6e.js → shared-5f43aa36.js} +1 -1
- package/dist/cdn/{shared-37dc0b85.js → shared-60150977.js} +1 -1
- package/dist/cdn/{shared-acdf3166.js → shared-61ef8001.js} +1 -1
- package/dist/cdn/{shared-9c82e27f.js → shared-6a45a781.js} +2 -2
- package/dist/cdn/{shared-0e1d094b.js → shared-6b76afc2.js} +1 -1
- package/dist/cdn/{shared-927f1a51.js → shared-6d11190a.js} +1 -1
- package/dist/cdn/{shared-61e50856.js → shared-76dcc864.js} +1 -1
- package/dist/cdn/{shared-40bed8c1.js → shared-7cb8722a.js} +1 -1
- package/dist/cdn/{shared-544b7d4b.js → shared-7ce74b42.js} +1 -1
- package/dist/cdn/shared-7e9fdf64.js +1 -0
- package/dist/cdn/{shared-2ca4d459.js → shared-8521017c.js} +1 -1
- package/dist/cdn/{shared-2eebd7bc.js → shared-85475a4e.js} +1 -1
- package/dist/cdn/{shared-c5972323.js → shared-8676e5c0.js} +1 -1
- package/dist/cdn/{shared-4fdc63d9.js → shared-86aa139c.js} +1 -1
- package/dist/cdn/{shared-59d9d6ca.js → shared-89d09114.js} +1 -1
- package/dist/cdn/{shared-21254863.js → shared-901b41cf.js} +1 -1
- package/dist/cdn/{shared-50f2497c.js → shared-9092b247.js} +1 -1
- package/dist/cdn/{shared-5741ba29.js → shared-93774efe.js} +1 -1
- package/dist/cdn/shared-9d7ae4aa.js +1 -0
- package/dist/cdn/{shared-3023dfb2.js → shared-b927be75.js} +3 -3
- package/dist/cdn/{shared-247297ce.js → shared-c1ade7a9.js} +1 -1
- package/dist/cdn/{shared-120413cd.js → shared-c52295d5.js} +1 -1
- package/dist/cdn/{shared-7f68743e.js → shared-c5cf889e.js} +1 -1
- package/dist/cdn/{shared-2676836d.js → shared-cbd1fab7.js} +1 -1
- package/dist/cdn/{shared-751c9f1e.js → shared-cc76a917.js} +1 -1
- package/dist/cdn/{shared-ebd077b5.js → shared-cd652fd0.js} +1 -1
- package/dist/cdn/{shared-a5bd0da6.js → shared-cf28d2c8.js} +1 -1
- package/dist/cdn/{shared-33ed0fe7.js → shared-d1dfac4d.js} +1 -1
- package/dist/cdn/{shared-900fd54f.js → shared-d2340faa.js} +1 -1
- package/dist/cdn/{shared-37c52c4c.js → shared-d279baa5.js} +1 -1
- package/dist/cdn/{shared-64d48bc6.js → shared-d784b79a.js} +1 -1
- package/dist/cdn/{shared-349a42e1.js → shared-e0d1856d.js} +1 -1
- package/dist/cdn/{shared-6fa216e7.js → shared-e622d8cf.js} +1 -1
- package/dist/cdn/{shared-939f50c2.js → shared-f20eefdd.js} +1 -1
- package/dist/cdn/{shared-d4e7383e.js → shared-f316780a.js} +1 -1
- package/dist/cdn/{shared-aa54bc96.js → shared-f72d82a9.js} +1 -1
- package/dist/cdn/{shared-cdb5ad48.js → shared-f92b9842.js} +1 -1
- package/dist/cdn/{shared-639dbd3f.js → shared-fea2714e.js} +1 -1
- package/dist/cdn/translations/native-integration-form/en.json +344 -214
- package/dist/cdn/translations/payments-api-payment-method-form/en.json +6 -0
- package/dist/cdn/translations/payments-api-payment-preset-form/en.json +6 -0
- package/dist/cdn/translations/tax-card/en.json +6 -4
- package/dist/cdn/translations/tax-form/en.json +161 -32
- package/dist/elements/internal/InternalForm/InternalForm.js +2 -2
- package/dist/elements/internal/InternalForm/InternalForm.js.map +1 -1
- package/dist/elements/public/NativeIntegrationForm/NativeIntegrationForm.d.ts +4 -5
- package/dist/elements/public/NativeIntegrationForm/NativeIntegrationForm.js +415 -292
- package/dist/elements/public/NativeIntegrationForm/NativeIntegrationForm.js.map +1 -1
- package/dist/elements/public/NativeIntegrationForm/defaults.d.ts +9 -68
- package/dist/elements/public/NativeIntegrationForm/defaults.js +18 -18
- package/dist/elements/public/NativeIntegrationForm/defaults.js.map +1 -1
- package/dist/elements/public/NativeIntegrationForm/index.d.ts +4 -3
- package/dist/elements/public/NativeIntegrationForm/index.js +4 -3
- package/dist/elements/public/NativeIntegrationForm/index.js.map +1 -1
- package/dist/elements/public/NucleonElement/API.js +8 -2
- package/dist/elements/public/NucleonElement/API.js.map +1 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js +11 -6
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map +1 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/index.d.ts +1 -0
- package/dist/elements/public/PaymentsApiPaymentMethodForm/index.js +1 -0
- package/dist/elements/public/PaymentsApiPaymentMethodForm/index.js.map +1 -1
- package/dist/elements/public/TaxCard/TaxCard.js +4 -0
- package/dist/elements/public/TaxCard/TaxCard.js.map +1 -1
- package/dist/elements/public/TaxForm/TaxForm.d.ts +31 -51
- package/dist/elements/public/TaxForm/TaxForm.js +260 -634
- package/dist/elements/public/TaxForm/TaxForm.js.map +1 -1
- package/dist/elements/public/TaxForm/index.d.ts +9 -9
- package/dist/elements/public/TaxForm/index.js +9 -9
- package/dist/elements/public/TaxForm/index.js.map +1 -1
- package/dist/mixins/themeable.js +4 -0
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-139024d1.js +0 -1
- package/dist/cdn/shared-3b1fc10b.js +0 -1
- package/dist/cdn/shared-433b15f9.js +0 -1
- package/dist/cdn/shared-67898669.js +0 -1
- package/dist/cdn/shared-d9393c31.js +0 -1
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { Checkbox, Dropdown, Metadata } from "../../private/index.js";
|
|
2
|
-
import { Nucleon } from '@foxy.io/sdk/core';
|
|
3
|
-
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
4
|
-
import { html } from 'lit-html';
|
|
5
|
-
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
6
|
-
import { NucleonElement } from "../NucleonElement/NucleonElement.js";
|
|
7
|
-
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
8
1
|
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
9
|
-
import {
|
|
2
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
3
|
+
import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
|
|
10
4
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
11
|
-
import {
|
|
5
|
+
import { html } from 'lit-html';
|
|
6
|
+
const NS = 'tax-form';
|
|
7
|
+
const Base = TranslatableMixin(InternalForm, NS);
|
|
12
8
|
// prettier-ignore
|
|
13
9
|
const defaultLiveRateCountries = ['US', 'CA', 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IM', 'IT', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'];
|
|
14
10
|
const taxJarLiveRateCountries = [...defaultLiveRateCountries, 'AU'];
|
|
15
|
-
const NS = 'tax-form';
|
|
16
|
-
const Base = ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(TranslatableMixin(NucleonElement, NS))));
|
|
17
11
|
/**
|
|
18
12
|
* Form element for creating or editing taxes (`fx:tax`).
|
|
19
13
|
*
|
|
@@ -23,673 +17,305 @@ const Base = ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(TranslatableMi
|
|
|
23
17
|
export class TaxForm extends Base {
|
|
24
18
|
constructor() {
|
|
25
19
|
super(...arguments);
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
throw new Error(await response.text());
|
|
35
|
-
return await response.json();
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
this.__regionsService = interpret(Nucleon.machine.withConfig({
|
|
40
|
-
services: {
|
|
41
|
-
sendGet: async () => {
|
|
42
|
-
var _a;
|
|
43
|
-
const url = new URL(this.regions);
|
|
44
|
-
url.searchParams.set('country_code', (_a = this.form.country) !== null && _a !== void 0 ? _a : 'US');
|
|
45
|
-
const response = await new TaxForm.API(this).fetch(url.toString());
|
|
46
|
-
if (!response.ok)
|
|
47
|
-
throw new Error(await response.text());
|
|
48
|
-
return await response.json();
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
static get scopedElements() {
|
|
54
|
-
return {
|
|
55
|
-
'vaadin-number-field': customElements.get('vaadin-number-field'),
|
|
56
|
-
'vaadin-text-field': customElements.get('vaadin-text-field'),
|
|
57
|
-
'vaadin-combo-box': customElements.get('vaadin-combo-box'),
|
|
58
|
-
'vaadin-button': customElements.get('vaadin-button'),
|
|
59
|
-
'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
|
|
60
|
-
'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
|
|
61
|
-
'foxy-spinner': customElements.get('foxy-spinner'),
|
|
62
|
-
'foxy-i18n': customElements.get('foxy-i18n'),
|
|
63
|
-
'x-metadata': Metadata,
|
|
64
|
-
'x-checkbox': Checkbox,
|
|
65
|
-
'x-dropdown': Dropdown,
|
|
20
|
+
/** URL of the `fx:native_integrations` collection for the store. */
|
|
21
|
+
this.nativeIntegrations = null;
|
|
22
|
+
/** URL of the `fx:countries` property helper resource. */
|
|
23
|
+
this.countries = null;
|
|
24
|
+
/** URL of the `fx:regions` property helper resource. */
|
|
25
|
+
this.regions = null;
|
|
26
|
+
this.__serviceProviderGetValue = () => {
|
|
27
|
+
return this.form.service_provider || (this.form.is_live ? 'default' : 'none');
|
|
66
28
|
};
|
|
29
|
+
this.__serviceProviderSetValue = (newValue) => {
|
|
30
|
+
const newProvider = ['none', 'default'].includes(newValue) ? '' : newValue;
|
|
31
|
+
this.edit({
|
|
32
|
+
service_provider: newProvider,
|
|
33
|
+
use_origin_rates: false,
|
|
34
|
+
is_live: newValue !== 'none',
|
|
35
|
+
});
|
|
36
|
+
this.edit({
|
|
37
|
+
exempt_all_customer_tax_ids: this.__isExemptAllCustomerTaxIdsHidden,
|
|
38
|
+
apply_to_shipping: this.__isApplyToShippingHidden,
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
this.__countrySetValue = (newValue) => {
|
|
42
|
+
this.edit({ country: newValue, region: '', city: '' });
|
|
43
|
+
this.edit({ apply_to_shipping: this.__isApplyToShippingHidden });
|
|
44
|
+
};
|
|
45
|
+
this.__regionSetValue = (newValue) => {
|
|
46
|
+
this.edit({ region: newValue, city: '' });
|
|
47
|
+
};
|
|
48
|
+
this.__typeSetValue = (newValue) => {
|
|
49
|
+
this.edit({
|
|
50
|
+
type: newValue,
|
|
51
|
+
country: '',
|
|
52
|
+
region: '',
|
|
53
|
+
city: '',
|
|
54
|
+
// @ts-expect-error SDK types are not up to date.
|
|
55
|
+
service_provider: newValue === 'custom_tax_endpoint' ? 'custom_tax' : '',
|
|
56
|
+
apply_to_shipping: false,
|
|
57
|
+
use_origin_rates: false,
|
|
58
|
+
exempt_all_customer_tax_ids: false,
|
|
59
|
+
is_live: false,
|
|
60
|
+
rate: 0,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
this.__typeOptions = JSON.stringify([
|
|
64
|
+
{ label: 'option_custom_tax_endpoint', value: 'custom_tax_endpoint' },
|
|
65
|
+
{ label: 'option_global', value: 'global' },
|
|
66
|
+
{ label: 'option_union', value: 'union' },
|
|
67
|
+
{ label: 'option_country', value: 'country' },
|
|
68
|
+
{ label: 'option_region', value: 'region' },
|
|
69
|
+
{ label: 'option_local', value: 'local' },
|
|
70
|
+
]);
|
|
67
71
|
}
|
|
68
72
|
static get properties() {
|
|
69
73
|
return {
|
|
70
74
|
...super.properties,
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
nativeIntegrations: { attribute: 'native-integrations' },
|
|
76
|
+
countries: {},
|
|
77
|
+
regions: {},
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
static get v8n() {
|
|
76
81
|
return [
|
|
77
|
-
({ name: v }) => !!v || '
|
|
78
|
-
({ name: v }) => !v || v.length <= 30 || '
|
|
79
|
-
({ country: c, type: t }) => t !== 'country' || !!c || '
|
|
80
|
-
({ country: c, type: t }) => t !== 'region' || !!c || '
|
|
81
|
-
({ country: c, use_origin_rates: r }) => !r || !!c || '
|
|
82
|
-
({
|
|
83
|
-
({ region: v
|
|
84
|
-
({
|
|
85
|
-
({ city:
|
|
86
|
-
({
|
|
87
|
-
({ rate: v }) => !v || v <= 100 || 'rate_invalid',
|
|
82
|
+
({ name: v }) => !!v || 'name:v8n_required',
|
|
83
|
+
({ name: v }) => !v || v.length <= 30 || 'name:v8n_too_long',
|
|
84
|
+
({ country: c, type: t }) => t !== 'country' || !!c || 'country:v8n_required',
|
|
85
|
+
({ country: c, type: t }) => t !== 'region' || !!c || 'country:v8n_required',
|
|
86
|
+
({ country: c, use_origin_rates: r }) => !r || !!c || 'country:v8n_required',
|
|
87
|
+
({ region: v, type: t }) => t != 'region' || !!v || 'region:v8n_required',
|
|
88
|
+
({ region: v }) => !v || v.length <= 20 || 'region:v8n_too_long',
|
|
89
|
+
({ city: v }) => !v || v.length <= 50 || 'city:v8n_too_long',
|
|
90
|
+
({ city: c, type: t }) => t != 'local' || !!c || 'city:v8n_required',
|
|
91
|
+
({ rate: v }) => v === void 0 || v > 0 || 'rate:v8n_invalid',
|
|
88
92
|
];
|
|
89
93
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
set countries(value) {
|
|
95
|
-
this.__countries = value;
|
|
96
|
-
if (value) {
|
|
97
|
-
this.__countriesService.send({ type: 'FETCH' });
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
this.__countriesService.send({ type: 'SET_DATA', data: null });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/** URI of the `fx:regions` hAPI resource. */
|
|
104
|
-
get regions() {
|
|
105
|
-
return this.__regions;
|
|
94
|
+
get readonlySelector() {
|
|
95
|
+
const alwaysMatch = [super.readonlySelector.toString()];
|
|
96
|
+
alwaysMatch.unshift('native-integrations');
|
|
97
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
106
98
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
get hiddenSelector() {
|
|
100
|
+
var _a, _b, _c;
|
|
101
|
+
const alwaysMatch = [super.hiddenSelector.toString()];
|
|
102
|
+
if (this.__nativeIntegrationsUrl === void 0)
|
|
103
|
+
alwaysMatch.unshift('native-integrations');
|
|
104
|
+
if (this.__isCountryHidden)
|
|
105
|
+
alwaysMatch.unshift('group-three:country');
|
|
106
|
+
if (this.__isRegionHidden) {
|
|
107
|
+
alwaysMatch.unshift('group-three:region-select', 'group-three:region-input');
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
if (this.__isCityHidden)
|
|
110
|
+
alwaysMatch.unshift('group-three:city');
|
|
111
|
+
if (this.__isProviderHidden)
|
|
112
|
+
alwaysMatch.unshift('group-one:service-provider');
|
|
113
|
+
if (this.__isRateHidden)
|
|
114
|
+
alwaysMatch.unshift('group-one:rate');
|
|
115
|
+
if (this.__isApplyToShippingHidden)
|
|
116
|
+
alwaysMatch.unshift('group-two:apply-to-shipping');
|
|
117
|
+
if (this.__isUseOriginRatesHidden)
|
|
118
|
+
alwaysMatch.unshift('group-two:use-origin-rates');
|
|
119
|
+
if (this.__isExemptAllCustomerTaxIdsHidden) {
|
|
120
|
+
alwaysMatch.unshift('group-two:exempt-all-customer-tax-ids');
|
|
114
121
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
render() {
|
|
126
|
-
var _a, _b;
|
|
122
|
+
const regions = Object.values((_c = (_b = (_a = this.__regionsLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.values) !== null && _c !== void 0 ? _c : {});
|
|
123
|
+
alwaysMatch.unshift(`group-three:region-${regions.length ? 'input' : 'select'}`);
|
|
124
|
+
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
125
|
+
}
|
|
126
|
+
renderBody() {
|
|
127
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
128
|
+
const countries = Object.values((_c = (_b = (_a = this.__countriesLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.values) !== null && _c !== void 0 ? _c : {});
|
|
129
|
+
const countryOptions = countries.map(c => ({ rawLabel: c.default, value: c.cc2 }));
|
|
130
|
+
const regions = Object.values((_f = (_e = (_d = this.__regionsLoader) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.values) !== null && _f !== void 0 ? _f : {});
|
|
131
|
+
const regionOptions = regions.map(r => ({ rawLabel: r.default, value: r.code }));
|
|
127
132
|
return html `
|
|
128
|
-
|
|
129
|
-
${this.__isNameHidden ? null : this.__renderName()}
|
|
130
|
-
${this.__isTypeHidden ? null : this.__renderType()}
|
|
131
|
-
${this.__isCountryHidden ? null : this.__renderCountry()}
|
|
132
|
-
${this.__isRegionHidden ? null : this.__renderRegion()}
|
|
133
|
-
${this.__isCityHidden ? null : this.__renderCity()}
|
|
134
|
-
${this.__isProviderHidden ? null : this.__renderProvider()}
|
|
135
|
-
${this.__isRateHidden ? null : this.__renderRate()}
|
|
136
|
-
${this.__isApplyToShippingHidden ? null : this.__renderApplyToShipping()}
|
|
137
|
-
${this.__isUseOriginRatesHidden ? null : this.__renderUseOriginRates()}
|
|
138
|
-
${this.__isExemptAllCustomerTaxIdsHidden ? null : this.__renderExemptAllCustomerTaxIds()}
|
|
139
|
-
${this.__isTimestampsHidden ? null : this.__renderTimestamps()}
|
|
140
|
-
${this.__isCreateHidden ? null : this.__renderCreate()}
|
|
141
|
-
${this.__isDeleteHidden ? null : this.__renderDelete()}
|
|
133
|
+
${this.renderHeader()}
|
|
142
134
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
135
|
+
<foxy-internal-summary-control infer="group-one">
|
|
136
|
+
<foxy-internal-text-control layout="summary-item" infer="name"></foxy-internal-text-control>
|
|
137
|
+
|
|
138
|
+
<foxy-internal-select-control
|
|
139
|
+
options=${this.__typeOptions}
|
|
140
|
+
layout="summary-item"
|
|
141
|
+
infer="type"
|
|
142
|
+
.setValue=${this.__typeSetValue}
|
|
149
143
|
>
|
|
150
|
-
|
|
151
|
-
layout="vertical"
|
|
152
|
-
class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
|
|
153
|
-
state=${this.in('fail') ? 'error' : this.in('busy') ? 'busy' : 'empty'}
|
|
154
|
-
lang=${this.lang}
|
|
155
|
-
ns="${this.ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
|
|
156
|
-
>
|
|
157
|
-
</foxy-spinner>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
`;
|
|
161
|
-
}
|
|
162
|
-
updated(changes) {
|
|
163
|
-
super.updated(changes);
|
|
164
|
-
if (this.form.country !== this.__previousCountry) {
|
|
165
|
-
this.__previousCountry = this.form.country;
|
|
166
|
-
this.__regionsService.send({ type: 'FETCH' });
|
|
167
|
-
}
|
|
168
|
-
// vaadin's combo box doesn't seem to validate on its own
|
|
169
|
-
this.renderRoot.querySelectorAll('vaadin-combo-box').forEach(e => e.validate());
|
|
170
|
-
}
|
|
171
|
-
disconnectedCallback() {
|
|
172
|
-
super.disconnectedCallback();
|
|
173
|
-
this.__countriesService.stop();
|
|
174
|
-
this.__regionsService.stop();
|
|
175
|
-
}
|
|
176
|
-
get __isNameHidden() {
|
|
177
|
-
return this.hiddenSelector.matches('name', true);
|
|
178
|
-
}
|
|
179
|
-
get __isTypeHidden() {
|
|
180
|
-
return this.hiddenSelector.matches('type', true);
|
|
181
|
-
}
|
|
182
|
-
get __isCountryHidden() {
|
|
183
|
-
if (this.hiddenSelector.matches('country', true))
|
|
184
|
-
return true;
|
|
185
|
-
if (this.form.type === 'union')
|
|
186
|
-
return !this.form.use_origin_rates;
|
|
187
|
-
return !['country', 'region', 'local'].includes(this.form.type);
|
|
188
|
-
}
|
|
189
|
-
get __isRegionHidden() {
|
|
190
|
-
if (this.hiddenSelector.matches('region', true))
|
|
191
|
-
return true;
|
|
192
|
-
return this.form.type !== 'local' && this.form.type !== 'region';
|
|
193
|
-
}
|
|
194
|
-
get __isCityHidden() {
|
|
195
|
-
if (this.hiddenSelector.matches('city', true))
|
|
196
|
-
return true;
|
|
197
|
-
return this.form.type !== 'local';
|
|
198
|
-
}
|
|
199
|
-
get __isProviderHidden() {
|
|
200
|
-
if (this.hiddenSelector.matches('provider', true))
|
|
201
|
-
return true;
|
|
202
|
-
return !this.form.type || this.form.type === 'global' || this.form.type === 'local';
|
|
203
|
-
}
|
|
204
|
-
get __isRateHidden() {
|
|
205
|
-
if (this.hiddenSelector.matches('rate', true))
|
|
206
|
-
return true;
|
|
207
|
-
return !this.form.type || this.form.is_live === true;
|
|
208
|
-
}
|
|
209
|
-
get __isApplyToShippingHidden() {
|
|
210
|
-
if (this.hiddenSelector.matches('apply-to-shipping', true))
|
|
211
|
-
return true;
|
|
212
|
-
if (this.form.type === undefined)
|
|
213
|
-
return true;
|
|
214
|
-
return !!this.form.is_live && defaultLiveRateCountries.includes(this.form.country);
|
|
215
|
-
}
|
|
216
|
-
get __isUseOriginRatesHidden() {
|
|
217
|
-
if (this.hiddenSelector.matches('use-origin-rates', true))
|
|
218
|
-
return true;
|
|
219
|
-
return this.form.type !== 'union' || !this.form.is_live || !!this.form.service_provider;
|
|
220
|
-
}
|
|
221
|
-
get __isExemptAllCustomerTaxIdsHidden() {
|
|
222
|
-
if (this.hiddenSelector.matches('exempt-all-customer-tax-ids', true))
|
|
223
|
-
return true;
|
|
224
|
-
const provider = this.form.service_provider;
|
|
225
|
-
return provider === undefined || provider === 'onesource' || provider === 'avalara';
|
|
226
|
-
}
|
|
227
|
-
get __isTimestampsHidden() {
|
|
228
|
-
if (this.hiddenSelector.matches('timestamps', true))
|
|
229
|
-
return true;
|
|
230
|
-
return !this.data;
|
|
231
|
-
}
|
|
232
|
-
get __isCreateHidden() {
|
|
233
|
-
if (this.hiddenSelector.matches('create', true))
|
|
234
|
-
return true;
|
|
235
|
-
return !!this.data;
|
|
236
|
-
}
|
|
237
|
-
get __isDeleteHidden() {
|
|
238
|
-
if (this.hiddenSelector.matches('delete', true))
|
|
239
|
-
return true;
|
|
240
|
-
return !this.data;
|
|
241
|
-
}
|
|
242
|
-
__getErrorMessage(prefix) {
|
|
243
|
-
const error = this.errors.find(err => err.startsWith(prefix));
|
|
244
|
-
return error ? this.t(error.replace(prefix, 'v8n')).toString() : '';
|
|
245
|
-
}
|
|
246
|
-
__getValidator(prefix) {
|
|
247
|
-
return () => !this.errors.some(err => err.startsWith(prefix));
|
|
248
|
-
}
|
|
249
|
-
__renderName() {
|
|
250
|
-
return html `
|
|
251
|
-
<div>
|
|
252
|
-
${this.renderTemplateOrSlot('name:before')}
|
|
144
|
+
</foxy-internal-select-control>
|
|
253
145
|
|
|
254
|
-
<
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
.
|
|
260
|
-
.errorMessage=${this.__getErrorMessage('name')}
|
|
261
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('name', true)}
|
|
262
|
-
?readonly=${this.readonlySelector.matches('name', true)}
|
|
263
|
-
required
|
|
264
|
-
@keydown=${this.__submitOnEnter}
|
|
265
|
-
@input=${(evt) => {
|
|
266
|
-
const newName = evt.currentTarget.value;
|
|
267
|
-
this.edit({ name: newName });
|
|
268
|
-
}}
|
|
146
|
+
<foxy-internal-select-control
|
|
147
|
+
options=${JSON.stringify(this.__serviceProviderOptions)}
|
|
148
|
+
layout="summary-item"
|
|
149
|
+
infer="service-provider"
|
|
150
|
+
.getValue=${this.__serviceProviderGetValue}
|
|
151
|
+
.setValue=${this.__serviceProviderSetValue}
|
|
269
152
|
>
|
|
270
|
-
</
|
|
153
|
+
</foxy-internal-select-control>
|
|
271
154
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
__renderType() {
|
|
277
|
-
if (!this.form.type)
|
|
278
|
-
this.edit({ type: 'global' });
|
|
279
|
-
return html `
|
|
280
|
-
<div>
|
|
281
|
-
${this.renderTemplateOrSlot('type:before')}
|
|
155
|
+
<foxy-internal-number-control layout="summary-item" suffix="%" infer="rate" min="0">
|
|
156
|
+
</foxy-internal-number-control>
|
|
157
|
+
</foxy-internal-summary-control>
|
|
282
158
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
.getText=${(value) => this.t(`tax_${value}`)}
|
|
290
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('type', true)}
|
|
291
|
-
?readonly=${this.readonlySelector.matches('type', true)}
|
|
292
|
-
@change=${(evt) => {
|
|
293
|
-
this.edit({
|
|
294
|
-
type: evt.detail,
|
|
295
|
-
country: '',
|
|
296
|
-
region: '',
|
|
297
|
-
city: '',
|
|
298
|
-
service_provider: '',
|
|
299
|
-
apply_to_shipping: false,
|
|
300
|
-
use_origin_rates: false,
|
|
301
|
-
exempt_all_customer_tax_ids: false,
|
|
302
|
-
is_live: false,
|
|
303
|
-
rate: 0,
|
|
304
|
-
});
|
|
305
|
-
}}
|
|
306
|
-
>
|
|
307
|
-
</x-dropdown>
|
|
159
|
+
<foxy-internal-async-list-control
|
|
160
|
+
infer="native-integrations"
|
|
161
|
+
first=${ifDefined(this.__nativeIntegrationsUrl)}
|
|
162
|
+
item="foxy-native-integration-card"
|
|
163
|
+
>
|
|
164
|
+
</foxy-internal-async-list-control>
|
|
308
165
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const isLoadingItems = !!((_a = this.__countriesService.state) === null || _a === void 0 ? void 0 : _a.matches('busy'));
|
|
316
|
-
const isLoadingData = this.in('busy');
|
|
317
|
-
const isLoading = isLoadingItems || isLoadingData;
|
|
318
|
-
const isFail = this.in('fail');
|
|
319
|
-
const json = (_b = this.__countriesService.state) === null || _b === void 0 ? void 0 : _b.context.data;
|
|
320
|
-
const items = Object.values((_c = json === null || json === void 0 ? void 0 : json.values) !== null && _c !== void 0 ? _c : {});
|
|
321
|
-
return html `
|
|
322
|
-
<div>
|
|
323
|
-
${this.renderTemplateOrSlot('country:before')}
|
|
166
|
+
<foxy-internal-summary-control infer="group-two">
|
|
167
|
+
<foxy-internal-switch-control infer="exempt-all-customer-tax-ids">
|
|
168
|
+
</foxy-internal-switch-control>
|
|
169
|
+
<foxy-internal-switch-control infer="apply-to-shipping"></foxy-internal-switch-control>
|
|
170
|
+
<foxy-internal-switch-control infer="use-origin-rates"></foxy-internal-switch-control>
|
|
171
|
+
</foxy-internal-summary-control>
|
|
324
172
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
value=${ifDefined(isLoadingItems ? undefined : this.form.country)}
|
|
332
|
-
class="w-full"
|
|
333
|
-
.checkValidity=${this.__getValidator('country')}
|
|
334
|
-
.errorMessage=${this.__getErrorMessage('country')}
|
|
335
|
-
.items=${items}
|
|
336
|
-
?allow-custom-value=${items.length === 0}
|
|
337
|
-
?disabled=${isFail || isLoading || this.disabledSelector.matches('country', true)}
|
|
338
|
-
?readonly=${this.readonlySelector.matches('country', true)}
|
|
339
|
-
required
|
|
340
|
-
@change=${(evt) => {
|
|
341
|
-
this.edit({
|
|
342
|
-
country: evt.currentTarget.value,
|
|
343
|
-
region: '',
|
|
344
|
-
city: '',
|
|
345
|
-
is_live: false,
|
|
346
|
-
service_provider: '',
|
|
347
|
-
});
|
|
348
|
-
if (this.__isApplyToShippingHidden)
|
|
349
|
-
this.edit({ apply_to_shipping: false });
|
|
350
|
-
this.__regionsService.send({ type: 'FETCH' });
|
|
351
|
-
}}
|
|
173
|
+
<foxy-internal-summary-control infer="group-three">
|
|
174
|
+
<foxy-internal-select-control
|
|
175
|
+
options=${JSON.stringify(countryOptions)}
|
|
176
|
+
layout="summary-item"
|
|
177
|
+
infer="country"
|
|
178
|
+
.setValue=${this.__countrySetValue}
|
|
352
179
|
>
|
|
353
|
-
</
|
|
180
|
+
</foxy-internal-select-control>
|
|
354
181
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const isLoading = isLoadingItems || isLoadingData;
|
|
364
|
-
const isFail = this.in('fail');
|
|
365
|
-
const json = (_b = this.__regionsService.state) === null || _b === void 0 ? void 0 : _b.context.data;
|
|
366
|
-
const items = Object.values((_c = json === null || json === void 0 ? void 0 : json.values) !== null && _c !== void 0 ? _c : {});
|
|
367
|
-
return html `
|
|
368
|
-
<div>
|
|
369
|
-
${this.renderTemplateOrSlot('region:before')}
|
|
182
|
+
<foxy-internal-select-control
|
|
183
|
+
property="region"
|
|
184
|
+
options=${JSON.stringify(regionOptions)}
|
|
185
|
+
layout="summary-item"
|
|
186
|
+
infer="region-select"
|
|
187
|
+
.setValue=${this.__regionSetValue}
|
|
188
|
+
>
|
|
189
|
+
</foxy-internal-select-control>
|
|
370
190
|
|
|
371
|
-
<
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
label="${this.t('region')}${isLoadingItems ? ` • ${this.t('loading_busy')}` : ''}"
|
|
377
|
-
value=${ifDefined(isLoadingItems ? undefined : this.form.region)}
|
|
378
|
-
class="w-full"
|
|
379
|
-
.checkValidity=${this.__getValidator('region')}
|
|
380
|
-
.errorMessage=${this.__getErrorMessage('region')}
|
|
381
|
-
.items=${items}
|
|
382
|
-
?allow-custom-value=${items.length === 0}
|
|
383
|
-
?disabled=${isFail || isLoading || this.disabledSelector.matches('region', true)}
|
|
384
|
-
?readonly=${this.readonlySelector.matches('region', true)}
|
|
385
|
-
required
|
|
386
|
-
@change=${(evt) => {
|
|
387
|
-
const newRegion = evt.currentTarget.value;
|
|
388
|
-
this.edit({ region: newRegion, city: '' });
|
|
389
|
-
}}
|
|
191
|
+
<foxy-internal-text-control
|
|
192
|
+
property="region"
|
|
193
|
+
layout="summary-item"
|
|
194
|
+
infer="region-input"
|
|
195
|
+
.setValue=${this.__regionSetValue}
|
|
390
196
|
>
|
|
391
|
-
</
|
|
197
|
+
</foxy-internal-text-control>
|
|
392
198
|
|
|
393
|
-
|
|
394
|
-
</
|
|
395
|
-
`;
|
|
396
|
-
}
|
|
397
|
-
__renderCity() {
|
|
398
|
-
return html `
|
|
399
|
-
<div>
|
|
400
|
-
${this.renderTemplateOrSlot('city:before')}
|
|
199
|
+
<foxy-internal-text-control layout="summary-item" infer="city"></foxy-internal-text-control>
|
|
200
|
+
</foxy-internal-summary-control>
|
|
401
201
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
@keydown=${this.__submitOnEnter}
|
|
413
|
-
@input=${(evt) => {
|
|
414
|
-
const newCity = evt.currentTarget.value;
|
|
415
|
-
this.edit({ city: newCity });
|
|
416
|
-
}}
|
|
417
|
-
>
|
|
418
|
-
</vaadin-text-field>
|
|
202
|
+
${super.renderBody()}
|
|
203
|
+
|
|
204
|
+
<foxy-nucleon
|
|
205
|
+
infer=""
|
|
206
|
+
class="hidden"
|
|
207
|
+
href=${ifDefined((_g = this.countries) !== null && _g !== void 0 ? _g : void 0)}
|
|
208
|
+
id="countriesLoader"
|
|
209
|
+
@update=${() => this.requestUpdate()}
|
|
210
|
+
>
|
|
211
|
+
</foxy-nucleon>
|
|
419
212
|
|
|
420
|
-
|
|
421
|
-
|
|
213
|
+
<foxy-nucleon
|
|
214
|
+
infer=""
|
|
215
|
+
class="hidden"
|
|
216
|
+
href=${ifDefined(this.__regionsUrl)}
|
|
217
|
+
id="regionsLoader"
|
|
218
|
+
@update=${() => this.requestUpdate()}
|
|
219
|
+
>
|
|
220
|
+
</foxy-nucleon>
|
|
422
221
|
`;
|
|
423
222
|
}
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
{ label:
|
|
427
|
-
{ label: '
|
|
428
|
-
{ label: '
|
|
223
|
+
get __serviceProviderOptions() {
|
|
224
|
+
const options = [
|
|
225
|
+
{ label: 'option_none', value: 'none' },
|
|
226
|
+
{ label: 'option_avalara', value: 'avalara' },
|
|
227
|
+
{ label: 'option_onesource', value: 'onesource' },
|
|
429
228
|
];
|
|
430
|
-
if (this.form.type === 'union' ||
|
|
431
|
-
|
|
229
|
+
if (this.form.type === 'union' ||
|
|
230
|
+
!this.form.country ||
|
|
231
|
+
defaultLiveRateCountries.includes(this.form.country)) {
|
|
232
|
+
options.unshift({ label: 'option_default', value: 'default' });
|
|
432
233
|
}
|
|
433
|
-
if (
|
|
434
|
-
|
|
234
|
+
if (this.form.type === 'union' ||
|
|
235
|
+
!this.form.country ||
|
|
236
|
+
taxJarLiveRateCountries.includes(this.form.country)) {
|
|
237
|
+
options.push({ label: 'option_taxjar', value: 'taxjar' });
|
|
435
238
|
}
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
.getText=${(value) => { var _a; return (_a = items.find(item => item.value === value)) === null || _a === void 0 ? void 0 : _a.label; }}
|
|
447
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('provider', true)}
|
|
448
|
-
?readonly=${this.readonlySelector.matches('provider', true)}
|
|
449
|
-
@change=${(evt) => {
|
|
450
|
-
const newValue = evt.detail;
|
|
451
|
-
const newProvider = ['none', 'default'].includes(newValue) ? '' : newValue;
|
|
452
|
-
this.edit({
|
|
453
|
-
service_provider: newProvider,
|
|
454
|
-
is_live: newValue !== 'none',
|
|
455
|
-
});
|
|
456
|
-
if (this.__isExemptAllCustomerTaxIdsHidden) {
|
|
457
|
-
this.edit({ exempt_all_customer_tax_ids: false });
|
|
239
|
+
return options;
|
|
240
|
+
}
|
|
241
|
+
get __nativeIntegrationsUrl() {
|
|
242
|
+
var _a;
|
|
243
|
+
try {
|
|
244
|
+
const url = new URL((_a = this.nativeIntegrations) !== null && _a !== void 0 ? _a : '');
|
|
245
|
+
const provider = this.form.service_provider;
|
|
246
|
+
if (provider) {
|
|
247
|
+
url.searchParams.set('provider', provider);
|
|
248
|
+
return url.toString();
|
|
458
249
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}}
|
|
464
|
-
>
|
|
465
|
-
</x-dropdown>
|
|
466
|
-
|
|
467
|
-
${this.renderTemplateOrSlot('provider:after')}
|
|
468
|
-
</div>
|
|
469
|
-
`;
|
|
250
|
+
}
|
|
251
|
+
catch (_b) {
|
|
252
|
+
// do nothing
|
|
253
|
+
}
|
|
470
254
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
.errorMessage=${this.__getErrorMessage('rate')}
|
|
484
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('rate', true)}
|
|
485
|
-
?readonly=${this.readonlySelector.matches('rate', true)}
|
|
486
|
-
required
|
|
487
|
-
@keydown=${this.__submitOnEnter}
|
|
488
|
-
@change=${(evt) => {
|
|
489
|
-
const newRate = parseFloat(evt.currentTarget.value);
|
|
490
|
-
if (!isNaN(newRate))
|
|
491
|
-
this.edit({ rate: newRate });
|
|
492
|
-
}}
|
|
493
|
-
>
|
|
494
|
-
</vaadin-number-field>
|
|
495
|
-
|
|
496
|
-
${this.renderTemplateOrSlot('rate:after')}
|
|
497
|
-
</div>
|
|
498
|
-
`;
|
|
255
|
+
get __regionsUrl() {
|
|
256
|
+
var _a;
|
|
257
|
+
try {
|
|
258
|
+
const regionsURL = new URL((_a = this.regions) !== null && _a !== void 0 ? _a : '');
|
|
259
|
+
const country = this.form.country;
|
|
260
|
+
if (country)
|
|
261
|
+
regionsURL.searchParams.set('country_code', country);
|
|
262
|
+
return regionsURL.toString();
|
|
263
|
+
}
|
|
264
|
+
catch (_b) {
|
|
265
|
+
// do nothing
|
|
266
|
+
}
|
|
499
267
|
}
|
|
500
|
-
|
|
501
|
-
return
|
|
502
|
-
<div>
|
|
503
|
-
${this.renderTemplateOrSlot('apply-to-shipping:before')}
|
|
504
|
-
|
|
505
|
-
<x-checkbox
|
|
506
|
-
data-testid="apply-to-shipping"
|
|
507
|
-
class="leading-s"
|
|
508
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('apply-to-shipping', true)}
|
|
509
|
-
?readonly=${this.readonlySelector.matches('apply-to-shipping', true)}
|
|
510
|
-
?checked=${!!this.form.apply_to_shipping}
|
|
511
|
-
@change=${(evt) => this.edit({ apply_to_shipping: evt.detail })}
|
|
512
|
-
>
|
|
513
|
-
<foxy-i18n
|
|
514
|
-
class="block text-m text-body"
|
|
515
|
-
lang=${this.lang}
|
|
516
|
-
key="tax_apply_to_shipping"
|
|
517
|
-
ns=${this.ns}
|
|
518
|
-
>
|
|
519
|
-
</foxy-i18n>
|
|
520
|
-
|
|
521
|
-
<foxy-i18n
|
|
522
|
-
class="block text-s text-secondary"
|
|
523
|
-
lang=${this.lang}
|
|
524
|
-
key="tax_apply_to_shipping_explainer"
|
|
525
|
-
ns=${this.ns}
|
|
526
|
-
>
|
|
527
|
-
</foxy-i18n>
|
|
528
|
-
</x-checkbox>
|
|
529
|
-
|
|
530
|
-
${this.renderTemplateOrSlot('apply-to-shipping:after')}
|
|
531
|
-
</div>
|
|
532
|
-
`;
|
|
268
|
+
get __countriesLoader() {
|
|
269
|
+
return this.renderRoot.querySelector('#countriesLoader');
|
|
533
270
|
}
|
|
534
|
-
|
|
535
|
-
return
|
|
536
|
-
<div>
|
|
537
|
-
${this.renderTemplateOrSlot('use-origin-rates:before')}
|
|
538
|
-
|
|
539
|
-
<x-checkbox
|
|
540
|
-
data-testid="use-origin-rates"
|
|
541
|
-
class="leading-s"
|
|
542
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('use-origin-rates', true)}
|
|
543
|
-
?readonly=${this.readonlySelector.matches('use-origin-rates', true)}
|
|
544
|
-
?checked=${!!this.form.use_origin_rates}
|
|
545
|
-
@change=${(evt) => this.edit({ use_origin_rates: evt.detail })}
|
|
546
|
-
>
|
|
547
|
-
<foxy-i18n
|
|
548
|
-
class="block text-m text-body"
|
|
549
|
-
lang=${this.lang}
|
|
550
|
-
key="tax_use_origin_rates"
|
|
551
|
-
ns=${this.ns}
|
|
552
|
-
>
|
|
553
|
-
</foxy-i18n>
|
|
554
|
-
|
|
555
|
-
<foxy-i18n
|
|
556
|
-
class="block text-s text-secondary"
|
|
557
|
-
lang=${this.lang}
|
|
558
|
-
key="tax_use_origin_rates_explainer"
|
|
559
|
-
ns=${this.ns}
|
|
560
|
-
>
|
|
561
|
-
</foxy-i18n>
|
|
562
|
-
</x-checkbox>
|
|
563
|
-
|
|
564
|
-
${this.renderTemplateOrSlot('use-origin-rates:after')}
|
|
565
|
-
</div>
|
|
566
|
-
`;
|
|
271
|
+
get __regionsLoader() {
|
|
272
|
+
return this.renderRoot.querySelector('#regionsLoader');
|
|
567
273
|
}
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
class="leading-s"
|
|
577
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches(scope, true)}
|
|
578
|
-
?readonly=${this.readonlySelector.matches(scope, true)}
|
|
579
|
-
?checked=${!!this.form.exempt_all_customer_tax_ids}
|
|
580
|
-
@change=${(evt) => {
|
|
581
|
-
this.edit({ exempt_all_customer_tax_ids: evt.detail });
|
|
582
|
-
}}
|
|
583
|
-
>
|
|
584
|
-
<foxy-i18n
|
|
585
|
-
class="block text-m text-body"
|
|
586
|
-
lang=${this.lang}
|
|
587
|
-
key="tax_exempt_all_customer_tax_ids"
|
|
588
|
-
ns=${this.ns}
|
|
589
|
-
>
|
|
590
|
-
</foxy-i18n>
|
|
591
|
-
|
|
592
|
-
<foxy-i18n
|
|
593
|
-
class="block text-s text-secondary"
|
|
594
|
-
lang=${this.lang}
|
|
595
|
-
key="tax_exempt_all_customer_tax_ids_explainer"
|
|
596
|
-
ns=${this.ns}
|
|
597
|
-
>
|
|
598
|
-
</foxy-i18n>
|
|
599
|
-
</x-checkbox>
|
|
600
|
-
|
|
601
|
-
${this.renderTemplateOrSlot(`${scope}:after`)}
|
|
602
|
-
</div>
|
|
603
|
-
`;
|
|
274
|
+
get __isExemptAllCustomerTaxIdsHidden() {
|
|
275
|
+
const type = this.form.type;
|
|
276
|
+
if (type === 'custom_tax_endpoint')
|
|
277
|
+
return true;
|
|
278
|
+
if (type === 'country' || type === 'region' || type === 'local')
|
|
279
|
+
return !!this.form.is_live;
|
|
280
|
+
const provider = this.form.service_provider;
|
|
281
|
+
return !provider || provider === 'onesource' || provider === 'avalara' || provider === 'taxjar';
|
|
604
282
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
return
|
|
615
|
-
|
|
616
|
-
value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
|
|
617
|
-
: '',
|
|
618
|
-
});
|
|
619
|
-
})}
|
|
620
|
-
>
|
|
621
|
-
</x-metadata>
|
|
622
|
-
|
|
623
|
-
${this.renderTemplateOrSlot('timestamps:after')}
|
|
624
|
-
</div>
|
|
625
|
-
`;
|
|
283
|
+
get __isApplyToShippingHidden() {
|
|
284
|
+
const type = this.form.type;
|
|
285
|
+
if (!type || type === 'custom_tax_endpoint')
|
|
286
|
+
return true;
|
|
287
|
+
if (type === 'union')
|
|
288
|
+
return false;
|
|
289
|
+
if (type === 'country' && this.form.is_live)
|
|
290
|
+
return true;
|
|
291
|
+
if (type === 'region' && this.form.is_live)
|
|
292
|
+
return true;
|
|
293
|
+
return !!this.form.is_live && defaultLiveRateCountries.includes(this.form.country);
|
|
626
294
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
const isDirtyTemplateInvalid = this.in({ idle: { template: { dirty: 'invalid' } } });
|
|
630
|
-
const isCleanSnapshotInvalid = this.in({ idle: { snapshot: { clean: 'invalid' } } });
|
|
631
|
-
const isDirtySnapshotInvalid = this.in({ idle: { snapshot: { dirty: 'invalid' } } });
|
|
632
|
-
const isTemplateInvalid = isCleanTemplateInvalid || isDirtyTemplateInvalid;
|
|
633
|
-
const isSnaphotInvalid = isCleanSnapshotInvalid || isDirtySnapshotInvalid;
|
|
634
|
-
const isInvalid = isTemplateInvalid || isSnaphotInvalid;
|
|
635
|
-
const isIdle = this.in('idle');
|
|
636
|
-
return html `
|
|
637
|
-
<div>
|
|
638
|
-
${this.renderTemplateOrSlot('create:before')}
|
|
639
|
-
|
|
640
|
-
<vaadin-button
|
|
641
|
-
data-testid="create"
|
|
642
|
-
class="w-full"
|
|
643
|
-
theme="primary success"
|
|
644
|
-
?disabled=${!isIdle || isInvalid || this.disabledSelector.matches('create', true)}
|
|
645
|
-
@click=${this.submit}
|
|
646
|
-
>
|
|
647
|
-
<foxy-i18n ns=${this.ns} key="create" lang=${this.lang}></foxy-i18n>
|
|
648
|
-
</vaadin-button>
|
|
649
|
-
|
|
650
|
-
${this.renderTemplateOrSlot('create:after')}
|
|
651
|
-
</div>
|
|
652
|
-
`;
|
|
295
|
+
get __isUseOriginRatesHidden() {
|
|
296
|
+
return this.form.type !== 'union' || !this.form.is_live || !!this.form.service_provider;
|
|
653
297
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
<foxy-internal-confirm-dialog
|
|
658
|
-
data-testid="confirm"
|
|
659
|
-
message="delete_prompt"
|
|
660
|
-
confirm="delete"
|
|
661
|
-
cancel="cancel"
|
|
662
|
-
header="delete"
|
|
663
|
-
theme="primary error"
|
|
664
|
-
lang=${this.lang}
|
|
665
|
-
ns=${this.ns}
|
|
666
|
-
id="confirm"
|
|
667
|
-
@hide=${(evt) => !evt.detail.cancelled && this.delete()}
|
|
668
|
-
>
|
|
669
|
-
</foxy-internal-confirm-dialog>
|
|
670
|
-
|
|
671
|
-
${this.renderTemplateOrSlot('delete:before')}
|
|
672
|
-
|
|
673
|
-
<vaadin-button
|
|
674
|
-
data-testid="delete"
|
|
675
|
-
theme="error"
|
|
676
|
-
class="w-full"
|
|
677
|
-
?disabled=${!this.in('idle') || this.disabledSelector.matches('delete', true)}
|
|
678
|
-
@click=${(evt) => {
|
|
679
|
-
const confirm = this.renderRoot.querySelector('#confirm');
|
|
680
|
-
confirm.show(evt.currentTarget);
|
|
681
|
-
}}
|
|
682
|
-
>
|
|
683
|
-
<foxy-i18n ns=${this.ns} key="delete" lang=${this.lang}></foxy-i18n>
|
|
684
|
-
</vaadin-button>
|
|
685
|
-
|
|
686
|
-
${this.renderTemplateOrSlot('delete:after')}
|
|
687
|
-
</div>
|
|
688
|
-
`;
|
|
298
|
+
get __isProviderHidden() {
|
|
299
|
+
const type = this.form.type;
|
|
300
|
+
return !type || type === 'global' || type === 'local' || type === 'custom_tax_endpoint';
|
|
689
301
|
}
|
|
690
|
-
|
|
691
|
-
if (
|
|
692
|
-
this.
|
|
302
|
+
get __isCountryHidden() {
|
|
303
|
+
if (this.form.type === 'union') {
|
|
304
|
+
return (!this.form.service_provider || this.form.is_live) && !this.form.use_origin_rates;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
return !['country', 'region', 'local'].includes(this.form.type);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
get __isRegionHidden() {
|
|
311
|
+
return this.form.type !== 'local' && this.form.type !== 'region';
|
|
312
|
+
}
|
|
313
|
+
get __isCityHidden() {
|
|
314
|
+
return this.form.type !== 'local';
|
|
315
|
+
}
|
|
316
|
+
get __isRateHidden() {
|
|
317
|
+
const type = this.form.type;
|
|
318
|
+
return !type || type === 'custom_tax_endpoint' || this.form.is_live === true;
|
|
693
319
|
}
|
|
694
320
|
}
|
|
695
321
|
//# sourceMappingURL=TaxForm.js.map
|