@visactor/react-vtable 1.6.0-alpha.5 → 1.6.0

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 (287) hide show
  1. package/cjs/components/avatar/avatar.d.ts +15 -0
  2. package/cjs/components/avatar/avatar.js +84 -0
  3. package/cjs/components/avatar/avatar.js.map +1 -0
  4. package/cjs/components/button/button.d.ts +27 -0
  5. package/cjs/components/button/button.js +107 -0
  6. package/cjs/components/button/button.js.map +1 -0
  7. package/cjs/components/checkbox/checkbox.d.ts +17 -0
  8. package/cjs/components/checkbox/checkbox.js +69 -0
  9. package/cjs/components/checkbox/checkbox.js.map +1 -0
  10. package/cjs/components/index.d.ts +7 -19
  11. package/cjs/components/index.js +4 -101
  12. package/cjs/components/index.js.map +1 -1
  13. package/cjs/components/link/link.d.ts +30 -0
  14. package/cjs/components/link/link.js +118 -0
  15. package/cjs/components/link/link.js.map +1 -0
  16. package/cjs/components/popover/popover.d.ts +13 -0
  17. package/cjs/components/popover/popover.js +281 -0
  18. package/cjs/components/popover/popover.js.map +1 -0
  19. package/cjs/components/radio/radio.d.ts +15 -0
  20. package/cjs/components/radio/radio.js +64 -0
  21. package/cjs/components/radio/radio.js.map +1 -0
  22. package/cjs/components/tag/tag.d.ts +13 -0
  23. package/cjs/components/tag/tag.js +48 -0
  24. package/cjs/components/tag/tag.js.map +1 -0
  25. package/cjs/components/vrender-components/checkbox.d.ts +4 -0
  26. package/cjs/components/vrender-components/checkbox.js +6 -0
  27. package/cjs/components/vrender-components/checkbox.js.map +1 -0
  28. package/cjs/components/vrender-components/component-creater.d.ts +2 -0
  29. package/cjs/components/vrender-components/component-creater.js +22 -0
  30. package/cjs/components/vrender-components/component-creater.js.map +1 -0
  31. package/cjs/components/vrender-components/radio.d.ts +4 -0
  32. package/cjs/components/vrender-components/radio.js +6 -0
  33. package/cjs/components/vrender-components/radio.js.map +1 -0
  34. package/cjs/components/vrender-components/tag.d.ts +4 -0
  35. package/cjs/components/vrender-components/tag.js +6 -0
  36. package/cjs/components/vrender-components/tag.js.map +1 -0
  37. package/cjs/components/vrender-components/type.d.ts +6 -0
  38. package/cjs/components/vrender-components/type.js +6 -0
  39. package/cjs/components/vrender-components/type.js.map +1 -0
  40. package/cjs/constants.js +2 -1
  41. package/cjs/eventsUtils.d.ts +1 -1
  42. package/cjs/eventsUtils.js +1 -1
  43. package/cjs/eventsUtils.js.map +1 -1
  44. package/cjs/index.d.ts +2 -2
  45. package/cjs/index.js +2 -2
  46. package/cjs/index.js.map +1 -1
  47. package/cjs/{components → table-components}/base-component.js +1 -0
  48. package/cjs/table-components/base-component.js.map +1 -0
  49. package/cjs/table-components/component/emptyTip.js.map +1 -0
  50. package/cjs/table-components/component/menu.js.map +1 -0
  51. package/cjs/table-components/component/title.d.ts +4 -0
  52. package/cjs/table-components/component/title.js +10 -0
  53. package/cjs/table-components/component/title.js.map +1 -0
  54. package/cjs/table-components/component/tooltip.js.map +1 -0
  55. package/cjs/{components → table-components}/custom/custom-layout.d.ts +1 -1
  56. package/cjs/{components → table-components}/custom/custom-layout.js +2 -6
  57. package/cjs/table-components/custom/custom-layout.js.map +1 -0
  58. package/{es/components → cjs/table-components}/custom/graphic.d.ts +1 -14
  59. package/cjs/table-components/custom/graphic.js.map +1 -0
  60. package/cjs/table-components/custom/reconciler.d.ts +5 -0
  61. package/cjs/{components → table-components}/custom/reconciler.js +12 -10
  62. package/cjs/table-components/custom/reconciler.js.map +1 -0
  63. package/cjs/table-components/custom/vtable-browser-env-contribution.d.ts +7 -0
  64. package/cjs/{components → table-components}/custom/vtable-browser-env-contribution.js +4 -4
  65. package/cjs/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
  66. package/{es/components → cjs/table-components}/custom/vtable-react-attribute-plugin.d.ts +2 -8
  67. package/cjs/{components → table-components}/custom/vtable-react-attribute-plugin.js +6 -6
  68. package/cjs/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
  69. package/cjs/table-components/custom-component.js.map +1 -0
  70. package/cjs/table-components/index.d.ts +19 -0
  71. package/cjs/table-components/index.js +130 -0
  72. package/cjs/table-components/index.js.map +1 -0
  73. package/cjs/table-components/list/list-column.js.map +1 -0
  74. package/cjs/table-components/pivot/pivot-corner.js.map +1 -0
  75. package/cjs/table-components/pivot/pivot-dimension.js.map +1 -0
  76. package/cjs/table-components/pivot/pivot-header-title.js.map +1 -0
  77. package/cjs/table-components/pivot/pivot-indicator.js.map +1 -0
  78. package/cjs/tables/base-table.d.ts +5 -4
  79. package/cjs/tables/base-table.js +7 -12
  80. package/cjs/tables/base-table.js.map +1 -1
  81. package/cjs/tables/index.d.ts +2 -0
  82. package/cjs/tables/index.js +19 -1
  83. package/cjs/tables/index.js.map +1 -1
  84. package/cjs/tables/list-table-simple.d.ts +8 -0
  85. package/cjs/tables/list-table-simple.js +13 -0
  86. package/cjs/tables/list-table-simple.js.map +1 -0
  87. package/cjs/tables/list-table.d.ts +1 -1
  88. package/cjs/tables/list-table.js +5 -2
  89. package/cjs/tables/list-table.js.map +1 -1
  90. package/cjs/tables/pivot-chart.d.ts +5 -1
  91. package/cjs/tables/pivot-chart.js +6 -29
  92. package/cjs/tables/pivot-chart.js.map +1 -1
  93. package/cjs/tables/pivot-table-simple.d.ts +8 -0
  94. package/cjs/tables/pivot-table-simple.js +13 -0
  95. package/cjs/tables/pivot-table-simple.js.map +1 -0
  96. package/cjs/tables/pivot-table.d.ts +1 -1
  97. package/cjs/tables/pivot-table.js +5 -2
  98. package/cjs/tables/pivot-table.js.map +1 -1
  99. package/cjs/util.js +1 -2
  100. package/cjs/vtable.d.ts +1 -2
  101. package/cjs/vtable.js +0 -33
  102. package/cjs/vtable.js.map +1 -1
  103. package/es/components/avatar/avatar.d.ts +15 -0
  104. package/es/components/avatar/avatar.js +82 -0
  105. package/es/components/avatar/avatar.js.map +1 -0
  106. package/es/components/button/button.d.ts +27 -0
  107. package/es/components/button/button.js +84 -0
  108. package/es/components/button/button.js.map +1 -0
  109. package/es/components/checkbox/checkbox.d.ts +17 -0
  110. package/es/components/checkbox/checkbox.js +48 -0
  111. package/es/components/checkbox/checkbox.js.map +1 -0
  112. package/es/components/index.d.ts +7 -19
  113. package/es/components/index.js +7 -17
  114. package/es/components/index.js.map +1 -1
  115. package/es/components/link/link.d.ts +30 -0
  116. package/es/components/link/link.js +95 -0
  117. package/es/components/link/link.js.map +1 -0
  118. package/es/components/popover/popover.d.ts +13 -0
  119. package/es/components/popover/popover.js +258 -0
  120. package/es/components/popover/popover.js.map +1 -0
  121. package/es/components/radio/radio.d.ts +15 -0
  122. package/es/components/radio/radio.js +43 -0
  123. package/es/components/radio/radio.js.map +1 -0
  124. package/es/components/tag/tag.d.ts +13 -0
  125. package/es/components/tag/tag.js +46 -0
  126. package/es/components/tag/tag.js.map +1 -0
  127. package/es/components/vrender-components/checkbox.d.ts +4 -0
  128. package/es/components/vrender-components/checkbox.js +2 -0
  129. package/es/components/vrender-components/checkbox.js.map +1 -0
  130. package/es/components/vrender-components/component-creater.d.ts +2 -0
  131. package/es/components/vrender-components/component-creater.js +14 -0
  132. package/es/components/vrender-components/component-creater.js.map +1 -0
  133. package/es/components/vrender-components/radio.d.ts +4 -0
  134. package/es/components/vrender-components/radio.js +2 -0
  135. package/es/components/vrender-components/radio.js.map +1 -0
  136. package/es/components/vrender-components/tag.d.ts +4 -0
  137. package/es/components/vrender-components/tag.js +2 -0
  138. package/es/components/vrender-components/tag.js.map +1 -0
  139. package/es/components/vrender-components/type.d.ts +6 -0
  140. package/es/components/vrender-components/type.js +2 -0
  141. package/es/components/vrender-components/type.js.map +1 -0
  142. package/es/constants.js +2 -1
  143. package/es/eventsUtils.d.ts +1 -1
  144. package/es/eventsUtils.js +2 -2
  145. package/es/eventsUtils.js.map +1 -1
  146. package/es/index.d.ts +2 -2
  147. package/es/index.js +3 -3
  148. package/es/index.js.map +1 -1
  149. package/es/{components → table-components}/base-component.js +2 -1
  150. package/es/table-components/base-component.js.map +1 -0
  151. package/es/table-components/component/emptyTip.js.map +1 -0
  152. package/es/table-components/component/menu.js.map +1 -0
  153. package/es/table-components/component/title.d.ts +4 -0
  154. package/es/table-components/component/title.js +4 -0
  155. package/es/table-components/component/title.js.map +1 -0
  156. package/es/table-components/component/tooltip.js.map +1 -0
  157. package/es/{components → table-components}/custom/custom-layout.d.ts +1 -1
  158. package/es/{components → table-components}/custom/custom-layout.js +1 -7
  159. package/es/table-components/custom/custom-layout.js.map +1 -0
  160. package/{cjs/components → es/table-components}/custom/graphic.d.ts +1 -14
  161. package/es/table-components/custom/graphic.js.map +1 -0
  162. package/es/table-components/custom/reconciler.d.ts +5 -0
  163. package/es/{components → table-components}/custom/reconciler.js +9 -8
  164. package/es/table-components/custom/reconciler.js.map +1 -0
  165. package/es/table-components/custom/vtable-browser-env-contribution.d.ts +7 -0
  166. package/es/{components → table-components}/custom/vtable-browser-env-contribution.js +3 -3
  167. package/es/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
  168. package/{cjs/components → es/table-components}/custom/vtable-react-attribute-plugin.d.ts +2 -8
  169. package/es/{components → table-components}/custom/vtable-react-attribute-plugin.js +1 -3
  170. package/es/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
  171. package/es/table-components/custom-component.js.map +1 -0
  172. package/es/table-components/index.d.ts +19 -0
  173. package/es/table-components/index.js +24 -0
  174. package/es/table-components/index.js.map +1 -0
  175. package/es/table-components/list/list-column.js.map +1 -0
  176. package/es/table-components/pivot/pivot-corner.js.map +1 -0
  177. package/es/table-components/pivot/pivot-dimension.js.map +1 -0
  178. package/es/table-components/pivot/pivot-header-title.js.map +1 -0
  179. package/es/table-components/pivot/pivot-indicator.js.map +1 -0
  180. package/es/tables/base-table.d.ts +5 -4
  181. package/es/tables/base-table.js +8 -15
  182. package/es/tables/base-table.js.map +1 -1
  183. package/es/tables/index.d.ts +2 -0
  184. package/es/tables/index.js +4 -0
  185. package/es/tables/index.js.map +1 -1
  186. package/es/tables/list-table-simple.d.ts +8 -0
  187. package/es/tables/list-table-simple.js +9 -0
  188. package/es/tables/list-table-simple.js.map +1 -0
  189. package/es/tables/list-table.d.ts +1 -1
  190. package/es/tables/list-table.js +6 -1
  191. package/es/tables/list-table.js.map +1 -1
  192. package/es/tables/pivot-chart.d.ts +5 -1
  193. package/es/tables/pivot-chart.js +8 -3
  194. package/es/tables/pivot-chart.js.map +1 -1
  195. package/es/tables/pivot-table-simple.d.ts +8 -0
  196. package/es/tables/pivot-table-simple.js +9 -0
  197. package/es/tables/pivot-table-simple.js.map +1 -0
  198. package/es/tables/pivot-table.d.ts +1 -1
  199. package/es/tables/pivot-table.js +6 -1
  200. package/es/tables/pivot-table.js.map +1 -1
  201. package/es/util.js +1 -2
  202. package/es/vtable.d.ts +1 -2
  203. package/es/vtable.js +1 -3
  204. package/es/vtable.js.map +1 -1
  205. package/package.json +5 -5
  206. package/cjs/components/base-component.js.map +0 -1
  207. package/cjs/components/component/emptyTip.js.map +0 -1
  208. package/cjs/components/component/menu.js.map +0 -1
  209. package/cjs/components/component/tooltip.js.map +0 -1
  210. package/cjs/components/custom/component.d.ts +0 -16
  211. package/cjs/components/custom/component.js +0 -7
  212. package/cjs/components/custom/component.js.map +0 -1
  213. package/cjs/components/custom/custom-layout.js.map +0 -1
  214. package/cjs/components/custom/graphic.js.map +0 -1
  215. package/cjs/components/custom/reconciler.d.ts +0 -5
  216. package/cjs/components/custom/reconciler.js.map +0 -1
  217. package/cjs/components/custom/vtable-browser-env-contribution.d.ts +0 -2
  218. package/cjs/components/custom/vtable-browser-env-contribution.js.map +0 -1
  219. package/cjs/components/custom/vtable-react-attribute-plugin.js.map +0 -1
  220. package/cjs/components/custom-component.js.map +0 -1
  221. package/cjs/components/list/list-column.js.map +0 -1
  222. package/cjs/components/pivot/pivot-corner.js.map +0 -1
  223. package/cjs/components/pivot/pivot-dimension.js.map +0 -1
  224. package/cjs/components/pivot/pivot-header-title.js.map +0 -1
  225. package/cjs/components/pivot/pivot-indicator.js.map +0 -1
  226. package/dist/react-vtable.js +0 -13799
  227. package/dist/react-vtable.min.js +0 -46
  228. package/es/components/base-component.js.map +0 -1
  229. package/es/components/component/emptyTip.js.map +0 -1
  230. package/es/components/component/menu.js.map +0 -1
  231. package/es/components/component/tooltip.js.map +0 -1
  232. package/es/components/custom/component.d.ts +0 -16
  233. package/es/components/custom/component.js +0 -6
  234. package/es/components/custom/component.js.map +0 -1
  235. package/es/components/custom/custom-layout.js.map +0 -1
  236. package/es/components/custom/graphic.js.map +0 -1
  237. package/es/components/custom/reconciler.d.ts +0 -5
  238. package/es/components/custom/reconciler.js.map +0 -1
  239. package/es/components/custom/vtable-browser-env-contribution.d.ts +0 -2
  240. package/es/components/custom/vtable-browser-env-contribution.js.map +0 -1
  241. package/es/components/custom/vtable-react-attribute-plugin.js.map +0 -1
  242. package/es/components/custom-component.js.map +0 -1
  243. package/es/components/list/list-column.js.map +0 -1
  244. package/es/components/pivot/pivot-corner.js.map +0 -1
  245. package/es/components/pivot/pivot-dimension.js.map +0 -1
  246. package/es/components/pivot/pivot-header-title.js.map +0 -1
  247. package/es/components/pivot/pivot-indicator.js.map +0 -1
  248. /package/cjs/{components → table-components}/base-component.d.ts +0 -0
  249. /package/cjs/{components → table-components}/component/emptyTip.d.ts +0 -0
  250. /package/cjs/{components → table-components}/component/emptyTip.js +0 -0
  251. /package/cjs/{components → table-components}/component/menu.d.ts +0 -0
  252. /package/cjs/{components → table-components}/component/menu.js +0 -0
  253. /package/cjs/{components → table-components}/component/tooltip.d.ts +0 -0
  254. /package/cjs/{components → table-components}/component/tooltip.js +0 -0
  255. /package/cjs/{components → table-components}/custom/graphic.js +0 -0
  256. /package/cjs/{components → table-components}/custom-component.d.ts +0 -0
  257. /package/cjs/{components → table-components}/custom-component.js +0 -0
  258. /package/cjs/{components → table-components}/list/list-column.d.ts +0 -0
  259. /package/cjs/{components → table-components}/list/list-column.js +0 -0
  260. /package/cjs/{components → table-components}/pivot/pivot-corner.d.ts +0 -0
  261. /package/cjs/{components → table-components}/pivot/pivot-corner.js +0 -0
  262. /package/cjs/{components → table-components}/pivot/pivot-dimension.d.ts +0 -0
  263. /package/cjs/{components → table-components}/pivot/pivot-dimension.js +0 -0
  264. /package/cjs/{components → table-components}/pivot/pivot-header-title.d.ts +0 -0
  265. /package/cjs/{components → table-components}/pivot/pivot-header-title.js +0 -0
  266. /package/cjs/{components → table-components}/pivot/pivot-indicator.d.ts +0 -0
  267. /package/cjs/{components → table-components}/pivot/pivot-indicator.js +0 -0
  268. /package/es/{components → table-components}/base-component.d.ts +0 -0
  269. /package/es/{components → table-components}/component/emptyTip.d.ts +0 -0
  270. /package/es/{components → table-components}/component/emptyTip.js +0 -0
  271. /package/es/{components → table-components}/component/menu.d.ts +0 -0
  272. /package/es/{components → table-components}/component/menu.js +0 -0
  273. /package/es/{components → table-components}/component/tooltip.d.ts +0 -0
  274. /package/es/{components → table-components}/component/tooltip.js +0 -0
  275. /package/es/{components → table-components}/custom/graphic.js +0 -0
  276. /package/es/{components → table-components}/custom-component.d.ts +0 -0
  277. /package/es/{components → table-components}/custom-component.js +0 -0
  278. /package/es/{components → table-components}/list/list-column.d.ts +0 -0
  279. /package/es/{components → table-components}/list/list-column.js +0 -0
  280. /package/es/{components → table-components}/pivot/pivot-corner.d.ts +0 -0
  281. /package/es/{components → table-components}/pivot/pivot-corner.js +0 -0
  282. /package/es/{components → table-components}/pivot/pivot-dimension.d.ts +0 -0
  283. /package/es/{components → table-components}/pivot/pivot-dimension.js +0 -0
  284. /package/es/{components → table-components}/pivot/pivot-header-title.d.ts +0 -0
  285. /package/es/{components → table-components}/pivot/pivot-header-title.js +0 -0
  286. /package/es/{components → table-components}/pivot/pivot-indicator.d.ts +0 -0
  287. /package/es/{components → table-components}/pivot/pivot-indicator.js +0 -0
