Skip to content

Commit 7758d4a

Browse files
author
FalkWolsky
committed
Update Scrollbars
1 parent 5cadfc3 commit 7758d4a

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

client/packages/lowcoder-design/src/components/ScrollBar.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,19 @@ interface IProps {
5858
hideScrollbar?: boolean;
5959
}
6060

61-
export const ScrollBar = ({ height = "100%", className, children, style, scrollableNodeProps, hideScrollbar, ...otherProps }: IProps) => {
61+
export const ScrollBar = ({ height = "100%", className, children, style, scrollableNodeProps, hideScrollbar = false, ...otherProps }: IProps) => {
6262
// You can now use the style prop directly or pass it to SimpleBar
6363
const combinedStyle = { ...style, height }; // Example of combining height with passed style
6464

65-
return (hideScrollbar ?? false) ? (
65+
return hideScrollbar ? (
66+
<ScrollBarWrapper className={className}>
67+
{children}
68+
</ScrollBarWrapper>
69+
) : (
6670
<ScrollBarWrapper className={className}>
6771
<SimpleBar style={combinedStyle} scrollableNodeProps={scrollableNodeProps} {...otherProps}>
6872
{children}
6973
</SimpleBar>
7074
</ScrollBarWrapper>
71-
)
72-
: (
73-
<ScrollBarWrapper className={className}>
74-
{children}
75-
</ScrollBarWrapper>
7675
);
7776
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export function ListView(props: Props) {
215215
<BackgroundColorContext.Provider value={style.background}>
216216
<ListViewWrapper $style={style} $paddingWidth={paddingWidth}>
217217
<BodyWrapper ref={ref} $autoHeight={autoHeight}>
218-
<ScrollBar style={{ height: autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }} hideScrollbar={scrollbars}>
218+
<ScrollBar style={{ height: autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }} hideScrollbar={!scrollbars}>
219219
<>{<ReactResizeDetector onResize={(width?: number, height?: number) => { if (height) setListHeight(height); }} observerOptions={{ box: "border-box" }} >
220220
<div style={{ height: autoHeight ? "auto" : "100%" }}>{renders}</div>
221221
</ReactResizeDetector>}</>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ class ModuleTmpComp extends ModuleCompBase {
505505
const ModuleCompWithView = withViewFn(ModuleTmpComp, (comp) => {
506506
const appId = comp.children.appId.getView();
507507
const error = comp.children.error.getView();
508+
const scrollbars = comp.children.scrollbars.getView();
508509

509510
const moduleExternalState: ExternalEditorContextState = useMemo(
510511
() => ({
@@ -530,7 +531,7 @@ const ModuleCompWithView = withViewFn(ModuleTmpComp, (comp) => {
530531
if (comp.moduleRootComp && comp.isReady) {
531532
content = (
532533
<Wrapper className="module-wrapper">
533-
<ScrollBar style={{ height: comp.children.scrollbars.getView() ? "100%" : "auto", margin: "0px", padding: "0px" }}>
534+
<ScrollBar style={{ height: comp.autoHeight() ? "100%" : "auto", margin: "0px", padding: "0px" }} hideScrollbar={!scrollbars}>
534535
<ExternalEditorContext.Provider value={moduleExternalState}>
535536
{comp.moduleRootComp.getView()}
536537
</ExternalEditorContext.Provider>

client/packages/lowcoder/src/comps/comps/tabs/tabbedContainerComp.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { JSONObject, JSONValue } from "util/jsonTypes";
33
import { CompAction, CompActionTypes, deleteCompAction, wrapChildAction } from "lowcoder-core";
44
import { DispatchType, RecordConstructorToView, wrapDispatch } from "lowcoder-core";
55
import { AutoHeightControl } from "comps/controls/autoHeightControl";
6-
import { BooleanStateControl, booleanExposingStateControl, stringExposingStateControl } from "comps/controls/codeStateControl";
6+
import { stringExposingStateControl } from "comps/controls/codeStateControl";
77
import { eventHandlerControl } from "comps/controls/eventHandlerControl";
88
import { TabsOptionControl } from "comps/controls/optionsControl";
99
import { styleControl } from "comps/controls/styleControl";
@@ -12,7 +12,7 @@ import { sameTypeMap, UICompBuilder, withDefault } from "comps/generators";
1212
import { addMapChildAction } from "comps/generators/sameTypeMap";
1313
import { NameConfig, NameConfigHidden, withExposingConfigs } from "comps/generators/withExposing";
1414
import { NameGenerator } from "comps/utils";
15-
import { ControlNode, Section, sectionNames } from "lowcoder-design";
15+
import { ScrollBar, Section, sectionNames } from "lowcoder-design";
1616
import { HintPlaceHolder } from "lowcoder-design";
1717
import _ from "lodash";
1818
import React, { useCallback, useContext } from "react";
@@ -33,6 +33,7 @@ import { DisabledContext } from "comps/generators/uiCompBuilder";
3333
import { EditorContext } from "comps/editorState";
3434
import { checkIsMobile } from "util/commonUtils";
3535
import { messageInstance } from "lowcoder-design";
36+
import { BoolControl } from "comps/controls/boolControl";
3637

3738
const EVENT_OPTIONS = [
3839
{
@@ -50,9 +51,10 @@ const childrenMap = {
5051
1: { layout: {}, items: {} },
5152
}),
5253
autoHeight: AutoHeightControl,
54+
scrollbars: withDefault(BoolControl, false),
5355
onEvent: eventHandlerControl(EVENT_OPTIONS),
5456
disabled: BoolCodeControl,
55-
showHeader: withDefault(BooleanStateControl, "true"),
57+
showHeader: withDefault(BoolControl, true),
5658
style: styleControl(TabContainerStyle),
5759
headerStyle: styleControl(ContainerHeaderStyle),
5860
bodyStyle: styleControl(ContainerBodyStyle),
@@ -211,7 +213,7 @@ const TabbedContainer = (props: TabbedContainerProps) => {
211213
const editorState = useContext(EditorContext);
212214
const maxWidth = editorState.getAppSettings().maxWidth;
213215
const isMobile = checkIsMobile(maxWidth);
214-
const showHeader = props.showHeader.value;
216+
const showHeader = props.showHeader.valueOf();
215217
const paddingWidth = isMobile ? 8 : 0;
216218

217219
const tabItems = visibleTabs.map((tab) => {
@@ -236,14 +238,16 @@ const TabbedContainer = (props: TabbedContainerProps) => {
236238
forceRender: true,
237239
children: (
238240
<BackgroundColorContext.Provider value={bodyStyle.background}>
239-
<ContainerInTab
240-
layout={containerProps.layout.getView()}
241-
items={gridItemCompToGridItems(containerProps.items.getView())}
242-
positionParams={containerProps.positionParams.getView()}
243-
dispatch={childDispatch}
244-
autoHeight={props.autoHeight}
245-
containerPadding={[paddingWidth, 20]}
246-
/>
241+
<ScrollBar style={{ height: props.autoHeight ? "100%" : "auto", margin: "0px", padding: "0px" }} hideScrollbar={!props.scrollbars}>
242+
<ContainerInTab
243+
layout={containerProps.layout.getView()}
244+
items={gridItemCompToGridItems(containerProps.items.getView())}
245+
positionParams={containerProps.positionParams.getView()}
246+
dispatch={childDispatch}
247+
autoHeight={props.autoHeight}
248+
containerPadding={[paddingWidth, 20]}
249+
/>
250+
</ScrollBar>
247251
</BackgroundColorContext.Provider>
248252
)
249253
}
@@ -307,6 +311,11 @@ export const TabbedContainerBaseComp = (function () {
307311
<>
308312
<Section name={sectionNames.layout}>
309313
{children.autoHeight.getPropertyView()}
314+
{!children.autoHeight.getView() && (
315+
children.scrollbars.propertyView({
316+
label: trans("prop.scrollbar"),
317+
})
318+
)}
310319
</Section>
311320
<Section name={sectionNames.style}>
312321
{children.style.getPropertyView()}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function TriContainer(props: TriContainerProps) {
147147
)}
148148
{showBody && (
149149
<BackgroundColorContext.Provider value={bodyStyle.background}>
150-
<ScrollBar style={{ height: container.autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }} hideScrollbar={scrollbars}>
150+
<ScrollBar style={{ height: container.autoHeight ? "auto" : "100%", margin: "0px", padding: "0px" }} hideScrollbar={!scrollbars}>
151151
<BodyInnerGrid
152152
$showBorder={showHeader}
153153
{...otherBodyProps}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,15 @@ export class TriContainerComp extends TriContainerBaseComp implements IContainer
125125
this.children.showHeader.propertyView({ label: trans("prop.showHeader") }),
126126
this.children.showBody.propertyView({ label: trans("prop.showBody") }),
127127
this.children.showFooter.propertyView({ label: trans("prop.showFooter") }),
128-
(!this.children.autoHeight.getView()) && this.children.scrollbars.propertyView({ label: trans("prop.scrollbar") }),
128+
129129
];
130130
}
131131

132132
heightPropertyView() {
133-
return this.children.autoHeight.getPropertyView();
133+
return [
134+
this.children.autoHeight.getPropertyView(),
135+
(!this.children.autoHeight.getView()) && this.children.scrollbars.propertyView({ label: trans("prop.scrollbar") })
136+
];
134137
}
135138

136139
stylePropertyView() {

0 commit comments

Comments
 (0)