@foxy.io/elements 1.25.0-beta.3 → 1.25.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) 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-api-browser.js +1 -1
  6. package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
  7. package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
  8. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  9. package/dist/cdn/foxy-attribute-card.js +1 -1
  10. package/dist/cdn/foxy-attribute-form.js +1 -1
  11. package/dist/cdn/foxy-billing-address-card.js +1 -1
  12. package/dist/cdn/foxy-cancellation-form.js +1 -1
  13. package/dist/cdn/foxy-cart-card.js +1 -1
  14. package/dist/cdn/foxy-cart-form.js +1 -1
  15. package/dist/cdn/foxy-client-card.js +1 -1
  16. package/dist/cdn/foxy-client-form.js +1 -1
  17. package/dist/cdn/foxy-collection-page.js +1 -1
  18. package/dist/cdn/foxy-collection-pages.js +1 -1
  19. package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
  20. package/dist/cdn/foxy-coupon-card.js +1 -1
  21. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  22. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  23. package/dist/cdn/foxy-coupon-detail-card.js +1 -1
  24. package/dist/cdn/foxy-coupon-form.js +1 -1
  25. package/dist/cdn/foxy-custom-field-card.js +1 -1
  26. package/dist/cdn/foxy-custom-field-form.js +1 -1
  27. package/dist/cdn/foxy-customer-card.js +1 -1
  28. package/dist/cdn/foxy-customer-form.js +1 -1
  29. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  30. package/dist/cdn/foxy-customer-portal.js +1 -1
  31. package/dist/cdn/foxy-customer.js +1 -1
  32. package/dist/cdn/foxy-customers-table.js +1 -1
  33. package/dist/cdn/foxy-discount-builder.js +1 -1
  34. package/dist/cdn/foxy-discount-card.js +1 -1
  35. package/dist/cdn/foxy-discount-detail-card.js +1 -1
  36. package/dist/cdn/foxy-donation.js +1 -1
  37. package/dist/cdn/foxy-downloadable-card.js +1 -1
  38. package/dist/cdn/foxy-downloadable-form.js +1 -1
  39. package/dist/cdn/foxy-email-template-card.js +1 -1
  40. package/dist/cdn/foxy-email-template-form.js +1 -1
  41. package/dist/cdn/foxy-error-entry-card.js +1 -1
  42. package/dist/cdn/foxy-filter-attribute-card.js +1 -1
  43. package/dist/cdn/foxy-filter-attribute-form.js +1 -1
  44. package/dist/cdn/foxy-form-dialog.js +1 -1
  45. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  46. package/dist/cdn/foxy-gift-card-card.js +1 -1
  47. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  48. package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
  49. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  50. package/dist/cdn/foxy-gift-card-form.js +1 -1
  51. package/dist/cdn/foxy-i18n-editor.js +2 -2
  52. package/dist/cdn/foxy-i18n.js +1 -1
  53. package/dist/cdn/foxy-integration-card.js +1 -1
  54. package/dist/cdn/foxy-integration-form.js +1 -1
  55. package/dist/cdn/foxy-item-card.js +1 -1
  56. package/dist/cdn/foxy-item-category-card.js +1 -1
  57. package/dist/cdn/foxy-item-category-form.js +1 -1
  58. package/dist/cdn/foxy-item-form.js +4 -4
  59. package/dist/cdn/foxy-item-option-card.js +1 -1
  60. package/dist/cdn/foxy-item-option-form.js +1 -1
  61. package/dist/cdn/foxy-items-form.js +1 -1
  62. package/dist/cdn/foxy-native-integration-card.js +1 -1
  63. package/dist/cdn/foxy-native-integration-form.js +1 -1
  64. package/dist/cdn/foxy-pagination.js +1 -1
  65. package/dist/cdn/foxy-passkey-card.js +1 -1
  66. package/dist/cdn/foxy-passkey-form.js +1 -1
  67. package/dist/cdn/foxy-payment-card.js +1 -1
  68. package/dist/cdn/foxy-payment-method-card.js +1 -1
  69. package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
  70. package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
  71. package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
  72. package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
  73. package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
  74. package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
  75. package/dist/cdn/foxy-query-builder.js +1 -1
  76. package/dist/cdn/foxy-report-form.js +5 -5
  77. package/dist/cdn/foxy-reports-table.js +1 -1
  78. package/dist/cdn/foxy-shipment-card.js +1 -1
  79. package/dist/cdn/foxy-shipping-method-card.js +1 -1
  80. package/dist/cdn/foxy-sign-in-form.js +1 -1
  81. package/dist/cdn/foxy-spinner.js +2 -2
  82. package/dist/cdn/foxy-store-card.js +1 -1
  83. package/dist/cdn/foxy-store-form.js +1 -1
  84. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  85. package/dist/cdn/foxy-subscription-card.js +1 -1
  86. package/dist/cdn/foxy-subscription-form.js +2 -96
  87. package/dist/cdn/foxy-subscription-settings-form.js +1 -1
  88. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  89. package/dist/cdn/foxy-table.js +1 -1
  90. package/dist/cdn/foxy-tax-card.js +1 -1
  91. package/dist/cdn/foxy-tax-form.js +1 -1
  92. package/dist/cdn/foxy-template-config-form.js +1 -1
  93. package/dist/cdn/foxy-template-form.js +1 -1
  94. package/dist/cdn/foxy-template-set-card.js +1 -1
  95. package/dist/cdn/foxy-template-set-form.js +1 -1
  96. package/dist/cdn/foxy-transaction-card.js +95 -1
  97. package/dist/cdn/foxy-transaction.js +1 -1
  98. package/dist/cdn/foxy-transactions-table.js +7 -7
  99. package/dist/cdn/foxy-user-card.js +1 -1
  100. package/dist/cdn/foxy-user-form.js +1 -1
  101. package/dist/cdn/foxy-users-table.js +1 -1
  102. package/dist/cdn/foxy-webhook-card.js +1 -1
  103. package/dist/cdn/foxy-webhook-form.js +1 -1
  104. package/dist/cdn/foxy-webhook-log-card.js +1 -1
  105. package/dist/cdn/foxy-webhook-status-card.js +1 -1
  106. package/dist/cdn/{shared-b113467e.js → shared-00c2793e.js} +1 -1
  107. package/dist/cdn/{shared-15dfa16d.js → shared-029816d7.js} +1 -1
  108. package/dist/cdn/{shared-61b1fd60.js → shared-02bc0368.js} +1 -1
  109. package/dist/cdn/{shared-87f55237.js → shared-174f37e9.js} +1 -1
  110. package/dist/cdn/{shared-3f3903d4.js → shared-20ba4cdc.js} +1 -1
  111. package/dist/cdn/{shared-06916671.js → shared-268571df.js} +1 -1
  112. package/dist/cdn/{shared-8d99b885.js → shared-2b27e2e7.js} +1 -1
  113. package/dist/cdn/{shared-979e24ec.js → shared-2bdc99f4.js} +1 -1
  114. package/dist/cdn/{shared-3d95605f.js → shared-2c8c4b43.js} +3 -3
  115. package/dist/cdn/shared-2cf08dd4.js +1 -0
  116. package/dist/cdn/{shared-f8d1abc9.js → shared-2f09d4df.js} +4 -4
  117. package/dist/cdn/{shared-54cbd346.js → shared-30d00b64.js} +1 -1
  118. package/dist/cdn/{shared-d9f4138b.js → shared-32e736eb.js} +1 -1
  119. package/dist/cdn/{shared-a1d39ddd.js → shared-43f449bb.js} +1 -1
  120. package/dist/cdn/{shared-87824001.js → shared-4462dc70.js} +2 -2
  121. package/dist/cdn/{shared-02f8245a.js → shared-4aa4d980.js} +1 -1
  122. package/dist/cdn/{shared-63d11888.js → shared-4c124efc.js} +7 -7
  123. package/dist/cdn/shared-4c650e5c.js +1 -0
  124. package/dist/cdn/{shared-b984ab7c.js → shared-4e59fd48.js} +16 -16
  125. package/dist/cdn/{shared-69c3549d.js → shared-54b0e48f.js} +1 -1
  126. package/dist/cdn/{shared-ecd5eb1b.js → shared-5fa697c4.js} +1 -1
  127. package/dist/cdn/shared-61ade33e.js +6 -0
  128. package/dist/cdn/{shared-3bd99d11.js → shared-6a9ae42e.js} +1 -1
  129. package/dist/cdn/{shared-a95067d6.js → shared-76400719.js} +1 -1
  130. package/dist/cdn/{shared-ceec93fa.js → shared-7dd17943.js} +1 -1
  131. package/dist/cdn/{shared-ea1ab750.js → shared-7deff07c.js} +1 -1
  132. package/dist/cdn/{shared-fad099e6.js → shared-7e1953f5.js} +1 -1
  133. package/dist/cdn/shared-8201d0b5.js +1 -0
  134. package/dist/cdn/{shared-29e74661.js → shared-8952aeac.js} +1 -1
  135. package/dist/cdn/{shared-320fadbf.js → shared-896982f9.js} +1 -1
  136. package/dist/cdn/{shared-a5a03f4f.js → shared-8d8bed82.js} +1 -1
  137. package/dist/cdn/{shared-92dd9964.js → shared-99c0ae04.js} +1 -1
  138. package/dist/cdn/{shared-6ffa9f84.js → shared-9c08cfab.js} +1 -1
  139. package/dist/cdn/{shared-0ffe26d8.js → shared-9df8f842.js} +2 -2
  140. package/dist/cdn/{shared-0961f769.js → shared-a8dc23f1.js} +1 -1
  141. package/dist/cdn/{shared-3fee360a.js → shared-ac7c5a5e.js} +14 -14
  142. package/dist/cdn/{shared-5db2fec0.js → shared-ad34b6db.js} +1 -1
  143. package/dist/cdn/{shared-a1be9c27.js → shared-b1b8ea67.js} +1 -1
  144. package/dist/cdn/{shared-85712eed.js → shared-b509bc2c.js} +1 -1
  145. package/dist/cdn/{shared-de8bf756.js → shared-bc0d8d01.js} +2 -2
  146. package/dist/cdn/{shared-4105aacf.js → shared-be7bfbb0.js} +1 -1
  147. package/dist/cdn/{shared-745a575c.js → shared-bed7aae1.js} +1 -1
  148. package/dist/cdn/{shared-5291bdca.js → shared-c7b3d22b.js} +3 -3
  149. package/dist/cdn/{shared-264c82b8.js → shared-c9ba1b64.js} +3 -3
  150. package/dist/cdn/{shared-c43cd1fa.js → shared-ca4c5f0f.js} +1 -1
  151. package/dist/cdn/{shared-efbd62cb.js → shared-cdd2358f.js} +4 -4
  152. package/dist/cdn/{shared-d8ca5c87.js → shared-d21fa1a6.js} +1 -1
  153. package/dist/cdn/{shared-835cf735.js → shared-d57fac94.js} +1 -1
  154. package/dist/cdn/{shared-d600815d.js → shared-dbadd9cf.js} +1 -1
  155. package/dist/cdn/{shared-452e38da.js → shared-e39807f8.js} +1 -1
  156. package/dist/cdn/{shared-25edf241.js → shared-e83f2983.js} +1 -1
  157. package/dist/cdn/{shared-d1265ca0.js → shared-e91453df.js} +1 -1
  158. package/dist/cdn/{shared-5f1f0d8f.js → shared-ea527e98.js} +1 -1
  159. package/dist/cdn/shared-f9a3d1ff.js +6 -0
  160. package/dist/cdn/{shared-324665fd.js → shared-fa4f6cd3.js} +1 -1
  161. package/dist/cdn/shared-fc15a882.js +1 -0
  162. package/dist/cdn/{shared-2c92c192.js → shared-ff8ca16b.js} +1 -1
  163. package/dist/cdn/{shared-6d0be1e4.js → shared-ff9791cf.js} +1 -1
  164. package/dist/cdn/translations/cart-form/en.json +7 -6
  165. package/dist/cdn/translations/customer/en.json +23 -14
  166. package/dist/cdn/translations/customer-portal/en.json +22 -13
  167. package/dist/cdn/translations/item-card/en.json +1 -0
  168. package/dist/cdn/translations/item-form/en.json +2 -2
  169. package/dist/cdn/translations/payments-api-payment-preset-form/en.json +2 -2
  170. package/dist/cdn/translations/shipment-card/en.json +1 -0
  171. package/dist/cdn/translations/subscription-form/en.json +23 -14
  172. package/dist/cdn/translations/transaction/en.json +27 -26
  173. package/dist/cdn/translations/transaction-card/en.json +22 -22
  174. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControl.js +28 -23
  175. package/dist/elements/internal/InternalAsyncListControl/InternalAsyncListControl.js.map +1 -1
  176. package/dist/elements/internal/InternalControl/InternalControl.js +2 -1
  177. package/dist/elements/internal/InternalControl/InternalControl.js.map +1 -1
  178. package/dist/elements/private/Dialog/Dialog.js +7 -1
  179. package/dist/elements/private/Dialog/Dialog.js.map +1 -1
  180. package/dist/elements/public/ItemCard/ItemCard.js +4 -2
  181. package/dist/elements/public/ItemCard/ItemCard.js.map +1 -1
  182. package/dist/elements/public/ItemsForm/private/Item.js +1 -0
  183. package/dist/elements/public/ItemsForm/private/Item.js.map +1 -1
  184. package/dist/elements/public/ShipmentCard/ShipmentCard.js +5 -2
  185. package/dist/elements/public/ShipmentCard/ShipmentCard.js.map +1 -1
  186. package/dist/elements/public/Transaction/Transaction.d.ts +2 -3
  187. package/dist/elements/public/Transaction/Transaction.js +129 -127
  188. package/dist/elements/public/Transaction/Transaction.js.map +1 -1
  189. package/dist/elements/public/Transaction/types.d.ts +9 -8
  190. package/dist/elements/public/Transaction/types.js.map +1 -1
  191. package/dist/elements/public/TransactionCard/TransactionCard.d.ts +8 -10
  192. package/dist/elements/public/TransactionCard/TransactionCard.js +71 -51
  193. package/dist/elements/public/TransactionCard/TransactionCard.js.map +1 -1
  194. package/dist/elements/public/TransactionCard/index.d.ts +2 -1
  195. package/dist/elements/public/TransactionCard/index.js +2 -1
  196. package/dist/elements/public/TransactionCard/index.js.map +1 -1
  197. package/dist/elements/public/TransactionCard/types.d.ts +8 -2
  198. package/dist/elements/public/TransactionCard/types.js.map +1 -1
  199. package/dist/mixins/themeable.js +4 -0
  200. package/dist/mixins/themeable.js.map +1 -1
  201. package/package.json +1 -1
  202. package/dist/cdn/shared-4761cbda.js +0 -1
  203. package/dist/cdn/shared-87142858.js +0 -1
  204. package/dist/cdn/shared-e9276306.js +0 -1
  205. package/dist/cdn/shared-eacc4539.js +0 -1
  206. package/dist/cdn/shared-ec59505f.js +0 -12
  207. package/dist/cdn/shared-f3cd4d07.js +0 -1
