@ant-design/icons-react
Advanced tools
Comparing version 0.1.0-alpha.5 to 0.1.0-alpha.6
import { IconDefinition } from '@ant-design/icons'; | ||
import * as React from 'react'; | ||
import { Library } from '../library'; | ||
export interface AntdIconProps { | ||
@@ -11,6 +10,9 @@ type: string | IconDefinition; | ||
declare class AntdIcon extends React.Component<AntdIconProps> { | ||
static library: Library; | ||
static displayName: string; | ||
static definitions: Map<string, IconDefinition>; | ||
static add(...icons: IconDefinition[]): void; | ||
static clear(): void; | ||
static get(key: string): IconDefinition | undefined; | ||
render(): any; | ||
} | ||
export default AntdIcon; |
@@ -78,7 +78,17 @@ import { Component, createElement } from 'react'; | ||
var Library = /** @class */ (function () { | ||
function Library() { | ||
this.definitions = new Map(); | ||
function log(message) { | ||
if (!(process && process.env && process.env.NODE_ENV === 'production')) { | ||
console.error("[@ant-design/icons-react]: " + message + "."); | ||
} | ||
Library.prototype.add = function () { | ||
} | ||
function isIconDefinition(target) { | ||
return typeof target === 'object' && target.name && target.width && Array.isArray(target.children); | ||
} | ||
var AntdIcon = /** @class */ (function (_super) { | ||
__extends(AntdIcon, _super); | ||
function AntdIcon() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
AntdIcon.add = function () { | ||
var _this = this; | ||
@@ -93,25 +103,8 @@ var icons = []; | ||
}; | ||
Library.prototype.clear = function () { | ||
AntdIcon.clear = function () { | ||
this.definitions.clear(); | ||
}; | ||
Library.prototype.get = function (key) { | ||
AntdIcon.get = function (key) { | ||
return this.definitions.get(key); | ||
}; | ||
return Library; | ||
}()); | ||
function log(message) { | ||
if (!(process && process.env && process.env.NODE_ENV === 'production')) { | ||
console.error("[@ant-design/icons-react]: " + message + "."); | ||
} | ||
} | ||
function isIconDefinition(target) { | ||
return typeof target === 'object' && target.name && target.width && Array.isArray(target.children); | ||
} | ||
var AntdIcon = /** @class */ (function (_super) { | ||
__extends(AntdIcon, _super); | ||
function AntdIcon() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
AntdIcon.prototype.render = function () { | ||
@@ -124,3 +117,3 @@ var _a = this.props, type = _a.type, rest = __rest(_a, ["type"]); | ||
else if (typeof type === 'string') { | ||
target = AntdIcon.library.get(type); | ||
target = AntdIcon.get(type); | ||
if (!target) { | ||
@@ -137,4 +130,4 @@ log("Could not find icon: " + type); | ||
}; | ||
AntdIcon.library = new Library(); | ||
AntdIcon.displayName = 'AntdIcon'; | ||
AntdIcon.definitions = new Map(); | ||
return AntdIcon; | ||
@@ -141,0 +134,0 @@ }(Component)); |
import { IconDefinition } from '@ant-design/icons'; | ||
import * as React from 'react'; | ||
import { Library } from '../library'; | ||
export interface AntdIconProps { | ||
@@ -11,6 +10,9 @@ type: string | IconDefinition; | ||
declare class AntdIcon extends React.Component<AntdIconProps> { | ||
static library: Library; | ||
static displayName: string; | ||
static definitions: Map<string, IconDefinition>; | ||
static add(...icons: IconDefinition[]): void; | ||
static clear(): void; | ||
static get(key: string): IconDefinition | undefined; | ||
render(): any; | ||
} | ||
export default AntdIcon; |
@@ -80,7 +80,17 @@ 'use strict'; | ||
var Library = /** @class */ (function () { | ||
function Library() { | ||
this.definitions = new Map(); | ||
function log(message) { | ||
if (!(process && process.env && process.env.NODE_ENV === 'production')) { | ||
console.error("[@ant-design/icons-react]: " + message + "."); | ||
} | ||
Library.prototype.add = function () { | ||
} | ||
function isIconDefinition(target) { | ||
return typeof target === 'object' && target.name && target.width && Array.isArray(target.children); | ||
} | ||
var AntdIcon = /** @class */ (function (_super) { | ||
__extends(AntdIcon, _super); | ||
function AntdIcon() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
AntdIcon.add = function () { | ||
var _this = this; | ||
@@ -95,25 +105,8 @@ var icons = []; | ||
}; | ||
Library.prototype.clear = function () { | ||
AntdIcon.clear = function () { | ||
this.definitions.clear(); | ||
}; | ||
Library.prototype.get = function (key) { | ||
AntdIcon.get = function (key) { | ||
return this.definitions.get(key); | ||
}; | ||
return Library; | ||
}()); | ||
function log(message) { | ||
if (!(process && process.env && process.env.NODE_ENV === 'production')) { | ||
console.error("[@ant-design/icons-react]: " + message + "."); | ||
} | ||
} | ||
function isIconDefinition(target) { | ||
return typeof target === 'object' && target.name && target.width && Array.isArray(target.children); | ||
} | ||
var AntdIcon = /** @class */ (function (_super) { | ||
__extends(AntdIcon, _super); | ||
function AntdIcon() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
AntdIcon.prototype.render = function () { | ||
@@ -126,3 +119,3 @@ var _a = this.props, type = _a.type, rest = __rest(_a, ["type"]); | ||
else if (typeof type === 'string') { | ||
target = AntdIcon.library.get(type); | ||
target = AntdIcon.get(type); | ||
if (!target) { | ||
@@ -139,4 +132,4 @@ log("Could not find icon: " + type); | ||
}; | ||
AntdIcon.library = new Library(); | ||
AntdIcon.displayName = 'AntdIcon'; | ||
AntdIcon.definitions = new Map(); | ||
return AntdIcon; | ||
@@ -143,0 +136,0 @@ }(React.Component)); |
{ | ||
"name": "@ant-design/icons-react", | ||
"version": "0.1.0-alpha.5", | ||
"version": "0.1.0-alpha.6", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./esm/index.js", |
@@ -5,4 +5,4 @@ # React Antd Icons | ||
```bash | ||
yarn add antd-icons | ||
yarn add react-antd-icons | ||
yarn add @ant-design/icons | ||
yarn add @ant-design/icons-react | ||
``` | ||
@@ -15,4 +15,5 @@ | ||
```ts | ||
import { library, Alibaba } from 'antd-icons/esm'; | ||
library.add(Alibaba); | ||
import { Alibaba, Dashboard, DashboardFill, Twitter } from '@ant-design/icons/esm'; | ||
import AntdIcon from '@ant-design/icons-react/esm'; | ||
AntdIcon.add(Alibaba, Dashboard, DashboardFill); | ||
``` | ||
@@ -26,6 +27,6 @@ | ||
import styles from './index.less'; | ||
import { library, Alibaba, Dashboard, Twitter } from 'antd-icons/esm'; | ||
import AntdIcon from 'react-antd-icons/esm'; | ||
import { Alibaba, Dashboard, DashboardFill, Twitter } from '@ant-design/icons/esm'; | ||
import AntdIcon from '@ant-design/icons-react/esm'; | ||
library.add(Alibaba, Dashboard, DashboardFill); | ||
AntdIcon.add(Alibaba, Dashboard, DashboardFill); | ||
@@ -47,3 +48,3 @@ export default class IndexPage extends React.Component { | ||
```ts | ||
interface IAntdIconProps { | ||
interface AntdIconProps { | ||
type: string | IconDefinition; | ||
@@ -50,0 +51,0 @@ className?: string; |
Sorry, the diff of this file is not supported yet
32839
94
52
435