1 module uim.bootstrap.bs4.components.forms.customcontrols.select;
2 
3 import uim.bootstrap; 
4 
5 class DBS4CustomSelect : DH5Select {
6 	mixin(H5This!("Select", ["custom-select"]));
7 
8 	mixin(MyContent!("option", "H5Option"));
9 	O options(this O)(string[] values, string selected = "", string disabled = "") {
10 		foreach(value; values) {
11 			if (value == selected) {
12 				if (value == disabled) 	this.option(["selected":"selected", "disabled":"disabled"], value); 
13 				else this.option(["selected":"selected"], value);
14 			}
15 			else if (value == disabled) this.option(["disabled":"disabled"], value);
16 			else this.option(value);
17 		}
18 		return cast(O)this;	
19 	}
20 	O options(this O)(string[string] values, string selectedKey = "", string disabledKey = "") {
21 		foreach(k; values.keys.sort) {
22 			if (k == selectedKey) {
23 				if (k == disabledKey) 	this.option(["selected":"selected", "disabled":"disabled"], k); 
24 				else this.option(["selected":"selected"], k);
25 			}
26 			else if (k == disabledKey) this.option(["disabled":"disabled"], k);
27 			else this.option(["value":k], values[k]);
28 		}
29 		return cast(O)this;	
30 	}
31 	O options(this O)(string[] values, string[] selected, string[] disabled = null) {
32 		foreach(value; values) {
33 			if (selected.has(value)) {
34 				if (disabled.has(value)) 	this.option(["selected":"selected", "disabled":"disabled"], value); 
35 				else this.option(["selected":"selected"], value);
36 			}
37 			else if (disabled.has(value)) this.option(["disabled":"disabled"], value);
38 			else this.option(value);
39 		}
40 		return cast(O)this;	
41 	}
42 	O options(this O)(string[string] values, string[] selectedKeys, string[] disabledKeys = null) {
43 		foreach(k; values.keys.sort) {
44 			if (selectedKeys.has(k)) {
45 				if (disabledKeys.has(k)) this.option(["selected":"selected", "disabled":"disabled"], k); 
46 				else this.option(["selected":"selected"], k);
47 			}
48 			else if (disabledKeys.has(k)) this.option(["disabled":"disabled"], k);
49 			else this.option(["value":k], values[k]);
50 		}
51 		return cast(O)this;	
52 	}
53 }
54 mixin(H5Calls!("BS4CustomSelect"));
55 
56 unittest {
57 	
58 	
59 }