85 lines
2.3 KiB
JavaScript
85 lines
2.3 KiB
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.svgBaseProps = undefined;
|
||
|
exports.getThemeFromTypeName = getThemeFromTypeName;
|
||
|
exports.removeTypeTheme = removeTypeTheme;
|
||
|
exports.withThemeSuffix = withThemeSuffix;
|
||
|
exports.alias = alias;
|
||
|
|
||
|
var _warning = require('../_util/warning');
|
||
|
|
||
|
var _warning2 = _interopRequireDefault(_warning);
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||
|
|
||
|
// 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
|
||
|
var svgBaseProps = exports.svgBaseProps = {
|
||
|
width: '1em',
|
||
|
height: '1em',
|
||
|
fill: 'currentColor',
|
||
|
'aria-hidden': 'true',
|
||
|
focusable: 'false'
|
||
|
};
|
||
|
|
||
|
var fillTester = /-fill$/;
|
||
|
var outlineTester = /-o$/;
|
||
|
var twoToneTester = /-twotone$/;
|
||
|
|
||
|
function getThemeFromTypeName(type) {
|
||
|
var result = null;
|
||
|
if (fillTester.test(type)) {
|
||
|
result = 'filled';
|
||
|
} else if (outlineTester.test(type)) {
|
||
|
result = 'outlined';
|
||
|
} else if (twoToneTester.test(type)) {
|
||
|
result = 'twoTone';
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function removeTypeTheme(type) {
|
||
|
return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, '');
|
||
|
}
|
||
|
|
||
|
function withThemeSuffix(type, theme) {
|
||
|
var result = type;
|
||
|
if (theme === 'filled') {
|
||
|
result += '-fill';
|
||
|
} else if (theme === 'outlined') {
|
||
|
result += '-o';
|
||
|
} else if (theme === 'twoTone') {
|
||
|
result += '-twotone';
|
||
|
} else {
|
||
|
(0, _warning2['default'])(false, 'Icon', 'This icon \'' + type + '\' has unknown theme \'' + theme + '\'');
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
// For alias or compatibility
|
||
|
function alias(type) {
|
||
|
var newType = type;
|
||
|
switch (type) {
|
||
|
case 'cross':
|
||
|
newType = 'close';
|
||
|
break;
|
||
|
// https://github.com/ant-design/ant-design/issues/13007
|
||
|
case 'interation':
|
||
|
newType = 'interaction';
|
||
|
break;
|
||
|
// https://github.com/ant-design/ant-design/issues/16810
|
||
|
case 'canlendar':
|
||
|
newType = 'calendar';
|
||
|
break;
|
||
|
// https://github.com/ant-design/ant-design/issues/17448
|
||
|
case 'colum-height':
|
||
|
newType = 'column-height';
|
||
|
break;
|
||
|
default:
|
||
|
}
|
||
|
(0, _warning2['default'])(newType === type, 'Icon', 'Icon \'' + type + '\' was a typo and is now deprecated, please use \'' + newType + '\' instead.');
|
||
|
return newType;
|
||
|
}
|