+
{(name === "radius" ||
- name === "gap" ||
- name === "cardRadius")
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "borderWidth"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "margin"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : (name === "padding" ||
- name === "containerheaderpadding" ||
- name === "containerfooterpadding" ||
- name === "containerbodypadding")
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "textSize"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "textWeight"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "fontFamily"
- ? (
- children[name] as InstanceType
- ).propertyView({
+ name === "gap" ||
+ name === "cardRadius")
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "borderWidth"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "backgroundImage" || name === "headerBackgroundImage" || name === "footerBackgroundImage"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "backgroundImageRepeat" || name === "headerBackgroundImageRepeat" || name === "footerBackgroundImageRepeat"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "backgroundImageSize" || name === "headerBackgroundImageSize" || name === "footerBackgroundImageSize"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
+ preInputNode: ,
+ placeholder: props[name],
})
- : name === "backgroundImagePosition" || name === "headerBackgroundImagePosition" || name === "footerBackgroundImagePosition"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : name === "backgroundImageOrigin" || name === "headerBackgroundImageOrigin" || name === "footerBackgroundImageOrigin"
- ? (
- children[name] as InstanceType
- ).propertyView({
- label: config.label,
- preInputNode: ,
- placeholder: props[name],
- })
- : children[name].propertyView({
- label: config.label,
- panelDefaultColor: props[name],
- // isDep: isDepColorConfig(config),
- isDep: true,
- depMsg: depMsg,
- })}
+ : name === "margin"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : (name === "padding" ||
+ name === "containerheaderpadding" ||
+ name === "containerfooterpadding" ||
+ name === "containerbodypadding")
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "textSize"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "textWeight"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "fontFamily"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "fontStyle"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "backgroundImage" || name === "headerBackgroundImage" || name === "footerBackgroundImage"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "backgroundImageRepeat" || name === "headerBackgroundImageRepeat" || name === "footerBackgroundImageRepeat"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "backgroundImageSize" || name === "headerBackgroundImageSize" || name === "footerBackgroundImageSize"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "backgroundImagePosition" || name === "headerBackgroundImagePosition" || name === "footerBackgroundImagePosition"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : name === "backgroundImageOrigin" || name === "headerBackgroundImageOrigin" || name === "footerBackgroundImageOrigin"
+ ? (
+ children[name] as InstanceType
+ ).propertyView({
+ label: config.label,
+ preInputNode: ,
+ placeholder: props[name],
+ })
+ : children[name].propertyView({
+ label: config.label,
+ panelDefaultColor: props[name],
+ // isDep: isDepColorConfig(config),
+ isDep: true,
+ depMsg: depMsg,
+ })}
);
})}
diff --git a/client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx b/client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx
index 5dea81d30..3df7ba687 100644
--- a/client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx
+++ b/client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx
@@ -1,7 +1,7 @@
import { ThemeDetail } from "api/commonSettingApi";
import { darkenColor, isDarkColor, lightenColor, toHex } from "lowcoder-design";
import { trans } from "i18n";
-import { StyleConfigType } from "./styleControl";
+import { StyleConfigType } from "./styleControl";
type SupportPlatform = "pc" | "mobile";
@@ -23,21 +23,21 @@ export type BorderWidthConfig = CommonColorConfig & {
export type BackgroundImageConfig = CommonColorConfig & { readonly backgroundImage: string; };
export type BackgroundImageRepeatConfig = CommonColorConfig & { readonly backgroundImageRepeat: string; };
-export type BackgroundImageSizeConfig = CommonColorConfig & { readonly backgroundImageSize: string;};
+export type BackgroundImageSizeConfig = CommonColorConfig & { readonly backgroundImageSize: string; };
export type BackgroundImagePositionConfig = CommonColorConfig & { readonly backgroundImagePosition: string; };
-export type BackgroundImageOriginConfig = CommonColorConfig & { readonly backgroundImageOrigin: string;};
+export type BackgroundImageOriginConfig = CommonColorConfig & { readonly backgroundImageOrigin: string; };
export type HeaderBackgroundImageConfig = CommonColorConfig & { readonly headerBackgroundImage: string; };
export type HeaderBackgroundImageRepeatConfig = CommonColorConfig & { readonly headerBackgroundImageRepeat: string; };
-export type HeaderBackgroundImageSizeConfig = CommonColorConfig & { readonly headerBackgroundImageSize: string;};
+export type HeaderBackgroundImageSizeConfig = CommonColorConfig & { readonly headerBackgroundImageSize: string; };
export type HeaderBackgroundImagePositionConfig = CommonColorConfig & { readonly headerBackgroundImagePosition: string; };
-export type HeaderBackgroundImageOriginConfig = CommonColorConfig & { readonly headerBackgroundImageOrigin: string;};
+export type HeaderBackgroundImageOriginConfig = CommonColorConfig & { readonly headerBackgroundImageOrigin: string; };
export type FooterBackgroundImageConfig = CommonColorConfig & { readonly footerBackgroundImage: string; };
export type FooterBackgroundImageRepeatConfig = CommonColorConfig & { readonly footerBackgroundImageRepeat: string; };
-export type FooterBackgroundImageSizeConfig = CommonColorConfig & { readonly footerBackgroundImageSize: string;};
+export type FooterBackgroundImageSizeConfig = CommonColorConfig & { readonly footerBackgroundImageSize: string; };
export type FooterBackgroundImagePositionConfig = CommonColorConfig & { readonly footerBackgroundImagePosition: string; };
-export type FooterBackgroundImageOriginConfig = CommonColorConfig & { readonly footerBackgroundImageOrigin: string;};
+export type FooterBackgroundImageOriginConfig = CommonColorConfig & { readonly footerBackgroundImageOrigin: string; };
export type TextSizeConfig = CommonColorConfig & {
readonly textSize: string;
@@ -51,6 +51,10 @@ export type FontFamilyConfig = CommonColorConfig & {
readonly fontFamily: string;
};
+export type FontStyleConfig = CommonColorConfig & {
+ readonly fontStyle: string;
+}
+
export type ContainerHeaderPaddigConfig = CommonColorConfig & {
readonly containerheaderpadding: string;
};
@@ -63,11 +67,11 @@ export type ContainerFooterPaddigConfig = CommonColorConfig & {
readonly containerfooterpadding: string;
};
-export type MarginConfig = CommonColorConfig & {
- readonly margin: string;
-};
-export type PaddingConfig = CommonColorConfig & {
- readonly padding: string;
+export type MarginConfig = CommonColorConfig & {
+ readonly margin: string;
+};
+export type PaddingConfig = CommonColorConfig & {
+ readonly padding: string;
};
export type DepColorConfig = CommonColorConfig & {
@@ -76,7 +80,7 @@ export type DepColorConfig = CommonColorConfig & {
readonly depType?: DEP_TYPE;
transformer: (color: string, ...rest: string[]) => string;
};
-export type SingleColorConfig = SimpleColorConfig | DepColorConfig | RadiusConfig | BorderWidthConfig | BackgroundImageConfig | BackgroundImageRepeatConfig | BackgroundImageSizeConfig | BackgroundImagePositionConfig | BackgroundImageOriginConfig | TextSizeConfig | TextWeightConfig | FontFamilyConfig | MarginConfig | PaddingConfig | ContainerHeaderPaddigConfig | ContainerFooterPaddigConfig | ContainerBodyPaddigConfig | HeaderBackgroundImageConfig | HeaderBackgroundImageRepeatConfig | HeaderBackgroundImageSizeConfig | HeaderBackgroundImagePositionConfig | HeaderBackgroundImageOriginConfig | FooterBackgroundImageConfig | FooterBackgroundImageRepeatConfig | FooterBackgroundImageSizeConfig | FooterBackgroundImagePositionConfig | FooterBackgroundImageOriginConfig;
+export type SingleColorConfig = SimpleColorConfig | DepColorConfig | RadiusConfig | BorderWidthConfig | BackgroundImageConfig | BackgroundImageRepeatConfig | BackgroundImageSizeConfig | BackgroundImagePositionConfig | BackgroundImageOriginConfig | TextSizeConfig | TextWeightConfig | FontFamilyConfig | FontStyleConfig | MarginConfig | PaddingConfig | ContainerHeaderPaddigConfig | ContainerFooterPaddigConfig | ContainerBodyPaddigConfig | HeaderBackgroundImageConfig | HeaderBackgroundImageRepeatConfig | HeaderBackgroundImageSizeConfig | HeaderBackgroundImagePositionConfig | HeaderBackgroundImageOriginConfig | FooterBackgroundImageConfig | FooterBackgroundImageRepeatConfig | FooterBackgroundImageSizeConfig | FooterBackgroundImagePositionConfig | FooterBackgroundImageOriginConfig;
export const defaultTheme: ThemeDetail = {
primary: "#3377FF",
@@ -85,7 +89,7 @@ export const defaultTheme: ThemeDetail = {
canvas: "#F5F5F6",
primarySurface: "#FFFFFF",
borderRadius: "4px",
- margin: "3px",
+ margin: "3px",
padding: "3px",
gridColumns: "24",
textSize: "14px",
@@ -322,61 +326,67 @@ const BACKGROUND_IMAGE_ORIGIN = {
backgroundImageOrigin: "backgroundImageOrigin",
} as const;
-const MARGIN = {
- name: "margin",
- label: trans("style.margin"),
- margin: "margin",
-} as const;
+const MARGIN = {
+ name: "margin",
+ label: trans("style.margin"),
+ margin: "margin",
+} as const;
-const PADDING = {
- name: "padding",
- label: trans("style.padding"),
- padding: "padding",
+const PADDING = {
+ name: "padding",
+ label: trans("style.padding"),
+ padding: "padding",
} as const;
-const TEXT_SIZE = {
+const TEXT_SIZE = {
name: "textSize",
- label: trans("style.textSize"),
- textSize: "textSize",
+ label: trans("style.textSize"),
+ textSize: "textSize",
} as const;
-const TEXT_WEIGHT = {
+const TEXT_WEIGHT = {
name: "textWeight",
- label: trans("style.textWeight"),
- textWeight: "textWeight",
+ label: trans("style.textWeight"),
+ textWeight: "textWeight",
} as const;
-const FONT_FAMILY = {
+const FONT_FAMILY = {
name: "fontFamily",
- label: trans("style.fontFamily"),
- fontFamily: "fontFamily",
+ label: trans("style.fontFamily"),
+ fontFamily: "fontFamily",
} as const;
-const CONTAINERHEADERPADDING = {
- name: "containerheaderpadding",
- label: trans("style.containerheaderpadding"),
- containerheaderpadding: "padding",
+const FONT_STYLE = {
+ name: "fontStyle",
+ label: trans("style.fontStyle"),
+ fontStyle: "fontStyle",
+} as const
+
+const CONTAINERHEADERPADDING = {
+ name: "containerheaderpadding",
+ label: trans("style.containerheaderpadding"),
+ containerheaderpadding: "padding",
} as const;
-const CONTAINERFOOTERPADDING = {
- name: "containerfooterpadding",
- label: trans("style.containerfooterpadding"),
- containerfooterpadding: "padding",
+const CONTAINERFOOTERPADDING = {
+ name: "containerfooterpadding",
+ label: trans("style.containerfooterpadding"),
+ containerfooterpadding: "padding",
} as const;
-const CONTAINERBODYPADDING = {
- name: "containerbodypadding",
- label: trans("style.containerbodypadding"),
- containerbodypadding: "padding",
+const CONTAINERBODYPADDING = {
+ name: "containerbodypadding",
+ label: trans("style.containerbodypadding"),
+ containerbodypadding: "padding",
} as const;
const getStaticBorder = (color: string = SECOND_SURFACE_COLOR) =>
- ({
- name: "border",
- label: trans("style.border"),
- color,
- } as const);
+({
+ name: "border",
+ label: trans("style.border"),
+ color,
+} as const);
const HEADER_BACKGROUND = {
name: "headerBackground",
@@ -439,13 +449,13 @@ function getStaticBackground(color: string) {
}
export const ButtonStyle = [
- ...getBgBorderRadiusByBg("primary"),
+ ...getBgBorderRadiusByBg("primary"),
BORDER_WIDTH,
- TEXT,
+ TEXT,
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
- MARGIN,
+ MARGIN,
PADDING
] as const;
@@ -464,7 +474,7 @@ export const ToggleButtonStyle = [
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -480,8 +490,9 @@ export const TextStyle = [
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
+ FONT_STYLE,
BORDER,
- MARGIN,
+ MARGIN,
PADDING,
{
name: "links",
@@ -491,16 +502,16 @@ export const TextStyle = [
transformer: toSelf,
},
RADIUS,
- BORDER_WIDTH
+ BORDER_WIDTH,
] as const;
-export const MarginStyle = [
- {
- name: "margin",
- label: trans("style.margin"),
- margin: "margin",
- },
-];
+export const MarginStyle = [
+ {
+ name: "margin",
+ label: trans("style.margin"),
+ margin: "margin",
+ },
+];
export const ContainerStyle = [
@@ -508,7 +519,7 @@ export const ContainerStyle = [
getStaticBorder(),
RADIUS,
BORDER_WIDTH,
- MARGIN,
+ MARGIN,
PADDING,
{
name: "background",
@@ -567,7 +578,7 @@ export const ContainerHeaderStyle = [
label: trans("style.backgroundImagePosition"),
headerBackgroundImagePosition: "headerBackgroundImagePosition",
}
- ,{
+ , {
name: "headerBackgroundImageOrigin",
label: trans("style.backgroundImageOrigin"),
headerBackgroundImageOrigin: "headerBackgroundImageOrigin",
@@ -639,7 +650,7 @@ export const ContainerFooterStyle = [
label: trans("style.backgroundImagePosition"),
footerBackgroundImagePosition: "footerBackgroundImagePosition",
}
- ,{
+ , {
name: "footerBackgroundImageOrigin",
label: trans("style.backgroundImageOrigin"),
footerBackgroundImageOrigin: "footerBackgroundImageOrigin",
@@ -662,7 +673,7 @@ export const SliderStyle = [
color: SURFACE_COLOR,
},
TRACK,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -674,7 +685,7 @@ export const InputLikeStyle = [
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
- MARGIN,
+ MARGIN,
PADDING,
...ACCENT_VALIDATE,
] as const;
@@ -691,7 +702,7 @@ export const RatingStyle = [
label: trans("style.unchecked"),
color: SECOND_SURFACE_COLOR,
},
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -715,7 +726,7 @@ export const SwitchStyle = [
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -723,7 +734,7 @@ export const SelectStyle = [
LABEL,
...getStaticBgBorderRadiusByBg(SURFACE_COLOR, "pc"),
TEXT,
- MARGIN,
+ MARGIN,
PADDING,
...ACCENT_VALIDATE,
] as const;
@@ -732,7 +743,7 @@ const multiSelectCommon = [
LABEL,
...getStaticBgBorderRadiusByBg(SURFACE_COLOR, "pc"),
TEXT,
- MARGIN,
+ MARGIN,
PADDING,
{
name: "tags",
@@ -784,7 +795,7 @@ export const TabContainerStyle = [
export const ModalStyle = [
...getBgBorderRadiusByBg(),
BORDER_WIDTH,
- MARGIN,
+ MARGIN,
PADDING,
BACKGROUND_IMAGE,
BACKGROUND_IMAGE_REPEAT,
@@ -798,7 +809,7 @@ export const CascaderStyle = [
...getStaticBgBorderRadiusByBg(SURFACE_COLOR, "pc"),
TEXT,
ACCENT,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -838,7 +849,7 @@ export const CheckboxStyle = [
RADIUS,
STATIC_TEXT,
VALIDATE,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -854,7 +865,7 @@ export const RadioStyle = [
},
STATIC_TEXT,
VALIDATE,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -880,7 +891,7 @@ export const SegmentStyle = [
},
RADIUS,
VALIDATE,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -1001,7 +1012,7 @@ export const FileViewerStyle = [
getStaticBackground("#FFFFFF"),
getStaticBorder("#00000000"),
RADIUS,
- MARGIN,
+ MARGIN,
PADDING,
BORDER_WIDTH
] as const;
@@ -1012,7 +1023,7 @@ export const DateTimeStyle = [
LABEL,
...getStaticBgBorderRadiusByBg(SURFACE_COLOR),
TEXT,
- MARGIN,
+ MARGIN,
PADDING,
...ACCENT_VALIDATE,
] as const;
@@ -1027,7 +1038,7 @@ function handleToHoverLink(color: string) {
export const LinkStyle = [
...LinkTextStyle,
- MARGIN,
+ MARGIN,
PADDING,
TEXT_SIZE
] as const;
@@ -1039,7 +1050,7 @@ export const DividerStyle = [
color: lightenColor(SECOND_SURFACE_COLOR, 0.05),
},
BORDER_WIDTH,
- MARGIN,
+ MARGIN,
PADDING,
{
name: "text",
@@ -1063,7 +1074,7 @@ export const ProgressStyle = [
TRACK,
FILL,
SUCCESS,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -1078,7 +1089,7 @@ export const NavigationStyle = [
ACCENT,
getStaticBackground("#FFFFFF00"),
getStaticBorder("#FFFFFF00"),
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -1095,7 +1106,7 @@ export const QRCodeStyle = [
label: trans("color"),
color: "#000000",
},
- MARGIN,
+ MARGIN,
PADDING,
BORDER,
RADIUS,
@@ -1119,7 +1130,7 @@ export const TimeLineStyle = [
label: trans("timeLine.subTitleColor"),
color: "#848484",
},
- MARGIN,
+ MARGIN,
PADDING,
RADIUS
] as const;
@@ -1199,7 +1210,7 @@ export const SignatureStyle = [
label: trans("style.footerIcon"),
color: "#222222",
},
- MARGIN,
+ MARGIN,
PADDING,
BORDER_WIDTH
] as const;
@@ -1213,7 +1224,7 @@ export const LottieStyle = [
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
- MARGIN,
+ MARGIN,
PADDING,
] as const;
/////////////////////
@@ -1225,19 +1236,19 @@ export const CommentStyle = [
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
- MARGIN,
+ MARGIN,
PADDING,
RADIUS,
] as const
export const ResponsiveLayoutRowStyle = [
...BG_STATIC_BORDER_RADIUS,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
export const ResponsiveLayoutColStyle = [
...BG_STATIC_BORDER_RADIUS,
- MARGIN,
+ MARGIN,
PADDING,
] as const;
@@ -1297,9 +1308,9 @@ export const NavLayoutItemActiveStyle = [
export const CarouselStyle = [getBackground("canvas")] as const;
export const RichTextEditorStyle = [
- getStaticBorder(),
- getBackground("primarySurface"),
- RADIUS,
+ getStaticBorder(),
+ getBackground("primarySurface"),
+ RADIUS,
BORDER_WIDTH
] as const;
@@ -1354,43 +1365,36 @@ export type NavLayoutItemHoverStyleType = StyleConfigType
;
export function widthCalculator(margin: string) {
- const marginArr = margin?.trim().replace(/\s+/g,' ').split(" ") || "";
+ const marginArr = margin?.trim().replace(/\s+/g, ' ').split(" ") || "";
if (marginArr.length === 1) {
- return `calc(100% - ${
- parseInt(margin.replace(/[^\d.]/g, "")) * 2 +
+ return `calc(100% - ${parseInt(margin.replace(/[^\d.]/g, "")) * 2 +
(margin.replace(/[0-9]/g, "") || "px")
- })`;
+ })`;
} else if (marginArr.length === 2 || marginArr.length === 3) {
- return `calc(100% - ${
- parseInt(marginArr[1].replace(/[^\d.]/g, "")) * 2 +
+ return `calc(100% - ${parseInt(marginArr[1].replace(/[^\d.]/g, "")) * 2 +
(marginArr[1].replace(/[0-9]/g, "") || 'px')
- })`;
+ })`;
} else {
- return `calc(100% - ${
- parseInt(marginArr[1]?.replace(/[^\d.]/g, "") || "0") +
+ return `calc(100% - ${parseInt(marginArr[1]?.replace(/[^\d.]/g, "") || "0") +
(marginArr[1]?.replace(/[0-9]/g, "") || "px")
- } - ${
- parseInt(marginArr[3]?.replace(/[^\d.]/g, "") || "0") +
+ } - ${parseInt(marginArr[3]?.replace(/[^\d.]/g, "") || "0") +
(marginArr[3]?.replace(/[0-9]/g, "") || "px")
- })`;
+ })`;
}
}
export function heightCalculator(margin: string) {
const marginArr = margin?.trim().split(" ") || "";
if (marginArr.length === 1 || marginArr.length === 2) {
- return `calc(100% - ${
- parseInt(marginArr[0].replace(/[^\d.]/g, "")) * 2 +
+ return `calc(100% - ${parseInt(marginArr[0].replace(/[^\d.]/g, "")) * 2 +
(marginArr[0].replace(/[0-9]/g, "") || 'px')
- })`;
- }else if(marginArr.length >2){
- return `calc(100% - ${
- parseInt(marginArr[0]?.replace(/[^\d.]/g, "") || "0") +
+ })`;
+ } else if (marginArr.length > 2) {
+ return `calc(100% - ${parseInt(marginArr[0]?.replace(/[^\d.]/g, "") || "0") +
(marginArr[0]?.replace(/[0-9]/g, "") || "px")
- } - ${
- parseInt(marginArr[2]?.replace(/[^\d.]/g, "") || "0") +
+ } - ${parseInt(marginArr[2]?.replace(/[^\d.]/g, "") || "0") +
(marginArr[2]?.replace(/[0-9]/g, "") || "px")
- })`;
+ })`;
}
}
diff --git a/client/packages/lowcoder/src/i18n/locales/en.ts b/client/packages/lowcoder/src/i18n/locales/en.ts
index 9cc91a970..fc05496d4 100644
--- a/client/packages/lowcoder/src/i18n/locales/en.ts
+++ b/client/packages/lowcoder/src/i18n/locales/en.ts
@@ -361,6 +361,7 @@ export const en = {
"textSize": "Text Size",
"textWeight": "Text Weight",
"fontFamily": "Font Family",
+ "fontStyle":"Font Style",
"backgroundImage": "BG Image",
"backgroundImageRepeat": "BG Repeat",
"backgroundImageSize": "BG Size",
From b0f8e670e92005dfdc9fc8e5beeb52535b47ff61 Mon Sep 17 00:00:00 2001
From: RAHEEL
Date: Wed, 14 Feb 2024 21:38:10 +0500
Subject: [PATCH 27/86] listView doesn't expose component updates for child
components
---
.../src/comps/comps/listViewComp/listView.tsx | 5 ++-
.../comps/comps/listViewComp/listViewComp.tsx | 14 +++++--
.../lowcoder/src/comps/comps/ratingComp.tsx | 22 ++++++++--
.../comps/selectInputComp/checkboxComp.tsx | 12 +++---
.../comps/selectInputComp/multiSelectComp.tsx | 16 +++----
.../comps/comps/selectInputComp/radioComp.tsx | 9 ++--
.../selectInputComp/radioCompConstants.tsx | 6 ++-
.../selectInputComp/segmentedControl.tsx | 13 +++---
.../comps/selectInputComp/selectComp.tsx | 14 +++----
.../selectInputComp/selectCompConstants.tsx | 3 +-
.../selectInputComp/selectInputConstants.tsx | 42 +++++++++++++++++--
.../src/comps/comps/tableComp/tableUtils.tsx | 1 -
.../textInputComp/textInputConstants.tsx | 19 +++++++--
.../comps/comps/treeComp/treeSelectComp.tsx | 10 +++--
.../src/comps/comps/treeComp/treeUtils.tsx | 6 ++-
.../src/comps/controls/optionsControl.tsx | 1 +
16 files changed, 141 insertions(+), 52 deletions(-)
diff --git a/client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx b/client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx
index 97319c64e..b45bc755b 100644
--- a/client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx
+++ b/client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx
@@ -176,7 +176,10 @@ export function ListView(props: Props) {
return ;
}
const containerProps = containerFn(
- { [itemIndexName]: itemIdx, [itemDataName]: getCurrentItemParams(data, itemIdx) },
+ {
+ [itemIndexName]: itemIdx,
+ [itemDataName]: getCurrentItemParams(data, itemIdx)
+ },
String(itemIdx)
).getView();
const unMountFn = () => {
diff --git a/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx b/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx
index 5df6f33f7..c9a28811d 100644
--- a/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx
@@ -7,7 +7,7 @@ import {
} from "comps/controls/codeControl";
import { styleControl } from "comps/controls/styleControl";
import { ListViewStyle } from "comps/controls/styleControlConstants";
-import { UICompBuilder, withDefault, withPropertyViewFn, withViewFn } from "comps/generators";
+import { UICompBuilder, stateComp, valueComp, withDefault, withPropertyViewFn, withViewFn } from "comps/generators";
import {
CompDepsConfig,
depsConfig,
@@ -80,10 +80,10 @@ export class ListViewImplComp extends ListViewTmpComp implements IContainer {
}
override reduce(action: CompAction): this {
// console.info("listView reduce. action: ", action);
-
let comp = reduceInContext({ inEventContext: true }, () => super.reduce(action));
+
if (action.type === CompActionTypes.UPDATE_NODES_V2) {
- const { itemCount } = getData(comp.children.noOfRows.getView());
+ const { itemCount} = getData(comp.children.noOfRows.getView());
const pagination = comp.children.pagination.getView();
const total = pagination.total || itemCount;
const offset = (pagination.current - 1) * pagination.pageSize;
@@ -171,6 +171,12 @@ export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
return data;
},
}),
+ // new CompDepsConfig(
+ // "index",
+ // (comp) => ({index: comp.children.itemIndexName.node() }),
+ // (input) => input.index.value,
+ // "index", // trans("listView.itemsDesc")
+ // ),
NameConfigHidden,
]);
@@ -232,7 +238,7 @@ export function defaultListViewData(compName: string, nameGenerator: NameGenerat
compType: "rating",
name: nameGenerator.genItemName("rating"),
comp: {
- value: "{{currentItem.rate / 2}}",
+ defaultValue: "{{currentItem.rate / 2}}",
max: "5",
label: {
text: "",
diff --git a/client/packages/lowcoder/src/comps/comps/ratingComp.tsx b/client/packages/lowcoder/src/comps/comps/ratingComp.tsx
index 992c45f74..40db580ab 100644
--- a/client/packages/lowcoder/src/comps/comps/ratingComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/ratingComp.tsx
@@ -15,7 +15,7 @@ import { migrateOldData } from "comps/generators/simpleGenerators";
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
import { trans } from "i18n";
-import { useContext } from "react";
+import { useContext, useEffect, useRef } from "react";
import { EditorContext } from "comps/editorState";
const EventOptions = [changeEvent] as const;
@@ -36,6 +36,7 @@ function fixOldData(oldData: any) {
const RatingBasicComp = (function () {
const childrenMap = {
+ defaultValue: numberExposingStateControl("defaultValue"),
value: numberExposingStateControl("value"),
max: withDefault(NumberControl, "5"),
label: LabelControl,
@@ -46,6 +47,21 @@ const RatingBasicComp = (function () {
...formDataChildren,
};
return new UICompBuilder(childrenMap, (props) => {
+ const defaultValue = { ...props.defaultValue }.value;
+ const value = { ...props.value }.value;
+ const changeRef = useRef(false)
+
+ useEffect(() => {
+ props.value.onChange(defaultValue);
+ }, [defaultValue]);
+
+ useEffect(() => {
+ if (!changeRef.current) return;
+
+ props.onEvent("change");
+ changeRef.current = false;
+ }, [value]);
+
return props.label({
style: props.style,
children: (
@@ -54,7 +70,7 @@ const RatingBasicComp = (function () {
value={props.value.value}
onChange={(e) => {
props.value.onChange(e);
- props.onEvent("change");
+ changeRef.current = true;
}}
allowHalf={props.allowHalf}
disabled={props.disabled}
@@ -67,7 +83,7 @@ const RatingBasicComp = (function () {
return (
<>
- {children.value.propertyView({ label: trans("prop.defaultValue") })}
+ {children.defaultValue.propertyView({ label: trans("prop.defaultValue") })}
{children.max.propertyView({
label: trans("rating.max"),
})}
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx
index 8152980d5..f30b92c45 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx
@@ -102,7 +102,8 @@ const CheckboxGroup = styled(AntdCheckboxGroup)<{
const CheckboxBasicComp = (function () {
const childrenMap = {
- value: arrayStringExposingStateControl("value", ["1"]),
+ defaultValue: arrayStringExposingStateControl("defaultValue"),
+ value: arrayStringExposingStateControl("value"),
label: LabelControl,
disabled: BoolCodeControl,
onEvent: ChangeEventHandlerControl,
@@ -115,7 +116,10 @@ const CheckboxBasicComp = (function () {
...formDataChildren,
};
return new UICompBuilder(childrenMap, (props) => {
- const [validateState, handleValidate] = useSelectInputValidate(props);
+ const [
+ validateState,
+ handleChange,
+ ] = useSelectInputValidate(props);
return props.label({
required: props.required,
style: props.style,
@@ -134,9 +138,7 @@ const CheckboxBasicComp = (function () {
disabled: option.disabled,
}))}
onChange={(values) => {
- handleValidate(values as string[]);
- props.value.onChange(values as string[]);
- props.onEvent("change");
+ handleChange(values as string[]);
}}
/>
),
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx
index c052f89fb..a8c2c0dc1 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx
@@ -14,18 +14,24 @@ import { SelectInputInvalidConfig, useSelectInputValidate } from "./selectInputC
import { PaddingControl } from "../../controls/paddingControl";
import { MarginControl } from "../../controls/marginControl";
+import { useEffect, useRef } from "react";
const MultiSelectBasicComp = (function () {
const childrenMap = {
...SelectChildrenMap,
- value: arrayStringExposingStateControl("value", ["1", "2"]),
+ defaultValue: arrayStringExposingStateControl("defaultValue", ["1", "2"]),
+ value: arrayStringExposingStateControl("value"),
style: styleControl(MultiSelectStyle),
margin: MarginControl,
padding: PaddingControl,
};
return new UICompBuilder(childrenMap, (props, dispatch) => {
const valueSet = new Set(props.options.map((o) => o.value)); // Filter illegal default values entered by the user
- const [validateState, handleValidate] = useSelectInputValidate(props);
+ const [
+ validateState,
+ handleChange,
+ ] = useSelectInputValidate(props);
+
return props.label({
required: props.required,
style: props.style,
@@ -34,11 +40,7 @@ const MultiSelectBasicComp = (function () {
{...props}
mode={"multiple"}
value={props.value.value.filter?.((v) => valueSet.has(v))}
- onChange={(value) => {
- handleValidate(value);
- props.value.onChange(value);
- props.onEvent("change");
- }}
+ onChange={handleChange}
dispatch={dispatch}
/>
),
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx
index e1bc7033c..494a3b24f 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx
@@ -83,7 +83,10 @@ const Radio = styled(AntdRadioGroup)<{
const RadioBasicComp = (function () {
return new UICompBuilder(RadioChildrenMap, (props) => {
- const [validateState, handleValidate] = useSelectInputValidate(props);
+ const [
+ validateState,
+ handleChange,
+ ] = useSelectInputValidate(props);
return props.label({
required: props.required,
style: props.style,
@@ -95,9 +98,7 @@ const RadioBasicComp = (function () {
$style={props.style}
$layout={props.layout}
onChange={(e) => {
- handleValidate(e.target.value);
- props.value.onChange(e.target.value);
- props.onEvent("change");
+ handleChange(e.target.value);
}}
options={props.options
.filter((option) => option.value !== undefined && !option.hidden)
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/radioCompConstants.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/radioCompConstants.tsx
index f84180dd0..56cf0c8c0 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/radioCompConstants.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/radioCompConstants.tsx
@@ -30,6 +30,7 @@ export const RadioLayoutOptions = [
] as const;
export const RadioChildrenMap = {
+ defaultValue: stringExposingStateControl("value"),
value: stringExposingStateControl("value"),
label: LabelControl,
disabled: BoolCodeControl,
@@ -46,6 +47,9 @@ export const RadioChildrenMap = {
export const RadioPropertyView = (
children: RecordConstructorToComp<
typeof RadioChildrenMap & { hidden: typeof BoolCodeControl } & {
+ defaultValue:
+ | ReturnType
+ | ReturnType;
value:
| ReturnType
| ReturnType;
@@ -55,7 +59,7 @@ export const RadioPropertyView = (
<>
{children.options.propertyView({})}
- {children.value.propertyView({ label: trans("prop.defaultValue") })}
+ {children.defaultValue.propertyView({ label: trans("prop.defaultValue") })}
{["logic", "both"].includes(useContext(EditorContext).editorModeStatus) && (
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/segmentedControl.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/segmentedControl.tsx
index bf105982a..6c82fd62b 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/segmentedControl.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/segmentedControl.tsx
@@ -62,6 +62,7 @@ const Segmented = styled(AntdSegmented)<{ $style: SegmentStyleType }>`
`;
const SegmentChildrenMap = {
+ defaultValue: stringExposingStateControl("value"),
value: stringExposingStateControl("value"),
label: LabelControl,
disabled: BoolCodeControl,
@@ -76,7 +77,11 @@ const SegmentChildrenMap = {
const SegmentedControlBasicComp = (function () {
return new UICompBuilder(SegmentChildrenMap, (props) => {
- const [validateState, handleValidate] = useSelectInputValidate(props);
+ const [
+ validateState,
+ handleValidate,
+ handleChange,
+ ] = useSelectInputValidate(props);
return props.label({
required: props.required,
style: props.style,
@@ -88,9 +93,7 @@ const SegmentedControlBasicComp = (function () {
value={props.value.value}
$style={props.style}
onChange={(value) => {
- handleValidate(value.toString());
- props.value.onChange(value.toString());
- props.onEvent("change");
+ handleChange(value.toString());
}}
options={props.options
.filter((option) => option.value !== undefined && !option.hidden)
@@ -109,7 +112,7 @@ const SegmentedControlBasicComp = (function () {
<>
{children.options.propertyView({})}
- {children.value.propertyView({ label: trans("prop.defaultValue") })}
+ {children.defaultValue.propertyView({ label: trans("prop.defaultValue") })}
{["logic", "both"].includes(useContext(EditorContext).editorModeStatus) && (
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectComp.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectComp.tsx
index 98c5b8bc8..1a30f2522 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectComp.tsx
@@ -21,16 +21,21 @@ import { RecordConstructorToView } from "lowcoder-core";
const SelectBasicComp = (function () {
const childrenMap = {
...SelectChildrenMap,
+ defaultValue: stringExposingStateControl("defaultValue"),
value: stringExposingStateControl("value"),
style: styleControl(SelectStyle),
};
return new UICompBuilder(childrenMap, (props, dispatch) => {
- const [validateState, handleValidate] = useSelectInputValidate(props);
+ const [
+ validateState,
+ handleChange,
+ ] = useSelectInputValidate(props);
const propsRef = useRef>(props);
propsRef.current = props;
const valueSet = new Set(props.options.map((o) => o.value)); // Filter illegal default values entered by the user
+
return props.label({
required: props.required,
style: props.style,
@@ -38,12 +43,7 @@ const SelectBasicComp = (function () {
{
- props.value.onChange(value ?? "").then(() => {
- propsRef.current.onEvent("change");
- handleValidate(value ?? "");
- });
- }}
+ onChange={handleChange}
dispatch={dispatch}
/>
),
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx
index 86493bf76..4f5a0ba18 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx
@@ -265,6 +265,7 @@ export const SelectPropertyView = (
hidden: typeof BoolCodeControl;
}
> & {
+ defaultValue: { propertyView: (params: ControlParams) => ControlNode };
value: { propertyView: (params: ControlParams) => ControlNode };
style: { getPropertyView: () => ControlNode };
}
@@ -272,7 +273,7 @@ export const SelectPropertyView = (
<>
{children.options.propertyView({})}
- {children.value.propertyView({ label: trans("prop.defaultValue") })}
+ {children.defaultValue.propertyView({ label: trans("prop.defaultValue") })}
{placeholderPropertyView(children)}
diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectInputConstants.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectInputConstants.tsx
index 8476a372c..7c4fdc126 100644
--- a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectInputConstants.tsx
+++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectInputConstants.tsx
@@ -11,7 +11,7 @@ import {
} from "../../controls/codeStateControl";
import { requiredPropertyView } from "comps/utils/propertyUtils";
import { trans } from "i18n";
-import { useRef, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { SelectInputOptionControl } from "../../controls/optionsControl";
import { refMethods } from "comps/generators/withMethodExposing";
import { blurMethod, focusWithOptions } from "comps/utils/methodUtils";
@@ -22,10 +22,18 @@ export const SelectInputValidationChildren = {
};
type ValidationComp = RecordConstructorToComp;
+type SelectValue = string | (string | number)[];
type ValidationParams = {
- value: { value: string | (string | number)[] };
+ defaultValue?: {
+ value: SelectValue,
+ };
+ value: {
+ value: SelectValue,
+ onChange?: (value: any) => Promise,
+ };
required: boolean;
customRule: string;
+ onEvent?: (eventName: string) => Promise,
};
export const selectInputValidate = (
@@ -45,10 +53,14 @@ export const selectInputValidate = (
};
export const useSelectInputValidate = (props: ValidationParams) => {
+ const [validateState, setValidateState] = useState({});
+ const changeRef = useRef(false)
const propsRef = useRef(props);
propsRef.current = props;
- const [validateState, setValidateState] = useState({});
+ const selectValue = props.value.value;
+ const defaultValue = props.defaultValue?.value;
+
const handleValidate = (value: string | (string | number)[]) => {
setValidateState(
selectInputValidate({
@@ -59,7 +71,29 @@ export const useSelectInputValidate = (props: ValidationParams) => {
})
);
};
- return [validateState, handleValidate] as const;
+
+ useEffect(() => {
+ props.value.onChange?.(defaultValue)
+ }, [defaultValue]);
+
+ useEffect(() => {
+ if (!changeRef.current) return;
+
+ handleValidate(selectValue);
+ props.onEvent?.("change");
+ changeRef.current = false;
+ }, [selectValue]);
+
+ const handleChange = (value: any) => {
+ props.value.onChange?.(value);
+ changeRef.current = true;
+ };
+
+ return [
+ validateState,
+ handleValidate,
+ handleChange,
+ ] as const;
};
type ValidationCompWithValue = ValidationComp & {
diff --git a/client/packages/lowcoder/src/comps/comps/tableComp/tableUtils.tsx b/client/packages/lowcoder/src/comps/comps/tableComp/tableUtils.tsx
index 967ce1fbf..f3a74123f 100644
--- a/client/packages/lowcoder/src/comps/comps/tableComp/tableUtils.tsx
+++ b/client/packages/lowcoder/src/comps/comps/tableComp/tableUtils.tsx
@@ -258,7 +258,6 @@ function getInitialColumns(
Object.keys(columnsAggrData).forEach(column => {
if(customColumns.includes(column)) return;
initialColumns.push({
- // label: {column},
label: column,
value: `{{currentRow.${column}}}`
});
diff --git a/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx b/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx
index 2deb701e6..66b7e4cdb 100644
--- a/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx
+++ b/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx
@@ -134,6 +134,7 @@ const TextInputInvalidConfig = depsConfig props.onEvent("focus"),
onBlur: () => props.onEvent("blur"),
@@ -164,13 +166,21 @@ export const textInputProps = (props: RecordConstructorToView) => {
const [validateState, setValidateState] = useState({});
+ const changeRef = useRef(false)
const propsRef = useRef>(props);
propsRef.current = props;
- const inputValue = props.value.value;
+ const defaultValue = { ...props.defaultValue }.value;
+ const inputValue = { ...props.value }.value;
useEffect(() => {
+ props.value.onChange(defaultValue)
+ }, [defaultValue]);
+
+ useEffect(() => {
+ if (!changeRef.current) return;
+
setValidateState(
textInputValidate({
...propsRef.current,
@@ -179,12 +189,15 @@ export const useTextInputProps = (props: RecordConstructorToView) => {
props.value.onChange(e.target.value);
- propsRef.current.onEvent("change");
+ changeRef.current = true;
};
+
return [
{
...textInputProps(props),
@@ -198,7 +211,7 @@ type TextInputComp = RecordConstructorToComp;
export const TextInputBasicSection = (children: TextInputComp) => (
- {children.value.propertyView({ label: trans("prop.defaultValue") })}
+ {children.defaultValue.propertyView({ label: trans("prop.defaultValue") })}
{placeholderPropertyView(children)}
);
diff --git a/client/packages/lowcoder/src/comps/comps/treeComp/treeSelectComp.tsx b/client/packages/lowcoder/src/comps/comps/treeComp/treeSelectComp.tsx
index 993113e97..ea31712a3 100644
--- a/client/packages/lowcoder/src/comps/comps/treeComp/treeSelectComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/treeComp/treeSelectComp.tsx
@@ -85,7 +85,11 @@ const TreeCompView = (
) => {
const { treeData, selectType, value, expanded, style, inputValue } = props;
const isSingle = selectType === "single";
- const [validateState, handleValidate] = useSelectInputValidate(props);
+ const [
+ validateState,
+ handleChange,
+ ] = useSelectInputValidate(props);
+
useEffect(() => {
if (isSingle && value.value.length > 1) {
value.onChange(value.value.slice(0, 1));
@@ -119,9 +123,7 @@ const TreeCompView = (
}}
onChange={(keys) => {
const nextValue = Array.isArray(keys) ? keys : keys !== undefined ? [keys] : [];
- handleValidate(nextValue);
- value.onChange(nextValue);
- props.onEvent("change");
+ handleChange(nextValue);
}}
showSearch={props.showSearch}
// search label
diff --git a/client/packages/lowcoder/src/comps/comps/treeComp/treeUtils.tsx b/client/packages/lowcoder/src/comps/comps/treeComp/treeUtils.tsx
index 1ad7ce909..2e6fb61d6 100644
--- a/client/packages/lowcoder/src/comps/comps/treeComp/treeUtils.tsx
+++ b/client/packages/lowcoder/src/comps/comps/treeComp/treeUtils.tsx
@@ -68,6 +68,7 @@ function expandAll(data: TreeDataNode[]) {
export const treeCommonChildren = {
// TODO: support loading mode
treeData: jsonControl(convertTreeData, defaultTreeData),
+ defaultValue: jsonExposingStateControl("value", checkNodeValues, []),
value: jsonExposingStateControl("value", checkNodeValues, []),
expanded: jsonStateControl(checkNodeValues, []),
defaultExpandAll: BoolControl,
@@ -94,8 +95,9 @@ type TreeCommonComp = NewChildren
children.treeData.propertyView({ label: trans("tree.treeData"), tooltip: treeDataTooltip });
-export const valuePropertyView = (children: TreeCommonComp) =>
- children.value.propertyView({ label: trans("tree.value") });
+export const valuePropertyView = (children: TreeCommonComp) => {
+ return children.defaultValue.propertyView({ label: trans("tree.value") });
+}
export const formSection = (children: TreeCommonComp) => ;
diff --git a/client/packages/lowcoder/src/comps/controls/optionsControl.tsx b/client/packages/lowcoder/src/comps/controls/optionsControl.tsx
index 221459b28..1230a195e 100644
--- a/client/packages/lowcoder/src/comps/controls/optionsControl.tsx
+++ b/client/packages/lowcoder/src/comps/controls/optionsControl.tsx
@@ -331,6 +331,7 @@ export function mapOptionsControl(
return comp.updateContext(dataExample);
}
}
+ return comp;
}
return super.reduce(action);
}
From d7daf285e54f92bb92e05c41323ef10ad8911ac3 Mon Sep 17 00:00:00 2001
From: RAHEEL
Date: Wed, 14 Feb 2024 21:46:34 +0500
Subject: [PATCH 28/86] expose setPage method on ListView and GridView
---
.../comps/comps/listViewComp/listViewComp.tsx | 21 +++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx b/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx
index c9a28811d..dd1dc85e9 100644
--- a/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx
@@ -37,6 +37,7 @@ import { ContextContainerComp } from "./contextContainerComp";
import { ListView } from "./listView";
import { listPropertyView } from "./listViewPropertyView";
import { getData } from "./listViewUtils";
+import { withMethodExposing } from "comps/generators/withMethodExposing";
const childrenMap = {
noOfRows: withIsLoadingMethod(NumberOrJSONObjectArrayControl), // FIXME: migrate "noOfRows" to "data"
@@ -151,11 +152,11 @@ export class ListViewImplComp extends ListViewTmpComp implements IContainer {
const ListViewRenderComp = withViewFn(ListViewImplComp, (comp) => );
const ListPropertyView = listPropertyView("listView");
-const ListViewPropertyComp = withPropertyViewFn(ListViewRenderComp, (comp) => {
+let ListViewPropertyComp = withPropertyViewFn(ListViewRenderComp, (comp) => {
return ;
});
-export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
+ListViewPropertyComp = withExposingConfigs(ListViewPropertyComp, [
new CompDepsConfig(
"items",
(comp) => ({ data: comp.itemsNode() }),
@@ -180,6 +181,22 @@ export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
NameConfigHidden,
]);
+export const ListViewComp = withMethodExposing(ListViewPropertyComp, [
+ {
+ method: {
+ name: "setPage",
+ description: "",
+ params: [{ name: "page", type: "number" }],
+ },
+ execute: (comp, values) => {
+ const page = values[0] as number;
+ if (page && page > 0) {
+ comp.children.pagination.children.pageNo.dispatchChangeValueAction(page);
+ }
+ },
+ },
+])
+
export function defaultListViewData(compName: string, nameGenerator: NameGenerator) {
return {
noOfRows:
From 349986e427dc48ec72de4376491587369f69c206 Mon Sep 17 00:00:00 2001
From: RAHEEL
Date: Thu, 15 Feb 2024 01:54:29 +0500
Subject: [PATCH 29/86] fix number input 'allow null value' has no effect
---
.../comps/numberInputComp/numberInputComp.tsx | 20 ++++++++++++++++---
.../src/comps/controls/dropdownControl.tsx | 1 -
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/client/packages/lowcoder/src/comps/comps/numberInputComp/numberInputComp.tsx b/client/packages/lowcoder/src/comps/comps/numberInputComp/numberInputComp.tsx
index f1c917521..4baacf4d1 100644
--- a/client/packages/lowcoder/src/comps/comps/numberInputComp/numberInputComp.tsx
+++ b/client/packages/lowcoder/src/comps/comps/numberInputComp/numberInputComp.tsx
@@ -10,7 +10,7 @@ import {
import { BoolControl } from "comps/controls/boolControl";
import { dropdownControl } from "comps/controls/dropdownControl";
import { LabelControl } from "comps/controls/labelControl";
-import { numberExposingStateControl } from "comps/controls/codeStateControl";
+import { numberExposingStateControl, stringExposingStateControl } from "comps/controls/codeStateControl";
import NP from "number-precision";
import {
@@ -234,6 +234,7 @@ const UndefinedNumberControl = codeControl((value: any) => {
});
const childrenMap = {
+ defaultValue: stringExposingStateControl("defaultValue"), // It is more convenient for string to handle various states, save raw input here
value: numberExposingStateControl("value"), // It is more convenient for string to handle various states, save raw input here
placeholder: StringControl,
disabled: BoolCodeControl,
@@ -261,6 +262,17 @@ const childrenMap = {
const CustomInputNumber = (props: RecordConstructorToView) => {
const ref = useRef(null);
+ const defaultValue = props.defaultValue.value;
+
+ useEffect(() => {
+ let value = 0;
+ if (defaultValue === 'null' && props.allowNull) {
+ value = NaN;
+ } else if (!isNaN(Number(defaultValue))) {
+ value = Number(defaultValue);
+ }
+ props.value.onChange(value);
+ }, [defaultValue]);
const formatFn = (value: number) =>
format(value, props.allowNull, props.formatter, props.precision, props.thousandsSeparator);
@@ -271,7 +283,9 @@ const CustomInputNumber = (props: RecordConstructorToView) =
const oldValue = props.value.value;
const newValue = parseNumber(tmpValue, props.allowNull);
props.value.onChange(newValue);
- oldValue !== newValue && props.onEvent("change");
+ if((oldValue !== newValue)) {
+ props.onEvent("change");
+ }
};
useEffect(() => {
@@ -363,7 +377,7 @@ const NumberInputTmpComp = (function () {
.setPropertyViewFn((children) => (
<>
- {children.value.propertyView({ label: trans("prop.defaultValue") })}
+ {children.defaultValue.propertyView({ label: trans("prop.defaultValue") })}
{placeholderPropertyView(children)}
{children.formatter.propertyView({ label: trans("numberInput.formatter") })}
diff --git a/client/packages/lowcoder/src/comps/controls/dropdownControl.tsx b/client/packages/lowcoder/src/comps/controls/dropdownControl.tsx
index 1492a97a4..01b7b832c 100644
--- a/client/packages/lowcoder/src/comps/controls/dropdownControl.tsx
+++ b/client/packages/lowcoder/src/comps/controls/dropdownControl.tsx
@@ -96,7 +96,6 @@ export function dropdownAbstractControl(
value={this.value}
options={finalOptions}
onChange={(value) => {
- console.log(value);
if (!params.disableDispatchValueChange) {
this.dispatchChangeValueAction(value);
}
From ad0d049ed73dde660f109a296d4887f26e247b2c Mon Sep 17 00:00:00 2001
From: freddysundowner
Date: Thu, 15 Feb 2024 11:40:52 +0300
Subject: [PATCH 30/86] fix:Date Range Component crashes when we remove Suffix
Icon
---
client/packages/lowcoder/src/comps/utils/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/packages/lowcoder/src/comps/utils/index.tsx b/client/packages/lowcoder/src/comps/utils/index.tsx
index d0ff1dcb6..1dda47b1e 100644
--- a/client/packages/lowcoder/src/comps/utils/index.tsx
+++ b/client/packages/lowcoder/src/comps/utils/index.tsx
@@ -84,4 +84,4 @@ export function arrayMove(data: Array, start: number, end: number) {
return result;
}
-export const hasIcon = (icon: ReactNode) => (icon as ReactElement).props.value;
+export const hasIcon = (icon: ReactNode) => (icon as ReactElement).props?.value;
From 92196587caf138ab1694f96958222703bdedb57b Mon Sep 17 00:00:00 2001
From: Ludo Mikula
Date: Thu, 15 Feb 2024 10:05:54 +0100
Subject: [PATCH 31/86] fix: fixed failing test
---
.../lowcoder/api/application/ApplicationApiServiceTest.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/application/ApplicationApiServiceTest.java b/server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/application/ApplicationApiServiceTest.java
index 50fc1d85d..5bf57b461 100644
--- a/server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/application/ApplicationApiServiceTest.java
+++ b/server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/application/ApplicationApiServiceTest.java
@@ -8,6 +8,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.lowcoder.api.application.ApplicationEndpoints.ApplicationRequestType;
import org.lowcoder.api.application.ApplicationEndpoints.CreateApplicationRequest;
import org.lowcoder.api.application.view.ApplicationPermissionView;
import org.lowcoder.api.application.view.ApplicationView;
@@ -133,7 +134,7 @@ public void testPublishApplication() {
.verifyComplete();
// published dsl before publish
- StepVerifier.create(applicationIdMono.flatMap(id -> applicationApiService.getPublishedApplication(id)))
+ StepVerifier.create(applicationIdMono.flatMap(id -> applicationApiService.getPublishedApplication(id, ApplicationRequestType.PUBLIC_TO_ALL)))
.assertNext(applicationView -> Assert.assertEquals(Map.of("comp", "table"), applicationView.getApplicationDSL()))
.verifyComplete();
@@ -147,7 +148,7 @@ public void testPublishApplication() {
.verifyComplete();
// published dsl after publish
- StepVerifier.create(applicationIdMono.flatMap(id -> applicationApiService.getPublishedApplication(id)))
+ StepVerifier.create(applicationIdMono.flatMap(id -> applicationApiService.getPublishedApplication(id, ApplicationRequestType.PUBLIC_TO_ALL)))
.assertNext(applicationView -> Assert.assertEquals(Map.of("comp", "list"), applicationView.getApplicationDSL()))
.verifyComplete();
}
From b1743852d6db41177ae20d2bdddf2645ec089ac4 Mon Sep 17 00:00:00 2001
From: RAHEEL
Date: Thu, 15 Feb 2024 17:04:18 +0500
Subject: [PATCH 32/86] bulk action value
---
.../src/pages/editor/LeftLayersContent.tsx | 28 +++++++++----------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx b/client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx
index 05470460f..5f2aeb25b 100644
--- a/client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx
+++ b/client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx
@@ -279,10 +279,6 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
const getCheckedKeys = () => {
return checkedKeys;
}
-
- useEffect(() => {
- console.log('onChange', actionValue);
- }, [actionValue])
const getActionValue = () => {
return actionValue;
@@ -350,14 +346,16 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
{trans("leftPanel.activatelayers")}
{
- toggleCollisionStatus(value == true ? "true" : "false");
- editorState.setCollisionStatus(value == true ? "true" : "false");
- } } />
+ style={{margin : "0px 10px"}}
+ size="small"
+ checked={editorState.collisionStatus == "true"}
+ disabled={false}
+ onChange={(value: any) => {
+ toggleCollisionStatus(value == true ? "true" : "false");
+ editorState.setCollisionStatus(value == true ? "true" : "false");
+ }}
+ />
+