11import type { EnsembleAction , Expression } from "@ensembleui/react-framework" ;
2- import { useRegisterBindings } from "@ensembleui/react-framework" ;
2+ import { unwrapWidget , useRegisterBindings } from "@ensembleui/react-framework" ;
33import { Button as AntButton , Form as AntForm } from "antd" ;
44import {
55 type MouseEvent ,
@@ -12,11 +12,13 @@ import { WidgetRegistry } from "../registry";
1212import type { EnsembleWidgetProps , IconProps } from "../shared/types" ;
1313import { useEnsembleAction } from "../runtime/hooks/useEnsembleAction" ;
1414import { Icon } from "./Icon" ;
15+ import { EnsembleRuntime } from "../runtime" ;
16+ import { isString } from "lodash-es" ;
1517
1618const widgetName = "Button" ;
1719
1820export type ButtonProps = {
19- label : Expression < string > ;
21+ label : Expression < string > | { [ key : string ] : unknown } ;
2022 onTap ?: EnsembleAction ;
2123 submitForm ?: boolean ;
2224 startingIcon ?: IconProps ;
@@ -58,10 +60,18 @@ export const Button: React.FC<ButtonProps> = ({ id, onTap, ...rest }) => {
5860 }
5961 } , [ values ?. loading ] ) ;
6062
63+ const label = useMemo ( ( ) => {
64+ const rawLabel = values ?. label ;
65+ if ( ! rawLabel ) return null ;
66+ if ( isString ( rawLabel ) ) return rawLabel ;
67+ return EnsembleRuntime . render ( [ unwrapWidget ( rawLabel ) ] ) ;
68+ } , [ values ?. label ] ) ;
69+
6170 const ButtonComponent = useMemo ( ( ) => {
6271 return (
6372 < AntButton
6473 disabled = { values ?. disabled ?? false }
74+ className = { values ?. styles ?. names }
6575 htmlType = { values ?. submitForm === true ? "submit" : "button" }
6676 loading = { Boolean ( loading ) }
6777 onClick = { onClickCallback }
@@ -82,7 +92,7 @@ export const Button: React.FC<ButtonProps> = ({ id, onTap, ...rest }) => {
8292 < Icon { ...values . startingIcon } />
8393 ) : null }
8494
85- { ! loading && < > { values ?. label } </ > }
95+ { ! loading && < > { label } </ > }
8696
8797 { ! loading && values ?. endingIcon ? (
8898 < Icon { ...values . endingIcon } />
0 commit comments