@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/).
83 lines (82 loc) • 3.03 kB
JavaScript
import '../mt-data-table-price-renderer.css';
;
const vue = require("vue");
const object = require("../object-deb13c0b.js");
const _pluginVue_exportHelper = require("../_plugin-vue_export-helper-9c783a34.js");
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 = vue.defineComponent({
name: "MtDataTablePriceRenderer",
props: {
columnDefinition: {
type: Object,
required: true
},
data: {
type: void 0,
required: true
}
},
setup(props) {
const renderString = vue.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 = object.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 ? (vue.openBlock(), vue.createElementBlock("a", {
key: 0,
class: "mt-data-table-price-renderer",
href: "#",
onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => _ctx.$emit("click", _ctx.data), ["prevent"]))
}, vue.toDisplayString(_ctx.renderString), 1)) : (vue.openBlock(), vue.createElementBlock("p", _hoisted_1, vue.toDisplayString(_ctx.renderString), 1));
}
const MtDataTablePriceRenderer = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render]]);
module.exports = MtDataTablePriceRenderer;
//# sourceMappingURL=MtDataTablePriceRenderer.js.map