@@ -130,40 +130,80 @@ function initializeWidgets() {
130130 const htmlElement = element as HTMLElement ;
131131 const props : any = { } ;
132132
133+ // Note: Event handlers (onVoiceStart, onVoiceEnd, onMessage, onError) and their deprecated versions
134+ // cannot be passed via HTML attributes. They must be set programmatically or via React props.
133135 const attributeMap : Record < string , string > = {
136+ // Mode & Theme
134137 mode : 'mode' ,
135138 theme : 'theme' ,
136- radius : 'radius' ,
137- size : 'size' ,
139+
140+ // Layout & Position
138141 position : 'position' ,
139- title : 'title' ,
142+ size : 'size' ,
143+ 'border-radius' : 'borderRadius' ,
144+ radius : 'radius' , // deprecated alias
145+
146+ // Colors
140147 'base-bg-color' : 'baseBgColor' ,
141148 'accent-color' : 'accentColor' ,
142149 'cta-button-color' : 'ctaButtonColor' ,
143150 'cta-button-text-color' : 'ctaButtonTextColor' ,
151+
152+ // Text & Labels
153+ title : 'title' ,
154+ 'cta-title' : 'ctaTitle' ,
155+ 'cta-subtitle' : 'ctaSubtitle' ,
144156 'start-button-text' : 'startButtonText' ,
145157 'end-button-text' : 'endButtonText' ,
158+
159+ // Empty State Messages
146160 'voice-empty-message' : 'voiceEmptyMessage' ,
147161 'voice-active-empty-message' : 'voiceActiveEmptyMessage' ,
148162 'chat-empty-message' : 'chatEmptyMessage' ,
149163 'hybrid-empty-message' : 'hybridEmptyMessage' ,
164+
165+ // Chat Configuration
150166 'chat-first-message' : 'chatFirstMessage' ,
151167 'chat-placeholder' : 'chatPlaceholder' ,
168+
169+ // Voice Configuration
152170 'voice-show-transcript' : 'voiceShowTranscript' ,
171+
172+ // Consent Configuration
153173 'consent-required' : 'consentRequired' ,
154174 'consent-title' : 'consentTitle' ,
155175 'consent-content' : 'consentContent' ,
156176 'consent-storage-key' : 'consentStorageKey' ,
177+
178+ // API Configuration
179+ 'api-url' : 'apiUrl' ,
180+
157181 // Vapi Configuration
158182 'public-key' : 'publicKey' ,
159183 'assistant-id' : 'assistantId' ,
160184 'assistant-overrides' : 'assistantOverrides' ,
161185 assistant : 'assistant' ,
186+
187+ // Deprecated properties
188+ 'base-color' : 'baseColor' ,
189+ 'button-base-color' : 'buttonBaseColor' ,
190+ 'button-accent-color' : 'buttonAccentColor' ,
191+ 'main-label' : 'mainLabel' ,
192+ 'empty-voice-message' : 'emptyVoiceMessage' ,
193+ 'empty-voice-active-message' : 'emptyVoiceActiveMessage' ,
194+ 'empty-chat-message' : 'emptyChatMessage' ,
195+ 'empty-hybrid-message' : 'emptyHybridMessage' ,
196+ 'first-chat-message' : 'firstChatMessage' ,
197+ 'show-transcript' : 'showTranscript' ,
198+ 'require-consent' : 'requireConsent' ,
199+ 'terms-content' : 'termsContent' ,
200+ 'local-storage-key' : 'localStorageKey' ,
162201 } ;
163202
164203 Object . entries ( attributeMap ) . forEach ( ( [ htmlAttr , propName ] ) => {
165204 const value = htmlElement . getAttribute ( htmlAttr ) ;
166205 if ( value !== null ) {
206+ // Special handling for JSON attributes
167207 if ( propName === 'assistantOverrides' || propName === 'assistant' ) {
168208 try {
169209 props [ propName ] = JSON . parse ( value ) ;
0 commit comments