@foxy.io/elements 1.14.0-beta.11 → 1.14.0-beta.12
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-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-cancellation-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-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.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-card.js +1 -1
- package/dist/cdn/foxy-donation.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-form-dialog.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-items-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-query-builder.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-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +3 -3
- 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-transaction-card.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/{shared-05956f55.js → shared-07abcd7b.js} +1 -1
- package/dist/cdn/{shared-775b37f9.js → shared-322e60b1.js} +1 -1
- package/dist/cdn/{shared-e36452b9.js → shared-35dbd2c5.js} +1 -1
- package/dist/cdn/{shared-93f23978.js → shared-5c8b531d.js} +1 -1
- package/dist/cdn/{shared-05b473a7.js → shared-5f54e916.js} +1 -1
- package/dist/cdn/{shared-fbeb1de3.js → shared-7a42073a.js} +5 -5
- package/dist/cdn/{shared-d3167239.js → shared-8a7bee0d.js} +1 -1
- package/dist/cdn/{shared-1177fd2a.js → shared-91e768be.js} +1 -1
- package/dist/cdn/{shared-4168c6cd.js → shared-9a40309d.js} +1 -1
- package/dist/cdn/{shared-8730c141.js → shared-b5147166.js} +1 -1
- package/dist/cdn/{shared-5d1314d7.js → shared-bc2bfe52.js} +1 -1
- package/dist/cdn/{shared-2b685624.js → shared-ce1da35d.js} +1 -1
- package/dist/cdn/{shared-70631d0a.js → shared-d01d809a.js} +1 -1
- package/dist/cdn/{shared-f968379d.js → shared-d8ffb279.js} +7 -7
- package/dist/cdn/{shared-bda600d6.js → shared-e5cbf291.js} +1 -1
- package/dist/cdn/{shared-a94b7271.js → shared-f1dc1c6c.js} +1 -1
- package/dist/cdn/translations/shared/de.json +94 -0
- package/dist/cdn/translations/shared/en.json +83 -83
- package/dist/cdn/translations/shared/es.json +93 -0
- package/dist/elements/public/TemplateConfigForm/CountriesList.d.ts +2 -4
- package/dist/elements/public/TemplateConfigForm/CountriesList.js +19 -20
- package/dist/elements/public/TemplateConfigForm/CountriesList.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/CountryCard.d.ts +1 -3
- package/dist/elements/public/TemplateConfigForm/CountryCard.js +21 -18
- package/dist/elements/public/TemplateConfigForm/CountryCard.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +117 -127
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -1
- package/dist/mixins/translatable.js +1 -1
- package/dist/mixins/translatable.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountriesList.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountriesList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAC5C,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAIlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,MAAM,IAAI,GAAG,mBAAmB,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"CountriesList.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountriesList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAC5C,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAIlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EA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AAC,EAAE,GAAG,EAAE,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { CountryCard } from './CountryCard';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst Base = ScopedElementsMixin(\n ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)))\n);\n\nexport class CountriesList extends Base<Resource<Rels.Countries>> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'x-country-card': CountryCard,\n 'iron-icon': customElements.get('iron-icon'),\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newCountry: { attribute: false },\n countries: { type: Object },\n regions: { type: String },\n };\n }\n\n countries: Record<string, '*' | string[]> = {};\n\n regions = '';\n\n private __newCountry = '';\n\n render(): TemplateResult {\n return html`\n <div>\n <div class=\"space-y-s\" data-testid=\"countries\">\n ${Object.entries(this.countries).map(([country, regions]) => {\n let regionsLink: string;\n\n try {\n const url = new URL(this.regions);\n url.searchParams.set('country_code', country);\n regionsLink = url.toString();\n } catch {\n regionsLink = '';\n }\n\n return html`\n <x-country-card\n regions=${JSON.stringify(regions === '*' ? [] : regions)}\n code=${country}\n name=${ifDefined(this.data?.values[country]?.default)}\n href=${regionsLink}\n lang=${this.lang}\n ns=${this.ns}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @update:regions=${(evt: CustomEvent) => {\n const newCountries = { ...this.countries };\n const newRegions = (evt.currentTarget as CountryCard).regions;\n\n newCountries[country] = newRegions.length ? newRegions : '*';\n this.countries = newCountries;\n\n this.dispatchEvent(new CustomEvent('update:countries'));\n }}\n @delete=${() => {\n const newCountries = { ...this.countries };\n delete newCountries[country];\n this.countries = newCountries;\n\n this.dispatchEvent(new CustomEvent('update:countries'));\n }}\n >\n </x-country-card>\n `;\n })}\n\n <div\n data-testid=\"new-country\"\n class=${classMap({\n 'h-m flex items-center rounded transition-colors': true,\n 'border border-contrast-10 ring-primary-50': true,\n 'hover-border-contrast-40': !this.disabled,\n 'focus-within-ring-1 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <input\n placeholder=${this.t('add_country')}\n class=\"w-full bg-transparent appearance-none h-m text-s px-m focus-outline-none\"\n list=\"list\"\n .value=${this.__newCountry}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.__newCountry) this.__addCountry();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.__newCountry = target.value;\n }}\n />\n\n <button\n aria-label=${this.t('create')}\n class=${classMap({\n 'mr-xs flex-shrink-0': true,\n 'flex items-center justify-center rounded-full transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': !this.__newCountry,\n 'bg-success-10 text-success cursor-pointer': !!this.__newCountry,\n 'hover-bg-success hover-text-success-contrast': !!this.__newCountry,\n 'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newCountry,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${!this.__newCountry || this.disabled}\n @click=${this.__addCountry}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n </div>\n\n <datalist id=\"list\">\n ${Object.entries(this.data?.values ?? {}).map(([code, country]) => {\n return html`<option value=${code}>${country.default}</option>`;\n })}\n </datalist>\n </div>\n `;\n }\n\n private __addCountry() {\n this.countries = { ...this.countries, [this.__newCountry]: '*' };\n this.__newCountry = '';\n this.dispatchEvent(new CustomEvent('update:countries'));\n }\n}\n"]}
|
|
@@ -10,12 +10,10 @@ declare const Base: typeof NucleonElement & import("lit-element").Constructor<im
|
|
|
10
10
|
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost>;
|
|
11
11
|
export declare class CountryCard extends Base<Resource<Rels.Regions>> {
|
|
12
12
|
static get properties(): PropertyDeclarations;
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
readonly: boolean;
|
|
15
13
|
regions: string[];
|
|
16
|
-
region: string;
|
|
17
14
|
name: string;
|
|
18
15
|
code: string;
|
|
16
|
+
private __newRegion;
|
|
19
17
|
render(): TemplateResult;
|
|
20
18
|
private __addRegion;
|
|
21
19
|
}
|
|
@@ -8,20 +8,16 @@ const Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement))
|
|
|
8
8
|
export class CountryCard extends Base {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
|
-
this.disabled = false;
|
|
12
|
-
this.readonly = false;
|
|
13
11
|
this.regions = [];
|
|
14
|
-
this.region = '';
|
|
15
12
|
this.name = '';
|
|
16
13
|
this.code = '';
|
|
14
|
+
this.__newRegion = '';
|
|
17
15
|
}
|
|
18
16
|
static get properties() {
|
|
19
17
|
return {
|
|
20
18
|
...super.properties,
|
|
21
|
-
|
|
22
|
-
readonly: { type: Boolean },
|
|
19
|
+
__newRegion: { attribute: false },
|
|
23
20
|
regions: { type: Array },
|
|
24
|
-
region: { type: String },
|
|
25
21
|
name: { type: String },
|
|
26
22
|
code: { type: String },
|
|
27
23
|
};
|
|
@@ -35,13 +31,17 @@ export class CountryCard extends Base {
|
|
|
35
31
|
'text-disabled': this.disabled,
|
|
36
32
|
})}
|
|
37
33
|
>
|
|
38
|
-
<div
|
|
34
|
+
<div
|
|
35
|
+
data-testid="country"
|
|
36
|
+
class="h-m flex justify-between items-center border-b border-contrast-10"
|
|
37
|
+
>
|
|
39
38
|
<div class="ml-m">
|
|
40
39
|
<span>${this.name || this.code}</span>
|
|
41
40
|
${this.name ? html `<span class="text-secondary">${this.code}</span>` : ''}
|
|
42
41
|
</div>
|
|
43
42
|
|
|
44
43
|
<button
|
|
44
|
+
aria-label=${this.t('delete')}
|
|
45
45
|
class=${classMap({
|
|
46
46
|
'mr-xs items-center justify-center rounded-full transition-colors': true,
|
|
47
47
|
'hover-bg-error-10 hover-text-error': !this.disabled,
|
|
@@ -58,7 +58,7 @@ export class CountryCard extends Base {
|
|
|
58
58
|
</button>
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
|
-
<div class="flex flex-wrap p-xs">
|
|
61
|
+
<div data-testid="regions" class="flex flex-wrap p-xs">
|
|
62
62
|
${this.regions.map(region => {
|
|
63
63
|
var _a, _b;
|
|
64
64
|
const name = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.values[region]) === null || _b === void 0 ? void 0 : _b.default;
|
|
@@ -74,6 +74,7 @@ export class CountryCard extends Base {
|
|
|
74
74
|
</span>
|
|
75
75
|
|
|
76
76
|
<button
|
|
77
|
+
aria-label=${this.t('delete')}
|
|
77
78
|
class=${classMap({
|
|
78
79
|
'items-center justify-center rounded-full transition-colors': true,
|
|
79
80
|
'hover-bg-error-10 hover-text-error': !this.disabled,
|
|
@@ -96,6 +97,7 @@ export class CountryCard extends Base {
|
|
|
96
97
|
})}
|
|
97
98
|
|
|
98
99
|
<div
|
|
100
|
+
data-testid="new-region"
|
|
99
101
|
style="border-radius: var(--lumo-size-s)"
|
|
100
102
|
class=${classMap({
|
|
101
103
|
'h-s m-xs items-center transition-colors border border-contrast-10': true,
|
|
@@ -110,15 +112,16 @@ export class CountryCard extends Base {
|
|
|
110
112
|
class="bg-transparent appearance-none h-s text-s px-s focus-outline-none"
|
|
111
113
|
style="width: 8rem"
|
|
112
114
|
list="list"
|
|
113
|
-
.value=${this.
|
|
115
|
+
.value=${this.__newRegion}
|
|
114
116
|
?disabled=${this.disabled}
|
|
117
|
+
?readonly=${this.readonly}
|
|
115
118
|
@keydown=${(evt) => {
|
|
116
|
-
if (evt.key === 'Enter' && this.
|
|
119
|
+
if (evt.key === 'Enter' && this.__newRegion)
|
|
117
120
|
this.__addRegion();
|
|
118
121
|
}}
|
|
119
122
|
@input=${(evt) => {
|
|
120
123
|
const target = evt.currentTarget;
|
|
121
|
-
this.
|
|
124
|
+
this.__newRegion = target.value;
|
|
122
125
|
}}
|
|
123
126
|
/>
|
|
124
127
|
|
|
@@ -127,12 +130,12 @@ export class CountryCard extends Base {
|
|
|
127
130
|
class=${classMap({
|
|
128
131
|
'flex-shrink-0': true,
|
|
129
132
|
'flex items-center justify-center rounded-full transition-colors': true,
|
|
130
|
-
'bg-contrast-5 text-disabled cursor-default': !this.
|
|
131
|
-
'bg-success-10 text-success cursor-pointer': !!this.
|
|
132
|
-
'hover-bg-success hover-text-success-contrast': !!this.
|
|
133
|
-
'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.
|
|
133
|
+
'bg-contrast-5 text-disabled cursor-default': !this.__newRegion,
|
|
134
|
+
'bg-success-10 text-success cursor-pointer': !!this.__newRegion,
|
|
135
|
+
'hover-bg-success hover-text-success-contrast': !!this.__newRegion,
|
|
136
|
+
'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newRegion,
|
|
134
137
|
})}
|
|
135
|
-
?disabled=${!this.
|
|
138
|
+
?disabled=${this.disabled || !this.__newRegion}
|
|
136
139
|
@click=${this.__addRegion}
|
|
137
140
|
>
|
|
138
141
|
<iron-icon icon="icons:add" class="icon-inline text-m"></iron-icon>
|
|
@@ -149,8 +152,8 @@ export class CountryCard extends Base {
|
|
|
149
152
|
`;
|
|
150
153
|
}
|
|
151
154
|
__addRegion() {
|
|
152
|
-
this.regions = [...new Set([...this.regions, this.
|
|
153
|
-
this.
|
|
155
|
+
this.regions = [...new Set([...this.regions, this.__newRegion])];
|
|
156
|
+
this.__newRegion = '';
|
|
154
157
|
this.dispatchEvent(new CustomEvent('update:regions'));
|
|
155
158
|
}
|
|
156
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountryCard.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountryCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAIlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,IAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAElF,MAAM,OAAO,WAAY,SAAQ,IAA4B;IAA7D;;QAaE,aAAQ,GAAG,KAAK,CAAC;QAEjB,aAAQ,GAAG,KAAK,CAAC;QAEjB,YAAO,GAAa,EAAE,CAAC;QAEvB,WAAM,GAAG,EAAE,CAAC;QAEZ,SAAI,GAAG,EAAE,CAAC;QAEV,SAAI,GAAG,EAAE,CAAC;IAgIZ,CAAC;IAtJC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;YAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;YAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACxB,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACtB,IAAI,EAAE,EAAE,IA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D,8CAA8C,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;YAC7D,4DAA4D,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;SAC5E,CAAC;0BACU,CAAC,IAAI,CAAC,MAAM;uBACf,IAAI,CAAC,WAAW;;;;;;;cAOzB,MAAM,CAAC,MAAM,aAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACpD,OAAO,IAAI,CAAA,iBAAiB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,WAAW,CAAC;QACvE,CAAC,CAAC;;;;KAIT,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)));\n\nexport class CountryCard extends Base<Resource<Rels.Regions>> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n disabled: { type: Boolean },\n readonly: { type: Boolean },\n regions: { type: Array },\n region: { type: String },\n name: { type: String },\n code: { type: String },\n };\n }\n\n disabled = false;\n\n readonly = false;\n\n regions: string[] = [];\n\n region = '';\n\n name = '';\n\n code = '';\n\n render(): TemplateResult {\n return html`\n <div\n class=${classMap({\n 'border border-contrast-10 rounded text-s': true,\n 'text-disabled': this.disabled,\n })}\n >\n <div class=\"h-m flex justify-between items-center border-b border-contrast-10\">\n <div class=\"ml-m\">\n <span>${this.name || this.code}</span>\n ${this.name ? html`<span class=\"text-secondary\">${this.code}</span>` : ''}\n </div>\n\n <button\n class=${classMap({\n 'mr-xs items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => this.dispatchEvent(new CustomEvent('delete'))}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <div class=\"flex flex-wrap p-xs\">\n ${this.regions.map(region => {\n const name = this.data?.values[region]?.default;\n const code = region;\n\n return html`\n <div\n class=\"flex items-center border border-contrast-10 h-s m-xs\"\n style=\"border-radius: var(--lumo-size-s)\"\n >\n <span class=\"mx-s\">\n <span>${name || code}</span>\n ${name ? html`<span class=\"text-secondary\">${code}</span>` : ''}\n </span>\n\n <button\n class=${classMap({\n 'items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => {\n this.regions = this.regions.filter(value => value !== region);\n this.dispatchEvent(new CustomEvent('update:regions'));\n }}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n `;\n })}\n\n <div\n style=\"border-radius: var(--lumo-size-s)\"\n class=${classMap({\n 'h-s m-xs items-center transition-colors border border-contrast-10': true,\n 'hover-border-contrast-40': !this.disabled,\n 'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <input\n placeholder=${this.t('add_region')}\n class=\"bg-transparent appearance-none h-s text-s px-s focus-outline-none\"\n style=\"width: 8rem\"\n list=\"list\"\n .value=${this.region}\n ?disabled=${this.disabled}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.region) this.__addRegion();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.region = target.value;\n }}\n />\n\n <button\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n class=${classMap({\n 'flex-shrink-0': true,\n 'flex items-center justify-center rounded-full transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': !this.region,\n 'bg-success-10 text-success cursor-pointer': !!this.region,\n 'hover-bg-success hover-text-success-contrast': !!this.region,\n 'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.region,\n })}\n ?disabled=${!this.region}\n @click=${this.__addRegion}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <datalist id=\"list\">\n ${Object.values(this.data?.values ?? {}).map(region => {\n return html`<option value=${region.code}>${region.default}</option>`;\n })}\n </datalist>\n </div>\n </div>\n `;\n }\n\n private __addRegion() {\n this.regions = [...new Set([...this.regions, this.region])];\n this.region = '';\n this.dispatchEvent(new CustomEvent('update:regions'));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CountryCard.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountryCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAA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O,WAAW,CAAC;QACvE,CAAC,CAAC;;;;KAIT,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)));\n\nexport class CountryCard extends Base<Resource<Rels.Regions>> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newRegion: { attribute: false },\n regions: { type: Array },\n name: { type: String },\n code: { type: String },\n };\n }\n\n regions: string[] = [];\n\n name = '';\n\n code = '';\n\n private __newRegion = '';\n\n render(): TemplateResult {\n return html`\n <div\n class=${classMap({\n 'border border-contrast-10 rounded text-s': true,\n 'text-disabled': this.disabled,\n })}\n >\n <div\n data-testid=\"country\"\n class=\"h-m flex justify-between items-center border-b border-contrast-10\"\n >\n <div class=\"ml-m\">\n <span>${this.name || this.code}</span>\n ${this.name ? html`<span class=\"text-secondary\">${this.code}</span>` : ''}\n </div>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'mr-xs items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => this.dispatchEvent(new CustomEvent('delete'))}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <div data-testid=\"regions\" class=\"flex flex-wrap p-xs\">\n ${this.regions.map(region => {\n const name = this.data?.values[region]?.default;\n const code = region;\n\n return html`\n <div\n class=\"flex items-center border border-contrast-10 h-s m-xs\"\n style=\"border-radius: var(--lumo-size-s)\"\n >\n <span class=\"mx-s\">\n <span>${name || code}</span>\n ${name ? html`<span class=\"text-secondary\">${code}</span>` : ''}\n </span>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => {\n this.regions = this.regions.filter(value => value !== region);\n this.dispatchEvent(new CustomEvent('update:regions'));\n }}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n `;\n })}\n\n <div\n data-testid=\"new-region\"\n style=\"border-radius: var(--lumo-size-s)\"\n class=${classMap({\n 'h-s m-xs items-center transition-colors border border-contrast-10': true,\n 'hover-border-contrast-40': !this.disabled,\n 'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <input\n placeholder=${this.t('add_region')}\n class=\"bg-transparent appearance-none h-s text-s px-s focus-outline-none\"\n style=\"width: 8rem\"\n list=\"list\"\n .value=${this.__newRegion}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.__newRegion) this.__addRegion();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.__newRegion = target.value;\n }}\n />\n\n <button\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n class=${classMap({\n 'flex-shrink-0': true,\n 'flex items-center justify-center rounded-full transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': !this.__newRegion,\n 'bg-success-10 text-success cursor-pointer': !!this.__newRegion,\n 'hover-bg-success hover-text-success-contrast': !!this.__newRegion,\n 'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newRegion,\n })}\n ?disabled=${this.disabled || !this.__newRegion}\n @click=${this.__addRegion}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <datalist id=\"list\">\n ${Object.values(this.data?.values ?? {}).map(region => {\n return html`<option value=${region.code}>${region.default}</option>`;\n })}\n </datalist>\n </div>\n </div>\n `;\n }\n\n private __addRegion() {\n this.regions = [...new Set([...this.regions, this.__newRegion])];\n this.__newRegion = '';\n this.dispatchEvent(new CustomEvent('update:regions'));\n }\n}\n"]}
|
|
@@ -105,12 +105,7 @@ export class TemplateConfigForm extends Base {
|
|
|
105
105
|
const json = this.form.json ? JSON.parse(this.form.json) : getDefaultJSON();
|
|
106
106
|
return html `
|
|
107
107
|
<div class="relative" aria-busy=${this.in('busy')} aria-live="polite">
|
|
108
|
-
<div
|
|
109
|
-
class=${classMap({
|
|
110
|
-
'space-y-l transition-opacity': true,
|
|
111
|
-
'opacity-50': !this.in('idle'),
|
|
112
|
-
})}
|
|
113
|
-
>
|
|
108
|
+
<div class="space-y-l">
|
|
114
109
|
${hidden.matches('cart-type', true) ? '' : this.__renderCartType(json)}
|
|
115
110
|
${hidden.matches('foxycomplete', true) ? '' : this.__renderFoxycomplete(json)}
|
|
116
111
|
${hidden.matches('locations', true) ? '' : this.__renderLocations(json)}
|
|
@@ -197,32 +192,27 @@ export class TemplateConfigForm extends Base {
|
|
|
197
192
|
}
|
|
198
193
|
__renderFoxycomplete(json) {
|
|
199
194
|
const { lang, ns } = this;
|
|
200
|
-
const isDisabled = this.disabledSelector.matches('foxycomplete', true);
|
|
195
|
+
const isDisabled = !this.in('idle') || this.disabledSelector.matches('foxycomplete', true);
|
|
201
196
|
const isReadonly = this.readonlySelector.matches('foxycomplete', true);
|
|
197
|
+
const config = json.foxycomplete;
|
|
202
198
|
const items = ['combobox', 'search', 'disabled'];
|
|
203
|
-
const value =
|
|
204
|
-
|
|
205
|
-
: json.foxycomplete.show_combobox
|
|
206
|
-
? 'combobox'
|
|
207
|
-
: 'search';
|
|
208
|
-
const renderFlagsCheckbox = () => html `
|
|
199
|
+
const value = config.usage === 'none' ? 'disabled' : config.show_combobox ? 'combobox' : 'search';
|
|
200
|
+
const flagsCheckbox = html `
|
|
209
201
|
<x-checkbox
|
|
202
|
+
data-testid="foxycomplete-flags-check"
|
|
210
203
|
?disabled=${isDisabled}
|
|
211
204
|
?readonly=${isReadonly}
|
|
212
|
-
?checked=${
|
|
205
|
+
?checked=${config.show_flags}
|
|
213
206
|
@change=${(evt) => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
show_flags: evt.detail,
|
|
217
|
-
};
|
|
218
|
-
this.edit({ json: JSON.stringify({ ...json, foxycomplete: newConfig }) });
|
|
207
|
+
config.show_flags = evt.detail;
|
|
208
|
+
this.edit({ json: JSON.stringify(json) });
|
|
219
209
|
}}
|
|
220
210
|
>
|
|
221
211
|
<foxy-i18n lang=${lang} key="show_country_flags" ns=${ns}></foxy-i18n>
|
|
222
212
|
</x-checkbox>
|
|
223
213
|
`;
|
|
224
214
|
return html `
|
|
225
|
-
<div>
|
|
215
|
+
<div data-testid="foxycomplete">
|
|
226
216
|
${this.renderTemplateOrSlot('foxycomplete:before')}
|
|
227
217
|
|
|
228
218
|
<x-group frame>
|
|
@@ -236,6 +226,7 @@ export class TemplateConfigForm extends Base {
|
|
|
236
226
|
</foxy-i18n>
|
|
237
227
|
|
|
238
228
|
<x-choice
|
|
229
|
+
data-testid="foxycomplete-choice"
|
|
239
230
|
.value=${value}
|
|
240
231
|
.items=${items}
|
|
241
232
|
?disabled=${isDisabled}
|
|
@@ -243,12 +234,9 @@ export class TemplateConfigForm extends Base {
|
|
|
243
234
|
@change=${(evt) => {
|
|
244
235
|
if (!(evt instanceof ChoiceChangeEvent))
|
|
245
236
|
return;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
show_combobox: evt.detail === 'combobox',
|
|
250
|
-
};
|
|
251
|
-
this.edit({ json: JSON.stringify({ ...json, foxycomplete: newConfig }) });
|
|
237
|
+
config.usage = evt.detail === 'disabled' ? 'none' : 'required';
|
|
238
|
+
config.show_combobox = evt.detail === 'combobox';
|
|
239
|
+
this.edit({ json: JSON.stringify(json) });
|
|
252
240
|
}}
|
|
253
241
|
>
|
|
254
242
|
${items.map(item => {
|
|
@@ -272,17 +260,15 @@ export class TemplateConfigForm extends Base {
|
|
|
272
260
|
const field = action === 'open' ? 'combobox_open' : 'combobox_close';
|
|
273
261
|
return html `
|
|
274
262
|
<vaadin-text-field
|
|
263
|
+
data-testid="foxycomplete-${action}-icon"
|
|
275
264
|
label=${this.t(`${action}_icon`)}
|
|
276
|
-
.value=${
|
|
265
|
+
.value=${config[field]}
|
|
277
266
|
?disabled=${isDisabled}
|
|
278
267
|
?readonly=${isReadonly}
|
|
268
|
+
@keydown=${(evt) => evt.key === 'Enter' && this.submit()}
|
|
279
269
|
@input=${(evt) => {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
...json.foxycomplete,
|
|
283
|
-
[field]: target.value,
|
|
284
|
-
};
|
|
285
|
-
this.edit({ json: JSON.stringify({ ...json, foxycomplete: newConfig }) });
|
|
270
|
+
config[field] = evt.currentTarget.value;
|
|
271
|
+
this.edit({ json: JSON.stringify(json) });
|
|
286
272
|
}}
|
|
287
273
|
>
|
|
288
274
|
</vaadin-text-field>
|
|
@@ -290,24 +276,21 @@ export class TemplateConfigForm extends Base {
|
|
|
290
276
|
})}
|
|
291
277
|
</div>
|
|
292
278
|
|
|
293
|
-
${
|
|
279
|
+
${flagsCheckbox}
|
|
294
280
|
</div>
|
|
295
281
|
|
|
296
|
-
<div slot="search" class="pb-s" ?hidden=${value !== 'search'}>
|
|
297
|
-
${renderFlagsCheckbox()}
|
|
298
|
-
</div>
|
|
282
|
+
<div slot="search" class="pb-s" ?hidden=${value !== 'search'}>${flagsCheckbox}</div>
|
|
299
283
|
</x-choice>
|
|
300
284
|
|
|
301
285
|
<div class="border-t border-contrast-10 p-m">
|
|
302
286
|
<x-checkbox
|
|
287
|
+
data-testid="foxycomplete-lookup-check"
|
|
303
288
|
?disabled=${isDisabled}
|
|
304
289
|
?readonly=${isReadonly}
|
|
305
290
|
?checked=${json.postal_code_lookup.usage === 'enabled'}
|
|
306
291
|
@change=${(evt) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
};
|
|
310
|
-
this.edit({ json: JSON.stringify({ ...json, postal_code_lookup: newConfig }) });
|
|
292
|
+
json.postal_code_lookup.usage = evt.detail ? 'enabled' : 'none';
|
|
293
|
+
this.edit({ json: JSON.stringify(json) });
|
|
311
294
|
}}
|
|
312
295
|
>
|
|
313
296
|
<foxy-i18n lang=${lang} key="enable_postcode_lookup" ns=${ns}></foxy-i18n>
|
|
@@ -322,7 +305,7 @@ export class TemplateConfigForm extends Base {
|
|
|
322
305
|
__renderLocations(json) {
|
|
323
306
|
const { lang, ns } = this;
|
|
324
307
|
const config = json.location_filtering;
|
|
325
|
-
const isDisabled = this.disabledSelector.matches('locations', true);
|
|
308
|
+
const isDisabled = !this.in('idle') || this.disabledSelector.matches('locations', true);
|
|
326
309
|
const isReadonly = this.readonlySelector.matches('locations', true);
|
|
327
310
|
const shippingChoice = config.shipping_filter_type === 'blacklist' ? 'block' : 'allow';
|
|
328
311
|
const billingChoice = config.usage === 'both'
|
|
@@ -353,81 +336,85 @@ export class TemplateConfigForm extends Base {
|
|
|
353
336
|
}
|
|
354
337
|
};
|
|
355
338
|
return html `
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
<x-group frame>
|
|
359
|
-
<foxy-i18n
|
|
360
|
-
class=${isDisabled ? 'text-disabled' : ''}
|
|
361
|
-
slot="header"
|
|
362
|
-
lang=${lang}
|
|
363
|
-
key="location_plural"
|
|
364
|
-
ns=${ns}
|
|
365
|
-
>
|
|
366
|
-
</foxy-i18n>
|
|
339
|
+
<div data-testid="locations">
|
|
340
|
+
${this.renderTemplateOrSlot('locations:before')}
|
|
367
341
|
|
|
368
|
-
<
|
|
369
|
-
<
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
</foxy-i18n>
|
|
342
|
+
<x-group frame>
|
|
343
|
+
<foxy-i18n
|
|
344
|
+
class=${isDisabled ? 'text-disabled' : ''}
|
|
345
|
+
slot="header"
|
|
346
|
+
lang=${lang}
|
|
347
|
+
key="location_plural"
|
|
348
|
+
ns=${ns}
|
|
349
|
+
>
|
|
350
|
+
</foxy-i18n>
|
|
378
351
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
352
|
+
<div class="grid sm-grid-cols-2 bg-contrast-10" style="gap: 1px">
|
|
353
|
+
<x-group class="bg-base pt-m">
|
|
354
|
+
<foxy-i18n
|
|
355
|
+
class=${isDisabled ? 'text-disabled' : 'text-tertiary'}
|
|
356
|
+
slot="header"
|
|
357
|
+
lang=${lang}
|
|
358
|
+
key="shipping"
|
|
359
|
+
ns=${ns}
|
|
360
|
+
>
|
|
361
|
+
</foxy-i18n>
|
|
362
|
+
|
|
363
|
+
<x-choice
|
|
364
|
+
data-testid="locations-shipping-choice"
|
|
365
|
+
.items=${['allow', 'block']}
|
|
366
|
+
.value=${shippingChoice}
|
|
367
|
+
?disabled=${isDisabled}
|
|
368
|
+
?readonly=${isReadonly}
|
|
369
|
+
@change=${(evt) => {
|
|
385
370
|
if (config.usage !== 'both')
|
|
386
371
|
config.usage = 'independent';
|
|
387
372
|
config.shipping_filter_type = evt.detail === 'block' ? 'blacklist' : 'whitelist';
|
|
388
373
|
normalize();
|
|
389
374
|
this.edit({ json: JSON.stringify(json) });
|
|
390
375
|
}}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
376
|
+
>
|
|
377
|
+
<foxy-i18n slot="allow-label" lang=${lang} key="allowlist" ns=${ns}></foxy-i18n>
|
|
378
|
+
<foxy-i18n slot="block-label" lang=${lang} key="blocklist" ns=${ns}></foxy-i18n>
|
|
379
|
+
|
|
380
|
+
<x-countries-list
|
|
381
|
+
data-testid="locations-shipping-list"
|
|
382
|
+
countries=${JSON.stringify(config.shipping_filter_values)}
|
|
383
|
+
regions=${this.regions}
|
|
384
|
+
class="mb-m"
|
|
385
|
+
href=${this.countries}
|
|
386
|
+
slot=${shippingChoice}
|
|
387
|
+
lang=${lang}
|
|
388
|
+
ns=${ns}
|
|
389
|
+
?disabled=${isDisabled}
|
|
390
|
+
?readonly=${isReadonly}
|
|
391
|
+
@update:countries=${(evt) => {
|
|
406
392
|
config.shipping_filter_values = evt.currentTarget.countries;
|
|
407
393
|
normalize();
|
|
408
394
|
this.edit({ json: JSON.stringify(json) });
|
|
409
395
|
}}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
396
|
+
>
|
|
397
|
+
</x-countries-list>
|
|
398
|
+
</x-choice>
|
|
399
|
+
</x-group>
|
|
414
400
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
401
|
+
<x-group class="bg-base pt-m">
|
|
402
|
+
<foxy-i18n
|
|
403
|
+
class=${isDisabled ? 'text-disabled' : 'text-tertiary'}
|
|
404
|
+
slot="header"
|
|
405
|
+
lang=${lang}
|
|
406
|
+
key="billing"
|
|
407
|
+
ns=${ns}
|
|
408
|
+
>
|
|
409
|
+
</foxy-i18n>
|
|
424
410
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
411
|
+
<x-choice
|
|
412
|
+
data-testid="locations-billing-choice"
|
|
413
|
+
.items=${['allow', 'block', 'copy']}
|
|
414
|
+
.value=${billingChoice}
|
|
415
|
+
?disabled=${isDisabled}
|
|
416
|
+
?readonly=${isReadonly}
|
|
417
|
+
@change=${(evt) => {
|
|
431
418
|
if (evt.detail === 'copy') {
|
|
432
419
|
config.usage = 'both';
|
|
433
420
|
}
|
|
@@ -438,35 +425,38 @@ export class TemplateConfigForm extends Base {
|
|
|
438
425
|
normalize();
|
|
439
426
|
this.edit({ json: JSON.stringify(json) });
|
|
440
427
|
}}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
countries
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
428
|
+
>
|
|
429
|
+
<foxy-i18n slot="allow-label" lang=${lang} key="allowlist" ns=${ns}></foxy-i18n>
|
|
430
|
+
<foxy-i18n slot="block-label" lang=${lang} key="blocklist" ns=${ns}></foxy-i18n>
|
|
431
|
+
<foxy-i18n slot="copy-label" lang=${lang} key="same_as_shipping" ns=${ns}>
|
|
432
|
+
</foxy-i18n>
|
|
433
|
+
|
|
434
|
+
<x-countries-list
|
|
435
|
+
data-testid="locations-billing-list"
|
|
436
|
+
countries=${JSON.stringify(config.billing_filter_values)}
|
|
437
|
+
regions=${this.regions}
|
|
438
|
+
class="mb-m"
|
|
439
|
+
href=${this.countries}
|
|
440
|
+
slot=${billingChoice}
|
|
441
|
+
lang=${lang}
|
|
442
|
+
ns=${ns}
|
|
443
|
+
?disabled=${isDisabled}
|
|
444
|
+
?readonly=${isReadonly}
|
|
445
|
+
?hidden=${billingChoice === 'copy'}
|
|
446
|
+
@update:countries=${(evt) => {
|
|
458
447
|
config.billing_filter_values = evt.currentTarget.countries;
|
|
459
448
|
normalize();
|
|
460
449
|
this.edit({ json: JSON.stringify(json) });
|
|
461
450
|
}}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
451
|
+
>
|
|
452
|
+
</x-countries-list>
|
|
453
|
+
</x-choice>
|
|
454
|
+
</x-group>
|
|
455
|
+
</div>
|
|
456
|
+
</x-group>
|
|
468
457
|
|
|
469
|
-
|
|
458
|
+
${this.renderTemplateOrSlot('locations:after')}
|
|
459
|
+
</div>
|
|
470
460
|
`;
|
|
471
461
|
}
|
|
472
462
|
__renderHiddenFields(json) {
|