@@ -185,6 +185,42 @@ function createSheet(
185185 return container ;
186186}
187187
188+ function showError ( container : HTMLElement , errorMessage : string ) {
189+ const content = container . querySelector ( ".sheet-content" ) as HTMLElement ;
190+ if ( ! content ) return ;
191+
192+ // Remove existing error if present
193+ const existingError = content . querySelector ( ".error-state" ) ;
194+ if ( existingError ) {
195+ existingError . remove ( ) ;
196+ }
197+
198+ // Create error state element
199+ const errorState = document . createElement ( "div" ) ;
200+ errorState . className =
201+ "error-state flex items-start gap-3 p-4 mt-4 rounded bg-[var(--sl-color-red-low)] border border-[var(--sl-color-red)] text-sm text-[var(--sl-color-text)]" ;
202+ errorState . innerHTML = `
203+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="flex-shrink-0 mt-0.5" style="color: var(--sl-color-red);">
204+ <circle cx="12" cy="12" r="10"/>
205+ <line x1="12" y1="8" x2="12" y2="12"/>
206+ <line x1="12" y1="16" x2="12.01" y2="16"/>
207+ </svg>
208+ <div>
209+ <p>${ errorMessage } </p>
210+ </div>
211+ ` ;
212+
213+ // Insert error after the explanation text
214+ const explanationText = content . querySelector (
215+ ".text-sm.text-\\[var\\(--sl-color-gray-2\\)\\].p-4" ,
216+ ) ;
217+ if ( explanationText && explanationText . nextSibling ) {
218+ content . insertBefore ( errorState , explanationText . nextSibling ) ;
219+ } else {
220+ content . appendChild ( errorState ) ;
221+ }
222+ }
223+
188224function initSheet ( container : HTMLElement ) {
189225 const content = container . querySelector ( ".sheet-content" ) as HTMLElement ;
190226 const closeButton = container . querySelector ( ".sheet-close" ) ;
0 commit comments