1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import { isDevMode } from '@angular/core';
- import { generate as generateColor } from '@ant-design/colors';
- export const ANT_ICON_ANGULAR_CONSOLE_PREFIX = '[@ant-design/icons-angular]:';
- export function error(message) {
- console.error(`${ANT_ICON_ANGULAR_CONSOLE_PREFIX} ${message}.`);
- }
- export function warn(message) {
- if (isDevMode()) {
- console.warn(`${ANT_ICON_ANGULAR_CONSOLE_PREFIX} ${message}.`);
- }
- }
- export function getSecondaryColor(primaryColor) {
- return generateColor(primaryColor)[0];
- }
- export function withSuffix(name, theme) {
- switch (theme) {
- case 'fill': return `${name}-fill`;
- case 'outline': return `${name}-o`;
- case 'twotone': return `${name}-twotone`;
- case undefined: return name;
- default: throw new Error(`${ANT_ICON_ANGULAR_CONSOLE_PREFIX}Theme "${theme}" is not a recognized theme!`);
- }
- }
- export function withSuffixAndColor(name, theme, pri, sec) {
- return `${withSuffix(name, theme)}-${pri}-${sec}`;
- }
- export function mapAbbrToTheme(abbr) {
- return abbr === 'o' ? 'outline' : abbr;
- }
- export function alreadyHasAThemeSuffix(name) {
- return name.endsWith('-fill') || name.endsWith('-o') || name.endsWith('-twotone');
- }
- export function isIconDefinition(target) {
- return (typeof target === 'object' &&
- typeof target.name === 'string' &&
- (typeof target.theme === 'string' || target.theme === undefined) &&
- typeof target.icon === 'string');
- }
- /**
- * Get an `IconDefinition` object from abbreviation type, like `account-book-fill`.
- * @param str
- */
- export function getIconDefinitionFromAbbr(str) {
- const arr = str.split('-');
- const theme = mapAbbrToTheme(arr.splice(arr.length - 1, 1)[0]);
- const name = arr.join('-');
- return {
- name,
- theme,
- icon: ''
- };
- }
- export function cloneSVG(svg) {
- return svg.cloneNode(true);
- }
- /**
- * Parse inline SVG string and replace colors with placeholders. For twotone icons only.
- */
- export function replaceFillColor(raw) {
- return raw
- .replace(/['"]#333['"]/g, '"primaryColor"')
- .replace(/['"]#E6E6E6['"]/g, '"secondaryColor"')
- .replace(/['"]#D9D9D9['"]/g, '"secondaryColor"')
- .replace(/['"]#D8D8D8['"]/g, '"secondaryColor"');
- }
- /**
- * Split a name with namespace in it into a tuple like [ name, namespace ].
- */
- export function getNameAndNamespace(type) {
- const split = type.split(':');
- switch (split.length) {
- case 1: return [type, ''];
- case 2: return [split[1], split[0]];
- default: throw new Error(`${ANT_ICON_ANGULAR_CONSOLE_PREFIX}The icon type ${type} is not valid!`);
- }
- }
- export function hasNamespace(type) {
- return getNameAndNamespace(type)[1] !== '';
- }
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMxQyxPQUFPLEVBQUUsUUFBUSxJQUFJLGFBQWEsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSS9ELE1BQU0sQ0FBQyxNQUFNLCtCQUErQixHQUFHLDhCQUE4QixDQUFDO0FBRTlFLE1BQU0sVUFBVSxLQUFLLENBQUMsT0FBZTtJQUNuQyxPQUFPLENBQUMsS0FBSyxDQUFDLEdBQUcsK0JBQStCLElBQUksT0FBTyxHQUFHLENBQUMsQ0FBQztBQUNsRSxDQUFDO0FBRUQsTUFBTSxVQUFVLElBQUksQ0FBQyxPQUFlO0lBQ2xDLElBQUksU0FBUyxFQUFFLEVBQUU7UUFDZixPQUFPLENBQUMsSUFBSSxDQUFDLEdBQUcsK0JBQStCLElBQUksT0FBTyxHQUFHLENBQUMsQ0FBQztLQUNoRTtBQUNILENBQUM7QUFFRCxNQUFNLFVBQVUsaUJBQWlCLENBQUMsWUFBb0I7SUFDcEQsT0FBTyxhQUFhLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7Q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