@@ -0,0 +1,15 @@
1
+ import type { IGroup } from '@visactor/vtable/es/vrender';
2
+ import { type BackgroundAttributes, type Cursor, type ITextGraphicAttribute } from '@visactor/vtable/es/vrender';
3
+ import React from 'react';
4
+ export interface AvatarProps {
5
+ children?: string | React.ReactNode;
6
+ textStyle?: Partial<ITextGraphicAttribute>;
7
+ panelStyle?: BackgroundAttributes;
8
+ size?: number;
9
+ shape?: 'circle' | 'square';
10
+ visible?: boolean;
11
+ cursor?: Cursor;
12
+ autoFixFontSize?: boolean;
13
+ onClick?: (e: Event) => void;
14
+ }
15
+ export declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<IGroup>>;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var __importDefault = this && this.__importDefault || function(mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ default: mod
6
+ };
7
+ };
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: !0
11
+ }), exports.Avatar = void 0;
12
+
13
+ const vrender_1 = require("@visactor/vtable/es/vrender"), vutils_1 = require("@visactor/vutils"), react_1 = __importDefault(require("react")), table_components_1 = require("../../table-components"), defaultProps = {
14
+ textStyle: {
15
+ fontSize: 14,
16
+ fontFamily: "sans-serif",
17
+ fill: "#FFF"
18
+ },
19
+ panelStyle: {
20
+ visible: !0,
21
+ fill: "rgb(201, 205, 212)",
22
+ lineWidth: 1,
23
+ cornerRadius: 2
24
+ },
25
+ size: 40,
26
+ shape: "circle",
27
+ autoFixFontSize: !0
28
+ };
29
+
30
+ function AvatarComponent(baseProps, ref) {
31
+ const props = (0, vutils_1.merge)({}, defaultProps, baseProps), {size: size, children: children, onClick: onClick} = props;
32
+ let avatarRef = react_1.default.useRef(null);
33
+ avatarRef = ref || avatarRef;
34
+ const handleClick = react_1.default.useCallback((event => {
35
+ onClick && onClick(event);
36
+ }), [ onClick ]), groupAttribute = getGroupAttribute(props);
37
+ if ((0, vutils_1.isString)(children)) {
38
+ const textAttribute = getTextAttribute(props);
39
+ return react_1.default.createElement(table_components_1.Group, {
40
+ ref: avatarRef,
41
+ attribute: groupAttribute,
42
+ onClick: handleClick
43
+ }, react_1.default.createElement(table_components_1.Text, {
44
+ attribute: textAttribute
45
+ }));
46
+ }
47
+ return "image" === children.type && (children.props.attribute.width = size, children.props.attribute.height = size),
48
+ react_1.default.createElement(table_components_1.Group, {
49
+ ref: avatarRef,
50
+ attribute: groupAttribute,
51
+ onClick: handleClick
52
+ }, children);
53
+ }
54
+
55
+ function getTextAttribute(props) {
56
+ const {textStyle: textStyle, size: size, children: children, autoFixFontSize: autoFixFontSize} = props, attribute = Object.assign({
57
+ text: children
58
+ }, textStyle);
59
+ return autoFixFontSize && getAutoFixFontSize(size, attribute), attribute;
60
+ }
61
+
62
+ function getGroupAttribute(props) {
63
+ var _a;
64
+ const {panelStyle: panelStyle, size: size, shape: shape} = props;
65
+ return Object.assign(Object.assign({}, panelStyle), {
66
+ width: size,
67
+ height: size,
68
+ clip: !0,
69
+ cornerRadius: "circle" === shape ? size / 2 : null !== (_a = panelStyle.cornerRadius) && void 0 !== _a ? _a : 2,
70
+ display: "flex",
71
+ alignItems: "center",
72
+ justifyContent: "center",
73
+ visibleAll: !0,
74
+ path: void 0
75
+ });
76
+ }
77
+
78
+ function getAutoFixFontSize(size, attribute) {
79
+ const scale = size / ((0, vrender_1.measureTextSize)(attribute.text, attribute).width + 8), fontSize = Math.max(Math.floor(attribute.fontSize * scale), 6);
80
+ attribute.fontSize = fontSize;
81
+ }
82
+
83
+ //# sourceMappingURL=avatar.js.map
84
+ exports.Avatar = react_1.default.forwardRef(AvatarComponent), exports.Avatar.displayName = "Avatar";
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/avatar/avatar.tsx"],"names":[],"mappings":";;;;;;AACA,yDASqC;AAErC,6CAAmD;AAEnD,kDAAyC;AACzC,6DAA4D;AAc5D,MAAM,YAAY,GAAgB;IAChC,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;KACb;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,oBAAoB;QAC1B,SAAS,EAAE,CAAC;QACZ,YAAY,EAA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CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,CAAC","file":"avatar.js","sourcesContent":["import type { IGroup, IGroupAttribute } from '@visactor/vtable/es/vrender';\nimport {\n measureTextSize,\n type BackgroundAttributes,\n type Cursor,\n type IRectGraphicAttribute,\n type ITextGraphicAttribute,\n type Padding,\n type Tag,\n type TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport { isString, merge } from '@visactor/vutils';\nimport type { ReactElement } from 'react';\nimport React, { useEffect } from 'react';\nimport { Group, Image, Text } from '../../table-components';\n\nexport interface AvatarProps {\n children?: string | React.ReactNode;\n textStyle?: Partial<ITextGraphicAttribute>;\n panelStyle?: BackgroundAttributes;\n size?: number;\n shape?: 'circle' | 'square';\n visible?: boolean;\n cursor?: Cursor;\n autoFixFontSize?: boolean;\n onClick?: (e: Event) => void;\n}\n\nconst defaultProps: AvatarProps = {\n textStyle: {\n fontSize: 14,\n fontFamily: 'sans-serif',\n fill: '#FFF'\n },\n panelStyle: {\n visible: true,\n fill: 'rgb(201, 205, 212)',\n lineWidth: 1,\n cornerRadius: 2\n },\n size: 40,\n shape: 'circle',\n autoFixFontSize: true\n // cursor: 'pointer',\n};\n\nfunction AvatarComponent(baseProps: AvatarProps, ref: React.Ref<IGroup>) {\n const props: AvatarProps = merge({}, defaultProps, baseProps);\n const { size, children, onClick } = props;\n let avatarRef = React.useRef<IGroup>(null);\n avatarRef = ref ? (ref as React.RefObject<IGroup>) : avatarRef;\n\n const handleClick: React.MouseEventHandler<HTMLElement> = React.useCallback(\n (event: any): void => {\n onClick && onClick(event);\n },\n [onClick]\n );\n\n const groupAttribute = getGroupAttribute(props);\n if (isString(children)) {\n const textAttribute = getTextAttribute(props);\n return (\n <Group ref={avatarRef} attribute={groupAttribute} onClick={handleClick}>\n <Text attribute={textAttribute}></Text>\n </Group>\n );\n }\n if ((children as ReactElement).type === 'image') {\n (children as ReactElement).props.attribute.width = size;\n (children as ReactElement).props.attribute.height = size;\n }\n return (\n <Group ref={avatarRef} attribute={groupAttribute} onClick={handleClick}>\n {children}\n </Group>\n );\n}\n\nfunction getTextAttribute(props: AvatarProps) {\n const { textStyle, size, children, autoFixFontSize } = props;\n\n const attribute: ITextGraphicAttribute = {\n text: children as string,\n ...textStyle\n };\n\n if (autoFixFontSize) {\n getAutoFixFontSize(size, attribute);\n }\n\n return attribute;\n}\nfunction getGroupAttribute(props: AvatarProps) {\n const { panelStyle, size, shape } = props;\n const attribute: IGroupAttribute = {\n ...panelStyle,\n width: size,\n height: size,\n clip: true,\n cornerRadius: shape === 'circle' ? size / 2 : panelStyle.cornerRadius ?? 2,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n visibleAll: true,\n path: undefined\n };\n return attribute;\n}\n\nexport const Avatar = React.forwardRef<IGroup, AvatarProps>(AvatarComponent);\n\nAvatar.displayName = 'Avatar';\n\n// auto adjust font size\nfunction getAutoFixFontSize(size: number, attribute: ITextGraphicAttribute) {\n const textWidth = measureTextSize(attribute.text, attribute).width;\n const scale = size / (textWidth + 8);\n const fontSize = Math.max(Math.floor(attribute.fontSize * scale), 6);\n attribute.fontSize = fontSize;\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import type { BackgroundAttributes, Cursor, IRectGraphicAttribute, ITextGraphicAttribute, Padding, Tag } from '@visactor/vtable/es/vrender';
2
+ import React from 'react';
3
+ interface ButtonStateStyle {
4
+ textStyle?: {
5
+ hover?: Partial<ITextGraphicAttribute>;
6
+ disabled?: Partial<ITextGraphicAttribute>;
7
+ };
8
+ panelStyle?: {
9
+ hover?: Partial<IRectGraphicAttribute>;
10
+ disabled?: Partial<IRectGraphicAttribute>;
11
+ };
12
+ }
13
+ export interface ButtonProps {
14
+ children?: string;
15
+ textStyle?: Partial<ITextGraphicAttribute>;
16
+ padding?: Padding;
17
+ panelStyle?: BackgroundAttributes;
18
+ minWidth?: number;
19
+ maxWidth?: number;
20
+ visible?: boolean;
21
+ state?: ButtonStateStyle;
22
+ disabled?: boolean;
23
+ cursor?: Cursor;
24
+ onClick?: (e: Event) => void;
25
+ }
26
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<Tag>>;
27
+ export {};
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
15
+ Object.defineProperty(o, "default", {
16
+ enumerable: !0,
17
+ value: v
18
+ });
19
+ } : function(o, v) {
20
+ o.default = v;
21
+ }), __importStar = this && this.__importStar || function(mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
25
+ return __setModuleDefault(result, mod), result;
26
+ };
27
+
28
+ Object.defineProperty(exports, "__esModule", {
29
+ value: !0
30
+ }), exports.Button = void 0;
31
+
32
+ const tag_1 = require("../vrender-components/tag"), vutils_1 = require("@visactor/vutils"), react_1 = __importStar(require("react")), defaultProps = {
33
+ textStyle: {
34
+ fontSize: 14,
35
+ fontFamily: "sans-serif",
36
+ fill: "#FFF"
37
+ },
38
+ panelStyle: {
39
+ visible: !0,
40
+ fill: "rgb(22, 93, 255)",
41
+ lineWidth: 1,
42
+ cornerRadius: 2
43
+ },
44
+ padding: 10,
45
+ state: {
46
+ panelStyle: {
47
+ hover: {
48
+ fill: "rgb(64, 128, 255)"
49
+ },
50
+ disabled: {
51
+ fill: "rgb(148, 191, 255)"
52
+ }
53
+ }
54
+ }
55
+ };
56
+
57
+ function ButtonComponent(baseProps, ref) {
58
+ const props = (0, vutils_1.merge)({}, defaultProps, baseProps), {disabled: disabled, onClick: onClick} = props;
59
+ let buttonRef = react_1.default.useRef(null);
60
+ buttonRef = ref || buttonRef;
61
+ const handleClick = react_1.default.useCallback((event => {
62
+ disabled ? "function" == typeof (null == event ? void 0 : event.preventDefault) && event.preventDefault() : onClick && onClick(event);
63
+ }), [ disabled, onClick ]), attribute = getTagAttribute(props);
64
+ return (0, react_1.useEffect)((() => {
65
+ buttonRef.current.addEventListener("mouseenter", (() => {
66
+ disabled || (buttonRef.current.addState("hover", !0, !1), buttonRef.current.stage.renderNextFrame());
67
+ })), buttonRef.current.addEventListener("mouseleave", (() => {
68
+ disabled || (buttonRef.current.removeState("hover", !1), buttonRef.current.stage.renderNextFrame());
69
+ }));
70
+ })), (0, react_1.useEffect)((() => {
71
+ disabled ? (buttonRef.current.removeState("disabled", !1), buttonRef.current.addState("disabled", !0, !1)) : buttonRef.current.removeState("disabled", !1),
72
+ buttonRef.current.stage.renderNextFrame();
73
+ })), react_1.default.createElement(tag_1.Tag, {
74
+ ref: buttonRef,
75
+ attribute: attribute,
76
+ onClick: handleClick
77
+ });
78
+ }
79
+
80
+ function getTagAttribute(props) {
81
+ var _a, _b, _c, _d;
82
+ const {textStyle: textStyle, padding: padding, panelStyle: panelStyle, minWidth: minWidth, maxWidth: maxWidth, visible: visible, cursor: cursor, disabled: disabled, state: state, children: children} = props;
83
+ return {
84
+ text: children,
85
+ textStyle: textStyle,
86
+ padding: padding,
87
+ panel: panelStyle,
88
+ minWidth: minWidth,
89
+ maxWidth: maxWidth,
90
+ visible: visible,
91
+ cursor: (null != cursor ? cursor : disabled) ? "not-allowed" : "pointer",
92
+ childrenPickable: !1,
93
+ state: {
94
+ text: {
95
+ hover: null === (_a = null == state ? void 0 : state.textStyle) || void 0 === _a ? void 0 : _a.hover,
96
+ disabled: null === (_b = null == state ? void 0 : state.textStyle) || void 0 === _b ? void 0 : _b.disabled
97
+ },
98
+ panel: {
99
+ hover: null === (_c = null == state ? void 0 : state.panelStyle) || void 0 === _c ? void 0 : _c.hover,
100
+ disabled: null === (_d = null == state ? void 0 : state.panelStyle) || void 0 === _d ? void 0 : _d.disabled
101
+ }
102
+ }
103
+ };
104
+ }
105
+
106
+ exports.Button = react_1.default.forwardRef(ButtonComponent), exports.Button.displayName = "Button";
107
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/button/button.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASA,mDAAwD;AACxD,6CAAyC;AACzC,+CAAyC;AA2BzC,MAAM,YAAY,GAAgB;IAChC,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;KACb;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,kBAAkB;QACxB,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;KAChB;IACD,OAAO,EAAE,EAAE;IAEX,KAAK,EAAE;QACL,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,mBAAmB;aAC1B;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,oBAAoB;aAC3B;SACF;KACF;CACF,CAAC;AAEF,SAAS,eAAe,CAAC,SAAsB,EAAE,GAAmB;IAClE,MAAM,KAAK,GAAgB,IAAA,cAAK,EAAC,EAAE,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAC9D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACpC,IAAI,SAAS,GAAG,eAAK,CAAC,MAAM,CAAM,IAAI,CAAC,CAAC;IACxC,SAAS,GAAG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OAAO,IAAI,CAAC;AACd,CAAC;AAEY,QAAA,MAAM,GAAG,eAAK,CAAC,UAAU,CAAmB,eAAe,CAAC,CAAC;AAE1E,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","file":"button.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport { merge } from '@visactor/vutils';\nimport React, { useEffect } from 'react';\n\ninterface ButtonStateStyle {\n textStyle?: {\n hover?: Partial<ITextGraphicAttribute>;\n disabled?: Partial<ITextGraphicAttribute>;\n };\n panelStyle?: {\n hover?: Partial<IRectGraphicAttribute>;\n disabled?: Partial<IRectGraphicAttribute>;\n };\n}\n\nexport interface ButtonProps {\n children?: string;\n textStyle?: Partial<ITextGraphicAttribute>;\n padding?: Padding;\n panelStyle?: BackgroundAttributes;\n minWidth?: number;\n maxWidth?: number;\n visible?: boolean;\n state?: ButtonStateStyle;\n disabled?: boolean;\n cursor?: Cursor;\n onClick?: (e: Event) => void;\n}\n\nconst defaultProps: ButtonProps = {\n textStyle: {\n fontSize: 14,\n fontFamily: 'sans-serif',\n fill: '#FFF'\n },\n panelStyle: {\n visible: true,\n fill: 'rgb(22, 93, 255)',\n lineWidth: 1,\n cornerRadius: 2\n },\n padding: 10,\n // cursor: 'pointer',\n state: {\n panelStyle: {\n hover: {\n fill: 'rgb(64, 128, 255)'\n },\n disabled: {\n fill: 'rgb(148, 191, 255)'\n }\n }\n }\n};\n\nfunction ButtonComponent(baseProps: ButtonProps, ref: React.Ref<Tag>) {\n const props: ButtonProps = merge({}, defaultProps, baseProps);\n const { disabled, onClick } = props;\n let buttonRef = React.useRef<Tag>(null);\n buttonRef = ref ? (ref as React.RefObject<Tag>) : buttonRef;\n\n const handleClick: React.MouseEventHandler<HTMLElement> = React.useCallback(\n (event: any): void => {\n if (disabled) {\n typeof event?.preventDefault === 'function' && event.preventDefault();\n return;\n }\n onClick && onClick(event);\n },\n [disabled, onClick]\n );\n\n const attribute: TagAttributes = getTagAttribute(props);\n\n useEffect(() => {\n buttonRef.current.addEventListener('mouseenter', () => {\n // console.log('mouseenter', buttonRef.current, e.clone());\n if (!disabled) {\n buttonRef.current.addState('hover', true, false);\n // buttonRef.current._bgRect.addState('hover', true, false);\n // buttonRef.current._textShape.addState('hover', true, false);\n buttonRef.current.stage.renderNextFrame();\n }\n });\n buttonRef.current.addEventListener('mouseleave', () => {\n // console.log('mouseleave', buttonRef.current, e.clone());\n if (!disabled) {\n buttonRef.current.removeState('hover', false);\n // buttonRef.current._bgRect.removeState('hover', false);\n // buttonRef.current._textShape.removeState('hover', false);\n buttonRef.current.stage.renderNextFrame();\n }\n });\n });\n\n useEffect(() => {\n if (disabled) {\n buttonRef.current.removeState('disabled', false);\n // buttonRef.current._bgRect.removeState('disabled', false);\n // buttonRef.current._textShape.removeState('disabled', false);\n\n buttonRef.current.addState('disabled', true, false);\n // buttonRef.current._bgRect.addState('disabled', true, false);\n // buttonRef.current._textShape.addState('disabled', true, false);\n // console.log('add disable');\n } else {\n buttonRef.current.removeState('disabled', false);\n // buttonRef.current._bgRect.removeState('disabled', false);\n // buttonRef.current._textShape.removeState('disabled', false);\n // console.log('remove disable');\n }\n buttonRef.current.stage.renderNextFrame();\n });\n\n return <VTag ref={buttonRef} attribute={attribute} onClick={handleClick}></VTag>;\n}\n\nfunction getTagAttribute(props: ButtonProps) {\n const { textStyle, padding, panelStyle, minWidth, maxWidth, visible, cursor, disabled, state, children } = props;\n const attr: TagAttributes = {\n text: children,\n textStyle,\n padding,\n panel: panelStyle,\n minWidth,\n maxWidth,\n visible,\n cursor: cursor ?? disabled ? 'not-allowed' : 'pointer',\n childrenPickable: false,\n state: {\n text: {\n hover: state?.textStyle?.hover,\n disabled: state?.textStyle?.disabled\n },\n panel: {\n hover: state?.panelStyle?.hover,\n disabled: state?.panelStyle?.disabled\n }\n }\n };\n\n return attr;\n}\n\nexport const Button = React.forwardRef<Tag, ButtonProps>(ButtonComponent);\n\nButton.displayName = 'Button';\n"]}
@@ -0,0 +1,17 @@
1
+ import type { Cursor, CheckBox as VRenderCheckbox, CheckboxAttributes } from '@visactor/vtable/es/vrender';
2
+ import React from 'react';
3
+ export interface CheckboxProps {
4
+ children?: string;
5
+ textStyle?: CheckboxAttributes['text'];
6
+ boxStyle?: CheckboxAttributes['box'];
7
+ iconStyle?: CheckboxAttributes['icon'];
8
+ checked?: boolean;
9
+ indeterminate?: boolean;
10
+ interactive?: boolean;
11
+ disabled?: boolean;
12
+ disableCursor?: Cursor;
13
+ spaceBetweenTextAndIcon?: number;
14
+ visible?: boolean;
15
+ onChange?: (checked: boolean) => void;
16
+ }
17
+ export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<VRenderCheckbox>>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
15
+ Object.defineProperty(o, "default", {
16
+ enumerable: !0,
17
+ value: v
18
+ });
19
+ } : function(o, v) {
20
+ o.default = v;
21
+ }), __importStar = this && this.__importStar || function(mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
25
+ return __setModuleDefault(result, mod), result;
26
+ }, __rest = this && this.__rest || function(s, e) {
27
+ var t = {};
28
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
29
+ if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
30
+ var i = 0;
31
+ for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
32
+ }
33
+ return t;
34
+ };
35
+
36
+ Object.defineProperty(exports, "__esModule", {
37
+ value: !0
38
+ }), exports.Checkbox = void 0;
39
+
40
+ const checkbox_1 = require("../vrender-components/checkbox"), vutils_1 = require("@visactor/vutils"), react_1 = __importStar(require("react")), defaultProps = {};
41
+
42
+ function CheckboxComponent(baseProps, ref) {
43
+ const props = (0, vutils_1.merge)({}, defaultProps, baseProps), {textStyle: textStyle, boxStyle: boxStyle, iconStyle: iconStyle, children: children} = props, rest = __rest(props, [ "textStyle", "boxStyle", "iconStyle", "children" ]);
44
+ let checkboxRef = react_1.default.useRef(null);
45
+ checkboxRef = ref || checkboxRef;
46
+ const handleChange = (0, react_1.useCallback)((event => {
47
+ props.onChange && props.onChange(event.target.attribute.checked);
48
+ }), []);
49
+ return (0, react_1.useEffect)((() => {
50
+ var _a;
51
+ return null === (_a = checkboxRef.current) || void 0 === _a || _a.addEventListener("checkbox_state_change", handleChange),
52
+ () => {
53
+ var _a;
54
+ null === (_a = checkboxRef.current) || void 0 === _a || _a.removeEventListener("checkbox_state_change", handleChange);
55
+ };
56
+ }), []), react_1.default.createElement(checkbox_1.Checkbox, {
57
+ ref: checkboxRef,
58
+ attribute: Object.assign({
59
+ text: Object.assign(Object.assign({}, textStyle), {
60
+ text: children
61
+ }),
62
+ box: boxStyle,
63
+ icon: iconStyle
64
+ }, rest)
65
+ });
66
+ }
67
+
68
+ exports.Checkbox = react_1.default.forwardRef(CheckboxComponent), exports.Checkbox.displayName = "Checkbox";
69
+ //# sourceMappingURL=checkbox.js.map
@@ -0,0 +1 @@
1
+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AI,EAAE,SAAS,IACZ,IAAI,IAEE,CACd,CAAC;AACJ,CAAC;AAEY,QAAA,QAAQ,GAAG,eAAK,CAAC,UAAU,CAAiC,iBAAiB,CAAC,CAAC;AAE5F,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","file":"checkbox.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n CheckBox as VRenderCheckbox,\n CheckboxAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Checkbox as VCheckbox } from '../vrender-components/checkbox';\nimport { merge } from '@visactor/vutils';\nimport React, { useCallback, useEffect } from 'react';\n\nexport interface CheckboxProps {\n children?: string;\n textStyle?: CheckboxAttributes['text'];\n boxStyle?: CheckboxAttributes['box'];\n iconStyle?: CheckboxAttributes['icon'];\n checked?: boolean;\n indeterminate?: boolean;\n interactive?: boolean;\n disabled?: boolean;\n disableCursor?: Cursor;\n spaceBetweenTextAndIcon?: number;\n visible?: boolean;\n onChange?: (checked: boolean) => void;\n}\n\nconst defaultProps: CheckboxProps = {};\n\nfunction CheckboxComponent(baseProps: CheckboxProps, ref: React.Ref<VRenderCheckbox>) {\n const props: CheckboxProps = merge({}, defaultProps, baseProps);\n const { textStyle, boxStyle, iconStyle, children, ...rest } = props;\n let checkboxRef = React.useRef<VRenderCheckbox>(null);\n checkboxRef = ref ? (ref as React.RefObject<VRenderCheckbox>) : checkboxRef;\n\n const handleChange = useCallback((event: { target: VRenderCheckbox }) => {\n props.onChange && props.onChange(event.target.attribute.checked);\n }, []);\n\n useEffect(() => {\n checkboxRef.current?.addEventListener('checkbox_state_change', handleChange);\n return () => {\n checkboxRef.current?.removeEventListener('checkbox_state_change', handleChange);\n };\n }, []);\n\n return (\n <VCheckbox\n ref={checkboxRef}\n attribute={{\n text: {\n ...textStyle,\n text: children\n },\n box: boxStyle,\n icon: iconStyle,\n ...rest\n }}\n ></VCheckbox>\n );\n}\n\nexport const Checkbox = React.forwardRef<VRenderCheckbox, CheckboxProps>(CheckboxComponent);\n\nCheckbox.displayName = 'Checkbox';\n"]}
@@ -1,19 +1,7 @@
1
- import type React from 'react';
2
- export { ListColumn } from './list/list-column';
3
- export { PivotColumnDimension, PivotRowDimension } from './pivot/pivot-dimension';
4
- export { PivotIndicator } from './pivot/pivot-indicator';
5
- export { PivotColumnHeaderTitle, PivotRowHeaderTitle } from './pivot/pivot-header-title';
6
- export { PivotCorner } from './pivot/pivot-corner';
7
- export { Menu } from './component/menu';
8
- export { Tooltip } from './component/tooltip';
9
- export { EmptyTip } from './component/emptyTip';
10
- export { CustomComponent } from './custom-component';
11
- export { CustomLayout, type CustomLayoutFunctionArg } from './custom/custom-layout';
12
- export * from './custom/graphic';
13
- export * from './custom/component';
14
- type Props = {
15
- updateId?: number;
16
- };
17
- export interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {
18
- id: string | number;
19
- }
1
+ export * from './button/button';
2
+ export * from './link/link';
3
+ export * from './avatar/avatar';
4
+ export * from './popover/popover';
5
+ export * from './tag/tag';
6
+ export * from './radio/radio';
7
+ export * from './checkbox/checkbox';
@@ -17,105 +17,8 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
17
17
 
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
- }), exports.CustomLayout = exports.CustomComponent = exports.EmptyTip = exports.Tooltip = exports.Menu = exports.PivotCorner = exports.PivotRowHeaderTitle = exports.PivotColumnHeaderTitle = exports.PivotIndicator = exports.PivotRowDimension = exports.PivotColumnDimension = exports.ListColumn = void 0;
21
-
22
- var list_column_1 = require("./list/list-column");
23
-
24
- Object.defineProperty(exports, "ListColumn", {
25
- enumerable: !0,
26
- get: function() {
27
- return list_column_1.ListColumn;
28
- }
29
- });
30
-
31
- var pivot_dimension_1 = require("./pivot/pivot-dimension");
32
-
33
- Object.defineProperty(exports, "PivotColumnDimension", {
34
- enumerable: !0,
35
- get: function() {
36
- return pivot_dimension_1.PivotColumnDimension;
37
- }
38
- }), Object.defineProperty(exports, "PivotRowDimension", {
39
- enumerable: !0,
40
- get: function() {
41
- return pivot_dimension_1.PivotRowDimension;
42
- }
43
- });
44
-
45
- var pivot_indicator_1 = require("./pivot/pivot-indicator");
46
-
47
- Object.defineProperty(exports, "PivotIndicator", {
48
- enumerable: !0,
49
- get: function() {
50
- return pivot_indicator_1.PivotIndicator;
51
- }
52
- });
53
-
54
- var pivot_header_title_1 = require("./pivot/pivot-header-title");
55
-
56
- Object.defineProperty(exports, "PivotColumnHeaderTitle", {
57
- enumerable: !0,
58
- get: function() {
59
- return pivot_header_title_1.PivotColumnHeaderTitle;
60
- }
61
- }), Object.defineProperty(exports, "PivotRowHeaderTitle", {
62
- enumerable: !0,
63
- get: function() {
64
- return pivot_header_title_1.PivotRowHeaderTitle;
65
- }
66
- });
67
-
68
- var pivot_corner_1 = require("./pivot/pivot-corner");
69
-
70
- Object.defineProperty(exports, "PivotCorner", {
71
- enumerable: !0,
72
- get: function() {
73
- return pivot_corner_1.PivotCorner;
74
- }
75
- });
76
-
77
- var menu_1 = require("./component/menu");
78
-
79
- Object.defineProperty(exports, "Menu", {
80
- enumerable: !0,
81
- get: function() {
82
- return menu_1.Menu;
83
- }
84
- });
85
-
86
- var tooltip_1 = require("./component/tooltip");
87
-
88
- Object.defineProperty(exports, "Tooltip", {
89
- enumerable: !0,
90
- get: function() {
91
- return tooltip_1.Tooltip;
92
- }
93
- });
94
-
95
- var emptyTip_1 = require("./component/emptyTip");
96
-
97
- Object.defineProperty(exports, "EmptyTip", {
98
- enumerable: !0,
99
- get: function() {
100
- return emptyTip_1.EmptyTip;
101
- }
102
- });
103
-
104
- var custom_component_1 = require("./custom-component");
105
-
106
- Object.defineProperty(exports, "CustomComponent", {
107
- enumerable: !0,
108
- get: function() {
109
- return custom_component_1.CustomComponent;
110
- }
111
- });
112
-
113
- var custom_layout_1 = require("./custom/custom-layout");
114
-
115
- Object.defineProperty(exports, "CustomLayout", {
116
- enumerable: !0,
117
- get: function() {
118
- return custom_layout_1.CustomLayout;
119
- }
120
- }), __exportStar(require("./custom/graphic"), exports), __exportStar(require("./custom/component"), exports);
20
+ }), __exportStar(require("./button/button"), exports), __exportStar(require("./link/link"), exports),
21
+ __exportStar(require("./avatar/avatar"), exports), __exportStar(require("./popover/popover"), exports),
22
+ __exportStar(require("./tag/tag"), exports), __exportStar(require("./radio/radio"), exports),
23
+ __exportStar(require("./checkbox/checkbox"), exports);
121
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,kDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,2DAAkF;AAAzE,uHAAA,oBAAoB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAChD,2DAAyD;AAAhD,iHAAA,cAAc,OAAA;AACvB,iEAAyF;AAAhF,4HAAA,sBAAsB,OAAA;AAAE,yHAAA,mBAAmB,OAAA;AACpD,qDAAmD;AAA1C,2GAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,4FAAA,IAAI,OAAA;AACb,+CAA8C;AAArC,kGAAA,OAAO,OAAA;AAChB,iDAAgD;AAAvC,oGAAA,QAAQ,OAAA;AAEjB,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,wDAAoF;AAA3E,6GAAA,YAAY,OAAA;AACrB,mDAAiC;AACjC,qDAAmC","file":"index.js","sourcesContent":["import type React from 'react';\nexport { ListColumn } from './list/list-column';\nexport { PivotColumnDimension, PivotRowDimension } from './pivot/pivot-dimension';\nexport { PivotIndicator } from './pivot/pivot-indicator';\nexport { PivotColumnHeaderTitle, PivotRowHeaderTitle } from './pivot/pivot-header-title';\nexport { PivotCorner } from './pivot/pivot-corner';\nexport { Menu } from './component/menu';\nexport { Tooltip } from './component/tooltip';\nexport { EmptyTip } from './component/emptyTip';\n\nexport { CustomComponent } from './custom-component';\nexport { CustomLayout, type CustomLayoutFunctionArg } from './custom/custom-layout';\nexport * from './custom/graphic';\nexport * from './custom/component';\n\ntype Props = { updateId?: number };\n\nexport interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {\n id: string | number;\n}\n"]}
1
+ {"version":3,"sources":["components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,kDAAgC;AAChC,8CAA4B;AAC5B,kDAAgC;AAChC,oDAAkC;AAClC,4CAA0B;AAC1B,gDAA8B;AAC9B,sDAAoC","file":"index.js","sourcesContent":["// export * from './vrender-components/tag';\n// export * from './vrender-components/checkbox';\n// export * from './vrender-components/radio';\nexport * from './button/button';\nexport * from './link/link';\nexport * from './avatar/avatar';\nexport * from './popover/popover';\nexport * from './tag/tag';\nexport * from './radio/radio';\nexport * from './checkbox/checkbox';\n"]}
@@ -0,0 +1,30 @@
1
+ import type { BackgroundAttributes, Cursor, IRectGraphicAttribute, ITextGraphicAttribute, Padding, Tag } from '@visactor/vtable/es/vrender';
2
+ import React from 'react';
3
+ interface LinkStateStyle {
4
+ textStyle?: {
5
+ hover?: Partial<ITextGraphicAttribute>;
6
+ disabled?: Partial<ITextGraphicAttribute>;
7
+ };
8
+ panelStyle?: {
9
+ hover?: Partial<IRectGraphicAttribute>;
10
+ disabled?: Partial<IRectGraphicAttribute>;
11
+ };
12
+ }
13
+ export interface LinkProps {
14
+ children?: string;
15
+ textStyle?: Partial<ITextGraphicAttribute>;
16
+ padding?: Padding;
17
+ space?: number;
18
+ panelStyle?: BackgroundAttributes;
19
+ minWidth?: number;
20
+ maxWidth?: number;
21
+ visible?: boolean;
22
+ state?: LinkStateStyle;
23
+ disabled?: boolean;
24
+ icon?: boolean;
25
+ cursor?: Cursor;
26
+ href?: string;
27
+ onClick?: (e: Event) => void;
28
+ }
29
+ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<Tag>>;
30
+ export {};