@@ -40,7 +40,8 @@ export class InternalControl extends ConfigurableMixin(TranslatableMixin(Themeab
40
40
  var _a, _b;
41
41
  super.applyInferredProperties(context);
42
42
  this.nucleon = (_a = context.get('nucleon')) !== null && _a !== void 0 ? _a : null;
43
- this.disabled = ((_b = this.nucleon) === null || _b === void 0 ? void 0 : _b.in('idle')) === false || super.disabled;
43
+ if (((_b = this.nucleon) === null || _b === void 0 ? void 0 : _b.in('idle')) === false)
44
+ this.disabled = true;
44
45
  }
45
46
  updated(changes) {
46
47
  super.updated(changes);
@@ -1 +1 @@
1
- {"version":3,"file":"InternalControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalControl/InternalControl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,cAAc,EAAE,sDAAmD;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB,CACpD,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAC/D;IAFD;;QAcE,wDAAwD;QACxD,YAAO,GAA+B,IAAI,CAAC;IA+C7C,CAAC;IA3DC,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,GAAG,KAAK,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAKD,gBAAgB,CAAC,GAAW,EAAE,OAAoB;QAChD,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,YAAY,cAAc;YAAE,OAAO,OAAO,CAAC;QAC3E,OAAO,KAAK,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,uBAAuB,CAAC,OAA6B;;QACnD,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,CAAC,OAAO,SAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAqC,mCAAI,IAAI,CAAC;QACnF,IAAI,CAAC,QAAQ,GAAG,OAAA,IAAI,CAAC,OAAO,0CAAE,EAAE,CAAC,MAAM,OAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC;IACvE,CAAC;IAED,OAAO,CAAC,OAAiC;QACvC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;YAClC,MAAM,gBAAgB,GAAG,IAAI,CAAA;sBACb,IAAI,CAAC,KAAK;sBACV,IAAI,CAAC,KAAK;OACzB,CAAC;YAEF,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;SAChC;IACH,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAA,EAAE,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE;QACzE,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;KACnD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport { render } from 'lit-html';\n\n/**\n * An internal base class for any control in a Nucleon form. That control can be as simple as a text field bound\n * to a property or as complex as a query builder, and it infers property values from the\n * parent Nucleon/Configurable/Translatable element, saving the need to manually calculate\n * and bind properties in Lit templates. Each control renders before and after slots in the regular DOM + its\n * own layout in the shadow DOM. When hidden via `hiddencontrols` in the parent,\n * uses `display: none` to hide itself.\n *\n * @element foxy-internal-control\n * @since 1.17.0\n */\nexport class InternalControl extends ConfigurableMixin(\n TranslatableMixin(ThemeableMixin(InferrableMixin(LitElement)))\n) {\n static get inferredProperties(): string[] {\n return [...super.inferredProperties, 'nucleon'];\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n nucleon: { attribute: false },\n };\n }\n\n /** NucleonElement instance this control is bound to. */\n nucleon: NucleonElement<any> | null = null;\n\n inferFromElement(key: string, element: HTMLElement): unknown | undefined {\n if (key === 'nucleon' && element instanceof NucleonElement) return element;\n return super.inferFromElement(key, element);\n }\n\n applyInferredProperties(context: Map<string, unknown>): void {\n super.applyInferredProperties(context);\n\n this.nucleon = (context.get('nucleon') as NucleonElement<any> | undefined) ?? null;\n this.disabled = this.nucleon?.in('idle') === false || super.disabled;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n\n if (typeof this.infer === 'string') {\n const lightDomTemplate = html`\n <slot name=\"${this.infer}:before\" slot=\"before\"></slot>\n <slot name=\"${this.infer}:after\" slot=\"after\"></slot>\n `;\n\n render(lightDomTemplate, this);\n }\n }\n\n /**\n * Renders the control itself. In most cases, you will need to implement\n * this method instead of `.render()` in your class to keep the before and after templates/slots.\n */\n renderControl(): TemplateResult {\n return html``;\n }\n\n /**\n * Renders the control (if visible) and the before/after templates/slots.\n * You should probably implement `.renderControl()` method instead of this one in your class.\n */\n render(): TemplateResult {\n if (this.hidden) return html``;\n\n return html`\n ${this.renderTemplateOrSlot('before', this.nucleon)} ${this.renderControl()}\n ${this.renderTemplateOrSlot('after', this.nucleon)}\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"InternalControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalControl/InternalControl.ts"],"names":[],"mappings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AAG,IAAI,CAAC;IAC/D,CAAC;IAED,OAAO,CAAC,OAAiC;QACvC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;YAClC,MAAM,gBAAgB,GAAG,IAAI,CAAA;sBACb,IAAI,CAAC,KAAK;sBACV,IAAI,CAAC,KAAK;OACzB,CAAC;YAEF,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;SAChC;IACH,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAA,EAAE,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE;QACzE,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;KACnD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport { render } from 'lit-html';\n\n/**\n * An internal base class for any control in a Nucleon form. That control can be as simple as a text field bound\n * to a property or as complex as a query builder, and it infers property values from the\n * parent Nucleon/Configurable/Translatable element, saving the need to manually calculate\n * and bind properties in Lit templates. Each control renders before and after slots in the regular DOM + its\n * own layout in the shadow DOM. When hidden via `hiddencontrols` in the parent,\n * uses `display: none` to hide itself.\n *\n * @element foxy-internal-control\n * @since 1.17.0\n */\nexport class InternalControl extends ConfigurableMixin(\n TranslatableMixin(ThemeableMixin(InferrableMixin(LitElement)))\n) {\n static get inferredProperties(): string[] {\n return [...super.inferredProperties, 'nucleon'];\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n nucleon: { attribute: false },\n };\n }\n\n /** NucleonElement instance this control is bound to. */\n nucleon: NucleonElement<any> | null = null;\n\n inferFromElement(key: string, element: HTMLElement): unknown | undefined {\n if (key === 'nucleon' && element instanceof NucleonElement) return element;\n return super.inferFromElement(key, element);\n }\n\n applyInferredProperties(context: Map<string, unknown>): void {\n super.applyInferredProperties(context);\n\n this.nucleon = (context.get('nucleon') as NucleonElement<any> | undefined) ?? null;\n if (this.nucleon?.in('idle') === false) this.disabled = true;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n\n if (typeof this.infer === 'string') {\n const lightDomTemplate = html`\n <slot name=\"${this.infer}:before\" slot=\"before\"></slot>\n <slot name=\"${this.infer}:after\" slot=\"after\"></slot>\n `;\n\n render(lightDomTemplate, this);\n }\n }\n\n /**\n * Renders the control itself. In most cases, you will need to implement\n * this method instead of `.render()` in your class to keep the before and after templates/slots.\n */\n renderControl(): TemplateResult {\n return html``;\n }\n\n /**\n * Renders the control (if visible) and the before/after templates/slots.\n * You should probably implement `.renderControl()` method instead of this one in your class.\n */\n render(): TemplateResult {\n if (this.hidden) return html``;\n\n return html`\n ${this.renderTemplateOrSlot('before', this.nucleon)} ${this.renderControl()}\n ${this.renderTemplateOrSlot('after', this.nucleon)}\n `;\n }\n}\n"]}
@@ -264,7 +264,13 @@ export class Dialog extends Base {
264
264
  // trigger exit transition
265
265
  new Promise(resolve => {
266
266
  const backdrop = this.renderRoot.querySelector('#backdrop');
267
- backdrop.addEventListener('transitionend', resolve, { once: true });
267
+ if (backdrop) {
268
+ backdrop.addEventListener('transitionend', () => resolve(), { once: true });
269
+ setTimeout(() => resolve(), 2000);
270
+ }
271
+ else {
272
+ resolve();
273
+ }
268
274
  this.__visible = Dialog.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QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,QAAiB;QAC5C,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;QAC5B,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACrE,CAAC;;AAlUD;;;;GAIG;AACa,wBAAiB,GAAG,iCAAiC,CAAC;AAEtE,iEAAiE;AACjD,oBAAa,GAAG,IAAI,OAAO,EAAwB,CAAC;AAEpE,0CAA0C;AAC1B,kBAAW,GAAa,EAAE,CAAC;AAE3C;;;GAGG;AACa,gBAAS,GAAG,eAAe,CAAC;AAE5C;;;GAGG;AACa,gBAAS,GAAG,eAAe,CAAC;AA8S9C,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { CSSResultArray, LitElement, PropertyDeclarations, css } from 'lit-element';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { API } from '../../public/NucleonElement/API';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from './DialogHideEvent';\nimport { DialogShowEvent } from './DialogShowEvent';\nimport { DialogWindow } from './DialogWindow';\nimport { FetchEvent } from '../../public/NucleonElement/FetchEvent';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { InferrableMixin } from '../../../mixins/inferrable';\n\nconst Base = TranslatableMixin(ConfigurableMixin(ThemeableMixin(InferrableMixin(LitElement))));\n\nexport abstract class Dialog extends Base {\n /**\n * Selector of an element that will serve as a mounting point to all dialog windows.\n * It's `<body>` by default, but you can add your own element with `id=\"foxy-dialog-windows-host\"`\n * anywhere in the light DOM to render dialogs there.\n */\n static readonly dialogWindowsHost = '#foxy-dialog-windows-host, body';\n\n /** Map of all dialog windows linked to their dialog elements. */\n static readonly dialogWindows = new WeakMap<Dialog, DialogWindow>();\n\n /** List of all currently open dialogs. */\n static readonly openDialogs: Dialog[] = [];\n\n /**\n * Instance of this event will be dispatched on a dialog when it finishes entering the screen.\n * This event does not bubble and can't cross shadow DOM boundary.\n */\n static readonly ShowEvent = DialogShowEvent;\n\n /**\n * Instance of this event will be dispatched on a dialog when it finishes leaving the screen.\n * This event does not bubble and can't cross shadow DOM boundary.\n */\n static readonly HideEvent = DialogHideEvent;\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __connected: { attribute: false },\n __visible: { attribute: false },\n centered: { type: Boolean },\n closable: { type: Boolean },\n editable: { type: Boolean },\n header: { type: String },\n group: {},\n alert: { type: Boolean },\n wide: { type: Boolean },\n open: { type: Boolean, noAccessor: true },\n };\n }\n\n /** @readonly */\n static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n .grid-cols-header {\n grid-template-columns: 1fr auto 1fr;\n }\n\n .scale-85 {\n --tw-scale-x: 0.85;\n --tw-scale-y: 0.85;\n }\n\n .max-h-alert {\n max-height: calc(100vh - var(--lumo-size-l) - var(--lumo-space-m) * 2);\n }\n `,\n ];\n }\n\n /** When true, renders Close button in the header. */\n closable = false;\n\n /** When true, renders Save button in the header. */\n editable = false;\n\n /** Header text or a i18next key for it. */\n header = '';\n\n /** NucleonElement's Rumour sync group. */\n group = '';\n\n /** When true, centers a dialog on the screen and does not animate the stack under. */\n alert = false;\n\n /** When true, dialog window will a larger maximum width. */\n wide = false;\n\n private __returnFocusTo?: HTMLElement;\n\n private __handleKeyDown = (evt: KeyboardEvent) => {\n if (evt.key === 'Escape' && Dialog.openDialogs[0] === this && this.closable)\n this.hide(this.editable);\n };\n\n private __connected = false;\n\n private __visible = false;\n\n /** True if dialog is mounted and has finished entering the screen. */\n get open(): boolean {\n return this.__visible && this.__connected;\n }\n\n set open(newValue: boolean) {\n newValue === this.open ? void 0 : newValue ? this.show() : this.hide(this.editable);\n }\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n addEventListener('keydown', this.__handleKeyDown);\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n removeEventListener('keydown', this.__handleKeyDown);\n\n Dialog.dialogWindows.get(this)?.remove();\n Dialog.dialogWindows.delete(this);\n }\n\n /** @readonly */\n createRenderRoot(): Element | ShadowRoot {\n const dialogWindow = new DialogWindow();\n const dialogWindowsHosts = document.querySelectorAll(Dialog.dialogWindowsHost);\n const dialogWindowsHost = Array.from(dialogWindowsHosts).pop();\n\n dialogWindow.addEventListener('fetch', (evt: Event) => {\n if (evt instanceof FetchEvent) {\n evt.stopImmediatePropagation();\n evt.preventDefault();\n evt.respondWith(new API(this).fetch(evt.request));\n }\n });\n\n dialogWindowsHost?.appendChild(dialogWindow);\n Dialog.dialogWindows.set(this, dialogWindow);\n\n return dialogWindow.shadowRoot!;\n }\n\n /** @readonly */\n render(content?: () => TemplateResult): TemplateResult {\n if (!this.__connected) return html``;\n\n const isFirst = Dialog.openDialogs[0] === this;\n const isSecond = Dialog.openDialogs[1] === this;\n const isThird = Dialog.openDialogs[2] === this;\n const isForthAndGreater = !isFirst && !isSecond && !isThird;\n\n return html`\n <div\n class=${classMap({ 'z-50 fixed inset-0': true, 'pointer-events-none': !this.__visible })}\n >\n <div\n id=\"backdrop\"\n class=${classMap({\n 'select-none ease-in-out transition duration-500 absolute inset-0 bg-shade-50 focus-outline-none':\n true,\n 'opacity-100': this.__visible,\n 'opacity-0': !this.__visible,\n })}\n tabindex=\"-1\"\n @click=${() => this.closable && this.hide(this.editable)}\n ></div>\n\n <div\n tabindex=\"0\"\n role=\"dialog\"\n aria-labelledby=\"dialog-title\"\n class=${classMap({\n 'transform ease-in-out transition duration-500 relative h-full ml-auto': true,\n 'origin-bottom sm-origin-center': true,\n 'focus-outline-none': true,\n 'sm-max-w-modal': !this.wide,\n 'sm-max-w-modal-wide': this.wide,\n 'flex justify-center items-end sm-items-center mr-auto': this.alert,\n 'translate-y-full sm-translate-y-0': !this.__visible,\n 'sm-translate-x-full': !this.alert && !this.__visible,\n 'sm-opacity-0 sm-scale-110': this.alert && !this.__visible,\n 'translate-y-0 translate-x-0': isFirst && this.__visible,\n 'scale-95 -translate-y-s sm-translate-y-0': isSecond && this.__visible,\n 'scale-90 -translate-y-m sm-translate-y-0': isThird && this.__visible,\n 'opacity-0 scale-85 -translate-y-l sm-translate-y-0':\n isForthAndGreater && this.__visible,\n })}\n >\n <div\n class=${classMap({\n 'overflow-hidden flex flex-col bg-base rounded-t-l sm-rounded-b-l': true,\n 'absolute inset-0 mt-xl sm-m-xl': !this.alert,\n 'shadow-xxl': this.__visible,\n 'flex-1': this.alert,\n })}\n >\n <div\n class=\"h-l grid grid-cols-header text-m font-lumo font-medium border-b border-contrast-10\"\n >\n ${this.closable && !this.hiddenSelector.matches('close-button', true)\n ? html`\n <vaadin-button\n id=\"close-button\"\n theme=\"tertiary-inline\"\n class=\"mr-auto m-s px-s\"\n ?disabled=${this.disabledSelector.matches('close-button', true)}\n @click=${() => this.hide(this.editable)}\n >\n <foxy-i18n\n lang=${this.lang}\n key=${this.editable ? 'cancel' : 'close'}\n ns=${this.ns}\n >\n </foxy-i18n>\n </vaadin-button>\n `\n : html`<div></div>`}\n\n <h1 id=\"dialog-title\" class=\"truncate self-center text-center\">\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=${this.header}></foxy-i18n>\n </h1>\n\n ${this.editable && !this.hiddenSelector.matches('save-button', true)\n ? html`\n <vaadin-button\n data-testid=\"save-button\"\n ?disabled=${this.disabledSelector.matches('save-button', true)}\n theme=\"primary\"\n class=\"ml-auto h-auto min-h-0 min-w-0 m-xs px-m\"\n @click=${this.save}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"save\"></foxy-i18n>\n </vaadin-button>\n `\n : html`<div></div>`}\n </div>\n\n <div\n class=${classMap({\n 'flex-1 overflow-y-auto overflow-x-hidden overscroll-contain': true,\n 'max-h-alert': this.alert,\n })}\n >\n <div class=\"p-m relative\">${content?.()}</div>\n </div>\n </div>\n </div>\n </div>\n `;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n\n const dialogWindow = Dialog.dialogWindows.get(this);\n\n if (dialogWindow) {\n dialogWindow.disabledControls = this.disabledControls;\n dialogWindow.disabled = this.disabled;\n\n dialogWindow.readonlyControls = this.readonlyControls;\n dialogWindow.readonly = this.readonly;\n\n dialogWindow.hiddenControls = this.hiddenControls;\n dialogWindow.hidden = this.hidden;\n\n dialogWindow.group = this.group;\n dialogWindow.lang = this.lang;\n dialogWindow.ns = this.ns;\n }\n }\n\n /**\n * Hides the dialog. Returns a promise that resolves when the dialog\n * finishes leaving the screen.\n *\n * @param cancelled Set this to `true` if closing an editable dialog without saving changes.\n */\n async hide(cancelled = false): Promise<void> {\n this.__returnFocusTo?.focus();\n\n await this.__setOpenDialogs(Dialog.openDialogs.filter(d => d !== this));\n await this.__setConnected(false);\n\n this.dispatchEvent(new Dialog.HideEvent(!!cancelled));\n }\n\n /**\n * Shows the dialog. Returns a promise that resolves when the dialog\n * finishes entering the screen.\n *\n * @param returnFocusTo If provided, the dialog will call `.focus()` on that element once it's closed.\n */\n async show(returnFocusTo?: HTMLElement): Promise<void> {\n this.__returnFocusTo = returnFocusTo;\n\n await this.__setConnected(true);\n await this.__setOpenDialogs([this, ...Dialog.openDialogs]);\n\n this.renderRoot.querySelector<HTMLDivElement>('[role=\"dialog\"]')?.focus();\n this.dispatchEvent(new Dialog.ShowEvent());\n }\n\n /** Alias for `dialog.hide(false)`. */\n async save(): Promise<void> {\n await this.hide(false);\n }\n\n private async __setOpenDialogs(newValue: Dialog[]) {\n Dialog.openDialogs.length = 0;\n Dialog.openDialogs.push(...newValue);\n\n await Promise.all([\n // animate dialog stack\n Promise.all(Dialog.openDialogs.map(dialog => dialog.requestUpdate())),\n\n // trigger exit transition\n new Promise(resolve => {\n const backdrop = this.renderRoot.querySelector('#backdrop') as HTMLDivElement;\n backdrop.addEventListener('transitionend', resolve, { once: true });\n this.__visible = Dialog.openDialogs.includes(this);\n }),\n ]);\n }\n\n private async __setConnected(newValue: boolean) {\n this.__connected = newValue;\n await this.updateComplete.then(() => this.getBoundingClientRect());\n }\n}\n\ncustomElements.define('foxy-dialog-window', DialogWindow);\n"]}
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/elements/private/Dialog/Dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAwB,GAAG,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,GAAG,EAAE,2CAAwC;AACtD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,UAAU,EAAE,kDAA+C;AACpE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAE7D,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/F,MAAM,OAAgB,MAAO,SAAQ,IAAI;IAAzC;;QAgEE,qDAAqD;QACrD,aAAQ,GAAG,KAAK,CAAC;QAEjB,oDAAoD;QACpD,aAAQ,GAAG,KAAK,CAAC;QAEjB,2CAA2C;QAC3C,WAAM,GAAG,EAAE,CAAC;QAEZ,0CAA0C;QAC1C,UAAK,GAAG,EAAE,CAAC;QAEX,sFAAsF;QACtF,UAAK,GAAG,KAAK,CAAC;QAEd,4DAA4D;QAC5D,SAAI,GAAG,KAAK,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;gBAE5D,IAAI,QAAQ,EAAE;oBACZ,QAAQ,CAAC,gBAAgB,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC5E,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;iBACnC;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;gBAED,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,QAAiB;QAC5C,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;QAC5B,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACrE,CAAC;;AAzUD;;;;GAIG;AACa,wBAAiB,GAAG,iCAAiC,CAAC;AAEtE,iEAAiE;AACjD,oBAAa,GAAG,IAAI,OAAO,EAAwB,CAAC;AAEpE,0CAA0C;AAC1B,kBAAW,GAAa,EAAE,CAAC;AAE3C;;;GAGG;AACa,gBAAS,GAAG,eAAe,CAAC;AAE5C;;;GAGG;AACa,gBAAS,GAAG,eAAe,CAAC;AAqT9C,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { CSSResultArray, LitElement, PropertyDeclarations, css } from 'lit-element';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { API } from '../../public/NucleonElement/API';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from './DialogHideEvent';\nimport { DialogShowEvent } from './DialogShowEvent';\nimport { DialogWindow } from './DialogWindow';\nimport { FetchEvent } from '../../public/NucleonElement/FetchEvent';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { InferrableMixin } from '../../../mixins/inferrable';\n\nconst Base = TranslatableMixin(ConfigurableMixin(ThemeableMixin(InferrableMixin(LitElement))));\n\nexport abstract class Dialog extends Base {\n /**\n * Selector of an element that will serve as a mounting point to all dialog windows.\n * It's `<body>` by default, but you can add your own element with `id=\"foxy-dialog-windows-host\"`\n * anywhere in the light DOM to render dialogs there.\n */\n static readonly dialogWindowsHost = '#foxy-dialog-windows-host, body';\n\n /** Map of all dialog windows linked to their dialog elements. */\n static readonly dialogWindows = new WeakMap<Dialog, DialogWindow>();\n\n /** List of all currently open dialogs. */\n static readonly openDialogs: Dialog[] = [];\n\n /**\n * Instance of this event will be dispatched on a dialog when it finishes entering the screen.\n * This event does not bubble and can't cross shadow DOM boundary.\n */\n static readonly ShowEvent = DialogShowEvent;\n\n /**\n * Instance of this event will be dispatched on a dialog when it finishes leaving the screen.\n * This event does not bubble and can't cross shadow DOM boundary.\n */\n static readonly HideEvent = DialogHideEvent;\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __connected: { attribute: false },\n __visible: { attribute: false },\n centered: { type: Boolean },\n closable: { type: Boolean },\n editable: { type: Boolean },\n header: { type: String },\n group: {},\n alert: { type: Boolean },\n wide: { type: Boolean },\n open: { type: Boolean, noAccessor: true },\n };\n }\n\n /** @readonly */\n static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n .grid-cols-header {\n grid-template-columns: 1fr auto 1fr;\n }\n\n .scale-85 {\n --tw-scale-x: 0.85;\n --tw-scale-y: 0.85;\n }\n\n .max-h-alert {\n max-height: calc(100vh - var(--lumo-size-l) - var(--lumo-space-m) * 2);\n }\n `,\n ];\n }\n\n /** When true, renders Close button in the header. */\n closable = false;\n\n /** When true, renders Save button in the header. */\n editable = false;\n\n /** Header text or a i18next key for it. */\n header = '';\n\n /** NucleonElement's Rumour sync group. */\n group = '';\n\n /** When true, centers a dialog on the screen and does not animate the stack under. */\n alert = false;\n\n /** When true, dialog window will a larger maximum width. */\n wide = false;\n\n private __returnFocusTo?: HTMLElement;\n\n private __handleKeyDown = (evt: KeyboardEvent) => {\n if (evt.key === 'Escape' && Dialog.openDialogs[0] === this && this.closable)\n this.hide(this.editable);\n };\n\n private __connected = false;\n\n private __visible = false;\n\n /** True if dialog is mounted and has finished entering the screen. */\n get open(): boolean {\n return this.__visible && this.__connected;\n }\n\n set open(newValue: boolean) {\n newValue === this.open ? void 0 : newValue ? this.show() : this.hide(this.editable);\n }\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n addEventListener('keydown', this.__handleKeyDown);\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n removeEventListener('keydown', this.__handleKeyDown);\n\n Dialog.dialogWindows.get(this)?.remove();\n Dialog.dialogWindows.delete(this);\n }\n\n /** @readonly */\n createRenderRoot(): Element | ShadowRoot {\n const dialogWindow = new DialogWindow();\n const dialogWindowsHosts = document.querySelectorAll(Dialog.dialogWindowsHost);\n const dialogWindowsHost = Array.from(dialogWindowsHosts).pop();\n\n dialogWindow.addEventListener('fetch', (evt: Event) => {\n if (evt instanceof FetchEvent) {\n evt.stopImmediatePropagation();\n evt.preventDefault();\n evt.respondWith(new API(this).fetch(evt.request));\n }\n });\n\n dialogWindowsHost?.appendChild(dialogWindow);\n Dialog.dialogWindows.set(this, dialogWindow);\n\n return dialogWindow.shadowRoot!;\n }\n\n /** @readonly */\n render(content?: () => TemplateResult): TemplateResult {\n if (!this.__connected) return html``;\n\n const isFirst = Dialog.openDialogs[0] === this;\n const isSecond = Dialog.openDialogs[1] === this;\n const isThird = Dialog.openDialogs[2] === this;\n const isForthAndGreater = !isFirst && !isSecond && !isThird;\n\n return html`\n <div\n class=${classMap({ 'z-50 fixed inset-0': true, 'pointer-events-none': !this.__visible })}\n >\n <div\n id=\"backdrop\"\n class=${classMap({\n 'select-none ease-in-out transition duration-500 absolute inset-0 bg-shade-50 focus-outline-none':\n true,\n 'opacity-100': this.__visible,\n 'opacity-0': !this.__visible,\n })}\n tabindex=\"-1\"\n @click=${() => this.closable && this.hide(this.editable)}\n ></div>\n\n <div\n tabindex=\"0\"\n role=\"dialog\"\n aria-labelledby=\"dialog-title\"\n class=${classMap({\n 'transform ease-in-out transition duration-500 relative h-full ml-auto': true,\n 'origin-bottom sm-origin-center': true,\n 'focus-outline-none': true,\n 'sm-max-w-modal': !this.wide,\n 'sm-max-w-modal-wide': this.wide,\n 'flex justify-center items-end sm-items-center mr-auto': this.alert,\n 'translate-y-full sm-translate-y-0': !this.__visible,\n 'sm-translate-x-full': !this.alert && !this.__visible,\n 'sm-opacity-0 sm-scale-110': this.alert && !this.__visible,\n 'translate-y-0 translate-x-0': isFirst && this.__visible,\n 'scale-95 -translate-y-s sm-translate-y-0': isSecond && this.__visible,\n 'scale-90 -translate-y-m sm-translate-y-0': isThird && this.__visible,\n 'opacity-0 scale-85 -translate-y-l sm-translate-y-0':\n isForthAndGreater && this.__visible,\n })}\n >\n <div\n class=${classMap({\n 'overflow-hidden flex flex-col bg-base rounded-t-l sm-rounded-b-l': true,\n 'absolute inset-0 mt-xl sm-m-xl': !this.alert,\n 'shadow-xxl': this.__visible,\n 'flex-1': this.alert,\n })}\n >\n <div\n class=\"h-l grid grid-cols-header text-m font-lumo font-medium border-b border-contrast-10\"\n >\n ${this.closable && !this.hiddenSelector.matches('close-button', true)\n ? html`\n <vaadin-button\n id=\"close-button\"\n theme=\"tertiary-inline\"\n class=\"mr-auto m-s px-s\"\n ?disabled=${this.disabledSelector.matches('close-button', true)}\n @click=${() => this.hide(this.editable)}\n >\n <foxy-i18n\n lang=${this.lang}\n key=${this.editable ? 'cancel' : 'close'}\n ns=${this.ns}\n >\n </foxy-i18n>\n </vaadin-button>\n `\n : html`<div></div>`}\n\n <h1 id=\"dialog-title\" class=\"truncate self-center text-center\">\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=${this.header}></foxy-i18n>\n </h1>\n\n ${this.editable && !this.hiddenSelector.matches('save-button', true)\n ? html`\n <vaadin-button\n data-testid=\"save-button\"\n ?disabled=${this.disabledSelector.matches('save-button', true)}\n theme=\"primary\"\n class=\"ml-auto h-auto min-h-0 min-w-0 m-xs px-m\"\n @click=${this.save}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"save\"></foxy-i18n>\n </vaadin-button>\n `\n : html`<div></div>`}\n </div>\n\n <div\n class=${classMap({\n 'flex-1 overflow-y-auto overflow-x-hidden overscroll-contain': true,\n 'max-h-alert': this.alert,\n })}\n >\n <div class=\"p-m relative\">${content?.()}</div>\n </div>\n </div>\n </div>\n </div>\n `;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n\n const dialogWindow = Dialog.dialogWindows.get(this);\n\n if (dialogWindow) {\n dialogWindow.disabledControls = this.disabledControls;\n dialogWindow.disabled = this.disabled;\n\n dialogWindow.readonlyControls = this.readonlyControls;\n dialogWindow.readonly = this.readonly;\n\n dialogWindow.hiddenControls = this.hiddenControls;\n dialogWindow.hidden = this.hidden;\n\n dialogWindow.group = this.group;\n dialogWindow.lang = this.lang;\n dialogWindow.ns = this.ns;\n }\n }\n\n /**\n * Hides the dialog. Returns a promise that resolves when the dialog\n * finishes leaving the screen.\n *\n * @param cancelled Set this to `true` if closing an editable dialog without saving changes.\n */\n async hide(cancelled = false): Promise<void> {\n this.__returnFocusTo?.focus();\n\n await this.__setOpenDialogs(Dialog.openDialogs.filter(d => d !== this));\n await this.__setConnected(false);\n\n this.dispatchEvent(new Dialog.HideEvent(!!cancelled));\n }\n\n /**\n * Shows the dialog. Returns a promise that resolves when the dialog\n * finishes entering the screen.\n *\n * @param returnFocusTo If provided, the dialog will call `.focus()` on that element once it's closed.\n */\n async show(returnFocusTo?: HTMLElement): Promise<void> {\n this.__returnFocusTo = returnFocusTo;\n\n await this.__setConnected(true);\n await this.__setOpenDialogs([this, ...Dialog.openDialogs]);\n\n this.renderRoot.querySelector<HTMLDivElement>('[role=\"dialog\"]')?.focus();\n this.dispatchEvent(new Dialog.ShowEvent());\n }\n\n /** Alias for `dialog.hide(false)`. */\n async save(): Promise<void> {\n await this.hide(false);\n }\n\n private async __setOpenDialogs(newValue: Dialog[]) {\n Dialog.openDialogs.length = 0;\n Dialog.openDialogs.push(...newValue);\n\n await Promise.all([\n // animate dialog stack\n Promise.all(Dialog.openDialogs.map(dialog => dialog.requestUpdate())),\n\n // trigger exit transition\n new Promise<void>(resolve => {\n const backdrop = this.renderRoot.querySelector('#backdrop');\n\n if (backdrop) {\n backdrop.addEventListener('transitionend', () => resolve(), { once: true });\n setTimeout(() => resolve(), 2000);\n } else {\n resolve();\n }\n\n this.__visible = Dialog.openDialogs.includes(this);\n }),\n ]);\n }\n\n private async __setConnected(newValue: boolean) {\n this.__connected = newValue;\n await this.updateComplete.then(() => this.getBoundingClientRect());\n }\n}\n\ncustomElements.define('foxy-dialog-window', DialogWindow);\n"]}
@@ -119,7 +119,9 @@ export class ItemCard extends Base {
119
119
  <div class="h-s flex items-center">
120
120
  <div class="min-w-0 flex-1 leading-s">
121
121
  <div class="flex items-center justify-between">
122
- <div class="truncate text-m font-medium">${(_h = this.data) === null || _h === void 0 ? void 0 : _h.name}</div>
122
+ <div class="truncate text-m font-medium">
123
+ ${((_h = this.data) === null || _h === void 0 ? void 0 : _h.name) || html `<foxy-i18n infer="" key="no_code"></foxy-i18n>`}
124
+ </div>
123
125
  <span class="text-s text-tertiary whitespace-nowrap">
124
126
  ${quantity} &times;
125
127
  <foxy-i18n
@@ -132,7 +134,7 @@ export class ItemCard extends Base {
132
134
  </div>
133
135
 
134
136
  <div class="truncate text-secondary text-s">
135
- ${(_j = this.data) === null || _j === void 0 ? void 0 : _j.code}
137
+ ${((_j = this.data) === null || _j === void 0 ? void 0 : _j.code) || undefined}
136
138
  ${((_k = this.data) === null || _k === void 0 ? void 0 : _k.subscription_frequency) &&
137
139
  !this.hiddenSelector.matches('autorenew-icon', true)
138
140
  ? html `
@@ -1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AAI,0CAAE,sBAAsB,CAAC;QACpD,IAAI,SAAS;YAAE,OAAO,WAAW,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACzF,CAAC;;AAzUuB,sBAAa,GACnC,+wDAA+wD,CAAC","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'item-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying an item.\n *\n * @element foxy-item-card\n * @since 1.17.0\n */\nexport class ItemCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n localeCodes: { type: String, attribute: 'locale-codes' },\n };\n }\n\n localeCodes: string | null = null;\n\n private static readonly __placeholder =\n 'data:image/svg+xml,%3Csvg width=\"40\" height=\"40\" viewBox=\"0 0 40 40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"%3E%3Crect width=\"40\" height=\"40\" fill=\"%23E8E8E8\"/%3E%3Cpath d=\"M31.5143 0H24.5476L0 24.5476V31.5143L11.7046 19.8097L11.9841 17.0782C12.0983 15.9624 13.0131 15.1154 14.1038 15.1154H15.7373V12.1923C15.7373 10.9815 16.6915 10 17.8687 10H21.5143L31.5143 0Z\" fill=\"white\"/%3E%3Cpath d=\"M11.5434 21.3852L0 32.9285V39.8953L11.5822 28.3131C11.172 27.8663 10.9438 27.2444 11.012 26.5782L11.5434 21.3852Z\" fill=\"white\"/%3E%3Cpath d=\"M12.4305 28.879L1.30951 40H8.27631L19.2763 29H13.1316C12.8853 29 12.6495 28.9573 12.4305 28.879Z\" fill=\"white\"/%3E%3Cpath d=\"M28.3113 19.965L28.0159 17.0782C27.9116 16.0591 27.1395 15.2642 26.1754 15.1341L40 1.3095V8.27627L28.3113 19.965Z\" fill=\"white\"/%3E%3Cpath d=\"M20.6905 29L9.69049 40H16.6572L27.9755 28.6817C27.6541 28.8832 27.2756 29 26.8684 29H20.6905Z\" fill=\"white\"/%3E%3Cpath d=\"M28.6572 28C28.9128 27.5952 29.0415 27.1003 28.988 26.5782L28.4426 21.2479L40 9.69053V16.6572L28.6572 28Z\" fill=\"white\"/%3E%3Cpath d=\"M25.0381 40H18.0715L40 18.0715V25.0381L25.0381 40Z\" fill=\"white\"/%3E%3Cpath d=\"M26.4524 40H33.4191L40 33.4191V26.4524L26.4524 40Z\" fill=\"white\"/%3E%3Cpath d=\"M40 40H34.8333L40 34.8333V40Z\" fill=\"white\"/%3E%3Cpath d=\"M16.1666 0H23.1334L0 23.1334V16.1666L16.1666 0Z\" fill=\"white\"/%3E%3Cpath d=\"M14.7524 0H7.78571L0 7.78573V14.7524L14.7524 0Z\" fill=\"white\"/%3E%3Cpath d=\"M0 0H6.37152L0 6.37151V0Z\" fill=\"white\"/%3E%3Cpath d=\"M21.467 11.4615H17.8687C17.4763 11.4615 17.1582 11.7887 17.1582 12.1923V15.1154H22.8418V12.1923C22.8418 11.7887 22.5237 11.4615 22.1313 11.4615H21.467Z\" fill=\"white\"/%3E%3Cpath d=\"M24.7798 15.1154H24.2627V12.1923C24.2627 11.227 23.6562 10.4075 22.8138 10.1148L32.9286 0H39.89L24.7798 15.1154Z\" fill=\"white\"/%3E%3C/svg%3E';\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __cartLoaderId = 'cartLoader';\n\n renderBody(): TemplateResult {\n const quantity = this.data?.quantity ?? 0;\n const options = this.data?._embedded?.['fx:item_options'];\n const price = this.data?.price ?? 0;\n\n const currencyDisplay = this.__currencyDisplay;\n const currencyCode = this.__currencyCode;\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionHref)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__cartHref)}\n id=${this.__cartLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div\n class=\"flex items-start leading-xs\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <img\n class=\"relative h-s w-s object-cover rounded-s bg-contrast-20 flex-shrink-0 shadow-xs\"\n src=${ifDefined(this.data?.image)}\n alt=\"\"\n @error=${(evt: Event) => {\n const img = evt.currentTarget as HTMLImageElement;\n img.src = ItemCard.__placeholder;\n }}\n />\n\n <div class=\"flex-1 min-w-0\">\n <div class=\"h-s flex items-center\">\n <div class=\"min-w-0 flex-1 leading-s\">\n <div class=\"flex items-center justify-between\">\n <div class=\"truncate text-m font-medium\">${this.data?.name}</div>\n <span class=\"text-s text-tertiary whitespace-nowrap\">\n ${quantity} &times;\n <foxy-i18n\n .options=${{ amount: `${price} ${currencyCode}`, currencyDisplay }}\n key=\"price\"\n infer=\"\"\n >\n </foxy-i18n>\n </span>\n </div>\n\n <div class=\"truncate text-secondary text-s\">\n ${this.data?.code}\n ${this.data?.subscription_frequency &&\n !this.hiddenSelector.matches('autorenew-icon', true)\n ? html`\n <span> &bull; </span>\n <foxy-i18n\n infer=\"\"\n key=${this.__subinfoKey}\n .options=${this.__subinfoOptions}\n >\n </foxy-i18n>\n `\n : ''}\n &ZeroWidthSpace;\n </div>\n </div>\n </div>\n\n ${options && options.length > 0\n ? html`\n <div class=\"mt-m\">\n ${options.map(\n option => html`\n <div data-testclass=\"option\" class=\"flex items-center gap-s text-s leading-s\">\n <div class=\"truncate text-secondary\">\n ${option.name}: <span class=\"font-medium text-body\">${option.value}</span>\n </div>\n\n ${option.price_mod\n ? html`\n <div class=\"border-t border-dashed border-contrast-10 flex-1\"></div>\n <div class=\"whitespace-nowrap text-tertiary\">\n <foxy-i18n\n options=${JSON.stringify({\n amount: `${option.price_mod} ${currencyCode}`,\n signDisplay: 'exceptZero',\n currencyDisplay: currencyDisplay,\n })}\n key=\"price\"\n infer=\"\"\n >\n </foxy-i18n>\n </div>\n `\n : ''}\n </div>\n `\n )}\n </div>\n `\n : ''}\n </div>\n </div>\n `;\n }\n\n get isBodyReady(): boolean {\n const isLoaded = !!this.__currencyDisplay && !!this.__currencyCode;\n return super.isBodyReady && isLoaded;\n }\n\n private get __transactionTemplateHref() {\n try {\n const links = this.data?._links as Partial<Record<string, { href: string }>> | undefined;\n const url = new URL(links?.['fx:subscription']?.href ?? '');\n url.searchParams.set('zoom', 'transaction_template');\n return url.toString();\n } catch {\n //\n }\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = (this.__cart ?? this.__transactionTemplate)?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __transactionHref() {\n return this.data?._links['fx:transaction']?.href;\n }\n\n private get __templateSetHref() {\n const cart = this.__cart ?? this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __storeHref() {\n return this.data?._links['fx:store']?.href;\n }\n\n private get __cartHref() {\n const links = this.data?._links as Partial<Record<string, { href: string }>> | undefined;\n return links?.['fx:cart']?.href;\n }\n\n private get __transactionTemplate() {\n type Loader = NucleonElement<Resource<Rels.Subscription, { zoom: 'transaction_template' }>>;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:transaction_template'] ?? null;\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __transaction() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n const selector = `#${this.__transactionLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __cart() {\n type Loader = NucleonElement<Resource<Rels.Cart>>;\n const selector = `#${this.__cartLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __currencyDisplay() {\n const useCode = this.__store?.use_international_currency_symbol;\n\n if (useCode === true) return 'code';\n if (useCode === false) return 'symbol';\n if (this.data && !this.data._links['fx:store']) return 'symbol';\n }\n\n private get __currencyCode() {\n const transaction = this.__transaction;\n\n if (transaction) {\n return transaction.currency_code;\n } else {\n const cart = this.__cart ?? this.__transactionTemplate;\n\n if (cart?.currency_code) {\n return cart.currency_code;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) return /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1];\n }\n }\n }\n\n private get __subinfoOptions() {\n const currencyDisplay = this.__currencyDisplay;\n if (currencyDisplay === undefined) return;\n\n const currencyCode = this.__currencyCode;\n if (currencyCode === undefined) return;\n\n const totalOrder = this.__transactionTemplate?.total_order;\n if (totalOrder === undefined) return;\n\n const frequency = this.data?.subscription_frequency;\n if (frequency === undefined) return;\n\n const startDate = this.data?.subscription_start_date;\n if (startDate === undefined) return;\n\n return {\n ...parseFrequency(frequency),\n amount: `${totalOrder} ${currencyCode}`,\n currencyDisplay,\n startDate,\n };\n }\n\n private get __subinfoKey() {\n const frequency = this.data?.subscription_frequency;\n if (frequency) return `subinfo_${frequency === '.5m' ? 'twice_a_month' : 'recurring'}`;\n }\n}\n"]}
1
+ {"version":3,"file":"ItemCard.js","sourceRoot":"","sources":["../../../../src/elements/public/ItemCard/ItemCard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,WAAW,CAAC;AACvB,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAU;IAAxC;;QAQE,gBAAW,GAAkB,IAAI,CAAC;QAKjB,kCAA6B,GAAG,2BAA2B,CAAC;QAE5D,iCAA4B,GAAG,0BAA0B,CAAC;QAE1D,gCAA2B,GAAG,mBAAmB,CAAC;QAElD,0BAAqB,GAAG,mBAAmB,CAAC;QAE5C,0BAAqB,GAAG,mBAAmB,CAAC;QAE5C,oBAAe,GAAG,aAAa,CAAC;QAEhC,mBAAc,GAAG,YAAY,CAAC;IA6TjD,CAAC;IArVC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE;SACzD,CAAC;IACJ,CAAC;IAqBD,UAAU;;QACR,MAAM,QAAQ,eAAG,IAAI,CAAC,IAAI,0CAAE,QAAQ,mCAAI,CAAC,CAAC;QAC1C,MAAM,OAAO,eAAG,IAAI,CAAC,IAA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5B,MAAM,EAAE,GAAG,UAAU,IAAI,YAAY,EAAE;YACvC,eAAe;YACf,SAAS;SACV,CAAC;IACJ,CAAC;IAED,IAAY,YAAY;;QACtB,MAAM,SAAS,SAAG,IAAI,CAAC,IAAI,0CAAE,sBAAsB,CAAC;QACpD,IAAI,SAAS;YAAE,OAAO,WAAW,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACzF,CAAC;;AA3UuB,sBAAa,GACnC,+wDAA+wD,CAAC","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'item-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying an item.\n *\n * @element foxy-item-card\n * @since 1.17.0\n */\nexport class ItemCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n localeCodes: { type: String, attribute: 'locale-codes' },\n };\n }\n\n localeCodes: string | null = null;\n\n private static readonly __placeholder =\n 'data:image/svg+xml,%3Csvg width=\"40\" height=\"40\" viewBox=\"0 0 40 40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"%3E%3Crect width=\"40\" height=\"40\" fill=\"%23E8E8E8\"/%3E%3Cpath d=\"M31.5143 0H24.5476L0 24.5476V31.5143L11.7046 19.8097L11.9841 17.0782C12.0983 15.9624 13.0131 15.1154 14.1038 15.1154H15.7373V12.1923C15.7373 10.9815 16.6915 10 17.8687 10H21.5143L31.5143 0Z\" fill=\"white\"/%3E%3Cpath d=\"M11.5434 21.3852L0 32.9285V39.8953L11.5822 28.3131C11.172 27.8663 10.9438 27.2444 11.012 26.5782L11.5434 21.3852Z\" fill=\"white\"/%3E%3Cpath d=\"M12.4305 28.879L1.30951 40H8.27631L19.2763 29H13.1316C12.8853 29 12.6495 28.9573 12.4305 28.879Z\" fill=\"white\"/%3E%3Cpath d=\"M28.3113 19.965L28.0159 17.0782C27.9116 16.0591 27.1395 15.2642 26.1754 15.1341L40 1.3095V8.27627L28.3113 19.965Z\" fill=\"white\"/%3E%3Cpath d=\"M20.6905 29L9.69049 40H16.6572L27.9755 28.6817C27.6541 28.8832 27.2756 29 26.8684 29H20.6905Z\" fill=\"white\"/%3E%3Cpath d=\"M28.6572 28C28.9128 27.5952 29.0415 27.1003 28.988 26.5782L28.4426 21.2479L40 9.69053V16.6572L28.6572 28Z\" fill=\"white\"/%3E%3Cpath d=\"M25.0381 40H18.0715L40 18.0715V25.0381L25.0381 40Z\" fill=\"white\"/%3E%3Cpath d=\"M26.4524 40H33.4191L40 33.4191V26.4524L26.4524 40Z\" fill=\"white\"/%3E%3Cpath d=\"M40 40H34.8333L40 34.8333V40Z\" fill=\"white\"/%3E%3Cpath d=\"M16.1666 0H23.1334L0 23.1334V16.1666L16.1666 0Z\" fill=\"white\"/%3E%3Cpath d=\"M14.7524 0H7.78571L0 7.78573V14.7524L14.7524 0Z\" fill=\"white\"/%3E%3Cpath d=\"M0 0H6.37152L0 6.37151V0Z\" fill=\"white\"/%3E%3Cpath d=\"M21.467 11.4615H17.8687C17.4763 11.4615 17.1582 11.7887 17.1582 12.1923V15.1154H22.8418V12.1923C22.8418 11.7887 22.5237 11.4615 22.1313 11.4615H21.467Z\" fill=\"white\"/%3E%3Cpath d=\"M24.7798 15.1154H24.2627V12.1923C24.2627 11.227 23.6562 10.4075 22.8138 10.1148L32.9286 0H39.89L24.7798 15.1154Z\" fill=\"white\"/%3E%3C/svg%3E';\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __cartLoaderId = 'cartLoader';\n\n renderBody(): TemplateResult {\n const quantity = this.data?.quantity ?? 0;\n const options = this.data?._embedded?.['fx:item_options'];\n const price = this.data?.price ?? 0;\n\n const currencyDisplay = this.__currencyDisplay;\n const currencyCode = this.__currencyCode;\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionHref)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__cartHref)}\n id=${this.__cartLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div\n class=\"flex items-start leading-xs\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <img\n class=\"relative h-s w-s object-cover rounded-s bg-contrast-20 flex-shrink-0 shadow-xs\"\n src=${ifDefined(this.data?.image)}\n alt=\"\"\n @error=${(evt: Event) => {\n const img = evt.currentTarget as HTMLImageElement;\n img.src = ItemCard.__placeholder;\n }}\n />\n\n <div class=\"flex-1 min-w-0\">\n <div class=\"h-s flex items-center\">\n <div class=\"min-w-0 flex-1 leading-s\">\n <div class=\"flex items-center justify-between\">\n <div class=\"truncate text-m font-medium\">\n ${this.data?.name || html`<foxy-i18n infer=\"\" key=\"no_code\"></foxy-i18n>`}\n </div>\n <span class=\"text-s text-tertiary whitespace-nowrap\">\n ${quantity} &times;\n <foxy-i18n\n .options=${{ amount: `${price} ${currencyCode}`, currencyDisplay }}\n key=\"price\"\n infer=\"\"\n >\n </foxy-i18n>\n </span>\n </div>\n\n <div class=\"truncate text-secondary text-s\">\n ${this.data?.code || undefined}\n ${this.data?.subscription_frequency &&\n !this.hiddenSelector.matches('autorenew-icon', true)\n ? html`\n <span> &bull; </span>\n <foxy-i18n\n infer=\"\"\n key=${this.__subinfoKey}\n .options=${this.__subinfoOptions}\n >\n </foxy-i18n>\n `\n : ''}\n &ZeroWidthSpace;\n </div>\n </div>\n </div>\n\n ${options && options.length > 0\n ? html`\n <div class=\"mt-m\">\n ${options.map(\n option => html`\n <div data-testclass=\"option\" class=\"flex items-center gap-s text-s leading-s\">\n <div class=\"truncate text-secondary\">\n ${option.name}: <span class=\"font-medium text-body\">${option.value}</span>\n </div>\n\n ${option.price_mod\n ? html`\n <div class=\"border-t border-dashed border-contrast-10 flex-1\"></div>\n <div class=\"whitespace-nowrap text-tertiary\">\n <foxy-i18n\n options=${JSON.stringify({\n amount: `${option.price_mod} ${currencyCode}`,\n signDisplay: 'exceptZero',\n currencyDisplay: currencyDisplay,\n })}\n key=\"price\"\n infer=\"\"\n >\n </foxy-i18n>\n </div>\n `\n : ''}\n </div>\n `\n )}\n </div>\n `\n : ''}\n </div>\n </div>\n `;\n }\n\n get isBodyReady(): boolean {\n const isLoaded = !!this.__currencyDisplay && !!this.__currencyCode;\n return super.isBodyReady && isLoaded;\n }\n\n private get __transactionTemplateHref() {\n try {\n const links = this.data?._links as Partial<Record<string, { href: string }>> | undefined;\n const url = new URL(links?.['fx:subscription']?.href ?? '');\n url.searchParams.set('zoom', 'transaction_template');\n return url.toString();\n } catch {\n //\n }\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = (this.__cart ?? this.__transactionTemplate)?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __transactionHref() {\n return this.data?._links['fx:transaction']?.href;\n }\n\n private get __templateSetHref() {\n const cart = this.__cart ?? this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __storeHref() {\n return this.data?._links['fx:store']?.href;\n }\n\n private get __cartHref() {\n const links = this.data?._links as Partial<Record<string, { href: string }>> | undefined;\n return links?.['fx:cart']?.href;\n }\n\n private get __transactionTemplate() {\n type Loader = NucleonElement<Resource<Rels.Subscription, { zoom: 'transaction_template' }>>;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:transaction_template'] ?? null;\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __transaction() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n const selector = `#${this.__transactionLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __cart() {\n type Loader = NucleonElement<Resource<Rels.Cart>>;\n const selector = `#${this.__cartLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __currencyDisplay() {\n const useCode = this.__store?.use_international_currency_symbol;\n\n if (useCode === true) return 'code';\n if (useCode === false) return 'symbol';\n if (this.data && !this.data._links['fx:store']) return 'symbol';\n }\n\n private get __currencyCode() {\n const transaction = this.__transaction;\n\n if (transaction) {\n return transaction.currency_code;\n } else {\n const cart = this.__cart ?? this.__transactionTemplate;\n\n if (cart?.currency_code) {\n return cart.currency_code;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) return /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1];\n }\n }\n }\n\n private get __subinfoOptions() {\n const currencyDisplay = this.__currencyDisplay;\n if (currencyDisplay === undefined) return;\n\n const currencyCode = this.__currencyCode;\n if (currencyCode === undefined) return;\n\n const totalOrder = this.__transactionTemplate?.total_order;\n if (totalOrder === undefined) return;\n\n const frequency = this.data?.subscription_frequency;\n if (frequency === undefined) return;\n\n const startDate = this.data?.subscription_start_date;\n if (startDate === undefined) return;\n\n return {\n ...parseFrequency(frequency),\n amount: `${totalOrder} ${currencyCode}`,\n currencyDisplay,\n startDate,\n };\n }\n\n private get __subinfoKey() {\n const frequency = this.data?.subscription_frequency;\n if (frequency) return `subinfo_${frequency === '.5m' ? 'twice_a_month' : 'recurring'}`;\n }\n}\n"]}
@@ -481,6 +481,7 @@ export class Item extends SignableFields {
481
481
  e.currency = this.currency;
482
482
  e.isItem = false;
483
483
  e.isChildItem = true;
484
+ e.setAttribute('data-bundled', '');
484
485
  if (this.code) {
485
486
  e.parent_code = this.code;
486
487
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../src/elements/public/ItemsForm/private/Item.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAC;AAExD,OAAO,EAAwD,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,kCAA+B;AAG3D,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,cAAc,EAAE,4BAAyB;AAElD;;;;;;;GAOG;AACH,MAAM,OAAO,IAAK,SAAQ,cAAc;IAyRtC;QACE,KAAK,CAAC,YAAY,CAAC,CAAC;QA7KN,QAAG,GAAG,cAAc,CAAC;QAgBrC;;WAEG;QACI,aAAQ,GAAG,KAAK,CAAC;QAmCxB;;WAEG;QACI,aAAQ,GAAG,CAAC,CAAC;QA+DpB;;;;WAIG;QACI,UAAK,GAAY,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAEnD;;;;;WAKG;QACI,aAAQ,GAAG,EAAE,CAAC;QAErB,wDAAwD;QAC9C,WAAM,GAAG,IAAI,CAAC;QAExB,wDAAwD;QAC9C,gBAAW,GAAG,KAAK,CAAC;QAE9B;;WA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AAC,CAAC,KAAK,CAAC,CAAC;aAC7B;QACH,CAAC,CAAC;QACF,MAAM,aAAa,GAAG,CAAC,CAAO,EAAE,EAAE;YAChC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC;QACF,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;QACpD,qCAAqC;QACrC,IAAI,CAAC,iBAAiB,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;QAEtE,IAAI,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;SAChD;QAED,yCAAyC;QACzC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC;QACxC,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,wDAAwD;IAChD,iBAAiB,CAAC,OAA8B;QACtD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAC7D,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,KAAK,CAAC,CAAS,CAAC,CAAC;aAClB;SACF;IACH,CAAC;;AAxZD,kDAAkD;AACnC,kBAAa,GAAa,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-text-field/vaadin-integer-field';\n\nimport { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\nimport { ErrorScreen, I18N } from '../../../private/index';\nimport { ImageDescription, ItemInterface } from '../types';\n\nimport { Preview } from './Preview';\nimport { SignableFields } from './SignableFields';\n\n/**\n * This component allows a user to configure an item.\n *\n * The item may be configured using HTML properties or a JS object.\n *\n * @csspart picture - Image of the product in preview stack (for single products) or grid (for bundles).\n * @csspart item - The root element inside of the shadow dom.\n */\nexport class Item extends SignableFields {\n // A list of item properties as defined in Foxy Cart Documentation\n\n /** @readonly */\n static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n :host {\n --quantity-width: 6.5rem;\n --preview-size: 5.5rem;\n --threshold: 20rem;\n }\n\n .min-w-description::before {\n content: '';\n width: var(--threshold);\n display: block;\n overflow: hidden;\n }\n\n .ml-description {\n --min-width: calc(var(--threshold) + var(--preview-size) + var(--lumo-space-l));\n --free-space: calc(100% - var(--min-width));\n --max-margin-left: calc(var(--preview-size) + var(--lumo-space-l));\n --final-margin-left: clamp(0rem, var(--free-space) * 999999999, var(--max-margin-left));\n margin-left: var(--final-margin-left);\n }\n\n .mr-quantity {\n --min-width: var(--threshold);\n --free-space: calc(100% - var(--min-width));\n --max-margin-right: calc(var(--quantity-width) + var(--lumo-space-l));\n --final-margin-right: clamp(0rem, var(--free-space) * 999999999, var(--max-margin-right));\n margin-right: var(--final-margin-right);\n }\n\n :host([data-bundled]:not(:last-of-type)) .separator::after {\n content: ' ';\n display: block;\n position: absolute;\n width: 100vw;\n border-bottom: solid thin var(--lumo-shade-10pct);\n left: 0;\n bottom: 0;\n }\n\n .w-quantity {\n width: var(--quantity-width);\n }\n\n .w-preview {\n width: var(--preview-size);\n }\n\n .h-preview {\n height: var(--preview-size);\n }\n `,\n ];\n }\n\n /** @readonly */\n public static get scopedElements(): Record<string, unknown> {\n return {\n 'vaadin-integer-field': customElements.get('vaadin-integer-field'),\n 'x-error-screen': ErrorScreen,\n 'x-preview': Preview,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __modified: {},\n readonly: { type: Boolean, reflect: true },\n currency: { type: String },\n category: { type: String },\n code: { type: String, reflect: true },\n expires: { type: String },\n height: { type: Number },\n image: { type: String },\n length: { type: Number },\n name: { type: String },\n parent_code: { type: String },\n price: { type: Number },\n quantity: { type: Number, reflect: true },\n quantity_max: { type: Number },\n quantity_min: { type: String },\n shipto: { type: String },\n total: { type: Number, reflect: true, attribute: 'total' },\n url: { type: String },\n value: { type: Object },\n weight: { type: Number },\n width: { type: Number },\n __childPrices: {},\n __childrenCount: {},\n __images: {},\n alt: { type: String },\n isChildItem: { type: Boolean, reflect: true, attribute: 'data-bundled' },\n isItem: { type: Boolean, reflect: true, attribute: 'data-item' },\n open: { type: Object },\n pid: { type: Number, reflect: true },\n items: { type: Array },\n };\n }\n\n public readonly rel = 'product_item';\n\n /**\n * **Required** the name of the item.\n *\n * **Example:** `\"Dog food\"`\n */\n public name?: string;\n\n /**\n * **Required** the price of a unit of this item\n *\n * **Example:** `10`\n */\n public price?: number;\n\n /**\n * Makes quantity input readonly.\n */\n public readonly = false;\n\n /**\n * Optional an image url to be displayed in the form.\n */\n public image?: string;\n\n /**\n * Optional the alt text for the image\n */\n public alt?: string;\n\n /**\n * Optional an image url to be displayed in the foxy cart once the custumer reaches the cart.\n */\n public url?: string;\n\n /**\n * Optional item code. 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?: string | number;\n\n /**\n * Optional parent code. This property affects cart UI only.\n * It causes Foxy Cart to recognize the parent-child relationship between two items.\n *\n * Nested items set this property automatically.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public parent_code?: string | number;\n\n /**\n * **Required** The quantity of this item in the cart.\n */\n public quantity = 0;\n\n /**\n * Optional quantity max. The maximum number of items of these to be added.\n */\n public quantity_max?: number;\n\n /**\n * Optional quantity min. The minimum number of items of these to be added.\n */\n public quantity_min?: number;\n\n /**\n * Optional category. Sets the category this item is in.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"heavy\"`\n */\n public category?: string;\n\n /**\n * Optional expires. Sets the expiration time of this item.\n *\n * Advanced usage only: This property affects cart UI only.\n * This web component will not react to this property.\n *\n * The item cannot be purchased after expiration, but if it is part of a\n * subscription, it remains in the subscription as long as it stands.\n *\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `15`\n */\n public expires?: string;\n\n /**\n * Optional per item weight. This property affects cart UI only.\n */\n public weight?: number;\n\n /**\n * Optional. Specify a ship-to address for a specific item.\n *\n * Advanced usage only: This property affects cart UI only.\n * This element does not provide any means for the user to specify this property.\n */\n public shipto?: string;\n\n /**\n * Optional length. This property affects cart UI only.\n */\n public length?: number;\n\n /**\n * Optional width. This property affects cart UI only.\n */\n public width?: number;\n\n /**\n * Optional height. This property affects cart UI only.\n */\n public height?: number;\n\n /**\n * The total price of this item.\n *\n * It takes into account child items and the quantity.\n */\n public total?: number = this.__computeTotalPrice();\n\n /**\n * 3-letter lowercase currency code.\n * It is provided by the form if not set.\n *\n * **Example:** `\"usd\"`\n */\n public currency = '';\n\n /** A boolean indicating that this element is a item **/\n protected isItem = true;\n\n /** Boolean indicating that this item is a child item */\n protected isChildItem = false;\n\n /**\n * A unique id set to the item. Advanced usage only.\n */\n public readonly pid: number = Item.__newId();\n\n // A list of all existing ids to guarantee unicity\n private static __existingIds: number[] = [];\n\n private __childItemsObserver?: MutationObserver;\n\n private __modified = false;\n\n private __childPrices: number[] = [];\n\n private __images: ImageDescription[] = [];\n\n private __childrenCount = 0;\n\n private __itemDescription = '';\n\n private __handleQuantity = {\n handleEvent: (ev: Event) => {\n const newValue = Number((ev.target as HTMLInputElement).value);\n this.quantity = newValue;\n this.__modified = true;\n this.__images = ([this.getImageDescription()] as ImageDescription[]).concat(\n this.__images.slice(1, this.__images.length)\n );\n },\n };\n\n public constructor() {\n super('items-form');\n this.__childItemsObserver = new MutationObserver(this.__observeItems.bind(this));\n this.__childItemsObserver.observe(this, {\n childList: true,\n attributes: false,\n subtree: true,\n });\n this.updateComplete.then(() => {\n this.__setCode();\n this.__acknowledgeChildItems();\n this.__changedChildItem();\n if (!this.__isValid()) {\n console.error('Invalid item', this.value);\n }\n });\n }\n\n /**\n * Each child item is an object that can have any of the public properties of this element.\n * Child elements will be created accordingly.\n */\n public get items(): ItemInterface[] {\n const items: ItemInterface[] = [];\n this.__onEachChildItem([i => items.push(i.value)]);\n return items;\n }\n\n /**\n * Creates child elements from ItemInterface[]\n */\n public set items(value: ItemInterface[]) {\n this.__createItems(value);\n }\n\n public get value(): ItemInterface {\n const r: Partial<Record<keyof ItemInterface, unknown>> = {};\n for (let i = 0; i < this.attributes.length; i++) {\n r[this.attributes[i].name] = this.attributes[i].value;\n }\n r.items = this.items;\n return r as ItemInterface;\n }\n\n public set value(v: ItemInterface) {\n this.__itemDescription = '';\n for (const k in v) {\n let attrValue = '';\n if (k == 'description') {\n this.__itemDescription = v[k] as string;\n continue;\n }\n if (typeof v[k as keyof ItemInterface] == 'object') {\n attrValue = JSON.stringify(v[k as keyof ItemInterface]);\n } else {\n const key = k as keyof ItemInterface;\n if ((v[key] && v[key] !== 'undefined') || v[key] === 0) {\n attrValue = v[k as keyof ItemInterface]!.toString();\n }\n }\n this.setAttribute(k, v[k as keyof ItemInterface] ? attrValue : '');\n }\n }\n\n public updated(changedProperties: Map<string, string>): void {\n changedProperties.forEach((oldValue, prop) => {\n if (prop == '__itemDescription' || prop == 'isChildItem') {\n this.__updateDescriptionEl();\n }\n });\n this.__setTotalPrice();\n this.dispatchEvent(new Event('change'));\n }\n\n public render(): TemplateResult {\n if (!this.__isValid()) {\n return html`<x-error-screen type=\"setup_needed\" class=\"relative\"></x-error-screen>`;\n }\n\n const removedStyle = this.quantity ? '' : 'removed opacity-50';\n const sharedStyle = `font-lumo text-body text-s leading-m transition duration-100 ${removedStyle}`;\n\n if (this.isChildItem) {\n return html`\n <article\n part=\"item\"\n class=\"py-s w-full relative separator item-summary flex justify-between ${sharedStyle}\"\n >\n <div class=\"description flex-1\">\n <h1 class=\"text-header font-medium\">${this.name}</h1>\n <section class=\"description text-secondary\">\n <slot></slot>\n </section>\n </div>\n\n ${this.quantity < 2\n ? ''\n : html`\n <section class=\"quantity font-medium text-tertiary whitespace-nowrap\">\n ${this._t('item.items', { quantity: this.quantity })}\n </section>\n `}\n </article>\n `;\n } else {\n const numericItemPrice = (this.price ?? 0) + this.__childPrices.reduce((p, c) => p + c, 0);\n const totalPrice = this.__translateAmount(numericItemPrice * this.quantity);\n const itemPrice = this.__translateAmount(numericItemPrice);\n\n return html`\n <article\n part=\"item\"\n class=\"p-l relative item ${sharedStyle} ${this.__modified ? 'modified' : ''}\"\n >\n <x-preview\n class=\"preview float-left w-preview h-preview mr-l mb-l\"\n exportparts=\"picture\"\n .image=${this.image}\n .quantity=${this.quantity}\n .items=${[...this.querySelectorAll('[data-bundled]')].map(child => ({\n quantity: (child as Item).quantity,\n image: (child as Item).image ?? '',\n }))}\n >\n </x-preview>\n\n <section class=\"description min-w-description ml-description\">\n <h1 class=\"text-header font-medium text-l leading-none mr-quantity mb-s\">\n ${this.name}\n </h1>\n\n <div class=\"item-description text-secondary mr-quantity mb-s\">\n <slot></slot>\n </div>\n\n <div class=\"child-items mb-s\">\n <slot name=\"items\"></slot>\n </div>\n\n ${itemPrice ? html`<div class=\"font-medium price text-l\">${itemPrice}</div>` : ''}\n </section>\n\n <section class=\"quantity w-quantity absolute top-0 right-0 m-l\">\n <vaadin-integer-field\n class=\"w-full p-0\"\n name=\"quantity\"\n @change=${this.__handleQuantity}\n value=\"${this.quantity}\"\n min=\"0\"\n has-controls\n ?readonly=${this.readonly}\n >\n </vaadin-integer-field>\n\n ${this.quantity > 1\n ? html`\n <x-i18n\n .ns=${this.ns}\n .lang=${this.lang}\n .opts=${{ amount: totalPrice }}\n class=\"price-total text-secondary text-xs text-center block mt-xs\"\n key=\"price.total\"\n >\n </x-i18n>\n `\n : ''}\n </section>\n </article>\n `;\n }\n }\n\n public getImageDescription(): ImageDescription {\n return {\n src: this.image,\n alt: this.alt,\n quantity: this.quantity,\n };\n }\n\n /**\n * Items have their signed names prefixed with their id.\n *\n * @argument fieldName the name of the field to get the signed version.\n * @argument open whether this field is editable by the user.\n * @returns signed version of the name, prefixed with the item id.\n */\n public signedName(fieldName: string): string {\n const signed = super.signedName(fieldName);\n return `${this.pid.toString()}:${signed}`;\n }\n\n /**\n * Creates a new unique id to be used in the form\n *\n * Ids are used to distinguish different items in a single form.\n * Ids are prepended to fields names to allow Foxy Cart to know to what\n * item a particular field relates.\n *\n * @return number the newly created id\n */\n private static __newId(): number {\n // Get the maximum value\n const newId = Item.__existingIds.reduce((accum, curr) => (curr > accum ? curr : accum), 0) + 1;\n Item.__existingIds.push(newId);\n return newId;\n }\n\n private __updateDescriptionEl() {\n if (this.__itemDescription) {\n let descEl: HTMLElement | null = this.shadowRoot!.querySelector('data-item-description');\n if (!descEl) {\n descEl = document.createElement('p') as HTMLElement;\n descEl.dataset.itemDescription = 'true';\n this.__addSlottedEl(descEl);\n }\n descEl.innerText = this.__itemDescription;\n } else {\n const descEl: HTMLElement | null = this.shadowRoot!.querySelector('data-item-description');\n if (descEl) descEl.remove();\n }\n }\n\n /**\n * Add an element to the default slot\n */\n private __addSlottedEl(el: HTMLElement) {\n const slot = this.shadowRoot!.querySelector('article');\n if (slot) {\n slot!.appendChild(el);\n }\n }\n\n /**\n * Creates a code if none is provided by the user\n */\n private __setCode(): void {\n if (!this.code) {\n this.code = `RAND${Math.random()}`;\n }\n }\n\n /**\n * Create child items from items field.\n */\n private __createItems(valuesArray: ItemInterface[]): void {\n valuesArray.forEach(p => {\n // Use a reference to the constructor of the instance in order to avoid issues in tests\n const item = document.createElement(this.tagName) as Item;\n item.value = p;\n item.currency = this.currency;\n item.__computeTotalPrice();\n this.__acknowledgeItem(item);\n this.appendChild(item);\n });\n }\n\n private __setTotalPrice(): void {\n this.total = this.__computeTotalPrice();\n }\n\n /**\n * The price of the total qty of each of the child items\n */\n private __computeTotalPrice(): number {\n if (!this.__childPrices) {\n if (!this.price) return 0;\n return this.price * this.quantity;\n }\n let myPrice = 0;\n this.__childPrices.forEach(p => {\n myPrice += p;\n });\n myPrice += this.price!;\n myPrice *= this.quantity;\n return myPrice;\n }\n\n /**\n * Constraints Items must eventually adhere to.\n **/\n private __isValid(): boolean {\n const error = [];\n if (!this.name || !this.name.length) {\n error.push('The name attribute of an item is required.');\n }\n if (!this.price && this.price !== 0) {\n error.push('The price attribute of an item is required.');\n }\n if (this.price && this.price! < 0) {\n error.push('Item added with negative price.');\n }\n if (this.quantity_min && this.quantity && this.quantity < this.quantity_min) {\n error.push('Quantity amount is less than minimum quantity.');\n }\n if (this.quantity_max && this.quantity && this.quantity > this.quantity_max) {\n error.push('Quantity amount is more than maximum quantity.');\n }\n console.error(...error);\n return !error.length;\n }\n\n private __translateAmount(amount: number) {\n if (!this.currency) {\n return '';\n }\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 2,\n currency: this.currency,\n style: 'currency',\n });\n }\n\n private __observeItems(mutationList: MutationRecord[]): void {\n mutationList.forEach(m => {\n if (m.type == 'childList') {\n m.addedNodes.forEach(n => {\n if (n.nodeType === Node.DOCUMENT_NODE) {\n this.__acknowledgeItem(n as Item);\n }\n });\n }\n });\n this.__setTotalPrice();\n }\n\n private __acknowledgeChildItems() {\n this.shadowRoot\n ?.querySelectorAll('[data-item]')\n .forEach(e => this.__acknowledgeItem(e as Item));\n this.querySelectorAll('[data-item]').forEach(e => this.__acknowledgeItem(e as Item));\n }\n\n private __acknowledgeItem(e: Item): void {\n e.addEventListener('change', this.__changedChildItem.bind(this));\n e.currency = this.currency;\n e.isItem = false;\n e.isChildItem = true;\n if (this.code) {\n e.parent_code = this.code;\n }\n }\n\n /** React to changes in child items */\n private __changedChildItem() {\n // Reset child attributes lists\n const newItemPrices: number[] = [];\n const newItemImages: ImageDescription[] = [];\n let newChildrenCount = 0;\n\n // Create collection functions\n const collectPrices = (p: Item) => {\n if (p.total !== undefined) {\n newItemPrices.push(p.total);\n }\n };\n const collectImages = (p: Item) => {\n newItemImages.push(p.getImageDescription());\n };\n const countChildren = () => (newChildrenCount += 1);\n // Collect information of every child\n this.__onEachChildItem([collectPrices, collectImages, countChildren]);\n\n if (this.image && newItemImages.length === 0) {\n newItemImages.push(this.getImageDescription());\n }\n\n // Update atributes regarding child items\n this.__childPrices = newItemPrices;\n this.__images = newItemImages;\n this.__childrenCount = newChildrenCount;\n this.__setTotalPrice();\n }\n\n /** Execute a list of actions against all child items */\n private __onEachChildItem(actions: ((c: Item) => void)[]) {\n const myChildItems = this.querySelectorAll('[data-bundled]');\n for (const c of myChildItems) {\n for (const actOn of actions) {\n actOn(c as Item);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../src/elements/public/ItemsForm/private/Item.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAC;AAExD,OAAO,EAAwD,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,kCAA+B;AAG3D,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,cAAc,EAAE,4BAAyB;AAElD;;;;;;;GAOG;AACH,MAAM,OAAO,IAAK,SAAQ,cAAc;IAyRtC;QACE,KAAK,CAAC,YAAY,CAAC,CAAC;QA7KN,QAAG,GAAG,cAAc,CAAC;QAgBrC;;WAEG;QACI,aAAQ,GAAG,KAAK,CAAC;QAmCxB;;WAEG;QACI,aAAQ,GAAG,CAAC,CAAC;QA+DpB;;;;WAIG;QACI,UAAK,GAAY,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAEnD;;;;;WAKG;QACI,aAAQ,GAAG,EAAE,CAAC;QAErB,wDAAwD;QAC9C,WAAM,GAAG,IAAI,CAAC;QAExB,wDAAwD;QAC9C,gBAAW,GAAG,KAAK,CAAC;QAE9B;;WAEG;QACa,QAAG,GAAW,IAAI,CAAC,OAAO,EAAE,CAAC;QAOrC,eAAU,GAAG,KAAK,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,CAAC,CAAC;aAC7B;QACH,CAAC,CAAC;QACF,MAAM,aAAa,GAAG,CAAC,CAAO,EAAE,EAAE;YAChC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC;QACF,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;QACpD,qCAAqC;QACrC,IAAI,CAAC,iBAAiB,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;QAEtE,IAAI,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;SAChD;QAED,yCAAyC;QACzC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC;QACxC,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,wDAAwD;IAChD,iBAAiB,CAAC,OAA8B;QACtD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAC7D,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,KAAK,CAAC,CAAS,CAAC,CAAC;aAClB;SACF;IACH,CAAC;;AAzZD,kDAAkD;AACnC,kBAAa,GAAa,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-text-field/vaadin-integer-field';\n\nimport { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\nimport { ErrorScreen, I18N } from '../../../private/index';\nimport { ImageDescription, ItemInterface } from '../types';\n\nimport { Preview } from './Preview';\nimport { SignableFields } from './SignableFields';\n\n/**\n * This component allows a user to configure an item.\n *\n * The item may be configured using HTML properties or a JS object.\n *\n * @csspart picture - Image of the product in preview stack (for single products) or grid (for bundles).\n * @csspart item - The root element inside of the shadow dom.\n */\nexport class Item extends SignableFields {\n // A list of item properties as defined in Foxy Cart Documentation\n\n /** @readonly */\n static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n :host {\n --quantity-width: 6.5rem;\n --preview-size: 5.5rem;\n --threshold: 20rem;\n }\n\n .min-w-description::before {\n content: '';\n width: var(--threshold);\n display: block;\n overflow: hidden;\n }\n\n .ml-description {\n --min-width: calc(var(--threshold) + var(--preview-size) + var(--lumo-space-l));\n --free-space: calc(100% - var(--min-width));\n --max-margin-left: calc(var(--preview-size) + var(--lumo-space-l));\n --final-margin-left: clamp(0rem, var(--free-space) * 999999999, var(--max-margin-left));\n margin-left: var(--final-margin-left);\n }\n\n .mr-quantity {\n --min-width: var(--threshold);\n --free-space: calc(100% - var(--min-width));\n --max-margin-right: calc(var(--quantity-width) + var(--lumo-space-l));\n --final-margin-right: clamp(0rem, var(--free-space) * 999999999, var(--max-margin-right));\n margin-right: var(--final-margin-right);\n }\n\n :host([data-bundled]:not(:last-of-type)) .separator::after {\n content: ' ';\n display: block;\n position: absolute;\n width: 100vw;\n border-bottom: solid thin var(--lumo-shade-10pct);\n left: 0;\n bottom: 0;\n }\n\n .w-quantity {\n width: var(--quantity-width);\n }\n\n .w-preview {\n width: var(--preview-size);\n }\n\n .h-preview {\n height: var(--preview-size);\n }\n `,\n ];\n }\n\n /** @readonly */\n public static get scopedElements(): Record<string, unknown> {\n return {\n 'vaadin-integer-field': customElements.get('vaadin-integer-field'),\n 'x-error-screen': ErrorScreen,\n 'x-preview': Preview,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __modified: {},\n readonly: { type: Boolean, reflect: true },\n currency: { type: String },\n category: { type: String },\n code: { type: String, reflect: true },\n expires: { type: String },\n height: { type: Number },\n image: { type: String },\n length: { type: Number },\n name: { type: String },\n parent_code: { type: String },\n price: { type: Number },\n quantity: { type: Number, reflect: true },\n quantity_max: { type: Number },\n quantity_min: { type: String },\n shipto: { type: String },\n total: { type: Number, reflect: true, attribute: 'total' },\n url: { type: String },\n value: { type: Object },\n weight: { type: Number },\n width: { type: Number },\n __childPrices: {},\n __childrenCount: {},\n __images: {},\n alt: { type: String },\n isChildItem: { type: Boolean, reflect: true, attribute: 'data-bundled' },\n isItem: { type: Boolean, reflect: true, attribute: 'data-item' },\n open: { type: Object },\n pid: { type: Number, reflect: true },\n items: { type: Array },\n };\n }\n\n public readonly rel = 'product_item';\n\n /**\n * **Required** the name of the item.\n *\n * **Example:** `\"Dog food\"`\n */\n public name?: string;\n\n /**\n * **Required** the price of a unit of this item\n *\n * **Example:** `10`\n */\n public price?: number;\n\n /**\n * Makes quantity input readonly.\n */\n public readonly = false;\n\n /**\n * Optional an image url to be displayed in the form.\n */\n public image?: string;\n\n /**\n * Optional the alt text for the image\n */\n public alt?: string;\n\n /**\n * Optional an image url to be displayed in the foxy cart once the custumer reaches the cart.\n */\n public url?: string;\n\n /**\n * Optional item code. 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?: string | number;\n\n /**\n * Optional parent code. This property affects cart UI only.\n * It causes Foxy Cart to recognize the parent-child relationship between two items.\n *\n * Nested items set this property automatically.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public parent_code?: string | number;\n\n /**\n * **Required** The quantity of this item in the cart.\n */\n public quantity = 0;\n\n /**\n * Optional quantity max. The maximum number of items of these to be added.\n */\n public quantity_max?: number;\n\n /**\n * Optional quantity min. The minimum number of items of these to be added.\n */\n public quantity_min?: number;\n\n /**\n * Optional category. Sets the category this item is in.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"heavy\"`\n */\n public category?: string;\n\n /**\n * Optional expires. Sets the expiration time of this item.\n *\n * Advanced usage only: This property affects cart UI only.\n * This web component will not react to this property.\n *\n * The item cannot be purchased after expiration, but if it is part of a\n * subscription, it remains in the subscription as long as it stands.\n *\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `15`\n */\n public expires?: string;\n\n /**\n * Optional per item weight. This property affects cart UI only.\n */\n public weight?: number;\n\n /**\n * Optional. Specify a ship-to address for a specific item.\n *\n * Advanced usage only: This property affects cart UI only.\n * This element does not provide any means for the user to specify this property.\n */\n public shipto?: string;\n\n /**\n * Optional length. This property affects cart UI only.\n */\n public length?: number;\n\n /**\n * Optional width. This property affects cart UI only.\n */\n public width?: number;\n\n /**\n * Optional height. This property affects cart UI only.\n */\n public height?: number;\n\n /**\n * The total price of this item.\n *\n * It takes into account child items and the quantity.\n */\n public total?: number = this.__computeTotalPrice();\n\n /**\n * 3-letter lowercase currency code.\n * It is provided by the form if not set.\n *\n * **Example:** `\"usd\"`\n */\n public currency = '';\n\n /** A boolean indicating that this element is a item **/\n protected isItem = true;\n\n /** Boolean indicating that this item is a child item */\n protected isChildItem = false;\n\n /**\n * A unique id set to the item. Advanced usage only.\n */\n public readonly pid: number = Item.__newId();\n\n // A list of all existing ids to guarantee unicity\n private static __existingIds: number[] = [];\n\n private __childItemsObserver?: MutationObserver;\n\n private __modified = false;\n\n private __childPrices: number[] = [];\n\n private __images: ImageDescription[] = [];\n\n private __childrenCount = 0;\n\n private __itemDescription = '';\n\n private __handleQuantity = {\n handleEvent: (ev: Event) => {\n const newValue = Number((ev.target as HTMLInputElement).value);\n this.quantity = newValue;\n this.__modified = true;\n this.__images = ([this.getImageDescription()] as ImageDescription[]).concat(\n this.__images.slice(1, this.__images.length)\n );\n },\n };\n\n public constructor() {\n super('items-form');\n this.__childItemsObserver = new MutationObserver(this.__observeItems.bind(this));\n this.__childItemsObserver.observe(this, {\n childList: true,\n attributes: false,\n subtree: true,\n });\n this.updateComplete.then(() => {\n this.__setCode();\n this.__acknowledgeChildItems();\n this.__changedChildItem();\n if (!this.__isValid()) {\n console.error('Invalid item', this.value);\n }\n });\n }\n\n /**\n * Each child item is an object that can have any of the public properties of this element.\n * Child elements will be created accordingly.\n */\n public get items(): ItemInterface[] {\n const items: ItemInterface[] = [];\n this.__onEachChildItem([i => items.push(i.value)]);\n return items;\n }\n\n /**\n * Creates child elements from ItemInterface[]\n */\n public set items(value: ItemInterface[]) {\n this.__createItems(value);\n }\n\n public get value(): ItemInterface {\n const r: Partial<Record<keyof ItemInterface, unknown>> = {};\n for (let i = 0; i < this.attributes.length; i++) {\n r[this.attributes[i].name] = this.attributes[i].value;\n }\n r.items = this.items;\n return r as ItemInterface;\n }\n\n public set value(v: ItemInterface) {\n this.__itemDescription = '';\n for (const k in v) {\n let attrValue = '';\n if (k == 'description') {\n this.__itemDescription = v[k] as string;\n continue;\n }\n if (typeof v[k as keyof ItemInterface] == 'object') {\n attrValue = JSON.stringify(v[k as keyof ItemInterface]);\n } else {\n const key = k as keyof ItemInterface;\n if ((v[key] && v[key] !== 'undefined') || v[key] === 0) {\n attrValue = v[k as keyof ItemInterface]!.toString();\n }\n }\n this.setAttribute(k, v[k as keyof ItemInterface] ? attrValue : '');\n }\n }\n\n public updated(changedProperties: Map<string, string>): void {\n changedProperties.forEach((oldValue, prop) => {\n if (prop == '__itemDescription' || prop == 'isChildItem') {\n this.__updateDescriptionEl();\n }\n });\n this.__setTotalPrice();\n this.dispatchEvent(new Event('change'));\n }\n\n public render(): TemplateResult {\n if (!this.__isValid()) {\n return html`<x-error-screen type=\"setup_needed\" class=\"relative\"></x-error-screen>`;\n }\n\n const removedStyle = this.quantity ? '' : 'removed opacity-50';\n const sharedStyle = `font-lumo text-body text-s leading-m transition duration-100 ${removedStyle}`;\n\n if (this.isChildItem) {\n return html`\n <article\n part=\"item\"\n class=\"py-s w-full relative separator item-summary flex justify-between ${sharedStyle}\"\n >\n <div class=\"description flex-1\">\n <h1 class=\"text-header font-medium\">${this.name}</h1>\n <section class=\"description text-secondary\">\n <slot></slot>\n </section>\n </div>\n\n ${this.quantity < 2\n ? ''\n : html`\n <section class=\"quantity font-medium text-tertiary whitespace-nowrap\">\n ${this._t('item.items', { quantity: this.quantity })}\n </section>\n `}\n </article>\n `;\n } else {\n const numericItemPrice = (this.price ?? 0) + this.__childPrices.reduce((p, c) => p + c, 0);\n const totalPrice = this.__translateAmount(numericItemPrice * this.quantity);\n const itemPrice = this.__translateAmount(numericItemPrice);\n\n return html`\n <article\n part=\"item\"\n class=\"p-l relative item ${sharedStyle} ${this.__modified ? 'modified' : ''}\"\n >\n <x-preview\n class=\"preview float-left w-preview h-preview mr-l mb-l\"\n exportparts=\"picture\"\n .image=${this.image}\n .quantity=${this.quantity}\n .items=${[...this.querySelectorAll('[data-bundled]')].map(child => ({\n quantity: (child as Item).quantity,\n image: (child as Item).image ?? '',\n }))}\n >\n </x-preview>\n\n <section class=\"description min-w-description ml-description\">\n <h1 class=\"text-header font-medium text-l leading-none mr-quantity mb-s\">\n ${this.name}\n </h1>\n\n <div class=\"item-description text-secondary mr-quantity mb-s\">\n <slot></slot>\n </div>\n\n <div class=\"child-items mb-s\">\n <slot name=\"items\"></slot>\n </div>\n\n ${itemPrice ? html`<div class=\"font-medium price text-l\">${itemPrice}</div>` : ''}\n </section>\n\n <section class=\"quantity w-quantity absolute top-0 right-0 m-l\">\n <vaadin-integer-field\n class=\"w-full p-0\"\n name=\"quantity\"\n @change=${this.__handleQuantity}\n value=\"${this.quantity}\"\n min=\"0\"\n has-controls\n ?readonly=${this.readonly}\n >\n </vaadin-integer-field>\n\n ${this.quantity > 1\n ? html`\n <x-i18n\n .ns=${this.ns}\n .lang=${this.lang}\n .opts=${{ amount: totalPrice }}\n class=\"price-total text-secondary text-xs text-center block mt-xs\"\n key=\"price.total\"\n >\n </x-i18n>\n `\n : ''}\n </section>\n </article>\n `;\n }\n }\n\n public getImageDescription(): ImageDescription {\n return {\n src: this.image,\n alt: this.alt,\n quantity: this.quantity,\n };\n }\n\n /**\n * Items have their signed names prefixed with their id.\n *\n * @argument fieldName the name of the field to get the signed version.\n * @argument open whether this field is editable by the user.\n * @returns signed version of the name, prefixed with the item id.\n */\n public signedName(fieldName: string): string {\n const signed = super.signedName(fieldName);\n return `${this.pid.toString()}:${signed}`;\n }\n\n /**\n * Creates a new unique id to be used in the form\n *\n * Ids are used to distinguish different items in a single form.\n * Ids are prepended to fields names to allow Foxy Cart to know to what\n * item a particular field relates.\n *\n * @return number the newly created id\n */\n private static __newId(): number {\n // Get the maximum value\n const newId = Item.__existingIds.reduce((accum, curr) => (curr > accum ? curr : accum), 0) + 1;\n Item.__existingIds.push(newId);\n return newId;\n }\n\n private __updateDescriptionEl() {\n if (this.__itemDescription) {\n let descEl: HTMLElement | null = this.shadowRoot!.querySelector('data-item-description');\n if (!descEl) {\n descEl = document.createElement('p') as HTMLElement;\n descEl.dataset.itemDescription = 'true';\n this.__addSlottedEl(descEl);\n }\n descEl.innerText = this.__itemDescription;\n } else {\n const descEl: HTMLElement | null = this.shadowRoot!.querySelector('data-item-description');\n if (descEl) descEl.remove();\n }\n }\n\n /**\n * Add an element to the default slot\n */\n private __addSlottedEl(el: HTMLElement) {\n const slot = this.shadowRoot!.querySelector('article');\n if (slot) {\n slot!.appendChild(el);\n }\n }\n\n /**\n * Creates a code if none is provided by the user\n */\n private __setCode(): void {\n if (!this.code) {\n this.code = `RAND${Math.random()}`;\n }\n }\n\n /**\n * Create child items from items field.\n */\n private __createItems(valuesArray: ItemInterface[]): void {\n valuesArray.forEach(p => {\n // Use a reference to the constructor of the instance in order to avoid issues in tests\n const item = document.createElement(this.tagName) as Item;\n item.value = p;\n item.currency = this.currency;\n item.__computeTotalPrice();\n this.__acknowledgeItem(item);\n this.appendChild(item);\n });\n }\n\n private __setTotalPrice(): void {\n this.total = this.__computeTotalPrice();\n }\n\n /**\n * The price of the total qty of each of the child items\n */\n private __computeTotalPrice(): number {\n if (!this.__childPrices) {\n if (!this.price) return 0;\n return this.price * this.quantity;\n }\n let myPrice = 0;\n this.__childPrices.forEach(p => {\n myPrice += p;\n });\n myPrice += this.price!;\n myPrice *= this.quantity;\n return myPrice;\n }\n\n /**\n * Constraints Items must eventually adhere to.\n **/\n private __isValid(): boolean {\n const error = [];\n if (!this.name || !this.name.length) {\n error.push('The name attribute of an item is required.');\n }\n if (!this.price && this.price !== 0) {\n error.push('The price attribute of an item is required.');\n }\n if (this.price && this.price! < 0) {\n error.push('Item added with negative price.');\n }\n if (this.quantity_min && this.quantity && this.quantity < this.quantity_min) {\n error.push('Quantity amount is less than minimum quantity.');\n }\n if (this.quantity_max && this.quantity && this.quantity > this.quantity_max) {\n error.push('Quantity amount is more than maximum quantity.');\n }\n console.error(...error);\n return !error.length;\n }\n\n private __translateAmount(amount: number) {\n if (!this.currency) {\n return '';\n }\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 2,\n currency: this.currency,\n style: 'currency',\n });\n }\n\n private __observeItems(mutationList: MutationRecord[]): void {\n mutationList.forEach(m => {\n if (m.type == 'childList') {\n m.addedNodes.forEach(n => {\n if (n.nodeType === Node.DOCUMENT_NODE) {\n this.__acknowledgeItem(n as Item);\n }\n });\n }\n });\n this.__setTotalPrice();\n }\n\n private __acknowledgeChildItems() {\n this.shadowRoot\n ?.querySelectorAll('[data-item]')\n .forEach(e => this.__acknowledgeItem(e as Item));\n this.querySelectorAll('[data-item]').forEach(e => this.__acknowledgeItem(e as Item));\n }\n\n private __acknowledgeItem(e: Item): void {\n e.addEventListener('change', this.__changedChildItem.bind(this));\n e.currency = this.currency;\n e.isItem = false;\n e.isChildItem = true;\n e.setAttribute('data-bundled', '');\n if (this.code) {\n e.parent_code = this.code;\n }\n }\n\n /** React to changes in child items */\n private __changedChildItem() {\n // Reset child attributes lists\n const newItemPrices: number[] = [];\n const newItemImages: ImageDescription[] = [];\n let newChildrenCount = 0;\n\n // Create collection functions\n const collectPrices = (p: Item) => {\n if (p.total !== undefined) {\n newItemPrices.push(p.total);\n }\n };\n const collectImages = (p: Item) => {\n newItemImages.push(p.getImageDescription());\n };\n const countChildren = () => (newChildrenCount += 1);\n // Collect information of every child\n this.__onEachChildItem([collectPrices, collectImages, countChildren]);\n\n if (this.image && newItemImages.length === 0) {\n newItemImages.push(this.getImageDescription());\n }\n\n // Update atributes regarding child items\n this.__childPrices = newItemPrices;\n this.__images = newItemImages;\n this.__childrenCount = newChildrenCount;\n this.__setTotalPrice();\n }\n\n /** Execute a list of actions against all child items */\n private __onEachChildItem(actions: ((c: Item) => void)[]) {\n const myChildItems = this.querySelectorAll('[data-bundled]');\n for (const c of myChildItems) {\n for (const actOn of actions) {\n actOn(c as Item);\n }\n }\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { TranslatableMixin } from "../../../mixins/translatable.js";
2
2
  import { InternalCard } from "../../internal/InternalCard/InternalCard.js";
3
3
  import { ifDefined } from 'lit-html/directives/if-defined';
4
+ import { decode } from 'html-entities';
4
5
  import { html } from 'lit-html';
5
6
  const NS = 'shipment-card';
6
7
  const Base = TranslatableMixin(InternalCard, NS);
@@ -53,7 +54,7 @@ export class ShipmentCard extends Base {
53
54
  </foxy-i18n>
54
55
 
55
56
  <span class="truncate text-s text-secondary">
56
- ${description ? html `${description} &bull; ` : ''}
57
+ ${description ? html `${decode(description)} &bull; ` : ''}
57
58
  <foxy-i18n key="price" infer="" .options=${priceOptions}></foxy-i18n>
58
59
  &bull;
59
60
  <foxy-i18n infer="" key="item" .options=${{ count: items.length }}></foxy-i18n>
@@ -74,7 +75,9 @@ export class ShipmentCard extends Base {
74
75
  const weightUnit = category === null || category === void 0 ? void 0 : category.default_weight_unit;
75
76
  return html `
76
77
  <tr>
77
- <td class="pr-s font-medium">${item.code}</td>
78
+ <td class="pr-s font-medium">
79
+ ${item.code || html `<foxy-i18n infer="" key="no_code"></foxy-i18n>`}
80
+ </td>
78
81
  <td class="px-s text-secondary">${item.name}</td>
79
82
  <td class="px-s text-tertiary">
80
83
  ${item.width}&times;${item.height}&times;${item.length} ${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AAC,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;IAChF,CAAC;IAED,IAAY,mBAAmB;QAE7B,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAY,iBAAiB;;QAC3B,MAAM,KAAK,SAAG,IAAI,CAAC,aAAa,0CAAE,IAAI,CAAC;QACvC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACxF,CAAC;IAED,IAAY,cAAc;;QACxB,mBAAO,IAAI,CAAC,mBAAmB,0CAAE,IAAI,0CAAE,aAAa,CAAC;IACvD,CAAC;CACF","sourcesContent":["import type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'shipment-card';\nconst Base = TranslatableMixin(InternalCard, NS);\n\n/**\n * Basic card displaying a shipment (`fx:shipment`).\n *\n * @element foxy-shipment-card\n * @since 1.17.0\n */\nexport class ShipmentCard extends Base<Data> {\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const { address_name, address1, address2, city, region, postal_code } = this.data ?? {};\n const addressOptions = { address_name, address1, address2, city, region, postal_code };\n\n const amount = `${this.data?.total_shipping} ${this.__currencyCode}`;\n const currencyDisplay = this.__currencyDisplay;\n const priceOptions = { amount, currencyDisplay };\n const description = this.data?.shipping_service_description;\n const items = this.data?._embedded?.['fx:items'] ?? [];\n\n return html`\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:transaction'].href)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"space-y-s\">\n <div class=\"grid leading-s text-body\">\n <foxy-i18n\n class=\"truncate text-m font-medium\"\n infer=\"\"\n key=\"full_address\"\n .options=${addressOptions}\n >\n </foxy-i18n>\n\n <span class=\"truncate text-s text-secondary\">\n ${description ? html`${description} &bull; ` : ''}\n <foxy-i18n key=\"price\" infer=\"\" .options=${priceOptions}></foxy-i18n>\n &bull;\n <foxy-i18n infer=\"\" key=\"item\" .options=${{ count: items.length }}></foxy-i18n>\n </span>\n </div>\n\n ${items.length > 0\n ? html`\n <div class=\"border-t border-dashed border-contrast-20\"></div>\n <div class=\"overflow-auto\">\n <table class=\"text-s leading-s whitespace-nowrap\">\n <thead></thead>\n <tbody>\n ${items.map(item => {\n const category = item._embedded?.['fx:item_category'];\n const lengthUnit = category?.default_length_unit;\n const weightUnit = category?.default_weight_unit;\n\n return html`\n <tr>\n <td class=\"pr-s font-medium\">${item.code}</td>\n <td class=\"px-s text-secondary\">${item.name}</td>\n <td class=\"px-s text-tertiary\">\n ${item.width}&times;${item.height}&times;${item.length} ${lengthUnit}\n </td>\n <td class=\"px-s text-tertiary\">${item.weight} ${weightUnit}</td>\n <td class=\"pl-s font-medium\">\n <foxy-i18n infer=\"\" key=\"quantity\" .options=${{ count: item.quantity }}>\n </foxy-i18n>\n </td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n </div>\n `\n : ''}\n </div>\n `;\n }\n\n get isBodyReady() {\n return super.isBodyReady && !!this.__currencyDisplay && !!this.__currencyCode;\n }\n\n private get __transactionLoader() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__transactionLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n private get __currencyDisplay() {\n const store = this.__storeLoader?.data;\n return store ? (store.use_international_currency_symbol ? 'code' : 'symbol') : void 0;\n }\n\n private get __currencyCode() {\n return this.__transactionLoader?.data?.currency_code;\n }\n}\n"]}
1
+ {"version":3,"file":"ShipmentCard.js","sourceRoot":"","sources":["../../../../src/elements/public/ShipmentCard/ShipmentCard.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,IAAU;IAA5C;;QACmB,0BAAqB,GAAG,mBAAmB,CAAC;QAE5C,oBAAe,GAAG,aAAa,CAAC;IA2GnD,CAAC;IAzGC,UAAU;;QACR,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAG,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;QACxF,MAAM,cAAc,GAAG,EAAE,YAAY,EAAE,QAAQ,EAA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} from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { decode } from 'html-entities';\nimport { html } from 'lit-html';\n\nconst NS = 'shipment-card';\nconst Base = TranslatableMixin(InternalCard, NS);\n\n/**\n * Basic card displaying a shipment (`fx:shipment`).\n *\n * @element foxy-shipment-card\n * @since 1.17.0\n */\nexport class ShipmentCard extends Base<Data> {\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const { address_name, address1, address2, city, region, postal_code } = this.data ?? {};\n const addressOptions = { address_name, address1, address2, city, region, postal_code };\n\n const amount = `${this.data?.total_shipping} ${this.__currencyCode}`;\n const currencyDisplay = this.__currencyDisplay;\n const priceOptions = { amount, currencyDisplay };\n const description = this.data?.shipping_service_description;\n const items = this.data?._embedded?.['fx:items'] ?? [];\n\n return html`\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:transaction'].href)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"space-y-s\">\n <div class=\"grid leading-s text-body\">\n <foxy-i18n\n class=\"truncate text-m font-medium\"\n infer=\"\"\n key=\"full_address\"\n .options=${addressOptions}\n >\n </foxy-i18n>\n\n <span class=\"truncate text-s text-secondary\">\n ${description ? html`${decode(description)} &bull; ` : ''}\n <foxy-i18n key=\"price\" infer=\"\" .options=${priceOptions}></foxy-i18n>\n &bull;\n <foxy-i18n infer=\"\" key=\"item\" .options=${{ count: items.length }}></foxy-i18n>\n </span>\n </div>\n\n ${items.length > 0\n ? html`\n <div class=\"border-t border-dashed border-contrast-20\"></div>\n <div class=\"overflow-auto\">\n <table class=\"text-s leading-s whitespace-nowrap\">\n <thead></thead>\n <tbody>\n ${items.map(item => {\n const category = item._embedded?.['fx:item_category'];\n const lengthUnit = category?.default_length_unit;\n const weightUnit = category?.default_weight_unit;\n\n return html`\n <tr>\n <td class=\"pr-s font-medium\">\n ${item.code || html`<foxy-i18n infer=\"\" key=\"no_code\"></foxy-i18n>`}\n </td>\n <td class=\"px-s text-secondary\">${item.name}</td>\n <td class=\"px-s text-tertiary\">\n ${item.width}&times;${item.height}&times;${item.length} ${lengthUnit}\n </td>\n <td class=\"px-s text-tertiary\">${item.weight} ${weightUnit}</td>\n <td class=\"pl-s font-medium\">\n <foxy-i18n infer=\"\" key=\"quantity\" .options=${{ count: item.quantity }}>\n </foxy-i18n>\n </td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n </div>\n `\n : ''}\n </div>\n `;\n }\n\n get isBodyReady() {\n return super.isBodyReady && !!this.__currencyDisplay && !!this.__currencyCode;\n }\n\n private get __transactionLoader() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__transactionLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n private get __currencyDisplay() {\n const store = this.__storeLoader?.data;\n return store ? (store.use_international_currency_symbol ? 'code' : 'symbol') : void 0;\n }\n\n private get __currencyCode() {\n return this.__transactionLoader?.data?.currency_code;\n }\n}\n"]}
@@ -2,7 +2,7 @@ import type { PropertyDeclarations, TemplateResult } from 'lit-element';
2
2
  import type { Data } from './types';
3
3
  import { BooleanSelector } from '@foxy.io/sdk/core';
4
4
  import { InternalForm } from '../../internal/InternalForm/InternalForm';
5
- declare const Transaction_base: typeof InternalForm & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
5
+ declare const Base: typeof InternalForm & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
6
6
  defaultNS: string;
7
7
  };
8
8
  /**
@@ -11,7 +11,7 @@ declare const Transaction_base: typeof InternalForm & import("lit-element").Cons
11
11
  * @element foxy-transaction
12
12
  * @since 1.17.0
13
13
  */
14
- export declare class Transaction extends Transaction_base<Data> {
14
+ export declare class Transaction extends Base<Data> {
15
15
  static get properties(): PropertyDeclarations;
16
16
  /** URL of the `fx:hosted_payment_gateways` property helper resource. */
17
17
  hostedPaymentGatewaysHelper: string | null;
@@ -19,7 +19,6 @@ export declare class Transaction extends Transaction_base<Data> {
19
19
  paymentGatewaysHelper: string | null;
20
20
  getSubscriptionPageHref: ((href: string) => string) | null;
21
21
  getCustomerPageHref: ((href: string) => string) | null;
22
- private readonly __renderHeader;
23
22
  get readonlySelector(): BooleanSelector;
24
23
  get hiddenSelector(): BooleanSelector;
25
24
  renderBody(): TemplateResult;