@esportsplus/ui 0.21.7 → 0.21.8

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.
@@ -16,6 +16,20 @@ const OMIT_MASK = [
16
16
  'tooltip-content',
17
17
  ];
18
18
  const OMIT_OPTION = ['content'];
19
+ let active = null;
20
+ function set(state, value) {
21
+ state.active = value;
22
+ if (state.active) {
23
+ root.onclick.push(() => state.active = false);
24
+ if (active) {
25
+ active.active = false;
26
+ active = null;
27
+ }
28
+ }
29
+ else if (active === state) {
30
+ active = null;
31
+ }
32
+ }
19
33
  const select = function (attributes, content) {
20
34
  let { option, options, state } = this;
21
35
  return html `
@@ -24,11 +38,10 @@ const select = function (attributes, content) {
24
38
  ${omit(attributes, OMIT_MASK)}
25
39
  ${{
26
40
  onclick: () => {
27
- state.active = !state.active;
28
- state.render = true;
29
- if (state.active) {
30
- root.onclick.push(() => state.active = false);
41
+ if (state.render) {
42
+ set(state, !state.active);
31
43
  }
44
+ state.render = true;
32
45
  }
33
46
  }}
34
47
  >
@@ -69,11 +82,14 @@ const select = function (attributes, content) {
69
82
  return;
70
83
  }
71
84
  let previous = state.selected;
85
+ set(state, false);
72
86
  state.selected = key;
73
- state.active = false;
74
87
  selected[key] = true;
75
88
  selected[previous] = false;
76
89
  },
90
+ onconnect: () => {
91
+ set(state, true);
92
+ },
77
93
  scrollbar: attributes['scrollbar'],
78
94
  'scrollbar-container-content': attributes['scrollbar-container-content']
79
95
  }, keys.map((key) => html `
package/package.json CHANGED
@@ -48,7 +48,7 @@
48
48
  "private": false,
49
49
  "sideEffects": false,
50
50
  "type": "module",
51
- "version": "0.21.7",
51
+ "version": "0.21.8",
52
52
  "scripts": {
53
53
  "build": "run-s build:vite build:ts",
54
54
  "build:ts": "tsc && tsc-alias",
@@ -22,6 +22,26 @@ const OMIT_MASK = [
22
22
  const OMIT_OPTION = ['content'];
23
23
 
24
24
 
25
+ let active: { active: boolean } | null = null;
26
+
27
+
28
+ function set(state: { active: boolean }, value: boolean) {
29
+ state.active = value;
30
+
31
+ if (state.active) {
32
+ root.onclick.push(() => state.active = false);
33
+
34
+ if (active) {
35
+ active.active = false;
36
+ active = null;
37
+ }
38
+ }
39
+ else if (active === state) {
40
+ active = null;
41
+ }
42
+ }
43
+
44
+
25
45
  const select = function(
26
46
  this: {
27
47
  options: { content: unknown } & Attributes;
@@ -49,12 +69,11 @@ const select = function(
49
69
  ${omit(attributes, OMIT_MASK)}
50
70
  ${{
51
71
  onclick: () => {
52
- state.active = !state.active;
53
- state.render = true;
54
-
55
- if (state.active) {
56
- root.onclick.push(() => state.active = false);
72
+ if (state.render) {
73
+ set(state, !state.active);
57
74
  }
75
+
76
+ state.render = true;
58
77
  }
59
78
  }}
60
79
  >
@@ -105,12 +124,15 @@ const select = function(
105
124
 
106
125
  let previous = state.selected;
107
126
 
127
+ set(state, false);
108
128
  state.selected = key;
109
- state.active = false;
110
129
 
111
130
  selected[key] = true;
112
131
  selected[previous] = false;
113
132
  },
133
+ onconnect: () => {
134
+ set(state, true);
135
+ },
114
136
  scrollbar: attributes['scrollbar'],
115
137
  'scrollbar-container-content': attributes['scrollbar-container-content']
116
138
  },