@esportsplus/ui 0.0.17 → 0.0.18
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.
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
onclick: ({ active, toggle }: {
|
|
3
|
+
active?: boolean | undefined;
|
|
4
|
+
toggle?: boolean | undefined;
|
|
5
|
+
}) => {
|
|
6
|
+
content: string;
|
|
7
|
+
type: string;
|
|
8
|
+
values: never[];
|
|
9
|
+
};
|
|
2
10
|
onfocus: (active?: boolean) => {
|
|
3
11
|
content: string;
|
|
4
12
|
type: string;
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
+
import events from '@esportsplus/delegated-events';
|
|
3
4
|
import menu from './menu';
|
|
5
|
+
let initialized = false, root = [];
|
|
6
|
+
const onclick = ({ active, toggle }) => {
|
|
7
|
+
if (!initialized) {
|
|
8
|
+
events.register(document.body, 'click', () => {
|
|
9
|
+
if (!root.length) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let deactivate = root.splice(0);
|
|
13
|
+
for (let i = 0, n = deactivate.length; i < n; i++) {
|
|
14
|
+
deactivate[i].active = false;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
initialized = true;
|
|
18
|
+
}
|
|
19
|
+
let state = reactive({
|
|
20
|
+
active: active || false
|
|
21
|
+
});
|
|
22
|
+
return html({
|
|
23
|
+
class: () => {
|
|
24
|
+
return `tooltip ${state.active ? '--active' : ''}`;
|
|
25
|
+
},
|
|
26
|
+
onclick: function (e) {
|
|
27
|
+
let active = true;
|
|
28
|
+
if (toggle && e.target && this.isSameNode(e.target)) {
|
|
29
|
+
active = !state.active;
|
|
30
|
+
}
|
|
31
|
+
state.active = active;
|
|
32
|
+
if (active) {
|
|
33
|
+
root.push(state);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
4
38
|
const onfocus = (active = false) => {
|
|
5
39
|
let state = reactive({ active });
|
|
6
40
|
return html({
|
|
@@ -29,4 +63,4 @@ const onhover = (active = false) => {
|
|
|
29
63
|
}
|
|
30
64
|
});
|
|
31
65
|
};
|
|
32
|
-
export default { onfocus, onhover, menu };
|
|
66
|
+
export default { onclick, onfocus, onhover, menu };
|
package/package.json
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@esportsplus/action": "^0.0.
|
|
4
|
+
"@esportsplus/action": "^0.0.31",
|
|
5
|
+
"@esportsplus/delegated-events": "^0.0.16",
|
|
5
6
|
"@esportsplus/reactivity": "^0.0.18",
|
|
6
7
|
"@esportsplus/template": "^0.0.11",
|
|
7
|
-
"autoprefixer": "^10.4.
|
|
8
|
+
"autoprefixer": "^10.4.13",
|
|
8
9
|
"clean-webpack-plugin": "^4.0.0",
|
|
9
|
-
"css-loader": "^6.7.
|
|
10
|
-
"css-minimizer-webpack-plugin": "^4.
|
|
11
|
-
"cssnano": "^5.1.
|
|
10
|
+
"css-loader": "^6.7.3",
|
|
11
|
+
"css-minimizer-webpack-plugin": "^4.2.2",
|
|
12
|
+
"cssnano": "^5.1.14",
|
|
12
13
|
"glob": "^8.0.3",
|
|
13
|
-
"mini-css-extract-plugin": "^2.
|
|
14
|
+
"mini-css-extract-plugin": "^2.7.2",
|
|
14
15
|
"modern-normalize": "^1.1.0",
|
|
15
16
|
"path-browserify": "^1.0.1",
|
|
16
|
-
"postcss-loader": "^7.0.
|
|
17
|
+
"postcss-loader": "^7.0.2",
|
|
17
18
|
"run-for-every-file": "^1.1.0",
|
|
18
|
-
"sass": "^1.
|
|
19
|
-
"sass-loader": "^13.0
|
|
19
|
+
"sass": "^1.57.1",
|
|
20
|
+
"sass-loader": "^13.2.0",
|
|
20
21
|
"style-loader": "^3.3.1",
|
|
21
|
-
"webpack": "^5.
|
|
22
|
-
"webpack-cli": "^
|
|
22
|
+
"webpack": "^5.75.0",
|
|
23
|
+
"webpack-cli": "^5.0.1"
|
|
23
24
|
},
|
|
24
25
|
"description": "UI",
|
|
25
26
|
"devDependencies": {
|
|
@@ -36,5 +37,5 @@
|
|
|
36
37
|
"prepublishOnly": "npm run build"
|
|
37
38
|
},
|
|
38
39
|
"types": "./build/index.d.ts",
|
|
39
|
-
"version": "0.0.
|
|
40
|
+
"version": "0.0.18"
|
|
40
41
|
}
|
|
@@ -1,8 +1,53 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
+
import events from '@esportsplus/delegated-events';
|
|
3
4
|
import menu from './menu';
|
|
4
5
|
|
|
5
6
|
|
|
7
|
+
let initialized = false,
|
|
8
|
+
root: { active: boolean }[] = [];
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const onclick = ({ active, toggle }: { active?: boolean, toggle?: boolean }) => {
|
|
12
|
+
if (!initialized) {
|
|
13
|
+
events.register(document.body, 'click', () => {
|
|
14
|
+
if (!root.length) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let deactivate = root.splice(0);
|
|
19
|
+
|
|
20
|
+
for (let i = 0, n = deactivate.length; i < n; i++) {
|
|
21
|
+
deactivate[i].active = false;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
initialized = true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let state = reactive({
|
|
28
|
+
active: active || false
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return html({
|
|
32
|
+
class: () => {
|
|
33
|
+
return `tooltip ${state.active ? '--active' : ''}`;
|
|
34
|
+
},
|
|
35
|
+
onclick: function(this: HTMLElement, e: Event) {
|
|
36
|
+
let active = true;
|
|
37
|
+
|
|
38
|
+
if (toggle && e.target && this.isSameNode(e.target as Node)) {
|
|
39
|
+
active = !state.active;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
state.active = active;
|
|
43
|
+
|
|
44
|
+
if (active) {
|
|
45
|
+
root.push(state);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
6
51
|
const onfocus = (active: boolean = false) => {
|
|
7
52
|
let state = reactive({ active });
|
|
8
53
|
|
|
@@ -36,4 +81,4 @@ const onhover = (active: boolean = false) => {
|
|
|
36
81
|
};
|
|
37
82
|
|
|
38
83
|
|
|
39
|
-
export default { onfocus, onhover, menu };
|
|
84
|
+
export default { onclick, onfocus, onhover, menu };
|