@@ -18,19 +18,32 @@ import { stateComp } from "comps/generators/simpleGenerators";
1818import { isEqual } from "lodash" ;
1919import { createGlobalStyle } from "styled-components" ;
2020
21- // Dynamic global styles for toast notifications - scoped by unique instance ID
22- // Using high specificity selectors to override Ant Design's default styles
21+
2322const ToastGlobalStyle = createGlobalStyle < {
2423 $instanceId : string ;
2524 $background ?: string ;
2625 $textColor ?: string ;
2726 $border ?: string ;
27+ $borderWidth ?: string ;
28+ $borderStyle ?: string ;
29+ $radius ?: string ;
30+ $margin ?: string ;
31+ $padding ?: string ;
32+ $width ?: string ;
2833} > `
29- .ant-notification .ant-notification-notice-wrapper .ant-notification-notice. lowcoder-toast-${ props => props . $instanceId } {
34+ .ant-notification .ant-notification-notice-wrapper:has(. lowcoder-toast-${ props => props . $instanceId } ) {
3035 background: ${ props => props . $background || 'inherit' } ;
31- border: ${ props => props . $border && props . $border !== 'transparent'
32- ? `1px solid ${ props . $border } `
33- : 'none' } ;
36+ border-color: ${ props => props . $border || 'transparent' } ;
37+ border-width: ${ props => props . $borderWidth || '0' } ;
38+ border-style: ${ props => props . $borderStyle || 'solid' } ;
39+ border-radius: ${ props => props . $radius || '8px' } ;
40+ ${ props => props . $margin ? `margin: ${ props . $margin } ;` : '' }
41+ ${ props => props . $width ? `width: ${ props . $width } ;` : '' }
42+ ${ props => props . $padding ? `padding: ${ props . $padding } ;` : '' }
43+
44+ .ant-notification-notice {
45+ background: transparent;
46+ }
3447
3548 .ant-notification-notice-message,
3649 .ant-notification-notice-description {
@@ -47,21 +60,18 @@ const toastTypeOptions = [
4760 { label : trans ( "toastComp.typeError" ) , value : "error" } ,
4861] as const ;
4962
50- // Placement options for notification position
5163const placementOptions = [
5264 { label : trans ( "toastComp.placementTopLeft" ) , value : "topLeft" } ,
5365 { label : trans ( "toastComp.placementTopRight" ) , value : "topRight" } ,
5466 { label : trans ( "toastComp.placementBottomLeft" ) , value : "bottomLeft" } ,
5567 { label : trans ( "toastComp.placementBottomRight" ) , value : "bottomRight" } ,
5668] as const ;
5769
58- // Event options for toast
5970const ToastEventOptions = [
6071 { label : trans ( "toastComp.click" ) , value : "click" , description : trans ( "toastComp.clickDesc" ) } ,
6172 { label : trans ( "toastComp.close" ) , value : "close" , description : trans ( "toastComp.closeDesc" ) } ,
6273] as const ;
6374
64- // Method parameters for programmatic API
6575const showParams : ParamsConfig = [
6676 { name : "text" , type : "string" } ,
6777 { name : "options" , type : "JSON" } ,
@@ -87,6 +97,9 @@ const childrenMap = {
8797 showProgress : withDefault ( BoolControl , false ) ,
8898 pauseOnHover : withDefault ( BoolControl , true ) ,
8999
100+ // Layout
101+ width : withDefault ( StringControl , "" ) ,
102+
90103 // Event handlers
91104 onEvent : eventHandlerControl ( ToastEventOptions ) ,
92105
@@ -96,6 +109,11 @@ const childrenMap = {
96109 background : "" ,
97110 color : "" ,
98111 border : "" ,
112+ radius : "" ,
113+ borderWidth : "" ,
114+ borderStyle : "" ,
115+ margin : "" ,
116+ padding : "" ,
99117 } ) ,
100118
101119 // Internal state for tracking visibility
@@ -242,6 +260,14 @@ const ToastPropertyView = React.memo((props: { comp: any }) => {
242260 } ) }
243261 </ Section >
244262
263+ < Section name = { sectionNames . layout } >
264+ { comp . children . width . propertyView ( {
265+ label : trans ( "toastComp.width" ) ,
266+ tooltip : trans ( "toastComp.widthTooltip" ) ,
267+ placeholder : "384" ,
268+ } ) }
269+ </ Section >
270+
245271 < Section name = { sectionNames . interaction } >
246272 { comp . children . onEvent . getPropertyView ( ) }
247273 </ Section >
@@ -256,14 +282,12 @@ const ToastPropertyView = React.memo((props: { comp: any }) => {
256282ToastPropertyView . displayName = "ToastPropertyView" ;
257283
258284/**
259- * Toast runtime view:
260- * - Resolves theme-dependent style values and stores them in `resolvedStyle`
261- * - Generates unique instance ID for scoped styling
262- * - Injects global styles scoped to this toast instance
285+ * Toast runtime view
263286 */
264287const ToastRuntimeView = React . memo ( ( props : { comp : any } ) => {
265288 const { comp } = props ;
266289 const style = comp . children . style . getView ( ) as NotificationStyleType ;
290+ const width = comp . children . width . getView ( ) as string ;
267291 const instanceId = useId ( ) . replace ( / : / g, '-' ) ;
268292
269293 // Store instance ID and resolved styles
@@ -284,6 +308,12 @@ const ToastRuntimeView = React.memo((props: { comp: any }) => {
284308 $background = { style . background }
285309 $textColor = { style . color }
286310 $border = { style . border }
311+ $borderWidth = { style . borderWidth }
312+ $borderStyle = { style . borderStyle }
313+ $radius = { style . radius }
314+ $margin = { style . margin }
315+ $padding = { style . padding || '20px' }
316+ $width = { width ? `${ width } px` : undefined }
287317 />
288318 ) ;
289319} ) ;
@@ -307,6 +337,7 @@ let ToastCompWithExposing = withExposingConfigs(ToastCompBase, [
307337 new NameConfig ( "type" , trans ( "toastComp.typeDesc" ) ) ,
308338 new NameConfig ( "duration" , trans ( "toastComp.durationDesc" ) ) ,
309339 new NameConfig ( "placement" , trans ( "toastComp.placementDesc" ) ) ,
340+ new NameConfig ( "width" , trans ( "toastComp.widthDesc" ) ) ,
310341] ) ;
311342
312343// Add method exposing
0 commit comments