@foxy.io/elements 1.52.0 → 1.53.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-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-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-form.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/shared-0489bbee.js +40 -0
- package/dist/cdn/{shared-2559d303.js → shared-1d6a5e81.js} +1 -1
- package/dist/cdn/{shared-49558171.js → shared-28c5d636.js} +1 -1
- package/dist/cdn/shared-2bb1f0f4.js +1 -0
- package/dist/cdn/{shared-d55c7c67.js → shared-3ce475ee.js} +1 -1
- package/dist/cdn/{shared-5ad5e258.js → shared-4332bafc.js} +1 -1
- package/dist/cdn/{shared-6bb9a580.js → shared-540adfea.js} +1 -1
- package/dist/cdn/{shared-61ddd174.js → shared-75771f16.js} +1 -1
- package/dist/cdn/{shared-54f824d8.js → shared-8146467b.js} +1 -1
- package/dist/cdn/{shared-d2b3205f.js → shared-8449b585.js} +1 -1
- package/dist/cdn/shared-8aeb0657.js +1 -0
- package/dist/cdn/{shared-17c9e095.js → shared-9ed0a201.js} +1 -1
- package/dist/cdn/{shared-4da1f187.js → shared-ad26f72d.js} +1 -1
- package/dist/cdn/shared-ba230a1b.js +1 -0
- package/dist/cdn/shared-d1125001.js +1 -0
- package/dist/cdn/{shared-e6804126.js → shared-d9bc3fec.js} +1 -1
- package/dist/cdn/{shared-d9f83737.js → shared-e77c5c90.js} +1 -1
- package/dist/cdn/{shared-c8368877.js → shared-ee48a1ed.js} +1 -1
- package/dist/cdn/{shared-9109ae93.js → shared-f3ec0559.js} +1 -1
- package/dist/cdn/{shared-fda3270b.js → shared-f6c6ce5f.js} +1 -1
- package/dist/cdn/{shared-da31cee5.js → shared-f892683b.js} +1 -1
- package/dist/cdn/shared-fe72474f.js +1 -0
- package/dist/elements/internal/InternalEditableControl/InternalEditableControl.d.ts +4 -0
- package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js +14 -0
- package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js.map +1 -1
- package/dist/elements/internal/InternalFrequencyControl/InternalFrequencyControl.d.ts +1 -0
- package/dist/elements/internal/InternalFrequencyControl/InternalFrequencyControl.js +11 -0
- package/dist/elements/internal/InternalFrequencyControl/InternalFrequencyControl.js.map +1 -1
- package/dist/elements/internal/InternalNativeDateControl/InternalNativeDateControl.d.ts +1 -0
- package/dist/elements/internal/InternalNativeDateControl/InternalNativeDateControl.js +9 -0
- package/dist/elements/internal/InternalNativeDateControl/InternalNativeDateControl.js.map +1 -1
- package/dist/elements/internal/InternalNumberControl/InternalNumberControl.d.ts +1 -0
- package/dist/elements/internal/InternalNumberControl/InternalNumberControl.js +11 -0
- package/dist/elements/internal/InternalNumberControl/InternalNumberControl.js.map +1 -1
- package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControl.d.ts +1 -0
- package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControl.js +11 -0
- package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControl.js.map +1 -1
- package/dist/elements/internal/InternalSelectControl/InternalSelectControl.d.ts +1 -0
- package/dist/elements/internal/InternalSelectControl/InternalSelectControl.js +11 -0
- package/dist/elements/internal/InternalSelectControl/InternalSelectControl.js.map +1 -1
- package/dist/elements/internal/InternalSwitchControl/InternalSwitchControl.d.ts +1 -0
- package/dist/elements/internal/InternalSwitchControl/InternalSwitchControl.js +9 -0
- package/dist/elements/internal/InternalSwitchControl/InternalSwitchControl.js.map +1 -1
- package/dist/elements/internal/InternalTextControl/InternalTextControl.d.ts +1 -0
- package/dist/elements/internal/InternalTextControl/InternalTextControl.js +11 -0
- package/dist/elements/internal/InternalTextControl/InternalTextControl.js.map +1 -1
- package/dist/elements/public/FilterAttributeForm/FilterAttributeForm.d.ts +4 -1
- package/dist/elements/public/FilterAttributeForm/FilterAttributeForm.js +5 -0
- package/dist/elements/public/FilterAttributeForm/FilterAttributeForm.js.map +1 -1
- package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js +3 -3
- package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js.map +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.d.ts +3 -3
- package/dist/elements/public/QueryBuilder/QueryBuilder.js +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/AdvancedGroup.d.ts +2 -2
- package/dist/elements/public/QueryBuilder/components/AdvancedGroup.js +4 -0
- package/dist/elements/public/QueryBuilder/components/AdvancedGroup.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/AdvancedOperatorToggle.js +3 -3
- package/dist/elements/public/QueryBuilder/components/AdvancedOperatorToggle.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleGroup.js +2 -0
- package/dist/elements/public/QueryBuilder/components/SimpleGroup.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleInput.js +7 -1
- package/dist/elements/public/QueryBuilder/components/SimpleInput.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleNameValuePairRule.d.ts +2 -0
- package/dist/elements/public/QueryBuilder/components/SimpleNameValuePairRule.js +78 -0
- package/dist/elements/public/QueryBuilder/components/SimpleNameValuePairRule.js.map +1 -0
- package/dist/elements/public/QueryBuilder/types.d.ts +5 -0
- package/dist/elements/public/QueryBuilder/types.js +1 -0
- package/dist/elements/public/QueryBuilder/types.js.map +1 -1
- package/package.json +2 -2
- package/dist/cdn/shared-1dfc1e37.js +0 -1
- package/dist/cdn/shared-79dd8c55.js +0 -40
- package/dist/cdn/shared-8874ec69.js +0 -1
- package/dist/cdn/shared-b0ff4acd.js +0 -1
- package/dist/cdn/shared-c57aac01.js +0 -1
- package/dist/cdn/shared-ec6a369a.js +0 -1
package/dist/elements/internal/InternalResourcePickerControl/InternalResourcePickerControl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalResourcePickerControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalResourcePickerControl/InternalResourcePickerControl.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,kDAA+C;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAIxC,MAAM,OAAO,6BAA8B,SAAQ,uBAAuB;IAA1E;;QAmBE,2BAAsB,GAA0B,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE3E,qBAAgB,GAAG,KAAK,CAAC;QAEzB,gBAAW,GAAG,QAAQ,CAAC,mCAAmC,CAAC,CAAC;QAE5D,eAAU,GAA4D,IAAI,CAAC;QAE3E,cAAS,GAA4B,EAAE,CAAC;QAExC,YAAO,G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AU,IAAI,CAAC,WAAW,QAAQ,IAAI,MAAM,KAAK,KAAK,EAAE;YAClE,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;SAChD;IACH,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,OAAgB;QAC3C,MAAM,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAA0B,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,IAAI,CAAC,WAAW,QAAQ,EAAE,EAAE;YAC9D,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,IAAI,CAAC,WAAW,QAAQ,EAAE,EAAE;YAC9D,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,cAAc,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { HALJSONResource } from '../../public/NucleonElement/types';\nimport type { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport type { FormRenderer } from '../../public/FormDialog/types';\nimport type { ItemRenderer } from '../../public/CollectionPage/types';\nimport type { FormDialog } from '../../public/FormDialog/FormDialog';\nimport type { Option } from '../../public/QueryBuilder/types';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { getResourceId } from '@foxy.io/sdk/core';\nimport { FetchEvent } from '../../public/NucleonElement/FetchEvent';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\nimport { uniqueId } from 'lodash-es';\nimport { spread } from '@open-wc/lit-helpers';\n\nimport memoize from 'lodash-es/memoize';\n\ntype DisplayValueOptionsCb = (resource: HALJSONResource) => Record<string, unknown>;\n\nexport class InternalResourcePickerControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getDisplayValueOptions: { attribute: false },\n showCopyIdButton: { type: Boolean, attribute: 'show-copy-id-button' },\n virtualHost: {},\n getItemUrl: { attribute: false },\n formProps: { type: Object },\n filters: { type: Array },\n extendFilter: { type: Function, attribute: false },\n layout: {},\n first: {},\n item: {},\n form: {},\n __isErrorVisible: { attribute: false },\n };\n }\n\n getDisplayValueOptions: DisplayValueOptionsCb = resource => ({ resource });\n\n showCopyIdButton = false;\n\n virtualHost = uniqueId('internal-resource-picker-control-');\n\n getItemUrl: ((href: string, data: unknown | null) => string) | null = null;\n\n formProps: Record<string, unknown> = {};\n\n filters: Option[] = [];\n\n /** Function to extend the filters applied to the dataset query without making it obvious to the user. */\n extendFilter: ((params: URLSearchParams) => void) | null = null;\n\n layout: 'summary-item' | 'standalone' | null = null;\n\n first: string | null = null;\n\n item: string | null = null;\n\n form: string | null | FormRenderer = null;\n\n private __isErrorVisible = false;\n\n private readonly __getItemRenderer = memoize((item: string | null) => {\n return new Function(\n 'ctx',\n `return ctx.html\\`\n <${item ?? 'foxy-null'}\n related=\\${JSON.stringify(ctx.related)}\n parent=\\${ctx.parent}\n infer=\"card\"\n href=$\\{ctx.href}\n ...=\\${ctx.spread(ctx.props)}\n >\n </${item ?? 'foxy-null'}>\\``\n ) as ItemRenderer;\n });\n\n renderControl(): TemplateResult {\n const dialogProps = {\n ...this.formProps,\n '.selectionProps': {\n '.extendFilter': this.extendFilter,\n '.filters': this.filters,\n '.first': this.first,\n '.item': this.item,\n },\n };\n\n return html`\n <foxy-form-dialog\n parent=\"foxy://${this.virtualHost}/select\"\n header=\"header\"\n infer=\"dialog\"\n alert\n .props=${dialogProps}\n .form=${this.form ?? 'foxy-internal-resource-picker-control-form'}\n @fetch=${this.__handleFetchEvent}\n @hide=${() => (this.__isErrorVisible = true)}\n >\n </foxy-form-dialog>\n\n ${this.layout === 'summary-item'\n ? this.__renderSummaryItemLayout()\n : this.__renderStandaloneLayout()}\n `;\n }\n\n reportValidity(): void {\n this.__isErrorVisible = true;\n super.reportValidity();\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (changes.has('item')) this.__getItemRenderer.cache.clear?.();\n }\n\n private __clear(): void {\n this._value = '';\n this.dispatchEvent(new CustomEvent('clear'));\n }\n\n private __renderSummaryItemLayout() {\n const resource = this.renderRoot.querySelector<NucleonElement<any>>('#value');\n const onClick = (evt: Event) => {\n if (this.disabled || this.readonly) return;\n const button = evt.currentTarget as HTMLButtonElement;\n const dialog = this.renderRoot.querySelector('foxy-form-dialog') as FormDialog;\n\n dialog.href = '';\n dialog.show(button);\n };\n\n return html`\n <div class=\"leading-xs\">\n <div class=\"flex items-center gap-xs\">\n <div class=\"text-m text-body whitespace-nowrap flex-1\">${this.label}</div>\n\n <button\n aria-label=${this.t('select')}\n class=${classMap({\n 'text-right min-w-0 transition-colors transition-opacity': true,\n 'rounded-s focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'cursor-pointer text-body hover-opacity-80': !this.disabled && !this.readonly,\n 'font-medium': !this.readonly,\n })}\n ?disabled=${this.disabled || this.readonly}\n @click=${onClick}\n >\n <div class=\"truncate min-w-0\">\n ${this._value\n ? html`\n <foxy-i18n\n infer=\"\"\n key=\"value\"\n .options=${resource?.data\n ? this.getDisplayValueOptions(resource.data)\n : { context: resource?.in('fail') ? 'fail' : 'busy' }}\n >\n </foxy-i18n>\n `\n : this.placeholder}\n </div>\n </button>\n\n <button\n aria-label=${this.t('clear')}\n class=${classMap({\n 'rounded-full transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'cursor-pointer text-tertiary hover-text-body': !this.disabled,\n 'cursor-default text-disabled': this.disabled,\n })}\n style=\"width: 1em; height: 1em;\"\n ?disabled=${this.disabled}\n ?hidden=${this.readonly || !this._value}\n @click=${this.__clear}\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1em; height: 1em; transform: scale(1.25); margin-right: -0.16em\"><path d=\"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" /></svg>`}\n </button>\n </div>\n\n <div style=\"max-width: 32rem\">\n <div class=\"text-xs text-secondary\">${this.helperText}</div>\n <div\n class=\"text-xs text-error\"\n ?hidden=${this.disabled || this.readonly || !this.__isErrorVisible}\n >\n ${this._errorMessage}\n </div>\n </div>\n </div>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this._value || void 0)}\n id=\"value\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private __renderStandaloneLayout() {\n const valueLoader = this.__valueLoader;\n const selectionId = typeof this._value === 'string' ? getResourceId(this._value) : void 0;\n const selectionUrl =\n typeof this._value === 'string'\n ? this.getItemUrl?.(this._value, valueLoader?.data ?? null)\n : void 0;\n\n return html`\n <div class=\"block group\">\n <div\n class=${classMap({\n 'flex items-center gap-s transition-colors font-medium': true,\n 'text-disabled': this.disabled,\n })}\n >\n <span class=\"mr-auto text-l\">${this.label}</span>\n ${selectionUrl\n ? html`\n <a\n class=\"text-body rounded transition-opacity hover-opacity-90 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=${selectionUrl}\n >\n <foxy-i18n infer=\"\" key=\"view\"></foxy-i18n>\n </a>\n `\n : ''}\n ${this.showCopyIdButton && selectionId !== null\n ? html`\n <foxy-copy-to-clipboard\n layout=\"text\"\n theme=\"contrast tertiary-inline\"\n infer=\"copy-id\"\n text=${selectionId}\n >\n </foxy-copy-to-clipboard>\n `\n : ''}\n ${this.readonly || !this._value\n ? ''\n : html`\n <vaadin-button\n theme=\"error tertiary-inline\"\n ?disabled=${this.disabled}\n @click=${this.__clear}\n >\n <foxy-i18n infer=\"\" key=\"clear\"></foxy-i18n>\n </vaadin-button>\n `}\n </div>\n\n <div class=\"text-secondary text-s\" ?hidden=${!this.helperText}>${this.helperText}</div>\n\n <button\n class=${classMap({\n 'block w-full bg-contrast-5 rounded text-left transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'cursor-pointer hover-bg-contrast-10': !this.disabled && !this.readonly,\n 'cursor-default': this.disabled || this.readonly,\n 'mt-s': !!this.label || !!this.helperText,\n })}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n ?disabled=${this.disabled || this.readonly}\n @click=${(evt: MouseEvent) => {\n const button = evt.currentTarget as HTMLButtonElement;\n const dialog = this.renderRoot.querySelector('foxy-form-dialog') as FormDialog;\n\n dialog.href = '';\n dialog.show(button);\n }}\n >\n <div class=${classMap({ 'transition-opacity': true, 'opacity-50': this.disabled })}>\n <foxy-nucleon\n class=\"block\"\n infer=\"\"\n href=${ifDefined(this._value || void 0)}\n id=\"valueLoader\"\n @update=${() => this.requestUpdate()}\n >\n ${this.__getItemRenderer(this.item)({\n html,\n data: valueLoader?.data ?? null,\n href: (this._value as string | undefined) || '',\n related: [],\n parent: '',\n props: {},\n spread: spread,\n simplifyNsLoading: this.simplifyNsLoading,\n disabled: this.disabled,\n disabledControls: this.disabledControls,\n readonly: this.readonly,\n readonlyControls: this.readonlyControls,\n hidden: this.hidden,\n hiddenControls: this.hiddenControls,\n templates: this.templates,\n previous: null,\n next: null,\n group: this.nucleon?.group ?? '',\n lang: this.lang,\n ns: this.ns,\n })}\n </foxy-nucleon>\n </div>\n </button>\n\n <div\n class=\"mt-xs text-xs leading-xs text-error\"\n ?hidden=${!this._errorMessage || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </div>\n </div>\n `;\n }\n\n private __handleFetchEvent(event: Event) {\n if (!(event instanceof FetchEvent)) return;\n if (event.defaultPrevented) return;\n\n const { url, method } = event.request;\n\n if (url === `foxy://${this.virtualHost}/select` && method === 'POST') {\n return event.respondWith(this.__handleSelect(event.request));\n }\n\n if (url === `foxy://${this.virtualHost}/empty` && method === 'GET') {\n return event.respondWith(this.__handleEmpty());\n }\n }\n\n private async __handleSelect(request: Request): Promise<Response> {\n const body = (await request.clone().json()) as { selection: string };\n this._value = body.selection;\n return new Response(\n JSON.stringify({\n _links: { self: { href: `foxy://${this.virtualHost}/empty` } },\n message: 'Resource selected.',\n })\n );\n }\n\n private async __handleEmpty(): Promise<Response> {\n return new Response(\n JSON.stringify({\n _links: { self: { href: `foxy://${this.virtualHost}/empty` } },\n message: 'Resource selected.',\n })\n );\n }\n\n private get __valueLoader() {\n type Loader = NucleonElement<any>;\n return this.renderRoot.querySelector<Loader>('#valueLoader');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalResourcePickerControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalResourcePickerControl/InternalResourcePickerControl.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,kDAA+C;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAA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AI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,IAAI,CAAC,WAAW,QAAQ,EAAE,EAAE;YAC9D,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,IAAI,CAAC,WAAW,QAAQ,EAAE,EAAE;YAC9D,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,cAAc,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { HALJSONResource } from '../../public/NucleonElement/types';\nimport type { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport type { FormRenderer } from '../../public/FormDialog/types';\nimport type { ItemRenderer } from '../../public/CollectionPage/types';\nimport type { FormDialog } from '../../public/FormDialog/FormDialog';\nimport type { Option } from '../../public/QueryBuilder/types';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { getResourceId } from '@foxy.io/sdk/core';\nimport { FetchEvent } from '../../public/NucleonElement/FetchEvent';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\nimport { uniqueId } from 'lodash-es';\nimport { spread } from '@open-wc/lit-helpers';\n\nimport memoize from 'lodash-es/memoize';\n\ntype DisplayValueOptionsCb = (resource: HALJSONResource) => Record<string, unknown>;\n\nexport class InternalResourcePickerControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getDisplayValueOptions: { attribute: false },\n showCopyIdButton: { type: Boolean, attribute: 'show-copy-id-button' },\n virtualHost: {},\n getItemUrl: { attribute: false },\n formProps: { type: Object },\n filters: { type: Array },\n extendFilter: { type: Function, attribute: false },\n layout: {},\n first: {},\n item: {},\n form: {},\n __isErrorVisible: { attribute: false },\n };\n }\n\n getDisplayValueOptions: DisplayValueOptionsCb = resource => ({ resource });\n\n showCopyIdButton = false;\n\n virtualHost = uniqueId('internal-resource-picker-control-');\n\n getItemUrl: ((href: string, data: unknown | null) => string) | null = null;\n\n formProps: Record<string, unknown> = {};\n\n filters: Option[] = [];\n\n /** Function to extend the filters applied to the dataset query without making it obvious to the user. */\n extendFilter: ((params: URLSearchParams) => void) | null = null;\n\n layout: 'summary-item' | 'standalone' | null = null;\n\n first: string | null = null;\n\n item: string | null = null;\n\n form: string | null | FormRenderer = null;\n\n private __isErrorVisible = false;\n\n private readonly __getItemRenderer = memoize((item: string | null) => {\n return new Function(\n 'ctx',\n `return ctx.html\\`\n <${item ?? 'foxy-null'}\n related=\\${JSON.stringify(ctx.related)}\n parent=\\${ctx.parent}\n infer=\"card\"\n href=$\\{ctx.href}\n ...=\\${ctx.spread(ctx.props)}\n >\n </${item ?? 'foxy-null'}>\\``\n ) as ItemRenderer;\n });\n\n renderControl(): TemplateResult {\n const dialogProps = {\n ...this.formProps,\n '.selectionProps': {\n '.extendFilter': this.extendFilter,\n '.filters': this.filters,\n '.first': this.first,\n '.item': this.item,\n },\n };\n\n return html`\n <foxy-form-dialog\n parent=\"foxy://${this.virtualHost}/select\"\n header=\"header\"\n infer=\"dialog\"\n alert\n .props=${dialogProps}\n .form=${this.form ?? 'foxy-internal-resource-picker-control-form'}\n @fetch=${this.__handleFetchEvent}\n @hide=${() => (this.__isErrorVisible = true)}\n >\n </foxy-form-dialog>\n\n ${this.layout === 'summary-item'\n ? this.__renderSummaryItemLayout()\n : this.__renderStandaloneLayout()}\n `;\n }\n\n reportValidity(): void {\n this.__isErrorVisible = true;\n super.reportValidity();\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (changes.has('item')) this.__getItemRenderer.cache.clear?.();\n }\n\n protected _handleHostClick(evt: MouseEvent): void {\n if (this.layout !== 'summary-item') return;\n const composedPath = evt.composedPath() as HTMLElement[];\n const noOp = new Set(['BUTTON']);\n if (!composedPath.some(el => noOp.has(el.tagName))) {\n this.renderRoot.querySelector('button')?.click();\n super._handleHostClick(evt);\n }\n }\n\n private __clear(): void {\n this._value = '';\n this.dispatchEvent(new CustomEvent('clear'));\n }\n\n private __renderSummaryItemLayout() {\n const resource = this.renderRoot.querySelector<NucleonElement<any>>('#value');\n const onClick = (evt: Event) => {\n if (this.disabled || this.readonly) return;\n const button = evt.currentTarget as HTMLButtonElement;\n const dialog = this.renderRoot.querySelector('foxy-form-dialog') as FormDialog;\n\n dialog.href = '';\n dialog.show(button);\n };\n\n return html`\n <div class=\"leading-xs\">\n <div class=\"flex items-center gap-xs\">\n <div class=\"text-m text-body whitespace-nowrap flex-1\">${this.label}</div>\n\n <button\n aria-label=${this.t('select')}\n class=${classMap({\n 'text-right min-w-0 transition-colors transition-opacity': true,\n 'rounded-s focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'cursor-pointer text-body hover-opacity-80': !this.disabled && !this.readonly,\n 'font-medium': !this.readonly,\n })}\n ?disabled=${this.disabled || this.readonly}\n @click=${onClick}\n >\n <div class=\"truncate min-w-0\">\n ${this._value\n ? html`\n <foxy-i18n\n infer=\"\"\n key=\"value\"\n .options=${resource?.data\n ? this.getDisplayValueOptions(resource.data)\n : { context: resource?.in('fail') ? 'fail' : 'busy' }}\n >\n </foxy-i18n>\n `\n : this.placeholder}\n </div>\n </button>\n\n <button\n aria-label=${this.t('clear')}\n class=${classMap({\n 'rounded-full transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'cursor-pointer text-tertiary hover-text-body': !this.disabled,\n 'cursor-default text-disabled': this.disabled,\n })}\n style=\"width: 1em; height: 1em;\"\n ?disabled=${this.disabled}\n ?hidden=${this.readonly || !this._value}\n @click=${this.__clear}\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1em; height: 1em; transform: scale(1.25); margin-right: -0.16em\"><path d=\"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" /></svg>`}\n </button>\n </div>\n\n <div style=\"max-width: 32rem\">\n <div class=\"text-xs text-secondary\">${this.helperText}</div>\n <div\n class=\"text-xs text-error\"\n ?hidden=${this.disabled || this.readonly || !this.__isErrorVisible}\n >\n ${this._errorMessage}\n </div>\n </div>\n </div>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this._value || void 0)}\n id=\"value\"\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private __renderStandaloneLayout() {\n const valueLoader = this.__valueLoader;\n const selectionId = typeof this._value === 'string' ? getResourceId(this._value) : void 0;\n const selectionUrl =\n typeof this._value === 'string'\n ? this.getItemUrl?.(this._value, valueLoader?.data ?? null)\n : void 0;\n\n return html`\n <div class=\"block group\">\n <div\n class=${classMap({\n 'flex items-center gap-s transition-colors font-medium': true,\n 'text-disabled': this.disabled,\n })}\n >\n <span class=\"mr-auto text-l\">${this.label}</span>\n ${selectionUrl\n ? html`\n <a\n class=\"text-body rounded transition-opacity hover-opacity-90 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=${selectionUrl}\n >\n <foxy-i18n infer=\"\" key=\"view\"></foxy-i18n>\n </a>\n `\n : ''}\n ${this.showCopyIdButton && selectionId !== null\n ? html`\n <foxy-copy-to-clipboard\n layout=\"text\"\n theme=\"contrast tertiary-inline\"\n infer=\"copy-id\"\n text=${selectionId}\n >\n </foxy-copy-to-clipboard>\n `\n : ''}\n ${this.readonly || !this._value\n ? ''\n : html`\n <vaadin-button\n theme=\"error tertiary-inline\"\n ?disabled=${this.disabled}\n @click=${this.__clear}\n >\n <foxy-i18n infer=\"\" key=\"clear\"></foxy-i18n>\n </vaadin-button>\n `}\n </div>\n\n <div class=\"text-secondary text-s\" ?hidden=${!this.helperText}>${this.helperText}</div>\n\n <button\n class=${classMap({\n 'block w-full bg-contrast-5 rounded text-left transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'cursor-pointer hover-bg-contrast-10': !this.disabled && !this.readonly,\n 'cursor-default': this.disabled || this.readonly,\n 'mt-s': !!this.label || !!this.helperText,\n })}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n ?disabled=${this.disabled || this.readonly}\n @click=${(evt: MouseEvent) => {\n const button = evt.currentTarget as HTMLButtonElement;\n const dialog = this.renderRoot.querySelector('foxy-form-dialog') as FormDialog;\n\n dialog.href = '';\n dialog.show(button);\n }}\n >\n <div class=${classMap({ 'transition-opacity': true, 'opacity-50': this.disabled })}>\n <foxy-nucleon\n class=\"block\"\n infer=\"\"\n href=${ifDefined(this._value || void 0)}\n id=\"valueLoader\"\n @update=${() => this.requestUpdate()}\n >\n ${this.__getItemRenderer(this.item)({\n html,\n data: valueLoader?.data ?? null,\n href: (this._value as string | undefined) || '',\n related: [],\n parent: '',\n props: {},\n spread: spread,\n simplifyNsLoading: this.simplifyNsLoading,\n disabled: this.disabled,\n disabledControls: this.disabledControls,\n readonly: this.readonly,\n readonlyControls: this.readonlyControls,\n hidden: this.hidden,\n hiddenControls: this.hiddenControls,\n templates: this.templates,\n previous: null,\n next: null,\n group: this.nucleon?.group ?? '',\n lang: this.lang,\n ns: this.ns,\n })}\n </foxy-nucleon>\n </div>\n </button>\n\n <div\n class=\"mt-xs text-xs leading-xs text-error\"\n ?hidden=${!this._errorMessage || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </div>\n </div>\n `;\n }\n\n private __handleFetchEvent(event: Event) {\n if (!(event instanceof FetchEvent)) return;\n if (event.defaultPrevented) return;\n\n const { url, method } = event.request;\n\n if (url === `foxy://${this.virtualHost}/select` && method === 'POST') {\n return event.respondWith(this.__handleSelect(event.request));\n }\n\n if (url === `foxy://${this.virtualHost}/empty` && method === 'GET') {\n return event.respondWith(this.__handleEmpty());\n }\n }\n\n private async __handleSelect(request: Request): Promise<Response> {\n const body = (await request.clone().json()) as { selection: string };\n this._value = body.selection;\n return new Response(\n JSON.stringify({\n _links: { self: { href: `foxy://${this.virtualHost}/empty` } },\n message: 'Resource selected.',\n })\n );\n }\n\n private async __handleEmpty(): Promise<Response> {\n return new Response(\n JSON.stringify({\n _links: { self: { href: `foxy://${this.virtualHost}/empty` } },\n message: 'Resource selected.',\n })\n );\n }\n\n private get __valueLoader() {\n type Loader = NucleonElement<any>;\n return this.renderRoot.querySelector<Loader>('#valueLoader');\n }\n}\n"]}
|
|
@@ -142,5 +142,16 @@ export class InternalSelectControl extends InternalEditableControl {
|
|
|
142
142
|
</div>
|
|
143
143
|
`;
|
|
144
144
|
}
|
|
145
|
+
_handleHostClick(evt) {
|
|
146
|
+
var _a;
|
|
147
|
+
if (this.layout !== 'summary-item')
|
|
148
|
+
return;
|
|
149
|
+
const composedPath = evt.composedPath();
|
|
150
|
+
const noOp = new Set(['SELECT', 'LABEL']);
|
|
151
|
+
if (!composedPath.some(el => noOp.has(el.tagName))) {
|
|
152
|
+
(_a = this.renderRoot.querySelector('select')) === null || _a === void 0 ? void 0 : _a.focus();
|
|
153
|
+
super._handleHostClick(evt);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
145
156
|
}
|
|
146
157
|
//# sourceMappingURL=InternalSelectControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalSelectControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalSelectControl/InternalSelectControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EA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AAI,IAAI,CAAC,QAAQ;;cAEhE,IAAI,CAAC,aAAa;;;;KAI3B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { ComboBoxElement } from '@vaadin/vaadin-combo-box';\nimport type { Option } from './types';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\n\n/**\n * Internal control wrapper for select elements.\n *\n * @since 1.21.0\n * @element foxy-internal-select-control\n */\nexport class InternalSelectControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n options: { type: Array },\n layout: {},\n theme: { type: String },\n __isErrorVisible: { attribute: false },\n };\n }\n\n /** List of radio buttons to render. */\n options: Option[] = [];\n\n /** Standalone renders Vaadin Combo Box. Summary item renders a special UI for summary control. */\n layout: 'summary-item' | 'standalone' | null = null;\n\n /** Same as the \"theme\" attribute/property of `vaadin-combo-box`. */\n theme: string | null = null;\n\n private __isErrorVisible = false;\n\n renderControl(): TemplateResult {\n if (this.layout === 'summary-item') return this.__renderSummaryItemLayout();\n\n return html`\n <vaadin-combo-box\n item-value-path=\"value\"\n item-label-path=\"label\"\n error-message=${ifDefined(this._errorMessage)}\n item-id-path=\"value\"\n helper-text=${this.helperText}\n placeholder=${this.placeholder}\n label=${this.label}\n class=\"w-full\"\n theme=${ifDefined(this.theme ?? undefined)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n clear-button-visible\n .checkValidity=${this._checkValidity}\n .items=${this.options.map(option => ({\n label: 'label' in option ? this.t(option.label) : option.rawLabel,\n value: option.value,\n }))}\n .value=${this._value}\n @change=${(evt: CustomEvent) => {\n evt.stopPropagation();\n const comboBox = evt.currentTarget as ComboBoxElement;\n this._value = comboBox.value;\n comboBox.validate();\n }}\n >\n </vaadin-combo-box>\n `;\n }\n\n reportValidity(): void {\n this.__isErrorVisible = true;\n super.reportValidity();\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n const comboBox = this.renderRoot.querySelector('vaadin-combo-box');\n if (comboBox && comboBox.value !== this._value) comboBox.value = this._value as string;\n }\n\n private __renderSummaryItemLayout() {\n const selection = this.options.find(v => v.value === this._value);\n\n return html`\n <div class=\"leading-xs\">\n <div class=\"flex items-center gap-s\">\n <label class=\"text-m text-body flex-1 whitespace-nowrap\" for=\"select\">\n ${this.label}\n </label>\n <div\n class=${classMap({\n 'relative rounded-s transition-colors transition-opacity min-w-0': true,\n 'focus-within-ring-2 focus-within-ring-primary-50': !this.disabled && !this.readonly,\n 'text-body hover-opacity-80 cursor-pointer': !this.disabled && !this.readonly,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'font-medium': !this.readonly,\n })}\n >\n <div class=\"flex items-center gap-xs min-w-0\">\n <div class=\"truncate min-w-0\">\n ${selection\n ? 'label' in selection\n ? this.t(selection.label)\n : selection.rawLabel\n : this.placeholder}\n </div>\n ${this.readonly\n ? ''\n : svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"flex-shrink-0\" style=\"width: 1em; height: 1em; transform: scale(1.25)\"><path fill-rule=\"evenodd\" d=\"M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z\" clip-rule=\"evenodd\" /></svg>`}\n </div>\n\n <select\n class=${classMap({\n 'absolute inset-0 opacity-0': true,\n 'cursor-pointer': !this.disabled && !this.readonly,\n })}\n id=\"select\"\n ?disabled=${this.disabled}\n ?hidden=${this.readonly}\n @blur=${() => (this.__isErrorVisible = true)}\n @change=${(evt: Event) => {\n evt.stopPropagation();\n this._value = (evt.target as HTMLSelectElement).value;\n }}\n >\n <option value=\"\" ?selected=${!selection} disabled hidden>${this.placeholder}</option>\n ${this.options.map(\n option =>\n html`\n <option\n value=${option.value}\n ?selected=${selection && option.value === this._value}\n >\n ${'label' in option ? this.t(option.label) : option.rawLabel}\n </option>\n `\n )}\n </select>\n </div>\n </div>\n\n <div style=\"max-width: 32rem\">\n <p class=\"text-xs text-secondary\">${this.helperText}</p>\n <p\n class=\"text-xs text-error\"\n ?hidden=${!this.__isErrorVisible || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </p>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalSelectControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalSelectControl/InternalSelectControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,uBAAuB;IAAlE;;QAWE,uCAAuC;QACvC,YAAO,GAAa,EAAE,CAAC;QAEvB,kGAAkG;QAClG,WAAM,GAAyC,IAAI,CAAC;QAEpD,oEAAoE;QACpE,UAAK,GAAkB,IAAI,CAAC;QAEpB,qBAAgB,GAAG,KAAK,CAAC;IAmInC,CAAC;IAtJC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACxB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACvB,gBAAgB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SACvC,CAAC;IACJ,CAAC;IAaD,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AAE,CAAC;YACtB,IAAI,CAAC,MAAM,GAAI,GAAG,CAAC,MAA4B,CAAC,KAAK,CAAC;QACxD,CAAC;;2CAE4B,CAAC,SAAS,oBAAoB,IAAI,CAAC,WAAW;gBACzE,IAAI,CAAC,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,EAAE,CACP,IAAI,CAAA;;8BAEQ,MAAM,CAAC,KAAK;kCACR,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM;;wBAEnD,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ;;mBAE/D,CACJ;;;;;;8CAM+B,IAAI,CAAC,UAAU;;;sBAGvC,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;;cAEhE,IAAI,CAAC,aAAa;;;;KAI3B,CAAC;IACJ,CAAC;IAES,gBAAgB,CAAC,GAAe;;QACxC,IAAI,IAAI,CAAC,MAAM,KAAK,cAAc;YAAE,OAAO;QAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,EAAmB,CAAC;QACzD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE;YAClD,MAAA,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,0CAAE,KAAK,GAAG;YACjD,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;SAC7B;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { ComboBoxElement } from '@vaadin/vaadin-combo-box';\nimport type { Option } from './types';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\n\n/**\n * Internal control wrapper for select elements.\n *\n * @since 1.21.0\n * @element foxy-internal-select-control\n */\nexport class InternalSelectControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n options: { type: Array },\n layout: {},\n theme: { type: String },\n __isErrorVisible: { attribute: false },\n };\n }\n\n /** List of radio buttons to render. */\n options: Option[] = [];\n\n /** Standalone renders Vaadin Combo Box. Summary item renders a special UI for summary control. */\n layout: 'summary-item' | 'standalone' | null = null;\n\n /** Same as the \"theme\" attribute/property of `vaadin-combo-box`. */\n theme: string | null = null;\n\n private __isErrorVisible = false;\n\n renderControl(): TemplateResult {\n if (this.layout === 'summary-item') return this.__renderSummaryItemLayout();\n\n return html`\n <vaadin-combo-box\n item-value-path=\"value\"\n item-label-path=\"label\"\n error-message=${ifDefined(this._errorMessage)}\n item-id-path=\"value\"\n helper-text=${this.helperText}\n placeholder=${this.placeholder}\n label=${this.label}\n class=\"w-full\"\n theme=${ifDefined(this.theme ?? undefined)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n clear-button-visible\n .checkValidity=${this._checkValidity}\n .items=${this.options.map(option => ({\n label: 'label' in option ? this.t(option.label) : option.rawLabel,\n value: option.value,\n }))}\n .value=${this._value}\n @change=${(evt: CustomEvent) => {\n evt.stopPropagation();\n const comboBox = evt.currentTarget as ComboBoxElement;\n this._value = comboBox.value;\n comboBox.validate();\n }}\n >\n </vaadin-combo-box>\n `;\n }\n\n reportValidity(): void {\n this.__isErrorVisible = true;\n super.reportValidity();\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n const comboBox = this.renderRoot.querySelector('vaadin-combo-box');\n if (comboBox && comboBox.value !== this._value) comboBox.value = this._value as string;\n }\n\n private __renderSummaryItemLayout() {\n const selection = this.options.find(v => v.value === this._value);\n\n return html`\n <div class=\"leading-xs\">\n <div class=\"flex items-center gap-s\">\n <label class=\"text-m text-body flex-1 whitespace-nowrap\" for=\"select\">\n ${this.label}\n </label>\n <div\n class=${classMap({\n 'relative rounded-s transition-colors transition-opacity min-w-0': true,\n 'focus-within-ring-2 focus-within-ring-primary-50': !this.disabled && !this.readonly,\n 'text-body hover-opacity-80 cursor-pointer': !this.disabled && !this.readonly,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'font-medium': !this.readonly,\n })}\n >\n <div class=\"flex items-center gap-xs min-w-0\">\n <div class=\"truncate min-w-0\">\n ${selection\n ? 'label' in selection\n ? this.t(selection.label)\n : selection.rawLabel\n : this.placeholder}\n </div>\n ${this.readonly\n ? ''\n : svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"flex-shrink-0\" style=\"width: 1em; height: 1em; transform: scale(1.25)\"><path fill-rule=\"evenodd\" d=\"M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z\" clip-rule=\"evenodd\" /></svg>`}\n </div>\n\n <select\n class=${classMap({\n 'absolute inset-0 opacity-0': true,\n 'cursor-pointer': !this.disabled && !this.readonly,\n })}\n id=\"select\"\n ?disabled=${this.disabled}\n ?hidden=${this.readonly}\n @blur=${() => (this.__isErrorVisible = true)}\n @change=${(evt: Event) => {\n evt.stopPropagation();\n this._value = (evt.target as HTMLSelectElement).value;\n }}\n >\n <option value=\"\" ?selected=${!selection} disabled hidden>${this.placeholder}</option>\n ${this.options.map(\n option =>\n html`\n <option\n value=${option.value}\n ?selected=${selection && option.value === this._value}\n >\n ${'label' in option ? this.t(option.label) : option.rawLabel}\n </option>\n `\n )}\n </select>\n </div>\n </div>\n\n <div style=\"max-width: 32rem\">\n <p class=\"text-xs text-secondary\">${this.helperText}</p>\n <p\n class=\"text-xs text-error\"\n ?hidden=${!this.__isErrorVisible || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </p>\n </div>\n </div>\n `;\n }\n\n protected _handleHostClick(evt: MouseEvent): void {\n if (this.layout !== 'summary-item') return;\n const composedPath = evt.composedPath() as HTMLElement[];\n const noOp = new Set(['SELECT', 'LABEL']);\n if (!composedPath.some(el => noOp.has(el.tagName))) {\n this.renderRoot.querySelector('select')?.focus();\n super._handleHostClick(evt);\n }\n }\n}\n"]}
|
|
@@ -119,5 +119,14 @@ export class InternalSwitchControl extends InternalEditableControl {
|
|
|
119
119
|
else
|
|
120
120
|
super._value = value;
|
|
121
121
|
}
|
|
122
|
+
_handleHostClick(evt) {
|
|
123
|
+
var _a;
|
|
124
|
+
const composedPath = evt.composedPath();
|
|
125
|
+
const noOp = new Set(['INPUT', 'LABEL']);
|
|
126
|
+
if (!composedPath.some(el => noOp.has(el.tagName))) {
|
|
127
|
+
(_a = this.renderRoot.querySelector('input')) === null || _a === void 0 ? void 0 : _a.click();
|
|
128
|
+
super._handleHostClick(evt);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
122
131
|
}
|
|
123
132
|
//# sourceMappingURL=InternalSwitchControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalSwitchControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalSwitchControl/InternalSwitchControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,IAAI,EAAwB,GAAG,EAAkB,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,OAAO,qBAAsB,SAAQ,uBAAuB;IAAlE;;QAWE,uBAAkB,GAAG,KAAK,CAAC;QAE3B,eAAU,GAAkB,IAAI,CAAC;QAEjC,cAAS,GAAkB,IAAI,CAAC;QAEhC,WAAM,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"InternalSwitchControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalSwitchControl/InternalSwitchControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,IAAI,EAAwB,GAAG,EAAkB,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,OAAO,qBAAsB,SAAQ,uBAAuB;IAAlE;;QAWE,uBAAkB,GAAG,KAAK,CAAC;QAE3B,eAAU,GAAkB,IAAI,CAAC;QAEjC,cAAS,GAAkB,IAAI,CAAC;QAEhC,WAAM,GAAG,KAAK,CAAC;IA6GjB,CAAC;IA7HC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE;YAC1E,UAAU,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE;YACxC,SAAS,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE;YACtC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC1B,CAAC;IACJ,CAAC;IAUD,aAAa;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC3D,OAAO,IAAI,CAAA;;;wDAGyC,IAAI,CAAC,KAAK;YACtD,IAAI,CAAC,kBAAkB;YACvB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,IAAI,CAAA;kBACA,IAAI,CAAC,UAAU;mBACd;;;;sBAIG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;;c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Ayf;;;;;;;;;4DASld,IAAI,CAAC,UAAU;;aAE9D;YACH,CAAC,CAAC,EAAE;;KAET,CAAC;IACJ,CAAC;IAED,IAAc,MAAM;QAClB,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;QACnC,IAAI,IAAI,CAAC,SAAS,IAAI,aAAa,KAAK,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QACpE,IAAI,IAAI,CAAC,UAAU,IAAI,aAAa,KAAK,IAAI,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACvE,OAAO,CAAC,CAAC,aAAa,CAAC;IACzB,CAAC;IAED,IAAc,MAAM,CAAC,KAAc;QACjC,IAAI,IAAI,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;aAC/D,IAAI,IAAI,CAAC,UAAU,IAAI,KAAK,KAAK,KAAK;YAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;;YACvE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IAC5B,CAAC;IAES,gBAAgB,CAAC,GAAe;;QACxC,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,EAAmB,CAAC;QACzD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE;YAClD,MAAA,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,0CAAE,KAAK,GAAG;YAChD,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;SAC7B;IACH,CAAC;CACF","sourcesContent":["import { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { html, PropertyDeclarations, svg, TemplateResult } from 'lit-element';\nimport { classMap } from '../../../utils/class-map';\n\nexport class InternalSwitchControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n helperTextAsToolip: { type: Boolean, attribute: 'helper-text-as-tooltip' },\n falseAlias: { attribute: 'false-alias' },\n trueAlias: { attribute: 'true-alias' },\n invert: { type: Boolean },\n };\n }\n\n helperTextAsToolip = false;\n\n falseAlias: string | null = null;\n\n trueAlias: string | null = null;\n\n invert = false;\n\n renderControl(): TemplateResult {\n const checked = this.invert ? !this._value : !!this._value;\n return html`\n <div class=\"flex items-start gap-s leading-xs text-m\">\n <div class=\"flex-1\">\n <label class=\"text-m text-body\" for=\"input\">${this.label}</label>\n ${this.helperTextAsToolip\n ? ''\n : html`<p class=\"text-xs text-secondary\" style=\"max-width: 32rem\">\n ${this.helperText}\n </p>`}\n <p\n class=\"text-xs text-error\"\n style=\"max-width: 32rem\"\n ?hidden=${this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </p>\n </div>\n\n ${this.readonly\n ? html`<p class=\"text-secondary\">${checked ? this.t('checked') : this.t('unchecked')}</p>`\n : html`\n <div style=\"height: calc(1em * var(--lumo-line-height-xs))\" class=\"flex items-center\">\n <div\n style=\"border-radius: var(--lumo-size-xl); width: calc((1em * var(--lumo-line-height-xs)) - 3px + var(--lumo-space-m))\"\n class=${classMap({\n 'cursor-pointer group transition-colors relative': true,\n 'flex flex-shrink-0 items-center': true,\n 'bg-success': !this.disabled && checked,\n 'bg-contrast-20 hover-bg-contrast-30': !this.disabled && !checked,\n 'bg-contrast-10': this.disabled,\n 'focus-within-ring-2 focus-within-ring-primary-50': true,\n })}\n @click=${() => (this._value = !this._value)}\n >\n <div\n style=\"margin: 1.5px; width: calc((1em * var(--lumo-line-height-xs)) - 6px); height: calc((1em * var(--lumo-line-height-xs)) - 6px)\"\n class=${classMap({\n 'transition-all transform block rounded-full': true,\n 'translate-x-m': checked,\n 'translate-x-0': !checked,\n 'bg-base': this.disabled,\n 'bg-tint': !this.disabled,\n })}\n ></div>\n\n <input\n class=\"opacity-0 absolute inset-0 focus-outline-none\"\n type=\"checkbox\"\n id=\"input\"\n switch\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?checked=${checked}\n @change=${(evt: Event) => {\n const checkbox = evt.currentTarget as HTMLInputElement;\n this._value = this.invert ? !checkbox.checked : checkbox.checked;\n }}\n />\n </div>\n </div>\n `}\n ${this.helperTextAsToolip && this.helperText\n ? html`\n <div\n class=\"transition-colors text-tertiary flex-shrink-0 cursor-pointer hover-text-body\"\n id=\"trigger\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" style=\"width: calc(1em * var(--lumo-line-height-xs)); height: calc(1em * var(--lumo-line-height-xs)); margin-right: -0.12em\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z\" /></svg>`}\n </div>\n <vcf-tooltip\n for=\"trigger\"\n style=\"--lumo-base-color: black; max-width: 30rem\"\n class=\"mt-s\"\n theme=\"light\"\n position=\"bottom\"\n >\n <span class=\"text-s\" style=\"color: white\">${this.helperText}</span>\n </vcf-tooltip>\n `\n : ''}\n </div>\n `;\n }\n\n protected get _value(): boolean {\n const originalValue = super._value;\n if (this.trueAlias && originalValue === this.trueAlias) return true;\n if (this.falseAlias && originalValue === this.falseAlias) return false;\n return !!originalValue;\n }\n\n protected set _value(value: boolean) {\n if (this.trueAlias && value === true) super._value = this.trueAlias;\n else if (this.falseAlias && value === false) super._value = this.falseAlias;\n else super._value = value;\n }\n\n protected _handleHostClick(evt: MouseEvent): void {\n const composedPath = evt.composedPath() as HTMLElement[];\n const noOp = new Set(['INPUT', 'LABEL']);\n if (!composedPath.some(el => noOp.has(el.tagName))) {\n this.renderRoot.querySelector('input')?.click();\n super._handleHostClick(evt);\n }\n }\n}\n"]}
|
|
@@ -17,6 +17,7 @@ export declare class InternalTextControl extends InternalEditableControl {
|
|
|
17
17
|
renderControl(): TemplateResult;
|
|
18
18
|
protected get _value(): string;
|
|
19
19
|
protected set _value(newValue: string);
|
|
20
|
+
protected _handleHostClick(evt: MouseEvent): void;
|
|
20
21
|
private __renderSummaryItemLayout;
|
|
21
22
|
private __renderPillLayout;
|
|
22
23
|
}
|
|
@@ -78,6 +78,17 @@ export class InternalTextControl extends InternalEditableControl {
|
|
|
78
78
|
set _value(newValue) {
|
|
79
79
|
super._value = newValue;
|
|
80
80
|
}
|
|
81
|
+
_handleHostClick(evt) {
|
|
82
|
+
var _a;
|
|
83
|
+
if (this.layout !== 'summary-item')
|
|
84
|
+
return;
|
|
85
|
+
const composedPath = evt.composedPath();
|
|
86
|
+
const noOp = new Set(['INPUT', 'LABEL']);
|
|
87
|
+
if (!composedPath.some(el => noOp.has(el.tagName))) {
|
|
88
|
+
(_a = this.renderRoot.querySelector('input')) === null || _a === void 0 ? void 0 : _a.focus();
|
|
89
|
+
super._handleHostClick(evt);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
81
92
|
__renderSummaryItemLayout() {
|
|
82
93
|
return html `
|
|
83
94
|
<div class="leading-xs">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalTextControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalTextControl/InternalTextControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,0BA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EAAE,IAAI;YAC9E,uDAAuD,EAAE,IAAI;YAC7D,oCAAoC,EAAE,IAAI;YAC1C,sBAAsB,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ;YACxD,gBAAgB,EAAE,IAAI,CAAC,QAAQ;YAC/B,eAAe,EAAE,CAAC,IAAI,CAAC,QAAQ;YAC/B,eAAe,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ;SACjD,CAAC;sBACU,IAAI,CAAC,QAAQ;sBACb,IAAI,CAAC,QAAQ;mBAChB,MAAA,IAAI,CAAC,MAAM,mCAAI,EAAE;qBACf,CAAC,GAAkB,EAAE,EAAE;;YAChC,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE;gBACvB,GAAG,CAAC,cAAc,EAAE,CAAC;gBACrB,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,GAAG;aACxB;QACH,CAAC;mBACQ,CAAC,GAAU,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,GAAG,CAAC,aAAiC,CAAC;YACpD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;QAC5B,CAAC;;;KAGN,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { TextFieldElement } from '@vaadin/vaadin-text-field';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { html, css, svg } from 'lit-element';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { live } from 'lit-html/directives/live';\n\n/**\n * Internal control displaying a basic text box.\n *\n * @since 1.17.0\n * @element foxy-internal-text-control\n */\nexport class InternalTextControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n layout: {},\n prefix: {},\n suffix: {},\n __isErrorVisible: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n input::-webkit-contacts-auto-fill-button {\n visibility: hidden;\n display: none !important;\n pointer-events: none;\n position: absolute;\n right: 0;\n }\n `,\n ];\n }\n\n layout: 'summary-item' | 'standalone' | 'pill' | null = null;\n\n prefix: string | null = null;\n\n suffix: string | null = null;\n\n private __isErrorVisible = false;\n\n reportValidity(): void {\n this.__isErrorVisible = true;\n super.reportValidity();\n }\n\n renderControl(): TemplateResult {\n if (this.layout === 'summary-item') return this.__renderSummaryItemLayout();\n if (this.layout === 'pill') return this.__renderPillLayout();\n\n return html`\n <vaadin-text-field\n error-message=${ifDefined(this._errorMessage)}\n helper-text=${this.helperText}\n placeholder=${this.placeholder}\n label=${this.label}\n class=\"w-full\"\n ?clear-button-visible=${!this.suffix}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .checkValidity=${this._checkValidity}\n .value=${this._value}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @input=${(evt: CustomEvent) => {\n const field = evt.currentTarget as TextFieldElement;\n this._value = field.value;\n }}\n >\n ${this.prefix ? html`<div slot=\"prefix\">${this.prefix}</div>` : ''}\n ${this.suffix ? html`<div class=\"pr-s font-medium\" slot=\"suffix\">${this.suffix}</div>` : ''}\n </vaadin-text-field>\n `;\n }\n\n protected get _value(): string {\n return (super._value as string | undefined) ?? '';\n }\n\n protected set _value(newValue: string) {\n super._value = newValue as unknown | undefined;\n }\n\n private __renderSummaryItemLayout() {\n return html`\n <div class=\"leading-xs\">\n <div class=\"flex items-center gap-xs\">\n <label class=\"text-m text-body flex-1 whitespace-nowrap\" for=\"input\">${this.label}</label>\n\n ${this.prefix ? html`<div>${this.prefix}</div>` : ''}\n\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'w-full appearance-none text-right bg-transparent transition-colors': true,\n 'text-m rounded-s focus-outline-none': true,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'font-medium': !this.readonly,\n })}\n type=\"text\"\n id=\"input\"\n .value=${live(this._value)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @blur=${() => (this.__isErrorVisible = true)}\n @input=${(evt: Event) => {\n evt.stopPropagation();\n this._value = (evt.target as HTMLInputElement).value;\n }}\n />\n\n ${this.suffix ? html`<div class=\"font-medium text-secondary\">${this.suffix}</div>` : ''}\n\n <button\n aria-label=${this.t('clear')}\n class=${classMap({\n 'flex-shrink-0 rounded-full transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'cursor-pointer text-tertiary hover-text-body': !this.disabled,\n 'cursor-default text-disabled': this.disabled,\n })}\n style=\"width: 1em; height: 1em;\"\n ?disabled=${this.disabled}\n ?hidden=${this.readonly || !this._value}\n @click=${() => {\n this._value = '';\n this.dispatchEvent(new CustomEvent('clear'));\n }}\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1em; height: 1em; transform: scale(1.25); margin-right: -0.16em\"><path d=\"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" /></svg>`}\n </button>\n </div>\n\n <div style=\"max-width: 32rem\">\n <p class=\"text-xs text-secondary\">${this.helperText}</p>\n <p\n class=\"text-xs text-error\"\n ?hidden=${!this.__isErrorVisible || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </p>\n </div>\n </div>\n `;\n }\n\n private __renderPillLayout() {\n const content = this._value || this.placeholder;\n const contentClass =\n 'relative block whitespace-pre text-center text-xl font-medium px-s py-xs -my-xs opacity-0';\n\n return html`\n <div class=\"text-center flex items-center gap-s relative\" style=\"min-width: 6rem\">\n <span class=${contentClass}>${content}</span>\n <input\n placeholder=${this.placeholder}\n aria-label=${this.label}\n class=${classMap({\n 'text-center appearance-none transition-all text-xl font-medium rounded': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'px-s py-xs -my-xs absolute inset-0': true,\n 'hover-bg-contrast-10': !this.disabled && !this.readonly,\n 'bg-transparent': this.readonly,\n 'bg-contrast-5': !this.readonly,\n 'text-disabled': this.disabled && !this.readonly,\n })}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .value=${this._value ?? ''}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter') {\n evt.preventDefault();\n this.nucleon?.submit();\n }\n }}\n @input=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n this._value = input.value;\n }}\n />\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalTextControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalTextControl/InternalTextControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,uBAAuB;IAAhE;;QA0BE,WAAM,GAAkD,IAAI,CAAC;QAE7D,WAAM,GAAkB,IAAI,CAAC;QAE7B,WAAM,GAAkB,IAAI,CAAC;QAErB,qBAAgB,GAAG,KAAK,CAAC;IA2JnC,CAAC;IA1LC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,gBAAgB,EAAE,EAAE,SAAS,EAAE,KAAK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AAI,OAAO;;wBAErB,IAAI,CAAC,WAAW;uBACjB,IAAI,CAAC,KAAK;kBACf,QAAQ,CAAC;YACf,wEAAwE,EAAE,IAAI;YAC9E,uDAAuD,EAAE,IAAI;YAC7D,oCAAoC,EAAE,IAAI;YAC1C,sBAAsB,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ;YACxD,gBAAgB,EAAE,IAAI,CAAC,QAAQ;YAC/B,eAAe,EAAE,CAAC,IAAI,CAAC,QAAQ;YAC/B,eAAe,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ;SACjD,CAAC;sBACU,IAAI,CAAC,QAAQ;sBACb,IAAI,CAAC,QAAQ;mBAChB,MAAA,IAAI,CAAC,MAAM,mCAAI,EAAE;qBACf,CAAC,GAAkB,EAAE,EAAE;;YAChC,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE;gBACvB,GAAG,CAAC,cAAc,EAAE,CAAC;gBACrB,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,GAAG;aACxB;QACH,CAAC;mBACQ,CAAC,GAAU,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,GAAG,CAAC,aAAiC,CAAC;YACpD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;QAC5B,CAAC;;;KAGN,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { TextFieldElement } from '@vaadin/vaadin-text-field';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { html, css, svg } from 'lit-element';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { live } from 'lit-html/directives/live';\n\n/**\n * Internal control displaying a basic text box.\n *\n * @since 1.17.0\n * @element foxy-internal-text-control\n */\nexport class InternalTextControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n layout: {},\n prefix: {},\n suffix: {},\n __isErrorVisible: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n input::-webkit-contacts-auto-fill-button {\n visibility: hidden;\n display: none !important;\n pointer-events: none;\n position: absolute;\n right: 0;\n }\n `,\n ];\n }\n\n layout: 'summary-item' | 'standalone' | 'pill' | null = null;\n\n prefix: string | null = null;\n\n suffix: string | null = null;\n\n private __isErrorVisible = false;\n\n reportValidity(): void {\n this.__isErrorVisible = true;\n super.reportValidity();\n }\n\n renderControl(): TemplateResult {\n if (this.layout === 'summary-item') return this.__renderSummaryItemLayout();\n if (this.layout === 'pill') return this.__renderPillLayout();\n\n return html`\n <vaadin-text-field\n error-message=${ifDefined(this._errorMessage)}\n helper-text=${this.helperText}\n placeholder=${this.placeholder}\n label=${this.label}\n class=\"w-full\"\n ?clear-button-visible=${!this.suffix}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .checkValidity=${this._checkValidity}\n .value=${this._value}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @input=${(evt: CustomEvent) => {\n const field = evt.currentTarget as TextFieldElement;\n this._value = field.value;\n }}\n >\n ${this.prefix ? html`<div slot=\"prefix\">${this.prefix}</div>` : ''}\n ${this.suffix ? html`<div class=\"pr-s font-medium\" slot=\"suffix\">${this.suffix}</div>` : ''}\n </vaadin-text-field>\n `;\n }\n\n protected get _value(): string {\n return (super._value as string | undefined) ?? '';\n }\n\n protected set _value(newValue: string) {\n super._value = newValue as unknown | undefined;\n }\n\n protected _handleHostClick(evt: MouseEvent): void {\n if (this.layout !== 'summary-item') return;\n const composedPath = evt.composedPath() as HTMLElement[];\n const noOp = new Set(['INPUT', 'LABEL']);\n if (!composedPath.some(el => noOp.has(el.tagName))) {\n this.renderRoot.querySelector('input')?.focus();\n super._handleHostClick(evt);\n }\n }\n\n private __renderSummaryItemLayout() {\n return html`\n <div class=\"leading-xs\">\n <div class=\"flex items-center gap-xs\">\n <label class=\"text-m text-body flex-1 whitespace-nowrap\" for=\"input\">${this.label}</label>\n\n ${this.prefix ? html`<div>${this.prefix}</div>` : ''}\n\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'w-full appearance-none text-right bg-transparent transition-colors': true,\n 'text-m rounded-s focus-outline-none': true,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'font-medium': !this.readonly,\n })}\n type=\"text\"\n id=\"input\"\n .value=${live(this._value)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @blur=${() => (this.__isErrorVisible = true)}\n @input=${(evt: Event) => {\n evt.stopPropagation();\n this._value = (evt.target as HTMLInputElement).value;\n }}\n />\n\n ${this.suffix ? html`<div class=\"font-medium text-secondary\">${this.suffix}</div>` : ''}\n\n <button\n aria-label=${this.t('clear')}\n class=${classMap({\n 'flex-shrink-0 rounded-full transition-colors': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'cursor-pointer text-tertiary hover-text-body': !this.disabled,\n 'cursor-default text-disabled': this.disabled,\n })}\n style=\"width: 1em; height: 1em;\"\n ?disabled=${this.disabled}\n ?hidden=${this.readonly || !this._value}\n @click=${() => {\n this._value = '';\n this.dispatchEvent(new CustomEvent('clear'));\n }}\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1em; height: 1em; transform: scale(1.25); margin-right: -0.16em\"><path d=\"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" /></svg>`}\n </button>\n </div>\n\n <div style=\"max-width: 32rem\">\n <p class=\"text-xs text-secondary\">${this.helperText}</p>\n <p\n class=\"text-xs text-error\"\n ?hidden=${!this.__isErrorVisible || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </p>\n </div>\n </div>\n `;\n }\n\n private __renderPillLayout() {\n const content = this._value || this.placeholder;\n const contentClass =\n 'relative block whitespace-pre text-center text-xl font-medium px-s py-xs -my-xs opacity-0';\n\n return html`\n <div class=\"text-center flex items-center gap-s relative\" style=\"min-width: 6rem\">\n <span class=${contentClass}>${content}</span>\n <input\n placeholder=${this.placeholder}\n aria-label=${this.label}\n class=${classMap({\n 'text-center appearance-none transition-all text-xl font-medium rounded': true,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,\n 'px-s py-xs -my-xs absolute inset-0': true,\n 'hover-bg-contrast-10': !this.disabled && !this.readonly,\n 'bg-transparent': this.readonly,\n 'bg-contrast-5': !this.readonly,\n 'text-disabled': this.disabled && !this.readonly,\n })}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .value=${this._value ?? ''}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter') {\n evt.preventDefault();\n this.nucleon?.submit();\n }\n }}\n @input=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n this._value = input.value;\n }}\n />\n </div>\n `;\n }\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { ConditionalOperator, Option } from '../QueryBuilder/types';
|
|
1
2
|
import type { PropertyDeclarations } from 'lit-element';
|
|
2
3
|
import type { TemplateResult } from 'lit-html';
|
|
3
|
-
import type { Option } from '../QueryBuilder/types';
|
|
4
4
|
import type { Data } from './types';
|
|
5
5
|
import { InternalForm } from '../../internal/InternalForm/InternalForm';
|
|
6
|
+
import { Operator } from '../QueryBuilder/types';
|
|
6
7
|
declare const Base: typeof InternalForm & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
7
8
|
defaultNS: string;
|
|
8
9
|
};
|
|
@@ -21,6 +22,8 @@ export declare class FilterAttributeForm extends Base<Data> {
|
|
|
21
22
|
static readonly attributeName: string;
|
|
22
23
|
static readonly filterNameKey: string;
|
|
23
24
|
static get properties(): PropertyDeclarations;
|
|
25
|
+
/** List of operators passed down to `QueryBuilder.operators`. */
|
|
26
|
+
operators: (Operator | ConditionalOperator)[];
|
|
24
27
|
/** Default filter query. */
|
|
25
28
|
defaults: string | null;
|
|
26
29
|
/** Admin page pathname. */
|
|
@@ -2,6 +2,7 @@ import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
|
2
2
|
import { encode, decode } from 'html-entities';
|
|
3
3
|
import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
|
|
4
4
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
5
|
+
import { Operator } from "../QueryBuilder/types.js";
|
|
5
6
|
import { html } from 'lit-html';
|
|
6
7
|
const NS = 'filter-attribute-form';
|
|
7
8
|
const Base = TranslatableMixin(InternalForm, NS);
|
|
@@ -17,6 +18,8 @@ const Base = TranslatableMixin(InternalForm, NS);
|
|
|
17
18
|
export class FilterAttributeForm extends Base {
|
|
18
19
|
constructor() {
|
|
19
20
|
super(...arguments);
|
|
21
|
+
/** List of operators passed down to `QueryBuilder.operators`. */
|
|
22
|
+
this.operators = Object.values(Operator);
|
|
20
23
|
/** Default filter query. */
|
|
21
24
|
this.defaults = null;
|
|
22
25
|
/** Admin page pathname. */
|
|
@@ -37,6 +40,7 @@ export class FilterAttributeForm extends Base {
|
|
|
37
40
|
static get properties() {
|
|
38
41
|
return {
|
|
39
42
|
...super.properties,
|
|
43
|
+
operators: { type: Array },
|
|
40
44
|
defaults: {},
|
|
41
45
|
pathname: {},
|
|
42
46
|
docsHref: { attribute: 'docs-href' },
|
|
@@ -111,6 +115,7 @@ export class FilterAttributeForm extends Base {
|
|
|
111
115
|
|
|
112
116
|
<foxy-query-builder
|
|
113
117
|
docs-href=${ifDefined((_a = this.docsHref) !== null && _a !== void 0 ? _a : void 0)}
|
|
118
|
+
operators=${JSON.stringify(this.operators)}
|
|
114
119
|
options=${JSON.stringify(this.options)}
|
|
115
120
|
infer="filter-query"
|
|
116
121
|
value=${filterQuery}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterAttributeForm.js","sourceRoot":"","sources":["../../../../src/elements/public/FilterAttributeForm/FilterAttributeForm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,uBAAuB,CAAC;AACnC,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,OAAO,mBAAoB,SAAQ,IAAU;IAAnD;;QAmBE,4BAA4B;QAC5B,aAAQ,GAAkB,IAAI,CAAC;QAE/B,2BAA2B;QAC3B,aAAQ,GAAkB,IAAI,CAAC;QAE/B,yDAAyD;QACzD,aAAQ,GAAkB,IAAI,CAAC;QAE/B,4DAA4D;QAC5D,YAAO,GAAa,EAAE,CAAC;QAEN,yBAAoB,GAAG,GAAG,EAAE;YAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,WAAyC,CAAC;YACnE,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QACzD,CAAC,CAAC;QAEe,yBAAoB,GAAG,CAAC,CAAS,EAAE,EAAE;YACpD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAyC,CAAC;YACnE,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC;IAiJJ,CAAC;IA/KC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CA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GAAW,cAAc,CAAC;AAExC,iCAAa,GAAW,qBAAqB,CAAC;AAE9C,iCAAa,GAAW,aAAa,CAAC","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { QueryBuilder } from '../QueryBuilder/QueryBuilder';\nimport type { Option } from '../QueryBuilder/types';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { encode, decode } from 'html-entities';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'filter-attribute-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for creating and editing saved filters in Admin. Saved filters\n * are powered by the Bookmark attribute format that allows adding custom sidebar items\n * to Admin. Bookmark attributes are named `foxy-admin-bookmark` and contain a\n * relative URL of the bookmarked Admin page in the value.\n *\n * @element foxy-filter-attribute-form\n * @since 1.24.0\n */\nexport class FilterAttributeForm extends Base<Data> {\n static readonly attributeVisibility: Data['visibility'] = 'restricted';\n\n static readonly filterQueryKey: string = 'filter_query';\n\n static readonly attributeName: string = 'foxy-admin-bookmark';\n\n static readonly filterNameKey: string = 'filter_name';\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n defaults: {},\n pathname: {},\n docsHref: { attribute: 'docs-href' },\n options: { type: Array },\n };\n }\n\n /** Default filter query. */\n defaults: string | null = null;\n\n /** Admin page pathname. */\n pathname: string | null = null;\n\n /** Same as the `docsHref` property of `QueryBuilder`. */\n docsHref: string | null = null;\n\n /** Filter options passed down to `QueryBuilder.options.` */\n options: Option[] = [];\n\n private readonly __filterNameGetValue = () => {\n const constructor = this.constructor as typeof FilterAttributeForm;\n return this.__getValueParam(constructor.filterNameKey);\n };\n\n private readonly __filterNameSetValue = (v: string) => {\n const constructor = this.constructor as typeof FilterAttributeForm;\n this.__setValueParam(constructor.filterNameKey, v);\n };\n\n renderBody(): TemplateResult {\n const constructor = this.constructor as typeof FilterAttributeForm;\n const filterQuery = this.__getValueParam(constructor.filterQueryKey);\n const hasValue = !!this.form.value;\n const hasData = !!this.data;\n const hasChanges =\n this.in({ idle: { snapshot: 'dirty' } }) || this.in({ idle: { template: 'dirty' } });\n\n return html`\n <div class=\"flex gap-s\">\n ${this.data\n ? html`\n <div\n class=\"flex-1 rounded bg-contrast-5 transition-colors hover-bg-contrast-10 focus-within-bg-contrast-10 focus-within-ring-2 focus-within-ring-primary-50\"\n >\n <input\n placeholder=${this.t('filter-name.placeholder')}\n aria-label=${this.t('filter-name.label')}\n style=\"padding: 0 calc(0.625 * var(--lumo-font-size-m) + (var(--lumo-border-radius) / 4) - 1px)\"\n class=\"block w-full h-full appearance-none bg-transparent text-xl font-medium focus-outline-none\"\n .value=${this.__filterNameGetValue()}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter') {\n evt.preventDefault();\n this.submit();\n }\n }}\n @input=${(evt: Event) => {\n this.__filterNameSetValue((evt.target as HTMLInputElement).value);\n }}\n />\n </div>\n `\n : html`\n <foxy-i18n class=\"text-xl flex-1 font-medium\" infer=\"header\" key=\"title\"></foxy-i18n>\n `}\n ${hasChanges\n ? html`\n <vaadin-button\n theme=\"secondary contrast\"\n style=${ifDefined(hasData ? void 0 : '--lumo-button-size: auto')}\n ?disabled=${this.disabled}\n @click=${() => this.undo()}\n >\n <foxy-i18n infer=\"action\" class=\"px-s\" key=\"reset\"></foxy-i18n>\n </vaadin-button>\n `\n : ''}\n ${!hasValue || (!filterQuery && !hasData)\n ? ''\n : html`\n <vaadin-button\n theme=${hasData ? (hasChanges ? 'secondary' : 'error') : 'success'}\n style=${ifDefined(hasData ? void 0 : '--lumo-button-size: auto')}\n ?disabled=${this.disabled}\n @click=${() => (!hasData || hasChanges ? this.submit() : this.delete())}\n >\n <foxy-i18n\n infer=\"action\"\n class=\"px-s\"\n key=${hasData ? (hasChanges ? 'update' : 'delete') : 'create'}\n >\n </foxy-i18n>\n </vaadin-button>\n `}\n </div>\n\n <foxy-query-builder\n docs-href=${ifDefined(this.docsHref ?? void 0)}\n options=${JSON.stringify(this.options)}\n infer=\"filter-query\"\n value=${filterQuery}\n disable-zoom\n @change=${this.__handleFilterQueryChange}\n >\n </foxy-query-builder>\n `;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (typeof this.form.value === 'string') {\n const url = new URL(decode(this.form.value), 'https://example.com');\n url.pathname = this.pathname ?? '';\n const value = encode(url.toString().substring(url.origin.length));\n if (value !== this.form.value) this.edit({ value });\n }\n }\n\n submit(): void {\n const constructor = this.constructor as typeof FilterAttributeForm;\n\n this.edit({\n visibility: constructor.attributeVisibility,\n name: constructor.attributeName,\n });\n\n super.submit();\n }\n\n private __getValueParam(key: string) {\n try {\n const constructor = this.constructor as typeof FilterAttributeForm;\n const url = new URL(decode(this.form.value ?? ''), 'https://example.com');\n\n let result = url.searchParams.get(key) ?? '';\n\n if (\n key === constructor.filterQueryKey &&\n (this.in({ idle: { snapshot: 'clean' } }) || this.in({ idle: { template: 'clean' } }))\n ) {\n try {\n const fullQuery = new URLSearchParams(result);\n const defaults = new URLSearchParams(this.defaults ?? '');\n fullQuery.forEach((v, k) => defaults.set(k, v));\n result = defaults.toString();\n } catch {\n // no-op\n }\n }\n\n return result;\n } catch {\n return '';\n }\n }\n\n private __setValueParam(key: string, value: string) {\n try {\n const url = new URL(decode(this.form.value ?? ''), 'https://example.com');\n url.searchParams.set(key, value);\n this.edit({ value: encode(url.toString().substring(url.origin.length)) });\n } catch {\n // ignore\n }\n }\n\n private __handleFilterQueryChange(evt: CustomEvent) {\n const constructor = this.constructor as typeof FilterAttributeForm;\n const element = evt.currentTarget as QueryBuilder;\n this.__setValueParam(constructor.filterQueryKey, element.value ?? '');\n this.requestUpdate();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilterAttributeForm.js","sourceRoot":"","sources":["../../../../src/elements/public/FilterAttributeForm/FilterAttributeForm.ts"],"names":[],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B,YAAY,CAAC;AAEvD,kCAAc,GAAW,cAAc,CAAC;AAExC,iCAAa,GAAW,qBAAqB,CAAC;AAE9C,iCAAa,GAAW,aAAa,CAAC","sourcesContent":["import type { ConditionalOperator, Option } from '../QueryBuilder/types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { QueryBuilder } from '../QueryBuilder/QueryBuilder';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { encode, decode } from 'html-entities';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { Operator } from '../QueryBuilder/types';\nimport { html } from 'lit-html';\n\nconst NS = 'filter-attribute-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for creating and editing saved filters in Admin. Saved filters\n * are powered by the Bookmark attribute format that allows adding custom sidebar items\n * to Admin. Bookmark attributes are named `foxy-admin-bookmark` and contain a\n * relative URL of the bookmarked Admin page in the value.\n *\n * @element foxy-filter-attribute-form\n * @since 1.24.0\n */\nexport class FilterAttributeForm extends Base<Data> {\n static readonly attributeVisibility: Data['visibility'] = 'restricted';\n\n static readonly filterQueryKey: string = 'filter_query';\n\n static readonly attributeName: string = 'foxy-admin-bookmark';\n\n static readonly filterNameKey: string = 'filter_name';\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n operators: { type: Array },\n defaults: {},\n pathname: {},\n docsHref: { attribute: 'docs-href' },\n options: { type: Array },\n };\n }\n\n /** List of operators passed down to `QueryBuilder.operators`. */\n operators: (Operator | ConditionalOperator)[] = Object.values(Operator);\n\n /** Default filter query. */\n defaults: string | null = null;\n\n /** Admin page pathname. */\n pathname: string | null = null;\n\n /** Same as the `docsHref` property of `QueryBuilder`. */\n docsHref: string | null = null;\n\n /** Filter options passed down to `QueryBuilder.options.` */\n options: Option[] = [];\n\n private readonly __filterNameGetValue = () => {\n const constructor = this.constructor as typeof FilterAttributeForm;\n return this.__getValueParam(constructor.filterNameKey);\n };\n\n private readonly __filterNameSetValue = (v: string) => {\n const constructor = this.constructor as typeof FilterAttributeForm;\n this.__setValueParam(constructor.filterNameKey, v);\n };\n\n renderBody(): TemplateResult {\n const constructor = this.constructor as typeof FilterAttributeForm;\n const filterQuery = this.__getValueParam(constructor.filterQueryKey);\n const hasValue = !!this.form.value;\n const hasData = !!this.data;\n const hasChanges =\n this.in({ idle: { snapshot: 'dirty' } }) || this.in({ idle: { template: 'dirty' } });\n\n return html`\n <div class=\"flex gap-s\">\n ${this.data\n ? html`\n <div\n class=\"flex-1 rounded bg-contrast-5 transition-colors hover-bg-contrast-10 focus-within-bg-contrast-10 focus-within-ring-2 focus-within-ring-primary-50\"\n >\n <input\n placeholder=${this.t('filter-name.placeholder')}\n aria-label=${this.t('filter-name.label')}\n style=\"padding: 0 calc(0.625 * var(--lumo-font-size-m) + (var(--lumo-border-radius) / 4) - 1px)\"\n class=\"block w-full h-full appearance-none bg-transparent text-xl font-medium focus-outline-none\"\n .value=${this.__filterNameGetValue()}\n @keydown=${(evt: KeyboardEvent) => {\n if (evt.key === 'Enter') {\n evt.preventDefault();\n this.submit();\n }\n }}\n @input=${(evt: Event) => {\n this.__filterNameSetValue((evt.target as HTMLInputElement).value);\n }}\n />\n </div>\n `\n : html`\n <foxy-i18n class=\"text-xl flex-1 font-medium\" infer=\"header\" key=\"title\"></foxy-i18n>\n `}\n ${hasChanges\n ? html`\n <vaadin-button\n theme=\"secondary contrast\"\n style=${ifDefined(hasData ? void 0 : '--lumo-button-size: auto')}\n ?disabled=${this.disabled}\n @click=${() => this.undo()}\n >\n <foxy-i18n infer=\"action\" class=\"px-s\" key=\"reset\"></foxy-i18n>\n </vaadin-button>\n `\n : ''}\n ${!hasValue || (!filterQuery && !hasData)\n ? ''\n : html`\n <vaadin-button\n theme=${hasData ? (hasChanges ? 'secondary' : 'error') : 'success'}\n style=${ifDefined(hasData ? void 0 : '--lumo-button-size: auto')}\n ?disabled=${this.disabled}\n @click=${() => (!hasData || hasChanges ? this.submit() : this.delete())}\n >\n <foxy-i18n\n infer=\"action\"\n class=\"px-s\"\n key=${hasData ? (hasChanges ? 'update' : 'delete') : 'create'}\n >\n </foxy-i18n>\n </vaadin-button>\n `}\n </div>\n\n <foxy-query-builder\n docs-href=${ifDefined(this.docsHref ?? void 0)}\n operators=${JSON.stringify(this.operators)}\n options=${JSON.stringify(this.options)}\n infer=\"filter-query\"\n value=${filterQuery}\n disable-zoom\n @change=${this.__handleFilterQueryChange}\n >\n </foxy-query-builder>\n `;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (typeof this.form.value === 'string') {\n const url = new URL(decode(this.form.value), 'https://example.com');\n url.pathname = this.pathname ?? '';\n const value = encode(url.toString().substring(url.origin.length));\n if (value !== this.form.value) this.edit({ value });\n }\n }\n\n submit(): void {\n const constructor = this.constructor as typeof FilterAttributeForm;\n\n this.edit({\n visibility: constructor.attributeVisibility,\n name: constructor.attributeName,\n });\n\n super.submit();\n }\n\n private __getValueParam(key: string) {\n try {\n const constructor = this.constructor as typeof FilterAttributeForm;\n const url = new URL(decode(this.form.value ?? ''), 'https://example.com');\n\n let result = url.searchParams.get(key) ?? '';\n\n if (\n key === constructor.filterQueryKey &&\n (this.in({ idle: { snapshot: 'clean' } }) || this.in({ idle: { template: 'clean' } }))\n ) {\n try {\n const fullQuery = new URLSearchParams(result);\n const defaults = new URLSearchParams(this.defaults ?? '');\n fullQuery.forEach((v, k) => defaults.set(k, v));\n result = defaults.toString();\n } catch {\n // no-op\n }\n }\n\n return result;\n } catch {\n return '';\n }\n }\n\n private __setValueParam(key: string, value: string) {\n try {\n const url = new URL(decode(this.form.value ?? ''), 'https://example.com');\n url.searchParams.set(key, value);\n this.edit({ value: encode(url.toString().substring(url.origin.length)) });\n } catch {\n // ignore\n }\n }\n\n private __handleFilterQueryChange(evt: CustomEvent) {\n const constructor = this.constructor as typeof FilterAttributeForm;\n const element = evt.currentTarget as QueryBuilder;\n this.__setValueParam(constructor.filterQueryKey, element.value ?? '');\n this.requestUpdate();\n }\n}\n"]}
|
|
@@ -55,12 +55,12 @@ export class PaymentsApiPaymentPresetForm extends Base {
|
|
|
55
55
|
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
56
56
|
}
|
|
57
57
|
get hiddenSelector() {
|
|
58
|
-
var _a;
|
|
58
|
+
var _a, _b;
|
|
59
59
|
const alwaysMatch = ['header:copy-json', super.hiddenSelector.toString()];
|
|
60
|
-
const
|
|
60
|
+
const isStoreActive = !!((_b = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.is_active);
|
|
61
61
|
if (!this.data)
|
|
62
62
|
alwaysMatch.unshift('payment-methods', 'fraud-protections');
|
|
63
|
-
if (!
|
|
63
|
+
if (!isStoreActive)
|
|
64
64
|
alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');
|
|
65
65
|
return new BooleanSelector(alwaysMatch.join(' ').trim());
|
|
66
66
|
}
|
package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentsApiPaymentPresetForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,kCAAkC,CAAC;AAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,M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AAW,CAAC,OAAO,CAAC,iBAAiB,EAAE,mCAAmC,CAAC,CAAC;SAC7E;QAED,OAAO,IAAI,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,cAAc;;QAChB,MAAM,WAAW,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1E,MAAM,
|
|
1
|
+
{"version":3,"file":"PaymentsApiPaymentPresetForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,kCAAkC,CAAC;AAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,4BAA6B,SAAQ,IAAU;IAA5D;;QAgBE,2EAA2E;QAC3E,+BAA0B,GAAsC,IAAI,CAAC;QAErE,yEAAyE;QACzE,6BAAwB,GAAsC,IAAI,CAAC;QAElD,qCAAgC,GAAG,GAAG,EAAE;;YACvD,OAAO,aAAA,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,SAAS,EAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC;QAC3F,CAAC,CAAC;QAEe,qBAAgB,GAAG,GAAG,EAAE;;YACvC,OAAO,aAAA,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,SA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AC,UAAU,EAAE;;;;;eAKX,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;aAC/C,IAAI,CAAC,eAAe;kBACf,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;;;KAGvC,CAAC;IACJ,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Data } from './types';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payments-api-payment-preset-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_preset` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-preset-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentPresetForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getFraudProtectionImageSrc: { attribute: false },\n getPaymentMethodImageSrc: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !!v || 'description:v8n_required',\n ({ description: v }) => (v && v.length <= 100) || 'description:v8n_too_long',\n ];\n }\n\n /** A function that returns image URL for given fraud protection `type`. */\n getFraudProtectionImageSrc: ((type: string) => string) | null = null;\n\n /** A function that returns image URL for given payment method `type`. */\n getPaymentMethodImageSrc: ((type: string) => string) | null = null;\n\n private readonly __isPurchaseOrderEnabledGetValue = () => {\n return this.__storeLoader?.data?.is_active ? this.form.is_purchase_order_enabled : false;\n };\n\n private readonly __isLiveGetValue = () => {\n return this.__storeLoader?.data?.is_active ? this.form.is_live : false;\n };\n\n private readonly __storeLoaderId = 'storeLoader';\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n\n if (!this.__storeLoader?.data?.is_active) {\n alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = ['header:copy-json', super.hiddenSelector.toString()];\n const isStoreActive = !!this.__storeLoader?.data?.is_active;\n\n if (!this.data) alwaysMatch.unshift('payment-methods', 'fraud-protections');\n if (!isStoreActive) alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n const isStoreActive = !!this.__storeLoader?.data?.is_active;\n const helperTextSuffix = isStoreActive ? '' : '_inactive_store';\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n <foxy-internal-switch-control\n helper-text=${this.t(`general.is-live.helper_text${helperTextSuffix}`)}\n infer=\"is-live\"\n helper-text-as-tooltip\n .getValue=${this.__isLiveGetValue}\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n helper-text=${this.t(`general.is-purchase-order-enabled.helper_text${helperTextSuffix}`)}\n infer=\"is-purchase-order-enabled\"\n helper-text-as-tooltip\n .getValue=${this.__isPurchaseOrderEnabledGetValue}\n >\n </foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"payment-methods\"\n first=${ifDefined(this.data?._links['fx:payment_methods'].href)}\n limit=\"5\"\n item=\"foxy-payments-api-payment-method-card\"\n form=\"foxy-payments-api-payment-method-form\"\n alert\n wide\n .itemProps=${{ '.getImageSrc': this.getPaymentMethodImageSrc }}\n .formProps=${{\n '.getImageSrc': this.getPaymentMethodImageSrc,\n 'payment-preset': this.href,\n 'store': this.data?._links['fx:store'].href,\n }}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n infer=\"fraud-protections\"\n first=${ifDefined(this.data?._links['fx:fraud_protections'].href)}\n limit=\"5\"\n item=\"foxy-payments-api-fraud-protection-card\"\n form=\"foxy-payments-api-fraud-protection-form\"\n alert\n .itemProps=${{ '.getImageSrc': this.getFraudProtectionImageSrc }}\n .formProps=${{ '.getImageSrc': this.getFraudProtectionImageSrc }}\n >\n </foxy-internal-async-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
|
-
import type { Option } from './types';
|
|
2
|
+
import type { Option, ConditionalOperator } from './types';
|
|
3
3
|
import { LitElement } from 'lit-element';
|
|
4
4
|
import { Operator, Type } from './types';
|
|
5
5
|
declare const Base: typeof LitElement & import("lit-element").Constructor<import("../../../mixins/inferrable").InferrableMixinHost> & {
|
|
@@ -61,8 +61,8 @@ export declare class QueryBuilder extends Base {
|
|
|
61
61
|
disableZoom: boolean;
|
|
62
62
|
/** If true, hides the UI for the "OR" operator in queries in the Advanced Mode. */
|
|
63
63
|
disableOr: boolean;
|
|
64
|
-
/** List of operators available in the builder UI. */
|
|
65
|
-
operators: Operator[];
|
|
64
|
+
/** List of operators available in the builder UI. When an operator is an object, it specifies the operator type and the paths it applies to. */
|
|
65
|
+
operators: (Operator | ConditionalOperator)[];
|
|
66
66
|
/** When provided, will display a documentation link in the Advanced Mode. */
|
|
67
67
|
docsHref: string | null;
|
|
68
68
|
/** Filter options in Simple Mode and autocomplete suggestions in Advanced Mode. */
|
|
@@ -32,7 +32,7 @@ export class QueryBuilder extends Base {
|
|
|
32
32
|
this.disableZoom = false;
|
|
33
33
|
/** If true, hides the UI for the "OR" operator in queries in the Advanced Mode. */
|
|
34
34
|
this.disableOr = false;
|
|
35
|
-
/** List of operators available in the builder UI. */
|
|
35
|
+
/** List of operators available in the builder UI. When an operator is an object, it specifies the operator type and the paths it applies to. */
|
|
36
36
|
this.operators = Object.values(Operator);
|
|
37
37
|
/** When provided, will display a documentation link in the Advanced Mode. */
|
|
38
38
|
this.docsHref = null;
|