UNPKG

antd-omi-icons

Version:
86 lines (85 loc) 4.15 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.iconStyles = exports.svgBaseProps = exports.normalizeTwoToneColors = exports.getSecondaryColor = exports.generate = exports.normalizeAttrs = exports.isIconDefinition = exports.warning = exports.warn = void 0; var omi_1 = require("omi"); var colors_1 = require("@ant-design/colors"); function warn(valid, message) { // Support uglify if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) { console.error("Warning: ".concat(message)); } } exports.warn = warn; function warning(valid, message) { warn(valid, "[antd-icons-omi] ".concat(message)); } exports.warning = warning; function isIconDefinition(target) { return target && (typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function')); } exports.isIconDefinition = isIconDefinition; function normalizeAttrs(attrs) { if (attrs === void 0) { attrs = {}; } return Object.keys(attrs).reduce(function (acc, key) { var val = attrs[key]; switch (key) { case 'class': acc.className = val; delete acc.class; break; default: acc[key] = val; } return acc; }, {}); } exports.normalizeAttrs = normalizeAttrs; function generate(node, key, rootProps) { if (!rootProps) { return (0, omi_1.h)(node.tag, __assign({ key: key }, node.attrs), (node.children || []).map(function (child, index) { return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index)); })); } return (0, omi_1.h)(node.tag, __assign(__assign({ key: key }, rootProps), node.attrs), (node.children || []).map(function (child, index) { return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index)); })); } exports.generate = generate; function getSecondaryColor(primaryColor) { // choose the second color return (0, colors_1.generate)(primaryColor)[0]; } exports.getSecondaryColor = getSecondaryColor; function normalizeTwoToneColors(twoToneColor) { if (!twoToneColor) { return []; } return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor]; } exports.normalizeTwoToneColors = normalizeTwoToneColors; // These props make sure that the SVG behaviours like general text. // Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4 exports.svgBaseProps = { width: '1em', height: '1em', fill: 'currentColor', 'aria-hidden': 'true', focusable: 'false', }; exports.iconStyles = "\nsvg.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\nsvg.anticon > * {\n line-height: 1;\n}\n\nsvg.anticon svg {\n display: inline-block;\n}\n\nsvg.anticon::before {\n display: none;\n}\n\nsvg.anticon .anticon-icon {\n display: block;\n}\n\nsvg.anticon[tabindex] {\n cursor: pointer;\n}\n\nsvg.anticon-spin::before,\nsvg.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n";