UNPKG

v-vectors

Version:
107 lines (92 loc) 4.12 kB
/*! * v-vectors v1.1.0 * Scalable Vector Graphics 🤝 Vue 3 * (c) 2021 Vinayak Kulkarni<inbox.vinayak@gmail.com> * Released under the MIT License */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var script = vue.defineComponent({ name: 'Marker', props: { marker: { type: Object , required: true, default: () => {}, }, }, setup(props) { const paths = vue.computed( () => _optionalChain([props, 'access', _ => _.marker, 'optionalAccess', _2 => _2.paths]) && _optionalChain([props, 'access', _3 => _3.marker, 'optionalAccess', _4 => _4.paths, 'access', _5 => _5.length]) > 0, ); const circles = vue.computed( () => _optionalChain([props, 'access', _6 => _6.marker, 'optionalAccess', _7 => _7.circles]) && _optionalChain([props, 'access', _8 => _8.marker, 'optionalAccess', _9 => _9.circles, 'access', _10 => _10.length]) > 0, ); return { paths, circles, }; }, }); const _hoisted_1 = ["viewBox"]; const _hoisted_2 = /*#__PURE__*/vue.createElementVNode("defs", null, null, -1 /* HOISTED */); const _hoisted_3 = ["d", "fill", "fill-opacity", "stroke", "stroke-opacity", "tabindex"]; const _hoisted_4 = ["cx", "cy", "r", "fill", "fill-opacity"]; function render(_ctx, _cache, $props, $setup, $data, $options) { return (Object.keys(_ctx.marker).length > 0) ? (vue.openBlock(), vue.createElementBlock("svg", { key: 0, xmlns: "http://www.w3.org/2000/svg", viewBox: _ctx.marker.viewBox }, [ _hoisted_2, vue.createCommentVNode(" https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path#attributes "), (_ctx.paths) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(_ctx.marker.paths, (path, index) => { return (vue.openBlock(), vue.createElementBlock("path", { key: index, d: path.d, fill: path.fillColor, "fill-opacity": path.fillOpacity, stroke: path.strokeColor, "stroke-opacity": path.strokeOpacity, tabindex: index }, null, 8 /* PROPS */, _hoisted_3)) }), 128 /* KEYED_FRAGMENT */)) : vue.createCommentVNode("v-if", true), vue.createCommentVNode(" https://developer.mozilla.org/en-US/docs/Web/SVG/Element/circle#attributes "), (_ctx.circles) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(_ctx.marker.circles, (circle, index) => { return (vue.openBlock(), vue.createElementBlock("circle", { key: `circle-${index}`, cx: circle.cx, cy: circle.cy, r: circle.r, fill: circle.fillColor, "fill-opacity": circle.fillOpacity || 1 }, null, 8 /* PROPS */, _hoisted_4)) }), 128 /* KEYED_FRAGMENT */)) : vue.createCommentVNode("v-if", true) ], 8 /* PROPS */, _hoisted_1)) : vue.createCommentVNode("v-if", true) } script.render = render; script.__file = "src/components/VSvg.vue"; const setVueInstance = (instance) => { }; let installed = false; const install = ( instance, ) => { if (!installed) { setVueInstance(instance); instance.component('VSvg', script); installed = true; } }; var install$1 = install; exports.VSvg = script; exports['default'] = install$1; //# sourceMappingURL=v-vectors.cjs.js.map