@foxy.io/elements 1.43.0-beta.4 → 1.43.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  2. package/dist/cdn/foxy-address-card.js +1 -1
  3. package/dist/cdn/foxy-address-form.js +1 -1
  4. package/dist/cdn/foxy-admin-subscription-card.js +1 -1
  5. package/dist/cdn/foxy-admin-subscription-form.js +1 -1
  6. package/dist/cdn/foxy-api-browser.js +1 -1
  7. package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
  8. package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
  9. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  10. package/dist/cdn/foxy-attribute-card.js +1 -1
  11. package/dist/cdn/foxy-attribute-form.js +1 -1
  12. package/dist/cdn/foxy-billing-address-card.js +1 -1
  13. package/dist/cdn/foxy-cancellation-form.js +1 -1
  14. package/dist/cdn/foxy-cart-card.js +1 -1
  15. package/dist/cdn/foxy-cart-form.js +1 -1
  16. package/dist/cdn/foxy-client-card.js +1 -1
  17. package/dist/cdn/foxy-client-form.js +1 -1
  18. package/dist/cdn/foxy-collection-page.js +1 -1
  19. package/dist/cdn/foxy-collection-pages.js +1 -1
  20. package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
  21. package/dist/cdn/foxy-coupon-card.js +1 -1
  22. package/dist/cdn/foxy-coupon-code-card.js +1 -1
  23. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  24. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  25. package/dist/cdn/foxy-coupon-detail-card.js +1 -1
  26. package/dist/cdn/foxy-coupon-form.js +1 -1
  27. package/dist/cdn/foxy-custom-field-card.js +1 -1
  28. package/dist/cdn/foxy-custom-field-form.js +1 -1
  29. package/dist/cdn/foxy-customer-card.js +1 -1
  30. package/dist/cdn/foxy-customer-form.js +1 -1
  31. package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
  32. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  33. package/dist/cdn/foxy-customer-portal.js +1 -1
  34. package/dist/cdn/foxy-customer.js +1 -1
  35. package/dist/cdn/foxy-customers-table.js +1 -1
  36. package/dist/cdn/foxy-discount-builder.js +1 -1
  37. package/dist/cdn/foxy-discount-card.js +1 -1
  38. package/dist/cdn/foxy-discount-detail-card.js +1 -1
  39. package/dist/cdn/foxy-donation.js +1 -1
  40. package/dist/cdn/foxy-downloadable-card.js +1 -1
  41. package/dist/cdn/foxy-downloadable-form.js +1 -1
  42. package/dist/cdn/foxy-email-template-card.js +1 -1
  43. package/dist/cdn/foxy-email-template-form.js +1 -1
  44. package/dist/cdn/foxy-error-entry-card.js +1 -1
  45. package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
  46. package/dist/cdn/foxy-filter-attribute-card.js +1 -1
  47. package/dist/cdn/foxy-filter-attribute-form.js +1 -1
  48. package/dist/cdn/foxy-form-dialog.js +1 -1
  49. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  50. package/dist/cdn/foxy-gift-card-card.js +1 -1
  51. package/dist/cdn/foxy-gift-card-code-card.js +1 -1
  52. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  53. package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
  54. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  55. package/dist/cdn/foxy-gift-card-form.js +1 -1
  56. package/dist/cdn/foxy-i18n-editor.js +1 -1
  57. package/dist/cdn/foxy-i18n.js +1 -1
  58. package/dist/cdn/foxy-integration-card.js +1 -1
  59. package/dist/cdn/foxy-integration-form.js +1 -1
  60. package/dist/cdn/foxy-item-card.js +1 -1
  61. package/dist/cdn/foxy-item-category-card.js +1 -1
  62. package/dist/cdn/foxy-item-category-form.js +1 -1
  63. package/dist/cdn/foxy-item-form.js +1 -1
  64. package/dist/cdn/foxy-item-option-card.js +1 -1
  65. package/dist/cdn/foxy-item-option-form.js +1 -1
  66. package/dist/cdn/foxy-items-form.js +1 -1
  67. package/dist/cdn/foxy-native-integration-card.js +1 -1
  68. package/dist/cdn/foxy-native-integration-form.js +1 -1
  69. package/dist/cdn/foxy-pagination.js +1 -1
  70. package/dist/cdn/foxy-passkey-card.js +1 -1
  71. package/dist/cdn/foxy-passkey-form.js +1 -1
  72. package/dist/cdn/foxy-payment-card-embed.js +1 -1
  73. package/dist/cdn/foxy-payment-card.js +1 -1
  74. package/dist/cdn/foxy-payment-method-card.js +1 -1
  75. package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
  76. package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
  77. package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
  78. package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
  79. package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
  80. package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
  81. package/dist/cdn/foxy-query-builder.js +1 -1
  82. package/dist/cdn/foxy-report-form.js +1 -1
  83. package/dist/cdn/foxy-reports-table.js +1 -1
  84. package/dist/cdn/foxy-shipment-card.js +1 -1
  85. package/dist/cdn/foxy-shipping-container-card.js +1 -1
  86. package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
  87. package/dist/cdn/foxy-shipping-method-card.js +1 -1
  88. package/dist/cdn/foxy-shipping-service-card.js +1 -1
  89. package/dist/cdn/foxy-sign-in-form.js +1 -1
  90. package/dist/cdn/foxy-spinner.js +1 -1
  91. package/dist/cdn/foxy-store-card.js +1 -1
  92. package/dist/cdn/foxy-store-form.js +1 -1
  93. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  94. package/dist/cdn/foxy-subscription-card.js +1 -1
  95. package/dist/cdn/foxy-subscription-form.js +1 -1
  96. package/dist/cdn/foxy-subscription-settings-form.js +1 -1
  97. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  98. package/dist/cdn/foxy-table.js +1 -1
  99. package/dist/cdn/foxy-tax-card.js +1 -1
  100. package/dist/cdn/foxy-tax-form.js +1 -1
  101. package/dist/cdn/foxy-template-config-form.js +1 -1
  102. package/dist/cdn/foxy-template-form.js +1 -1
  103. package/dist/cdn/foxy-template-set-card.js +1 -1
  104. package/dist/cdn/foxy-template-set-form.js +1 -1
  105. package/dist/cdn/foxy-transaction-card.js +1 -1
  106. package/dist/cdn/foxy-transaction.js +1 -1
  107. package/dist/cdn/foxy-transactions-table.js +2 -2
  108. package/dist/cdn/foxy-update-payment-method-form.js +1 -1
  109. package/dist/cdn/foxy-user-card.js +1 -1
  110. package/dist/cdn/foxy-user-form.js +1 -1
  111. package/dist/cdn/foxy-user-invitation-card.js +1 -1
  112. package/dist/cdn/foxy-user-invitation-form.js +1 -1
  113. package/dist/cdn/foxy-users-table.js +1 -1
  114. package/dist/cdn/foxy-webhook-card.js +1 -1
  115. package/dist/cdn/foxy-webhook-form.js +1 -1
  116. package/dist/cdn/foxy-webhook-log-card.js +1 -1
  117. package/dist/cdn/foxy-webhook-status-card.js +1 -1
  118. package/dist/cdn/shared-02dd05dd.js +1 -0
  119. package/dist/cdn/{shared-5492f8eb.js → shared-050780e9.js} +1 -1
  120. package/dist/cdn/{shared-f2e8070b.js → shared-090ee4eb.js} +1 -1
  121. package/dist/cdn/{shared-0fb90a71.js → shared-0d01cd66.js} +1 -1
  122. package/dist/cdn/{shared-46a20973.js → shared-0eef6fb7.js} +1 -1
  123. package/dist/cdn/{shared-7d1512e1.js → shared-15a7e329.js} +1 -1
  124. package/dist/cdn/{shared-d8b0432a.js → shared-1abfcf87.js} +1 -1
  125. package/dist/cdn/{shared-48129732.js → shared-1d03ea56.js} +1 -1
  126. package/dist/cdn/{shared-cf6122d9.js → shared-1d6ed748.js} +1 -1
  127. package/dist/cdn/{shared-b15efc37.js → shared-24998349.js} +1 -1
  128. package/dist/cdn/{shared-5a6e4a7b.js → shared-25a9d87d.js} +1 -1
  129. package/dist/cdn/{shared-160072f2.js → shared-264fb8a2.js} +1 -1
  130. package/dist/cdn/{shared-f2be9863.js → shared-297155d9.js} +1 -1
  131. package/dist/cdn/{shared-a0fbe3ef.js → shared-2d6478b0.js} +5 -5
  132. package/dist/cdn/{shared-2c7e0ed1.js → shared-302f3391.js} +1 -1
  133. package/dist/cdn/{shared-a89e8a07.js → shared-387d7254.js} +1 -1
  134. package/dist/cdn/{shared-5af5ab06.js → shared-3bc9eaf7.js} +1 -1
  135. package/dist/cdn/{shared-d3f37507.js → shared-3db3f3c3.js} +1 -1
  136. package/dist/cdn/{shared-f3590d20.js → shared-438e41ab.js} +1 -1
  137. package/dist/cdn/{shared-6313b188.js → shared-46efbc40.js} +1 -1
  138. package/dist/cdn/shared-47269bb6.js +1 -0
  139. package/dist/cdn/{shared-50a355d6.js → shared-4dba0d50.js} +1 -1
  140. package/dist/cdn/{shared-a41ccdc7.js → shared-51919259.js} +1 -1
  141. package/dist/cdn/{shared-acee789f.js → shared-5574ea83.js} +1 -1
  142. package/dist/cdn/{shared-e82550b1.js → shared-57b7386e.js} +1 -1
  143. package/dist/cdn/{shared-8530fbae.js → shared-597fffaa.js} +1 -1
  144. package/dist/cdn/{shared-e126cf44.js → shared-5b93d193.js} +1 -1
  145. package/dist/cdn/{shared-1b4a3e56.js → shared-64210e53.js} +1 -1
  146. package/dist/cdn/{shared-69c7ad04.js → shared-64c855e5.js} +1 -1
  147. package/dist/cdn/{shared-f7b4a4f6.js → shared-6c2a7d2f.js} +1 -1
  148. package/dist/cdn/{shared-88a1cb23.js → shared-73c199ae.js} +1 -1
  149. package/dist/cdn/{shared-0e605594.js → shared-7a818ad5.js} +1 -1
  150. package/dist/cdn/{shared-140c6b70.js → shared-7fa24559.js} +1 -1
  151. package/dist/cdn/{shared-3eb6e232.js → shared-8a83a6eb.js} +5 -5
  152. package/dist/cdn/{shared-ebfb86b5.js → shared-8ee6bff5.js} +1 -1
  153. package/dist/cdn/{shared-dc1fc2e6.js → shared-8f2da12b.js} +1 -1
  154. package/dist/cdn/{shared-8a743005.js → shared-9b599205.js} +1 -1
  155. package/dist/cdn/{shared-9884fb7d.js → shared-a1cfe9d5.js} +1 -1
  156. package/dist/cdn/{shared-0fa21237.js → shared-a1f181bf.js} +1 -1
  157. package/dist/cdn/{shared-d4928805.js → shared-a5580ef6.js} +1 -1
  158. package/dist/cdn/{shared-3f4549ba.js → shared-a6cf5b1f.js} +1 -1
  159. package/dist/cdn/{shared-9bfb584b.js → shared-ab9dfa48.js} +1 -1
  160. package/dist/cdn/{shared-ce0df878.js → shared-ac44a3a5.js} +1 -1
  161. package/dist/cdn/{shared-28253ef3.js → shared-af39ffd8.js} +1 -1
  162. package/dist/cdn/{shared-d3aefd9b.js → shared-b4a3d776.js} +1 -1
  163. package/dist/cdn/{shared-4388f7ea.js → shared-b56949d3.js} +1 -1
  164. package/dist/cdn/{shared-ad8d209a.js → shared-c1b71162.js} +1 -1
  165. package/dist/cdn/{shared-e02936f0.js → shared-c3d1d247.js} +4 -4
  166. package/dist/cdn/{shared-8a570d01.js → shared-c4df3a2a.js} +1 -1
  167. package/dist/cdn/{shared-fa482a7d.js → shared-caac6517.js} +1 -1
  168. package/dist/cdn/{shared-7e18a7d9.js → shared-cee1c6f1.js} +1 -1
  169. package/dist/cdn/{shared-2b328555.js → shared-d0c1664e.js} +1 -1
  170. package/dist/cdn/{shared-59c064c2.js → shared-d35ed355.js} +1 -1
  171. package/dist/cdn/{shared-c16f05d9.js → shared-d525b69b.js} +1 -1
  172. package/dist/cdn/{shared-34a7df04.js → shared-da4f539a.js} +1 -1
  173. package/dist/cdn/{shared-1f95aa71.js → shared-db758d3b.js} +1 -1
  174. package/dist/cdn/{shared-3c64ecdd.js → shared-dc357e9d.js} +1 -1
  175. package/dist/cdn/{shared-742899dc.js → shared-dda75cab.js} +1 -1
  176. package/dist/cdn/{shared-a16ef278.js → shared-e275989e.js} +1 -1
  177. package/dist/cdn/{shared-070211c0.js → shared-e6559d84.js} +1 -1
  178. package/dist/cdn/{shared-364b98a1.js → shared-e6d5f375.js} +1 -1
  179. package/dist/cdn/{shared-a4871405.js → shared-ed24a3f9.js} +1 -1
  180. package/dist/cdn/{shared-db50afd9.js → shared-f00cd094.js} +1 -1
  181. package/dist/cdn/shared-f0fa0a88.js +1 -0
  182. package/dist/cdn/translations/admin-subscription-form/en.json +63 -10
  183. package/dist/cdn/translations/coupon-code-form/en.json +2 -2
  184. package/dist/cdn/translations/coupon-form/en.json +2 -2
  185. package/dist/cdn/translations/customer/en.json +5 -5
  186. package/dist/cdn/translations/customer-portal/de.json +6 -5
  187. package/dist/cdn/translations/customer-portal/en.json +6 -5
  188. package/dist/cdn/translations/customer-portal/es.json +6 -5
  189. package/dist/cdn/translations/customer-portal/fr.json +6 -5
  190. package/dist/cdn/translations/customer-portal/nl.json +6 -5
  191. package/dist/cdn/translations/customer-portal/pl.json +6 -5
  192. package/dist/cdn/translations/customer-portal/sv.json +6 -5
  193. package/dist/cdn/translations/customer-portal/zh-HK.json +6 -5
  194. package/dist/cdn/translations/payments-api-payment-method-form/en.json +1 -0
  195. package/dist/cdn/translations/payments-api-payment-preset-form/en.json +1 -0
  196. package/dist/cdn/translations/subscription-card/en.json +2 -1
  197. package/dist/cdn/translations/subscription-form/en.json +2 -2
  198. package/dist/cdn/translations/subscriptions-table/en.json +2 -1
  199. package/dist/cdn/translations/transaction-card/en.json +2 -2
  200. package/dist/cdn/translations/transactions-table/en.json +3 -3
  201. package/dist/elements/internal/InternalDateControl/InternalDateControl.d.ts +4 -0
  202. package/dist/elements/internal/InternalDateControl/InternalDateControl.js +9 -2
  203. package/dist/elements/internal/InternalDateControl/InternalDateControl.js.map +1 -1
  204. package/dist/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.d.ts +1 -0
  205. package/dist/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.js +6 -2
  206. package/dist/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.js.map +1 -1
  207. package/dist/elements/public/AdminSubscriptionForm/index.d.ts +1 -0
  208. package/dist/elements/public/AdminSubscriptionForm/index.js +1 -0
  209. package/dist/elements/public/AdminSubscriptionForm/index.js.map +1 -1
  210. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusAction/InternalAdminSubscriptionFormStatusAction.d.ts +7 -0
  211. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusAction/InternalAdminSubscriptionFormStatusAction.js +65 -0
  212. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusAction/InternalAdminSubscriptionFormStatusAction.js.map +1 -0
  213. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusAction/index.d.ts +8 -0
  214. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusAction/index.js +10 -0
  215. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusAction/index.js.map +1 -0
  216. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/InternalAdminSubscriptionFormStatusActionForm.d.ts +18 -0
  217. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/InternalAdminSubscriptionFormStatusActionForm.js +184 -0
  218. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/InternalAdminSubscriptionFormStatusActionForm.js.map +1 -0
  219. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/index.d.ts +8 -0
  220. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/index.js +10 -0
  221. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/index.js.map +1 -0
  222. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/types.d.ts +5 -0
  223. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/types.js +2 -0
  224. package/dist/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/types.js.map +1 -0
  225. package/dist/elements/public/Donation/Donation.d.ts +1 -1
  226. package/dist/elements/public/Donation/Donation.js +8 -6
  227. package/dist/elements/public/Donation/Donation.js.map +1 -1
  228. package/dist/elements/public/FormDialog/FormDialog.d.ts +2 -0
  229. package/dist/elements/public/FormDialog/FormDialog.js +4 -1
  230. package/dist/elements/public/FormDialog/FormDialog.js.map +1 -1
  231. package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.d.ts +1 -0
  232. package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js +38 -23
  233. package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map +1 -1
  234. package/dist/elements/public/SubscriptionCard/SubscriptionCard.js +1 -1
  235. package/dist/elements/public/SubscriptionCard/SubscriptionCard.js.map +1 -1
  236. package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js +1 -1
  237. package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js.map +1 -1
  238. package/dist/elements/public/TaxCard/TaxCard.js +1 -1
  239. package/dist/elements/public/TaxCard/TaxCard.js.map +1 -1
  240. package/dist/elements/public/TransactionCard/TransactionCard.js +1 -1
  241. package/dist/elements/public/TransactionCard/TransactionCard.js.map +1 -1
  242. package/dist/elements/public/TransactionsTable/TransactionsTable.js +1 -1
  243. package/dist/elements/public/TransactionsTable/TransactionsTable.js.map +1 -1
  244. package/dist/mixins/themeable.js +4 -0
  245. package/dist/mixins/themeable.js.map +1 -1
  246. package/dist/utils/parse-date.js +2 -0
  247. package/dist/utils/parse-date.js.map +1 -1
  248. package/package.json +2 -1
  249. package/dist/cdn/shared-2d3bdc6b.js +0 -1
  250. package/dist/cdn/shared-43e2c3f6.js +0 -1
  251. package/dist/cdn/shared-dfe59df6.js +0 -1
