UNPKG

@carbon/icons-vue

Version:

Vue components for icons in digital and software products using the Carbon Design System

99 lines (98 loc) 3.21 kB
/** * Copyright IBM Corp. 2019, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. * * Code generated by @carbon/icon-build-helpers. DO NOT EDIT. */ //#region \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); //#endregion let _carbon_icon_helpers = require("@carbon/icon-helpers"); let vue = require("vue"); vue = __toESM(vue); //#region virtual:./utils.js /** * Copyright IBM Corp. 2018, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ function getVueExport(key) { return vue[key]; } const h = getVueExport("h"); const createApp = getVueExport("createApp"); const getSvgAttrs = (title, svgAttrs, componentAttrs) => { return (0, _carbon_icon_helpers.getAttributes)({ ...svgAttrs, preserveAspectRatio: "xMidYMid meet", xmlns: "http://www.w3.org/2000/svg", title, ...componentAttrs }); }; const getVue2SvgAttrs = (title, svgAttrs, data, listeners) => { const result = { attrs: getSvgAttrs(title, svgAttrs, data.attrs), on: listeners, style: { ...data.staticStyle, ...data.style } }; delete result.attrs.style; if (data.staticClass || data.class) { result.class = {}; if (data.staticClass) result.class[data.staticClass] = true; if (data.class) result.class[data.class] = true; } return result; }; const createSVGComponent = (name, svgAttrs, svgContent) => ({ props: { title: String }, name, ...createApp ? { setup({ title }, { attrs: componentAttrs, slots }) { return () => h("svg", getSvgAttrs(title, svgAttrs, componentAttrs), [ ...title ? [h("title", title)] : [], ...svgContent.map(({ elem, attrs }) => h(elem, attrs)), ...slots.default ? slots.default() : [] ]); } } : { functional: true, render(createElement, { props: { title }, children, data, listeners }) { return createElement("svg", getVue2SvgAttrs(title, svgAttrs, data, listeners), [ ...title ? [createElement("title", null, title)] : [], ...svgContent.map(({ elem, attrs }) => createElement(elem, { attrs })), ...children || [] ]); } } }); //#endregion Object.defineProperty(exports, "createSVGComponent", { enumerable: true, get: function() { return createSVGComponent; } });