@foxy.io/elements 1.17.0 → 1.18.0-beta.3

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 (200) hide show
  1. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  2. package/dist/cdn/foxy-address-card.js +3 -85
  3. package/dist/cdn/foxy-address-form.js +1 -1
  4. package/dist/cdn/foxy-api-browser.js +1 -1
  5. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  6. package/dist/cdn/foxy-attribute-card.js +1 -1
  7. package/dist/cdn/foxy-attribute-form.js +1 -1
  8. package/dist/cdn/foxy-cancellation-form.js +1 -1
  9. package/dist/cdn/foxy-collection-page.js +1 -1
  10. package/dist/cdn/foxy-collection-pages.js +1 -1
  11. package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
  12. package/dist/cdn/foxy-coupon-card.js +1 -1
  13. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  14. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  15. package/dist/cdn/foxy-coupon-detail-card.js +1 -1
  16. package/dist/cdn/foxy-coupon-form.js +1 -1
  17. package/dist/cdn/foxy-custom-field-card.js +1 -1
  18. package/dist/cdn/foxy-custom-field-form.js +1 -1
  19. package/dist/cdn/foxy-customer-api.js +1 -1
  20. package/dist/cdn/foxy-customer-card.js +1 -1
  21. package/dist/cdn/foxy-customer-form.js +1 -1
  22. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  23. package/dist/cdn/foxy-customer-portal.js +15 -15
  24. package/dist/cdn/foxy-customer.js +6 -6
  25. package/dist/cdn/foxy-customers-table.js +1 -1
  26. package/dist/cdn/foxy-discount-builder.js +1 -1
  27. package/dist/cdn/foxy-discount-card.js +1 -1
  28. package/dist/cdn/foxy-discount-detail-card.js +1 -1
  29. package/dist/cdn/foxy-donation.js +1 -1
  30. package/dist/cdn/foxy-email-template-form.js +1 -1
  31. package/dist/cdn/foxy-error-entry-card.js +1 -1
  32. package/dist/cdn/foxy-form-dialog.js +1 -1
  33. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  34. package/dist/cdn/foxy-gift-card-card.js +1 -1
  35. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  36. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  37. package/dist/cdn/foxy-gift-card-form.js +1 -1
  38. package/dist/cdn/foxy-i18n.js +1 -1
  39. package/dist/cdn/foxy-item-card.js +1 -1
  40. package/dist/cdn/foxy-item-form.js +1 -1
  41. package/dist/cdn/foxy-item-option-card.js +1 -1
  42. package/dist/cdn/foxy-item-option-form.js +1 -1
  43. package/dist/cdn/foxy-items-form.js +1 -1
  44. package/dist/cdn/foxy-nucleon-element.js +1 -1
  45. package/dist/cdn/foxy-pagination.js +1 -1
  46. package/dist/cdn/foxy-payment-card.js +1 -1
  47. package/dist/cdn/foxy-payment-method-card.js +1 -1
  48. package/dist/cdn/foxy-query-builder.js +1 -1
  49. package/dist/cdn/foxy-report-form.js +4 -4
  50. package/dist/cdn/foxy-reports-table.js +5 -5
  51. package/dist/cdn/foxy-shipment-card.js +1 -1
  52. package/dist/cdn/foxy-sign-in-form.js +1 -1
  53. package/dist/cdn/foxy-spinner.js +1 -1
  54. package/dist/cdn/foxy-store-shipping-method-form.js +150 -0
  55. package/dist/cdn/foxy-subscription-card.js +1 -1
  56. package/dist/cdn/foxy-subscription-form.js +4 -4
  57. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  58. package/dist/cdn/foxy-table.js +1 -1
  59. package/dist/cdn/foxy-tax-card.js +1 -1
  60. package/dist/cdn/foxy-tax-form.js +1 -1
  61. package/dist/cdn/foxy-template-config-form.js +1 -1
  62. package/dist/cdn/foxy-template-form.js +1 -1
  63. package/dist/cdn/foxy-transaction-card.js +1 -1
  64. package/dist/cdn/foxy-transaction.js +1 -1
  65. package/dist/cdn/foxy-transactions-table.js +1 -1
  66. package/dist/cdn/foxy-user-form.js +1 -1
  67. package/dist/cdn/foxy-users-table.js +1 -1
  68. package/dist/cdn/foxy-webhook-card.js +1 -1
  69. package/dist/cdn/foxy-webhook-form.js +1 -1
  70. package/dist/cdn/foxy-webhook-log-card.js +1 -1
  71. package/dist/cdn/foxy-webhook-status-card.js +1 -1
  72. package/dist/cdn/{shared-26ce8d23.js → shared-023c287a.js} +1 -1
  73. package/dist/cdn/{shared-195fd5af.js → shared-084b6372.js} +1 -1
  74. package/dist/cdn/shared-11f0daea.js +169 -0
  75. package/dist/cdn/{shared-6d104622.js → shared-189dfb49.js} +1 -1
  76. package/dist/cdn/shared-23fd456c.js +134 -0
  77. package/dist/cdn/{shared-baf79b0b.js → shared-2ca6d676.js} +1 -1
  78. package/dist/cdn/{shared-c309e0ef.js → shared-2f0efb2c.js} +1 -1
  79. package/dist/cdn/{shared-dda2a74d.js → shared-37b61010.js} +1 -1
  80. package/dist/cdn/shared-381aa7fe.js +1 -0
  81. package/dist/cdn/shared-3a7cf739.js +15 -0
  82. package/dist/cdn/{shared-2188d5f7.js → shared-3e3c07ac.js} +1 -1
  83. package/dist/cdn/{shared-8e9a3bbb.js → shared-412670b8.js} +1 -1
  84. package/dist/cdn/{shared-31c43743.js → shared-4560425c.js} +1 -1
  85. package/dist/cdn/shared-4773b634.js +1 -0
  86. package/dist/cdn/{shared-7c8bb60c.js → shared-4c0520f6.js} +1 -1
  87. package/dist/cdn/{shared-5c3a88d2.js → shared-5482630e.js} +1 -1
  88. package/dist/cdn/{shared-322e7efb.js → shared-5e43b817.js} +1 -1
  89. package/dist/cdn/{shared-a0836fa5.js → shared-60c862aa.js} +1 -1
  90. package/dist/cdn/shared-619adfad.js +1 -0
  91. package/dist/cdn/{shared-b3df4f38.js → shared-68ab037d.js} +1 -1
  92. package/dist/cdn/{shared-7c612495.js → shared-6af95088.js} +1 -1
  93. package/dist/cdn/shared-6ce2acfa.js +1 -0
  94. package/dist/cdn/{shared-c8677ba3.js → shared-6f89d2e0.js} +1 -1
  95. package/dist/cdn/{shared-c5c60417.js → shared-71acf673.js} +1 -1
  96. package/dist/cdn/{shared-c89ba319.js → shared-74a27421.js} +1 -1
  97. package/dist/cdn/{shared-d699348f.js → shared-80b90eec.js} +2 -2
  98. package/dist/cdn/{shared-98497473.js → shared-85d45495.js} +1 -1
  99. package/dist/cdn/{shared-a5e52b8f.js → shared-872ceacf.js} +3 -3
  100. package/dist/cdn/{shared-4e201e09.js → shared-901ca702.js} +1 -1
  101. package/dist/cdn/{shared-ae415a98.js → shared-91b86bae.js} +1 -1
  102. package/dist/cdn/shared-9b392ba8.js +1 -0
  103. package/dist/cdn/{shared-1bbd9b73.js → shared-9be1a70f.js} +1 -1
  104. package/dist/cdn/{shared-8d4fef94.js → shared-9ef13805.js} +1 -1
  105. package/dist/cdn/{shared-bb686fc6.js → shared-9ef81b37.js} +1 -1
  106. package/dist/cdn/{shared-3b2dedf9.js → shared-a2a1193d.js} +1 -1
  107. package/dist/cdn/shared-a48a9dfc.js +82 -0
  108. package/dist/cdn/{shared-8d937ae4.js → shared-c0fb5a33.js} +3 -3
  109. package/dist/cdn/{shared-a052131e.js → shared-c63ba384.js} +1 -1
  110. package/dist/cdn/{shared-d28ac9dc.js → shared-c7280a24.js} +1 -1
  111. package/dist/cdn/{shared-e9a4a204.js → shared-c7c8d1b6.js} +1 -1
  112. package/dist/cdn/{shared-fadcb2e1.js → shared-ca0f14c1.js} +1 -1
  113. package/dist/cdn/{shared-7474af47.js → shared-d91ed0a8.js} +1 -1
  114. package/dist/cdn/{shared-39f2c345.js → shared-daa454bf.js} +1 -1
  115. package/dist/cdn/{shared-2bdd4f74.js → shared-ec7cfc23.js} +1 -1
  116. package/dist/cdn/{shared-bf6fb415.js → shared-f2639daf.js} +1 -1
  117. package/dist/cdn/{shared-62169210.js → shared-f31044b8.js} +1 -1
  118. package/dist/cdn/{shared-f84686a8.js → shared-fcbf9a41.js} +1 -1
  119. package/dist/cdn/{shared-dd6d3c18.js → shared-fd595d0a.js} +1 -1
  120. package/dist/cdn/{shared-dc23b751.js → shared-fe68657a.js} +1 -1
  121. package/dist/cdn/{shared-f1317609.js → shared-ff1d9854.js} +1 -1
  122. package/dist/cdn/translations/store-shipping-method-form/en.json +90 -0
  123. package/dist/elements/internal/InternalAsyncComboBoxControl/InternalAsyncComboBoxControl.d.ts +3 -0
  124. package/dist/elements/internal/InternalAsyncComboBoxControl/InternalAsyncComboBoxControl.js +22 -0
  125. package/dist/elements/internal/InternalAsyncComboBoxControl/InternalAsyncComboBoxControl.js.map +1 -1
  126. package/dist/elements/internal/InternalCheckboxGroupControl/InternalCheckboxGroupControl.d.ts +17 -0
  127. package/dist/elements/internal/InternalCheckboxGroupControl/InternalCheckboxGroupControl.js +51 -0
  128. package/dist/elements/internal/InternalCheckboxGroupControl/InternalCheckboxGroupControl.js.map +1 -0
  129. package/dist/elements/internal/InternalCheckboxGroupControl/index.d.ts +6 -0
  130. package/dist/elements/internal/InternalCheckboxGroupControl/index.js +8 -0
  131. package/dist/elements/internal/InternalCheckboxGroupControl/index.js.map +1 -0
  132. package/dist/elements/internal/InternalCheckboxGroupControl/types.d.ts +6 -0
  133. package/dist/elements/internal/InternalCheckboxGroupControl/types.js +2 -0
  134. package/dist/elements/internal/InternalCheckboxGroupControl/types.js.map +1 -0
  135. package/dist/elements/internal/InternalEditableControl/InternalEditableControl.d.ts +2 -0
  136. package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js +6 -4
  137. package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js.map +1 -1
  138. package/dist/elements/internal/InternalTextAreaControl/InternalTextAreaControl.d.ts +13 -0
  139. package/dist/elements/internal/InternalTextAreaControl/InternalTextAreaControl.js +40 -0
  140. package/dist/elements/internal/InternalTextAreaControl/InternalTextAreaControl.js.map +1 -0
  141. package/dist/elements/internal/InternalTextAreaControl/index.d.ts +4 -0
  142. package/dist/elements/internal/InternalTextAreaControl/index.js +6 -0
  143. package/dist/elements/internal/InternalTextAreaControl/index.js.map +1 -0
  144. package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.js +10 -23
  145. package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.js.map +1 -1
  146. package/dist/elements/public/NucleonElement/NucleonElement.d.ts +2 -1
  147. package/dist/elements/public/NucleonElement/NucleonElement.js +12 -10
  148. package/dist/elements/public/NucleonElement/NucleonElement.js.map +1 -1
  149. package/dist/elements/public/ShipmentCard/ShipmentCard.js +1 -1
  150. package/dist/elements/public/ShipmentCard/ShipmentCard.js.map +1 -1
  151. package/dist/elements/public/StoreShippingMethodForm/StoreShippingMethodForm.d.ts +25 -0
  152. package/dist/elements/public/StoreShippingMethodForm/StoreShippingMethodForm.js +201 -0
  153. package/dist/elements/public/StoreShippingMethodForm/StoreShippingMethodForm.js.map +1 -0
  154. package/dist/elements/public/StoreShippingMethodForm/index.d.ts +11 -0
  155. package/dist/elements/public/StoreShippingMethodForm/index.js +13 -0
  156. package/dist/elements/public/StoreShippingMethodForm/index.js.map +1 -0
  157. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesControl/InternalStoreShippingMethodFormServicesControl.d.ts +5 -0
  158. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesControl/InternalStoreShippingMethodFormServicesControl.js +33 -0
  159. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesControl/InternalStoreShippingMethodFormServicesControl.js.map +1 -0
  160. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesControl/index.d.ts +6 -0
  161. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesControl/index.js +8 -0
  162. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesControl/index.js.map +1 -0
  163. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPage/InternalStoreShippingMethodFormServicesPage.d.ts +19 -0
  164. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPage/InternalStoreShippingMethodFormServicesPage.js +96 -0
  165. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPage/InternalStoreShippingMethodFormServicesPage.js.map +1 -0
  166. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPage/index.d.ts +5 -0
  167. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPage/index.js +7 -0
  168. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPage/index.js.map +1 -0
  169. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItem/InternalStoreShippingMethodFormServicesPageItem.d.ts +17 -0
  170. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItem/InternalStoreShippingMethodFormServicesPageItem.js +45 -0
  171. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItem/InternalStoreShippingMethodFormServicesPageItem.js.map +1 -0
  172. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItem/index.d.ts +3 -0
  173. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItem/index.js +5 -0
  174. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItem/index.js.map +1 -0
  175. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItemContent/InternalStoreShippingMethodFormServicesPageItemContent.d.ts +16 -0
  176. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItemContent/InternalStoreShippingMethodFormServicesPageItemContent.js +49 -0
  177. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItemContent/InternalStoreShippingMethodFormServicesPageItemContent.js.map +1 -0
  178. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItemContent/index.d.ts +3 -0
  179. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItemContent/index.js +5 -0
  180. package/dist/elements/public/StoreShippingMethodForm/internal/InternalStoreShippingMethodFormServicesPageItemContent/index.js.map +1 -0
  181. package/dist/elements/public/StoreShippingMethodForm/types.d.ts +5 -0
  182. package/dist/elements/public/StoreShippingMethodForm/types.js +2 -0
  183. package/dist/elements/public/StoreShippingMethodForm/types.js.map +1 -0
  184. package/dist/elements/public/index.d.ts +1 -0
  185. package/dist/elements/public/index.defined.d.ts +1 -0
  186. package/dist/elements/public/index.defined.js +1 -0
  187. package/dist/elements/public/index.defined.js.map +1 -1
  188. package/dist/elements/public/index.js +1 -0
  189. package/dist/elements/public/index.js.map +1 -1
  190. package/dist/mixins/configurable.js +16 -8
  191. package/dist/mixins/configurable.js.map +1 -1
  192. package/dist/mixins/inferrable.js +25 -23
  193. package/dist/mixins/inferrable.js.map +1 -1
  194. package/package.json +2 -2
  195. package/dist/cdn/shared-45feee83.js +0 -1
  196. package/dist/cdn/shared-63685d2e.js +0 -302
  197. package/dist/cdn/shared-92327224.js +0 -15
  198. package/dist/cdn/shared-ac44429d.js +0 -1
  199. package/dist/cdn/shared-dc1c6edd.js +0 -1
  200. package/dist/cdn/shared-dc3ffd38.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"InternalCustomerPortalLoggedInView.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,wCAAqC;AAC3E,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,GAAG,EAAE,iCAA8B;AAG5C,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAKlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,MAAM,IAAI,GAAG,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,c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;IAED,IAAY,iBAAiB;QAC3B,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAW,WAAW,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import { ConfigurableMixin, Renderer } from '../../../mixins/configurable';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { API } from '../NucleonElement/API';\nimport { Customer } from '../Customer/Customer';\nimport { Templates as CustomerTemplates } from '../Customer/types';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/customer';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { Templates } from './types';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\n\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement)));\ntype Data = Resource<Rels.CustomerPortalSettings>;\n\nexport class InternalCustomerPortalLoggedInView extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n customer: { type: String },\n loggingOutState: { attribute: false },\n loggingOutStateResetTimeout: { attribute: false },\n };\n }\n\n templates: Templates = {};\n\n customer = '';\n\n loggingOutState: 'idle' | 'busy' | 'fail' = 'idle';\n\n loggingOutStateResetTimeout: NodeJS.Timeout | null = null;\n\n private readonly __renderHeaderActionsSignOut = () => {\n const scope = 'customer:header:actions:sign-out';\n const state = this.loggingOutState;\n\n const isDisabled =\n this.disabledSelector.matches(scope) ||\n !this.__customerElement?.in({ idle: 'snapshot' }) ||\n state !== 'idle';\n\n const handleClick = async () => {\n try {\n this.loggingOutState = 'busy';\n await new API(this).fetch('foxy://customer-api/session', { method: 'DELETE' });\n this.loggingOutState = 'idle';\n } catch {\n this.loggingOutState = 'fail';\n this.loggingOutStateResetTimeout = setTimeout(() => {\n this.loggingOutState = 'idle';\n this.loggingOutStateResetTimeout = null;\n }, 1000);\n }\n };\n\n const style = {\n 'border-radius': '100%',\n 'padding': 'var(--lumo-space-xs)',\n 'display': 'flex',\n 'margin': '0',\n 'cursor': isDisabled ? 'default' : 'pointer',\n };\n\n return html`\n <div style=\"display: flex; margin-left: var(--lumo-space-m)\">\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <vaadin-button\n data-testid=\"sign-out\"\n aria-label=${this.t('sign_out').toString()}\n style=${Object.entries(style).reduce((p, [k, v]) => `${p}${k}:${v};`, '')}\n theme=\"icon\"\n ?disabled=${isDisabled}\n @click=${handleClick}\n >\n ${state === 'idle'\n ? html`<iron-icon icon=\"icons:exit-to-app\"></iron-icon>`\n : html`\n <foxy-spinner\n layout=\"no-label\"\n state=${state === 'fail' ? 'error' : 'busy'}\n style=\"margin: auto\"\n lang=${this.lang}\n ns=${[\n this.ns,\n customElements.get('foxy-customer')?.defaultNS ?? '',\n customElements.get('foxy-spinner')?.defaultNS ?? '',\n ].join(' ')}\n >\n </foxy-spinner>\n `}\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n </div>\n `;\n };\n\n private readonly __renderSubscriptions: Renderer<Customer> = (html, host) => {\n const scope = 'customer:subscriptions';\n\n return html`\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <foxy-internal-customer-portal-subscriptions\n readonlycontrols=${this.readonlySelector.zoom(scope).toString()}\n disabledcontrols=${this.disabledSelector.zoom(scope).toString()}\n hiddencontrols=${this.hiddenSelector.zoom(scope).toString()}\n group=${host.group}\n lang=${host.lang}\n ns=${host.ns}\n .templates=${this.getNestedTemplates(scope)}\n .settings=${this.data}\n .customer=${host.data}\n >\n </foxy-internal-customer-portal-subscriptions>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n `;\n };\n\n private readonly __renderTransactions: Renderer<Customer> = (html, host) => {\n const scope = 'customer:transactions';\n\n return html`\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <foxy-internal-customer-portal-transactions\n readonlycontrols=${this.readonlySelector.zoom(scope).toString()}\n disabledcontrols=${this.disabledSelector.zoom(scope).toString()}\n hiddencontrols=${this.hiddenSelector.zoom(scope).toString()}\n group=${host.group}\n lang=${host.lang}\n ns=${host.ns}\n .templates=${this.getNestedTemplates(scope)}\n .customer=${host.data}\n >\n </foxy-internal-customer-portal-transactions>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n `;\n };\n\n render(): TemplateResult {\n const hiddenSelector = this.hiddenSelector.zoom('customer');\n const optionallyHiddenInCustomer = ['payment-methods'];\n const alwaysHiddenInCustomer = [\n 'attributes',\n 'transactions',\n 'subscriptions',\n 'addresses:actions:create',\n 'header:actions:edit:form:delete',\n ];\n\n const customerHiddenControls = [\n ...optionallyHiddenInCustomer\n .filter(id => hiddenSelector.matches(id))\n .map(id => `${id}:${hiddenSelector.zoom(id)}`),\n\n ...alwaysHiddenInCustomer.map(id => {\n const splitId = id.split(':');\n\n for (let i = 0; i < splitId.length; ++i) {\n const hostId = splitId.slice(0, i + 1).join(':');\n if (hiddenSelector.matches(hostId, true)) return hostId;\n }\n\n return id;\n }),\n ];\n\n const templates: CustomerTemplates = this.getNestedTemplates('customer');\n const originalHeaderActionsAfterTemplate = templates['header:actions:after'];\n const originalTimestampsAfterTemplate = templates['header:actions:edit:form:timestamps:after'];\n const originalDefaultTemplate = templates['default'];\n\n templates['header:actions:after'] = (html, host) => {\n const isSignOutHidden = hiddenSelector.matches('header:actions:sign-out', true);\n return html`\n <div style=\"display:flex\">\n ${isSignOutHidden ? '' : this.__renderHeaderActionsSignOut()}\n ${originalHeaderActionsAfterTemplate?.(html, host)}\n </div>\n `;\n };\n\n templates['default'] = (html, host) => {\n const renderSubscriptions = this.__renderSubscriptions;\n const renderTransactions = this.__renderTransactions;\n\n return html`\n <style>\n .space-y-m > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(var(--lumo-space-m, 1rem) * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(var(--lumo-space-m, 1rem) * var(--tw-space-y-reverse));\n }\n </style>\n\n ${hiddenSelector.matches('default', true) ? '' : originalDefaultTemplate?.(html, host)}\n\n <div class=\"space-y-m\">\n ${hiddenSelector.matches('subscriptions', true) ? '' : renderSubscriptions(html, host)}\n ${hiddenSelector.matches('transactions', true) ? '' : renderTransactions(html, host)}\n </div>\n `;\n };\n\n templates['header:actions:edit:form:timestamps:after'] = (html, host) => {\n const scope = 'change-password';\n\n return html`\n ${originalTimestampsAfterTemplate?.(html, host)}\n ${host.hiddenSelector.matches(scope, true)\n ? ''\n : html`\n ${host.renderTemplateOrSlot(`${scope}:before`)}\n\n <foxy-internal-customer-portal-change-password\n customer=${host.href}\n session=\"foxy://customer-api/session\"\n style=\"margin-top: var(--lumo-space-l)\"\n email=${host.data?.email ?? ''}\n lang=${host.lang}\n ns=${host.ns}\n ?disabled=${host.in('busy') || host.disabledSelector.matches(scope, true)}\n >\n </foxy-internal-customer-portal-change-password>\n\n ${host.renderTemplateOrSlot(`${scope}:after`)}\n `}\n `;\n };\n\n return html`\n <foxy-customer\n readonlycontrols=${this.readonlySelector.zoom('customer').toString()}\n disabledcontrols=${this.disabledSelector.zoom('customer').toString()}\n hiddencontrols=${customerHiddenControls.join(' ')}\n data-testid=\"customer\"\n group=${this.group}\n href=${this.customer}\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-customer')?.defaultNS ?? ''}\"\n id=\"customer\"\n .templates=${templates}\n @update=${() => this.requestUpdate()}\n >\n </foxy-customer>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.loggingOutStateResetTimeout) clearTimeout(this.loggingOutStateResetTimeout);\n }\n\n private get __customerElement() {\n return this.renderRoot.querySelector<Customer>('#customer');\n }\n}\n"]}
