@foxy.io/elements 1.22.0-beta.4 → 1.22.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 +2 -2
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.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-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-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-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.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- 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 -0
- package/dist/cdn/foxy-downloadable-form.js +505 -0
- 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-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-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 +2 -2
- 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-pagination.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 +2 -2
- package/dist/cdn/foxy-reports-table.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-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 +7 -7
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-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-014f1513.js +1 -0
- package/dist/cdn/{shared-e6d3d6f5.js → shared-01ad847f.js} +1 -1
- package/dist/cdn/{shared-698c9002.js → shared-03858aee.js} +1 -1
- package/dist/cdn/{shared-a306168b.js → shared-055ca9db.js} +1 -1
- package/dist/cdn/{shared-a19ce620.js → shared-06c64816.js} +1 -1
- package/dist/cdn/{shared-685ca959.js → shared-15c94a90.js} +1 -1
- package/dist/cdn/{shared-f628a723.js → shared-178f7222.js} +1 -1
- package/dist/cdn/{shared-aa5785d9.js → shared-1a6fb0f3.js} +1 -1
- package/dist/cdn/{shared-1bd28b9c.js → shared-1a9496d4.js} +1 -1
- package/dist/cdn/{shared-b590adb2.js → shared-1f4b9c6b.js} +1 -1
- package/dist/cdn/{shared-5c5d13bd.js → shared-24a762c1.js} +1 -1
- package/dist/cdn/{shared-f42077ab.js → shared-2c6ea96d.js} +1 -1
- package/dist/cdn/{shared-50c6daa1.js → shared-38ed7905.js} +1 -1
- package/dist/cdn/{shared-87405fc7.js → shared-3b8b5eda.js} +3 -3
- package/dist/cdn/{shared-26390fea.js → shared-3b9b9427.js} +1 -1
- package/dist/cdn/{shared-67790b63.js → shared-4055f94a.js} +1 -1
- package/dist/cdn/{shared-cf49ce0c.js → shared-473aaeff.js} +1 -1
- package/dist/cdn/{shared-fad30ff5.js → shared-499c6db5.js} +1 -1
- package/dist/cdn/{shared-5a09ad7e.js → shared-49b65f1e.js} +1 -1
- package/dist/cdn/{shared-ccfb87fb.js → shared-4ac2a677.js} +1 -1
- package/dist/cdn/{shared-9e18688d.js → shared-533c3914.js} +3 -3
- package/dist/cdn/{shared-83a12835.js → shared-5425e3d3.js} +3 -3
- package/dist/cdn/{shared-468eb208.js → shared-57c6cfd1.js} +2 -2
- package/dist/cdn/{shared-493b8bc1.js → shared-590d8dae.js} +1 -1
- package/dist/cdn/{shared-7163796c.js → shared-5fbda766.js} +1 -1
- package/dist/cdn/{shared-445dda5a.js → shared-668947de.js} +1 -1
- package/dist/cdn/{shared-ffb6c2d3.js → shared-6f4005e5.js} +1 -1
- package/dist/cdn/{shared-308e67f3.js → shared-72817759.js} +1 -1
- package/dist/cdn/{shared-a6deb2a4.js → shared-7e9c240a.js} +1 -1
- package/dist/cdn/{shared-5cf7e764.js → shared-809df8d2.js} +1 -1
- package/dist/cdn/{shared-53af541e.js → shared-82f873bd.js} +1 -1
- package/dist/cdn/{shared-6860c8d1.js → shared-8b0c77a7.js} +1 -1
- package/dist/cdn/{shared-d7b778b7.js → shared-9271a609.js} +1 -1
- package/dist/cdn/{shared-00d2cbe9.js → shared-950875f2.js} +1 -1
- package/dist/cdn/{shared-f8bcab5c.js → shared-963c4a87.js} +1 -1
- package/dist/cdn/{shared-5a445ebd.js → shared-9725c399.js} +1 -1
- package/dist/cdn/{shared-dfe7652e.js → shared-9e04b9c3.js} +1 -1
- package/dist/cdn/{shared-b2d6bbad.js → shared-9e8bff76.js} +1 -1
- package/dist/cdn/shared-b137f17a.js +1 -0
- package/dist/cdn/{shared-5897f089.js → shared-b23ccea9.js} +1 -1
- package/dist/cdn/{shared-2b1c3f7a.js → shared-b2474263.js} +1 -1
- package/dist/cdn/{shared-c5fe5675.js → shared-bc36bc72.js} +1 -1
- package/dist/cdn/{shared-643791c8.js → shared-bcc4cf7f.js} +1 -1
- package/dist/cdn/{shared-2bae351a.js → shared-be591e92.js} +1 -1
- package/dist/cdn/shared-c0816371.js +1 -0
- package/dist/cdn/{shared-5ec39f11.js → shared-c0ec65fa.js} +1 -1
- package/dist/cdn/{shared-2a9718a9.js → shared-c1dd32b6.js} +1 -1
- package/dist/cdn/{shared-01dd0fd6.js → shared-c27aaa05.js} +1 -1
- package/dist/cdn/{shared-3c20c295.js → shared-c2cfc26d.js} +1 -1
- package/dist/cdn/{shared-394981eb.js → shared-c2ec3291.js} +1 -1
- package/dist/cdn/{shared-46c6d1e6.js → shared-c3fa6df1.js} +1 -1
- package/dist/cdn/{shared-10f92654.js → shared-c5106979.js} +1 -1
- package/dist/cdn/shared-cb34d19f.js +1 -0
- package/dist/cdn/{shared-aa678ec4.js → shared-e2f4962c.js} +1 -1
- package/dist/cdn/{shared-14f0cf8e.js → shared-e9c81269.js} +1 -1
- package/dist/cdn/{shared-3a329baf.js → shared-f8e3be56.js} +1 -1
- package/dist/cdn/{shared-8db9452f.js → shared-fcce5337.js} +1 -1
- package/dist/cdn/translations/downloadable-card/en.json +7 -0
- package/dist/cdn/translations/downloadable-form/en.json +65 -0
- package/dist/elements/private/Choice/Choice.d.ts +3 -2
- package/dist/elements/private/Choice/Choice.js +5 -0
- package/dist/elements/private/Choice/Choice.js.map +1 -1
- package/dist/elements/private/Choice/machine.js +33 -0
- package/dist/elements/private/Choice/machine.js.map +1 -1
- package/dist/elements/public/CouponForm/CouponForm.d.ts +1 -5
- package/dist/elements/public/CouponForm/CouponForm.js +27 -289
- package/dist/elements/public/CouponForm/CouponForm.js.map +1 -1
- package/dist/elements/public/CouponForm/index.d.ts +1 -0
- package/dist/elements/public/CouponForm/index.js +1 -0
- package/dist/elements/public/CouponForm/index.js.map +1 -1
- package/dist/elements/public/CouponForm/types.d.ts +0 -24
- package/dist/elements/public/CouponForm/types.js.map +1 -1
- package/dist/elements/public/DiscountBuilder/DiscountBuilder.js +8 -4
- package/dist/elements/public/DiscountBuilder/DiscountBuilder.js.map +1 -1
- package/dist/elements/public/Donation/Donation.js +3 -3
- package/dist/elements/public/Donation/Donation.js.map +1 -1
- package/dist/elements/public/DownloadableCard/DownloadableCard.d.ts +21 -0
- package/dist/elements/public/DownloadableCard/DownloadableCard.js +84 -0
- package/dist/elements/public/DownloadableCard/DownloadableCard.js.map +1 -0
- package/dist/elements/public/DownloadableCard/index.d.ts +6 -0
- package/dist/elements/public/DownloadableCard/index.js +8 -0
- package/dist/elements/public/DownloadableCard/index.js.map +1 -0
- package/dist/elements/public/DownloadableCard/types.d.ts +8 -0
- package/dist/elements/public/DownloadableCard/types.js +2 -0
- package/dist/elements/public/DownloadableCard/types.js.map +1 -0
- package/dist/elements/public/DownloadableForm/DownloadableForm.d.ts +54 -0
- package/dist/elements/public/DownloadableForm/DownloadableForm.js +149 -0
- package/dist/elements/public/DownloadableForm/DownloadableForm.js.map +1 -0
- package/dist/elements/public/DownloadableForm/index.d.ts +8 -0
- package/dist/elements/public/DownloadableForm/index.js +10 -0
- package/dist/elements/public/DownloadableForm/index.js.map +1 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/InternalDownloadableFormUploadControl.d.ts +11 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/InternalDownloadableFormUploadControl.js +124 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/InternalDownloadableFormUploadControl.js.map +1 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/index.d.ts +6 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/index.js +8 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/index.js.map +1 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/style.d.ts +1 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/style.js +42 -0
- package/dist/elements/public/DownloadableForm/internal/InternalDownloadableFormUploadControl/style.js.map +1 -0
- package/dist/elements/public/DownloadableForm/types.d.ts +11 -0
- package/dist/elements/public/DownloadableForm/types.js +2 -0
- package/dist/elements/public/DownloadableForm/types.js.map +1 -0
- package/dist/elements/public/FormDialog/FormDialog.d.ts +4 -0
- package/dist/elements/public/FormDialog/FormDialog.js +18 -7
- package/dist/elements/public/FormDialog/FormDialog.js.map +1 -1
- package/dist/elements/public/I18n/format/discount.js +1 -1
- package/dist/elements/public/I18n/format/discount.js.map +1 -1
- package/dist/elements/public/I18n/format/percent.js +4 -3
- package/dist/elements/public/I18n/format/percent.js.map +1 -1
- package/dist/elements/public/index.d.ts +2 -0
- package/dist/elements/public/index.defined.d.ts +2 -0
- package/dist/elements/public/index.defined.js +2 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +2 -0
- package/dist/elements/public/index.js.map +1 -1
- package/dist/mixins/themeable.js +4 -0
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-095ad002.js +0 -1
- package/dist/cdn/shared-349bbd7e.js +0 -1
- package/dist/cdn/shared-7f47c677.js +0 -1
- package/dist/cdn/shared-9eeb2bec.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscountBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/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;YACnB,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;YACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;SAC/D,CAAC;;;;YAIA,IAAI,CAAC,cAAc,CAAC;YACpB,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;YACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;SACvE,CAAC;;;UAGF,MAAM,CAAC,IAAI;YACX,CAAC,CAAC,IAAI,CAAA;;;6BAGa,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;wBACrB,QAAQ,CAAC;gBACf,uEAAuE,EAAE,IAAI;gBAC7E,oEAAoE,EAClE,CAAC,IAAI,CAAC,QAAQ;gBAChB,8BAA8B,EAAE,IAAI,CAAC,QAAQ;aAC9C,CAAC;4BACU,IAAI,CAAC,QAAQ;0BACf,IAAI,CAAC,QAAQ;yBACd,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE;;;;aAInC;YACH,CAAC,CAAC,EAAE;;KAET,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n DiscountType,\n ParsedValue,\n RulesTierParams,\n RulesTierSelectParams,\n RulesTierSwitchParams,\n RulesTierFieldParams,\n} from './types';\n\nimport { html, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { operatorGreaterThanOrEqual } from '../QueryBuilder/icons/operatorGreaterThanOrEqual';\n\nconst NS = 'discount-builder';\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)));\n\n/**\n * Visual builder for discount URL parameters in coupons and more.\n * Learn more about discounts here: [Foxy Wiki](https://wiki.foxycart.com/v/2.0/coupons_and_discounts).\n *\n * @element foxy-discount-builder\n * @since 1.17.0\n */\nexport class DiscountBuilder extends Base {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n value: { type: String },\n };\n }\n\n /**\n * Discount URL parameter.\n *\n * Note that if you set this value, it **must be encoded** for the\n * builder to work correctly. You can use either `encodeURIComponent` or `URLSearchParams` like so:\n *\n * ```ts\n * discountBuilder.value = new URLSearchParams([\n * ['discount_amount_percentage', 'Test{allunits|1-2|3-4}']\n * ]).toString();\n * ```\n */\n value: string | null = null;\n\n get parsedValue(): ParsedValue {\n let details = '';\n let name = '';\n let type: DiscountType = 'quantity_amount';\n\n try {\n const [[key, value]] = Array.from(new URLSearchParams(this.value ?? '').entries());\n\n const parsedType = key.substring('discount_'.length);\n const allowedTypes = [\n 'price_amount',\n 'price_percentage',\n 'quantity_amount',\n 'quantity_percentage',\n ];\n\n if (allowedTypes.includes(parsedType)) {\n type = parsedType as DiscountType;\n }\n\n const detailsStart = value.indexOf('{');\n const detailsEnd = value.lastIndexOf('}');\n\n if (detailsStart !== -1 && detailsEnd !== -1) {\n details = value.substring(detailsStart + 1, detailsEnd);\n name = value.substring(0, detailsStart);\n }\n } catch {\n // ignore and use the defaults\n }\n\n if (name.length === 0) name = 'Discount';\n\n return { type, name, details };\n }\n\n set parsedValue({ name, type, details }: ParsedValue) {\n this.value = new URLSearchParams([[`discount_${type}`, `${name}{${details}}`]]).toString();\n }\n\n render(): TemplateResult {\n const details = this.parsedValue.details;\n const tiers = details.split('|').filter(v => !!v.trim());\n const method = (/[-+]/.test(tiers[0]) ? null : tiers.shift()) ?? 'single';\n const renderedTiers = method === 'repeat' ? [tiers[0]] : [...tiers, undefined];\n\n const type = this.parsedValue.type;\n const [source, units] = type.split('_');\n\n return html`\n <div class=\"space-y-s\">\n ${repeat(renderedTiers, (tier, tierIndex) => {\n const onChange = (changedParams: Partial<RulesTierParams>) => {\n const newMethod = changedParams.method ?? method;\n const newSource = changedParams.source ?? source;\n const newUnits = changedParams.units ?? units;\n const newTier = changedParams.tier;\n const newTiers = [...tiers];\n\n if (newTier) {\n const newTierIndex = tier ? tierIndex : newTiers.length;\n const oldTiersCount = tier ? 1 : 0;\n newTiers.splice(newTierIndex, oldTiersCount, newTier);\n }\n\n this.parsedValue = {\n ...this.parsedValue,\n type: `${newSource}_${newUnits}` as DiscountType,\n details: `${newMethod}|${newTiers.join('|')}`,\n };\n\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n const onDelete = () => {\n const newTiers = tiers.filter((_, i) => i !== tierIndex);\n const newDetails = `${method}|${newTiers.join('|')}`;\n\n this.parsedValue = { ...this.parsedValue, details: newDetails };\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n return this.__renderTier({ source, method, units, tier, onChange, onDelete });\n })}\n </div>\n `;\n }\n\n private __renderSelect({ label, value, options, onChange }: RulesTierSelectParams) {\n const isInteractive = !this.disabled && !this.readonly;\n\n return html`\n <label\n class=${classMap({\n 'h-xs whitespace-nowrap block ring-primary-50 rounded pl-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n >\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n\n <span class=\"relative leading-none font-medium flex items-center h-full\">\n <span class=\"truncate\">${this.t(options[value])}</span>\n <iron-icon class=\"icon-inline text-xl ml-xs\" icon=\"icons:expand-more\"></iron-icon>\n\n <select\n data-testclass=\"interactive editable\"\n class=\"opacity-0 absolute inset-0 focus-outline-none\"\n ?disabled=${!isInteractive}\n @change=${(evt: Event) => {\n const select = evt.currentTarget as HTMLSelectElement;\n onChange(select.options[select.selectedIndex].value);\n }}\n >\n ${Object.entries(options).map(([optionValue, optionKey]) => {\n return html`\n <option value=${optionValue} ?selected=${optionValue === value}>\n ${this.t(optionKey)}\n </option>\n `;\n })}\n </select>\n </span>\n </label>\n `;\n }\n\n private __renderSwitch({ value, options, onChange }: RulesTierSwitchParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const name = `switch-${Math.floor(Math.random() * Math.pow(10, 10))}`;\n const dotStyle = 'width: 0.4rem; height: 0.4rem';\n\n return html`\n <div\n class=${classMap({\n 'h-xs px-xs space-x-xs flex items-center rounded-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'ring-primary-50 cursor-pointer bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n @click=${(evt: Event) => {\n if (!isInteractive) return;\n\n const target = evt.currentTarget as HTMLDivElement;\n const firstInput = target.querySelector('input') as HTMLInputElement;\n\n firstInput.focus();\n onChange(value === 0 ? 1 : 0);\n }}\n >\n <div class=\"leading-none font-medium px-xs pointer-events-none\">\n ${options.map((option, optionIndex) => {\n return html`\n <label>\n <foxy-i18n\n class=${classMap({ 'sr-only': optionIndex !== value })}\n infer=\"\"\n key=${option}\n >\n </foxy-i18n>\n\n <input\n data-testclass=\"interactive editable\"\n class=\"sr-only\"\n value=${option}\n name=${name}\n type=\"radio\"\n ?disabled=${!isInteractive}\n ?checked=${optionIndex === value}\n @change=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n if (input.checked) onChange(optionIndex);\n }}\n />\n </label>\n `;\n })}\n </div>\n\n <div class=\"flex justify-evenly h-full ${value ? 'flex-col-reverse' : 'flex-col'}\">\n <div style=${dotStyle} class=\"bg-current rounded-full\"></div>\n <div style=${dotStyle} class=\"border border-current rounded-full\"></div>\n </div>\n </div>\n `;\n }\n\n private __renderField({ value, label, onChange }: RulesTierFieldParams) {\n const isInteractive = !this.disabled && !this.readonly;\n\n return html`\n <label>\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n <input\n data-testclass=\"interactive editable\"\n class=${classMap({\n 'transition-colors border p-xs h-xs font-medium text-m rounded-s w-xl': true,\n 'ring-primary-50 text-body bg-contrast-10': isInteractive,\n 'hover-bg-contrast-20': isInteractive,\n 'focus-outline-none focus-ring-2': isInteractive,\n 'text-disabled bg-contrast-5': this.disabled,\n 'text-secondary': this.readonly && !this.disabled,\n 'border-transparent border-solid': !this.readonly,\n 'border-dashed border-contrast-30': this.readonly,\n })}\n type=\"number\"\n min=\"0\"\n ?disabled=${!isInteractive}\n .value=${value}\n @input=${(evt: InputEvent) => {\n const input = evt.currentTarget as HTMLInputElement;\n onChange(input.value);\n }}\n />\n </label>\n `;\n }\n\n private __renderTier(params: RulesTierParams) {\n const tier = params.tier ?? '0-0';\n const sign = tier.includes('+') ? '+' : '-';\n const [from, adjustment] = tier.split(/[-+]/).map(v => parseFloat(v));\n\n return html`\n <div\n data-testclass=\"rules:tier\"\n aria-label=${this.t('tier')}\n class=${classMap({\n 'flex items-start justify-between rounded': true,\n 'border border-contrast-10': true,\n 'border-dashed': !params.tier,\n })}\n >\n <div\n class=${classMap({\n 'transition-colors flex flex-wrap items-center gap-s p-s': true,\n 'text-tertiary': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n >\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_if\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['total', 'quantity'],\n value: params.source === 'price' ? 0 : 1,\n onChange: i => params.onChange({ source: i ? 'quantity' : 'price' }),\n })}\n\n <div class=\"h-s w-s\">${operatorGreaterThanOrEqual}</div>\n\n ${this.__renderField({\n label: 'from',\n value: String(from),\n onChange: v => params.onChange({ tier: `${v}${sign}${adjustment}` }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_then\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['reduce', 'increase'],\n value: sign === '-' ? 0 : 1,\n onChange: i => params.onChange({ tier: `${from}${i ? '+' : '-'}${adjustment}` }),\n })}\n\n <!---->\n\n ${this.__renderSelect({\n options: {\n incremental: 'tier_incremental',\n allunits: 'tier_allunits',\n repeat: 'tier_repeat',\n single: 'tier_single',\n },\n value: params.method,\n label: 'target',\n onChange: v => params.onChange({ method: v }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_by\"></foxy-i18n>\n\n ${this.__renderField({\n label: 'adjustment',\n value: String(adjustment),\n onChange: v => params.onChange({ tier: `${from}${sign}${v}` }),\n })}\n\n <!---->\n\n ${this.__renderSwitch({\n value: params.units === 'percentage' ? 0 : 1,\n options: ['%', '¤'],\n onChange: i => params.onChange({ units: i ? 'amount' : 'percentage' }),\n })}\n </div>\n\n ${params.tier\n ? html`\n <button\n data-testclass=\"interactive\"\n aria-label=${this.t('delete')}\n class=${classMap({\n 'w-s h-s m-s flex-shrink-0 rounded-s transition-colors ring-primary-50': true,\n 'text-tertiary hover-text-secondary focus-outline-none focus-ring-2':\n !this.disabled,\n 'text-disabled cursor-default': this.disabled,\n })}\n ?disabled=${this.disabled}\n ?hidden=${this.readonly}\n @click=${() => params.onDelete()}\n >\n <iron-icon icon=\"lumo:cross\"></iron-icon>\n </button>\n `\n : ''}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DiscountBuilder.js","sourceRoot":"","sources":["../../../../src/elements/public/DiscountBuilder/DiscountBuilder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAwC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MA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EAAE,CAAC;SAC9C,CAAC;;;;YAIA,IAAI,CAAC,aAAa,CAAC;YACnB,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;YACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;SAC/D,CAAC;;;;YAIA,IAAI,CAAC,cAAc,CAAC;YACpB,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;YACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;SACvE,CAAC;;;UAGF,MAAM,CAAC,IAAI;YACX,CAAC,CAAC,IAAI,CAAA;;;6BAGa,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;wBACrB,QAAQ,CAAC;gBACf,uEAAuE,EAAE,IAAI;gBAC7E,oEAAoE,EAClE,CAAC,IAAI,CAAC,QAAQ;gBAChB,8BAA8B,EAAE,IAAI,CAAC,QAAQ;aAC9C,CAAC;4BACU,IAAI,CAAC,QAAQ;0BACf,IAAI,CAAC,QAAQ;yBACd,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE;;;;aAInC;YACH,CAAC,CAAC,EAAE;;KAET,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n DiscountType,\n ParsedValue,\n RulesTierParams,\n RulesTierSelectParams,\n RulesTierSwitchParams,\n RulesTierFieldParams,\n} from './types';\n\nimport { html, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport { repeat } from 'lit-html/directives/repeat';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { operatorGreaterThanOrEqual } from '../QueryBuilder/icons/operatorGreaterThanOrEqual';\n\nconst NS = 'discount-builder';\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(InferrableMixin(LitElement), NS)));\n\n/**\n * Visual builder for discount URL parameters in coupons and more.\n * Learn more about discounts here: [Foxy Wiki](https://wiki.foxycart.com/v/2.0/coupons_and_discounts).\n *\n * @element foxy-discount-builder\n * @since 1.17.0\n */\nexport class DiscountBuilder extends Base {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n value: { type: String },\n };\n }\n\n /**\n * Discount URL parameter.\n *\n * Note that if you set this value, it **must be encoded** for the\n * builder to work correctly. You can use either `encodeURIComponent` or `URLSearchParams` like so:\n *\n * ```ts\n * discountBuilder.value = new URLSearchParams([\n * ['discount_amount_percentage', 'Test{allunits|1-2|3-4}']\n * ]).toString();\n * ```\n */\n value: string | null = null;\n\n get parsedValue(): ParsedValue {\n let details = '';\n let name = '';\n let type: DiscountType = 'quantity_amount';\n\n try {\n const [[key, value]] = Array.from(new URLSearchParams(this.value ?? '').entries());\n\n const parsedType = key.substring('discount_'.length);\n const allowedTypes = [\n 'price_amount',\n 'price_percentage',\n 'quantity_amount',\n 'quantity_percentage',\n ];\n\n if (allowedTypes.includes(parsedType)) {\n type = parsedType as DiscountType;\n }\n\n const detailsStart = value.indexOf('{');\n const detailsEnd = value.lastIndexOf('}');\n\n if (detailsStart !== -1 && detailsEnd !== -1) {\n details = value.substring(detailsStart + 1, detailsEnd);\n name = value.substring(0, detailsStart);\n }\n } catch {\n // ignore and use the defaults\n }\n\n if (name.length === 0) name = 'Discount';\n\n return { type, name, details };\n }\n\n set parsedValue({ name, type, details }: ParsedValue) {\n this.value = new URLSearchParams([[`discount_${type}`, `${name}{${details}}`]]).toString();\n }\n\n render(): TemplateResult {\n const details = this.parsedValue.details;\n const tiers = details.split('|').filter(v => !!v.trim());\n const method = (/[-+]/.test(tiers[0]) ? null : tiers.shift()) ?? 'single';\n const renderedTiers = method === 'repeat' ? [tiers[0]] : [...tiers, undefined];\n\n const type = this.parsedValue.type;\n const [source, units] = type.split('_');\n\n return html`\n <div class=\"space-y-s\">\n ${repeat(renderedTiers, (tier, tierIndex) => {\n const onChange = (changedParams: Partial<RulesTierParams>) => {\n const newMethod = changedParams.method ?? method;\n const newSource = changedParams.source ?? source;\n const newUnits = changedParams.units ?? units;\n const newTier = changedParams.tier;\n const newTiers = [...tiers];\n\n if (newTier) {\n const newTierIndex = tier ? tierIndex : newTiers.length;\n const oldTiersCount = tier ? 1 : 0;\n newTiers.splice(newTierIndex, oldTiersCount, newTier);\n }\n\n this.parsedValue = {\n ...this.parsedValue,\n type: `${newSource}_${newUnits}` as DiscountType,\n details: `${newMethod}|${newTiers.join('|')}`,\n };\n\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n const onDelete = () => {\n const newTiers = tiers.filter((_, i) => i !== tierIndex);\n const newDetails = `${method}|${newTiers.join('|')}`;\n\n this.parsedValue = { ...this.parsedValue, details: newDetails };\n this.dispatchEvent(new CustomEvent('change'));\n };\n\n return this.__renderTier({ source, method, units, tier, onChange, onDelete });\n })}\n </div>\n `;\n }\n\n private __renderSelect({ label, value, options, onChange }: RulesTierSelectParams) {\n const isInteractive = !this.disabled && !this.readonly;\n\n return html`\n <label\n class=${classMap({\n 'h-xs whitespace-nowrap block ring-primary-50 rounded-s pl-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n >\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n\n <span class=\"relative leading-none font-medium flex items-center h-full\">\n <span class=\"truncate\">${this.t(options[value])}</span>\n <iron-icon class=\"icon-inline text-xl ml-xs\" icon=\"icons:expand-more\"></iron-icon>\n\n <select\n data-testclass=\"interactive editable\"\n class=\"opacity-0 absolute inset-0 w-full focus-outline-none\"\n ?disabled=${!isInteractive}\n @change=${(evt: Event) => {\n const select = evt.currentTarget as HTMLSelectElement;\n onChange(select.options[select.selectedIndex].value);\n }}\n >\n ${Object.entries(options).map(([optionValue, optionKey]) => {\n return html`\n <option value=${optionValue} ?selected=${optionValue === value}>\n ${this.t(optionKey)}\n </option>\n `;\n })}\n </select>\n </span>\n </label>\n `;\n }\n\n private __renderSwitch({ value, options, onChange }: RulesTierSwitchParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const name = `switch-${Math.floor(Math.random() * Math.pow(10, 10))}`;\n const dotStyle = 'width: 0.4rem; height: 0.4rem';\n\n return html`\n <div\n class=${classMap({\n 'h-xs px-xs space-x-xs flex items-center rounded-s transition-colors': true,\n 'hover-bg-primary hover-text-primary-contrast focus-within-ring-2': isInteractive,\n 'ring-primary-50 cursor-pointer bg-primary-10 text-primary': isInteractive,\n 'bg-contrast-5 text-disabled': this.disabled,\n 'bg-contrast-5 text-secondary': this.readonly && !this.disabled,\n })}\n @click=${(evt: Event) => {\n if (!isInteractive) return;\n\n const target = evt.currentTarget as HTMLDivElement;\n const firstInput = target.querySelector('input') as HTMLInputElement;\n\n firstInput.focus();\n onChange(value === 0 ? 1 : 0);\n }}\n >\n <div class=\"leading-none font-medium px-xs pointer-events-none\">\n ${options.map((option, optionIndex) => {\n return html`\n <label>\n <foxy-i18n\n class=${classMap({ 'sr-only': optionIndex !== value })}\n infer=\"\"\n key=${option}\n >\n </foxy-i18n>\n\n <input\n data-testclass=\"interactive editable\"\n class=\"sr-only\"\n value=${option}\n name=${name}\n type=\"radio\"\n ?disabled=${!isInteractive}\n ?checked=${optionIndex === value}\n @change=${(evt: Event) => {\n const input = evt.currentTarget as HTMLInputElement;\n if (input.checked) onChange(optionIndex);\n }}\n />\n </label>\n `;\n })}\n </div>\n\n <div class=\"flex justify-evenly h-full ${value ? 'flex-col-reverse' : 'flex-col'}\">\n <div style=${dotStyle} class=\"bg-current rounded-full\"></div>\n <div style=${dotStyle} class=\"border border-current rounded-full\"></div>\n </div>\n </div>\n `;\n }\n\n private __renderField({ value, label, onChange }: RulesTierFieldParams) {\n const isInteractive = !this.disabled && !this.readonly;\n const length = value.toString().length;\n const factor = length <= 2 ? 1 : 2.5;\n\n return html`\n <label>\n <foxy-i18n class=\"sr-only\" infer=\"\" key=${label}></foxy-i18n>\n <input\n data-testclass=\"interactive editable\"\n style=\"width: calc(var(--lumo-size-xl) * ${factor})\"\n class=${classMap({\n 'transition-colors border p-xs h-xs font-medium text-m rounded-s': true,\n 'ring-primary-50 text-body bg-contrast-10': isInteractive,\n 'hover-bg-contrast-20': isInteractive,\n 'focus-outline-none focus-ring-2': isInteractive,\n 'text-disabled bg-contrast-5': this.disabled,\n 'text-secondary': this.readonly && !this.disabled,\n 'border-transparent border-solid': !this.readonly,\n 'border-dashed border-contrast-30': this.readonly,\n })}\n type=\"number\"\n lang=${this.lang}\n min=\"0\"\n ?disabled=${!isInteractive}\n .value=${value}\n @input=${(evt: InputEvent) => {\n const input = evt.currentTarget as HTMLInputElement;\n onChange(input.value || '0');\n }}\n />\n </label>\n `;\n }\n\n private __renderTier(params: RulesTierParams) {\n const tier = params.tier ?? '0-0';\n const sign = tier.includes('+') ? '+' : '-';\n const [from, adjustment] = tier.split(/[-+]/).map(v => parseFloat(v));\n\n return html`\n <div\n data-testclass=\"rules:tier\"\n aria-label=${this.t('tier')}\n class=${classMap({\n 'flex items-start justify-between rounded': true,\n 'border border-contrast-10': true,\n 'border-dashed': !params.tier,\n })}\n >\n <div\n class=${classMap({\n 'transition-colors flex flex-wrap items-center gap-s p-s': true,\n 'text-tertiary': !this.disabled,\n 'text-disabled': this.disabled,\n })}\n >\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_if\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['total', 'quantity'],\n value: params.source === 'price' ? 0 : 1,\n onChange: i => params.onChange({ source: i ? 'quantity' : 'price' }),\n })}\n\n <div class=\"h-s w-s\">${operatorGreaterThanOrEqual}</div>\n\n ${this.__renderField({\n label: 'from',\n value: String(from),\n onChange: v => params.onChange({ tier: `${v}${sign}${adjustment}` }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_then\"></foxy-i18n>\n\n ${this.__renderSwitch({\n options: ['reduce', 'increase'],\n value: sign === '-' ? 0 : 1,\n onChange: i => params.onChange({ tier: `${from}${i ? '+' : '-'}${adjustment}` }),\n })}\n\n <!---->\n\n ${this.__renderSelect({\n options: {\n incremental: 'tier_incremental',\n allunits: 'tier_allunits',\n repeat: 'tier_repeat',\n single: 'tier_single',\n },\n value: params.method,\n label: 'target',\n onChange: v => params.onChange({ method: v }),\n })}\n\n <foxy-i18n class=\"uppercase text-s font-medium\" infer=\"\" key=\"tier_by\"></foxy-i18n>\n\n ${this.__renderField({\n label: 'adjustment',\n value: String(adjustment),\n onChange: v => params.onChange({ tier: `${from}${sign}${v}` }),\n })}\n\n <!---->\n\n ${this.__renderSwitch({\n value: params.units === 'percentage' ? 0 : 1,\n options: ['%', '¤'],\n onChange: i => params.onChange({ units: i ? 'amount' : 'percentage' }),\n })}\n </div>\n\n ${params.tier\n ? html`\n <button\n data-testclass=\"interactive\"\n aria-label=${this.t('delete')}\n class=${classMap({\n 'w-s h-s m-s flex-shrink-0 rounded-s transition-colors ring-primary-50': true,\n 'text-tertiary hover-text-secondary focus-outline-none focus-ring-2':\n !this.disabled,\n 'text-disabled cursor-default': this.disabled,\n })}\n ?disabled=${this.disabled}\n ?hidden=${this.readonly}\n @click=${() => params.onDelete()}\n >\n <iron-icon icon=\"lumo:cross\"></iron-icon>\n </button>\n `\n : ''}\n </div>\n `;\n }\n}\n"]}
|
|
@@ -236,16 +236,16 @@ export class Donation extends Translatable {
|
|
|
236
236
|
<x-i18n ns=${this.ns} lang=${this.lang} key="amount" slot="header"></x-i18n>
|
|
237
237
|
<x-choice
|
|
238
238
|
?custom=${!!((_a = this.custom) === null || _a === void 0 ? void 0 : _a.includes('amount'))}
|
|
239
|
-
.getText=${(v) => this.__translateAmount(
|
|
239
|
+
.getText=${(v) => this.__translateAmount(parseFloat(v))}
|
|
240
240
|
.items=${this.amounts.map(String)}
|
|
241
241
|
.value=${this.amount.toString()}
|
|
242
|
-
type="
|
|
242
|
+
type="number"
|
|
243
243
|
lang=${this.lang}
|
|
244
244
|
min="1"
|
|
245
245
|
ns=${this.ns}
|
|
246
246
|
data-testid="amount"
|
|
247
247
|
@change=${(evt) => {
|
|
248
|
-
const value =
|
|
248
|
+
const value = parseFloat(evt.detail);
|
|
249
249
|
this.amount = isNaN(value) ? /* istanbul ignore next */ 1 : value;
|
|
250
250
|
}}
|
|
251
251
|
>
|
|
@@ -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,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;AAO5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAkNxC;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;QAlKpB;;;;WAIG;QACI,aAAQ,GAAkB,IAAI,CAAC;QAEtC;;;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AAC,KAAK,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,UAAW,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC;IACjD,CAAC;IAEO,oBAAoB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,SAAS,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAE1D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE;YAC1B,KAAK,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\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(parseInt(v, 10))}\n .items=${this.amounts.map(String)}\n .value=${this.amount.toString()}\n type=\"integer\"\n lang=${this.lang}\n min=\"1\"\n ns=${this.ns}\n data-testid=\"amount\"\n @change=${(evt: ChoiceChangeEvent) => {\n const value = parseInt(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\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;AAO5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAkNxC;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;QAlKpB;;;;WAIG;QACI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AC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,UAAW,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC;IACjD,CAAC;IAEO,oBAAoB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,SAAS,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAE1D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE;YAC1B,KAAK,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\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\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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TemplateResult } from 'lit-html';
|
|
2
|
+
import type { Data } from './types';
|
|
3
|
+
import { TwoLineCard } from '../CustomFieldCard/TwoLineCard';
|
|
4
|
+
declare const Base: typeof TwoLineCard & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
5
|
+
defaultNS: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Basic card displaying a downloadable resource (`fx:downloadable`).
|
|
9
|
+
* Icons by {@link https://heroicons.com}.
|
|
10
|
+
*
|
|
11
|
+
* @element foxy-downloadable-card
|
|
12
|
+
* @since 1.22.0
|
|
13
|
+
*/
|
|
14
|
+
export declare class DownloadableCard extends Base<Data> {
|
|
15
|
+
renderBody(): TemplateResult;
|
|
16
|
+
private get __formattedFileSize();
|
|
17
|
+
private get __formattedPrice();
|
|
18
|
+
private get __extension();
|
|
19
|
+
private __renderExtension;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
2
|
+
import { TwoLineCard } from "../CustomFieldCard/TwoLineCard.js";
|
|
3
|
+
import { html, svg } from 'lit-html';
|
|
4
|
+
const NS = 'downloadable-card';
|
|
5
|
+
const Base = TranslatableMixin(TwoLineCard, NS);
|
|
6
|
+
/**
|
|
7
|
+
* Basic card displaying a downloadable resource (`fx:downloadable`).
|
|
8
|
+
* Icons by {@link https://heroicons.com}.
|
|
9
|
+
*
|
|
10
|
+
* @element foxy-downloadable-card
|
|
11
|
+
* @since 1.22.0
|
|
12
|
+
*/
|
|
13
|
+
export class DownloadableCard extends Base {
|
|
14
|
+
renderBody() {
|
|
15
|
+
const extension = this.__extension;
|
|
16
|
+
return html `
|
|
17
|
+
<div class="flex gap-s">
|
|
18
|
+
<div class="w-s h-s flex-shrink-0 rounded-s bg-contrast-5 flex" aria-hidden="true">
|
|
19
|
+
${extension.length < 5
|
|
20
|
+
? this.__renderExtension(extension)
|
|
21
|
+
: svg `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="m-auto" style="width: 64%; height: 64%"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" /></svg>`}
|
|
22
|
+
</div>
|
|
23
|
+
<div class="flex-1 min-w-0">
|
|
24
|
+
${super.renderBody({
|
|
25
|
+
title: data => html `
|
|
26
|
+
<span class="inline-flex w-full items-center">
|
|
27
|
+
<span class="mr-auto truncate min-w-0">${data.name} • ${data.code}</span>
|
|
28
|
+
<span class="text-s text-tertiary font-normal flex-shrink-0">
|
|
29
|
+
${svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="inline" style="width: 1.15em; height: 1.15em"><path d="M10.75 10.818v2.614A3.13 3.13 0 0011.888 13c.482-.315.612-.648.612-.875 0-.227-.13-.56-.612-.875a3.13 3.13 0 00-1.138-.432zM8.33 8.62c.053.055.115.11.184.164.208.16.46.284.736.363V6.603a2.45 2.45 0 00-.35.13c-.14.065-.27.143-.386.233-.377.292-.514.627-.514.909 0 .184.058.39.202.592.037.051.08.102.128.152z" /><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-6a.75.75 0 01.75.75v.316a3.78 3.78 0 011.653.713c.426.33.744.74.925 1.2a.75.75 0 01-1.395.55 1.35 1.35 0 00-.447-.563 2.187 2.187 0 00-.736-.363V9.3c.698.093 1.383.32 1.959.696.787.514 1.29 1.27 1.29 2.13 0 .86-.504 1.616-1.29 2.13-.576.377-1.261.603-1.96.696v.299a.75.75 0 11-1.5 0v-.3c-.697-.092-1.382-.318-1.958-.695-.482-.315-.857-.717-1.078-1.188a.75.75 0 111.359-.636c.08.173.245.376.54.569.313.205.706.353 1.138.432v-2.748a3.782 3.782 0 01-1.653-.713C6.9 9.433 6.5 8.681 6.5 7.875c0-.805.4-1.558 1.097-2.096a3.78 3.78 0 011.653-.713V4.75A.75.75 0 0110 4z" clip-rule="evenodd" /></svg>`}
|
|
30
|
+
${this.__formattedPrice}
|
|
31
|
+
</span>
|
|
32
|
+
</span>
|
|
33
|
+
`,
|
|
34
|
+
subtitle: data => html `${data.file_name} (${this.__formattedFileSize})`,
|
|
35
|
+
})}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
get __formattedFileSize() {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const fileSize = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.file_size) !== null && _b !== void 0 ? _b : 0;
|
|
43
|
+
const KB = 1024;
|
|
44
|
+
const MB = KB * 1024;
|
|
45
|
+
const GB = MB * 1024;
|
|
46
|
+
const options = { maximumFractionDigits: 2 };
|
|
47
|
+
const lang = this.lang || 'en';
|
|
48
|
+
try {
|
|
49
|
+
if (fileSize / GB > 1)
|
|
50
|
+
return `${(fileSize / GB).toLocaleString(lang, options)} GB`;
|
|
51
|
+
if (fileSize / MB > 1)
|
|
52
|
+
return `${(fileSize / MB).toLocaleString(lang, options)} MB`;
|
|
53
|
+
if (fileSize / KB > 1)
|
|
54
|
+
return `${(fileSize / KB).toLocaleString(lang, options)} KB`;
|
|
55
|
+
return `${fileSize.toLocaleString(lang, options)} B`;
|
|
56
|
+
}
|
|
57
|
+
catch (_c) {
|
|
58
|
+
return `${fileSize} B`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
get __formattedPrice() {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const price = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
64
|
+
try {
|
|
65
|
+
return price.toLocaleString(this.lang || 'en', {
|
|
66
|
+
maximumFractionDigits: 2,
|
|
67
|
+
minimumFractionDigits: 2,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (_c) {
|
|
71
|
+
return String(price);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
get __extension() {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const parts = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.file_name.split('.').filter(v => !!v)) !== null && _b !== void 0 ? _b : [];
|
|
77
|
+
return parts.length < 2 ? '?????' : parts.pop();
|
|
78
|
+
}
|
|
79
|
+
__renderExtension(ext) {
|
|
80
|
+
const style = `font: 700 calc(var(--lumo-size-s) / ${Math.max(2, ext.length)}) sans-serif`;
|
|
81
|
+
return html `<span style=${style} class="m-auto font-medium uppercase">${ext}</span>`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=DownloadableCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadableCard.js","sourceRoot":"","sources":["../../../../src/elements/public/DownloadableCard/DownloadableCard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,WAAW,EAAE,0CAAuC;AAC7D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,EAAE,GAAG,mBAAmB,CAAC;AAC/B,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAiB,SAAQ,IAAU;IAC9C,UAAU;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC;QAEnC,OAAO,IAAI,CAAA;;;YAGH,SAAS,CAAC,MAAM,GAAG,CAAC;YACpB,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC;YACnC,CAAC,CAAC,GAAG,CAAA,geAAge;;;YAGre,KAAK,CAAC,UAAU,CAAC;YACjB,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAA;;yDAE0B,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,IAAI;;oBAElE,GAAG,CAAA,wlCAAwlC;oBAC3lC,IAAI,CAAC,gBAAgB;;;aAG5B;YACD,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAA,GAAG,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,mBAAmB,GAAG;SACxE,CAAC;;;KAGP,CAAC;IACJ,CAAC;IAED,IAAY,mBAAmB;;QAC7B,MAAM,QAAQ,eAAG,IAAI,CAAC,IAAI,0CAAE,SAAS,mCAAI,CAAC,CAAC;QAE3C,MAAM,EAAE,GAAG,IAAI,CAA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S,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,oCAAK,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,KAAK,CAAC,GAAG,EAAa,CAAC;IAC9D,CAAC;IAEO,iBAAiB,CAAC,GAAW;QACnC,MAAM,KAAK,GAAG,uCAAuC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC;QAC3F,OAAO,IAAI,CAAA,eAAe,KAAK,yCAAyC,GAAG,SAAS,CAAC;IACvF,CAAC;CACF","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { TwoLineCard } from '../CustomFieldCard/TwoLineCard';\nimport { html, svg } from 'lit-html';\n\nconst NS = 'downloadable-card';\nconst Base = TranslatableMixin(TwoLineCard, NS);\n\n/**\n * Basic card displaying a downloadable resource (`fx:downloadable`).\n * Icons by {@link https://heroicons.com}.\n *\n * @element foxy-downloadable-card\n * @since 1.22.0\n */\nexport class DownloadableCard extends Base<Data> {\n renderBody(): TemplateResult {\n const extension = this.__extension;\n\n return html`\n <div class=\"flex gap-s\">\n <div class=\"w-s h-s flex-shrink-0 rounded-s bg-contrast-5 flex\" aria-hidden=\"true\">\n ${extension.length < 5\n ? this.__renderExtension(extension)\n : svg`<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" class=\"m-auto\" style=\"width: 64%; height: 64%\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z\" /></svg>`}\n </div>\n <div class=\"flex-1 min-w-0\">\n ${super.renderBody({\n title: data => html`\n <span class=\"inline-flex w-full items-center\">\n <span class=\"mr-auto truncate min-w-0\">${data.name} • ${data.code}</span>\n <span class=\"text-s text-tertiary font-normal flex-shrink-0\">\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" class=\"inline\" style=\"width: 1.15em; height: 1.15em\"><path d=\"M10.75 10.818v2.614A3.13 3.13 0 0011.888 13c.482-.315.612-.648.612-.875 0-.227-.13-.56-.612-.875a3.13 3.13 0 00-1.138-.432zM8.33 8.62c.053.055.115.11.184.164.208.16.46.284.736.363V6.603a2.45 2.45 0 00-.35.13c-.14.065-.27.143-.386.233-.377.292-.514.627-.514.909 0 .184.058.39.202.592.037.051.08.102.128.152z\" /><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-6a.75.75 0 01.75.75v.316a3.78 3.78 0 011.653.713c.426.33.744.74.925 1.2a.75.75 0 01-1.395.55 1.35 1.35 0 00-.447-.563 2.187 2.187 0 00-.736-.363V9.3c.698.093 1.383.32 1.959.696.787.514 1.29 1.27 1.29 2.13 0 .86-.504 1.616-1.29 2.13-.576.377-1.261.603-1.96.696v.299a.75.75 0 11-1.5 0v-.3c-.697-.092-1.382-.318-1.958-.695-.482-.315-.857-.717-1.078-1.188a.75.75 0 111.359-.636c.08.173.245.376.54.569.313.205.706.353 1.138.432v-2.748a3.782 3.782 0 01-1.653-.713C6.9 9.433 6.5 8.681 6.5 7.875c0-.805.4-1.558 1.097-2.096a3.78 3.78 0 011.653-.713V4.75A.75.75 0 0110 4z\" clip-rule=\"evenodd\" /></svg>`}\n ${this.__formattedPrice}\n </span>\n </span>\n `,\n subtitle: data => html`${data.file_name} (${this.__formattedFileSize})`,\n })}\n </div>\n </div>\n `;\n }\n\n private get __formattedFileSize() {\n const fileSize = this.data?.file_size ?? 0;\n\n const KB = 1024;\n const MB = KB * 1024;\n const GB = MB * 1024;\n\n const options: Intl.NumberFormatOptions = { maximumFractionDigits: 2 };\n const lang = this.lang || 'en';\n\n try {\n if (fileSize / GB > 1) return `${(fileSize / GB).toLocaleString(lang, options)} GB`;\n if (fileSize / MB > 1) return `${(fileSize / MB).toLocaleString(lang, options)} MB`;\n if (fileSize / KB > 1) return `${(fileSize / KB).toLocaleString(lang, options)} KB`;\n\n return `${fileSize.toLocaleString(lang, options)} B`;\n } catch {\n return `${fileSize} B`;\n }\n }\n\n private get __formattedPrice() {\n const price = this.data?.price ?? 0;\n\n try {\n return price.toLocaleString(this.lang || 'en', {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n });\n } catch {\n return String(price);\n }\n }\n\n private get __extension() {\n const parts = this.data?.file_name.split('.').filter(v => !!v) ?? [];\n return parts.length < 2 ? '?????' : (parts.pop() as string);\n }\n\n private __renderExtension(ext: string) {\n const style = `font: 700 calc(var(--lumo-size-s) / ${Math.max(2, ext.length)}) sans-serif`;\n return html`<span style=${style} class=\"m-auto font-medium uppercase\">${ext}</span>`;\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../../internal/InternalSandbox/index.js";
|
|
2
|
+
import "../../internal/InternalCard/index.js";
|
|
3
|
+
import "../Spinner/index.js";
|
|
4
|
+
import "../I18n/index.js";
|
|
5
|
+
import { DownloadableCard } from "./DownloadableCard.js";
|
|
6
|
+
customElements.define('foxy-downloadable-card', DownloadableCard);
|
|
7
|
+
export { DownloadableCard };
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/public/DownloadableCard/index.ts"],"names":[],"mappings":"AAAA,iDAA8C;AAC9C,8CAA2C;AAC3C,6BAA0B;AAC1B,0BAAuB;AAEvB,OAAO,EAAE,gBAAgB,EAAE,8BAA2B;AAEtD,cAAc,CAAC,MAAM,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import '../../internal/InternalSandbox/index';\nimport '../../internal/InternalCard/index';\nimport '../Spinner/index';\nimport '../I18n/index';\n\nimport { DownloadableCard } from './DownloadableCard';\n\ncustomElements.define('foxy-downloadable-card', DownloadableCard);\n\nexport { DownloadableCard };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Resource } from '@foxy.io/sdk/core';
|
|
2
|
+
import type { Rels } from '@foxy.io/sdk/backend';
|
|
3
|
+
export declare type Downloadable = Rels.Downloadable & {
|
|
4
|
+
links: {
|
|
5
|
+
'fx:create_upload_url': any;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare type Data = Resource<Downloadable>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/DownloadableCard/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nexport type Downloadable = Rels.Downloadable & { links: { 'fx:create_upload_url': any } };\nexport type Data = Resource<Downloadable>;\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { PropertyDeclarations } from 'lit-element';
|
|
2
|
+
import type { TemplateResult } from 'lit-html';
|
|
3
|
+
import type { NucleonV8N } from '../NucleonElement/types';
|
|
4
|
+
import type { Data } from './types';
|
|
5
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
6
|
+
import { InternalForm } from '../../internal/InternalForm/InternalForm';
|
|
7
|
+
declare const Base: typeof InternalForm & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
8
|
+
defaultNS: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Basic form for managing `fx:downloadable` resources.
|
|
12
|
+
* This element requires an augmented version of hAPI currently limited
|
|
13
|
+
* only to the new Foxy Admin.
|
|
14
|
+
*
|
|
15
|
+
* @slot item-category-uri:before
|
|
16
|
+
* @slot item-category-uri:after
|
|
17
|
+
*
|
|
18
|
+
* @slot name:before
|
|
19
|
+
* @slot name:after
|
|
20
|
+
*
|
|
21
|
+
* @slot code:before
|
|
22
|
+
* @slot code:after
|
|
23
|
+
*
|
|
24
|
+
* @slot price:before
|
|
25
|
+
* @slot price:after
|
|
26
|
+
*
|
|
27
|
+
* @slot upload:before
|
|
28
|
+
* @slot upload:after
|
|
29
|
+
*
|
|
30
|
+
* @slot timestamps:before
|
|
31
|
+
* @slot timestamps:after
|
|
32
|
+
*
|
|
33
|
+
* @slot create:before
|
|
34
|
+
* @slot create:after
|
|
35
|
+
*
|
|
36
|
+
* @slot delete:before
|
|
37
|
+
* @slot delete:after
|
|
38
|
+
*
|
|
39
|
+
* @element foxy-downloadable-form
|
|
40
|
+
* @since 1.22.0
|
|
41
|
+
*/
|
|
42
|
+
export declare class DownloadableForm extends Base<Data> {
|
|
43
|
+
static get properties(): PropertyDeclarations;
|
|
44
|
+
static get v8n(): NucleonV8N<Data>;
|
|
45
|
+
/** URL of the `fx:downloadable_item_categories` collection for the store. */
|
|
46
|
+
downloadableItemCategories: string | null;
|
|
47
|
+
private readonly __downloadableItemCategoryLoaderId;
|
|
48
|
+
get disabledSelector(): BooleanSelector;
|
|
49
|
+
renderBody(): TemplateResult;
|
|
50
|
+
protected _sendPatch(edits: Partial<Data>): Promise<Data>;
|
|
51
|
+
protected _sendPost(edits: Partial<Data>): Promise<Data>;
|
|
52
|
+
private get __downloadableItemCategoryLoader();
|
|
53
|
+
}
|
|
54
|
+
export {};
|