-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into fix/fs-style-align
- Loading branch information
Showing
49 changed files
with
1,152 additions
and
218 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@visactor/vtable/feat-react-component-container_2024-05-07-09-28.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@visactor/vtable", | ||
"comment": "feat: add CustomComponent in react-vtable", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@visactor/vtable" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@visactor/vtable/fix-custom-merge-size_2024-05-06-12-17.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@visactor/vtable", | ||
"comment": "fix: fix custom merge cell size update #1636", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@visactor/vtable" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@visactor/vtable/fix-selecting-cell_2024-05-06-12-55.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@visactor/vtable", | ||
"comment": "fix: add selecting cell range deduplication #1628", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@visactor/vtable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
docs/assets/demo-react/en/component/custom-component.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
category: examples | ||
group: component | ||
title: Custom Component | ||
cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/preview/custom-component.png | ||
order: 1-1 | ||
link: '../guide/Developer_Ecology/react' | ||
--- | ||
|
||
# Custom Component | ||
|
||
The `CustomComponent` component facilitates overlaying external components on React-VTable components. | ||
|
||
## Code Example | ||
```javascript livedemo template=vtable-react | ||
// import * as ReactVTable from '@visactor/react-vtable'; | ||
|
||
const { useCallback, useRef, useState } = React; | ||
const { ListTable, CustomComponent } = ReactVTable; | ||
const { Popconfirm, Message, Button } = ArcoDesign; | ||
|
||
function Tooltip(props) { | ||
return ( | ||
<div style={{ width: '100%', height: '100%', border: '1px solid #333', backgroundColor: '#ccc', fontSize: 10 }}> | ||
{`${props.value}(click to show more)`} | ||
</div> | ||
); | ||
} | ||
|
||
function App() { | ||
const [hoverCol, setHoverCol] = useState(-1); | ||
const [hoverRow, setHoverRow] = useState(-1); | ||
const [clickCol, setClickCol] = useState(-1); | ||
const [clickRow, setClickRow] = useState(-1); | ||
const [value, setValue] = useState(''); | ||
const visible = useRef(false); | ||
const tableInstance = useRef(null); | ||
|
||
const option = { | ||
columns: [ | ||
{ | ||
field: '0', | ||
caption: 'name' | ||
}, | ||
{ | ||
field: '1', | ||
caption: 'age' | ||
}, | ||
{ | ||
field: '2', | ||
caption: 'gender' | ||
}, | ||
{ | ||
field: '3', | ||
caption: 'hobby' | ||
} | ||
], | ||
records: new Array(1000).fill(['John', 18, 'male', '🏀']) | ||
}; | ||
|
||
const updateHoverPos = useCallback((args) => { | ||
if (visible.current) { | ||
return; | ||
} | ||
setHoverCol(args.col); | ||
setHoverRow(args.row); | ||
const cellValue = tableInstance.current.getCellValue(args.col, args.row); | ||
setValue(cellValue); | ||
}, []); | ||
const hide = useCallback(() => { | ||
setHoverCol(-1); | ||
setHoverRow(-1); | ||
}, []); | ||
|
||
const updateClickPos = useCallback((args) => { | ||
setClickCol(args.col); | ||
setClickRow(args.row); | ||
}, []); | ||
|
||
const ready = (instance, isInitial) => { | ||
if (isInitial) { | ||
tableInstance.current = instance; | ||
} | ||
}; | ||
|
||
return ( | ||
<ListTable | ||
option={option} | ||
onMouseEnterCell={updateHoverPos} | ||
onMouseLeaveTable={hide} | ||
onClickCell={updateClickPos} | ||
onReady={ready} | ||
> | ||
<CustomComponent | ||
width="80%" | ||
height="100%" | ||
displayMode="cell" | ||
col={hoverCol} | ||
row={hoverRow} | ||
anchor="bottom-right" | ||
dx="-80%" | ||
> | ||
<Tooltip value={value} /> | ||
</CustomComponent> | ||
<CustomComponent width="100%" height="100%" displayMode="cell" col={clickCol} row={clickRow} anchor="top-left"> | ||
<Popconfirm | ||
focusLock | ||
title="Popconfirm" | ||
content="Click component!" | ||
onOk={() => { | ||
Message.info({ | ||
content: 'ok' | ||
}); | ||
setClickCol(-1); | ||
setClickRow(-1); | ||
}} | ||
onCancel={() => { | ||
Message.error({ | ||
content: 'cancel' | ||
}); | ||
setClickCol(-1); | ||
setClickRow(-1); | ||
}} | ||
onVisibleChange={(popVisible) => { | ||
visible.current = popVisible; | ||
}} | ||
> | ||
<Button style={{ width: '100%', height: '100%' }}>Click</Button> | ||
</Popconfirm> | ||
</CustomComponent> | ||
</ListTable> | ||
); | ||
} | ||
|
||
const root = ReactDom.createRoot(document.getElementById(CONTAINER_ID)); | ||
root.render(<App />); | ||
|
||
// release react instance, do not copy | ||
window.customRelease = () => { | ||
root.unmount(); | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.