Skip to content

Commit 6e961e3

Browse files
committed
formating removed-113
1 parent 0148e43 commit 6e961e3

File tree

1 file changed

+60
-90
lines changed

1 file changed

+60
-90
lines changed

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

Lines changed: 60 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,47 @@
1-
import {default as Row} from 'antd/es/row';
2-
import {default as Col} from 'antd/es/col';
3-
import {JSONObject, JSONValue} from 'util/jsonTypes';
4-
import {
5-
CompAction,
6-
CompActionTypes,
7-
deleteCompAction,
8-
wrapChildAction,
9-
} from 'lowcoder-core';
10-
import {
11-
DispatchType,
12-
RecordConstructorToView,
13-
wrapDispatch,
14-
} from 'lowcoder-core';
15-
import {AutoHeightControl} from 'comps/controls/autoHeightControl';
16-
import {ColumnOptionControl} from 'comps/controls/optionsControl';
17-
import {styleControl} from 'comps/controls/styleControl';
1+
import { default as Row } from "antd/es/row";
2+
import { default as Col } from "antd/es/col";
3+
import { JSONObject, JSONValue } from "util/jsonTypes";
4+
import { CompAction, CompActionTypes, deleteCompAction, wrapChildAction } from "lowcoder-core";
5+
import { DispatchType, RecordConstructorToView, wrapDispatch } from "lowcoder-core";
6+
import { AutoHeightControl } from "comps/controls/autoHeightControl";
7+
import { ColumnOptionControl } from "comps/controls/optionsControl";
8+
import { styleControl } from "comps/controls/styleControl";
189
import {
1910
ResponsiveLayoutRowStyle,
2011
ResponsiveLayoutRowStyleType,
2112
ResponsiveLayoutColStyleType,
2213
ResponsiveLayoutColStyle,
2314
AnimationStyle,
24-
AnimationStyleType,
25-
} from 'comps/controls/styleControlConstants';
26-
import {sameTypeMap, UICompBuilder, withDefault} from 'comps/generators';
27-
import {addMapChildAction} from 'comps/generators/sameTypeMap';
28-
import {
29-
NameConfigHidden,
30-
withExposingConfigs,
31-
} from 'comps/generators/withExposing';
32-
import {NameGenerator} from 'comps/utils';
33-
import {Section, controlItem, sectionNames} from 'lowcoder-design';
34-
import {HintPlaceHolder} from 'lowcoder-design';
35-
import _ from 'lodash';
36-
import React from 'react';
37-
import styled from 'styled-components';
38-
import {IContainer} from '../containerBase/iContainer';
39-
import {SimpleContainerComp} from '../containerBase/simpleContainerComp';
40-
import {CompTree, mergeCompTrees} from '../containerBase/utils';
15+
AnimationStyleType
16+
} from "comps/controls/styleControlConstants";
17+
import { sameTypeMap, UICompBuilder, withDefault } from "comps/generators";
18+
import { addMapChildAction } from "comps/generators/sameTypeMap";
19+
import { NameConfigHidden, withExposingConfigs } from "comps/generators/withExposing";
20+
import { NameGenerator } from "comps/utils";
21+
import { Section, controlItem, sectionNames } from "lowcoder-design";
22+
import { HintPlaceHolder } from "lowcoder-design";
23+
import _ from "lodash";
24+
import React from "react";
25+
import styled from "styled-components";
26+
import { IContainer } from "../containerBase/iContainer";
27+
import { SimpleContainerComp } from "../containerBase/simpleContainerComp";
28+
import { CompTree, mergeCompTrees } from "../containerBase/utils";
4129
import {
4230
ContainerBaseProps,
4331
gridItemCompToGridItems,
4432
InnerGrid,
45-
} from '../containerComp/containerView';
46-
import {BackgroundColorContext} from 'comps/utils/backgroundColorContext';
47-
import {trans} from 'i18n';
48-
import {messageInstance} from 'lowcoder-design/src/components/GlobalInstances';
49-
import {BoolControl} from 'comps/controls/boolControl';
50-
import {BoolCodeControl, NumberControl} from 'comps/controls/codeControl';
33+
} from "../containerComp/containerView";
34+
import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
35+
import { trans } from "i18n";
36+
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
37+
import { BoolControl } from "comps/controls/boolControl";
38+
import { BoolCodeControl, NumberControl } from "comps/controls/codeControl";
5139

