Skip to content

Commit 1c14de6

Browse files
author
FalkWolsky
committed
Introduce switchable Scrollbar for Module and List View
1 parent 042e67d commit 1c14de6

File tree

8 files changed

+57
-23
lines changed

8 files changed

+57
-23
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { defaultTheme } from "comps/controls/styleControlConstants";
1919
import { checkIsMobile } from "util/commonUtils";
2020
import { CanvasContainerID } from "constants/domLocators";
2121
import { CNRootContainer } from "constants/styleSelectors";
22+
import { ScrollBar } from "lowcoder-design";
2223

2324
const UICompContainer = styled.div<{ $maxWidth?: number; readOnly?: boolean; $bgColor: string }>`
2425
height: 100%;
@@ -112,7 +113,8 @@ export function CanvasView(props: ContainerBaseProps) {
112113
$bgColor={bgColor}
113114
>
114115
<div>
115-
<Profiler id="Panel" onRender={profilerCallback}>
116+
<ScrollBar style={{ height: "100%", margin: "0px", padding: "0px" }}>
117+
<Profiler id="Panel" onRender={profilerCallback}>
116118
<InnerGrid
117119
containerPadding={rootContainerPadding}
118120
overflow={rootContainerOverflow}
@@ -123,6 +125,8 @@ export function CanvasView(props: ContainerBaseProps) {
123125
radius="0px"
124126
/>
125127
</Profiler>
128+
</ScrollBar>
129+
126130
</div>
127131
</UICompContainer>
128132
);

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EditorContext } from "comps/editorState";
33
import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
44
import _ from "lodash";
55
import { ConstructorToView, deferAction } from "lowcoder-core";
6-
import { HintPlaceHolder, pageItemRender } from "lowcoder-design";
6+
import { HintPlaceHolder, ScrollBar, pageItemRender } from "lowcoder-design";
77
import { RefObject, useContext, useEffect, useMemo, useRef } from "react";
88
import ReactResizeDetector from "react-resize-detector";
99
import styled from "styled-components";
@@ -80,7 +80,7 @@ function ListItem(props: ListItemProps) {
8080
// }, []);
8181

8282
return (
83-
<ContainerInListView
83+
<ContainerInListView
8484
layout={containerProps.layout}
8585
items={gridItemCompToGridItems(containerProps.items)}
8686
positionParams={containerProps.positionParams}
@@ -95,7 +95,7 @@ function ListItem(props: ListItemProps) {
9595
scrollContainerRef={scrollContainerRef}
9696
overflow={"hidden"}
9797
minHeight={minHeight}
98-
enableGridLines={true}
98+
enableGridLines={true}
9999
/>
100100
);
101101
}
@@ -125,6 +125,7 @@ export function ListView(props: Props) {
125125
[children.noOfRows]
126126
);
127127
const autoHeight = useMemo(() => children.autoHeight.getView(), [children.autoHeight]);
128+
const scrollbars = useMemo(() => children.scrollbars.getView(), [children.scrollbars]);
128129
const noOfColumns = useMemo(
129130
() => Math.max(1, children.noOfColumns.getView()),
130131
[children.noOfColumns]
@@ -214,14 +215,17 @@ export function ListView(props: Props) {
214215
<BackgroundColorContext.Provider value={style.background}>
215216
<ListViewWrapper $style={style} $paddingWidth={paddingWidth}>
216217
<BodyWrapper ref={ref} $autoHeight={autoHeight}>
217-
<ReactResizeDetector
218-
onResize={(width?: number, height?: number) => {
219-
if (height) setListHeight(height);
220-
}}
221-
observerOptions={{ box: "border-box" }}
222-
>
223-
<div style={{ height: autoHeight ? "auto" : "100%" }}>{renders}</div>
224-
</ReactResizeDetector>
218+
{scrollbars ? (
219+
<ScrollBar style={{ height: autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }}>
220+
<>{<ReactResizeDetector onResize={(width?: number, height?: number) => { if (height) setListHeight(height); }} observerOptions={{ box: "border-box" }} >
221+
<div style={{ height: autoHeight ? "auto" : "100%" }}>{renders}</div>
222+
</ReactResizeDetector>}</>
223+
</ScrollBar>
224+
) : (
225+
<>{<ReactResizeDetector onResize={(width?: number, height?: number) => { if (height) setListHeight(height); }} observerOptions={{ box: "border-box" }} >
226+
<div style={{ height: autoHeight ? "auto" : "100%" }}>{renders}</div>
227+
</ReactResizeDetector>}</>
228+
)}
225229
</BodyWrapper>
226230
<FooterWrapper>
227231
<Pagination size="small" itemRender={pageItemRender} {...pageInfo.pagination} />

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const childrenMap = {
4848
heightUnitOfRow: withDefault(NumberControl, 1),
4949
container: ContextContainerComp,
5050
autoHeight: AutoHeightControl,
51+
scrollbars: withDefault(BoolControl, false),
5152
showBorder: BoolControl,
5253
pagination: withDefault(PaginationControl, { pageSize: "6" }),
5354
style: styleControl(ListViewStyle),

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ListViewImplComp } from "./listViewComp";
44
import { ListCompType } from "./listViewUtils";
55
import { useContext } from "react";
66
import { EditorContext } from "comps/editorState";
7+
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
78

89
type Props = {
910
comp: InstanceType<typeof ListViewImplComp>;
@@ -52,9 +53,18 @@ export function listPropertyView(compType: ListCompType) {
5253
</Section>
5354
)}
5455

56+
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
57+
<Section name={sectionNames.interaction}>
58+
{hiddenPropertyView(children)}
59+
</Section>
60+
)}
61+
5562
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
5663
<><Section name={sectionNames.layout}>
5764
{children.autoHeight.getPropertyView()}
65+
{children.scrollbars.propertyView({
66+
label: trans("prop.scrollbar"),
67+
})}
5868
</Section>
5969
<Section name={sectionNames.style}>
6070
{children.style.getPropertyView()}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "lowcoder-core";
1414
import { RootComp } from "comps/comps/rootComp";
1515
import { AutoHeightControl } from "comps/controls/autoHeightControl";
16-
import { valueComp, withViewFn } from "comps/generators";
16+
import { valueComp, withDefault, withViewFn } from "comps/generators";
1717
import { ToDataType, ToInstanceType } from "comps/generators/multi";
1818
import { HidableView, UICompBuilder } from "comps/generators/uiCompBuilder";
1919
import { withExposingRaw } from "comps/generators/withExposing";
@@ -22,7 +22,7 @@ import { getReduceContext, PartialReduceContext, reduceInContext } from "comps/u
2222
import { API_STATUS_CODES } from "constants/apiConstants";
2323
import { AppTypeEnum } from "constants/applicationConstants";
2424
import { GreyTextColor } from "constants/style";
25-
import { Section, sectionNames } from "lowcoder-design";
25+
import { ScrollBar, Section, sectionNames } from "lowcoder-design";
2626
import { ReactNode, useEffect, useMemo } from "react";
2727
import styled from "styled-components";
2828
import {
@@ -38,6 +38,7 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
3838
import { ModuleLoading } from "components/ModuleLoading";
3939
import { trans } from "i18n";
4040
import { ParamsConfig, ParamType } from "comps/controls/actionSelector/executeCompTypes";
41+
import { BoolControl } from "comps/controls/boolControl";
4142

4243
const Wrapper = styled.div`
4344
height: 100%;
@@ -83,6 +84,7 @@ const childrenMap = {
8384
inputs: ModuleInputComp,
8485
events: eventHandlerControl(),
8586
autoHeight: AutoHeightControl,
87+
scrollbars: withDefault(BoolControl, false),
8688
};
8789

