| 
									
										
										
										
											2025-08-06 11:39:31 +03:00
										 |  |  | import { ComponentChildren } from "preact"; | 
					
						
							|  |  |  | import Icon from "./Icon"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | interface FormListOpts { | 
					
						
							|  |  |  |     children: ComponentChildren; | 
					
						
							|  |  |  |     onSelect?: (value: string) => void; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default function FormList({ children, onSelect }: FormListOpts) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |         <div class="dropdown-menu static show" style={{ | 
					
						
							|  |  |  |             position: "relative" | 
					
						
							|  |  |  |         }} onClick={(e) => { | 
					
						
							|  |  |  |             const value = (e.target as HTMLElement)?.dataset?.value; | 
					
						
							|  |  |  |             if (value && onSelect) { | 
					
						
							|  |  |  |                 onSelect(value); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }}> | 
					
						
							|  |  |  |             {children} | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | interface FormListItemOpts { | 
					
						
							| 
									
										
										
										
											2025-08-06 12:12:37 +03:00
										 |  |  |     children: ComponentChildren; | 
					
						
							| 
									
										
										
										
											2025-08-06 11:39:31 +03:00
										 |  |  |     icon?: string; | 
					
						
							|  |  |  |     value?: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-06 12:12:37 +03:00
										 |  |  | export function FormListItem({ children, icon, value }: FormListItemOpts) { | 
					
						
							| 
									
										
										
										
											2025-08-06 11:39:31 +03:00
										 |  |  |     return ( | 
					
						
							|  |  |  |         <a class="dropdown-item" data-value={value}> | 
					
						
							|  |  |  |             <Icon icon={icon} />  | 
					
						
							| 
									
										
										
										
											2025-08-06 12:12:37 +03:00
										 |  |  |             {children} | 
					
						
							| 
									
										
										
										
											2025-08-06 11:39:31 +03:00
										 |  |  |         </a> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | interface FormListHeaderOpts { | 
					
						
							|  |  |  |     text: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function FormListHeader({ text }: FormListHeaderOpts) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |         <li> | 
					
						
							|  |  |  |             <h6 className="dropdown-header">{text}</h6> | 
					
						
							|  |  |  |         </li> | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | } |