| 
									
										
										
										
											2022-07-05 13:44:36 +02:00
										 |  |  | import * as shops from "./assets/generated/layers/shops.json" | 
					
						
							|  |  |  | import Combine from "./UI/Base/Combine"; | 
					
						
							|  |  |  | import Img from "./UI/Base/Img"; | 
					
						
							|  |  |  | import BaseUIElement from "./UI/BaseUIElement"; | 
					
						
							| 
									
										
										
										
											2022-06-09 02:55:14 +02:00
										 |  |  | import {VariableUiElement} from "./UI/Base/VariableUIElement"; | 
					
						
							| 
									
										
										
										
											2022-07-05 13:44:36 +02:00
										 |  |  | import LanguagePicker from "./UI/LanguagePicker"; | 
					
						
							|  |  |  | import TagRenderingConfig, {Mapping} from "./Models/ThemeConfig/TagRenderingConfig"; | 
					
						
							|  |  |  | import {MappingConfigJson} from "./Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"; | 
					
						
							|  |  |  | import {FixedUiElement} from "./UI/Base/FixedUiElement"; | 
					
						
							|  |  |  | import {TagsFilter} from "./Logic/Tags/TagsFilter"; | 
					
						
							| 
									
										
										
										
											2022-07-10 03:58:07 +02:00
										 |  |  | import {SearchablePillsSelector} from "./UI/Input/SearchableMappingsSelector"; | 
					
						
							|  |  |  | import {UIEventSource} from "./Logic/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2022-07-05 13:44:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const mappingsRaw: MappingConfigJson[] = <any>shops.tagRenderings.find(tr => tr.id == "shop_types").mappings | 
					
						
							|  |  |  | const mappings = mappingsRaw.map((m, i) => TagRenderingConfig.ExtractMapping(m, i, "test", "test")) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function fromMapping(m: Mapping): { show: BaseUIElement, value: TagsFilter, mainTerm: Record<string, string>, searchTerms?: Record<string, string[]> } { | 
					
						
							|  |  |  |     const el: BaseUIElement = m.then | 
					
						
							|  |  |  |     let icon: BaseUIElement | 
					
						
							|  |  |  |     if (m.icon !== undefined) { | 
					
						
							|  |  |  |         icon = new Img(m.icon).SetClass("h-8 w-8 pr-2") | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         icon = new FixedUiElement("").SetClass("h-8 w-1") | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     const show = new Combine([ | 
					
						
							|  |  |  |         icon, | 
					
						
							|  |  |  |         el.SetClass("block-ruby") | 
					
						
							|  |  |  |     ]).SetClass("flex items-center") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return {show, mainTerm: m.then.translations, searchTerms: m.searchTerms, value: m.if}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-07-10 03:58:07 +02:00
										 |  |  | const search = new UIEventSource("") | 
					
						
							|  |  |  | const sp = new SearchablePillsSelector( | 
					
						
							| 
									
										
										
										
											2022-07-05 13:44:36 +02:00
										 |  |  |     mappings.map(m => fromMapping(m)), | 
					
						
							| 
									
										
										
										
											2022-07-10 03:58:07 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         noMatchFound: new VariableUiElement(search.map(s => "Mark this a `"+s+"`")), | 
					
						
							|  |  |  |         onNoSearch: new FixedUiElement("Search in "+mappingsRaw.length+" categories"), | 
					
						
							|  |  |  |         selectIfSingle: true, | 
					
						
							|  |  |  |         searchValue: search | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-06-09 02:55:14 +02:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-05 13:44:36 +02:00
										 |  |  | sp.AttachTo("maindiv") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const lp = new LanguagePicker(["en", "nl"], "") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | new Combine([ | 
					
						
							|  |  |  |     new VariableUiElement(sp.GetValue().map(tf => new FixedUiElement("Selected tags: " + tf.map(tf => tf.asHumanString(false, false, {})).join(", ")))), | 
					
						
							|  |  |  |     lp | 
					
						
							|  |  |  | ]).SetClass("flex flex-col") | 
					
						
							|  |  |  |     .AttachTo("extradiv") |