@ewc-lib/ewc-icon-button-group 3.3.0-alpha → 3.3.2-alpha

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ewc-lib/ewc-icon-button-group",
3
3
  "//": "please always keep version in sync with constructor in main.js",
4
- "version": "3.3.0-alpha",
4
+ "version": "3.3.2-alpha",
5
5
  "basedOnStandard": "3.0.1",
6
6
  "description": "",
7
7
  "main": "src/main.js",
@@ -16,6 +16,6 @@
16
16
  "@ewc-lib/ewc-css-common": "0.1.0"
17
17
  },
18
18
  "dependencies": {
19
- "@ewc-lib/ewc-icon-button": "3.2.0-alpha"
19
+ "@ewc-lib/ewc-icon-button": "3.4.1-alpha"
20
20
  }
21
21
  }
package/readme.md CHANGED
@@ -35,7 +35,7 @@ Within a button-group, only buttons that are not currently pressed and not disab
35
35
  |----------------|-----------------------|---------------------|---------|------------
36
36
  | selectedIndex | selectedIndex | Number | 0 | The 0-based ordinal number of the button pressed.
37
37
  | selectedId | selectedId | Number | - | The id of the button pressed. Can be null if the id attribute is not set.
38
- | breakpoint | breakpoint | CSS String | 650px | if viewport width is smaller than this, the buttons are displayed without label.
38
+ | breakpoint | breakpoint | Number | 480 | a unitless number, interpreted as pixel. if viewport width is smaller than this, the buttons are displayed without label.
39
39
  | selectedElement| | HTML element | - | The HTML element currently selected. Read only.
40
40
 
41
41
 
@@ -182,6 +182,9 @@ European Union Public License (EUPL)
182
182
 
183
183
  # Changelog
184
184
 
185
+ - 3.3.1-alpha
186
+ - when label is shown (depending on breakpoint), don't show tooltip
187
+
185
188
  - 3.3.0-alpha
186
189
  - udate dependency, tooltip
187
190
 
