UNPKG

5.03 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.warn = warn;
7exports.warning = warning;
8exports.isIconDefinition = isIconDefinition;
9exports.normalizeAttrs = normalizeAttrs;
10exports.generate = generate;
11exports.getSecondaryColor = getSecondaryColor;
12exports.normalizeTwoToneColors = normalizeTwoToneColors;
13exports.useInsertStyles = exports.iconStyles = exports.svgBaseProps = void 0;
14
15var _vue = require("vue");
16
17var _colors = require("@ant-design/colors");
18
19var _insertCss = _interopRequireDefault(require("./insert-css"));
20
21function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
22
23function _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; }
24
25function _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; }
26
27function warn(valid, message) {
28 // Support uglify
29 if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
30 console.error("Warning: ".concat(message));
31 }
32}
33
34function warning(valid, message) {
35 warn(valid, "[@ant-design/icons-vue] ".concat(message));
36} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
37
38
39function isIconDefinition(target) {
40 return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
41}
42
43function normalizeAttrs() {
44 var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
45 return Object.keys(attrs).reduce(function (acc, key) {
46 var val = attrs[key];
47
48 switch (key) {
49 case 'class':
50 acc.className = val;
51 delete acc["class"];
52 break;
53
54 default:
55 acc[key] = val;
56 }
57
58 return acc;
59 }, {});
60}
61
62function generate(node, key, rootProps) {
63 if (!rootProps) {
64 return (0, _vue.h)(node.tag, _objectSpread({
65 key: key
66 }, node.attrs), (node.children || []).map(function (child, index) {
67 return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
68 }));
69 }
70
71 return (0, _vue.h)(node.tag, _objectSpread({
72 key: key
73 }, rootProps, node.attrs), (node.children || []).map(function (child, index) {
74 return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
75 }));
76}
77
78function getSecondaryColor(primaryColor) {
79 // choose the second color
80 return (0, _colors.generate)(primaryColor)[0];
81}
82
83function normalizeTwoToneColors(twoToneColor) {
84 if (!twoToneColor) {
85 return [];
86 }
87
88 return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
89} // These props make sure that the SVG behaviours like general text.
90// Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
91
92
93var svgBaseProps = {
94 width: '1em',
95 height: '1em',
96 fill: 'currentColor',
97 'aria-hidden': 'true',
98 focusable: 'false'
99};
100exports.svgBaseProps = svgBaseProps;
101var 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";
102exports.iconStyles = iconStyles;
103var cssInjectedFlag = false;
104
105var useInsertStyles = function useInsertStyles() {
106 var styleStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : iconStyles;
107 (0, _vue.nextTick)(function () {
108 if (!cssInjectedFlag) {
109 if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
110 (0, _insertCss["default"])(styleStr, {
111 prepend: true
112 });
113 }
114
115 cssInjectedFlag = true;
116 }
117 });
118};
119
120exports.useInsertStyles = useInsertStyles;
\No newline at end of file