Skip to content

Commit 4e98bf6

Browse files
committed
animation style separated in autocomplete
1 parent bbd43cd commit 4e98bf6

File tree

5 files changed

+154
-113
lines changed

5 files changed

+154
-113
lines changed

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

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { trans } from "i18n/design";
2-
import React, { ReactNode, useContext } from "react";
3-
import styled from "styled-components";
4-
import { ReactComponent as Packup } from "icons/icon-Pack-up.svg";
5-
import { labelCss } from "./Label";
6-
import { controlItem, ControlNode } from "./control";
7-
8-
const SectionItem = styled.div<{ $width?: number }>`
1+
import {trans} from 'i18n/design';
2+
import React, {ReactNode, useContext} from 'react';
3+
import styled from 'styled-components';
4+
import {ReactComponent as Packup} from 'icons/icon-Pack-up.svg';
5+
import {labelCss} from './Label';
6+
import {controlItem, ControlNode} from './control';
7+
8+
const SectionItem = styled.div<{$width?: number}>`
99
width: ${(props) => (props.$width ? props.$width : 312)}px;
1010
border-bottom: 1px solid #e1e3eb;
1111
@@ -63,14 +63,14 @@ const SectionLabelDiv = styled.div`
6363
}
6464
`;
6565

66-
const ShowChildren = styled.div<{ $show?: string; $noMargin?: boolean }>`
67-
display: ${(props) => props.$show || "none"};
66+
const ShowChildren = styled.div<{$show?: string; $noMargin?: boolean}>`
67+
display: ${(props) => props.$show || 'none'};
6868
flex-direction: column;
6969
gap: 8px;
7070
transition: all 3s;
7171
margin-left: ${(props) => (props.$noMargin ? 0 : 16)}px;
7272
padding-bottom: 16px;
73-
padding-right: ${(props) => (props.$noMargin ? 0 : "16px")};
73+
padding-right: ${(props) => (props.$noMargin ? 0 : '16px')};
7474
`;
7575

7676
interface ISectionConfig<T> {
@@ -95,16 +95,22 @@ export interface PropertySectionContextType {
9595
state: PropertySectionState;
9696
}
9797

98-
export const PropertySectionContext = React.createContext<PropertySectionContextType>({
99-
toggle: () => {},
100-
compName: "",
101-
state: {},
102-
});
98+
export const PropertySectionContext =
99+
React.createContext<PropertySectionContextType>({
100+
toggle: () => {},
101+
compName: '',
102+
state: {},
103+
});
103104

104105
export const BaseSection = (props: ISectionConfig<ReactNode>) => {
105-
const { name } = props;
106-
const { compName, state, toggle } = useContext(PropertySectionContext);
107-
const open = props.open !== undefined ? props.open : name ? state[compName]?.[name] !== false : true;
106+
const {name} = props;
107+
const {compName, state, toggle} = useContext(PropertySectionContext);
108+
const open =
109+
props.open !== undefined
110+
? props.open
111+
: name
112+
? state[compName]?.[name] !== false
113+
: true;
108114

109115
// console.log("open", open, props.open);
110116

@@ -118,43 +124,47 @@ export const BaseSection = (props: ISectionConfig<ReactNode>) => {
118124
return (
119125
<SectionItem $width={props.width} style={props.style}>
120126
{props.name && (
121-
<SectionLabelDiv onClick={handleToggle} className={"section-header"}>
127+
<SectionLabelDiv onClick={handleToggle} className={'section-header'}>
122128
<SectionLabel>{props.name}</SectionLabel>
123-
<div style={{ display: "flex" }}>
129+
<div style={{display: 'flex'}}>
124130
{open && props.additionalButton}
125-
<PackupIcon deg={open ? "rotate(0deg)" : "rotate(180deg)"} />
131+
<PackupIcon deg={open ? 'rotate(0deg)' : 'rotate(180deg)'} />
126132
</div>
127133
</SectionLabelDiv>
128134
)}
129-
<ShowChildren $show={open ? "flex" : "none"} $noMargin={props.noMargin}>
135+
<ShowChildren $show={open ? 'flex' : 'none'} $noMargin={props.noMargin}>
130136
{props.children}
131137
</ShowChildren>
132138
</SectionItem>
133139
);
134140
};
135141

136142
export function Section(props: ISectionConfig<ControlNode>) {
137-
return controlItem({ filterText: props.name, searchChild: true }, <BaseSection {...props} />);
143+
return controlItem(
144+
{filterText: props.name, searchChild: true},
145+
<BaseSection {...props} />
146+
);
138147
}
139148

140149
// common section names
141150
export const sectionNames = {
142-
basic: trans("prop.basic"),
143-
interaction: trans("prop.interaction"),
144-
advanced: trans("prop.advanced"),
145-
validation: trans("prop.validation"),
146-
layout: trans("prop.layout"),
147-
style: trans("prop.style"),
148-
labelStyle:trans("prop.labelStyle"),
149-
data: trans("prop.data"),
150-
meetings: trans("prop.meetings"), // added by Falk Wolsky
151-
field: trans("prop.field"),
152-
inputFieldStyle:trans("prop.inputFieldStyle"),
153-
avatarStyle:trans("prop.avatarStyle"),
154-
captionStyle:trans("prop.captionStyle"),
155-
startButtonStyle:trans("prop.startButtonStyle"),
156-
resetButtonStyle:trans("prop.resetButtonStyle"),
157-
headerStyle:trans("prop.headerStyle"),
158-
bodyStyle:trans("prop.bodyStyle"),
159-
badgeStyle:trans("prop.badgeStyle"),
151+
basic: trans('prop.basic'),
152+
interaction: trans('prop.interaction'),
153+
advanced: trans('prop.advanced'),
154+
validation: trans('prop.validation'),
155+
layout: trans('prop.layout'),
156+
style: trans('prop.style'),
157+
labelStyle: trans('prop.labelStyle'),
158+
animationStyle: trans('prop.animationStyle'),
159+
data: trans('prop.data'),
160+
meetings: trans('prop.meetings'), // added by Falk Wolsky
161+
field: trans('prop.field'),
162+
inputFieldStyle: trans('prop.inputFieldStyle'),
163+
avatarStyle: trans('prop.avatarStyle'),
164+
captionStyle: trans('prop.captionStyle'),
165+
startButtonStyle: trans('prop.startButtonStyle'),
166+
resetButtonStyle: trans('prop.resetButtonStyle'),
167+
headerStyle: trans('prop.headerStyle'),
168+
bodyStyle: trans('prop.bodyStyle'),
169+
badgeStyle: trans('prop.badgeStyle'),
160170
};
Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
export const en = {
2-
addItem: "Add",
3-
duplicate: "Duplicate",
4-
rename: "Rename",
5-
delete: "Delete",
6-
edit: "Edit",
7-
ok: "OK",
8-
cancel: "Cancel",
9-
previousStep: "Previous",
10-
nextStep: "Next",
11-
finish: "Finish",
2+
addItem: 'Add',
3+
duplicate: 'Duplicate',
4+
rename: 'Rename',
5+
delete: 'Delete',
6+
edit: 'Edit',
7+
ok: 'OK',
8+
cancel: 'Cancel',
9+
previousStep: 'Previous',
10+
nextStep: 'Next',
11+
finish: 'Finish',
1212
country: {
13-
china: "China",
13+
china: 'China',
1414
},
1515
notification: {
16-
copySuccess: "Copy success",
17-
copyFail: "Copy failed",
16+
copySuccess: 'Copy success',
17+
copyFail: 'Copy failed',
1818
},
1919
prop: {
20-
basic: "Basic",
21-
resources: "Resources",
22-
interaction: "Interaction",
23-
advanced: "Advanced",
24-
validation: "Validation",
25-
layout: "Layout",
26-
labelStyle: "Label Style",
27-
style: "Style",
28-
meetings: "Meeting Settings",
29-
data: "Data",
20+
basic: 'Basic',
21+
resources: 'Resources',
22+
interaction: 'Interaction',
23+
advanced: 'Advanced',
24+
validation: 'Validation',
25+
layout: 'Layout',
26+
animationStyle: 'Animation Style',
27+
labelStyle: 'Label Style',
28+
style: 'Style',
29+
meetings: 'Meeting Settings',
30+
data: 'Data',
3031
field: 'Field',
3132
inputFieldStyle: 'Input Field Style',
3233
avatarStyle: 'Avatar Style',
@@ -38,39 +39,39 @@ export const en = {
3839
badgeStyle: 'Badge Style',
3940
},
4041
passwordInput: {
41-
label: "Password:",
42-
placeholder: "Please enter your password",
43-
inconsistentPassword: "Two passwords are inconsistent",
44-
confirmPasswordLabel: "Confirm password:",
45-
confirmPasswordPlaceholder: "Please enter your password again",
42+
label: 'Password:',
43+
placeholder: 'Please enter your password',
44+
inconsistentPassword: 'Two passwords are inconsistent',
45+
confirmPasswordLabel: 'Confirm password:',
46+
confirmPasswordPlaceholder: 'Please enter your password again',
4647
},
4748
verifyCodeInput: {
48-
label: "Verification code:",
49-
errorMsg: "Code should be {digitNum} digits",
50-
placeholder: "Please enter {digitNum} digits code",
51-
sendCode: "Send code",
49+
label: 'Verification code:',
50+
errorMsg: 'Code should be {digitNum} digits',
51+
placeholder: 'Please enter {digitNum} digits code',
52+
sendCode: 'Send code',
5253
},
5354
iconSelect: {
54-
title: "Select icon",
55-
searchPlaceholder: "Search icon",
55+
title: 'Select icon',
56+
searchPlaceholder: 'Search icon',
5657
},
5758
shapeSelect: {
58-
title: "Select shape",
59-
searchPlaceholder: "Search shape",
59+
title: 'Select shape',
60+
searchPlaceholder: 'Search shape',
6061
},
6162
eventHandler: {
62-
advanced: "Advanced",
63+
advanced: 'Advanced',
6364
},
6465
comp: {
65-
selectedCompsTitle: "{selectCompNum} components are selected",
66-
selectedCompsDetail: "Click component to view its properties",
67-
batchDelete: "Batch delete",
66+
selectedCompsTitle: '{selectCompNum} components are selected',
67+
selectedCompsDetail: 'Click component to view its properties',
68+
batchDelete: 'Batch delete',
6869
},
6970
optionsControl: {
7071
optionItemErrorMSg: `Found duplicate option value "{value}". Only the first item will be displayed. Please change to a unique value.`,
71-
emptyList: "No options",
72+
emptyList: 'No options',
7273
},
7374
container: {
74-
hintPlaceHolder: "Drag components from the right panel",
75+
hintPlaceHolder: 'Drag components from the right panel',
7576
},
7677
};

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Input, Section, sectionNames} from 'lowcoder-design';
33
import {BoolControl} from 'comps/controls/boolControl';
44
import {styleControl} from 'comps/controls/styleControl';
55
import {
6+
AnimationStyle,
67
InputFieldStyle,
78
InputLikeStyle,
89
InputLikeStyleType,
@@ -87,6 +88,7 @@ const childrenMap = {
8788
componentSize: dropdownControl(componentSize, 'small'),
8889
valueInItems: booleanExposingStateControl('valueInItems'),
8990
inputFieldStyle: styleControl(InputLikeStyle),
91+
animationStyle: styleControl(AnimationStyle),
9092
};
9193

9294
const getValidate = (value: any): '' | 'warning' | 'error' | undefined => {
@@ -280,6 +282,7 @@ let AutoCompleteCompBase = (function () {
280282
style: props.style,
281283
labelStyle: props.labelStyle,
282284
inputFieldStyle: props.inputFieldStyle,
285+
animationStyle: props.animationStyle,
283286
...validateState,
284287
});
285288
})
@@ -344,6 +347,9 @@ let AutoCompleteCompBase = (function () {
344347
<Section name={sectionNames.inputFieldStyle}>
345348
{children.inputFieldStyle.getPropertyView()}
346349
</Section>
350+
<Section name={sectionNames.animationStyle}>
351+
{children.animationStyle.getPropertyView()}
352+
</Section>
347353
</>
348354
);
349355
})

client/packages/lowcoder/src/comps/controls/labelControl.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {NumberControl, StringControl} from 'comps/controls/codeControl';
66
import {dropdownControl} from 'comps/controls/dropdownControl';
77
import {withDefault} from 'comps/generators';
88
import {MultiCompBuilder} from 'comps/generators/multi';
9-
import {labelCss, Section, Tooltip, UnderlineCss} from 'lowcoder-design';
9+
import {labelCss, Section, Tooltip} from 'lowcoder-design';
1010
import {ValueFromOption} from 'lowcoder-design';
1111
import {isEmpty} from 'lodash';
12-
import {Fragment, ReactNode} from 'react';
12+
import {ReactNode} from 'react';
1313
import styled, {css} from 'styled-components';
1414
import {AlignLeft} from 'lowcoder-design';
1515
import {AlignRight} from 'lowcoder-design';
@@ -31,6 +31,7 @@ type LabelViewProps = Pick<
3131
field?: Record<string, string>;
3232
inputFieldStyle?: Record<string, string>;
3333
childrenInputFieldStyle?: Record<string, string>;
34+
animationStyle?: Record<string, string>;
3435
};
3536

3637
const StyledStarIcon = styled(StarIcon)`
@@ -51,7 +52,11 @@ function getStyle(style: any) {
5152
`;
5253
}
5354

54-
const LabelViewWrapper = styled.div<{$style: any; inputFieldStyle: any}>`
55+
const LabelViewWrapper = styled.div<{
56+
$style: any;
57+
inputFieldStyle: any;
58+
$animationStyle: any;
59+
}>`
5560
${(props) => {
5661
return (
5762
props.$style && {
@@ -63,10 +68,19 @@ const LabelViewWrapper = styled.div<{$style: any; inputFieldStyle: any}>`
6368
);
6469
}}
6570
${(props) => props.inputFieldStyle && getStyle(props.inputFieldStyle)}
71+
${(props) => props.$animationStyle && props.$animationStyle}
6672
display: flex;
6773
flex-direction: column;
6874
height: 100%;
69-
border: ${(props)=>{return props.$style.borderWidth}} ${(props)=>{return props.$style.borderStyle}} ${(props)=>{return props.$style.border}} !important;
75+
border: ${(props) => {
76+
return props.$style.borderWidth;
77+
}}
78+
${(props) => {
79+
return props.$style.borderStyle;
80+
}}
81+
${(props) => {
82+
return props.$style.border;
83+
}} !important;
7084
`;
7185

7286
const MainWrapper = styled.div<{
@@ -199,6 +213,7 @@ export const LabelControl = (function () {
199213
<LabelViewWrapper
200214
$style={args.style}
201215
inputFieldStyle={args.inputFieldStyle}
216+
$animationStyle={args.animationStyle}
202217
>
203218
<MainWrapper
204219
$position={props.position}

0 commit comments

Comments
 (0)