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.
Files changed (170) hide show
  1. package/es/icon/IconFont.js +52 -0
  2. package/es/icon/IconFont.js.map +1 -0
  3. package/es/icon/components/Icon.js +106 -0
  4. package/es/icon/components/Icon.js.map +1 -0
  5. package/es/icon/components/index.js +1 -0
  6. package/es/icon/components/index.js.map +1 -0
  7. package/es/icon/components/utils.js +79 -0
  8. package/es/icon/components/utils.js.map +1 -0
  9. package/es/icon/index.js +114 -3
  10. package/es/icon/index.js.map +1 -1
  11. package/es/icon/twoTonePrimaryColor.js +10 -0
  12. package/es/icon/twoTonePrimaryColor.js.map +1 -0
  13. package/es/icon/utils.js +64 -0
  14. package/es/icon/utils.js.map +1 -0
  15. package/lib/icon/IconFont.d.ts +10 -0
  16. package/lib/icon/IconFont.d.ts.map +1 -0
  17. package/lib/icon/IconFont.js +62 -0
  18. package/lib/icon/IconFont.js.map +1 -0
  19. package/lib/icon/components/Icon.d.ts +31 -0
  20. package/lib/icon/components/Icon.d.ts.map +1 -0
  21. package/lib/icon/components/Icon.js +149 -0
  22. package/lib/icon/components/Icon.js.map +1 -0
  23. package/lib/icon/components/index.d.ts +2 -0
  24. package/lib/icon/components/index.d.ts.map +1 -0
  25. package/lib/icon/components/index.js +13 -0
  26. package/lib/icon/components/index.js.map +1 -0
  27. package/lib/icon/components/utils.d.ts +22 -0
  28. package/lib/icon/components/utils.d.ts.map +1 -0
  29. package/lib/icon/components/utils.js +120 -0
  30. package/lib/icon/components/utils.js.map +1 -0
  31. package/lib/icon/index.d.ts +45 -3
  32. package/lib/icon/index.d.ts.map +1 -1
  33. package/lib/icon/index.js +121 -15
  34. package/lib/icon/index.js.map +1 -1
  35. package/lib/icon/twoTonePrimaryColor.d.ts +3 -0
  36. package/lib/icon/twoTonePrimaryColor.d.ts.map +1 -0
  37. package/lib/icon/twoTonePrimaryColor.js +18 -0
  38. package/lib/icon/twoTonePrimaryColor.js.map +1 -0
  39. package/lib/icon/utils.d.ts +13 -0
  40. package/lib/icon/utils.d.ts.map +1 -0
  41. package/lib/icon/utils.js +76 -0
  42. package/lib/icon/utils.js.map +1 -0
  43. package/lib/segmented/index.d.ts +1 -1
  44. package/lib/svg-components/illustration-403.d.ts +1 -1
  45. package/lib/svg-components/illustration-404.d.ts +1 -1
  46. package/lib/svg-components/illustration-500.d.ts +1 -1
  47. package/lib/svg-components/illustration-empty.d.ts +1 -1
  48. package/lib/svg-components/illustration-failure.d.ts +1 -1
  49. package/lib/svg-components/illustration-no-access.d.ts +1 -1
  50. package/lib/svg-components/illustration-no-chart.d.ts +1 -1
  51. package/lib/svg-components/illustration-no-result.d.ts +1 -1
  52. package/lib/svg-components/illustration-offline.d.ts +1 -1
  53. package/lib/svg-components/illustration-success.d.ts +1 -1
  54. package/lib/table/assets/image-loading-background.d.ts +1 -1
  55. package/lib/table/assets/image-loading.d.ts +1 -1
  56. package/package.json +106 -105
  57. package/es/tntd-form/_util/context.js +0 -12
  58. package/es/tntd-form/_util/context.js.map +0 -1
  59. package/es/tntd-form/_util/defaultRenderEmpty.js +0 -31
  60. package/es/tntd-form/_util/defaultRenderEmpty.js.map +0 -1
  61. package/es/tntd-form/_util/hooks/useFlexGapSupport.js +0 -9
  62. package/es/tntd-form/_util/hooks/useFlexGapSupport.js.map +0 -1
  63. package/es/tntd-form/_util/hooks/useForceUpdate.js +0 -5
  64. package/es/tntd-form/_util/hooks/useForceUpdate.js.map +0 -1
  65. package/es/tntd-form/_util/motion.js +0 -47
  66. package/es/tntd-form/_util/motion.js.map +0 -1
  67. package/es/tntd-form/_util/reactNode.js +0 -16
  68. package/es/tntd-form/_util/reactNode.js.map +0 -1
  69. package/es/tntd-form/_util/responsiveObserve.js +0 -59
  70. package/es/tntd-form/_util/responsiveObserve.js.map +0 -1
  71. package/es/tntd-form/_util/scrollTo.js +0 -35
  72. package/es/tntd-form/_util/scrollTo.js.map +0 -1
  73. package/es/tntd-form/_util/styleChecker.js +0 -26
  74. package/es/tntd-form/_util/styleChecker.js.map +0 -1
  75. package/es/tntd-form/_util/type.js +0 -3
  76. package/es/tntd-form/_util/type.js.map +0 -1
  77. package/es/tntd-form/_util/warning.js +0 -5
  78. package/es/tntd-form/_util/warning.js.map +0 -1
  79. package/es/tntd-form/_util/wave.js +0 -168
  80. package/es/tntd-form/_util/wave.js.map +0 -1
  81. package/es/tntd-form/grid/RowContext.js +0 -3
  82. package/es/tntd-form/grid/RowContext.js.map +0 -1
  83. package/es/tntd-form/grid/col.js +0 -104
  84. package/es/tntd-form/grid/col.js.map +0 -1
  85. package/es/tntd-form/grid/hooks/useBreakpoint.js +0 -18
  86. package/es/tntd-form/grid/hooks/useBreakpoint.js.map +0 -1
  87. package/es/tntd-form/grid/index.js +0 -14
  88. package/es/tntd-form/grid/index.js.map +0 -1
  89. package/es/tntd-form/grid/row.js +0 -153
  90. package/es/tntd-form/grid/row.js.map +0 -1
  91. package/es/tntd-form/grid/style/index.js +0 -2
  92. package/es/tntd-form/grid/style/index.js.map +0 -1
  93. package/es/tntd-form/tntd-form.stories.js +0 -836
  94. package/es/tntd-form/tntd-form.stories.js.map +0 -1
  95. package/lib/tntd-form/_util/context.d.ts +0 -42
  96. package/lib/tntd-form/_util/context.d.ts.map +0 -1
  97. package/lib/tntd-form/_util/context.js +0 -22
  98. package/lib/tntd-form/_util/context.js.map +0 -1
  99. package/lib/tntd-form/_util/defaultRenderEmpty.d.ts +0 -5
  100. package/lib/tntd-form/_util/defaultRenderEmpty.d.ts.map +0 -1
  101. package/lib/tntd-form/_util/defaultRenderEmpty.js +0 -44
  102. package/lib/tntd-form/_util/defaultRenderEmpty.js.map +0 -1
  103. package/lib/tntd-form/_util/hooks/useFlexGapSupport.d.ts +0 -3
  104. package/lib/tntd-form/_util/hooks/useFlexGapSupport.d.ts.map +0 -1
  105. package/lib/tntd-form/_util/hooks/useFlexGapSupport.js +0 -28
  106. package/lib/tntd-form/_util/hooks/useFlexGapSupport.js.map +0 -1
  107. package/lib/tntd-form/_util/hooks/useForceUpdate.d.ts +0 -3
  108. package/lib/tntd-form/_util/hooks/useForceUpdate.d.ts.map +0 -1
  109. package/lib/tntd-form/_util/hooks/useForceUpdate.js +0 -24
  110. package/lib/tntd-form/_util/hooks/useForceUpdate.js.map +0 -1
  111. package/lib/tntd-form/_util/motion.d.ts +0 -9
  112. package/lib/tntd-form/_util/motion.d.ts.map +0 -1
  113. package/lib/tntd-form/_util/motion.js +0 -59
  114. package/lib/tntd-form/_util/motion.js.map +0 -1
  115. package/lib/tntd-form/_util/reactNode.d.ts +0 -9
  116. package/lib/tntd-form/_util/reactNode.d.ts.map +0 -1
  117. package/lib/tntd-form/_util/reactNode.js +0 -27
  118. package/lib/tntd-form/_util/reactNode.js.map +0 -1
  119. package/lib/tntd-form/_util/responsiveObserve.d.ts +0 -22
  120. package/lib/tntd-form/_util/responsiveObserve.d.ts.map +0 -1
  121. package/lib/tntd-form/_util/responsiveObserve.js +0 -73
  122. package/lib/tntd-form/_util/responsiveObserve.js.map +0 -1
  123. package/lib/tntd-form/_util/scrollTo.d.ts +0 -1
  124. package/lib/tntd-form/_util/scrollTo.d.ts.map +0 -1
  125. package/lib/tntd-form/_util/scrollTo.js +0 -35
  126. package/lib/tntd-form/_util/scrollTo.js.map +0 -1
  127. package/lib/tntd-form/_util/styleChecker.d.ts +0 -5
  128. package/lib/tntd-form/_util/styleChecker.d.ts.map +0 -1
  129. package/lib/tntd-form/_util/styleChecker.js +0 -42
  130. package/lib/tntd-form/_util/styleChecker.js.map +0 -1
  131. package/lib/tntd-form/_util/type.d.ts +0 -4
  132. package/lib/tntd-form/_util/type.d.ts.map +0 -1
  133. package/lib/tntd-form/_util/type.js +0 -21
  134. package/lib/tntd-form/_util/type.js.map +0 -1
  135. package/lib/tntd-form/_util/warning.d.ts +0 -5
  136. package/lib/tntd-form/_util/warning.d.ts.map +0 -1
  137. package/lib/tntd-form/_util/warning.js +0 -20
  138. package/lib/tntd-form/_util/warning.js.map +0 -1
  139. package/lib/tntd-form/_util/wave.d.ts +0 -1
  140. package/lib/tntd-form/_util/wave.d.ts.map +0 -1
  141. package/lib/tntd-form/_util/wave.js +0 -168
  142. package/lib/tntd-form/_util/wave.js.map +0 -1
  143. package/lib/tntd-form/grid/RowContext.d.ts +0 -9
  144. package/lib/tntd-form/grid/RowContext.d.ts.map +0 -1
  145. package/lib/tntd-form/grid/RowContext.js +0 -10
  146. package/lib/tntd-form/grid/RowContext.js.map +0 -1
  147. package/lib/tntd-form/grid/col.d.ts +0 -29
  148. package/lib/tntd-form/grid/col.d.ts.map +0 -1
  149. package/lib/tntd-form/grid/col.js +0 -105
  150. package/lib/tntd-form/grid/col.js.map +0 -1
  151. package/lib/tntd-form/grid/hooks/useBreakpoint.d.ts +0 -4
  152. package/lib/tntd-form/grid/hooks/useBreakpoint.d.ts.map +0 -1
  153. package/lib/tntd-form/grid/hooks/useBreakpoint.js +0 -29
  154. package/lib/tntd-form/grid/hooks/useBreakpoint.js.map +0 -1
  155. package/lib/tntd-form/grid/index.d.ts +0 -12
  156. package/lib/tntd-form/grid/index.d.ts.map +0 -1
  157. package/lib/tntd-form/grid/index.js +0 -31
  158. package/lib/tntd-form/grid/index.js.map +0 -1
  159. package/lib/tntd-form/grid/row.d.ts +0 -21
  160. package/lib/tntd-form/grid/row.d.ts.map +0 -1
  161. package/lib/tntd-form/grid/row.js +0 -186
  162. package/lib/tntd-form/grid/row.js.map +0 -1
  163. package/lib/tntd-form/grid/style/index.d.ts +0 -3
  164. package/lib/tntd-form/grid/style/index.d.ts.map +0 -1
  165. package/lib/tntd-form/grid/style/index.js +0 -4
  166. package/lib/tntd-form/grid/style/index.js.map +0 -1
  167. package/lib/tntd-form/tntd-form.stories.d.ts +0 -33
  168. package/lib/tntd-form/tntd-form.stories.d.ts.map +0 -1
  169. package/lib/tntd-form/tntd-form.stories.js +0 -943
  170. package/lib/tntd-form/tntd-form.stories.js.map +0 -1
