@foxy.io/elements 1.43.0-beta.4 → 1.43.0
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/README.md +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +7 -7
- package/dist/cdn/{shared-3eb6e232.js → shared-107dc7d7.js} +4 -4
- package/dist/cdn/translations/admin-subscription-form/en.json +2 -2
- package/dist/cdn/translations/coupon-code-form/en.json +2 -2
- package/dist/cdn/translations/coupon-form/en.json +2 -2
- package/dist/cdn/translations/customer/en.json +5 -5
- package/dist/cdn/translations/customer-portal/de.json +6 -5
- package/dist/cdn/translations/customer-portal/en.json +6 -5
- package/dist/cdn/translations/customer-portal/es.json +6 -5
- package/dist/cdn/translations/customer-portal/fr.json +6 -5
- package/dist/cdn/translations/customer-portal/nl.json +6 -5
- package/dist/cdn/translations/customer-portal/pl.json +6 -5
- package/dist/cdn/translations/customer-portal/sv.json +6 -5
- package/dist/cdn/translations/customer-portal/zh-HK.json +6 -5
- package/dist/cdn/translations/subscription-card/en.json +2 -1
- package/dist/cdn/translations/subscription-form/en.json +2 -2
- package/dist/cdn/translations/subscriptions-table/en.json +2 -1
- package/dist/cdn/translations/transaction-card/en.json +2 -2
- package/dist/cdn/translations/transactions-table/en.json +3 -3
- package/dist/elements/public/Donation/Donation.d.ts +1 -1
- package/dist/elements/public/Donation/Donation.js +8 -6
- package/dist/elements/public/Donation/Donation.js.map +1 -1
- package/dist/elements/public/SubscriptionCard/SubscriptionCard.js +1 -1
- package/dist/elements/public/SubscriptionCard/SubscriptionCard.js.map +1 -1
- package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js +1 -1
- package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js.map +1 -1
- package/dist/elements/public/TransactionCard/TransactionCard.js +1 -1
- package/dist/elements/public/TransactionCard/TransactionCard.js.map +1 -1
- package/dist/elements/public/TransactionsTable/TransactionsTable.js +1 -1
- package/dist/elements/public/TransactionsTable/TransactionsTable.js.map +1 -1
- package/package.json +1 -1
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"transaction_pending": "I väntan på",
|
|
59
59
|
"transaction_refunded": "Återbetalas",
|
|
60
60
|
"transaction_rejected": "avvisade",
|
|
61
|
-
"transaction_summary": "{{
|
|
62
|
-
"transaction_summary_plural": "{{
|
|
61
|
+
"transaction_summary": "{{first_item.name}}",
|
|
62
|
+
"transaction_summary_plural": "{{first_item.name}} och {{count_minus_one}} Mer",
|
|
63
63
|
"transaction_verified": "Verifierad",
|
|
64
64
|
"transaction_voided": "Ogiltigförklarad",
|
|
65
65
|
"spinner": {
|
|
@@ -938,7 +938,8 @@
|
|
|
938
938
|
"status_next_payment": "Nästa betalning den {{ next_transaction_date, date }}",
|
|
939
939
|
"status_next_payment_no_nextdate": "Aktiv",
|
|
940
940
|
"status_inactive": "Inaktiv",
|
|
941
|
-
"transaction_summary": "{{
|
|
941
|
+
"transaction_summary": "{{first_item.name}}",
|
|
942
|
+
"transaction_summary_plural": "{{first_item.name}} och {{count_minus_one}} Mer",
|
|
942
943
|
"fees_hint": "inkl. ",
|
|
943
944
|
"fees_explainer": "Skatter, frakt och rabatter kan ändra beloppet som debiteras.",
|
|
944
945
|
"twice_a_month": "två gånger i månaden",
|
|
@@ -1090,8 +1091,8 @@
|
|
|
1090
1091
|
"status_refunded": "Återbetalas",
|
|
1091
1092
|
"status_voided": "Ogiltigförklarad",
|
|
1092
1093
|
"status_verified": "Verifierad",
|
|
1093
|
-
"summary": "{{
|
|
1094
|
-
"summary_plural": "{{
|
|
1094
|
+
"summary": "{{first_item.name}}",
|
|
1095
|
+
"summary_plural": "{{first_item.name}} och {{count_minus_one}} Mer",
|
|
1095
1096
|
"summary_payment_method_change": "Ändring av betalningsmetod",
|
|
1096
1097
|
"summary_subscription_modification": "Ändring av abonnemang",
|
|
1097
1098
|
"summary_subscription_cancellation": "Uppsägning av prenumeration",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"transaction_pending": "待办的",
|
|
59
59
|
"transaction_refunded": "已退款",
|
|
60
60
|
"transaction_rejected": "拒绝",
|
|
61
|
-
"transaction_summary": "{{
|
|
62
|
-
"transaction_summary_plural": "{{
|
|
61
|
+
"transaction_summary": "{{first_item.name}}",
|
|
62
|
+
"transaction_summary_plural": "{{first_item.name}} 和 {{count_minus_one}} 更多的",
|
|
63
63
|
"transaction_verified": "已验证",
|
|
64
64
|
"transaction_voided": "作废",
|
|
65
65
|
"spinner": {
|
|
@@ -938,7 +938,8 @@
|
|
|
938
938
|
"status_next_payment": "下次付款日期为 {{ next_transaction_date, date }}",
|
|
939
939
|
"status_next_payment_no_nextdate": "活跃",
|
|
940
940
|
"status_inactive": "不活跃",
|
|
941
|
-
"transaction_summary": "{{
|
|
941
|
+
"transaction_summary": "{{first_item.name}}",
|
|
942
|
+
"transaction_summary_plural": "{{first_item.name}} 和 {{count_minus_one}} 更多的",
|
|
942
943
|
"fees_hint": "公司",
|
|
943
944
|
"fees_explainer": "税费、运费和折扣可能会改变收费金额。",
|
|
944
945
|
"twice_a_month": "每月两次",
|
|
@@ -1090,8 +1091,8 @@
|
|
|
1090
1091
|
"status_refunded": "已退款",
|
|
1091
1092
|
"status_voided": "作废",
|
|
1092
1093
|
"status_verified": "已验证",
|
|
1093
|
-
"summary": "{{
|
|
1094
|
-
"summary_plural": "{{
|
|
1094
|
+
"summary": "{{first_item.name}}",
|
|
1095
|
+
"summary_plural": "{{first_item.name}} 和 {{count_minus_one}} 更多的",
|
|
1095
1096
|
"summary_payment_method_change": "付款方式变更",
|
|
1096
1097
|
"summary_subscription_modification": "订阅修改",
|
|
1097
1098
|
"summary_subscription_cancellation": "取消订阅",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"status_next_payment": "Next payment on {{ next_transaction_date, date }}",
|
|
23
23
|
"status_next_payment_no_nextdate": "Active",
|
|
24
24
|
"status_inactive": "Inactive",
|
|
25
|
-
"transaction_summary": "{{
|
|
25
|
+
"transaction_summary": "{{first_item.name}}",
|
|
26
|
+
"transaction_summary_plural": "{{first_item.name}} and {{ count_minus_one }} more",
|
|
26
27
|
"fees_hint": "inc. shipping, taxes, etc.",
|
|
27
28
|
"fees_explainer": "Taxes, shipping, and discounts may change the amount charged.",
|
|
28
29
|
"twice_a_month": "Twice a month",
|
|
@@ -202,8 +202,8 @@
|
|
|
202
202
|
"status_refunded": "Refunded",
|
|
203
203
|
"status_voided": "Voided",
|
|
204
204
|
"status_verified": "Verified",
|
|
205
|
-
"summary": "{{
|
|
206
|
-
"summary_plural": "{{
|
|
205
|
+
"summary": "{{first_item.name}}",
|
|
206
|
+
"summary_plural": "{{first_item.name}} and {{count_minus_one}} more",
|
|
207
207
|
"summary_payment_method_change": "Payment method change",
|
|
208
208
|
"summary_subscription_modification": "Subscription modification",
|
|
209
209
|
"summary_subscription_cancellation": "Subscription cancellation",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"status_ended": "Ended on {{ end_date, date }}",
|
|
15
15
|
"status_next_payment": "Next payment on {{ next_transaction_date, date }}",
|
|
16
16
|
"status_inactive": "Inactive",
|
|
17
|
-
"transaction_summary": "{{
|
|
17
|
+
"transaction_summary": "{{first_item.name}}",
|
|
18
|
+
"transaction_summary_plural": "{{first_item.name}} and {{ count_minus_one }} more",
|
|
18
19
|
"twice_a_month": "Twice a month",
|
|
19
20
|
"update": "Update",
|
|
20
21
|
"weekly": "Weekly",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"status_refunded": "Refunded",
|
|
21
21
|
"status_voided": "Voided",
|
|
22
22
|
"status_verified": "Verified",
|
|
23
|
-
"summary": "{{
|
|
24
|
-
"summary_plural": "{{
|
|
23
|
+
"summary": "{{first_item.name}}",
|
|
24
|
+
"summary_plural": "{{first_item.name}} and {{count_minus_one}} more",
|
|
25
25
|
"summary_payment_method_change": "Payment method change",
|
|
26
26
|
"summary_subscription_modification": "Subscription modification",
|
|
27
27
|
"summary_subscription_cancellation": "Subscription cancellation",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"transaction_pending": "Pending",
|
|
11
11
|
"transaction_refunded": "Refunded",
|
|
12
12
|
"transaction_rejected": "Rejected",
|
|
13
|
-
"transaction_summary": "{{
|
|
14
|
-
"transaction_summary_plural": "{{
|
|
13
|
+
"transaction_summary": "{{first_item.name}}",
|
|
14
|
+
"transaction_summary_plural": "{{first_item.name}} and {{count_minus_one}} more",
|
|
15
15
|
"transaction_verified": "Verified",
|
|
16
16
|
"transaction_voided": "Voided",
|
|
17
17
|
"spinner": {
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
"loading_empty": "No data",
|
|
21
21
|
"loading_error": "Unknown error"
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|
|
@@ -356,13 +356,13 @@ export class Donation extends Translatable {
|
|
|
356
356
|
`;
|
|
357
357
|
}
|
|
358
358
|
connectedCallback() {
|
|
359
|
-
var _a;
|
|
359
|
+
var _a, _b;
|
|
360
360
|
super.connectedCallback();
|
|
361
|
-
if (!((_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings.session_id) && this.__fcSessionPollInterval === null) {
|
|
361
|
+
if (!((_b = (_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.session_id) && this.__fcSessionPollInterval === null) {
|
|
362
362
|
this.__fcSessionPollInterval = window.setInterval(() => {
|
|
363
|
-
var _a, _b;
|
|
364
|
-
if ((_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings.session_id) {
|
|
365
|
-
clearInterval((
|
|
363
|
+
var _a, _b, _c;
|
|
364
|
+
if ((_b = (_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.session_id) {
|
|
365
|
+
clearInterval((_c = this.__fcSessionPollInterval) !== null && _c !== void 0 ? _c : void 0);
|
|
366
366
|
this.requestUpdate();
|
|
367
367
|
}
|
|
368
368
|
}, 1000);
|
|
@@ -377,6 +377,7 @@ export class Donation extends Translatable {
|
|
|
377
377
|
this.dispatchEvent(new DonationChangeEvent(this.__data));
|
|
378
378
|
}
|
|
379
379
|
get __data() {
|
|
380
|
+
var _a, _b;
|
|
380
381
|
const data = new FormData();
|
|
381
382
|
if (typeof this.designation === 'string') {
|
|
382
383
|
data.set('Designation', this.designation.trim());
|
|
@@ -402,8 +403,9 @@ export class Donation extends Translatable {
|
|
|
402
403
|
data.set('empty', this.empty);
|
|
403
404
|
if (this.anonymous)
|
|
404
405
|
data.set('Anonymous', 'true');
|
|
405
|
-
if (window.FC)
|
|
406
|
+
if (((_b = (_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.session_id) && window.FC.settings.session_name) {
|
|
406
407
|
data.set(window.FC.settings.session_name, window.FC.settings.session_id);
|
|
408
|
+
}
|
|
407
409
|
data.set('quantity', '1');
|
|
408
410
|
return data;
|
|
409
411
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Donation.js","sourceRoot":"","sources":["../../../../src/elements/public/Donation/Donation.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4CAA4C,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,wCAAqC;AAC5D,OAAO,EAAE,aAAa,EAAE,yCAAsC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,+BAA4B;AAC3F,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAk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,CAAC;IACjD,CAAC;IAEO,oBAAoB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,SAAS,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAE1D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE;YAC1B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;YAChC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE;YACtC,qBAAqB,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAS;YACxB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport '@vaadin/vaadin-button';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { PropertyDeclarations } from 'lit-element';\nimport { html, TemplateResult } from 'lit-html';\nimport { Translatable } from '../../../mixins/translatable';\nimport { parseDuration } from '../../../utils/parse-duration';\nimport { CheckboxChangeEvent, ChoiceChangeEvent, DropdownChangeEvent } from '../../private/events';\nimport { Checkbox, Choice, Dropdown, ErrorScreen, Group, I18N } from '../../private/index';\nimport { DonationChangeEvent } from './DonationChangeEvent';\nimport { DonationSubmitEvent } from './DonationSubmitEvent';\n\ndeclare global {\n interface Window {\n FC?: {\n settings: {\n session_name: string;\n session_id: string;\n };\n };\n }\n}\n\ninterface DonationEventsMap {\n change: typeof DonationChangeEvent;\n submit: typeof DonationSubmitEvent;\n}\n\n/**\n * A custom element providing customizable donation forms.\n *\n * @fires Donation#change - Instance of `Donation.events.change`. Emitted after user input triggers a change in the form data.\n * @fires Donation#submit - Instance of `Donation.events.submit`. Emitted when the form is submitted. Cancelling this event will stop the submission.\n *\n * @slot amount - Space below the amount selector, if it's visible.\n * @slot designation - Space below the designation selector, if it's visible.\n * @slot comment - Space below the comment field, if it's visible.\n *\n * @element foxy-donation\n * @since 0.3.0\n */\nexport class Donation extends Translatable {\n /** @readonly */\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-error-screen': ErrorScreen,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-dropdown': Dropdown,\n 'x-checkbox': Checkbox,\n 'x-choice': Choice,\n 'x-group': Group,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n currency: { type: String },\n custom: { type: Array },\n amount: { type: Number },\n amounts: { type: Array },\n frequency: { type: String },\n frequencies: { type: Array },\n designation: { type: Array },\n designations: { type: Array },\n comment: { type: String },\n anonymity: { reflect: true, type: Boolean },\n anonymous: { reflect: true, type: Boolean },\n image: { type: String },\n store: { type: String },\n name: { type: String },\n code: { type: String },\n url: { type: String },\n cart: { type: String },\n target: { type: String },\n empty: { type: String },\n };\n }\n\n /** @readonly */\n public static get events(): DonationEventsMap {\n return {\n change: DonationChangeEvent,\n submit: DonationSubmitEvent,\n };\n }\n\n /**\n * **Required** 3-letter lowercase currency code.\n *\n * **Example:** `\"usd\"`\n */\n public currency: null | string = null;\n\n /**\n * **Required** donation amount in specified currency. When more than one amount option\n * is available, this field will contain the selected amount. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `25`\n */\n public amount: null | number = null;\n\n /**\n * **Required** store domain. This is usually the part after before `.foxycart.com`\n * and after `https://`, e.g. the `foxy-demo` bit of `https://foxy-demo.foxycart.com`.\n * Custom domains like `my.domain.example.com` are also supported since v1.6.1.\n *\n * **Example:** `\"foxy-demo\"`\n */\n public store: null | string = null;\n\n /**\n * **Required** product name for this donation. This will show up in the cart when this form is submitted.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"One-time donation\"`\n */\n public name: null | string = null;\n\n /**\n * Optional parts of the form including a custom (\"other\") option.\n * Adding `amount` to this array will enable custom amount.\n *\n * **Example:** `[\"amount\"]`\n */\n public custom: null | 'amount'[] = null;\n\n /**\n * Optional donation amount variants. If this property is set, the form will render\n * the amount selection interface. If this array includes the value of the `amount` property,\n * it will be pre-selected in the form.\n *\n * **Example:** `[25, 50, 75]`\n */\n public amounts: null | number[] = null;\n\n /**\n * Optional donation frequency string encoded as count (integer) + units (one\n * of: `d` for days, `w` for weeks, `m` for months, `y` for years). A special\n * value for twice a month is also supported: `.5m`. If set, the form will\n * create a subscription with the specified frequency in the cart. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `\"1m\"`\n */\n public frequency: null | string = null;\n\n /**\n * Optional donation frequency variants in the same format as `frequency`. If this property is set,\n * the form will render the frequency selection interface. If this array includes\n * the value of the `frequency` property, it will be pre-selected in the form.\n *\n * **Example:** `[\"7d\", \".5m\", \"1y\"]`\n */\n public frequencies: null | string[] = null;\n\n /**\n * Optional donation designation(s). The form will serialize and pass this value to the cart\n * on submission. This value is deliberately not limited to the predefined options:\n * whatever you set it to will show up in the cart.\n *\n * **Example:** `\"Medical Care\"`\n * **Example:** `[\"Medical Care\", \"Daily Meals\"]`\n */\n public designation: null | string = null;\n\n /**\n * Optional donation designation(s) variants. If this property is set,\n * the form will render the designation selection interface: multiple choice\n * if `designation` is an array and a single choice otherwise. All values overlapping\n * with the `designation` property will be pre-selected in the form.\n *\n * **Example:** `[\"Medical Care\", \"Daily Meals\", \"Area of Greatest Need\"]`\n */\n public designations: null | string[] = null;\n\n /**\n * Optional comment accompanying the donation. If set (even to an empty string),\n * the form will render a comment field. The value of this property will be updated\n * as the customer enters their message and will be added to the order as a custom field in the end.\n *\n * **Example:** `\"\"`\n */\n public comment: null | string = null;\n\n /**\n * Optional switch controlling visibility of the anonymity checkbox. If set to `true`, the form\n * will render the checkbox. All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymity = false;\n\n /**\n * Optional switch marking this donation as anonymous via a custom field when set to `true`. When\n * the anonymity checkbox is rendered, also checks or unchecks it depending on the value.\n * All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymous = false;\n\n /**\n * Optional product image URL (absolute path). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://picsum.photos/320\"`\n */\n public image: null | string = null;\n\n /**\n * Optional product code for this donation. This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public code: null | string = null;\n\n /**\n * Optional product URL for this donation. Accepts a full URL to the product page, starting\n * with `http://` or `https://`, or a relative path to the produt from the store's\n * domain (as configured in the store settings). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://example.com/my-product\"`\n */\n public url: null | string = null;\n\n /**\n * Optional cart\n * If set to 'add' will add items to the cart and, on submit, user is redirected to the cart.\n * If set to 'checkout', the default, on submit user is redirected to checkout directly\n */\n public cart = 'checkout';\n\n /**\n * Optional empty\n * If set to 'true' clears the contents of the cart prior to adding the donation to the cart\n * If set to 'reset' clears the contents of the cart and cookies prior to adding the donation to the cart\n */\n public empty?: string;\n\n /**\n * Optional target to display the form response.\n */\n public target = '_top';\n\n private __fcSessionPollInterval: number | null = null;\n\n public constructor() {\n super('donation');\n }\n\n /** Submits the form, emitting a cancelable `submit` event. */\n public submit(): void {\n /* istanbul ignore if */\n if (this.dispatchEvent(new DonationSubmitEvent())) this.__form.submit();\n }\n\n public render(): TemplateResult {\n if (!this.currency || !this.amount || !this.store || !this.name) {\n return html`\n <x-error-screen data-testid=\"error\" type=\"setup_needed\" class=\"relative\"></x-error-screen>\n `;\n }\n\n const domain = this.store.includes('.') ? this.store : `${this.store}.foxycart.com`;\n\n return html`\n <form\n target=\"${this.target}\"\n class=\"sr-only\"\n method=\"POST\"\n action=\"https://${domain}/cart\"\n data-testid=\"form\"\n >\n ${[...this.__data.entries()].map(\n ([name, value]) => html`<input type=\"hidden\" name=${name} value=${value} />`\n )}\n </form>\n\n <section>\n ${this.amounts && this.amounts.length > 0\n ? html`\n <x-group frame>\n <x-i18n ns=${this.ns} lang=${this.lang} key=\"amount\" slot=\"header\"></x-i18n>\n <x-choice\n ?custom=${!!this.custom?.includes('amount')}\n .getText=${(v: string) => this.__translateAmount(parseFloat(v))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"number\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseFloat(evt.detail as string);\n this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;\n }}\n >\n </x-choice>\n </x-group>\n\n <slot name=\"amount\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.designations && this.designations.length > 0\n ? html`\n <x-dropdown\n .label=${this._t('designation').toString()}\n .items=${this.designations}\n .value=${Array.isArray(this.designation)\n ? '${this.designation[0]}: ${this.designation[1]}'\n : this.designation}\n data-testid=\"designation\"\n @change=${(evt: DropdownChangeEvent) => {\n this.designation = evt.detail as string;\n }}\n >\n </x-dropdown>\n\n <slot name=\"designation\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${typeof this.comment === 'string'\n ? html`\n <vaadin-text-area\n placeholder=${this._t('comment_placeholder').toString()}\n value=${this.comment!}\n label=${this._t('comment_label').toString()}\n class=\"w-full\"\n data-testid=\"comment\"\n @input=${(evt: InputEvent) => {\n evt.stopPropagation();\n this.comment = (evt.target as HTMLTextAreaElement).value;\n }}\n >\n </vaadin-text-area>\n\n <slot name=\"comment\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.anonymity\n ? html`\n <x-checkbox\n class=\"my-m\"\n data-testid=\"anonymity\"\n ?checked=${this.anonymous}\n @change=${(evt: CheckboxChangeEvent) => (this.anonymous = evt.detail)}\n >\n ${this._t('anonymous')}\n </x-checkbox>\n `\n : ''}\n\n <div class=\"flex flex-wrap -m-s\">\n ${this.frequencies && this.frequencies.length > 0\n ? html`\n <div class=\"flex-1 p-s\">\n <x-dropdown\n .value=${this.frequency}\n .items=${this.frequencies}\n .getText=${this.__translateFrequency.bind(this)}\n data-testid=\"frequency\"\n @change=${(evt: DropdownChangeEvent) => {\n this.frequency = evt.detail as string;\n }}\n >\n </x-dropdown>\n </div>\n `\n : ''}\n\n <div class=\"flex-1 p-s\">\n <vaadin-button\n class=\"w-full\"\n theme=\"primary\"\n data-testid=\"submit\"\n @click=${() => this.submit()}\n >\n <x-i18n\n .opts=${{\n amount: this.__translateAmount(this.amount),\n frequency: this.frequency ? this.__translateFrequency(this.frequency) : '',\n }}\n lang=${this.lang}\n key=${this.frequency && !this.frequencies?.length ? 'donate_recurrently' : 'donate'}\n ns=${this.ns}\n >\n </x-i18n>\n </vaadin-button>\n </div>\n </div>\n </section>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n if (!window.FC?.settings.session_id && this.__fcSessionPollInterval === null) {\n this.__fcSessionPollInterval = window.setInterval(() => {\n if (window.FC?.settings.session_id) {\n clearInterval(this.__fcSessionPollInterval ?? void 0);\n this.requestUpdate();\n }\n }, 1000);\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n clearInterval(this.__fcSessionPollInterval ?? void 0);\n }\n\n public updated(): void {\n this.dispatchEvent(new DonationChangeEvent(this.__data));\n }\n\n private get __data() {\n const data = new FormData();\n\n if (typeof this.designation === 'string') {\n data.set('Designation', this.designation.trim());\n }\n\n if (typeof this.amount === 'number' && typeof this.currency === 'string') {\n data.set('price', `${this.amount.toFixed(2)}${this.currency}`);\n }\n\n if (this.frequency) data.set('sub_frequency', this.frequency);\n if (typeof this.comment === 'string') data.set('Comment', this.comment.trim());\n if (typeof this.image === 'string') data.set('image', this.image);\n if (typeof this.code === 'string') data.set('code', this.code);\n if (typeof this.name === 'string') data.set('name', this.name.trim());\n if (typeof this.url === 'string') data.set('url', this.url);\n if (typeof this.cart === 'string') data.set('cart', this.cart);\n if (this.empty) data.set('empty', this.empty);\n if (this.anonymous) data.set('Anonymous', 'true');\n if (window.FC) data.set(window.FC.settings.session_name, window.FC.settings.session_id);\n\n data.set('quantity', '1');\n\n return data;\n }\n\n private get __form(): HTMLFormElement {\n return this.shadowRoot!.querySelector('form')!;\n }\n\n private __translateFrequency(frequency: string) {\n if (!frequency || frequency.match(/^\\s*$/)) return this._t('frequency_once');\n if (frequency === '.5m') return this._t('frequency_0_5m');\n\n const { count, units } = parseDuration(frequency);\n return this._t('frequency', {\n units: this._t(units, { count }),\n count,\n });\n }\n\n private __translateAmount(amount: number) {\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 0,\n currency: this.currency!,\n style: 'currency',\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Donation.js","sourceRoot":"","sources":["../../../../src/elements/public/Donation/Donation.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4CAA4C,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,wCAAqC;AAC5D,OAAO,EAAE,aAAa,EAAE,yCAAsC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,+BAA4B;AAC3F,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAkB5D;;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,CAAC;IACd,CAAC;IAED,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,UAAW,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC;IACjD,CAAC;IAEO,oBAAoB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,SAAS,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAE1D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE;YAC1B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;YAChC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE;YACtC,qBAAqB,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAS;YACxB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport '@vaadin/vaadin-button';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { PropertyDeclarations } from 'lit-element';\nimport { html, TemplateResult } from 'lit-html';\nimport { Translatable } from '../../../mixins/translatable';\nimport { parseDuration } from '../../../utils/parse-duration';\nimport { CheckboxChangeEvent, ChoiceChangeEvent, DropdownChangeEvent } from '../../private/events';\nimport { Checkbox, Choice, Dropdown, ErrorScreen, Group, I18N } from '../../private/index';\nimport { DonationChangeEvent } from './DonationChangeEvent';\nimport { DonationSubmitEvent } from './DonationSubmitEvent';\n\ndeclare global {\n interface Window {\n FC?: {\n settings?: {\n session_name: string;\n session_id: string;\n };\n };\n }\n}\n\ninterface DonationEventsMap {\n change: typeof DonationChangeEvent;\n submit: typeof DonationSubmitEvent;\n}\n\n/**\n * A custom element providing customizable donation forms.\n *\n * @fires Donation#change - Instance of `Donation.events.change`. Emitted after user input triggers a change in the form data.\n * @fires Donation#submit - Instance of `Donation.events.submit`. Emitted when the form is submitted. Cancelling this event will stop the submission.\n *\n * @slot amount - Space below the amount selector, if it's visible.\n * @slot designation - Space below the designation selector, if it's visible.\n * @slot comment - Space below the comment field, if it's visible.\n *\n * @element foxy-donation\n * @since 0.3.0\n */\nexport class Donation extends Translatable {\n /** @readonly */\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-error-screen': ErrorScreen,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-dropdown': Dropdown,\n 'x-checkbox': Checkbox,\n 'x-choice': Choice,\n 'x-group': Group,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n currency: { type: String },\n custom: { type: Array },\n amount: { type: Number },\n amounts: { type: Array },\n frequency: { type: String },\n frequencies: { type: Array },\n designation: { type: Array },\n designations: { type: Array },\n comment: { type: String },\n anonymity: { reflect: true, type: Boolean },\n anonymous: { reflect: true, type: Boolean },\n image: { type: String },\n store: { type: String },\n name: { type: String },\n code: { type: String },\n url: { type: String },\n cart: { type: String },\n target: { type: String },\n empty: { type: String },\n };\n }\n\n /** @readonly */\n public static get events(): DonationEventsMap {\n return {\n change: DonationChangeEvent,\n submit: DonationSubmitEvent,\n };\n }\n\n /**\n * **Required** 3-letter lowercase currency code.\n *\n * **Example:** `\"usd\"`\n */\n public currency: null | string = null;\n\n /**\n * **Required** donation amount in specified currency. When more than one amount option\n * is available, this field will contain the selected amount. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `25`\n */\n public amount: null | number = null;\n\n /**\n * **Required** store domain. This is usually the part after before `.foxycart.com`\n * and after `https://`, e.g. the `foxy-demo` bit of `https://foxy-demo.foxycart.com`.\n * Custom domains like `my.domain.example.com` are also supported since v1.6.1.\n *\n * **Example:** `\"foxy-demo\"`\n */\n public store: null | string = null;\n\n /**\n * **Required** product name for this donation. This will show up in the cart when this form is submitted.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"One-time donation\"`\n */\n public name: null | string = null;\n\n /**\n * Optional parts of the form including a custom (\"other\") option.\n * Adding `amount` to this array will enable custom amount.\n *\n * **Example:** `[\"amount\"]`\n */\n public custom: null | 'amount'[] = null;\n\n /**\n * Optional donation amount variants. If this property is set, the form will render\n * the amount selection interface. If this array includes the value of the `amount` property,\n * it will be pre-selected in the form.\n *\n * **Example:** `[25, 50, 75]`\n */\n public amounts: null | number[] = null;\n\n /**\n * Optional donation frequency string encoded as count (integer) + units (one\n * of: `d` for days, `w` for weeks, `m` for months, `y` for years). A special\n * value for twice a month is also supported: `.5m`. If set, the form will\n * create a subscription with the specified frequency in the cart. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `\"1m\"`\n */\n public frequency: null | string = null;\n\n /**\n * Optional donation frequency variants in the same format as `frequency`. If this property is set,\n * the form will render the frequency selection interface. If this array includes\n * the value of the `frequency` property, it will be pre-selected in the form.\n *\n * **Example:** `[\"7d\", \".5m\", \"1y\"]`\n */\n public frequencies: null | string[] = null;\n\n /**\n * Optional donation designation(s). The form will serialize and pass this value to the cart\n * on submission. This value is deliberately not limited to the predefined options:\n * whatever you set it to will show up in the cart.\n *\n * **Example:** `\"Medical Care\"`\n * **Example:** `[\"Medical Care\", \"Daily Meals\"]`\n */\n public designation: null | string = null;\n\n /**\n * Optional donation designation(s) variants. If this property is set,\n * the form will render the designation selection interface: multiple choice\n * if `designation` is an array and a single choice otherwise. All values overlapping\n * with the `designation` property will be pre-selected in the form.\n *\n * **Example:** `[\"Medical Care\", \"Daily Meals\", \"Area of Greatest Need\"]`\n */\n public designations: null | string[] = null;\n\n /**\n * Optional comment accompanying the donation. If set (even to an empty string),\n * the form will render a comment field. The value of this property will be updated\n * as the customer enters their message and will be added to the order as a custom field in the end.\n *\n * **Example:** `\"\"`\n */\n public comment: null | string = null;\n\n /**\n * Optional switch controlling visibility of the anonymity checkbox. If set to `true`, the form\n * will render the checkbox. All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymity = false;\n\n /**\n * Optional switch marking this donation as anonymous via a custom field when set to `true`. When\n * the anonymity checkbox is rendered, also checks or unchecks it depending on the value.\n * All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymous = false;\n\n /**\n * Optional product image URL (absolute path). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://picsum.photos/320\"`\n */\n public image: null | string = null;\n\n /**\n * Optional product code for this donation. This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public code: null | string = null;\n\n /**\n * Optional product URL for this donation. Accepts a full URL to the product page, starting\n * with `http://` or `https://`, or a relative path to the produt from the store's\n * domain (as configured in the store settings). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://example.com/my-product\"`\n */\n public url: null | string = null;\n\n /**\n * Optional cart\n * If set to 'add' will add items to the cart and, on submit, user is redirected to the cart.\n * If set to 'checkout', the default, on submit user is redirected to checkout directly\n */\n public cart = 'checkout';\n\n /**\n * Optional empty\n * If set to 'true' clears the contents of the cart prior to adding the donation to the cart\n * If set to 'reset' clears the contents of the cart and cookies prior to adding the donation to the cart\n */\n public empty?: string;\n\n /**\n * Optional target to display the form response.\n */\n public target = '_top';\n\n private __fcSessionPollInterval: number | null = null;\n\n public constructor() {\n super('donation');\n }\n\n /** Submits the form, emitting a cancelable `submit` event. */\n public submit(): void {\n /* istanbul ignore if */\n if (this.dispatchEvent(new DonationSubmitEvent())) this.__form.submit();\n }\n\n public render(): TemplateResult {\n if (!this.currency || !this.amount || !this.store || !this.name) {\n return html`\n <x-error-screen data-testid=\"error\" type=\"setup_needed\" class=\"relative\"></x-error-screen>\n `;\n }\n\n const domain = this.store.includes('.') ? this.store : `${this.store}.foxycart.com`;\n\n return html`\n <form\n target=\"${this.target}\"\n class=\"sr-only\"\n method=\"POST\"\n action=\"https://${domain}/cart\"\n data-testid=\"form\"\n >\n ${[...this.__data.entries()].map(\n ([name, value]) => html`<input type=\"hidden\" name=${name} value=${value} />`\n )}\n </form>\n\n <section>\n ${this.amounts && this.amounts.length > 0\n ? html`\n <x-group frame>\n <x-i18n ns=${this.ns} lang=${this.lang} key=\"amount\" slot=\"header\"></x-i18n>\n <x-choice\n ?custom=${!!this.custom?.includes('amount')}\n .getText=${(v: string) => this.__translateAmount(parseFloat(v))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"number\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseFloat(evt.detail as string);\n this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;\n }}\n >\n </x-choice>\n </x-group>\n\n <slot name=\"amount\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.designations && this.designations.length > 0\n ? html`\n <x-dropdown\n .label=${this._t('designation').toString()}\n .items=${this.designations}\n .value=${Array.isArray(this.designation)\n ? '${this.designation[0]}: ${this.designation[1]}'\n : this.designation}\n data-testid=\"designation\"\n @change=${(evt: DropdownChangeEvent) => {\n this.designation = evt.detail as string;\n }}\n >\n </x-dropdown>\n\n <slot name=\"designation\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${typeof this.comment === 'string'\n ? html`\n <vaadin-text-area\n placeholder=${this._t('comment_placeholder').toString()}\n value=${this.comment!}\n label=${this._t('comment_label').toString()}\n class=\"w-full\"\n data-testid=\"comment\"\n @input=${(evt: InputEvent) => {\n evt.stopPropagation();\n this.comment = (evt.target as HTMLTextAreaElement).value;\n }}\n >\n </vaadin-text-area>\n\n <slot name=\"comment\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.anonymity\n ? html`\n <x-checkbox\n class=\"my-m\"\n data-testid=\"anonymity\"\n ?checked=${this.anonymous}\n @change=${(evt: CheckboxChangeEvent) => (this.anonymous = evt.detail)}\n >\n ${this._t('anonymous')}\n </x-checkbox>\n `\n : ''}\n\n <div class=\"flex flex-wrap -m-s\">\n ${this.frequencies && this.frequencies.length > 0\n ? html`\n <div class=\"flex-1 p-s\">\n <x-dropdown\n .value=${this.frequency}\n .items=${this.frequencies}\n .getText=${this.__translateFrequency.bind(this)}\n data-testid=\"frequency\"\n @change=${(evt: DropdownChangeEvent) => {\n this.frequency = evt.detail as string;\n }}\n >\n </x-dropdown>\n </div>\n `\n : ''}\n\n <div class=\"flex-1 p-s\">\n <vaadin-button\n class=\"w-full\"\n theme=\"primary\"\n data-testid=\"submit\"\n @click=${() => this.submit()}\n >\n <x-i18n\n .opts=${{\n amount: this.__translateAmount(this.amount),\n frequency: this.frequency ? this.__translateFrequency(this.frequency) : '',\n }}\n lang=${this.lang}\n key=${this.frequency && !this.frequencies?.length ? 'donate_recurrently' : 'donate'}\n ns=${this.ns}\n >\n </x-i18n>\n </vaadin-button>\n </div>\n </div>\n </section>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n if (!window.FC?.settings?.session_id && this.__fcSessionPollInterval === null) {\n this.__fcSessionPollInterval = window.setInterval(() => {\n if (window.FC?.settings?.session_id) {\n clearInterval(this.__fcSessionPollInterval ?? void 0);\n this.requestUpdate();\n }\n }, 1000);\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n clearInterval(this.__fcSessionPollInterval ?? void 0);\n }\n\n public updated(): void {\n this.dispatchEvent(new DonationChangeEvent(this.__data));\n }\n\n private get __data() {\n const data = new FormData();\n\n if (typeof this.designation === 'string') {\n data.set('Designation', this.designation.trim());\n }\n\n if (typeof this.amount === 'number' && typeof this.currency === 'string') {\n data.set('price', `${this.amount.toFixed(2)}${this.currency}`);\n }\n\n if (this.frequency) data.set('sub_frequency', this.frequency);\n if (typeof this.comment === 'string') data.set('Comment', this.comment.trim());\n if (typeof this.image === 'string') data.set('image', this.image);\n if (typeof this.code === 'string') data.set('code', this.code);\n if (typeof this.name === 'string') data.set('name', this.name.trim());\n if (typeof this.url === 'string') data.set('url', this.url);\n if (typeof this.cart === 'string') data.set('cart', this.cart);\n if (this.empty) data.set('empty', this.empty);\n if (this.anonymous) data.set('Anonymous', 'true');\n\n if (window.FC?.settings?.session_id && window.FC.settings.session_name) {\n data.set(window.FC.settings.session_name, window.FC.settings.session_id);\n }\n\n data.set('quantity', '1');\n\n return data;\n }\n\n private get __form(): HTMLFormElement {\n return this.shadowRoot!.querySelector('form')!;\n }\n\n private __translateFrequency(frequency: string) {\n if (!frequency || frequency.match(/^\\s*$/)) return this._t('frequency_once');\n if (frequency === '.5m') return this._t('frequency_0_5m');\n\n const { count, units } = parseDuration(frequency);\n return this._t('frequency', {\n units: this._t(units, { count }),\n count,\n });\n }\n\n private __translateAmount(amount: number) {\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 0,\n currency: this.currency!,\n style: 'currency',\n });\n }\n}\n"]}
|
|
@@ -141,8 +141,8 @@ export class SubscriptionCard extends Base {
|
|
|
141
141
|
return {};
|
|
142
142
|
const items = this.data._embedded['fx:transaction_template']._embedded['fx:items'];
|
|
143
143
|
return {
|
|
144
|
-
most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],
|
|
145
144
|
count_minus_one: items.length - 1,
|
|
145
|
+
first_item: items[0],
|
|
146
146
|
count: items.length,
|
|
147
147
|
};
|
|
148
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subscript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AAI;kBACV,IAAI,CAAC,EAAE,IAAI,YAAA,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,0CAAE,SAAS,mCAAI,EAAE;;;;;;QAMxE,IAAI,CAAC,oBAAoB,EAAE;KAC9B,CAAC;IACJ,CAAC;IAEO,mBAAmB;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAEnF,OAAO;YACL,eAAe,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;YACjC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;YACpB,KAAK,EAAE,KAAK,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;IAEO,iBAAiB;QACvB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAElC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3D,OAAO,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5D,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { Data, Settings } from './types';\n\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { parseFrequency } from '../../../utils/parse-frequency';\n\nimport {\n getExtendedSubscriptionStatus,\n getSubscriptionStatus,\n} from '../../../utils/get-subscription-status';\n\nconst NS = 'subscription-card';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Card element displaying subscription summary.\n *\n * @element foxy-subscription-card\n * @since 1.4.0\n */\nexport class SubscriptionCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n settings: { type: Object },\n };\n }\n\n settings: Settings | null = null;\n\n render(): TemplateResult {\n const status = this.settings\n ? getExtendedSubscriptionStatus(this.data, this.settings)\n : getSubscriptionStatus(this.data);\n\n const isRed = status === 'failed';\n const isGreen = status?.startsWith('next_payment') || !!status?.startsWith('will_end');\n const isNormal = !isGreen && !isRed;\n\n return html`\n <div class=\"relative text-left\">\n <div\n class=${classMap({\n 'flex items-start sm-items-center space-x-m transition duration-150 ease-in-out': true,\n 'opacity-0': !this.in({ idle: 'snapshot' }),\n })}\n >\n <div\n class=${classMap({\n 'min-w-0 flex-shrink-0 rounded-full relative flex p-s': true,\n 'text-success bg-success-10': isGreen,\n 'text-body bg-contrast-5': isNormal,\n 'text-error bg-error-10': isRed,\n })}\n >\n <iron-icon\n class=\"m-auto\"\n icon=${isRed ? 'error-outline' : isGreen ? 'done' : 'done-all'}\n >\n </iron-icon>\n </div>\n\n <div class=\"flex-1 min-w-0 leading-xs flex flex-col sm-flex-row sm-items-center\">\n <div class=\"order-1 sm-order-0\">\n <div class=\"text-body font-medium origin-top-left text-m\">\n <foxy-i18n\n data-testid=\"summary\"\n options=${JSON.stringify(this.__getSummaryOptions())}\n lang=${this.lang}\n key=\"transaction_summary\"\n ns=${this.ns}\n >\n </foxy-i18n>\n ​\n </div>\n\n <div\n class=${classMap({\n 'text-m': true,\n 'text-tertiary': isNormal,\n 'text-success': isGreen,\n 'text-error': isRed,\n })}\n >\n <foxy-i18n\n data-testid=\"status\"\n lang=${this.lang}\n key=\"status_${status}\"\n ns=${this.ns}\n .options=${this.data}\n >\n </foxy-i18n>\n ​\n </div>\n </div>\n\n <div\n class=\"flex-1 leading-xs mb-xs sm-mb-0 sm-text-right order-0 sm-order-1\"\n >\n <foxy-i18n\n data-testid=\"price\"\n options=${JSON.stringify(this.__getPriceOptions())}\n class=\"text-xxs sm-text-l font-tnum tracking-wide sm-tracking-normal uppercase sm-normal-case font-medium text-secondary sm-text-body sm-block\"\n lang=${this.lang}\n key=\"price${\n this.settings?.cart_display_config.show_sub_frequency ?? true\n ? `_${this.data?.frequency === '.5m' ? 'twice_a_month' : 'recurring'}`\n : ''\n }\"\n ns=${this.ns}\n >\n </foxy-i18n>\n <span class=\"text-secondary font-medium sm-font-normal sm-block text-xxs sm-text-s\">\n <span class=\"sm-hidden\">(</span><span class=\"hidden sm-inline\">*</span><foxy-i18n infer=\"\" key=\"fees_hint\"></foxy-i18n><span class=\"sm-hidden\">)</span>\n <iron-icon id=\"hint\" icon=\"icons:info-outline\" class=\"icon-inline\"></iron-icon>\n <vcf-tooltip for=\"hint\" position=\"bottom\">\n <span class=\"text-s\"><foxy-i18n infer=\"\" key=\"fees_explainer\"></foxy-i18n></span>\n </vcf-tooltip>\n <span>\n ​\n </div>\n </div>\n </div>\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition ease-in-out duration-150': true,\n 'opacity-0': this.in({ idle: 'snapshot' }),\n })}\n >\n <foxy-spinner\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n\n ${this.renderTemplateOrSlot()}\n `;\n }\n\n private __getSummaryOptions() {\n if (this.data === null) return {};\n const items = this.data._embedded['fx:transaction_template']._embedded['fx:items'];\n\n return {\n count_minus_one: items.length - 1,\n first_item: items[0],\n count: items.length,\n };\n }\n\n private __getPriceOptions() {\n if (this.data === null) return {};\n\n const cart = this.data._embedded['fx:transaction_template'];\n const amount = `${cart.total_order} ${cart.currency_code}`;\n return { ...parseFrequency(this.data.frequency), amount };\n }\n}\n"]}
|
|
@@ -35,8 +35,8 @@ SubscriptionsTable.summaryColumn = {
|
|
|
35
35
|
cell: ctx => {
|
|
36
36
|
const items = ctx.data._embedded['fx:transaction_template']._embedded['fx:items'];
|
|
37
37
|
const options = {
|
|
38
|
-
most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],
|
|
39
38
|
count_minus_one: items.length - 1,
|
|
39
|
+
first_item: items[0],
|
|
40
40
|
count: items.length,
|
|
41
41
|
};
|
|
42
42
|
return ctx.html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionsTable.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionsTable/SubscriptionsTable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,0BAAuB;AACvC,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,qBAAqB,EAAE,kDAA+C;AAC/E,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,CAAO;IAA7F;;QA2FE,YAAO,GAAG;YACR,kBAAkB,CAAC,WAAW;YAC9B,kBAAkB,CAAC,aAAa;YAChC,kBAAkB,CAAC,YAAY;YAC/B,kBAAkB,CAAC,iBAAiB;SACrC,CAAC;IACJ,CAAC;;AAhGQ,8BAAW,GAAiB;IACjC,IAAI,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QAE3D,OAAO,GAAG,CAAC,IAAI,CAAA;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IAAI,CAAA;;;kBAGC,QAAQ,CAAC;YACf,sEAAsE,EAAE,IAAI;YAC5E,8BAA8B,EAAE,QAAQ;YACxC,4BAA4B,EAAE,OAAO;YACrC,wBAAwB,EAAE,KAAK;SAChC,CAAC;iBACK,IAAI;wBACG,MAAM;eACf,EAAE;qBACI,IAAI;;;OAGlB,CAAC;IACJ,CAAC;CACF,CAAC;AAEK,oCAAiB,GAAiB;IACvC,IAAI,EAAE,GAAG,CAAC,EAAE;QACV,OAAO,GAAG,CAAC,IAAI,CAAA;;;;;iBAKJ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI;;;;mBAItC,GAAG,CAAC,IAAI;;iBAEV,GAAG,CAAC,EAAE;;;;OAIhB,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { Column } from '../Table/types';\nimport { Data } from './types';\nimport { Table } from '../Table/Table';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { getSubscriptionStatus } from '../../../utils/get-subscription-status';\nimport { classMap } from '../../../utils/class-map';\n\nexport class SubscriptionsTable extends TranslatableMixin(Table, 'subscriptions-table')<Data> {\n static priceColumn: Column<Data> = {\n cell: ctx => {\n const cart = ctx.data._embedded['fx:transaction_template'];\n const amount = `${cart.total_order} ${cart.currency_code}`;\n\n return ctx.html`\n <foxy-i18n\n data-testclass=\"i18n frequencies\"\n class=\"font-medium text-m font-tnum\"\n lang=${ctx.lang}\n key=\"price_${ctx.data.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${ctx.ns}\n .options=${{ ...parseFrequency(ctx.data.frequency), amount }}\n >\n </foxy-i18n>\n `;\n },\n };\n\n static summaryColumn: Column<Data> = {\n cell: ctx => {\n const items = ctx.data._embedded['fx:transaction_template']._embedded['fx:items'];\n const options = {\n count_minus_one: items.length - 1,\n first_item: items[0],\n count: items.length,\n };\n\n return ctx.html`\n <foxy-i18n\n data-testclass=\"i18n summaries\"\n class=\"text-m\"\n lang=${ctx.lang}\n key=\"transaction_summary\"\n ns=${ctx.ns}\n .options=${options}\n >\n </foxy-i18n>\n `;\n },\n };\n\n static statusColumn: Column<Data> = {\n hideBelow: 'sm',\n cell: ({ ns, lang, data, html }) => {\n const status = getSubscriptionStatus(data);\n const isRed = status === 'failed';\n const isGreen = status === 'next_payment' || !!status?.startsWith('will_end');\n const isNormal = !isGreen && !isRed;\n\n return html`\n <foxy-i18n\n data-testclass=\"i18n statuses\"\n class=${classMap({\n 'px-s py-xs text-m font-medium inline-block whitespace-normal rounded': true,\n 'text-secondary bg-contrast-5': isNormal,\n 'text-success bg-success-10': isGreen,\n 'text-error bg-error-10': isRed,\n })}\n lang=${lang}\n key=\"status_${status}\"\n ns=${ns}\n .options=${data}\n >\n </foxy-i18n>\n `;\n },\n };\n\n static subTokenURLColumn: Column<Data> = {\n cell: ctx => {\n return ctx.html`\n <a\n data-testclass=\"links\"\n target=\"_blank\"\n class=\"text-m font-medium text-primary rounded hover-underline focus-outline-none focus-shadow-outline\"\n href=${ctx.data._links['fx:sub_token_url'].href}\n >\n <foxy-i18n\n data-testclass=\"i18n\"\n lang=${ctx.lang}\n key=\"update\"\n ns=${ctx.ns}\n >\n </foxy-i18n>\n </a>\n `;\n },\n };\n\n columns = [\n SubscriptionsTable.priceColumn,\n SubscriptionsTable.summaryColumn,\n SubscriptionsTable.statusColumn,\n SubscriptionsTable.subTokenURLColumn,\n ];\n}\n"]}
|
|
@@ -211,8 +211,8 @@ class TransactionCard extends Base {
|
|
|
211
211
|
}
|
|
212
212
|
if (items) {
|
|
213
213
|
const options = {
|
|
214
|
-
most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],
|
|
215
214
|
count_minus_one: items.length - 1,
|
|
215
|
+
first_item: items[0],
|
|
216
216
|
count: items.length,
|
|
217
217
|
};
|
|
218
218
|
content = html `<foxy-i18n .options=${options} infer="" key=${key}></foxy-i18n>`;
|
|
@@ -1 +1 @@
|
|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C,cAAc,GAAG;YACvF,CAAC,CAAC,IAAI,CAAA,kBAAkB,CAAC;QAE3B,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;qDACD,OAAO;UAClD,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC;;KAEhD,CAAC;IACJ,CAAC;CACF;AAED,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { Data } from './types';\nimport type { TemplateResult } from 'lit-html';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { Resource, getResourceId } from '@foxy.io/sdk/core';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nconst NS = 'transaction-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a transaction.\n *\n * @element foxy-transaction-card\n * @since 1.12.0\n */\nclass TransactionCard extends Base<Data> {\n private __currencyDisplay = '';\n\n renderBody(): TemplateResult {\n const hiddenSelector = this.hiddenSelector;\n const hasTotal = !hiddenSelector.matches('total', true);\n const hasStatus = !hiddenSelector.matches('status', true);\n\n return html`\n <div\n aria-busy=${this.in('busy')}\n aria-live=\"polite\"\n class=\"relative leading-s font-lumo text-m\"\n >\n <div class=${classMap({ 'transition-opacity': true, 'opacity-0': !this.data })}>\n ${hasTotal || hasStatus\n ? html`\n <div class=\"flex items-center justify-between gap-s\">\n ${hasTotal ? this.__renderIdAndTotal() : ''}\n ${hasStatus ? this.__renderStatus() : ''}\n </div>\n `\n : ''}\n ${hiddenSelector.matches('description', true) ? '' : this.__renderSummary()}\n ${hiddenSelector.matches('customer', true) ? '' : this.__renderCustomer()}\n </div>\n\n <div\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition-opacity': true,\n 'opacity-0': !!this.data,\n })}\n >\n <foxy-spinner\n data-testid=\"spinner\"\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n protected async _sendGet(): Promise<Data> {\n const transaction = await super._sendGet();\n const storeLink = transaction._links['fx:store']?.href;\n\n if (typeof storeLink === 'string') {\n const store = await super._fetch<Resource<Rels.Store>>(storeLink);\n this.__currencyDisplay = store.use_international_currency_symbol ? 'code' : 'symbol';\n } else {\n this.__currencyDisplay = 'symbol';\n }\n\n return transaction;\n }\n\n private __renderIdAndTotal() {\n const data = this.data;\n let content: TemplateResult;\n\n if (data) {\n const amount = `${data.total_order} ${data.currency_code}`;\n const currencyDisplay = this.__currencyDisplay;\n const options = { amount, currencyDisplay };\n\n content = html`\n <span class=\"truncate\">ID ${data.display_id || getResourceId(data._links.self.href)}</span>\n ${data.type !== 'updateinfo' && data.type !== 'subscription_cancellation'\n ? html`\n <span>•</span>\n <foxy-i18n .options=${options} infer=\"\" class=\"whitespace-nowrap\" key=\"price\">\n </foxy-i18n>\n `\n : ''}\n ${data?.is_test\n ? html`\n <foxy-i18n\n infer=\"\"\n class=\"inline-block text-xs font-medium uppercase bg-contrast-5 text-tertiary rounded-s p-xs leading-none tracking-wider\"\n key=\"test\"\n >\n </foxy-i18n>\n `\n : ''}\n `;\n } else {\n content = html`​`;\n }\n\n return html`\n <div class=\"min-w-0\" data-testid=\"total\">\n ${this.renderTemplateOrSlot('total:before')}\n <div class=\"font-medium flex items-center gap-xs\">${content}</div>\n ${this.renderTemplateOrSlot('total:after')}\n </div>\n `;\n }\n\n private __renderStatus() {\n const specialIcons: Record<string, string> = {\n authorized: 'icons:done',\n capturing: 'icons:done',\n captured: 'icons:done',\n approved: 'icons:done',\n pending: 'icons:done',\n\n completed: 'icons:done-all',\n\n pending_fraud_review: 'icons:info-outline',\n declined: 'icons:highlight-off',\n rejected: 'icons:highlight-off',\n problem: 'icons:info-outline',\n\n refunded: 'icons:restore',\n voided: 'icons:remove-circle-outline',\n };\n\n const specialColors: Record<string, string> = {\n authorized: 'text-success',\n completed: 'text-success',\n capturing: 'text-success',\n captured: 'text-success',\n approved: 'text-success',\n pending: 'text-success',\n\n pending_fraud_review: 'text-error',\n declined: 'text-error',\n rejected: 'text-error',\n problem: 'text-error',\n };\n\n const status = this.data?.status || 'completed';\n const source = this.data?.source?.substring(0, 3).toUpperCase();\n\n return html`\n <div class=\"flex-shrink-0\" data-testid=\"status\">\n ${this.renderTemplateOrSlot('status:before')}\n\n <div class=\"text-tertiary text-s flex items-center space-x-xs\">\n ${this.data?.hide_transaction\n ? html`\n <vcf-tooltip for=\"hidden\" theme=\"light\" position=\"top\">\n <foxy-i18n infer=\"\" key=\"hidden_hint\"></foxy-i18n>\n </vcf-tooltip>\n <iron-icon\n class=\"icon-inline cursor-default\"\n icon=\"icons:visibility-off\"\n id=\"hidden\"\n >\n </iron-icon>\n `\n : ''}\n ${source\n ? html`\n <vcf-tooltip for=\"source\" theme=\"light\" position=\"top\">\n <foxy-i18n infer=\"\" key=\"source_${source}\"></foxy-i18n>\n </vcf-tooltip>\n <span class=\"cursor-default\" id=\"source\">${source}</span>\n `\n : ''}\n\n <foxy-i18n\n options=${JSON.stringify({ value: this.data?.transaction_date })}\n lang=${this.lang}\n key=\"time\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <iron-icon\n data-testid=\"status-icon\"\n class=\"icon-inline cursor-default text-l ${specialColors[status] ?? 'text-tertiary'}\"\n id=\"status\"\n icon=${specialIcons[status] ?? 'icons:schedule'}\n >\n </iron-icon>\n\n <vcf-tooltip for=\"status\" theme=\"light\" position=\"top\">\n <foxy-i18n infer=\"\" key=\"status_${status}\"></foxy-i18n>\n </vcf-tooltip>\n </div>\n\n ${this.renderTemplateOrSlot('status:after')}\n </div>\n `;\n }\n\n private __renderSummary() {\n const items = this.data?._embedded?.['fx:items'];\n const type = this.data?.type;\n\n let content: TemplateResult;\n let key: string;\n\n if (type === 'updateinfo') {\n key = 'summary_payment_method_change';\n } else if (type === 'subscription_modification') {\n key = 'summary_subscription_modification';\n } else if (type === 'subscription_cancellation') {\n key = 'summary_subscription_cancellation';\n } else {\n key = 'summary';\n }\n\n if (items) {\n const options = {\n most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],\n count_minus_one: items.length - 1,\n count: items.length,\n };\n\n content = html`<foxy-i18n .options=${options} infer=\"\" key=${key}></foxy-i18n>`;\n } else {\n content = html`​`;\n }\n\n return html`\n <div data-testid=\"description\">\n ${this.renderTemplateOrSlot('description:before')}\n <div class=\"text-s text-secondary truncate\">${content}</div>\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderCustomer() {\n const data = this.data;\n const content = data\n ? html`${data.customer_first_name} ${data.customer_last_name} (${data.customer_email})`\n : html`​`;\n\n return html`\n <div data-testid=\"customer\">\n ${this.renderTemplateOrSlot('customer:before')}\n <div class=\"text-tertiary truncate text-s\">${content}</div>\n ${this.renderTemplateOrSlot('customer:after')}\n </div>\n `;\n }\n}\n\nexport { TransactionCard };\n"]}
|
|
1
|
+
{"version":3,"file":"TransactionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/TransactionCard/TransactionCard.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,kBAAkB,CAAC;AAC9B,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE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,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;gBACjC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;gBACpB,KAAK,EAAE,KAAK,CAAC,MAAM;aACpB,CAAC;YAEF,OAAO,GAAG,IAAI,CAAA,uBAAuB,OAAO,iBAAiB,GAAG,eAAe,CAAC;SACjF;aAAM;YACL,OAAO,GAAG,IAAI,CAAA,kBAAkB,CAAC;SAClC;QAED,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,oBAAoB,CAAC,oBAAoB,CAAC;sDACH,OAAO;UACnD,IAAI,CAAC,oBAAoB,CAAC,mBAAmB,CAAC;;KAEnD,CAAC;IACJ,CAAC;IAEO,gBAAgB;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI;YAClB,CAAC,CAAC,IAAI,CAAA,GAAG,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,cAAc,GAAG;YACvF,CAAC,CAAC,IAAI,CAAA,kBAAkB,CAAC;QAE3B,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;qDACD,OAAO;UAClD,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC;;KAEhD,CAAC;IACJ,CAAC;CACF;AAED,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { Data } from './types';\nimport type { TemplateResult } from 'lit-html';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { Resource, getResourceId } from '@foxy.io/sdk/core';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nconst NS = 'transaction-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a transaction.\n *\n * @element foxy-transaction-card\n * @since 1.12.0\n */\nclass TransactionCard extends Base<Data> {\n private __currencyDisplay = '';\n\n renderBody(): TemplateResult {\n const hiddenSelector = this.hiddenSelector;\n const hasTotal = !hiddenSelector.matches('total', true);\n const hasStatus = !hiddenSelector.matches('status', true);\n\n return html`\n <div\n aria-busy=${this.in('busy')}\n aria-live=\"polite\"\n class=\"relative leading-s font-lumo text-m\"\n >\n <div class=${classMap({ 'transition-opacity': true, 'opacity-0': !this.data })}>\n ${hasTotal || hasStatus\n ? html`\n <div class=\"flex items-center justify-between gap-s\">\n ${hasTotal ? this.__renderIdAndTotal() : ''}\n ${hasStatus ? this.__renderStatus() : ''}\n </div>\n `\n : ''}\n ${hiddenSelector.matches('description', true) ? '' : this.__renderSummary()}\n ${hiddenSelector.matches('customer', true) ? '' : this.__renderCustomer()}\n </div>\n\n <div\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition-opacity': true,\n 'opacity-0': !!this.data,\n })}\n >\n <foxy-spinner\n data-testid=\"spinner\"\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n protected async _sendGet(): Promise<Data> {\n const transaction = await super._sendGet();\n const storeLink = transaction._links['fx:store']?.href;\n\n if (typeof storeLink === 'string') {\n const store = await super._fetch<Resource<Rels.Store>>(storeLink);\n this.__currencyDisplay = store.use_international_currency_symbol ? 'code' : 'symbol';\n } else {\n this.__currencyDisplay = 'symbol';\n }\n\n return transaction;\n }\n\n private __renderIdAndTotal() {\n const data = this.data;\n let content: TemplateResult;\n\n if (data) {\n const amount = `${data.total_order} ${data.currency_code}`;\n const currencyDisplay = this.__currencyDisplay;\n const options = { amount, currencyDisplay };\n\n content = html`\n <span class=\"truncate\">ID ${data.display_id || getResourceId(data._links.self.href)}</span>\n ${data.type !== 'updateinfo' && data.type !== 'subscription_cancellation'\n ? html`\n <span>•</span>\n <foxy-i18n .options=${options} infer=\"\" class=\"whitespace-nowrap\" key=\"price\">\n </foxy-i18n>\n `\n : ''}\n ${data?.is_test\n ? html`\n <foxy-i18n\n infer=\"\"\n class=\"inline-block text-xs font-medium uppercase bg-contrast-5 text-tertiary rounded-s p-xs leading-none tracking-wider\"\n key=\"test\"\n >\n </foxy-i18n>\n `\n : ''}\n `;\n } else {\n content = html`​`;\n }\n\n return html`\n <div class=\"min-w-0\" data-testid=\"total\">\n ${this.renderTemplateOrSlot('total:before')}\n <div class=\"font-medium flex items-center gap-xs\">${content}</div>\n ${this.renderTemplateOrSlot('total:after')}\n </div>\n `;\n }\n\n private __renderStatus() {\n const specialIcons: Record<string, string> = {\n authorized: 'icons:done',\n capturing: 'icons:done',\n captured: 'icons:done',\n approved: 'icons:done',\n pending: 'icons:done',\n\n completed: 'icons:done-all',\n\n pending_fraud_review: 'icons:info-outline',\n declined: 'icons:highlight-off',\n rejected: 'icons:highlight-off',\n problem: 'icons:info-outline',\n\n refunded: 'icons:restore',\n voided: 'icons:remove-circle-outline',\n };\n\n const specialColors: Record<string, string> = {\n authorized: 'text-success',\n completed: 'text-success',\n capturing: 'text-success',\n captured: 'text-success',\n approved: 'text-success',\n pending: 'text-success',\n\n pending_fraud_review: 'text-error',\n declined: 'text-error',\n rejected: 'text-error',\n problem: 'text-error',\n };\n\n const status = this.data?.status || 'completed';\n const source = this.data?.source?.substring(0, 3).toUpperCase();\n\n return html`\n <div class=\"flex-shrink-0\" data-testid=\"status\">\n ${this.renderTemplateOrSlot('status:before')}\n\n <div class=\"text-tertiary text-s flex items-center space-x-xs\">\n ${this.data?.hide_transaction\n ? html`\n <vcf-tooltip for=\"hidden\" theme=\"light\" position=\"top\">\n <foxy-i18n infer=\"\" key=\"hidden_hint\"></foxy-i18n>\n </vcf-tooltip>\n <iron-icon\n class=\"icon-inline cursor-default\"\n icon=\"icons:visibility-off\"\n id=\"hidden\"\n >\n </iron-icon>\n `\n : ''}\n ${source\n ? html`\n <vcf-tooltip for=\"source\" theme=\"light\" position=\"top\">\n <foxy-i18n infer=\"\" key=\"source_${source}\"></foxy-i18n>\n </vcf-tooltip>\n <span class=\"cursor-default\" id=\"source\">${source}</span>\n `\n : ''}\n\n <foxy-i18n\n options=${JSON.stringify({ value: this.data?.transaction_date })}\n lang=${this.lang}\n key=\"time\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <iron-icon\n data-testid=\"status-icon\"\n class=\"icon-inline cursor-default text-l ${specialColors[status] ?? 'text-tertiary'}\"\n id=\"status\"\n icon=${specialIcons[status] ?? 'icons:schedule'}\n >\n </iron-icon>\n\n <vcf-tooltip for=\"status\" theme=\"light\" position=\"top\">\n <foxy-i18n infer=\"\" key=\"status_${status}\"></foxy-i18n>\n </vcf-tooltip>\n </div>\n\n ${this.renderTemplateOrSlot('status:after')}\n </div>\n `;\n }\n\n private __renderSummary() {\n const items = this.data?._embedded?.['fx:items'];\n const type = this.data?.type;\n\n let content: TemplateResult;\n let key: string;\n\n if (type === 'updateinfo') {\n key = 'summary_payment_method_change';\n } else if (type === 'subscription_modification') {\n key = 'summary_subscription_modification';\n } else if (type === 'subscription_cancellation') {\n key = 'summary_subscription_cancellation';\n } else {\n key = 'summary';\n }\n\n if (items) {\n const options = {\n count_minus_one: items.length - 1,\n first_item: items[0],\n count: items.length,\n };\n\n content = html`<foxy-i18n .options=${options} infer=\"\" key=${key}></foxy-i18n>`;\n } else {\n content = html`​`;\n }\n\n return html`\n <div data-testid=\"description\">\n ${this.renderTemplateOrSlot('description:before')}\n <div class=\"text-s text-secondary truncate\">${content}</div>\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderCustomer() {\n const data = this.data;\n const content = data\n ? html`${data.customer_first_name} ${data.customer_last_name} (${data.customer_email})`\n : html`​`;\n\n return html`\n <div data-testid=\"customer\">\n ${this.renderTemplateOrSlot('customer:before')}\n <div class=\"text-tertiary truncate text-s\">${content}</div>\n ${this.renderTemplateOrSlot('customer:after')}\n </div>\n `;\n }\n}\n\nexport { TransactionCard };\n"]}
|
|
@@ -33,8 +33,8 @@ TransactionsTable.summaryColumn = {
|
|
|
33
33
|
if (!items)
|
|
34
34
|
return '';
|
|
35
35
|
const options = {
|
|
36
|
-
most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],
|
|
37
36
|
count_minus_one: items.length - 1,
|
|
37
|
+
first_item: items[0],
|
|
38
38
|
count: items.length,
|
|
39
39
|
};
|
|
40
40
|
return ctx.html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionsTable.js","sourceRoot":"","sources":["../../../../src/elements/public/TransactionsTable/TransactionsTable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,0BAAuB;AACvC,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAO;IAA3F;;QAoHE,YAAO,GAAG;YACR,iBAAiB,CAAC,WAAW;YAC7B,iBAAiB,CAAC,aAAa;YAC/B,iBAAiB,CAAC,YAAY;YAC9B,iBAAiB,CAAC,QAAQ;YAC1B,iBAAiB,CAAC,UAAU;YAC5B,iBAAiB,CAAC,aAAa;SAChC,CAAC;IAGJ,CAAC;;AA7HQ,6BAAW,GAAiB;IACjC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAA;;;;eAIV,GAAG,CAAC,IAAI;;aAEV,GAAG,CAAC,EAAE;mBACA,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE;;;KAG7E;CACF,CAAC;AAEK,+BAAa,GAAiB;IACnC,IAAI,EAAE,GAAG,CAAC,EAAE;;QACV,MAAM,KAAK,SAAG,GAAG,CAAC,IAAI,CAAC,SAAS,0CA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G,CAAC,IAAI,CAAA;;;;;iBAKJ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI;;;;iBAIlC,GAAG,CAAC,EAAE;mBACJ,GAAG,CAAC,IAAI;;;;;;OAMpB,CAAC;IACJ,CAAC;CACF,CAAC;AAWa,sBAAI,GAAG,oBAAoB,CAAC","sourcesContent":["import { Column } from '../Table/types';\nimport { Data } from './types';\nimport { Table } from '../Table/Table';\nimport { TranslatableMixin } from '../../../mixins/translatable';\n\nexport class TransactionsTable extends TranslatableMixin(Table, 'transactions-table')<Data> {\n static priceColumn: Column<Data> = {\n cell: ctx => ctx.html`\n <foxy-i18n\n data-testclass=\"i18n totals\"\n class=\"text-m font-medium font-tnum\"\n lang=${ctx.lang}\n key=\"price\"\n ns=${ctx.ns}\n .options=${{ amount: `${ctx.data.total_order} ${ctx.data.currency_code}` }}\n >\n </foxy-i18n>\n `,\n };\n\n static summaryColumn: Column<Data> = {\n cell: ctx => {\n const items = ctx.data._embedded?.['fx:items'];\n if (!items) return '';\n\n const options = {\n count_minus_one: items.length - 1,\n first_item: items[0],\n count: items.length,\n };\n\n return ctx.html`\n <foxy-i18n\n data-testclass=\"i18n summaries\"\n class=\"text-m\"\n lang=${ctx.lang}\n key=\"transaction_summary\"\n ns=${ctx.ns}\n .options=${options}\n >\n </foxy-i18n>\n `;\n },\n };\n\n static statusColumn: Column<Data> = {\n hideBelow: 'sm',\n cell: ctx => {\n const colors = {\n completed: 'bg-success-10 text-success',\n declined: 'bg-error-10 text-error',\n rejected: 'bg-error-10 text-error',\n };\n\n const status = ctx.data.status || 'completed';\n const defaultColor = 'bg-contrast-5 text-contrast';\n const color = status in colors ? colors[status as keyof typeof colors] : defaultColor;\n\n return ctx.html`\n <foxy-i18n\n data-testclass=\"i18n statuses\"\n class=\"px-s py-xs text-m font-medium rounded ${color}\"\n lang=${ctx.lang}\n key=${`transaction_${status}`}\n ns=${ctx.ns}\n >\n </foxy-i18n>\n `;\n },\n };\n\n static idColumn: Column<Data> = {\n hideBelow: 'sm',\n cell: ctx => {\n return ctx.html`\n <span class=\"text-m text-secondary font-tnum\" data-testclass=\"ids\">\n <span class=\"text-tertiary\">ID</span> ${ctx.data.id}\n </span>\n `;\n },\n };\n\n static dateColumn: Column<Data> = {\n hideBelow: 'sm' as const,\n cell: ctx => {\n return ctx.html`\n <foxy-i18n\n data-testclass=\"i18n dates\"\n class=\"text-m text-secondary font-tnum\"\n lang=${ctx.lang}\n key=\"date\"\n ns=${ctx.ns}\n .options=${{ value: ctx.data.transaction_date }}\n >\n </foxy-i18n>\n `;\n },\n };\n\n static receiptColumn: Column<Data> = {\n cell: ctx => {\n return ctx.html`\n <a\n data-testclass=\"links\"\n target=\"_blank\"\n class=\"text-m font-medium text-primary rounded hover-underline focus-outline-none focus-shadow-outline\"\n href=${ctx.data._links['fx:receipt'].href}\n >\n <foxy-i18n\n data-testclass=\"i18n\"\n ns=${ctx.ns}\n lang=${ctx.lang}\n key=\"receipt\"\n >\n </foxy-i18n>\n <iron-icon icon=\"icons:open-in-new\" class=\"icon-inline\"></iron-icon>\n </a>\n `;\n },\n };\n\n columns = [\n TransactionsTable.priceColumn,\n TransactionsTable.summaryColumn,\n TransactionsTable.statusColumn,\n TransactionsTable.idColumn,\n TransactionsTable.dateColumn,\n TransactionsTable.receiptColumn,\n ];\n\n private static __ns = 'transactions-table';\n}\n"]}
|