@foxy.io/elements 1.14.0 → 1.15.0-beta.2

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 (178) hide show
  1. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  2. package/dist/cdn/foxy-address-card.js +1 -1
  3. package/dist/cdn/foxy-address-form.js +1 -1
  4. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  5. package/dist/cdn/foxy-attribute-card.js +1 -1
  6. package/dist/cdn/foxy-attribute-form.js +1 -1
  7. package/dist/cdn/foxy-cancellation-form.js +1 -1
  8. package/dist/cdn/foxy-collection-page.js +1 -1
  9. package/dist/cdn/foxy-collection-pages.js +1 -1
  10. package/dist/cdn/foxy-coupon-card.js +1 -0
  11. package/dist/cdn/foxy-coupon-code-form.js +1 -0
  12. package/dist/cdn/foxy-coupon-codes-form.js +1 -0
  13. package/dist/cdn/foxy-coupon-form.js +1 -0
  14. package/dist/cdn/foxy-custom-field-card.js +1 -1
  15. package/dist/cdn/foxy-custom-field-form.js +1 -1
  16. package/dist/cdn/foxy-customer-api.js +1 -1
  17. package/dist/cdn/foxy-customer-card.js +1 -1
  18. package/dist/cdn/foxy-customer-form.js +1 -1
  19. package/dist/cdn/foxy-customer-portal-settings.js +4 -807
  20. package/dist/cdn/foxy-customer-portal.js +4 -4
  21. package/dist/cdn/foxy-customer.js +1 -1
  22. package/dist/cdn/foxy-customers-table.js +1 -1
  23. package/dist/cdn/foxy-discount-card.js +1 -1
  24. package/dist/cdn/foxy-donation.js +1 -1
  25. package/dist/cdn/foxy-email-template-form.js +1 -1
  26. package/dist/cdn/foxy-error-entry-card.js +1 -1
  27. package/dist/cdn/foxy-form-dialog.js +1 -1
  28. package/dist/cdn/foxy-generate-codes-form.js +1 -0
  29. package/dist/cdn/foxy-i18n.js +1 -1
  30. package/dist/cdn/foxy-items-form.js +1 -1
  31. package/dist/cdn/foxy-nucleon-element.js +1 -1
  32. package/dist/cdn/foxy-pagination.js +1 -0
  33. package/dist/cdn/foxy-payment-card.js +1 -1
  34. package/dist/cdn/foxy-payment-method-card.js +1 -1
  35. package/dist/cdn/foxy-query-builder.js +1 -69
  36. package/dist/cdn/foxy-sign-in-form.js +1 -1
  37. package/dist/cdn/foxy-spinner.js +1 -1
  38. package/dist/cdn/foxy-subscription-card.js +1 -1
  39. package/dist/cdn/foxy-subscription-form.js +3 -3
  40. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  41. package/dist/cdn/foxy-table.js +1 -1
  42. package/dist/cdn/foxy-tax-card.js +1 -1
  43. package/dist/cdn/foxy-tax-form.js +1 -1
  44. package/dist/cdn/foxy-template-config-form.js +1 -1
  45. package/dist/cdn/foxy-template-form.js +1 -1
  46. package/dist/cdn/foxy-transaction-card.js +1 -1
  47. package/dist/cdn/foxy-transactions-table.js +1 -1
  48. package/dist/cdn/foxy-user-form.js +1 -1
  49. package/dist/cdn/foxy-users-table.js +1 -1
  50. package/dist/cdn/{shared-5c8b531d.js → shared-0bda8ecb.js} +1 -1
  51. package/dist/cdn/{shared-07abcd7b.js → shared-0fcdd1c4.js} +1 -1
  52. package/dist/cdn/{shared-a46edf4b.js → shared-30131f76.js} +1 -1
  53. package/dist/cdn/shared-36629ded.js +131 -0
  54. package/dist/cdn/{shared-bc2bfe52.js → shared-4038cb18.js} +1 -1
  55. package/dist/cdn/{shared-44cfc617.js → shared-423a4840.js} +1 -1
  56. package/dist/cdn/shared-4fa5f144.js +1 -0
  57. package/dist/cdn/shared-51b5e223.js +1 -0
  58. package/dist/cdn/{shared-593f7e2c.js → shared-51e28c83.js} +1 -1
  59. package/dist/cdn/shared-710ed658.js +134 -0
  60. package/dist/cdn/shared-800a5471.js +1 -0
  61. package/dist/cdn/{shared-8a7bee0d.js → shared-8f7a66c4.js} +1 -1
  62. package/dist/cdn/{shared-91e768be.js → shared-9af7b5f0.js} +1 -1
  63. package/dist/cdn/{shared-7a42073a.js → shared-a11160e7.js} +5 -5
  64. package/dist/cdn/{shared-5f54e916.js → shared-a4e6ecb0.js} +1 -1
  65. package/dist/cdn/{shared-b5147166.js → shared-a8d96c23.js} +1 -1
  66. package/dist/cdn/{shared-322e60b1.js → shared-b03b6d72.js} +1 -1
  67. package/dist/cdn/shared-b2330475.js +1 -0
  68. package/dist/cdn/{shared-1761daef.js → shared-c1dadefe.js} +1 -1
  69. package/dist/cdn/shared-c6a4b2d6.js +1 -0
  70. package/dist/cdn/shared-ccea5a33.js +69 -0
  71. package/dist/cdn/shared-cd3c902e.js +1 -0
  72. package/dist/cdn/{shared-34b2c1e2.js → shared-d3831f99.js} +1 -1
  73. package/dist/cdn/shared-d9a260f0.js +1 -0
  74. package/dist/cdn/{shared-e5cbf291.js → shared-f875a4f8.js} +1 -1
  75. package/dist/cdn/{shared-e7f8ffe9.js → shared-fb403e1f.js} +1 -1
  76. package/dist/cdn/shared-ff149b55.js +804 -0
  77. package/dist/cdn/translations/customer-portal/zh-hk.json +35 -0
  78. package/dist/cdn/translations/shared/en.json +105 -0
  79. package/dist/elements/private/Checkbox/Checkbox.js +36 -22
  80. package/dist/elements/private/Checkbox/Checkbox.js.map +1 -1
  81. package/dist/elements/private/EditableList/EditableList.d.ts +20 -0
  82. package/dist/elements/private/EditableList/EditableList.js +123 -0
  83. package/dist/elements/private/EditableList/EditableList.js.map +1 -0
  84. package/dist/elements/public/CouponCard/CouponCard.d.ts +29 -0
  85. package/dist/elements/public/CouponCard/CouponCard.js +130 -0
  86. package/dist/elements/public/CouponCard/CouponCard.js.map +1 -0
  87. package/dist/elements/public/CouponCard/index.d.ts +5 -0
  88. package/dist/elements/public/CouponCard/index.js +7 -0
  89. package/dist/elements/public/CouponCard/index.js.map +1 -0
  90. package/dist/elements/public/CouponCard/types.d.ts +15 -0
  91. package/dist/elements/public/CouponCard/types.js +2 -0
  92. package/dist/elements/public/CouponCard/types.js.map +1 -0
  93. package/dist/elements/public/CouponCodeForm/CouponCodeForm.d.ts +45 -0
  94. package/dist/elements/public/CouponCodeForm/CouponCodeForm.js +218 -0
  95. package/dist/elements/public/CouponCodeForm/CouponCodeForm.js.map +1 -0
  96. package/dist/elements/public/CouponCodeForm/index.d.ts +8 -0
  97. package/dist/elements/public/CouponCodeForm/index.js +10 -0
  98. package/dist/elements/public/CouponCodeForm/index.js.map +1 -0
  99. package/dist/elements/public/CouponCodeForm/types.d.ts +15 -0
  100. package/dist/elements/public/CouponCodeForm/types.js +2 -0
  101. package/dist/elements/public/CouponCodeForm/types.js.map +1 -0
  102. package/dist/elements/public/CouponCodesForm/CouponCodesForm.d.ts +29 -0
  103. package/dist/elements/public/CouponCodesForm/CouponCodesForm.js +209 -0
  104. package/dist/elements/public/CouponCodesForm/CouponCodesForm.js.map +1 -0
  105. package/dist/elements/public/CouponCodesForm/index.d.ts +8 -0
  106. package/dist/elements/public/CouponCodesForm/index.js +12 -0
  107. package/dist/elements/public/CouponCodesForm/index.js.map +1 -0
  108. package/dist/elements/public/CouponCodesForm/internal/InternalCouponCodesFormListItem.d.ts +14 -0
  109. package/dist/elements/public/CouponCodesForm/internal/InternalCouponCodesFormListItem.js +48 -0
  110. package/dist/elements/public/CouponCodesForm/internal/InternalCouponCodesFormListItem.js.map +1 -0
  111. package/dist/elements/public/CouponCodesForm/types.d.ts +16 -0
  112. package/dist/elements/public/CouponCodesForm/types.js +2 -0
  113. package/dist/elements/public/CouponCodesForm/types.js.map +1 -0
  114. package/dist/elements/public/CouponForm/CouponForm.d.ts +77 -0
  115. package/dist/elements/public/CouponForm/CouponForm.js +1266 -0
  116. package/dist/elements/public/CouponForm/CouponForm.js.map +1 -0
  117. package/dist/elements/public/CouponForm/index.d.ts +19 -0
  118. package/dist/elements/public/CouponForm/index.js +21 -0
  119. package/dist/elements/public/CouponForm/index.js.map +1 -0
  120. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.d.ts +19 -0
  121. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.js +98 -0
  122. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPage.js.map +1 -0
  123. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.d.ts +19 -0
  124. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.js +51 -0
  125. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItem.js.map +1 -0
  126. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.d.ts +19 -0
  127. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.js +52 -0
  128. package/dist/elements/public/CouponForm/private/CategoryRestrictionsPageItemContent.js.map +1 -0
  129. package/dist/elements/public/CouponForm/types.d.ts +27 -0
  130. package/dist/elements/public/CouponForm/types.js +2 -0
  131. package/dist/elements/public/CouponForm/types.js.map +1 -0
  132. package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.js +19 -6
  133. package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.js.map +1 -1
  134. package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.d.ts +39 -0
  135. package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.js +197 -0
  136. package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.js.map +1 -0
  137. package/dist/elements/public/GenerateCodesForm/index.d.ts +8 -0
  138. package/dist/elements/public/GenerateCodesForm/index.js +10 -0
  139. package/dist/elements/public/GenerateCodesForm/index.js.map +1 -0
  140. package/dist/elements/public/GenerateCodesForm/types.d.ts +24 -0
  141. package/dist/elements/public/GenerateCodesForm/types.js +2 -0
  142. package/dist/elements/public/GenerateCodesForm/types.js.map +1 -0
  143. package/dist/elements/public/I18n/I18n.js +1 -1
  144. package/dist/elements/public/I18n/I18n.js.map +1 -1
  145. package/dist/elements/public/I18n/format/date.js +7 -6
  146. package/dist/elements/public/I18n/format/date.js.map +1 -1
  147. package/dist/elements/public/I18n/format/discount.d.ts +6 -0
  148. package/dist/elements/public/I18n/format/discount.js +20 -0
  149. package/dist/elements/public/I18n/format/discount.js.map +1 -0
  150. package/dist/elements/public/I18n/format/index.js +4 -0
  151. package/dist/elements/public/I18n/format/index.js.map +1 -1
  152. package/dist/elements/public/I18n/format/ordinal.d.ts +6 -0
  153. package/dist/elements/public/I18n/format/ordinal.js +9 -0
  154. package/dist/elements/public/I18n/format/ordinal.js.map +1 -0
  155. package/dist/elements/public/Pagination/Pagination.d.ts +37 -0
  156. package/dist/elements/public/Pagination/Pagination.js +154 -0
  157. package/dist/elements/public/Pagination/Pagination.js.map +1 -0
  158. package/dist/elements/public/Pagination/index.d.ts +6 -0
  159. package/dist/elements/public/Pagination/index.js +8 -0
  160. package/dist/elements/public/Pagination/index.js.map +1 -0
  161. package/dist/elements/public/Table/Table.js +20 -5
  162. package/dist/elements/public/Table/Table.js.map +1 -1
  163. package/dist/elements/public/index.d.ts +6 -0
  164. package/dist/elements/public/index.defined.d.ts +6 -0
  165. package/dist/elements/public/index.defined.js +6 -0
  166. package/dist/elements/public/index.defined.js.map +1 -1
  167. package/dist/elements/public/index.js +6 -0
  168. package/dist/elements/public/index.js.map +1 -1
  169. package/dist/mixins/themeable.js +80 -4
  170. package/dist/mixins/themeable.js.map +1 -1
  171. package/package.json +1 -1
  172. package/dist/cdn/shared-00563cb0.js +0 -1
  173. package/dist/cdn/shared-35dbd2c5.js +0 -1
  174. package/dist/cdn/shared-9a40309d.js +0 -1
  175. package/dist/cdn/shared-ce1da35d.js +0 -1
  176. package/dist/cdn/shared-d01d809a.js +0 -1
  177. package/dist/cdn/shared-d8ffb279.js +0 -264
  178. package/dist/cdn/shared-f1dc1c6c.js +0 -1
