Skip to content

Commit 4cdbe2a

Browse files
author
FalkWolsky
committed
Adding scrollbar Support for Containers
1 parent 1c14de6 commit 4cdbe2a

File tree

6 files changed

+74
-44
lines changed

6 files changed

+74
-44
lines changed

client/packages/lowcoder/src/comps/comps/containerComp/containerComp.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const ContainerBaseComp = (function () {
2424
return new ContainerCompBuilder(childrenMap, (props, dispatch) => {
2525
return (
2626
<DisabledContext.Provider value={props.disabled}>
27-
<TriContainer {...props} />
27+
<TriContainer {...props} />
2828
</DisabledContext.Provider>
2929
);
3030
})
@@ -78,6 +78,7 @@ function convertOldContainerParams(params: CompParams<any>) {
7878
// old params
7979
if (container && (container.hasOwnProperty("layout") || container.hasOwnProperty("items"))) {
8080
const autoHeight = tempParams.value.autoHeight;
81+
const scrollbars = tempParams.value.scrollbars;
8182
return {
8283
...tempParams,
8384
value: {
@@ -87,6 +88,7 @@ function convertOldContainerParams(params: CompParams<any>) {
8788
showBody: true,
8889
showFooter: false,
8990
autoHeight: autoHeight,
91+
scrollbars: scrollbars,
9092
},
9193
},
9294
};
@@ -123,7 +125,7 @@ export function defaultContainerData(
123125
layoutItem: {
124126
i: "",
125127
h: 5,
126-
w: 24,
128+
w: 12,
127129
x: 0,
128130
y: 0,
129131
},

client/packages/lowcoder/src/comps/comps/containerComp/containerView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { hookCompCategory, HookCompType } from "comps/hooks/hookCompTypes";
55
import { UICompLayoutInfo, uiCompRegistry, UICompType } from "comps/uiCompRegistry";
66
import { genRandomKey } from "comps/utils/idGenerator";
77
import { parseCompType } from "comps/utils/remote";
8+
import { ScrollBar } from "lowcoder-design";
89
import {
910
DEFAULT_POSITION_PARAMS,
1011
draggingUtils,
@@ -102,6 +103,7 @@ type ExtraProps = {
102103
rowCount?: number;
103104
isRowCountLocked?: boolean;
104105
autoHeight?: boolean;
106+
scrollbars?: boolean;
105107
minHeight?: string;
106108
emptyRows?: number;
107109
extraHeight?: string;

client/packages/lowcoder/src/comps/comps/gridLayoutComp/canvasView.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,19 @@ export function CanvasView(props: ContainerBaseProps) {
113113
$bgColor={bgColor}
114114
>
115115
<div>
116-
<ScrollBar style={{ height: "100%", margin: "0px", padding: "0px" }}>
116+
{/* <ScrollBar style={{ height: "100%", margin: "0px", padding: "0px" }}> */}
117117
<Profiler id="Panel" onRender={profilerCallback}>
118-
<InnerGrid
119-
containerPadding={rootContainerPadding}
120-
overflow={rootContainerOverflow}
121-
{...props}
122-
positionParams={positionParams} // Added By Aqib Mirza
123-
{...gridLayoutCanvasProps}
124-
bgColor={bgColor}
125-
radius="0px"
126-
/>
127-
</Profiler>
128-
</ScrollBar>
129-
118+
<InnerGrid
119+
containerPadding={rootContainerPadding}
120+
overflow={rootContainerOverflow}
121+
{...props}
122+
positionParams={positionParams} // Added By Aqib Mirza
123+
{...gridLayoutCanvasProps}
124+
bgColor={bgColor}
125+
radius="0px"
126+
/>
127+
</Profiler>
128+
{/*</ScrollBar> */}
130129
</div>
131130
</UICompContainer>
132131
);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ export function listPropertyView(compType: ListCompType) {
6262
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
6363
<><Section name={sectionNames.layout}>
6464
{children.autoHeight.getPropertyView()}
65-
{children.scrollbars.propertyView({
66-
label: trans("prop.scrollbar"),
67-
})}
65+
{!children.autoHeight.getView() &&
66+
children.scrollbars.propertyView({
67+
label: trans("prop.scrollbar"),
68+
}
69+
)}
6870
</Section>
6971
<Section name={sectionNames.style}>
7072
{children.style.getPropertyView()}

client/packages/lowcoder/src/comps/comps/triContainerComp/triContainer.tsx

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ContainerStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
22
import { EditorContext } from "comps/editorState";
33
import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
4-
import { HintPlaceHolder } from "lowcoder-design";
4+
import { HintPlaceHolder, ScrollBar } from "lowcoder-design";
55
import { ReactNode, useContext } from "react";
66
import styled, { css } from "styled-components";
77
import { checkIsMobile } from "util/commonUtils";
@@ -14,10 +14,7 @@ const getStyle = (style: ContainerStyleType) => {
1414
border-width: ${style.borderWidth};
1515
border-radius: ${style.radius};
1616
overflow: hidden;
17-
// margin: ${style.margin};
1817
padding: ${style.padding};
19-
// width: ${widthCalculator(style.margin)};
20-
// height: ${heightCalculator(style.margin)};
2118
${style.background && `background-color: ${style.background};`}
2219
${style.backgroundImage && `background-image: ${style.backgroundImage};`}
2320
${style.backgroundImageRepeat && `background-repeat: ${style.backgroundImageRepeat};`}
@@ -107,6 +104,7 @@ export function TriContainer(props: TriContainerProps) {
107104
const { showHeader, showFooter } = container;
108105
// When the header and footer are not displayed, the body must be displayed
109106
const showBody = container.showBody || (!showHeader && !showFooter);
107+
const scrollbars = container.scrollbars;
110108

111109
const { items: headerItems, ...otherHeaderProps } = container.header;
112110
const { items: bodyItems, ...otherBodyProps } = container.body["0"].children.view.getView();
@@ -149,27 +147,52 @@ export function TriContainer(props: TriContainerProps) {
149147
)}
150148
{showBody && (
151149
<BackgroundColorContext.Provider value={bodyStyle.background}>
152-
<BodyInnerGrid
153-
$showBorder={showHeader}
154-
{...otherBodyProps}
155-
items={gridItemCompToGridItems(bodyItems)}
156-
autoHeight={container.autoHeight}
157-
emptyRows={14}
158-
minHeight={showHeader ? "143px" : "142px"}
159-
containerPadding={
160-
(showHeader && showFooter) || showHeader ? [paddingWidth, 11.5] : [paddingWidth, 11]
161-
}
162-
hintPlaceholder={props.hintPlaceholder ?? HintPlaceHolder}
163-
$backgroundColor={bodyStyle?.background || 'transparent'}
164-
$borderColor={style?.border}
165-
$borderWidth={style?.borderWidth}
166-
$backgroundImage={bodyStyle?.backgroundImage}
167-
$backgroundImageRepeat={bodyStyle?.backgroundImageRepeat}
168-
$backgroundImageSize={bodyStyle?.backgroundImageSize}
169-
$backgroundImagePosition={bodyStyle?.backgroundImagePosition}
170-
$backgroundImageOrigin={bodyStyle?.backgroundImageOrigin}
171-
style={{padding: bodyStyle.containerbodypadding}}
172-
/>
150+
{scrollbars ? (
151+
<ScrollBar style={{ height: container.autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }}>
152+
<BodyInnerGrid
153+
$showBorder={showHeader}
154+
{...otherBodyProps}
155+
items={gridItemCompToGridItems(bodyItems)}
156+
autoHeight={container.autoHeight}
157+
emptyRows={14}
158+
minHeight={showHeader ? "143px" : "142px"}
159+
containerPadding={
160+
(showHeader && showFooter) || showHeader ? [paddingWidth, 11.5] : [paddingWidth, 11]
161+
}
162+
hintPlaceholder={props.hintPlaceholder ?? HintPlaceHolder}
163+
$backgroundColor={bodyStyle?.background || 'transparent'}
164+
$borderColor={style?.border}
165+
$borderWidth={style?.borderWidth}
166+
$backgroundImage={bodyStyle?.backgroundImage}
167+
$backgroundImageRepeat={bodyStyle?.backgroundImageRepeat}
168+
$backgroundImageSize={bodyStyle?.backgroundImageSize}
169+
$backgroundImagePosition={bodyStyle?.backgroundImagePosition}
170+
$backgroundImageOrigin={bodyStyle?.backgroundImageOrigin}
171+
style={{padding: bodyStyle.containerbodypadding}}
172+
/>
173+
</ScrollBar>
174+
) : (
175+
<BodyInnerGrid
176+
$showBorder={showHeader}
177+
{...otherBodyProps}
178+
items={gridItemCompToGridItems(bodyItems)}
179+
autoHeight={container.autoHeight}
180+
emptyRows={14}
181+
minHeight={showHeader ? "143px" : "142px"}
182+
containerPadding={
183+
(showHeader && showFooter) || showHeader ? [paddingWidth, 11.5] : [paddingWidth, 11]
184+
}
185+
hintPlaceholder={props.hintPlaceholder ?? HintPlaceHolder}
186+
$backgroundColor={bodyStyle?.background || 'transparent'}
187+
$borderColor={style?.border}
188+
$borderWidth={style?.borderWidth}
189+
$backgroundImage={bodyStyle?.backgroundImage}
190+
$backgroundImageRepeat={bodyStyle?.backgroundImageRepeat}
191+
$backgroundImageSize={bodyStyle?.backgroundImageSize}
192+
$backgroundImagePosition={bodyStyle?.backgroundImagePosition}
193+
$backgroundImageOrigin={bodyStyle?.backgroundImageOrigin}
194+
style={{padding: bodyStyle.containerbodypadding}}/>
195+
)}
173196
</BackgroundColorContext.Provider>
174197
)}
175198
{showFooter && (

client/packages/lowcoder/src/comps/comps/triContainerComp/triContainerComp.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const childrenMap = {
3939
showBody: BoolControl.DEFAULT_TRUE,
4040
showFooter: BoolControl,
4141
autoHeight: AutoHeightControl,
42-
42+
scrollbars: withDefault(BoolControl, false),
4343
style: styleControl(ContainerStyle),
4444
headerStyle: styleControl(ContainerHeaderStyle),
4545
bodyStyle: styleControl(ContainerBodyStyle),
@@ -55,6 +55,7 @@ const TriContainerBaseComp = migrateOldData(
5555
);
5656

5757
export class TriContainerComp extends TriContainerBaseComp implements IContainer {
58+
scrollbars: any;
5859
private allContainers() {
5960
return [
6061
this.children.header,
@@ -124,6 +125,7 @@ export class TriContainerComp extends TriContainerBaseComp implements IContainer
124125
this.children.showHeader.propertyView({ label: trans("prop.showHeader") }),
125126
this.children.showBody.propertyView({ label: trans("prop.showBody") }),
126127
this.children.showFooter.propertyView({ label: trans("prop.showFooter") }),
128+
this.children.scrollbars.propertyView({ label: trans("prop.scrollbar") }),
127129
];
128130
}
129131

0 commit comments

Comments
 (0)