Skip to content

Commit 5639011

Browse files
remove useMergeCompStyles hook from comps
1 parent 2f3329d commit 5639011

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+51
-249
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ import {
5555
autocompleteIconColor,
5656
componentSize,
5757
} from "./autoCompleteConstants";
58-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
59-
6058

6159
const InputStyle = styled(Input) <{ $style: InputLikeStyleType }>`
6260
box-shadow: ${props=>`${props.$style?.boxShadow} ${props.$style?.boxShadowColor}`};
@@ -104,9 +102,7 @@ const getValidate = (value: any): "" | "warning" | "error" | undefined => {
104102
};
105103

106104
let AutoCompleteCompBase = (function () {
107-
return new UICompBuilder(childrenMap, (props, dispatch) => {
108-
useMergeCompStyles(props as Record<string, any>, dispatch);
109-
105+
return new UICompBuilder(childrenMap, (props) => {
110106
const {
111107
items,
112108
onEvent,

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { BadgeBasicSection, badgeChildren } from "./badgeComp/badgeConstants";
3434
import { DropdownOptionControl } from "../controls/optionsControl";
3535
import { ReactElement, useContext, useEffect } from "react";
3636
import { CompNameContext, EditorContext } from "../editorState";
37-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
3837

3938
const AvatarWrapper = styled(Avatar) <AvatarProps & { $cursorPointer?: boolean, $style: AvatarStyleType }>`
4039
background: ${(props) => props.$style.background};
@@ -198,9 +197,7 @@ const AvatarView = (props: RecordConstructorToView<typeof childrenMap>) => {
198197
};
199198

