@foxy.io/elements 1.23.0-beta.3 → 1.23.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/shared-2756a4f0.js +64 -0
- package/dist/cdn/shared-79d0699c.js +1 -0
- package/dist/cdn/translations/template-config-form/en.json +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +2 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.js +9 -2
- package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/Input.js +12 -9
- package/dist/elements/public/QueryBuilder/components/Input.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/parse.js +2 -0
- package/dist/elements/public/QueryBuilder/utils/parse.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/stringify.js +31 -9
- package/dist/elements/public/QueryBuilder/utils/stringify.js.map +1 -1
- package/dist/elements/public/TemplateForm/TemplateForm.js +2 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
- package/dist/utils/serialize-date.d.ts +1 -1
- package/dist/utils/serialize-date.js +7 -6
- package/dist/utils/serialize-date.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-29aa4bca.js +0 -64
- package/dist/cdn/shared-bc7f58ef.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailTemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/EmailTemplateForm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAE3D,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,MAAM,EAAE,GAAG,qBAAqB,CAAC;AACjC,MAAM,IAAI,GAAG,mBAAmB,CAC9B,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CACzE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAU;IAAjD;;QA0BE,cAAS,GAAc,EAAE,CAAC;QAElB,8BAAyB,GAAG;YAClC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;YACxC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;YAC5C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;YAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;YAChC,EAAE,KAAK,EAAE,KAAK,EAA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AAG,CAAC,MAAM,CAAC,SAAS;gBAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;;;;;;kBAMO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE;wBACrD,MAAM;sBACR,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,UAAU;mBAC5D,WAAW;;0BAEJ,EAAE,QAAQ,MAAM,SAAS,IAAI;;;UAG7C,IAAI,CAAC,oBAAoB,CAAC,GAAG,MAAM,QAAQ,CAAC;;KAEjD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACtF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAClD,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport type { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport type { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport type { Data, Templates } from './types';\n\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-element';\n\nconst NS = 'email-template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing email templates (`fx:email_template`).\n *\n * @slot description:before\n * @slot description:after\n *\n * @slot template-language:before\n * @slot template-language:after\n *\n * @slot content:before\n * @slot content:after\n *\n * @slot timestamps:before\n * @slot timestamps:after\n *\n * @slot create:before\n * @slot create:after\n *\n * @slot delete:before\n * @slot delete:after\n *\n * @element foxy-email-template-form\n * @since 1.14.0\n */\nexport class EmailTemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-select-control': customElements.get('foxy-internal-select-control'),\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-source-control': customElements.get('foxy-internal-source-control'),\n 'foxy-internal-text-control': customElements.get('foxy-internal-text-control'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n templates: Templates = {};\n\n private __templateLanguageOptions = [\n { label: 'Nunjucks', value: 'nunjucks' },\n { label: 'Handlebars', value: 'handlebars' },\n { label: 'Pug', value: 'pug' },\n { label: 'Twig', value: 'twig' },\n { label: 'EJS', value: 'ejs' },\n ];\n\n private __textContentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n private __htmlContentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\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 <div class=\"space-y-m\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n\n <foxy-internal-text-control infer=\"subject\"></foxy-internal-text-control>\n\n ${this.data?.description === 'Email Receipt Template'\n ? ''\n : html`\n <foxy-internal-select-control\n infer=\"template-language\"\n .options=${this.__templateLanguageOptions}\n >\n </foxy-internal-select-control>\n `}\n\n <!-- -->\n\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\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 protected async _sendPost(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPost(edits);\n if (!data.content_html_url && !data.content_text_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPatch(edits);\n if (!data.content_html_url && !data.content_text_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n private __renderDescription() {\n const scope = 'description';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <vaadin-text-field\n data-testid=${scope}\n class=\"w-full mb-s\"\n label=${this.t(scope)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(scope)}\n ?readonly=${this.readonlySelector.matches(scope)}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n </div>\n `;\n }\n\n private __renderContent() {\n const variants = ['text', 'html'] as const;\n return html`\n <div data-testid=\"content\">\n <div class=\"space-y-l\">${variants.map(v => this.__renderContentVariant(v))}</div>\n </div>\n `;\n }\n\n private __renderContentVariant(variant: 'text' | 'html') {\n const urlPath = variant === 'text' ? 'content_text_url' : 'content_html_url';\n const textPath = variant === 'text' ? 'content_text' : 'content_html';\n const header = variant === 'text' ? 'text_template' : 'html_template';\n const urlValue = this.form[urlPath];\n const textValue = this.form[textPath];\n const contentChoiceKey = variant === 'text' ? '__textContentChoice' : '__htmlContentChoice';\n const contentChoice = urlValue ? 'url' : textValue ? 'clipboard' : this[contentChoiceKey];\n\n const isDisabled = !this.in('idle') || this.disabledSelector.matches('content', true);\n const isReadonly = this.readonlySelector.matches('content', true);\n const isSyncProhibited = isReadonly || !this.data?.[urlPath] || urlValue !== this.data[urlPath];\n\n return html`\n <x-group frame>\n <foxy-i18n\n class=${classMap({ 'transition-colors': true, 'text-disabled': isDisabled })}\n lang=${this.lang}\n slot=\"header\"\n key=${header}\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <x-choice\n data-testid=\"${textPath.replace('_', '-')}-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ [textPath]: '', [urlPath]: '' });\n this[contentChoiceKey] = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s leading-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n class=\"mb-m\"\n slot=\"url\"\n ?hidden=${contentChoice !== 'url'}\n >\n <div class=\"flex items-end mt-0\">\n <vaadin-text-field\n data-testid=\"${textPath.replace('_', '-')}-url\"\n placeholder=\"https://example.com/my-template\"\n label=${this.t('url')}\n class=\"flex-1 min-w-0\"\n value=${ifDefined(this.form[urlPath])}\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ [textPath]: '', [urlPath]: value });\n }}\n >\n </vaadin-text-field>\n\n <vaadin-button\n data-testid=\"${textPath.replace('_', '-')}-cache\"\n class=\"relative flex-shrink-0 ml-s\"\n ?disabled=${isDisabled || this.__cacheState === 'busy'}\n ?hidden=${isSyncProhibited}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('url_source_placeholder')}\n property=${textPath}\n label=${this.t('url_source_label')}\n infer=\"content\"\n class=\"mt-m${this.data?.[textPath] ? '' : ' hidden'}\"\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n >\n </foxy-internal-source-control>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('clipboard_source_placeholder')}\n property=${textPath}\n label=${this.t('clipboard_source_label')}\n infer=\"content\"\n class=\"mb-m${contentChoice === 'clipboard' ? '' : ' hidden'}\"\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n slot=\"clipboard\"\n >\n </foxy-internal-source-control>\n </x-choice>\n </x-group>\n `;\n }\n\n private __renderTimestamps() {\n const scope = 'timestamps';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}: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(`${scope}: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 <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 <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? (href ? 'error' : 'primary 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 private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n this.refresh();\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EmailTemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/EmailTemplateForm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAA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C,oBAAoB,CAAC,GAAG,MAAM,QAAQ,CAAC;;KAEjD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACtF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAClD,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport type { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport type { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport type { Data, Templates } from './types';\n\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-element';\n\nconst NS = 'email-template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing email templates (`fx:email_template`).\n *\n * @slot description:before\n * @slot description:after\n *\n * @slot template-language:before\n * @slot template-language:after\n *\n * @slot content:before\n * @slot content:after\n *\n * @slot timestamps:before\n * @slot timestamps:after\n *\n * @slot create:before\n * @slot create:after\n *\n * @slot delete:before\n * @slot delete:after\n *\n * @element foxy-email-template-form\n * @since 1.14.0\n */\nexport class EmailTemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-select-control': customElements.get('foxy-internal-select-control'),\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-source-control': customElements.get('foxy-internal-source-control'),\n 'foxy-internal-text-control': customElements.get('foxy-internal-text-control'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n templates: Templates = {};\n\n private __templateLanguageOptions = [\n { label: 'Nunjucks', value: 'nunjucks' },\n { label: 'Handlebars', value: 'handlebars' },\n { label: 'Pug', value: 'pug' },\n { label: 'Twig', value: 'twig' },\n { label: 'EJS', value: 'ejs' },\n ];\n\n private __textContentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n private __htmlContentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\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 <div class=\"space-y-m\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n\n <foxy-internal-text-control infer=\"subject\"></foxy-internal-text-control>\n\n ${this.data?.description === 'Email Receipt Template'\n ? ''\n : html`\n <foxy-internal-select-control\n infer=\"template-language\"\n .options=${this.__templateLanguageOptions}\n >\n </foxy-internal-select-control>\n `}\n\n <!-- -->\n\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\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 protected async _sendPost(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPost(edits);\n if (!data.content_html_url && !data.content_text_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPatch(edits);\n if (!data.content_html_url && !data.content_text_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n private __renderDescription() {\n const scope = 'description';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <vaadin-text-field\n data-testid=${scope}\n class=\"w-full mb-s\"\n label=${this.t(scope)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(scope)}\n ?readonly=${this.readonlySelector.matches(scope)}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n </div>\n `;\n }\n\n private __renderContent() {\n const variants = ['text', 'html'] as const;\n return html`\n <div data-testid=\"content\">\n <div class=\"space-y-l\">${variants.map(v => this.__renderContentVariant(v))}</div>\n </div>\n `;\n }\n\n private __renderContentVariant(variant: 'text' | 'html') {\n const urlPath = variant === 'text' ? 'content_text_url' : 'content_html_url';\n const textPath = variant === 'text' ? 'content_text' : 'content_html';\n const header = variant === 'text' ? 'text_template' : 'html_template';\n const urlValue = this.form[urlPath];\n const textValue = this.form[textPath];\n const contentChoiceKey = variant === 'text' ? '__textContentChoice' : '__htmlContentChoice';\n const contentChoice = urlValue ? 'url' : textValue ? 'clipboard' : this[contentChoiceKey];\n\n const isDisabled = !this.in('idle') || this.disabledSelector.matches('content', true);\n const isReadonly = this.readonlySelector.matches('content', true);\n const isSyncProhibited = isReadonly || !this.data?.[urlPath] || urlValue !== this.data[urlPath];\n\n return html`\n <x-group frame>\n <foxy-i18n\n class=${classMap({ 'transition-colors': true, 'text-disabled': isDisabled })}\n lang=${this.lang}\n slot=\"header\"\n key=${header}\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <x-choice\n data-testid=\"${textPath.replace('_', '-')}-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ [textPath]: '', [urlPath]: '' });\n this[contentChoiceKey] = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s leading-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n class=\"mb-m\"\n slot=\"url\"\n ?hidden=${contentChoice !== 'url'}\n >\n <div class=\"flex items-end mt-0\">\n <vaadin-text-field\n data-testid=\"${textPath.replace('_', '-')}-url\"\n placeholder=\"https://example.com/my-template\"\n label=${this.t('url')}\n class=\"flex-1 min-w-0\"\n value=${ifDefined(this.form[urlPath])}\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ [textPath]: '', [urlPath]: value });\n }}\n >\n </vaadin-text-field>\n\n <vaadin-button\n data-testid=\"${textPath.replace('_', '-')}-cache\"\n class=\"relative flex-shrink-0 ml-s\"\n ?disabled=${isDisabled || this.__cacheState === 'busy'}\n ?hidden=${isSyncProhibited}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('url_source_placeholder')}\n helper-text=\"\"\n property=${textPath}\n label=${this.t('url_source_label')}\n infer=\"content\"\n class=\"mt-m${this.data?.[textPath] ? '' : ' hidden'}\"\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n >\n </foxy-internal-source-control>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('clipboard_source_placeholder')}\n helper-text=\"\"\n property=${textPath}\n label=${this.t('clipboard_source_label')}\n infer=\"content\"\n class=\"mb-m${contentChoice === 'clipboard' ? '' : ' hidden'}\"\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n slot=\"clipboard\"\n >\n </foxy-internal-source-control>\n </x-choice>\n </x-group>\n `;\n }\n\n private __renderTimestamps() {\n const scope = 'timestamps';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}: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(`${scope}: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 <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 <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? (href ? 'error' : 'primary 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 private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n this.refresh();\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
|
|
@@ -39,14 +39,21 @@ class QueryBuilder extends Base {
|
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
41
|
var _a, _b;
|
|
42
|
+
const reservedPaths = new Set(['zoom', 'limit', 'offset', 'order', 'fields']);
|
|
43
|
+
const hiddenValues = [];
|
|
44
|
+
const visibleValues = [];
|
|
45
|
+
parse((_a = this.value) !== null && _a !== void 0 ? _a : '').forEach(value => {
|
|
46
|
+
const isVisible = Array.isArray(value) || !reservedPaths.has(value.path);
|
|
47
|
+
isVisible ? visibleValues.push(value) : hiddenValues.push(value);
|
|
48
|
+
});
|
|
42
49
|
return Group({
|
|
43
|
-
parsedValues:
|
|
50
|
+
parsedValues: visibleValues,
|
|
44
51
|
disabled: this.disabled,
|
|
45
52
|
readonly: this.readonly,
|
|
46
53
|
options: (_b = this.options) !== null && _b !== void 0 ? _b : [],
|
|
47
54
|
t: this.t.bind(this),
|
|
48
55
|
onChange: newValue => {
|
|
49
|
-
this.value = stringify(newValue);
|
|
56
|
+
this.value = stringify([...newValue, ...hiddenValues]);
|
|
50
57
|
this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));
|
|
51
58
|
},
|
|
52
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAwC,MAAM,aAAa,CAAC;AAC/F,OAAO,
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAwC,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAe,QAAQ,EAAU,IAAI,EAAE,mBAAgB;AAE9D,OAAO,EAAE,KAAK,EAAE,8BAA2B;AAC3C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,KAAK,EAAE,yBAAsB;AACtC,OAAO,EAAE,SAAS,EAAE,6BAA0B;AAC9C,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAClC,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,iBAAiB,CAC5B,eAAe,CAAC,cAAc,CAAC,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CACpF,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,YAAa,SAAQ,IAAI;IAA/B;;QAsBE,gCAAgC;QAChC,YAAO,GAAoB,IAAI,CAAC;QAEhC,2CAA2C;QAC3C,UAAK,GAAkB,IAAI,CAAC;IAwB9B,CAAC;IAxCC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACxB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;S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W,GAAG,KAAM,SAAQ,WAAiB;CAAG,CAAC;AAEjE,2DAA2D;AAC3C,qBAAQ,GAAG,QAAQ,CAAC;AAEpC,6DAA6D;AAC7C,iBAAI,GAAG,IAAI,CAAC;AA4C9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { CSSResultArray, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport { ParsedValue, Operator, Option, Type } from './types';\n\nimport { Group } from './components/Group';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { parse } from './utils/parse';\nimport { stringify } from './utils/stringify';\nimport { styles } from './styles';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\n\nconst NS = 'query-builder';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)))\n);\n\n/**\n * UI component for creating Foxy hAPI filters visually. Compatible with\n * Backend API, Customer API or any other API using the same format as described\n * in our [docs](https://api.foxy.io/docs/cheat-sheet).\n *\n * @element foxy-query-builder\n * @since 1.12.0\n */\nclass QueryBuilder extends Base {\n /** QueryBuilder dispatches this event on itself when value changes. */\n static readonly ChangeEvent = class extends CustomEvent<void> {};\n\n /** Operator dictionary for use in autocomplete options. */\n static readonly Operator = Operator;\n\n /** Field type dictionary for use in autocomplete options. */\n static readonly Type = Type;\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n options: { type: Array },\n value: { type: String },\n };\n }\n\n static get styles(): CSSResultArray {\n return [super.styles, styles];\n }\n\n /** Autocomplete suggestions. */\n options: Option[] | null = null;\n\n /** Current value as hAPI filter string. */\n value: string | null = null;\n\n render(): TemplateResult {\n const reservedPaths = new Set(['zoom', 'limit', 'offset', 'order', 'fields']);\n const hiddenValues: (ParsedValue | ParsedValue[])[] = [];\n const visibleValues: (ParsedValue | ParsedValue[])[] = [];\n\n parse(this.value ?? '').forEach(value => {\n const isVisible = Array.isArray(value) || !reservedPaths.has(value.path);\n isVisible ? visibleValues.push(value) : hiddenValues.push(value);\n });\n\n return Group({\n parsedValues: visibleValues,\n disabled: this.disabled,\n readonly: this.readonly,\n options: this.options ?? [],\n t: this.t.bind(this),\n onChange: newValue => {\n this.value = stringify([...newValue, ...hiddenValues]);\n this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));\n },\n });\n }\n}\n\nexport { QueryBuilder };\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
2
|
import { classMap } from "../../../../utils/class-map.js";
|
|
3
3
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
|
-
import {
|
|
4
|
+
import { serializeDateTime } from "../../../../utils/serialize-date.js";
|
|
5
5
|
export function Input(params) {
|
|
6
6
|
var _a;
|
|
7
7
|
const id = (_a = params.id) !== null && _a !== void 0 ? _a : String(Math.floor(Math.random() * Math.pow(10, 8)));
|
|
@@ -10,7 +10,7 @@ export function Input(params) {
|
|
|
10
10
|
let normalizedValue = params.value;
|
|
11
11
|
if (params.type === 'date') {
|
|
12
12
|
const date = new Date(params.value);
|
|
13
|
-
normalizedValue = isNaN(date.getTime()) ? '' :
|
|
13
|
+
normalizedValue = isNaN(date.getTime()) ? '' : serializeDateTime(date);
|
|
14
14
|
}
|
|
15
15
|
return html `
|
|
16
16
|
<label class="relative flex items-center cursor-text group text-tertiary">
|
|
@@ -43,21 +43,24 @@ export function Input(params) {
|
|
|
43
43
|
'opacity-0 focus-opacity-100': hasDisplayValue,
|
|
44
44
|
})}
|
|
45
45
|
list=${ifDefined(params.list ? listId : undefined)}
|
|
46
|
-
type=${params.type}
|
|
47
|
-
max=${ifDefined(params.type === 'date' ? '9999-12-
|
|
46
|
+
type=${params.type === 'date' ? 'datetime-local' : params.type}
|
|
47
|
+
max=${ifDefined(params.type === 'date' ? '9999-12-31T23:59' : '')}
|
|
48
48
|
.value=${normalizedValue}
|
|
49
49
|
?disabled=${params.disabled || params.readonly}
|
|
50
50
|
@input=${(evt) => {
|
|
51
51
|
const input = evt.currentTarget;
|
|
52
|
+
let newValue = input.value;
|
|
52
53
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (params.type === 'date') {
|
|
55
|
+
const newDate = new Date(input.value);
|
|
56
|
+
if (!isNaN(newDate.getTime()))
|
|
57
|
+
newValue = newDate.toISOString();
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
catch (_a) {
|
|
59
|
-
|
|
61
|
+
// ignore
|
|
60
62
|
}
|
|
63
|
+
params.onChange(newValue);
|
|
61
64
|
}}
|
|
62
65
|
/>
|
|
63
66
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/Input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,uCAAoC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/components/Input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,uCAAoC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,4CAAyC;AAerE,MAAM,UAAU,KAAK,CAAC,MAAmB;;IACvC,MAAM,EAAE,SAAG,MAAM,CAAC,EAAE,mCAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAA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C,CAAC,MAAM,CAAC,KAAK,CAAC;;;QAGxB,MAAM,CAAC,IAAI;QACX,CAAC,CAAC,IAAI,CAAA;2BACa,MAAM;gBACjB,MAAM,CAAC,IAAI,CAAC,GAAG,CACf,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,CAAA,iBAAiB,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAC/E;;WAEJ;QACH,CAAC,CAAC,EAAE;QACJ,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ;QAClC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,IAAI,CAAA;;;;WAIH;;GAER,CAAC;AACJ,CAAC","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { I18n } from '../../I18n/I18n';\nimport { classMap } from '../../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { serializeDateTime } from '../../../../utils/serialize-date';\n\nexport type InputParams = {\n t: I18n['t'];\n id?: string;\n list?: { label: string; value: string }[];\n type: string;\n label: string;\n value: string;\n disabled: boolean;\n readonly: boolean;\n displayValue?: string;\n onChange: (newValue: string) => void;\n};\n\nexport function Input(params: InputParams): TemplateResult {\n const id = params.id ?? String(Math.floor(Math.random() * Math.pow(10, 8)));\n const listId = `${id}-list`;\n const hasDisplayValue = !!params.displayValue;\n\n let normalizedValue = params.value;\n\n if (params.type === 'date') {\n const date = new Date(params.value);\n normalizedValue = isNaN(date.getTime()) ? '' : serializeDateTime(date);\n }\n\n return html`\n <label class=\"relative flex items-center cursor-text group text-tertiary\">\n <div class=\"relative flex-1 min-w-0 overflow-hidden\">\n ${hasDisplayValue\n ? html`\n <div\n aria-hidden=\"true\"\n class=${classMap({\n 'absolute inset-0 h-m px-s font-medium flex items-center': true,\n 'text-body': !params.disabled && !params.readonly,\n 'text-disabled': params.disabled,\n 'text-secondary': params.readonly,\n })}\n >\n <div class=\"truncate\">${params.t(params.displayValue!)}</div>\n </div>\n `\n : ''}\n\n <input\n placeholder=${normalizedValue || params.type === 'date' ? '' : params.t(params.label)}\n class=${classMap({\n 'bg-base relative flex h-m px-s font-medium w-full': true,\n 'text-body': !params.disabled && !params.readonly,\n 'text-disabled': params.disabled,\n 'text-secondary': params.readonly,\n 'flex max-w-full whitespace-nowrap': true, // ugh safari\n 'focus-outline-none': true,\n 'opacity-0 focus-opacity-100': hasDisplayValue,\n })}\n list=${ifDefined(params.list ? listId : undefined)}\n type=${params.type === 'date' ? 'datetime-local' : params.type}\n max=${ifDefined(params.type === 'date' ? '9999-12-31T23:59' : '')}\n .value=${normalizedValue}\n ?disabled=${params.disabled || params.readonly}\n @input=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n let newValue = input.value;\n\n try {\n if (params.type === 'date') {\n const newDate = new Date(input.value);\n if (!isNaN(newDate.getTime())) newValue = newDate.toISOString();\n }\n } catch {\n // ignore\n }\n\n params.onChange(newValue);\n }}\n />\n </div>\n\n <span\n class=${classMap({\n 'font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s': true,\n 'inline-block': !!normalizedValue || params.type === 'date',\n 'sr-only': !normalizedValue && params.type !== 'date',\n 'text-body': !params.disabled && !params.readonly,\n 'text-disabled': params.disabled,\n 'text-secondary': params.readonly,\n })}\n >\n ${params.t(params.label)}\n </span>\n\n ${params.list\n ? html`\n <datalist id=${listId}>\n ${params.list.map(\n ({ label, value }) => html`<option value=${value}>${params.t(label)}</option>`\n )}\n </datalist>\n `\n : ''}\n ${params.disabled || params.readonly\n ? ''\n : html`\n <div\n class=\"absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none\"\n ></div>\n `}\n </label>\n `;\n}\n"]}
|
|
@@ -10,6 +10,8 @@ function parseGroup(search) {
|
|
|
10
10
|
if (path.endsWith(']') && nameStart !== -1) {
|
|
11
11
|
name = path.substring(nameStart + 1, path.length - 1);
|
|
12
12
|
path = path.substring(0, nameStart);
|
|
13
|
+
if (path.endsWith(':name'))
|
|
14
|
+
path = path.substring(0, path.length - 5);
|
|
13
15
|
}
|
|
14
16
|
return { name, path, value, operator };
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,oBAAiB;AAEjD,SAAS,UAAU,CAAC,MAAc;;IAChC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAe,CAAC;IACxD,MAAM,QAAQ,SAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,mCAAI,IAAI,CAAC;IAEvF,IAAI,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACnF,IAAI,IAAI,GAAuB,SAAS,CAAC;IAEzC,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QAC1C,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACtD,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../../src/elements/public/Que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AAK,CAAC,MAAc;IAC3B,OAAO,MAAM;SACV,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAChB,GAAG,CAAC,KAAK,CAAC,EAAE;QACX,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAC/D,IAAI,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,GAAG,EAAC;YAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACP,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { Operator, ParsedValue } from '../types';\n\nfunction parseGroup(search: string): ParsedValue {\n const [fullPath, value] = search.split('=').map(decodeURIComponent);\n\n const operators = Object.values(Operator) as Operator[];\n const operator = operators.find(operator => fullPath.endsWith(`:${operator}`)) ?? null;\n\n let path = fullPath.substring(0, operator ? fullPath.lastIndexOf(':') : undefined);\n let name: string | undefined = undefined;\n\n const nameStart = fullPath.lastIndexOf('[');\n\n if (path.endsWith(']') && nameStart !== -1) {\n name = path.substring(nameStart + 1, path.length - 1);\n path = path.substring(0, nameStart);\n if (path.endsWith(':name')) path = path.substring(0, path.length - 5);\n }\n\n return { name, path, value, operator };\n}\n\nfunction parse(search: string): (ParsedValue | ParsedValue[])[] {\n return search\n .split('&')\n .filter(v => !!v)\n .map(entry => {\n const [name, value] = entry.split('=').map(decodeURIComponent);\n if (!value?.includes('|')) return parseGroup(entry);\n return `${encodeURIComponent(name)}=${value}`.split('|').map(v => parseGroup(v));\n });\n}\n\nexport { parse };\n"]}
|
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
function stringifyGroup(parsedValue) {
|
|
2
2
|
let result = parsedValue.path;
|
|
3
3
|
if (parsedValue.name)
|
|
4
|
-
result +=
|
|
4
|
+
result += `:name[${parsedValue.name}]`;
|
|
5
5
|
if (parsedValue.operator)
|
|
6
6
|
result += `:${parsedValue.operator}`;
|
|
7
7
|
result = `${encodeURIComponent(result)}=${encodeURIComponent(parsedValue.value)}`;
|
|
8
8
|
return result === '=' ? '' : result;
|
|
9
9
|
}
|
|
10
10
|
function stringify(newValue) {
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
const alternatives = [newRule[0].value, newRule.slice(1).map(or => stringifyGroup(or))];
|
|
11
|
+
const toQuery = (rules, rule) => {
|
|
12
|
+
if (Array.isArray(rule)) {
|
|
13
|
+
const alternatives = [rule[0].value, rule.slice(1).map(or => stringifyGroup(or))];
|
|
15
14
|
const orValue = alternatives.join('|');
|
|
16
|
-
|
|
15
|
+
rules.push(`${rule[0].path}=${encodeURIComponent(orValue)}`);
|
|
17
16
|
}
|
|
18
|
-
else {
|
|
19
|
-
|
|
17
|
+
else if (rule.path !== 'zoom') {
|
|
18
|
+
rules.push(stringifyGroup(rule));
|
|
20
19
|
}
|
|
20
|
+
return rules;
|
|
21
|
+
};
|
|
22
|
+
const query = newValue.reduce(toQuery, []);
|
|
23
|
+
const zoom = getZoomedRels(newValue).join(',');
|
|
24
|
+
if (zoom)
|
|
25
|
+
query.push(`zoom=${encodeURIComponent(zoom)}`);
|
|
26
|
+
return query.join('&');
|
|
27
|
+
}
|
|
28
|
+
function getZoomedRels(value) {
|
|
29
|
+
return value
|
|
30
|
+
.map(rule => {
|
|
31
|
+
if (Array.isArray(rule))
|
|
32
|
+
return getZoomedRels(rule);
|
|
33
|
+
if (rule.name)
|
|
34
|
+
return [rule.path];
|
|
35
|
+
const pathMembers = rule.path.split(':');
|
|
36
|
+
return pathMembers.slice(0, pathMembers.length - 1);
|
|
21
37
|
})
|
|
22
|
-
.
|
|
38
|
+
.flat()
|
|
39
|
+
.sort((rel1, rel2) => rel2.length - rel1.length)
|
|
40
|
+
.filter((rel, index, rels) => {
|
|
41
|
+
return rels.every((_rel, _index) => {
|
|
42
|
+
return (_index >= index || _rel !== rel) && !_rel.startsWith(`${rel}:`);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
23
45
|
}
|
|
24
46
|
export { stringify };
|
|
25
47
|
//# sourceMappingURL=stringify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/stringify.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,WAAwB;IAC9C,IAAI,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,IAAI,WAAW,CAAC,IAAI;QAAE,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../../../../src/elements/public/QueryBuilder/utils/stringify.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,WAAwB;IAC9C,IAAI,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,IAAI,WAAW,CAAC,IAAI;QAAE,MAAM,IAAI,SAAS,WAAW,CAAC,IAAI,GAAG,CAAC;IAC7D,IAAI,WAAW,CAAC,QAAQ;QAAE,MAAM,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC/D,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;IAClF,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACtC,CAAC;AAED,SAAS,SAAS,CAAC,QAAyC;IAC1D,MAAM,OAAO,GAAG,CAAC,KAAe,EAAE,IAAiC,EAAE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IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC;SACD,IAAI,EAAE;SACN,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;SAC/C,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACjC,OAAO,CAAC,MAAM,IAAI,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { ParsedValue } from '../types';\n\nfunction stringifyGroup(parsedValue: ParsedValue): string {\n let result = parsedValue.path;\n if (parsedValue.name) result += `:name[${parsedValue.name}]`;\n if (parsedValue.operator) result += `:${parsedValue.operator}`;\n result = `${encodeURIComponent(result)}=${encodeURIComponent(parsedValue.value)}`;\n return result === '=' ? '' : result;\n}\n\nfunction stringify(newValue: (ParsedValue | ParsedValue[])[]): string {\n const toQuery = (rules: string[], rule: ParsedValue | ParsedValue[]) => {\n if (Array.isArray(rule)) {\n const alternatives = [rule[0].value, rule.slice(1).map(or => stringifyGroup(or))];\n const orValue = alternatives.join('|');\n\n rules.push(`${rule[0].path}=${encodeURIComponent(orValue)}`);\n } else if (rule.path !== 'zoom') {\n rules.push(stringifyGroup(rule));\n }\n\n return rules;\n };\n\n const query = newValue.reduce(toQuery, [] as string[]);\n const zoom = getZoomedRels(newValue).join(',');\n\n if (zoom) query.push(`zoom=${encodeURIComponent(zoom)}`);\n return query.join('&');\n}\n\nfunction getZoomedRels(value: (ParsedValue | ParsedValue[])[]): string[] {\n return value\n .map(rule => {\n if (Array.isArray(rule)) return getZoomedRels(rule);\n if (rule.name) return [rule.path];\n\n const pathMembers = rule.path.split(':');\n return pathMembers.slice(0, pathMembers.length - 1);\n })\n .flat()\n .sort((rel1, rel2) => rel2.length - rel1.length)\n .filter((rel, index, rels) => {\n return rels.every((_rel, _index) => {\n return (_index >= index || _rel !== rel) && !_rel.startsWith(`${rel}:`);\n });\n });\n}\n\nexport { stringify };\n"]}
|
|
@@ -239,6 +239,7 @@ export class TemplateForm extends Base {
|
|
|
239
239
|
|
|
240
240
|
<foxy-internal-source-control
|
|
241
241
|
placeholder=${this.t('url_source_placeholder')}
|
|
242
|
+
helper-text=""
|
|
242
243
|
label=${this.t('url_source_label')}
|
|
243
244
|
infer="content"
|
|
244
245
|
class="mt-m${((_b = this.data) === null || _b === void 0 ? void 0 : _b.content) ? '' : ' hidden'}"
|
|
@@ -248,6 +249,7 @@ export class TemplateForm extends Base {
|
|
|
248
249
|
|
|
249
250
|
<foxy-internal-source-control
|
|
250
251
|
placeholder=${this.t('clipboard_source_placeholder')}
|
|
252
|
+
helper-text=""
|
|
251
253
|
label=${this.t('clipboard_source_label')}
|
|
252
254
|
infer="content"
|
|
253
255
|
class="mb-m${contentChoice === 'clipboard' ? '' : ' hidden'}"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateForm/TemplateForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AAEnE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;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IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import { PropertyDeclarations, TemplateResult, html } from 'lit-element';\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { Data, Templates } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\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 { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst NS = 'template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing templates (`fx:cart_include_template`, `fx:checkout_template`, `fx:cart_template`).\n *\n * @slot description:before\n * @slot description:after\n *\n * @slot content:before\n * @slot content:after\n *\n * @slot timestamps:before\n * @slot timestamps:after\n *\n * @slot create:before\n * @slot create:after\n *\n * @slot delete:before\n * @slot delete:after\n *\n * @element foxy-template-form\n * @since 1.14.0\n */\nexport class TemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-source-control': customElements.get('foxy-internal-source-control'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n templates: Templates = {};\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\n\n private __contentChoice: 'default' | 'url' | 'clipboard' = 'default';\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 <div class=\"space-y-m relative\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\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 protected async _sendPost(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPost(edits);\n if (!data.content_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPatch(edits);\n if (!edits.content_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n private __renderDescription() {\n const scope = 'description';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <vaadin-text-field\n data-testid=${scope}\n class=\"w-full mb-s\"\n label=${this.t(scope)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(scope)}\n ?readonly=${this.readonlySelector.matches(scope)}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n </div>\n `;\n }\n\n private __renderContent() {\n const scope = 'content';\n const url = this.form.content_url;\n const source = this.form.content;\n const contentChoice = url ? 'url' : source ? 'clipboard' : this.__contentChoice;\n\n const isDisabled = !this.in('idle') || this.disabledSelector.matches(scope);\n const isReadonly = this.readonlySelector.matches(scope);\n const isSyncProhibited = isReadonly || !this.data?.content_url || url !== this.data.content_url;\n\n return html`\n <div data-testid=\"content\">\n <x-group frame>\n <foxy-i18n\n class=${classMap({ 'transition-colors': true, 'text-disabled': isDisabled })}\n lang=${this.lang}\n slot=\"header\"\n key=\"template\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <x-choice\n data-testid=\"content-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ content: '', content_url: '' });\n this.__contentChoice = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s leading-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n class=\"mb-m\"\n slot=\"url\"\n ?hidden=${contentChoice !== 'url'}\n >\n <div class=\"flex items-end mt-0\">\n <vaadin-text-field\n data-testid=\"content-url\"\n placeholder=\"https://example.com/my-template\"\n label=${this.t('url')}\n class=\"flex-1 min-w-0\"\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n .value=${this.form.content_url}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ content: '', content_url: value });\n }}\n >\n </vaadin-text-field>\n\n <vaadin-button\n data-testid=\"cache\"\n class=\"relative flex-shrink-0 ml-s\"\n ?hidden=${isSyncProhibited}\n ?disabled=${isDisabled || this.__cacheState === 'busy'}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('url_source_placeholder')}\n label=${this.t('url_source_label')}\n infer=\"content\"\n class=\"mt-m${this.data?.content ? '' : ' hidden'}\"\n >\n </foxy-internal-source-control>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('clipboard_source_placeholder')}\n label=${this.t('clipboard_source_label')}\n infer=\"content\"\n class=\"mb-m${contentChoice === 'clipboard' ? '' : ' hidden'}\"\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n slot=\"clipboard\"\n >\n </foxy-internal-source-control>\n </x-choice>\n </x-group>\n </div>\n `;\n }\n\n private __renderTimestamps() {\n const scope = 'timestamps';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}: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(`${scope}: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 <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 <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? (href ? 'error' : 'primary 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 private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n this.refresh();\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/TemplateForm/TemplateForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AAEnE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAElE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,EAAE,GAAG,eAAe,CAAC;AAC3B,MAAM,IAAI,GAAG,mBAAmB,CAC9B,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CACzE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,YAAa,SAAQ,IAAU;IAA5C;;QAwBE,cAAS,GAAc,EAAE,CAAC;QAElB,iBAAY,GAA6B,MAAM,CAAC;QAEhD,oBAAe,GAAoC,SAAS,CAAC;IA6SvE,CAAC;IAxUC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAClC,eAAe,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SACtC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,cAAc;Q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CAAC,oBAAoB,CAAC,GAAG,MAAM,QAAQ,CAAC;;KAEjD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAClD,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import { PropertyDeclarations, TemplateResult, html } from 'lit-element';\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { Data, Templates } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\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 { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst NS = 'template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing templates (`fx:cart_include_template`, `fx:checkout_template`, `fx:cart_template`).\n *\n * @slot description:before\n * @slot description:after\n *\n * @slot content:before\n * @slot content:after\n *\n * @slot timestamps:before\n * @slot timestamps:after\n *\n * @slot create:before\n * @slot create:after\n *\n * @slot delete:before\n * @slot delete:after\n *\n * @element foxy-template-form\n * @since 1.14.0\n */\nexport class TemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-source-control': customElements.get('foxy-internal-source-control'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n templates: Templates = {};\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\n\n private __contentChoice: 'default' | 'url' | 'clipboard' = 'default';\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 <div class=\"space-y-m relative\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\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 protected async _sendPost(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPost(edits);\n if (!data.content_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPatch(edits);\n if (!edits.content_url) return data;\n\n this.__cacheState = 'busy';\n const url = data._links['fx:cache'].href;\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n\n return await this._fetch(data._links.self.href);\n }\n\n private __renderDescription() {\n const scope = 'description';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}:before`)}\n\n <vaadin-text-field\n data-testid=${scope}\n class=\"w-full mb-s\"\n label=${this.t(scope)}\n ?disabled=${!this.in('idle') || this.disabledSelector.matches(scope)}\n ?readonly=${this.readonlySelector.matches(scope)}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot(`${scope}:after`)}\n </div>\n `;\n }\n\n private __renderContent() {\n const scope = 'content';\n const url = this.form.content_url;\n const source = this.form.content;\n const contentChoice = url ? 'url' : source ? 'clipboard' : this.__contentChoice;\n\n const isDisabled = !this.in('idle') || this.disabledSelector.matches(scope);\n const isReadonly = this.readonlySelector.matches(scope);\n const isSyncProhibited = isReadonly || !this.data?.content_url || url !== this.data.content_url;\n\n return html`\n <div data-testid=\"content\">\n <x-group frame>\n <foxy-i18n\n class=${classMap({ 'transition-colors': true, 'text-disabled': isDisabled })}\n lang=${this.lang}\n slot=\"header\"\n key=\"template\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <x-choice\n data-testid=\"content-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ content: '', content_url: '' });\n this.__contentChoice = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s leading-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n class=\"mb-m\"\n slot=\"url\"\n ?hidden=${contentChoice !== 'url'}\n >\n <div class=\"flex items-end mt-0\">\n <vaadin-text-field\n data-testid=\"content-url\"\n placeholder=\"https://example.com/my-template\"\n label=${this.t('url')}\n class=\"flex-1 min-w-0\"\n ?readonly=${isReadonly}\n ?disabled=${isDisabled}\n .value=${this.form.content_url}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ content: '', content_url: value });\n }}\n >\n </vaadin-text-field>\n\n <vaadin-button\n data-testid=\"cache\"\n class=\"relative flex-shrink-0 ml-s\"\n ?hidden=${isSyncProhibited}\n ?disabled=${isDisabled || this.__cacheState === 'busy'}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('url_source_placeholder')}\n helper-text=\"\"\n label=${this.t('url_source_label')}\n infer=\"content\"\n class=\"mt-m${this.data?.content ? '' : ' hidden'}\"\n >\n </foxy-internal-source-control>\n </div>\n\n <foxy-internal-source-control\n placeholder=${this.t('clipboard_source_placeholder')}\n helper-text=\"\"\n label=${this.t('clipboard_source_label')}\n infer=\"content\"\n class=\"mb-m${contentChoice === 'clipboard' ? '' : ' hidden'}\"\n style=\"--lumo-border-radius: var(--lumo-border-radius-s)\"\n slot=\"clipboard\"\n >\n </foxy-internal-source-control>\n </x-choice>\n </x-group>\n </div>\n `;\n }\n\n private __renderTimestamps() {\n const scope = 'timestamps';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${scope}: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(`${scope}: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 <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 <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? (href ? 'error' : 'primary 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 private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new TemplateForm.API(this).fetch(url, { method: 'POST' });\n this.__cacheState = response.ok ? 'idle' : 'fail';\n this.refresh();\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function serializeDate(date: Date): string;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function serializeDateTime(date: Date): string;
|
|
@@ -5,11 +5,12 @@ export function serializeDate(date) {
|
|
|
5
5
|
date.getDate().toString().padStart(2, '0'),
|
|
6
6
|
].join('-');
|
|
7
7
|
}
|
|
8
|
-
export function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export function serializeDateTime(date) {
|
|
9
|
+
const YYYY = date.getFullYear().toString().padStart(4, '0');
|
|
10
|
+
const MM = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
11
|
+
const DD = date.getDate().toString().padStart(2, '0');
|
|
12
|
+
const hh = date.getHours().toString().padStart(2, '0');
|
|
13
|
+
const mm = date.getMinutes().toString().padStart(2, '0');
|
|
14
|
+
return `${YYYY}-${MM}-${DD}T${hh}:${mm}`;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=serialize-date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-date.js","sourceRoot":"","sources":["../../src/utils/serialize-date.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC,OAAO;QACL,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;QAC9C,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;QACjD,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;KAC3C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"serialize-date.js","sourceRoot":"","sources":["../../src/utils/serialize-date.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC,OAAO;QACL,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;QAC9C,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;QACjD,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;KAC3C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAU;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7D,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtD,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEzD,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["export function serializeDate(date: Date): string {\n return [\n date.getFullYear().toString().padStart(4, '0'),\n (date.getMonth() + 1).toString().padStart(2, '0'),\n date.getDate().toString().padStart(2, '0'),\n ].join('-');\n}\n\nexport function serializeDateTime(date: Date): string {\n const YYYY = date.getFullYear().toString().padStart(4, '0');\n const MM = (date.getMonth() + 1).toString().padStart(2, '0');\n const DD = date.getDate().toString().padStart(2, '0');\n const hh = date.getHours().toString().padStart(2, '0');\n const mm = date.getMinutes().toString().padStart(2, '0');\n\n return `${YYYY}-${MM}-${DD}T${hh}:${mm}`;\n}\n"]}
|