52-
import {useContext} from 'react';
53-
import {EditorContext} from 'comps/editorState';
40+
import { useContext } from "react";
41+
import { EditorContext } from "comps/editorState";
5442

55-
import {
56-
disabledPropertyView,
57-
hiddenPropertyView,
58-
} from 'comps/utils/propertyUtils';
59-
import {DisabledContext} from 'comps/generators/uiCompBuilder';
43+
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
44+
import { DisabledContext } from "comps/generators/uiCompBuilder";
6045

6146
const RowWrapper = styled(Row)<{
6247
$style: ResponsiveLayoutRowStyleType;
@@ -72,33 +57,33 @@ const RowWrapper = styled(Row)<{
7257
`;
7358

7459
const ColWrapper = styled(Col)<{
75-
$style: ResponsiveLayoutColStyleType;
76-
$minWidth?: string;
77-
$matchColumnsHeight: boolean;
60+
$style: ResponsiveLayoutColStyleType,
61+
$minWidth?: string,
62+
$matchColumnsHeight: boolean,
7863
}>`
7964
display: flex;
8065
flex-direction: column;
8166
flex-basis: ${(props) => props.$minWidth};
8267
max-width: ${(props) => props.$minWidth};
8368
8469
> div {
85-
height: ${(props) => (props.$matchColumnsHeight ? '100%' : 'auto')};
70+
height: ${(props) => props.$matchColumnsHeight ? '100%' : 'auto'};
8671
}
8772
`;
8873

89-
const childrenMap = {
74+
const childrenMap = {
9075
disabled: BoolCodeControl,
9176
columns: ColumnOptionControl,
9277
containers: withDefault(sameTypeMap(SimpleContainerComp), {
93-
0: {view: {}, layout: {}},
94-
1: {view: {}, layout: {}},
78+
0: { view: {}, layout: {} },
79+
1: { view: {}, layout: {} },
9580
}),
9681
autoHeight: AutoHeightControl,
9782
rowBreak: withDefault(BoolControl, false),
9883
matchColumnsHeight: withDefault(BoolControl, true),
9984
rowStyle: withDefault(styleControl(ResponsiveLayoutRowStyle), {}),
10085
columnStyle: withDefault(styleControl(ResponsiveLayoutColStyle), {}),
101-
animationStyle: styleControl(AnimationStyle),
86+
animationStyle:styleControl(AnimationStyle),
10287
columnPerRowLG: withDefault(NumberControl, 4),
10388
columnPerRowMD: withDefault(NumberControl, 2),
10489
columnPerRowSM: withDefault(NumberControl, 1),
@@ -107,10 +92,10 @@ const childrenMap = {
10792
};
10893

10994
type ViewProps = RecordConstructorToView<typeof childrenMap>;
110-
type ResponsiveLayoutProps = ViewProps & {dispatch: DispatchType};
95+
type ResponsiveLayoutProps = ViewProps & { dispatch: DispatchType };
11196
type ColumnContainerProps = Omit<ContainerBaseProps, 'style'> & {
112-
style: ResponsiveLayoutColStyleType;
113-
};
97+
style: ResponsiveLayoutColStyleType,
98+
}
11499

115100
const ColumnContainer = (props: ColumnContainerProps) => {
116101
return (
@@ -124,6 +109,7 @@ const ColumnContainer = (props: ColumnContainerProps) => {
124109
);
125110
};
126111

112+
127113
const ResponsiveLayout = (props: ResponsiveLayoutProps) => {
128114
let {
129115
columns,
@@ -138,7 +124,7 @@ const ResponsiveLayout = (props: ResponsiveLayoutProps) => {
138124
columnPerRowSM,
139125
verticalSpacing,
140126
horizontalSpacing,
141-
animationStyle,
127+
animationStyle
142128
} = props;
143129

144130
return (
@@ -236,7 +222,9 @@ const ResponsiveLayout = (props: ResponsiveLayoutProps) => {
236222

237223
export const ResponsiveLayoutBaseComp = (function () {
238224
return new UICompBuilder(childrenMap, (props, dispatch) => {
239-
return <ResponsiveLayout {...props} dispatch={dispatch} />;
225+
return (
226+
<ResponsiveLayout {...props} dispatch={dispatch} />
227+
);
240228
})
241229
.setPropertyViewFn((children) => {
242230
return (
@@ -317,35 +305,25 @@ export const ResponsiveLayoutBaseComp = (function () {
317305
.build();
318306
})();
319307

320-
class ResponsiveLayoutImplComp
321-
extends ResponsiveLayoutBaseComp
322-
implements IContainer
323-
{
308+
class ResponsiveLayoutImplComp extends ResponsiveLayoutBaseComp implements IContainer {
324309
private syncContainers(): this {
325310
const columns = this.children.columns.getView();
326-
const ids: Set<string> = new Set(
327-
columns.map((column) => String(column.id))
328-
);
311+
const ids: Set<string> = new Set(columns.map((column) => String(column.id)));
329312
let containers = this.children.containers.getView();
330313
// delete
331314
const actions: CompAction[] = [];
332315
Object.keys(containers).forEach((id) => {
333316
if (!ids.has(id)) {
334317
// log.debug("syncContainers delete. ids=", ids, " id=", id);
335-
actions.push(
336-
wrapChildAction('containers', wrapChildAction(id, deleteCompAction()))
337-
);
318+
actions.push(wrapChildAction("containers", wrapChildAction(id, deleteCompAction())));
338319
}
339320
});
340321
// new
341322
ids.forEach((id) => {
342323
if (!containers.hasOwnProperty(id)) {
343324
// log.debug("syncContainers new containers: ", containers, " id: ", id);
344325
actions.push(
345-
wrapChildAction(
346-
'containers',
347-
addMapChildAction(id, {layout: {}, items: {}})
348-
)
326+
wrapChildAction("containers", addMapChildAction(id, { layout: {}, items: {} }))
349327
);
350328
}
351329
});
@@ -361,26 +339,20 @@ class ResponsiveLayoutImplComp
361339
const columns = this.children.columns.getView();
362340
if (action.type === CompActionTypes.CUSTOM) {
363341
const value = action.value as JSONObject;
364-
if (value.type === 'push') {
342+
if (value.type === "push") {
365343
const itemValue = value.value as JSONObject;
366344
if (_.isEmpty(itemValue.key)) itemValue.key = itemValue.label;
367345
action = {
368346
...action,
369347
value: {
370348
...value,
371-
value: {...itemValue},
349+
value: { ...itemValue },
372350
},
373351
} as CompAction;
374352
}
375-
const {path} = action;
376-
if (
377-
value.type === 'delete' &&
378-
path[0] === 'columns' &&
379-
columns.length <= 1
380-
) {
381-
messageInstance.warning(
382-
trans('responsiveLayout.atLeastOneColumnError')
383-
);
353+
const { path } = action;
354+
if (value.type === "delete" && path[0] === 'columns' && columns.length <= 1) {
355+
messageInstance.warning(trans("responsiveLayout.atLeastOneColumnError"));
384356
// at least one column
385357
return this;
386358
}
@@ -403,9 +375,7 @@ class ResponsiveLayoutImplComp
403375

404376
getCompTree(): CompTree {
405377
const containerMap = this.children.containers.getView();
406-
const compTrees = Object.values(containerMap).map((container) =>
407-
container.getCompTree()
408-
);
378+
const compTrees = Object.values(containerMap).map((container) => container.getCompTree());
409379
return mergeCompTrees(compTrees);
410380
}
411381

@@ -426,7 +396,7 @@ class ResponsiveLayoutImplComp
426396
container.getPasteValue(nameGenerator)
427397
);
428398

429-
return {...this.toJsonValue(), containers: containerPasteValueMap};
399+
return { ...this.toJsonValue(), containers: containerPasteValueMap };
430400
}
431401

432402
override autoHeight(): boolean {
@@ -436,5 +406,5 @@ class ResponsiveLayoutImplComp
436406

437407
export const ResponsiveLayoutComp = withExposingConfigs(
438408
ResponsiveLayoutImplComp,
439-
[NameConfigHidden]
409+
[ NameConfigHidden]
440410
);

0 commit comments

Comments
 (0)