package/src/main.js CHANGED
@@ -18,6 +18,8 @@ class Element extends HTMLElement {
18
18
  #cssClassPrefix = "css-scope-"+ (Math.random() + 1).toString(36).substring(2)
19
19
  #isInitialised = false
20
20
  #buttonGroup = new ButtonGroup()
21
+ #resizeDebounceTimer = null
22
+ #breakpoint = "480" // px assumed
21
23
 
22
24
  getAttr(name, _default) {
23
25
  const r = this.hasAttribute(name) ? this.getAttribute(name) : _default
@@ -29,11 +31,12 @@ class Element extends HTMLElement {
29
31
  }
30
32
 
31
33
  connectedCallback() {
32
- this.setAttribute("ewc-version", "3.3.0-alpha") // please always keep in sync with version in package.json
34
+ this.setAttribute("ewc-version", "3.3.1-alpha") // please always keep in sync with version in package.json
33
35
  if(this.#isInitialised == true) {return}
34
36
 
35
37
  this.classList.add(this.#cssClassPrefix)
36
- this.appendChild(CSS(this.#cssClassPrefix, this.getAttr("breakpoint","480px")).cloneNode(true)) // .ecl-col-s- in ECL 4.8.1.
38
+ this.#breakpoint = this.getAttr("breakpoint","480")
39
+ this.appendChild(CSS(this.#cssClassPrefix, this.#breakpoint+"px").cloneNode(true)) // .ecl-col-s- in ECL 4.8.1.
37
40
 
38
41
  const nodes = this.querySelectorAll("ewc-icon-button")
39
42
  this.#setAttributes(nodes)
@@ -171,6 +174,23 @@ class Element extends HTMLElement {
171
174
  }.bind(this))
172
175
  }
173
176
 
177
+ #installResizeEventHandler(nodes) {
178
+
179
+ const setTooltips = function () {
180
+ for(let i=0;i<nodes.length;i++) {
181
+ const w = window.innerWidth<Number(this.#breakpoint)
182
+ nodes[i].setAttribute("tooltip-suppressed", w?"false":"true")
183
+ }
184
+ }.bind(this)
185
+
186
+ window.addEventListener('resize', function(ev) {
187
+ clearTimeout(this.#resizeDebounceTimer)
188
+ this.#resizeDebounceTimer = setTimeout(setTooltips, 200)
189
+ }.bind(this))
190
+
191
+ setTooltips()
192
+ }
193
+
174
194
  #setAttributes(nodes) {
175
195
  for(let i=0;i<nodes.length;i++) {
176
196
  nodes[i].setAttribute("__index", i) // assign 0-based ordinal number to each button
@@ -181,6 +201,7 @@ class Element extends HTMLElement {
181
201
  #installEventHandlers(nodes) {
182
202
  this.#installActionEventHandler(nodes)
183
203
  this.#installArrowKeyEventHandler(nodes)
204
+ this.#installResizeEventHandler(nodes)
184
205
  }
185
206
 
186
207
  }
@@ -30,10 +30,20 @@
30
30
  <script src="./ewc-icon-button-group/src/main.js" type="module"></script>
31
31
 
32
32
  <div id="container">
33
+ <form>
34
+ <fieldset id="tooltippos" style="display:flex; gap:15px;">
35
+ <legend>Tooltip position</legend>
36
+ <label> <input type="radio" id="top" name="tt">top</label>
37
+ <label> <input type="radio" id="right" name="tt">right</label>
38
+ <label> <input type="radio" id="bottom" name="tt" checked="checked">bottom (default)</label>
39
+ <label> <input type="radio" id="left" name="tt">left</label>
40
+ </fieldset>
41
+ </form>
42
+
33
43
  <p class="pa">Buttons available; on light, dark and blue background</p>
34
44
 
35
45
  <div style="margin:20px; padding:20px;">
36
- <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800px" id="lightEnabled">
46
+ <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800" id="lightEnabled">
37
47
  <ewc-icon-button icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart"></ewc-icon-button>
38
48
  <ewc-icon-button icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart"></ewc-icon-button>
39
49
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot"></ewc-icon-button>
@@ -42,7 +52,7 @@
42
52
  </div>
43
53
 
44
54
  <div style="margin:20px; padding:20px; background: black;">
45
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="darkEnabled">
55
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="darkEnabled">
46
56
  <ewc-icon-button icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
47
57
  <ewc-icon-button icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
48
58
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -51,7 +61,7 @@
51
61
  </div>
52
62
 
53
63
  <div style="margin:20px; padding:20px; background: var(--c-p-140);">
54
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="blueEnabled">
64
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="blueEnabled">
55
65
  <ewc-icon-button icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
56
66
  <ewc-icon-button icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
57
67
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -62,7 +72,7 @@
62
72
  <p class="pa">Disabled buttons</p>
63
73
 
64
74
  <div style="margin:20px; padding:20px;">
65
- <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800px" id="lightDisabled">
75
+ <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800" id="lightDisabled">
66
76
  <ewc-icon-button state="disabled" icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart"></ewc-icon-button>
67
77
  <ewc-icon-button state="disabled" icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart"></ewc-icon-button>
68
78
  <ewc-icon-button state="disabled" icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot"></ewc-icon-button>
@@ -71,7 +81,7 @@
71
81
  </div>
72
82
 
73
83
  <div style="margin:20px; padding:20px; background: black;">
74
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="darkDisabled">
84
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="darkDisabled">
75
85
  <ewc-icon-button state="disabled" icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
76
86
  <ewc-icon-button state="disabled" icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
77
87
  <ewc-icon-button state="disabled" icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -80,7 +90,7 @@
80
90
  </div>
81
91
 
82
92
  <div style="margin:20px; padding:20px; background: var(--c-p-140);">
83
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="blueDisabled">
93
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="blueDisabled">
84
94
  <ewc-icon-button state="disabled" icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
85
95
  <ewc-icon-button state="disabled" icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
86
96
  <ewc-icon-button state="disabled" icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -131,7 +141,7 @@
131
141
  </p>
132
142
 
133
143
  <div style="margin:20px; padding:20px;">
134
- <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedId="grp1-table" breakpoint="800px" id="ForDevelopers">
144
+ <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedId="grp1-table" breakpoint="800" id="ForDevelopers">
135
145
  <ewc-icon-button icon="linechart" use-config="grp-linechart" label="Line chart" btn-aria-label="Line chart" id="grp1-line"></ewc-icon-button>
136
146
  <ewc-icon-button icon="barchart" use-config="grp-barchart" label="Bar chart" btn-aria-label="Bar chart" id="grp1-bar"></ewc-icon-button>
137
147
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" label="Dot plot" btn-aria-label="Dot plot" id="grp1-dot"></ewc-icon-button>
@@ -197,6 +207,13 @@
197
207
  group.selectedIndex = toSet ? 0 : -1
198
208
  })
199
209
 
210
+
211
+ document.getElementById("tooltippos").addEventListener("change", (e) => {
212
+ document.querySelectorAll("ewc-icon-button").forEach(el => {
213
+ el.setAttribute("tooltip-pos",e.target.id)
214
+ })
215
+ })
216
+
200
217
  })
201
218
  </script>
202
219
 
@@ -26,14 +26,22 @@
26
26
  </head>
27
27
 
28
28
  <body>
29
- <script src="./ewc-icon-button/src/main.js" type="module"></script>
30
- <script src="./ewc-icon-button-group/src/main.js" type="module"></script>
31
29
 
32
30
  <div id="container">
31
+ <form>
32
+ <fieldset id="tooltippos" style="display:flex; gap:15px;">
33
+ <legend>Tooltip position</legend>
34
+ <label> <input type="radio" id="top" name="tt">top</label>
35
+ <label> <input type="radio" id="right" name="tt">right</label>
36
+ <label> <input type="radio" id="bottom" name="tt" checked="checked">bottom (default)</label>
37
+ <label> <input type="radio" id="left" name="tt">left</label>
38
+ </fieldset>
39
+ </form>
40
+
33
41
  <p class="pa">Buttons available; on light, dark and blue background</p>
34
42
 
35
43
  <div style="margin:20px; padding:20px;">
36
- <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800px" id="lightEnabled">
44
+ <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800" id="lightEnabled">
37
45
  <ewc-icon-button icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart"></ewc-icon-button>
38
46
  <ewc-icon-button icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart"></ewc-icon-button>
39
47
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot"></ewc-icon-button>
@@ -42,7 +50,7 @@
42
50
  </div>
43
51
 
44
52
  <div style="margin:20px; padding:20px; background: black;">
45
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="darkEnabled">
53
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="darkEnabled">
46
54
  <ewc-icon-button icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
47
55
  <ewc-icon-button icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
48
56
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -51,7 +59,7 @@
51
59
  </div>
52
60
 
53
61
  <div style="margin:20px; padding:20px; background: var(--c-p-140);">
54
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="blueEnabled">
62
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="blueEnabled">
55
63
  <ewc-icon-button icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
56
64
  <ewc-icon-button icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
57
65
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -62,7 +70,7 @@
62
70
  <p class="pa">Disabled buttons</p>
63
71
 
64
72
  <div style="margin:20px; padding:20px;">
65
- <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800px" id="lightDisabled">
73
+ <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedIndex="0" breakpoint="800" id="lightDisabled">
66
74
  <ewc-icon-button state="disabled" icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart"></ewc-icon-button>
67
75
  <ewc-icon-button state="disabled" icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart"></ewc-icon-button>
68
76
  <ewc-icon-button state="disabled" icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot"></ewc-icon-button>
@@ -71,7 +79,7 @@
71
79
  </div>
72
80
 
73
81
  <div style="margin:20px; padding:20px; background: black;">
74
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="darkDisabled">
82
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="darkDisabled">
75
83
  <ewc-icon-button state="disabled" icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
76
84
  <ewc-icon-button state="disabled" icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
77
85
  <ewc-icon-button state="disabled" icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -80,7 +88,7 @@
80
88
  </div>
81
89
 
82
90
  <div style="margin:20px; padding:20px; background: var(--c-p-140);">
83
- <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800px" id="blueDisabled">
91
+ <ewc-icon-button-group style="width:600px;" selectedIndex="3" breakpoint="800" id="blueDisabled">
84
92
  <ewc-icon-button state="disabled" icon="linechart" use-config="grp-linechart" btn-aria-label="Line chart" title="Line chart" label="Line chart" btn-aria-label="Line chart" background="dark"></ewc-icon-button>
85
93
  <ewc-icon-button state="disabled" icon="barchart" use-config="grp-barchart" btn-aria-label="Bar chart" title="Bar chart" label="Bar chart" btn-aria-label="Bar chart" background="dark"></ewc-icon-button>
86
94
  <ewc-icon-button state="disabled" icon="dotplot" use-config="grp-dotplot" btn-aria-label="Dotplot" title="Dotplot" label="Dotplot" btn-aria-label="Dotplot" background="dark"></ewc-icon-button>
@@ -89,33 +97,6 @@
89
97
  </div>
90
98
 
91
99
 
92
- <script>
93
- window.addEventListener('DOMContentLoaded',function () {
94
-
95
- // catch events of all buttons at once
96
- document.getElementById("lightEnabled").addEventListener("action",(e)=>{
97
- document.getElementById("lightEnabled").setAttribute("selectedIndex",e.detail.index)
98
- const el = document.getElementById("lightEnabled").selectedElement
99
- console.log("button clicked or selected w/ kdb: ", e.detail, el)
100
- })
101
-
102
- document.getElementById("darkEnabled").addEventListener("action",(e)=>{
103
- document.getElementById("darkEnabled").setAttribute("selectedIndex",e.detail.index)
104
- const el = document.getElementById("darkEnabled").selectedElement
105
- console.log("button clicked or selected w/ kdb: ", e.detail, el)
106
- })
107
-
108
- document.getElementById("blueEnabled").addEventListener("action",(e)=>{
109
- document.getElementById("blueEnabled").setAttribute("selectedIndex",e.detail.index)
110
- const el = document.getElementById("darkEnabled").selectedElement
111
- console.log("button clicked or selected w/ kdb: ", e.detail, el)
112
- })
113
-
114
- })
115
- </script>
116
-
117
-
118
-
119
100
 
120
101
  <details>
121
102
  <summary>Click to see more detailled information intended for developers</summary>
@@ -131,7 +112,7 @@
131
112
  </p>
132
113
 
133
114
  <div style="margin:20px; padding:20px;">
134
- <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedId="grp1-table" breakpoint="800px" id="ForDevelopers">
115
+ <ewc-icon-button-group style="width:600px; padding-right:10px;" selectedId="grp1-table" breakpoint="800" id="ForDevelopers">
135
116
  <ewc-icon-button icon="linechart" use-config="grp-linechart" label="Line chart" btn-aria-label="Line chart" id="grp1-line"></ewc-icon-button>
136
117
  <ewc-icon-button icon="barchart" use-config="grp-barchart" label="Bar chart" btn-aria-label="Bar chart" id="grp1-bar"></ewc-icon-button>
137
118
  <ewc-icon-button icon="dotplot" use-config="grp-dotplot" label="Dot plot" btn-aria-label="Dot plot" id="grp1-dot"></ewc-icon-button>
@@ -143,6 +124,7 @@
143
124
  </div>
144
125
  </div>
145
126
 
127
+
146
128
  </details>
147
129
 
148
130
  </div>
@@ -78,4 +78,11 @@ window.addEventListener('DOMContentLoaded',function () {
78
78
  group.selectedIndex = toSet ? 0 : -1
79
79
  })
80
80
 
81
+
82
+ document.getElementById("tooltippos").addEventListener("change", (e) => {
83
+ document.querySelectorAll("ewc-icon-button").forEach(el => {
84
+ el.setAttribute("tooltip-pos",e.target.id)
85
+ })
86
+ })
87
+
81
88
  })
package/src/element.js DELETED
File without changes