8890
type DataType = ToDataType<ToInstanceType<typeof childrenMap>>;
@@ -121,6 +123,9 @@ class ModuleTmpComp extends ModuleCompBase {
121123
)}
122124
<Section name={sectionNames.layout}>
123125
{!this.autoScaleCompHeight() && this.children.autoHeight.getPropertyView()}
126+
{this.children.scrollbars.propertyView({
127+
label: trans("prop.scrollbar"),
128+
})}
124129
{hiddenPropertyView(this.children)}
125130
</Section>
126131
</>
@@ -525,9 +530,11 @@ const ModuleCompWithView = withViewFn(ModuleTmpComp, (comp) => {
525530
if (comp.moduleRootComp && comp.isReady) {
526531
content = (
527532
<Wrapper className="module-wrapper">
528-
<ExternalEditorContext.Provider value={moduleExternalState}>
529-
{comp.moduleRootComp.getView()}
530-
</ExternalEditorContext.Provider>
533+
<ScrollBar style={{ height: comp.children.scrollbars.getView() ? "100%" : "auto", margin: "0px", padding: "0px" }}>
534+
<ExternalEditorContext.Provider value={moduleExternalState}>
535+
{comp.moduleRootComp.getView()}
536+
</ExternalEditorContext.Provider>
537+
</ScrollBar>
531538
</Wrapper>
532539
);
533540
}

client/packages/lowcoder/src/comps/comps/moduleContainerComp/moduleLayoutComp.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BoolControl } from "comps/controls/boolControl";
2-
import { stateComp, UICompBuilder, valueComp } from "comps/generators";
2+
import { stateComp, UICompBuilder, valueComp, withDefault } from "comps/generators";
33
import { NameGenerator } from "comps/utils";
44
import { NameAndExposingInfo } from "comps/utils/exposingTypes";
55
import { trans } from "i18n";
@@ -11,7 +11,7 @@ import { CompAction, CompActionTypes } from "lowcoder-core";
1111
import { ReactElement, useContext } from "react";
1212
import { ExternalEditorContext } from "util/context/ExternalEditorContext";
1313
import { JSONValue } from "util/jsonTypes";
14-
import { Section, sectionNames } from "lowcoder-design";
14+
import { ScrollBar, Section, sectionNames } from "lowcoder-design";
1515
import { getAllCompItems, IContainer } from "../containerBase";
1616
import { SimpleContainerComp } from "../containerBase/simpleContainerComp";
1717
import { GridItemsType } from "../containerComp/containerView";
@@ -67,7 +67,9 @@ function ModuleLayoutView(props: IProps) {
6767

6868
if (readOnly) {
6969
return (
70-
<ModulePreviewWrapper className={CNRootContainer}>{props.containerView}</ModulePreviewWrapper>
70+
<ScrollBar style={{ height: "100%", margin: "0px", padding: "0px" }}>
71+
<ModulePreviewWrapper className={CNRootContainer}>{props.containerView}</ModulePreviewWrapper>
72+
</ScrollBar>
7173
);
7274
}
7375

@@ -94,7 +96,8 @@ function ModuleLayoutView(props: IProps) {
9496
};
9597

9698
return (
97-
<CanvasView
99+
<ScrollBar style={{ height: "100%", margin: "0px", padding: "0px" }}>
100+
<CanvasView
98101
layout={layout}
99102
items={items}
100103
positionParams={{ ...positionParams, cols: parseInt(defaultGrid) }}
@@ -103,6 +106,7 @@ function ModuleLayoutView(props: IProps) {
103106
onLayoutChange={onLayoutChange}
104107
extraHeight="0px"
105108
/>
109+
</ScrollBar>
106110
);
107111
}
108112

@@ -113,7 +117,8 @@ export class ModuleLayoutComp extends ModuleLayoutCompBase implements IContainer
113117
const isRowCountLocked = this.children.autoScaleCompHeight.getView();
114118
const rowCount = this.children.containerRowCount.getView();
115119
return (
116-
<ModuleLayoutView
120+
<div>
121+
<ModuleLayoutView
117122
positionParams={this.children.positionParams.getView()}
118123
containerSize={this.children.containerSize.getView()}
119124
containerView={this.children.container.containerView({
@@ -133,6 +138,7 @@ export class ModuleLayoutComp extends ModuleLayoutCompBase implements IContainer
133138
});
134139
}}
135140
/>
141+
</div>
136142
);
137143
}
138144
getPropertyView() {

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export const en = {
193193
"maskClosable": "Click Outside to Close",
194194
"showMask": "Show Mask",
195195
"textOverflow": "Text Overflow",
196+
"scrollbar" : "Show Scrollbars",
196197
},
197198
"autoHeightProp": {
198199
"auto": "Auto",

client/packages/lowcoder/src/i18n/locales/zh.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ prop: {
185185
showBody: "显示表体",
186186
showFooter: "显示表尾",
187187
maskClosable: "点击蒙层关闭",
188-
showMask: "显示蒙层"
188+
showMask: "显示蒙层",
189+
scrollbar: "滚动条",
189190
},
190191
autoHeightProp: {
191192
auto: "自动",

0 commit comments

Comments
 (0)