@foxy.io/elements 1.13.0 → 1.14.0-beta.4
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-api.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 +10 -10
- 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 -0
- 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-nucleon-element.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 +2 -2
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +26 -9
- 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 +14 -0
- package/dist/cdn/foxy-template-form.js +1 -0
- 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-d4dad105.js → shared-00563cb0.js} +1 -1
- package/dist/cdn/shared-0ced76a0.js +358 -0
- package/dist/cdn/{shared-f47647ac.js → shared-106daaca.js} +1 -1
- package/dist/cdn/{shared-145cc9eb.js → shared-10bdb6b9.js} +1 -1
- package/dist/cdn/{shared-91a9e922.js → shared-1469c1c4.js} +4 -4
- package/dist/cdn/{shared-f4119f12.js → shared-16f72e27.js} +1 -1
- package/dist/cdn/shared-1761daef.js +15 -0
- package/dist/cdn/shared-18459dcd.js +264 -0
- package/dist/cdn/{shared-e55b6bb7.js → shared-1b7e65e4.js} +1 -1
- package/dist/cdn/{shared-5fedf5e4.js → shared-200f613b.js} +2 -2
- package/dist/cdn/{shared-d9159fe1.js → shared-2174bcd4.js} +1 -1
- package/dist/cdn/{shared-4059f633.js → shared-218ba06e.js} +1 -1
- package/dist/cdn/{shared-e9920617.js → shared-34b2c1e2.js} +1 -1
- package/dist/cdn/{shared-036a8b21.js → shared-3d868b17.js} +1 -1
- package/dist/cdn/{shared-cf248335.js → shared-44cfc617.js} +1 -1
- package/dist/cdn/{shared-45d647e4.js → shared-46ee137f.js} +1 -1
- package/dist/cdn/{shared-b0b1d248.js → shared-4a52d9b5.js} +1 -1
- package/dist/cdn/shared-4be4e513.js +314 -0
- package/dist/cdn/{shared-f0199313.js → shared-593f7e2c.js} +1 -1
- package/dist/cdn/shared-59e44f29.js +1 -0
- package/dist/cdn/{shared-cd700eac.js → shared-60126eee.js} +1 -1
- package/dist/cdn/{shared-67157a25.js → shared-614e1a4e.js} +1 -1
- package/dist/cdn/{shared-17968c53.js → shared-63eaded9.js} +3 -3
- package/dist/cdn/shared-6b7602c7.js +1 -0
- package/dist/cdn/{shared-98ee7fad.js → shared-6d45a07b.js} +1 -1
- package/dist/cdn/{shared-a99dea97.js → shared-7a39a41f.js} +1 -1
- package/dist/cdn/{shared-84fa75d9.js → shared-9221e6b2.js} +1 -1
- package/dist/cdn/{shared-2860a3d3.js → shared-94b0ae99.js} +2 -2
- package/dist/cdn/{shared-f2cf6cfb.js → shared-9d779f46.js} +1 -1
- package/dist/cdn/shared-a46edf4b.js +1 -0
- package/dist/cdn/{shared-54702b33.js → shared-b0f0e8b5.js} +1 -1
- package/dist/cdn/shared-b28a59de.js +1 -0
- package/dist/cdn/{shared-ed4ed7a5.js → shared-b710881a.js} +2 -2
- package/dist/cdn/{shared-3ae39e52.js → shared-bb824ab4.js} +3 -3
- package/dist/cdn/shared-c4b96261.js +1 -0
- package/dist/cdn/shared-d94ffc2b.js +1 -0
- package/dist/cdn/shared-df573cea.js +12 -0
- package/dist/cdn/{shared-e5de8675.js → shared-e7f8ffe9.js} +1 -1
- package/dist/cdn/{shared-54c485d2.js → shared-ec861f31.js} +21 -21
- package/dist/cdn/{shared-e0248713.js → shared-f0a83bd6.js} +1 -1
- package/dist/cdn/{shared-b77179fd.js → shared-fb90e05c.js} +1 -1
- package/dist/cdn/{shared-747b0842.js → shared-ff79f3f9.js} +1 -1
- package/dist/cdn/translations/shared/en.json +52 -1
- package/dist/elements/private/Choice/Choice.js +0 -2
- package/dist/elements/private/Choice/Choice.js.map +1 -1
- package/dist/elements/private/Group/Group.js +1 -1
- package/dist/elements/private/Group/Group.js.map +1 -1
- package/dist/elements/private/I18N/I18N.js +1 -1
- package/dist/elements/private/I18N/I18N.js.map +1 -1
- package/dist/elements/public/AddressForm/AddressForm.js +8 -4
- package/dist/elements/public/AddressForm/AddressForm.js.map +1 -1
- package/dist/elements/public/AttributeForm/AttributeForm.js +8 -4
- package/dist/elements/public/AttributeForm/AttributeForm.js.map +1 -1
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.js +8 -4
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.js.map +1 -1
- package/dist/elements/public/CustomerForm/CustomerForm.js +8 -4
- package/dist/elements/public/CustomerForm/CustomerForm.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.d.ts +24 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +311 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/index.d.ts +9 -0
- package/dist/elements/public/EmailTemplateForm/index.js +11 -0
- package/dist/elements/public/EmailTemplateForm/index.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/types.d.ts +3 -0
- package/dist/elements/public/EmailTemplateForm/types.js +2 -0
- package/dist/elements/public/EmailTemplateForm/types.js.map +1 -0
- package/dist/elements/public/ItemsForm/ItemsForm.js +2 -2
- package/dist/elements/public/ItemsForm/ItemsForm.js.map +1 -1
- package/dist/elements/public/NucleonElement/serveFromCache.js +1 -0
- package/dist/elements/public/NucleonElement/serveFromCache.js.map +1 -1
- package/dist/elements/public/TaxForm/TaxForm.js +8 -4
- package/dist/elements/public/TaxForm/TaxForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/CountriesList.d.ts +23 -0
- package/dist/elements/public/TemplateConfigForm/CountriesList.js +129 -0
- package/dist/elements/public/TemplateConfigForm/CountriesList.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/CountryCard.d.ts +20 -0
- package/dist/elements/public/TemplateConfigForm/CountryCard.js +125 -0
- package/dist/elements/public/TemplateConfigForm/CountryCard.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.d.ts +25 -0
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +529 -0
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/defaults.d.ts +2 -0
- package/dist/elements/public/TemplateConfigForm/defaults.js +95 -0
- package/dist/elements/public/TemplateConfigForm/defaults.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/index.d.ts +9 -0
- package/dist/elements/public/TemplateConfigForm/index.js +11 -0
- package/dist/elements/public/TemplateConfigForm/index.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/types.d.ts +116 -0
- package/dist/elements/public/TemplateConfigForm/types.js +2 -0
- package/dist/elements/public/TemplateConfigForm/types.js.map +1 -0
- package/dist/elements/public/TemplateForm/TemplateForm.d.ts +23 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js +303 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -0
- package/dist/elements/public/TemplateForm/index.d.ts +9 -0
- package/dist/elements/public/TemplateForm/index.js +11 -0
- package/dist/elements/public/TemplateForm/index.js.map +1 -0
- package/dist/elements/public/TemplateForm/types.d.ts +3 -0
- package/dist/elements/public/TemplateForm/types.js +2 -0
- package/dist/elements/public/TemplateForm/types.js.map +1 -0
- package/dist/elements/public/index.d.ts +3 -0
- package/dist/elements/public/index.defined.d.ts +3 -0
- package/dist/elements/public/index.defined.js +3 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +3 -0
- package/dist/elements/public/index.js.map +1 -1
- package/dist/mixins/themeable.js +94 -12
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +2 -7
- package/dist/cdn/shared-296637c5.js +0 -1
- package/dist/cdn/shared-4a990126.js +0 -1
- package/dist/cdn/shared-50744508.js +0 -15
- package/dist/cdn/shared-b98f88c9.js +0 -369
- package/dist/cdn/shared-bf09e011.js +0 -572
- package/dist/cdn/shared-c0161e6a.js +0 -1
- package/dist/cdn/shared-c1e0e11f.js +0 -1
- package/dist/cdn/shared-dbcffd8e.js +0 -1
- package/dist/cdn/shared-e21a2aac.js +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export const getDefaultJSON = () => ({
|
|
2
|
+
cart_type: 'default',
|
|
3
|
+
checkout_type: 'default_account',
|
|
4
|
+
csc_requirements: 'all_cards',
|
|
5
|
+
tos_checkbox_settings: {
|
|
6
|
+
usage: 'none',
|
|
7
|
+
initial_state: 'unchecked',
|
|
8
|
+
is_hidden: false,
|
|
9
|
+
url: '',
|
|
10
|
+
},
|
|
11
|
+
eu_secure_data_transfer_consent: {
|
|
12
|
+
usage: 'required',
|
|
13
|
+
},
|
|
14
|
+
newsletter_subscribe: {
|
|
15
|
+
usage: 'none',
|
|
16
|
+
},
|
|
17
|
+
analytics_config: {
|
|
18
|
+
usage: 'none',
|
|
19
|
+
google_analytics: {
|
|
20
|
+
usage: 'none',
|
|
21
|
+
account_id: '',
|
|
22
|
+
include_on_site: false,
|
|
23
|
+
},
|
|
24
|
+
segment_io: {
|
|
25
|
+
usage: 'none',
|
|
26
|
+
account_id: '',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
colors: {
|
|
30
|
+
usage: 'none',
|
|
31
|
+
primary: '4D4D4D',
|
|
32
|
+
secondary: 'FFFFFF',
|
|
33
|
+
tertiary: 'FFFFFF',
|
|
34
|
+
},
|
|
35
|
+
use_checkout_confirmation_window: {
|
|
36
|
+
usage: 'none',
|
|
37
|
+
},
|
|
38
|
+
supported_payment_cards: ['visa', 'mastercard', 'discover', 'amex'],
|
|
39
|
+
custom_checkout_field_requirements: {
|
|
40
|
+
cart_controls: 'enabled',
|
|
41
|
+
coupon_entry: 'enabled',
|
|
42
|
+
billing_first_name: 'required',
|
|
43
|
+
billing_last_name: 'required',
|
|
44
|
+
billing_company: 'optional',
|
|
45
|
+
billing_tax_id: 'hidden',
|
|
46
|
+
billing_phone: 'optional',
|
|
47
|
+
billing_address1: 'required',
|
|
48
|
+
billing_address2: 'optional',
|
|
49
|
+
billing_city: 'required',
|
|
50
|
+
billing_region: 'default',
|
|
51
|
+
billing_postal_code: 'required',
|
|
52
|
+
billing_country: 'required',
|
|
53
|
+
},
|
|
54
|
+
cart_display_config: {
|
|
55
|
+
usage: 'none',
|
|
56
|
+
show_product_weight: true,
|
|
57
|
+
show_product_category: true,
|
|
58
|
+
show_product_code: true,
|
|
59
|
+
show_product_options: true,
|
|
60
|
+
show_sub_frequency: true,
|
|
61
|
+
show_sub_startdate: true,
|
|
62
|
+
show_sub_nextdate: true,
|
|
63
|
+
show_sub_enddate: true,
|
|
64
|
+
hidden_product_options: [],
|
|
65
|
+
},
|
|
66
|
+
foxycomplete: {
|
|
67
|
+
usage: 'required',
|
|
68
|
+
show_combobox: true,
|
|
69
|
+
combobox_open: '\\u25bc',
|
|
70
|
+
combobox_close: '\\u25b2',
|
|
71
|
+
show_flags: true,
|
|
72
|
+
},
|
|
73
|
+
custom_script_values: {
|
|
74
|
+
header: '',
|
|
75
|
+
footer: '',
|
|
76
|
+
checkout_fields: '',
|
|
77
|
+
multiship_checkout_fields: '',
|
|
78
|
+
},
|
|
79
|
+
http_receipt: false,
|
|
80
|
+
custom_config: '',
|
|
81
|
+
debug: {
|
|
82
|
+
usage: 'none',
|
|
83
|
+
},
|
|
84
|
+
location_filtering: {
|
|
85
|
+
usage: 'none',
|
|
86
|
+
shipping_filter_type: 'blacklist',
|
|
87
|
+
billing_filter_type: 'blacklist',
|
|
88
|
+
shipping_filter_values: {},
|
|
89
|
+
billing_filter_values: {},
|
|
90
|
+
},
|
|
91
|
+
postal_code_lookup: {
|
|
92
|
+
usage: 'enabled',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,GAAuB,EAAE,CAAC,CAAC;IACvD,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,iBAAiB;IAChC,gBAAgB,EAAE,WAAW;IAC7B,qBAAqB,EAAE;QACrB,KAAK,EAAE,MAAM;Q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,EAAE,IAAI;QACtB,sBAAsB,EAAE,EAAE;KAC3B;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,UAAU;QACjB,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,SAAS;QACxB,cAAc,EAAE,SAAS;QACzB,UAAU,EAAE,IAAI;KACjB;IACD,oBAAoB,EAAE;QACpB,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,eAAe,EAAE,EAAE;QACnB,yBAAyB,EAAE,EAAE;KAC9B;IACD,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,EAAE;IACjB,KAAK,EAAE;QACL,KAAK,EAAE,MAAM;KACd;IACD,kBAAkB,EAAE;QAClB,KAAK,EAAE,MAAM;QACb,oBAAoB,EAAE,WAAW;QACjC,mBAAmB,EAAE,WAAW;QAChC,sBAAsB,EAAE,EAAE;QAC1B,qBAAqB,EAAE,EAAE;KAC1B;IACD,kBAAkB,EAAE;QAClB,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC","sourcesContent":["import { TemplateConfigJSON } from './types';\n\nexport const getDefaultJSON = (): TemplateConfigJSON => ({\n cart_type: 'default',\n checkout_type: 'default_account',\n csc_requirements: 'all_cards',\n tos_checkbox_settings: {\n usage: 'none',\n initial_state: 'unchecked',\n is_hidden: false,\n url: '',\n },\n eu_secure_data_transfer_consent: {\n usage: 'required',\n },\n newsletter_subscribe: {\n usage: 'none',\n },\n analytics_config: {\n usage: 'none',\n google_analytics: {\n usage: 'none',\n account_id: '',\n include_on_site: false,\n },\n segment_io: {\n usage: 'none',\n account_id: '',\n },\n },\n colors: {\n usage: 'none',\n primary: '4D4D4D',\n secondary: 'FFFFFF',\n tertiary: 'FFFFFF',\n },\n use_checkout_confirmation_window: {\n usage: 'none',\n },\n supported_payment_cards: ['visa', 'mastercard', 'discover', 'amex'],\n custom_checkout_field_requirements: {\n cart_controls: 'enabled',\n coupon_entry: 'enabled',\n billing_first_name: 'required',\n billing_last_name: 'required',\n billing_company: 'optional',\n billing_tax_id: 'hidden',\n billing_phone: 'optional',\n billing_address1: 'required',\n billing_address2: 'optional',\n billing_city: 'required',\n billing_region: 'default',\n billing_postal_code: 'required',\n billing_country: 'required',\n },\n cart_display_config: {\n usage: 'none',\n show_product_weight: true,\n show_product_category: true,\n show_product_code: true,\n show_product_options: true,\n show_sub_frequency: true,\n show_sub_startdate: true,\n show_sub_nextdate: true,\n show_sub_enddate: true,\n hidden_product_options: [],\n },\n foxycomplete: {\n usage: 'required',\n show_combobox: true,\n combobox_open: '\\\\u25bc',\n combobox_close: '\\\\u25b2',\n show_flags: true,\n },\n custom_script_values: {\n header: '',\n footer: '',\n checkout_fields: '',\n multiship_checkout_fields: '',\n },\n http_receipt: false,\n custom_config: '',\n debug: {\n usage: 'none',\n },\n location_filtering: {\n usage: 'none',\n shipping_filter_type: 'blacklist',\n billing_filter_type: 'blacklist',\n shipping_filter_values: {},\n billing_filter_values: {},\n },\n postal_code_lookup: {\n usage: 'enabled',\n },\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@polymer/iron-icons';
|
|
2
|
+
import '@polymer/iron-icon';
|
|
3
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
4
|
+
import '@vaadin/vaadin-text-field/vaadin-text-area';
|
|
5
|
+
import '../../internal/InternalSandbox/index';
|
|
6
|
+
import '../Spinner/index';
|
|
7
|
+
import '../I18n/index';
|
|
8
|
+
import { TemplateConfigForm } from './TemplateConfigForm';
|
|
9
|
+
export { TemplateConfigForm };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@polymer/iron-icons';
|
|
2
|
+
import '@polymer/iron-icon';
|
|
3
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
4
|
+
import '@vaadin/vaadin-text-field/vaadin-text-area';
|
|
5
|
+
import "../../internal/InternalSandbox/index.js";
|
|
6
|
+
import "../Spinner/index.js";
|
|
7
|
+
import "../I18n/index.js";
|
|
8
|
+
import { TemplateConfigForm } from "./TemplateConfigForm.js";
|
|
9
|
+
customElements.define('foxy-template-config-form', TemplateConfigForm);
|
|
10
|
+
export { TemplateConfigForm };
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,6CAA6C,CAAC;AACrD,OAAO,4CAA4C,CAAC;AACpD,iDAA8C;AAC9C,6BAA0B;AAC1B,0BAAuB;AAEvB,OAAO,EAAE,kBAAkB,EAAE,gCAA6B;AAE1D,cAAc,CAAC,MAAM,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import '@polymer/iron-icons';\nimport '@polymer/iron-icon';\nimport '@vaadin/vaadin-text-field/vaadin-text-field';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport '../../internal/InternalSandbox/index';\nimport '../Spinner/index';\nimport '../I18n/index';\n\nimport { TemplateConfigForm } from './TemplateConfigForm';\n\ncustomElements.define('foxy-template-config-form', TemplateConfigForm);\n\nexport { TemplateConfigForm };\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Rels } from '@foxy.io/sdk/backend';
|
|
2
|
+
import { Resource } from '@foxy.io/sdk/core';
|
|
3
|
+
export declare type Data = Resource<Rels.TemplateConfig>;
|
|
4
|
+
export declare type TemplateConfigJSON = {
|
|
5
|
+
/** Controls how your cart functions. */
|
|
6
|
+
cart_type: 'default' | 'fullpage' | 'custom';
|
|
7
|
+
/** Determines how you'd like customers to interact with your checkout regarding guest checkout or account checkout. The default value shows which option is shown first by default. */
|
|
8
|
+
checkout_type: 'default_account' | 'default_guest' | 'guest_only' | 'account_only';
|
|
9
|
+
/** Sets under what circumstances the card security code should be required. */
|
|
10
|
+
csc_requirements: 'all_cards' | 'sso_only' | 'new_cards_only';
|
|
11
|
+
/** Determines if you'd like a terms of service checkbox and url on your checkout. */
|
|
12
|
+
tos_checkbox_settings: {
|
|
13
|
+
usage: 'none' | 'required' | 'optional';
|
|
14
|
+
initial_state: 'checked' | 'unchecked';
|
|
15
|
+
is_hidden: boolean;
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
18
|
+
/** Display a Secure Data Transfer agreement to EU customers. */
|
|
19
|
+
eu_secure_data_transfer_consent: {
|
|
20
|
+
usage: 'none' | 'required';
|
|
21
|
+
};
|
|
22
|
+
/** Display a newsletter subscribe checkbox on your checkout. */
|
|
23
|
+
newsletter_subscribe: {
|
|
24
|
+
usage: 'none' | 'required';
|
|
25
|
+
};
|
|
26
|
+
/** Determine if you'd like to use an analytics service. */
|
|
27
|
+
analytics_config: {
|
|
28
|
+
usage: 'none' | 'required';
|
|
29
|
+
google_analytics: {
|
|
30
|
+
usage: 'none' | 'required';
|
|
31
|
+
account_id: string;
|
|
32
|
+
include_on_site: boolean;
|
|
33
|
+
};
|
|
34
|
+
segment_io: {
|
|
35
|
+
usage: 'none' | 'required';
|
|
36
|
+
account_id: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** Can be used to set some basic colors for your cart, checkout, and receipt templates. */
|
|
40
|
+
colors: {
|
|
41
|
+
usage: 'none' | 'required';
|
|
42
|
+
primary: string;
|
|
43
|
+
secondary: string;
|
|
44
|
+
tertiary: string;
|
|
45
|
+
};
|
|
46
|
+
/** Not currently implemented. */
|
|
47
|
+
use_checkout_confirmation_window: {
|
|
48
|
+
usage: 'none' | 'required';
|
|
49
|
+
};
|
|
50
|
+
/** Add the payment card types you support and want displayed on the checkout page. */
|
|
51
|
+
supported_payment_cards: ('visa' | 'mastercard' | 'discover' | 'amex' | 'dinersclub' | 'maestro' | 'laser')[];
|
|
52
|
+
/** Customize which fields should be required, option, hidden or default on the checkout page. */
|
|
53
|
+
custom_checkout_field_requirements: {
|
|
54
|
+
cart_controls: 'enabled' | 'disabled';
|
|
55
|
+
coupon_entry: 'enabled' | 'disabled';
|
|
56
|
+
billing_first_name: 'default' | 'optional' | 'required' | 'hidden';
|
|
57
|
+
billing_last_name: 'default' | 'optional' | 'required' | 'hidden';
|
|
58
|
+
billing_company: 'default' | 'optional' | 'required' | 'hidden';
|
|
59
|
+
billing_tax_id: 'default' | 'optional' | 'required' | 'hidden';
|
|
60
|
+
billing_phone: 'default' | 'optional' | 'required' | 'hidden';
|
|
61
|
+
billing_address1: 'default' | 'optional' | 'required' | 'hidden';
|
|
62
|
+
billing_address2: 'default' | 'optional' | 'required' | 'hidden';
|
|
63
|
+
billing_city: 'default' | 'optional' | 'required' | 'hidden';
|
|
64
|
+
billing_region: 'default' | 'optional' | 'required' | 'hidden';
|
|
65
|
+
billing_postal_code: 'default' | 'optional' | 'required' | 'hidden';
|
|
66
|
+
billing_country: 'default' | 'optional' | 'required' | 'hidden';
|
|
67
|
+
};
|
|
68
|
+
/** Customize which fields in the cart are shown or hidden. */
|
|
69
|
+
cart_display_config: {
|
|
70
|
+
usage: 'none' | 'required';
|
|
71
|
+
show_product_weight: boolean;
|
|
72
|
+
show_product_category: boolean;
|
|
73
|
+
show_product_code: boolean;
|
|
74
|
+
show_product_options: boolean;
|
|
75
|
+
show_sub_frequency: boolean;
|
|
76
|
+
show_sub_startdate: boolean;
|
|
77
|
+
show_sub_nextdate: boolean;
|
|
78
|
+
show_sub_enddate: boolean;
|
|
79
|
+
hidden_product_options: string[];
|
|
80
|
+
};
|
|
81
|
+
/** Allows you to customize and control the functionality of our find-as-you type system from countries and regions. */
|
|
82
|
+
foxycomplete: {
|
|
83
|
+
usage: 'none' | 'required';
|
|
84
|
+
show_combobox: boolean;
|
|
85
|
+
show_flags: boolean;
|
|
86
|
+
combobox_open: string;
|
|
87
|
+
combobox_close: string;
|
|
88
|
+
};
|
|
89
|
+
/** Custom HTML, css, and JavaScript for your cart, checkout and receipt templates. Twig is not allowed in the header template. */
|
|
90
|
+
custom_script_values: {
|
|
91
|
+
header: string;
|
|
92
|
+
footer: string;
|
|
93
|
+
checkout_fields: string;
|
|
94
|
+
multiship_checkout_fields: string;
|
|
95
|
+
};
|
|
96
|
+
/** @deprecated */
|
|
97
|
+
http_receipt: boolean;
|
|
98
|
+
/** A place where you can store your own custom JSON configuration data to be used by your Twig templates. */
|
|
99
|
+
custom_config: string;
|
|
100
|
+
/** Log debug info to browser console. */
|
|
101
|
+
debug: {
|
|
102
|
+
usage: 'none' | 'required';
|
|
103
|
+
};
|
|
104
|
+
/** This controls which countries and regions you want to allow on your cart and checkout pages. */
|
|
105
|
+
location_filtering: {
|
|
106
|
+
usage: 'none' | 'shipping' | 'billing' | 'both' | 'independent';
|
|
107
|
+
shipping_filter_type: 'blacklist' | 'whitelist';
|
|
108
|
+
billing_filter_type: 'blacklist' | 'whitelist';
|
|
109
|
+
shipping_filter_values: Record<string, '*' | string[]>;
|
|
110
|
+
billing_filter_values: Record<string, '*' | string[]>;
|
|
111
|
+
};
|
|
112
|
+
/** Enable postal code lookup on checkout. */
|
|
113
|
+
postal_code_lookup: {
|
|
114
|
+
usage: 'none' | 'enabled';
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\n\nexport type Data = Resource<Rels.TemplateConfig>;\n\nexport type TemplateConfigJSON = {\n /** Controls how your cart functions. */\n cart_type: 'default' | 'fullpage' | 'custom';\n\n /** Determines how you'd like customers to interact with your checkout regarding guest checkout or account checkout. The default value shows which option is shown first by default. */\n checkout_type: 'default_account' | 'default_guest' | 'guest_only' | 'account_only';\n\n /** Sets under what circumstances the card security code should be required. */\n csc_requirements: 'all_cards' | 'sso_only' | 'new_cards_only';\n\n /** Determines if you'd like a terms of service checkbox and url on your checkout. */\n tos_checkbox_settings: {\n usage: 'none' | 'required' | 'optional';\n initial_state: 'checked' | 'unchecked';\n is_hidden: boolean;\n url: string;\n };\n\n /** Display a Secure Data Transfer agreement to EU customers. */\n eu_secure_data_transfer_consent: {\n usage: 'none' | 'required';\n };\n\n /** Display a newsletter subscribe checkbox on your checkout. */\n newsletter_subscribe: {\n usage: 'none' | 'required';\n };\n\n /** Determine if you'd like to use an analytics service. */\n analytics_config: {\n usage: 'none' | 'required';\n google_analytics: {\n usage: 'none' | 'required';\n account_id: string;\n include_on_site: boolean;\n };\n segment_io: {\n usage: 'none' | 'required';\n account_id: string;\n };\n };\n\n /** Can be used to set some basic colors for your cart, checkout, and receipt templates. */\n colors: {\n usage: 'none' | 'required';\n primary: string;\n secondary: string;\n tertiary: string;\n };\n\n /** Not currently implemented. */\n use_checkout_confirmation_window: {\n usage: 'none' | 'required';\n };\n\n /** Add the payment card types you support and want displayed on the checkout page. */\n supported_payment_cards: (\n | 'visa'\n | 'mastercard'\n | 'discover'\n | 'amex'\n | 'dinersclub'\n | 'maestro'\n | 'laser'\n )[];\n\n /** Customize which fields should be required, option, hidden or default on the checkout page. */\n custom_checkout_field_requirements: {\n cart_controls: 'enabled' | 'disabled';\n coupon_entry: 'enabled' | 'disabled';\n billing_first_name: 'default' | 'optional' | 'required' | 'hidden';\n billing_last_name: 'default' | 'optional' | 'required' | 'hidden';\n billing_company: 'default' | 'optional' | 'required' | 'hidden';\n billing_tax_id: 'default' | 'optional' | 'required' | 'hidden';\n billing_phone: 'default' | 'optional' | 'required' | 'hidden';\n billing_address1: 'default' | 'optional' | 'required' | 'hidden';\n billing_address2: 'default' | 'optional' | 'required' | 'hidden';\n billing_city: 'default' | 'optional' | 'required' | 'hidden';\n billing_region: 'default' | 'optional' | 'required' | 'hidden';\n billing_postal_code: 'default' | 'optional' | 'required' | 'hidden';\n billing_country: 'default' | 'optional' | 'required' | 'hidden';\n };\n\n /** Customize which fields in the cart are shown or hidden. */\n cart_display_config: {\n usage: 'none' | 'required';\n show_product_weight: boolean;\n show_product_category: boolean;\n show_product_code: boolean;\n show_product_options: boolean;\n show_sub_frequency: boolean;\n show_sub_startdate: boolean;\n show_sub_nextdate: boolean;\n show_sub_enddate: boolean;\n hidden_product_options: string[];\n };\n\n /** Allows you to customize and control the functionality of our find-as-you type system from countries and regions. */\n foxycomplete: {\n usage: 'none' | 'required';\n show_combobox: boolean;\n show_flags: boolean;\n combobox_open: string;\n combobox_close: string;\n };\n\n /** Custom HTML, css, and JavaScript for your cart, checkout and receipt templates. Twig is not allowed in the header template. */\n custom_script_values: {\n header: string;\n footer: string;\n checkout_fields: string;\n multiship_checkout_fields: string;\n };\n\n /** @deprecated */\n http_receipt: boolean;\n\n /** A place where you can store your own custom JSON configuration data to be used by your Twig templates. */\n custom_config: string;\n\n /** Log debug info to browser console. */\n debug: {\n usage: 'none' | 'required';\n };\n\n /** This controls which countries and regions you want to allow on your cart and checkout pages. */\n location_filtering: {\n usage: 'none' | 'shipping' | 'billing' | 'both' | 'independent';\n shipping_filter_type: 'blacklist' | 'whitelist';\n billing_filter_type: 'blacklist' | 'whitelist';\n shipping_filter_values: Record<string, '*' | string[]>;\n billing_filter_values: Record<string, '*' | string[]>;\n };\n\n /** Enable postal code lookup on checkout. */\n postal_code_lookup: {\n usage: 'none' | 'enabled';\n };\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
|
+
import { ScopedElementsMap } from '@open-wc/scoped-elements';
|
|
3
|
+
import { Data } from './types';
|
|
4
|
+
import { NucleonElement } from '../NucleonElement/NucleonElement';
|
|
5
|
+
declare const Base: typeof NucleonElement & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
6
|
+
defaultNS: string;
|
|
7
|
+
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost> & {
|
|
8
|
+
styles: CSSResultArray;
|
|
9
|
+
} & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/src/types").ScopedElementsHost>;
|
|
10
|
+
export declare class TemplateForm extends Base<Data> {
|
|
11
|
+
static get properties(): PropertyDeclarations;
|
|
12
|
+
static get styles(): CSSResultArray;
|
|
13
|
+
static get scopedElements(): ScopedElementsMap;
|
|
14
|
+
private __cacheState;
|
|
15
|
+
private __contentChoice;
|
|
16
|
+
render(): TemplateResult;
|
|
17
|
+
private __renderDescription;
|
|
18
|
+
private __renderContent;
|
|
19
|
+
private __renderTimestamps;
|
|
20
|
+
private __renderAction;
|
|
21
|
+
private __cache;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { css, html } from 'lit-element';
|
|
2
|
+
import { Choice, Group, PropertyTable } from "../../private/index.js";
|
|
3
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
4
|
+
import { ChoiceChangeEvent } from "../../private/events.js";
|
|
5
|
+
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
6
|
+
import { NucleonElement } from "../NucleonElement/NucleonElement.js";
|
|
7
|
+
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
8
|
+
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
9
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
10
|
+
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
11
|
+
const NS = 'template-form';
|
|
12
|
+
const Base = ScopedElementsMixin(ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS))));
|
|
13
|
+
export class TemplateForm extends Base {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.__cacheState = 'idle';
|
|
17
|
+
this.__contentChoice = 'default';
|
|
18
|
+
}
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
...super.properties,
|
|
22
|
+
__cacheState: { attribute: false },
|
|
23
|
+
__contentChoice: { attribute: false },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static get styles() {
|
|
27
|
+
return [
|
|
28
|
+
...super.styles,
|
|
29
|
+
css `#cached-content::part(input-field){
|
|
30
|
+
max-height:15em;
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
static get scopedElements() {
|
|
36
|
+
return {
|
|
37
|
+
'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
|
|
38
|
+
'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
|
|
39
|
+
'foxy-spinner': customElements.get('foxy-spinner'),
|
|
40
|
+
'foxy-i18n': customElements.get('foxy-i18n'),
|
|
41
|
+
'vaadin-text-field': customElements.get('vaadin-text-field'),
|
|
42
|
+
'vaadin-text-area': customElements.get('vaadin-text-area'),
|
|
43
|
+
'vaadin-button': customElements.get('vaadin-button'),
|
|
44
|
+
'x-property-table': PropertyTable,
|
|
45
|
+
'x-choice': Choice,
|
|
46
|
+
'x-group': Group,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const { hiddenSelector, href, lang, ns } = this;
|
|
52
|
+
const action = href ? 'delete' : 'create';
|
|
53
|
+
const isBusy = this.in('busy');
|
|
54
|
+
const isFail = this.in('fail');
|
|
55
|
+
return html `
|
|
56
|
+
<div class="space-y-m">
|
|
57
|
+
${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}
|
|
58
|
+
${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}
|
|
59
|
+
${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}
|
|
60
|
+
${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
data-testid="spinner"
|
|
64
|
+
class=${classMap({
|
|
65
|
+
'transition duration-500 ease-in-out absolute inset-0 flex': true,
|
|
66
|
+
'opacity-0 pointer-events-none': !isBusy && !isFail,
|
|
67
|
+
})}
|
|
68
|
+
>
|
|
69
|
+
<foxy-spinner
|
|
70
|
+
layout="vertical"
|
|
71
|
+
class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
|
|
72
|
+
state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}
|
|
73
|
+
lang=${lang}
|
|
74
|
+
ns="${ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
|
|
75
|
+
>
|
|
76
|
+
</foxy-spinner>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
__renderDescription() {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
return html `
|
|
84
|
+
<div>
|
|
85
|
+
${this.renderTemplateOrSlot('description:before')}
|
|
86
|
+
|
|
87
|
+
<vaadin-text-field
|
|
88
|
+
class="w-full mb-s"
|
|
89
|
+
label=${this.t('description')}
|
|
90
|
+
.value=${(_b = (_a = this.form) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : ''}
|
|
91
|
+
@keydown=${(evt) => evt.key === 'Enter' && this.submit()}
|
|
92
|
+
@input=${(evt) => {
|
|
93
|
+
this.edit({ description: evt.currentTarget.value });
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
</vaadin-text-field>
|
|
97
|
+
|
|
98
|
+
${this.renderTemplateOrSlot('description:after')}
|
|
99
|
+
</div>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
__renderContent() {
|
|
103
|
+
var _a;
|
|
104
|
+
const contentChoice = this.form.content_url
|
|
105
|
+
? 'url'
|
|
106
|
+
: this.form.content
|
|
107
|
+
? 'clipboard'
|
|
108
|
+
: this.__contentChoice;
|
|
109
|
+
return html `
|
|
110
|
+
<div>
|
|
111
|
+
${this.renderTemplateOrSlot('content:before')}
|
|
112
|
+
|
|
113
|
+
<x-group frame>
|
|
114
|
+
<foxy-i18n lang=${this.lang} slot="header" key="template" ns=${this.ns}></foxy-i18n>
|
|
115
|
+
|
|
116
|
+
<x-choice
|
|
117
|
+
data-testid="template-type"
|
|
118
|
+
.value=${contentChoice}
|
|
119
|
+
.items=${['default', 'url', 'clipboard']}
|
|
120
|
+
?readonly=${this.readonlySelector.matches('content', true)}
|
|
121
|
+
?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}
|
|
122
|
+
@change=${(evt) => {
|
|
123
|
+
if (evt instanceof ChoiceChangeEvent) {
|
|
124
|
+
this.edit({ content: '', content_url: '' });
|
|
125
|
+
this.__contentChoice = evt.detail;
|
|
126
|
+
}
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
${['default', 'url', 'clipboard'].map(value => {
|
|
130
|
+
return html `
|
|
131
|
+
<div slot="${value}-label" class="py-s">
|
|
132
|
+
<foxy-i18n class="block" lang=${this.lang} key="template_${value}" ns=${this.ns}>
|
|
133
|
+
</foxy-i18n>
|
|
134
|
+
|
|
135
|
+
<foxy-i18n
|
|
136
|
+
class="block text-s opacity-70"
|
|
137
|
+
lang=${this.lang}
|
|
138
|
+
key="template_${value}_explainer"
|
|
139
|
+
ns=${this.ns}
|
|
140
|
+
>
|
|
141
|
+
</foxy-i18n>
|
|
142
|
+
</div>
|
|
143
|
+
`;
|
|
144
|
+
})}
|
|
145
|
+
|
|
146
|
+
<div slot="url" ?hidden=${contentChoice !== 'url'}>
|
|
147
|
+
<div class="flex items-center mt-0 mb-m">
|
|
148
|
+
<vaadin-text-field
|
|
149
|
+
data-testid="content_url"
|
|
150
|
+
value=${ifDefined(this.form.content_url)}
|
|
151
|
+
class="mr-s flex-grow"
|
|
152
|
+
@input=${(evt) => {
|
|
153
|
+
const value = evt.currentTarget.value;
|
|
154
|
+
this.edit({ content: '', content_url: value });
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
</vaadin-text-field>
|
|
158
|
+
|
|
159
|
+
${this.form.content_url === ((_a = this.data) === null || _a === void 0 ? void 0 : _a.content_url)
|
|
160
|
+
? html `
|
|
161
|
+
<vaadin-button
|
|
162
|
+
class="relative"
|
|
163
|
+
?disabled=${this.__cacheState === 'busy'}
|
|
164
|
+
@click=${this.__cache}
|
|
165
|
+
>
|
|
166
|
+
<foxy-i18n
|
|
167
|
+
class=${classMap({
|
|
168
|
+
'relative transition-opacity': true,
|
|
169
|
+
'opacity-0': this.__cacheState !== 'idle',
|
|
170
|
+
})}
|
|
171
|
+
lang=${this.lang}
|
|
172
|
+
key="cache"
|
|
173
|
+
ns=${this.ns}
|
|
174
|
+
>
|
|
175
|
+
</foxy-i18n>
|
|
176
|
+
|
|
177
|
+
<div
|
|
178
|
+
class=${classMap({
|
|
179
|
+
'absolute inset-0 flex transition-opacity': true,
|
|
180
|
+
'opacity-0': this.__cacheState === 'idle',
|
|
181
|
+
})}
|
|
182
|
+
>
|
|
183
|
+
<foxy-spinner
|
|
184
|
+
layout="no-label"
|
|
185
|
+
class="m-auto"
|
|
186
|
+
state=${this.__cacheState === 'fail' ? 'error' : 'busy'}
|
|
187
|
+
lang=${this.lang}
|
|
188
|
+
ns=${this.ns}
|
|
189
|
+
>
|
|
190
|
+
</foxy-spinner>
|
|
191
|
+
</div>
|
|
192
|
+
</vaadin-button>
|
|
193
|
+
`
|
|
194
|
+
: ''}
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<div slot="clipboard" ?hidden=${contentChoice !== 'clipboard'}>
|
|
199
|
+
<vaadin-text-area
|
|
200
|
+
id="cached-content"
|
|
201
|
+
data-testid="content"
|
|
202
|
+
class="w-full mb-m"
|
|
203
|
+
.value=${this.form.content}
|
|
204
|
+
@input=${(evt) => {
|
|
205
|
+
const value = evt.currentTarget.value;
|
|
206
|
+
this.edit({ content: value, content_url: '' });
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
</vaadin-text-area>
|
|
210
|
+
</div>
|
|
211
|
+
</x-choice>
|
|
212
|
+
</x-group>
|
|
213
|
+
|
|
214
|
+
${this.renderTemplateOrSlot('content:after')}
|
|
215
|
+
</div>
|
|
216
|
+
`;
|
|
217
|
+
}
|
|
218
|
+
__renderTimestamps() {
|
|
219
|
+
return html `
|
|
220
|
+
<div>
|
|
221
|
+
${this.renderTemplateOrSlot('timestamps:before')}
|
|
222
|
+
|
|
223
|
+
<x-property-table
|
|
224
|
+
data-testid="timestamps"
|
|
225
|
+
.items=${['date_modified', 'date_created'].map(field => {
|
|
226
|
+
var _a;
|
|
227
|
+
return ({
|
|
228
|
+
name: this.t(field),
|
|
229
|
+
value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
|
|
230
|
+
: '',
|
|
231
|
+
});
|
|
232
|
+
})}
|
|
233
|
+
>
|
|
234
|
+
</x-property-table>
|
|
235
|
+
|
|
236
|
+
${this.renderTemplateOrSlot('timestamps:after')}
|
|
237
|
+
</div>
|
|
238
|
+
`;
|
|
239
|
+
}
|
|
240
|
+
__renderAction(action) {
|
|
241
|
+
const { disabledSelector, href, lang, ns } = this;
|
|
242
|
+
const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });
|
|
243
|
+
const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });
|
|
244
|
+
const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);
|
|
245
|
+
const isValid = isTemplateValid || isSnapshotValid;
|
|
246
|
+
const handleClick = (evt) => {
|
|
247
|
+
if (action === 'delete') {
|
|
248
|
+
const confirm = this.renderRoot.querySelector('#confirm');
|
|
249
|
+
confirm.show(evt.currentTarget);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.submit();
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return html `
|
|
256
|
+
<div>
|
|
257
|
+
${this.renderTemplateOrSlot(`${action}:before`)}
|
|
258
|
+
|
|
259
|
+
<foxy-internal-confirm-dialog
|
|
260
|
+
message="delete_prompt"
|
|
261
|
+
confirm="delete"
|
|
262
|
+
cancel="cancel"
|
|
263
|
+
header="delete"
|
|
264
|
+
theme="primary error"
|
|
265
|
+
lang=${lang}
|
|
266
|
+
ns=${ns}
|
|
267
|
+
id="confirm"
|
|
268
|
+
data-testid="confirm"
|
|
269
|
+
@hide=${(evt) => {
|
|
270
|
+
if (!evt.detail.cancelled)
|
|
271
|
+
this.delete();
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
</foxy-internal-confirm-dialog>
|
|
275
|
+
|
|
276
|
+
<vaadin-button
|
|
277
|
+
class="w-full"
|
|
278
|
+
theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}
|
|
279
|
+
data-testid=${action}
|
|
280
|
+
?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}
|
|
281
|
+
@click=${handleClick}
|
|
282
|
+
>
|
|
283
|
+
<foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>
|
|
284
|
+
</vaadin-button>
|
|
285
|
+
|
|
286
|
+
${this.renderTemplateOrSlot(`${action}:after`)}
|
|
287
|
+
</div>
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
async __cache() {
|
|
291
|
+
var _a, _b;
|
|
292
|
+
this.__cacheState = 'busy';
|
|
293
|
+
try {
|
|
294
|
+
const url = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:cache'].href) !== null && _b !== void 0 ? _b : '';
|
|
295
|
+
const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });
|
|
296
|
+
this.__cacheState = response.ok ? 'idle' : 'fail';
|
|
297
|
+
}
|
|
298
|
+
catch (_c) {
|
|
299
|
+
this.__cacheState = 'fail';
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=TemplateForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateForm.js","source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GAAG,CAAC,MAAM,CAAC,SAAS;gBAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;;;;;;kBAMO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE;wBACxD,MAAM;sBACR,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,UAAU;mBAC5D,WAAW;;0BAEJ,EAAE,QAAQ,MAAM,SAAS,IAAI;;;UAG7C,IAAI,CAAC,oBAAoB,CAAC,GAAG,MAAM,QAAQ,CAAC;;KAEjD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAEjF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;SACnD;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\n\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { Data } from './types';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { TextAreaElement } from '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field';\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 NS = 'template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\nexport class TemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n #cached-content::part(input-field) {\n max-height: 15em;\n }\n `,\n ];\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\n\n private __contentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n render(): TemplateResult {\n const { hiddenSelector, href, lang, ns } = this;\n const action = href ? 'delete' : 'create';\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <div class=\"space-y-m\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\n ${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !isBusy && !isFail,\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}\n lang=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __renderDescription() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('description:before')}\n\n <vaadin-text-field\n class=\"w-full mb-s\"\n label=${this.t('description')}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderContent() {\n const contentChoice = this.form.content_url\n ? 'url'\n : this.form.content\n ? 'clipboard'\n : this.__contentChoice;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('content:before')}\n\n <x-group frame>\n <foxy-i18n lang=${this.lang} slot=\"header\" key=\"template\" ns=${this.ns}></foxy-i18n>\n\n <x-choice\n data-testid=\"template-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${this.readonlySelector.matches('content', true)}\n ?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ content: '', content_url: '' });\n this.__contentChoice = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n\n <foxy-i18n\n class=\"block text-s opacity-70\"\n lang=${this.lang}\n key=\"template_${value}_explainer\"\n ns=${this.ns}\n >\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div slot=\"url\" ?hidden=${contentChoice !== 'url'}>\n <div class=\"flex items-center mt-0 mb-m\">\n <vaadin-text-field\n data-testid=\"content_url\"\n value=${ifDefined(this.form.content_url)}\n class=\"mr-s flex-grow\"\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ content: '', content_url: value });\n }}\n >\n </vaadin-text-field>\n\n ${this.form.content_url === this.data?.content_url\n ? html`\n <vaadin-button\n class=\"relative\"\n ?disabled=${this.__cacheState === 'busy'}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n `\n : ''}\n </div>\n </div>\n\n <div slot=\"clipboard\" ?hidden=${contentChoice !== 'clipboard'}>\n <vaadin-text-area\n id=\"cached-content\"\n data-testid=\"content\"\n class=\"w-full mb-m\"\n .value=${this.form.content}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextAreaElement).value;\n this.edit({ content: value, content_url: '' });\n }}\n >\n </vaadin-text-area>\n </div>\n </x-choice>\n </x-group>\n\n ${this.renderTemplateOrSlot('content:after')}\n </div>\n `;\n }\n\n private __renderTimestamps() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n }\n\n private __renderAction(action: string) {\n const { disabledSelector, href, lang, ns } = this;\n\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);\n const isValid = isTemplateValid || isSnapshotValid;\n\n const handleClick = (evt: Event) => {\n if (action === 'delete') {\n const confirm = this.renderRoot.querySelector('#confirm');\n (confirm as InternalConfirmDialog).show(evt.currentTarget as HTMLElement);\n } else {\n this.submit();\n }\n };\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${action}:before`)}\n\n <foxy-internal-confirm-dialog\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n data-testid=\"confirm\"\n @hide=${(evt: DialogHideEvent) => {\n if (!evt.detail.cancelled) this.delete();\n }}\n >\n </foxy-internal-confirm-dialog>\n\n <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}\n data-testid=${action}\n ?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}\n @click=${handleClick}\n >\n <foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${action}:after`)}\n </div>\n `;\n }\n\n private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n\n this.__cacheState = response.ok ? 'idle' : 'fail';\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
2
|
+
import '@vaadin/vaadin-text-field/vaadin-text-area';
|
|
3
|
+
import '@vaadin/vaadin-button';
|
|
4
|
+
import '../../internal/InternalConfirmDialog/index';
|
|
5
|
+
import '../../internal/InternalSandbox/index';
|
|
6
|
+
import '../Spinner/index';
|
|
7
|
+
import '../I18n/index';
|
|
8
|
+
import { TemplateForm } from './TemplateForm';
|
|
9
|
+
export { TemplateForm };
|