@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.
- package/cjs/components/avatar/avatar.d.ts +15 -0
- package/cjs/components/avatar/avatar.js +84 -0
- package/cjs/components/avatar/avatar.js.map +1 -0
- package/cjs/components/button/button.d.ts +27 -0
- package/cjs/components/button/button.js +107 -0
- package/cjs/components/button/button.js.map +1 -0
- package/cjs/components/checkbox/checkbox.d.ts +17 -0
- package/cjs/components/checkbox/checkbox.js +69 -0
- package/cjs/components/checkbox/checkbox.js.map +1 -0
- package/cjs/components/index.d.ts +7 -19
- package/cjs/components/index.js +4 -101
- package/cjs/components/index.js.map +1 -1
- package/cjs/components/link/link.d.ts +30 -0
- package/cjs/components/link/link.js +118 -0
- package/cjs/components/link/link.js.map +1 -0
- package/cjs/components/popover/popover.d.ts +13 -0
- package/cjs/components/popover/popover.js +281 -0
- package/cjs/components/popover/popover.js.map +1 -0
- package/cjs/components/radio/radio.d.ts +15 -0
- package/cjs/components/radio/radio.js +64 -0
- package/cjs/components/radio/radio.js.map +1 -0
- package/cjs/components/tag/tag.d.ts +13 -0
- package/cjs/components/tag/tag.js +48 -0
- package/cjs/components/tag/tag.js.map +1 -0
- package/cjs/components/vrender-components/checkbox.d.ts +4 -0
- package/cjs/components/vrender-components/checkbox.js +6 -0
- package/cjs/components/vrender-components/checkbox.js.map +1 -0
- package/cjs/components/vrender-components/component-creater.d.ts +2 -0
- package/cjs/components/vrender-components/component-creater.js +22 -0
- package/cjs/components/vrender-components/component-creater.js.map +1 -0
- package/cjs/components/vrender-components/radio.d.ts +4 -0
- package/cjs/components/vrender-components/radio.js +6 -0
- package/cjs/components/vrender-components/radio.js.map +1 -0
- package/cjs/components/vrender-components/tag.d.ts +4 -0
- package/cjs/components/vrender-components/tag.js +6 -0
- package/cjs/components/vrender-components/tag.js.map +1 -0
- package/cjs/components/vrender-components/type.d.ts +6 -0
- package/cjs/components/vrender-components/type.js +6 -0
- package/cjs/components/vrender-components/type.js.map +1 -0
- package/cjs/constants.js +2 -1
- package/cjs/eventsUtils.d.ts +1 -1
- package/cjs/eventsUtils.js +1 -1
- package/cjs/eventsUtils.js.map +1 -1
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -1
- package/cjs/{components → table-components}/base-component.js +1 -0
- package/cjs/table-components/base-component.js.map +1 -0
- package/cjs/table-components/component/emptyTip.js.map +1 -0
- package/cjs/table-components/component/menu.js.map +1 -0
- package/cjs/table-components/component/title.d.ts +4 -0
- package/cjs/table-components/component/title.js +10 -0
- package/cjs/table-components/component/title.js.map +1 -0
- package/cjs/table-components/component/tooltip.js.map +1 -0
- package/cjs/{components → table-components}/custom/custom-layout.d.ts +1 -1
- package/cjs/{components → table-components}/custom/custom-layout.js +2 -6
- package/cjs/table-components/custom/custom-layout.js.map +1 -0
- package/{es/components → cjs/table-components}/custom/graphic.d.ts +1 -14
- package/cjs/table-components/custom/graphic.js.map +1 -0
- package/cjs/table-components/custom/reconciler.d.ts +5 -0
- package/cjs/{components → table-components}/custom/reconciler.js +12 -10
- package/cjs/table-components/custom/reconciler.js.map +1 -0
- package/cjs/table-components/custom/vtable-browser-env-contribution.d.ts +7 -0
- package/cjs/{components → table-components}/custom/vtable-browser-env-contribution.js +4 -4
- package/cjs/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
- package/{es/components → cjs/table-components}/custom/vtable-react-attribute-plugin.d.ts +2 -8
- package/cjs/{components → table-components}/custom/vtable-react-attribute-plugin.js +6 -6
- package/cjs/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
- package/cjs/table-components/custom-component.js.map +1 -0
- package/cjs/table-components/index.d.ts +19 -0
- package/cjs/table-components/index.js +130 -0
- package/cjs/table-components/index.js.map +1 -0
- package/cjs/table-components/list/list-column.js.map +1 -0
- package/cjs/table-components/pivot/pivot-corner.js.map +1 -0
- package/cjs/table-components/pivot/pivot-dimension.js.map +1 -0
- package/cjs/table-components/pivot/pivot-header-title.js.map +1 -0
- package/cjs/table-components/pivot/pivot-indicator.js.map +1 -0
- package/cjs/tables/base-table.d.ts +5 -4
- package/cjs/tables/base-table.js +7 -12
- package/cjs/tables/base-table.js.map +1 -1
- package/cjs/tables/index.d.ts +2 -0
- package/cjs/tables/index.js +19 -1
- package/cjs/tables/index.js.map +1 -1
- package/cjs/tables/list-table-simple.d.ts +8 -0
- package/cjs/tables/list-table-simple.js +13 -0
- package/cjs/tables/list-table-simple.js.map +1 -0
- package/cjs/tables/list-table.d.ts +1 -1
- package/cjs/tables/list-table.js +5 -2
- package/cjs/tables/list-table.js.map +1 -1
- package/cjs/tables/pivot-chart.d.ts +5 -1
- package/cjs/tables/pivot-chart.js +6 -29
- package/cjs/tables/pivot-chart.js.map +1 -1
- package/cjs/tables/pivot-table-simple.d.ts +8 -0
- package/cjs/tables/pivot-table-simple.js +13 -0
- package/cjs/tables/pivot-table-simple.js.map +1 -0
- package/cjs/tables/pivot-table.d.ts +1 -1
- package/cjs/tables/pivot-table.js +5 -2
- package/cjs/tables/pivot-table.js.map +1 -1
- package/cjs/util.js +1 -2
- package/cjs/vtable.d.ts +1 -2
- package/cjs/vtable.js +0 -33
- package/cjs/vtable.js.map +1 -1
- package/es/components/avatar/avatar.d.ts +15 -0
- package/es/components/avatar/avatar.js +82 -0
- package/es/components/avatar/avatar.js.map +1 -0
- package/es/components/button/button.d.ts +27 -0
- package/es/components/button/button.js +84 -0
- package/es/components/button/button.js.map +1 -0
- package/es/components/checkbox/checkbox.d.ts +17 -0
- package/es/components/checkbox/checkbox.js +48 -0
- package/es/components/checkbox/checkbox.js.map +1 -0
- package/es/components/index.d.ts +7 -19
- package/es/components/index.js +7 -17
- package/es/components/index.js.map +1 -1
- package/es/components/link/link.d.ts +30 -0
- package/es/components/link/link.js +95 -0
- package/es/components/link/link.js.map +1 -0
- package/es/components/popover/popover.d.ts +13 -0
- package/es/components/popover/popover.js +258 -0
- package/es/components/popover/popover.js.map +1 -0
- package/es/components/radio/radio.d.ts +15 -0
- package/es/components/radio/radio.js +43 -0
- package/es/components/radio/radio.js.map +1 -0
- package/es/components/tag/tag.d.ts +13 -0
- package/es/components/tag/tag.js +46 -0
- package/es/components/tag/tag.js.map +1 -0
- package/es/components/vrender-components/checkbox.d.ts +4 -0
- package/es/components/vrender-components/checkbox.js +2 -0
- package/es/components/vrender-components/checkbox.js.map +1 -0
- package/es/components/vrender-components/component-creater.d.ts +2 -0
- package/es/components/vrender-components/component-creater.js +14 -0
- package/es/components/vrender-components/component-creater.js.map +1 -0
- package/es/components/vrender-components/radio.d.ts +4 -0
- package/es/components/vrender-components/radio.js +2 -0
- package/es/components/vrender-components/radio.js.map +1 -0
- package/es/components/vrender-components/tag.d.ts +4 -0
- package/es/components/vrender-components/tag.js +2 -0
- package/es/components/vrender-components/tag.js.map +1 -0
- package/es/components/vrender-components/type.d.ts +6 -0
- package/es/components/vrender-components/type.js +2 -0
- package/es/components/vrender-components/type.js.map +1 -0
- package/es/constants.js +2 -1
- package/es/eventsUtils.d.ts +1 -1
- package/es/eventsUtils.js +2 -2
- package/es/eventsUtils.js.map +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/{components → table-components}/base-component.js +2 -1
- package/es/table-components/base-component.js.map +1 -0
- package/es/table-components/component/emptyTip.js.map +1 -0
- package/es/table-components/component/menu.js.map +1 -0
- package/es/table-components/component/title.d.ts +4 -0
- package/es/table-components/component/title.js +4 -0
- package/es/table-components/component/title.js.map +1 -0
- package/es/table-components/component/tooltip.js.map +1 -0
- package/es/{components → table-components}/custom/custom-layout.d.ts +1 -1
- package/es/{components → table-components}/custom/custom-layout.js +1 -7
- package/es/table-components/custom/custom-layout.js.map +1 -0
- package/{cjs/components → es/table-components}/custom/graphic.d.ts +1 -14
- package/es/table-components/custom/graphic.js.map +1 -0
- package/es/table-components/custom/reconciler.d.ts +5 -0
- package/es/{components → table-components}/custom/reconciler.js +9 -8
- package/es/table-components/custom/reconciler.js.map +1 -0
- package/es/table-components/custom/vtable-browser-env-contribution.d.ts +7 -0
- package/es/{components → table-components}/custom/vtable-browser-env-contribution.js +3 -3
- package/es/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
- package/{cjs/components → es/table-components}/custom/vtable-react-attribute-plugin.d.ts +2 -8
- package/es/{components → table-components}/custom/vtable-react-attribute-plugin.js +1 -3
- package/es/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
- package/es/table-components/custom-component.js.map +1 -0
- package/es/table-components/index.d.ts +19 -0
- package/es/table-components/index.js +24 -0
- package/es/table-components/index.js.map +1 -0
- package/es/table-components/list/list-column.js.map +1 -0
- package/es/table-components/pivot/pivot-corner.js.map +1 -0
- package/es/table-components/pivot/pivot-dimension.js.map +1 -0
- package/es/table-components/pivot/pivot-header-title.js.map +1 -0
- package/es/table-components/pivot/pivot-indicator.js.map +1 -0
- package/es/tables/base-table.d.ts +5 -4
- package/es/tables/base-table.js +8 -15
- package/es/tables/base-table.js.map +1 -1
- package/es/tables/index.d.ts +2 -0
- package/es/tables/index.js +4 -0
- package/es/tables/index.js.map +1 -1
- package/es/tables/list-table-simple.d.ts +8 -0
- package/es/tables/list-table-simple.js +9 -0
- package/es/tables/list-table-simple.js.map +1 -0
- package/es/tables/list-table.d.ts +1 -1
- package/es/tables/list-table.js +6 -1
- package/es/tables/list-table.js.map +1 -1
- package/es/tables/pivot-chart.d.ts +5 -1
- package/es/tables/pivot-chart.js +8 -3
- package/es/tables/pivot-chart.js.map +1 -1
- package/es/tables/pivot-table-simple.d.ts +8 -0
- package/es/tables/pivot-table-simple.js +9 -0
- package/es/tables/pivot-table-simple.js.map +1 -0
- package/es/tables/pivot-table.d.ts +1 -1
- package/es/tables/pivot-table.js +6 -1
- package/es/tables/pivot-table.js.map +1 -1
- package/es/util.js +1 -2
- package/es/vtable.d.ts +1 -2
- package/es/vtable.js +1 -3
- package/es/vtable.js.map +1 -1
- package/package.json +5 -5
- package/cjs/components/base-component.js.map +0 -1
- package/cjs/components/component/emptyTip.js.map +0 -1
- package/cjs/components/component/menu.js.map +0 -1
- package/cjs/components/component/tooltip.js.map +0 -1
- package/cjs/components/custom/component.d.ts +0 -16
- package/cjs/components/custom/component.js +0 -7
- package/cjs/components/custom/component.js.map +0 -1
- package/cjs/components/custom/custom-layout.js.map +0 -1
- package/cjs/components/custom/graphic.js.map +0 -1
- package/cjs/components/custom/reconciler.d.ts +0 -5
- package/cjs/components/custom/reconciler.js.map +0 -1
- package/cjs/components/custom/vtable-browser-env-contribution.d.ts +0 -2
- package/cjs/components/custom/vtable-browser-env-contribution.js.map +0 -1
- package/cjs/components/custom/vtable-react-attribute-plugin.js.map +0 -1
- package/cjs/components/custom-component.js.map +0 -1
- package/cjs/components/list/list-column.js.map +0 -1
- package/cjs/components/pivot/pivot-corner.js.map +0 -1
- package/cjs/components/pivot/pivot-dimension.js.map +0 -1
- package/cjs/components/pivot/pivot-header-title.js.map +0 -1
- package/cjs/components/pivot/pivot-indicator.js.map +0 -1
- package/dist/react-vtable.js +0 -13799
- package/dist/react-vtable.min.js +0 -46
- package/es/components/base-component.js.map +0 -1
- package/es/components/component/emptyTip.js.map +0 -1
- package/es/components/component/menu.js.map +0 -1
- package/es/components/component/tooltip.js.map +0 -1
- package/es/components/custom/component.d.ts +0 -16
- package/es/components/custom/component.js +0 -6
- package/es/components/custom/component.js.map +0 -1
- package/es/components/custom/custom-layout.js.map +0 -1
- package/es/components/custom/graphic.js.map +0 -1
- package/es/components/custom/reconciler.d.ts +0 -5
- package/es/components/custom/reconciler.js.map +0 -1
- package/es/components/custom/vtable-browser-env-contribution.d.ts +0 -2
- package/es/components/custom/vtable-browser-env-contribution.js.map +0 -1
- package/es/components/custom/vtable-react-attribute-plugin.js.map +0 -1
- package/es/components/custom-component.js.map +0 -1
- package/es/components/list/list-column.js.map +0 -1
- package/es/components/pivot/pivot-corner.js.map +0 -1
- package/es/components/pivot/pivot-dimension.js.map +0 -1
- package/es/components/pivot/pivot-header-title.js.map +0 -1
- package/es/components/pivot/pivot-indicator.js.map +0 -1
- /package/cjs/{components → table-components}/base-component.d.ts +0 -0
- /package/cjs/{components → table-components}/component/emptyTip.d.ts +0 -0
- /package/cjs/{components → table-components}/component/emptyTip.js +0 -0
- /package/cjs/{components → table-components}/component/menu.d.ts +0 -0
- /package/cjs/{components → table-components}/component/menu.js +0 -0
- /package/cjs/{components → table-components}/component/tooltip.d.ts +0 -0
- /package/cjs/{components → table-components}/component/tooltip.js +0 -0
- /package/cjs/{components → table-components}/custom/graphic.js +0 -0
- /package/cjs/{components → table-components}/custom-component.d.ts +0 -0
- /package/cjs/{components → table-components}/custom-component.js +0 -0
- /package/cjs/{components → table-components}/list/list-column.d.ts +0 -0
- /package/cjs/{components → table-components}/list/list-column.js +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-corner.d.ts +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-corner.js +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-dimension.d.ts +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-dimension.js +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-header-title.d.ts +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-header-title.js +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-indicator.d.ts +0 -0
- /package/cjs/{components → table-components}/pivot/pivot-indicator.js +0 -0
- /package/es/{components → table-components}/base-component.d.ts +0 -0
- /package/es/{components → table-components}/component/emptyTip.d.ts +0 -0
- /package/es/{components → table-components}/component/emptyTip.js +0 -0
- /package/es/{components → table-components}/component/menu.d.ts +0 -0
- /package/es/{components → table-components}/component/menu.js +0 -0
- /package/es/{components → table-components}/component/tooltip.d.ts +0 -0
- /package/es/{components → table-components}/component/tooltip.js +0 -0
- /package/es/{components → table-components}/custom/graphic.js +0 -0
- /package/es/{components → table-components}/custom-component.d.ts +0 -0
- /package/es/{components → table-components}/custom-component.js +0 -0
- /package/es/{components → table-components}/list/list-column.d.ts +0 -0
- /package/es/{components → table-components}/list/list-column.js +0 -0
- /package/es/{components → table-components}/pivot/pivot-corner.d.ts +0 -0
- /package/es/{components → table-components}/pivot/pivot-corner.js +0 -0
- /package/es/{components → table-components}/pivot/pivot-dimension.d.ts +0 -0
- /package/es/{components → table-components}/pivot/pivot-dimension.js +0 -0
- /package/es/{components → table-components}/pivot/pivot-header-title.d.ts +0 -0
- /package/es/{components → table-components}/pivot/pivot-header-title.js +0 -0
- /package/es/{components → table-components}/pivot/pivot-indicator.d.ts +0 -0
- /package/es/{components → table-components}/pivot/pivot-indicator.js +0 -0
package/cjs/vtable.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { VTable };
|
|
1
|
+
|
package/cjs/vtable.js
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
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.VTable = void 0;
|
|
31
|
-
|
|
32
|
-
const VTable = __importStar(require("@visactor/vtable"));
|
|
33
|
-
|
|
34
|
-
exports.VTable = VTable;
|
|
35
2
|
//# sourceMappingURL=vtable.js.map
|
package/cjs/vtable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["vtable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["vtable.ts"],"names":[],"mappings":"","file":"vtable.js","sourcesContent":["// import * as VTable from '@visactor/vtable';\n\n// export { VTable };\n"]}
|
|
@@ -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,82 @@
|
|
|
1
|
+
import { measureTextSize } from "@visactor/vtable/es/vrender";
|
|
2
|
+
|
|
3
|
+
import { isString, merge } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
import { Group, Text } from "../../table-components";
|
|
8
|
+
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
textStyle: {
|
|
11
|
+
fontSize: 14,
|
|
12
|
+
fontFamily: "sans-serif",
|
|
13
|
+
fill: "#FFF"
|
|
14
|
+
},
|
|
15
|
+
panelStyle: {
|
|
16
|
+
visible: !0,
|
|
17
|
+
fill: "rgb(201, 205, 212)",
|
|
18
|
+
lineWidth: 1,
|
|
19
|
+
cornerRadius: 2
|
|
20
|
+
},
|
|
21
|
+
size: 40,
|
|
22
|
+
shape: "circle",
|
|
23
|
+
autoFixFontSize: !0
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function AvatarComponent(baseProps, ref) {
|
|
27
|
+
const props = merge({}, defaultProps, baseProps), {size: size, children: children, onClick: onClick} = props;
|
|
28
|
+
let avatarRef = React.useRef(null);
|
|
29
|
+
avatarRef = ref || avatarRef;
|
|
30
|
+
const handleClick = React.useCallback((event => {
|
|
31
|
+
onClick && onClick(event);
|
|
32
|
+
}), [ onClick ]), groupAttribute = getGroupAttribute(props);
|
|
33
|
+
if (isString(children)) {
|
|
34
|
+
const textAttribute = getTextAttribute(props);
|
|
35
|
+
return React.createElement(Group, {
|
|
36
|
+
ref: avatarRef,
|
|
37
|
+
attribute: groupAttribute,
|
|
38
|
+
onClick: handleClick
|
|
39
|
+
}, React.createElement(Text, {
|
|
40
|
+
attribute: textAttribute
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
return "image" === children.type && (children.props.attribute.width = size, children.props.attribute.height = size),
|
|
44
|
+
React.createElement(Group, {
|
|
45
|
+
ref: avatarRef,
|
|
46
|
+
attribute: groupAttribute,
|
|
47
|
+
onClick: handleClick
|
|
48
|
+
}, children);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getTextAttribute(props) {
|
|
52
|
+
const {textStyle: textStyle, size: size, children: children, autoFixFontSize: autoFixFontSize} = props, attribute = Object.assign({
|
|
53
|
+
text: children
|
|
54
|
+
}, textStyle);
|
|
55
|
+
return autoFixFontSize && getAutoFixFontSize(size, attribute), attribute;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getGroupAttribute(props) {
|
|
59
|
+
var _a;
|
|
60
|
+
const {panelStyle: panelStyle, size: size, shape: shape} = props;
|
|
61
|
+
return Object.assign(Object.assign({}, panelStyle), {
|
|
62
|
+
width: size,
|
|
63
|
+
height: size,
|
|
64
|
+
clip: !0,
|
|
65
|
+
cornerRadius: "circle" === shape ? size / 2 : null !== (_a = panelStyle.cornerRadius) && void 0 !== _a ? _a : 2,
|
|
66
|
+
display: "flex",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
visibleAll: !0,
|
|
70
|
+
path: void 0
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const Avatar = React.forwardRef(AvatarComponent);
|
|
75
|
+
|
|
76
|
+
function getAutoFixFontSize(size, attribute) {
|
|
77
|
+
const scale = size / (measureTextSize(attribute.text, attribute).width + 8), fontSize = Math.max(Math.floor(attribute.fontSize * scale), 6);
|
|
78
|
+
attribute.fontSize = fontSize;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=avatar.js.map
|
|
82
|
+
Avatar.displayName = "Avatar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/avatar/avatar.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAQhB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,KAAK,EAAS,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAc5D,MAAM,YAAY,GAAgB;IAChC,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAA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E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,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,84 @@
|
|
|
1
|
+
import { Tag as VTag } from "../vrender-components/tag";
|
|
2
|
+
|
|
3
|
+
import { merge } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import React, { useEffect } from "react";
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
textStyle: {
|
|
9
|
+
fontSize: 14,
|
|
10
|
+
fontFamily: "sans-serif",
|
|
11
|
+
fill: "#FFF"
|
|
12
|
+
},
|
|
13
|
+
panelStyle: {
|
|
14
|
+
visible: !0,
|
|
15
|
+
fill: "rgb(22, 93, 255)",
|
|
16
|
+
lineWidth: 1,
|
|
17
|
+
cornerRadius: 2
|
|
18
|
+
},
|
|
19
|
+
padding: 10,
|
|
20
|
+
state: {
|
|
21
|
+
panelStyle: {
|
|
22
|
+
hover: {
|
|
23
|
+
fill: "rgb(64, 128, 255)"
|
|
24
|
+
},
|
|
25
|
+
disabled: {
|
|
26
|
+
fill: "rgb(148, 191, 255)"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function ButtonComponent(baseProps, ref) {
|
|
33
|
+
const props = merge({}, defaultProps, baseProps), {disabled: disabled, onClick: onClick} = props;
|
|
34
|
+
let buttonRef = React.useRef(null);
|
|
35
|
+
buttonRef = ref || buttonRef;
|
|
36
|
+
const handleClick = React.useCallback((event => {
|
|
37
|
+
disabled ? "function" == typeof (null == event ? void 0 : event.preventDefault) && event.preventDefault() : onClick && onClick(event);
|
|
38
|
+
}), [ disabled, onClick ]), attribute = getTagAttribute(props);
|
|
39
|
+
return useEffect((() => {
|
|
40
|
+
buttonRef.current.addEventListener("mouseenter", (() => {
|
|
41
|
+
disabled || (buttonRef.current.addState("hover", !0, !1), buttonRef.current.stage.renderNextFrame());
|
|
42
|
+
})), buttonRef.current.addEventListener("mouseleave", (() => {
|
|
43
|
+
disabled || (buttonRef.current.removeState("hover", !1), buttonRef.current.stage.renderNextFrame());
|
|
44
|
+
}));
|
|
45
|
+
})), useEffect((() => {
|
|
46
|
+
disabled ? (buttonRef.current.removeState("disabled", !1), buttonRef.current.addState("disabled", !0, !1)) : buttonRef.current.removeState("disabled", !1),
|
|
47
|
+
buttonRef.current.stage.renderNextFrame();
|
|
48
|
+
})), React.createElement(VTag, {
|
|
49
|
+
ref: buttonRef,
|
|
50
|
+
attribute: attribute,
|
|
51
|
+
onClick: handleClick
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getTagAttribute(props) {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
const {textStyle: textStyle, padding: padding, panelStyle: panelStyle, minWidth: minWidth, maxWidth: maxWidth, visible: visible, cursor: cursor, disabled: disabled, state: state, children: children} = props;
|
|
58
|
+
return {
|
|
59
|
+
text: children,
|
|
60
|
+
textStyle: textStyle,
|
|
61
|
+
padding: padding,
|
|
62
|
+
panel: panelStyle,
|
|
63
|
+
minWidth: minWidth,
|
|
64
|
+
maxWidth: maxWidth,
|
|
65
|
+
visible: visible,
|
|
66
|
+
cursor: (null != cursor ? cursor : disabled) ? "not-allowed" : "pointer",
|
|
67
|
+
childrenPickable: !1,
|
|
68
|
+
state: {
|
|
69
|
+
text: {
|
|
70
|
+
hover: null === (_a = null == state ? void 0 : state.textStyle) || void 0 === _a ? void 0 : _a.hover,
|
|
71
|
+
disabled: null === (_b = null == state ? void 0 : state.textStyle) || void 0 === _b ? void 0 : _b.disabled
|
|
72
|
+
},
|
|
73
|
+
panel: {
|
|
74
|
+
hover: null === (_c = null == state ? void 0 : state.panelStyle) || void 0 === _c ? void 0 : _c.hover,
|
|
75
|
+
disabled: null === (_d = null == state ? void 0 : state.panelStyle) || void 0 === _d ? void 0 : _d.disabled
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const Button = React.forwardRef(ButtonComponent);
|
|
82
|
+
|
|
83
|
+
Button.displayName = "Button";
|
|
84
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/button/button.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;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;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E,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,0CAAE,QAAQ;aACrC;YACD,KAAK,EAAE;gBACL,KAAK,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,KAAK;gBAC/B,QAAQ,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,QAAQ;aACtC;SACF;KACF,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAmB,eAAe,CAAC,CAAC;AAE1E,MAAM,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,48 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function(s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
4
|
+
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
|
|
5
|
+
var i = 0;
|
|
6
|
+
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]]);
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
import { Checkbox as VCheckbox } from "../vrender-components/checkbox";
|
|
12
|
+
|
|
13
|
+
import { merge } from "@visactor/vutils";
|
|
14
|
+
|
|
15
|
+
import React, { useCallback, useEffect } from "react";
|
|
16
|
+
|
|
17
|
+
const defaultProps = {};
|
|
18
|
+
|
|
19
|
+
function CheckboxComponent(baseProps, ref) {
|
|
20
|
+
const props = merge({}, defaultProps, baseProps), {textStyle: textStyle, boxStyle: boxStyle, iconStyle: iconStyle, children: children} = props, rest = __rest(props, [ "textStyle", "boxStyle", "iconStyle", "children" ]);
|
|
21
|
+
let checkboxRef = React.useRef(null);
|
|
22
|
+
checkboxRef = ref || checkboxRef;
|
|
23
|
+
const handleChange = useCallback((event => {
|
|
24
|
+
props.onChange && props.onChange(event.target.attribute.checked);
|
|
25
|
+
}), []);
|
|
26
|
+
return useEffect((() => {
|
|
27
|
+
var _a;
|
|
28
|
+
return null === (_a = checkboxRef.current) || void 0 === _a || _a.addEventListener("checkbox_state_change", handleChange),
|
|
29
|
+
() => {
|
|
30
|
+
var _a;
|
|
31
|
+
null === (_a = checkboxRef.current) || void 0 === _a || _a.removeEventListener("checkbox_state_change", handleChange);
|
|
32
|
+
};
|
|
33
|
+
}), []), React.createElement(VCheckbox, {
|
|
34
|
+
ref: checkboxRef,
|
|
35
|
+
attribute: Object.assign({
|
|
36
|
+
text: Object.assign(Object.assign({}, textStyle), {
|
|
37
|
+
text: children
|
|
38
|
+
}),
|
|
39
|
+
box: boxStyle,
|
|
40
|
+
icon: iconStyle
|
|
41
|
+
}, rest)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const Checkbox = React.forwardRef(CheckboxComponent);
|
|
46
|
+
|
|
47
|
+
Checkbox.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AC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,WAAW,EAChB,SAAS,kBACP,IAAI,kCACC,SAAS,KACZ,IAAI,EAAE,QAAQ,KAEhB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,SAAS,IACZ,IAAI,IAEE,CACd,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAiC,iBAAiB,CAAC,CAAC;AAE5F,QAAQ,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"]}
|
package/es/components/index.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
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';
|
package/es/components/index.js
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./button/button";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export * from "./link/link";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export * from "./avatar/avatar";
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export * from "./popover/popover";
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export * from "./tag/tag";
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export * from "./radio/radio";
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
export { EmptyTip } from "./component/emptyTip";
|
|
16
|
-
|
|
17
|
-
export { CustomComponent } from "./custom-component";
|
|
18
|
-
|
|
19
|
-
export { CustomLayout } from "./custom/custom-layout";
|
|
20
|
-
|
|
21
|
-
export * from "./custom/graphic";
|
|
22
|
-
|
|
23
|
-
export * from "./custom/component";
|
|
13
|
+
export * from "./checkbox/checkbox";
|
|
24
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["components/index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC","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 {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Tag as VTag } from "../vrender-components/tag";
|
|
2
|
+
|
|
3
|
+
import { merge } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import React, { useEffect } from "react";
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
textStyle: {
|
|
9
|
+
fontSize: 14,
|
|
10
|
+
fontFamily: "sans-serif",
|
|
11
|
+
fill: "rgb(64, 128, 255)"
|
|
12
|
+
},
|
|
13
|
+
panelStyle: {
|
|
14
|
+
visible: !0,
|
|
15
|
+
opacity: 0,
|
|
16
|
+
fill: "rgba(242, 243, 245, 0.5)",
|
|
17
|
+
lineWidth: 1,
|
|
18
|
+
cornerRadius: 2
|
|
19
|
+
},
|
|
20
|
+
padding: 4,
|
|
21
|
+
space: 6,
|
|
22
|
+
state: {
|
|
23
|
+
textStyle: {
|
|
24
|
+
disabled: {
|
|
25
|
+
fill: "rgb(148, 191, 255)"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
panelStyle: {
|
|
29
|
+
hover: {
|
|
30
|
+
opacity: 1
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function LinkComponent(baseProps, ref) {
|
|
37
|
+
const props = merge({}, defaultProps, baseProps), {disabled: disabled, href: href, onClick: onClick} = props;
|
|
38
|
+
let linkRef = React.useRef(null);
|
|
39
|
+
linkRef = ref || linkRef;
|
|
40
|
+
const handleClick = React.useCallback((event => {
|
|
41
|
+
disabled ? "function" == typeof (null == event ? void 0 : event.preventDefault) && event.preventDefault() : (onClick && onClick(event),
|
|
42
|
+
href && window.open(href));
|
|
43
|
+
}), [ disabled, href, onClick ]), attribute = getTagAttribute(props);
|
|
44
|
+
return useEffect((() => {
|
|
45
|
+
linkRef.current.addEventListener("mouseenter", (() => {
|
|
46
|
+
disabled || (linkRef.current.addState("hover", !0, !1), linkRef.current.stage.renderNextFrame());
|
|
47
|
+
})), linkRef.current.addEventListener("mouseleave", (() => {
|
|
48
|
+
disabled || (linkRef.current.removeState("hover", !1), linkRef.current.stage.renderNextFrame());
|
|
49
|
+
}));
|
|
50
|
+
}), []), useEffect((() => {
|
|
51
|
+
disabled ? (linkRef.current.removeState("disabled", !1), linkRef.current.addState("disabled", !0, !1)) : linkRef.current.removeState("disabled", !1),
|
|
52
|
+
linkRef.current.stage.renderNextFrame();
|
|
53
|
+
})), React.createElement(VTag, {
|
|
54
|
+
ref: linkRef,
|
|
55
|
+
attribute: attribute,
|
|
56
|
+
onClick: handleClick
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getTagAttribute(props) {
|
|
61
|
+
var _a, _b, _c, _d;
|
|
62
|
+
const {textStyle: textStyle, padding: padding, space: space, panelStyle: panelStyle, minWidth: minWidth, maxWidth: maxWidth, visible: visible, cursor: cursor, disabled: disabled, icon: icon, state: state, children: children} = props;
|
|
63
|
+
return {
|
|
64
|
+
text: children,
|
|
65
|
+
textStyle: textStyle,
|
|
66
|
+
padding: padding,
|
|
67
|
+
panel: panelStyle,
|
|
68
|
+
minWidth: minWidth,
|
|
69
|
+
maxWidth: maxWidth,
|
|
70
|
+
visible: visible,
|
|
71
|
+
cursor: (null != cursor ? cursor : disabled) ? "not-allowed" : "pointer",
|
|
72
|
+
childrenPickable: !1,
|
|
73
|
+
state: {
|
|
74
|
+
text: {
|
|
75
|
+
hover: null === (_a = null == state ? void 0 : state.textStyle) || void 0 === _a ? void 0 : _a.hover,
|
|
76
|
+
disabled: null === (_b = null == state ? void 0 : state.textStyle) || void 0 === _b ? void 0 : _b.disabled
|
|
77
|
+
},
|
|
78
|
+
panel: {
|
|
79
|
+
hover: null === (_c = null == state ? void 0 : state.panelStyle) || void 0 === _c ? void 0 : _c.hover,
|
|
80
|
+
disabled: null === (_d = null == state ? void 0 : state.panelStyle) || void 0 === _d ? void 0 : _d.disabled
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
space: space,
|
|
84
|
+
shape: {
|
|
85
|
+
visible: !!icon,
|
|
86
|
+
fill: !1,
|
|
87
|
+
stroke: textStyle.fill,
|
|
88
|
+
symbolType: "M -0.2927 -15.4348 L -15.142 -0.5855 C -18.6567 2.9292 -18.6567 8.6277 -15.142 12.1424 V 12.1424 C -11.6273 15.6571 -5.9288 15.6571 -2.4141 12.1424 L 15.2636 -5.5353 C 17.6067 -7.8784 17.6067 -11.6774 15.2636 -14.0206 V -14.0206 C 12.9205 -16.3637 9.1215 -16.3637 6.7783 -14.0206 L -10.8993 3.6571 C -12.0709 4.8287 -12.0709 6.7282 -10.8993 7.8997 V 7.8997 C -9.7278 9.0713 -7.8283 9.0713 -6.6567 7.8997 L 8.1925 -6.9495"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const Link = React.forwardRef(LinkComponent);
|
|
94
|
+
|
|
95
|
+
Link.displayName = "Link";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/link/link.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,IAAI,IAAI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AAiB,aAAa,CAAC,CAAC;AAEpE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC","file":"link.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 LinkStateStyle {\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 LinkProps {\n children?: string;\n textStyle?: Partial<ITextGraphicAttribute>;\n padding?: Padding;\n space?: number;\n panelStyle?: BackgroundAttributes;\n minWidth?: number;\n maxWidth?: number;\n visible?: boolean;\n state?: LinkStateStyle;\n disabled?: boolean;\n icon?: boolean;\n cursor?: Cursor;\n href?: string;\n onClick?: (e: Event) => void;\n}\n\nconst defaultProps: LinkProps = {\n textStyle: {\n fontSize: 14,\n fontFamily: 'sans-serif',\n fill: 'rgb(64, 128, 255)'\n },\n panelStyle: {\n visible: true,\n opacity: 0,\n fill: 'rgba(242, 243, 245, 0.5)',\n lineWidth: 1,\n cornerRadius: 2\n },\n padding: 4,\n space: 6,\n // cursor: 'pointer',\n state: {\n textStyle: {\n disabled: {\n fill: 'rgb(148, 191, 255)'\n }\n },\n panelStyle: {\n hover: {\n // visible: true\n opacity: 1\n }\n }\n }\n};\n\nfunction LinkComponent(baseProps: LinkProps, ref: React.Ref<Tag>) {\n const props: LinkProps = merge({}, defaultProps, baseProps);\n const { disabled, href, onClick } = props;\n let linkRef = React.useRef<Tag>(null);\n linkRef = ref ? (ref as React.RefObject<Tag>) : linkRef;\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 if (href) {\n // eslint-disable-next-line no-undef\n window.open(href);\n }\n },\n [disabled, href, onClick]\n );\n\n const attribute: TagAttributes = getTagAttribute(props);\n\n useEffect(() => {\n linkRef.current.addEventListener('mouseenter', () => {\n // console.log('mouseenter', linkRef.current, e.clone());\n if (!disabled) {\n linkRef.current.addState('hover', true, false);\n // linkRef.current._bgRect.addState('hover', true, false);\n // linkRef.current._textShape.addState('hover', true, false);\n linkRef.current.stage.renderNextFrame();\n }\n });\n linkRef.current.addEventListener('mouseleave', () => {\n // console.log('mouseleave', linkRef.current, e.clone());\n if (!disabled) {\n linkRef.current.removeState('hover', false);\n // linkRef.current._bgRect.removeState('hover', false);\n // linkRef.current._textShape.removeState('hover', false);\n linkRef.current.stage.renderNextFrame();\n }\n });\n }, []);\n\n useEffect(() => {\n if (disabled) {\n linkRef.current.removeState('disabled', false);\n // linkRef.current._bgRect.removeState('disabled', false);\n // linkRef.current._textShape.removeState('disabled', false);\n\n linkRef.current.addState('disabled', true, false);\n // linkRef.current._bgRect.addState('disabled', true, false);\n // linkRef.current._textShape.addState('disabled', true, false);\n // console.log('add disable');\n } else {\n linkRef.current.removeState('disabled', false);\n // linkRef.current._bgRect.removeState('disabled', false);\n // linkRef.current._textShape.removeState('disabled', false);\n // console.log('remove disable');\n }\n linkRef.current.stage.renderNextFrame();\n });\n\n return <VTag ref={linkRef} attribute={attribute} onClick={handleClick}></VTag>;\n}\n\nfunction getTagAttribute(props: LinkProps) {\n const {\n textStyle,\n padding,\n space,\n panelStyle,\n minWidth,\n maxWidth,\n visible,\n cursor,\n disabled,\n icon,\n state,\n children\n } = 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 space,\n shape: {\n visible: !!icon,\n fill: false,\n stroke: textStyle.fill,\n symbolType:\n // eslint-disable-next-line max-len\n 'M -0.2927 -15.4348 L -15.142 -0.5855 C -18.6567 2.9292 -18.6567 8.6277 -15.142 12.1424 V 12.1424 C -11.6273 15.6571 -5.9288 15.6571 -2.4141 12.1424 L 15.2636 -5.5353 C 17.6067 -7.8784 17.6067 -11.6774 15.2636 -14.0206 V -14.0206 C 12.9205 -16.3637 9.1215 -16.3637 6.7783 -14.0206 L -10.8993 3.6571 C -12.0709 4.8287 -12.0709 6.7282 -10.8993 7.8997 V 7.8997 C -9.7278 9.0713 -7.8283 9.0713 -6.6567 7.8997 L 8.1925 -6.9495'\n }\n };\n\n return attr;\n}\n\nexport const Link = React.forwardRef<Tag, LinkProps>(LinkComponent);\n\nLink.displayName = 'Link';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IGroup } from '@visactor/vtable/es/vrender';
|
|
2
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
type Anchor = 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';
|
|
5
|
+
export interface PopoverProps {
|
|
6
|
+
children?: ReactElement;
|
|
7
|
+
defaultPopupVisible?: boolean;
|
|
8
|
+
popupVisible?: boolean;
|
|
9
|
+
position?: Anchor;
|
|
10
|
+
content?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<IGroup>>;
|
|
13
|
+
export {};
|