-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapting KeyValueListControl for better imports
- Loading branch information
FalkWolsky
committed
Jan 31, 2025
1 parent
8071763
commit 84e1903
Showing
13 changed files
with
75 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
client/packages/lowcoder/src/comps/controls/keyValueListControl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ControlPropertyViewWrapper, KeyValueList, OptionsType } from "lowcoder-design"; | ||
import { ReactNode } from "react"; | ||
import styled from "styled-components"; | ||
import { list } from "../generators/list"; | ||
import { ControlParams } from "./controlParams"; | ||
import { ParamsControlType, ParamsStringControl } from "./paramsControl"; | ||
import { FunctionProperty } from "../queries/queryCompUtils"; | ||
import { keyValueControl, KeyValueControlParams } from "./keyValueControl" | ||
|
||
/** | ||
* Provides a list of kv input boxes with add and delete buttons | ||
* output [{key: "", value: ""}, {key: "", value: ""}] | ||
*/ | ||
export function keyValueListControl<T extends OptionsType>( | ||
hasType: boolean = false, | ||
types: T | OptionsType = [], | ||
controlType: "params" | "string" = "params" | ||
) { | ||
return class extends list(keyValueControl(hasType, types, controlType)) { | ||
getQueryParams() { | ||
if (controlType === "params") { | ||
return this.getView().reduce( | ||
(result: FunctionProperty[], kv) => [ | ||
...result, | ||
...(kv.children.key as InstanceType<ParamsControlType>).getQueryParams(), | ||
...(kv.children.value as InstanceType<ParamsControlType>).getQueryParams(), | ||
], | ||
[] | ||
); | ||
} | ||
return []; | ||
} | ||
|
||
propertyView(params: KeyValueControlParams): ReactNode { | ||
return ( | ||
<ControlPropertyViewWrapper {...params}> | ||
<KeyValueList | ||
list={this.getView().map((child) => child.propertyView(params))} | ||
onAdd={() => this.dispatch(this.pushAction({}))} | ||
onDelete={(item, index) => this.dispatch(this.deleteAction(index))} | ||
isStatic={params.isStatic} | ||
indicatorForAll={params.indicatorForAll} | ||
/> | ||
</ControlPropertyViewWrapper> | ||
); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
client/packages/lowcoder/src/comps/queries/queryComp/variablesComp.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters