@@ -18,6 +18,7 @@ export interface MainButtonState {
1818 isLoaderVisible : boolean ;
1919 text : string ;
2020 textColor ?: RGB ;
21+ iconCustomEmojiId ?: string ;
2122}
2223
2324export interface MainButtonOptions extends Omit <
@@ -30,6 +31,7 @@ export interface MainButtonOptions extends Omit<
3031 defaults : {
3132 bgColor : MaybeAccessor < RGB > ;
3233 textColor : MaybeAccessor < RGB > ;
34+ iconCustomEmojiId : MaybeAccessor < string > ;
3335 } ;
3436}
3537
@@ -44,6 +46,7 @@ export class MainButton {
4446 isLoaderVisible : false ,
4547 isVisible : false ,
4648 text : 'Continue' ,
49+ iconCustomEmojiId : '' ,
4750 } ,
4851 method : 'web_app_setup_main_button' ,
4952 payload : state => ( {
@@ -54,23 +57,33 @@ export class MainButton {
5457 text : state . text ,
5558 color : state . bgColor ,
5659 text_color : state . textColor ,
60+ icon_custom_emoji_id : state . iconCustomEmojiId ,
5761 } ) ,
5862 } ) ;
5963
60- const withDefault = (
64+ const withDefaultColor = (
6165 field : 'bgColor' | 'textColor' ,
6266 getDefault : MaybeAccessor < RGB > ,
6367 ) => {
6468 const fromState = button . stateGetter ( field ) ;
6569 return computed ( ( ) => fromState ( ) || access ( getDefault ) ) ;
6670 } ;
6771
68- this . bgColor = withDefault ( 'bgColor' , defaults . bgColor ) ;
69- this . textColor = withDefault ( 'textColor' , defaults . textColor ) ;
72+ const withDefault = (
73+ field : 'iconCustomEmojiId' ,
74+ getDefault : MaybeAccessor < string > ,
75+ ) => {
76+ const fromState = button . stateGetter ( field ) ;
77+ return computed ( ( ) => fromState ( ) || access ( getDefault ) ) ;
78+ } ;
79+
80+ this . bgColor = withDefaultColor ( 'bgColor' , defaults . bgColor ) ;
81+ this . textColor = withDefaultColor ( 'textColor' , defaults . textColor ) ;
7082 this . hasShineEffect = button . stateGetter ( 'hasShineEffect' ) ;
7183 this . isEnabled = button . stateGetter ( 'isEnabled' ) ;
7284 this . isLoaderVisible = button . stateGetter ( 'isLoaderVisible' ) ;
7385 this . text = button . stateGetter ( 'text' ) ;
86+ this . iconCustomEmojiId = withDefault ( 'iconCustomEmojiId' , '' ) ;
7487 this . isVisible = button . stateGetter ( 'isVisible' ) ;
7588 this . isMounted = button . isMounted ;
7689 this . state = button . state ;
@@ -91,6 +104,7 @@ export class MainButton {
91104 ] = button . stateBoolSetters ( 'isLoaderVisible' ) ;
92105
93106 [ this . setText , this . setTextFp ] = button . stateSetters ( 'text' ) ;
107+ [ this . setIconCustomEmojiId , this . setIconCustomEmojiIdFp ] = button . stateSetters ( 'iconCustomEmojiId' ) ;
94108 [ [ this . hide , this . hideFp ] , [ this . show , this . showFp ] ] = button . stateBoolSetters ( 'isVisible' ) ;
95109 this . setParams = button . setState ;
96110 this . setParamsFp = button . setStateFp ;
@@ -152,6 +166,12 @@ export class MainButton {
152166 * params colors.
153167 */
154168 readonly textColor : Computed < RGB > ;
169+
170+ /**
171+ * The ID of custom emoji icon displayed alongside button text.
172+ * @since Mini Apps v9.5
173+ */
174+ readonly iconCustomEmojiId : Computed < string > ;
155175 //#endregion
156176
157177 //#region Methods.
@@ -245,6 +265,17 @@ export class MainButton {
245265 */
246266 readonly setText : WithChecks < ( value : string ) => void , false > ;
247267
268+ /**
269+ * Updates the button custom emoji ID.
270+ * @since Mini Apps v9.5
271+ */
272+ readonly setIconCustomEmojiIdFp : WithChecksFp < ( value : string ) => MainButtonEither , false > ;
273+
274+ /**
275+ * @see setIconCustomEmojiIdFp
276+ */
277+ readonly setIconCustomEmojiId : WithChecks < ( value : string ) => void , false > ;
278+
248279 /**
249280 * Shows the button loader.
250281 */
0 commit comments