@foxy.io/elements 1.14.0-beta.3 → 1.14.0-beta.7

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.
Files changed (127) hide show
  1. package/README.md +1 -1
  2. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  3. package/dist/cdn/foxy-address-card.js +1 -1
  4. package/dist/cdn/foxy-address-form.js +1 -1
  5. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  6. package/dist/cdn/foxy-attribute-card.js +1 -1
  7. package/dist/cdn/foxy-attribute-form.js +1 -1
  8. package/dist/cdn/foxy-cancellation-form.js +1 -1
  9. package/dist/cdn/foxy-collection-page.js +1 -1
  10. package/dist/cdn/foxy-collection-pages.js +1 -1
  11. package/dist/cdn/foxy-custom-field-card.js +1 -1
  12. package/dist/cdn/foxy-custom-field-form.js +1 -1
  13. package/dist/cdn/foxy-customer-api.js +1 -1
  14. package/dist/cdn/foxy-customer-card.js +1 -1
  15. package/dist/cdn/foxy-customer-form.js +1 -1
  16. package/dist/cdn/foxy-customer-portal-settings.js +9 -9
  17. package/dist/cdn/foxy-customer-portal.js +2 -2
  18. package/dist/cdn/foxy-customer.js +2 -2
  19. package/dist/cdn/foxy-customers-table.js +1 -1
  20. package/dist/cdn/foxy-discount-card.js +1 -1
  21. package/dist/cdn/foxy-donation.js +1 -1
  22. package/dist/cdn/foxy-email-template-form.js +1 -1
  23. package/dist/cdn/foxy-error-entry-card.js +1 -1
  24. package/dist/cdn/foxy-form-dialog.js +1 -1
  25. package/dist/cdn/foxy-i18n.js +1 -1
  26. package/dist/cdn/foxy-items-form.js +1 -1
  27. package/dist/cdn/foxy-nucleon-element.js +1 -1
  28. package/dist/cdn/foxy-payment-card.js +1 -1
  29. package/dist/cdn/foxy-payment-method-card.js +1 -1
  30. package/dist/cdn/foxy-query-builder.js +1 -1
  31. package/dist/cdn/foxy-sign-in-form.js +1 -1
  32. package/dist/cdn/foxy-spinner.js +1 -1
  33. package/dist/cdn/foxy-subscription-card.js +1 -1
  34. package/dist/cdn/foxy-subscription-form.js +4 -4
  35. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  36. package/dist/cdn/foxy-table.js +1 -1
  37. package/dist/cdn/foxy-tax-card.js +1 -1
  38. package/dist/cdn/foxy-tax-form.js +1 -1
  39. package/dist/cdn/foxy-template-config-form.js +14 -0
  40. package/dist/cdn/foxy-template-form.js +1 -1
  41. package/dist/cdn/foxy-transaction-card.js +1 -1
  42. package/dist/cdn/foxy-transactions-table.js +1 -1
  43. package/dist/cdn/foxy-user-form.js +1 -1
  44. package/dist/cdn/foxy-users-table.js +1 -1
  45. package/dist/cdn/{shared-14788132.js → shared-00563cb0.js} +1 -1
  46. package/dist/cdn/shared-09feabf8.js +1 -0
  47. package/dist/cdn/{shared-57522229.js → shared-0ba88744.js} +1 -1
  48. package/dist/cdn/shared-0ced76a0.js +358 -0
  49. package/dist/cdn/{shared-84df58e1.js → shared-16e28f3b.js} +1 -1
  50. package/dist/cdn/{shared-d196432b.js → shared-16f72e27.js} +1 -1
  51. package/dist/cdn/{shared-82dd0556.js → shared-1761daef.js} +1 -1
  52. package/dist/cdn/{shared-302d8a7b.js → shared-1bafffd0.js} +1 -1
  53. package/dist/cdn/{shared-3534b284.js → shared-200f613b.js} +1 -1
  54. package/dist/cdn/{shared-3e14c0d2.js → shared-218ba06e.js} +1 -1
  55. package/dist/cdn/{shared-acf49ecc.js → shared-34b2c1e2.js} +1 -1
  56. package/dist/cdn/{shared-2b2b56f6.js → shared-3f35fa81.js} +1 -1
  57. package/dist/cdn/{shared-b8349f79.js → shared-44cfc617.js} +1 -1
  58. package/dist/cdn/{shared-dd66b354.js → shared-4d3c7828.js} +1 -1
  59. package/dist/cdn/{shared-c7f352fa.js → shared-50c7a176.js} +1 -1
  60. package/dist/cdn/{shared-a4410f22.js → shared-593f7e2c.js} +1 -1
  61. package/dist/cdn/{shared-d19e2399.js → shared-59e44f29.js} +1 -1
  62. package/dist/cdn/{shared-d97a6ee5.js → shared-63eaded9.js} +3 -3
  63. package/dist/cdn/shared-691da586.js +1 -0
  64. package/dist/cdn/{shared-7fd12533.js → shared-6b7602c7.js} +1 -1
  65. package/dist/cdn/{shared-94c83b2b.js → shared-6d45a07b.js} +1 -1
  66. package/dist/cdn/{shared-2d99835c.js → shared-6ecbc785.js} +1 -1
  67. package/dist/cdn/{shared-bbc97ae0.js → shared-6f7f752e.js} +1 -1
  68. package/dist/cdn/shared-7629a1a5.js +314 -0
  69. package/dist/cdn/shared-8edee4e1.js +264 -0
  70. package/dist/cdn/{shared-652ef7fe.js → shared-9221e6b2.js} +1 -1
  71. package/dist/cdn/{shared-59a0cb0f.js → shared-94b0ae99.js} +1 -1
  72. package/dist/cdn/{shared-3553ff4d.js → shared-a46edf4b.js} +1 -1
  73. package/dist/cdn/{shared-72678c5d.js → shared-a6c047b1.js} +1 -1
  74. package/dist/cdn/shared-ace85f1b.js +1 -0
  75. package/dist/cdn/{shared-27d93838.js → shared-b0f0e8b5.js} +1 -1
  76. package/dist/cdn/{shared-8e38d64f.js → shared-b710881a.js} +2 -2
  77. package/dist/cdn/{shared-dce03b47.js → shared-bb824ab4.js} +1 -1
  78. package/dist/cdn/{shared-e969772e.js → shared-c66e9946.js} +1 -1
  79. package/dist/cdn/shared-d8852c42.js +1 -0
  80. package/dist/cdn/shared-df573cea.js +12 -0
  81. package/dist/cdn/{shared-fda14a3d.js → shared-e7f8ffe9.js} +1 -1
  82. package/dist/cdn/{shared-92442eb1.js → shared-ec861f31.js} +1 -1
  83. package/dist/cdn/{shared-a71bd9f0.js → shared-f0a83bd6.js} +1 -1
  84. package/dist/cdn/translations/shared/en.json +83 -1
  85. package/dist/elements/private/Checkbox/Checkbox.js +5 -1
  86. package/dist/elements/private/Checkbox/Checkbox.js.map +1 -1
  87. package/dist/elements/private/Choice/Choice.js +2 -2
  88. package/dist/elements/private/Choice/Choice.js.map +1 -1
  89. package/dist/elements/private/Group/Group.js +1 -1
  90. package/dist/elements/private/Group/Group.js.map +1 -1
  91. package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +1 -1
  92. package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -1
  93. package/dist/elements/public/TemplateConfigForm/CountriesList.d.ts +23 -0
  94. package/dist/elements/public/TemplateConfigForm/CountriesList.js +129 -0
  95. package/dist/elements/public/TemplateConfigForm/CountriesList.js.map +1 -0
  96. package/dist/elements/public/TemplateConfigForm/CountryCard.d.ts +20 -0
  97. package/dist/elements/public/TemplateConfigForm/CountryCard.js +125 -0
  98. package/dist/elements/public/TemplateConfigForm/CountryCard.js.map +1 -0
  99. package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.d.ts +34 -0
  100. package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +1123 -0
  101. package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -0
  102. package/dist/elements/public/TemplateConfigForm/defaults.d.ts +2 -0
  103. package/dist/elements/public/TemplateConfigForm/defaults.js +95 -0
  104. package/dist/elements/public/TemplateConfigForm/defaults.js.map +1 -0
  105. package/dist/elements/public/TemplateConfigForm/index.d.ts +9 -0
  106. package/dist/elements/public/TemplateConfigForm/index.js +11 -0
  107. package/dist/elements/public/TemplateConfigForm/index.js.map +1 -0
  108. package/dist/elements/public/TemplateConfigForm/types.d.ts +116 -0
  109. package/dist/elements/public/TemplateConfigForm/types.js +2 -0
  110. package/dist/elements/public/TemplateConfigForm/types.js.map +1 -0
  111. package/dist/elements/public/TemplateForm/TemplateForm.js +1 -1
  112. package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
  113. package/dist/elements/public/index.d.ts +1 -0
  114. package/dist/elements/public/index.defined.d.ts +1 -0
  115. package/dist/elements/public/index.defined.js +1 -0
  116. package/dist/elements/public/index.defined.js.map +1 -1
  117. package/dist/elements/public/index.js +1 -0
  118. package/dist/elements/public/index.js.map +1 -1
  119. package/dist/mixins/themeable.js +72 -0
  120. package/dist/mixins/themeable.js.map +1 -1
  121. package/package.json +1 -1
  122. package/dist/cdn/shared-04b77f79.js +0 -369
  123. package/dist/cdn/shared-1108653b.js +0 -577
  124. package/dist/cdn/shared-4ee97558.js +0 -1
  125. package/dist/cdn/shared-a0c2bbe0.js +0 -1
  126. package/dist/cdn/shared-a21a7562.js +0 -1
  127. package/dist/cdn/shared-bec929ac.js +0 -1
