JezK
Edit File: sc-product-price-choices.cjs.entry.js.map
{"file":"sc-product-price-choices.entry.cjs.js","mappings":";;;;;;;;;;;;;;;AAAA,MAAM,wBAAwB,GAAG,kEAAkE,CAAC;AACpG,oCAAe,wBAAwB;;;;;;;;;;;;0BC4Bf,UAAE;wBACJ,UAAE;sBACJ,UAAE;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/controllers/product/sc-product-price-choices/sc-product-price-choices.css?tag=sc-product-price-choices&encapsulation=shadow","src/components/controllers/product/sc-product-price-choices/sc-product-price-choices.tsx"],"sourcesContent":[":host {\n display: block;\n text-align: left;\n position: relative;\n z-index: 1;\n}\n","import { Component, h, Prop, Fragment, Host } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport { intervalString } from '../../../../functions/price';\nimport { state } from '@store/product';\nimport { availablePrices } from '@store/product/getters';\nimport { setProduct } from '@store/product/setters';\n\n@Component({\n tag: 'sc-product-price-choices',\n styleUrl: 'sc-product-price-choices.css',\n shadow: true,\n})\nexport class ScProductPriceChoices {\n /** The product price choice label */\n @Prop() label: string;\n\n /** Whether to show the price */\n @Prop() showPrice: boolean;\n\n /** The product id */\n @Prop() productId: string;\n\n renderPrice(price) {\n return (\n <Fragment>\n <sc-format-number type=\"currency\" value={price.amount} currency={price.currency}></sc-format-number>\n <span slot=\"per\">\n {intervalString(price, {\n labels: {\n interval: __('Every', 'surecart'),\n period: __('for', 'surecart'),\n once: __('Once', 'surecart'),\n },\n showOnce: true,\n })}\n </span>\n </Fragment>\n );\n }\n\n render() {\n const prices = availablePrices(this.productId);\n if (prices?.length < 2) return <Host style={{ display: 'none' }}></Host>;\n\n return (\n <sc-choices label={this.label} required style={{ '--sc-input-required-indicator': ' ' }}>\n {(prices || []).map(price => (\n <sc-price-choice-container\n label={price?.name || state[this.productId]?.product?.name}\n showPrice={!!this.showPrice}\n price={price}\n checked={state[this.productId]?.selectedPrice?.id === price?.id}\n onScChange={e => {\n if (e.target.checked) {\n setProduct(this.productId, { selectedPrice: price });\n }\n }}\n />\n ))}\n </sc-choices>\n );\n }\n}\n"],"version":3}