@ant-design/icons-react
Advanced tools
Comparing version 0.3.0-beta.2 to 0.3.0-beta.3
@@ -16,4 +16,4 @@ import { IconDefinition } from '@ant-design/icons'; | ||
static get(key: string): IconDefinition | undefined; | ||
render(): JSX.Element | null; | ||
render(): any; | ||
} | ||
export default Icon; |
@@ -1,4 +0,2 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray'; | ||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
import _defineProperty from 'babel-runtime/helpers/defineProperty'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
@@ -9,3 +7,3 @@ import _createClass from 'babel-runtime/helpers/createClass'; | ||
import * as React from 'react'; | ||
import { isIconDefinition, log, MiniMap, normalizeAttrs } from '../utils'; | ||
import { generate, isIconDefinition, log, MiniMap } from '../utils'; | ||
@@ -24,5 +22,9 @@ var Icon = function (_React$Component) { | ||
value: function render() { | ||
var _generate; | ||
var _props = this.props, | ||
type = _props.type, | ||
rest = _objectWithoutProperties(_props, ['type']); | ||
className = _props.className, | ||
onClick = _props.onClick, | ||
style = _props.style; | ||
@@ -43,23 +45,7 @@ var target = void 0; | ||
} | ||
var children = []; | ||
if (target.style) { | ||
children.push(React.createElement( | ||
'style', | ||
{ key: target.name + '-style' }, | ||
target.style | ||
)); | ||
} | ||
children.push.apply(children, _toConsumableArray(target.children.map(function (_ref, index) { | ||
var tag = _ref.tag, | ||
attrs = _ref.attrs; | ||
return React.createElement(tag, _extends({}, normalizeAttrs(attrs), { | ||
key: tag + '-' + index | ||
})); | ||
}))); | ||
return React.createElement( | ||
'svg', | ||
_extends({}, rest, { 'data-icon': target.name, viewBox: '0 0 ' + target.width + ' ' + target.height, width: '1em', height: '1em', fill: 'currentColor', 'aria-hidden': 'true' }), | ||
children | ||
); | ||
return generate(target, 'svg-' + target.name, (_generate = { | ||
className: className, | ||
onClick: onClick, | ||
style: style | ||
}, _defineProperty(_generate, 'data-icon', target.name), _defineProperty(_generate, 'width', '1em'), _defineProperty(_generate, 'height', '1em'), _defineProperty(_generate, 'fill', 'currentColor'), _defineProperty(_generate, 'aria-hidden', 'true'), _generate)); | ||
} | ||
@@ -66,0 +52,0 @@ }], [{ |
@@ -1,2 +0,2 @@ | ||
import { IconDefinition } from '@ant-design/icons'; | ||
import { AbstractNode, IconDefinition } from '@ant-design/icons'; | ||
export declare function log(message: string): void; | ||
@@ -17,1 +17,4 @@ export declare function isIconDefinition(target: any): target is IconDefinition; | ||
} | ||
export declare function generate(node: AbstractNode, key: string, rootProps?: { | ||
[key: string]: any; | ||
} | false): any; |
@@ -0,3 +1,5 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import * as React from 'react'; | ||
export function log(message) { | ||
@@ -9,3 +11,3 @@ if (!(process && process.env && process.env.NODE_ENV === 'production')) { | ||
export function isIconDefinition(target) { | ||
return typeof target === 'object' && target.name && target.width && Array.isArray(target.children) && typeof target.viewBox === 'string'; | ||
return typeof target === 'object' && target.name && typeof target.attrs === 'object' && Array.isArray(target.children); | ||
} | ||
@@ -69,2 +71,14 @@ export function normalizeAttrs() { | ||
return MiniMap; | ||
}(); | ||
}(); | ||
export function generate(node, key, rootProps) { | ||
if (!rootProps) { | ||
return React.createElement(node.tag, _extends({ key: key }, normalizeAttrs(node.attrs)), node.children.map(function (child, index) { | ||
return generate(child, key + '-' + node.tag + '-' + index); | ||
})); | ||
} | ||
return React.createElement(node.tag, _extends({ | ||
key: key | ||
}, normalizeAttrs(node.attrs), rootProps), node.children.map(function (child, index) { | ||
return generate(child, key + '-' + node.tag + '-' + index); | ||
})); | ||
} |
@@ -16,4 +16,4 @@ import { IconDefinition } from '@ant-design/icons'; | ||
static get(key: string): IconDefinition | undefined; | ||
render(): JSX.Element | null; | ||
render(): any; | ||
} | ||
export default Icon; |
@@ -7,14 +7,6 @@ 'use strict'; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _defineProperty3 = _interopRequireDefault(_defineProperty2); | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties'); | ||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
@@ -57,5 +49,9 @@ | ||
value: function render() { | ||
var _generate; | ||
var _props = this.props, | ||
type = _props.type, | ||
rest = (0, _objectWithoutProperties3['default'])(_props, ['type']); | ||
className = _props.className, | ||
onClick = _props.onClick, | ||
style = _props.style; | ||
@@ -76,23 +72,7 @@ var target = void 0; | ||
} | ||
var children = []; | ||
if (target.style) { | ||
children.push(React.createElement( | ||
'style', | ||
{ key: target.name + '-style' }, | ||
target.style | ||
)); | ||
} | ||
children.push.apply(children, (0, _toConsumableArray3['default'])(target.children.map(function (_ref, index) { | ||
var tag = _ref.tag, | ||
attrs = _ref.attrs; | ||
return React.createElement(tag, (0, _extends3['default'])({}, (0, _utils.normalizeAttrs)(attrs), { | ||
key: tag + '-' + index | ||
})); | ||
}))); | ||
return React.createElement( | ||
'svg', | ||
(0, _extends3['default'])({}, rest, { 'data-icon': target.name, viewBox: '0 0 ' + target.width + ' ' + target.height, width: '1em', height: '1em', fill: 'currentColor', 'aria-hidden': 'true' }), | ||
children | ||
); | ||
return (0, _utils.generate)(target, 'svg-' + target.name, (_generate = { | ||
className: className, | ||
onClick: onClick, | ||
style: style | ||
}, (0, _defineProperty3['default'])(_generate, 'data-icon', target.name), (0, _defineProperty3['default'])(_generate, 'width', '1em'), (0, _defineProperty3['default'])(_generate, 'height', '1em'), (0, _defineProperty3['default'])(_generate, 'fill', 'currentColor'), (0, _defineProperty3['default'])(_generate, 'aria-hidden', 'true'), _generate)); | ||
} | ||
@@ -99,0 +79,0 @@ }], [{ |
@@ -1,2 +0,2 @@ | ||
import { IconDefinition } from '@ant-design/icons'; | ||
import { AbstractNode, IconDefinition } from '@ant-design/icons'; | ||
export declare function log(message: string): void; | ||
@@ -17,1 +17,4 @@ export declare function isIconDefinition(target: any): target is IconDefinition; | ||
} | ||
export declare function generate(node: AbstractNode, key: string, rootProps?: { | ||
[key: string]: any; | ||
} | false): any; |
@@ -8,2 +8,6 @@ 'use strict'; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
@@ -20,3 +24,10 @@ | ||
exports.normalizeAttrs = normalizeAttrs; | ||
exports.generate = generate; | ||
var _react = require('react'); | ||
var React = _interopRequireWildcard(_react); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
@@ -30,3 +41,3 @@ | ||
function isIconDefinition(target) { | ||
return typeof target === 'object' && target.name && target.width && Array.isArray(target.children) && typeof target.viewBox === 'string'; | ||
return typeof target === 'object' && target.name && typeof target.attrs === 'object' && Array.isArray(target.children); | ||
} | ||
@@ -90,2 +101,15 @@ function normalizeAttrs() { | ||
return MiniMap; | ||
}(); | ||
}(); | ||
function generate(node, key, rootProps) { | ||
if (!rootProps) { | ||
return React.createElement(node.tag, (0, _extends3['default'])({ key: key }, normalizeAttrs(node.attrs)), node.children.map(function (child, index) { | ||
return generate(child, key + '-' + node.tag + '-' + index); | ||
})); | ||
} | ||
return React.createElement(node.tag, (0, _extends3['default'])({ | ||
key: key | ||
}, normalizeAttrs(node.attrs), rootProps), node.children.map(function (child, index) { | ||
return generate(child, key + '-' + node.tag + '-' + index); | ||
})); | ||
} |
{ | ||
"name": "@ant-design/icons-react", | ||
"version": "0.3.0-beta.2", | ||
"version": "0.3.0-beta.3", | ||
"main": "./lib/index.js", | ||
@@ -26,4 +26,4 @@ "module": "./es/index.js", | ||
"peerDependencies": { | ||
"react": "16.x", | ||
"@ant-design/icons-react": "^0.3.0-beta.1" | ||
"@ant-design/icons-react": "^0.3.0-beta.1", | ||
"react": "16.x" | ||
}, | ||
@@ -34,3 +34,3 @@ "devDependencies": { | ||
"@types/node": "^10.5.5", | ||
"@types/react": "^16.4.7", | ||
"@types/react": "^16.4.12", | ||
"@types/react-dom": "^16.0.6", | ||
@@ -41,3 +41,3 @@ "@types/react-test-renderer": "^16.0.1", | ||
"jest": "^23.4.2", | ||
"rc-tools": "^8.1.5", | ||
"rc-tools": "^8.1.6", | ||
"react": "^16.4.2", | ||
@@ -44,0 +44,0 @@ "react-dom": "^16.4.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18219
407