@foxy.io/elements 1.43.0-beta.3 → 1.43.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.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-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.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-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +11 -11
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.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-i18n-editor.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.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-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.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-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card-embed.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.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-reports-table.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +2 -2
- package/dist/cdn/foxy-store-card.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-subscription-card.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-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +2 -2
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.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-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-3558bfae.js → shared-070211c0.js} +1 -1
- package/dist/cdn/{shared-457789d7.js → shared-0e605594.js} +1 -1
- package/dist/cdn/{shared-206d3153.js → shared-0fa21237.js} +1 -1
- package/dist/cdn/{shared-cd3cfea5.js → shared-0fb90a71.js} +1 -1
- package/dist/cdn/{shared-a3234358.js → shared-107dc7d7.js} +4 -4
- package/dist/cdn/{shared-6540a584.js → shared-140c6b70.js} +1 -1
- package/dist/cdn/{shared-a715e3e5.js → shared-160072f2.js} +1 -1
- package/dist/cdn/{shared-7b5bdf0e.js → shared-1b4a3e56.js} +1 -1
- package/dist/cdn/{shared-0993c2f5.js → shared-1f95aa71.js} +1 -1
- package/dist/cdn/{shared-2ebcaabc.js → shared-28253ef3.js} +1 -1
- package/dist/cdn/{shared-5aacbf1f.js → shared-2b328555.js} +1 -1
- package/dist/cdn/{shared-8b0d25e5.js → shared-2c7e0ed1.js} +1 -1
- package/dist/cdn/shared-2d3bdc6b.js +1 -0
- package/dist/cdn/{shared-21a445d9.js → shared-34a7df04.js} +1 -1
- package/dist/cdn/{shared-aab4ed2b.js → shared-364b98a1.js} +1 -1
- package/dist/cdn/{shared-2c00e6b1.js → shared-3c64ecdd.js} +1 -1
- package/dist/cdn/{shared-12bab9de.js → shared-3f4549ba.js} +1 -1
- package/dist/cdn/{shared-ee689ddc.js → shared-4388f7ea.js} +1 -1
- package/dist/cdn/{shared-2f17b0fa.js → shared-46a20973.js} +1 -1
- package/dist/cdn/{shared-264bea6b.js → shared-48129732.js} +1 -1
- package/dist/cdn/{shared-0584a904.js → shared-50a355d6.js} +1 -1
- package/dist/cdn/{shared-9363a954.js → shared-5492f8eb.js} +1 -1
- package/dist/cdn/{shared-9006bac2.js → shared-59c064c2.js} +1 -1
- package/dist/cdn/{shared-e52d2fdd.js → shared-5a6e4a7b.js} +1 -1
- package/dist/cdn/{shared-3e3c5095.js → shared-5af5ab06.js} +1 -1
- package/dist/cdn/{shared-03b67a3d.js → shared-6313b188.js} +1 -1
- package/dist/cdn/{shared-6a65acb4.js → shared-69c7ad04.js} +1 -1
- package/dist/cdn/{shared-5700fbfd.js → shared-742899dc.js} +1 -1
- package/dist/cdn/{shared-bdbdf963.js → shared-7d1512e1.js} +1 -1
- package/dist/cdn/{shared-74a5f2a4.js → shared-7e18a7d9.js} +1 -1
- package/dist/cdn/{shared-3ffa26c1.js → shared-8530fbae.js} +1 -1
- package/dist/cdn/{shared-944fab16.js → shared-88a1cb23.js} +1 -1
- package/dist/cdn/{shared-90a8d5cf.js → shared-8a570d01.js} +1 -1
- package/dist/cdn/{shared-1b627cc5.js → shared-8a743005.js} +1 -1
- package/dist/cdn/{shared-76c608e2.js → shared-9884fb7d.js} +1 -1
- package/dist/cdn/{shared-ab0bbad5.js → shared-9bfb584b.js} +1 -1
- package/dist/cdn/{shared-1af6aa1d.js → shared-a0fbe3ef.js} +5 -5
- package/dist/cdn/{shared-998c0ace.js → shared-a16ef278.js} +1 -1
- package/dist/cdn/{shared-68d1075b.js → shared-a41ccdc7.js} +3 -3
- package/dist/cdn/{shared-aedaf182.js → shared-a4871405.js} +1 -1
- package/dist/cdn/{shared-ddda911c.js → shared-a89e8a07.js} +1 -1
- package/dist/cdn/{shared-f497cd69.js → shared-acee789f.js} +1 -1
- package/dist/cdn/{shared-80dafe85.js → shared-ad8d209a.js} +1 -1
- package/dist/cdn/{shared-2db6b377.js → shared-b15efc37.js} +1 -1
- package/dist/cdn/{shared-02acac7f.js → shared-c16f05d9.js} +1 -1
- package/dist/cdn/{shared-8dd6f543.js → shared-ce0df878.js} +1 -1
- package/dist/cdn/{shared-2557c0c4.js → shared-cf6122d9.js} +1 -1
- package/dist/cdn/{shared-10c8f21c.js → shared-d3aefd9b.js} +1 -1
- package/dist/cdn/{shared-be7af87f.js → shared-d3f37507.js} +1 -1
- package/dist/cdn/{shared-19b43f73.js → shared-d4928805.js} +1 -1
- package/dist/cdn/{shared-6ebe5ef5.js → shared-d8b0432a.js} +1 -1
- package/dist/cdn/{shared-b2bd7666.js → shared-db50afd9.js} +1 -1
- package/dist/cdn/shared-dc1fc2e6.js +1 -0
- package/dist/cdn/shared-dfe59df6.js +1 -0
- package/dist/cdn/{shared-cd0ae051.js → shared-e02936f0.js} +3 -3
- package/dist/cdn/{shared-6eebe353.js → shared-e126cf44.js} +2 -2
- package/dist/cdn/shared-e82550b1.js +40 -0
- package/dist/cdn/{shared-8259d01b.js → shared-ebfb86b5.js} +1 -1
- package/dist/cdn/{shared-1c252319.js → shared-f2be9863.js} +1 -1
- package/dist/cdn/{shared-109cfbba.js → shared-f2e8070b.js} +1 -1
- package/dist/cdn/{shared-13ba9f3a.js → shared-f3590d20.js} +2 -2
- package/dist/cdn/{shared-049295b7.js → shared-f7b4a4f6.js} +1 -1
- package/dist/cdn/{shared-3e0b2588.js → shared-fa482a7d.js} +1 -1
- package/dist/cdn/translations/admin-subscription-form/en.json +2 -2
- package/dist/cdn/translations/coupon-code-form/en.json +2 -2
- package/dist/cdn/translations/coupon-form/en.json +2 -2
- package/dist/cdn/translations/customer/en.json +5 -5
- package/dist/cdn/translations/customer-portal/de.json +6 -5
- package/dist/cdn/translations/customer-portal/en.json +6 -5
- package/dist/cdn/translations/customer-portal/es.json +6 -5
- package/dist/cdn/translations/customer-portal/fr.json +6 -5
- package/dist/cdn/translations/customer-portal/nl.json +6 -5
- package/dist/cdn/translations/customer-portal/pl.json +6 -5
- package/dist/cdn/translations/customer-portal/sv.json +6 -5
- package/dist/cdn/translations/customer-portal/zh-HK.json +6 -5
- package/dist/cdn/translations/subscription-card/en.json +2 -1
- package/dist/cdn/translations/subscription-form/en.json +2 -2
- package/dist/cdn/translations/subscriptions-table/en.json +2 -1
- package/dist/cdn/translations/transaction-card/en.json +2 -2
- package/dist/cdn/translations/transactions-table/en.json +3 -3
- package/dist/elements/internal/InternalEditableListControl/InternalEditableListControl.js +5 -4
- package/dist/elements/internal/InternalEditableListControl/InternalEditableListControl.js.map +1 -1
- package/dist/elements/internal/InternalSummaryControl/InternalSummaryControl.js +6 -6
- package/dist/elements/internal/InternalSummaryControl/InternalSummaryControl.js.map +1 -1
- package/dist/elements/public/Donation/Donation.d.ts +4 -1
- package/dist/elements/public/Donation/Donation.js +22 -1
- package/dist/elements/public/Donation/Donation.js.map +1 -1
- package/dist/elements/public/FilterAttributeForm/FilterAttributeForm.js +4 -15
- package/dist/elements/public/FilterAttributeForm/FilterAttributeForm.js.map +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.d.ts +2 -0
- package/dist/elements/public/QueryBuilder/QueryBuilder.js +5 -0
- package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/AdvancedInput.js +2 -1
- package/dist/elements/public/QueryBuilder/components/AdvancedInput.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/SimpleInput.js +9 -2
- package/dist/elements/public/QueryBuilder/components/SimpleInput.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/parse.js +19 -16
- package/dist/elements/public/QueryBuilder/utils/parse.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/stringify.js +22 -45
- package/dist/elements/public/QueryBuilder/utils/stringify.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/zoom.d.ts +3 -0
- package/dist/elements/public/QueryBuilder/utils/zoom.js +29 -0
- package/dist/elements/public/QueryBuilder/utils/zoom.js.map +1 -0
- package/dist/elements/public/SubscriptionCard/SubscriptionCard.js +1 -1
- package/dist/elements/public/SubscriptionCard/SubscriptionCard.js.map +1 -1
- package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js +1 -1
- package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js.map +1 -1
- package/dist/elements/public/TransactionCard/TransactionCard.js +1 -1
- package/dist/elements/public/TransactionCard/TransactionCard.js.map +1 -1
- package/dist/elements/public/TransactionsTable/TransactionsTable.js +1 -1
- package/dist/elements/public/TransactionsTable/TransactionsTable.js.map +1 -1
- package/dist/mixins/themeable.js +0 -6
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-2f1ced90.js +0 -1
- package/dist/cdn/shared-88a59a2e.js +0 -1
- package/dist/cdn/shared-dd7e85be.js +0 -1
- package/dist/cdn/shared-f4be6924.js +0 -40
package/dist/elements/internal/InternalEditableListControl/InternalEditableListControl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalEditableListControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalEditableListControl/InternalEditableListControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,MAAM,OAAO,2BAA4B,SAAQ,uBAAuB;IAAxE;;QAuCE,gBAAW,GAA4B,EAAE,CAAC;QAE1C,gBAAW,GAAG,KAAK,CAAC;QAEpB,YAAO,GAAa,EAAE,CAAC;QAEvB,WAAM,GAAyC,IAAI,CAAC;QAEpD,UAAK,GAAW,EAAE,CAAC;QAEnB,UAAK,GAAsB,IAAI,C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AC,mBAAmB;SACrC,CAAC;0BACU,mBAAmB;uBACtB,OAAO;;;;;;;;;gBASd,QAAQ,CAAC;YACf,4BAA4B,EAAE,IAAI;YAClC,SAAS,EAAE,aAAa;YACxB,QAAQ,EAAE,CAAC,aAAa;SACzB,CAAC;kBACQ,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;;UAEvF,IAAI,CAAC,aAAa;;KAEvB,CAAC;IACJ,CAAC;IAED,IAAc,MAAM;;QAClB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,OAAE,KAAkB,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACnF,OAAO,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAW,CAAC;IACjC,CAAC;IAED,IAAc,MAAM,CAAC,QAAgB;QACnC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;SACnD;aAAM;YACL,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;SACzB;IACH,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Item, Option, Unit } from './types';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { html, css } from 'lit-element';\nimport { classMap } from '../../../utils/class-map';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { spread } from '@open-wc/lit-helpers';\nimport { live } from 'lit-html/directives/live';\n\nexport class InternalEditableListControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n inputParams: { attribute: false },\n simpleValue: { type: Boolean, attribute: 'simple-value' },\n options: { type: Array },\n layout: {},\n units: { type: Array },\n range: {},\n __isErrorVisible: { attribute: false },\n __newItem: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n div:has(> select) {\n position: relative;\n }\n\n div:has(> select)::after {\n content: ' ';\n position: absolute;\n top: 50%;\n margin-top: -2px;\n right: 10px;\n width: 0;\n height: 0;\n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n border-top: 5px solid currentColor;\n }\n `,\n ];\n }\n\n inputParams: Record<string, unknown> = {};\n\n simpleValue = false;\n\n options: Option[] = [];\n\n layout: 'standalone' | 'summary-item' | null = null;\n\n units: Unit[] = [];\n\n range: null | 'optional' = null;\n\n private __isErrorVisible = false;\n\n private __newItem = '';\n\n render(): TemplateResult {\n const isSummaryItem = this.layout === 'summary-item';\n const isInteractive = !this.disabled && !this.readonly;\n\n const deleteButtonClass = classMap({\n 'w-xs h-xs rounded-s transition-colors flex-shrink-0': true,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': true,\n 'text-tertiary hover-bg-error-10 hover-text-error': !this.disabled,\n 'cursor-default text-disabled': this.disabled,\n 'flex items-center justify-center': !this.readonly,\n 'hidden': this.readonly,\n 'mr-xs': !isSummaryItem,\n });\n\n const itemClass = classMap({\n 'transition-colors flex items-center': true,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'border border-contrast-10 rounded-s': isSummaryItem,\n 'h-m': !isSummaryItem,\n });\n\n const isAddButtonDisabled = this.disabled || !this.__newItem;\n\n const addItem = () => {\n const newValue = [...this._value];\n const unit = this.renderRoot.querySelector('select')?.value;\n\n this.__newItem\n .split('\\n')\n .map(code => code.trim())\n .filter(code => code.length > 0)\n .forEach(value => {\n if (!newValue.some(item => item.value === value)) {\n newValue.push({ value, unit });\n }\n });\n\n this._value = newValue;\n this.__newItem = '';\n };\n\n return html`\n <div class=\"mb-s\" ?hidden=${!this.label && !this.helperText}>\n <div class=${classMap({ 'font-medium text-l': !isSummaryItem })}>${this.label}</div>\n <div\n class=${classMap({\n 'text-secondary': true,\n 'text-xs': isSummaryItem,\n 'text-s': !isSummaryItem,\n })}\n ?hidden=${!this.helperText}\n >\n ${this.helperText}\n </div>\n </div>\n\n <div\n class=${classMap({\n 'bg-contrast-5 rounded': !isSummaryItem,\n 'mt-s': isSummaryItem,\n })}\n >\n <ol\n class=${classMap({\n 'transition-colors font-medium': true,\n 'divide-y divide-contrast-10': !isSummaryItem,\n 'flex flex-wrap gap-s': isSummaryItem,\n })}\n >\n ${repeat(\n this._value,\n item => item.value,\n (item, index) => {\n return html`\n <li\n class=${itemClass}\n style=\"padding-left: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <div class=\"flex-1 mr-s\">${item.label ?? item.value}</div>\n\n <button\n aria-label=${this.t('delete')}\n class=${deleteButtonClass}\n ?disabled=${this.disabled}\n @click=${() => {\n this._value = this._value.filter((_, i) => i !== index);\n }}\n >\n <iron-icon icon=\"lumo:cross\" class=\"icon-inline text-xl\"></iron-icon>\n </button>\n </li>\n `;\n }\n )}\n </ol>\n\n <div\n style=\"padding-left: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n class=${classMap({\n 'transition-colors h-m flex items-center gap-xs': true,\n 'focus-within-ring-2 focus-within-ring-primary-50': !isSummaryItem,\n 'bg-contrast-5 hover-bg-contrast-10': !isSummaryItem && isInteractive,\n 'bg-contrast-5': !isSummaryItem && this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n 'rounded-s border border-contrast-10': isSummaryItem,\n 'mt-s': isSummaryItem && this._value.length > 0,\n 'rounded': !isSummaryItem && this._value.length === 0,\n 'rounded-b': !isSummaryItem && this._value.length > 0,\n })}\n >\n ${this.range\n ? html`\n <foxy-i18n infer=\"\" class=\"text-disabled font-medium\" key=\"range_from\"> </foxy-i18n>\n\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'bg-transparent appearance-none h-m font-medium focus-outline-none': true,\n 'text-disabled': this.disabled,\n })}\n list=\"list\"\n ...=${spread(this.inputParams)}\n .value=${live(this.__newItem.split('..')[0] ?? '')}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && addItem()}\n @change=${(evt: Event) => evt.stopPropagation()}\n @input=${(evt: InputEvent) => {\n const newFrom = (evt.currentTarget as HTMLInputElement).value.trim();\n const oldTo = this.__newItem.split('..')[1] ?? '';\n this.__newItem = oldTo ? `${newFrom}..${oldTo}` : newFrom;\n }}\n @paste=${(evt: ClipboardEvent) => {\n evt.preventDefault();\n\n const newFrom = evt.clipboardData?.getData('text') ?? '';\n const oldTo = this.__newItem.split('..')[1] ?? '';\n this.__newItem = oldTo ? `${newFrom}..${oldTo}` : newFrom;\n\n addItem();\n }}\n @blur=${() => {\n this.__isErrorVisible = true;\n }}\n />\n\n <foxy-i18n infer=\"\" class=\"text-disabled font-medium\" key=\"range_to\"></foxy-i18n>\n\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'bg-transparent appearance-none h-m font-medium focus-outline-none': true,\n 'text-disabled': this.disabled,\n })}\n list=\"list\"\n ...=${spread(this.inputParams)}\n .value=${live(this.__newItem.split('..')[1] ?? '')}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && addItem()}\n @change=${(evt: Event) => evt.stopPropagation()}\n @input=${(evt: InputEvent) => {\n const newTo = (evt.currentTarget as HTMLInputElement).value.trim();\n const oldFrom = this.__newItem.split('..')[0] ?? '';\n this.__newItem = oldFrom ? `${oldFrom}..${newTo}` : newTo;\n }}\n @paste=${(evt: ClipboardEvent) => {\n evt.preventDefault();\n\n const newTo = evt.clipboardData?.getData('text') ?? '';\n const oldFrom = this.__newItem.split('..')[0] ?? '';\n this.__newItem = oldFrom ? `${oldFrom}..${newTo}` : newTo;\n\n addItem();\n }}\n @blur=${() => {\n this.__isErrorVisible = true;\n }}\n />\n `\n : html`\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'w-full bg-transparent appearance-none h-m font-medium focus-outline-none':\n true,\n 'text-disabled': this.disabled,\n })}\n list=\"list\"\n ...=${spread(this.inputParams)}\n .value=${live(this.__newItem)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && addItem()}\n @change=${(evt: Event) => evt.stopPropagation()}\n @input=${(evt: InputEvent) => {\n this.__newItem = (evt.currentTarget as HTMLInputElement).value.trim();\n }}\n @paste=${(evt: ClipboardEvent) => {\n evt.preventDefault();\n this.__newItem = evt.clipboardData?.getData('text') ?? '';\n if (this.__newItem.includes('\\n')) addItem();\n }}\n @blur=${() => {\n this.__isErrorVisible = true;\n }}\n />\n `}\n\n <div\n class=${classMap({\n 'relative': true,\n 'hover-text-base focus-within-text-primary-contrast': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n ?hidden=${this.units.length === 0}\n >\n <select\n style=\"min-width: 8rem\"\n class=${classMap({\n 'transition-colors rounded-s mx-xs px-s': true,\n 'bg-contrast-5 appearance-none h-xs font-medium focus-outline-none': true,\n 'hover-bg-contrast focus-bg-primary': !this.disabled,\n })}\n ?disabled=${this.disabled}\n >\n ${this.units.map(({ label, value }) => {\n return html`<option value=${value}>${label ?? value}</option>`;\n })}\n </select>\n </div>\n\n <datalist id=\"list\">\n ${this.options.map(({ label, value }) => {\n if (this._value.some(item => item.value === value)) return;\n return html`<option value=${value}>${label ?? value}</option>`;\n })}\n </datalist>\n\n <div class=\"mr-xs ml-auto\" ?hidden=${!this.__newItem}>\n <button\n aria-label=${this.t('submit')}\n class=${classMap({\n 'w-xs h-xs flex-shrink-0 ring-inset ring-success-50 focus-outline-none': true,\n 'flex items-center justify-center rounded-s transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': isAddButtonDisabled,\n 'bg-contrast-5 text-body cursor-pointer': !isAddButtonDisabled,\n 'hover-bg-success hover-text-success-contrast': !isAddButtonDisabled,\n 'focus-ring-2': !isAddButtonDisabled,\n })}\n ?disabled=${isAddButtonDisabled}\n @click=${addItem}\n >\n <iron-icon icon=\"lumo:plus\" class=\"icon-inline text-l\"></iron-icon>\n </button>\n </div>\n </div>\n </div>\n\n <div\n class=${classMap({\n 'mt-s leading-xs text-error': true,\n 'text-xs': isSummaryItem,\n 'text-s': !isSummaryItem,\n })}\n ?hidden=${!this.__isErrorVisible || !this._errorMessage || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </div>\n `;\n }\n\n protected get _value(): Item[] {\n const value = super._value;\n if (this.simpleValue) return ((value as string[]) ?? []).map(value => ({ value }));\n return (value ?? []) as Item[];\n }\n\n protected set _value(newValue: Item[]) {\n if (this.simpleValue) {\n super._value = newValue.map(({ value }) => value);\n } else {\n super._value = newValue;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalEditableListControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalEditableListControl/InternalEditableListControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,MAAM,OAAO,2BAA4B,SAAQ,uBAAuB;IAAxE;;QAuCE,gBAAW,GAA4B,EAAE,CAAC;QAE1C,gBAAW,GAAG,KAAK,CAAC;QAEpB,YAAO,GAAa,EAAE,CAAC;QAEvB,WAAM,GAAyC,IAAI,CAAC;QAEpD,UAAK,GAAW,EAAE,CAAC;QAEnB,UAAK,GAAsB,IAAI,CAAC;QAExB,qBAAgB,GAAG,KAA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Q,CAAC;sBACrB,QAAQ,CAAC;YACf,uEAAuE,EAAE,IAAI;YAC7E,8DAA8D,EAAE,IAAI;YACpE,4CAA4C,EAAE,mBAAmB;YACjE,wCAAwC,EAAE,CAAC,mBAAmB;YAC9D,8CAA8C,EAAE,CAAC,mBAAmB;YACpE,cAAc,EAAE,CAAC,mBAAmB;SACrC,CAAC;0BACU,mBAAmB;uBACtB,OAAO;;;;;;;;;gBASd,QAAQ,CAAC;YACf,4BAA4B,EAAE,IAAI;YAClC,SAAS,EAAE,aAAa;YACxB,QAAQ,EAAE,CAAC,aAAa;SACzB,CAAC;kBACQ,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;;UAEvF,IAAI,CAAC,aAAa;;KAEvB,CAAC;IACJ,CAAC;IAED,IAAc,MAAM;;QAClB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,OAAE,KAAkB,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACnF,OAAO,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAW,CAAC;IACjC,CAAC;IAED,IAAc,MAAM,CAAC,QAAgB;QACnC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;SACnD;aAAM;YACL,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;SACzB;IACH,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Item, Option, Unit } from './types';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { html, css } from 'lit-element';\nimport { classMap } from '../../../utils/class-map';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { spread } from '@open-wc/lit-helpers';\nimport { live } from 'lit-html/directives/live';\n\nexport class InternalEditableListControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n inputParams: { attribute: false },\n simpleValue: { type: Boolean, attribute: 'simple-value' },\n options: { type: Array },\n layout: {},\n units: { type: Array },\n range: {},\n __isErrorVisible: { attribute: false },\n __newItem: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n div:has(> select) {\n position: relative;\n }\n\n div:has(> select)::after {\n content: ' ';\n position: absolute;\n top: 50%;\n margin-top: -2px;\n right: 10px;\n width: 0;\n height: 0;\n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n border-top: 5px solid currentColor;\n }\n `,\n ];\n }\n\n inputParams: Record<string, unknown> = {};\n\n simpleValue = false;\n\n options: Option[] = [];\n\n layout: 'standalone' | 'summary-item' | null = null;\n\n units: Unit[] = [];\n\n range: null | 'optional' = null;\n\n private __isErrorVisible = false;\n\n private __newItem = '';\n\n render(): TemplateResult {\n const isSummaryItem = this.layout === 'summary-item';\n const isInteractive = !this.disabled && !this.readonly;\n\n const deleteButtonClass = classMap({\n 'w-xs h-xs rounded-s transition-colors flex-shrink-0': true,\n 'focus-outline-none focus-ring-2 ring-inset ring-error-50': true,\n 'text-tertiary hover-bg-error-10 hover-text-error': !this.disabled,\n 'cursor-default text-disabled': this.disabled,\n 'flex items-center justify-center': !this.readonly,\n 'hidden': this.readonly,\n 'mr-xs': !isSummaryItem,\n });\n\n const itemClass = classMap({\n 'transition-colors flex items-center': true,\n 'text-secondary': this.readonly,\n 'text-disabled': this.disabled,\n 'border border-contrast-10 rounded-s': isSummaryItem,\n 'h-m': !isSummaryItem,\n });\n\n const isAddButtonDisabled = this.disabled || !this.__newItem;\n\n const addItem = (split = false) => {\n const newValue = [...this._value];\n const splitBy = split && this.__newItem.includes(',') ? ',' : '\\n';\n const unit = this.renderRoot.querySelector('select')?.value;\n\n this.__newItem\n .split(splitBy)\n .map(code => code.trim())\n .filter(code => code.length > 0)\n .forEach(value => {\n if (!newValue.some(item => item.value === value)) {\n newValue.push({ value, unit });\n }\n });\n\n this._value = newValue;\n this.__newItem = '';\n };\n\n return html`\n <div class=\"mb-s\" ?hidden=${!this.label && !this.helperText}>\n <div class=${classMap({ 'font-medium text-l': !isSummaryItem })}>${this.label}</div>\n <div\n class=${classMap({\n 'text-secondary': true,\n 'text-xs': isSummaryItem,\n 'text-s': !isSummaryItem,\n })}\n ?hidden=${!this.helperText}\n >\n ${this.helperText}\n </div>\n </div>\n\n <div\n class=${classMap({\n 'bg-contrast-5 rounded': !isSummaryItem,\n 'mt-s': isSummaryItem,\n })}\n >\n <ol\n class=${classMap({\n 'transition-colors font-medium': true,\n 'divide-y divide-contrast-10': !isSummaryItem,\n 'flex flex-wrap gap-s': isSummaryItem,\n })}\n >\n ${repeat(\n this._value,\n item => item.value,\n (item, index) => {\n return html`\n <li\n class=${itemClass}\n style=\"padding-left: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <div class=\"flex-1 mr-s\">${item.label ?? item.value}</div>\n\n <button\n aria-label=${this.t('delete')}\n class=${deleteButtonClass}\n ?disabled=${this.disabled}\n @click=${() => {\n this._value = this._value.filter((_, i) => i !== index);\n }}\n >\n <iron-icon icon=\"lumo:cross\" class=\"icon-inline text-xl\"></iron-icon>\n </button>\n </li>\n `;\n }\n )}\n </ol>\n\n <div\n style=\"padding-left: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n class=${classMap({\n 'transition-colors h-m flex items-center gap-xs': true,\n 'focus-within-ring-2 focus-within-ring-primary-50': !isSummaryItem,\n 'bg-contrast-5 hover-bg-contrast-10': !isSummaryItem && isInteractive,\n 'bg-contrast-5': !isSummaryItem && this.disabled,\n 'flex': !this.readonly,\n 'hidden': this.readonly,\n 'rounded-s border border-contrast-10': isSummaryItem,\n 'mt-s': isSummaryItem && this._value.length > 0,\n 'rounded': !isSummaryItem && this._value.length === 0,\n 'rounded-b': !isSummaryItem && this._value.length > 0,\n })}\n >\n ${this.range\n ? html`\n <foxy-i18n infer=\"\" class=\"text-disabled font-medium\" key=\"range_from\"> </foxy-i18n>\n\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'bg-transparent appearance-none h-m font-medium focus-outline-none': true,\n 'text-disabled': this.disabled,\n })}\n list=\"list\"\n ...=${spread(this.inputParams)}\n .value=${live(this.__newItem.split('..')[0] ?? '')}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && addItem()}\n @change=${(evt: Event) => evt.stopPropagation()}\n @input=${(evt: InputEvent) => {\n const newFrom = (evt.currentTarget as HTMLInputElement).value.trim();\n const oldTo = this.__newItem.split('..')[1] ?? '';\n this.__newItem = oldTo ? `${newFrom}..${oldTo}` : newFrom;\n }}\n @paste=${(evt: ClipboardEvent) => {\n evt.preventDefault();\n\n const newFrom = evt.clipboardData?.getData('text') ?? '';\n const oldTo = this.__newItem.split('..')[1] ?? '';\n this.__newItem = oldTo ? `${newFrom}..${oldTo}` : newFrom;\n\n addItem();\n }}\n @blur=${() => {\n this.__isErrorVisible = true;\n }}\n />\n\n <foxy-i18n infer=\"\" class=\"text-disabled font-medium\" key=\"range_to\"></foxy-i18n>\n\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'bg-transparent appearance-none h-m font-medium focus-outline-none': true,\n 'text-disabled': this.disabled,\n })}\n list=\"list\"\n ...=${spread(this.inputParams)}\n .value=${live(this.__newItem.split('..')[1] ?? '')}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && addItem()}\n @change=${(evt: Event) => evt.stopPropagation()}\n @input=${(evt: InputEvent) => {\n const newTo = (evt.currentTarget as HTMLInputElement).value.trim();\n const oldFrom = this.__newItem.split('..')[0] ?? '';\n this.__newItem = oldFrom ? `${oldFrom}..${newTo}` : newTo;\n }}\n @paste=${(evt: ClipboardEvent) => {\n evt.preventDefault();\n\n const newTo = evt.clipboardData?.getData('text') ?? '';\n const oldFrom = this.__newItem.split('..')[0] ?? '';\n this.__newItem = oldFrom ? `${oldFrom}..${newTo}` : newTo;\n\n addItem();\n }}\n @blur=${() => {\n this.__isErrorVisible = true;\n }}\n />\n `\n : html`\n <input\n placeholder=${this.placeholder}\n class=${classMap({\n 'w-full bg-transparent appearance-none h-m font-medium focus-outline-none':\n true,\n 'text-disabled': this.disabled,\n })}\n list=\"list\"\n ...=${spread(this.inputParams)}\n .value=${live(this.__newItem)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && addItem()}\n @change=${(evt: Event) => evt.stopPropagation()}\n @input=${(evt: InputEvent) => {\n this.__newItem = (evt.currentTarget as HTMLInputElement).value.trim();\n }}\n @paste=${(evt: ClipboardEvent) => {\n evt.preventDefault();\n this.__newItem = evt.clipboardData?.getData('text') ?? '';\n if (this.__newItem.includes('\\n') || this.__newItem.includes(','))\n addItem(true);\n }}\n @blur=${() => {\n this.__isErrorVisible = true;\n }}\n />\n `}\n\n <div\n class=${classMap({\n 'relative': true,\n 'hover-text-base focus-within-text-primary-contrast': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n ?hidden=${this.units.length === 0}\n >\n <select\n style=\"min-width: 8rem\"\n class=${classMap({\n 'transition-colors rounded-s mx-xs px-s': true,\n 'bg-contrast-5 appearance-none h-xs font-medium focus-outline-none': true,\n 'hover-bg-contrast focus-bg-primary': !this.disabled,\n })}\n ?disabled=${this.disabled}\n >\n ${this.units.map(({ label, value }) => {\n return html`<option value=${value}>${label ?? value}</option>`;\n })}\n </select>\n </div>\n\n <datalist id=\"list\">\n ${this.options.map(({ label, value }) => {\n if (this._value.some(item => item.value === value)) return;\n return html`<option value=${value}>${label ?? value}</option>`;\n })}\n </datalist>\n\n <div class=\"mr-xs ml-auto\" ?hidden=${!this.__newItem}>\n <button\n aria-label=${this.t('submit')}\n class=${classMap({\n 'w-xs h-xs flex-shrink-0 ring-inset ring-success-50 focus-outline-none': true,\n 'flex items-center justify-center rounded-s transition-colors': true,\n 'bg-contrast-5 text-disabled cursor-default': isAddButtonDisabled,\n 'bg-contrast-5 text-body cursor-pointer': !isAddButtonDisabled,\n 'hover-bg-success hover-text-success-contrast': !isAddButtonDisabled,\n 'focus-ring-2': !isAddButtonDisabled,\n })}\n ?disabled=${isAddButtonDisabled}\n @click=${addItem}\n >\n <iron-icon icon=\"lumo:plus\" class=\"icon-inline text-l\"></iron-icon>\n </button>\n </div>\n </div>\n </div>\n\n <div\n class=${classMap({\n 'mt-s leading-xs text-error': true,\n 'text-xs': isSummaryItem,\n 'text-s': !isSummaryItem,\n })}\n ?hidden=${!this.__isErrorVisible || !this._errorMessage || this.disabled || this.readonly}\n >\n ${this._errorMessage}\n </div>\n `;\n }\n\n protected get _value(): Item[] {\n const value = super._value;\n if (this.simpleValue) return ((value as string[]) ?? []).map(value => ({ value }));\n return (value ?? []) as Item[];\n }\n\n protected set _value(newValue: Item[]) {\n if (this.simpleValue) {\n super._value = newValue.map(({ value }) => value);\n } else {\n super._value = newValue;\n }\n }\n}\n"]}
|
|
@@ -78,14 +78,14 @@ details[open] summary > div{
|
|
|
78
78
|
style="padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
|
|
79
79
|
?hidden=${!this.label && !this.helperText}
|
|
80
80
|
>
|
|
81
|
-
<p
|
|
82
|
-
|
|
81
|
+
<p
|
|
82
|
+
class="flex items-center justify-between gap-s transition-opacity group-hover-opacity-80"
|
|
83
|
+
?hidden=${!this.label}
|
|
84
|
+
>
|
|
85
|
+
<span class="font-medium">
|
|
83
86
|
${this.label}${typeof this.count === 'number' ? ` (${this.count})` : ''}
|
|
84
87
|
</span>
|
|
85
|
-
<span
|
|
86
|
-
class="flex items-center justify-center transition-colors text-tertiary group-hover-text-body"
|
|
87
|
-
style="transform: scale(1.35)"
|
|
88
|
-
>
|
|
88
|
+
<span class="flex items-center justify-center" style="transform: scale(1.35)">
|
|
89
89
|
${svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.2em; height: 1.2em"><path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /></svg>`}
|
|
90
90
|
</span>
|
|
91
91
|
</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalSummaryControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalSummaryControl/InternalSummaryControl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAkB,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,sBAAuB,SAAQ,uBAAuB;IAAnE;;QAkDE,qBAAgB,GAAG,KAAK,CAAC;QAEzB,WAAM,GAAiC,IAAI,CAAC;QAE5C,UAAK,GAAkB,IAAI,CAAC;QAE5B,SAAI,GAAG,KAAK,CAAC;IA2Df,CAAC;IAlHC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,gBAAgB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE;YACpE,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACvB,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;SACvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,GAAG,KAAK,CAAC,MAAM;YACf,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCF;SACF,CAAC;IACJ,CAAC;IAUD,cAAc;QACZ,OAAO;IACT,CAAC;IAED,aAAa;QACX,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,IAAI,CAAA;;;kBAGC,IAAI,CAAC,IAAI;oBACP,CAAC,GAAU,EAAE,EAAE;gBACvB,MAAM,OAAO,GAAG,GAAG,CAAC,aAAmC,CAAC;gBACxD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;gBACzB,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,OAAO;oBAAE,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnF,CAAC;;;;;;wBAMa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU
|
|
1
|
+
{"version":3,"file":"InternalSummaryControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalSummaryControl/InternalSummaryControl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAkB,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,sBAAuB,SAAQ,uBAAuB;IAAnE;;QAkDE,qBAAgB,GAAG,KAAK,CAAC;QAEzB,WAAM,GAAiC,IAAI,CAAC;QAE5C,UAAK,GAAkB,IAAI,CAAC;QAE5B,SAAI,GAAG,KAAK,CAAC;IA2Df,CAAC;IAlHC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KA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,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU;;;;;;;;OAQhF,CAAC;SACH;QAED,OAAO,IAAI,CAAA;4CAC6B,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU;0DACjB,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK;+DACpB,CAAC,IAAI,CAAC,UAAU;YACnE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU;;;;;;KAM5E,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations } from 'lit-element';\nimport { svg, TemplateResult } from 'lit-html';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\nimport { html, css } from 'lit-element';\n\nexport class InternalSummaryControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n unsafeHelperText: { type: Boolean, attribute: 'unsafe-helper-text' },\n layout: {},\n count: { type: Number },\n open: { type: Boolean, reflect: true },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n ::slotted(*) {\n min-width: 100%;\n }\n\n :host(:not([layout='section'])) slot::slotted(*) {\n background-color: var(--lumo-contrast-5pct);\n padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px);\n }\n\n details summary > div {\n border-radius: var(--lumo-border-radius);\n }\n\n details[open] summary > div {\n border-radius: var(--lumo-border-radius) var(--lumo-border-radius) 0 0;\n }\n\n .with-unsafe a {\n text-decoration: underline;\n transition: color 0.1s ease-in-out;\n }\n\n .with-unsafe a:hover {\n color: var(--lumo-primary-text-color);\n }\n\n .with-unsafe a:focus {\n outline: none;\n box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);\n border-radius: var(--lumo-border-radius-s);\n }\n `,\n ];\n }\n\n unsafeHelperText = false;\n\n layout: null | 'section' | 'details' = null;\n\n count: number | null = null;\n\n open = false;\n\n renderLightDom(): void {\n return;\n }\n\n renderControl(): TemplateResult {\n if (this.layout === 'details') {\n return html`\n <details\n class=\"rounded overflow-hidden\"\n ?open=${this.open}\n @toggle=${(evt: Event) => {\n const details = evt.currentTarget as HTMLDetailsElement;\n this.open = details.open;\n if (!evt.composed && !evt.bubbles) this.dispatchEvent(new CustomEvent('toggle'));\n }}\n >\n <summary class=\"select-none cursor-pointer focus-outline-none group\">\n <div\n class=\"leading-xs bg-contrast-5 group-focus-ring-2 group-focus-ring-inset group-focus-ring-primary-50\"\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n ?hidden=${!this.label && !this.helperText}\n >\n <p\n class=\"flex items-center justify-between gap-s transition-opacity group-hover-opacity-80\"\n ?hidden=${!this.label}\n >\n <span class=\"font-medium\">\n ${this.label}${typeof this.count === 'number' ? ` (${this.count})` : ''}\n </span>\n <span class=\"flex items-center justify-center\" style=\"transform: scale(1.35)\">\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1.2em; height: 1.2em\"><path fill-rule=\"evenodd\" d=\"M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z\" clip-rule=\"evenodd\" /></svg>`}\n </span>\n </p>\n <p class=\"text-xs text-secondary with-unsafe\" ?hidden=${!this.helperText}>\n ${this.unsafeHelperText ? unsafeHTML(this.helperText) : this.helperText}\n </p>\n </div>\n </summary>\n <div class=\"overflow-hidden grid\" style=\"gap: 1px\">\n <slot></slot>\n </div>\n </details>\n `;\n }\n\n return html`\n <div class=\"leading-s mb-s\" ?hidden=${!this.label && !this.helperText}>\n <p class=\"font-medium text-body text-l\" ?hidden=${!this.label}>${this.label}</p>\n <p class=\"text-s text-secondary with-unsafe\" ?hidden=${!this.helperText}>\n ${this.unsafeHelperText ? unsafeHTML(this.helperText) : this.helperText}\n </p>\n </div>\n <div class=\"rounded overflow-hidden grid\" style=\"gap: 1px\">\n <slot></slot>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -9,7 +9,7 @@ import { DonationSubmitEvent } from './DonationSubmitEvent';
|
|
|
9
9
|
declare global {
|
|
10
10
|
interface Window {
|
|
11
11
|
FC?: {
|
|
12
|
-
settings
|
|
12
|
+
settings?: {
|
|
13
13
|
session_name: string;
|
|
14
14
|
session_id: string;
|
|
15
15
|
};
|
|
@@ -182,10 +182,13 @@ export declare class Donation extends Translatable {
|
|
|
182
182
|
* Optional target to display the form response.
|
|
183
183
|
*/
|
|
184
184
|
target: string;
|
|
185
|
+
private __fcSessionPollInterval;
|
|
185
186
|
constructor();
|
|
186
187
|
/** Submits the form, emitting a cancelable `submit` event. */
|
|
187
188
|
submit(): void;
|
|
188
189
|
render(): TemplateResult;
|
|
190
|
+
connectedCallback(): void;
|
|
191
|
+
disconnectedCallback(): void;
|
|
189
192
|
updated(): void;
|
|
190
193
|
private get __data();
|
|
191
194
|
private get __form();
|
|
@@ -158,6 +158,7 @@ export class Donation extends Translatable {
|
|
|
158
158
|
* Optional target to display the form response.
|
|
159
159
|
*/
|
|
160
160
|
this.target = '_top';
|
|
161
|
+
this.__fcSessionPollInterval = null;
|
|
161
162
|
}
|
|
162
163
|
/** @readonly */
|
|
163
164
|
static get scopedElements() {
|
|
@@ -354,10 +355,29 @@ export class Donation extends Translatable {
|
|
|
354
355
|
</section>
|
|
355
356
|
`;
|
|
356
357
|
}
|
|
358
|
+
connectedCallback() {
|
|
359
|
+
var _a, _b;
|
|
360
|
+
super.connectedCallback();
|
|
361
|
+
if (!((_b = (_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.session_id) && this.__fcSessionPollInterval === null) {
|
|
362
|
+
this.__fcSessionPollInterval = window.setInterval(() => {
|
|
363
|
+
var _a, _b, _c;
|
|
364
|
+
if ((_b = (_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.session_id) {
|
|
365
|
+
clearInterval((_c = this.__fcSessionPollInterval) !== null && _c !== void 0 ? _c : void 0);
|
|
366
|
+
this.requestUpdate();
|
|
367
|
+
}
|
|
368
|
+
}, 1000);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
disconnectedCallback() {
|
|
372
|
+
var _a;
|
|
373
|
+
super.disconnectedCallback();
|
|
374
|
+
clearInterval((_a = this.__fcSessionPollInterval) !== null && _a !== void 0 ? _a : void 0);
|
|
375
|
+
}
|
|
357
376
|
updated() {
|
|
358
377
|
this.dispatchEvent(new DonationChangeEvent(this.__data));
|
|
359
378
|
}
|
|
360
379
|
get __data() {
|
|
380
|
+
var _a, _b;
|
|
361
381
|
const data = new FormData();
|
|
362
382
|
if (typeof this.designation === 'string') {
|
|
363
383
|
data.set('Designation', this.designation.trim());
|
|
@@ -383,8 +403,9 @@ export class Donation extends Translatable {
|
|
|
383
403
|
data.set('empty', this.empty);
|
|
384
404
|
if (this.anonymous)
|
|
385
405
|
data.set('Anonymous', 'true');
|
|
386
|
-
if (window.FC)
|
|
406
|
+
if (((_b = (_a = window.FC) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.session_id) && window.FC.settings.session_name) {
|
|
387
407
|
data.set(window.FC.settings.session_name, window.FC.settings.session_id);
|
|
408
|
+
}
|
|
388
409
|
data.set('quantity', '1');
|
|
389
410
|
return data;
|
|
390
411
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Donation.js","sourceRoot":"","sources":["../../../../src/elements/public/Donation/Donation.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4CAA4C,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,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AAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;YAChC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE;YACtC,qBAAqB,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAS;YACxB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport '@vaadin/vaadin-button';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { PropertyDeclarations } from 'lit-element';\nimport { html, TemplateResult } from 'lit-html';\nimport { Translatable } from '../../../mixins/translatable';\nimport { parseDuration } from '../../../utils/parse-duration';\nimport { CheckboxChangeEvent, ChoiceChangeEvent, DropdownChangeEvent } from '../../private/events';\nimport { Checkbox, Choice, Dropdown, ErrorScreen, Group, I18N } from '../../private/index';\nimport { DonationChangeEvent } from './DonationChangeEvent';\nimport { DonationSubmitEvent } from './DonationSubmitEvent';\n\ndeclare global {\n interface Window {\n FC?: {\n settings: {\n session_name: string;\n session_id: string;\n };\n };\n }\n}\n\ninterface DonationEventsMap {\n change: typeof DonationChangeEvent;\n submit: typeof DonationSubmitEvent;\n}\n\n/**\n * A custom element providing customizable donation forms.\n *\n * @fires Donation#change - Instance of `Donation.events.change`. Emitted after user input triggers a change in the form data.\n * @fires Donation#submit - Instance of `Donation.events.submit`. Emitted when the form is submitted. Cancelling this event will stop the submission.\n *\n * @slot amount - Space below the amount selector, if it's visible.\n * @slot designation - Space below the designation selector, if it's visible.\n * @slot comment - Space below the comment field, if it's visible.\n *\n * @element foxy-donation\n * @since 0.3.0\n */\nexport class Donation extends Translatable {\n /** @readonly */\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-error-screen': ErrorScreen,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-dropdown': Dropdown,\n 'x-checkbox': Checkbox,\n 'x-choice': Choice,\n 'x-group': Group,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n currency: { type: String },\n custom: { type: Array },\n amount: { type: Number },\n amounts: { type: Array },\n frequency: { type: String },\n frequencies: { type: Array },\n designation: { type: Array },\n designations: { type: Array },\n comment: { type: String },\n anonymity: { reflect: true, type: Boolean },\n anonymous: { reflect: true, type: Boolean },\n image: { type: String },\n store: { type: String },\n name: { type: String },\n code: { type: String },\n url: { type: String },\n cart: { type: String },\n target: { type: String },\n empty: { type: String },\n };\n }\n\n /** @readonly */\n public static get events(): DonationEventsMap {\n return {\n change: DonationChangeEvent,\n submit: DonationSubmitEvent,\n };\n }\n\n /**\n * **Required** 3-letter lowercase currency code.\n *\n * **Example:** `\"usd\"`\n */\n public currency: null | string = null;\n\n /**\n * **Required** donation amount in specified currency. When more than one amount option\n * is available, this field will contain the selected amount. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `25`\n */\n public amount: null | number = null;\n\n /**\n * **Required** store domain. This is usually the part after before `.foxycart.com`\n * and after `https://`, e.g. the `foxy-demo` bit of `https://foxy-demo.foxycart.com`.\n * Custom domains like `my.domain.example.com` are also supported since v1.6.1.\n *\n * **Example:** `\"foxy-demo\"`\n */\n public store: null | string = null;\n\n /**\n * **Required** product name for this donation. This will show up in the cart when this form is submitted.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"One-time donation\"`\n */\n public name: null | string = null;\n\n /**\n * Optional parts of the form including a custom (\"other\") option.\n * Adding `amount` to this array will enable custom amount.\n *\n * **Example:** `[\"amount\"]`\n */\n public custom: null | 'amount'[] = null;\n\n /**\n * Optional donation amount variants. If this property is set, the form will render\n * the amount selection interface. If this array includes the value of the `amount` property,\n * it will be pre-selected in the form.\n *\n * **Example:** `[25, 50, 75]`\n */\n public amounts: null | number[] = null;\n\n /**\n * Optional donation frequency string encoded as count (integer) + units (one\n * of: `d` for days, `w` for weeks, `m` for months, `y` for years). A special\n * value for twice a month is also supported: `.5m`. If set, the form will\n * create a subscription with the specified frequency in the cart. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `\"1m\"`\n */\n public frequency: null | string = null;\n\n /**\n * Optional donation frequency variants in the same format as `frequency`. If this property is set,\n * the form will render the frequency selection interface. If this array includes\n * the value of the `frequency` property, it will be pre-selected in the form.\n *\n * **Example:** `[\"7d\", \".5m\", \"1y\"]`\n */\n public frequencies: null | string[] = null;\n\n /**\n * Optional donation designation(s). The form will serialize and pass this value to the cart\n * on submission. This value is deliberately not limited to the predefined options:\n * whatever you set it to will show up in the cart.\n *\n * **Example:** `\"Medical Care\"`\n * **Example:** `[\"Medical Care\", \"Daily Meals\"]`\n */\n public designation: null | string = null;\n\n /**\n * Optional donation designation(s) variants. If this property is set,\n * the form will render the designation selection interface: multiple choice\n * if `designation` is an array and a single choice otherwise. All values overlapping\n * with the `designation` property will be pre-selected in the form.\n *\n * **Example:** `[\"Medical Care\", \"Daily Meals\", \"Area of Greatest Need\"]`\n */\n public designations: null | string[] = null;\n\n /**\n * Optional comment accompanying the donation. If set (even to an empty string),\n * the form will render a comment field. The value of this property will be updated\n * as the customer enters their message and will be added to the order as a custom field in the end.\n *\n * **Example:** `\"\"`\n */\n public comment: null | string = null;\n\n /**\n * Optional switch controlling visibility of the anonymity checkbox. If set to `true`, the form\n * will render the checkbox. All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymity = false;\n\n /**\n * Optional switch marking this donation as anonymous via a custom field when set to `true`. When\n * the anonymity checkbox is rendered, also checks or unchecks it depending on the value.\n * All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymous = false;\n\n /**\n * Optional product image URL (absolute path). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://picsum.photos/320\"`\n */\n public image: null | string = null;\n\n /**\n * Optional product code for this donation. This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public code: null | string = null;\n\n /**\n * Optional product URL for this donation. Accepts a full URL to the product page, starting\n * with `http://` or `https://`, or a relative path to the produt from the store's\n * domain (as configured in the store settings). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://example.com/my-product\"`\n */\n public url: null | string = null;\n\n /**\n * Optional cart\n * If set to 'add' will add items to the cart and, on submit, user is redirected to the cart.\n * If set to 'checkout', the default, on submit user is redirected to checkout directly\n */\n public cart = 'checkout';\n\n /**\n * Optional empty\n * If set to 'true' clears the contents of the cart prior to adding the donation to the cart\n * If set to 'reset' clears the contents of the cart and cookies prior to adding the donation to the cart\n */\n public empty?: string;\n\n /**\n * Optional target to display the form response.\n */\n public target = '_top';\n\n public constructor() {\n super('donation');\n }\n\n /** Submits the form, emitting a cancelable `submit` event. */\n public submit(): void {\n /* istanbul ignore if */\n if (this.dispatchEvent(new DonationSubmitEvent())) this.__form.submit();\n }\n\n public render(): TemplateResult {\n if (!this.currency || !this.amount || !this.store || !this.name) {\n return html`\n <x-error-screen data-testid=\"error\" type=\"setup_needed\" class=\"relative\"></x-error-screen>\n `;\n }\n\n const domain = this.store.includes('.') ? this.store : `${this.store}.foxycart.com`;\n\n return html`\n <form\n target=\"${this.target}\"\n class=\"sr-only\"\n method=\"POST\"\n action=\"https://${domain}/cart\"\n data-testid=\"form\"\n >\n ${[...this.__data.entries()].map(\n ([name, value]) => html`<input type=\"hidden\" name=${name} value=${value} />`\n )}\n </form>\n\n <section>\n ${this.amounts && this.amounts.length > 0\n ? html`\n <x-group frame>\n <x-i18n ns=${this.ns} lang=${this.lang} key=\"amount\" slot=\"header\"></x-i18n>\n <x-choice\n ?custom=${!!this.custom?.includes('amount')}\n .getText=${(v: string) => this.__translateAmount(parseFloat(v))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"number\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseFloat(evt.detail as string);\n this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;\n }}\n >\n </x-choice>\n </x-group>\n\n <slot name=\"amount\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.designations && this.designations.length > 0\n ? html`\n <x-dropdown\n .label=${this._t('designation').toString()}\n .items=${this.designations}\n .value=${Array.isArray(this.designation)\n ? '${this.designation[0]}: ${this.designation[1]}'\n : this.designation}\n data-testid=\"designation\"\n @change=${(evt: DropdownChangeEvent) => {\n this.designation = evt.detail as string;\n }}\n >\n </x-dropdown>\n\n <slot name=\"designation\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${typeof this.comment === 'string'\n ? html`\n <vaadin-text-area\n placeholder=${this._t('comment_placeholder').toString()}\n value=${this.comment!}\n label=${this._t('comment_label').toString()}\n class=\"w-full\"\n data-testid=\"comment\"\n @input=${(evt: InputEvent) => {\n evt.stopPropagation();\n this.comment = (evt.target as HTMLTextAreaElement).value;\n }}\n >\n </vaadin-text-area>\n\n <slot name=\"comment\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.anonymity\n ? html`\n <x-checkbox\n class=\"my-m\"\n data-testid=\"anonymity\"\n ?checked=${this.anonymous}\n @change=${(evt: CheckboxChangeEvent) => (this.anonymous = evt.detail)}\n >\n ${this._t('anonymous')}\n </x-checkbox>\n `\n : ''}\n\n <div class=\"flex flex-wrap -m-s\">\n ${this.frequencies && this.frequencies.length > 0\n ? html`\n <div class=\"flex-1 p-s\">\n <x-dropdown\n .value=${this.frequency}\n .items=${this.frequencies}\n .getText=${this.__translateFrequency.bind(this)}\n data-testid=\"frequency\"\n @change=${(evt: DropdownChangeEvent) => {\n this.frequency = evt.detail as string;\n }}\n >\n </x-dropdown>\n </div>\n `\n : ''}\n\n <div class=\"flex-1 p-s\">\n <vaadin-button\n class=\"w-full\"\n theme=\"primary\"\n data-testid=\"submit\"\n @click=${() => this.submit()}\n >\n <x-i18n\n .opts=${{\n amount: this.__translateAmount(this.amount),\n frequency: this.frequency ? this.__translateFrequency(this.frequency) : '',\n }}\n lang=${this.lang}\n key=${this.frequency && !this.frequencies?.length ? 'donate_recurrently' : 'donate'}\n ns=${this.ns}\n >\n </x-i18n>\n </vaadin-button>\n </div>\n </div>\n </section>\n `;\n }\n\n public updated(): void {\n this.dispatchEvent(new DonationChangeEvent(this.__data));\n }\n\n private get __data() {\n const data = new FormData();\n\n if (typeof this.designation === 'string') {\n data.set('Designation', this.designation.trim());\n }\n\n if (typeof this.amount === 'number' && typeof this.currency === 'string') {\n data.set('price', `${this.amount.toFixed(2)}${this.currency}`);\n }\n\n if (this.frequency) data.set('sub_frequency', this.frequency);\n if (typeof this.comment === 'string') data.set('Comment', this.comment.trim());\n if (typeof this.image === 'string') data.set('image', this.image);\n if (typeof this.code === 'string') data.set('code', this.code);\n if (typeof this.name === 'string') data.set('name', this.name.trim());\n if (typeof this.url === 'string') data.set('url', this.url);\n if (typeof this.cart === 'string') data.set('cart', this.cart);\n if (this.empty) data.set('empty', this.empty);\n if (this.anonymous) data.set('Anonymous', 'true');\n if (window.FC) data.set(window.FC.settings.session_name, window.FC.settings.session_id);\n\n data.set('quantity', '1');\n\n return data;\n }\n\n private get __form(): HTMLFormElement {\n return this.shadowRoot!.querySelector('form')!;\n }\n\n private __translateFrequency(frequency: string) {\n if (!frequency || frequency.match(/^\\s*$/)) return this._t('frequency_once');\n if (frequency === '.5m') return this._t('frequency_0_5m');\n\n const { count, units } = parseDuration(frequency);\n return this._t('frequency', {\n units: this._t(units, { count }),\n count,\n });\n }\n\n private __translateAmount(amount: number) {\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 0,\n currency: this.currency!,\n style: 'currency',\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Donation.js","sourceRoot":"","sources":["../../../../src/elements/public/Donation/Donation.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4CAA4C,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,wCAAqC;AAC5D,OAAO,EAAE,aAAa,EAAE,yCAAsC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,+BAA4B;AAC3F,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAkB5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAoNxC;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;QApKpB;;;;WAIG;QACI,aAAQ,GAAkB,IAAI,CAAC;QAEtC;;;;;;WAMG;QACI,WAAM,GAAkB,IAAI,CAAC;QAEpC;;;;;;WAMG;QACI,UAAK,GAAkB,IAAI,CAAC;QAEnC;;;;;WAKG;QACI,SAAI,GAAkB,IAAI,CAAC;QAElC;;;;;WAKG;QACI,WAAM,GAAsB,IAAI,CAAC;QAExC;;;;;;WAMG;QACI,YAAO,GAAoB,IAAI,CAAC;QAEvC;;;;;;;;WAQG;QACI,cAAS,GAAkB,IAAI,CAAC;QAEvC;;;;;;WAMG;QACI,gBAAW,GAAoB,IAAI,CAAC;QAE3C;;;;;;;WAOG;QACI,gBAAW,GAAkB,IAAI,CAAC;QAEzC;;;;;;;WAOG;QACI,iBAAY,GAAoB,IAAI,CAAC;QAE5C;;;;;;WAMG;QACI,YAAO,GAAkB,IAAI,CAAC;QAErC;;;;;WAKG;QACI,cAAS,GAAG,KAAK,CAAC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ACtC,qBAAqB,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAS;YACxB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport '@vaadin/vaadin-button';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { PropertyDeclarations } from 'lit-element';\nimport { html, TemplateResult } from 'lit-html';\nimport { Translatable } from '../../../mixins/translatable';\nimport { parseDuration } from '../../../utils/parse-duration';\nimport { CheckboxChangeEvent, ChoiceChangeEvent, DropdownChangeEvent } from '../../private/events';\nimport { Checkbox, Choice, Dropdown, ErrorScreen, Group, I18N } from '../../private/index';\nimport { DonationChangeEvent } from './DonationChangeEvent';\nimport { DonationSubmitEvent } from './DonationSubmitEvent';\n\ndeclare global {\n interface Window {\n FC?: {\n settings?: {\n session_name: string;\n session_id: string;\n };\n };\n }\n}\n\ninterface DonationEventsMap {\n change: typeof DonationChangeEvent;\n submit: typeof DonationSubmitEvent;\n}\n\n/**\n * A custom element providing customizable donation forms.\n *\n * @fires Donation#change - Instance of `Donation.events.change`. Emitted after user input triggers a change in the form data.\n * @fires Donation#submit - Instance of `Donation.events.submit`. Emitted when the form is submitted. Cancelling this event will stop the submission.\n *\n * @slot amount - Space below the amount selector, if it's visible.\n * @slot designation - Space below the designation selector, if it's visible.\n * @slot comment - Space below the comment field, if it's visible.\n *\n * @element foxy-donation\n * @since 0.3.0\n */\nexport class Donation extends Translatable {\n /** @readonly */\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'x-error-screen': ErrorScreen,\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-dropdown': Dropdown,\n 'x-checkbox': Checkbox,\n 'x-choice': Choice,\n 'x-group': Group,\n 'x-i18n': I18N,\n };\n }\n\n /** @readonly */\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n currency: { type: String },\n custom: { type: Array },\n amount: { type: Number },\n amounts: { type: Array },\n frequency: { type: String },\n frequencies: { type: Array },\n designation: { type: Array },\n designations: { type: Array },\n comment: { type: String },\n anonymity: { reflect: true, type: Boolean },\n anonymous: { reflect: true, type: Boolean },\n image: { type: String },\n store: { type: String },\n name: { type: String },\n code: { type: String },\n url: { type: String },\n cart: { type: String },\n target: { type: String },\n empty: { type: String },\n };\n }\n\n /** @readonly */\n public static get events(): DonationEventsMap {\n return {\n change: DonationChangeEvent,\n submit: DonationSubmitEvent,\n };\n }\n\n /**\n * **Required** 3-letter lowercase currency code.\n *\n * **Example:** `\"usd\"`\n */\n public currency: null | string = null;\n\n /**\n * **Required** donation amount in specified currency. When more than one amount option\n * is available, this field will contain the selected amount. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `25`\n */\n public amount: null | number = null;\n\n /**\n * **Required** store domain. This is usually the part after before `.foxycart.com`\n * and after `https://`, e.g. the `foxy-demo` bit of `https://foxy-demo.foxycart.com`.\n * Custom domains like `my.domain.example.com` are also supported since v1.6.1.\n *\n * **Example:** `\"foxy-demo\"`\n */\n public store: null | string = null;\n\n /**\n * **Required** product name for this donation. This will show up in the cart when this form is submitted.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"One-time donation\"`\n */\n public name: null | string = null;\n\n /**\n * Optional parts of the form including a custom (\"other\") option.\n * Adding `amount` to this array will enable custom amount.\n *\n * **Example:** `[\"amount\"]`\n */\n public custom: null | 'amount'[] = null;\n\n /**\n * Optional donation amount variants. If this property is set, the form will render\n * the amount selection interface. If this array includes the value of the `amount` property,\n * it will be pre-selected in the form.\n *\n * **Example:** `[25, 50, 75]`\n */\n public amounts: null | number[] = null;\n\n /**\n * Optional donation frequency string encoded as count (integer) + units (one\n * of: `d` for days, `w` for weeks, `m` for months, `y` for years). A special\n * value for twice a month is also supported: `.5m`. If set, the form will\n * create a subscription with the specified frequency in the cart. This value is deliberately not\n * limited to the predefined options: whatever you set it to will show up in the cart.\n *\n * **Example:** `\"1m\"`\n */\n public frequency: null | string = null;\n\n /**\n * Optional donation frequency variants in the same format as `frequency`. If this property is set,\n * the form will render the frequency selection interface. If this array includes\n * the value of the `frequency` property, it will be pre-selected in the form.\n *\n * **Example:** `[\"7d\", \".5m\", \"1y\"]`\n */\n public frequencies: null | string[] = null;\n\n /**\n * Optional donation designation(s). The form will serialize and pass this value to the cart\n * on submission. This value is deliberately not limited to the predefined options:\n * whatever you set it to will show up in the cart.\n *\n * **Example:** `\"Medical Care\"`\n * **Example:** `[\"Medical Care\", \"Daily Meals\"]`\n */\n public designation: null | string = null;\n\n /**\n * Optional donation designation(s) variants. If this property is set,\n * the form will render the designation selection interface: multiple choice\n * if `designation` is an array and a single choice otherwise. All values overlapping\n * with the `designation` property will be pre-selected in the form.\n *\n * **Example:** `[\"Medical Care\", \"Daily Meals\", \"Area of Greatest Need\"]`\n */\n public designations: null | string[] = null;\n\n /**\n * Optional comment accompanying the donation. If set (even to an empty string),\n * the form will render a comment field. The value of this property will be updated\n * as the customer enters their message and will be added to the order as a custom field in the end.\n *\n * **Example:** `\"\"`\n */\n public comment: null | string = null;\n\n /**\n * Optional switch controlling visibility of the anonymity checkbox. If set to `true`, the form\n * will render the checkbox. All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymity = false;\n\n /**\n * Optional switch marking this donation as anonymous via a custom field when set to `true`. When\n * the anonymity checkbox is rendered, also checks or unchecks it depending on the value.\n * All changes in the value are reflected to the attribute.\n *\n * **Example:** `true`\n */\n public anonymous = false;\n\n /**\n * Optional product image URL (absolute path). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://picsum.photos/320\"`\n */\n public image: null | string = null;\n\n /**\n * Optional product code for this donation. This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"ISBN 978-0-12-345678-9\"`\n */\n public code: null | string = null;\n\n /**\n * Optional product URL for this donation. Accepts a full URL to the product page, starting\n * with `http://` or `https://`, or a relative path to the produt from the store's\n * domain (as configured in the store settings). This property affects cart UI only.\n * See [Products](https://wiki.foxycart.com/v/2.0/products) wiki for more details.\n *\n * **Example:** `\"https://example.com/my-product\"`\n */\n public url: null | string = null;\n\n /**\n * Optional cart\n * If set to 'add' will add items to the cart and, on submit, user is redirected to the cart.\n * If set to 'checkout', the default, on submit user is redirected to checkout directly\n */\n public cart = 'checkout';\n\n /**\n * Optional empty\n * If set to 'true' clears the contents of the cart prior to adding the donation to the cart\n * If set to 'reset' clears the contents of the cart and cookies prior to adding the donation to the cart\n */\n public empty?: string;\n\n /**\n * Optional target to display the form response.\n */\n public target = '_top';\n\n private __fcSessionPollInterval: number | null = null;\n\n public constructor() {\n super('donation');\n }\n\n /** Submits the form, emitting a cancelable `submit` event. */\n public submit(): void {\n /* istanbul ignore if */\n if (this.dispatchEvent(new DonationSubmitEvent())) this.__form.submit();\n }\n\n public render(): TemplateResult {\n if (!this.currency || !this.amount || !this.store || !this.name) {\n return html`\n <x-error-screen data-testid=\"error\" type=\"setup_needed\" class=\"relative\"></x-error-screen>\n `;\n }\n\n const domain = this.store.includes('.') ? this.store : `${this.store}.foxycart.com`;\n\n return html`\n <form\n target=\"${this.target}\"\n class=\"sr-only\"\n method=\"POST\"\n action=\"https://${domain}/cart\"\n data-testid=\"form\"\n >\n ${[...this.__data.entries()].map(\n ([name, value]) => html`<input type=\"hidden\" name=${name} value=${value} />`\n )}\n </form>\n\n <section>\n ${this.amounts && this.amounts.length > 0\n ? html`\n <x-group frame>\n <x-i18n ns=${this.ns} lang=${this.lang} key=\"amount\" slot=\"header\"></x-i18n>\n <x-choice\n ?custom=${!!this.custom?.includes('amount')}\n .getText=${(v: string) => this.__translateAmount(parseFloat(v))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"number\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseFloat(evt.detail as string);\n this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;\n }}\n >\n </x-choice>\n </x-group>\n\n <slot name=\"amount\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.designations && this.designations.length > 0\n ? html`\n <x-dropdown\n .label=${this._t('designation').toString()}\n .items=${this.designations}\n .value=${Array.isArray(this.designation)\n ? '${this.designation[0]}: ${this.designation[1]}'\n : this.designation}\n data-testid=\"designation\"\n @change=${(evt: DropdownChangeEvent) => {\n this.designation = evt.detail as string;\n }}\n >\n </x-dropdown>\n\n <slot name=\"designation\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${typeof this.comment === 'string'\n ? html`\n <vaadin-text-area\n placeholder=${this._t('comment_placeholder').toString()}\n value=${this.comment!}\n label=${this._t('comment_label').toString()}\n class=\"w-full\"\n data-testid=\"comment\"\n @input=${(evt: InputEvent) => {\n evt.stopPropagation();\n this.comment = (evt.target as HTMLTextAreaElement).value;\n }}\n >\n </vaadin-text-area>\n\n <slot name=\"comment\" class=\"block my-m\"></slot>\n `\n : ''}\n </section>\n\n <section>\n ${this.anonymity\n ? html`\n <x-checkbox\n class=\"my-m\"\n data-testid=\"anonymity\"\n ?checked=${this.anonymous}\n @change=${(evt: CheckboxChangeEvent) => (this.anonymous = evt.detail)}\n >\n ${this._t('anonymous')}\n </x-checkbox>\n `\n : ''}\n\n <div class=\"flex flex-wrap -m-s\">\n ${this.frequencies && this.frequencies.length > 0\n ? html`\n <div class=\"flex-1 p-s\">\n <x-dropdown\n .value=${this.frequency}\n .items=${this.frequencies}\n .getText=${this.__translateFrequency.bind(this)}\n data-testid=\"frequency\"\n @change=${(evt: DropdownChangeEvent) => {\n this.frequency = evt.detail as string;\n }}\n >\n </x-dropdown>\n </div>\n `\n : ''}\n\n <div class=\"flex-1 p-s\">\n <vaadin-button\n class=\"w-full\"\n theme=\"primary\"\n data-testid=\"submit\"\n @click=${() => this.submit()}\n >\n <x-i18n\n .opts=${{\n amount: this.__translateAmount(this.amount),\n frequency: this.frequency ? this.__translateFrequency(this.frequency) : '',\n }}\n lang=${this.lang}\n key=${this.frequency && !this.frequencies?.length ? 'donate_recurrently' : 'donate'}\n ns=${this.ns}\n >\n </x-i18n>\n </vaadin-button>\n </div>\n </div>\n </section>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n if (!window.FC?.settings?.session_id && this.__fcSessionPollInterval === null) {\n this.__fcSessionPollInterval = window.setInterval(() => {\n if (window.FC?.settings?.session_id) {\n clearInterval(this.__fcSessionPollInterval ?? void 0);\n this.requestUpdate();\n }\n }, 1000);\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n clearInterval(this.__fcSessionPollInterval ?? void 0);\n }\n\n public updated(): void {\n this.dispatchEvent(new DonationChangeEvent(this.__data));\n }\n\n private get __data() {\n const data = new FormData();\n\n if (typeof this.designation === 'string') {\n data.set('Designation', this.designation.trim());\n }\n\n if (typeof this.amount === 'number' && typeof this.currency === 'string') {\n data.set('price', `${this.amount.toFixed(2)}${this.currency}`);\n }\n\n if (this.frequency) data.set('sub_frequency', this.frequency);\n if (typeof this.comment === 'string') data.set('Comment', this.comment.trim());\n if (typeof this.image === 'string') data.set('image', this.image);\n if (typeof this.code === 'string') data.set('code', this.code);\n if (typeof this.name === 'string') data.set('name', this.name.trim());\n if (typeof this.url === 'string') data.set('url', this.url);\n if (typeof this.cart === 'string') data.set('cart', this.cart);\n if (this.empty) data.set('empty', this.empty);\n if (this.anonymous) data.set('Anonymous', 'true');\n\n if (window.FC?.settings?.session_id && window.FC.settings.session_name) {\n data.set(window.FC.settings.session_name, window.FC.settings.session_id);\n }\n\n data.set('quantity', '1');\n\n return data;\n }\n\n private get __form(): HTMLFormElement {\n return this.shadowRoot!.querySelector('form')!;\n }\n\n private __translateFrequency(frequency: string) {\n if (!frequency || frequency.match(/^\\s*$/)) return this._t('frequency_once');\n if (frequency === '.5m') return this._t('frequency_0_5m');\n\n const { count, units } = parseDuration(frequency);\n return this._t('frequency', {\n units: this._t(units, { count }),\n count,\n });\n }\n\n private __translateAmount(amount: number) {\n return amount.toLocaleString(this.lang, {\n minimumFractionDigits: 0,\n currency: this.currency!,\n style: 'currency',\n });\n }\n}\n"]}
|
|
@@ -2,7 +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 { html
|
|
5
|
+
import { html } from 'lit-html';
|
|
6
6
|
const NS = 'filter-attribute-form';
|
|
7
7
|
const Base = TranslatableMixin(InternalForm, NS);
|
|
8
8
|
/**
|
|
@@ -47,9 +47,9 @@ export class FilterAttributeForm extends Base {
|
|
|
47
47
|
var _a;
|
|
48
48
|
const constructor = this.constructor;
|
|
49
49
|
const filterQuery = this.__getValueParam(constructor.filterQueryKey);
|
|
50
|
-
const hasChanges = this.in({ idle: { snapshot: 'dirty' } });
|
|
51
50
|
const hasValue = !!this.form.value;
|
|
52
51
|
const hasData = !!this.data;
|
|
52
|
+
const hasChanges = this.in({ idle: { snapshot: 'dirty' } }) || this.in({ idle: { template: 'dirty' } });
|
|
53
53
|
return html `
|
|
54
54
|
<div class="flex gap-s">
|
|
55
55
|
${this.data
|
|
@@ -81,19 +81,6 @@ export class FilterAttributeForm extends Base {
|
|
|
81
81
|
${!hasValue || (!filterQuery && !hasData)
|
|
82
82
|
? ''
|
|
83
83
|
: html `
|
|
84
|
-
${hasData && hasChanges
|
|
85
|
-
? html `
|
|
86
|
-
<vaadin-button
|
|
87
|
-
aria-label=${this.t('action.reset')}
|
|
88
|
-
theme="contrast icon"
|
|
89
|
-
?disabled=${this.disabled}
|
|
90
|
-
@click=${() => this.undo()}
|
|
91
|
-
>
|
|
92
|
-
${svg `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 1em; height: 1em; transform: translateY(-0.1em) scale(1.25)"><path stroke-linecap="round" stroke-linejoin="round" d="M9 15 3 9m0 0 6-6M3 9h12a6 6 0 0 1 0 12h-3" /></svg>`}
|
|
93
|
-
</vaadin-button>
|
|
94
|
-
`
|
|
95
|
-
: ''}
|
|
96
|
-
|
|
97
84
|
<vaadin-button
|
|
98
85
|
theme=${hasData ? (hasChanges ? 'secondary' : 'error') : 'success'}
|
|
99
86
|
style=${ifDefined(hasData ? void 0 : '--lumo-button-size: auto')}
|
|
@@ -115,6 +102,7 @@ export class FilterAttributeForm extends Base {
|
|
|
115
102
|
options=${JSON.stringify(this.options)}
|
|
116
103
|
infer="filter-query"
|
|
117
104
|
value=${filterQuery}
|
|
105
|
+
disable-zoom
|
|
118
106
|
@change=${this.__handleFilterQueryChange}
|
|
119
107
|
>
|
|
120
108
|
</foxy-query-builder>
|
|
@@ -179,6 +167,7 @@ export class FilterAttributeForm extends Base {
|
|
|
179
167
|
const constructor = this.constructor;
|
|
180
168
|
const element = evt.currentTarget;
|
|
181
169
|
this.__setValueParam(constructor.filterQueryKey, (_a = element.value) !== null && _a !== void 0 ? _a : '');
|
|
170
|
+
this.requestUpdate();
|
|
182
171
|
}
|
|
183
172
|
}
|
|
184
173
|
FilterAttributeForm.attributeVisibility = 'restricted';
|
|
@@ -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,EA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,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,OAAC,IAAI,CAAC,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAC,EAAE,qBAAqB,CAAC,CAAC;YAC1E,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;SAC3E;QAAC,WAAM;YACN,SAAS;SACV;IACH,CAAC;IAEO,yBAAyB,CAAC,GAAgB;;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAyC,CAAC;QACnE,MAAM,OAAO,GAAG,GAAG,CAAC,aAA6B,CAAC;QAClD,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,cAAc,QAAE,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC;IACxE,CAAC;;AApLe,uCAAmB,GAAuB,YAAY,CAAC;AAEvD,kCAAc,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, svg } 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 hasChanges = this.in({ idle: { snapshot: 'dirty' } });\n const hasValue = !!this.form.value;\n const hasData = !!this.data;\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 ${!hasValue || (!filterQuery && !hasData)\n ? ''\n : html`\n ${hasData && hasChanges\n ? html`\n <vaadin-button\n aria-label=${this.t('action.reset')}\n theme=\"contrast icon\"\n ?disabled=${this.disabled}\n @click=${() => this.undo()}\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: 1em; height: 1em; transform: translateY(-0.1em) scale(1.25)\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 15 3 9m0 0 6-6M3 9h12a6 6 0 0 1 0 12h-3\" /></svg>`}\n </vaadin-button>\n `\n : ''}\n\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 @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 }\n}\n"]}
|
|
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,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,EAAE,CAAC,CAAC;SAC3E;QAAC,WAAM;YACN,SAAS;SACV;IACH,CAAC;IAEO,yBAAyB,CAAC,GAAgB;;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAyC,CAAC;QACnE,MAAM,OAAO,GAAG,GAAG,CAAC,aAA6B,CAAC;QAClD,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,cAAc,QAAE,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;;AA1Ke,uCAAmB,GAAuB,YAAY,CAAC;AAEvD,kCAAc,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 ${!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"]}
|
|
@@ -51,6 +51,8 @@ export declare class QueryBuilder extends Base {
|
|
|
51
51
|
static readonly Operator: typeof Operator;
|
|
52
52
|
/** Field type dictionary for use in autocomplete options. */
|
|
53
53
|
static readonly Type: typeof Type;
|
|
54
|
+
/** Returns zoom value for a filter query. */
|
|
55
|
+
static zoom(value: string): string;
|
|
54
56
|
static get properties(): PropertyDeclarations;
|
|
55
57
|
static get styles(): CSSResultArray;
|
|
56
58
|
/** Simple Mode will not show controls for these paths unless explicitly specified in options. */
|
|
@@ -12,6 +12,7 @@ import { ifDefined } from 'lit-html/directives/if-defined';
|
|
|
12
12
|
import { classMap } from "../../../utils/class-map.js";
|
|
13
13
|
import { styles } from "./styles.js";
|
|
14
14
|
import { parse } from "./utils/parse.js";
|
|
15
|
+
import { zoom } from "./utils/zoom.js";
|
|
15
16
|
const NS = 'query-builder';
|
|
16
17
|
const Base = ConfigurableMixin(ResponsiveMixin(ThemeableMixin(TranslatableMixin(InferrableMixin(LitElement), NS))));
|
|
17
18
|
/**
|
|
@@ -41,6 +42,10 @@ export class QueryBuilder extends Base {
|
|
|
41
42
|
this.value = null;
|
|
42
43
|
this.__isAdvancedMode = false;
|
|
43
44
|
}
|
|
45
|
+
/** Returns zoom value for a filter query. */
|
|
46
|
+
static zoom(value) {
|
|
47
|
+
return zoom(parse(value));
|
|
48
|
+
}
|
|
44
49
|
static get properties() {
|
|
45
50
|
return {
|
|
46
51
|
...super.properties,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aA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AK,CAAC,IAAI,EAAC,CACzD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAY,mBAAmB;;QAC7B,aAAO,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;YAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,WAAC,OAAA,KAAK,CAAC,IAAI,YAAK,MAAM,CAAC,KAAK,0CAAE,IAAI,CAAA,CAAA,EAAA,CAAC,CAAC;YAEtE,IAAI,KAAK,EAAE;gBACT,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC5B;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;aACrD;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,EAA6D,EAAE;IACpE,CAAC;;AAtLD,uEAAuE;AACvD,wBAAW,GAAG,KAAM,SAAQ,WAAiB;CAAG,CAAC;AAEjE,2DAA2D;AAC3C,qBAAQ,GAAG,QAAQ,CAAC;AAEpC,6DAA6D;AAC7C,iBAAI,GAAG,IAAI,CAAC","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Rule, Option } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { Operator, Type } from './types';\nimport { AdvancedGroup } from './components/AdvancedGroup';\nimport { SimpleGroup } from './components/SimpleGroup';\nimport { stringify } from './utils/stringify';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { styles } from './styles';\nimport { parse } from './utils/parse';\n\nconst NS = 'query-builder';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)))\n);\n\n/**\n * UI component for creating Foxy hAPI filters visually. Compatible with\n * Backend API, Customer API or any other API using the same format as described\n * in our [docs](https://api.foxy.io/docs/cheat-sheet).\n *\n * @element foxy-query-builder\n * @since 1.12.0\n */\nexport class QueryBuilder extends Base {\n /** QueryBuilder dispatches this event on itself when value changes. */\n static readonly ChangeEvent = class extends CustomEvent<void> {};\n\n /** Operator dictionary for use in autocomplete options. */\n static readonly Operator = Operator;\n\n /** Field type dictionary for use in autocomplete options. */\n static readonly Type = Type;\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n reservedPaths: { type: Array, attribute: 'reserved-paths' },\n disableZoom: { type: Boolean, attribute: 'disable-zoom' },\n disableOr: { type: Boolean, attribute: 'disable-or' },\n operators: { type: Array },\n docsHref: { attribute: 'docs-href' },\n options: { type: Array },\n value: {},\n __isAdvancedMode: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [super.styles, styles];\n }\n\n /** Simple Mode will not show controls for these paths unless explicitly specified in options. */\n reservedPaths: string[] = ['zoom', 'limit', 'offset', 'order', 'fields'];\n\n /** If true, doesn't add `zoom` query parameter for complex paths. */\n disableZoom = false;\n\n /** If true, hides the UI for the \"OR\" operator in queries in the Advanced Mode. */\n disableOr = false;\n\n /** List of operators available in the builder UI. */\n operators: Operator[] = Object.values(Operator);\n\n /** When provided, will display a documentation link in the Advanced Mode. */\n docsHref: string | null = null;\n\n /** Filter options in Simple Mode and autocomplete suggestions in Advanced Mode. */\n options: Option[] | null = null;\n\n /** Current value as hAPI filter string. */\n value: string | null = null;\n\n private __isAdvancedMode = false;\n\n render(): TemplateResult {\n const isSimpleModeSupported = this.__isSimpleModeSupported;\n const parsedValue = parse(this.value ?? '');\n const operators = this.operators ?? [];\n const options = this.options ?? [];\n const t = this.t.bind(this);\n\n const onChange = (newParsedValue: (Rule | Rule[])[]) => {\n this.value = stringify(newParsedValue, this.disableZoom);\n this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));\n };\n\n // This will trigger a re-render but is necessary to stay in the advanced mode once the support\n // for simple mode is available again.\n if (!isSimpleModeSupported && !this.__isAdvancedMode) this.__isAdvancedMode = true;\n\n return html`\n <div class=\"space-y-m\">\n <div\n class=\"grid grid-cols-2 gap-xs p-xs bg-contrast-5 rounded\"\n ?hidden=${!this.options?.length}\n >\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': !this.__isAdvancedMode && isSimpleModeSupported,\n 'hover-bg-contrast-5': this.__isAdvancedMode && isSimpleModeSupported,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n 'cursor-pointer': isSimpleModeSupported,\n 'text-disabled': !isSimpleModeSupported,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_simple${isSimpleModeSupported ? '' : '_unsupported'}\">\n </foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?disabled=${!isSimpleModeSupported}\n ?checked=${!this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = false)}\n />\n </label>\n\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium cursor-pointer transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': this.__isAdvancedMode,\n 'hover-bg-contrast-5': !this.__isAdvancedMode,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_advanced\"></foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?checked=${this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = true)}\n />\n </label>\n </div>\n\n ${this.__isAdvancedMode || !isSimpleModeSupported\n ? html`\n <p class=\"leading-s text-tertiary\" ?hidden=${this.docsHref === null}>\n <foxy-i18n infer=\"\" key=\"advanced_mode_notice\"></foxy-i18n>\n <a\n target=\"_blank\"\n class=\"cursor-pointer rounded-s text-secondary font-medium hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=${ifDefined(this.docsHref ?? void 0)}\n rel=\"nofollow noreferrer noopener\"\n >\n <foxy-i18n infer=\"\" key=\"api_reference_link\"></foxy-i18n>\n </a>\n </p>\n\n ${AdvancedGroup({\n disableOr: this.disableOr,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue,\n operators,\n onChange,\n options,\n t,\n })}\n `\n : this.__simpleModeOptions?.map(group => {\n return SimpleGroup({\n ...group,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue as Rule[],\n onChange,\n t,\n });\n })}\n </div>\n `;\n }\n\n private get __isSimpleModeSupported() {\n if (this.options === null) return false;\n if (this.options.length === 0) return false;\n\n const parsedValue = parse(this.value ?? '');\n if (parsedValue.length === 0) return true;\n\n return parsedValue.every(entry => {\n if (Array.isArray(entry)) return false;\n if (entry.operator === Operator.In) return false;\n if (entry.operator === Operator.IsDefined && entry.value !== 'true') return false;\n return !!(\n this.reservedPaths.includes(entry.path) ||\n this.options?.find(option => option.path === entry.path)\n );\n });\n }\n\n private get __simpleModeOptions() {\n return this.options?.reduce((result, option) => {\n const group = result.find(group => group.name === option.group?.name);\n\n if (group) {\n group.options.push(option);\n } else {\n result.push({ ...option.group, options: [option] });\n }\n\n return result;\n }, [] as { name?: string; layout?: string; options: Option[] }[]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7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C,IAAI,CAAC,WACvC,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAC,CACzD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAY,mBAAmB;;QAC7B,aAAO,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;YAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,WAAC,OAAA,KAAK,CAAC,IAAI,YAAK,MAAM,CAAC,KAAK,0CAAE,IAAI,CAAA,CAAA,EAAA,CAAC,CAAC;YAEtE,IAAI,KAAK,EAAE;gBACT,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC5B;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;aACrD;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,EAA6D,EAAE;IACpE,CAAC;;AA3LD,uEAAuE;AACvD,wBAAW,GAAG,KAAM,SAAQ,WAAiB;CAAG,CAAC;AAEjE,2DAA2D;AAC3C,qBAAQ,GAAG,QAAQ,CAAC;AAEpC,6DAA6D;AAC7C,iBAAI,GAAG,IAAI,CAAC","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Rule, Option } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { Operator, Type } from './types';\nimport { AdvancedGroup } from './components/AdvancedGroup';\nimport { SimpleGroup } from './components/SimpleGroup';\nimport { stringify } from './utils/stringify';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { styles } from './styles';\nimport { parse } from './utils/parse';\nimport { zoom } from './utils/zoom';\n\nconst NS = 'query-builder';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)))\n);\n\n/**\n * UI component for creating Foxy hAPI filters visually. Compatible with\n * Backend API, Customer API or any other API using the same format as described\n * in our [docs](https://api.foxy.io/docs/cheat-sheet).\n *\n * @element foxy-query-builder\n * @since 1.12.0\n */\nexport class QueryBuilder extends Base {\n /** QueryBuilder dispatches this event on itself when value changes. */\n static readonly ChangeEvent = class extends CustomEvent<void> {};\n\n /** Operator dictionary for use in autocomplete options. */\n static readonly Operator = Operator;\n\n /** Field type dictionary for use in autocomplete options. */\n static readonly Type = Type;\n\n /** Returns zoom value for a filter query. */\n static zoom(value: string): string {\n return zoom(parse(value));\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n reservedPaths: { type: Array, attribute: 'reserved-paths' },\n disableZoom: { type: Boolean, attribute: 'disable-zoom' },\n disableOr: { type: Boolean, attribute: 'disable-or' },\n operators: { type: Array },\n docsHref: { attribute: 'docs-href' },\n options: { type: Array },\n value: {},\n __isAdvancedMode: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [super.styles, styles];\n }\n\n /** Simple Mode will not show controls for these paths unless explicitly specified in options. */\n reservedPaths: string[] = ['zoom', 'limit', 'offset', 'order', 'fields'];\n\n /** If true, doesn't add `zoom` query parameter for complex paths. */\n disableZoom = false;\n\n /** If true, hides the UI for the \"OR\" operator in queries in the Advanced Mode. */\n disableOr = false;\n\n /** List of operators available in the builder UI. */\n operators: Operator[] = Object.values(Operator);\n\n /** When provided, will display a documentation link in the Advanced Mode. */\n docsHref: string | null = null;\n\n /** Filter options in Simple Mode and autocomplete suggestions in Advanced Mode. */\n options: Option[] | null = null;\n\n /** Current value as hAPI filter string. */\n value: string | null = null;\n\n private __isAdvancedMode = false;\n\n render(): TemplateResult {\n const isSimpleModeSupported = this.__isSimpleModeSupported;\n const parsedValue = parse(this.value ?? '');\n const operators = this.operators ?? [];\n const options = this.options ?? [];\n const t = this.t.bind(this);\n\n const onChange = (newParsedValue: (Rule | Rule[])[]) => {\n this.value = stringify(newParsedValue, this.disableZoom);\n this.dispatchEvent(new QueryBuilder.ChangeEvent('change'));\n };\n\n // This will trigger a re-render but is necessary to stay in the advanced mode once the support\n // for simple mode is available again.\n if (!isSimpleModeSupported && !this.__isAdvancedMode) this.__isAdvancedMode = true;\n\n return html`\n <div class=\"space-y-m\">\n <div\n class=\"grid grid-cols-2 gap-xs p-xs bg-contrast-5 rounded\"\n ?hidden=${!this.options?.length}\n >\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': !this.__isAdvancedMode && isSimpleModeSupported,\n 'hover-bg-contrast-5': this.__isAdvancedMode && isSimpleModeSupported,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n 'cursor-pointer': isSimpleModeSupported,\n 'text-disabled': !isSimpleModeSupported,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_simple${isSimpleModeSupported ? '' : '_unsupported'}\">\n </foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?disabled=${!isSimpleModeSupported}\n ?checked=${!this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = false)}\n />\n </label>\n\n <label\n class=${classMap({\n 'p-xs rounded-s text-center font-medium cursor-pointer transition-colors': true,\n 'bg-base ring-1 ring-contrast-5': this.__isAdvancedMode,\n 'hover-bg-contrast-5': !this.__isAdvancedMode,\n 'focus-within-ring-2 focus-within-ring-inset focus-within-ring-primary-50': true,\n })}\n >\n <foxy-i18n infer=\"\" key=\"mode_advanced\"></foxy-i18n>\n <input\n class=\"sr-only\"\n type=\"radio\"\n name=\"mode\"\n ?checked=${this.__isAdvancedMode}\n @change=${() => (this.__isAdvancedMode = true)}\n />\n </label>\n </div>\n\n ${this.__isAdvancedMode || !isSimpleModeSupported\n ? html`\n <p class=\"leading-s text-tertiary\" ?hidden=${this.docsHref === null}>\n <foxy-i18n infer=\"\" key=\"advanced_mode_notice\"></foxy-i18n>\n <a\n target=\"_blank\"\n class=\"cursor-pointer rounded-s text-secondary font-medium hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=${ifDefined(this.docsHref ?? void 0)}\n rel=\"nofollow noreferrer noopener\"\n >\n <foxy-i18n infer=\"\" key=\"api_reference_link\"></foxy-i18n>\n </a>\n </p>\n\n ${AdvancedGroup({\n disableOr: this.disableOr,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue,\n operators,\n onChange,\n options,\n t,\n })}\n `\n : this.__simpleModeOptions?.map(group => {\n return SimpleGroup({\n ...group,\n disabled: this.disabled,\n readonly: this.readonly,\n rules: parsedValue as Rule[],\n onChange,\n t,\n });\n })}\n </div>\n `;\n }\n\n private get __isSimpleModeSupported() {\n if (this.options === null) return false;\n if (this.options.length === 0) return false;\n\n const parsedValue = parse(this.value ?? '');\n if (parsedValue.length === 0) return true;\n\n return parsedValue.every(entry => {\n if (Array.isArray(entry)) return false;\n if (entry.operator === Operator.In) return false;\n if (entry.operator === Operator.IsDefined && entry.value !== 'true') return false;\n return !!(\n this.reservedPaths.includes(entry.path) ||\n this.options?.find(option => option.path === entry.path)\n );\n });\n }\n\n private get __simpleModeOptions() {\n return this.options?.reduce((result, option) => {\n const group = result.find(group => group.name === option.group?.name);\n\n if (group) {\n group.options.push(option);\n } else {\n result.push({ ...option.group, options: [option] });\n }\n\n return result;\n }, [] as { name?: string; layout?: string; options: Option[] }[]);\n }\n}\n"]}
|
|
@@ -16,9 +16,10 @@ export function AdvancedInput(params) {
|
|
|
16
16
|
})}
|
|
17
17
|
.value=${params.value}
|
|
18
18
|
?disabled=${params.disabled || params.readonly}
|
|
19
|
+
@keydown=${(evt) => evt.key === '|' && evt.preventDefault()}
|
|
19
20
|
@input=${(evt) => {
|
|
20
21
|
const input = evt.currentTarget;
|
|
21
|
-
params.onChange(input.value);
|
|
22
|
+
params.onChange(input.value.replace(/\|/gi, ''));
|
|
22
23
|
}}
|
|
23
24
|
/>
|
|
24
25
|
</div>
|