@@ -0,0 +1,1123 @@
1
+ import * as logos from "../PaymentMethodCard/logos.js";
2
+ import { ChoiceChangeEvent } from "../../private/events.js";
3
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
4
+ import { html } from 'lit-html';
5
+ import { Checkbox } from "../../private/Checkbox/Checkbox.js";
6
+ import { Choice } from "../../private/Choice/Choice.js";
7
+ import { ConfigurableMixin } from "../../../mixins/configurable.js";
8
+ import { CountriesList } from "./CountriesList.js";
9
+ import { Group } from "../../private/Group/Group.js";
10
+ import { NucleonElement } from "../NucleonElement/NucleonElement.js";
11
+ import { ResponsiveMixin } from "../../../mixins/responsive.js";
12
+ import { ThemeableMixin } from "../../../mixins/themeable.js";
13
+ import { TranslatableMixin } from "../../../mixins/translatable.js";
14
+ import { classMap } from "../../../utils/class-map.js";
15
+ import { getDefaultJSON } from "./defaults.js";
16
+ import { live } from 'lit-html/directives/live';
17
+ const NS = 'template-config-form';
18
+ const Base = ScopedElementsMixin(ResponsiveMixin(ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)))));
19
+ export class TemplateConfigForm extends Base {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.countries = '';
23
+ this.regions = '';
24
+ this.__addHiddenFieldInputValue = '';
25
+ }
26
+ static get scopedElements() {
27
+ return {
28
+ 'vaadin-text-field': customElements.get('vaadin-text-field'),
29
+ 'vaadin-text-area': customElements.get('vaadin-text-area'),
30
+ 'iron-icon': customElements.get('iron-icon'),
31
+ 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
32
+ 'foxy-spinner': customElements.get('foxy-spinner'),
33
+ 'foxy-i18n': customElements.get('foxy-i18n'),
34
+ 'x-countries-list': CountriesList,
35
+ 'x-checkbox': Checkbox,
36
+ 'x-choice': Choice,
37
+ 'x-group': Group,
38
+ };
39
+ }
40
+ static get properties() {
41
+ return {
42
+ ...super.properties,
43
+ __addHiddenFieldInputValue: { attribute: false },
44
+ countries: { type: String },
45
+ regions: { type: String },
46
+ };
47
+ }
48
+ render() {
49
+ var _a, _b;
50
+ const hidden = this.hiddenControls;
51
+ const json = this.form.json ? JSON.parse(this.form.json) : getDefaultJSON();
52
+ return html `
53
+ <div class="relative" aria-busy=${this.in('busy')} aria-live="polite">
54
+ <div
55
+ class=${classMap({
56
+ 'space-y-l transition-opacity': true,
57
+ 'opacity-50': !this.in('idle'),
58
+ })}
59
+ >
60
+ ${hidden.matches('cart-type', true) ? '' : this.__renderCartType(json)}
61
+ ${hidden.matches('foxycomplete', true) ? '' : this.__renderFoxycomplete(json)}
62
+ ${hidden.matches('locations', true) ? '' : this.__renderLocations(json)}
63
+ ${hidden.matches('hidden-fields', true) ? '' : this.__renderHiddenFields(json)}
64
+ ${hidden.matches('cards', true) ? '' : this.__renderCards(json)}
65
+ ${hidden.matches('checkout-type', true) ? '' : this.__renderCheckoutType(json)}
66
+ ${hidden.matches('consent', true) ? '' : this.__renderConsent(json)}
67
+ ${hidden.matches('fields', true) ? '' : this.__renderFields(json)}
68
+ ${hidden.matches('google-analytics', true) ? '' : this.__renderGoogleAnalytics(json)}
69
+ ${hidden.matches('segment-io', true) ? '' : this.__renderSegmentIo(json)}
70
+ ${hidden.matches('troubleshooting', true) ? '' : this.__renderTroubleshooting(json)}
71
+ ${hidden.matches('custom-config', true) ? '' : this.__renderCustomConfig(json)}
72
+ ${hidden.matches('header', true) ? '' : this.__renderHeader(json)}
73
+ ${hidden.matches('custom-fields', true) ? '' : this.__renderCustomFields(json)}
74
+ ${hidden.matches('footer', true) ? '' : this.__renderFooter(json)}
75
+ </div>
76
+
77
+ <div
78
+ class=${classMap({
79
+ 'transition duration-500 ease-in-out absolute inset-0 flex': true,
80
+ 'opacity-0 pointer-events-none': this.in('idle'),
81
+ })}
82
+ >
83
+ <foxy-spinner
84
+ layout="vertical"
85
+ class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
86
+ state=${this.in('fail') ? 'error' : 'busy'}
87
+ lang=${this.lang}
88
+ ns="${this.ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
89
+ >
90
+ </foxy-spinner>
91
+ </div>
92
+ </div>
93
+ `;
94
+ }
95
+ __renderCartType(json) {
96
+ const { lang, ns } = this;
97
+ const items = ['default', 'fullpage', 'custom'];
98
+ return html `
99
+ <div>
100
+ ${this.renderTemplateOrSlot('cart-type:before')}
101
+
102
+ <x-group frame>
103
+ <foxy-i18n slot="header" lang=${lang} key="cart_type" ns=${ns}></foxy-i18n>
104
+
105
+ <x-choice
106
+ .value=${json.cart_type}
107
+ .items=${items}
108
+ ?disabled=${this.disabledSelector.matches('cart-type', true)}
109
+ ?readonly=${this.readonlySelector.matches('cart-type', true)}
110
+ @change=${(evt) => {
111
+ this.edit({ json: JSON.stringify({ ...json, cart_type: evt.detail }) });
112
+ }}
113
+ >
114
+ ${items.map(item => {
115
+ return html `
116
+ <div slot="${item}-label" class="grid leading-s py-s">
117
+ <foxy-i18n lang=${lang} key="cart_type_${item}" ns=${ns}></foxy-i18n>
118
+ <foxy-i18n
119
+ class="text-secondary text-xs"
120
+ lang=${lang}
121
+ key="cart_type_${item}_explainer"
122
+ ns=${ns}
123
+ >
124
+ </foxy-i18n>
125
+ </div>
126
+ `;
127
+ })}
128
+ </x-choice>
129
+ </x-group>
130
+
131
+ ${this.renderTemplateOrSlot('cart-type:after')}
132
+ </div>
133
+ `;
134
+ }
135
+ __renderFoxycomplete(json) {
136
+ const { lang, ns } = this;
137
+ const isDisabled = this.disabledSelector.matches('foxycomplete', true);
138
+ const isReadonly = this.readonlySelector.matches('foxycomplete', true);
139
+ const items = ['combobox', 'search', 'disabled'];
140
+ const value = json.foxycomplete.usage === 'none'
141
+ ? 'disabled'
142
+ : json.foxycomplete.show_combobox
143
+ ? 'combobox'
144
+ : 'search';
145
+ const renderFlagsCheckbox = () => html `
146
+ <x-checkbox
147
+ ?disabled=${isDisabled}
148
+ ?readonly=${isReadonly}
149
+ ?checked=${json.foxycomplete.show_flags}
150
+ @change=${(evt) => {
151
+ const newConfig = {
152
+ ...json.foxycomplete,
153
+ show_flags: evt.detail,
154
+ };
155
+ this.edit({ json: JSON.stringify({ ...json, foxycomplete: newConfig }) });
156
+ }}
157
+ >
158
+ <foxy-i18n class="leading-s block" lang=${lang} key="show_country_flags" ns=${ns}>
159
+ </foxy-i18n>
160
+ </x-checkbox>
161
+ `;
162
+ return html `
163
+ <div>
164
+ ${this.renderTemplateOrSlot('foxycomplete:before')}
165
+
166
+ <x-group frame>
167
+ <foxy-i18n slot="header" lang=${lang} key="foxycomplete" ns=${ns}></foxy-i18n>
168
+
169
+ <x-choice
170
+ .value=${value}
171
+ .items=${items}
172
+ ?disabled=${isDisabled}
173
+ ?readonly=${isReadonly}
174
+ @change=${(evt) => {
175
+ if (!(evt instanceof ChoiceChangeEvent))
176
+ return;
177
+ const newConfig = {
178
+ ...json.foxycomplete,
179
+ usage: evt.detail === 'disabled' ? 'none' : 'required',
180
+ show_combobox: evt.detail === 'combobox',
181
+ };
182
+ this.edit({ json: JSON.stringify({ ...json, foxycomplete: newConfig }) });
183
+ }}
184
+ >
185
+ ${items.map(item => {
186
+ return html `
187
+ <div slot="${item}-label" class="grid leading-s py-s">
188
+ <foxy-i18n lang=${lang} key="foxycomplete_${item}" ns=${ns}></foxy-i18n>
189
+ <foxy-i18n
190
+ class="text-secondary text-xs"
191
+ lang=${lang}
192
+ key="foxycomplete_${item}_explainer"
193
+ ns=${ns}
194
+ >
195
+ </foxy-i18n>
196
+ </div>
197
+ `;
198
+ })}
199
+
200
+ <div slot="combobox" class="space-y-m pb-s" ?hidden=${value !== 'combobox'}>
201
+ <div class="grid grid-cols-2 gap-m" style="max-width: 16rem">
202
+ ${['open', 'close'].map(action => {
203
+ const field = action === 'open' ? 'combobox_open' : 'combobox_close';
204
+ return html `
205
+ <vaadin-text-field
206
+ label=${this.t(`${action}_icon`)}
207
+ .value=${json.foxycomplete[field]}
208
+ ?disabled=${isDisabled}
209
+ ?readonly=${isReadonly}
210
+ @input=${(evt) => {
211
+ const target = evt.currentTarget;
212
+ const newConfig = {
213
+ ...json.foxycomplete,
214
+ [field]: target.value,
215
+ };
216
+ this.edit({ json: JSON.stringify({ ...json, foxycomplete: newConfig }) });
217
+ }}
218
+ >
219
+ </vaadin-text-field>
220
+ `;
221
+ })}
222
+ </div>
223
+
224
+ ${renderFlagsCheckbox()}
225
+ </div>
226
+
227
+ <div slot="search" class="pb-s" ?hidden=${value !== 'search'}>
228
+ ${renderFlagsCheckbox()}
229
+ </div>
230
+ </x-choice>
231
+
232
+ <div class="border-t border-contrast-10 p-m">
233
+ <x-checkbox
234
+ ?disabled=${isDisabled}
235
+ ?readonly=${isReadonly}
236
+ ?checked=${json.postal_code_lookup.usage === 'enabled'}
237
+ @change=${(evt) => {
238
+ const newConfig = {
239
+ usage: evt.detail ? 'enabled' : 'none',
240
+ };
241
+ this.edit({ json: JSON.stringify({ ...json, postal_code_lookup: newConfig }) });
242
+ }}
243
+ >
244
+ <foxy-i18n lang=${lang} key="enable_postcode_lookup" ns=${ns}></foxy-i18n>
245
+ </x-checkbox>
246
+ </div>
247
+ </x-group>
248
+
249
+ ${this.renderTemplateOrSlot('foxycomplete:after')}
250
+ </div>
251
+ `;
252
+ }
253
+ __renderLocations(json) {
254
+ const { lang, ns } = this;
255
+ const config = json.location_filtering;
256
+ const shippingChoice = config.shipping_filter_type === 'blacklist' ? 'block' : 'allow';
257
+ const billingChoice = config.usage === 'both'
258
+ ? 'copy'
259
+ : config.billing_filter_type === 'blacklist'
260
+ ? 'block'
261
+ : 'allow';
262
+ const normalize = () => {
263
+ if (config.usage === 'both') {
264
+ config.billing_filter_type = config.shipping_filter_type;
265
+ config.billing_filter_values = config.shipping_filter_values;
266
+ }
267
+ else {
268
+ const hasBillingFilters = Object.keys(config.billing_filter_values).length > 0;
269
+ const hasShippingFilters = Object.keys(config.shipping_filter_values).length > 0;
270
+ if (!hasBillingFilters && !hasShippingFilters) {
271
+ config.usage = 'none';
272
+ }
273
+ else if (hasBillingFilters && !hasShippingFilters) {
274
+ config.usage = 'billing';
275
+ }
276
+ else if (hasShippingFilters && !hasBillingFilters) {
277
+ config.usage = 'shipping';
278
+ }
279
+ else {
280
+ config.usage = 'independent';
281
+ }
282
+ }
283
+ };
284
+ return html `
285
+ ${this.renderTemplateOrSlot('locations:before')}
286
+
287
+ <x-group frame>
288
+ <foxy-i18n slot="header" lang=${lang} key="location_plural" ns=${ns}></foxy-i18n>
289
+
290
+ <div class="grid sm-grid-cols-2 bg-contrast-10" style="gap: 1px">
291
+ <x-group class="bg-base pt-m">
292
+ <foxy-i18n class="text-tertiary" slot="header" lang=${lang} key="shipping" ns=${ns}>
293
+ </foxy-i18n>
294
+
295
+ <x-choice
296
+ .items=${['allow', 'block']}
297
+ .value=${shippingChoice}
298
+ @change=${(evt) => {
299
+ if (config.usage !== 'both')
300
+ config.usage = 'independent';
301
+ config.shipping_filter_type = evt.detail === 'block' ? 'blacklist' : 'whitelist';
302
+ normalize();
303
+ this.edit({ json: JSON.stringify(json) });
304
+ }}
305
+ >
306
+ <foxy-i18n slot="allow-label" lang=${lang} key="allowlist" ns=${ns}></foxy-i18n>
307
+ <foxy-i18n slot="block-label" lang=${lang} key="blocklist" ns=${ns}></foxy-i18n>
308
+
309
+ <x-countries-list
310
+ countries=${JSON.stringify(config.shipping_filter_values)}
311
+ regions=${this.regions}
312
+ class="mb-m"
313
+ href=${this.countries}
314
+ slot=${shippingChoice}
315
+ lang=${lang}
316
+ ns=${ns}
317
+ ?disabled=${this.disabledSelector.matches('locations', true)}
318
+ ?readonly=${this.readonlySelector.matches('locations', true)}
319
+ @update:countries=${(evt) => {
320
+ config.shipping_filter_values = evt.currentTarget.countries;
321
+ normalize();
322
+ this.edit({ json: JSON.stringify(json) });
323
+ }}
324
+ >
325
+ </x-countries-list>
326
+ </x-choice>
327
+ </x-group>
328
+
329
+ <x-group class="bg-base pt-m">
330
+ <foxy-i18n class="text-tertiary" slot="header" lang=${lang} key="billing" ns=${ns}>
331
+ </foxy-i18n>
332
+
333
+ <x-choice
334
+ .items=${['allow', 'block', 'copy']}
335
+ .value=${billingChoice}
336
+ @change=${(evt) => {
337
+ if (evt.detail === 'copy') {
338
+ config.usage = 'both';
339
+ }
340
+ else {
341
+ config.usage = 'independent';
342
+ config.billing_filter_type = evt.detail === 'block' ? 'blacklist' : 'whitelist';
343
+ }
344
+ normalize();
345
+ this.edit({ json: JSON.stringify(json) });
346
+ }}
347
+ >
348
+ <foxy-i18n slot="allow-label" lang=${lang} key="allowlist" ns=${ns}></foxy-i18n>
349
+ <foxy-i18n slot="block-label" lang=${lang} key="blocklist" ns=${ns}></foxy-i18n>
350
+ <foxy-i18n slot="copy-label" lang=${lang} key="same_as_shipping" ns=${ns}></foxy-i18n>
351
+
352
+ <x-countries-list
353
+ countries=${JSON.stringify(config.billing_filter_values)}
354
+ regions=${this.regions}
355
+ class="mb-m"
356
+ href=${this.countries}
357
+ slot=${billingChoice}
358
+ lang=${lang}
359
+ ns=${ns}
360
+ ?disabled=${this.disabledSelector.matches('locations', true)}
361
+ ?readonly=${this.readonlySelector.matches('locations', true)}
362
+ ?hidden=${billingChoice === 'copy'}
363
+ @update:countries=${(evt) => {
364
+ config.billing_filter_values = evt.currentTarget.countries;
365
+ normalize();
366
+ this.edit({ json: JSON.stringify(json) });
367
+ }}
368
+ >
369
+ </x-countries-list>
370
+ </x-choice>
371
+ </x-group>
372
+ </div>
373
+ </x-group>
374
+
375
+ ${this.renderTemplateOrSlot('locations:after')}
376
+ `;
377
+ }
378
+ __renderHiddenFields(json) {
379
+ const { lang, ns } = this;
380
+ const suggestions = [];
381
+ const fields = [];
382
+ const config = json.cart_display_config;
383
+ for (const key in config) {
384
+ if (!key.startsWith('show_'))
385
+ continue;
386
+ const field = key.substring(5);
387
+ suggestions.push(field);
388
+ if (config.usage === 'required' && !config[key])
389
+ fields.push(field);
390
+ }
391
+ if (config.usage === 'required') {
392
+ fields.push(...config.hidden_product_options);
393
+ }
394
+ const addField = () => {
395
+ config.usage = 'required';
396
+ if (suggestions.includes(this.__addHiddenFieldInputValue)) {
397
+ config[`show_${this.__addHiddenFieldInputValue}`] = false;
398
+ }
399
+ else if (!config.hidden_product_options.includes(this.__addHiddenFieldInputValue)) {
400
+ config.hidden_product_options.push(this.__addHiddenFieldInputValue);
401
+ }
402
+ this.edit({ json: JSON.stringify(json) });
403
+ this.__addHiddenFieldInputValue = '';
404
+ };
405
+ const radius = 'calc(var(--lumo-border-radius-l) / 1.2)';
406
+ const inputRadius = fields.length === 0 ? [radius] : ['0', '0', radius, radius];
407
+ return html `
408
+ <div>
409
+ ${this.renderTemplateOrSlot('hidden-fields:before')}
410
+
411
+ <x-group frame>
412
+ <foxy-i18n slot="header" lang=${lang} key="hidden_fields" ns=${ns}></foxy-i18n>
413
+
414
+ <div class="divide-y divide-contrast-10">
415
+ ${fields.map(field => html `
416
+ <div class="h-m ml-m pr-xs flex items-center justify-between">
417
+ ${suggestions.includes(field)
418
+ ? html `<foxy-i18n lang=${lang} key=${field} ns=${ns}></foxy-i18n>`
419
+ : html `<span>${field}</span>`}
420
+
421
+ <button
422
+ class="flex w-xs h-xs items-center justify-center rounded-full transition-colors hover-bg-error-10 hover-text-error focus-outline-none focus-ring-2 focus-ring-inset focus-ring-error-50"
423
+ @click=${() => {
424
+ if (typeof config[`show_${field}`] === 'boolean') {
425
+ config[`show_${field}`] = true;
426
+ }
427
+ else {
428
+ config.hidden_product_options = config.hidden_product_options.filter(option => option !== field);
429
+ }
430
+ this.edit({ json: JSON.stringify(json) });
431
+ }}
432
+ >
433
+ <iron-icon icon="icons:close" class="icon-inline text-m"></iron-icon>
434
+ </button>
435
+ </div>
436
+ `)}
437
+ </div>
438
+
439
+ <div
440
+ style="border-radius: ${inputRadius.join(' ')}"
441
+ class=${classMap({
442
+ 'h-m flex items-center ring-inset ring-primary-50 focus-within-ring-2': true,
443
+ 'border-t border-contrast-10': fields.length > 0,
444
+ })}
445
+ >
446
+ <input
447
+ placeholder=${this.t('add_field')}
448
+ class="w-full bg-transparent appearance-none h-m px-m focus-outline-none"
449
+ list="hidden-fields-list"
450
+ .value=${live(this.__addHiddenFieldInputValue)}
451
+ @keydown=${(evt) => evt.key === 'Enter' && addField()}
452
+ @input=${(evt) => {
453
+ this.__addHiddenFieldInputValue = evt.currentTarget.value;
454
+ }}
455
+ />
456
+
457
+ <datalist id="hidden-fields-list">
458
+ ${suggestions
459
+ .filter(suggestion => !fields.includes(suggestion))
460
+ .map(suggestion => html `<option value=${suggestion}>${this.t(suggestion)}</option>`)}
461
+ </datalist>
462
+
463
+ <button
464
+ aria-label=${this.t('add_field')}
465
+ class=${classMap({
466
+ 'w-xs h-xs mr-xs flex-shrink-0 ring-inset ring-success-50': true,
467
+ 'flex items-center justify-center rounded-full transition-colors': true,
468
+ 'bg-contrast-5 text-disabled cursor-default': !this.__addHiddenFieldInputValue,
469
+ 'bg-success-10 text-success cursor-pointer': !!this.__addHiddenFieldInputValue,
470
+ 'hover-bg-success hover-text-success-contrast': !!this.__addHiddenFieldInputValue,
471
+ 'focus-outline-none focus-ring-2': !!this.__addHiddenFieldInputValue,
472
+ })}
473
+ ?disabled=${!this.__addHiddenFieldInputValue}
474
+ @click=${addField}
475
+ >
476
+ <iron-icon icon="icons:add" class="icon-inline text-m"></iron-icon>
477
+ </button>
478
+ </div>
479
+ </x-group>
480
+
481
+ ${this.renderTemplateOrSlot('hidden-fields:after')}
482
+ </div>
483
+ `;
484
+ }
485
+ __renderCards(json) {
486
+ const { lang, ns } = this;
487
+ const isDisabled = this.disabledSelector.matches('cards', true);
488
+ const config = json.supported_payment_cards;
489
+ let skipForSaved;
490
+ let skipForSSO;
491
+ if (json.csc_requirements === 'all_cards') {
492
+ skipForSaved = false;
493
+ skipForSSO = false;
494
+ }
495
+ else if (json.csc_requirements === 'sso_only') {
496
+ skipForSaved = true;
497
+ skipForSSO = false;
498
+ }
499
+ else {
500
+ skipForSaved = true;
501
+ skipForSSO = true;
502
+ }
503
+ const typeToName = {
504
+ amex: 'American Express',
505
+ diners: 'Diners Club',
506
+ discover: 'Discover',
507
+ jcb: 'JCB',
508
+ maestro: 'Maestro',
509
+ mastercard: 'Mastercard',
510
+ unionpay: 'UnionPay',
511
+ visa: 'Visa',
512
+ };
513
+ return html `
514
+ <div>
515
+ ${this.renderTemplateOrSlot('cards:before')}
516
+
517
+ <div class="space-y-xs">
518
+ <x-group frame>
519
+ <foxy-i18n slot="header" lang=${lang} key="supported_cards" ns=${ns}></foxy-i18n>
520
+
521
+ <div class="flex flex-wrap m-xs p-s">
522
+ ${Object.entries(logos).map(([type, logo]) => {
523
+ if (!typeToName[type])
524
+ return;
525
+ const isChecked = config.includes(type);
526
+ return html `
527
+ <div
528
+ class=${classMap({
529
+ 'm-xs rounded': true,
530
+ 'opacity-50 cursor-default': isDisabled,
531
+ 'cursor-pointer ring-primary-50 focus-within-ring-2': !isDisabled,
532
+ })}
533
+ >
534
+ <label
535
+ class=${classMap({
536
+ 'overflow-hidden transition-colors flex rounded border': true,
537
+ 'border-primary bg-primary-10 text-primary': isChecked,
538
+ 'hover-text-body': isChecked && !isDisabled,
539
+ 'border-contrast-10': !isChecked,
540
+ 'hover-border-primary hover-text-primary': !isChecked && !isDisabled,
541
+ })}
542
+ >
543
+ <div class="h-s">${logo}</div>
544
+
545
+ <div class="text-s font-medium mx-s my-auto leading-none">
546
+ ${typeToName[type]}
547
+ </div>
548
+
549
+ <input
550
+ type="checkbox"
551
+ class="sr-only"
552
+ ?disabled=${isDisabled}
553
+ ?checked=${isChecked}
554
+ @change=${(evt) => {
555
+ evt.stopPropagation();
556
+ if (isChecked) {
557
+ config.splice(config.indexOf(type), 1);
558
+ }
559
+ else {
560
+ config.push(type);
561
+ }
562
+ this.edit({ json: JSON.stringify(json) });
563
+ }}
564
+ />
565
+ </label>
566
+ </div>
567
+ `;
568
+ })}
569
+ </div>
570
+
571
+ <div class="flex flex-wrap p-s border-t border-contrast-10">
572
+ <x-checkbox
573
+ class="m-s"
574
+ ?disabled=${isDisabled || json.csc_requirements === 'new_cards_only'}
575
+ ?checked=${skipForSaved}
576
+ @change=${(evt) => {
577
+ json.csc_requirements = evt.detail ? 'sso_only' : 'all_cards';
578
+ this.edit({ json: JSON.stringify(json) });
579
+ }}
580
+ >
581
+ <foxy-i18n class="leading-s block" lang=${lang} key="skip_csc_for_saved" ns=${ns}>
582
+ </foxy-i18n>
583
+ </x-checkbox>
584
+
585
+ <x-checkbox
586
+ class="m-s"
587
+ ?disabled=${isDisabled}
588
+ ?checked=${skipForSSO}
589
+ @change=${(evt) => {
590
+ json.csc_requirements = evt.detail
591
+ ? 'new_cards_only'
592
+ : skipForSaved
593
+ ? 'sso_only'
594
+ : 'all_cards';
595
+ this.edit({ json: JSON.stringify(json) });
596
+ }}
597
+ >
598
+ <foxy-i18n class="leading-s block" lang=${lang} key="skip_csc_for_sso" ns=${ns}>
599
+ </foxy-i18n>
600
+ </x-checkbox>
601
+ </div>
602
+ </x-group>
603
+
604
+ <foxy-i18n
605
+ class="text-xs text-secondary leading-s block"
606
+ lang=${lang}
607
+ key="supported_cards_disclaimer"
608
+ ns=${ns}
609
+ >
610
+ </foxy-i18n>
611
+ </div>
612
+
613
+ ${this.renderTemplateOrSlot('cards:after')}
614
+ </div>
615
+ `;
616
+ }
617
+ __renderCheckoutType(json) {
618
+ const { lang, ns } = this;
619
+ return html `
620
+ <div>
621
+ ${this.renderTemplateOrSlot('checkout-type:before')}
622
+
623
+ <div class="space-y-xs">
624
+ <x-group frame>
625
+ <foxy-i18n slot="header" lang=${lang} key="checkout_type" ns=${ns}></foxy-i18n>
626
+
627
+ <x-choice
628
+ ?disabled=${this.disabledSelector.matches('checkout-type', true)}
629
+ ?readonly=${this.readonlySelector.matches('checkout-type', true)}
630
+ .items=${['default_account', 'default_guest', 'guest_only', 'account_only']}
631
+ .value=${json.checkout_type}
632
+ .getText=${(item) => this.t(`checkout_type_${item}`)}
633
+ @change=${(evt) => {
634
+ json.checkout_type = evt.detail;
635
+ this.edit({ json: JSON.stringify(json) });
636
+ }}
637
+ >
638
+ </x-choice>
639
+ </x-group>
640
+
641
+ <foxy-i18n
642
+ class="text-secondary text-xs leading-s block"
643
+ lang=${lang}
644
+ key="checkout_type_helper_text"
645
+ ns=${ns}
646
+ >
647
+ </foxy-i18n>
648
+ </div>
649
+
650
+ ${this.renderTemplateOrSlot('checkout-type:after')}
651
+ </div>
652
+ `;
653
+ }
654
+ __renderConsent(json) {
655
+ const { lang, ns } = this;
656
+ const tosConfig = json.tos_checkbox_settings;
657
+ const mailConfig = json.newsletter_subscribe;
658
+ const sdtaConfig = json.eu_secure_data_transfer_consent;
659
+ const isDisabled = this.disabledSelector.matches('consent', true);
660
+ const isReadonly = this.readonlySelector.matches('consent', true);
661
+ const dividerStyle = 'margin-left: calc(1.125rem + (var(--lumo-space-m) * 2))';
662
+ return html `
663
+ <div>
664
+ ${this.renderTemplateOrSlot('consent:before')}
665
+
666
+ <x-group frame>
667
+ <foxy-i18n slot="header" lang=${lang} key="consent" ns=${ns}></foxy-i18n>
668
+
669
+ <x-checkbox
670
+ ?disabled=${isDisabled}
671
+ ?readonly=${isReadonly}
672
+ ?checked=${tosConfig.usage === 'required' || tosConfig.usage === 'optional'}
673
+ class="m-m"
674
+ @change=${(evt) => {
675
+ tosConfig.initial_state = evt.detail ? tosConfig.initial_state : 'unchecked';
676
+ tosConfig.is_hidden = false;
677
+ tosConfig.usage = evt.detail ? 'required' : 'none';
678
+ tosConfig.url = evt.detail ? tosConfig.url : '';
679
+ this.edit({ json: JSON.stringify(json) });
680
+ }}
681
+ >
682
+ <div class="flex flex-col">
683
+ <foxy-i18n lang=${lang} key="display_tos_link" ns=${ns}></foxy-i18n>
684
+ <foxy-i18n
685
+ class="text-xs leading-s text-secondary"
686
+ lang=${lang}
687
+ key="display_tos_link_explainer"
688
+ ns=${ns}
689
+ >
690
+ </foxy-i18n>
691
+ </div>
692
+
693
+ <div slot="content" ?hidden=${tosConfig.usage === 'none'}>
694
+ <vaadin-text-field
695
+ label=${this.t('location_url')}
696
+ class="w-full mt-m"
697
+ placeholder="https://example.com/path/to/tos"
698
+ clear-button-visible
699
+ ?disabled=${isDisabled}
700
+ ?readonly=${isReadonly}
701
+ .value=${tosConfig.url}
702
+ @input=${(evt) => {
703
+ tosConfig.url = evt.currentTarget.value;
704
+ this.edit({ json: JSON.stringify(json) });
705
+ }}
706
+ >
707
+ </vaadin-text-field>
708
+
709
+ <div class="flex flex-wrap -mx-s -mb-s mt-s">
710
+ <x-checkbox
711
+ class="m-s"
712
+ ?disabled=${isDisabled}
713
+ ?checked=${tosConfig.usage === 'required'}
714
+ @change=${(evt) => {
715
+ tosConfig.usage = evt.detail ? 'required' : 'optional';
716
+ this.edit({ json: JSON.stringify(json) });
717
+ }}
718
+ >
719
+ <foxy-i18n class="leading-s block" lang=${lang} key="require_consent" ns=${ns}>
720
+ </foxy-i18n>
721
+ </x-checkbox>
722
+
723
+ <x-checkbox
724
+ class="m-s"
725
+ ?disabled=${isDisabled}
726
+ ?checked=${tosConfig.initial_state === 'checked'}
727
+ @change=${(evt) => {
728
+ tosConfig.initial_state = evt.detail ? 'checked' : 'unchecked';
729
+ this.edit({ json: JSON.stringify(json) });
730
+ }}
731
+ >
732
+ <foxy-i18n class="leading-s block" lang=${lang} key="checked_by_default" ns=${ns}>
733
+ </foxy-i18n>
734
+ </x-checkbox>
735
+ </div>
736
+ </div>
737
+ </x-checkbox>
738
+
739
+ <div style=${dividerStyle} class="border-b border-contrast-10"></div>
740
+
741
+ <x-checkbox
742
+ ?disabled=${isDisabled}
743
+ ?readonly=${isReadonly}
744
+ ?checked=${mailConfig.usage === 'required'}
745
+ class="m-m"
746
+ @change=${(evt) => {
747
+ mailConfig.usage = evt.detail ? 'required' : 'none';
748
+ this.edit({ json: JSON.stringify(json) });
749
+ }}
750
+ >
751
+ <div class="flex flex-col">
752
+ <foxy-i18n lang=${lang} key="newsletter_subscribe" ns=${ns}></foxy-i18n>
753
+ <foxy-i18n
754
+ class="text-xs leading-s text-secondary"
755
+ lang=${lang}
756
+ key="newsletter_subscribe_explainer"
757
+ ns=${ns}
758
+ >
759
+ </foxy-i18n>
760
+ </div>
761
+ </x-checkbox>
762
+
763
+ <div style=${dividerStyle} class="border-b border-contrast-10"></div>
764
+
765
+ <x-checkbox
766
+ ?disabled=${isDisabled}
767
+ ?readonly=${isReadonly}
768
+ ?checked=${sdtaConfig.usage === 'required'}
769
+ class="m-m"
770
+ @change=${(evt) => {
771
+ sdtaConfig.usage = evt.detail ? 'required' : 'none';
772
+ this.edit({ json: JSON.stringify(json) });
773
+ }}
774
+ >
775
+ <div class="flex flex-col">
776
+ <foxy-i18n lang=${lang} key="display_sdta" ns=${ns}></foxy-i18n>
777
+ <foxy-i18n
778
+ class="text-xs leading-s text-secondary"
779
+ lang=${lang}
780
+ key="display_sdta_explainer"
781
+ ns=${ns}
782
+ >
783
+ </foxy-i18n>
784
+ </div>
785
+ </x-checkbox>
786
+ </x-group>
787
+
788
+ ${this.renderTemplateOrSlot('consent:before')}
789
+ </div>
790
+ `;
791
+ }
792
+ __renderFields(json) {
793
+ const { lang, ns } = this;
794
+ const isDisabled = this.disabledSelector.matches('fields', true);
795
+ const config = json.custom_checkout_field_requirements;
796
+ const options = {
797
+ cart_controls: ['enabled', 'disabled'],
798
+ coupon_entry: ['enabled', 'disabled'],
799
+ billing_first_name: ['default', 'optional', 'required', 'hidden'],
800
+ billing_last_name: ['default', 'optional', 'required', 'hidden'],
801
+ billing_company: ['default', 'optional', 'required', 'hidden'],
802
+ billing_tax_id: ['default', 'optional', 'required', 'hidden'],
803
+ billing_phone: ['default', 'optional', 'required', 'hidden'],
804
+ billing_address1: ['default', 'optional', 'required', 'hidden'],
805
+ billing_address2: ['default', 'optional', 'required', 'hidden'],
806
+ billing_city: ['default', 'optional', 'required', 'hidden'],
807
+ billing_region: ['default', 'optional', 'required', 'hidden'],
808
+ billing_postal_code: ['default', 'optional', 'required', 'hidden'],
809
+ billing_country: ['default', 'optional', 'required', 'hidden'],
810
+ };
811
+ return html `
812
+ <div>
813
+ ${this.renderTemplateOrSlot('fields:before')}
814
+
815
+ <x-group frame>
816
+ <foxy-i18n slot="header" lang=${lang} key="field_plural" ns=${ns}></foxy-i18n>
817
+
818
+ <div class="bg-contrast-10 grid grid-cols-1 md-grid-cols-2" style="gap: 1px">
819
+ ${Object.entries(options).map(([property, values]) => {
820
+ return html `
821
+ <label class="flex items-center pl-m bg-base">
822
+ <foxy-i18n
823
+ class="flex-1"
824
+ lang=${lang}
825
+ key=${property.replace('billing_', '')}
826
+ ns=${ns}
827
+ >
828
+ </foxy-i18n>
829
+
830
+ <div
831
+ class=${classMap({
832
+ 'px-s m-xs flex items-center cursor-pointer rounded leading-none': true,
833
+ 'ring-primary-50 ring-inset focus-within-ring-2': !isDisabled,
834
+ 'hover-text-primary': !isDisabled,
835
+ 'opacity-50': isDisabled,
836
+ })}
837
+ >
838
+ <select
839
+ class="h-s mr-xs text-right appearance-none bg-transparent cursor-pointer focus-outline-none font-medium"
840
+ @change=${(evt) => {
841
+ const select = evt.currentTarget;
842
+ const value = select.options[select.options.selectedIndex].value;
843
+ config[property] = value;
844
+ this.edit({ json: JSON.stringify(json) });
845
+ }}
846
+ >
847
+ ${values.map(value => {
848
+ return html `
849
+ <option
850
+ value=${value}
851
+ ?selected=${config[property] === value}
852
+ >
853
+ ${this.t(value)}
854
+ </option>
855
+ `;
856
+ })}
857
+ </select>
858
+
859
+ <iron-icon
860
+ class="pointer-events-none icon-inline text-xl"
861
+ icon="icons:expand-more"
862
+ >
863
+ </iron-icon>
864
+ </div>
865
+ </label>
866
+ `;
867
+ })}
868
+
869
+ <div class="bg-base hidden md-block"></div>
870
+ </div>
871
+ </x-group>
872
+
873
+ ${this.renderTemplateOrSlot('fields:after')}
874
+ </div>
875
+ `;
876
+ }
877
+ __renderGoogleAnalytics(json) {
878
+ const { lang, ns } = this;
879
+ const config = json.analytics_config;
880
+ const sioConfig = config.segment_io;
881
+ const gaConfig = config.google_analytics;
882
+ const isDisabled = this.disabledSelector.matches('google-analytics', true);
883
+ const isReadonly = this.readonlySelector.matches('google-analytics', true);
884
+ return html `
885
+ <div>
886
+ ${this.renderTemplateOrSlot('google-analytics:before')}
887
+
888
+ <x-group frame>
889
+ <span slot="header">Google Analytics</span>
890
+
891
+ <div class="p-m space-y-m">
892
+ <vaadin-text-field
893
+ class="w-full"
894
+ label=${this.t('ga_account_id')}
895
+ placeholder="UA-1234567-1"
896
+ helper-text=${this.t('ga_account_id_explainer')}
897
+ .value=${live(gaConfig.account_id)}
898
+ ?disabled=${isDisabled}
899
+ ?readonly=${isReadonly}
900
+ clear-button-visible
901
+ @keydown=${(evt) => evt.key === 'Enter' && this.submit()}
902
+ @input=${(evt) => {
903
+ gaConfig.account_id = evt.currentTarget.value;
904
+ gaConfig.usage = gaConfig.account_id ? 'required' : 'none';
905
+ config.usage = gaConfig.account_id || sioConfig.account_id ? 'required' : 'none';
906
+ }}
907
+ >
908
+ </vaadin-text-field>
909
+
910
+ <x-checkbox
911
+ ?disabled=${isDisabled}
912
+ ?readonly=${isReadonly}
913
+ ?checked=${gaConfig.include_on_site}
914
+ @change=${(evt) => {
915
+ gaConfig.include_on_site = evt.detail;
916
+ this.edit({ json: JSON.stringify(json) });
917
+ }}
918
+ >
919
+ <div class="flex flex-col">
920
+ <foxy-i18n lang=${lang} key="ga_include_on_site" ns=${ns}></foxy-i18n>
921
+ <foxy-i18n
922
+ class="text-xs leading-s text-secondary"
923
+ lang=${lang}
924
+ key="ga_include_on_site_explainer"
925
+ ns=${ns}
926
+ >
927
+ </foxy-i18n>
928
+ </div>
929
+ </x-checkbox>
930
+ </div>
931
+ </x-group>
932
+
933
+ ${this.renderTemplateOrSlot('google-analytics:after')}
934
+ </div>
935
+ `;
936
+ }
937
+ __renderSegmentIo(json) {
938
+ const config = json.analytics_config;
939
+ const sioConfig = config.segment_io;
940
+ const gaConfig = config.google_analytics;
941
+ const isDisabled = this.disabledSelector.matches('segment-io', true);
942
+ const isReadonly = this.readonlySelector.matches('segment-io', true);
943
+ return html `
944
+ <div>
945
+ ${this.renderTemplateOrSlot('segment-io:before')}
946
+
947
+ <x-group frame>
948
+ <span slot="header">Segment.io</span>
949
+
950
+ <div class="p-m">
951
+ <vaadin-text-field
952
+ class="w-full"
953
+ label=${this.t('sio_account_id')}
954
+ placeholder="MY-WRITE-KEY"
955
+ helper-text=${this.t('sio_account_id_explainer')}
956
+ .value=${live(sioConfig.account_id)}
957
+ ?disabled=${isDisabled}
958
+ ?readonly=${isReadonly}
959
+ clear-button-visible
960
+ @keydown=${(evt) => evt.key === 'Enter' && this.submit()}
961
+ @input=${(evt) => {
962
+ sioConfig.account_id = evt.currentTarget.value;
963
+ sioConfig.usage = sioConfig.account_id ? 'required' : 'none';
964
+ config.usage = gaConfig.account_id || sioConfig.account_id ? 'required' : 'none';
965
+ }}
966
+ >
967
+ </vaadin-text-field>
968
+ </div>
969
+ </x-group>
970
+
971
+ ${this.renderTemplateOrSlot('segment-io:after')}
972
+ </div>
973
+ `;
974
+ }
975
+ __renderTroubleshooting(json) {
976
+ const { lang, ns } = this;
977
+ const config = json.debug;
978
+ return html `
979
+ <div>
980
+ ${this.renderTemplateOrSlot('troubleshooting:before')}
981
+
982
+ <x-group frame>
983
+ <foxy-i18n slot="header" lang=${lang} key="troubleshooting" ns=${ns}></foxy-i18n>
984
+
985
+ <div class="p-m space-y-m">
986
+ <x-checkbox
987
+ ?disabled=${this.disabledSelector.matches('troubleshooting', true)}
988
+ ?readonly=${this.readonlySelector.matches('troubleshooting', true)}
989
+ ?checked=${config.usage === 'required'}
990
+ @change=${(evt) => {
991
+ config.usage = evt.detail ? 'required' : 'none';
992
+ this.edit({ json: JSON.stringify(json) });
993
+ }}
994
+ >
995
+ <div class="flex flex-col">
996
+ <foxy-i18n lang=${lang} key="troubleshooting_debug" ns=${ns}></foxy-i18n>
997
+ <foxy-i18n
998
+ class="text-xs leading-s text-secondary"
999
+ lang=${lang}
1000
+ key="troubleshooting_debug_explainer"
1001
+ ns=${ns}
1002
+ >
1003
+ </foxy-i18n>
1004
+ </div>
1005
+ </x-checkbox>
1006
+ </div>
1007
+ </x-group>
1008
+
1009
+ ${this.renderTemplateOrSlot('troubleshooting:after')}
1010
+ </div>
1011
+ `;
1012
+ }
1013
+ __renderCustomConfig(json) {
1014
+ return html `
1015
+ <div>
1016
+ ${this.renderTemplateOrSlot('custom-config:before')}
1017
+
1018
+ <vaadin-text-area
1019
+ class="w-full"
1020
+ label=${this.t('custom_config')}
1021
+ placeholder='{ "key": "value" }'
1022
+ helper-text=${this.t('custom_config_helper_text')}
1023
+ .value=${json.custom_config ? JSON.stringify(json.custom_config, null, 2) : ''}
1024
+ ?disabled=${this.disabledSelector.matches('custom-config', true)}
1025
+ ?readonly=${this.readonlySelector.matches('custom-config', true)}
1026
+ @input=${(evt) => {
1027
+ const input = evt.currentTarget;
1028
+ try {
1029
+ json.custom_config = input.value ? JSON.parse(input.value) : '';
1030
+ this.edit({ json: JSON.stringify(json) });
1031
+ input.invalid = false;
1032
+ }
1033
+ catch (_a) {
1034
+ input.invalid = true;
1035
+ }
1036
+ }}
1037
+ >
1038
+ </vaadin-text-area>
1039
+
1040
+ ${this.renderTemplateOrSlot('custom-config:after')}
1041
+ </div>
1042
+ `;
1043
+ }
1044
+ __renderHeader(json) {
1045
+ return html `
1046
+ <div>
1047
+ ${this.renderTemplateOrSlot('header:before')}
1048
+
1049
+ <vaadin-text-area
1050
+ class="w-full"
1051
+ label=${this.t('custom_header')}
1052
+ helper-text=${this.t('custom_header_helper_text')}
1053
+ .value=${json.custom_script_values.header}
1054
+ ?disabled=${this.disabledSelector.matches('header', true)}
1055
+ ?readonly=${this.readonlySelector.matches('header', true)}
1056
+ @input=${(evt) => {
1057
+ const target = evt.currentTarget;
1058
+ const newConfig = {
1059
+ ...json.custom_script_values,
1060
+ header: target.value,
1061
+ };
1062
+ this.edit({ json: JSON.stringify({ ...json, custom_script_values: newConfig }) });
1063
+ }}
1064
+ >
1065
+ </vaadin-text-area>
1066
+
1067
+ ${this.renderTemplateOrSlot('header:after')}
1068
+ </div>
1069
+ `;
1070
+ }
1071
+ __renderCustomFields(json) {
1072
+ return html `
1073
+ <div>
1074
+ ${this.renderTemplateOrSlot('custom-fields:before')}
1075
+
1076
+ <vaadin-text-area
1077
+ class="w-full"
1078
+ label=${this.t('custom_fields')}
1079
+ helper-text=${this.t('custom_fields_helper_text')}
1080
+ .value=${json.custom_script_values.header}
1081
+ ?disabled=${this.disabledSelector.matches('header', true)}
1082
+ ?readonly=${this.readonlySelector.matches('header', true)}
1083
+ @input=${(evt) => {
1084
+ const newValue = evt.currentTarget.value;
1085
+ json.custom_script_values.checkout_fields = newValue;
1086
+ this.edit({ json: JSON.stringify(json) });
1087
+ }}
1088
+ >
1089
+ </vaadin-text-area>
1090
+
1091
+ ${this.renderTemplateOrSlot('custom-fields:after')}
1092
+ </div>
1093
+ `;
1094
+ }
1095
+ __renderFooter(json) {
1096
+ return html `
1097
+ <div>
1098
+ ${this.renderTemplateOrSlot('footer:before')}
1099
+
1100
+ <vaadin-text-area
1101
+ class="w-full"
1102
+ label=${this.t('custom_footer')}
1103
+ helper-text=${this.t('custom_footer_helper_text')}
1104
+ .value=${json.custom_script_values.footer}
1105
+ ?disabled=${this.disabledSelector.matches('footer', true)}
1106
+ ?readonly=${this.readonlySelector.matches('footer', true)}
1107
+ @input=${(evt) => {
1108
+ const target = evt.currentTarget;
1109
+ const newConfig = {
1110
+ ...json.custom_script_values,
1111
+ footer: target.value,
1112
+ };
1113
+ this.edit({ json: JSON.stringify({ ...json, custom_script_values: newConfig }) });
1114
+ }}
1115
+ >
1116
+ </vaadin-text-area>
1117
+
1118
+ ${this.renderTemplateOrSlot('footer:after')}
1119
+ </div>
1120
+ `;
1121
+ }
1122
+ }
1123
+ //# sourceMappingURL=TemplateConfigForm.js.map