import {
antd,
UICompBuilder,
numberExposingStateControl,
Section,
withDefault,
withExposingConfigs,
NumberControl,
NameConfig,
eventHandlerControl,
withMethodExposing,
} from "lowcoder-sdk";
import styles from "./style.module.css";
const { Button } = antd;
const childrenMap = {
value: numberExposingStateControl("value", 10),
step: withDefault(NumberControl, 1),
onEvent: eventHandlerControl([
{
label: "onChange",
value: "change",
description: "",
},
]),
};
const CounterCompBase = new UICompBuilder(childrenMap, (props: any) => {
const currentValue = props.value.value;
return (
{currentValue}
);
})
.setPropertyViewFn((children: any) => {
return (
<>
{children.value.propertyView({ label: "Initial Value" })}
{children.step.propertyView({ label: "Step" })}
{children.onEvent.propertyView()}
>
);
})
.build();
const CounterCompTemp = withMethodExposing(CounterCompBase, [
{
method: {
name: "random",
params: [],
},
execute(comp: any) {
comp.children.value.getView().onChange(Math.floor(Math.random() * 100));
},
},
]);
export default withExposingConfigs(CounterCompTemp, [
new NameConfig("value", ""),
new NameConfig("step", ""),
]);