Skip to content

Commit 1be2fc5

Browse files
author
FalkWolsky
committed
Resize handles
1 parent 683c87e commit 1be2fc5

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export class TableImplComp extends TableInitComp implements IContainer {
6464
override autoHeight(): boolean {
6565
return this.children.autoHeight.getView();
6666
}
67+
68+
getTableAutoHeight() {
69+
return this.children.autoHeight.getView();
70+
}
6771

6872
private getSlotContainer() {
6973
return this.children.expansion.children.slot.getSelectedComp().getComp().children.container;

client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const getStyle = (
5757
const selectedRowBackground = genLinerGradient(rowStyle.selectedRowBackground);
5858
const hoverRowBackground = genLinerGradient(rowStyle.hoverRowBackground);
5959
const alternateBackground = genLinerGradient(rowStyle.alternateBackground);
60-
// const tableAutoHeight =
6160

6261
return css`
6362
.ant-table-body {
@@ -123,7 +122,9 @@ const getStyle = (
123122
`;
124123
};
125124

126-
const TitleResizeHandle = styled.span`
125+
const TitleResizeHandle = styled.span<{
126+
$visibleResizables: boolean;
127+
}>`
127128
position: absolute;
128129
top: 0;
129130
right: -5px;
@@ -135,10 +136,9 @@ const TitleResizeHandle = styled.span`
135136

136137
const BackgroundWrapper = styled.div<{
137138
$style: TableStyleType;
138-
$tableAutoHeight?: boolean;
139+
$tableAutoHeight: boolean;
139140
}>`
140-
${(props) => !props.$tableAutoHeight && ` height: calc(100% - ${props.$style.margin} - ${props.$style.margin}) !important`};
141-
${(props) => props.$tableAutoHeight && ` height: calc(100% + ${props.$style.margin}`};
141+
${(props) => !props.$tableAutoHeight && `height: calc(100% - ${props.$style.margin} - ${props.$style.margin});`}
142142
background: ${(props) => props.$style.background} !important;
143143
border: ${(props) => `${props.$style.borderWidth} solid ${props.$style.border} !important`};
144144
border-radius: ${(props) => props.$style.radius} !important;
@@ -435,7 +435,8 @@ const ResizeableTitle = (props: any) => {
435435
draggableOpts={{ enableUserSelectHack: false }}
436436
handle={(axis: ResizeHandleAxis, ref: ReactRef<HTMLDivElement>) => (
437437
<TitleResizeHandle
438-
ref={ref}
438+
ref={ref}
439+
$visibleResizables={props.visibleResizables}
439440
onClick={(e) => {
440441
e.preventDefault();
441442
e.stopPropagation();
@@ -451,6 +452,7 @@ const ResizeableTitle = (props: any) => {
451452
type CustomTableProps<RecordType> = Omit<TableProps<RecordType>, "components" | "columns"> & {
452453
columns: CustomColumnType<RecordType>[];
453454
viewModeResizable: boolean;
455+
visibleResizables: boolean;
454456
rowColorFn: RowColorViewType;
455457
rowHeightFn: RowHeightViewType;
456458
columnsStyle: TableColumnStyleType;
@@ -673,12 +675,13 @@ export function TableCompView(props: {
673675
const [loading, setLoading] = useState(false);
674676
const { comp, onDownload, onRefresh } = props;
675677
const compChildren = comp.children;
676-
const tableAutoHeight = compChildren.autoHeight.getView();
677678
const style = compChildren.style.getView();
678679
const rowStyle = compChildren.rowStyle.getView();
679680
const headerStyle = compChildren.headerStyle.getView();
680681
const toolbarStyle = compChildren.toolbarStyle.getView();
681682
const rowAutoHeight = compChildren.rowAutoHeight.getView();
683+
const tableAutoHeight = comp.getTableAutoHeight();
684+
const visibleResizables = compChildren.visibleResizables.getView();
682685
const columnsStyle = compChildren.columnsStyle.getView();
683686
const changeSet = useMemo(() => compChildren.columns.getChangeSet(), [compChildren.columns]);
684687
const hasChange = useMemo(() => !_.isEmpty(changeSet), [changeSet]);
@@ -785,11 +788,9 @@ export function TableCompView(props: {
785788
}
786789

787790
return (
788-
<BackgroundColorContext.Provider value={style.background}>
791+
<BackgroundColorContext.Provider value={style.background} >
789792

790-
<BackgroundWrapper ref={ref} $style={style}
791-
$tableAutoHeight={compChildren.autoHeight.getView()}
792-
>
793+
<BackgroundWrapper ref={ref} $style={style} $tableAutoHeight={tableAutoHeight}>
793794
{toolbar.position === "above" && toolbarView}
794795
<TableWrapper
795796
$style={style}
@@ -800,8 +801,6 @@ export function TableCompView(props: {
800801
$fixedHeader={compChildren.fixedHeader.getView()}
801802
$fixedToolbar={toolbar.fixedToolbar && toolbar.position === 'above'}
802803
>
803-
804-
805804
<ResizeableTable<RecordType>
806805
expandable={{
807806
...expansion.expandableConfig,
@@ -824,6 +823,7 @@ export function TableCompView(props: {
824823
columns={antdColumns}
825824
columnsStyle={columnsStyle}
826825
viewModeResizable={compChildren.viewModeResizable.getView()}
826+
visibleResizables={compChildren.visibleResizables.getView()}
827827
dataSource={pageDataInfo.data}
828828
size={compChildren.size.getView()}
829829
rowAutoHeight={rowAutoHeight}

client/packages/lowcoder/src/comps/comps/tableComp/tablePropertyView.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
473473
label: trans("table.viewModeResizable"),
474474
tooltip: trans("table.viewModeResizableTooltip"),
475475
})}
476+
{comp.children.visibleResizables.propertyView({
477+
label: trans("table.visibleResizables"),
478+
tooltip: trans("table.visibleResizablesTooltip"),
479+
})}
476480
</Section>
477481
<Section name={trans("prop.pagination")}>
478482
{comp.children.pagination.getPropertyView()}

client/packages/lowcoder/src/comps/comps/tableComp/tableTypes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,14 @@ const tableChildrenMap = {
191191
searchText: StringControl,
192192
columnsStyle: withDefault(styleControl(TableColumnStyle), {borderWidth: '1px', radius: '0px'}),
193193
viewModeResizable: BoolControl,
194+
visibleResizables: BoolControl,
194195
// sample data for regenerating columns
195196
dataRowExample: stateComp<JSONObject | null>(null),
196197
onEvent: TableEventControl,
197198
loading: BoolCodeControl,
198199
rowColor: RowColorComp,
199200
rowAutoHeight: withDefault(AutoHeightControl, "auto"),
201+
tableAutoHeight: withDefault(AutoHeightControl, "auto"),
200202
rowHeight: RowHeightComp,
201203
dynamicColumn: BoolPureControl,
202204
// todo: support object config

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,8 @@ export const en = {
11911191
"columnNum": "Columns",
11921192
"viewModeResizable": "Column Width Adjusted by User",
11931193
"viewModeResizableTooltip": "Whether Users Can Adjust Column Width.",
1194+
"visibleResizables": "Show Resize Handles",
1195+
"visibleResizablesTooltip": "Display visible Resize Handles in the Table Header.",
11941196
"showFilter": "Show Filter Button",
11951197
"showRefresh": "Show Refresh Button",
11961198
"showDownload": "Show Download Button",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@ table: {
11571157
columnNum: "列数",
11581158
viewModeResizable: "用户调整列宽",
11591159
viewModeResizableTooltip: "是否允许调整列宽.",
1160+
"visibleResizables": "Show Resize Handles",
1161+
"visibleResizablesTooltip": "Display visible Resize Handles in the Table Header.",
11601162
showFilter: "显示筛选按钮",
11611163
showRefresh: "显示刷新按钮",
11621164
showDownload: "显示下载按钮",
@@ -1218,6 +1220,7 @@ table: {
12181220
link: "链接",
12191221
links: "多链接",
12201222
tag: "标签",
1223+
select: "下拉单选",
12211224
date: "日期",
12221225
dateTime: "日期时间",
12231226
badgeStatus: "状态",

0 commit comments

Comments
 (0)