tntd 2.7.33 → 2.8.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/icon/IconFont.js +52 -0
- package/es/icon/IconFont.js.map +1 -0
- package/es/icon/components/Icon.js +106 -0
- package/es/icon/components/Icon.js.map +1 -0
- package/es/icon/components/index.js +1 -0
- package/es/icon/components/index.js.map +1 -0
- package/es/icon/components/utils.js +79 -0
- package/es/icon/components/utils.js.map +1 -0
- package/es/icon/index.js +114 -3
- package/es/icon/index.js.map +1 -1
- package/es/icon/twoTonePrimaryColor.js +10 -0
- package/es/icon/twoTonePrimaryColor.js.map +1 -0
- package/es/icon/utils.js +64 -0
- package/es/icon/utils.js.map +1 -0
- package/lib/icon/IconFont.d.ts +10 -0
- package/lib/icon/IconFont.d.ts.map +1 -0
- package/lib/icon/IconFont.js +62 -0
- package/lib/icon/IconFont.js.map +1 -0
- package/lib/icon/components/Icon.d.ts +31 -0
- package/lib/icon/components/Icon.d.ts.map +1 -0
- package/lib/icon/components/Icon.js +149 -0
- package/lib/icon/components/Icon.js.map +1 -0
- package/lib/icon/components/index.d.ts +2 -0
- package/lib/icon/components/index.d.ts.map +1 -0
- package/lib/icon/components/index.js +13 -0
- package/lib/icon/components/index.js.map +1 -0
- package/lib/icon/components/utils.d.ts +22 -0
- package/lib/icon/components/utils.d.ts.map +1 -0
- package/lib/icon/components/utils.js +120 -0
- package/lib/icon/components/utils.js.map +1 -0
- package/lib/icon/index.d.ts +45 -3
- package/lib/icon/index.d.ts.map +1 -1
- package/lib/icon/index.js +121 -15
- package/lib/icon/index.js.map +1 -1
- package/lib/icon/twoTonePrimaryColor.d.ts +3 -0
- package/lib/icon/twoTonePrimaryColor.d.ts.map +1 -0
- package/lib/icon/twoTonePrimaryColor.js +18 -0
- package/lib/icon/twoTonePrimaryColor.js.map +1 -0
- package/lib/icon/utils.d.ts +13 -0
- package/lib/icon/utils.d.ts.map +1 -0
- package/lib/icon/utils.js +76 -0
- package/lib/icon/utils.js.map +1 -0
- package/lib/segmented/index.d.ts +1 -1
- package/lib/svg-components/illustration-403.d.ts +1 -1
- package/lib/svg-components/illustration-404.d.ts +1 -1
- package/lib/svg-components/illustration-500.d.ts +1 -1
- package/lib/svg-components/illustration-empty.d.ts +1 -1
- package/lib/svg-components/illustration-failure.d.ts +1 -1
- package/lib/svg-components/illustration-no-access.d.ts +1 -1
- package/lib/svg-components/illustration-no-chart.d.ts +1 -1
- package/lib/svg-components/illustration-no-result.d.ts +1 -1
- package/lib/svg-components/illustration-offline.d.ts +1 -1
- package/lib/svg-components/illustration-success.d.ts +1 -1
- package/lib/table/assets/image-loading-background.d.ts +1 -1
- package/lib/table/assets/image-loading.d.ts +1 -1
- package/package.json +106 -105
- package/es/tntd-form/_util/context.js +0 -12
- package/es/tntd-form/_util/context.js.map +0 -1
- package/es/tntd-form/_util/defaultRenderEmpty.js +0 -31
- package/es/tntd-form/_util/defaultRenderEmpty.js.map +0 -1
- package/es/tntd-form/_util/hooks/useFlexGapSupport.js +0 -9
- package/es/tntd-form/_util/hooks/useFlexGapSupport.js.map +0 -1
- package/es/tntd-form/_util/hooks/useForceUpdate.js +0 -5
- package/es/tntd-form/_util/hooks/useForceUpdate.js.map +0 -1
- package/es/tntd-form/_util/motion.js +0 -47
- package/es/tntd-form/_util/motion.js.map +0 -1
- package/es/tntd-form/_util/reactNode.js +0 -16
- package/es/tntd-form/_util/reactNode.js.map +0 -1
- package/es/tntd-form/_util/responsiveObserve.js +0 -59
- package/es/tntd-form/_util/responsiveObserve.js.map +0 -1
- package/es/tntd-form/_util/scrollTo.js +0 -35
- package/es/tntd-form/_util/scrollTo.js.map +0 -1
- package/es/tntd-form/_util/styleChecker.js +0 -26
- package/es/tntd-form/_util/styleChecker.js.map +0 -1
- package/es/tntd-form/_util/type.js +0 -3
- package/es/tntd-form/_util/type.js.map +0 -1
- package/es/tntd-form/_util/warning.js +0 -5
- package/es/tntd-form/_util/warning.js.map +0 -1
- package/es/tntd-form/_util/wave.js +0 -168
- package/es/tntd-form/_util/wave.js.map +0 -1
- package/es/tntd-form/grid/RowContext.js +0 -3
- package/es/tntd-form/grid/RowContext.js.map +0 -1
- package/es/tntd-form/grid/col.js +0 -104
- package/es/tntd-form/grid/col.js.map +0 -1
- package/es/tntd-form/grid/hooks/useBreakpoint.js +0 -18
- package/es/tntd-form/grid/hooks/useBreakpoint.js.map +0 -1
- package/es/tntd-form/grid/index.js +0 -14
- package/es/tntd-form/grid/index.js.map +0 -1
- package/es/tntd-form/grid/row.js +0 -153
- package/es/tntd-form/grid/row.js.map +0 -1
- package/es/tntd-form/grid/style/index.js +0 -2
- package/es/tntd-form/grid/style/index.js.map +0 -1
- package/es/tntd-form/tntd-form.stories.js +0 -836
- package/es/tntd-form/tntd-form.stories.js.map +0 -1
- package/lib/tntd-form/_util/context.d.ts +0 -42
- package/lib/tntd-form/_util/context.d.ts.map +0 -1
- package/lib/tntd-form/_util/context.js +0 -22
- package/lib/tntd-form/_util/context.js.map +0 -1
- package/lib/tntd-form/_util/defaultRenderEmpty.d.ts +0 -5
- package/lib/tntd-form/_util/defaultRenderEmpty.d.ts.map +0 -1
- package/lib/tntd-form/_util/defaultRenderEmpty.js +0 -44
- package/lib/tntd-form/_util/defaultRenderEmpty.js.map +0 -1
- package/lib/tntd-form/_util/hooks/useFlexGapSupport.d.ts +0 -3
- package/lib/tntd-form/_util/hooks/useFlexGapSupport.d.ts.map +0 -1
- package/lib/tntd-form/_util/hooks/useFlexGapSupport.js +0 -28
- package/lib/tntd-form/_util/hooks/useFlexGapSupport.js.map +0 -1
- package/lib/tntd-form/_util/hooks/useForceUpdate.d.ts +0 -3
- package/lib/tntd-form/_util/hooks/useForceUpdate.d.ts.map +0 -1
- package/lib/tntd-form/_util/hooks/useForceUpdate.js +0 -24
- package/lib/tntd-form/_util/hooks/useForceUpdate.js.map +0 -1
- package/lib/tntd-form/_util/motion.d.ts +0 -9
- package/lib/tntd-form/_util/motion.d.ts.map +0 -1
- package/lib/tntd-form/_util/motion.js +0 -59
- package/lib/tntd-form/_util/motion.js.map +0 -1
- package/lib/tntd-form/_util/reactNode.d.ts +0 -9
- package/lib/tntd-form/_util/reactNode.d.ts.map +0 -1
- package/lib/tntd-form/_util/reactNode.js +0 -27
- package/lib/tntd-form/_util/reactNode.js.map +0 -1
- package/lib/tntd-form/_util/responsiveObserve.d.ts +0 -22
- package/lib/tntd-form/_util/responsiveObserve.d.ts.map +0 -1
- package/lib/tntd-form/_util/responsiveObserve.js +0 -73
- package/lib/tntd-form/_util/responsiveObserve.js.map +0 -1
- package/lib/tntd-form/_util/scrollTo.d.ts +0 -1
- package/lib/tntd-form/_util/scrollTo.d.ts.map +0 -1
- package/lib/tntd-form/_util/scrollTo.js +0 -35
- package/lib/tntd-form/_util/scrollTo.js.map +0 -1
- package/lib/tntd-form/_util/styleChecker.d.ts +0 -5
- package/lib/tntd-form/_util/styleChecker.d.ts.map +0 -1
- package/lib/tntd-form/_util/styleChecker.js +0 -42
- package/lib/tntd-form/_util/styleChecker.js.map +0 -1
- package/lib/tntd-form/_util/type.d.ts +0 -4
- package/lib/tntd-form/_util/type.d.ts.map +0 -1
- package/lib/tntd-form/_util/type.js +0 -21
- package/lib/tntd-form/_util/type.js.map +0 -1
- package/lib/tntd-form/_util/warning.d.ts +0 -5
- package/lib/tntd-form/_util/warning.d.ts.map +0 -1
- package/lib/tntd-form/_util/warning.js +0 -20
- package/lib/tntd-form/_util/warning.js.map +0 -1
- package/lib/tntd-form/_util/wave.d.ts +0 -1
- package/lib/tntd-form/_util/wave.d.ts.map +0 -1
- package/lib/tntd-form/_util/wave.js +0 -168
- package/lib/tntd-form/_util/wave.js.map +0 -1
- package/lib/tntd-form/grid/RowContext.d.ts +0 -9
- package/lib/tntd-form/grid/RowContext.d.ts.map +0 -1
- package/lib/tntd-form/grid/RowContext.js +0 -10
- package/lib/tntd-form/grid/RowContext.js.map +0 -1
- package/lib/tntd-form/grid/col.d.ts +0 -29
- package/lib/tntd-form/grid/col.d.ts.map +0 -1
- package/lib/tntd-form/grid/col.js +0 -105
- package/lib/tntd-form/grid/col.js.map +0 -1
- package/lib/tntd-form/grid/hooks/useBreakpoint.d.ts +0 -4
- package/lib/tntd-form/grid/hooks/useBreakpoint.d.ts.map +0 -1
- package/lib/tntd-form/grid/hooks/useBreakpoint.js +0 -29
- package/lib/tntd-form/grid/hooks/useBreakpoint.js.map +0 -1
- package/lib/tntd-form/grid/index.d.ts +0 -12
- package/lib/tntd-form/grid/index.d.ts.map +0 -1
- package/lib/tntd-form/grid/index.js +0 -31
- package/lib/tntd-form/grid/index.js.map +0 -1
- package/lib/tntd-form/grid/row.d.ts +0 -21
- package/lib/tntd-form/grid/row.d.ts.map +0 -1
- package/lib/tntd-form/grid/row.js +0 -186
- package/lib/tntd-form/grid/row.js.map +0 -1
- package/lib/tntd-form/grid/style/index.d.ts +0 -3
- package/lib/tntd-form/grid/style/index.d.ts.map +0 -1
- package/lib/tntd-form/grid/style/index.js +0 -4
- package/lib/tntd-form/grid/style/index.js.map +0 -1
- package/lib/tntd-form/tntd-form.stories.d.ts +0 -33
- package/lib/tntd-form/tntd-form.stories.d.ts.map +0 -1
- package/lib/tntd-form/tntd-form.stories.js +0 -943
- package/lib/tntd-form/tntd-form.stories.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
22
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
24
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) {
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
29
|
+
}
|
|
30
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
32
|
+
}
|
|
33
|
+
return t;
|
|
34
|
+
};
|
|
35
|
+
var twoToneColorPalette = {
|
|
36
|
+
primaryColor: '#333',
|
|
37
|
+
secondaryColor: '#E6E6E6'
|
|
38
|
+
};
|
|
39
|
+
var Icon = /*#__PURE__*/function (_React$Component) {
|
|
40
|
+
_inherits(Icon, _React$Component);
|
|
41
|
+
var _super = _createSuper(Icon);
|
|
42
|
+
function Icon() {
|
|
43
|
+
_classCallCheck(this, Icon);
|
|
44
|
+
return _super.apply(this, arguments);
|
|
45
|
+
}
|
|
46
|
+
_createClass(Icon, [{
|
|
47
|
+
key: "render",
|
|
48
|
+
value: function render() {
|
|
49
|
+
var _Object$assign;
|
|
50
|
+
var _a = this.props,
|
|
51
|
+
type = _a.type,
|
|
52
|
+
className = _a.className,
|
|
53
|
+
onClick = _a.onClick,
|
|
54
|
+
style = _a.style,
|
|
55
|
+
primaryColor = _a.primaryColor,
|
|
56
|
+
secondaryColor = _a.secondaryColor,
|
|
57
|
+
rest = __rest(_a, ["type", "className", "onClick", "style", "primaryColor", "secondaryColor"]);
|
|
58
|
+
var target;
|
|
59
|
+
var colors = twoToneColorPalette;
|
|
60
|
+
if (primaryColor) {
|
|
61
|
+
colors = {
|
|
62
|
+
primaryColor: primaryColor,
|
|
63
|
+
secondaryColor: secondaryColor || (0, _utils.getSecondaryColor)(primaryColor)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if ((0, _utils.isIconDefinition)(type)) {
|
|
67
|
+
target = type;
|
|
68
|
+
} else if (typeof type === 'string') {
|
|
69
|
+
target = Icon.get(type, colors);
|
|
70
|
+
if (!target) {
|
|
71
|
+
// log(`Could not find icon: ${type}`);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!target) {
|
|
76
|
+
(0, _utils.log)("type should be string or icon definiton, but got ".concat(type));
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (target && typeof target.icon === 'function') {
|
|
80
|
+
target = Object.assign(Object.assign({}, target), {
|
|
81
|
+
icon: target.icon(colors.primaryColor, colors.secondaryColor)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return (0, _utils.generate)(target.icon, "svg-".concat(target.name), Object.assign((_Object$assign = {
|
|
85
|
+
className: className,
|
|
86
|
+
onClick: onClick,
|
|
87
|
+
style: style
|
|
88
|
+
}, _defineProperty(_Object$assign, 'data-icon', target.name), _defineProperty(_Object$assign, "width", '1em'), _defineProperty(_Object$assign, "height", '1em'), _defineProperty(_Object$assign, "fill", 'currentColor'), _defineProperty(_Object$assign, 'aria-hidden', 'true'), _Object$assign), rest));
|
|
89
|
+
}
|
|
90
|
+
}], [{
|
|
91
|
+
key: "add",
|
|
92
|
+
value: function add() {
|
|
93
|
+
var _this = this;
|
|
94
|
+
for (var _len = arguments.length, icons = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
95
|
+
icons[_key] = arguments[_key];
|
|
96
|
+
}
|
|
97
|
+
icons.forEach(function (icon) {
|
|
98
|
+
_this.definitions.set((0, _utils.withSuffix)(icon.name, icon.theme), icon);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "clear",
|
|
103
|
+
value: function clear() {
|
|
104
|
+
this.definitions.clear();
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "get",
|
|
108
|
+
value: function get(key) {
|
|
109
|
+
var colors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : twoToneColorPalette;
|
|
110
|
+
if (key) {
|
|
111
|
+
var target = this.definitions.get(key);
|
|
112
|
+
if (target && typeof target.icon === 'function') {
|
|
113
|
+
target = Object.assign(Object.assign({}, target), {
|
|
114
|
+
icon: target.icon(colors.primaryColor, colors.secondaryColor)
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "setTwoToneColors",
|
|
122
|
+
value: function setTwoToneColors(_ref) {
|
|
123
|
+
var primaryColor = _ref.primaryColor,
|
|
124
|
+
secondaryColor = _ref.secondaryColor;
|
|
125
|
+
twoToneColorPalette.primaryColor = primaryColor;
|
|
126
|
+
twoToneColorPalette.secondaryColor = secondaryColor || (0, _utils.getSecondaryColor)(primaryColor);
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "getTwoToneColors",
|
|
130
|
+
value: function getTwoToneColors() {
|
|
131
|
+
return Object.assign({}, twoToneColorPalette);
|
|
132
|
+
}
|
|
133
|
+
}]);
|
|
134
|
+
return Icon;
|
|
135
|
+
}(React.Component);
|
|
136
|
+
Object.defineProperty(Icon, "displayName", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
writable: true,
|
|
140
|
+
value: 'IconReact'
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(Icon, "definitions", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: new _utils.MiniMap()
|
|
147
|
+
});
|
|
148
|
+
var _default = Icon;
|
|
149
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/icon/components/Icon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;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P,CAAA;IACJ,CAAC;;AA5EM;;;;WAAc,WAAW;GAAA;AAChC;;;;WAAqB,IAAI,eAAO,EAAkB;GAAA;AA8EpD,kBAAe,IAAI,CAAA","sourcesContent":["import type { AbstractNode, IconDefinition } from '@tntd/icons/lib/types'\nimport * as React from 'react'\nimport { generate, getSecondaryColor, isIconDefinition, log, MiniMap, withSuffix } from './utils'\n\nexport interface IconProps {\n type: string | IconDefinition\n className?: string\n onClick?: React.MouseEventHandler<SVGSVGElement>\n style?: React.CSSProperties\n primaryColor?: string // only for two-tone\n secondaryColor?: string // only for two-tone\n focusable?: string\n}\n\nexport interface TwoToneColorPaletteSetter {\n primaryColor: string\n secondaryColor?: string\n}\n\nexport interface TwoToneColorPalette extends TwoToneColorPaletteSetter {\n secondaryColor: string\n}\n\nconst twoToneColorPalette: TwoToneColorPalette = {\n primaryColor: '#333',\n secondaryColor: '#E6E6E6',\n}\n\nclass Icon extends React.Component<IconProps> {\n static displayName = 'IconReact'\n static definitions = new MiniMap<IconDefinition>()\n static add(...icons: IconDefinition[]) {\n icons.forEach((icon) => {\n this.definitions.set(withSuffix(icon.name, icon.theme), icon)\n })\n }\n static clear() {\n this.definitions.clear()\n }\n\n static get(key?: string, colors: TwoToneColorPalette = twoToneColorPalette) {\n if (key) {\n let target = this.definitions.get(key)\n if (target && typeof target.icon === 'function') {\n target = {\n ...target,\n icon: target.icon(colors.primaryColor, colors.secondaryColor),\n }\n }\n return target\n }\n }\n\n static setTwoToneColors({ primaryColor, secondaryColor }: TwoToneColorPaletteSetter) {\n twoToneColorPalette.primaryColor = primaryColor\n twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor)\n }\n\n static getTwoToneColors(): TwoToneColorPalette {\n return {\n ...twoToneColorPalette,\n }\n }\n\n render() {\n const { type, className, onClick, style, primaryColor, secondaryColor, ...rest } = this.props\n\n let target: IconDefinition | undefined\n let colors: TwoToneColorPalette = twoToneColorPalette\n if (primaryColor) {\n colors = {\n primaryColor,\n secondaryColor: secondaryColor || getSecondaryColor(primaryColor),\n }\n }\n if (isIconDefinition(type)) {\n target = type\n } else if (typeof type === 'string') {\n target = Icon.get(type, colors)\n if (!target) {\n // log(`Could not find icon: ${type}`);\n return null\n }\n }\n if (!target) {\n log(`type should be string or icon definiton, but got ${type}`)\n return null\n }\n if (target && typeof target.icon === 'function') {\n target = {\n ...target,\n icon: target.icon(colors.primaryColor, colors.secondaryColor),\n }\n }\n return generate(target.icon as AbstractNode, `svg-${target.name}`, {\n className,\n onClick,\n style,\n ['data-icon']: target.name,\n width: '1em',\n height: '1em',\n fill: 'currentColor',\n ['aria-hidden']: 'true',\n ...rest,\n })\n }\n}\n\nexport default Icon\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/icon/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Icon["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/icon/components/index.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA2F;AAAlF,gHAAA,OAAO,OAAA","sourcesContent":["export { default, IconProps, TwoToneColorPaletteSetter, TwoToneColorPalette } from './Icon'\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AbstractNode, IconDefinition } from '@tntd/icons/lib/types';
|
|
2
|
+
export declare function log(message: string): void;
|
|
3
|
+
export declare function isIconDefinition(target: any): target is IconDefinition;
|
|
4
|
+
export declare function normalizeAttrs(attrs?: Attrs): Attrs;
|
|
5
|
+
export interface Attrs {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class MiniMap<V> {
|
|
9
|
+
get size(): number;
|
|
10
|
+
private collection;
|
|
11
|
+
clear(): void;
|
|
12
|
+
delete(key: string): boolean;
|
|
13
|
+
get(key: string): V | undefined;
|
|
14
|
+
has(key: string): boolean;
|
|
15
|
+
set(key: string, value: V): this;
|
|
16
|
+
}
|
|
17
|
+
export declare function generate(node: AbstractNode, key: string, rootProps?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
} | false): any;
|
|
20
|
+
export declare function getSecondaryColor(primaryColor: string): string;
|
|
21
|
+
export declare function withSuffix(name: string, theme: 'fill' | 'outline' | 'twotone'): string;
|
|
22
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/icon/components/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAIzE,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,QAIlC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,cAAc,CAOtE;AAED,wBAAgB,cAAc,CAAC,KAAK,GAAE,KAAU,GAAG,KAAK,CAavD;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,qBAAa,OAAO,CAAC,CAAC;IACpB,IAAI,IAAI,WAEP;IACD,OAAO,CAAC,UAAU,CAA2B;IAC7C,KAAK,IAAI,IAAI;IAGb,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAG5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAG/B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAGzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;CAIjC;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,KAAK,GACzC,GAAG,CAqBL;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,UAW7E"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MiniMap = void 0;
|
|
7
|
+
exports.generate = generate;
|
|
8
|
+
exports.getSecondaryColor = getSecondaryColor;
|
|
9
|
+
exports.isIconDefinition = isIconDefinition;
|
|
10
|
+
exports.log = log;
|
|
11
|
+
exports.normalizeAttrs = normalizeAttrs;
|
|
12
|
+
exports.withSuffix = withSuffix;
|
|
13
|
+
var _colors = require("@ant-design/colors");
|
|
14
|
+
var React = _interopRequireWildcard(require("react"));
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
23
|
+
function log(message) {
|
|
24
|
+
if (!(process && process.env && process.env.NODE_ENV === 'production')) {
|
|
25
|
+
console.error("[@ant-design/icons-react]: ".concat(message, "."));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function isIconDefinition(target) {
|
|
29
|
+
return _typeof(target) === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (_typeof(target.icon) === 'object' || typeof target.icon === 'function');
|
|
30
|
+
}
|
|
31
|
+
function normalizeAttrs() {
|
|
32
|
+
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
33
|
+
return Object.keys(attrs).reduce(function (acc, key) {
|
|
34
|
+
var val = attrs[key];
|
|
35
|
+
switch (key) {
|
|
36
|
+
case 'class':
|
|
37
|
+
acc.className = val;
|
|
38
|
+
delete acc["class"];
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
acc[key] = val;
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
45
|
+
}
|
|
46
|
+
var MiniMap = /*#__PURE__*/function () {
|
|
47
|
+
function MiniMap() {
|
|
48
|
+
_classCallCheck(this, MiniMap);
|
|
49
|
+
Object.defineProperty(this, "collection", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: {}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
_createClass(MiniMap, [{
|
|
57
|
+
key: "size",
|
|
58
|
+
get: function get() {
|
|
59
|
+
return Object.keys(this.collection).length;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "clear",
|
|
63
|
+
value: function clear() {
|
|
64
|
+
this.collection = {};
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "delete",
|
|
68
|
+
value: function _delete(key) {
|
|
69
|
+
return delete this.collection[key];
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "get",
|
|
73
|
+
value: function get(key) {
|
|
74
|
+
return this.collection[key];
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "has",
|
|
78
|
+
value: function has(key) {
|
|
79
|
+
return Boolean(this.collection[key]);
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "set",
|
|
83
|
+
value: function set(key, value) {
|
|
84
|
+
this.collection[key] = value;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
}]);
|
|
88
|
+
return MiniMap;
|
|
89
|
+
}();
|
|
90
|
+
exports.MiniMap = MiniMap;
|
|
91
|
+
function generate(node, key, rootProps) {
|
|
92
|
+
if (!rootProps) {
|
|
93
|
+
return React.createElement(node.tag, Object.assign({
|
|
94
|
+
key: key
|
|
95
|
+
}, normalizeAttrs(node.attrs)), (node.children || []).map(function (child, index) {
|
|
96
|
+
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
return React.createElement(node.tag, Object.assign(Object.assign({
|
|
100
|
+
key: key
|
|
101
|
+
}, normalizeAttrs(node.attrs)), rootProps), (node.children || []).map(function (child, index) {
|
|
102
|
+
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
function getSecondaryColor(primaryColor) {
|
|
106
|
+
// choose the second color
|
|
107
|
+
return (0, _colors.generate)(primaryColor)[0];
|
|
108
|
+
}
|
|
109
|
+
function withSuffix(name, theme) {
|
|
110
|
+
switch (theme) {
|
|
111
|
+
case 'fill':
|
|
112
|
+
return "".concat(name, "-fill");
|
|
113
|
+
case 'outline':
|
|
114
|
+
return "".concat(name, "-o");
|
|
115
|
+
case 'twotone':
|
|
116
|
+
return "".concat(name, "-twotone");
|
|
117
|
+
default:
|
|
118
|
+
throw new TypeError("Unknown theme type: ".concat(theme, ", name: ").concat(name));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
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AE,CACtD,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC,CAC/C,CACF,CAAA;AACH,CAAC;AAzBD,4BAyBC;AAED,SAAgB,iBAAiB,CAAC,YAAoB;IACpD,0BAA0B;IAC1B,OAAO,IAAA,iBAAa,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC;AAHD,8CAGC;AAED,SAAgB,UAAU,CAAC,IAAY,EAAE,KAAqC;IAC5E,QAAQ,KAAK,EAAE;QACb,KAAK,MAAM;YACT,OAAO,GAAG,IAAI,OAAO,CAAA;QACvB,KAAK,SAAS;YACZ,OAAO,GAAG,IAAI,IAAI,CAAA;QACpB,KAAK,SAAS;YACZ,OAAO,GAAG,IAAI,UAAU,CAAA;QAC1B;YACE,MAAM,IAAI,SAAS,CAAC,uBAAuB,KAAK,WAAW,IAAI,EAAE,CAAC,CAAA;KACrE;AACH,CAAC;AAXD,gCAWC","sourcesContent":["// @ts-nocheck\nimport type { AbstractNode, IconDefinition } from '@tntd/icons/lib/types'\nimport { generate as generateColor } from '@ant-design/colors'\nimport * as React from 'react'\n\nexport function log(message: string) {\n if (!(process && process.env && process.env.NODE_ENV === 'production')) {\n console.error(`[@ant-design/icons-react]: ${message}.`)\n }\n}\n\nexport function isIconDefinition(target: any): target is IconDefinition {\n return (\n typeof target === 'object' &&\n typeof target.name === 'string' &&\n typeof target.theme === 'string' &&\n (typeof target.icon === 'object' || typeof target.icon === 'function')\n )\n}\n\nexport function normalizeAttrs(attrs: Attrs = {}): Attrs {\n return Object.keys(attrs).reduce((acc: Attrs, key) => {\n const val = attrs[key]\n switch (key) {\n case 'class':\n acc.className = val\n delete acc.class\n break\n default:\n acc[key] = val\n }\n return acc\n }, {})\n}\n\nexport interface Attrs {\n [key: string]: string\n}\n\nexport class MiniMap<V> {\n get size() {\n return Object.keys(this.collection).length\n }\n private collection: { [key: string]: V } = {}\n clear(): void {\n this.collection = {}\n }\n delete(key: string): boolean {\n return delete this.collection[key]\n }\n get(key: string): V | undefined {\n return this.collection[key]\n }\n has(key: string): boolean {\n return Boolean(this.collection[key])\n }\n set(key: string, value: V): this {\n this.collection[key] = value\n return this\n }\n}\n\nexport function generate(\n node: AbstractNode,\n key: string,\n rootProps?: { [key: string]: any } | false\n): any {\n if (!rootProps) {\n return React.createElement(\n node.tag,\n { key, ...normalizeAttrs(node.attrs) },\n (node.children || []).map((child: any, index: any) =>\n generate(child, `${key}-${node.tag}-${index}`)\n )\n )\n }\n return React.createElement(\n node.tag,\n {\n key,\n ...normalizeAttrs(node.attrs),\n ...rootProps,\n },\n (node.children || []).map((child: any, index: number) =>\n generate(child, `${key}-${node.tag}-${index}`)\n )\n )\n}\n\nexport function getSecondaryColor(primaryColor: string): string {\n // choose the second color\n return generateColor(primaryColor)[0]\n}\n\nexport function withSuffix(name: string, theme: 'fill' | 'outline' | 'twotone') {\n switch (theme) {\n case 'fill':\n return `${name}-fill`\n case 'outline':\n return `${name}-o`\n case 'twotone':\n return `${name}-twotone`\n default:\n throw new TypeError(`Unknown theme type: ${theme}, name: ${name}`)\n }\n}\n"]}
|
package/lib/icon/index.d.ts
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import '
|
|
3
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import createFromIconfontCN from './IconFont';
|
|
3
|
+
import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
|
|
4
|
+
declare function unstable_ChangeThemeOfIconsDangerously(theme?: ThemeType): void;
|
|
5
|
+
declare function unstable_ChangeDefaultThemeOfIcons(theme: ThemeType): void;
|
|
6
|
+
export interface TransferLocale {
|
|
7
|
+
icon: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CustomIconComponentProps {
|
|
10
|
+
width: string | number;
|
|
11
|
+
height: string | number;
|
|
12
|
+
fill: string;
|
|
13
|
+
viewBox?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
spin?: boolean;
|
|
17
|
+
rotate?: number;
|
|
18
|
+
['aria-hidden']?: React.AriaAttributes['aria-hidden'];
|
|
19
|
+
}
|
|
20
|
+
export declare type ThemeType = 'filled' | 'outlined' | 'twoTone';
|
|
21
|
+
export interface IconProps {
|
|
22
|
+
tabIndex?: number;
|
|
23
|
+
type?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
theme?: ThemeType;
|
|
26
|
+
title?: string;
|
|
27
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
|
|
28
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
29
|
+
component?: React.ComponentType<CustomIconComponentProps | React.SVGProps<SVGSVGElement>>;
|
|
30
|
+
twoToneColor?: string;
|
|
31
|
+
viewBox?: string;
|
|
32
|
+
spin?: boolean;
|
|
33
|
+
rotate?: number;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
prefixCls?: string;
|
|
36
|
+
role?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface IconComponent<P> extends React.SFC<P> {
|
|
39
|
+
createFromIconfontCN: typeof createFromIconfontCN;
|
|
40
|
+
getTwoToneColor: typeof getTwoToneColor;
|
|
41
|
+
setTwoToneColor: typeof setTwoToneColor;
|
|
42
|
+
unstable_ChangeThemeOfIconsDangerously?: typeof unstable_ChangeThemeOfIconsDangerously;
|
|
43
|
+
unstable_ChangeDefaultThemeOfIcons?: typeof unstable_ChangeDefaultThemeOfIcons;
|
|
44
|
+
}
|
|
45
|
+
declare const Icon: IconComponent<IconProps>;
|
|
4
46
|
export default Icon;
|
|
5
47
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/icon/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/icon/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/icon/index.tsx"],"names":[],"mappings":"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AC,CAAC,CAAA;IACzF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,oBAAoB,EAAE,OAAO,oBAAoB,CAAA;IACjD,eAAe,EAAE,OAAO,eAAe,CAAA;IACvC,eAAe,EAAE,OAAO,eAAe,CAAA;IACvC,sCAAsC,CAAC,EAAE,OAAO,sCAAsC,CAAA;IACtF,kCAAkC,CAAC,EAAE,OAAO,kCAAkC,CAAA;CAC/E;AAED,QAAA,MAAM,IAAI,EAAE,aAAa,CAAC,SAAS,CAmIlC,CAAA;AAMD,eAAe,IAAI,CAAA"}
|
package/lib/icon/index.js
CHANGED
|
@@ -4,22 +4,128 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
var _exportNames = {};
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
require("antd/lib/icon/style");
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var allIcons = _interopRequireWildcard(require("@tntd/icons/lib/dist"));
|
|
11
|
+
var _components = _interopRequireDefault(require("./components"));
|
|
12
|
+
var _IconFont = _interopRequireDefault(require("./IconFont"));
|
|
13
|
+
var _utils = require("./utils");
|
|
14
|
+
var _warning = _interopRequireDefault(require("../_util/warning"));
|
|
15
|
+
var _LocaleReceiver = _interopRequireDefault(require("antd/lib/locale-provider/LocaleReceiver"));
|
|
16
|
+
var _twoTonePrimaryColor = require("./twoTonePrimaryColor");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
-
|
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
24
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
27
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
30
|
+
var t = {};
|
|
31
|
+
for (var p in s) {
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
33
|
+
}
|
|
34
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
35
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
};
|
|
39
|
+
/* eslint-disable camelcase */
|
|
40
|
+
|
|
41
|
+
// Initial setting
|
|
42
|
+
_components["default"].add.apply(_components["default"], _toConsumableArray(Object.keys(allIcons).map(function (key) {
|
|
43
|
+
return allIcons[key];
|
|
44
|
+
})));
|
|
45
|
+
(0, _twoTonePrimaryColor.setTwoToneColor)('#1890ff');
|
|
46
|
+
var defaultTheme = 'outlined';
|
|
47
|
+
var dangerousTheme;
|
|
48
|
+
function unstable_ChangeThemeOfIconsDangerously(theme) {
|
|
49
|
+
(0, _warning["default"])(false, 'Icon', "You are using the unstable method 'Icon.unstable_ChangeThemeOfAllIconsDangerously', " + "make sure that all the icons with theme '".concat(theme, "' display correctly."));
|
|
50
|
+
dangerousTheme = theme;
|
|
51
|
+
}
|
|
52
|
+
function unstable_ChangeDefaultThemeOfIcons(theme) {
|
|
53
|
+
(0, _warning["default"])(false, 'Icon', "You are using the unstable method 'Icon.unstable_ChangeDefaultThemeOfIcons', " + "make sure that all the icons with theme '".concat(theme, "' display correctly."));
|
|
54
|
+
defaultTheme = theme;
|
|
55
|
+
}
|
|
56
|
+
var Icon = function Icon(props) {
|
|
57
|
+
var _classNames;
|
|
58
|
+
var className = props.className,
|
|
59
|
+
type = props.type,
|
|
60
|
+
Component = props.component,
|
|
61
|
+
viewBox = props.viewBox,
|
|
62
|
+
spin = props.spin,
|
|
63
|
+
rotate = props.rotate,
|
|
64
|
+
tabIndex = props.tabIndex,
|
|
65
|
+
onClick = props.onClick,
|
|
66
|
+
children = props.children,
|
|
67
|
+
theme = props.theme,
|
|
68
|
+
twoToneColor = props.twoToneColor,
|
|
69
|
+
restProps = __rest(props, ["className", "type", "component", "viewBox", "spin", "rotate", "tabIndex", "onClick", "children", "theme", "twoToneColor"]);
|
|
70
|
+
(0, _warning["default"])(Boolean(type || Component || children), 'Icon', 'Should have `type` prop or `component` prop or `children`.');
|
|
71
|
+
var classString = (0, _classnames["default"])((_classNames = {}, _defineProperty(_classNames, "anticon", true), _defineProperty(_classNames, "anticon-".concat(type), Boolean(type)), _classNames), className);
|
|
72
|
+
var svgClassString = (0, _classnames["default"])(_defineProperty({}, "anticon-spin", !!spin || type === 'loading'));
|
|
73
|
+
var svgStyle = rotate ? {
|
|
74
|
+
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
75
|
+
transform: "rotate(".concat(rotate, "deg)")
|
|
76
|
+
} : undefined;
|
|
77
|
+
var innerSvgProps = Object.assign(Object.assign({}, _utils.svgBaseProps), {
|
|
78
|
+
className: svgClassString,
|
|
79
|
+
style: svgStyle,
|
|
80
|
+
viewBox: viewBox
|
|
81
|
+
});
|
|
82
|
+
if (!viewBox) {
|
|
83
|
+
delete innerSvgProps.viewBox;
|
|
84
|
+
}
|
|
85
|
+
var renderInnerNode = function renderInnerNode() {
|
|
86
|
+
// component > children > type
|
|
87
|
+
if (Component) {
|
|
88
|
+
return React.createElement(Component, Object.assign({}, innerSvgProps), children);
|
|
89
|
+
}
|
|
90
|
+
if (children) {
|
|
91
|
+
(0, _warning["default"])(Boolean(viewBox) || React.Children.count(children) === 1 && React.isValidElement(children) && React.Children.only(children).type === 'use', 'Icon', 'Make sure that you provide correct `viewBox`' + ' prop (default `0 0 1024 1024`) to the icon.');
|
|
92
|
+
return React.createElement("svg", Object.assign({}, innerSvgProps, {
|
|
93
|
+
viewBox: viewBox
|
|
94
|
+
}), children);
|
|
95
|
+
}
|
|
96
|
+
if (typeof type === 'string') {
|
|
97
|
+
var computedType = type;
|
|
98
|
+
if (theme) {
|
|
99
|
+
var themeInName = (0, _utils.getThemeFromTypeName)(type);
|
|
100
|
+
(0, _warning["default"])(!themeInName || theme === themeInName, 'Icon', "The icon name '".concat(type, "' already specify a theme '").concat(themeInName, "',") + " the 'theme' prop '".concat(theme, "' will be ignored."));
|
|
101
|
+
}
|
|
102
|
+
computedType = (0, _utils.withThemeSuffix)((0, _utils.removeTypeTheme)((0, _utils.alias)(computedType)), dangerousTheme || theme || defaultTheme);
|
|
103
|
+
return React.createElement(_components["default"], {
|
|
104
|
+
className: svgClassString,
|
|
105
|
+
type: computedType,
|
|
106
|
+
primaryColor: twoToneColor,
|
|
107
|
+
style: svgStyle
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var iconTabIndex = tabIndex;
|
|
112
|
+
if (iconTabIndex === undefined && onClick) {
|
|
113
|
+
iconTabIndex = -1;
|
|
114
|
+
}
|
|
115
|
+
return React.createElement(_LocaleReceiver["default"], {
|
|
116
|
+
componentName: "Icon"
|
|
117
|
+
}, function (locale) {
|
|
118
|
+
return React.createElement("i", Object.assign({
|
|
119
|
+
"aria-label": type && "".concat(locale.icon, ": ").concat(type)
|
|
120
|
+
}, restProps, {
|
|
121
|
+
tabIndex: iconTabIndex,
|
|
122
|
+
onClick: onClick,
|
|
123
|
+
className: classString
|
|
124
|
+
}), renderInnerNode());
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
Icon.createFromIconfontCN = _IconFont["default"];
|
|
128
|
+
Icon.getTwoToneColor = _twoTonePrimaryColor.getTwoToneColor;
|
|
129
|
+
Icon.setTwoToneColor = _twoTonePrimaryColor.setTwoToneColor;
|
|
130
|
+
var _default = Icon;
|
|
25
131
|
exports["default"] = _default;
|
package/lib/icon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/icon/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/icon/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,6CAA8B;AAC9B,4DAAmC;AACnC,+DAAgD;AAChD,8DAAoC;AACpC,0DAA6C;AAC7C,mCAMgB;AAChB,+DAAsC;AACtC,4FAAmE;AACnE,+DAAwE;AAExE,kBAAkB;AAClB,oBAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,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BACjE,sBAAsB,KAAK,oBAAoB,CAClD,CAAA;aACF;YACD,YAAY,GAAG,IAAA,uBAAe,EAC5B,IAAA,uBAAe,EAAC,IAAA,aAAK,EAAC,YAAY,CAAC,CAAC,EACpC,cAAc,IAAI,KAAK,IAAI,YAAY,CACxC,CAAA;YAED,OAAO,CACL,oBAAC,oBAAS,IACR,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,QAAQ,GACf,CACH,CAAA;SACF;IACH,CAAC,CAAA;IAED,IAAI,YAAY,GAAG,QAAQ,CAAA;IAC3B,IAAI,YAAY,KAAK,SAAS,IAAI,OAAO,EAAE;QACzC,YAAY,GAAG,CAAC,CAAC,CAAA;KAClB;IAED,OAAO,CACL,oBAAC,wBAAc,IAAC,aAAa,EAAC,MAAM,IACjC,CAAC,MAAM,EAAE,EAAE,CAAC,CACX,uDACc,IAAI,IAAI,GAAI,MAAiC,CAAC,IAAI,KAAK,IAAI,EAAE,IACrE,SAAS,IACb,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,WAAW,KAErB,eAAe,EAAE,CAChB,CACL,CACc,CAClB,CAAA;AACH,CAAC,CAAA;AAED,IAAI,CAAC,oBAAoB,GAAG,kBAAoB,CAAA;AAChD,IAAI,CAAC,eAAe,GAAG,qCAAe,CAAA;AACtC,IAAI,CAAC,eAAe,GAAG,qCAAe,CAAA;AAEtC,kBAAe,IAAI,CAAA","sourcesContent":["/* eslint-disable camelcase */\nimport * as React from 'react'\nimport classNames from 'classnames'\nimport * as allIcons from '@tntd/icons/lib/dist'\nimport ReactIcon from './components'\nimport createFromIconfontCN from './IconFont'\nimport {\n svgBaseProps,\n withThemeSuffix,\n removeTypeTheme,\n getThemeFromTypeName,\n alias,\n} from './utils'\nimport warning from '../_util/warning'\nimport LocaleReceiver from 'antd/lib/locale-provider/LocaleReceiver'\nimport { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor'\n\n// Initial setting\nReactIcon.add(...Object.keys(allIcons).map((key) => (allIcons as any)[key]))\nsetTwoToneColor('#1890ff')\nlet defaultTheme: ThemeType = 'outlined'\nlet dangerousTheme: ThemeType | undefined\n\nfunction unstable_ChangeThemeOfIconsDangerously(theme?: ThemeType) {\n warning(\n false,\n 'Icon',\n `You are using the unstable method 'Icon.unstable_ChangeThemeOfAllIconsDangerously', ` +\n `make sure that all the icons with theme '${theme}' display correctly.`\n )\n dangerousTheme = theme\n}\n\nfunction unstable_ChangeDefaultThemeOfIcons(theme: ThemeType) {\n warning(\n false,\n 'Icon',\n `You are using the unstable method 'Icon.unstable_ChangeDefaultThemeOfIcons', ` +\n `make sure that all the icons with theme '${theme}' display correctly.`\n )\n defaultTheme = theme\n}\n\nexport interface TransferLocale {\n icon: string\n}\n\nexport interface CustomIconComponentProps {\n width: string | number\n height: string | number\n fill: string\n viewBox?: string\n className?: string\n style?: React.CSSProperties\n spin?: boolean\n rotate?: number\n ['aria-hidden']?: React.AriaAttributes['aria-hidden']\n}\n\nexport type ThemeType = 'filled' | 'outlined' | 'twoTone'\n\nexport interface IconProps {\n tabIndex?: number\n type?: string\n className?: string\n theme?: ThemeType\n title?: string\n onKeyUp?: React.KeyboardEventHandler<HTMLElement>\n onClick?: React.MouseEventHandler<HTMLElement>\n component?: React.ComponentType<CustomIconComponentProps | React.SVGProps<SVGSVGElement>>\n twoToneColor?: string\n viewBox?: string\n spin?: boolean\n rotate?: number\n style?: React.CSSProperties\n prefixCls?: string\n role?: string\n}\n\nexport interface IconComponent<P> extends React.SFC<P> {\n createFromIconfontCN: typeof createFromIconfontCN\n getTwoToneColor: typeof getTwoToneColor\n setTwoToneColor: typeof setTwoToneColor\n unstable_ChangeThemeOfIconsDangerously?: typeof unstable_ChangeThemeOfIconsDangerously\n unstable_ChangeDefaultThemeOfIcons?: typeof unstable_ChangeDefaultThemeOfIcons\n}\n\nconst Icon: IconComponent<IconProps> = (props) => {\n const {\n // affect outter <i>...</i>\n className,\n\n // affect inner <svg>...</svg>\n type,\n component: Component,\n viewBox,\n spin,\n rotate,\n\n tabIndex,\n onClick,\n\n // children\n children,\n\n // other\n theme, // default to outlined\n twoToneColor,\n\n ...restProps\n } = props\n\n warning(\n Boolean(type || Component || children),\n 'Icon',\n 'Should have `type` prop or `component` prop or `children`.'\n )\n\n const classString = classNames(\n {\n [`anticon`]: true,\n [`anticon-${type}`]: Boolean(type),\n },\n className\n )\n\n const svgClassString = classNames({\n [`anticon-spin`]: !!spin || type === 'loading',\n })\n\n const svgStyle = rotate\n ? {\n msTransform: `rotate(${rotate}deg)`,\n transform: `rotate(${rotate}deg)`,\n }\n : undefined\n\n const innerSvgProps: CustomIconComponentProps = {\n ...svgBaseProps,\n className: svgClassString,\n style: svgStyle,\n viewBox,\n }\n\n if (!viewBox) {\n delete innerSvgProps.viewBox\n }\n\n const renderInnerNode = () => {\n // component > children > type\n if (Component) {\n return <Component {...innerSvgProps}>{children}</Component>\n }\n\n if (children) {\n warning(\n Boolean(viewBox) ||\n (React.Children.count(children) === 1 &&\n React.isValidElement(children) &&\n React.Children.only(children).type === 'use'),\n 'Icon',\n 'Make sure that you provide correct `viewBox`' +\n ' prop (default `0 0 1024 1024`) to the icon.'\n )\n return (\n <svg {...innerSvgProps} viewBox={viewBox}>\n {children}\n </svg>\n )\n }\n\n if (typeof type === 'string') {\n let computedType = type\n if (theme) {\n const themeInName = getThemeFromTypeName(type)\n warning(\n !themeInName || theme === themeInName,\n 'Icon',\n `The icon name '${type}' already specify a theme '${themeInName}',` +\n ` the 'theme' prop '${theme}' will be ignored.`\n )\n }\n computedType = withThemeSuffix(\n removeTypeTheme(alias(computedType)),\n dangerousTheme || theme || defaultTheme\n )\n\n return (\n <ReactIcon\n className={svgClassString}\n type={computedType}\n primaryColor={twoToneColor}\n style={svgStyle}\n />\n )\n }\n }\n\n let iconTabIndex = tabIndex\n if (iconTabIndex === undefined && onClick) {\n iconTabIndex = -1\n }\n\n return (\n <LocaleReceiver componentName=\"Icon\">\n {(locale) => (\n <i\n aria-label={type && `${(locale as Record<'icon', object>).icon}: ${type}`}\n {...restProps}\n tabIndex={iconTabIndex}\n onClick={onClick}\n className={classString}\n >\n {renderInnerNode()}\n </i>\n )}\n </LocaleReceiver>\n )\n}\n\nIcon.createFromIconfontCN = createFromIconfontCN\nIcon.getTwoToneColor = getTwoToneColor\nIcon.setTwoToneColor = setTwoToneColor\n\nexport default Icon\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twoTonePrimaryColor.d.ts","sourceRoot":"","sources":["../../src/icon/twoTonePrimaryColor.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAI1D;AAED,wBAAgB,eAAe,IAAI,MAAM,CAGxC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTwoToneColor = getTwoToneColor;
|
|
7
|
+
exports.setTwoToneColor = setTwoToneColor;
|
|
8
|
+
var _components = _interopRequireDefault(require("./components"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
function setTwoToneColor(primaryColor) {
|
|
11
|
+
return _components["default"].setTwoToneColors({
|
|
12
|
+
primaryColor: primaryColor
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function getTwoToneColor() {
|
|
16
|
+
var colors = _components["default"].getTwoToneColors();
|
|
17
|
+
return colors.primaryColor;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twoTonePrimaryColor.js","sourceRoot":"","sources":["../../src/icon/twoTonePrimaryColor.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAoC;AAEpC,SAAgB,eAAe,CAAC,YAAoB;IAClD,OAAO,oBAAS,CAAC,gBAAgB,CAAC;QAChC,YAAY;KACb,CAAC,CAAA;AACJ,CAAC;AAJD,0CAIC;AAED,SAAgB,eAAe;IAC7B,MAAM,MAAM,GAAG,oBAAS,CAAC,gBAAgB,EAAE,CAAA;IAC3C,OAAO,MAAM,CAAC,YAAY,CAAA;AAC5B,CAAC;AAHD,0CAGC","sourcesContent":["import ReactIcon from './components'\n\nexport function setTwoToneColor(primaryColor: string): void {\n return ReactIcon.setTwoToneColors({\n primaryColor,\n })\n}\n\nexport function getTwoToneColor(): string {\n const colors = ReactIcon.getTwoToneColors()\n return colors.primaryColor\n}\n"]}
|