Skip to content

Commit d9ebc3c

Browse files
committed
Generate types for editable files and images
1 parent 5e128cb commit d9ebc3c

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/pluggable-widgets-tools/src/typings-generator/WidgetXml.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface Property {
5151
isDefault?: string;
5252
dataSource?: string;
5353
onChange?: string;
54+
allowUpload?: string;
5455
};
5556
caption?: string[];
5657
category?: string[];

packages/pluggable-widgets-tools/src/typings-generator/generate.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const mxExports = [
1010
"DynamicValue",
1111
"EditableValue",
1212
"EditableListValue",
13+
"EditableFileValue",
14+
"EditableImageValue",
1315
"FileValue",
1416
"ListValue",
1517
"NativeIcon",

packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,15 @@ function toClientPropType(
128128
return "number";
129129
case "decimal":
130130
return "Big";
131-
case "icon":
131+
case "icon":
132132
return isNative ? "DynamicValue<NativeIcon>" : "DynamicValue<WebIcon>";
133-
case "image":
134-
return isNative ? "DynamicValue<NativeImage>" : "DynamicValue<WebImage>";
133+
case "image": {
134+
const allowUpload = prop.$.allowUpload === "true";
135+
const imageType = isNative ? "NativeImage" : "WebImage";
136+
return allowUpload ? `EditableImageValue<${imageType}>` : `DynamicValue<${imageType}>`;
137+
}
135138
case "file":
136-
return "DynamicValue<FileValue>";
139+
return prop.$.allowUpload ? "EditableFileValue<FileValue>" : "DynamicValue<FileValue>";
137140
case "datasource":
138141
return "ListValue";
139142
case "attribute": {

0 commit comments

Comments
 (0)