1
+ {"version":3,"file":"InternalCustomerPortalLoggedInView.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,wCAAqC;AAC3E,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU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,IAAI,CAAC;;;;gBAIzE,IAAI,CAAC,oBAAoB,CAAC,GAAG,KAAK,QAAQ,CAAC;aAC9C;OACN,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO,IAAI,CAAA;;2BAEY,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;2BACjD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;yBACnD,sBAAsB;;gBAE/B,IAAI,CAAC,KAAK;eACX,IAAI,CAAC,QAAQ;eACb,IAAI,CAAC,IAAI;cACV,IAAI,CAAC,EAAE,IAAI,YAAA,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,0CAAE,SAAS,mCAAI,EAAE;;qBAExD,SAAS;kBACZ,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;;;KAGvC,CAAC;IACJ,CAAC;IAED,oBAAoB;QAClB,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,2BAA2B;YAAE,YAAY,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACvF,CAAC;IAED,IAAY,iBAAiB;QAC3B,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAW,WAAW,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import { ConfigurableMixin, Renderer } from '../../../mixins/configurable';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { API } from '../NucleonElement/API';\nimport { Customer } from '../Customer/Customer';\nimport { Templates as CustomerTemplates } from '../Customer/types';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/customer';\nimport { BooleanSelector, Resource } from '@foxy.io/sdk/core';\nimport { Templates } from './types';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\n\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement)));\ntype Data = Resource<Rels.CustomerPortalSettings>;\n\nexport class InternalCustomerPortalLoggedInView extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n customer: { type: String },\n loggingOutState: { attribute: false },\n loggingOutStateResetTimeout: { attribute: false },\n };\n }\n\n templates: Templates = {};\n\n customer = '';\n\n loggingOutState: 'idle' | 'busy' | 'fail' = 'idle';\n\n loggingOutStateResetTimeout: NodeJS.Timeout | null = null;\n\n private readonly __renderHeaderActionsSignOut = () => {\n const scope = 'customer:header:actions:sign-out';\n const state = this.loggingOutState;\n\n const isDisabled =\n this.disabledSelector.matches(scope) ||\n !this.__customerElement?.in({ idle: 'snapshot' }) ||\n state !== 'idle';\n\n const handleClick = async () => {\n try {\n this.loggingOutState = 'busy';\n await new API(this).fetch('foxy://customer-api/session', { method: 'DELETE' });\n this.loggingOutState = 'idle';\n } catch {\n this.loggingOutState = 'fail';\n this.loggingOutStateResetTimeout = setTimeout(() => {\n this.loggingOutState = 'idle';\n this.loggingOutStateResetTimeout = null;\n }, 1000);\n }\n };\n\n const style = {\n 'border-radius': '100%',\n 'padding': 'var(--lumo-space-xs)',\n 'display': 'flex',\n 'margin': '0',\n 'cursor': isDisabled ? 'default' : 'pointer',\n };\n\n return html`\n <div style=\"display: flex; margin-left: var(--lumo-space-m)\">\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <vaadin-button\n data-testid=\"sign-out\"\n aria-label=${this.t('sign_out').toString()}\n style=${Object.entries(style).reduce((p, [k, v]) => `${p}${k}:${v};`, '')}\n theme=\"icon\"\n ?disabled=${isDisabled}\n @click=${handleClick}\n >\n ${state === 'idle'\n ? html`<iron-icon icon=\"icons:exit-to-app\"></iron-icon>`\n : html`\n <foxy-spinner\n layout=\"no-label\"\n state=${state === 'fail' ? 'error' : 'busy'}\n style=\"margin: auto\"\n lang=${this.lang}\n ns=${[\n this.ns,\n customElements.get('foxy-customer')?.defaultNS ?? '',\n customElements.get('foxy-spinner')?.defaultNS ?? '',\n ].join(' ')}\n >\n </foxy-spinner>\n `}\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n </div>\n `;\n };\n\n private readonly __renderSubscriptions: Renderer<Customer> = (html, host) => {\n const scope = 'customer:subscriptions';\n\n return html`\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <foxy-internal-customer-portal-subscriptions\n readonlycontrols=${this.readonlySelector.zoom(scope).toString()}\n disabledcontrols=${this.disabledSelector.zoom(scope).toString()}\n hiddencontrols=${this.hiddenSelector.zoom(scope).toString()}\n group=${host.group}\n lang=${host.lang}\n ns=${host.ns}\n .templates=${this.getNestedTemplates(scope)}\n .settings=${this.data}\n .customer=${host.data}\n >\n </foxy-internal-customer-portal-subscriptions>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n `;\n };\n\n private readonly __renderTransactions: Renderer<Customer> = (html, host) => {\n const scope = 'customer:transactions';\n\n return html`\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <foxy-internal-customer-portal-transactions\n readonlycontrols=${this.readonlySelector.zoom(scope).toString()}\n disabledcontrols=${this.disabledSelector.zoom(scope).toString()}\n hiddencontrols=${this.hiddenSelector.zoom(scope).toString()}\n group=${host.group}\n lang=${host.lang}\n ns=${host.ns}\n .templates=${this.getNestedTemplates(scope)}\n .customer=${host.data}\n >\n </foxy-internal-customer-portal-transactions>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n `;\n };\n\n render(): TemplateResult {\n const hiddenSelector = this.hiddenSelector.zoom('customer');\n const customerHiddenControls = new BooleanSelector(`\n attributes\n transactions\n subscriptions\n addresses:actions:create\n header:actions:edit:form:delete\n ${hiddenSelector.toString()}\n `).toString();\n\n const templates: CustomerTemplates = this.getNestedTemplates('customer');\n const originalHeaderActionsAfterTemplate = templates['header:actions:after'];\n const originalTimestampsAfterTemplate = templates['header:actions:edit:form:timestamps:after'];\n const originalDefaultTemplate = templates['default'];\n\n templates['header:actions:after'] = (html, host) => {\n const isSignOutHidden = hiddenSelector.matches('header:actions:sign-out', true);\n return html`\n <div style=\"display:flex\">\n ${isSignOutHidden ? '' : this.__renderHeaderActionsSignOut()}\n ${originalHeaderActionsAfterTemplate?.(html, host)}\n </div>\n `;\n };\n\n templates['default'] = (html, host) => {\n const renderSubscriptions = this.__renderSubscriptions;\n const renderTransactions = this.__renderTransactions;\n\n return html`\n <style>\n .space-y-m > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(var(--lumo-space-m, 1rem) * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(var(--lumo-space-m, 1rem) * var(--tw-space-y-reverse));\n }\n </style>\n\n ${hiddenSelector.matches('default', true) ? '' : originalDefaultTemplate?.(html, host)}\n\n <div class=\"space-y-m\">\n ${hiddenSelector.matches('subscriptions', true) ? '' : renderSubscriptions(html, host)}\n ${hiddenSelector.matches('transactions', true) ? '' : renderTransactions(html, host)}\n </div>\n `;\n };\n\n templates['header:actions:edit:form:timestamps:after'] = (html, host) => {\n const scope = 'change-password';\n\n return html`\n ${originalTimestampsAfterTemplate?.(html, host)}\n ${host.hiddenSelector.matches(scope, true)\n ? ''\n : html`\n ${host.renderTemplateOrSlot(`${scope}:before`)}\n\n <foxy-internal-customer-portal-change-password\n customer=${host.href}\n session=\"foxy://customer-api/session\"\n style=\"margin-top: var(--lumo-space-l)\"\n email=${host.data?.email ?? ''}\n lang=${host.lang}\n ns=${host.ns}\n ?disabled=${host.in('busy') || host.disabledSelector.matches(scope, true)}\n >\n </foxy-internal-customer-portal-change-password>\n\n ${host.renderTemplateOrSlot(`${scope}:after`)}\n `}\n `;\n };\n\n return html`\n <foxy-customer\n readonlycontrols=${this.readonlySelector.zoom('customer').toString()}\n disabledcontrols=${this.disabledSelector.zoom('customer').toString()}\n hiddencontrols=${customerHiddenControls}\n data-testid=\"customer\"\n group=${this.group}\n href=${this.customer}\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-customer')?.defaultNS ?? ''}\"\n id=\"customer\"\n .templates=${templates}\n @update=${() => this.requestUpdate()}\n >\n </foxy-customer>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.loggingOutStateResetTimeout) clearTimeout(this.loggingOutStateResetTimeout);\n }\n\n private get __customerElement() {\n return this.renderRoot.querySelector<Customer>('#customer');\n }\n}\n"]}
@@ -67,6 +67,7 @@ export declare class NucleonElement<TData extends HALJSONResource> extends Nucle
67
67
  private __fetchEventHandler;
