Skip to content

Commit 1c8f1f6

Browse files
authored
Merge pull request #809 from raheeliftikhar5/echart-click-events
Click events for echarts json/map view
2 parents f33b807 + cb826f8 commit 1c8f1f6

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

client/packages/lowcoder-comps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-comps",
3-
"version": "0.0.29",
3+
"version": "0.0.30",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {

client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
7676
}
7777

7878
useEffect(() => {
79+
// click events for JSON/Map mode
80+
if (mode === 'ui') return;
81+
82+
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
83+
if (!echartsCompInstance) {
84+
return _.noop;
85+
}
86+
echartsCompInstance?.on("click", (param: any) => {
87+
document.dispatchEvent(new CustomEvent("clickEvent", {
88+
bubbles: true,
89+
detail: {
90+
action: 'click',
91+
data: param.data,
92+
}
93+
}));
94+
});
95+
return () => {
96+
echartsCompInstance?.off("click");
97+
document.removeEventListener('clickEvent', clickEventCallback)
98+
};
99+
}, [mode, mapScriptLoaded]);
100+
101+
useEffect(() => {
102+
// click events for UI mode
79103
if(mode !== 'ui') return;
80104

81105
// bind events

client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,26 @@ const FlexWrapper = styled.div`
4242
height: 100%;
4343
display: flex;
4444
align-items: center;
45-
justify-content: center;
46-
flex-wrap: 'wrap'};
45+
// justify-content: center;
4746
`;
4847

49-
const ListOrientationWrapper = styled.div<{ $isHorizontal: boolean, $autoHeight : boolean }>`
48+
const ListOrientationWrapper = styled.div<{
49+
$isHorizontal: boolean,
50+
$autoHeight : boolean,
51+
$isGrid: boolean,
52+
}>`
5053
height: ${(props) => (props.$autoHeight ? "auto" : "100%")};
5154
display: flex;
52-
flex-direction: ${(props) => (props.$isHorizontal ? "row" : "column")};
55+
flex-direction: ${(props) => (props.$isHorizontal && !props.$isGrid ? "row" : "column")};
5356
height: 100%;
5457
`;
5558

56-
const MinHorizontalWidthContext = createContext({
59+
type MinHorizontalWidthContextType = {
60+
horizontalWidth: string,
61+
minHorizontalWidth?: string,
62+
}
63+
64+
const MinHorizontalWidthContext = createContext<MinHorizontalWidthContextType>({
5765
horizontalWidth: '100%',
5866
minHorizontalWidth: '100px',
5967
});
@@ -63,11 +71,12 @@ const ContainerInListView = (props: ContainerBaseProps ) => {
6371
horizontalWidth,
6472
minHorizontalWidth
6573
} = useContext(MinHorizontalWidthContext);
74+
6675
return (
6776
<div
6877
style={{
6978
width: horizontalWidth,
70-
minWidth: minHorizontalWidth,
79+
minWidth: minHorizontalWidth || '0px',
7180
}}
7281
>
7382
<InnerGrid
@@ -88,7 +97,7 @@ type ListItemProps = {
8897
scrollContainerRef?: RefObject<HTMLDivElement>;
8998
minHeight?: string;
9099
unMountFn?: () => void;
91-
minHorizontalWidth: string;
100+
minHorizontalWidth?: string;
92101
horizontalWidth: string;
93102
};
94103

@@ -129,8 +138,10 @@ function ListItem({
129138
dispatch={itemIdx === offset ? containerProps.dispatch : _.noop}
130139
style={{
131140
height: "100%",
141+
// in case of horizontal mode, minHorizontalWidth is 0px
142+
width: minHorizontalWidth || '100%',
132143
backgroundColor: "transparent",
133-
flex: "auto",
144+
// flex: "auto",
134145
}}
135146
autoHeight={autoHeight}
136147
isDroppable={itemIdx === offset}
@@ -247,7 +258,7 @@ export function ListView(props: Props) {
247258
minHeight={minHeight}
248259
unMountFn={unMountFn}
249260
horizontalWidth={`${100 / noOfColumns}%`}
250-
minHorizontalWidth={horizontal ? minHorizontalWidth : '0px'}
261+
minHorizontalWidth={horizontal ? minHorizontalWidth : undefined}
251262
/>
252263
);
253264
})}
@@ -268,7 +279,13 @@ export function ListView(props: Props) {
268279
<BodyWrapper ref={ref} $autoHeight={autoHeight}>
269280
<ScrollBar style={{ height: autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }} hideScrollbar={!scrollbars}>
270281
<>{<ReactResizeDetector onResize={(width?: number, height?: number) => { if (height) setListHeight(height); }} observerOptions={{ box: "border-box" }} >
271-
<ListOrientationWrapper $isHorizontal={horizontal} $autoHeight={autoHeight}>{renders}</ListOrientationWrapper>
282+
<ListOrientationWrapper
283+
$isHorizontal={horizontal}
284+
$isGrid={noOfColumns > 1}
285+
$autoHeight={autoHeight}
286+
>
287+
{renders}
288+
</ListOrientationWrapper>
272289
</ReactResizeDetector>}</>
273290
</ScrollBar>
274291
</BodyWrapper>

0 commit comments

Comments
 (0)