@web-atoms/web-controls 2.1.74 → 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 { BindableProperty } from "@web-atoms/core/dist/core/BindableProperty";
2
+ import Colors from "@web-atoms/core/dist/core/Colors";
3
+ import XNode from "@web-atoms/core/dist/core/XNode";
4
+ import StyleRule from "@web-atoms/core/dist/style/StyleRule";
5
+ import CSS from "@web-atoms/core/dist/web/styles/CSS";
6
+ import AtomRepeater from "./AtomRepeater";
7
+
8
+ CSS(StyleRule()
9
+ .flexLayout({ inline: true, justifyContent: "flex-start"})
10
+ .flexFlow("wrap"),
11
+ "div[data-checkbox-list=checkbox-list]");
12
+
13
+ CSS(StyleRule()
14
+ .flexLayout({ justifyContent: "flex-start" })
15
+ .marginRight(5)
16
+ .child(StyleRule("span")
17
+ .cursor("pointer")
18
+ )
19
+ .and(StyleRule("[data-selected-item=true]")
20
+ .color(Colors.blue)
21
+ )
22
+ .displayNone("[data-selected-item=true] > i.far")
23
+ .displayNone("[data-selected-item=false] > i.fas")
24
+ , "div[data-item-type=checkbox]");
25
+
26
+ export default class CheckBoxList extends AtomRepeater {
27
+
28
+ @BindableProperty
29
+ public labelPath;
30
+
31
+ protected preCreate(): void {
32
+ super.preCreate();
33
+ this.element.dataset.checkboxList = "checkbox-list";
34
+ this.bindEvent(this.element, "itemClick", (e: CustomEvent) => {
35
+ const s = this.selectedItems;
36
+ if (!s) {
37
+ return;
38
+ }
39
+ const item = e.detail;
40
+ if (s.indexOf(item) === -1) {
41
+ s.add(item);
42
+ this.element.dispatchEvent(new CustomEvent("itemSelect", { detail: item, bubbles: false }));
43
+ } else {
44
+ this.element.dispatchEvent(new CustomEvent("itemDeselect", { detail: item, bubbles: false }));
45
+ s.remove(item);
46
+ }
47
+ });
48
+
49
+ this.itemRenderer = (item) => <div data-item-type="checkbox">
50
+ <i class="far fa-square"/>
51
+ <i class="fas fa-check-square"/>
52
+ <span text={item.label}/>
53
+ </div>;
54
+ }
55
+
56
+ }
@@ -39,6 +39,7 @@ const css = CSS(StyleRule()
39
39
  )
40
40
  )
41
41
  .child(StyleRule(".label")
42
+ .display("flex")
42
43
  .child(StyleRule(".true")
43
44
  .visibility("visible")
44
45
  .color(Colors.red)
@@ -48,24 +49,18 @@ const css = CSS(StyleRule()
48
49
  )
49
50
  .child(StyleRule("i")
50
51
  .cursor("pointer")
51
- .marginLeft(5)
52
+ .marginLeft("auto")
53
+ .color(Colors.lightGreen)
52
54
  )
53
55
  )
54
56
  , "div[data-wa-form-field=wa-form-field]");
55
57
 
56
- const helpCSS = CSS(StyleRule()
57
- .padding(10)
58
- .child(StyleRule(".fad")
59
- .absolutePosition({ top: 5, right: 5 })
60
- )
61
- );
62
-
63
58
  export default function FormField(
64
59
  {
65
60
  label,
66
61
  required,
67
62
  error,
68
- helpIcon = "fad fa-question-circle",
63
+ helpIcon = "fas fa-question-circle",
69
64
  help,
70
65
  helpEventClick,
71
66
  helpTitle,
@@ -82,21 +77,14 @@ export default function FormField(
82
77
  return;
83
78
  }
84
79
 
85
- const cancelToken = new CancelToken();
86
-
87
- class HelpPopup extends AtomControl {
80
+ class HelpPopup extends PopupWindow {
88
81
  protected create(): void {
89
- this.render(<div class={helpCSS}>
90
- <i
91
- class="fad fa-times-circle"
92
- eventClick={() => cancelToken.cancel()}
93
- />
82
+ this.render(<div>
94
83
  { help as any}
95
84
  </div>);
96
85
  }
97
86
  }
98
- const hp = new HelpPopup(app);
99
- PopupService.show(s.element as any, hp.element, { alignment: "centerOfScreen", cancelToken });
87
+ HelpPopup.showWindow({ title : helpTitle ?? "Help" });
100
88
  });
101
89
  }
102
90
 
@@ -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
+ }