68
68
  private __fetchEventQueue;
69
69
  private readonly __service;
70
+ constructor();
70
71
  /**
71
72
  * If network request returns non-2XX code, the entire error response
72
73
  * will be available via this getter.
@@ -160,8 +161,8 @@ export declare class NucleonElement<TData extends HALJSONResource> extends Nucle
160
161
  protected _sendPatch(edits: Partial<TData>): Promise<TData>;
161
162
  /** DELETEs `element.href`, shares response with the Rumour group and returns parsed JSON. */
162
163
  protected _sendDelete(): Promise<TData>;
164
+ private get __state();
163
165
  private __createService;
164
- private __destroyService;
165
166
  private __createRumour;
166
167
  private __destroyRumour;
167
168
  private __createServer;
@@ -18,7 +18,7 @@ import { InferrableMixin } from "../../../mixins/inferrable.js";
18
18
  */
19
19
  export class NucleonElement extends InferrableMixin(LitElement) {
20
20
  constructor() {
21
- super(...arguments);
21
+ super();
22
22
  /**
23
23
  * Optional ISO 639-1 code describing the language element content is written in.
24
24
  * Changing the `lang` attribute will update the value of this property.
@@ -57,6 +57,8 @@ export class NucleonElement extends InferrableMixin(LitElement) {
57
57
  }),
58
58
  },
59
59
  }));
60
+ this.__createService();
61
+ this.__createRumour();
60
62
  }
61
63
  static get inferredProperties() {
62
64
  return [...super.inferredProperties, 'group', 'lang'];
@@ -64,6 +66,7 @@ export class NucleonElement extends InferrableMixin(LitElement) {
64
66
  /** @readonly */
65
67
  static get properties() {
66
68
  return {
69
+ __state: { type: String, reflect: true, attribute: 'state' },
67
70
  related: { type: Array },
68
71
  parent: { type: String },
69
72
  group: { type: String, noAccessor: true },
@@ -201,16 +204,14 @@ export class NucleonElement extends InferrableMixin(LitElement) {
201
204
  /** @readonly */
202
205
  connectedCallback() {
203
206
  super.connectedCallback();
204
- this.__createService();
205
- this.__createRumour();
207
+ if (this.href)
208
+ this.refresh();
206
209
  this.__createServer();
207
210
  this.__processFetchEventQueue();
208
211
  }
209
212
  /** @readonly */
210
213
  disconnectedCallback() {
211
214
  super.disconnectedCallback();
212
- this.__destroyService();
213
- this.__destroyRumour();
214
215
  this.__destroyServer();
215
216
  this.__flushFetchEventQueue('parent element was disconnected');
216
217
  }
@@ -269,12 +270,16 @@ export class NucleonElement extends InferrableMixin(LitElement) {
269
270
  this.__createRumour();
270
271
  return data;
271
272
  }
273
+ // this getter is used by LitElement to set the "state" attribute
274
+ get __state() {
275
+ const state = this.__service.state;
276
+ const flags = state.toStrings().reduce((p, c) => [...p, ...c.split('.')], []);
277
+ return [...new Set(flags)].join(' ');
278
+ }
272
279
  __createService() {
273
280
  this.__service.onTransition(state => {
274
281
  if (!state.changed)
275
282
  return;
276
- const flags = state.toStrings().reduce((p, c) => [...p, ...c.split('.')], []);
277
- this.setAttribute('state', [...new Set(flags)].join(' '));
278
283
  this.requestUpdate();
279
284
  this.dispatchEvent(new UpdateEvent());
280
285
  if (!state.matches('busy'))
@@ -286,9 +291,6 @@ export class NucleonElement extends InferrableMixin(LitElement) {
286
291
  });
287
292
  this.__service.start();
288
293
  }
289
- __destroyService() {
290
- this.__service.stop();
291
- }
292
294
  __createRumour() {
293
295
  const rumour = NucleonElement.Rumour(this.group);
294
296
  this.__unsubscribeFromRumour = rumour.track(update => this.__handleRumourUpdate(update));
@@ -1 +1 @@
1
- {"version":3,"file":"NucleonElement.js","sourceRoot":"","sources":["../../../../src/elements/public/NucleonElement/NucleonElement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAwB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAA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,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO;QACpD,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI;YAAE,OAAO;QAE7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,wBAAwB,EAAE,CAAC;IACxD,CAAC;;AA5aD;;;;;GAKG;AACa,0BAAW,GAAG,WAAW,CAAC;AAE1C;;;;;GAKG;AACa,qBAAM,GAAG,OAAO,CAA4B,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAEhF;;;;GAIG;AACa,kBAAG,GAAG,GAAG,CAAC","sourcesContent":["import { ComputedElementProperties, HALJSONResource, NucleonMachine, NucleonV8N } from './types';\nimport { LitElement, PropertyDeclarations } from 'lit-element';\nimport { Nucleon, Rumour } from '@foxy.io/sdk/core';\nimport { assign, interpret } from 'xstate';\n\nimport { API } from './API';\nimport { FetchEvent } from './FetchEvent';\nimport { UpdateEvent } from './UpdateEvent';\nimport memoize from 'lodash-es/memoize';\nimport { serveFromCache } from './serveFromCache';\nimport { InferrableMixin } from '../../../mixins/inferrable';\n\n/**\n * Base class for custom elements working with remote HAL+JSON resources.\n *\n * @fires NucleonElement#update - Instance of `NucleonElement.UpdateEvent`. Dispatched on an element whenever it changes its state.\n * @fires NucleonElement#fetch - Instance of `NucleonElement.API.FetchEvent`. Emitted before each API request.\n *\n * @element foxy-nucleon\n * @since 1.1.0\n */\nexport class NucleonElement<TData extends HALJSONResource> extends InferrableMixin(LitElement) {\n /**\n * Instances of this event are dispatched on an element whenever it changes its\n * state (e.g. when going from `busy` to `idle` or on `form` data change).\n * This event isn't cancelable, and it does not bubble.\n * @readonly\n */\n static readonly UpdateEvent = UpdateEvent;\n\n /**\n * Creates a tagged [Rumour](https://sdk.foxy.dev/classes/_core_index_.rumour.html)\n * instance if it doesn't exist or returns cached one otherwise. NucleonElements\n * use empty Rumour group by default.\n * @readonly\n */\n static readonly Rumour = memoize<(group: string) => Rumour>(() => new Rumour());\n\n /**\n * Universal [API](https://sdk.foxy.dev/classes/_core_index_.api.html) client\n * that dispatches cancellable `FetchEvent` on an element before each request.\n * @readonly\n */\n static readonly API = API;\n\n static get inferredProperties(): string[] {\n return [...super.inferredProperties, 'group', 'lang'];\n }\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n related: { type: Array },\n parent: { type: String },\n group: { type: String, noAccessor: true },\n href: { type: String, noAccessor: true },\n lang: { type: String },\n };\n }\n\n /**\n * Array of validation functions. Each function accepts `element.form` and must return\n * either an error code string if form data fails the check or `true` otherwise.\n * Error codes are collected in `element.errors`. Empty by default.\n */\n static get v8n(): NucleonV8N<any> {\n return [];\n }\n\n /**\n * Optional ISO 639-1 code describing the language element content is written in.\n * Changing the `lang` attribute will update the value of this property.\n */\n lang = '';\n\n /**\n * Optional URL of the collection this element's resource belongs to.\n * Changing the `parent` attribute will update the value of this property.\n */\n parent = '';\n\n /**\n * Optional URI list of the related resources. If Rumour encounters a related\n * resource on creation or deletion, it will be reloaded from source.\n */\n related: string[] = [];\n\n private __href = '';\n\n private __group = '';\n\n private __unsubscribeFromRumour!: () => void;\n\n private __fetchEventHandler!: (evt: Event) => void;\n\n private __fetchEventQueue: FetchEvent[] = [];\n\n private readonly __service = interpret(\n (Nucleon.machine as NucleonMachine<TData>).withConfig({\n services: {\n sendDelete: () => this._sendDelete(),\n sendPatch: ({ edits }) => this._sendPatch(edits!),\n sendPost: ({ edits }) => this._sendPost(edits!),\n sendGet: () => this._sendGet(),\n },\n\n actions: {\n validate: assign<Nucleon.Context<TData, string>, Nucleon.Event<TData>>({\n errors: context => {\n const rules = (this.constructor as typeof NucleonElement).v8n;\n const form = { ...context.data, ...context.edits };\n\n return rules\n .map(validate => validate(form))\n .filter(v8nResult => typeof v8nResult === 'string')\n .filter((err, errIndex, errs) => errs.indexOf(err) === errIndex) as string[];\n },\n }),\n },\n })\n );\n\n /**\n * If network request returns non-2XX code, the entire error response\n * will be available via this getter.\n *\n * This property is readonly. Changing failure records via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override error status.\n *\n * @since 1.4.0\n */\n get failure(): Response | null {\n return this.__service.state.context.failure;\n }\n\n /**\n * Array of validation errors returned from `NucleonElement.v8n` checks.\n *\n * This property is readonly. Adding or removing error codes via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override validity status.\n */\n get errors(): string[] {\n return this.__service.state.context.errors;\n }\n\n /**\n * Resource snapshot with edits applied. Empty object if unavailable.\n *\n * This property and its value are readonly. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please use `element.edit({ foo: 'bar' })` instead.\n * If you need to replace the entire data object, consider using `element.data`.\n */\n get form(): Partial<TData> {\n const { data, edits } = this.__service.state.context;\n return { ...data, ...edits } as Partial<TData>;\n }\n\n /**\n * Resource snapshot as-is, no edits applied. Null if unavailable.\n *\n * Returned value is not reactive. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please set the property instead: `element.data = { ...element.data, foo: 'bar' }`.\n * If you're processing user input, consider using `element.form` and `element.edit()` instead.\n */\n get data(): TData | null {\n return this.__service.state.context.data;\n }\n\n set data(data: TData | null) {\n this.__service.send({ type: 'SET_DATA', data });\n this.__href = data?._links.self.href ?? '';\n }\n\n /**\n * Rumour group. Elements in different groups will not share updates. Empty by default.\n * @example element.group = 'my-group'\n */\n get group(): string {\n return this.__group;\n }\n\n set group(value: string) {\n this.__group = value;\n this.__destroyRumour();\n this.__createRumour();\n }\n\n /**\n * Optional URL of the resource to load. Switches element to `idle.template` state if empty (default).\n * @example element.href = 'https://demo.foxycart.com/s/customer/attributes/0'\n */\n get href(): string {\n return this.__href;\n }\n\n set href(value: string) {\n this.__href = value;\n\n if (value) {\n this.__service.send({ type: 'FETCH' });\n } else {\n this.__service.send({ type: 'SET_DATA', data: null });\n }\n }\n\n /**\n * Checks if this element is in the given state.\n * @example element.in({ idle: 'snapshot' })\n */\n in<TStateValue extends Nucleon.State<TData, string>['value']>(\n stateValue: TStateValue\n ): this is this & ComputedElementProperties<TData, TStateValue> {\n return this.__service.state.matches(stateValue);\n }\n\n /**\n * Clears all edits and emits the `update` event.\n * @example element.undo()\n */\n undo(): void {\n this.__service.send({ type: 'UNDO' });\n }\n\n /**\n * Applies an edit to the local resource snapshot or its template and emits the `update` event.\n * @example element.edit({ first_name: 'Alex' })\n */\n edit(data: Partial<TData>): void {\n this.__service.send({ type: 'EDIT', data });\n }\n\n /**\n * Submits the form, updating the resource if href isn't empty or creating it otherwise.\n * Emits multiple `update` events as element state changes. Has no effect on invalid forms.\n * @example element.submit()\n */\n submit(): void {\n this.__service.send({ type: 'SUBMIT' });\n }\n\n /**\n * Sends a DELETE request to `element.href` and clears local data on success.\n * Emits multiple update events as element state changes.\n * @example element.delete()\n */\n delete(): void {\n this.__service.send({ type: 'DELETE' });\n }\n\n /**\n * Fetches data from `element.href` in background, keeping the edits and v8n errors.\n * @example element.refresh()\n */\n refresh(): void {\n this.__service.send({ type: 'REFRESH' });\n }\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n\n this.__createService();\n this.__createRumour();\n this.__createServer();\n this.__processFetchEventQueue();\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.__destroyService();\n this.__destroyRumour();\n this.__destroyServer();\n this.__flushFetchEventQueue('parent element was disconnected');\n }\n\n applyInferredProperties(context: Map<string, unknown>): void {\n super.applyInferredProperties(context);\n\n if (this.infer === null) return;\n\n this.group = (context.get('group') as string | undefined) ?? '';\n this.lang = (context.get('lang') as string | undefined) ?? '';\n }\n\n /** Sends API request. Throws an error on non-2XX response. */\n protected async _fetch<TResult = TData>(...args: Parameters<Window['fetch']>): Promise<TResult> {\n const response = await new API(this).fetch(...args);\n if (!response.ok) throw response;\n return response.json();\n }\n\n /** POSTs to `element.parent`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPost(edits: Partial<TData>): Promise<TData> {\n this.__destroyRumour();\n\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.parent, { body, method: 'POST' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n rumour.share({ data, related, source: data._links.self.href });\n this.__createRumour();\n\n return data;\n }\n\n /** GETs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendGet(): Promise<TData> {\n this.__destroyRumour();\n\n const data = await this._fetch(this.href);\n const rumour = NucleonElement.Rumour(this.group);\n\n rumour.share({ data, source: this.href });\n this.__createRumour();\n\n return data;\n }\n\n /** PATCHes `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPatch(edits: Partial<TData>): Promise<TData> {\n this.__destroyRumour();\n\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.href, { body, method: 'PATCH' });\n const rumour = NucleonElement.Rumour(this.group);\n\n rumour.share({ data, source: this.href, related: this.related });\n this.__createRumour();\n\n return data;\n }\n\n /** DELETEs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendDelete(): Promise<TData> {\n this.__destroyRumour();\n\n const data = await this._fetch(this.href, { method: 'DELETE' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n rumour.share({ data: null, source: this.href, related });\n this.__createRumour();\n\n return data;\n }\n\n private __createService() {\n this.__service.onTransition(state => {\n if (!state.changed) return;\n\n const flags = state.toStrings().reduce((p, c) => [...p, ...c.split('.')], [] as string[]);\n this.setAttribute('state', [...new Set(flags)].join(' '));\n\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n\n if (!state.matches('busy')) this.__processFetchEventQueue();\n });\n\n this.__service.onChange(() => {\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n });\n\n this.__service.start();\n }\n\n private __destroyService() {\n this.__service.stop();\n }\n\n private __createRumour() {\n const rumour = NucleonElement.Rumour(this.group);\n this.__unsubscribeFromRumour = rumour.track(update => this.__handleRumourUpdate(update));\n }\n\n private __destroyRumour() {\n this.__unsubscribeFromRumour?.();\n }\n\n private __createServer() {\n this.__fetchEventHandler = this.__handleFetchEvent.bind(this);\n this.addEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __destroyServer() {\n this.removeEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __handleRumourUpdate(update: (oldData: TData) => TData | null) {\n try {\n const oldData = this.__service.state?.context.data;\n if (!oldData) return;\n\n const newData = update(oldData);\n if (newData !== oldData) this.__service.send({ data: newData, type: 'SET_DATA' });\n } catch (err) {\n if (err instanceof Rumour.UpdateError) {\n this.__service.send({ type: 'REFRESH' });\n } else {\n throw err;\n }\n }\n }\n\n private __processFetchEventQueue() {\n const api = new NucleonElement.API(this);\n\n this.__fetchEventQueue.forEach(event => {\n const request = event.request;\n const cacheResponse = serveFromCache(request.url, this.data);\n const whenResponseReady = cacheResponse.ok ? cacheResponse : api.fetch(request);\n\n event.respondWith(Promise.resolve(whenResponseReady));\n\n if (cacheResponse.ok) {\n console.debug(\n `%c@foxy.io/elements::${this.localName}\\n%c200%c GET ${request.url}`,\n 'color: gray',\n `background: gray; padding: 0 .2em; border-radius: .2em; color: white;`,\n ''\n );\n }\n });\n\n this.__fetchEventQueue = [];\n }\n\n private __flushFetchEventQueue(errorMessage: string) {\n this.__fetchEventQueue.forEach(event => {\n event.respondWith(Promise.reject(new Error(errorMessage)));\n });\n\n this.__fetchEventQueue = [];\n }\n\n private __handleFetchEvent(event: Event) {\n if (!(event instanceof FetchEvent)) return;\n if (event.defaultPrevented) return;\n if (event.request.method !== 'GET') return;\n if (event.request.url.startsWith('foxy://')) return;\n if (event.composedPath()[0] === this) return;\n\n event.preventDefault();\n this.__fetchEventQueue.push(event);\n\n if (!this.in('busy')) this.__processFetchEventQueue();\n }\n}\n"]}
1
+ {"version":3,"file":"NucleonElement.js","source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7D,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAC9B,CAAC;IAEO,kBAAkB,CAAC,KAAY;QACrC,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;YAAE,OAAO;QAC3C,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAO;QACnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK;YAAE,OAAO;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO;QACpD,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI;YAAE,OAAO;QAE7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,wBAAwB,EAAE,CAAC;IACxD,CAAC;;AAhbD;;;;;GAKG;AACa,0BAAW,GAAG,WAAW,CAAC;AAE1C;;;;;GAKG;AACa,qBAAM,GAAG,OAAO,CAA4B,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAEhF;;;;GAIG;AACa,kBAAG,GAAG,GAAG,CAAC","sourcesContent":["import { ComputedElementProperties, HALJSONResource, NucleonMachine, NucleonV8N } from './types';\nimport { LitElement, PropertyDeclarations } from 'lit-element';\nimport { Nucleon, Rumour } from '@foxy.io/sdk/core';\nimport { assign, interpret } from 'xstate';\n\nimport { API } from './API';\nimport { FetchEvent } from './FetchEvent';\nimport { UpdateEvent } from './UpdateEvent';\nimport memoize from 'lodash-es/memoize';\nimport { serveFromCache } from './serveFromCache';\nimport { InferrableMixin } from '../../../mixins/inferrable';\n\n/**\n * Base class for custom elements working with remote HAL+JSON resources.\n *\n * @fires NucleonElement#update - Instance of `NucleonElement.UpdateEvent`. Dispatched on an element whenever it changes its state.\n * @fires NucleonElement#fetch - Instance of `NucleonElement.API.FetchEvent`. Emitted before each API request.\n *\n * @element foxy-nucleon\n * @since 1.1.0\n */\nexport class NucleonElement<TData extends HALJSONResource> extends InferrableMixin(LitElement) {\n /**\n * Instances of this event are dispatched on an element whenever it changes its\n * state (e.g. when going from `busy` to `idle` or on `form` data change).\n * This event isn't cancelable, and it does not bubble.\n * @readonly\n */\n static readonly UpdateEvent = UpdateEvent;\n\n /**\n * Creates a tagged [Rumour](https://sdk.foxy.dev/classes/_core_index_.rumour.html)\n * instance if it doesn't exist or returns cached one otherwise. NucleonElements\n * use empty Rumour group by default.\n * @readonly\n */\n static readonly Rumour = memoize<(group: string) => Rumour>(() => new Rumour());\n\n /**\n * Universal [API](https://sdk.foxy.dev/classes/_core_index_.api.html) client\n * that dispatches cancellable `FetchEvent` on an element before each request.\n * @readonly\n */\n static readonly API = API;\n\n static get inferredProperties(): string[] {\n return [...super.inferredProperties, 'group', 'lang'];\n }\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n __state: { type: String, reflect: true, attribute: 'state' },\n related: { type: Array },\n parent: { type: String },\n group: { type: String, noAccessor: true },\n href: { type: String, noAccessor: true },\n lang: { type: String },\n };\n }\n\n /**\n * Array of validation functions. Each function accepts `element.form` and must return\n * either an error code string if form data fails the check or `true` otherwise.\n * Error codes are collected in `element.errors`. Empty by default.\n */\n static get v8n(): NucleonV8N<any> {\n return [];\n }\n\n /**\n * Optional ISO 639-1 code describing the language element content is written in.\n * Changing the `lang` attribute will update the value of this property.\n */\n lang = '';\n\n /**\n * Optional URL of the collection this element's resource belongs to.\n * Changing the `parent` attribute will update the value of this property.\n */\n parent = '';\n\n /**\n * Optional URI list of the related resources. If Rumour encounters a related\n * resource on creation or deletion, it will be reloaded from source.\n */\n related: string[] = [];\n\n private __href = '';\n\n private __group = '';\n\n private __unsubscribeFromRumour!: () => void;\n\n private __fetchEventHandler!: (evt: Event) => void;\n\n private __fetchEventQueue: FetchEvent[] = [];\n\n private readonly __service = interpret(\n (Nucleon.machine as NucleonMachine<TData>).withConfig({\n services: {\n sendDelete: () => this._sendDelete(),\n sendPatch: ({ edits }) => this._sendPatch(edits!),\n sendPost: ({ edits }) => this._sendPost(edits!),\n sendGet: () => this._sendGet(),\n },\n\n actions: {\n validate: assign<Nucleon.Context<TData, string>, Nucleon.Event<TData>>({\n errors: context => {\n const rules = (this.constructor as typeof NucleonElement).v8n;\n const form = { ...context.data, ...context.edits };\n\n return rules\n .map(validate => validate(form))\n .filter(v8nResult => typeof v8nResult === 'string')\n .filter((err, errIndex, errs) => errs.indexOf(err) === errIndex) as string[];\n },\n }),\n },\n })\n );\n\n constructor() {\n super();\n this.__createService();\n this.__createRumour();\n }\n\n /**\n * If network request returns non-2XX code, the entire error response\n * will be available via this getter.\n *\n * This property is readonly. Changing failure records via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override error status.\n *\n * @since 1.4.0\n */\n get failure(): Response | null {\n return this.__service.state.context.failure;\n }\n\n /**\n * Array of validation errors returned from `NucleonElement.v8n` checks.\n *\n * This property is readonly. Adding or removing error codes via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override validity status.\n */\n get errors(): string[] {\n return this.__service.state.context.errors;\n }\n\n /**\n * Resource snapshot with edits applied. Empty object if unavailable.\n *\n * This property and its value are readonly. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please use `element.edit({ foo: 'bar' })` instead.\n * If you need to replace the entire data object, consider using `element.data`.\n */\n get form(): Partial<TData> {\n const { data, edits } = this.__service.state.context;\n return { ...data, ...edits } as Partial<TData>;\n }\n\n /**\n * Resource snapshot as-is, no edits applied. Null if unavailable.\n *\n * Returned value is not reactive. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please set the property instead: `element.data = { ...element.data, foo: 'bar' }`.\n * If you're processing user input, consider using `element.form` and `element.edit()` instead.\n */\n get data(): TData | null {\n return this.__service.state.context.data;\n }\n\n set data(data: TData | null) {\n this.__service.send({ type: 'SET_DATA', data });\n this.__href = data?._links.self.href ?? '';\n }\n\n /**\n * Rumour group. Elements in different groups will not share updates. Empty by default.\n * @example element.group = 'my-group'\n */\n get group(): string {\n return this.__group;\n }\n\n set group(value: string) {\n this.__group = value;\n this.__destroyRumour();\n this.__createRumour();\n }\n\n /**\n * Optional URL of the resource to load. Switches element to `idle.template` state if empty (default).\n * @example element.href = 'https://demo.foxycart.com/s/customer/attributes/0'\n */\n get href(): string {\n return this.__href;\n }\n\n set href(value: string) {\n this.__href = value;\n\n if (value) {\n this.__service.send({ type: 'FETCH' });\n } else {\n this.__service.send({ type: 'SET_DATA', data: null });\n }\n }\n\n /**\n * Checks if this element is in the given state.\n * @example element.in({ idle: 'snapshot' })\n */\n in<TStateValue extends Nucleon.State<TData, string>['value']>(\n stateValue: TStateValue\n ): this is this & ComputedElementProperties<TData, TStateValue> {\n return this.__service.state.matches(stateValue);\n }\n\n /**\n * Clears all edits and emits the `update` event.\n * @example element.undo()\n */\n undo(): void {\n this.__service.send({ type: 'UNDO' });\n }\n\n /**\n * Applies an edit to the local resource snapshot or its template and emits the `update` event.\n * @example element.edit({ first_name: 'Alex' })\n */\n edit(data: Partial<TData>): void {\n this.__service.send({ type: 'EDIT', data });\n }\n\n /**\n * Submits the form, updating the resource if href isn't empty or creating it otherwise.\n * Emits multiple `update` events as element state changes. Has no effect on invalid forms.\n * @example element.submit()\n */\n submit(): void {\n this.__service.send({ type: 'SUBMIT' });\n }\n\n /**\n * Sends a DELETE request to `element.href` and clears local data on success.\n * Emits multiple update events as element state changes.\n * @example element.delete()\n */\n delete(): void {\n this.__service.send({ type: 'DELETE' });\n }\n\n /**\n * Fetches data from `element.href` in background, keeping the edits and v8n errors.\n * @example element.refresh()\n */\n refresh(): void {\n this.__service.send({ type: 'REFRESH' });\n }\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n if (this.href) this.refresh();\n\n this.__createServer();\n this.__processFetchEventQueue();\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.__destroyServer();\n this.__flushFetchEventQueue('parent element was disconnected');\n }\n\n applyInferredProperties(context: Map<string, unknown>): void {\n super.applyInferredProperties(context);\n\n if (this.infer === null) return;\n\n this.group = (context.get('group') as string | undefined) ?? '';\n this.lang = (context.get('lang') as string | undefined) ?? '';\n }\n\n /** Sends API request. Throws an error on non-2XX response. */\n protected async _fetch<TResult = TData>(...args: Parameters<Window['fetch']>): Promise<TResult> {\n const response = await new API(this).fetch(...args);\n if (!response.ok) throw response;\n return response.json();\n }\n\n /** POSTs to `element.parent`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPost(edits: Partial<TData>): Promise<TData> {\n this.__destroyRumour();\n\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.parent, { body, method: 'POST' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n rumour.share({ data, related, source: data._links.self.href });\n this.__createRumour();\n\n return data;\n }\n\n /** GETs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendGet(): Promise<TData> {\n this.__destroyRumour();\n\n const data = await this._fetch(this.href);\n const rumour = NucleonElement.Rumour(this.group);\n\n rumour.share({ data, source: this.href });\n this.__createRumour();\n\n return data;\n }\n\n /** PATCHes `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPatch(edits: Partial<TData>): Promise<TData> {\n this.__destroyRumour();\n\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.href, { body, method: 'PATCH' });\n const rumour = NucleonElement.Rumour(this.group);\n\n rumour.share({ data, source: this.href, related: this.related });\n this.__createRumour();\n\n return data;\n }\n\n /** DELETEs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendDelete(): Promise<TData> {\n this.__destroyRumour();\n\n const data = await this._fetch(this.href, { method: 'DELETE' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n rumour.share({ data: null, source: this.href, related });\n this.__createRumour();\n\n return data;\n }\n\n // this getter is used by LitElement to set the \"state\" attribute\n private get __state(): string {\n const state = this.__service.state;\n const flags = state.toStrings().reduce((p, c) => [...p, ...c.split('.')], [] as string[]);\n return [...new Set(flags)].join(' ');\n }\n\n private __createService() {\n this.__service.onTransition(state => {\n if (!state.changed) return;\n\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n\n if (!state.matches('busy')) this.__processFetchEventQueue();\n });\n\n this.__service.onChange(() => {\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n });\n\n this.__service.start();\n }\n\n private __createRumour() {\n const rumour = NucleonElement.Rumour(this.group);\n this.__unsubscribeFromRumour = rumour.track(update => this.__handleRumourUpdate(update));\n }\n\n private __destroyRumour() {\n this.__unsubscribeFromRumour?.();\n }\n\n private __createServer() {\n this.__fetchEventHandler = this.__handleFetchEvent.bind(this);\n this.addEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __destroyServer() {\n this.removeEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __handleRumourUpdate(update: (oldData: TData) => TData | null) {\n try {\n const oldData = this.__service.state?.context.data;\n if (!oldData) return;\n\n const newData = update(oldData);\n if (newData !== oldData) this.__service.send({ data: newData, type: 'SET_DATA' });\n } catch (err) {\n if (err instanceof Rumour.UpdateError) {\n this.__service.send({ type: 'REFRESH' });\n } else {\n throw err;\n }\n }\n }\n\n private __processFetchEventQueue() {\n const api = new NucleonElement.API(this);\n\n this.__fetchEventQueue.forEach(event => {\n const request = event.request;\n const cacheResponse = serveFromCache(request.url, this.data);\n const whenResponseReady = cacheResponse.ok ? cacheResponse : api.fetch(request);\n\n event.respondWith(Promise.resolve(whenResponseReady));\n\n if (cacheResponse.ok) {\n console.debug(\n `%c@foxy.io/elements::${this.localName}\\n%c200%c GET ${request.url}`,\n 'color: gray',\n `background: gray; padding: 0 .2em; border-radius: .2em; color: white;`,\n ''\n );\n }\n });\n\n this.__fetchEventQueue = [];\n }\n\n private __flushFetchEventQueue(errorMessage: string) {\n this.__fetchEventQueue.forEach(event => {\n event.respondWith(Promise.reject(new Error(errorMessage)));\n });\n\n this.__fetchEventQueue = [];\n }\n\n private __handleFetchEvent(event: Event) {\n if (!(event instanceof FetchEvent)) return;\n if (event.defaultPrevented) return;\n if (event.request.method !== 'GET') return;\n if (event.request.url.startsWith('foxy://')) return;\n if (event.composedPath()[0] === this) return;\n\n event.preventDefault();\n this.__fetchEventQueue.push(event);\n\n if (!this.in('busy')) this.__processFetchEventQueue();\n }\n}\n"]}
@@ -34,7 +34,7 @@ export class ShipmentCard extends Base {
34
34
  };
35
35
  }
36
36
  get hiddenSelector() {
37
- return new BooleanSelector(`${super.hiddenSelector.toString()} address:not=full-address`);
37
+ return new BooleanSelector(`address:not=full-address ${super.hiddenSelector.toString()}`);
38
38
  }
39
39
  get readonlySelector() {
40
40
  return this.__editable ? super.readonlySelector : BooleanSelector.True;
@@ -1 +1 @@
1
- {"version":3,"file":"ShipmentCard.js","sourceRoot":"","sources":["../../../../src/elements/public/ShipmentCard/ShipmentCard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAY,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,oDAAiD;AAExE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,IAAU;IAA5C;;QAaE,wBAAmB,GAAG,EAAE,CAAC;QAEzB,sBAAiB,GAAG,EAAE,CAAC;QAEvB,qBAAgB,GAAG,EAAE,CAAC;QAEtB,eAAU,GA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AAM,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrF,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC;QAChE,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;QAEjD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { Data } from './types';\n\nimport { html } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector, Resource } from '@foxy.io/sdk/core';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { PropertyDeclarations } from 'lit-element';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { FormRenderer } from '../FormDialog/types';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\n\nconst NS = 'shipment-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a shipment.\n *\n * @element foxy-shipment-card\n * @since 1.17.0\n */\nexport class ShipmentCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __customerAddresses: { attribute: false },\n __currencyDisplay: { attribute: false },\n __itemCategories: { attribute: false },\n __editable: { attribute: false },\n __currency: { attribute: false },\n __coupons: { attribute: false },\n };\n }\n\n __customerAddresses = '';\n\n __currencyDisplay = '';\n\n __itemCategories = '';\n\n __editable = false;\n\n __currency = '';\n\n __coupons = '';\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`${super.hiddenSelector.toString()} address:not=full-address`);\n }\n\n get readonlySelector(): BooleanSelector {\n return this.__editable ? super.readonlySelector : BooleanSelector.True;\n }\n\n renderBody(): TemplateResult {\n let itemsLink: string | undefined = undefined;\n\n if (this.data) {\n try {\n const url = new URL(this.data._links['fx:items'].href);\n url.searchParams.set('zoom', 'item_options');\n itemsLink = url.toString();\n } catch {\n //\n }\n }\n\n const itemFormRenderer: FormRenderer = ({ html, dialog, handleFetch, handleUpdate }) => html`\n <foxy-item-form\n customer-addresses=${this.__customerAddresses}\n item-categories=${this.__itemCategories}\n coupons=${this.__coupons}\n parent=${dialog.parent}\n href=${dialog.href}\n infer=\"\"\n @fetch=${handleFetch}\n @update=${handleUpdate}\n >\n </foxy-item-form>\n `;\n\n return html`\n <div class=\"space-y-m\">\n <foxy-address-card\n infer=\"address\"\n href=${ifDefined(this.data?._links['fx:customer_address'].href)}\n >\n <div slot=\"full-address:after\" class=\"flex items-center text-m space-x-s text-secondary\">\n <iron-icon icon=\"maps:local-shipping\" class=\"icon-inline flex-shrink-0\"></iron-icon>\n <span class=\"truncate\">\n ${this.data?.shipping_service_description} &bull;\n <foxy-i18n\n options=${JSON.stringify({\n amount: `${this.data?.total_shipping} ${this.__currency}`,\n currencyDisplay: this.__currencyDisplay,\n })}\n key=\"price\"\n infer=\"\"\n >\n </foxy-i18n>\n </span>\n </div>\n </foxy-address-card>\n\n <foxy-internal-async-details-control\n infer=\"items\"\n first=${ifDefined(itemsLink)}\n limit=\"5\"\n item=\"foxy-item-card\"\n open\n .form=${itemFormRenderer as any}\n >\n </foxy-internal-async-details-control>\n </div>\n `;\n }\n\n protected async _sendGet(): Promise<Data> {\n type Transaction = Resource<Rels.Transaction>;\n type Customer = Resource<Rels.Customer>;\n type Store = Resource<Rels.Store>;\n\n const shipment = await super._sendGet();\n const [transaction, customer, store] = await Promise.all([\n super._fetch<Transaction>(shipment._links['fx:transaction'].href),\n super._fetch<Customer>(shipment._links['fx:customer'].href),\n super._fetch<Store>(shipment._links['fx:store'].href),\n ]);\n\n this.__customerAddresses = customer._links['fx:customer_addresses'].href;\n this.__currencyDisplay = store.use_international_currency_symbol ? 'code' : 'symbol';\n this.__itemCategories = store._links['fx:item_categories'].href;\n this.__currency = transaction.currency_code;\n this.__editable = !!transaction._links['fx:void'] || !!transaction._links['fx:refund'];\n this.__coupons = store._links['fx:coupons'].href;\n\n return shipment;\n }\n}\n"]}
1
+ {"version":3,"file":"ShipmentCard.js","sourceRoot":"","sources":["../../../../src/elements/public/ShipmentCard/ShipmentCard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAY,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,oDAAiD;AAExE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,IAAU;IAA5C;;QAaE,wBAAmB,GAAG,EAAE,CAAC;QAEzB,sBAAiB,GAAG,EAAE,CAAC;QAEvB,qBAAgB,GAAG,EAAE,CAAC;QAEtB,eAAU,GAAG,KAAK,CAAC;QAEnB,eAAU,GAAG,EAAE,CAAC;QAEhB,cAAS,GAAG,EAAE,CAAC;IA8FjB,CAAC;IApHC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,mBAAmB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YACzC,iBAAiB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YACvC,gBAAgB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YACtC,UAAU,EA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,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;QAEjD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { Data } from './types';\n\nimport { html } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector, Resource } from '@foxy.io/sdk/core';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { PropertyDeclarations } from 'lit-element';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { FormRenderer } from '../FormDialog/types';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\n\nconst NS = 'shipment-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a shipment.\n *\n * @element foxy-shipment-card\n * @since 1.17.0\n */\nexport class ShipmentCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __customerAddresses: { attribute: false },\n __currencyDisplay: { attribute: false },\n __itemCategories: { attribute: false },\n __editable: { attribute: false },\n __currency: { attribute: false },\n __coupons: { attribute: false },\n };\n }\n\n __customerAddresses = '';\n\n __currencyDisplay = '';\n\n __itemCategories = '';\n\n __editable = false;\n\n __currency = '';\n\n __coupons = '';\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`address:not=full-address ${super.hiddenSelector.toString()}`);\n }\n\n get readonlySelector(): BooleanSelector {\n return this.__editable ? super.readonlySelector : BooleanSelector.True;\n }\n\n renderBody(): TemplateResult {\n let itemsLink: string | undefined = undefined;\n\n if (this.data) {\n try {\n const url = new URL(this.data._links['fx:items'].href);\n url.searchParams.set('zoom', 'item_options');\n itemsLink = url.toString();\n } catch {\n //\n }\n }\n\n const itemFormRenderer: FormRenderer = ({ html, dialog, handleFetch, handleUpdate }) => html`\n <foxy-item-form\n customer-addresses=${this.__customerAddresses}\n item-categories=${this.__itemCategories}\n coupons=${this.__coupons}\n parent=${dialog.parent}\n href=${dialog.href}\n infer=\"\"\n @fetch=${handleFetch}\n @update=${handleUpdate}\n >\n </foxy-item-form>\n `;\n\n return html`\n <div class=\"space-y-m\">\n <foxy-address-card\n infer=\"address\"\n href=${ifDefined(this.data?._links['fx:customer_address'].href)}\n >\n <div slot=\"full-address:after\" class=\"flex items-center text-m space-x-s text-secondary\">\n <iron-icon icon=\"maps:local-shipping\" class=\"icon-inline flex-shrink-0\"></iron-icon>\n <span class=\"truncate\">\n ${this.data?.shipping_service_description} &bull;\n <foxy-i18n\n options=${JSON.stringify({\n amount: `${this.data?.total_shipping} ${this.__currency}`,\n currencyDisplay: this.__currencyDisplay,\n })}\n key=\"price\"\n infer=\"\"\n >\n </foxy-i18n>\n </span>\n </div>\n </foxy-address-card>\n\n <foxy-internal-async-details-control\n infer=\"items\"\n first=${ifDefined(itemsLink)}\n limit=\"5\"\n item=\"foxy-item-card\"\n open\n .form=${itemFormRenderer as any}\n >\n </foxy-internal-async-details-control>\n </div>\n `;\n }\n\n protected async _sendGet(): Promise<Data> {\n type Transaction = Resource<Rels.Transaction>;\n type Customer = Resource<Rels.Customer>;\n type Store = Resource<Rels.Store>;\n\n const shipment = await super._sendGet();\n const [transaction, customer, store] = await Promise.all([\n super._fetch<Transaction>(shipment._links['fx:transaction'].href),\n super._fetch<Customer>(shipment._links['fx:customer'].href),\n super._fetch<Store>(shipment._links['fx:store'].href),\n ]);\n\n this.__customerAddresses = customer._links['fx:customer_addresses'].href;\n this.__currencyDisplay = store.use_international_currency_symbol ? 'code' : 'symbol';\n this.__itemCategories = store._links['fx:item_categories'].href;\n this.__currency = transaction.currency_code;\n this.__editable = !!transaction._links['fx:void'] || !!transaction._links['fx:refund'];\n this.__coupons = store._links['fx:coupons'].href;\n\n return shipment;\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { TemplateResult } from 'lit-html';
2
+ import type { NucleonV8N } from '../NucleonElement/types';
3
+ import type { Data } from './types';
4
+ import { BooleanSelector } from '@foxy.io/sdk/core';
5
+ import { InternalForm } from '../../internal/InternalForm/InternalForm';
6
+ declare const Base: typeof InternalForm & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
7
+ defaultNS: string;
8
+ };
9
+ /**
10
+ * Form element for creating and editing store shipping methods (`fx:store_shipping_method`).
11
+ *
12
+ * @element foxy-store-shipping-method-form
13
+ * @since 1.18.0
14
+ */
15
+ export declare class StoreShippingMethodForm extends Base<Data> {
16
+ static get properties(): typeof Base['properties'];
17
+ static get v8n(): NucleonV8N<Data>;
18
+ shippingMethods: string | null;
19
+ private __destinations;
20
+ private __getDestinations;
21
+ private __setDestinations;
22
+ get hiddenSelector(): BooleanSelector;
23
+ renderBody(): TemplateResult;
24
+ }
25
+ export {};
@@ -0,0 +1,201 @@
1
+ import { TranslatableMixin } from "../../../mixins/translatable.js";
2
+ import { BooleanSelector } from '@foxy.io/sdk/core';
3
+ import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
4
+ import { ifDefined } from 'lit-html/directives/if-defined';
5
+ import { html } from 'lit-html';
6
+ const NS = 'store-shipping-method-form';
7
+ const Base = TranslatableMixin(InternalForm, NS);
8
+ const getKbSize = (value) => new Blob([value]).size / 1024;
9
+ const isURL = (value) => {
10
+ try {
11
+ new URL(value);
12
+ return true;
13
+ }
14
+ catch (_a) {
15
+ return false;
16
+ }
17
+ };
18
+ /**
19
+ * Form element for creating and editing store shipping methods (`fx:store_shipping_method`).
20
+ *
21
+ * @element foxy-store-shipping-method-form
22
+ * @since 1.18.0
23
+ */
24
+ export class StoreShippingMethodForm extends Base {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.shippingMethods = null;
28
+ this.__destinations = [
29
+ { value: 'domestic', label: 'domestic' },
30
+ { value: 'international', label: 'international' },
31
+ ];
32
+ this.__getDestinations = () => {
33
+ const value = [];
34
+ if (this.form.use_for_domestic)
35
+ value.push('domestic');
36
+ if (this.form.use_for_international)
37
+ value.push('international');
38
+ return value;
39
+ };
40
+ this.__setDestinations = (newValue) => {
41
+ this.edit({
42
+ // TODO remove error directive after SDK types are fixed
43
+ // @ts-expect-error SDK types are wrong
44
+ use_for_domestic: newValue.includes('domestic'),
45
+ // TODO remove error directive after SDK types are fixed
46
+ // @ts-expect-error SDK types are wrong
47
+ use_for_international: newValue.includes('international'),
48
+ });
49
+ };
50
+ }
51
+ static get properties() {
52
+ return {
53
+ ...super.properties,
54
+ shippingMethods: { type: String, attribute: 'shipping-methods' },
55
+ };
56
+ }
57
+ static get v8n() {
58
+ return [
59
+ ({ shipping_method_uri: v }) => (v && isURL(v)) || 'shipping-method-uri:required',
60
+ ({ accountid: v }) => !v || v.length <= 50 || 'accountid:too_long',
61
+ ({ password: v }) => !v || v.length <= 50 || 'password:too_long',
62
+ ({ meter_number: v }) => !v || v.length <= 50 || 'meter-number:too_long',
63
+ ({ authentication_key: v }) => !v || v.length <= 50 || 'authentication-key:too_long',
64
+ ({ custom_code: v }) => !v || getKbSize(v) <= 64 || 'custom-code:too_long',
65
+ form => {
66
+ var _a;
67
+ if (((_a = form._embedded) === null || _a === void 0 ? void 0 : _a['fx:shipping_method'].code) === 'CUSTOM-ENDPOINT-POST') {
68
+ return (form.accountid && isURL(form.accountid)) || 'endpoint:required';
69
+ }
70
+ else {
71
+ return true;
72
+ }
73
+ },
74
+ form => {
75
+ var _a;
76
+ const url = form.shipping_container_uri;
77
+ const code = (_a = form._embedded) === null || _a === void 0 ? void 0 : _a['fx:shipping_method'].code;
78
+ const codes = ['USPS', 'FedEx', 'UPS'];
79
+ if (code && codes.includes(code)) {
80
+ return (url && isURL(url)) || 'shipping-container-uri:required';
81
+ }
82
+ else {
83
+ return true;
84
+ }
85
+ },
86
+ form => {
87
+ var _a;
88
+ const url = form.shipping_drop_type_uri;
89
+ const code = (_a = form._embedded) === null || _a === void 0 ? void 0 : _a['fx:shipping_method'].code;
90
+ const codes = ['FedEx', 'UPS'];
91
+ if (code && codes.includes(code)) {
92
+ return (url && isURL(url)) || 'shipping-drop-type-uri:required';
93
+ }
94
+ else {
95
+ return true;
96
+ }
97
+ },
98
+ ];
99
+ }
100
+ get hiddenSelector() {
101
+ var _a;
102
+ const code = (_a = this.form._embedded) === null || _a === void 0 ? void 0 : _a['fx:shipping_method'].code;
103
+ if (!code)
104
+ return new BooleanSelector('not=shipping-method-uri,timestamps,create,delete');
105
+ const orgControls = ['shipping-container-uri', 'shipping-drop-type-uri', 'destinations'];
106
+ const authControls = ['authentication-key', 'meter-number', 'accountid', 'password'];
107
+ const codeToControls = {
108
+ 'CUSTOM-ENDPOINT-POST': ['endpoint'],
109
+ 'CUSTOM-CODE': ['custom-code'],
110
+ 'CUSTOM': ['destinations', 'services'],
111
+ 'FedEx': [...orgControls, ...authControls, 'services'],
112
+ 'USPS': [...orgControls, 'services'],
113
+ 'UPS': [...orgControls, ...authControls, 'services'],
114
+ };
115
+ if (codeToControls[code]) {
116
+ const controls = codeToControls[code];
117
+ const set = ['shipping-method-uri', ...controls, 'timestamps', 'delete', 'create'];
118
+ return new BooleanSelector(`not=${set.join()} ${super.hiddenSelector}`);
119
+ }
120
+ else {
121
+ return super.hiddenSelector;
122
+ }
123
+ }
124
+ renderBody() {
125
+ var _a, _b, _c, _d, _e, _f;
126
+ const method = (_a = this.form._embedded) === null || _a === void 0 ? void 0 : _a['fx:shipping_method'];
127
+ return html `
128
+ <foxy-internal-async-combo-box-control
129
+ item-value-path="_links.self.href"
130
+ item-label-path="name"
131
+ first=${ifDefined((_b = this.shippingMethods) !== null && _b !== void 0 ? _b : (_c = this.form._links) === null || _c === void 0 ? void 0 : _c['fx:shipping_methods'].href)}
132
+ infer="shipping-method-uri"
133
+ .selectedItem=${(_d = this.form._embedded) === null || _d === void 0 ? void 0 : _d['fx:shipping_method']}
134
+ @selected-item-changed=${(evt) => {
135
+ const { selectedItem } = evt.currentTarget;
136
+ const newEmbeds = { 'fx:shipping_method': selectedItem };
137
+ this.edit({
138
+ _embedded: newEmbeds,
139
+ shipping_container_uri: '',
140
+ shipping_drop_type_uri: '',
141
+ });
142
+ }}
143
+ >
144
+ </foxy-internal-async-combo-box-control>
145
+
146
+ <foxy-internal-async-combo-box-control
147
+ item-value-path="_links.self.href"
148
+ item-label-path="name"
149
+ first=${ifDefined(method === null || method === void 0 ? void 0 : method._links['fx:shipping_containers'].href)}
150
+ infer="shipping-container-uri"
151
+ .selectedItem=${(_e = this.form._embedded) === null || _e === void 0 ? void 0 : _e['fx:shipping_container']}
152
+ @selected-item-changed=${(evt) => {
153
+ const { selectedItem } = evt.currentTarget;
154
+ const newEmbeds = { ...this.form._embedded, 'fx:shipping_container': selectedItem };
155
+ this.edit({ _embedded: newEmbeds });
156
+ }}
157
+ >
158
+ </foxy-internal-async-combo-box-control>
159
+
160
+ <foxy-internal-async-combo-box-control
161
+ item-value-path="_links.self.href"
162
+ item-label-path="name"
163
+ first=${ifDefined(method === null || method === void 0 ? void 0 : method._links['fx:shipping_drop_types'].href)}
164
+ infer="shipping-drop-type-uri"
165
+ .selectedItem=${(_f = this.form._embedded) === null || _f === void 0 ? void 0 : _f['fx:shipping_drop_type']}
166
+ @selected-item-changed=${(evt) => {
167
+ const { selectedItem } = evt.currentTarget;
168
+ const newEmbeds = { ...this.form._embedded, 'fx:shipping_drop_type': selectedItem };
169
+ this.edit({ _embedded: newEmbeds });
170
+ }}
171
+ >
172
+ </foxy-internal-async-combo-box-control>
173
+
174
+ <foxy-internal-checkbox-group-control
175
+ infer="destinations"
176
+ .getValue=${this.__getDestinations}
177
+ .setValue=${this.__setDestinations}
178
+ .options=${this.__destinations}
179
+ >
180
+ </foxy-internal-checkbox-group-control>
181
+
182
+ <foxy-internal-text-control infer="authentication-key"> </foxy-internal-text-control>
183
+ <foxy-internal-text-control infer="meter-number"></foxy-internal-text-control>
184
+
185
+ <foxy-internal-text-control
186
+ infer=${(method === null || method === void 0 ? void 0 : method.code) === 'CUSTOM-ENDPOINT-POST' ? 'endpoint' : 'accountid'}
187
+ property="accountid"
188
+ >
189
+ </foxy-internal-text-control>
190
+
191
+ <foxy-internal-text-control infer="password"></foxy-internal-text-control>
192
+ <foxy-internal-text-area-control infer="custom-code"></foxy-internal-text-area-control>
193
+
194
+ <foxy-internal-store-shipping-method-form-services-control infer="services">
195
+ </foxy-internal-store-shipping-method-form-services-control>
196
+
197
+ ${super.renderBody()}
198
+ `;
199
+ }
200
+ }
201
+ //# sourceMappingURL=StoreShippingMethodForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoreShippingMethodForm.js","sourceRoot":"","sources":["../../../../src/elements/public/StoreShippingMethodForm/StoreShippingMethodForm.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,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,4BAA4B,CAAC;AACxC,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AACjD,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AACnE,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE;IAC9B,IAAI;QACF,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;KACb;IAAC,WAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,IAAU;IAAvD;;QAmDE,oBAAe,GAAkB,IAAI,CAAC;QAE9B,mBAAc,GAAG;YACvB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAA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;;;gBAOO,SAAS,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,wBAAwB,EAAE,IAAI,CAAC;;wBAEhD,MAAA,IAAI,CAAC,IAAI,CAAC,SAAS,0CAAG,uBAAuB,CAAC;iCACrC,CAAC,GAAgB,EAAE,EAAE;YAC5C,MAAM,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,aAA6C,CAAC;YAC3E,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC;YACpF,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,SAA8B,EAAE,CAAC,CAAC;QAC3D,CAAC;;;;;;oBAMW,IAAI,CAAC,iBAAiB;oBACtB,IAAI,CAAC,iBAAiB;mBACvB,IAAI,CAAC,cAAc;;;;;;;;gBAQtB,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,sBAAsB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW;;;;;;;;;;;QAW1E,KAAK,CAAC,UAAU,EAAE;KACrB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { InternalAsyncComboBoxControl } from '../../internal/InternalAsyncComboBoxControl/InternalAsyncComboBoxControl';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'store-shipping-method-form';\nconst Base = TranslatableMixin(InternalForm, NS);\nconst getKbSize = (value: string) => new Blob([value]).size / 1024;\nconst isURL = (value: string) => {\n try {\n new URL(value);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Form element for creating and editing store shipping methods (`fx:store_shipping_method`).\n *\n * @element foxy-store-shipping-method-form\n * @since 1.18.0\n */\nexport class StoreShippingMethodForm extends Base<Data> {\n static get properties(): typeof Base['properties'] {\n return {\n ...super.properties,\n shippingMethods: { type: String, attribute: 'shipping-methods' },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ shipping_method_uri: v }) => (v && isURL(v)) || 'shipping-method-uri:required',\n ({ accountid: v }) => !v || v.length <= 50 || 'accountid:too_long',\n ({ password: v }) => !v || v.length <= 50 || 'password:too_long',\n ({ meter_number: v }) => !v || v.length <= 50 || 'meter-number:too_long',\n ({ authentication_key: v }) => !v || v.length <= 50 || 'authentication-key:too_long',\n ({ custom_code: v }) => !v || getKbSize(v) <= 64 || 'custom-code:too_long',\n\n form => {\n if (form._embedded?.['fx:shipping_method'].code === 'CUSTOM-ENDPOINT-POST') {\n return (form.accountid && isURL(form.accountid)) || 'endpoint:required';\n } else {\n return true;\n }\n },\n\n form => {\n const url = form.shipping_container_uri;\n const code = form._embedded?.['fx:shipping_method'].code;\n const codes = ['USPS', 'FedEx', 'UPS'];\n\n if (code && codes.includes(code)) {\n return (url && isURL(url)) || 'shipping-container-uri:required';\n } else {\n return true;\n }\n },\n\n form => {\n const url = form.shipping_drop_type_uri;\n const code = form._embedded?.['fx:shipping_method'].code;\n const codes = ['FedEx', 'UPS'];\n\n if (code && codes.includes(code)) {\n return (url && isURL(url)) || 'shipping-drop-type-uri:required';\n } else {\n return true;\n }\n },\n ];\n }\n\n shippingMethods: string | null = null;\n\n private __destinations = [\n { value: 'domestic', label: 'domestic' },\n { value: 'international', label: 'international' },\n ];\n\n private __getDestinations = () => {\n const value: string[] = [];\n if (this.form.use_for_domestic) value.push('domestic');\n if (this.form.use_for_international) value.push('international');\n return value;\n };\n\n private __setDestinations = (newValue: string[]) => {\n this.edit({\n // TODO remove error directive after SDK types are fixed\n // @ts-expect-error SDK types are wrong\n use_for_domestic: newValue.includes('domestic'),\n\n // TODO remove error directive after SDK types are fixed\n // @ts-expect-error SDK types are wrong\n use_for_international: newValue.includes('international'),\n });\n };\n\n get hiddenSelector(): BooleanSelector {\n const code = this.form._embedded?.['fx:shipping_method'].code;\n if (!code) return new BooleanSelector('not=shipping-method-uri,timestamps,create,delete');\n\n const orgControls = ['shipping-container-uri', 'shipping-drop-type-uri', 'destinations'];\n const authControls = ['authentication-key', 'meter-number', 'accountid', 'password'];\n const codeToControls: Record<string, string[]> = {\n 'CUSTOM-ENDPOINT-POST': ['endpoint'],\n 'CUSTOM-CODE': ['custom-code'],\n 'CUSTOM': ['destinations', 'services'],\n 'FedEx': [...orgControls, ...authControls, 'services'],\n 'USPS': [...orgControls, 'services'],\n 'UPS': [...orgControls, ...authControls, 'services'],\n };\n\n if (codeToControls[code]) {\n const controls = codeToControls[code];\n const set = ['shipping-method-uri', ...controls, 'timestamps', 'delete', 'create'];\n return new BooleanSelector(`not=${set.join()} ${super.hiddenSelector}`);\n } else {\n return super.hiddenSelector;\n }\n }\n\n renderBody(): TemplateResult {\n const method = this.form._embedded?.['fx:shipping_method'];\n\n return html`\n <foxy-internal-async-combo-box-control\n item-value-path=\"_links.self.href\"\n item-label-path=\"name\"\n first=${ifDefined(this.shippingMethods ?? this.form._links?.['fx:shipping_methods'].href)}\n infer=\"shipping-method-uri\"\n .selectedItem=${this.form._embedded?.['fx:shipping_method']}\n @selected-item-changed=${(evt: CustomEvent) => {\n const { selectedItem } = evt.currentTarget as InternalAsyncComboBoxControl;\n const newEmbeds = { 'fx:shipping_method': selectedItem };\n\n this.edit({\n _embedded: newEmbeds as Data['_embedded'],\n shipping_container_uri: '',\n shipping_drop_type_uri: '',\n });\n }}\n >\n </foxy-internal-async-combo-box-control>\n\n <foxy-internal-async-combo-box-control\n item-value-path=\"_links.self.href\"\n item-label-path=\"name\"\n first=${ifDefined(method?._links['fx:shipping_containers'].href)}\n infer=\"shipping-container-uri\"\n .selectedItem=${this.form._embedded?.['fx:shipping_container']}\n @selected-item-changed=${(evt: CustomEvent) => {\n const { selectedItem } = evt.currentTarget as InternalAsyncComboBoxControl;\n const newEmbeds = { ...this.form._embedded, 'fx:shipping_container': selectedItem };\n this.edit({ _embedded: newEmbeds as Data['_embedded'] });\n }}\n >\n </foxy-internal-async-combo-box-control>\n\n <foxy-internal-async-combo-box-control\n item-value-path=\"_links.self.href\"\n item-label-path=\"name\"\n first=${ifDefined(method?._links['fx:shipping_drop_types'].href)}\n infer=\"shipping-drop-type-uri\"\n .selectedItem=${this.form._embedded?.['fx:shipping_drop_type']}\n @selected-item-changed=${(evt: CustomEvent) => {\n const { selectedItem } = evt.currentTarget as InternalAsyncComboBoxControl;\n const newEmbeds = { ...this.form._embedded, 'fx:shipping_drop_type': selectedItem };\n this.edit({ _embedded: newEmbeds as Data['_embedded'] });\n }}\n >\n </foxy-internal-async-combo-box-control>\n\n <foxy-internal-checkbox-group-control\n infer=\"destinations\"\n .getValue=${this.__getDestinations}\n .setValue=${this.__setDestinations}\n .options=${this.__destinations}\n >\n </foxy-internal-checkbox-group-control>\n\n <foxy-internal-text-control infer=\"authentication-key\"> </foxy-internal-text-control>\n <foxy-internal-text-control infer=\"meter-number\"></foxy-internal-text-control>\n\n <foxy-internal-text-control\n infer=${method?.code === 'CUSTOM-ENDPOINT-POST' ? 'endpoint' : 'accountid'}\n property=\"accountid\"\n >\n </foxy-internal-text-control>\n\n <foxy-internal-text-control infer=\"password\"></foxy-internal-text-control>\n <foxy-internal-text-area-control infer=\"custom-code\"></foxy-internal-text-area-control>\n\n <foxy-internal-store-shipping-method-form-services-control infer=\"services\">\n </foxy-internal-store-shipping-method-form-services-control>\n\n ${super.renderBody()}\n `;\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import '@polymer/iron-icons/maps-icons';
2
+ import '@polymer/iron-icon';
3
+ import '../../internal/InternalAsyncComboBoxControl/index';
4
+ import '../../internal/InternalCheckboxGroupControl/index';
5
+ import '../../internal/InternalTextAreaControl/index';
6
+ import '../../internal/InternalTextControl/index';
7
+ import '../../internal/InternalForm/index';
8
+ import '../I18n/index';
9
+ import './internal/InternalStoreShippingMethodFormServicesControl/index';
10
+ import { StoreShippingMethodForm } from './StoreShippingMethodForm';
11
+ export { StoreShippingMethodForm };