@foxy.io/elements 1.14.0-beta.7 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +17 -17
- package/dist/cdn/foxy-customer-portal.js +18 -15
- package/dist/cdn/foxy-customer.js +4 -4
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-query-builder.js +2 -2
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +3 -3
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -14
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/shared-07134f93.js +14 -0
- package/dist/cdn/{shared-691da586.js → shared-07abcd7b.js} +1 -1
- package/dist/cdn/{shared-6f7f752e.js → shared-322e60b1.js} +1 -1
- package/dist/cdn/shared-35dbd2c5.js +1 -0
- package/dist/cdn/{shared-1bafffd0.js → shared-5c8b531d.js} +1 -1
- package/dist/cdn/{shared-6ecbc785.js → shared-5f54e916.js} +1 -1
- package/dist/cdn/{shared-50c7a176.js → shared-7a42073a.js} +1 -1
- package/dist/cdn/{shared-c66e9946.js → shared-8a7bee0d.js} +1 -1
- package/dist/cdn/{shared-4d3c7828.js → shared-91e768be.js} +1 -1
- package/dist/cdn/shared-9a40309d.js +1 -0
- package/dist/cdn/{shared-7629a1a5.js → shared-b5147166.js} +1 -1
- package/dist/cdn/{shared-16e28f3b.js → shared-bc2bfe52.js} +1 -1
- package/dist/cdn/{shared-0ba88744.js → shared-ce1da35d.js} +1 -1
- package/dist/cdn/{shared-09feabf8.js → shared-d01d809a.js} +1 -1
- package/dist/cdn/{shared-8edee4e1.js → shared-d8ffb279.js} +7 -7
- package/dist/cdn/{shared-a6c047b1.js → shared-e5cbf291.js} +1 -1
- package/dist/cdn/shared-f1dc1c6c.js +1 -0
- package/dist/cdn/translations/shared/de.json +94 -0
- package/dist/cdn/translations/shared/en.json +83 -83
- package/dist/cdn/translations/shared/es.json +93 -0
- package/dist/elements/private/Checkbox/Checkbox.d.ts +3 -1
- package/dist/elements/private/Checkbox/Checkbox.js +43 -14
- package/dist/elements/private/Checkbox/Checkbox.js.map +1 -1
- package/dist/elements/private/Choice/Choice.js +7 -5
- package/dist/elements/private/Choice/Choice.js.map +1 -1
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLink.d.ts +1 -0
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLink.js +17 -8
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLink.js.map +1 -1
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.js +19 -6
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedInView.js.map +1 -1
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalSubscriptions.js +11 -3
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalSubscriptions.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.d.ts +24 -2
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +89 -50
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/types.d.ts +14 -0
- package/dist/elements/public/EmailTemplateForm/types.js.map +1 -1
- package/dist/elements/public/ItemsForm/private/Picture.d.ts +1 -0
- package/dist/elements/public/ItemsForm/private/Picture.js +2 -0
- package/dist/elements/public/ItemsForm/private/Picture.js.map +1 -1
- package/dist/elements/public/SubscriptionForm/SubscriptionForm.js +12 -4
- package/dist/elements/public/SubscriptionForm/SubscriptionForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/CountriesList.d.ts +2 -4
- package/dist/elements/public/TemplateConfigForm/CountriesList.js +29 -21
- package/dist/elements/public/TemplateConfigForm/CountriesList.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/CountryCard.d.ts +1 -1
- package/dist/elements/public/TemplateConfigForm/CountryCard.js +53 -18
- package/dist/elements/public/TemplateConfigForm/CountryCard.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.d.ts +55 -1
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +395 -185
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/types.d.ts +34 -0
- package/dist/elements/public/TemplateConfigForm/types.js.map +1 -1
- package/dist/elements/public/TemplateForm/TemplateForm.d.ts +23 -1
- package/dist/elements/public/TemplateForm/TemplateForm.js +92 -52
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
- package/dist/elements/public/TemplateForm/types.d.ts +14 -0
- package/dist/elements/public/TemplateForm/types.js.map +1 -1
- package/dist/mixins/themeable.js +30 -14
- package/dist/mixins/themeable.js.map +1 -1
- package/dist/mixins/translatable.js +1 -1
- package/dist/mixins/translatable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-3f35fa81.js +0 -1
- package/dist/cdn/shared-ace85f1b.js +0 -1
- package/dist/cdn/shared-d8852c42.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionForm.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionForm/SubscriptionForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,+BAA4B;AAE9D,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,mCAAgC;AAEzD,OAAO,EAAE,OAAO,EAAE,wCAAqC;AAEvD,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,kDAA+C;AAE3E,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,aAAa,EAAE,yCAAsC;AAE9D,MAAM,E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OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { Choice, Group, Skeleton } from '../../private/index';\nimport { Data, Item, Settings, Templates } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\nimport {\n getAllowedFrequencies,\n getNextTransactionDateConstraints,\n isNextTransactionDate,\n} from '@foxy.io/sdk/customer';\n\nimport { ButtonElement } from '@vaadin/vaadin-button';\nimport { CellContext } from '../Table/types';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { FormDialog } from '../FormDialog';\nimport { InternalCalendar } from '../../internal/InternalCalendar';\nimport { NucleonElement } from '../NucleonElement/index';\nimport { PageRendererContext } from '../CollectionPages/types';\nimport { Preview } from '../ItemsForm/private/Preview';\nimport { PropertyDeclarations } from 'lit-element';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TransactionsTable } from '../TransactionsTable/TransactionsTable';\nimport { Data as TransactionsTableData } from '../TransactionsTable/types';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { serializeDate } from '../../../utils/serialize-date';\n\nconst NS = 'subscription-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing subscriptions.\n *\n * @slot header:before - **new in v1.4.0**\n * @slot header:after - **new in v1.4.0**\n *\n * @slot items:before - **new in v1.4.0**\n * @slot items:after - **new in v1.4.0**\n * @slot items:actions:before - **new in v1.4.0**\n * @slot items:actions:after - **new in v1.4.0**\n *\n * @slot end-date:before - **new in v1.4.0**\n * @slot end-date:after - **new in v1.4.0**\n *\n * @slot next-transaction-date:before - **new in v1.4.0**\n * @slot next-transaction-date:after - **new in v1.4.0**\n *\n * @slot frequency:before - **new in v1.4.0**\n * @slot frequency:after - **new in v1.4.0**\n *\n * @slot transactions:before - **new in v1.4.0**\n * @slot transactions:after - **new in v1.4.0**\n *\n * @element foxy-subscription-form\n * @since 1.2.0\n */\nexport class SubscriptionForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-calendar': customElements.get('foxy-internal-calendar'),\n 'foxy-collection-pages': customElements.get('foxy-collection-pages'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-combo-box': customElements.get('vaadin-combo-box'),\n 'foxy-form-dialog': customElements.get('foxy-form-dialog'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'vcf-tooltip': customElements.get('vcf-tooltip'),\n 'foxy-table': customElements.get('foxy-table'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'iron-icon': customElements.get('iron-icon'),\n 'x-skeleton': Skeleton,\n 'x-preview': Preview,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n settings: { type: Object },\n };\n }\n\n settings: Settings | null = null;\n\n templates: Templates = {};\n\n private readonly __renderHeaderSubtitle = () => {\n const { data, lang, ns } = this;\n\n if (data) {\n let color = 'text-secondary';\n let date: string;\n let key: string;\n\n if (data.first_failed_transaction_date) {\n color = 'text-error';\n date = data.first_failed_transaction_date;\n key = 'subscription_failed';\n } else if (data.end_date) {\n date = data.end_date;\n const hasEnded = new Date(date).getTime() > Date.now();\n key = hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n } else {\n date = data.next_transaction_date ?? new Date().toISOString();\n key = `subscription_${data.is_active ? 'active' : 'inactive'}`;\n }\n\n const text = html`\n <foxy-i18n\n data-testid=\"header-subtitle\"\n options=${JSON.stringify({ date })}\n class=${color}\n lang=${lang}\n key=${key}\n ns=${ns}\n >\n </foxy-i18n>\n `;\n\n if (data.first_failed_transaction_date) {\n return html`\n <span id=\"status\" class=\"flex items-center space-x-xs ${color}\">\n ${text}<iron-icon icon=\"icons:info-outline\" class=\"icon-inline\"></iron-icon>\n </span>\n <vcf-tooltip for=\"status\" position=\"bottom\">\n <span class=\"text-s\">${data.error_message}</span>\n </vcf-tooltip>\n `;\n }\n\n return text;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\"> </x-skeleton>`;\n };\n\n private readonly __renderHeaderTitle = () => {\n const { data, lang, ns } = this;\n\n if (data) {\n const frequency = parseFrequency(data.frequency);\n const currency = data._embedded['fx:last_transaction'].currency_code;\n const total = data._embedded['fx:last_transaction'].total_order;\n\n return html`\n <foxy-i18n\n data-testid=\"header-title\"\n options=${JSON.stringify({ ...frequency, amount: `${total} ${currency}` })}\n lang=${lang}\n key=\"price_${data.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${ns}\n >\n </foxy-i18n>\n `;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\"> </x-skeleton>`;\n };\n\n private readonly __renderHeader = () => {\n return html`\n <div data-testid=\"header\">\n ${this.renderTemplateOrSlot('header:before')}\n <div class=\"leading-xs text-xxl font-bold\">${this.__renderHeaderTitle()}</div>\n <div class=\"leading-xs text-l\">${this.__renderHeaderSubtitle()}</div>\n ${this.renderTemplateOrSlot('header:after')}\n </div>\n `;\n };\n\n private readonly __renderItemsActions = () => {\n return html`\n <div class=\"flex\" data-testid=\"items:actions\">\n ${this.renderTemplateOrSlot('items:actions:before')}\n\n <foxy-i18n\n data-testid=\"items:actions-label\"\n class=\"flex-1\"\n lang=${this.lang}\n key=\"item_plural\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('items:actions:after')}\n </div>\n `;\n };\n\n private readonly __renderItemsItem = (item: Item) => {\n const price = item.price.toLocaleString(this.lang || 'en', {\n style: 'currency',\n currency: this.data!._embedded['fx:last_transaction'].currency_code,\n });\n\n let quantity: TemplateResult;\n\n if (item.quantity > 1) {\n quantity = html`\n <div\n data-testclass=\"item-quantity\"\n class=\"px-s h-xs rounded bg-contrast-5 flex items-center font-tnum text-contrast text-s font-bold\"\n >\n ${item.quantity}\n </div>\n `;\n } else {\n quantity = html``;\n }\n\n return html`\n <figure class=\"flex items-center space-x-m py-s pr-m\" data-testclass=\"item\">\n <x-preview\n data-testclass=\"item-preview\"\n class=\"w-l h-l\"\n .quantity=${item.quantity}\n .image=${item.image}\n >\n </x-preview>\n\n <figcaption class=\"leading-s flex-1 flex justify-between items-center\">\n <div class=\"flex flex-col\">\n <span class=\"font-medium\" data-testclass=\"item-name\">${item.name}</span>\n <span class=\"text-secondary text-s\" data-testclass=\"item-price\">${price}</span>\n </div>\n\n ${quantity}\n </figcaption>\n </figure>\n `;\n };\n\n private readonly __renderItems = () => {\n const hiddenSelector = this.hiddenSelector;\n const items = this.data?._embedded['fx:transaction_template']._embedded['fx:items'] ?? [];\n const label = hiddenSelector.matches('items:actions', true) ? '' : this.__renderItemsActions();\n\n return html`\n <div data-testid=\"items\">\n ${this.renderTemplateOrSlot('items:before')}\n <x-group frame>\n <div slot=\"header\">${label}</div>\n <div class=\"divide-y divide-contrast-10 pl-s\">${items.map(this.__renderItemsItem)}</div>\n </x-group>\n ${this.renderTemplateOrSlot('items:after')}\n </div>\n `;\n };\n\n private readonly __renderEndDate = () => {\n const { disabledSelector, lang, ns } = this;\n const formHiddenSelector = this.hiddenSelector.zoom('end-date:form').toString();\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('end-date:before')}\n\n <foxy-form-dialog\n readonlycontrols=${this.readonlySelector.zoom('end-date:form').toString()}\n disabledcontrols=${disabledSelector.zoom('end-date:form').toString()}\n hiddencontrols=\"save-button ${formHiddenSelector}\"\n data-testid=\"cancellation-form\"\n parent=${this.parent}\n header=\"end_subscription\"\n alert\n form=\"foxy-cancellation-form\"\n href=${this.href}\n lang=${lang}\n id=\"end-date-form\"\n ns=${ns}\n .templates=${this.getNestedTemplates('end-date:form')}\n >\n </foxy-form-dialog>\n\n <vaadin-button\n data-testid=\"end-date\"\n theme=\"error\"\n class=\"w-full\"\n ?disabled=${!this.data || disabledSelector.matches('end-date', true)}\n @click=${(evt: Event) => {\n const form = this.renderRoot.querySelector('#end-date-form') as FormDialog;\n form.show(evt.currentTarget as ButtonElement);\n }}\n >\n <foxy-i18n key=\"end_subscription\" ns=${ns} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('end-date:after')}\n </div>\n `;\n };\n\n private readonly __checkNextTransactionDateAvailability = (date: Date) => {\n const { settings, data: subscription } = this;\n\n if (settings && subscription) {\n const value = serializeDate(date);\n return isNextTransactionDate({ value, settings, subscription });\n }\n\n return date.getTime() >= Date.now();\n };\n\n private readonly __renderNextTransactionDate = () => {\n const { data, lang, ns } = this;\n const isActive = !!data?.is_active;\n\n return html`\n <div data-testid=\"next-transaction-date\">\n ${this.renderTemplateOrSlot('next-transaction-date:before')}\n\n <x-group frame>\n <foxy-i18n key=\"next_transaction_date\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n <foxy-internal-calendar\n start=${ifDefined(data?.next_transaction_date.substr(0, 10))}\n value=${ifDefined(data?.next_transaction_date)}\n lang=${lang}\n ?readonly=${!isActive || this.readonlySelector.matches('next-transaction-date', true)}\n ?disabled=${!data || this.disabledSelector.matches('next-transaction-date', true)}\n .checkAvailability=${this.__checkNextTransactionDateAvailability}\n @change=${(evt: Event) => {\n const target = evt.target as InternalCalendar;\n this.edit({ next_transaction_date: target.value });\n }}\n >\n </foxy-internal-calendar>\n </x-group>\n\n ${this.renderTemplateOrSlot('next-transaction-date:after')}\n </div>\n `;\n };\n\n private readonly __renderFrequencyAsDropdown = () => {\n const { data } = this;\n const active = !!data?.is_active;\n const items = this.__frequencies.map(v => ({\n label: this.t(v === '.5m' ? 'twice_a_month' : 'frequency', parseFrequency(v)),\n value: v,\n }));\n\n return html`\n <vaadin-combo-box\n item-value-path=\"value\"\n item-label-path=\"label\"\n data-testid=\"frequency\"\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!active || this.readonlySelector.matches('frequency', true))}\n class=\"w-full\"\n label=${this.t('frequency_label').toString()}\n value=${ifDefined(this.form.frequency)}\n .items=${items}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n </vaadin-combo-box>\n `;\n };\n\n private readonly __renderFrequencyAsRadioList = () => {\n const { data, lang, ns } = this;\n\n return html`\n <x-group frame>\n <foxy-i18n key=\"frequency_label\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n\n <x-choice\n default-custom-value=\"1d\"\n data-testid=\"frequency\"\n type=\"frequency\"\n ns=${SubscriptionForm.defaultNS}\n ?custom=${this.settings === null}\n .items=${this.__frequencies}\n .value=${this.form.frequency ?? null}\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!data.is_active || this.readonlySelector.matches('frequency', true))}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n ${this.__frequencies.map(\n frequency => html`\n <foxy-i18n\n options=${JSON.stringify(parseFrequency(frequency))}\n slot=\"${frequency}-label\"\n lang=${lang}\n key=${frequency === '.5m' ? 'twice_a_month' : 'frequency'}\n ns=${ns}\n >\n </foxy-i18n>\n `\n )}\n </x-choice>\n </x-group>\n `;\n };\n\n private readonly __renderFrequency = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('frequency:before')}\n ${this.settings && this.__frequencies.length > 4\n ? this.__renderFrequencyAsDropdown()\n : this.__renderFrequencyAsRadioList()}\n ${this.renderTemplateOrSlot('frequency:after')}\n </div>\n `;\n };\n\n private readonly __transactionsTableColumns = [\n {\n cell(ctx: CellContext<TransactionsTableData>) {\n const colors: Record<string, string> = {\n declined: 'text-error',\n rejected: 'text-error',\n };\n\n const status = TransactionsTable.statusColumn.cell!(ctx);\n const price = TransactionsTable.priceColumn.cell!(ctx);\n const color = colors[ctx.data.status] ?? 'text-body';\n\n return ctx.html`\n <span class=\"sr-only\">${status}</span>\n <span class=\"${color} text-s\">${price}</span>\n `;\n },\n },\n { cell: TransactionsTable.idColumn.cell, hideBelow: 'sm' },\n { cell: TransactionsTable.dateColumn.cell },\n { cell: TransactionsTable.receiptColumn.cell },\n ];\n\n private readonly __renderTransactionsPage = ({ html, ...ctx }: PageRendererContext) => {\n return html`\n <foxy-table\n group=${ctx.group}\n lang=${ctx.lang}\n href=${ctx.href}\n ns=\"${ctx.ns} ${customElements.get('foxy-transactions-table')?.defaultNS ?? ''}\"\n .columns=${this.__transactionsTableColumns}\n >\n </foxy-table>\n `;\n };\n\n private readonly __renderTransactions = () => {\n const { lang, ns } = this;\n\n return html`\n <div data-testid=\"transactions\">\n ${this.renderTemplateOrSlot('transactions:before')}\n\n <x-group frame>\n <foxy-i18n lang=${lang} slot=\"header\" key=\"transaction_plural\" ns=${ns}></foxy-i18n>\n <foxy-collection-pages\n group=${this.group}\n class=\"block divide-y divide-contrast-10 px-m\"\n first=${this.data?._links['fx:transactions'].href ?? ''}\n lang=${lang}\n ns=${ns}\n .page=${this.__renderTransactionsPage}\n >\n </foxy-collection-pages>\n </x-group>\n\n ${this.renderTemplateOrSlot('transactions:after')}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <div\n data-testid=\"wrapper\"\n aria-busy=${isBusy}\n aria-live=\"polite\"\n class=\"relative space-y-l text-body font-lumo text-m leading-m\"\n >\n ${this.hiddenSelector.matches('header', true) ? '' : this.__renderHeader()}\n ${this.hiddenSelector.matches('items', true) ? '' : this.__renderItems()}\n ${this.hiddenSelector.matches('end-date', true) ? '' : this.__renderEndDate()}\n ${this.__isNextTransactionDateVisible ? this.__renderNextTransactionDate() : ''}\n ${this.__isFrequencyVisible ? this.__renderFrequency() : ''}\n ${this.hiddenSelector.matches('transactions', true) ? '' : this.__renderTransactions()}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !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' : isBusy ? 'busy' : 'empty'}\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private get __isNextTransactionDateVisible() {\n if (this.hiddenSelector.matches('next-transaction-date', true)) return false;\n if (this.settings === null) return true;\n if (this.data === null) return false;\n\n const rules = this.settings.subscriptions.allow_next_date_modification;\n return !!getNextTransactionDateConstraints(this.data, rules);\n }\n\n private get __isFrequencyVisible() {\n if (this.hiddenSelector.matches('frequency', true)) return false;\n if (this.settings === null) return true;\n if (this.data === null) return false;\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return !allowedFrequencies.next().done;\n }\n\n private get __frequencies() {\n if (!this.settings || !this.data) return ['.5m', '1m', '1y'];\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return Array.from(allowedFrequencies);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SubscriptionForm.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionForm/SubscriptionForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,+BAA4B;AAE9D,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,mCAAgC;AAEzD,OAAO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AAI;YAAE,OAAO,KAAK,CAAC;QACrC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QAC7F,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAChD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAExC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;YAC/C,YAAY,EAAE,IAAI,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;IACzC,CAAC;IAED,IAAY,aAAa;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAE7D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;YAC/C,YAAY,EAAE,IAAI,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { Choice, Group, Skeleton } from '../../private/index';\nimport { Data, Item, Settings, Templates } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\nimport {\n getAllowedFrequencies,\n getNextTransactionDateConstraints,\n isNextTransactionDate,\n} from '@foxy.io/sdk/customer';\n\nimport { ButtonElement } from '@vaadin/vaadin-button';\nimport { CellContext } from '../Table/types';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { FormDialog } from '../FormDialog';\nimport { InternalCalendar } from '../../internal/InternalCalendar';\nimport { NucleonElement } from '../NucleonElement/index';\nimport { PageRendererContext } from '../CollectionPages/types';\nimport { Preview } from '../ItemsForm/private/Preview';\nimport { PropertyDeclarations } from 'lit-element';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TransactionsTable } from '../TransactionsTable/TransactionsTable';\nimport { Data as TransactionsTableData } from '../TransactionsTable/types';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { serializeDate } from '../../../utils/serialize-date';\n\nconst NS = 'subscription-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing subscriptions.\n *\n * @slot header:before - **new in v1.4.0**\n * @slot header:after - **new in v1.4.0**\n *\n * @slot items:before - **new in v1.4.0**\n * @slot items:after - **new in v1.4.0**\n * @slot items:actions:before - **new in v1.4.0**\n * @slot items:actions:after - **new in v1.4.0**\n *\n * @slot end-date:before - **new in v1.4.0**\n * @slot end-date:after - **new in v1.4.0**\n *\n * @slot next-transaction-date:before - **new in v1.4.0**\n * @slot next-transaction-date:after - **new in v1.4.0**\n *\n * @slot frequency:before - **new in v1.4.0**\n * @slot frequency:after - **new in v1.4.0**\n *\n * @slot transactions:before - **new in v1.4.0**\n * @slot transactions:after - **new in v1.4.0**\n *\n * @element foxy-subscription-form\n * @since 1.2.0\n */\nexport class SubscriptionForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-calendar': customElements.get('foxy-internal-calendar'),\n 'foxy-collection-pages': customElements.get('foxy-collection-pages'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-combo-box': customElements.get('vaadin-combo-box'),\n 'foxy-form-dialog': customElements.get('foxy-form-dialog'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'vcf-tooltip': customElements.get('vcf-tooltip'),\n 'foxy-table': customElements.get('foxy-table'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'iron-icon': customElements.get('iron-icon'),\n 'x-skeleton': Skeleton,\n 'x-preview': Preview,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n settings: { type: Object },\n };\n }\n\n settings: Settings | null = null;\n\n templates: Templates = {};\n\n private readonly __renderHeaderSubtitle = () => {\n const { data, lang, ns } = this;\n\n if (data) {\n let color = 'text-secondary';\n let date: string;\n let key: string;\n\n if (data.first_failed_transaction_date) {\n color = 'text-error';\n date = data.first_failed_transaction_date;\n key = 'subscription_failed';\n } else if (data.end_date) {\n date = data.end_date;\n const hasEnded = new Date(date).getTime() > Date.now();\n key = hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n } else {\n date = data.next_transaction_date ?? new Date().toISOString();\n key = `subscription_${data.is_active ? 'active' : 'inactive'}`;\n }\n\n const text = html`\n <foxy-i18n\n data-testid=\"header-subtitle\"\n options=${JSON.stringify({ date })}\n class=${color}\n lang=${lang}\n key=${key}\n ns=${ns}\n >\n </foxy-i18n>\n `;\n\n if (data.first_failed_transaction_date) {\n return html`\n <span id=\"status\" class=\"flex items-center space-x-xs ${color}\">\n ${text}<iron-icon icon=\"icons:info-outline\" class=\"icon-inline\"></iron-icon>\n </span>\n <vcf-tooltip for=\"status\" position=\"bottom\">\n <span class=\"text-s\">${data.error_message}</span>\n </vcf-tooltip>\n `;\n }\n\n return text;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\"> </x-skeleton>`;\n };\n\n private readonly __renderHeaderTitle = () => {\n const { data, lang, ns } = this;\n\n if (data) {\n const frequency = parseFrequency(data.frequency);\n const currency = data._embedded['fx:last_transaction'].currency_code;\n const total = data._embedded['fx:last_transaction'].total_order;\n\n return html`\n <foxy-i18n\n data-testid=\"header-title\"\n options=${JSON.stringify({ ...frequency, amount: `${total} ${currency}` })}\n lang=${lang}\n key=\"price_${data.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${ns}\n >\n </foxy-i18n>\n `;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\"> </x-skeleton>`;\n };\n\n private readonly __renderHeader = () => {\n return html`\n <div data-testid=\"header\">\n ${this.renderTemplateOrSlot('header:before')}\n <div class=\"leading-xs text-xxl font-bold\">${this.__renderHeaderTitle()}</div>\n <div class=\"leading-xs text-l\">${this.__renderHeaderSubtitle()}</div>\n ${this.renderTemplateOrSlot('header:after')}\n </div>\n `;\n };\n\n private readonly __renderItemsActions = () => {\n return html`\n <div class=\"flex\" data-testid=\"items:actions\">\n ${this.renderTemplateOrSlot('items:actions:before')}\n\n <foxy-i18n\n data-testid=\"items:actions-label\"\n class=\"flex-1\"\n lang=${this.lang}\n key=\"item_plural\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('items:actions:after')}\n </div>\n `;\n };\n\n private readonly __renderItemsItem = (item: Item) => {\n const price = item.price.toLocaleString(this.lang || 'en', {\n style: 'currency',\n currency: this.data!._embedded['fx:last_transaction'].currency_code,\n });\n\n let quantity: TemplateResult;\n\n if (item.quantity > 1) {\n quantity = html`\n <div\n data-testclass=\"item-quantity\"\n class=\"px-s h-xs rounded bg-contrast-5 flex items-center font-tnum text-contrast text-s font-bold\"\n >\n ${item.quantity}\n </div>\n `;\n } else {\n quantity = html``;\n }\n\n return html`\n <figure class=\"flex items-center space-x-m py-s pr-m\" data-testclass=\"item\">\n <x-preview\n data-testclass=\"item-preview\"\n class=\"w-l h-l\"\n .quantity=${item.quantity}\n .image=${item.image}\n >\n </x-preview>\n\n <figcaption class=\"leading-s flex-1 flex justify-between items-center\">\n <div class=\"flex flex-col\">\n <span class=\"font-medium\" data-testclass=\"item-name\">${item.name}</span>\n <span class=\"text-secondary text-s\" data-testclass=\"item-price\">${price}</span>\n </div>\n\n ${quantity}\n </figcaption>\n </figure>\n `;\n };\n\n private readonly __renderItems = () => {\n const hiddenSelector = this.hiddenSelector;\n const items = this.data?._embedded['fx:transaction_template']._embedded['fx:items'] ?? [];\n const label = hiddenSelector.matches('items:actions', true) ? '' : this.__renderItemsActions();\n\n return html`\n <div data-testid=\"items\">\n ${this.renderTemplateOrSlot('items:before')}\n <x-group frame>\n <div slot=\"header\">${label}</div>\n <div class=\"divide-y divide-contrast-10 pl-s\">${items.map(this.__renderItemsItem)}</div>\n </x-group>\n ${this.renderTemplateOrSlot('items:after')}\n </div>\n `;\n };\n\n private readonly __renderEndDate = () => {\n const { disabledSelector, lang, ns } = this;\n const formHiddenSelector = this.hiddenSelector.zoom('end-date:form').toString();\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('end-date:before')}\n\n <foxy-form-dialog\n readonlycontrols=${this.readonlySelector.zoom('end-date:form').toString()}\n disabledcontrols=${disabledSelector.zoom('end-date:form').toString()}\n hiddencontrols=\"save-button ${formHiddenSelector}\"\n data-testid=\"cancellation-form\"\n parent=${this.parent}\n header=\"end_subscription\"\n alert\n form=\"foxy-cancellation-form\"\n href=${this.href}\n lang=${lang}\n id=\"end-date-form\"\n ns=${ns}\n .templates=${this.getNestedTemplates('end-date:form')}\n >\n </foxy-form-dialog>\n\n <vaadin-button\n data-testid=\"end-date\"\n theme=\"error\"\n class=\"w-full\"\n ?disabled=${!this.data || disabledSelector.matches('end-date', true)}\n @click=${(evt: Event) => {\n const form = this.renderRoot.querySelector('#end-date-form') as FormDialog;\n form.show(evt.currentTarget as ButtonElement);\n }}\n >\n <foxy-i18n key=\"end_subscription\" ns=${ns} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('end-date:after')}\n </div>\n `;\n };\n\n private readonly __checkNextTransactionDateAvailability = (date: Date) => {\n const { settings, data: subscription } = this;\n\n if (settings && subscription) {\n const value = serializeDate(date);\n return isNextTransactionDate({ value, settings, subscription });\n }\n\n return date.getTime() >= Date.now();\n };\n\n private readonly __renderNextTransactionDate = () => {\n const { data, lang, ns } = this;\n const isActive = !!data?.is_active;\n\n return html`\n <div data-testid=\"next-transaction-date\">\n ${this.renderTemplateOrSlot('next-transaction-date:before')}\n\n <x-group frame>\n <foxy-i18n key=\"next_transaction_date\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n <foxy-internal-calendar\n start=${ifDefined(data?.next_transaction_date.substr(0, 10))}\n value=${ifDefined(data?.next_transaction_date)}\n lang=${lang}\n ?readonly=${!isActive || this.readonlySelector.matches('next-transaction-date', true)}\n ?disabled=${!data || this.disabledSelector.matches('next-transaction-date', true)}\n .checkAvailability=${this.__checkNextTransactionDateAvailability}\n @change=${(evt: Event) => {\n const target = evt.target as InternalCalendar;\n this.edit({ next_transaction_date: target.value });\n }}\n >\n </foxy-internal-calendar>\n </x-group>\n\n ${this.renderTemplateOrSlot('next-transaction-date:after')}\n </div>\n `;\n };\n\n private readonly __renderFrequencyAsDropdown = () => {\n const { data } = this;\n const active = !!data?.is_active;\n const items = this.__frequencies.map(v => ({\n label: this.t(v === '.5m' ? 'twice_a_month' : 'frequency', parseFrequency(v)),\n value: v,\n }));\n\n return html`\n <vaadin-combo-box\n item-value-path=\"value\"\n item-label-path=\"label\"\n data-testid=\"frequency\"\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!active || this.readonlySelector.matches('frequency', true))}\n class=\"w-full\"\n label=${this.t('frequency_label').toString()}\n value=${ifDefined(this.form.frequency)}\n .items=${items}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n </vaadin-combo-box>\n `;\n };\n\n private readonly __renderFrequencyAsRadioList = () => {\n const { data, lang, ns } = this;\n\n return html`\n <x-group frame>\n <foxy-i18n key=\"frequency_label\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n\n <x-choice\n default-custom-value=\"1d\"\n data-testid=\"frequency\"\n type=\"frequency\"\n ns=${SubscriptionForm.defaultNS}\n ?custom=${this.settings === null}\n .items=${this.__frequencies}\n .value=${this.form.frequency ?? null}\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!data.is_active || this.readonlySelector.matches('frequency', true))}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n ${this.__frequencies.map(\n frequency => html`\n <foxy-i18n\n options=${JSON.stringify(parseFrequency(frequency))}\n slot=\"${frequency}-label\"\n lang=${lang}\n key=${frequency === '.5m' ? 'twice_a_month' : 'frequency'}\n ns=${ns}\n >\n </foxy-i18n>\n `\n )}\n </x-choice>\n </x-group>\n `;\n };\n\n private readonly __renderFrequency = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('frequency:before')}\n ${this.settings && this.__frequencies.length > 4\n ? this.__renderFrequencyAsDropdown()\n : this.__renderFrequencyAsRadioList()}\n ${this.renderTemplateOrSlot('frequency:after')}\n </div>\n `;\n };\n\n private readonly __transactionsTableColumns = [\n {\n cell(ctx: CellContext<TransactionsTableData>) {\n const colors: Record<string, string> = {\n declined: 'text-error',\n rejected: 'text-error',\n };\n\n const status = TransactionsTable.statusColumn.cell!(ctx);\n const price = TransactionsTable.priceColumn.cell!(ctx);\n const color = colors[ctx.data.status] ?? 'text-body';\n\n return ctx.html`\n <span class=\"sr-only\">${status}</span>\n <span class=\"${color} text-s\">${price}</span>\n `;\n },\n },\n { cell: TransactionsTable.idColumn.cell, hideBelow: 'sm' },\n { cell: TransactionsTable.dateColumn.cell },\n { cell: TransactionsTable.receiptColumn.cell },\n ];\n\n private readonly __renderTransactionsPage = ({ html, ...ctx }: PageRendererContext) => {\n return html`\n <foxy-table\n group=${ctx.group}\n lang=${ctx.lang}\n href=${ctx.href}\n ns=\"${ctx.ns} ${customElements.get('foxy-transactions-table')?.defaultNS ?? ''}\"\n .columns=${this.__transactionsTableColumns}\n >\n </foxy-table>\n `;\n };\n\n private readonly __renderTransactions = () => {\n const { lang, ns } = this;\n\n return html`\n <div data-testid=\"transactions\">\n ${this.renderTemplateOrSlot('transactions:before')}\n\n <x-group frame>\n <foxy-i18n lang=${lang} slot=\"header\" key=\"transaction_plural\" ns=${ns}></foxy-i18n>\n <foxy-collection-pages\n group=${this.group}\n class=\"block divide-y divide-contrast-10 px-m\"\n first=${this.data?._links['fx:transactions'].href ?? ''}\n lang=${lang}\n ns=${ns}\n .page=${this.__renderTransactionsPage}\n >\n </foxy-collection-pages>\n </x-group>\n\n ${this.renderTemplateOrSlot('transactions:after')}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <div\n data-testid=\"wrapper\"\n aria-busy=${isBusy}\n aria-live=\"polite\"\n class=\"relative space-y-l text-body font-lumo text-m leading-m\"\n >\n ${this.hiddenSelector.matches('header', true) ? '' : this.__renderHeader()}\n ${this.hiddenSelector.matches('items', true) ? '' : this.__renderItems()}\n ${this.hiddenSelector.matches('end-date', true) ? '' : this.__renderEndDate()}\n ${this.__isNextTransactionDateVisible ? this.__renderNextTransactionDate() : ''}\n ${this.__isFrequencyVisible ? this.__renderFrequency() : ''}\n ${this.hiddenSelector.matches('transactions', true) ? '' : this.__renderTransactions()}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !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' : isBusy ? 'busy' : 'empty'}\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private get __isNextTransactionDateVisible() {\n if (this.hiddenSelector.matches('next-transaction-date', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now()) return false;\n if (this.data.is_active === false) return false;\n if (this.settings === null) return true;\n\n const rules = this.settings.subscriptions.allow_next_date_modification;\n return !!getNextTransactionDateConstraints(this.data, rules);\n }\n\n private get __isFrequencyVisible() {\n if (this.hiddenSelector.matches('frequency', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now()) return false;\n if (this.data.is_active === false) return false;\n if (this.settings === null) return true;\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return !allowedFrequencies.next().done;\n }\n\n private get __frequencies() {\n if (!this.settings || !this.data) return ['.5m', '1m', '1y'];\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return Array.from(allowedFrequencies);\n }\n}\n"]}
|
|
@@ -8,15 +8,13 @@ declare const Base: typeof NucleonElement & import("lit-element").Constructor<im
|
|
|
8
8
|
defaultNS: string;
|
|
9
9
|
} & {
|
|
10
10
|
styles: import("lit-element").CSSResultArray;
|
|
11
|
-
} & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/src/types").ScopedElementsHost>;
|
|
11
|
+
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost> & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/src/types").ScopedElementsHost>;
|
|
12
12
|
export declare class CountriesList extends Base<Resource<Rels.Countries>> {
|
|
13
13
|
static get scopedElements(): ScopedElementsMap;
|
|
14
14
|
static get properties(): PropertyDeclarations;
|
|
15
15
|
countries: Record<string, '*' | string[]>;
|
|
16
|
-
disabled: boolean;
|
|
17
|
-
readonly: boolean;
|
|
18
16
|
regions: string;
|
|
19
|
-
|
|
17
|
+
private __newCountry;
|
|
20
18
|
render(): TemplateResult;
|
|
21
19
|
private __addCountry;
|
|
22
20
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
2
2
|
import { html } from 'lit-html';
|
|
3
|
+
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
3
4
|
import { CountryCard } from "./CountryCard.js";
|
|
4
5
|
import { NucleonElement } from "../NucleonElement/NucleonElement.js";
|
|
5
6
|
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
6
7
|
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
7
8
|
import { classMap } from "../../../utils/class-map.js";
|
|
8
9
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
9
|
-
const Base = ScopedElementsMixin(ThemeableMixin(TranslatableMixin(NucleonElement)));
|
|
10
|
+
const Base = ScopedElementsMixin(ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement))));
|
|
10
11
|
export class CountriesList extends Base {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
14
|
this.countries = {};
|
|
14
|
-
this.disabled = false;
|
|
15
|
-
this.readonly = false;
|
|
16
15
|
this.regions = '';
|
|
17
|
-
this.
|
|
16
|
+
this.__newCountry = '';
|
|
18
17
|
}
|
|
19
18
|
static get scopedElements() {
|
|
20
19
|
return {
|
|
@@ -25,18 +24,16 @@ export class CountriesList extends Base {
|
|
|
25
24
|
static get properties() {
|
|
26
25
|
return {
|
|
27
26
|
...super.properties,
|
|
27
|
+
__newCountry: { attribute: false },
|
|
28
28
|
countries: { type: Object },
|
|
29
|
-
disabled: { type: Boolean },
|
|
30
|
-
readonly: { type: Boolean },
|
|
31
29
|
regions: { type: String },
|
|
32
|
-
country: { type: String },
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
32
|
render() {
|
|
36
33
|
var _a, _b;
|
|
37
34
|
return html `
|
|
38
35
|
<div>
|
|
39
|
-
<div class="space-y-s">
|
|
36
|
+
<div class="space-y-s" data-testid="countries">
|
|
40
37
|
${Object.entries(this.countries).map(([country, regions]) => {
|
|
41
38
|
var _a, _b;
|
|
42
39
|
let regionsLink;
|
|
@@ -77,34 +74,45 @@ export class CountriesList extends Base {
|
|
|
77
74
|
})}
|
|
78
75
|
|
|
79
76
|
<div
|
|
80
|
-
|
|
77
|
+
data-testid="new-country"
|
|
78
|
+
class=${classMap({
|
|
79
|
+
'h-m flex items-center rounded transition-colors': true,
|
|
80
|
+
'border border-contrast-10 ring-primary-50': true,
|
|
81
|
+
'hover-border-contrast-40': !this.disabled,
|
|
82
|
+
'focus-within-ring-1 focus-within-border-primary-50': !this.disabled,
|
|
83
|
+
'flex': !this.readonly,
|
|
84
|
+
'hidden': this.readonly,
|
|
85
|
+
})}
|
|
81
86
|
>
|
|
82
87
|
<input
|
|
83
88
|
placeholder=${this.t('add_country')}
|
|
84
89
|
class="w-full bg-transparent appearance-none h-m text-s px-m focus-outline-none"
|
|
85
90
|
list="list"
|
|
86
|
-
.value=${this.
|
|
91
|
+
.value=${this.__newCountry}
|
|
92
|
+
?disabled=${this.disabled}
|
|
93
|
+
?readonly=${this.readonly}
|
|
87
94
|
@keydown=${(evt) => {
|
|
88
|
-
if (evt.key === 'Enter' && this.
|
|
95
|
+
if (evt.key === 'Enter' && this.__newCountry)
|
|
89
96
|
this.__addCountry();
|
|
90
97
|
}}
|
|
91
98
|
@input=${(evt) => {
|
|
92
99
|
const target = evt.currentTarget;
|
|
93
|
-
this.
|
|
100
|
+
this.__newCountry = target.value;
|
|
94
101
|
}}
|
|
95
102
|
/>
|
|
96
103
|
|
|
97
104
|
<button
|
|
105
|
+
aria-label=${this.t('create')}
|
|
98
106
|
class=${classMap({
|
|
99
107
|
'mr-xs flex-shrink-0': true,
|
|
100
108
|
'flex items-center justify-center rounded-full transition-colors': true,
|
|
101
|
-
'bg-contrast-5 text-disabled cursor-default': !this.
|
|
102
|
-
'bg-success-10 text-success cursor-pointer': !!this.
|
|
103
|
-
'hover-bg-success hover-text-success-contrast': !!this.
|
|
104
|
-
'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.
|
|
109
|
+
'bg-contrast-5 text-disabled cursor-default': !this.__newCountry,
|
|
110
|
+
'bg-success-10 text-success cursor-pointer': !!this.__newCountry,
|
|
111
|
+
'hover-bg-success hover-text-success-contrast': !!this.__newCountry,
|
|
112
|
+
'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newCountry,
|
|
105
113
|
})}
|
|
106
114
|
style="width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)"
|
|
107
|
-
?disabled=${!this.
|
|
115
|
+
?disabled=${!this.__newCountry || this.disabled}
|
|
108
116
|
@click=${this.__addCountry}
|
|
109
117
|
>
|
|
110
118
|
<iron-icon icon="icons:add" class="icon-inline text-m"></iron-icon>
|
|
@@ -113,16 +121,16 @@ export class CountriesList extends Base {
|
|
|
113
121
|
</div>
|
|
114
122
|
|
|
115
123
|
<datalist id="list">
|
|
116
|
-
${Object.
|
|
117
|
-
return html `<option value=${
|
|
124
|
+
${Object.entries((_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : {}).map(([code, country]) => {
|
|
125
|
+
return html `<option value=${code}>${country.default}</option>`;
|
|
118
126
|
})}
|
|
119
127
|
</datalist>
|
|
120
128
|
</div>
|
|
121
129
|
`;
|
|
122
130
|
}
|
|
123
131
|
__addCountry() {
|
|
124
|
-
this.countries = { ...this.countries, [this.
|
|
125
|
-
this.
|
|
132
|
+
this.countries = { ...this.countries, [this.__newCountry]: '*' };
|
|
133
|
+
this.__newCountry = '';
|
|
126
134
|
this.dispatchEvent(new CustomEvent('update:countries'));
|
|
127
135
|
}
|
|
128
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountriesList.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountriesList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,WAAW,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BACrB,QAAQ,CAAC;YACf,qBAAqB,EAAE,IAAI;YAC3B,iEAAiE,EAAE,IAAI;YACvE,4CAA4C,EAAE,CAAC,IAAI,CAAC,YAAY;YAChE,2CAA2C,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY;YAChE,8CAA8C,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY;YACnE,4DAA4D,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY;SAClF,CAAC;;0BAEU,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,QAAQ;uBACtC,IAAI,CAAC,YAAY;;;;;;;;YAQ5B,MAAM,CAAC,OAAO,aAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE;YAChE,OAAO,IAAI,CAAA,iBAAiB,IAAI,IAAI,OAAO,CAAC,OAAO,WAAW,CAAC;QACjE,CAAC,CAAC;;;KAGP,CAAC;IACJ,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { CountryCard } from './CountryCard';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst Base = ScopedElementsMixin(\n ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)))\n);\n\nexport class CountriesList extends Base<Resource<Rels.Countries>> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'x-country-card': CountryCard,\n 'iron-icon': customElements.get('iron-icon'),\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newCountry: { attribute: false },\n countries: { type: Object },\n regions: { type: String },\n };\n }\n\n countries: Record<string, '*' | string[]> = {};\n\n regions = '';\n\n private __newCountry = '';\n\n render(): TemplateResult {\n return html`\n <div>\n <div class=\"space-y-s\" data-testid=\"countries\">\n ${Object.entries(this.countries).map(([country, regions]) => {\n let regionsLink: string;\n\n try {\n const url = new URL(this.regions);\n url.searchParams.set('country_code', country);\n regionsLink = url.toString();\n } catch {\n regionsLink = '';\n }\n\n return html`\n <x-country-card\n regions=${JSON.stringify(regions === '*' ? [] : regions)}\n code=${country}\n name=${ifDefined(this.data?.values[country]?.default)}\n href=${regionsLink}\n lang=${this.lang}\n ns=${this.ns}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @update:regions=${(evt: CustomEvent) => {\n const newCountries = { ...this.countries };\n const newRegions = (evt.currentTarget as CountryCard).regions;\n\n newCountries[country] = newRegions.length ? newRegions : '*';\n this.countries = newCountries;\n\n this.dispatchEvent(new CustomEvent('update:countries'));\n }}\n @delete=${() => {\n const newCountries = { ...this.countries };\n delete newCountries[country];\n this.countries = newCountries;\n\n this.dispatchEvent(new CustomEvent('update:countries'));\n }}\n >\n </x-country-card>\n `;\n })}\n\n <div\n data-testid=\"new-country\"\n class=${classMap({\n 'h-m flex items-center rounded transition-colors': true,\n 'border border-contrast-10 ring-primary-50': true,\n 'hover-border-contrast-40': !this.disabled,\n 'focus-within-ring-1 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <input\n placeholder=${this.t('add_country')}\n class=\"w-full bg-transparent appearance-none h-m text-s px-m focus-outline-none\"\n list=\"list\"\n .value=${this.__newCountry}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.__newCountry) this.__addCountry();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.__newCountry = target.value;\n }}\n />\n\n <button\n aria-label=${this.t('create')}\n class=${classMap({\n 'mr-xs flex-shrink-0': true,\n 'flex items-center justify-center rounded-full transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': !this.__newCountry,\n 'bg-success-10 text-success cursor-pointer': !!this.__newCountry,\n 'hover-bg-success hover-text-success-contrast': !!this.__newCountry,\n 'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newCountry,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${!this.__newCountry || this.disabled}\n @click=${this.__addCountry}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n </div>\n\n <datalist id=\"list\">\n ${Object.entries(this.data?.values ?? {}).map(([code, country]) => {\n return html`<option value=${code}>${country.default}</option>`;\n })}\n </datalist>\n </div>\n `;\n }\n\n private __addCountry() {\n this.countries = { ...this.countries, [this.__newCountry]: '*' };\n this.__newCountry = '';\n this.dispatchEvent(new CustomEvent('update:countries'));\n }\n}\n"]}
|
|
@@ -11,9 +11,9 @@ declare const Base: typeof NucleonElement & import("lit-element").Constructor<im
|
|
|
11
11
|
export declare class CountryCard extends Base<Resource<Rels.Regions>> {
|
|
12
12
|
static get properties(): PropertyDeclarations;
|
|
13
13
|
regions: string[];
|
|
14
|
-
region: string;
|
|
15
14
|
name: string;
|
|
16
15
|
code: string;
|
|
16
|
+
private __newRegion;
|
|
17
17
|
render(): TemplateResult;
|
|
18
18
|
private __addRegion;
|
|
19
19
|
}
|
|
@@ -9,15 +9,15 @@ export class CountryCard extends Base {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
this.regions = [];
|
|
12
|
-
this.region = '';
|
|
13
12
|
this.name = '';
|
|
14
13
|
this.code = '';
|
|
14
|
+
this.__newRegion = '';
|
|
15
15
|
}
|
|
16
16
|
static get properties() {
|
|
17
17
|
return {
|
|
18
18
|
...super.properties,
|
|
19
|
+
__newRegion: { attribute: false },
|
|
19
20
|
regions: { type: Array },
|
|
20
|
-
region: { type: String },
|
|
21
21
|
name: { type: String },
|
|
22
22
|
code: { type: String },
|
|
23
23
|
};
|
|
@@ -25,23 +25,40 @@ export class CountryCard extends Base {
|
|
|
25
25
|
render() {
|
|
26
26
|
var _a, _b;
|
|
27
27
|
return html `
|
|
28
|
-
<div
|
|
29
|
-
|
|
28
|
+
<div
|
|
29
|
+
class=${classMap({
|
|
30
|
+
'border border-contrast-10 rounded text-s': true,
|
|
31
|
+
'text-disabled': this.disabled,
|
|
32
|
+
})}
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
data-testid="country"
|
|
36
|
+
class="h-m flex justify-between items-center border-b border-contrast-10"
|
|
37
|
+
>
|
|
30
38
|
<div class="ml-m">
|
|
31
39
|
<span>${this.name || this.code}</span>
|
|
32
40
|
${this.name ? html `<span class="text-secondary">${this.code}</span>` : ''}
|
|
33
41
|
</div>
|
|
34
42
|
|
|
35
43
|
<button
|
|
36
|
-
|
|
44
|
+
aria-label=${this.t('delete')}
|
|
45
|
+
class=${classMap({
|
|
46
|
+
'mr-xs items-center justify-center rounded-full transition-colors': true,
|
|
47
|
+
'hover-bg-error-10 hover-text-error': !this.disabled,
|
|
48
|
+
'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,
|
|
49
|
+
'cursor-default': this.disabled,
|
|
50
|
+
'flex': !this.readonly,
|
|
51
|
+
'hidden': this.readonly,
|
|
52
|
+
})}
|
|
37
53
|
style="width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)"
|
|
54
|
+
?disabled=${this.disabled}
|
|
38
55
|
@click=${() => this.dispatchEvent(new CustomEvent('delete'))}
|
|
39
56
|
>
|
|
40
57
|
<iron-icon icon="icons:close" class="icon-inline text-m"></iron-icon>
|
|
41
58
|
</button>
|
|
42
59
|
</div>
|
|
43
60
|
|
|
44
|
-
<div class="flex flex-wrap p-xs">
|
|
61
|
+
<div data-testid="regions" class="flex flex-wrap p-xs">
|
|
45
62
|
${this.regions.map(region => {
|
|
46
63
|
var _a, _b;
|
|
47
64
|
const name = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.values[region]) === null || _b === void 0 ? void 0 : _b.default;
|
|
@@ -57,8 +74,17 @@ export class CountryCard extends Base {
|
|
|
57
74
|
</span>
|
|
58
75
|
|
|
59
76
|
<button
|
|
60
|
-
|
|
77
|
+
aria-label=${this.t('delete')}
|
|
78
|
+
class=${classMap({
|
|
79
|
+
'items-center justify-center rounded-full transition-colors': true,
|
|
80
|
+
'hover-bg-error-10 hover-text-error': !this.disabled,
|
|
81
|
+
'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,
|
|
82
|
+
'cursor-default': this.disabled,
|
|
83
|
+
'flex': !this.readonly,
|
|
84
|
+
'hidden': this.readonly,
|
|
85
|
+
})}
|
|
61
86
|
style="width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)"
|
|
87
|
+
?disabled=${this.disabled}
|
|
62
88
|
@click=${() => {
|
|
63
89
|
this.regions = this.regions.filter(value => value !== region);
|
|
64
90
|
this.dispatchEvent(new CustomEvent('update:regions'));
|
|
@@ -71,22 +97,31 @@ export class CountryCard extends Base {
|
|
|
71
97
|
})}
|
|
72
98
|
|
|
73
99
|
<div
|
|
74
|
-
|
|
100
|
+
data-testid="new-region"
|
|
75
101
|
style="border-radius: var(--lumo-size-s)"
|
|
102
|
+
class=${classMap({
|
|
103
|
+
'h-s m-xs items-center transition-colors border border-contrast-10': true,
|
|
104
|
+
'hover-border-contrast-40': !this.disabled,
|
|
105
|
+
'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50': !this.disabled,
|
|
106
|
+
'flex': !this.readonly,
|
|
107
|
+
'hidden': this.readonly,
|
|
108
|
+
})}
|
|
76
109
|
>
|
|
77
110
|
<input
|
|
78
111
|
placeholder=${this.t('add_region')}
|
|
79
112
|
class="bg-transparent appearance-none h-s text-s px-s focus-outline-none"
|
|
80
113
|
style="width: 8rem"
|
|
81
114
|
list="list"
|
|
82
|
-
.value=${this.
|
|
115
|
+
.value=${this.__newRegion}
|
|
116
|
+
?disabled=${this.disabled}
|
|
117
|
+
?readonly=${this.readonly}
|
|
83
118
|
@keydown=${(evt) => {
|
|
84
|
-
if (evt.key === 'Enter' && this.
|
|
119
|
+
if (evt.key === 'Enter' && this.__newRegion)
|
|
85
120
|
this.__addRegion();
|
|
86
121
|
}}
|
|
87
122
|
@input=${(evt) => {
|
|
88
123
|
const target = evt.currentTarget;
|
|
89
|
-
this.
|
|
124
|
+
this.__newRegion = target.value;
|
|
90
125
|
}}
|
|
91
126
|
/>
|
|
92
127
|
|
|
@@ -95,12 +130,12 @@ export class CountryCard extends Base {
|
|
|
95
130
|
class=${classMap({
|
|
96
131
|
'flex-shrink-0': true,
|
|
97
132
|
'flex items-center justify-center rounded-full transition-colors': true,
|
|
98
|
-
'bg-contrast-5 text-disabled cursor-default': !this.
|
|
99
|
-
'bg-success-10 text-success cursor-pointer': !!this.
|
|
100
|
-
'hover-bg-success hover-text-success-contrast': !!this.
|
|
101
|
-
'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.
|
|
133
|
+
'bg-contrast-5 text-disabled cursor-default': !this.__newRegion,
|
|
134
|
+
'bg-success-10 text-success cursor-pointer': !!this.__newRegion,
|
|
135
|
+
'hover-bg-success hover-text-success-contrast': !!this.__newRegion,
|
|
136
|
+
'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newRegion,
|
|
102
137
|
})}
|
|
103
|
-
?disabled=${!this.
|
|
138
|
+
?disabled=${this.disabled || !this.__newRegion}
|
|
104
139
|
@click=${this.__addRegion}
|
|
105
140
|
>
|
|
106
141
|
<iron-icon icon="icons:add" class="icon-inline text-m"></iron-icon>
|
|
@@ -117,8 +152,8 @@ export class CountryCard extends Base {
|
|
|
117
152
|
`;
|
|
118
153
|
}
|
|
119
154
|
__addRegion() {
|
|
120
|
-
this.regions = [...new Set([...this.regions, this.
|
|
121
|
-
this.
|
|
155
|
+
this.regions = [...new Set([...this.regions, this.__newRegion])];
|
|
156
|
+
this.__newRegion = '';
|
|
122
157
|
this.dispatchEvent(new CustomEvent('update:regions'));
|
|
123
158
|
}
|
|
124
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountryCard.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountryCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAIlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,IAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAElF,MAAM,OAAO,WAAY,SAAQ,IAA4B;IAA7D;;QAWE,YAAO,GAAa,EAAE,CAAC;QAEvB,WAAM,GAAG,EAAE,CAAC;QAEZ,SAAI,GAAG,EAAE,CAAC;QAEV,SAAI,GAAG,EAAE,CAAC;IAoGZ,CAAC;IApHC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YAC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,IAAI,CAAC,MAAM;gBAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7D,CAAC;uBACQ,CAAC,GAAe,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,aAAiC,CAAC;YACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC7B,CAAC;;;;;sBAKO,QAAQ,CAAC;YACf,eAAe,EAAE,IAAI;YACrB,iEAAiE,EAAE,IAAI;YACvE,4CAA4C,EAAE,CAAC,IAAI,CAAC,MAAM;YAC1D,2CAA2C,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;YAC1D,8CAA8C,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;YAC7D,4DAA4D,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;SAC5E,CAAC;0BACU,CAAC,IAAI,CAAC,MAAM;uBACf,IAAI,CAAC,WAAW;;;;;;;cAOzB,MAAM,CAAC,MAAM,aAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACpD,OAAO,IAAI,CAAA,iBAAiB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,WAAW,CAAC;QACvE,CAAC,CAAC;;;;KAIT,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)));\n\nexport class CountryCard extends Base<Resource<Rels.Regions>> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n regions: { type: Array },\n region: { type: String },\n name: { type: String },\n code: { type: String },\n };\n }\n\n regions: string[] = [];\n\n region = '';\n\n name = '';\n\n code = '';\n\n render(): TemplateResult {\n return html`\n <div class=\"border border-contrast-10 rounded text-s\">\n <div class=\"h-m flex justify-between items-center border-b border-contrast-10\">\n <div class=\"ml-m\">\n <span>${this.name || this.code}</span>\n ${this.name ? html`<span class=\"text-secondary\">${this.code}</span>` : ''}\n </div>\n\n <button\n class=\"mr-xs flex items-center justify-center rounded-full transition-colors hover-bg-error-10 hover-text-error focus-outline-none focus-ring-2 focus-ring-inset focus-ring-error-50\"\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n @click=${() => this.dispatchEvent(new CustomEvent('delete'))}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <div class=\"flex flex-wrap p-xs\">\n ${this.regions.map(region => {\n const name = this.data?.values[region]?.default;\n const code = region;\n\n return html`\n <div\n class=\"flex items-center border border-contrast-10 h-s m-xs\"\n style=\"border-radius: var(--lumo-size-s)\"\n >\n <span class=\"mx-s\">\n <span>${name || code}</span>\n ${name ? html`<span class=\"text-secondary\">${code}</span>` : ''}\n </span>\n\n <button\n class=\"flex items-center justify-center rounded-full transition-colors hover-bg-error-10 hover-text-error focus-outline-none focus-ring-2 focus-ring-inset focus-ring-error-50\"\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n @click=${() => {\n this.regions = this.regions.filter(value => value !== region);\n this.dispatchEvent(new CustomEvent('update:regions'));\n }}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n `;\n })}\n\n <div\n class=\"h-s m-xs flex items-center transition-colors border border-contrast-10 hover-border-contrast-40 focus-within-ring-1 focus-within-ring-primary-50 focus-within-border-primary-50\"\n style=\"border-radius: var(--lumo-size-s)\"\n >\n <input\n placeholder=${this.t('add_region')}\n class=\"bg-transparent appearance-none h-s text-s px-s focus-outline-none\"\n style=\"width: 8rem\"\n list=\"list\"\n .value=${this.region}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.region) this.__addRegion();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.region = target.value;\n }}\n />\n\n <button\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n class=${classMap({\n 'flex-shrink-0': true,\n 'flex items-center justify-center rounded-full transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': !this.region,\n 'bg-success-10 text-success cursor-pointer': !!this.region,\n 'hover-bg-success hover-text-success-contrast': !!this.region,\n 'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.region,\n })}\n ?disabled=${!this.region}\n @click=${this.__addRegion}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <datalist id=\"list\">\n ${Object.values(this.data?.values ?? {}).map(region => {\n return html`<option value=${region.code}>${region.default}</option>`;\n })}\n </datalist>\n </div>\n </div>\n `;\n }\n\n private __addRegion() {\n this.regions = [...new Set([...this.regions, this.region])];\n this.region = '';\n this.dispatchEvent(new CustomEvent('update:regions'));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CountryCard.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateConfigForm/CountryCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,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OAAO,WAAW,CAAC;QACvE,CAAC,CAAC;;;;KAIT,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { PropertyDeclarations } from 'lit-element';\nimport { Rels } from '@foxy.io/sdk/backend';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst Base = ConfigurableMixin(ThemeableMixin(TranslatableMixin(NucleonElement)));\n\nexport class CountryCard extends Base<Resource<Rels.Regions>> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __newRegion: { attribute: false },\n regions: { type: Array },\n name: { type: String },\n code: { type: String },\n };\n }\n\n regions: string[] = [];\n\n name = '';\n\n code = '';\n\n private __newRegion = '';\n\n render(): TemplateResult {\n return html`\n <div\n class=${classMap({\n 'border border-contrast-10 rounded text-s': true,\n 'text-disabled': this.disabled,\n })}\n >\n <div\n data-testid=\"country\"\n class=\"h-m flex justify-between items-center border-b border-contrast-10\"\n >\n <div class=\"ml-m\">\n <span>${this.name || this.code}</span>\n ${this.name ? html`<span class=\"text-secondary\">${this.code}</span>` : ''}\n </div>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'mr-xs items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => this.dispatchEvent(new CustomEvent('delete'))}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <div data-testid=\"regions\" class=\"flex flex-wrap p-xs\">\n ${this.regions.map(region => {\n const name = this.data?.values[region]?.default;\n const code = region;\n\n return html`\n <div\n class=\"flex items-center border border-contrast-10 h-s m-xs\"\n style=\"border-radius: var(--lumo-size-s)\"\n >\n <span class=\"mx-s\">\n <span>${name || code}</span>\n ${name ? html`<span class=\"text-secondary\">${code}</span>` : ''}\n </span>\n\n <button\n aria-label=${this.t('delete')}\n class=${classMap({\n 'items-center justify-center rounded-full transition-colors': true,\n 'hover-bg-error-10 hover-text-error': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': !this.disabled,\n 'cursor-default': this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n ?disabled=${this.disabled}\n @click=${() => {\n this.regions = this.regions.filter(value => value !== region);\n this.dispatchEvent(new CustomEvent('update:regions'));\n }}\n >\n <iron-icon icon=\"icons:close\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n `;\n })}\n\n <div\n data-testid=\"new-region\"\n style=\"border-radius: var(--lumo-size-s)\"\n class=${classMap({\n 'h-s m-xs items-center transition-colors border border-contrast-10': true,\n 'hover-border-contrast-40': !this.disabled,\n 'focus-within-ring-1 ring-primary-50 focus-within-border-primary-50': !this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n })}\n >\n <input\n placeholder=${this.t('add_region')}\n class=\"bg-transparent appearance-none h-s text-s px-s focus-outline-none\"\n style=\"width: 8rem\"\n list=\"list\"\n .value=${this.__newRegion}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter' && this.__newRegion) this.__addRegion();\n }}\n @input=${(evt: InputEvent) => {\n const target = evt.currentTarget as HTMLInputElement;\n this.__newRegion = target.value;\n }}\n />\n\n <button\n style=\"width: calc(var(--lumo-size-s) - 2px); height: calc(var(--lumo-size-s) - 2px)\"\n class=${classMap({\n 'flex-shrink-0': true,\n 'flex items-center justify-center rounded-full transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': !this.__newRegion,\n 'bg-success-10 text-success cursor-pointer': !!this.__newRegion,\n 'hover-bg-success hover-text-success-contrast': !!this.__newRegion,\n 'focus-outline-none focus-ring-2 ring-inset ring-success-50': !!this.__newRegion,\n })}\n ?disabled=${this.disabled || !this.__newRegion}\n @click=${this.__addRegion}\n >\n <iron-icon icon=\"icons:add\" class=\"icon-inline text-m\"></iron-icon>\n </button>\n </div>\n\n <datalist id=\"list\">\n ${Object.values(this.data?.values ?? {}).map(region => {\n return html`<option value=${region.code}>${region.default}</option>`;\n })}\n </datalist>\n </div>\n </div>\n `;\n }\n\n private __addRegion() {\n this.regions = [...new Set([...this.regions, this.__newRegion])];\n this.__newRegion = '';\n this.dispatchEvent(new CustomEvent('update:regions'));\n }\n}\n"]}
|