@foxy.io/elements 1.14.0-beta.1 → 1.14.0-beta.5
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/README.md +1 -1
- 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-api.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 +10 -10
- package/dist/cdn/foxy-customer-portal.js +2 -2
- package/dist/cdn/foxy-customer.js +1 -1
- 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 -0
- 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-nucleon-element.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 +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +2 -2
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +26 -9
- 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 +14 -0
- 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-d4dad105.js → shared-00563cb0.js} +1 -1
- package/dist/cdn/shared-0ced76a0.js +358 -0
- package/dist/cdn/{shared-151ca103.js → shared-10bdb6b9.js} +1 -1
- package/dist/cdn/{shared-99f45065.js → shared-1469c1c4.js} +1 -1
- package/dist/cdn/shared-166c44ae.js +264 -0
- package/dist/cdn/{shared-f4119f12.js → shared-16f72e27.js} +1 -1
- package/dist/cdn/shared-1761daef.js +15 -0
- package/dist/cdn/{shared-e057788f.js → shared-1b7e65e4.js} +1 -1
- package/dist/cdn/{shared-5fedf5e4.js → shared-200f613b.js} +2 -2
- package/dist/cdn/{shared-6783c996.js → shared-2174bcd4.js} +1 -1
- package/dist/cdn/{shared-4059f633.js → shared-218ba06e.js} +1 -1
- package/dist/cdn/{shared-e9920617.js → shared-34b2c1e2.js} +1 -1
- package/dist/cdn/shared-396320f9.js +314 -0
- package/dist/cdn/{shared-566252ac.js → shared-3d868b17.js} +1 -1
- package/dist/cdn/{shared-cf248335.js → shared-44cfc617.js} +1 -1
- package/dist/cdn/{shared-45d647e4.js → shared-46ee137f.js} +1 -1
- package/dist/cdn/shared-4a52d9b5.js +1 -0
- package/dist/cdn/{shared-f0199313.js → shared-593f7e2c.js} +1 -1
- package/dist/cdn/shared-59e44f29.js +1 -0
- package/dist/cdn/{shared-cd700eac.js → shared-60126eee.js} +1 -1
- package/dist/cdn/{shared-dbbe03f9.js → shared-614e1a4e.js} +1 -1
- package/dist/cdn/{shared-17968c53.js → shared-63eaded9.js} +3 -3
- package/dist/cdn/shared-6b7602c7.js +1 -0
- package/dist/cdn/{shared-98ee7fad.js → shared-6d45a07b.js} +1 -1
- package/dist/cdn/shared-75ce6e43.js +1 -0
- package/dist/cdn/shared-782bf922.js +1 -0
- package/dist/cdn/{shared-5d286626.js → shared-7a39a41f.js} +1 -1
- package/dist/cdn/{shared-35415106.js → shared-87190eae.js} +1 -1
- package/dist/cdn/{shared-84fa75d9.js → shared-9221e6b2.js} +1 -1
- package/dist/cdn/{shared-2860a3d3.js → shared-94b0ae99.js} +2 -2
- package/dist/cdn/shared-9d779f46.js +1 -0
- package/dist/cdn/shared-a46edf4b.js +1 -0
- package/dist/cdn/{shared-54702b33.js → shared-b0f0e8b5.js} +1 -1
- package/dist/cdn/{shared-ed4ed7a5.js → shared-b710881a.js} +2 -2
- package/dist/cdn/{shared-3ae39e52.js → shared-bb824ab4.js} +3 -3
- package/dist/cdn/shared-d94ffc2b.js +1 -0
- package/dist/cdn/shared-df573cea.js +12 -0
- package/dist/cdn/{shared-e5de8675.js → shared-e7f8ffe9.js} +1 -1
- package/dist/cdn/{shared-54c485d2.js → shared-ec861f31.js} +21 -21
- package/dist/cdn/{shared-e0248713.js → shared-f0a83bd6.js} +1 -1
- package/dist/cdn/{shared-f2a4fd27.js → shared-fb90e05c.js} +1 -1
- package/dist/cdn/{shared-747b0842.js → shared-ff79f3f9.js} +1 -1
- package/dist/cdn/translations/shared/en.json +56 -3
- package/dist/elements/private/Choice/Choice.js +3 -3
- package/dist/elements/private/Choice/Choice.js.map +1 -1
- package/dist/elements/private/Group/Group.js +1 -1
- package/dist/elements/private/Group/Group.js.map +1 -1
- package/dist/elements/private/I18N/I18N.js +1 -1
- package/dist/elements/private/I18N/I18N.js.map +1 -1
- package/dist/elements/public/AddressForm/AddressForm.js +8 -4
- package/dist/elements/public/AddressForm/AddressForm.js.map +1 -1
- package/dist/elements/public/AttributeForm/AttributeForm.js +8 -4
- package/dist/elements/public/AttributeForm/AttributeForm.js.map +1 -1
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.js +8 -4
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.js.map +1 -1
- package/dist/elements/public/CustomerForm/CustomerForm.js +8 -4
- package/dist/elements/public/CustomerForm/CustomerForm.js.map +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.d.ts +24 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +311 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/index.d.ts +9 -0
- package/dist/elements/public/EmailTemplateForm/index.js +11 -0
- package/dist/elements/public/EmailTemplateForm/index.js.map +1 -0
- package/dist/elements/public/EmailTemplateForm/types.d.ts +3 -0
- package/dist/elements/public/EmailTemplateForm/types.js +2 -0
- package/dist/elements/public/EmailTemplateForm/types.js.map +1 -0
- package/dist/elements/public/ItemsForm/ItemsForm.js +2 -2
- package/dist/elements/public/ItemsForm/ItemsForm.js.map +1 -1
- package/dist/elements/public/NucleonElement/serveFromCache.js +1 -0
- package/dist/elements/public/NucleonElement/serveFromCache.js.map +1 -1
- package/dist/elements/public/TaxForm/TaxForm.js +8 -4
- package/dist/elements/public/TaxForm/TaxForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/CountriesList.d.ts +23 -0
- package/dist/elements/public/TemplateConfigForm/CountriesList.js +129 -0
- package/dist/elements/public/TemplateConfigForm/CountriesList.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/CountryCard.d.ts +20 -0
- package/dist/elements/public/TemplateConfigForm/CountryCard.js +125 -0
- package/dist/elements/public/TemplateConfigForm/CountryCard.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.d.ts +29 -0
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +700 -0
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/defaults.d.ts +2 -0
- package/dist/elements/public/TemplateConfigForm/defaults.js +95 -0
- package/dist/elements/public/TemplateConfigForm/defaults.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/index.d.ts +9 -0
- package/dist/elements/public/TemplateConfigForm/index.js +11 -0
- package/dist/elements/public/TemplateConfigForm/index.js.map +1 -0
- package/dist/elements/public/TemplateConfigForm/types.d.ts +116 -0
- package/dist/elements/public/TemplateConfigForm/types.js +2 -0
- package/dist/elements/public/TemplateConfigForm/types.js.map +1 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js +10 -6
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
- package/dist/elements/public/index.d.ts +2 -0
- package/dist/elements/public/index.defined.d.ts +2 -0
- package/dist/elements/public/index.defined.js +2 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +2 -0
- package/dist/elements/public/index.js.map +1 -1
- package/dist/mixins/themeable.js +86 -12
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +2 -7
- package/dist/cdn/shared-35502e88.js +0 -1
- package/dist/cdn/shared-50744508.js +0 -15
- package/dist/cdn/shared-5388f705.js +0 -1
- package/dist/cdn/shared-7f588649.js +0 -1
- package/dist/cdn/shared-9467cb31.js +0 -572
- package/dist/cdn/shared-b98f88c9.js +0 -369
- package/dist/cdn/shared-c0161e6a.js +0 -1
- package/dist/cdn/shared-dbcffd8e.js +0 -1
- package/dist/cdn/shared-e21a2aac.js +0 -1
- package/dist/cdn/shared-ebbef842.js +0 -1
- package/dist/cdn/shared-fd5b81be.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeForm.js","sourceRoot":"","sources":["../../../../src/elements/public/AttributeForm/AttributeForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AAEnE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAA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AAC,MAAM,CAAC,CAAC,CAAC;QAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC;IAEO,eAAe,CAAC,GAAkB;QACxC,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IAEO,oBAAoB,CAAC,GAAsB;QACjD,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,MAA4B,EAAE,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB,CAAC,GAAU;QACpC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,aAA4B,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB,CAAC,GAAoB;QAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3C,CAAC;;AAhOuB,iCAAmB,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAC","sourcesContent":["import { Choice, Group, PropertyTable } from '../../private/index';\nimport { Data, Templates, TextFieldParams } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport memoize from 'lodash-es/memoize';\n\nconst NS = 'attribute-form';\nconst Base = TranslatableMixin(\n ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(NucleonElement))),\n NS\n);\n\n/**\n * Form element for creating or editing attributes.\n *\n * @slot name:before - **new in v1.4.0**\n * @slot name:after - **new in v1.4.0**\n * @slot value:before - **new in v1.4.0**\n * @slot value:after - **new in v1.4.0**\n * @slot visibility:before - **new in v1.4.0**\n * @slot visibility:after - **new in v1.4.0**\n * @slot timestamps:before - **new in v1.4.0**\n * @slot timestamps:after - **new in v1.4.0**\n * @slot create:before - **new in v1.4.0**\n * @slot create:after - **new in v1.4.0**\n * @slot delete:before - **new in v1.4.0**\n * @slot delete:after - **new in v1.4.0**\n *\n * @element foxy-attribute-form\n * @since 1.2.0\n */\nexport class AttributeForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-property-table': PropertyTable,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-choice': Choice,\n 'x-group': Group,\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ value }) => (value && value.length > 0) || 'value_required',\n ({ value }) => (value && value.length <= 1000) || 'value_too_long',\n ({ name }) => (name && name.length > 0) || 'name_required',\n ({ name }) => (name && name.length <= 500) || 'name_too_long',\n ];\n }\n\n templates: Templates = {};\n\n private static readonly __visibilityOptions = ['private', 'restricted', 'public'] as const;\n\n private readonly __getValidator = memoize((prefix: string) => () => {\n return !this.errors.some(err => err.startsWith(prefix));\n });\n\n private readonly __bindField = memoize((key: keyof Data) => {\n return (evt: CustomEvent) => {\n const target = evt.target as HTMLInputElement;\n this.edit({ [key]: target.value });\n };\n });\n\n private readonly __maybeRenderTextField = ({ field }: TextFieldParams) => {\n const bsid = field.replace(/_/, '-');\n if (this.hiddenSelector.matches(bsid)) return '';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${bsid}:before`)}\n\n <vaadin-text-field\n class=\"w-full\"\n label=${this.t(field).toString()}\n value=${ifDefined(this.form?.[field]?.toString())}\n error-message=${this.__getErrorMessage(field)}\n data-testid=${field}\n .checkValidity=${this.__getValidator(field)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(bsid)}\n ?readonly=${this.readonlySelector.matches(bsid)}\n @input=${this.__bindField(field)}\n @keydown=${this.__handleKeyDown}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${bsid}:after`)}\n </div>\n `;\n };\n\n private readonly __renderVisibility = () => {\n const { disabledSelector, readonlySelector, form, lang, ns } = this;\n const isBusyOrFailed = !this.in('idle');\n const isDisabled = isBusyOrFailed || disabledSelector.matches('visibility', true);\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('visibility:before')}\n\n <x-group frame>\n <foxy-i18n\n data-testid=\"visibility-label\"\n class=${classMap({ 'text-disabled': isDisabled })}\n lang=${lang}\n slot=\"header\"\n key=\"visibility\"\n ns=${ns}\n >\n </foxy-i18n>\n\n <x-choice\n data-testid=\"visibility\"\n lang=${lang}\n ns=${AttributeForm.defaultNS}\n .items=${AttributeForm.__visibilityOptions}\n .value=${(form?.visibility ?? 'private') as any}\n ?disabled=${isBusyOrFailed || disabledSelector.matches('visibility', true)}\n ?readonly=${readonlySelector.matches('visibility', true)}\n @change=${this.__handleChoiceChange}\n >\n <foxy-i18n slot=\"private-label\" lang=${lang} key=\"visibility_private\" ns=${ns}>\n </foxy-i18n>\n\n <foxy-i18n slot=\"restricted-label\" lang=${lang} key=\"visibility_restricted\" ns=${ns}>\n </foxy-i18n>\n\n <foxy-i18n ns=${ns} lang=${lang} slot=\"public-label\" key=\"visibility_public\">\n </foxy-i18n>\n </x-choice>\n </x-group>\n\n ${this.renderTemplateOrSlot('visibility:after')}\n </div>\n `;\n };\n\n private readonly __renderTimestamps = () => {\n const items = (['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.t('date', { value: new Date(this.data![field]) }),\n }));\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n <x-property-table .items=${items} data-testid=\"timestamps\"></x-property-table>\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n };\n\n private readonly __renderDelete = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('delete:before')}\n\n <vaadin-button\n class=\"w-full\"\n data-testid=\"delete\"\n theme=\"error primary\"\n ?disabled=${!this.in('idle') || this.disabledSelector.matches('delete', true)}\n @click=${this.__handleDeleteClick}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"delete\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('delete:after')}\n </div>\n `;\n };\n\n private readonly __renderCreate = () => {\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isValid = isTemplateValid || isSnapshotValid;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('create:before')}\n\n <vaadin-button\n data-testid=\"create\"\n class=\"w-full\"\n theme=\"success primary\"\n ?disabled=${!this.in('idle') || !isValid || this.disabledSelector.matches('create', true)}\n @click=${() => this.submit()}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"create\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const { hiddenSelector, data, lang, ns } = this;\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <foxy-internal-confirm-dialog\n data-testid=\"confirm\"\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n @hide=${this.__handleConfirmHide}\n >\n </foxy-internal-confirm-dialog>\n\n <div class=\"relative\" aria-busy=${this.in('busy')} aria-live=\"polite\">\n <div class=\"grid grid-cols-1 gap-l\">\n ${this.__maybeRenderTextField({ field: 'name' })}\n ${this.__maybeRenderTextField({ field: 'value' })}\n ${hiddenSelector.matches('visibility', true) ? '' : this.__renderVisibility()}\n ${hiddenSelector.matches('timestamps', true) || !data ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches('delete', true) || !data ? '' : this.__renderDelete()}\n ${hiddenSelector.matches('create', true) || data ? '' : this.__renderCreate()}\n </div>\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=${lang}\n ns=${ns}\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__bindField.cache.clear?.();\n this.__getValidator.cache.clear?.();\n }\n\n private get __confirmDialog(): InternalConfirmDialog {\n return this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\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')).toString() : '';\n }\n\n private __handleKeyDown(evt: KeyboardEvent) {\n if (evt.key === 'Enter') this.submit();\n }\n\n private __handleChoiceChange(evt: ChoiceChangeEvent) {\n this.edit({ visibility: evt.detail as Data['visibility'] });\n }\n\n private __handleDeleteClick(evt: Event) {\n this.__confirmDialog.show(evt.currentTarget as HTMLElement);\n }\n\n private __handleConfirmHide(evt: DialogHideEvent) {\n if (!evt.detail.cancelled) this.delete();\n }\n}\n"]}
|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QAC7B,MAAA,MAAA,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,KAAK,mDAAK;QACjC,MAAA,MAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAC,KAAK,mDAAK;IACtC,CAAC;IAED,IAAY,eAAe;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAA0B,CAAC;IAC5E,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC;IAEO,eAAe,CAAC,GAAkB;QACxC,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IAEO,oBAAoB,CAAC,GAAsB;QACjD,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,MAA4B,EAAE,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB,CAAC,GAAU;QACpC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,aAA4B,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB,CAAC,GAAoB;QAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3C,CAAC;;AAlOuB,iCAAmB,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAC","sourcesContent":["import { Choice, Group, PropertyTable } from '../../private/index';\nimport { Data, Templates, TextFieldParams } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport memoize from 'lodash-es/memoize';\n\nconst NS = 'attribute-form';\nconst Base = TranslatableMixin(\n ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(NucleonElement))),\n NS\n);\n\n/**\n * Form element for creating or editing attributes.\n *\n * @slot name:before - **new in v1.4.0**\n * @slot name:after - **new in v1.4.0**\n * @slot value:before - **new in v1.4.0**\n * @slot value:after - **new in v1.4.0**\n * @slot visibility:before - **new in v1.4.0**\n * @slot visibility:after - **new in v1.4.0**\n * @slot timestamps:before - **new in v1.4.0**\n * @slot timestamps:after - **new in v1.4.0**\n * @slot create:before - **new in v1.4.0**\n * @slot create:after - **new in v1.4.0**\n * @slot delete:before - **new in v1.4.0**\n * @slot delete:after - **new in v1.4.0**\n *\n * @element foxy-attribute-form\n * @since 1.2.0\n */\nexport class AttributeForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-property-table': PropertyTable,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-choice': Choice,\n 'x-group': Group,\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ value }) => (value && value.length > 0) || 'value_required',\n ({ value }) => (value && value.length <= 1000) || 'value_too_long',\n ({ name }) => (name && name.length > 0) || 'name_required',\n ({ name }) => (name && name.length <= 500) || 'name_too_long',\n ];\n }\n\n templates: Templates = {};\n\n private static readonly __visibilityOptions = ['private', 'restricted', 'public'] as const;\n\n private readonly __getValidator = memoize((prefix: string) => () => {\n return !this.errors.some(err => err.startsWith(prefix));\n });\n\n private readonly __bindField = memoize((key: keyof Data) => {\n return (evt: CustomEvent) => {\n const target = evt.target as HTMLInputElement;\n this.edit({ [key]: target.value });\n };\n });\n\n private readonly __maybeRenderTextField = ({ field }: TextFieldParams) => {\n const bsid = field.replace(/_/, '-');\n if (this.hiddenSelector.matches(bsid)) return '';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${bsid}:before`)}\n\n <vaadin-text-field\n class=\"w-full\"\n label=${this.t(field).toString()}\n value=${ifDefined(this.form?.[field]?.toString())}\n error-message=${this.__getErrorMessage(field)}\n data-testid=${field}\n .checkValidity=${this.__getValidator(field)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(bsid)}\n ?readonly=${this.readonlySelector.matches(bsid)}\n @input=${this.__bindField(field)}\n @keydown=${this.__handleKeyDown}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${bsid}:after`)}\n </div>\n `;\n };\n\n private readonly __renderVisibility = () => {\n const { disabledSelector, readonlySelector, form, lang, ns } = this;\n const isBusyOrFailed = !this.in('idle');\n const isDisabled = isBusyOrFailed || disabledSelector.matches('visibility', true);\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('visibility:before')}\n\n <x-group frame>\n <foxy-i18n\n data-testid=\"visibility-label\"\n class=${classMap({ 'text-disabled': isDisabled })}\n lang=${lang}\n slot=\"header\"\n key=\"visibility\"\n ns=${ns}\n >\n </foxy-i18n>\n\n <x-choice\n data-testid=\"visibility\"\n lang=${lang}\n ns=${AttributeForm.defaultNS}\n .items=${AttributeForm.__visibilityOptions}\n .value=${(form?.visibility ?? 'private') as any}\n ?disabled=${isBusyOrFailed || disabledSelector.matches('visibility', true)}\n ?readonly=${readonlySelector.matches('visibility', true)}\n @change=${this.__handleChoiceChange}\n >\n <foxy-i18n slot=\"private-label\" lang=${lang} key=\"visibility_private\" ns=${ns}>\n </foxy-i18n>\n\n <foxy-i18n slot=\"restricted-label\" lang=${lang} key=\"visibility_restricted\" ns=${ns}>\n </foxy-i18n>\n\n <foxy-i18n ns=${ns} lang=${lang} slot=\"public-label\" key=\"visibility_public\">\n </foxy-i18n>\n </x-choice>\n </x-group>\n\n ${this.renderTemplateOrSlot('visibility:after')}\n </div>\n `;\n };\n\n private readonly __renderTimestamps = () => {\n const items = (['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }));\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n <x-property-table .items=${items} data-testid=\"timestamps\"></x-property-table>\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n };\n\n private readonly __renderDelete = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('delete:before')}\n\n <vaadin-button\n class=\"w-full\"\n data-testid=\"delete\"\n theme=\"error primary\"\n ?disabled=${!this.in('idle') || this.disabledSelector.matches('delete', true)}\n @click=${this.__handleDeleteClick}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"delete\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('delete:after')}\n </div>\n `;\n };\n\n private readonly __renderCreate = () => {\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isValid = isTemplateValid || isSnapshotValid;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('create:before')}\n\n <vaadin-button\n data-testid=\"create\"\n class=\"w-full\"\n theme=\"success primary\"\n ?disabled=${!this.in('idle') || !isValid || this.disabledSelector.matches('create', true)}\n @click=${() => this.submit()}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"create\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const { hiddenSelector, data, lang, ns } = this;\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <foxy-internal-confirm-dialog\n data-testid=\"confirm\"\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n @hide=${this.__handleConfirmHide}\n >\n </foxy-internal-confirm-dialog>\n\n <div class=\"relative\" aria-busy=${this.in('busy')} aria-live=\"polite\">\n <div class=\"grid grid-cols-1 gap-l\">\n ${this.__maybeRenderTextField({ field: 'name' })}\n ${this.__maybeRenderTextField({ field: 'value' })}\n ${hiddenSelector.matches('visibility', true) ? '' : this.__renderVisibility()}\n ${hiddenSelector.matches('timestamps', true) || !data ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches('delete', true) || !data ? '' : this.__renderDelete()}\n ${hiddenSelector.matches('create', true) || data ? '' : this.__renderCreate()}\n </div>\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=${lang}\n ns=${ns}\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__bindField.cache.clear?.();\n this.__getValidator.cache.clear?.();\n }\n\n private get __confirmDialog(): InternalConfirmDialog {\n return this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\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')).toString() : '';\n }\n\n private __handleKeyDown(evt: KeyboardEvent) {\n if (evt.key === 'Enter') this.submit();\n }\n\n private __handleChoiceChange(evt: ChoiceChangeEvent) {\n this.edit({ visibility: evt.detail as Data['visibility'] });\n }\n\n private __handleDeleteClick(evt: Event) {\n this.__confirmDialog.show(evt.currentTarget as HTMLElement);\n }\n\n private __handleConfirmHide(evt: DialogHideEvent) {\n if (!evt.detail.cancelled) this.delete();\n }\n}\n"]}
|
|
@@ -92,10 +92,14 @@ export class CustomFieldForm extends Base {
|
|
|
92
92
|
`;
|
|
93
93
|
};
|
|
94
94
|
this.__renderTimestamps = () => {
|
|
95
|
-
const items = ['date_modified', 'date_created'].map(field =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
const items = ['date_modified', 'date_created'].map(field => {
|
|
96
|
+
var _a;
|
|
97
|
+
return ({
|
|
98
|
+
name: this.t(field),
|
|
99
|
+
value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
|
|
100
|
+
: '',
|
|
101
|
+
});
|
|
102
|
+
});
|
|
99
103
|
return html `
|
|
100
104
|
<div>
|
|
101
105
|
${this.renderTemplateOrSlot('timestamps:before')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomFieldForm/CustomFieldForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAElE,OAAO,EAAE,aAAa,EAAE,+BAA4B;AACpD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C,aAA4B,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB,CAAC,GAAoB;QAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { Data, Templates, TextFieldParams } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { CheckboxElement } from '@vaadin/vaadin-checkbox';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { PropertyTable } from '../../private/index';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport memoize from 'lodash-es/memoize';\n\nconst NS = 'custom-field-form';\nconst Base = TranslatableMixin(\n ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(NucleonElement))),\n NS\n);\n\n/**\n * Form element for creating or editing custom fields.\n *\n * @slot name:before\n * @slot name:after\n * @slot value:before\n * @slot value:after\n * @slot visibility:before\n * @slot visibility:after\n * @slot timestamps:before\n * @slot timestamps:after\n * @slot create:before\n * @slot create:after\n * @slot delete:before\n * @slot delete:after\n *\n * @element foxy-custom-field-form\n * @since 1.11.0\n */\nexport class CustomFieldForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-checkbox': customElements.get('vaadin-checkbox'),\n 'x-property-table': PropertyTable,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ value }) => (value && value.length > 0) || 'value_required',\n ({ value }) => (value && value.length <= 1000) || 'value_too_long',\n ({ name }) => (name && name.length > 0) || 'name_required',\n ({ name }) => (name && name.length <= 500) || 'name_too_long',\n ];\n }\n\n templates: Templates = {};\n\n private readonly __getValidator = memoize((prefix: string) => () => {\n return !this.errors.some(err => err.startsWith(prefix));\n });\n\n private readonly __bindField = memoize((key: keyof Data) => {\n return (evt: CustomEvent) => {\n const target = evt.target as HTMLInputElement;\n this.edit({ [key]: target.value });\n };\n });\n\n private readonly __maybeRenderTextField = ({ field }: TextFieldParams) => {\n const bsid = field.replace(/_/, '-');\n if (this.hiddenSelector.matches(bsid)) return '';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${bsid}:before`)}\n\n <vaadin-text-field\n class=\"w-full\"\n label=${this.t(field).toString()}\n value=${ifDefined(this.form?.[field]?.toString())}\n error-message=${this.__getErrorMessage(field)}\n data-testid=${field}\n .checkValidity=${this.__getValidator(field)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(bsid)}\n ?readonly=${this.readonlySelector.matches(bsid)}\n @input=${this.__bindField(field)}\n @keydown=${this.__handleKeyDown}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${bsid}:after`)}\n </div>\n `;\n };\n\n private readonly __renderVisibility = () => {\n const { disabledSelector, form, lang, ns } = this;\n const isDisabled = !this.in('idle') || disabledSelector.matches('visibility', true);\n\n return html`\n <div data-testid=\"visibility\">\n ${this.renderTemplateOrSlot('visibility:before')}\n\n <vaadin-checkbox\n ?disabled=${isDisabled}\n ?checked=${!form.is_hidden}\n @change=${(evt: CustomEvent) => {\n const checkbox = evt.currentTarget as CheckboxElement;\n this.edit({ is_hidden: !checkbox.checked });\n }}\n >\n <foxy-i18n lang=${lang} key=\"show_on_receipt\" ns=${ns}></foxy-i18n>\n </vaadin-checkbox>\n\n ${this.renderTemplateOrSlot('visibility:after')}\n </div>\n `;\n };\n\n private readonly __renderTimestamps = () => {\n const items = (['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.t('date', { value: new Date(this.data![field]) }),\n }));\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n <x-property-table .items=${items} data-testid=\"timestamps\"></x-property-table>\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n };\n\n private readonly __renderDelete = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('delete:before')}\n\n <vaadin-button\n class=\"w-full\"\n data-testid=\"delete\"\n theme=\"error primary\"\n ?disabled=${!this.in('idle') || this.disabledSelector.matches('delete', true)}\n @click=${this.__handleDeleteClick}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"delete\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('delete:after')}\n </div>\n `;\n };\n\n private readonly __renderCreate = () => {\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isValid = isTemplateValid || isSnapshotValid;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('create:before')}\n\n <vaadin-button\n data-testid=\"create\"\n class=\"w-full\"\n theme=\"success primary\"\n ?disabled=${!this.in('idle') || !isValid || this.disabledSelector.matches('create', true)}\n @click=${() => this.submit()}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"create\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const { hiddenSelector, data, lang, ns } = this;\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <foxy-internal-confirm-dialog\n data-testid=\"confirm\"\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n @hide=${this.__handleConfirmHide}\n >\n </foxy-internal-confirm-dialog>\n\n <div class=\"relative\" aria-busy=${this.in('busy')} aria-live=\"polite\">\n <div class=\"grid grid-cols-1 gap-l\">\n ${this.__maybeRenderTextField({ field: 'name' })}\n ${this.__maybeRenderTextField({ field: 'value' })}\n ${hiddenSelector.matches('visibility', true) ? '' : this.__renderVisibility()}\n ${hiddenSelector.matches('timestamps', true) || !data ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches('delete', true) || !data ? '' : this.__renderDelete()}\n ${hiddenSelector.matches('create', true) || data ? '' : this.__renderCreate()}\n </div>\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=${lang}\n ns=${ns}\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__bindField.cache.clear?.();\n this.__getValidator.cache.clear?.();\n }\n\n private get __confirmDialog(): InternalConfirmDialog {\n return this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\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')).toString() : '';\n }\n\n private __handleKeyDown(evt: KeyboardEvent) {\n if (evt.key === 'Enter') this.submit();\n }\n\n private __handleDeleteClick(evt: Event) {\n this.__confirmDialog.show(evt.currentTarget as HTMLElement);\n }\n\n private __handleConfirmHide(evt: DialogHideEvent) {\n if (!evt.detail.cancelled) this.delete();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CustomFieldForm.js","sourceRoot":"","sources":["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AC,CAAC;QAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC;IAEO,eAAe,CAAC,GAAkB;QACxC,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IAEO,mBAAmB,CAAC,GAAU;QACpC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,aAA4B,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB,CAAC,GAAoB;QAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { Data, Templates, TextFieldParams } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { CheckboxElement } from '@vaadin/vaadin-checkbox';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { PropertyTable } from '../../private/index';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport memoize from 'lodash-es/memoize';\n\nconst NS = 'custom-field-form';\nconst Base = TranslatableMixin(\n ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(NucleonElement))),\n NS\n);\n\n/**\n * Form element for creating or editing custom fields.\n *\n * @slot name:before\n * @slot name:after\n * @slot value:before\n * @slot value:after\n * @slot visibility:before\n * @slot visibility:after\n * @slot timestamps:before\n * @slot timestamps:after\n * @slot create:before\n * @slot create:after\n * @slot delete:before\n * @slot delete:after\n *\n * @element foxy-custom-field-form\n * @since 1.11.0\n */\nexport class CustomFieldForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-checkbox': customElements.get('vaadin-checkbox'),\n 'x-property-table': PropertyTable,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ value }) => (value && value.length > 0) || 'value_required',\n ({ value }) => (value && value.length <= 1000) || 'value_too_long',\n ({ name }) => (name && name.length > 0) || 'name_required',\n ({ name }) => (name && name.length <= 500) || 'name_too_long',\n ];\n }\n\n templates: Templates = {};\n\n private readonly __getValidator = memoize((prefix: string) => () => {\n return !this.errors.some(err => err.startsWith(prefix));\n });\n\n private readonly __bindField = memoize((key: keyof Data) => {\n return (evt: CustomEvent) => {\n const target = evt.target as HTMLInputElement;\n this.edit({ [key]: target.value });\n };\n });\n\n private readonly __maybeRenderTextField = ({ field }: TextFieldParams) => {\n const bsid = field.replace(/_/, '-');\n if (this.hiddenSelector.matches(bsid)) return '';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${bsid}:before`)}\n\n <vaadin-text-field\n class=\"w-full\"\n label=${this.t(field).toString()}\n value=${ifDefined(this.form?.[field]?.toString())}\n error-message=${this.__getErrorMessage(field)}\n data-testid=${field}\n .checkValidity=${this.__getValidator(field)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(bsid)}\n ?readonly=${this.readonlySelector.matches(bsid)}\n @input=${this.__bindField(field)}\n @keydown=${this.__handleKeyDown}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${bsid}:after`)}\n </div>\n `;\n };\n\n private readonly __renderVisibility = () => {\n const { disabledSelector, form, lang, ns } = this;\n const isDisabled = !this.in('idle') || disabledSelector.matches('visibility', true);\n\n return html`\n <div data-testid=\"visibility\">\n ${this.renderTemplateOrSlot('visibility:before')}\n\n <vaadin-checkbox\n ?disabled=${isDisabled}\n ?checked=${!form.is_hidden}\n @change=${(evt: CustomEvent) => {\n const checkbox = evt.currentTarget as CheckboxElement;\n this.edit({ is_hidden: !checkbox.checked });\n }}\n >\n <foxy-i18n lang=${lang} key=\"show_on_receipt\" ns=${ns}></foxy-i18n>\n </vaadin-checkbox>\n\n ${this.renderTemplateOrSlot('visibility:after')}\n </div>\n `;\n };\n\n private readonly __renderTimestamps = () => {\n const items = (['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }));\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n <x-property-table .items=${items} data-testid=\"timestamps\"></x-property-table>\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n };\n\n private readonly __renderDelete = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('delete:before')}\n\n <vaadin-button\n class=\"w-full\"\n data-testid=\"delete\"\n theme=\"error primary\"\n ?disabled=${!this.in('idle') || this.disabledSelector.matches('delete', true)}\n @click=${this.__handleDeleteClick}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"delete\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('delete:after')}\n </div>\n `;\n };\n\n private readonly __renderCreate = () => {\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isValid = isTemplateValid || isSnapshotValid;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('create:before')}\n\n <vaadin-button\n data-testid=\"create\"\n class=\"w-full\"\n theme=\"success primary\"\n ?disabled=${!this.in('idle') || !isValid || this.disabledSelector.matches('create', true)}\n @click=${() => this.submit()}\n >\n <foxy-i18n ns=${this.ns} lang=${this.lang} key=\"create\"></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const { hiddenSelector, data, lang, ns } = this;\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <foxy-internal-confirm-dialog\n data-testid=\"confirm\"\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n @hide=${this.__handleConfirmHide}\n >\n </foxy-internal-confirm-dialog>\n\n <div class=\"relative\" aria-busy=${this.in('busy')} aria-live=\"polite\">\n <div class=\"grid grid-cols-1 gap-l\">\n ${this.__maybeRenderTextField({ field: 'name' })}\n ${this.__maybeRenderTextField({ field: 'value' })}\n ${hiddenSelector.matches('visibility', true) ? '' : this.__renderVisibility()}\n ${hiddenSelector.matches('timestamps', true) || !data ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches('delete', true) || !data ? '' : this.__renderDelete()}\n ${hiddenSelector.matches('create', true) || data ? '' : this.__renderCreate()}\n </div>\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=${lang}\n ns=${ns}\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__bindField.cache.clear?.();\n this.__getValidator.cache.clear?.();\n }\n\n private get __confirmDialog(): InternalConfirmDialog {\n return this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\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')).toString() : '';\n }\n\n private __handleKeyDown(evt: KeyboardEvent) {\n if (evt.key === 'Enter') this.submit();\n }\n\n private __handleDeleteClick(evt: Event) {\n this.__confirmDialog.show(evt.currentTarget as HTMLElement);\n }\n\n private __handleConfirmHide(evt: DialogHideEvent) {\n if (!evt.detail.cancelled) this.delete();\n }\n}\n"]}
|
|
@@ -81,10 +81,14 @@ export class CustomerForm extends Base {
|
|
|
81
81
|
|
|
82
82
|
<x-property-table
|
|
83
83
|
data-testid="timestamps"
|
|
84
|
-
.items=${['date_modified', 'date_created'].map(field =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
.items=${['date_modified', 'date_created'].map(field => {
|
|
85
|
+
var _a;
|
|
86
|
+
return ({
|
|
87
|
+
name: this.t(field),
|
|
88
|
+
value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
|
|
89
|
+
: '',
|
|
90
|
+
});
|
|
91
|
+
})}
|
|
88
92
|
>
|
|
89
93
|
</x-property-table>
|
|
90
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerForm/CustomerForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,mCAAgC;AAEzD,OAAO,EAAE,aAAa,EAAE,+BAA4B;AACpD,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OA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,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE;UACpF,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;;;;kBAIzD,QAAQ,CAAC;YACf,2DAA2D,EAAE,IAAI;YACjE,+BAA+B,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM;SACpD,CAAC;;;;;oBAKQ,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;mBAC7C,IAAI;kBACL,EAAE,IAAI,YAAA,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,0CAAE,SAAS,mCAAI,EAAE;;;;;KAKtE,CAAC;IACJ,CAAC;IAED,oBAAoB;;QAClB,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC7B,MAAA,MAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAC,KAAK,mDAAK;IACtC,CAAC;CACF","sourcesContent":["import { Data, Templates, TextFieldParams } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/index';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { PropertyTable } from '../../private/index';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { validate as isEmail } from 'email-validator';\nimport memoize from 'lodash-es/memoize';\n\nconst NS = 'customer-form';\nconst Base = ResponsiveMixin(\n ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(TranslatableMixin(NucleonElement, NS))))\n);\n\n/**\n * Form element for creating or editing customers.\n *\n * @slot first-name:before - **new in v1.4.0**\n * @slot first-name:after - **new in v1.4.0**\n *\n * @slot last-name:before - **new in v1.4.0**\n * @slot last-name:after - **new in v1.4.0**\n *\n * @slot email:before - **new in v1.4.0**\n * @slot email:after - **new in v1.4.0**\n *\n * @slot tax-id:before - **new in v1.4.0**\n * @slot tax-id:after - **new in v1.4.0**\n *\n * @slot timestamps:before - **new in v1.4.0**\n * @slot timestamps:after - **new in v1.4.0**\n *\n * @slot create:before - **new in v1.4.0**\n * @slot create:after - **new in v1.4.0**\n *\n * @slot delete:before - **new in v1.4.0**\n * @slot delete:after - **new in v1.4.0**\n *\n * @element foxy-customer-form\n * @since 1.2.0\n */\nexport class CustomerForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'x-property-table': PropertyTable,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ first_name: v }) => !v || v.length <= 50 || 'first_name_too_long',\n ({ last_name: v }) => !v || v.length <= 50 || 'last_name_too_long',\n ({ tax_id: v }) => !v || v.length <= 50 || 'tax_id_too_long',\n ({ email: v }) => (v && v.length > 0) || 'email_required',\n ({ email: v }) => (v && v.length <= 100) || 'email_too_long',\n ({ email: v }) => (v && isEmail(v)) || 'email_invalid_email',\n ];\n }\n\n templates: Templates = {};\n\n private __getValidator = memoize((prefix: string) => () => {\n return !this.errors.some(err => err.startsWith(prefix));\n });\n\n private __maybeRenderTextField = ({ field }: TextFieldParams) => {\n const bsid = field.replace(/_/, '-');\n const error = this.errors.find(err => err.startsWith(field));\n\n if (this.hiddenSelector.matches(bsid, true)) return '';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${bsid}:before`)}\n\n <vaadin-text-field\n class=\"w-full\"\n label=${this.t(field).toString()}\n value=${ifDefined(this.form?.[field]?.toString())}\n error-message=${error ? this.t(error.replace(field, 'v8n')).toString() : ''}\n data-testid=${bsid}\n .checkValidity=${this.__getValidator(field)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(bsid, true)}\n ?readonly=${this.readonlySelector.matches(bsid, true)}\n @input=${(evt: Event) => this.edit({ [field]: (evt.target as HTMLInputElement).value })}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${bsid}:after`)}\n </div>\n `;\n };\n\n private __renderTimestamps = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data ? this.t('date', { value: new Date(this.data[field]) }) : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n };\n\n private __renderAction = (action: string) => {\n const { disabledSelector, href, lang, ns } = this;\n\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);\n const isValid = isTemplateValid || isSnapshotValid;\n\n const handleClick = (evt: Event) => {\n if (action === 'delete') {\n const confirm = this.renderRoot.querySelector('#confirm');\n (confirm as InternalConfirmDialog).show(evt.currentTarget as HTMLElement);\n } else {\n this.submit();\n }\n };\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${action}:before`)}\n\n <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}\n data-testid=${action}\n ?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}\n @click=${handleClick}\n >\n <foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${action}:after`)}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const { hiddenSelector, href, lang, ns } = this;\n const action = href ? 'delete' : 'create';\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <foxy-internal-confirm-dialog\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n data-testid=\"confirm\"\n @hide=${(evt: DialogHideEvent) => {\n if (!evt.detail.cancelled) this.delete();\n }}\n >\n </foxy-internal-confirm-dialog>\n\n <div data-testid=\"wrapper\" aria-busy=${isBusy} aria-live=\"polite\" class=\"space-y-l relative\">\n <div class=\"grid grid-cols-1 sm-grid-cols-2 gap-m\">\n ${this.__maybeRenderTextField({ field: 'first_name' })}\n ${this.__maybeRenderTextField({ field: 'last_name' })}\n ${this.__maybeRenderTextField({ field: 'email' })}\n ${this.__maybeRenderTextField({ field: 'tax_id' })}\n </div>\n\n ${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}\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=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__getValidator.cache.clear?.();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CustomerForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerForm/CustomerForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,mCAAgC;AAEzD,OAAO,EAAE,aAAa,EAAE,+BAA4B;AACpD,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,eAAe,CAC1B,iBAAiB,CAAC,cAAc,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAC9F,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,YAAa,SAAQ,IAAU;IAA5C;;QAwBE,cAAS,GAAc,EAAE,CAAC;QAElB,mBAAc,GAAG,OAAO,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,GAAG,EAAE;YACxD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAE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, TextFieldParams } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/index';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { PropertyTable } from '../../private/index';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { validate as isEmail } from 'email-validator';\nimport memoize from 'lodash-es/memoize';\n\nconst NS = 'customer-form';\nconst Base = ResponsiveMixin(\n ConfigurableMixin(ThemeableMixin(ScopedElementsMixin(TranslatableMixin(NucleonElement, NS))))\n);\n\n/**\n * Form element for creating or editing customers.\n *\n * @slot first-name:before - **new in v1.4.0**\n * @slot first-name:after - **new in v1.4.0**\n *\n * @slot last-name:before - **new in v1.4.0**\n * @slot last-name:after - **new in v1.4.0**\n *\n * @slot email:before - **new in v1.4.0**\n * @slot email:after - **new in v1.4.0**\n *\n * @slot tax-id:before - **new in v1.4.0**\n * @slot tax-id:after - **new in v1.4.0**\n *\n * @slot timestamps:before - **new in v1.4.0**\n * @slot timestamps:after - **new in v1.4.0**\n *\n * @slot create:before - **new in v1.4.0**\n * @slot create:after - **new in v1.4.0**\n *\n * @slot delete:before - **new in v1.4.0**\n * @slot delete:after - **new in v1.4.0**\n *\n * @element foxy-customer-form\n * @since 1.2.0\n */\nexport class CustomerForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'x-property-table': PropertyTable,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ first_name: v }) => !v || v.length <= 50 || 'first_name_too_long',\n ({ last_name: v }) => !v || v.length <= 50 || 'last_name_too_long',\n ({ tax_id: v }) => !v || v.length <= 50 || 'tax_id_too_long',\n ({ email: v }) => (v && v.length > 0) || 'email_required',\n ({ email: v }) => (v && v.length <= 100) || 'email_too_long',\n ({ email: v }) => (v && isEmail(v)) || 'email_invalid_email',\n ];\n }\n\n templates: Templates = {};\n\n private __getValidator = memoize((prefix: string) => () => {\n return !this.errors.some(err => err.startsWith(prefix));\n });\n\n private __maybeRenderTextField = ({ field }: TextFieldParams) => {\n const bsid = field.replace(/_/, '-');\n const error = this.errors.find(err => err.startsWith(field));\n\n if (this.hiddenSelector.matches(bsid, true)) return '';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${bsid}:before`)}\n\n <vaadin-text-field\n class=\"w-full\"\n label=${this.t(field).toString()}\n value=${ifDefined(this.form?.[field]?.toString())}\n error-message=${error ? this.t(error.replace(field, 'v8n')).toString() : ''}\n data-testid=${bsid}\n .checkValidity=${this.__getValidator(field)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(bsid, true)}\n ?readonly=${this.readonlySelector.matches(bsid, true)}\n @input=${(evt: Event) => this.edit({ [field]: (evt.target as HTMLInputElement).value })}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${bsid}:after`)}\n </div>\n `;\n };\n\n private __renderTimestamps = () => {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n };\n\n private __renderAction = (action: string) => {\n const { disabledSelector, href, lang, ns } = this;\n\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);\n const isValid = isTemplateValid || isSnapshotValid;\n\n const handleClick = (evt: Event) => {\n if (action === 'delete') {\n const confirm = this.renderRoot.querySelector('#confirm');\n (confirm as InternalConfirmDialog).show(evt.currentTarget as HTMLElement);\n } else {\n this.submit();\n }\n };\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${action}:before`)}\n\n <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}\n data-testid=${action}\n ?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}\n @click=${handleClick}\n >\n <foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${action}:after`)}\n </div>\n `;\n };\n\n render(): TemplateResult {\n const { hiddenSelector, href, lang, ns } = this;\n const action = href ? 'delete' : 'create';\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <foxy-internal-confirm-dialog\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n data-testid=\"confirm\"\n @hide=${(evt: DialogHideEvent) => {\n if (!evt.detail.cancelled) this.delete();\n }}\n >\n </foxy-internal-confirm-dialog>\n\n <div data-testid=\"wrapper\" aria-busy=${isBusy} aria-live=\"polite\" class=\"space-y-l relative\">\n <div class=\"grid grid-cols-1 sm-grid-cols-2 gap-m\">\n ${this.__maybeRenderTextField({ field: 'first_name' })}\n ${this.__maybeRenderTextField({ field: 'last_name' })}\n ${this.__maybeRenderTextField({ field: 'email' })}\n ${this.__maybeRenderTextField({ field: 'tax_id' })}\n </div>\n\n ${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}\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=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.__getValidator.cache.clear?.();\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
|
+
import { ScopedElementsMap } from '@open-wc/scoped-elements';
|
|
3
|
+
import { Data } from './types';
|
|
4
|
+
import { NucleonElement } from '../NucleonElement/NucleonElement';
|
|
5
|
+
declare const Base: typeof NucleonElement & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
6
|
+
defaultNS: string;
|
|
7
|
+
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost> & {
|
|
8
|
+
styles: CSSResultArray;
|
|
9
|
+
} & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/src/types").ScopedElementsHost>;
|
|
10
|
+
export declare class EmailTemplateForm extends Base<Data> {
|
|
11
|
+
static get properties(): PropertyDeclarations;
|
|
12
|
+
static get styles(): CSSResultArray;
|
|
13
|
+
static get scopedElements(): ScopedElementsMap;
|
|
14
|
+
private __cacheState;
|
|
15
|
+
private __contentChoice;
|
|
16
|
+
render(): TemplateResult;
|
|
17
|
+
private __renderDescription;
|
|
18
|
+
private __renderContent;
|
|
19
|
+
private __renderTabContent;
|
|
20
|
+
private __renderTimestamps;
|
|
21
|
+
private __renderAction;
|
|
22
|
+
private __cache;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { css, html } from 'lit-element';
|
|
2
|
+
import { Choice, Group, PropertyTable } from "../../private/index.js";
|
|
3
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
4
|
+
import { ChoiceChangeEvent } from "../../private/events.js";
|
|
5
|
+
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
6
|
+
import { NucleonElement } from "../NucleonElement/NucleonElement.js";
|
|
7
|
+
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
8
|
+
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
9
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
10
|
+
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
11
|
+
const NS = 'email-template-form';
|
|
12
|
+
const Base = ScopedElementsMixin(ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS))));
|
|
13
|
+
export class EmailTemplateForm extends Base {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.__cacheState = 'idle';
|
|
17
|
+
this.__contentChoice = 'default';
|
|
18
|
+
}
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
...super.properties,
|
|
22
|
+
__cacheState: { attribute: false },
|
|
23
|
+
__contentChoice: { attribute: false },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static get styles() {
|
|
27
|
+
return [
|
|
28
|
+
...super.styles,
|
|
29
|
+
css `#cached-content::part(input-field){
|
|
30
|
+
max-height:15em;
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
static get scopedElements() {
|
|
36
|
+
return {
|
|
37
|
+
'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),
|
|
38
|
+
'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),
|
|
39
|
+
'foxy-spinner': customElements.get('foxy-spinner'),
|
|
40
|
+
'foxy-i18n': customElements.get('foxy-i18n'),
|
|
41
|
+
'vaadin-text-field': customElements.get('vaadin-text-field'),
|
|
42
|
+
'vaadin-text-area': customElements.get('vaadin-text-area'),
|
|
43
|
+
'vaadin-button': customElements.get('vaadin-button'),
|
|
44
|
+
'x-property-table': PropertyTable,
|
|
45
|
+
'x-choice': Choice,
|
|
46
|
+
'x-group': Group,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const { hiddenSelector, href, lang, ns } = this;
|
|
52
|
+
const action = href ? 'delete' : 'create';
|
|
53
|
+
const isBusy = this.in('busy');
|
|
54
|
+
const isFail = this.in('fail');
|
|
55
|
+
return html `
|
|
56
|
+
<div class="space-y-m">
|
|
57
|
+
${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}
|
|
58
|
+
${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}
|
|
59
|
+
${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}
|
|
60
|
+
${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
data-testid="spinner"
|
|
64
|
+
class=${classMap({
|
|
65
|
+
'transition duration-500 ease-in-out absolute inset-0 flex': true,
|
|
66
|
+
'opacity-0 pointer-events-none': !isBusy && !isFail,
|
|
67
|
+
})}
|
|
68
|
+
>
|
|
69
|
+
<foxy-spinner
|
|
70
|
+
layout="vertical"
|
|
71
|
+
class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l"
|
|
72
|
+
state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}
|
|
73
|
+
lang=${lang}
|
|
74
|
+
ns="${ns} ${(_b = (_a = customElements.get('foxy-spinner')) === null || _a === void 0 ? void 0 : _a.defaultNS) !== null && _b !== void 0 ? _b : ''}"
|
|
75
|
+
>
|
|
76
|
+
</foxy-spinner>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
__renderDescription() {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
return html `
|
|
84
|
+
<div>
|
|
85
|
+
${this.renderTemplateOrSlot('description:before')}
|
|
86
|
+
|
|
87
|
+
<vaadin-text-field
|
|
88
|
+
class="w-full mb-s"
|
|
89
|
+
label=${this.t('description')}
|
|
90
|
+
.value=${(_b = (_a = this.form) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : ''}
|
|
91
|
+
@keydown=${(evt) => evt.key === 'Enter' && this.submit()}
|
|
92
|
+
@input=${(evt) => {
|
|
93
|
+
this.edit({ description: evt.currentTarget.value });
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
</vaadin-text-field>
|
|
97
|
+
|
|
98
|
+
${this.renderTemplateOrSlot('description:after')}
|
|
99
|
+
</div>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
__renderContent() {
|
|
103
|
+
return html `
|
|
104
|
+
<div>
|
|
105
|
+
${this.renderTemplateOrSlot('content:before')}
|
|
106
|
+
|
|
107
|
+
<div class="space-y-l">
|
|
108
|
+
${this.__renderTabContent('content_text_url', 'content_text', 'text_template')}
|
|
109
|
+
${this.__renderTabContent('content_html_url', 'content_html', 'html_template')}
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
${this.renderTemplateOrSlot('content:after')}
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
__renderTabContent(urlPath, textPath, header) {
|
|
117
|
+
var _a;
|
|
118
|
+
const contentChoice = this.form[urlPath]
|
|
119
|
+
? 'url'
|
|
120
|
+
: this.form[textPath]
|
|
121
|
+
? 'clipboard'
|
|
122
|
+
: this.__contentChoice;
|
|
123
|
+
return html `
|
|
124
|
+
<x-group frame>
|
|
125
|
+
<foxy-i18n lang=${this.lang} slot="header" key=${header} ns=${this.ns}></foxy-i18n>
|
|
126
|
+
|
|
127
|
+
<x-choice
|
|
128
|
+
data-testid="template-type"
|
|
129
|
+
.value=${contentChoice}
|
|
130
|
+
.items=${['default', 'url', 'clipboard']}
|
|
131
|
+
?readonly=${this.readonlySelector.matches('content', true)}
|
|
132
|
+
?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}
|
|
133
|
+
@change=${(evt) => {
|
|
134
|
+
if (evt instanceof ChoiceChangeEvent) {
|
|
135
|
+
this.edit({ [textPath]: '', [urlPath]: '' });
|
|
136
|
+
this.__contentChoice = evt.detail;
|
|
137
|
+
}
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
${['default', 'url', 'clipboard'].map(value => {
|
|
141
|
+
return html `
|
|
142
|
+
<div slot="${value}-label" class="py-s leading-s">
|
|
143
|
+
<foxy-i18n class="block" lang=${this.lang} key="template_${value}" ns=${this.ns}>
|
|
144
|
+
</foxy-i18n>
|
|
145
|
+
|
|
146
|
+
<foxy-i18n
|
|
147
|
+
class="block text-s opacity-70"
|
|
148
|
+
lang=${this.lang}
|
|
149
|
+
key="template_${value}_explainer"
|
|
150
|
+
ns=${this.ns}
|
|
151
|
+
>
|
|
152
|
+
</foxy-i18n>
|
|
153
|
+
</div>
|
|
154
|
+
`;
|
|
155
|
+
})}
|
|
156
|
+
|
|
157
|
+
<div slot="url" ?hidden=${contentChoice !== 'url'}>
|
|
158
|
+
<div class="flex items-center mt-0 mb-m">
|
|
159
|
+
<vaadin-text-field
|
|
160
|
+
data-testid="content_url"
|
|
161
|
+
value=${ifDefined(this.form[urlPath])}
|
|
162
|
+
class="mr-s flex-grow"
|
|
163
|
+
@input=${(evt) => {
|
|
164
|
+
const value = evt.currentTarget.value;
|
|
165
|
+
this.edit({ [textPath]: '', [urlPath]: value });
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
</vaadin-text-field>
|
|
169
|
+
|
|
170
|
+
${this.form[urlPath] === ((_a = this.data) === null || _a === void 0 ? void 0 : _a[urlPath])
|
|
171
|
+
? html `
|
|
172
|
+
<vaadin-button
|
|
173
|
+
class="relative"
|
|
174
|
+
?disabled=${this.__cacheState === 'busy'}
|
|
175
|
+
@click=${this.__cache}
|
|
176
|
+
>
|
|
177
|
+
<foxy-i18n
|
|
178
|
+
class=${classMap({
|
|
179
|
+
'relative transition-opacity': true,
|
|
180
|
+
'opacity-0': this.__cacheState !== 'idle',
|
|
181
|
+
})}
|
|
182
|
+
lang=${this.lang}
|
|
183
|
+
key="cache"
|
|
184
|
+
ns=${this.ns}
|
|
185
|
+
>
|
|
186
|
+
</foxy-i18n>
|
|
187
|
+
|
|
188
|
+
<div
|
|
189
|
+
class=${classMap({
|
|
190
|
+
'absolute inset-0 flex transition-opacity': true,
|
|
191
|
+
'opacity-0': this.__cacheState === 'idle',
|
|
192
|
+
})}
|
|
193
|
+
>
|
|
194
|
+
<foxy-spinner
|
|
195
|
+
layout="no-label"
|
|
196
|
+
class="m-auto"
|
|
197
|
+
state=${this.__cacheState === 'fail' ? 'error' : 'busy'}
|
|
198
|
+
lang=${this.lang}
|
|
199
|
+
ns=${this.ns}
|
|
200
|
+
>
|
|
201
|
+
</foxy-spinner>
|
|
202
|
+
</div>
|
|
203
|
+
</vaadin-button>
|
|
204
|
+
`
|
|
205
|
+
: ''}
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<div slot="clipboard" ?hidden=${contentChoice !== 'clipboard'}>
|
|
210
|
+
<vaadin-text-area
|
|
211
|
+
id="cached-content"
|
|
212
|
+
data-testid="content"
|
|
213
|
+
class="w-full mb-m"
|
|
214
|
+
.value=${this.form[textPath]}
|
|
215
|
+
@input=${(evt) => {
|
|
216
|
+
const value = evt.currentTarget.value;
|
|
217
|
+
this.edit({ [textPath]: value, [urlPath]: '' });
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
</vaadin-text-area>
|
|
221
|
+
</div>
|
|
222
|
+
</x-choice>
|
|
223
|
+
</x-group>
|
|
224
|
+
`;
|
|
225
|
+
}
|
|
226
|
+
__renderTimestamps() {
|
|
227
|
+
return html `
|
|
228
|
+
<div>
|
|
229
|
+
${this.renderTemplateOrSlot('timestamps:before')}
|
|
230
|
+
|
|
231
|
+
<x-property-table
|
|
232
|
+
data-testid="timestamps"
|
|
233
|
+
.items=${['date_modified', 'date_created'].map(field => {
|
|
234
|
+
var _a;
|
|
235
|
+
return ({
|
|
236
|
+
name: this.t(field),
|
|
237
|
+
value: ((_a = this.data) === null || _a === void 0 ? void 0 : _a[field]) ? this.t('date', { value: new Date(this.data[field]) })
|
|
238
|
+
: '',
|
|
239
|
+
});
|
|
240
|
+
})}
|
|
241
|
+
>
|
|
242
|
+
</x-property-table>
|
|
243
|
+
|
|
244
|
+
${this.renderTemplateOrSlot('timestamps:after')}
|
|
245
|
+
</div>
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
__renderAction(action) {
|
|
249
|
+
const { disabledSelector, href, lang, ns } = this;
|
|
250
|
+
const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });
|
|
251
|
+
const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });
|
|
252
|
+
const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);
|
|
253
|
+
const isValid = isTemplateValid || isSnapshotValid;
|
|
254
|
+
const handleClick = (evt) => {
|
|
255
|
+
if (action === 'delete') {
|
|
256
|
+
const confirm = this.renderRoot.querySelector('#confirm');
|
|
257
|
+
confirm.show(evt.currentTarget);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
this.submit();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
return html `
|
|
264
|
+
<div>
|
|
265
|
+
${this.renderTemplateOrSlot(`${action}:before`)}
|
|
266
|
+
|
|
267
|
+
<foxy-internal-confirm-dialog
|
|
268
|
+
message="delete_prompt"
|
|
269
|
+
confirm="delete"
|
|
270
|
+
cancel="cancel"
|
|
271
|
+
header="delete"
|
|
272
|
+
theme="primary error"
|
|
273
|
+
lang=${lang}
|
|
274
|
+
ns=${ns}
|
|
275
|
+
id="confirm"
|
|
276
|
+
data-testid="confirm"
|
|
277
|
+
@hide=${(evt) => {
|
|
278
|
+
if (!evt.detail.cancelled)
|
|
279
|
+
this.delete();
|
|
280
|
+
}}
|
|
281
|
+
>
|
|
282
|
+
</foxy-internal-confirm-dialog>
|
|
283
|
+
|
|
284
|
+
<vaadin-button
|
|
285
|
+
class="w-full"
|
|
286
|
+
theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}
|
|
287
|
+
data-testid=${action}
|
|
288
|
+
?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}
|
|
289
|
+
@click=${handleClick}
|
|
290
|
+
>
|
|
291
|
+
<foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>
|
|
292
|
+
</vaadin-button>
|
|
293
|
+
|
|
294
|
+
${this.renderTemplateOrSlot(`${action}:after`)}
|
|
295
|
+
</div>
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
async __cache() {
|
|
299
|
+
var _a, _b;
|
|
300
|
+
this.__cacheState = 'busy';
|
|
301
|
+
try {
|
|
302
|
+
const url = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:cache'].href) !== null && _b !== void 0 ? _b : '';
|
|
303
|
+
const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });
|
|
304
|
+
this.__cacheState = response.ok ? 'idle' : 'fail';
|
|
305
|
+
}
|
|
306
|
+
catch (_c) {
|
|
307
|
+
this.__cacheState = 'fail';
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=EmailTemplateForm.js.map
|