Skip to content

Commit bf5230d

Browse files
committed
chore: update props and code cleanup
1 parent f5af4d3 commit bf5230d

File tree

8 files changed

+21
-38
lines changed

8 files changed

+21
-38
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<!-- TODO: Update marketplace URL -->
22

3-
Please see [App Events](https://docs.mendix.com/appstore/widgets/) in the Mendix documentation for details.
3+
Please see [Signature](https://docs.mendix.com/appstore/widgets/) in the Mendix documentation for details.

packages/pluggableWidgets/signature-web/src/Signature.editorConfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export function getProperties(
1616
values: SignaturePreviewProps,
1717
defaultProperties: Properties /* , target: Platform*/
1818
): Properties {
19-
if (values.heightUnit === "percentageOfWidth") {
19+
if (values.heightUnit === "auto") {
2020
hidePropertyIn(defaultProperties, values, "height");
2121
} else {
2222
hidePropertiesIn(defaultProperties, values, [
2323
"minHeight",
2424
"minHeightUnit",
2525
"maxHeight",
2626
"maxHeightUnit",
27-
"OverflowY"
27+
"overflowY"
2828
]);
2929
}
3030

@@ -33,7 +33,7 @@ export function getProperties(
3333
}
3434

3535
if (values.maxHeightUnit === "none") {
36-
hidePropertiesIn(defaultProperties, values, ["maxHeight", "OverflowY"]);
36+
hidePropertiesIn(defaultProperties, values, ["maxHeight", "overflowY"]);
3737
}
3838

3939
return defaultProperties;
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
import { ReactElement, useCallback } from "react";
1+
import { ReactElement } from "react";
22
import { SignatureContainerProps } from "../typings/SignatureProps";
33
import { SignatureComponent } from "./components/Signature";
44
import "./ui/Signature.scss";
55

66
export default function Signature(props: SignatureContainerProps): ReactElement {
7-
const { class: className, onSignEndAction } = props;
8-
const handleSignEnd = useCallback(
9-
(imageDataUrl?: string) => {
10-
if (onSignEndAction && !onSignEndAction.isExecuting && onSignEndAction.canExecute) {
11-
onSignEndAction.execute({ signatureImage: imageDataUrl });
12-
}
13-
},
14-
[onSignEndAction]
15-
);
16-
return (
17-
<SignatureComponent
18-
readOnly={false}
19-
{...props}
20-
className={className}
21-
onSignEndAction={handleSignEnd}
22-
clearSignature={false}
23-
/>
24-
);
7+
const { class: className } = props;
8+
return <SignatureComponent {...props} readOnly={props.imageSource.readOnly} className={className} />;
259
}

packages/pluggableWidgets/signature-web/src/Signature.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<attributeType name="Boolean" />
1818
</attributeTypes>
1919
</property>
20+
<systemProperty key="Editability" />
2021
</propertyGroup>
2122
<propertyGroup caption="Appearance">
2223
<property key="penType" type="enumeration" defaultValue="fountain">
@@ -52,7 +53,7 @@
5253
<caption>Height unit</caption>
5354
<description />
5455
<enumerationValues>
55-
<enumerationValue key="percentageOfWidth">Auto</enumerationValue>
56+
<enumerationValue key="auto">Auto</enumerationValue>
5657
<enumerationValue key="pixels">Pixels</enumerationValue>
5758
<enumerationValue key="percentageOfParent">Percentage</enumerationValue>
5859
<enumerationValue key="percentageOfView">Viewport</enumerationValue>
@@ -90,7 +91,7 @@
9091
<caption>Maximum height</caption>
9192
<description />
9293
</property>
93-
<property key="OverflowY" type="enumeration" defaultValue="auto">
94+
<property key="overflowY" type="enumeration" defaultValue="auto">
9495
<caption>Vertical Overflow</caption>
9596
<description />
9697
<enumerationValues>

packages/pluggableWidgets/signature-web/src/components/Signature.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export function SignatureComponent(props: SignatureProps): ReactElement {
1717
}
1818

1919
// Trigger microflow to update signature attribute
20-
if (onSignEndAction) {
21-
onSignEndAction(imageDataUrl);
20+
if (onSignEndAction && !onSignEndAction.isExecuting && onSignEndAction.canExecute) {
21+
onSignEndAction.execute({ signatureImage: imageDataUrl });
2222
}
2323
};
2424

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { PenTypeEnum, SignatureContainerProps } from "../../typings/SignatureProps";
22

3-
export interface SignatureProps extends Omit<SignatureContainerProps, "onSignEndAction"> {
3+
export interface SignatureProps extends SignatureContainerProps {
44
className: string;
55
alertMessage?: string;
6-
clearSignature: boolean;
76
showGrid: boolean;
87
gridCellWidth: number;
98
gridCellHeight: number;
109
gridBorderColor: string;
1110
gridBorderWidth: number;
1211
penType: PenTypeEnum;
1312
penColor: string;
14-
onSignEndAction?: (imageUrl?: string) => void;
1513
wrapperStyle?: object;
1614
readOnly: boolean;
1715
}

packages/pluggableWidgets/signature-web/src/utils/dimensions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CSSProperties } from "react";
22

33
export type WidthUnitEnum = "pixels" | "percentage";
44

5-
export type HeightUnitEnum = "percentageOfWidth" | "pixels" | "percentageOfParent" | "percentageOfView";
5+
export type HeightUnitEnum = "auto" | "pixels" | "percentageOfParent" | "percentageOfView";
66

77
export type MinHeightUnitEnum = "none" | "pixels" | "percentageOfParent" | "percentageOfView";
88

@@ -19,22 +19,22 @@ export type DimensionsProps = {
1919
minHeight: number;
2020
maxHeightUnit: MaxHeightUnitEnum;
2121
maxHeight: number;
22-
OverflowY: OverflowYEnum;
22+
overflowY: OverflowYEnum;
2323
};
2424

2525
function getHeightScale(height: number, heightUnit: "pixels" | "percentageOfParent" | "percentageOfView"): string {
2626
return `${height}${heightUnit === "pixels" ? "px" : heightUnit === "percentageOfView" ? "vh" : "%"}`;
2727
}
2828

2929
export function constructWrapperStyle(props: DimensionsProps): CSSProperties {
30-
const { widthUnit, heightUnit, minHeightUnit, maxHeightUnit, width, height, minHeight, maxHeight, OverflowY } =
30+
const { widthUnit, heightUnit, minHeightUnit, maxHeightUnit, width, height, minHeight, maxHeight, overflowY } =
3131
props;
3232

3333
const wrapperStyle: Pick<CSSProperties, "width" | "height" | "minHeight" | "maxHeight" | "maxWidth" | "overflowY"> =
3434
{};
3535

3636
wrapperStyle.width = `${width}${widthUnit === "pixels" ? "px" : "%"}`;
37-
if (heightUnit === "percentageOfWidth") {
37+
if (heightUnit === "auto") {
3838
wrapperStyle.height = "auto";
3939

4040
if (minHeightUnit !== "none") {
@@ -43,7 +43,7 @@ export function constructWrapperStyle(props: DimensionsProps): CSSProperties {
4343

4444
if (maxHeightUnit !== "none") {
4545
wrapperStyle.maxHeight = getHeightScale(maxHeight, maxHeightUnit);
46-
wrapperStyle.overflowY = OverflowY;
46+
wrapperStyle.overflowY = overflowY;
4747
}
4848
} else {
4949
wrapperStyle.height = getHeightScale(height, heightUnit);

packages/pluggableWidgets/signature-web/typings/SignatureProps.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type PenTypeEnum = "fountain" | "ballpoint" | "marker";
1010

1111
export type WidthUnitEnum = "pixels" | "percentage";
1212

13-
export type HeightUnitEnum = "percentageOfWidth" | "pixels" | "percentageOfParent" | "percentageOfView";
13+
export type HeightUnitEnum = "auto" | "pixels" | "percentageOfParent" | "percentageOfView";
1414

1515
export type MinHeightUnitEnum = "none" | "pixels" | "percentageOfParent" | "percentageOfView";
1616

@@ -35,7 +35,7 @@ export interface SignatureContainerProps {
3535
minHeight: number;
3636
maxHeightUnit: MaxHeightUnitEnum;
3737
maxHeight: number;
38-
OverflowY: OverflowYEnum;
38+
overflowY: OverflowYEnum;
3939
onSignEndAction?: ActionValue<{ signatureImage: Option<string> }>;
4040
showGrid: boolean;
4141
gridBorderColor: string;
@@ -67,7 +67,7 @@ export interface SignaturePreviewProps {
6767
minHeight: number | null;
6868
maxHeightUnit: MaxHeightUnitEnum;
6969
maxHeight: number | null;
70-
OverflowY: OverflowYEnum;
70+
overflowY: OverflowYEnum;
7171
onSignEndAction: {} | null;
7272
showGrid: boolean;
7373
gridBorderColor: string;

0 commit comments

Comments
 (0)