Skip to content

Commit a21a575

Browse files
committed
scrollbar toggle
1 parent 4299c67 commit a21a575

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

client/packages/lowcoder/src/comps/comps/jsonComp/jsonEditorComp.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ import {
2121
import { useExtensions } from "base/codeEditor/extensions";
2222
import { EditorContext } from "comps/editorState";
2323
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
24-
import { AutoHeightControl } from "@lowcoder-ee/index.sdk";
24+
import { AutoHeightControl, BoolControl } from "@lowcoder-ee/index.sdk";
2525

2626
/**
2727
* JsonEditor Comp
2828
*/
2929

30-
const Wrapper = styled.div<{$height: boolean}>`
30+
const Wrapper = styled.div<{$height: boolean; $showVerticalScrollbar:boolean}>`
3131
background-color: #fff;
3232
border: 1px solid #d7d9e0;
3333
border-radius: 4px;
3434
overflow: scroll;
3535
height: ${(props) => (props.$height ? '100%' : '300px')};
3636
&::-webkit-scrollbar {
3737
width: 16px;
38-
display:block !important;
38+
display: ${props=>props.$showVerticalScrollbar&&'block !important'};
3939
}
4040
`;
4141

@@ -71,6 +71,7 @@ const childrenMap = {
7171
value: jsonValueExposingStateControl('value', defaultData),
7272
onEvent: ChangeEventHandlerControl,
7373
autoHeight: AutoHeightControl,
74+
showVerticalScrollbar:BoolControl,
7475
label: withDefault(LabelControl, {position: 'column'}),
7576
style: styleControl(JsonEditorStyle, 'style'),
7677
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
@@ -127,7 +128,14 @@ let JsonEditorTmpComp = (function () {
127128
return props.label({
128129
style: props.style,
129130
animationStyle: props.animationStyle,
130-
children: <Wrapper ref={wrapperRef} onFocus={() => (editContent.current = "focus")} $height={props.autoHeight}/>,
131+
children: (
132+
<Wrapper
133+
ref={wrapperRef}
134+
onFocus={() => (editContent.current = 'focus')}
135+
$height={props.autoHeight}
136+
$showVerticalScrollbar={props.showVerticalScrollbar}
137+
/>
138+
),
131139
});
132140
})
133141
.setPropertyViewFn((children) => {
@@ -148,6 +156,9 @@ let JsonEditorTmpComp = (function () {
148156
<Section name={trans('prop.height')}>
149157
{children.autoHeight.propertyView({ label: trans('prop.height') })}
150158
</Section>
159+
<Section name={sectionNames.layout}>
160+
{children.showVerticalScrollbar.propertyView({label:trans('prop.showVerticalScrollbar')})}
161+
</Section>
151162
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && ( children.label.getPropertyView() )}
152163
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
153164
<>

client/packages/lowcoder/src/comps/comps/jsonComp/jsonExplorerComp.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const JsonExplorerContainer = styled.div<{
4242
$theme: keyof typeof bgColorMap;
4343
$animationStyle: AnimationStyleType;
4444
$height: boolean;
45+
$showVerticalScrollbar:boolean;
4546
}>`
4647
${(props) => props.$animationStyle}
4748
height: ${(props) => (props.$height ? '100%' : '300px')};
@@ -52,14 +53,15 @@ const JsonExplorerContainer = styled.div<{
5253
padding: 10px;
5354
&::-webkit-scrollbar {
5455
width: 16px;
55-
display: block !important;
56+
display: ${props=>props.$showVerticalScrollbar&&'block !important'};
5657
}
5758
`;
5859

5960
let JsonExplorerTmpComp = (function () {
6061
const childrenMap = {
6162
value: withDefault(ArrayOrJSONObjectControl, JSON.stringify(defaultData, null, 2)),
6263
autoHeight: AutoHeightControl,
64+
showVerticalScrollbar:BoolControl,
6365
indent: withDefault(NumberControl, 4),
6466
expandToggle: BoolControl.DEFAULT_TRUE,
6567
theme: dropdownControl(themeOptions, 'shapeshifter:inverted'),
@@ -73,6 +75,7 @@ let JsonExplorerTmpComp = (function () {
7375
$height={props.autoHeight}
7476
$theme={props.theme as keyof typeof bgColorMap}
7577
$animationStyle={props.animationStyle}
78+
$showVerticalScrollbar={props.showVerticalScrollbar}
7679
>
7780
<ReactJson
7881
name={false}
@@ -107,6 +110,11 @@ let JsonExplorerTmpComp = (function () {
107110
<Section name={trans('prop.height')}>
108111
{children.autoHeight.propertyView({label: trans('prop.height')})}
109112
</Section>
113+
<Section name={sectionNames.layout}>
114+
{children.showVerticalScrollbar.propertyView({
115+
label: trans('prop.showVerticalScrollbar'),
116+
})}
117+
</Section>
110118
{(useContext(EditorContext).editorModeStatus === 'layout' ||
111119
useContext(EditorContext).editorModeStatus === 'both') && (
112120
<>

0 commit comments

Comments
 (0)