UNPKG

4.39 kBJavaScriptView Raw
1function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
2
3function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
5import { nextTick, h } from 'vue';
6import { generate as generateColor } from '@ant-design/colors';
7import insertCss from './insert-css';
8export function warn(valid, message) {
9 // Support uglify
10 if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
11 console.error("Warning: ".concat(message));
12 }
13}
14export function warning(valid, message) {
15 warn(valid, "[@ant-design/icons-vue] ".concat(message));
16} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
17
18export function isIconDefinition(target) {
19 return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
20}
21export function normalizeAttrs() {
22 var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23 return Object.keys(attrs).reduce(function (acc, key) {
24 var val = attrs[key];
25
26 switch (key) {
27 case 'class':
28 acc.className = val;
29 delete acc["class"];
30 break;
31
32 default:
33 acc[key] = val;
34 }
35
36 return acc;
37 }, {});
38}
39export function generate(node, key, rootProps) {
40 if (!rootProps) {
41 return h(node.tag, _objectSpread({
42 key: key
43 }, node.attrs), (node.children || []).map(function (child, index) {
44 return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
45 }));
46 }
47
48 return h(node.tag, _objectSpread({
49 key: key
50 }, rootProps, node.attrs), (node.children || []).map(function (child, index) {
51 return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
52 }));
53}
54export function getSecondaryColor(primaryColor) {
55 // choose the second color
56 return generateColor(primaryColor)[0];
57}
58export function normalizeTwoToneColors(twoToneColor) {
59 if (!twoToneColor) {
60 return [];
61 }
62
63 return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
64} // These props make sure that the SVG behaviours like general text.
65// Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
66
67export var svgBaseProps = {
68 width: '1em',
69 height: '1em',
70 fill: 'currentColor',
71 'aria-hidden': 'true',
72 focusable: 'false'
73};
74export var iconStyles = "\n.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\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.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";
75var cssInjectedFlag = false;
76export var useInsertStyles = function useInsertStyles() {
77 var styleStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : iconStyles;
78 nextTick(function () {
79 if (!cssInjectedFlag) {
80 if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
81 insertCss(styleStr, {
82 prepend: true
83 });
84 }
85
86 cssInjectedFlag = true;
87 }
88 });
89};
\No newline at end of file