@@ -0,0 +1,52 @@
1
+ var __rest = this && this.__rest || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
6
+ }
7
+ return t;
8
+ };
9
+ import * as React from 'react';
10
+ import Icon from './index';
11
+ const customCache = new Set();
12
+ export default function create(options = {}) {
13
+ const {
14
+ scriptUrl,
15
+ extraCommonProps = {}
16
+ } = options;
17
+ /**
18
+ * DOM API required.
19
+ * Make sure in browser environment.
20
+ * The Custom Icon will create a <script/>
21
+ * that loads SVG symbols and insert the SVG Element into the document body.
22
+ */
23
+ if (typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function' && typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl)) {
24
+ const script = document.createElement('script');
25
+ script.setAttribute('src', scriptUrl);
26
+ script.setAttribute('data-namespace', scriptUrl);
27
+ customCache.add(scriptUrl);
28
+ document.body.appendChild(script);
29
+ }
30
+ const Iconfont = props => {
31
+ const {
32
+ type,
33
+ children
34
+ } = props,
35
+ restProps = __rest(props
36
+ // component > children > type
37
+ , ["type", "children"]);
38
+ // component > children > type
39
+ let content = null;
40
+ if (props.type) {
41
+ content = React.createElement("use", {
42
+ xlinkHref: `#${type}`
43
+ });
44
+ }
45
+ if (children) {
46
+ content = children;
47
+ }
48
+ return React.createElement(Icon, Object.assign({}, extraCommonProps, restProps), content);
49
+ };
50
+ Iconfont.displayName = 'Iconfont';
51
+ return Iconfont;
52
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconFont.js","sourceRoot":"","sources":["../../src/icon/IconFont.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,KAA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M,SAAS,GACtC,OAAO,CACH,CACR,CAAA;IACH,CAAC,CAAA;IAED,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA;IAEjC,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import * as React from 'react'\nimport Icon, { IconProps } from './index'\n\nconst customCache = new Set<string>()\n\nexport interface CustomIconOptions {\n scriptUrl?: string\n extraCommonProps?: { [key: string]: any }\n}\n\nexport default function create(options: CustomIconOptions = {}): React.SFC<IconProps> {\n const { scriptUrl, extraCommonProps = {} } = options\n\n /**\n * DOM API required.\n * Make sure in browser environment.\n * The Custom Icon will create a <script/>\n * that loads SVG symbols and insert the SVG Element into the document body.\n */\n if (\n typeof document !== 'undefined' &&\n typeof window !== 'undefined' &&\n typeof document.createElement === 'function' &&\n typeof scriptUrl === 'string' &&\n scriptUrl.length &&\n !customCache.has(scriptUrl)\n ) {\n const script = document.createElement('script')\n script.setAttribute('src', scriptUrl)\n script.setAttribute('data-namespace', scriptUrl)\n customCache.add(scriptUrl)\n document.body.appendChild(script)\n }\n\n const Iconfont: React.SFC<IconProps> = (props) => {\n const { type, children, ...restProps } = props\n\n // component > children > type\n let content = null\n if (props.type) {\n content = <use xlinkHref={`#${type}`} />\n }\n if (children) {\n content = children\n }\n return (\n <Icon {...extraCommonProps} {...restProps}>\n {content}\n </Icon>\n )\n }\n\n Iconfont.displayName = 'Iconfont'\n\n return Iconfont\n}\n"]}
@@ -0,0 +1,106 @@
1
+ var __rest = this && this.__rest || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
6
+ }
7
+ return t;
8
+ };
9
+ import * as React from 'react';
10
+ import { generate, getSecondaryColor, isIconDefinition, log, MiniMap, withSuffix } from './utils';
11
+ const twoToneColorPalette = {
12
+ primaryColor: '#333',
13
+ secondaryColor: '#E6E6E6'
14
+ };
15
+ class Icon extends React.Component {
16
+ static add(...icons) {
17
+ icons.forEach(icon => {
18
+ this.definitions.set(withSuffix(icon.name, icon.theme), icon);
19
+ });
20
+ }
21
+ static clear() {
22
+ this.definitions.clear();
23
+ }
24
+ static get(key, colors = twoToneColorPalette) {
25
+ if (key) {
26
+ let target = this.definitions.get(key);
27
+ if (target && typeof target.icon === 'function') {
28
+ target = Object.assign(Object.assign({}, target), {
29
+ icon: target.icon(colors.primaryColor, colors.secondaryColor)
30
+ });
31
+ }
32
+ return target;
33
+ }
34
+ }
35
+ static setTwoToneColors({
36
+ primaryColor,
37
+ secondaryColor
38
+ }) {
39
+ twoToneColorPalette.primaryColor = primaryColor;
40
+ twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
41
+ }
42
+ static getTwoToneColors() {
43
+ return Object.assign({}, twoToneColorPalette);
44
+ }
45
+ render() {
46
+ const _a = this.props,
47
+ {
48
+ type,
49
+ className,
50
+ onClick,
51
+ style,
52
+ primaryColor,
53
+ secondaryColor
54
+ } = _a,
55
+ rest = __rest(_a, ["type", "className", "onClick", "style", "primaryColor", "secondaryColor"]);
56
+ let target;
57
+ let colors = twoToneColorPalette;
58
+ if (primaryColor) {
59
+ colors = {
60
+ primaryColor,
61
+ secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
62
+ };
63
+ }
64
+ if (isIconDefinition(type)) {
65
+ target = type;
66
+ } else if (typeof type === 'string') {
67
+ target = Icon.get(type, colors);
68
+ if (!target) {
69
+ // log(`Could not find icon: ${type}`);
70
+ return null;
71
+ }
72
+ }
73
+ if (!target) {
74
+ log(`type should be string or icon definiton, but got ${type}`);
75
+ return null;
76
+ }
77
+ if (target && typeof target.icon === 'function') {
78
+ target = Object.assign(Object.assign({}, target), {
79
+ icon: target.icon(colors.primaryColor, colors.secondaryColor)
80
+ });
81
+ }
82
+ return generate(target.icon, `svg-${target.name}`, Object.assign({
83
+ className,
84
+ onClick,
85
+ style,
86
+ ['data-icon']: target.name,
87
+ width: '1em',
88
+ height: '1em',
89
+ fill: 'currentColor',
90
+ ['aria-hidden']: 'true'
91
+ }, rest));
92
+ }
93
+ }
94
+ Object.defineProperty(Icon, "displayName", {
95
+ enumerable: true,
96
+ configurable: true,
97
+ writable: true,
98
+ value: 'IconReact'
99
+ });
100
+ Object.defineProperty(Icon, "definitions", {
101
+ enumerable: true,
102
+ configurable: true,
103
+ writable: true,
104
+ value: new MiniMap()
105
+ });
106
+ export default Icon;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/icon/components/Icon.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAqBjG,MAAM,mBAAmB,GAAwB;IAC/C,YAAY,EAAE,MAAM;IACpB,cAAc,EAAE,SAAS;CAC1B,CAAA;AAED,MAAM,IAAK,SAAQ,KAAK,CAAC,SAAoB;IAG3C,MAAM,CAAC,GAAG,CAAC,GAAG,KAAuB;QACnC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;QAC/D,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,CAAC,KAAK;QACV,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,GAAY,EAAE,SAA8B,mBAAmB;QACxE,IAAI,GAAG,EAAE;YACP,I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,MAAM,EAAE;YACX,GAAG,CAAC,oDAAoD,IAAI,EAAE,CAAC,CAAA;YAC/D,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;YAC/C,MAAM,mCACD,MAAM,KACT,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,GAC9D,CAAA;SACF;QACD,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAoB,EAAE,OAAO,MAAM,CAAC,IAAI,EAAE,kBAC/D,SAAS;YACT,OAAO;YACP,KAAK,EACL,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,IAAI,EAC1B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,cAAc,EACpB,CAAC,aAAa,CAAC,EAAE,MAAM,IACpB,IAAI,EACP,CAAA;IACJ,CAAC;;AA5EM;;;;WAAc,WAAW;GAAA;AAChC;;;;WAAqB,IAAI,OAAO,EAAkB;GAAA;AA8EpD,eAAe,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
+ export { default } from './Icon';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/icon/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA6D,MAAM,QAAQ,CAAA","sourcesContent":["export { default, IconProps, TwoToneColorPaletteSetter, TwoToneColorPalette } from './Icon'\n"]}
@@ -0,0 +1,79 @@
1
+ import { generate as generateColor } from '@ant-design/colors';
2
+ import * as React from 'react';
3
+ export function log(message) {
4
+ if (!(process && process.env && process.env.NODE_ENV === 'production')) {
5
+ console.error(`[@ant-design/icons-react]: ${message}.`);
6
+ }
7
+ }
8
+ export function isIconDefinition(target) {
9
+ return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
10
+ }
11
+ export function normalizeAttrs(attrs = {}) {
12
+ return Object.keys(attrs).reduce((acc, key) => {
13
+ const val = attrs[key];
14
+ switch (key) {
15
+ case 'class':
16
+ acc.className = val;
17
+ delete acc.class;
18
+ break;
19
+ default:
20
+ acc[key] = val;
21
+ }
22
+ return acc;
23
+ }, {});
24
+ }
25
+ export class MiniMap {
26
+ constructor() {
27
+ Object.defineProperty(this, "collection", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: {}
32
+ });
33
+ }
34
+ get size() {
35
+ return Object.keys(this.collection).length;
36
+ }
37
+ clear() {
38
+ this.collection = {};
39
+ }
40
+ delete(key) {
41
+ return delete this.collection[key];
42
+ }
43
+ get(key) {
44
+ return this.collection[key];
45
+ }
46
+ has(key) {
47
+ return Boolean(this.collection[key]);
48
+ }
49
+ set(key, value) {
50
+ this.collection[key] = value;
51
+ return this;
52
+ }
53
+ }
54
+ export function generate(node, key, rootProps) {
55
+ if (!rootProps) {
56
+ return React.createElement(node.tag, Object.assign({
57
+ key
58
+ }, normalizeAttrs(node.attrs)), (node.children || []).map((child, index) => generate(child, `${key}-${node.tag}-${index}`)));
59
+ }
60
+ return React.createElement(node.tag, Object.assign(Object.assign({
61
+ key
62
+ }, normalizeAttrs(node.attrs)), rootProps), (node.children || []).map((child, index) => generate(child, `${key}-${node.tag}-${index}`)));
63
+ }
64
+ export function getSecondaryColor(primaryColor) {
65
+ // choose the second color
66
+ return generateColor(primaryColor)[0];
67
+ }
68
+ export function withSuffix(name, theme) {
69
+ switch (theme) {
70
+ case 'fill':
71
+ return `${name}-fill`;
72
+ case 'outline':
73
+ return `${name}-o`;
74
+ case 'twotone':
75
+ return `${name}-twotone`;
76
+ default:
77
+ throw new TypeError(`Unknown theme type: ${theme}, name: ${name}`);
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/icon/components/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,UAAU,GAAG,CAAC,OAAe;IACjC,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,EAAE;QACtE,OAAO,CAAC,KAAK,CAAC,8BAA8B,OAAO,GAAG,CAAC,CAAA;KACxD;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAW;IAC1C,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC/B,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;QAChC,CAAC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,CACvE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAe,EAAE;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAU,EAAE,GAAG,EAAE,EAAE;QACnD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;QACtB,QAAQ,GAAG,EAAE;YACX,KAAK,OAAO;gBACV,GAAG,CAAC,SAAS,GAAG,GAAG,CAAA;gBACnB,OAAO,GAAG,CAAC,KAAK,CAAA;gBAChB,M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AO,KAAK,CAAC,aAAa,CACxB,IAAI,CAAC,GAAG,gCAEN,GAAG,IACA,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,GAC1B,SAAS,GAEd,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,KAAa,EAAE,EAAE,CACtD,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC,CAC/C,CACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,YAAoB;IACpD,0BAA0B;IAC1B,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,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","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/es/icon/index.js CHANGED
@@ -1,4 +1,115 @@
1
- import Icon from 'antd/es/icon';
2
- import 'antd/es/icon/style';
3
- export * from 'antd/es/icon';
1
+ var __rest = this && this.__rest || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
6
+ }
7
+ return t;
8
+ };
9
+ /* eslint-disable camelcase */
10
+ import * as React from 'react';
11
+ import classNames from 'classnames';
12
+ import * as allIcons from '@tntd/icons/lib/dist';
13
+ import ReactIcon from './components';
14
+ import createFromIconfontCN from './IconFont';
15
+ import { svgBaseProps, withThemeSuffix, removeTypeTheme, getThemeFromTypeName, alias } from './utils';
16
+ import warning from '../_util/warning';
17
+ import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
18
+ import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
19
+ // Initial setting
20
+ ReactIcon.add(...Object.keys(allIcons).map(key => allIcons[key]));
21
+ setTwoToneColor('#1890ff');
22
+ let defaultTheme = 'outlined';
23
+ let dangerousTheme;
24
+ function unstable_ChangeThemeOfIconsDangerously(theme) {
25
+ warning(false, 'Icon', `You are using the unstable method 'Icon.unstable_ChangeThemeOfAllIconsDangerously', ` + `make sure that all the icons with theme '${theme}' display correctly.`);
26
+ dangerousTheme = theme;
27
+ }
28
+ function unstable_ChangeDefaultThemeOfIcons(theme) {
29
+ warning(false, 'Icon', `You are using the unstable method 'Icon.unstable_ChangeDefaultThemeOfIcons', ` + `make sure that all the icons with theme '${theme}' display correctly.`);
30
+ defaultTheme = theme;
31
+ }
32
+ const Icon = props => {
33
+ const {
34
+ // affect outter <i>...</i>
35
+ className,
36
+ // affect inner <svg>...</svg>
37
+ type,
38
+ component: Component,
39
+ viewBox,
40
+ spin,
41
+ rotate,
42
+ tabIndex,
43
+ onClick,
44
+ // children
45
+ children,
46
+ // other
47
+ theme,
48
+ // default to outlined
49
+ twoToneColor
50
+ } = props,
51
+ restProps = __rest(props, ["className", "type", "component", "viewBox", "spin", "rotate", "tabIndex", "onClick", "children", "theme", "twoToneColor"]);
52
+ warning(Boolean(type || Component || children), 'Icon', 'Should have `type` prop or `component` prop or `children`.');
53
+ const classString = classNames({
54
+ [`anticon`]: true,
55
+ [`anticon-${type}`]: Boolean(type)
56
+ }, className);
57
+ const svgClassString = classNames({
58
+ [`anticon-spin`]: !!spin || type === 'loading'
59
+ });
60
+ const svgStyle = rotate ? {
61
+ msTransform: `rotate(${rotate}deg)`,
62
+ transform: `rotate(${rotate}deg)`
63
+ } : undefined;
64
+ const innerSvgProps = Object.assign(Object.assign({}, svgBaseProps), {
65
+ className: svgClassString,
66
+ style: svgStyle,
67
+ viewBox
68
+ });
69
+ if (!viewBox) {
70
+ delete innerSvgProps.viewBox;
71
+ }
72
+ const renderInnerNode = () => {
73
+ // component > children > type
74
+ if (Component) {
75
+ return React.createElement(Component, Object.assign({}, innerSvgProps), children);
76
+ }
77
+ if (children) {
78
+ warning(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.');
79
+ return React.createElement("svg", Object.assign({}, innerSvgProps, {
80
+ viewBox: viewBox
81
+ }), children);
82
+ }
83
+ if (typeof type === 'string') {
84
+ let computedType = type;
85
+ if (theme) {
86
+ const themeInName = getThemeFromTypeName(type);
87
+ warning(!themeInName || theme === themeInName, 'Icon', `The icon name '${type}' already specify a theme '${themeInName}',` + ` the 'theme' prop '${theme}' will be ignored.`);
88
+ }
89
+ computedType = withThemeSuffix(removeTypeTheme(alias(computedType)), dangerousTheme || theme || defaultTheme);
90
+ return React.createElement(ReactIcon, {
91
+ className: svgClassString,
92
+ type: computedType,
93
+ primaryColor: twoToneColor,
94
+ style: svgStyle
95
+ });
96
+ }
97
+ };
98
+ let iconTabIndex = tabIndex;
99
+ if (iconTabIndex === undefined && onClick) {
100
+ iconTabIndex = -1;
101
+ }
102
+ return React.createElement(LocaleReceiver, {
103
+ componentName: "Icon"
104
+ }, locale => React.createElement("i", Object.assign({
105
+ "aria-label": type && `${locale.icon}: ${type}`
106
+ }, restProps, {
107
+ tabIndex: iconTabIndex,
108
+ onClick: onClick,
109
+ className: classString
110
+ }), renderInnerNode()));
111
+ };
112
+ Icon.createFromIconfontCN = createFromIconfontCN;
113
+ Icon.getTwoToneColor = getTwoToneColor;
114
+ Icon.setTwoToneColor = setTwoToneColor;
4
115
  export default Icon;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,cAAc,CAAA;AAE/B,OAAO,oBAAoB,CAAA;AAE3B,cAAc,cAAc,CAAA;AAE5B,eAAe,IAAI,CAAA","sourcesContent":["import Icon from 'antd/es/icon'\n\nimport 'antd/es/icon/style'\n\nexport * from 'antd/es/icon'\n\nexport default Icon\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/icon/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,8BAA8B;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAA;AAChD,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,oBAAoB,MAAM,YAAY,CAAA;AAC7C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,KAAK,GACN,MAAM,SAAS,CAAA;AAChB,OAAO,OAAO,MAAM,kBAAkB,CAAA;AACtC,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAExE,kBAAkB;AAClB,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAE,QAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAC5E,eAAe,CAAC,SAAS,CAAC,CAAA;AAC1B,IAAI,YAAY,GAAc,UAAU,CAAA;AACxC,IAAI,cAAqC,CAAA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AClB,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,cAAc,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,oBAAoB,CAAA;AAChD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;AACtC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;AAEtC,eAAe,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/es/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,10 @@
1
+ import ReactIcon from './components';
2
+ export function setTwoToneColor(primaryColor) {
3
+ return ReactIcon.setTwoToneColors({
4
+ primaryColor
5
+ });
6
+ }
7
+ export function getTwoToneColor() {
8
+ const colors = ReactIcon.getTwoToneColors();
9
+ return colors.primaryColor;
10
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"twoTonePrimaryColor.js","sourceRoot":"","sources":["../../src/icon/twoTonePrimaryColor.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,MAAM,UAAU,eAAe,CAAC,YAAoB;IAClD,OAAO,SAAS,CAAC,gBAAgB,CAAC;QAChC,YAAY;KACb,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAG,SAAS,CAAC,gBAAgB,EAAE,CAAA;IAC3C,OAAO,MAAM,CAAC,YAAY,CAAA;AAC5B,CAAC","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"]}
@@ -0,0 +1,64 @@
1
+ import warning from '../_util/warning';
2
+ // These props make sure that the SVG behaviours like general text.
3
+ // Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
4
+ export const svgBaseProps = {
5
+ width: '1em',
6
+ height: '1em',
7
+ fill: 'currentColor',
8
+ 'aria-hidden': true,
9
+ focusable: 'false'
10
+ };
11
+ const fillTester = /-fill$/;
12
+ const outlineTester = /-o$/;
13
+ const twoToneTester = /-twotone$/;
14
+ export function getThemeFromTypeName(type) {
15
+ let result = null;
16
+ if (fillTester.test(type)) {
17
+ result = 'filled';
18
+ } else if (outlineTester.test(type)) {
19
+ result = 'outlined';
20
+ } else if (twoToneTester.test(type)) {
21
+ result = 'twoTone';
22
+ }
23
+ return result;
24
+ }
25
+ export function removeTypeTheme(type) {
26
+ return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, '');
27
+ }
28
+ export function withThemeSuffix(type, theme) {
29
+ let result = type;
30
+ if (theme === 'filled') {
31
+ result += '-fill';
32
+ } else if (theme === 'outlined') {
33
+ result += '-o';
34
+ } else if (theme === 'twoTone') {
35
+ result += '-twotone';
36
+ } else {
37
+ warning(false, 'Icon', `This icon '${type}' has unknown theme '${theme}'`);
38
+ }
39
+ return result;
40
+ }
41
+ // For alias or compatibility
42
+ export function alias(type) {
43
+ let newType = type;
44
+ switch (type) {
45
+ case 'cross':
46
+ newType = 'close';
47
+ break;
48
+ // https://github.com/ant-design/ant-design/issues/13007
49
+ case 'interation':
50
+ newType = 'interaction';
51
+ break;
52
+ // https://github.com/ant-design/ant-design/issues/16810
53
+ case 'canlendar':
54
+ newType = 'calendar';
55
+ break;
56
+ // https://github.com/ant-design/ant-design/issues/17448
57
+ case 'colum-height':
58
+ newType = 'column-height';
59
+ break;
60
+ default:
61
+ }
62
+ warning(newType === type, 'Icon', `Icon '${type}' was a typo and is now deprecated, please use '${newType}' instead.`);
63
+ return newType;
64
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/icon/utils.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,kBAAkB,CAAA;AAEtC,mEAAmE;AACnE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,cAAc;IACpB,aAAa,EAAE,IAAI;IACnB,SAAS,EAAE,OAAO;CACnB,CAAA;AAED,MAAM,UAAU,GAAG,QAAQ,CAAA;AAC3B,MAAM,aAAa,GAAG,KAAK,CAAA;AAC3B,MAAM,aAAa,GAAG,WAAW,CAAA;AAEjC,MAAM,UAAU,oBAAoB,CAAC,IAAY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AAwD;QACxD,KAAK,WAAW;YACd,OAAO,GAAG,UAAU,CAAA;YACpB,MAAK;QACP,wDAAwD;QACxD,KAAK,cAAc;YACjB,OAAO,GAAG,eAAe,CAAA;YACzB,MAAK;QACP,QAAQ;KACT;IACD,OAAO,CACL,OAAO,KAAK,IAAI,EAChB,MAAM,EACN,SAAS,IAAI,mDAAmD,OAAO,YAAY,CACpF,CAAA;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import type { ThemeType } from './index'\nimport warning from '../_util/warning'\n\n// These props make sure that the SVG behaviours like general text.\n// Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4\nexport const svgBaseProps = {\n width: '1em',\n height: '1em',\n fill: 'currentColor',\n 'aria-hidden': true,\n focusable: 'false',\n}\n\nconst fillTester = /-fill$/\nconst outlineTester = /-o$/\nconst twoToneTester = /-twotone$/\n\nexport function getThemeFromTypeName(type: string): ThemeType | null {\n let result: ThemeType | null = null\n if (fillTester.test(type)) {\n result = 'filled'\n } else if (outlineTester.test(type)) {\n result = 'outlined'\n } else if (twoToneTester.test(type)) {\n result = 'twoTone'\n }\n return result\n}\n\nexport function removeTypeTheme(type: string) {\n return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, '')\n}\n\nexport function withThemeSuffix(type: string, theme: ThemeType) {\n let result = type\n if (theme === 'filled') {\n result += '-fill'\n } else if (theme === 'outlined') {\n result += '-o'\n } else if (theme === 'twoTone') {\n result += '-twotone'\n } else {\n warning(false, 'Icon', `This icon '${type}' has unknown theme '${theme}'`)\n }\n return result\n}\n\n// For alias or compatibility\nexport function alias(type: string) {\n let newType = type\n switch (type) {\n case 'cross':\n newType = 'close'\n break\n // https://github.com/ant-design/ant-design/issues/13007\n case 'interation':\n newType = 'interaction'\n break\n // https://github.com/ant-design/ant-design/issues/16810\n case 'canlendar':\n newType = 'calendar'\n break\n // https://github.com/ant-design/ant-design/issues/17448\n case 'colum-height':\n newType = 'column-height'\n break\n default:\n }\n warning(\n newType === type,\n 'Icon',\n `Icon '${type}' was a typo and is now deprecated, please use '${newType}' instead.`\n )\n return newType\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { IconProps } from './index';
3
+ export interface CustomIconOptions {
4
+ scriptUrl?: string;
5
+ extraCommonProps?: {
6
+ [key: string]: any;
7
+ };
8
+ }
9
+ export default function create(options?: CustomIconOptions): React.SFC<IconProps>;
10
+ //# sourceMappingURL=IconFont.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconFont.d.ts","sourceRoot":"","sources":["../../src/icon/IconFont.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIzC,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CAC1C;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,GAAE,iBAAsB,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CA6CpF"}
@@ -0,0 +1,62 @@
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"] = create;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _index = _interopRequireDefault(require("./index"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ 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); }
12
+ 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; }
13
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) {
16
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
17
+ }
18
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ var customCache = new Set();
24
+ function create() {
25
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ var scriptUrl = options.scriptUrl,
27
+ _options$extraCommonP = options.extraCommonProps,
28
+ extraCommonProps = _options$extraCommonP === void 0 ? {} : _options$extraCommonP;
29
+ /**
30
+ * DOM API required.
31
+ * Make sure in browser environment.
32
+ * The Custom Icon will create a <script/>
33
+ * that loads SVG symbols and insert the SVG Element into the document body.
34
+ */
35
+ if (typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function' && typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl)) {
36
+ var script = document.createElement('script');
37
+ script.setAttribute('src', scriptUrl);
38
+ script.setAttribute('data-namespace', scriptUrl);
39
+ customCache.add(scriptUrl);
40
+ document.body.appendChild(script);
41
+ }
42
+ var Iconfont = function Iconfont(props) {
43
+ var type = props.type,
44
+ children = props.children,
45
+ restProps = __rest(props
46
+ // component > children > type
47
+ , ["type", "children"]);
48
+ // component > children > type
49
+ var content = null;
50
+ if (props.type) {
51
+ content = React.createElement("use", {
52
+ xlinkHref: "#".concat(type)
53
+ });
54
+ }
55
+ if (children) {
56
+ content = children;
57
+ }
58
+ return React.createElement(_index["default"], Object.assign({}, extraCommonProps, restProps), content);
59
+ };
60
+ Iconfont.displayName = 'Iconfont';
61
+ return Iconfont;
62
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconFont.js","sourceRoot":"","sources":["../../src/icon/IconFont.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8B;AAC9B,oDAAyC;AAEzC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAA;AAOrC,SAAwB,MAAM,CAAC,UAA6B,EAAE;IAC5D,MAAM,EAAE,SAAS,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;IAEpD;;;;;OAKG;IACH,IACE,OAAO,QAAQ,KAAK,WAAW;QAC/B,OAAO,MAAM,KAAK,WAAW;QAC7B,OAAO,QAAQ,CAAC,aAAa,KAAK,UAAU;QAC5C,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,CAAC,MAAM;QAChB,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAC3B;QACA,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC/C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACrC,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAA;QAChD,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;KAClC;IAED,MAAM,QAAQ,GAAyB,CAAC,KAAK,EAAE,EAAE;QAC/C,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK;QAE9C,8BAA8B;UAFxB,oBAAgC,CAAQ,CAAA;QAE9C,8BAA8B;QAC9B,IAAI,OAAO,GAAG,IAAI,CAAA;QAClB,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,OAAO,GAAG,6BAAK,SAAS,EAAE,IAAI,IAAI,EAAE,GAAI,CAAA;SACzC;QACD,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG,QAAQ,CAAA;SACnB;QACD,OAAO,CACL,oBAAC,eAAI,oBAAK,gBAAgB,EAAM,SAAS,GACtC,OAAO,CACH,CACR,CAAA;IACH,CAAC,CAAA;IAED,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA;IAEjC,OAAO,QAAQ,CAAA;AACjB,CAAC;AA7CD,yBA6CC","sourcesContent":["import * as React from 'react'\nimport Icon, { IconProps } from './index'\n\nconst customCache = new Set<string>()\n\nexport interface CustomIconOptions {\n scriptUrl?: string\n extraCommonProps?: { [key: string]: any }\n}\n\nexport default function create(options: CustomIconOptions = {}): React.SFC<IconProps> {\n const { scriptUrl, extraCommonProps = {} } = options\n\n /**\n * DOM API required.\n * Make sure in browser environment.\n * The Custom Icon will create a <script/>\n * that loads SVG symbols and insert the SVG Element into the document body.\n */\n if (\n typeof document !== 'undefined' &&\n typeof window !== 'undefined' &&\n typeof document.createElement === 'function' &&\n typeof scriptUrl === 'string' &&\n scriptUrl.length &&\n !customCache.has(scriptUrl)\n ) {\n const script = document.createElement('script')\n script.setAttribute('src', scriptUrl)\n script.setAttribute('data-namespace', scriptUrl)\n customCache.add(scriptUrl)\n document.body.appendChild(script)\n }\n\n const Iconfont: React.SFC<IconProps> = (props) => {\n const { type, children, ...restProps } = props\n\n // component > children > type\n let content = null\n if (props.type) {\n content = <use xlinkHref={`#${type}`} />\n }\n if (children) {\n content = children\n }\n return (\n <Icon {...extraCommonProps} {...restProps}>\n {content}\n </Icon>\n )\n }\n\n Iconfont.displayName = 'Iconfont'\n\n return Iconfont\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import type { IconDefinition } from '@tntd/icons/lib/types';
2
+ import * as React from 'react';
3
+ import { MiniMap } from './utils';
4
+ export interface IconProps {
5
+ type: string | IconDefinition;
6
+ className?: string;
7
+ onClick?: React.MouseEventHandler<SVGSVGElement>;
8
+ style?: React.CSSProperties;
9
+ primaryColor?: string;
10
+ secondaryColor?: string;
11
+ focusable?: string;
12
+ }
13
+ export interface TwoToneColorPaletteSetter {
14
+ primaryColor: string;
15
+ secondaryColor?: string;
16
+ }
17
+ export interface TwoToneColorPalette extends TwoToneColorPaletteSetter {
18
+ secondaryColor: string;
19
+ }
20
+ declare class Icon extends React.Component<IconProps> {
21
+ static displayName: string;
22
+ static definitions: MiniMap<IconDefinition>;
23
+ static add(...icons: IconDefinition[]): void;
24
+ static clear(): void;
25
+ static get(key?: string, colors?: TwoToneColorPalette): IconDefinition | undefined;
26
+ static setTwoToneColors({ primaryColor, secondaryColor }: TwoToneColorPaletteSetter): void;
27
+ static getTwoToneColors(): TwoToneColorPalette;
28
+ render(): any;
29
+ }
30
+ export default Icon;
31
+ //# sourceMappingURL=Icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../src/icon/components/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAsD,OAAO,EAAc,MAAM,SAAS,CAAA;AAEjG,MA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