Skip to content

Commit 47c1723

Browse files
refactor: antd component changes
1 parent 5baddfe commit 47c1723

34 files changed

+197
-127
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function Dropdown<T extends OptionsType>(props: DropdownProps<T>) {
170170
<CustomSelect
171171
open={props.open}
172172
listHeight={props.lineHeight}
173-
dropdownClassName="ob-dropdown-control-select"
173+
popupClassName="ob-dropdown-control-select"
174174
showSearch={props.showSearch}
175175
filterOption={(input, option) => {
176176
if (props.optionFilterProp) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function TriggeredDialog(props: {
3838
</div>
3939
)}
4040
<CustomModal
41-
visible={visible}
41+
open={visible}
4242
title={modalTitle}
4343
destroyOnClose
4444
onCancel={() => setVisible(false)}

client/packages/lowcoder-design/src/components/colorSelect/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RgbaStringColorPicker } from "react-colorful";
22
import { Popover } from "antd";
3+
import { ActionType } from '@rc-component/trigger/lib/interface';
34
import {
45
alphaOfRgba,
56
toRGBA,
@@ -14,7 +15,7 @@ import { changeValueAction } from "lowcoder-core";
1415

1516
interface ColorSelectProps {
1617
color: string;
17-
trigger?: string;
18+
trigger?: ActionType;
1819
dispatch?: (value: any) => void;
1920
changeColor?: (value: any) => void;
2021
}
@@ -35,7 +36,7 @@ export const ColorSelect = (props: ColorSelectProps) => {
3536
<Popover
3637
trigger={trigger}
3738
destroyTooltipOnHide={true}
38-
onVisibleChange={(value) => {
39+
onOpenChange={(value) => {
3940
pickerColor.current = toRGBA(color);
4041
setVisible(value);
4142
}}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ function CustomSelect(props: CustomSelectProps & AntdSelectProps) {
8383
innerRef,
8484
className,
8585
border,
86-
dropdownClassName = "custom-ant-select-dropdown",
86+
popupClassName = "custom-ant-select-dropdown",
8787
...restProps
8888
} = props;
8989
return (
9090
<SelectWrapper className={className} ref={innerRef} border={border}>
9191
<AntdSelect
92-
dropdownClassName={dropdownClassName}
93-
dropdownMatchSelectWidth={false}
92+
popupClassName={popupClassName}
93+
popupMatchSelectWidth={false}
9494
suffixIcon={<PackUpIcon />}
9595
{...restProps}
9696
>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ const FormSelect = (props: any) => {
335335
onChange(x);
336336
props.afterChange && props.afterChange(x);
337337
}}
338-
dropdownMatchSelectWidth={false}
338+
popupMatchSelectWidth={false}
339339
placeholder={props.placeholder}
340340
dropdownRender={props.dropdownRender}
341341
>

client/packages/lowcoder-design/src/components/iconSelect/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import type { IconDefinition } from "@fortawesome/free-regular-svg-icons";
33
import { Popover } from "antd";
4+
import { ActionType } from '@rc-component/trigger/lib/interface';
45
import { TacoInput } from "components/tacoInput";
56
import { Tooltip } from "components/toolTip";
67
import { trans } from "i18n/design";
@@ -274,7 +275,7 @@ export const IconSelectBase = (props: {
274275
children?: ReactNode;
275276
visible?: boolean;
276277
setVisible?: (v: boolean) => void;
277-
trigger?: string;
278+
trigger?: ActionType;
278279
leftOffset?: number;
279280
parent?: HTMLElement | null;
280281
searchKeywords?: Record<string, string>;
@@ -285,8 +286,8 @@ export const IconSelectBase = (props: {
285286
trigger={props.trigger}
286287
placement="left"
287288
align={{ offset: [props.leftOffset ?? 0, 0, 0, 0] }}
288-
visible={props.visible}
289-
onVisibleChange={setVisible}
289+
open={props.visible}
290+
onOpenChange={setVisible}
290291
getPopupContainer={parent ? () => parent : undefined}
291292
// hide the original background when dragging the popover is allowed
292293
overlayInnerStyle={{ border: "none", boxShadow: "none", background: "transparent" }}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const SimplePopover = (props: {
6868
destroyTooltipOnHide
6969
content={contentWithBox}
7070
trigger="click"
71-
visible={visible}
72-
onVisibleChange={setVisible}
71+
open={visible}
72+
onOpenChange={setVisible}
7373
placement="left"
7474
overlayStyle={{ width: "310px" }}
7575
>
@@ -100,8 +100,8 @@ const CustomPopover = (props: {
100100
<Popover
101101
content={contentWithBox}
102102
trigger="click"
103-
visible={visible}
104-
onVisibleChange={setVisible}
103+
open={visible}
104+
onOpenChange={setVisible}
105105
placement={props.type === "query" ? "top" : "left"}
106106
overlayStyle={{ width: "310px" }}
107107
align={{
@@ -225,8 +225,8 @@ const EditPopover = (props: EditPopoverProps) => {
225225
</>
226226
)}
227227
trigger="click"
228-
visible={visible}
229-
onVisibleChange={setVisible}
228+
open={visible}
229+
onOpenChange={setVisible}
230230
placement="bottomRight"
231231
// overlayStyle={{ width: "88px" }}
232232
align={{

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ function ToolTipLabel(
182182
color="#2c2c2c"
183183
title={title && <TooltipTitleWrapper>{title}</TooltipTitleWrapper>}
184184
overlayInnerStyle={{ maxWidth: "232px", whiteSpace: "break-spaces" }}
185-
arrowPointAtCenter={true}
185+
arrow={{
186+
pointAtCenter: true
187+
}}
186188
placement="top"
187-
defaultVisible={false}
189+
defaultOpen={false}
188190
trigger="hover"
189191
popupVisible={!!title}
190192
style={tooltipStyle}

client/packages/lowcoder/src/components/PermissionDialog/PermissionDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const PermissionDialog = (props: {
6464

6565
return (
6666
<StepModal
67-
visible={visible}
67+
open={visible}
6868
destroyOnClose
6969
onCancel={() => {
7070
setActiveStepKey("view");

client/packages/lowcoder/src/components/ResCreatePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export function ResCreatePanel(props: ResCreateModalProps) {
341341
</ScrollBar>
342342
</Content>
343343
<CreateDataSourceModal
344-
visible={visible}
344+
open={visible}
345345
onCancel={() => setVisible(false)}
346346
onCreated={() => setVisible(false)}
347347
/>

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AjvError, ErrorListProps, UISchemaSubmitButtonOptions, withTheme } from "@rjsf/core";
1+
import { withTheme } from '@rjsf/core';
2+
import { RJSFValidationError, ErrorListProps, UISchemaSubmitButtonOptions } from "@rjsf/utils";
3+
import validator from "@rjsf/validator-ajv8";
4+
// import Ajv from "@rjsf/validator-ajv8";
25
import { Button } from "antd";
36
import { BoolControl } from "comps/controls/boolControl";
47
import { jsonObjectExposingStateControl } from "comps/controls/codeStateControl";
@@ -107,7 +110,7 @@ function convertData(schema?: JSONSchema7, data?: any) {
107110
// refer to ajv-i18n, https://github.com/ajv-validator/ajv-i18n/blob/master/messages/index.js
108111
// https://github.com/ajv-validator/ajv/tree/6a671057ea6aae690b5967ee26a0ddf8452c6297#Validation-keywords
109112
// JSON schema refer to https://json-schema.org/understanding-json-schema/reference/
110-
function getErrorMessage(error: AjvError): string {
113+
function getErrorMessage(error: RJSFValidationError): string {
111114
switch (error.name) {
112115
case "required":
113116
return trans("jsonSchemaForm.required");
@@ -133,7 +136,7 @@ function getErrorMessage(error: AjvError): string {
133136
return "";
134137
}
135138

136-
function transformErrors(errors: AjvError[]): AjvError[] {
139+
function transformErrors(errors: RJSFValidationError[]): RJSFValidationError[] {
137140
return errors.map((error) => {
138141
const message = getErrorMessage(error);
139142
if (message) {
@@ -194,13 +197,14 @@ let FormBasicComp = (function () {
194197
<Container $style={props.style}>
195198
<ErrorBoundary>
196199
<Form
200+
validator={validator}
197201
schema={props.schema}
198202
uiSchema={props.uiSchema}
199203
formData={convertData(props.schema, props.data.value)}
200204
onSubmit={() => onSubmit(props)}
201205
onChange={(e) => props.data.onChange(e.formData)}
202206
transformErrors={(errors) => transformErrors(errors)}
203-
ErrorList={ErrorList}
207+
// ErrorList={ErrorList}
204208
children={
205209
<Button
206210
hidden={buttonOptions?.norender}

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,24 @@ enum TabKey {
243243
function PreloadConfigModal(props: ChildrenInstance) {
244244
const [activeKey, setActiveKey] = useState(TabKey.JavaScript);
245245
const { showScriptsAndStyleModal, changeExternalState } = useContext(ExternalEditorContext);
246+
247+
const tabItems = [
248+
{
249+
key: TabKey.JavaScript,
250+
label: 'JavaScript',
251+
children: <JavaScriptTabPane comp={props.script} />
252+
},
253+
{
254+
key: TabKey.CSS,
255+
label: 'CSS',
256+
children: <CSSTabPane comp={props.css} />
257+
},
258+
]
246259
return (
247260
<CustomModal
248261
draggable
249262
mask={activeKey !== TabKey.CSS}
250-
visible={showScriptsAndStyleModal}
263+
open={showScriptsAndStyleModal}
251264
title={trans("preLoad.scriptsAndStyles")}
252265
destroyOnClose
253266
onCancel={() => changeExternalState?.({ showScriptsAndStyleModal: false })}
@@ -259,13 +272,8 @@ function PreloadConfigModal(props: ChildrenInstance) {
259272
onChange={(k) => setActiveKey(k as TabKey)}
260273
style={{ marginBottom: 8, marginTop: 4 }}
261274
activeKey={activeKey}
275+
items={ tabItems }
262276
>
263-
<Tabs.TabPane key={TabKey.JavaScript} tab="JavaScript">
264-
<JavaScriptTabPane comp={props.script} />
265-
</Tabs.TabPane>
266-
<Tabs.TabPane key={TabKey.CSS} tab="CSS">
267-
<CSSTabPane comp={props.css} />
268-
</Tabs.TabPane>
269277
</Tabs>
270278
</CustomModal>
271279
);

client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeComps/columnTagsComp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Tag } from "antd";
2-
import { PresetColorTypes } from "antd/lib/_util/colors";
2+
import { PresetStatusColorTypes } from "antd/lib/_util/colors";
33
import { TagsContext } from "components/table/EditableCell";
44
import {
55
ColumnTypeCompBuilder,
@@ -16,7 +16,7 @@ import { hashToNum } from "util/stringUtils";
1616
import { CustomSelect, PackUpIcon } from "lowcoder-design";
1717
import { ScrollBar } from "lowcoder-design";
1818

19-
const colors = PresetColorTypes;
19+
const colors = PresetStatusColorTypes;
2020

2121
const isStringArray = (value: any) => {
2222
return (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ function ToolbarPopover(props: {
655655
const popOverRef = useRef<HTMLDivElement>(null);
656656
return (
657657
<Popover
658-
visible={visible}
658+
open={visible}
659659
overlayStyle={{ pointerEvents: "auto" }}
660660
content={
661661
<div

client/packages/lowcoder/src/comps/comps/tabs/tabbedContainerComp.tsx

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { message, Tabs } from "antd";
1+
import { Tabs } from "antd";
22
import { JSONObject, JSONValue } from "util/jsonTypes";
33
import { CompAction, CompActionTypes, deleteCompAction, wrapChildAction } from "lowcoder-core";
44
import { DispatchType, RecordConstructorToView, wrapDispatch } from "lowcoder-core";
@@ -32,8 +32,7 @@ import { BoolCodeControl } from "comps/controls/codeControl";
3232
import { DisabledContext } from "comps/generators/uiCompBuilder";
3333
import { EditorContext } from "comps/editorState";
3434
import { checkIsMobile } from "util/commonUtils";
35-
36-
const { TabPane } = Tabs;
35+
import { messageInstance } from "lowcoder-design";
3736

3837
const EVENT_OPTIONS = [
3938
{
@@ -163,6 +162,56 @@ const TabbedContainer = (props: TabbedContainerProps) => {
163162

164163
// log.debug("TabbedContainer. props: ", props);
165164

165+
const tabItems = visibleTabs.map((tab) => {
166+
// log.debug("Tab. tab: ", tab, " containers: ", containers);
167+
const id = String(tab.id);
168+
const childDispatch = wrapDispatch(wrapDispatch(dispatch, "containers"), id);
169+
const containerProps = containers[id].children;
170+
const hasIcon = tab.icon.props.value;
171+
const label = (
172+
<>
173+
{tab.iconPosition === "left" && hasIcon && (
174+
<span style={{ marginRight: "4px" }}>{tab.icon}</span>
175+
)}
176+
{tab.label}
177+
{tab.iconPosition === "right" && hasIcon && (
178+
<span style={{ marginLeft: "4px" }}>{tab.icon}</span>
179+
)}
180+
</>
181+
);
182+
return {
183+
label,
184+
key: tab.key,
185+
forceRender: true,
186+
children: (
187+
<BackgroundColorContext.Provider value={props.style.background}>
188+
<ContainerInTab
189+
layout={containerProps.layout.getView()}
190+
items={gridItemCompToGridItems(containerProps.items.getView())}
191+
positionParams={containerProps.positionParams.getView()}
192+
dispatch={childDispatch}
193+
autoHeight={props.autoHeight}
194+
containerPadding={[paddingWidth, 20]}
195+
/>
196+
</BackgroundColorContext.Provider>
197+
)
198+
}
199+
// return (
200+
// <TabPane tab={label} key={tab.key} forceRender>
201+
// <BackgroundColorContext.Provider value={props.style.background}>
202+
// <ContainerInTab
203+
// layout={containerProps.layout.getView()}
204+
// items={gridItemCompToGridItems(containerProps.items.getView())}
205+
// positionParams={containerProps.positionParams.getView()}
206+
// dispatch={childDispatch}
207+
// autoHeight={props.autoHeight}
208+
// containerPadding={[paddingWidth, 20]}
209+
// />
210+
// </BackgroundColorContext.Provider>
211+
// </TabPane>
212+
// );
213+
})
214+
166215
return (
167216
<div style={{padding: props.style.margin}}>
168217
<StyledTabs
@@ -178,39 +227,8 @@ const TabbedContainer = (props: TabbedContainerProps) => {
178227
animated
179228
$isMobile={isMobile}
180229
// tabBarGutter={32}
230+
items={tabItems}
181231
>
182-
{visibleTabs.map((tab) => {
183-
// log.debug("Tab. tab: ", tab, " containers: ", containers);
184-
const id = String(tab.id);
185-
const childDispatch = wrapDispatch(wrapDispatch(dispatch, "containers"), id);
186-
const containerProps = containers[id].children;
187-
const hasIcon = tab.icon.props.value;
188-
const label = (
189-
<>
190-
{tab.iconPosition === "left" && hasIcon && (
191-
<span style={{ marginRight: "4px" }}>{tab.icon}</span>
192-
)}
193-
{tab.label}
194-
{tab.iconPosition === "right" && hasIcon && (
195-
<span style={{ marginLeft: "4px" }}>{tab.icon}</span>
196-
)}
197-
</>
198-
);
199-
return (
200-
<TabPane tab={label} key={tab.key} forceRender>
201-
<BackgroundColorContext.Provider value={props.style.background}>
202-
<ContainerInTab
203-
layout={containerProps.layout.getView()}
204-
items={gridItemCompToGridItems(containerProps.items.getView())}
205-
positionParams={containerProps.positionParams.getView()}
206-
dispatch={childDispatch}
207-
autoHeight={props.autoHeight}
208-
containerPadding={[paddingWidth, 20]}
209-
/>
210-
</BackgroundColorContext.Provider>
211-
</TabPane>
212-
);
213-
})}
214232
</StyledTabs>
215233
</div>
216234
);
@@ -293,7 +311,7 @@ class TabbedContainerImplComp extends TabbedContainerBaseComp implements IContai
293311
} as CompAction;
294312
}
295313
if (value.type === "delete" && this.children.tabs.getView().length <= 1) {
296-
message.warn(trans("tabbedContainer.atLeastOneTabError"));
314+
messageInstance.warning(trans("tabbedContainer.atLeastOneTabError"));
297315
// at least one tab
298316
return this;
299317
}

0 commit comments

Comments
 (0)