200199
let AvatarBasicComp = (function () {
201-
return new UICompBuilder(childrenMap, (props , dispatch) => {
202-
useMergeCompStyles(props as Record<string, any>, dispatch);
203-
200+
return new UICompBuilder(childrenMap, (props) => {
204201
return(<AvatarView {...props} />)})
205202
.setPropertyViewFn((children) => (
206203
<>

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { optionsControl } from "../controls/optionsControl";
1919
import { BoolControl } from "../controls/boolControl";
2020
import { dropdownControl } from "../controls/dropdownControl";
2121
import { JSONObject } from "util/jsonTypes";
22-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2322

2423
const MacaroneList = [
2524
'#fde68a',
@@ -143,9 +142,7 @@ const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & {
143142
};
144143

145144
let AvatarGroupBasicComp = (function () {
146-
return new UICompBuilder(childrenMap, (props, dispatch) =>{
147-
useMergeCompStyles(props as Record<string, any>, dispatch);
148-
145+
return new UICompBuilder(childrenMap, (props, dispatch) => {
149146
return( <AvatarGroupView {...props} dispatch={dispatch} />
150147
)})
151148
.setPropertyViewFn((children) => (

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { RefControl } from "comps/controls/refControl";
2727
import React, { useContext, useEffect } from "react";
2828
import { AnimationStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
2929
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
30-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
3130

3231
const FormLabel = styled(CommonBlueLabel)`
3332
font-size: 13px;
@@ -135,9 +134,7 @@ const ButtonTmpComp = (function () {
135134
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
136135
viewRef: RefControl<HTMLElement>,
137136
};
138-
return new UICompBuilder(childrenMap, (props , dispatch) => {
139-
useMergeCompStyles(props as Record<string, any>, dispatch);
140-
137+
return new UICompBuilder(childrenMap, (props) => {
141138
return(
142139
<ButtonCompWrapper disabled={props.disabled}>
143140
<EditorContext.Consumer>

client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
getButtonStyle,
2323
} from "./buttonCompConstants";
2424
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
25-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2625

2726
const StyledDropdownButton = styled(DropdownButton)`
2827
width: 100%;
@@ -90,9 +89,7 @@ const DropdownTmpComp = (function () {
9089
onEvent: ButtonEventHandlerControl,
9190
style: styleControl(DropdownStyle, 'style'),
9291
};
93-
return new UICompBuilder(childrenMap, (props, dispatch) => {
94-
useMergeCompStyles(props as Record<string, any>, dispatch);
95-
92+
return new UICompBuilder(childrenMap, (props) => {
9693
const hasIcon =
9794
props.options.findIndex((option) => (option.prefixIcon as ReactElement)?.props.value) > -1;
9895
const items = props.options

client/packages/lowcoder/src/comps/comps/buttonComp/floatButtonComp.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import styled from "styled-components";
1717
import { ButtonEventHandlerControl } from "comps/controls/eventHandlerControl";
1818
import { manualOptionsControl } from "comps/controls/optionsControl";
1919
import { useContext, useEffect } from "react";
20-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2120

2221
const StyledFloatButton = styled(FloatButton)<{
2322
$animationStyle: AnimationStyleType;
@@ -133,8 +132,7 @@ const FloatButtonView = (props: RecordConstructorToView<typeof childrenMap>) =>
133132
};
134133

135134
let FloatButtonBasicComp = (function () {
136-
return new UICompBuilder(childrenMap, (props , dispatch) => {
137-
useMergeCompStyles(props, dispatch);
135+
return new UICompBuilder(childrenMap, (props) => {
138136
return(
139137
<FloatButtonView {...props} />
140138
)})

client/packages/lowcoder/src/comps/comps/buttonComp/linkComp.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { RefControl } from "comps/controls/refControl";
2222

2323
import { EditorContext } from "comps/editorState";
2424
import React, { useContext, useEffect } from "react";
25-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2625

2726
const Link = styled(Button)<{
2827
$style: LinkStyleType;
@@ -92,10 +91,7 @@ const LinkTmpComp = (function () {
9291
suffixIcon: IconControl,
9392
viewRef: RefControl<HTMLElement>,
9493
};
95-
return new UICompBuilder(childrenMap, (props, dispatch) => {
96-
useMergeCompStyles(props as Record<string, any>, dispatch);
97-
98-
94+
return new UICompBuilder(childrenMap, (props) => {
9995
// chrome86 bug: button children should not contain only empty span
10096
const hasChildren = hasIcon(props.prefixIcon) || !!props.text || hasIcon(props.suffixIcon);
10197
return (

client/packages/lowcoder/src/comps/comps/buttonComp/scannerComp.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { BoolControl } from "comps/controls/boolControl";
2424
import type { ItemType } from "antd/es/menu/interface";
2525
import { RefControl } from "comps/controls/refControl";
2626
import { EditorContext } from "comps/editorState";
27-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2827

2928
const Error = styled.div`
3029
color: #f5222d;
@@ -74,9 +73,7 @@ const ScannerTmpComp = (function () {
7473
style: styleControl(DropdownStyle, 'style'),
7574
viewRef: RefControl<HTMLElement>,
7675
};
77-
return new UICompBuilder(childrenMap, (props, dispatch) => {
78-
useMergeCompStyles(props as Record<string, any>, dispatch);
79-
76+
return new UICompBuilder(childrenMap, (props) => {
8077
const [showModal, setShowModal] = useState(false);
8178
const [errMessage, setErrMessage] = useState("");
8279
const [videoConstraints, setVideoConstraints] = useState<MediaTrackConstraints>({

client/packages/lowcoder/src/comps/comps/buttonComp/toggleButtonComp.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { BoolControl } from "comps/controls/boolControl";
2525
import { RefControl } from "comps/controls/refControl";
2626
import React, { useContext, useEffect } from "react";
2727
import { EditorContext } from "comps/editorState";
28-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2928

3029
const IconWrapper = styled.div`
3130
display: flex;
@@ -66,11 +65,10 @@ const ToggleTmpComp = (function () {
6665
showBorder: withDefault(BoolControl, true),
6766
viewRef: RefControl<HTMLElement>,
6867
};
69-
return new UICompBuilder(childrenMap, (props, dispatch) => {
68+
return new UICompBuilder(childrenMap, (props) => {
7069
const text = props.showText
7170
? (props.value.value ? props.trueText : props.falseText) || undefined
7271
: undefined;
73-
useMergeCompStyles(props as Record<string, any>, dispatch);
7472

7573
return (
7674
<ButtonCompWrapperStyled

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { AnimationStyle, AnimationStyleType, CarouselStyle } from "comps/control
1717

1818
import { useContext } from "react";
1919
import { EditorContext } from "comps/editorState";
20-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2120

2221
// TODO: dots at top position needs proper margin (should be the same as bottom position)
2322

@@ -49,9 +48,7 @@ let CarouselBasicComp = (function () {
4948
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
5049
...formDataChildren,
5150
};
52-
return new UICompBuilder(childrenMap, (props, dispatch) => {
53-
useMergeCompStyles(props as Record<string, any>, dispatch);
54-
51+
return new UICompBuilder(childrenMap, (props) => {
5552
const containerRef = useRef<HTMLDivElement>(null);
5653
const [height, setHeight] = useState(0);
5754
const onResize = () => {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import { EditorContext } from "comps/editorState";
4040

4141
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
4242
import { DisabledContext } from "comps/generators/uiCompBuilder";
43-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
4443
import SliderControl from "@lowcoder-ee/comps/controls/sliderControl";
4544

4645
const ContainWrapper = styled.div<{
@@ -183,8 +182,6 @@ const ColumnLayout = (props: ColumnLayoutProps) => {
183182

184183
export const ResponsiveLayoutBaseComp = (function () {
185184
return new UICompBuilder(childrenMap, (props, dispatch) => {
186-
useMergeCompStyles(props as Record<string, any>, dispatch);
187-
188185
return (
189186
<ColumnLayout {...props} dispatch={dispatch} />
190187
);

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ import dayjs from "dayjs";
6767
import { getInitialsAndColorCode } from "util/stringUtils";
6868
import { default as CloseOutlined } from "@ant-design/icons/CloseOutlined";
6969

70-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
71-
72-
7370
dayjs.extend(relativeTime);
7471
// dayjs.locale("zh-cn");
7572

@@ -374,9 +371,7 @@ const CommentCompBase = (
374371
};
375372

376373
let CommentBasicComp = (function () {
377-
return new UICompBuilder(childrenMap, (props, dispatch) =>{
378-
useMergeCompStyles(props as Record<string, any>, dispatch);
379-
374+
return new UICompBuilder(childrenMap, (props, dispatch) => {
380375
return (
381376
<CommentCompBase {...props} dispatch={dispatch} />
382377
)})

client/packages/lowcoder/src/comps/comps/containerComp/cardComp.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ButtonEventHandlerControl, CardEventHandlerControl, clickEvent, refresh
2020
import { optionsControl } from "comps/controls/optionsControl";
2121
import { dropdownControl } from "comps/controls/dropdownControl";
2222
import { styleControl } from "comps/controls/styleControl";
23-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
23+
2424
const { Meta } = Card;
2525

2626
const Wrapper = styled.div<{
@@ -193,9 +193,7 @@ export const ContainerBaseComp = (function () {
193193
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
194194
};
195195

196-
return new ContainerCompBuilder(childrenMap, (props, dispatch) => {
197-
useMergeCompStyles(props as Record<string, any>, dispatch);
198-
196+
return new ContainerCompBuilder(childrenMap, (props) => {
199197
props.container.showHeader = false;
200198
// 注入容器参数
201199
props.container.style = Object.assign(props.container.style, {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { trans } from "i18n";
1414
import { EditorContext } from "comps/editorState";
1515
import { AnimationStyle, AnimationStyleType, CustomStyle, CustomStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants";
1616
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
17-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
1817

1918
// TODO: eventually to embedd in container so we have styling?
2019
// TODO: support different starter templates for different frameworks (react, ANT, Flutter, Angular, etc)
@@ -225,8 +224,6 @@ const childrenMap = {
225224
};
226225

227226
const CustomCompBase = new UICompBuilder(childrenMap, (props, dispatch) => {
228-
useMergeCompStyles(props as Record<string, any>, dispatch);
229-
230227
const { code, model } = props;
231228
return (
232229
<InnerCustomComponent

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import { RefControl } from "comps/controls/refControl";
4848
// import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
4949
import { DateRangeUIView } from "comps/comps/dateComp/dateRangeUIView";
5050
import { EditorContext } from "comps/editorState";
51-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
5251

5352
const EventOptions = [changeEvent, focusEvent, blurEvent] as const;
5453

@@ -163,9 +162,7 @@ export type DateCompViewProps = Pick<
163162
placeholder?: string | [string, string];
164163
};
165164

166-
export const datePickerControl = new UICompBuilder(childrenMap, (props, dispatch) => {
167-
useMergeCompStyles(props as Record<string, any>, dispatch);
168-
165+
export const datePickerControl = new UICompBuilder(childrenMap, (props) => {
169166
let time: dayjs.Dayjs | null = null;
170167
if (props.value.value !== '') {
171168
time = dayjs(props.value.value, DateParser);
@@ -294,9 +291,7 @@ export const dateRangeControl = (function () {
294291
...commonChildren,
295292
};
296293

297-
return new UICompBuilder(childrenMap, (props, dispatch) => {
298-
useMergeCompStyles(props as Record<string, any>, dispatch);
299-
294+
return new UICompBuilder(childrenMap, (props) => {
300295
let start: dayjs.Dayjs | null = null;
301296
if (props.start.value !== '') {
302297
start = dayjs(props.start.value, DateParser);

client/packages/lowcoder/src/comps/comps/dateComp/timeComp.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import { RefControl } from "comps/controls/refControl";
5252
import { TimePickerProps } from "antd/es/time-picker";
5353

5454
import { EditorContext } from "comps/editorState";
55-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
5655

5756
const EventOptions = [changeEvent, focusEvent, blurEvent] as const;
5857

@@ -143,9 +142,7 @@ export type TimeCompViewProps = Pick<
143142
placeholder?: string | [string, string];
144143
};
145144

146-
export const timePickerControl = new UICompBuilder(childrenMap, (props, dispatch) => {
147-
useMergeCompStyles(props as Record<string, any>, dispatch);
148-
145+
export const timePickerControl = new UICompBuilder(childrenMap, (props) => {
149146
let time: dayjs.Dayjs | null = null;
150147
if(props.value.value !== '') {
151148
time = dayjs(props.value.value, TimeParser);
@@ -263,9 +260,7 @@ export const timeRangeControl = (function () {
263260
...commonChildren,
264261
};
265262

266-
return new UICompBuilder(childrenMap, (props, dispatch) => {
267-
useMergeCompStyles(props as Record<string, any>, dispatch);
268-
263+
return new UICompBuilder(childrenMap, (props) => {
269264
let start: dayjs.Dayjs | null = null;
270265
if(props.start.value !== '') {
271266
start = dayjs(props.start.value, TimeParser);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { AutoHeightControl } from "comps/controls/autoHeightControl";
1717

1818
import { useContext } from "react";
1919
import { EditorContext } from "comps/editorState";
20-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2120

2221
type IProps = DividerProps & {
2322
$style: DividerStyleType;
@@ -110,8 +109,7 @@ function fixOldStyleData(oldData: any) {
110109

111110
// Compatible with historical style data 2022-8-26
112111
const DividerTempComp = migrateOldData(
113-
new UICompBuilder(childrenMap, (props , dispatch) => {
114-
useMergeCompStyles(props as Record<string, any>, dispatch);
112+
new UICompBuilder(childrenMap, (props) => {
115113
const dividerType = props.type ? 'vertical' : 'horizontal';
116114

117115
return (

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import { messageInstance } from "lowcoder-design/src/components/GlobalInstances"
4242

4343
import React, { useContext } from "react";
4444
import { EditorContext } from "comps/editorState";
45-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
4645

4746
const FileSizeControl = codeControl((value) => {
4847
if (typeof value === "number") {
@@ -381,7 +380,6 @@ const childrenMap = {
381380
};
382381

383382
let FileTmpComp = new UICompBuilder(childrenMap, (props, dispatch) => {
384-
useMergeCompStyles(props, dispatch);
385383
return(
386384
<Upload {...props} dispatch={dispatch} />
387385
)})

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { trans } from "i18n";
1313

1414
import { useContext } from "react";
1515
import { EditorContext } from "comps/editorState";
16-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
1716

1817
const getStyle = (style: FileViewerStyleType) => {
1918
return css`
@@ -71,9 +70,7 @@ let FileViewerBasicComp = (function () {
7170
style: styleControl(FileViewerStyle , 'style'),
7271
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
7372
};
74-
return new UICompBuilder(childrenMap, (props, dispatch) => {
75-
useMergeCompStyles(props as Record<string, any>, dispatch);
76-
73+
return new UICompBuilder(childrenMap, (props) => {
7774
if (isEmpty(props.src)) {
7875
return (
7976
<ErrorWrapper

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
} from "../controls/eventHandlerControl";
3131
import { useContext } from "react";
3232
import { EditorContext } from "comps/editorState";
33-
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
3433

3534
const Container = styled.div<{
3635
$style: IconStyleType | undefined;
@@ -113,9 +112,7 @@ const IconView = (props: RecordConstructorToView<typeof childrenMap>) => {
113112
};
114113

115114
let IconBasicComp = (function () {
116-
return new UICompBuilder(childrenMap, (props, dispatch) => {
117-
useMergeCompStyles(props as Record<string, any>, dispatch);
118-
115+
return new UICompBuilder(childrenMap, (props) => {
119116
return(<IconView {...props} />)})
120117
.setPropertyViewFn((children) => (
121118
<>

0 commit comments

Comments
 (0)