k-react-vtable 1.0.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/README.md +93 -0
- package/cjs/components/avatar/avatar.d.ts +14 -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 -0
- package/cjs/components/index.js +24 -0
- package/cjs/components/index.js.map +1 -0
- package/cjs/components/link/link.d.ts +30 -0
- package/cjs/components/link/link.js +119 -0
- package/cjs/components/link/link.js.map +1 -0
- package/cjs/components/popover/popover.d.ts +14 -0
- package/cjs/components/popover/popover.js +283 -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 +68 -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 +47 -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 +1 -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.d.ts +1 -0
- package/cjs/constants.js +6 -0
- package/cjs/constants.js.map +1 -0
- package/cjs/containers/withContainer.d.ts +8 -0
- package/cjs/containers/withContainer.js +63 -0
- package/cjs/containers/withContainer.js.map +1 -0
- package/cjs/context/table.d.ts +9 -0
- package/cjs/context/table.js +25 -0
- package/cjs/context/table.js.map +1 -0
- package/cjs/eventsUtils.d.ts +130 -0
- package/cjs/eventsUtils.js +93 -0
- package/cjs/eventsUtils.js.map +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +22 -0
- package/cjs/index.js.map +1 -0
- package/cjs/table-components/base-component.d.ts +12 -0
- package/cjs/table-components/base-component.js +87 -0
- package/cjs/table-components/base-component.js.map +1 -0
- package/cjs/table-components/component/emptyTip.d.ts +20 -0
- package/cjs/table-components/component/emptyTip.js +10 -0
- package/cjs/table-components/component/emptyTip.js.map +1 -0
- package/cjs/table-components/component/menu.d.ts +10 -0
- package/cjs/table-components/component/menu.js +10 -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.d.ts +7 -0
- package/cjs/table-components/component/tooltip.js +10 -0
- package/cjs/table-components/component/tooltip.js.map +1 -0
- package/cjs/table-components/custom/custom-layout.d.ts +11 -0
- package/cjs/table-components/custom/custom-layout.js +107 -0
- package/cjs/table-components/custom/custom-layout.js.map +1 -0
- package/cjs/table-components/custom/graphic.d.ts +19 -0
- package/cjs/table-components/custom/graphic.js +9 -0
- package/cjs/table-components/custom/graphic.js.map +1 -0
- package/cjs/table-components/custom/reconciler.d.ts +2 -0
- package/cjs/table-components/custom/reconciler.js +107 -0
- package/cjs/table-components/custom/reconciler.js.map +1 -0
- package/cjs/table-components/custom/vtable-browser-env-contribution.d.ts +6 -0
- package/cjs/table-components/custom/vtable-browser-env-contribution.js +35 -0
- package/cjs/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
- package/cjs/table-components/custom/vtable-react-attribute-plugin.d.ts +21 -0
- package/cjs/table-components/custom/vtable-react-attribute-plugin.js +135 -0
- package/cjs/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
- package/cjs/table-components/custom-component.d.ts +17 -0
- package/cjs/table-components/custom-component.js +98 -0
- package/cjs/table-components/custom-component.js.map +1 -0
- package/cjs/table-components/index.d.ts +20 -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.d.ts +4 -0
- package/cjs/table-components/list/list-column.js +10 -0
- package/cjs/table-components/list/list-column.js.map +1 -0
- package/cjs/table-components/pivot/pivot-corner.d.ts +4 -0
- package/cjs/table-components/pivot/pivot-corner.js +10 -0
- package/cjs/table-components/pivot/pivot-corner.js.map +1 -0
- package/cjs/table-components/pivot/pivot-dimension.d.ts +6 -0
- package/cjs/table-components/pivot/pivot-dimension.js +11 -0
- package/cjs/table-components/pivot/pivot-dimension.js.map +1 -0
- package/cjs/table-components/pivot/pivot-header-title.d.ts +5 -0
- package/cjs/table-components/pivot/pivot-header-title.js +11 -0
- package/cjs/table-components/pivot/pivot-header-title.js.map +1 -0
- package/cjs/table-components/pivot/pivot-indicator.d.ts +4 -0
- package/cjs/table-components/pivot/pivot-indicator.js +10 -0
- package/cjs/table-components/pivot/pivot-indicator.js.map +1 -0
- package/cjs/tables/base-table.d.ts +23 -0
- package/cjs/tables/base-table.js +199 -0
- package/cjs/tables/base-table.js.map +1 -0
- package/cjs/tables/index.d.ts +6 -0
- package/cjs/tables/index.js +65 -0
- package/cjs/tables/index.js.map +1 -0
- 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 +8 -0
- package/cjs/tables/list-table.js +13 -0
- package/cjs/tables/list-table.js.map +1 -0
- package/cjs/tables/pivot-chart.d.ts +13 -0
- package/cjs/tables/pivot-chart.js +17 -0
- package/cjs/tables/pivot-chart.js.map +1 -0
- 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 +8 -0
- package/cjs/tables/pivot-table.js +13 -0
- package/cjs/tables/pivot-table.js.map +1 -0
- package/cjs/util.d.ts +8 -0
- package/cjs/util.js +56 -0
- package/cjs/util.js.map +1 -0
- package/cjs/vtable.d.ts +1 -0
- package/cjs/vtable.js +2 -0
- package/cjs/vtable.js.map +1 -0
- package/dist/react-vtable.js +7662 -0
- package/dist/react-vtable.min.js +10 -0
- package/es/components/avatar/avatar.d.ts +14 -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 -0
- package/es/components/index.js +14 -0
- package/es/components/index.js.map +1 -0
- package/es/components/link/link.d.ts +30 -0
- package/es/components/link/link.js +96 -0
- package/es/components/link/link.js.map +1 -0
- package/es/components/popover/popover.d.ts +14 -0
- package/es/components/popover/popover.js +260 -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 +47 -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 +45 -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 +1 -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.d.ts +1 -0
- package/es/constants.js +2 -0
- package/es/constants.js.map +1 -0
- package/es/containers/withContainer.d.ts +8 -0
- package/es/containers/withContainer.js +32 -0
- package/es/containers/withContainer.js.map +1 -0
- package/es/context/table.d.ts +9 -0
- package/es/context/table.js +16 -0
- package/es/context/table.js.map +1 -0
- package/es/eventsUtils.d.ts +130 -0
- package/es/eventsUtils.js +86 -0
- package/es/eventsUtils.js.map +1 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +8 -0
- package/es/index.js.map +1 -0
- package/es/table-components/base-component.d.ts +12 -0
- package/es/table-components/base-component.js +60 -0
- package/es/table-components/base-component.js.map +1 -0
- package/es/table-components/component/emptyTip.d.ts +20 -0
- package/es/table-components/component/emptyTip.js +4 -0
- package/es/table-components/component/emptyTip.js.map +1 -0
- package/es/table-components/component/menu.d.ts +10 -0
- package/es/table-components/component/menu.js +4 -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.d.ts +7 -0
- package/es/table-components/component/tooltip.js +4 -0
- package/es/table-components/component/tooltip.js.map +1 -0
- package/es/table-components/custom/custom-layout.d.ts +11 -0
- package/es/table-components/custom/custom-layout.js +79 -0
- package/es/table-components/custom/custom-layout.js.map +1 -0
- package/es/table-components/custom/graphic.d.ts +19 -0
- package/es/table-components/custom/graphic.js +22 -0
- package/es/table-components/custom/graphic.js.map +1 -0
- package/es/table-components/custom/reconciler.d.ts +2 -0
- package/es/table-components/custom/reconciler.js +106 -0
- package/es/table-components/custom/reconciler.js.map +1 -0
- package/es/table-components/custom/vtable-browser-env-contribution.d.ts +6 -0
- package/es/table-components/custom/vtable-browser-env-contribution.js +33 -0
- package/es/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
- package/es/table-components/custom/vtable-react-attribute-plugin.d.ts +21 -0
- package/es/table-components/custom/vtable-react-attribute-plugin.js +127 -0
- package/es/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
- package/es/table-components/custom-component.d.ts +17 -0
- package/es/table-components/custom-component.js +67 -0
- package/es/table-components/custom-component.js.map +1 -0
- package/es/table-components/index.d.ts +20 -0
- package/es/table-components/index.js +26 -0
- package/es/table-components/index.js.map +1 -0
- package/es/table-components/list/list-column.d.ts +4 -0
- package/es/table-components/list/list-column.js +4 -0
- package/es/table-components/list/list-column.js.map +1 -0
- package/es/table-components/pivot/pivot-corner.d.ts +4 -0
- package/es/table-components/pivot/pivot-corner.js +4 -0
- package/es/table-components/pivot/pivot-corner.js.map +1 -0
- package/es/table-components/pivot/pivot-dimension.d.ts +6 -0
- package/es/table-components/pivot/pivot-dimension.js +6 -0
- package/es/table-components/pivot/pivot-dimension.js.map +1 -0
- package/es/table-components/pivot/pivot-header-title.d.ts +5 -0
- package/es/table-components/pivot/pivot-header-title.js +6 -0
- package/es/table-components/pivot/pivot-header-title.js.map +1 -0
- package/es/table-components/pivot/pivot-indicator.d.ts +4 -0
- package/es/table-components/pivot/pivot-indicator.js +4 -0
- package/es/table-components/pivot/pivot-indicator.js.map +1 -0
- package/es/tables/base-table.d.ts +23 -0
- package/es/tables/base-table.js +178 -0
- package/es/tables/base-table.js.map +1 -0
- package/es/tables/index.d.ts +6 -0
- package/es/tables/index.js +12 -0
- package/es/tables/index.js.map +1 -0
- 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 +8 -0
- package/es/tables/list-table.js +9 -0
- package/es/tables/list-table.js.map +1 -0
- package/es/tables/pivot-chart.d.ts +13 -0
- package/es/tables/pivot-chart.js +15 -0
- package/es/tables/pivot-chart.js.map +1 -0
- 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 +8 -0
- package/es/tables/pivot-table.js +9 -0
- package/es/tables/pivot-table.js.map +1 -0
- package/es/util.d.ts +8 -0
- package/es/util.js +35 -0
- package/es/util.js.map +1 -0
- package/es/vtable.d.ts +1 -0
- package/es/vtable.js +2 -0
- package/es/vtable.js.map +1 -0
- package/package.json +104 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="" target="_blank">
|
|
3
|
+
<img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/500_200.svg"/>
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<h1>React-VTable</h1>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
|
|
13
|
+
VTable is not just a high-performance multidimensional data analysis table, but also a grid artist that creates art between rows and columns.React-VTable is a React wrapper of VTable.
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/@visactor/react-vtable)
|
|
16
|
+
[](https://www.npmjs.com/package/@visactor/react-vvtable)
|
|
17
|
+
[](https://github.com/visactor/vtable/blob/main/LICENSE)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
# Usage
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
[npm package](https://www.npmjs.com/package/@visactor/react-vtable)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
// npm
|
|
29
|
+
npm install @visactor/react-vtable
|
|
30
|
+
|
|
31
|
+
// yarn
|
|
32
|
+
yarn add @visactor/react-vtable
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import React from 'react';
|
|
39
|
+
import ReactDOM from 'react-dom/client';
|
|
40
|
+
import { ListTable } from "k-react-table";
|
|
41
|
+
|
|
42
|
+
const option = {
|
|
43
|
+
header: [
|
|
44
|
+
{
|
|
45
|
+
field: "0",
|
|
46
|
+
title: "name",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
field: "1",
|
|
50
|
+
title: "age",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
field: "2",
|
|
54
|
+
title: "gender",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
field: "3",
|
|
58
|
+
title: "hobby",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
records: new Array(1000).fill(["John", 18, "male", "🏀"]),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
|
65
|
+
<ListTable option={option} height={'500px'}/>
|
|
66
|
+
);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
|
|
71
|
+
[More demos and detailed tutorials](https://visactor.io/vtable)
|
|
72
|
+
|
|
73
|
+
# Related Links
|
|
74
|
+
|
|
75
|
+
- [Official website](https://visactor.io/vtable)
|
|
76
|
+
|
|
77
|
+
# Ecosystem
|
|
78
|
+
|
|
79
|
+
| Project | Description |
|
|
80
|
+
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
81
|
+
| [AI-generated Components](https://visactor.io/ai-vtable) | AI-generated table component. |
|
|
82
|
+
|
|
83
|
+
# Contribution
|
|
84
|
+
|
|
85
|
+
If you would like to contribute, please read the [Code of Conduct ](./CODE_OF_CONDUCT.md) 和 [ Guide](./CONTRIBUTING.zh-CN.md) first。
|
|
86
|
+
|
|
87
|
+
Small streams converge to make great rivers and seas!
|
|
88
|
+
|
|
89
|
+
<a href="https://github.com/visactor/vtable/graphs/contributors"><img src="https://contrib.rocks/image?repo=visactor/vtable" /></a>
|
|
90
|
+
|
|
91
|
+
# License
|
|
92
|
+
|
|
93
|
+
[MIT License](./LICENSE)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BackgroundAttributes, type Cursor, type ITextGraphicAttribute } from 'k-vtable/es/vrender';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface AvatarProps {
|
|
4
|
+
children?: string | React.ReactNode;
|
|
5
|
+
textStyle?: Partial<ITextGraphicAttribute>;
|
|
6
|
+
panelStyle?: BackgroundAttributes;
|
|
7
|
+
size?: number;
|
|
8
|
+
shape?: 'circle' | 'square';
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
cursor?: Cursor;
|
|
11
|
+
autoFixFontSize?: boolean;
|
|
12
|
+
onClick?: (e: Event) => void;
|
|
13
|
+
}
|
|
14
|
+
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("k-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,iDAS6B;AAE7B,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,EAAE,CAAC;KAChB;IACD,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,QAAQ;IACf,eAAe,EAAE,IAAI;CAEtB,CAAC;AAEF,SAAS,eAAe,CAAC,SAAsB,EAAE,GAAsB;IACrE,MAAM,KAAK,G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":"avatar.js","sourcesContent":["import type { IGroup, IGroupAttribute } from 'k-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 'k-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 } from 'k-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: "#165dff",
|
|
41
|
+
lineWidth: 1,
|
|
42
|
+
cornerRadius: 2
|
|
43
|
+
},
|
|
44
|
+
padding: 10,
|
|
45
|
+
state: {
|
|
46
|
+
panelStyle: {
|
|
47
|
+
hover: {
|
|
48
|
+
fill: "#4080ff"
|
|
49
|
+
},
|
|
50
|
+
disabled: {
|
|
51
|
+
fill: "#94bfff"
|
|
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":["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QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACjH,MAAM,IAAI,GAAkB;QAC1B,IAAI,EAAE,QAAQ;QACd,SAAS;QACT,OAAO;QACP,KAAK,EAAE,UAAU;QACjB,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,MAAM,EAAE,CAAA,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,QAAQ,EAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;QACtD,gBAAgB,EAAE,KAAK;QACvB,KAAK,EAAE;YACL,IAAI,EAAE;gBACJ,KAAK,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,0CAAE,KAAK;gBAC9B,QAAQ,EAAE,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;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 'k-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: '#165dff',\n lineWidth: 1,\n cornerRadius: 2\n },\n padding: 10,\n // cursor: 'pointer',\n state: {\n panelStyle: {\n hover: {\n fill: '#4080ff'\n },\n disabled: {\n fill: '#94bfff'\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, CheckboxAttributes } from 'k-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, Object.assign({
|
|
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
|
+
}, rest));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.Checkbox = react_1.default.forwardRef(CheckboxComponent), exports.Checkbox.displayName = "Checkbox";
|
|
69
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/checkbox/checkbox.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,6DAAuE;AACvE,6CAAyC;AACzC,+CAAsD;AAiBtD,MAAM,YAAY,GAAkB,EAAE,CAAC;AAEvC,SAAS,iBAAiB,CAAC,SAAwB,EAAE,GAA+B;IAClF,MAAM,KAAK,GAAkB,IAAA,cAAK,EAAC,EAAE,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAChE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA7D,kDAAqD,CAAQ,CAAC;IACpE,IAAI,WAAW,GAAG,eAAK,CAAC,MAAM,CAAkB,IAAI,CAAC,CAAC;IACtD,WAAW,GAAG,GAAG,CAAC,CAAC,CAAE,GAAwC,CAAC,CAAC,CAAC,WAAW,CAAC;IAE5E,MAAM,YAAY,GAAG,IAAA,mBAAW,EAAC,CAAC,KAAkC,EAAE,EAAE;QACtE,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAA,iBAAS,EAAC,GAAG,EAAE;;QACb,MAAA,WAAW,CAAC,OAAO,0CAAE,gBAAgB,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;QAC7E,OAAO,GAAG,EAAE;;YACV,MAAA,WAAW,CAAC,OAAO,0CAAE,mBAAmB,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;QAClF,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,8BAAC,mBAAS,kBACR,GAAG,EAAE,WAAW,EAChB,SAAS,kBACP,IAAI,kCACC,SAAS,KACZ,IAAI,EAAE,QAAQ,KAEhB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,SAAS,IACZ,IAAI,KAEL,IAAI,EACG,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 'k-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 {...rest} // for REACT_TO_CANOPUS_EVENTS\n ></VCheckbox>\n );\n}\n\nexport const Checkbox = React.forwardRef<VRenderCheckbox, CheckboxProps>(CheckboxComponent);\n\nCheckbox.displayName = 'Checkbox';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
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);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 } from 'k-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,119 @@
|
|
|
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.Link = 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: "rgb(64, 128, 255)"
|
|
37
|
+
},
|
|
38
|
+
panelStyle: {
|
|
39
|
+
visible: !0,
|
|
40
|
+
opacity: 0,
|
|
41
|
+
fill: "rgba(242, 243, 245, 0.5)",
|
|
42
|
+
lineWidth: 1,
|
|
43
|
+
cornerRadius: 2
|
|
44
|
+
},
|
|
45
|
+
padding: 4,
|
|
46
|
+
space: 6,
|
|
47
|
+
state: {
|
|
48
|
+
textStyle: {
|
|
49
|
+
disabled: {
|
|
50
|
+
fill: "rgb(148, 191, 255)"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
panelStyle: {
|
|
54
|
+
hover: {
|
|
55
|
+
opacity: 1
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function LinkComponent(baseProps, ref) {
|
|
62
|
+
const props = (0, vutils_1.merge)({}, defaultProps, baseProps), {disabled: disabled, href: href, onClick: onClick} = props;
|
|
63
|
+
let linkRef = react_1.default.useRef(null);
|
|
64
|
+
linkRef = ref || linkRef;
|
|
65
|
+
const handleClick = react_1.default.useCallback((event => {
|
|
66
|
+
disabled ? "function" == typeof (null == event ? void 0 : event.preventDefault) && event.preventDefault() : (onClick && onClick(event),
|
|
67
|
+
href && window.open(href));
|
|
68
|
+
}), [ disabled, href, onClick ]), attribute = getTagAttribute(props);
|
|
69
|
+
return (0, react_1.useEffect)((() => {
|
|
70
|
+
linkRef.current.addEventListener("mouseenter", (() => {
|
|
71
|
+
disabled || (linkRef.current.addState("hover", !0, !1), linkRef.current.stage.renderNextFrame());
|
|
72
|
+
})), linkRef.current.addEventListener("mouseleave", (() => {
|
|
73
|
+
disabled || (linkRef.current.removeState("hover", !1), linkRef.current.stage.renderNextFrame());
|
|
74
|
+
}));
|
|
75
|
+
}), []), (0, react_1.useEffect)((() => {
|
|
76
|
+
disabled ? (linkRef.current.removeState("disabled", !1), linkRef.current.addState("disabled", !0, !1)) : linkRef.current.removeState("disabled", !1),
|
|
77
|
+
linkRef.current.stage.renderNextFrame();
|
|
78
|
+
})), react_1.default.createElement(tag_1.Tag, {
|
|
79
|
+
ref: linkRef,
|
|
80
|
+
attribute: attribute,
|
|
81
|
+
onClick: handleClick
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getTagAttribute(props) {
|
|
86
|
+
var _a, _b, _c, _d;
|
|
87
|
+
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;
|
|
88
|
+
return {
|
|
89
|
+
text: children,
|
|
90
|
+
textStyle: textStyle,
|
|
91
|
+
padding: padding,
|
|
92
|
+
panel: panelStyle,
|
|
93
|
+
minWidth: minWidth,
|
|
94
|
+
maxWidth: maxWidth,
|
|
95
|
+
visible: visible,
|
|
96
|
+
cursor: (null != cursor ? cursor : disabled) ? "not-allowed" : "pointer",
|
|
97
|
+
childrenPickable: !1,
|
|
98
|
+
state: {
|
|
99
|
+
text: {
|
|
100
|
+
hover: null === (_a = null == state ? void 0 : state.textStyle) || void 0 === _a ? void 0 : _a.hover,
|
|
101
|
+
disabled: null === (_b = null == state ? void 0 : state.textStyle) || void 0 === _b ? void 0 : _b.disabled
|
|
102
|
+
},
|
|
103
|
+
panel: {
|
|
104
|
+
hover: null === (_c = null == state ? void 0 : state.panelStyle) || void 0 === _c ? void 0 : _c.hover,
|
|
105
|
+
disabled: null === (_d = null == state ? void 0 : state.panelStyle) || void 0 === _d ? void 0 : _d.disabled
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
space: space,
|
|
109
|
+
shape: {
|
|
110
|
+
visible: !!icon,
|
|
111
|
+
fill: !1,
|
|
112
|
+
stroke: textStyle.fill,
|
|
113
|
+
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"
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
exports.Link = react_1.default.forwardRef(LinkComponent), exports.Link.displayName = "Link";
|
|
119
|
+
//# sourceMappingURL=link.js.map
|