UNPKG

@shopware-ag/meteor-component-library

Version:

The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).

84 lines (83 loc) 3.03 kB
import '../mt-data-table-price-renderer.css'; import { defineComponent, computed, openBlock, createElementBlock, withModifiers, toDisplayString } from "vue"; import { a as get } from "../object-e11d5dd3.mjs"; import { _ as _export_sfc } from "../_plugin-vue_export-helper-cc2b3d55.mjs"; function currency(val, sign, decimalPlaces, additionalOptions = {}) { const decimalOpts = decimalPlaces !== void 0 ? { minimumFractionDigits: decimalPlaces, maximumFractionDigits: decimalPlaces } : { minimumFractionDigits: 2, maximumFractionDigits: 20 }; const opts = { style: "currency", currency: sign, ...decimalOpts, ...additionalOptions }; return val.toLocaleString(additionalOptions.language ?? "en-US", opts); } const _sfc_main = defineComponent({ name: "MtDataTablePriceRenderer", props: { columnDefinition: { type: Object, required: true }, data: { type: void 0, required: true } }, setup(props) { const renderString = computed(() => { var _a, _b, _c, _d, _e, _f; if (props.columnDefinition.renderer !== "price") { return "Wrong renderer for price renderer"; } const currencyId = (_b = (_a = props.columnDefinition) == null ? void 0 : _a.rendererOptions) == null ? void 0 : _b.currencyId; if (!currencyId) { return "No currency id found"; } const prices = get(props.data, props.columnDefinition.property); if (!prices) { return "No prices found"; } const price = prices.find((price2) => price2.currencyId === currencyId); if (!price) { return "No price found"; } const currencyISOCode = (_d = (_c = props.columnDefinition) == null ? void 0 : _c.rendererOptions) == null ? void 0 : _d.currencyISOCode; if (!currencyISOCode) { return "No iso code found"; } const currencySource = (_f = (_e = props.columnDefinition) == null ? void 0 : _e.rendererOptions) == null ? void 0 : _f.source; if (!currencySource) { return "No source (gross/net) found"; } return currency(price[currencySource], currencyISOCode); }); return { renderString }; } }); const mtDataTablePriceRenderer_vue_vue_type_style_index_0_lang = ""; const _hoisted_1 = { key: 1, class: "mt-data-table-price-renderer" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return _ctx.columnDefinition.clickable ? (openBlock(), createElementBlock("a", { key: 0, class: "mt-data-table-price-renderer", href: "#", onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.$emit("click", _ctx.data), ["prevent"])) }, toDisplayString(_ctx.renderString), 1)) : (openBlock(), createElementBlock("p", _hoisted_1, toDisplayString(_ctx.renderString), 1)); } const MtDataTablePriceRenderer = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { MtDataTablePriceRenderer as default }; //# sourceMappingURL=MtDataTablePriceRenderer.js.map