@@ -0,0 +1,184 @@
1
+ import { BooleanSelector } from '@foxy.io/sdk/core';
2
+ import { serializeDate } from "../../../../../utils/serialize-date.js";
3
+ import { InternalForm } from "../../../../internal/InternalForm/InternalForm.js";
4
+ import { parseDate } from "../../../../../utils/parse-date.js";
5
+ import { html, svg } from 'lit-html';
6
+ export class InternalAdminSubscriptionFormStatusActionForm extends InternalForm {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.__endDatePresetOptions = JSON.stringify([
10
+ { value: 'tomorrow', label: 'option_tomorrow' },
11
+ { value: 'next_transaction_date', label: 'option_next_transaction_date' },
12
+ { value: 'custom_date', label: 'option_custom_date' },
13
+ ]);
14
+ this.__endDatePresetGetValue = () => { var _a; return (_a = this.form.end_date_preset) !== null && _a !== void 0 ? _a : 'next_transaction_date'; };
15
+ this.__endDatePresetSetValue = (newValue) => {
16
+ this.edit({ end_date_preset: newValue });
17
+ if (newValue === 'tomorrow') {
18
+ const tomorrowDate = new Date();
19
+ tomorrowDate.setDate(tomorrowDate.getDate() + 1);
20
+ tomorrowDate.setHours(0, 0, 0, 0);
21
+ this.edit({ end_date: serializeDate(tomorrowDate) });
22
+ }
23
+ else if (newValue === 'next_transaction_date') {
24
+ this.edit({ end_date: this.form.next_transaction_date });
25
+ }
26
+ else {
27
+ this.edit({ end_date: '' });
28
+ }
29
+ };
30
+ this.__endDateGetValue = () => {
31
+ return this.form.end_date_preset ? this.form.end_date : this.form.next_transaction_date;
32
+ };
33
+ this.__nextTransactionDateGetValue = () => {
34
+ const tomorrowDate = new Date();
35
+ tomorrowDate.setDate(tomorrowDate.getDate() + 1);
36
+ tomorrowDate.setHours(0, 0, 0, 0);
37
+ const tomorrow = serializeDate(tomorrowDate);
38
+ if (!this.form.next_transaction_date)
39
+ return tomorrow;
40
+ const currentNextDate = parseDate(this.form.next_transaction_date.substring(0, 10));
41
+ if (!currentNextDate || currentNextDate < tomorrowDate)
42
+ return tomorrow;
43
+ return this.form.next_transaction_date;
44
+ };
45
+ }
46
+ static get v8n() {
47
+ return [
48
+ ({ next_transaction_date, end_date, is_active }) => {
49
+ if (is_active) {
50
+ if (!end_date || end_date === '0000-00-00')
51
+ return 'end-date:v8n_required';
52
+ }
53
+ else {
54
+ if (!next_transaction_date)
55
+ return 'next-transaction-date:v8n_required';
56
+ }
57
+ return true;
58
+ },
59
+ ];
60
+ }
61
+ get readonlySelector() {
62
+ const alwaysMatch = [super.readonlySelector.toString()];
63
+ if (this.form.end_date_preset !== 'custom_date')
64
+ alwaysMatch.push('end-date');
65
+ return new BooleanSelector(alwaysMatch.join(' ').trim());
66
+ }
67
+ renderBody() {
68
+ var _a;
69
+ const tomorrowDate = new Date();
70
+ tomorrowDate.setDate(tomorrowDate.getDate() + 1);
71
+ tomorrowDate.setHours(0, 0, 0, 0);
72
+ const isActive = !!((_a = this.data) === null || _a === void 0 ? void 0 : _a.is_active);
73
+ const action = isActive ? 'cancel' : 'reactivate';
74
+ const color = isActive ? 'bg-error-10' : 'bg-success-10';
75
+ const icon = isActive
76
+ ? svg `<svg class="text-error" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 2rem; height: 2rem;"><path stroke-linecap="round" stroke-linejoin="round" d="M5.25 7.5A2.25 2.25 0 0 1 7.5 5.25h9a2.25 2.25 0 0 1 2.25 2.25v9a2.25 2.25 0 0 1-2.25 2.25h-9a2.25 2.25 0 0 1-2.25-2.25v-9Z" /></svg>`
77
+ : svg `<svg class="text-success" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 2rem; height: 2rem;"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>`;
78
+ return html `
79
+ <foxy-internal-summary-control infer="" label="" helper-text="">
80
+ <div class="text-center flex flex-col items-center bg-transparent">
81
+ <div class="rounded-full ${color} p-m mb-s mx-auto">${icon}</div>
82
+ <p class="font-medium text-xl leading-m">
83
+ <foxy-i18n infer="" key="${action}_title"></foxy-i18n>
84
+ </p>
85
+ <p class="text-secondary leading-s">
86
+ <foxy-i18n infer="" key="${action}_subtitle"></foxy-i18n>
87
+ </p>
88
+ </div>
89
+ </foxy-internal-summary-control>
90
+
91
+ <foxy-internal-summary-control infer="" label="" helper-text="">
92
+ ${isActive
93
+ ? html `
94
+ <foxy-internal-select-control
95
+ options=${this.__endDatePresetOptions}
96
+ layout="summary-item"
97
+ infer="end-date-preset"
98
+ .getValue=${this.__endDatePresetGetValue}
99
+ .setValue=${this.__endDatePresetSetValue}
100
+ >
101
+ </foxy-internal-select-control>
102
+
103
+ <foxy-internal-date-control
104
+ layout="summary-item"
105
+ infer="end-date"
106
+ min=${serializeDate(tomorrowDate)}
107
+ hide-clear-button
108
+ .getValue=${this.__endDateGetValue}
109
+ >
110
+ </foxy-internal-date-control>
111
+ `
112
+ : html `
113
+ <foxy-internal-date-control
114
+ layout="summary-item"
115
+ infer="next-transaction-date"
116
+ min=${serializeDate(tomorrowDate)}
117
+ hide-clear-button
118
+ .getValue=${this.__nextTransactionDateGetValue}
119
+ >
120
+ </foxy-internal-date-control>
121
+ `}
122
+ </foxy-internal-summary-control>
123
+
124
+ <foxy-internal-summary-control infer="" label="" helper-text="">
125
+ ${isActive
126
+ ? [
127
+ this.__renderFaq('cancel_why_not_today', svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="text-error flex-shrink-0" style="width: 1.25em; height: 1.25em;"><path d="M5.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H6a.75.75 0 0 1-.75-.75V12ZM6 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H6ZM7.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H8a.75.75 0 0 1-.75-.75V12ZM8 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H8ZM9.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V10ZM10 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H10ZM9.25 14a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V14ZM12 9.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V10a.75.75 0 0 0-.75-.75H12ZM11.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H12a.75.75 0 0 1-.75-.75V12ZM12 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H12ZM13.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H14a.75.75 0 0 1-.75-.75V10ZM14 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H14Z" /><path fill-rule="evenodd" d="M5.75 2a.75.75 0 0 1 .75.75V4h7V2.75a.75.75 0 0 1 1.5 0V4h.25A2.75 2.75 0 0 1 18 6.75v8.5A2.75 2.75 0 0 1 15.25 18H4.75A2.75 2.75 0 0 1 2 15.25v-8.5A2.75 2.75 0 0 1 4.75 4H5V2.75A.75.75 0 0 1 5.75 2Zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75Z" clip-rule="evenodd" /></svg>`),
128
+ this.__renderFaq('cancel_whats_next', svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="text-error flex-shrink-0" style="width: 1.25em; height: 1.25em;"><path d="M3.288 4.818A1.5 1.5 0 0 0 1 6.095v7.81a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905c.155-.096.285-.213.389-.344v2.973a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905a1.5 1.5 0 0 0 0-2.552l-6.323-3.906A1.5 1.5 0 0 0 10 6.095v2.972a1.506 1.506 0 0 0-.389-.343L3.288 4.818Z" /></svg>`),
129
+ this.__renderFaq('cancel_how_to_reactivate', svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="text-error flex-shrink-0" style="width: 1.25em; height: 1.25em;"><path d="M6.111 11.89A5.5 5.5 0 1 1 15.501 8 .75.75 0 0 0 17 8a7 7 0 1 0-11.95 4.95.75.75 0 0 0 1.06-1.06Z" /><path d="M8.232 6.232a2.5 2.5 0 0 0 0 3.536.75.75 0 1 1-1.06 1.06A4 4 0 1 1 14 8a.75.75 0 0 1-1.5 0 2.5 2.5 0 0 0-4.268-1.768Z" /><path d="M10.766 7.51a.75.75 0 0 0-1.37.365l-.492 6.861a.75.75 0 0 0 1.204.65l1.043-.799.985 3.678a.75.75 0 0 0 1.45-.388l-.978-3.646 1.292.204a.75.75 0 0 0 .74-1.16l-3.874-5.764Z" /></svg>`),
130
+ ]
131
+ : [
132
+ this.__renderFaq('reactivate_why_not_today', svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="text-success flex-shrink-0" style="width: 1.25em; height: 1.25em;"><path d="M5.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H6a.75.75 0 0 1-.75-.75V12ZM6 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H6ZM7.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H8a.75.75 0 0 1-.75-.75V12ZM8 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H8ZM9.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V10ZM10 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H10ZM9.25 14a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V14ZM12 9.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V10a.75.75 0 0 0-.75-.75H12ZM11.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H12a.75.75 0 0 1-.75-.75V12ZM12 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H12ZM13.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H14a.75.75 0 0 1-.75-.75V10ZM14 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H14Z" /><path fill-rule="evenodd" d="M5.75 2a.75.75 0 0 1 .75.75V4h7V2.75a.75.75 0 0 1 1.5 0V4h.25A2.75 2.75 0 0 1 18 6.75v8.5A2.75 2.75 0 0 1 15.25 18H4.75A2.75 2.75 0 0 1 2 15.25v-8.5A2.75 2.75 0 0 1 4.75 4H5V2.75A.75.75 0 0 1 5.75 2Zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75Z" clip-rule="evenodd" /></svg>`),
133
+ this.__renderFaq('reactivate_whats_next', svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="text-success flex-shrink-0" style="width: 1.25em; height: 1.25em;"><path d="M3.288 4.818A1.5 1.5 0 0 0 1 6.095v7.81a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905c.155-.096.285-.213.389-.344v2.973a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905a1.5 1.5 0 0 0 0-2.552l-6.323-3.906A1.5 1.5 0 0 0 10 6.095v2.972a1.506 1.506 0 0 0-.389-.343L3.288 4.818Z" /></svg>`),
134
+ ]}
135
+ </foxy-internal-summary-control>
136
+
137
+ <vaadin-button
138
+ theme="primary ${isActive ? 'error' : 'success'} large"
139
+ class="w-full"
140
+ ?disabled=${this.disabled}
141
+ @click=${() => this.submit()}
142
+ >
143
+ <foxy-i18n infer="" key="${action}_submit"></foxy-i18n>
144
+ </vaadin-button>
145
+ `;
146
+ }
147
+ submit() {
148
+ var _a;
149
+ if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.is_active) {
150
+ if (this.__endDatePresetGetValue() === 'next_transaction_date') {
151
+ this.edit({ end_date: this.form.next_transaction_date });
152
+ }
153
+ }
154
+ else {
155
+ this.edit({
156
+ next_transaction_date: this.__nextTransactionDateGetValue(),
157
+ is_active: true,
158
+ end_date: '0000-00-00',
159
+ });
160
+ }
161
+ super.submit();
162
+ }
163
+ async _sendPatch(edits) {
164
+ delete edits.end_date_preset;
165
+ return super._sendPatch(edits);
166
+ }
167
+ __renderFaq(prefix, icon) {
168
+ return html `
169
+ <div
170
+ class="bg-transparent flex leading-xs"
171
+ style="gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
172
+ >
173
+ ${icon}
174
+ <p class="grid">
175
+ <foxy-i18n class="leading-m text-s font-medium" infer="" key="${prefix}_title">
176
+ </foxy-i18n>
177
+ <foxy-i18n class="leading-xs text-secondary text-xs" infer="" key="${prefix}_text">
178
+ </foxy-i18n>
179
+ </p>
180
+ </div>
181
+ `;
182
+ }
183
+ }
184
+ //# sourceMappingURL=InternalAdminSubscriptionFormStatusActionForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalAdminSubscriptionFormStatusActionForm.js","sourceRoot":"","sources":["../../../../../../src/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/InternalAdminSubscriptionFormStatusActionForm.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,+CAA4C;AACpE,OAAO,EAAE,YAAY,EAAE,0DAAuD;AAC9E,OAAO,EAAE,SAAS,EAAE,2CAAwC;AAC5D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,OAAO,6CAA8C,SAAQ,YAAkB;IAArF;;QAemB,2BAAsB,GAAG,IAAI,CAAC,SAAS,CAAC;YACvD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAiB,EAAE;YAC/C,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,8BAA8B,EAAE;YACzE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,oBAAoB,EAAE;SACtD,CAAC,CAAC;QAEc,4BAAuB,GAAG,GAAG,EAAE,wBAC9C,IAAI,CAAC,IAAI,CAAC,eAAe,mCAAI,uBAAuB,GAAA,CAAC;QAEtC,4BAAuB,GAAG,CAAC,QAAgB,EAAE,EAAE;YAC9D,IAAI,CAAC,IAAI,CAAC,EAAE,e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EAAE,CAAC,IAAI,CAAC,MAAM,EAAE;;mCAED,MAAM;;KAEpC,CAAC;IACJ,CAAC;IAED,MAAM;;QACJ,UAAI,IAAI,CAAC,IAAI,0CAAE,SAAS,EAAE;YACxB,IAAI,IAAI,CAAC,uBAAuB,EAAE,KAAK,uBAAuB,EAAE;gBAC9D,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;aAC1D;SACF;aAAM;YACL,IAAI,CAAC,IAAI,CAAC;gBACR,qBAAqB,EAAE,IAAI,CAAC,6BAA6B,EAAE;gBAC3D,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,YAAY;aACvB,CAAC,CAAC;SACJ;QAED,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;IAES,KAAK,CAAC,UAAU,CAAC,KAAoB;QAC7C,OAAO,KAAK,CAAC,eAAe,CAAC;QAC7B,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAEO,WAAW,CAAC,MAAc,EAAE,IAAuB;QACzD,OAAO,IAAI,CAAA;;;;;UAKL,IAAI;;0EAE4D,MAAM;;+EAED,MAAM;;;;KAIhF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { SVGTemplateResult, TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../../../NucleonElement/types';\nimport type { Data } from './types';\n\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { serializeDate } from '../../../../../utils/serialize-date';\nimport { InternalForm } from '../../../../internal/InternalForm/InternalForm';\nimport { parseDate } from '../../../../../utils/parse-date';\nimport { html, svg } from 'lit-html';\n\nexport class InternalAdminSubscriptionFormStatusActionForm extends InternalForm<Data> {\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ next_transaction_date, end_date, is_active }) => {\n if (is_active) {\n if (!end_date || end_date === '0000-00-00') return 'end-date:v8n_required';\n } else {\n if (!next_transaction_date) return 'next-transaction-date:v8n_required';\n }\n\n return true;\n },\n ];\n }\n\n private readonly __endDatePresetOptions = JSON.stringify([\n { value: 'tomorrow', label: 'option_tomorrow' },\n { value: 'next_transaction_date', label: 'option_next_transaction_date' },\n { value: 'custom_date', label: 'option_custom_date' },\n ]);\n\n private readonly __endDatePresetGetValue = () =>\n this.form.end_date_preset ?? 'next_transaction_date';\n\n private readonly __endDatePresetSetValue = (newValue: string) => {\n this.edit({ end_date_preset: newValue });\n\n if (newValue === 'tomorrow') {\n const tomorrowDate = new Date();\n tomorrowDate.setDate(tomorrowDate.getDate() + 1);\n tomorrowDate.setHours(0, 0, 0, 0);\n this.edit({ end_date: serializeDate(tomorrowDate) });\n } else if (newValue === 'next_transaction_date') {\n this.edit({ end_date: this.form.next_transaction_date });\n } else {\n this.edit({ end_date: '' });\n }\n };\n\n private readonly __endDateGetValue = () => {\n return this.form.end_date_preset ? this.form.end_date : this.form.next_transaction_date;\n };\n\n private readonly __nextTransactionDateGetValue = () => {\n const tomorrowDate = new Date();\n tomorrowDate.setDate(tomorrowDate.getDate() + 1);\n tomorrowDate.setHours(0, 0, 0, 0);\n\n const tomorrow = serializeDate(tomorrowDate);\n if (!this.form.next_transaction_date) return tomorrow;\n\n const currentNextDate = parseDate(this.form.next_transaction_date.substring(0, 10));\n if (!currentNextDate || currentNextDate < tomorrowDate) return tomorrow;\n\n return this.form.next_transaction_date;\n };\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.readonlySelector.toString()];\n if (this.form.end_date_preset !== 'custom_date') alwaysMatch.push('end-date');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n const tomorrowDate = new Date();\n tomorrowDate.setDate(tomorrowDate.getDate() + 1);\n tomorrowDate.setHours(0, 0, 0, 0);\n\n const isActive = !!this.data?.is_active;\n const action = isActive ? 'cancel' : 'reactivate';\n const color = isActive ? 'bg-error-10' : 'bg-success-10';\n const icon = isActive\n ? svg`<svg class=\"text-error\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" style=\"width: 2rem; height: 2rem;\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M5.25 7.5A2.25 2.25 0 0 1 7.5 5.25h9a2.25 2.25 0 0 1 2.25 2.25v9a2.25 2.25 0 0 1-2.25 2.25h-9a2.25 2.25 0 0 1-2.25-2.25v-9Z\" /></svg>`\n : svg`<svg class=\"text-success\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" style=\"width: 2rem; height: 2rem;\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99\" /></svg>`;\n\n return html`\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n <div class=\"text-center flex flex-col items-center bg-transparent\">\n <div class=\"rounded-full ${color} p-m mb-s mx-auto\">${icon}</div>\n <p class=\"font-medium text-xl leading-m\">\n <foxy-i18n infer=\"\" key=\"${action}_title\"></foxy-i18n>\n </p>\n <p class=\"text-secondary leading-s\">\n <foxy-i18n infer=\"\" key=\"${action}_subtitle\"></foxy-i18n>\n </p>\n </div>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${isActive\n ? html`\n <foxy-internal-select-control\n options=${this.__endDatePresetOptions}\n layout=\"summary-item\"\n infer=\"end-date-preset\"\n .getValue=${this.__endDatePresetGetValue}\n .setValue=${this.__endDatePresetSetValue}\n >\n </foxy-internal-select-control>\n\n <foxy-internal-date-control\n layout=\"summary-item\"\n infer=\"end-date\"\n min=${serializeDate(tomorrowDate)}\n hide-clear-button\n .getValue=${this.__endDateGetValue}\n >\n </foxy-internal-date-control>\n `\n : html`\n <foxy-internal-date-control\n layout=\"summary-item\"\n infer=\"next-transaction-date\"\n min=${serializeDate(tomorrowDate)}\n hide-clear-button\n .getValue=${this.__nextTransactionDateGetValue}\n >\n </foxy-internal-date-control>\n `}\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${isActive\n ? [\n this.__renderFaq(\n 'cancel_why_not_today',\n svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"text-error flex-shrink-0\" style=\"width: 1.25em; height: 1.25em;\"><path d=\"M5.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H6a.75.75 0 0 1-.75-.75V12ZM6 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H6ZM7.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H8a.75.75 0 0 1-.75-.75V12ZM8 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H8ZM9.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V10ZM10 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H10ZM9.25 14a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V14ZM12 9.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V10a.75.75 0 0 0-.75-.75H12ZM11.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H12a.75.75 0 0 1-.75-.75V12ZM12 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H12ZM13.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H14a.75.75 0 0 1-.75-.75V10ZM14 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H14Z\" /><path fill-rule=\"evenodd\" d=\"M5.75 2a.75.75 0 0 1 .75.75V4h7V2.75a.75.75 0 0 1 1.5 0V4h.25A2.75 2.75 0 0 1 18 6.75v8.5A2.75 2.75 0 0 1 15.25 18H4.75A2.75 2.75 0 0 1 2 15.25v-8.5A2.75 2.75 0 0 1 4.75 4H5V2.75A.75.75 0 0 1 5.75 2Zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75Z\" clip-rule=\"evenodd\" /></svg>`\n ),\n this.__renderFaq(\n 'cancel_whats_next',\n svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"text-error flex-shrink-0\" style=\"width: 1.25em; height: 1.25em;\"><path d=\"M3.288 4.818A1.5 1.5 0 0 0 1 6.095v7.81a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905c.155-.096.285-.213.389-.344v2.973a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905a1.5 1.5 0 0 0 0-2.552l-6.323-3.906A1.5 1.5 0 0 0 10 6.095v2.972a1.506 1.506 0 0 0-.389-.343L3.288 4.818Z\" /></svg>`\n ),\n this.__renderFaq(\n 'cancel_how_to_reactivate',\n svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"text-error flex-shrink-0\" style=\"width: 1.25em; height: 1.25em;\"><path d=\"M6.111 11.89A5.5 5.5 0 1 1 15.501 8 .75.75 0 0 0 17 8a7 7 0 1 0-11.95 4.95.75.75 0 0 0 1.06-1.06Z\" /><path d=\"M8.232 6.232a2.5 2.5 0 0 0 0 3.536.75.75 0 1 1-1.06 1.06A4 4 0 1 1 14 8a.75.75 0 0 1-1.5 0 2.5 2.5 0 0 0-4.268-1.768Z\" /><path d=\"M10.766 7.51a.75.75 0 0 0-1.37.365l-.492 6.861a.75.75 0 0 0 1.204.65l1.043-.799.985 3.678a.75.75 0 0 0 1.45-.388l-.978-3.646 1.292.204a.75.75 0 0 0 .74-1.16l-3.874-5.764Z\" /></svg>`\n ),\n ]\n : [\n this.__renderFaq(\n 'reactivate_why_not_today',\n svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"text-success flex-shrink-0\" style=\"width: 1.25em; height: 1.25em;\"><path d=\"M5.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H6a.75.75 0 0 1-.75-.75V12ZM6 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H6ZM7.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H8a.75.75 0 0 1-.75-.75V12ZM8 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H8ZM9.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V10ZM10 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H10ZM9.25 14a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H10a.75.75 0 0 1-.75-.75V14ZM12 9.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V10a.75.75 0 0 0-.75-.75H12ZM11.25 12a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H12a.75.75 0 0 1-.75-.75V12ZM12 13.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V14a.75.75 0 0 0-.75-.75H12ZM13.25 10a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-.75.75H14a.75.75 0 0 1-.75-.75V10ZM14 11.25a.75.75 0 0 0-.75.75v.01c0 .414.336.75.75.75h.01a.75.75 0 0 0 .75-.75V12a.75.75 0 0 0-.75-.75H14Z\" /><path fill-rule=\"evenodd\" d=\"M5.75 2a.75.75 0 0 1 .75.75V4h7V2.75a.75.75 0 0 1 1.5 0V4h.25A2.75 2.75 0 0 1 18 6.75v8.5A2.75 2.75 0 0 1 15.25 18H4.75A2.75 2.75 0 0 1 2 15.25v-8.5A2.75 2.75 0 0 1 4.75 4H5V2.75A.75.75 0 0 1 5.75 2Zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75Z\" clip-rule=\"evenodd\" /></svg>`\n ),\n this.__renderFaq(\n 'reactivate_whats_next',\n svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"text-success flex-shrink-0\" style=\"width: 1.25em; height: 1.25em;\"><path d=\"M3.288 4.818A1.5 1.5 0 0 0 1 6.095v7.81a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905c.155-.096.285-.213.389-.344v2.973a1.5 1.5 0 0 0 2.288 1.276l6.323-3.905a1.5 1.5 0 0 0 0-2.552l-6.323-3.906A1.5 1.5 0 0 0 10 6.095v2.972a1.506 1.506 0 0 0-.389-.343L3.288 4.818Z\" /></svg>`\n ),\n ]}\n </foxy-internal-summary-control>\n\n <vaadin-button\n theme=\"primary ${isActive ? 'error' : 'success'} large\"\n class=\"w-full\"\n ?disabled=${this.disabled}\n @click=${() => this.submit()}\n >\n <foxy-i18n infer=\"\" key=\"${action}_submit\"></foxy-i18n>\n </vaadin-button>\n `;\n }\n\n submit(): void {\n if (this.data?.is_active) {\n if (this.__endDatePresetGetValue() === 'next_transaction_date') {\n this.edit({ end_date: this.form.next_transaction_date });\n }\n } else {\n this.edit({\n next_transaction_date: this.__nextTransactionDateGetValue(),\n is_active: true,\n end_date: '0000-00-00',\n });\n }\n\n super.submit();\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n delete edits.end_date_preset;\n return super._sendPatch(edits);\n }\n\n private __renderFaq(prefix: string, icon: SVGTemplateResult) {\n return html`\n <div\n class=\"bg-transparent flex leading-xs\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${icon}\n <p class=\"grid\">\n <foxy-i18n class=\"leading-m text-s font-medium\" infer=\"\" key=\"${prefix}_title\">\n </foxy-i18n>\n <foxy-i18n class=\"leading-xs text-secondary text-xs\" infer=\"\" key=\"${prefix}_text\">\n </foxy-i18n>\n </p>\n </div>\n `;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import '@vaadin/vaadin-button';
2
+ import '../../../../internal/InternalSummaryControl/index';
3
+ import '../../../../internal/InternalSelectControl/index';
4
+ import '../../../../internal/InternalDateControl/index';
5
+ import '../../../../internal/InternalForm/index';
6
+ import '../../../I18n/index';
7
+ import { InternalAdminSubscriptionFormStatusActionForm } from './InternalAdminSubscriptionFormStatusActionForm';
8
+ export { InternalAdminSubscriptionFormStatusActionForm };
@@ -0,0 +1,10 @@
1
+ import '@vaadin/vaadin-button';
2
+ import "../../../../internal/InternalSummaryControl/index.js";
3
+ import "../../../../internal/InternalSelectControl/index.js";
4
+ import "../../../../internal/InternalDateControl/index.js";
5
+ import "../../../../internal/InternalForm/index.js";
6
+ import "../../../I18n/index.js";
7
+ import { InternalAdminSubscriptionFormStatusActionForm } from "./InternalAdminSubscriptionFormStatusActionForm.js";
8
+ customElements.define('foxy-internal-admin-subscription-form-status-action-form', InternalAdminSubscriptionFormStatusActionForm);
9
+ export { InternalAdminSubscriptionFormStatusActionForm };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,8DAA2D;AAC3D,6DAA0D;AAC1D,2DAAwD;AACxD,oDAAiD;AAEjD,gCAA6B;AAE7B,OAAO,EAAE,6CAA6C,EAAE,2DAAwD;AAEhH,cAAc,CAAC,MAAM,CACnB,0DAA0D,EAC1D,6CAA6C,CAC9C,CAAC;AAEF,OAAO,EAAE,6CAA6C,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-button';\n\nimport '../../../../internal/InternalSummaryControl/index';\nimport '../../../../internal/InternalSelectControl/index';\nimport '../../../../internal/InternalDateControl/index';\nimport '../../../../internal/InternalForm/index';\n\nimport '../../../I18n/index';\n\nimport { InternalAdminSubscriptionFormStatusActionForm } from './InternalAdminSubscriptionFormStatusActionForm';\n\ncustomElements.define(\n 'foxy-internal-admin-subscription-form-status-action-form',\n InternalAdminSubscriptionFormStatusActionForm\n);\n\nexport { InternalAdminSubscriptionFormStatusActionForm };\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Resource } from '@foxy.io/sdk/core';
2
+ import type { Rels } from '@foxy.io/sdk/backend';
3
+ export declare type Data = Resource<Rels.Subscription> & {
4
+ end_date_preset?: string | null;
5
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/elements/public/AdminSubscriptionForm/internal/InternalAdminSubscriptionFormStatusActionForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nexport type Data = Resource<Rels.Subscription> & { end_date_preset?: string | null };\n"]}
@@ -9,7 +9,7 @@ import { DonationSubmitEvent } from './DonationSubmitEvent';
9
9
  declare global {
10
10
  interface Window {
11
11
  FC?: {
12
- settings: {
12
+ settings?: {
13
13
  session_name: string;
14
14
  session_id: string;
15
15
  };
@@ -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((_b = this.__fcSessionPollInterval) !== null && _b !== void 0 ? _b : void 0);
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;AAkB5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAoNxC;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;QApKpB;;;;WAIG;QACI,aAAQ,GAAkB,IAAI,CAAC;QAEtC;;;;;;WAMG;QACI,WAAM,GAAkB,IAAI,CAAC;QAEpC;;;;;;WAMG;QACI,UAAK,GAAkB,IAAI,CAAC;QAEnC;;;;;WAKG;QACI,SAAI,GAAkB,IAAI,CAAC;QAElC;;;;;WAKG;QACI,WAAM,GAAsB,IAAI,CAAC;QAExC;;;;;;WAMG;QACI,YAAO,GAAoB,IAAI,CAAC;QAEvC;;;;;;;;WAQG;QACI,cAAS,GAAkB,IAAI,C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,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;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAoNxC;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;QApKpB;;;;WAIG;QACI,aAAQ,GAAkB,IAAI,CAAC;QAEtC;;;;;;WAMG;QACI,WAAM,GAAkB,IAAI,CAAC;QAEpC;;;;;;WAMG;QACI,UAAK,GAAkB,IAAI,CAAC;QAEnC;;;;;WAKG;QACI,SAAI,GAAkB,IAAI,CAAC;QAElC;;;;;WAKG;QACI,WAAM,GAAsB,IAAI,CAAC;QAExC;;;;;;WAMG;QACI,YAAO,GAAoB,IAAI,CAAC;QAEvC;;;;;;;;WAQG;QACI,cAAS,GAAkB,IAAI,CAAC;QAEvC;;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I,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"]}
@@ -14,6 +14,8 @@ import { BooleanSelector } from '@foxy.io/sdk/core';
14
14
  export declare class FormDialog extends Dialog {
15
15
  /** @readonly */
16
16
  static get properties(): PropertyDeclarations;
17
+ /** If true, FormDialog won't show the confirmation dialog when the form is dirty. */
18
+ noConfirmWhenDirty: boolean;
17
19
  /** If true, FormDialog will automatically close after the associated form updates the resource. */
18
20
  closeOnPatch: boolean;
19
21
  /** If true, FormDialog won't automatically close after the associated form deletes the resource. */
@@ -17,6 +17,8 @@ import { BooleanSelector } from '@foxy.io/sdk/core';
17
17
  export class FormDialog extends Dialog {
18
18
  constructor() {
19
19
  super(...arguments);
20
+ /** If true, FormDialog won't show the confirmation dialog when the form is dirty. */
21
+ this.noConfirmWhenDirty = false;
20
22
  /** If true, FormDialog will automatically close after the associated form updates the resource. */
21
23
  this.closeOnPatch = false;
22
24
  /** If true, FormDialog won't automatically close after the associated form deletes the resource. */
@@ -76,6 +78,7 @@ export class FormDialog extends Dialog {
76
78
  closeOnPatch: { type: Boolean, attribute: 'close-on-patch' },
77
79
  keepOpenOnPost: { type: Boolean, attribute: 'keep-open-on-post' },
78
80
  keepOpenOnDelete: { type: Boolean, attribute: 'keep-open-on-delete' },
81
+ noConfirmWhenDirty: { type: Boolean, attribute: 'no-confirm-when-dirty' },
79
82
  };
80
83
  }
81
84
  get hiddenSelector() {
@@ -150,7 +153,7 @@ export class FormDialog extends Dialog {
150
153
  `;
151
154
  }
152
155
  async hide(cancelled = false) {
153
- if (cancelled && this.editable) {
156
+ if (cancelled && this.editable && !this.noConfirmWhenDirty) {
154
157
  const confirm = this.renderRoot.querySelector('#confirm');
155
158
  confirm.show();
156
159
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FormDialog.js","sourceRoot":"","sources":["../../../../src/elements/public/FormDialog/FormDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,iCAA8B;AAC5C,OAAO,EAAE,MAAM,EAAE,uCAAoC;AAErD,OAAO,EAAE,UAAU,EAAE,wCAAqC;AAI1D,OAAO,EAAE,WAAW,EAAE,yCAAsC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM;IAAtC;;QAiBE,mGAAmG;QACnG,iBAAY,GAAG,KAAK,CAAC;QAErB,oGAAoG;QACpG,qBAAgB,GAAG,KAAK,CAAC;QAEzB,kGAAkG;QAClG,mBAAc,GAAG,KAAK,CAAC;QAEvB,mEAAmE;QACnE,YAAO,GAAa,EAAE,CAAC;QAEvB,gFAAgF;QAChF,WAAM,GAAG,EAAE,CAAC;QAEZ,yEAAyE;QACzE,UAAK,GAA4B,EAAE,CAAC;QAEpC,UAAK,GAAG,EAAE,CAAC;QAEX,6DAA6D;QAC7D,SAAI,GAAG,EAAE,CAAC;QAEF,WAAM,GAAiC,IAAI,CAAC;QAE5C,iBAAY,GAAwB,IAAI,CAAC;QAEzC,kBAAa,GAAG,CAAC,GAAU,EAAE,EAAE;YACrC,IAAI,CAAC,CAAC,GAAG,YAAY,UAAU,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aACK,KAAK;;+DAE6C,KAAK;;;;;;;;;;;;;;;;;cAiBtD,KAAK,KAAK,CACD,CAAC;SACnB;aAAM;YACL,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC3B;QAED,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED,gBAAgB;IAChB,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;eAOA,IAAI,CAAC,IAAI;aACX,IAAI,CAAC,EAAE;;gBAEJ,CAAC,GAAoB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;;;QAI3E,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE;;YAClB,OAAO,IAAI,CAAA,GAAG,MAAA,IAAI,CAAC,YAAY,+CAAjB,IAAI,EAAgB;gBAChC,YAAY,EAAE,IAAI,CAAC,cAAc;gBACjC,WAAW,EAAE,IAAI,CAAC,aAAa;gBAC/B,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,IAAI;gBACZ,IAAI;aACL,CAAC,EAAE,CAAC;QACP,CAAC,CAAC;KACH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK;QAC1B,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAA0B,CAAC;YACnF,OAAO,CAAC,IAAI,EAAE,CAAC;SAChB;aAAM;YACL,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9B;IACH,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,IAAI;QACP,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAA2B,CAAC,MAAM,EAAE,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import { PropertyDeclarations, TemplateResult, html } from 'lit-element';\n\nimport { API } from '../NucleonElement/API';\nimport { Dialog } from '../../private/Dialog/Dialog';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { FetchEvent } from '../NucleonElement/FetchEvent';\nimport { FormRenderer } from './types';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { UpdateEvent } from '../NucleonElement/UpdateEvent';\nimport { spread } from '@open-wc/lit-helpers';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\n\n/**\n * Dialog wrapper for the forms made with NucleonElement.\n *\n * @fires FormDialog#show - Instance of `FormDialog.ShowEvent`. Dispatched after dialog finishes entry transition.\n * @fires FormDialog#hide - Instance of `FormDialog.HideEvent`. Dispatched after dialog finishes exit transition.\n *\n * @element foxy-form-dialog\n * @since 1.1.0\n */\nexport class FormDialog extends Dialog {\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n href: { type: String },\n form: { type: String, noAccessor: true },\n group: { type: String },\n props: { type: Object },\n parent: { type: String },\n related: { type: Array },\n closeOnPatch: { type: Boolean, attribute: 'close-on-patch' },\n keepOpenOnPost: { type: Boolean, attribute: 'keep-open-on-post' },\n keepOpenOnDelete: { type: Boolean, attribute: 'keep-open-on-delete' },\n };\n }\n\n /** If true, FormDialog will automatically close after the associated form updates the resource. */\n closeOnPatch = false;\n\n /** If true, FormDialog won't automatically close after the associated form deletes the resource. */\n keepOpenOnDelete = false;\n\n /** If true, FormDialog won't automatically close after the associated form creates a resource. */\n keepOpenOnPost = false;\n\n /** Optional URI list of the related resources (passed to form). */\n related: string[] = [];\n\n /** Optional URL of the collection this resource belongs to (passed to form). */\n parent = '';\n\n /** Properties to set on the form element using the `spread()` helper. */\n props: Record<string, unknown> = {};\n\n group = '';\n\n /** Optional URL of the resource to load (passed to form). */\n href = '';\n\n private __form: string | null | FormRenderer = null;\n\n private __renderForm: FormRenderer | null = null;\n\n private __handleFetch = (evt: Event) => {\n if (!(evt instanceof FetchEvent)) return;\n\n evt.stopImmediatePropagation();\n evt.preventDefault();\n evt.respondWith(new API(this).fetch(evt.request));\n };\n\n private __handleUpdate = (evt: Event) => {\n if (!(evt instanceof UpdateEvent)) return;\n\n const result = evt.detail?.result;\n const Result = UpdateEvent.UpdateResult;\n const target = evt.currentTarget as NucleonElement<never>;\n\n if (\n (!this.keepOpenOnDelete && result === Result.ResourceDeleted) ||\n (!this.keepOpenOnPost && result === Result.ResourceCreated) ||\n (this.closeOnPatch && result === Result.ResourceUpdated && target.errors.length === 0)\n ) {\n this.open = false;\n }\n\n if (this.parent !== target.parent) this.parent = target.parent;\n if (this.href !== target.href) this.href = target.href;\n\n this.closable = !target.in('busy');\n this.editable =\n target.in({ idle: { template: { dirty: 'valid' } } }) ||\n target.in({ idle: { snapshot: { dirty: 'valid' } } });\n };\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`submit undo ${super.hiddenSelector}`.trim());\n }\n\n /**\n * Form's custom element tag. Generated custom element will have the following attributes:\n *\n * - `parent` – same as `foxy-form-dialog[parent]`;\n * - `href` – same as `foxy-form-dialog[href]`;\n * - `lang` – same as `foxy-form-dialog[lang]`;\n */\n get form(): string | null | FormRenderer {\n return this.__form;\n }\n\n set form(value: string | null | FormRenderer) {\n this.__form = value;\n\n if (typeof value === 'string') {\n this.__renderForm = new Function(\n 'options',\n `return options.html\\`\n <${value}\n id=\"form\"\n ns=\"$\\{options.dialog.ns} $\\{customElements.get('${value}')?.defaultNS ?? ''}\"\n href=\\${options.dialog.href}\n lang=\\${options.dialog.lang}\n group=\\${options.dialog.group}\n parent=\\${options.dialog.parent}\n disabledcontrols=\\${options.dialog.disabledSelector.toString()}\n readonlycontrols=\\${options.dialog.readonlySelector.toString()}\n hiddencontrols=\\${options.dialog.hiddenSelector.toString()}\n ?disabled=\\${options.dialog.disabled}\n ?readonly=\\${options.dialog.readonly}\n ?hidden=\\${options.dialog.hidden}\n .templates=\\${options.dialog.templates}\n .related=\\${options.dialog.related}\n ...=$\\{options.spread(options.dialog.props)}\n @fetch=\\${options.handleFetch}\n @update=\\${options.handleUpdate}\n >\n </${value}>\\``\n ) as FormRenderer;\n } else {\n this.__renderForm = value;\n }\n\n this.requestUpdate();\n }\n\n /** @readonly */\n render(): TemplateResult {\n return html`\n <foxy-internal-confirm-dialog\n message=\"undo_message\"\n confirm=\"undo_confirm\"\n cancel=\"undo_cancel\"\n header=\"undo_header\"\n theme=\"error\"\n lang=${this.lang}\n ns=${this.ns}\n id=\"confirm\"\n @hide=${(evt: DialogHideEvent) => !evt.detail.cancelled && super.hide(true)}\n >\n </foxy-internal-confirm-dialog>\n\n ${super.render(() => {\n return html`${this.__renderForm?.({\n handleUpdate: this.__handleUpdate,\n handleFetch: this.__handleFetch,\n spread: spread,\n dialog: this,\n html,\n })}`;\n })}\n `;\n }\n\n async hide(cancelled = false): Promise<void> {\n if (cancelled && this.editable) {\n const confirm = this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\n confirm.show();\n } else {\n return super.hide(cancelled);\n }\n }\n\n /** Submits the form. */\n async save(): Promise<void> {\n (this.renderRoot.querySelector('#form') as NucleonElement<never>).submit();\n }\n}\n"]}
1
+ {"version":3,"file":"FormDialog.js","sourceRoot":"","sources":["../../../../src/elements/public/FormDialog/FormDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,iCAA8B;AAC5C,OAAO,EAAE,MAAM,EAAE,uCAAoC;AAErD,OAAO,EAAE,UAAU,EAAE,wCAAqC;AAI1D,OAAO,EAAE,WAAW,EAAE,yCAAsC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM;IAAtC;;QAkBE,qFAAqF;QACrF,uBAAkB,GAAG,KAAK,C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,EAAE,IAAI;gBACZ,IAAI;aACL,CAAC,EAAE,CAAC;QACP,CAAC,CAAC;KACH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK;QAC1B,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAA0B,CAAC;YACnF,OAAO,CAAC,IAAI,EAAE,CAAC;SAChB;aAAM;YACL,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9B;IACH,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,IAAI;QACP,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAA2B,CAAC,MAAM,EAAE,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import { PropertyDeclarations, TemplateResult, html } from 'lit-element';\n\nimport { API } from '../NucleonElement/API';\nimport { Dialog } from '../../private/Dialog/Dialog';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { FetchEvent } from '../NucleonElement/FetchEvent';\nimport { FormRenderer } from './types';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { UpdateEvent } from '../NucleonElement/UpdateEvent';\nimport { spread } from '@open-wc/lit-helpers';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\n\n/**\n * Dialog wrapper for the forms made with NucleonElement.\n *\n * @fires FormDialog#show - Instance of `FormDialog.ShowEvent`. Dispatched after dialog finishes entry transition.\n * @fires FormDialog#hide - Instance of `FormDialog.HideEvent`. Dispatched after dialog finishes exit transition.\n *\n * @element foxy-form-dialog\n * @since 1.1.0\n */\nexport class FormDialog extends Dialog {\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n href: { type: String },\n form: { type: String, noAccessor: true },\n group: { type: String },\n props: { type: Object },\n parent: { type: String },\n related: { type: Array },\n closeOnPatch: { type: Boolean, attribute: 'close-on-patch' },\n keepOpenOnPost: { type: Boolean, attribute: 'keep-open-on-post' },\n keepOpenOnDelete: { type: Boolean, attribute: 'keep-open-on-delete' },\n noConfirmWhenDirty: { type: Boolean, attribute: 'no-confirm-when-dirty' },\n };\n }\n\n /** If true, FormDialog won't show the confirmation dialog when the form is dirty. */\n noConfirmWhenDirty = false;\n\n /** If true, FormDialog will automatically close after the associated form updates the resource. */\n closeOnPatch = false;\n\n /** If true, FormDialog won't automatically close after the associated form deletes the resource. */\n keepOpenOnDelete = false;\n\n /** If true, FormDialog won't automatically close after the associated form creates a resource. */\n keepOpenOnPost = false;\n\n /** Optional URI list of the related resources (passed to form). */\n related: string[] = [];\n\n /** Optional URL of the collection this resource belongs to (passed to form). */\n parent = '';\n\n /** Properties to set on the form element using the `spread()` helper. */\n props: Record<string, unknown> = {};\n\n group = '';\n\n /** Optional URL of the resource to load (passed to form). */\n href = '';\n\n private __form: string | null | FormRenderer = null;\n\n private __renderForm: FormRenderer | null = null;\n\n private __handleFetch = (evt: Event) => {\n if (!(evt instanceof FetchEvent)) return;\n\n evt.stopImmediatePropagation();\n evt.preventDefault();\n evt.respondWith(new API(this).fetch(evt.request));\n };\n\n private __handleUpdate = (evt: Event) => {\n if (!(evt instanceof UpdateEvent)) return;\n\n const result = evt.detail?.result;\n const Result = UpdateEvent.UpdateResult;\n const target = evt.currentTarget as NucleonElement<never>;\n\n if (\n (!this.keepOpenOnDelete && result === Result.ResourceDeleted) ||\n (!this.keepOpenOnPost && result === Result.ResourceCreated) ||\n (this.closeOnPatch && result === Result.ResourceUpdated && target.errors.length === 0)\n ) {\n this.open = false;\n }\n\n if (this.parent !== target.parent) this.parent = target.parent;\n if (this.href !== target.href) this.href = target.href;\n\n this.closable = !target.in('busy');\n this.editable =\n target.in({ idle: { template: { dirty: 'valid' } } }) ||\n target.in({ idle: { snapshot: { dirty: 'valid' } } });\n };\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`submit undo ${super.hiddenSelector}`.trim());\n }\n\n /**\n * Form's custom element tag. Generated custom element will have the following attributes:\n *\n * - `parent` – same as `foxy-form-dialog[parent]`;\n * - `href` – same as `foxy-form-dialog[href]`;\n * - `lang` – same as `foxy-form-dialog[lang]`;\n */\n get form(): string | null | FormRenderer {\n return this.__form;\n }\n\n set form(value: string | null | FormRenderer) {\n this.__form = value;\n\n if (typeof value === 'string') {\n this.__renderForm = new Function(\n 'options',\n `return options.html\\`\n <${value}\n id=\"form\"\n ns=\"$\\{options.dialog.ns} $\\{customElements.get('${value}')?.defaultNS ?? ''}\"\n href=\\${options.dialog.href}\n lang=\\${options.dialog.lang}\n group=\\${options.dialog.group}\n parent=\\${options.dialog.parent}\n disabledcontrols=\\${options.dialog.disabledSelector.toString()}\n readonlycontrols=\\${options.dialog.readonlySelector.toString()}\n hiddencontrols=\\${options.dialog.hiddenSelector.toString()}\n ?disabled=\\${options.dialog.disabled}\n ?readonly=\\${options.dialog.readonly}\n ?hidden=\\${options.dialog.hidden}\n .templates=\\${options.dialog.templates}\n .related=\\${options.dialog.related}\n ...=$\\{options.spread(options.dialog.props)}\n @fetch=\\${options.handleFetch}\n @update=\\${options.handleUpdate}\n >\n </${value}>\\``\n ) as FormRenderer;\n } else {\n this.__renderForm = value;\n }\n\n this.requestUpdate();\n }\n\n /** @readonly */\n render(): TemplateResult {\n return html`\n <foxy-internal-confirm-dialog\n message=\"undo_message\"\n confirm=\"undo_confirm\"\n cancel=\"undo_cancel\"\n header=\"undo_header\"\n theme=\"error\"\n lang=${this.lang}\n ns=${this.ns}\n id=\"confirm\"\n @hide=${(evt: DialogHideEvent) => !evt.detail.cancelled && super.hide(true)}\n >\n </foxy-internal-confirm-dialog>\n\n ${super.render(() => {\n return html`${this.__renderForm?.({\n handleUpdate: this.__handleUpdate,\n handleFetch: this.__handleFetch,\n spread: spread,\n dialog: this,\n html,\n })}`;\n })}\n `;\n }\n\n async hide(cancelled = false): Promise<void> {\n if (cancelled && this.editable && !this.noConfirmWhenDirty) {\n const confirm = this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\n confirm.show();\n } else {\n return super.hide(cancelled);\n }\n }\n\n /** Submits the form. */\n async save(): Promise<void> {\n (this.renderRoot.querySelector('#form') as NucleonElement<never>).submit();\n }\n}\n"]}
@@ -37,6 +37,7 @@ export declare class PaymentsApiPaymentMethodForm extends Base<Data> {
37
37
  private readonly __threeDSecureToggleSetValue;
38
38
  private readonly __threeDSecureToggleOptions;
39
39
  private readonly __cardVerificationOptions;
40
+ private __search;
40
41
  get hiddenSelector(): BooleanSelector;
41
42
  renderHeader(...params: Parameters<InternalForm<Data>['renderHeader']>): TemplateResult;
42
43
  get headerTitleOptions(): Record<string, unknown>;