@@ -114,21 +114,34 @@ export class InternalCustomerPortalLoggedInView extends Base {
114
114
  render() {
115
115
  var _a, _b;
116
116
  const hiddenSelector = this.hiddenSelector.zoom('customer');
117
- const extendedhiddencontrolsArray = [
118
- hiddenSelector.toString(),
119
- 'header:actions:edit:form:delete',
117
+ const optionallyHiddenInCustomer = ['payment-methods'];
118
+ const alwaysHiddenInCustomer = [
120
119
  'attributes',
121
120
  'transactions',
122
121
  'subscriptions',
123
122
  'addresses:actions:create',
124
- 'payment-methods:list:card',
123
+ 'header:actions:edit:form:delete',
124
+ ];
125
+ const customerHiddenControls = [
126
+ ...optionallyHiddenInCustomer
127
+ .filter(id => hiddenSelector.matches(id))
128
+ .map(id => `${id}:${hiddenSelector.zoom(id)}`),
129
+ ...alwaysHiddenInCustomer.map(id => {
130
+ const splitId = id.split(':');
131
+ for (let i = 0; i < splitId.length; ++i) {
132
+ const hostId = splitId.slice(0, i + 1).join(':');
133
+ if (hiddenSelector.matches(hostId, true))
134
+ return hostId;
135
+ }
136
+ return id;
137
+ }),
125
138
  ];
126
139
  const templates = this.getNestedTemplates('customer');
127
140
  const originalHeaderActionsAfterTemplate = templates['header:actions:after'];
128
141
  const originalTimestampsAfterTemplate = templates['header:actions:edit:form:timestamps:after'];
129
142
  const originalDefaultTemplate = templates['default'];
130
143
  templates['header:actions:after'] = (html, host) => {
131
- const isSignOutHidden = host.hiddenSelector.matches('header:actions:sign-out', true);
144
+ const isSignOutHidden = hiddenSelector.matches('header:actions:sign-out', true);
132
145
  return html `
133
146
  <div style="display:flex">
134
147
  ${isSignOutHidden ? '' : this.__renderHeaderActionsSignOut()}
@@ -185,7 +198,7 @@ export class InternalCustomerPortalLoggedInView extends Base {
185
198
  <foxy-customer
186
199
  readonlycontrols=${this.readonlySelector.zoom('customer').toString()}
187
200
  disabledcontrols=${this.disabledSelector.zoom('customer').toString()}
188
- hiddencontrols=${extendedhiddencontrolsArray.join(' ').trim()}
201
+ hiddencontrols=${customerHiddenControls.join(' ')}
189
202
  data-testid="customer"
190
203
  group=${this.group}
191
204
  href=${this.customer}
@@ -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,GA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D,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 { 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 const isCustomerLoaded = !!this.__customerElement?.in({ idle: 'snapshot' });\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 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=\"padding: var(--lumo-space-xs); margin: 0; border-radius: 100%; display: flex\"\n theme=\"icon\"\n ?disabled=${this.disabledSelector.matches(scope) || !isCustomerLoaded || state !== 'idle'}\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=\"${this.ns} ${customElements.get('foxy-customer')?.defaultNS ?? ''}\"\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 extendedhiddencontrolsArray = [\n hiddenSelector.toString(),\n 'header:actions:edit:form:delete',\n 'attributes',\n 'transactions',\n 'subscriptions',\n 'addresses:actions:create',\n 'payment-methods:list:card',\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 = host.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=${extendedhiddencontrolsArray.join(' ').trim()}\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,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;AAE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IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,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,CAAC,IAAI,CAAC,GAAG,CAAC;;gBAEzC,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 { 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 const isCustomerLoaded = !!this.__customerElement?.in({ idle: 'snapshot' });\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 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=\"padding: var(--lumo-space-xs); margin: 0; border-radius: 100%; display: flex\"\n theme=\"icon\"\n ?disabled=${this.disabledSelector.matches(scope) || !isCustomerLoaded || state !== 'idle'}\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=\"${this.ns} ${customElements.get('foxy-customer')?.defaultNS ?? ''}\"\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"]}
@@ -0,0 +1,39 @@
1
+ import { Data, Templates } from './types';
2
+ import { TemplateResult } from 'lit-html';
3
+ import { NucleonElement } from '../NucleonElement/NucleonElement';
4
+ import { NucleonV8N } from '../NucleonElement/types';
5
+ declare const Base: typeof NucleonElement & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
6
+ defaultNS: string;
7
+ } & {
8
+ styles: import("lit-element").CSSResultArray;
9
+ } & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost>;
10
+ /**
11
+ * Form element for generating codes for coupons or gift cards (`fx:generate_codes`).
12
+ *
13
+ * @slot length:before
14
+ * @slot length:after
15
+ *
16
+ * @slot number-of-codes:before
17
+ * @slot number-of-codes:after
18
+ *
19
+ * @slot prefix:before
20
+ * @slot prefix:after
21
+ *
22
+ * @slot generate:before
23
+ * @slot generate:after
24
+ *
25
+ * @element foxy-generate-codes-form
26
+ * @since 1.15.0
27
+ */
28
+ export declare class GenerateCodesForm extends Base<Data> {
29
+ static get v8n(): NucleonV8N<Data>;
30
+ templates: Templates;
31
+ render(): TemplateResult;
32
+ private __getErrorMessage;
33
+ private __getValidator;
34
+ private __renderLength;
35
+ private __renderNumberOfCodes;
36
+ private __renderPrefix;
37
+ private __renderGenerate;
38
+ }
39
+ export {};
@@ -0,0 +1,197 @@
1
+ import { html } from 'lit-html';
2
+ import { ConfigurableMixin } from "../../../mixins/configurable.js";
3
+ import { NucleonElement } from "../NucleonElement/NucleonElement.js";
4
+ import { ThemeableMixin } from "../../../mixins/themeable.js";
5
+ import { TranslatableMixin } from "../../../mixins/translatable.js";
6
+ import { classMap } from "../../../utils/class-map.js";
7
+ const NS = 'generate-codes';
8
+ const Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)));
9
+ /**
10
+ * Form element for generating codes for coupons or gift cards (`fx:generate_codes`).
11
+ *
12
+ * @slot length:before
13
+ * @slot length:after
14
+ *
15
+ * @slot number-of-codes:before
16
+ * @slot number-of-codes:after
17
+ *
18
+ * @slot prefix:before
19
+ * @slot prefix:after
20
+ *
21
+ * @slot generate:before
22
+ * @slot generate:after
23
+ *
24
+ * @element foxy-generate-codes-form
25
+ * @since 1.15.0
26
+ */
27
+ export class GenerateCodesForm extends Base {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.templates = {};
31
+ }
32
+ static get v8n() {
33
+ return [
34
+ ({ number_of_codes: v }) => (v && v > 0) || 'number_of_codes_required',
35
+ ({ length: v }) => (v && v > 0) || 'length_required',
36
+ ];
37
+ }
38
+ render() {
39
+ var _a, _b;
40
+ const { hiddenSelector, lang, ns } = this;
41
+ const isBusy = this.in('busy');
42
+ const isFail = this.in('fail');
43
+ const isSnapshot = this.in({ idle: 'snapshot' });
44
+ const isTemplate = this.in({ idle: 'template' });
45
+ const transition = 'transition-opacity duration-500';
46
+ const hidden = 'opacity-0 pointer-events-none';
47
+ return html `
48
+ <div aria-busy=${isBusy} aria-live="polite" class="relative">
49
+ <div
50
+ class=${classMap({
51
+ 'grid grid-cols-2 gap-m': true,
52
+ [transition]: true,
53
+ [hidden]: isSnapshot,
54
+ })}
55
+ >
56
+ ${hiddenSelector.matches('length', true) ? '' : this.__renderLength()}
57
+ ${hiddenSelector.matches('number-of-codes', true) ? '' : this.__renderNumberOfCodes()}
58
+ ${hiddenSelector.matches('prefix', true) ? '' : this.__renderPrefix()}
59
+ ${hiddenSelector.matches('generate', true) ? '' : this.__renderGenerate()}
60
+ </div>
61
+
62
+ <div
63
+ class=${classMap({
64
+ 'absolute inset-0 flex flex-col items-center justify-center': true,
65
+ 'text-center text-m text-secondary leading-m': true,
66
+ [transition]: true,
67
+ [hidden]: !isSnapshot,
68
+ })}
69
+ >
70
+ <div class="mx-auto flex mb-m w-l h-l rounded-t-l rounded-b-l bg-success">
71
+ <iron-icon icon="icons:done-all" class="m-auto text-success-contrast"></iron-icon>
72
+ </div>
73
+
74
+ <foxy-i18n class="block" lang=${lang} key="generate_codes_done" ns=${ns}></foxy-i18n>
75
+ </div>
76
+
77
+ <div
78
+ class=${classMap({
79
+ 'absolute inset-0 flex': true,
80
+ [transition]: true,
81
+ [hidden]: !isBusy && !isFail,
82
+ })}
83
+ >
84
+ <foxy-spinner
85
+ layout="vertical"
86
+ class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
87
+ state=${isFail ? 'error' : isTemplate ? 'empty' : 'busy'}
88
+ lang=${lang}
89
+ ns="${ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
90
+ >
91
+ </foxy-spinner>
92
+ </div>
93
+ </div>
94
+ `;
95
+ }
96
+ __getErrorMessage(prefix) {
97
+ const error = this.errors.find(err => err.startsWith(prefix));
98
+ return error ? this.t(error.replace(prefix, 'v8n')) : '';
99
+ }
100
+ __getValidator(prefix) {
101
+ return () => !this.errors.some(err => err.startsWith(prefix));
102
+ }
103
+ __renderLength() {
104
+ const isTemplate = this.in({ idle: 'template' });
105
+ return html `
106
+ ${this.renderTemplateOrSlot('length:before')}
107
+
108
+ <vaadin-integer-field
109
+ error-message=${this.__getErrorMessage('length')}
110
+ label=${this.t('length')}
111
+ class="w-full"
112
+ min="1"
113
+ ?disabled=${!isTemplate || this.disabledSelector.matches('length', true)}
114
+ ?readonly=${this.readonlySelector.matches('length', true)}
115
+ prevent-invalid-input
116
+ has-controls
117
+ .checkValidity=${this.__getValidator('length')}
118
+ .value=${isTemplate ? this.form.length : ''}
119
+ @change=${(evt) => {
120
+ const field = evt.currentTarget;
121
+ this.edit({ length: parseInt(field.value) });
122
+ }}
123
+ >
124
+ </vaadin-integer-field>
125
+
126
+ ${this.renderTemplateOrSlot('length:after')}
127
+ `;
128
+ }
129
+ __renderNumberOfCodes() {
130
+ const isTemplate = this.in({ idle: 'template' });
131
+ return html `
132
+ ${this.renderTemplateOrSlot('number-of-codes:before')}
133
+
134
+ <vaadin-integer-field
135
+ error-message=${this.__getErrorMessage('number_of_codes')}
136
+ label=${this.t('number_of_codes')}
137
+ class="w-full"
138
+ min="1"
139
+ ?disabled=${!isTemplate || this.disabledSelector.matches('number-of-codes', true)}
140
+ ?readonly=${this.readonlySelector.matches('number-of-codes', true)}
141
+ prevent-invalid-input
142
+ has-controls
143
+ .checkValidity=${this.__getValidator('number_of_codes')}
144
+ .value=${isTemplate ? this.form.number_of_codes : ''}
145
+ @change=${(evt) => {
146
+ const field = evt.currentTarget;
147
+ this.edit({ number_of_codes: parseInt(field.value) });
148
+ }}
149
+ >
150
+ </vaadin-integer-field>
151
+
152
+ ${this.renderTemplateOrSlot('number-of-codes:after')}
153
+ `;
154
+ }
155
+ __renderPrefix() {
156
+ const isTemplate = this.in({ idle: 'template' });
157
+ return html `
158
+ ${this.renderTemplateOrSlot('prefix:before')}
159
+
160
+ <vaadin-text-field
161
+ helper-text=${this.t('leave_empty_for_random_codes')}
162
+ label=${this.t('prefix')}
163
+ class="col-span-2"
164
+ min="1"
165
+ ?disabled=${!isTemplate || this.disabledSelector.matches('prefix', true)}
166
+ ?readonly=${this.readonlySelector.matches('prefix', true)}
167
+ clear-button-visible
168
+ .value=${isTemplate ? this.form.prefix : ''}
169
+ @change=${(evt) => {
170
+ const field = evt.currentTarget;
171
+ this.edit({ prefix: field.value });
172
+ }}
173
+ >
174
+ </vaadin-text-field>
175
+
176
+ ${this.renderTemplateOrSlot('prefix:after')}
177
+ `;
178
+ }
179
+ __renderGenerate() {
180
+ const isValidTemplate = this.in({ idle: { template: { dirty: 'valid' } } });
181
+ return html `
182
+ ${this.renderTemplateOrSlot('generate:before')}
183
+
184
+ <vaadin-button
185
+ class="col-span-2"
186
+ theme="success primary"
187
+ ?disabled=${!isValidTemplate || this.disabledSelector.matches('generate', true)}
188
+ @click=${this.submit}
189
+ >
190
+ <foxy-i18n lang=${this.lang} key="generate" ns=${this.ns}></foxy-i18n>
191
+ </vaadin-button>
192
+
193
+ ${this.renderTemplateOrSlot('create:after')}
194
+ `;
195
+ }
196
+ }
197
+ //# sourceMappingURL=GenerateCodesForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenerateCodesForm.js","sourceRoot":"","sources":["../../../../src/elements/public/GenerateCodesForm/GenerateCodesForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAGlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAC5B,MAAM,IAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAEtF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAU;IAAjD;;QAQE,cAAS,GAAc,EAAE,CAAC;IA4K5B,CAAC;IAnLC,MAAM,KAAK,GAAG;QACZ,OAAO;YACL,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAA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C,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAE5E,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;;;;;oBAKhC,CAAC,eAAe,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;iBACtE,IAAI,CAAC,MAAM;;0BAEF,IAAI,CAAC,IAAI,sBAAsB,IAAI,CAAC,EAAE;;;QAGxD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;KAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Data, Templates } from './types';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { IntegerFieldElement } from '@vaadin/vaadin-text-field/vaadin-integer-field';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst NS = 'generate-codes';\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)));\n\n/**\n * Form element for generating codes for coupons or gift cards (`fx:generate_codes`).\n *\n * @slot length:before\n * @slot length:after\n *\n * @slot number-of-codes:before\n * @slot number-of-codes:after\n *\n * @slot prefix:before\n * @slot prefix:after\n *\n * @slot generate:before\n * @slot generate:after\n *\n * @element foxy-generate-codes-form\n * @since 1.15.0\n */\nexport class GenerateCodesForm extends Base<Data> {\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ number_of_codes: v }) => (v && v > 0) || 'number_of_codes_required',\n ({ length: v }) => (v && v > 0) || 'length_required',\n ];\n }\n\n templates: Templates = {};\n\n render(): TemplateResult {\n const { hiddenSelector, lang, ns } = this;\n\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n const isSnapshot = this.in({ idle: 'snapshot' });\n const isTemplate = this.in({ idle: 'template' });\n\n const transition = 'transition-opacity duration-500';\n const hidden = 'opacity-0 pointer-events-none';\n\n return html`\n <div aria-busy=${isBusy} aria-live=\"polite\" class=\"relative\">\n <div\n class=${classMap({\n 'grid grid-cols-2 gap-m': true,\n [transition]: true,\n [hidden]: isSnapshot,\n })}\n >\n ${hiddenSelector.matches('length', true) ? '' : this.__renderLength()}\n ${hiddenSelector.matches('number-of-codes', true) ? '' : this.__renderNumberOfCodes()}\n ${hiddenSelector.matches('prefix', true) ? '' : this.__renderPrefix()}\n ${hiddenSelector.matches('generate', true) ? '' : this.__renderGenerate()}\n </div>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex flex-col items-center justify-center': true,\n 'text-center text-m text-secondary leading-m': true,\n [transition]: true,\n [hidden]: !isSnapshot,\n })}\n >\n <div class=\"mx-auto flex mb-m w-l h-l rounded-t-l rounded-b-l bg-success\">\n <iron-icon icon=\"icons:done-all\" class=\"m-auto text-success-contrast\"></iron-icon>\n </div>\n\n <foxy-i18n class=\"block\" lang=${lang} key=\"generate_codes_done\" ns=${ns}></foxy-i18n>\n </div>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex': true,\n [transition]: true,\n [hidden]: !isBusy && !isFail,\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${isFail ? 'error' : isTemplate ? 'empty' : 'busy'}\n lang=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __getErrorMessage(prefix: string) {\n const error = this.errors.find(err => err.startsWith(prefix));\n return error ? this.t(error.replace(prefix, 'v8n')) : '';\n }\n\n private __getValidator(prefix: string) {\n return () => !this.errors.some(err => err.startsWith(prefix));\n }\n\n private __renderLength() {\n const isTemplate = this.in({ idle: 'template' });\n\n return html`\n ${this.renderTemplateOrSlot('length:before')}\n\n <vaadin-integer-field\n error-message=${this.__getErrorMessage('length')}\n label=${this.t('length')}\n class=\"w-full\"\n min=\"1\"\n ?disabled=${!isTemplate || this.disabledSelector.matches('length', true)}\n ?readonly=${this.readonlySelector.matches('length', true)}\n prevent-invalid-input\n has-controls\n .checkValidity=${this.__getValidator('length')}\n .value=${isTemplate ? this.form.length : ''}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as IntegerFieldElement;\n this.edit({ length: parseInt(field.value) });\n }}\n >\n </vaadin-integer-field>\n\n ${this.renderTemplateOrSlot('length:after')}\n `;\n }\n\n private __renderNumberOfCodes() {\n const isTemplate = this.in({ idle: 'template' });\n\n return html`\n ${this.renderTemplateOrSlot('number-of-codes:before')}\n\n <vaadin-integer-field\n error-message=${this.__getErrorMessage('number_of_codes')}\n label=${this.t('number_of_codes')}\n class=\"w-full\"\n min=\"1\"\n ?disabled=${!isTemplate || this.disabledSelector.matches('number-of-codes', true)}\n ?readonly=${this.readonlySelector.matches('number-of-codes', true)}\n prevent-invalid-input\n has-controls\n .checkValidity=${this.__getValidator('number_of_codes')}\n .value=${isTemplate ? this.form.number_of_codes : ''}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as IntegerFieldElement;\n this.edit({ number_of_codes: parseInt(field.value) });\n }}\n >\n </vaadin-integer-field>\n\n ${this.renderTemplateOrSlot('number-of-codes:after')}\n `;\n }\n\n private __renderPrefix() {\n const isTemplate = this.in({ idle: 'template' });\n\n return html`\n ${this.renderTemplateOrSlot('prefix:before')}\n\n <vaadin-text-field\n helper-text=${this.t('leave_empty_for_random_codes')}\n label=${this.t('prefix')}\n class=\"col-span-2\"\n min=\"1\"\n ?disabled=${!isTemplate || this.disabledSelector.matches('prefix', true)}\n ?readonly=${this.readonlySelector.matches('prefix', true)}\n clear-button-visible\n .value=${isTemplate ? this.form.prefix : ''}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as TextFieldElement;\n this.edit({ prefix: field.value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('prefix:after')}\n `;\n }\n\n private __renderGenerate() {\n const isValidTemplate = this.in({ idle: { template: { dirty: 'valid' } } });\n\n return html`\n ${this.renderTemplateOrSlot('generate:before')}\n\n <vaadin-button\n class=\"col-span-2\"\n theme=\"success primary\"\n ?disabled=${!isValidTemplate || this.disabledSelector.matches('generate', true)}\n @click=${this.submit}\n >\n <foxy-i18n lang=${this.lang} key=\"generate\" ns=${this.ns}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n `;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import '@vaadin/vaadin-text-field/vaadin-integer-field';
2
+ import '@vaadin/vaadin-text-field/vaadin-text-field';
3
+ import '@vaadin/vaadin-button';
4
+ import '../../internal/InternalSandbox/index';
5
+ import '../Spinner/index';
6
+ import '../I18n/index';
7
+ import { GenerateCodesForm } from './GenerateCodesForm';
8
+ export { GenerateCodesForm };
@@ -0,0 +1,10 @@
1
+ import '@vaadin/vaadin-text-field/vaadin-integer-field';
2
+ import '@vaadin/vaadin-text-field/vaadin-text-field';
3
+ import '@vaadin/vaadin-button';
4
+ import "../../internal/InternalSandbox/index.js";
5
+ import "../Spinner/index.js";
6
+ import "../I18n/index.js";
7
+ import { GenerateCodesForm } from "./GenerateCodesForm.js";
8
+ customElements.define('foxy-generate-codes-form', GenerateCodesForm);
9
+ export { GenerateCodesForm };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/GenerateCodesForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAC;AACxD,OAAO,6CAA6C,CAAC;AACrD,OAAO,uBAAuB,CAAC;AAC/B,iDAA8C;AAC9C,6BAA0B;AAC1B,0BAAuB;AAEvB,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AAExD,cAAc,CAAC,MAAM,CAAC,0BAA0B,EAAE,iBAAiB,CAAC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import '@vaadin/vaadin-text-field/vaadin-integer-field';\nimport '@vaadin/vaadin-text-field/vaadin-text-field';\nimport '@vaadin/vaadin-button';\nimport '../../internal/InternalSandbox/index';\nimport '../Spinner/index';\nimport '../I18n/index';\n\nimport { GenerateCodesForm } from './GenerateCodesForm';\n\ncustomElements.define('foxy-generate-codes-form', GenerateCodesForm);\n\nexport { GenerateCodesForm };\n"]}
@@ -0,0 +1,24 @@
1
+ import { GenerateCodesForm } from '.';
2
+ import { Rels } from '@foxy.io/sdk/backend';
3
+ import { Renderer } from '../../../mixins/configurable';
4
+ import { Resource } from '@foxy.io/sdk/core';
5
+ export declare type Data = Resource<Rels.GenerateCodes> & {
6
+ /** Present only in the response. */
7
+ _links: {
8
+ self: {
9
+ href: string;
10
+ };
11
+ };
12
+ /** Present only in the response. */
13
+ message: string;
14
+ };
15
+ export declare type Templates = {
16
+ 'length:before'?: Renderer<GenerateCodesForm>;
17
+ 'length:after'?: Renderer<GenerateCodesForm>;
18
+ 'number-of-codes:before'?: Renderer<GenerateCodesForm>;
19
+ 'number-of-codes:after'?: Renderer<GenerateCodesForm>;
20
+ 'prefix:before'?: Renderer<GenerateCodesForm>;
21
+ 'prefix:after'?: Renderer<GenerateCodesForm>;
22
+ 'generate:before'?: Renderer<GenerateCodesForm>;
23
+ 'generate:after'?: Renderer<GenerateCodesForm>;
24
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/GenerateCodesForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GenerateCodesForm } from '.';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Renderer } from '../../../mixins/configurable';\nimport { Resource } from '@foxy.io/sdk/core';\n\nexport type Data = Resource<Rels.GenerateCodes> & {\n /** Present only in the response. */\n _links: { self: { href: string } };\n /** Present only in the response. */\n message: string;\n};\n\nexport type Templates = {\n 'length:before'?: Renderer<GenerateCodesForm>;\n 'length:after'?: Renderer<GenerateCodesForm>;\n 'number-of-codes:before'?: Renderer<GenerateCodesForm>;\n 'number-of-codes:after'?: Renderer<GenerateCodesForm>;\n 'prefix:before'?: Renderer<GenerateCodesForm>;\n 'prefix:after'?: Renderer<GenerateCodesForm>;\n 'generate:before'?: Renderer<GenerateCodesForm>;\n 'generate:after'?: Renderer<GenerateCodesForm>;\n};\n"]}
@@ -104,7 +104,7 @@ I18n.FetchEvent = FetchEvent;
104
104
  /** Shared [i18next](https://www.i18next.com) instance for all I18n elements. */
105
105
  I18n.i18next = i18next.createInstance().use(backend);
106
106
  I18n.i18next.init({
107
- interpolation: { format },
107
+ interpolation: { format, escapeValue: false },
108
108
  fallbackLng: 'en',
109
109
  fallbackNS: 'shared',
110
110
  defaultNS: 'shared',
@@ -1 +1 @@
1
- {"version":3,"file":"I18n.js","sourceRoot":"","sources":["../../../../src/elements/public/I18n/I18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,OAAgC,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,wCAAqC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,MAAM,EAAE,0BAAuB;AAExC;;;;;;;GAOG;AACH,MAAM,OAAO,IAAK,SAAQ,iBAAiB,CAAC,UAAU,EAAE,EAAE,CAAC;IAA3D;;QAuEE;;;WAGG;QACH,YAAO,GAAwB,EAAE,CAAC;QAElC;;;WAGG;QACH,QAAG,GAAG,EAAE,CAAC;IAoBX,CAAC;IA9FC;;;;;;;OAOG;IACH,MAAM,CAAC,mB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O,CAAC,IAAI,CAAC;IAChB,aAAa,EAAE,EAAE,MAAM,EAAE;IACzB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,QAAQ;IACnB,EAAE,EAAE,CAAC,QAAQ,CAAC;CACf,CAAC,CAAC","sourcesContent":["import { LitElement, PropertyDeclarations, TemplateResult, html } from 'lit-element';\nimport i18next, { StringMap, TOptions } from 'i18next';\n\nimport { FetchEvent } from '../NucleonElement/FetchEvent';\nimport { Gateways } from './types';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { backend } from './backend';\nimport { format } from './format/index';\n\n/**\n * Custom element for effortless localization with i18next.\n *\n * @fires I18n#fetch - Instance of `I18n.FetchEvent`. Emitted before each translation request.\n *\n * @element foxy-i18n\n * @since 1.1.0\n */\nexport class I18n extends TranslatableMixin(LitElement, '') {\n /** Instances of this event are dispatched on an element before each translation request. */\n static readonly FetchEvent = FetchEvent;\n\n /** Shared [i18next](https://www.i18next.com) instance for all I18n elements. */\n static readonly i18next = i18next.createInstance().use(backend);\n\n /**\n * Registers a joint event listener for all i18next events that indicate\n * the availability of new translations. If you're using `I18n.i18next` to localize\n * your components, this function will call the provided handler every time an update is needed.\n *\n * @param handler Callback to invoke when translation changes.\n * @example const unsubscribe = I18n.onTranslationChange(triggerUpdate);\n */\n static onTranslationChange(handler: () => void): () => void {\n const i18nextEvents = ['initialized', 'loaded'] as const;\n const storeEvents = ['removed', 'added'] as const;\n\n i18nextEvents.forEach(type => I18n.i18next.on(type, handler));\n storeEvents.forEach(type => I18n.i18next.store.on(type, handler));\n\n return () => {\n i18nextEvents.forEach(type => I18n.i18next.off(type, handler));\n storeEvents.forEach(type => I18n.i18next.store.off(type, handler));\n };\n }\n\n /**\n * Registers a global event listener that calls `handler` every time an i18next resource\n * is downloaded by `foxy-i18n`. Allows devs to specify resource location and/or fetch it\n * via a different channel (e.g. web sockets or using a localization SaaS).\n *\n * @param handler Callback to invoke on resource fetch.\n * @example const unsubscribe = I18n.onResourceFetch((ns, lang) => fetch(`path/to/${ns}/${lang}`));\n */\n static onResourceFetch(handler: (ns: string, lang: string) => Promise<Response>): () => void {\n const handleFetch = (evt: unknown) => {\n if (evt instanceof FetchEvent && evt.request.url.startsWith('foxy://i18n/')) {\n const [lang, ns] = evt.request.url.split('/').reverse();\n evt.respondWith(handler(ns, lang));\n }\n };\n\n addEventListener('fetch', handleFetch);\n return () => removeEventListener('fetch', handleFetch);\n }\n\n /**\n * Adds payment gateway names to the i18next store. Fetch `fx:hosted_payment_gateways`\n * and `fx:payment_gateways` and call this method to make gateway names available to\n * elements like `foxy-payment-card`.\n *\n * @param param0 `fx:hosted_payment_gateways` or `fx:payment_gateways`\n * @example I18n.setGateways({ values: { authorize: { name: 'Authorize.Net' }}})\n */\n static setGateways({ values }: Gateways): void {\n for (const id in values) {\n this.i18next.addResource('en', 'gateways', `gateways.${id}`, values[id].name);\n }\n }\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n options: { type: Object },\n key: { type: String },\n };\n }\n\n /**\n * Optional i18next translation function\n * [options](https://www.i18next.com/translation-function/essentials#overview-options).\n */\n options: TOptions<StringMap> = {};\n\n /**\n * Optional key to translate. Empty by default (renders nothing).\n * See [i18next docs](https://www.i18next.com/translation-function/essentials#accessing-keys) for more info.\n */\n key = '';\n\n private __unsubscribe?: () => void;\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n this.__unsubscribe = I18n.onTranslationChange(() => this.requestUpdate());\n }\n\n /** @readonly */\n render(): TemplateResult {\n return html`<span>${this.t(this.key, { ...this.options, lng: this.lang })}</span>`;\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__unsubscribe?.();\n }\n}\n\nI18n.i18next.init({\n interpolation: { format },\n fallbackLng: 'en',\n fallbackNS: 'shared',\n defaultNS: 'shared',\n ns: ['shared'],\n});\n"]}
1
+ {"version":3,"file":"I18n.js","sourceRoot":"","sources":["../../../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AAE,CAAC,CAAC;IAC5E,CAAC;IAED,gBAAgB;IAChB,MAAM;QACJ,OAAO,IAAI,CAAA,SAAS,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC;IACrF,CAAC;IAED,gBAAgB;IAChB,oBAAoB;;QAClB,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC7B,MAAA,IAAI,CAAC,aAAa,+CAAlB,IAAI,EAAmB;IACzB,CAAC;;AAnGD,4FAA4F;AAC5E,eAAU,GAAG,UAAU,CAAC;AAExC,gFAAgF;AAChE,YAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAkGlE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAChB,aAAa,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE;IAC7C,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,QAAQ;IACnB,EAAE,EAAE,CAAC,QAAQ,CAAC;CACf,CAAC,CAAC","sourcesContent":["import { LitElement, PropertyDeclarations, TemplateResult, html } from 'lit-element';\nimport i18next, { StringMap, TOptions } from 'i18next';\n\nimport { FetchEvent } from '../NucleonElement/FetchEvent';\nimport { Gateways } from './types';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { backend } from './backend';\nimport { format } from './format/index';\n\n/**\n * Custom element for effortless localization with i18next.\n *\n * @fires I18n#fetch - Instance of `I18n.FetchEvent`. Emitted before each translation request.\n *\n * @element foxy-i18n\n * @since 1.1.0\n */\nexport class I18n extends TranslatableMixin(LitElement, '') {\n /** Instances of this event are dispatched on an element before each translation request. */\n static readonly FetchEvent = FetchEvent;\n\n /** Shared [i18next](https://www.i18next.com) instance for all I18n elements. */\n static readonly i18next = i18next.createInstance().use(backend);\n\n /**\n * Registers a joint event listener for all i18next events that indicate\n * the availability of new translations. If you're using `I18n.i18next` to localize\n * your components, this function will call the provided handler every time an update is needed.\n *\n * @param handler Callback to invoke when translation changes.\n * @example const unsubscribe = I18n.onTranslationChange(triggerUpdate);\n */\n static onTranslationChange(handler: () => void): () => void {\n const i18nextEvents = ['initialized', 'loaded'] as const;\n const storeEvents = ['removed', 'added'] as const;\n\n i18nextEvents.forEach(type => I18n.i18next.on(type, handler));\n storeEvents.forEach(type => I18n.i18next.store.on(type, handler));\n\n return () => {\n i18nextEvents.forEach(type => I18n.i18next.off(type, handler));\n storeEvents.forEach(type => I18n.i18next.store.off(type, handler));\n };\n }\n\n /**\n * Registers a global event listener that calls `handler` every time an i18next resource\n * is downloaded by `foxy-i18n`. Allows devs to specify resource location and/or fetch it\n * via a different channel (e.g. web sockets or using a localization SaaS).\n *\n * @param handler Callback to invoke on resource fetch.\n * @example const unsubscribe = I18n.onResourceFetch((ns, lang) => fetch(`path/to/${ns}/${lang}`));\n */\n static onResourceFetch(handler: (ns: string, lang: string) => Promise<Response>): () => void {\n const handleFetch = (evt: unknown) => {\n if (evt instanceof FetchEvent && evt.request.url.startsWith('foxy://i18n/')) {\n const [lang, ns] = evt.request.url.split('/').reverse();\n evt.respondWith(handler(ns, lang));\n }\n };\n\n addEventListener('fetch', handleFetch);\n return () => removeEventListener('fetch', handleFetch);\n }\n\n /**\n * Adds payment gateway names to the i18next store. Fetch `fx:hosted_payment_gateways`\n * and `fx:payment_gateways` and call this method to make gateway names available to\n * elements like `foxy-payment-card`.\n *\n * @param param0 `fx:hosted_payment_gateways` or `fx:payment_gateways`\n * @example I18n.setGateways({ values: { authorize: { name: 'Authorize.Net' }}})\n */\n static setGateways({ values }: Gateways): void {\n for (const id in values) {\n this.i18next.addResource('en', 'gateways', `gateways.${id}`, values[id].name);\n }\n }\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n options: { type: Object },\n key: { type: String },\n };\n }\n\n /**\n * Optional i18next translation function\n * [options](https://www.i18next.com/translation-function/essentials#overview-options).\n */\n options: TOptions<StringMap> = {};\n\n /**\n * Optional key to translate. Empty by default (renders nothing).\n * See [i18next docs](https://www.i18next.com/translation-function/essentials#accessing-keys) for more info.\n */\n key = '';\n\n private __unsubscribe?: () => void;\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n this.__unsubscribe = I18n.onTranslationChange(() => this.requestUpdate());\n }\n\n /** @readonly */\n render(): TemplateResult {\n return html`<span>${this.t(this.key, { ...this.options, lng: this.lang })}</span>`;\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__unsubscribe?.();\n }\n}\n\nI18n.i18next.init({\n interpolation: { format, escapeValue: false },\n fallbackLng: 'en',\n fallbackNS: 'shared',\n defaultNS: 'shared',\n ns: ['shared'],\n});\n"]}
@@ -2,12 +2,13 @@
2
2
  * i18next formatter that localizes ISO date.
3
3
  * @see https://www.i18next.com/translation-function/formatting
4
4
  */
5
- export const date = (value, format, lang) => {
5
+ export const date = (value, _, lang) => {
6
+ if (!value)
7
+ return '$t(unknown)';
6
8
  const valueAsDate = new Date(value);
7
- return valueAsDate.toLocaleDateString(lang, {
8
- month: 'long',
9
- year: new Date().getFullYear() === valueAsDate.getFullYear() ? undefined : 'numeric',
10
- day: 'numeric',
11
- });
9
+ const month = 'long';
10
+ const year = new Date().getFullYear() === valueAsDate.getFullYear() ? undefined : 'numeric';
11
+ const day = 'numeric';
12
+ return valueAsDate.toLocaleDateString(lang, { month, year, day });
12
13
  };
13
14
  //# sourceMappingURL=date.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/date.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAU,EAAE;IAClE,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE;QAC1C,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACpF,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\n/**\n * i18next formatter that localizes ISO date.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const date: FormatFunction = (value, format, lang): string => {\n const valueAsDate = new Date(value);\n return valueAsDate.toLocaleDateString(lang, {\n month: 'long',\n year: new Date().getFullYear() === valueAsDate.getFullYear() ? undefined : 'numeric',\n day: 'numeric',\n });\n};\n"]}
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/date.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAmB,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAU,EAAE;IAC7D,IAAI,CAAC,KAAK;QAAE,OAAO,aAAa,CAAC;IAEjC,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC;IACrB,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5F,MAAM,GAAG,GAAG,SAAS,CAAC;IAEtB,OAAO,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\n/**\n * i18next formatter that localizes ISO date.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const date: FormatFunction = (value, _, lang): string => {\n if (!value) return '$t(unknown)';\n\n const valueAsDate = new Date(value);\n const month = 'long';\n const year = new Date().getFullYear() === valueAsDate.getFullYear() ? undefined : 'numeric';\n const day = 'numeric';\n\n return valueAsDate.toLocaleDateString(lang, { month, year, day });\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import { FormatFunction } from 'i18next';
2
+ /**
3
+ * i18next formatter that returns a human-readable discount description for an API value.
4
+ * @see https://www.i18next.com/translation-function/formatting
5
+ */
6
+ export declare const discount: FormatFunction;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * i18next formatter that returns a human-readable discount description for an API value.
3
+ * @see https://www.i18next.com/translation-function/formatting
4
+ */
5
+ export const discount = ({ type, details }, format, lang) => {
6
+ const methods = ['allunits', 'incremental', 'repeat', 'single'];
7
+ const factor = type.endsWith('_percentage') ? 0.01 : 1;
8
+ const tiers = details.split('|');
9
+ const method = methods.includes(tiers[0]) ? tiers.shift() : 'single';
10
+ const i18nKey = `${method}_${type}_discount_summary`;
11
+ const translatedTiers = tiers.map(tier => {
12
+ var _a, _b;
13
+ const signIndex = (_b = (_a = /[-+]/.exec(tier)) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : -1;
14
+ const adjustment = parseFloat(tier.substring(signIndex)) * factor;
15
+ const from = parseFloat(tier.substring(0, signIndex));
16
+ return `$t(${i18nKey}, ${JSON.stringify({ adjustment, from })})`;
17
+ });
18
+ return translatedTiers.join('; ');
19
+ };
20
+ //# sourceMappingURL=discount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discount.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/discount.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAS,EAAE,MAAM,EAAE,IAAI,EAAU,EAAE;IACzF,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrE,MAAM,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,mBAAmB,CAAC;IAErD,MAAM,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;;QACvC,MAAM,SAAS,eAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,0CAAE,KAAK,mCAAI,CAAC,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC;QAClE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAEtD,OAAO,MAAM,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\ntype Value = { type: string; details: string };\n\n/**\n * i18next formatter that returns a human-readable discount description for an API value.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const discount: FormatFunction = ({ type, details }: Value, format, lang): string => {\n const methods = ['allunits', 'incremental', 'repeat', 'single'];\n const factor = type.endsWith('_percentage') ? 0.01 : 1;\n const tiers = details.split('|');\n const method = methods.includes(tiers[0]) ? tiers.shift() : 'single';\n const i18nKey = `${method}_${type}_discount_summary`;\n\n const translatedTiers = tiers.map(tier => {\n const signIndex = /[-+]/.exec(tier)?.index ?? -1;\n const adjustment = parseFloat(tier.substring(signIndex)) * factor;\n const from = parseFloat(tier.substring(0, signIndex));\n\n return `$t(${i18nKey}, ${JSON.stringify({ adjustment, from })})`;\n });\n\n return translatedTiers.join('; ');\n};\n"]}
@@ -1,9 +1,13 @@
1
1
  import { date } from "./date.js";
2
+ import { discount } from "./discount.js";
3
+ import { ordinal } from "./ordinal.js";
2
4
  import { percent } from "./percent.js";
3
5
  import { price } from "./price.js";
4
6
  import { time } from "./time.js";
5
7
  const formatters = {
8
+ discount,
6
9
  percent,
10
+ ordinal,
7
11
  price,
8
12
  date,
9
13
  time,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,IAAI,EAAE,kBAAe;AAE9B,MAAM,UAAU,GAAmC;IACjD,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,EAAE,EAAU,EAAE;IAC1F,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;;QACnD,mBAAO,UAAU,CAAC,IAAI,CAAC,+CAAhB,UAAU,EAAS,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,oCAAK,MAAM,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\nimport { date } from './date';\nimport { percent } from './percent';\nimport { price } from './price';\nimport { time } from './time';\n\nconst formatters: Record<string, FormatFunction> = {\n percent,\n price,\n date,\n time,\n};\n\n/**\n * Chooses the right i18next formatter for the given template.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const format: FormatFunction = (value, names = '', lang = 'en', opts = {}): string => {\n const parsedNames = names.split(' ').filter(v => !!v.trim());\n const applyFormat = (result: string, name: string) => {\n return formatters[name]?.(result, name, lang, opts) ?? result;\n };\n\n return parsedNames.reduce(applyFormat, value);\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,QAAQ,EAAE,sBAAmB;AACtC,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,IAAI,EAAE,kBAAe;AAE9B,MAAM,UAAU,GAAmC;IACjD,QAAQ;IACR,OAAO;IACP,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,EAAE,EAAU,EAAE;IAC1F,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;;QACnD,mBAAO,UAAU,CAAC,IAAI,CAAC,+CAAhB,UAAU,EAAS,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,oCAAK,MAAM,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\nimport { date } from './date';\nimport { discount } from './discount';\nimport { ordinal } from './ordinal';\nimport { percent } from './percent';\nimport { price } from './price';\nimport { time } from './time';\n\nconst formatters: Record<string, FormatFunction> = {\n discount,\n percent,\n ordinal,\n price,\n date,\n time,\n};\n\n/**\n * Chooses the right i18next formatter for the given template.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const format: FormatFunction = (value, names = '', lang = 'en', opts = {}): string => {\n const parsedNames = names.split(' ').filter(v => !!v.trim());\n const applyFormat = (result: string, name: string) => {\n return formatters[name]?.(result, name, lang, opts) ?? result;\n };\n\n return parsedNames.reduce(applyFormat, value);\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import { FormatFunction } from 'i18next';
2
+ /**
3
+ * i18next formatter that returns ordinal for a number.
4
+ * @see https://www.i18next.com/translation-function/formatting
5
+ */
6
+ export declare const ordinal: FormatFunction;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * i18next formatter that returns ordinal for a number.
3
+ * @see https://www.i18next.com/translation-function/formatting
4
+ */
5
+ export const ordinal = (value, format, lang) => {
6
+ const rules = new Intl.PluralRules(lang, { type: 'ordinal' });
7
+ return `${value}$t(ordinal_${rules.select(value)})`;
8
+ };
9
+ //# sourceMappingURL=ordinal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordinal.js","sourceRoot":"","sources":["../../../../../src/elements/public/I18n/format/ordinal.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAU,EAAE;IACrE,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,OAAO,GAAG,KAAK,cAAc,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AACtD,CAAC,CAAC","sourcesContent":["import { FormatFunction } from 'i18next';\n\n/**\n * i18next formatter that returns ordinal for a number.\n * @see https://www.i18next.com/translation-function/formatting\n */\nexport const ordinal: FormatFunction = (value, format, lang): string => {\n const rules = new Intl.PluralRules(lang, { type: 'ordinal' });\n return `${value}$t(ordinal_${rules.select(value)})`;\n};\n"]}