@web-atoms/web-controls 2.1.77 → 2.1.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ import Bind from "@web-atoms/core/dist/core/Bind";
2
+ import { BindableProperty } from "@web-atoms/core/dist/core/BindableProperty";
3
+ import Colors from "@web-atoms/core/dist/core/Colors";
4
+ import XNode from "@web-atoms/core/dist/core/XNode";
5
+ import StyleRule from "@web-atoms/core/dist/style/StyleRule";
6
+ import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl";
7
+ import CSS from "@web-atoms/core/dist/web/styles/CSS";
8
+ import AtomRepeater from "./AtomRepeater";
9
+
10
+ CSS(StyleRule()
11
+ .flexLayout({ inline: true, justifyContent: "flex-start"})
12
+ .flexFlow("wrap"),
13
+ "*[data-radio-button-list=radio-button-list]");
14
+
15
+ CSS(StyleRule()
16
+ .flexLayout({ justifyContent: "flex-start" })
17
+ .marginRight(5)
18
+ .child(StyleRule("span")
19
+ .cursor("pointer")
20
+ )
21
+ .and(StyleRule("[data-selected-item=true]")
22
+ .color(Colors.blue)
23
+ )
24
+ .displayNone("[data-selected-item=true] > i.fa-circle")
25
+ .displayNone("[data-selected-item=false] > i.fa-dot-circle")
26
+ , "div[data-item-type=radio]");
27
+
28
+ export default class RadioButtonList extends AtomRepeater {
29
+
30
+ protected preCreate(): void {
31
+ super.preCreate();
32
+ this.valuePath = (item) => item?.value ?? item;
33
+ this.bindEvent(this.element, "itemClick", (e: CustomEvent) => {
34
+ const s = this.selectedItems;
35
+ if (!s) {
36
+ return;
37
+ }
38
+ const item = e.detail;
39
+ const old = this.selectedItem;
40
+ if (old) {
41
+ this.element.dispatchEvent(new CustomEvent("itemDeselect", { detail: old, bubbles: false }));
42
+ }
43
+ this.selectedItem = item;
44
+ this.element.dispatchEvent(new CustomEvent("itemSelect", { detail: item, bubbles: false }));
45
+ });
46
+ this.element.dataset.radioButtonList = "radio-button-list";
47
+ this.itemRenderer = (item) => <div
48
+ data-item-type="radio">
49
+ <i class="far fa-dot-circle"/>
50
+ <i class="far fa-circle"/>
51
+ <span text={item.label}/>
52
+ </div>;
53
+
54
+ }
55
+
56
+ }