@esportsplus/ui 0.12.1 → 0.13.1
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/build/components/field/index.d.ts +4 -2
- package/build/components/field/select.d.ts +3 -2
- package/build/components/field/select.js +31 -38
- package/build/components/index.d.ts +2 -2
- package/build/components/index.js +2 -2
- package/build/components/magnet/index.js +10 -6
- package/build/components/modal/index.d.ts +3 -0
- package/build/components/modal/index.js +9 -0
- package/build/components/scrollbar/index.d.ts +3 -12
- package/build/components/scrollbar/index.js +21 -22
- package/build/components/sidebar/index.d.ts +3 -0
- package/build/components/sidebar/index.js +9 -0
- package/build/components/site/index.d.ts +1 -6
- package/build/components/site/index.js +9 -13
- package/build/components/tooltip/index.d.ts +5 -18
- package/build/components/tooltip/index.js +56 -42
- package/package.json +1 -1
- package/src/components/field/select.ts +50 -57
- package/src/components/index.ts +2 -2
- package/src/components/magnet/index.ts +10 -6
- package/src/components/modal/index.ts +14 -1
- package/src/components/scrollbar/index.ts +24 -26
- package/src/components/sidebar/index.ts +14 -1
- package/src/components/site/index.ts +9 -18
- package/src/components/tooltip/index.ts +43 -25
|
@@ -55,9 +55,11 @@ declare const _default: {
|
|
|
55
55
|
text?: Record<string, unknown>;
|
|
56
56
|
title?: unknown;
|
|
57
57
|
tooltip?: {
|
|
58
|
-
|
|
58
|
+
content?: Record<string, unknown>;
|
|
59
59
|
} & Record<string, unknown>;
|
|
60
|
-
} & Record<string, unknown>
|
|
60
|
+
} & Record<string, unknown> & {
|
|
61
|
+
scrollbar?: Record<string, unknown>;
|
|
62
|
+
}) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
61
63
|
switch: (data: Parameters<typeof checkbox>[0]) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
62
64
|
textarea: (data: Parameters<typeof text>[0]) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
63
65
|
text: (data: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import scrollbar from '../../components/scrollbar/index.js';
|
|
1
2
|
type Data<T extends Record<number | string, number | string>> = {
|
|
2
3
|
class?: string;
|
|
3
4
|
content?: unknown;
|
|
@@ -15,8 +16,8 @@ type Data<T extends Record<number | string, number | string>> = {
|
|
|
15
16
|
text?: Record<string, unknown>;
|
|
16
17
|
title?: unknown;
|
|
17
18
|
tooltip?: {
|
|
18
|
-
|
|
19
|
+
content?: Record<string, unknown>;
|
|
19
20
|
} & Record<string, unknown>;
|
|
20
|
-
} & Record<string, unknown>;
|
|
21
|
+
} & Parameters<typeof scrollbar>[0] & Record<string, unknown>;
|
|
21
22
|
declare const _default: <T extends Record<number | string, number | string>>(data: Data<T>) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
22
23
|
export default _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
3
|
+
import { isArray, omit } from '@esportsplus/utilities';
|
|
4
4
|
import form from '../../components/form/index.js';
|
|
5
|
-
import scrollbar from '../../components/scrollbar/index.js';
|
|
6
5
|
import root from '../../components/root/index.js';
|
|
6
|
+
import scrollbar from '../../components/scrollbar/index.js';
|
|
7
7
|
import description from './description.js';
|
|
8
8
|
import error from './error.js';
|
|
9
9
|
import title from './title.js';
|
|
@@ -18,7 +18,6 @@ const FIELD_OMIT = [
|
|
|
18
18
|
'selected', 'scrollbar',
|
|
19
19
|
'tag', 'text', 'title', 'tooltip'
|
|
20
20
|
];
|
|
21
|
-
const TOOLTIP_OMIT = ['direction'];
|
|
22
21
|
function parse(keys, selected) {
|
|
23
22
|
let options = {};
|
|
24
23
|
for (let key of keys) {
|
|
@@ -32,22 +31,20 @@ function parse(keys, selected) {
|
|
|
32
31
|
}
|
|
33
32
|
function template(data, state) {
|
|
34
33
|
data.scrollbar ??= {};
|
|
35
|
-
data.scrollbar.style
|
|
34
|
+
data.scrollbar.style ??= '--background-default: var(--color-black-400);';
|
|
36
35
|
data.tooltip ??= {};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
let content = data.tooltip.content ??= {};
|
|
37
|
+
if (isArray(content.class)) {
|
|
38
|
+
content.class.push('tooltip-content tooltip-content--s --flex-column --width-full');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
content.class = [content.class, 'tooltip-content tooltip-content--s --flex-column --width-full'];
|
|
42
|
+
}
|
|
43
|
+
content.scrollbar = data.scrollbar;
|
|
44
|
+
return scrollbar(content, html `
|
|
44
45
|
<div
|
|
45
|
-
class='
|
|
46
|
-
${
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
class='row --flex-column'
|
|
50
|
-
onclick='${(e) => {
|
|
46
|
+
class='row --flex-column'
|
|
47
|
+
onclick='${(e) => {
|
|
51
48
|
let key = e?.target?.dataset?.key;
|
|
52
49
|
if (key === undefined) {
|
|
53
50
|
return;
|
|
@@ -60,28 +57,24 @@ function template(data, state) {
|
|
|
60
57
|
data.effect(key);
|
|
61
58
|
}
|
|
62
59
|
}}'
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
`)}
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
${h}
|
|
60
|
+
>
|
|
61
|
+
${Object.keys(data.options || {}).map((key) => html `
|
|
62
|
+
<div
|
|
63
|
+
class='
|
|
64
|
+
${() => state.options[key] && '--active'}
|
|
65
|
+
link
|
|
66
|
+
--flex-vertical
|
|
67
|
+
'
|
|
68
|
+
data-key='${key}'
|
|
69
|
+
${data.option}
|
|
70
|
+
>
|
|
71
|
+
<span class='--text-truncate'>
|
|
72
|
+
${data.options[key]}
|
|
73
|
+
</span>
|
|
74
|
+
</div>
|
|
75
|
+
`)}
|
|
83
76
|
</div>
|
|
84
|
-
|
|
77
|
+
`);
|
|
85
78
|
}
|
|
86
79
|
export default (data) => {
|
|
87
80
|
let state = reactive(Object.assign({
|
|
@@ -16,13 +16,13 @@ export * as frame from './frame/index.js';
|
|
|
16
16
|
export * as grid from './grid/index.js';
|
|
17
17
|
export * as group from './group/index.js';
|
|
18
18
|
export { default as highlight } from './highlight/index.js';
|
|
19
|
-
export
|
|
19
|
+
export { default as icon } from './icon/index.js';
|
|
20
20
|
export { default as json } from './json/index.js';
|
|
21
21
|
export { default as link } from './link/index.js';
|
|
22
22
|
export * as loader from './loader/index.js';
|
|
23
23
|
export { default as loading } from './loading/index.js';
|
|
24
24
|
export { default as magnet } from './magnet/index.js';
|
|
25
|
-
export
|
|
25
|
+
export { default as modal } from './modal/index.js';
|
|
26
26
|
export { default as number } from './number/index.js';
|
|
27
27
|
export { default as page } from './page/index.js';
|
|
28
28
|
export { default as root } from './root/index.js';
|
|
@@ -16,13 +16,13 @@ export * as frame from './frame/index.js';
|
|
|
16
16
|
export * as grid from './grid/index.js';
|
|
17
17
|
export * as group from './group/index.js';
|
|
18
18
|
export { default as highlight } from './highlight/index.js';
|
|
19
|
-
export
|
|
19
|
+
export { default as icon } from './icon/index.js';
|
|
20
20
|
export { default as json } from './json/index.js';
|
|
21
21
|
export { default as link } from './link/index.js';
|
|
22
22
|
export * as loader from './loader/index.js';
|
|
23
23
|
export { default as loading } from './loading/index.js';
|
|
24
24
|
export { default as magnet } from './magnet/index.js';
|
|
25
|
-
export
|
|
25
|
+
export { default as modal } from './modal/index.js';
|
|
26
26
|
export { default as number } from './number/index.js';
|
|
27
27
|
export { default as page } from './page/index.js';
|
|
28
28
|
export { default as root } from './root/index.js';
|
|
@@ -33,12 +33,16 @@ export default ({ attributes, hide }) => {
|
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
html: html `
|
|
36
|
-
<div
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
<div
|
|
37
|
+
class='magnet'
|
|
38
|
+
style='${() => `
|
|
39
|
+
height: ${state.height ? `${state.height}px` : '100%'};
|
|
40
|
+
opacity: ${state.opacity};
|
|
41
|
+
transform: translate(${state.left}px, ${state.top}px);
|
|
42
|
+
width: ${state.width}px;
|
|
43
|
+
`}'
|
|
44
|
+
${attributes}
|
|
45
|
+
></div>
|
|
42
46
|
`,
|
|
43
47
|
sibling: {
|
|
44
48
|
attributes: events
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
|
+
import scrollbar from '../../components/scrollbar/index.js';
|
|
1
3
|
import './scss/index.scss';
|
|
4
|
+
export default (data, content) => {
|
|
5
|
+
if (!isArray(data.class)) {
|
|
6
|
+
data.class = data.class ? [data.class] : [];
|
|
7
|
+
}
|
|
8
|
+
data.class.push('modal');
|
|
9
|
+
return scrollbar(data, content);
|
|
10
|
+
};
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import './scss/index.scss';
|
|
2
|
-
declare const _default: (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) => {
|
|
6
|
-
html: import("@esportsplus/template/build/types").RenderableTemplate;
|
|
7
|
-
parent: {
|
|
8
|
-
attributes: {
|
|
9
|
-
class: string;
|
|
10
|
-
onscroll: (this: HTMLElement) => void;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
2
|
+
declare const _default: (data: Record<string, unknown> & {
|
|
3
|
+
scrollbar?: Record<string, unknown>;
|
|
4
|
+
}, content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
14
5
|
export default _default;
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
3
4
|
import './scss/index.scss';
|
|
4
5
|
let root = document.body, width;
|
|
5
|
-
export default (
|
|
6
|
+
export default (data, content) => {
|
|
6
7
|
let state = reactive({
|
|
7
8
|
height: 100,
|
|
8
9
|
translate: 0
|
|
9
10
|
});
|
|
10
|
-
return
|
|
11
|
-
|
|
11
|
+
return html `
|
|
12
|
+
<div
|
|
13
|
+
onscroll='${function () {
|
|
14
|
+
if (width === undefined) {
|
|
15
|
+
width = this.offsetWidth - this.clientWidth;
|
|
16
|
+
if (width && width !== 17) {
|
|
17
|
+
root.style.setProperty('--scrollbar-width', `${width}px`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
state.height = (this.clientHeight / this.scrollHeight) * 100;
|
|
21
|
+
state.translate = (this.scrollTop / this.clientHeight) * 100;
|
|
22
|
+
}}'
|
|
23
|
+
${omit(data, ['scrollbar'])}
|
|
24
|
+
>
|
|
25
|
+
${content}
|
|
26
|
+
|
|
12
27
|
<div
|
|
13
28
|
class='
|
|
14
|
-
${fixed && 'scrollbar--fixed'}
|
|
15
29
|
${() => state.height >= 100 && 'scrollbar--hidden'}
|
|
16
30
|
scrollbar
|
|
17
31
|
'
|
|
@@ -19,24 +33,9 @@ export default ({ attributes, fixed } = {}) => {
|
|
|
19
33
|
--translate: translate3d(0, ${state.translate}%, 0);
|
|
20
34
|
--height: ${state.height}%;
|
|
21
35
|
`}'
|
|
22
|
-
${
|
|
36
|
+
${data.scrollbar}
|
|
23
37
|
>
|
|
24
38
|
</div>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
attributes: {
|
|
28
|
-
class: 'scrollbar-content',
|
|
29
|
-
onscroll: function () {
|
|
30
|
-
if (width === undefined) {
|
|
31
|
-
width = this.offsetWidth - this.clientWidth;
|
|
32
|
-
if (width && width !== 17) {
|
|
33
|
-
root.style.setProperty('--scrollbar-width', `${width}px`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
state.height = (this.clientHeight / this.scrollHeight) * 100;
|
|
37
|
-
state.translate = (this.scrollTop / this.clientHeight) * 100;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
42
41
|
};
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
|
+
import scrollbar from '../../components/scrollbar/index.js';
|
|
1
3
|
import './scss/index.scss';
|
|
4
|
+
export default (data, content) => {
|
|
5
|
+
if (!isArray(data.class)) {
|
|
6
|
+
data.class = data.class ? [data.class] : [];
|
|
7
|
+
}
|
|
8
|
+
data.class.push('sidebar');
|
|
9
|
+
return scrollbar(data, content);
|
|
10
|
+
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import scrollbar from '../../components/scrollbar/index.js';
|
|
2
2
|
import './scss/index.scss';
|
|
3
|
-
|
|
4
|
-
attributes?: Record<string, unknown>;
|
|
5
|
-
content?: any;
|
|
6
|
-
scrollbar?: Parameters<typeof scrollbar>[0];
|
|
7
|
-
};
|
|
8
|
-
declare const _default: ({ attributes, content, scrollbar: sb }: Data) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
3
|
+
declare const _default: (data: Parameters<typeof scrollbar>[0], content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
9
4
|
export default _default;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
2
|
import { onclick } from '../../components/root/index.js';
|
|
3
3
|
import scrollbar from '../../components/scrollbar/index.js';
|
|
4
4
|
import './scss/index.scss';
|
|
5
|
-
export default (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
${content || ''}
|
|
14
|
-
${h}
|
|
15
|
-
</section>
|
|
16
|
-
`;
|
|
5
|
+
export default (data, content) => {
|
|
6
|
+
data.style ??= '--background-default: var(--color-black-400);';
|
|
7
|
+
if (!isArray(data.class)) {
|
|
8
|
+
data.class = data.class ? [data.class] : [];
|
|
9
|
+
}
|
|
10
|
+
data.class.push('site');
|
|
11
|
+
data.onclick = onclick;
|
|
12
|
+
return scrollbar(data, content);
|
|
17
13
|
};
|
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import './scss/index.scss';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
onclick: (data
|
|
3
|
+
onclick: (data: Record<string, unknown> & {
|
|
4
4
|
active?: boolean;
|
|
5
5
|
toggle?: boolean;
|
|
6
|
-
}) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
state: Prettify<{ [K in keyof T]: import("@esportsplus/reactivity").Infer<T[K]>; } & {
|
|
12
|
-
dispose: VoidFunction;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
onhover: (active?: boolean) => {
|
|
16
|
-
attributes: {
|
|
17
|
-
class: () => string;
|
|
18
|
-
onmouseover: () => void;
|
|
19
|
-
onmouseout: () => void;
|
|
20
|
-
};
|
|
21
|
-
toggle: () => void;
|
|
22
|
-
};
|
|
6
|
+
}, content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
7
|
+
onhover: (data: Record<string, unknown> & {
|
|
8
|
+
active?: boolean;
|
|
9
|
+
}, content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
|
|
23
10
|
};
|
|
24
11
|
export default _default;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html } from '@esportsplus/template';
|
|
3
|
+
import { isArray, omit } from '@esportsplus/utilities';
|
|
2
4
|
import root from '../../components/root/index.js';
|
|
3
5
|
import './scss/index.scss';
|
|
4
6
|
let queue = [], running = false, scheduled = false;
|
|
@@ -13,52 +15,64 @@ function frame() {
|
|
|
13
15
|
}
|
|
14
16
|
running = false;
|
|
15
17
|
}
|
|
16
|
-
const onclick = (data
|
|
18
|
+
const onclick = (data, content) => {
|
|
17
19
|
let state = reactive({
|
|
18
20
|
active: data.active || false
|
|
19
21
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
if (!isArray(data.class)) {
|
|
23
|
+
data.class = data.class ? [data.class] : [];
|
|
24
|
+
}
|
|
25
|
+
data.class.push(() => {
|
|
26
|
+
return state.active && '--active';
|
|
27
|
+
});
|
|
28
|
+
return html `
|
|
29
|
+
<div
|
|
30
|
+
class='tooltip'
|
|
31
|
+
onclick='${function (e) {
|
|
32
|
+
let active = true, node = e.target;
|
|
33
|
+
if (data.toggle && (this.contains(node) || this.isSameNode(node))) {
|
|
34
|
+
active = !state.active;
|
|
35
|
+
}
|
|
36
|
+
frame();
|
|
37
|
+
state.active = active;
|
|
38
|
+
if (active) {
|
|
39
|
+
queue.push(() => state.active = false);
|
|
40
|
+
}
|
|
41
|
+
if (!scheduled) {
|
|
42
|
+
root.onclick.push(() => {
|
|
30
43
|
frame();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
if (!scheduled) {
|
|
36
|
-
root.onclick.push(() => {
|
|
37
|
-
frame();
|
|
38
|
-
scheduled = false;
|
|
39
|
-
});
|
|
40
|
-
scheduled = true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
state
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const onhover = (active = false) => {
|
|
48
|
-
let state = reactive({ active });
|
|
49
|
-
return {
|
|
50
|
-
attributes: {
|
|
51
|
-
class: () => `tooltip ${state.active ? '--active' : ''}`,
|
|
52
|
-
onmouseover: () => {
|
|
53
|
-
state.active = true;
|
|
54
|
-
},
|
|
55
|
-
onmouseout: () => {
|
|
56
|
-
state.active = false;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
toggle: () => {
|
|
60
|
-
state.active = !state.active;
|
|
44
|
+
scheduled = false;
|
|
45
|
+
});
|
|
46
|
+
scheduled = true;
|
|
61
47
|
}
|
|
62
|
-
}
|
|
48
|
+
}}}'
|
|
49
|
+
${omit(data, ['active', 'toggle'])}
|
|
50
|
+
>
|
|
51
|
+
${content}
|
|
52
|
+
</div>
|
|
53
|
+
`;
|
|
54
|
+
};
|
|
55
|
+
const onhover = (data, content) => {
|
|
56
|
+
let state = reactive({ active: data.active || false });
|
|
57
|
+
if (!isArray(data.class)) {
|
|
58
|
+
data.class = data.class ? [data.class] : [];
|
|
59
|
+
}
|
|
60
|
+
data.class.push(() => {
|
|
61
|
+
return state.active && '--active';
|
|
62
|
+
});
|
|
63
|
+
return html `
|
|
64
|
+
<div
|
|
65
|
+
class='tooltip'
|
|
66
|
+
onmouseover='${() => {
|
|
67
|
+
state.active = true;
|
|
68
|
+
}}}'
|
|
69
|
+
onmouseout='${() => {
|
|
70
|
+
state.active = false;
|
|
71
|
+
}}'
|
|
72
|
+
${omit(data, ['active', 'toggle'])}
|
|
73
|
+
>
|
|
74
|
+
${content}
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
63
77
|
};
|
|
64
78
|
export default { onclick, onhover };
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
3
|
+
import { isArray, omit } from '@esportsplus/utilities';
|
|
4
4
|
import form from '~/components/form';
|
|
5
|
-
import scrollbar from '~/components/scrollbar';
|
|
6
5
|
import root from '~/components/root';
|
|
6
|
+
import scrollbar from '~/components/scrollbar';
|
|
7
7
|
import description from './description';
|
|
8
8
|
import error from './error';
|
|
9
9
|
import title from './title';
|
|
@@ -26,9 +26,9 @@ type Data<T extends Record<number | string, number | string>> = {
|
|
|
26
26
|
text?: Record<string, unknown>;
|
|
27
27
|
title?: unknown;
|
|
28
28
|
tooltip?: {
|
|
29
|
-
|
|
29
|
+
content?: Record<string, unknown>;
|
|
30
30
|
} & Record<string, unknown>;
|
|
31
|
-
} & Record<string, unknown>;
|
|
31
|
+
} & Parameters<typeof scrollbar>[0] & Record<string, unknown>;
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
const FIELD_OMIT: (keyof Data<any>)[] = [
|
|
@@ -43,8 +43,6 @@ const FIELD_OMIT: (keyof Data<any>)[] = [
|
|
|
43
43
|
'tag', 'text', 'title', 'tooltip'
|
|
44
44
|
];
|
|
45
45
|
|
|
46
|
-
const TOOLTIP_OMIT: (keyof NonNullable<Data<any>['tooltip']>)[] = ['direction'];
|
|
47
|
-
|
|
48
46
|
|
|
49
47
|
function parse(keys: (number | string)[], selected: number | string) {
|
|
50
48
|
let options: Record<string, boolean> = {};
|
|
@@ -63,63 +61,58 @@ function parse(keys: (number | string)[], selected: number | string) {
|
|
|
63
61
|
|
|
64
62
|
function template<T extends Record<number | string, number | string>>(data: Data<T>, state: { active: boolean, options: Record<number | string, boolean>, selected: number | string }) {
|
|
65
63
|
data.scrollbar ??= {};
|
|
66
|
-
data.scrollbar.style
|
|
67
|
-
|
|
64
|
+
data.scrollbar.style ??= '--background-default: var(--color-black-400);';
|
|
68
65
|
data.tooltip ??= {};
|
|
69
|
-
data.tooltip.class = `tooltip-content--${data.tooltip?.direction || 's'} ${data.tooltip?.class || ''}`;
|
|
70
|
-
data.tooltip.direction ??= 's';
|
|
71
66
|
|
|
72
|
-
let
|
|
73
|
-
attributes: data.scrollbar,
|
|
74
|
-
fixed: true
|
|
75
|
-
});
|
|
67
|
+
let content = data.tooltip.content ??= {};
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
if (isArray(content.class)) {
|
|
70
|
+
content.class.push('tooltip-content tooltip-content--s --flex-column --width-full');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
content.class = [content.class, 'tooltip-content tooltip-content--s --flex-column --width-full'];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
content.scrollbar = data.scrollbar;
|
|
77
|
+
|
|
78
|
+
return scrollbar(content, html`
|
|
78
79
|
<div
|
|
79
|
-
class='
|
|
80
|
-
${
|
|
80
|
+
class='row --flex-column'
|
|
81
|
+
onclick='${(e: Event) => {
|
|
82
|
+
let key = (e?.target as HTMLElement)?.dataset?.key;
|
|
83
|
+
|
|
84
|
+
if (key === undefined) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
state.options[key] = true;
|
|
89
|
+
state.options[state.selected] = false;
|
|
90
|
+
|
|
91
|
+
state.active = false;
|
|
92
|
+
state.selected = key;
|
|
93
|
+
|
|
94
|
+
if (data.effect) {
|
|
95
|
+
data.effect(key);
|
|
96
|
+
}
|
|
97
|
+
}}'
|
|
81
98
|
>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (data.effect) {
|
|
98
|
-
data.effect(key);
|
|
99
|
-
}
|
|
100
|
-
}}'
|
|
101
|
-
${a}
|
|
102
|
-
>
|
|
103
|
-
${Object.keys( data.options || {} ).map((key: number | string) => html`
|
|
104
|
-
<div
|
|
105
|
-
class='
|
|
106
|
-
${() => state.options[key] && '--active'}
|
|
107
|
-
link
|
|
108
|
-
--flex-vertical
|
|
109
|
-
'
|
|
110
|
-
data-key='${key}'
|
|
111
|
-
${data.option}
|
|
112
|
-
>
|
|
113
|
-
<span class='--text-truncate'>
|
|
114
|
-
${data.options[key]}
|
|
115
|
-
</span>
|
|
116
|
-
</div>
|
|
117
|
-
`)}
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
${h}
|
|
99
|
+
${Object.keys( data.options || {} ).map((key: number | string) => html`
|
|
100
|
+
<div
|
|
101
|
+
class='
|
|
102
|
+
${() => state.options[key] && '--active'}
|
|
103
|
+
link
|
|
104
|
+
--flex-vertical
|
|
105
|
+
'
|
|
106
|
+
data-key='${key}'
|
|
107
|
+
${data.option}
|
|
108
|
+
>
|
|
109
|
+
<span class='--text-truncate'>
|
|
110
|
+
${data.options[key]}
|
|
111
|
+
</span>
|
|
112
|
+
</div>
|
|
113
|
+
`)}
|
|
121
114
|
</div>
|
|
122
|
-
|
|
115
|
+
`);
|
|
123
116
|
}
|
|
124
117
|
|
|
125
118
|
|
package/src/components/index.ts
CHANGED
|
@@ -16,13 +16,13 @@ export * as frame from './frame';
|
|
|
16
16
|
export * as grid from './grid';
|
|
17
17
|
export * as group from './group';
|
|
18
18
|
export { default as highlight } from './highlight';
|
|
19
|
-
export
|
|
19
|
+
export { default as icon } from './icon';
|
|
20
20
|
export { default as json } from './json';
|
|
21
21
|
export { default as link } from './link';
|
|
22
22
|
export * as loader from './loader';
|
|
23
23
|
export { default as loading } from './loading';
|
|
24
24
|
export { default as magnet } from './magnet';
|
|
25
|
-
export
|
|
25
|
+
export { default as modal } from './modal';
|
|
26
26
|
export { default as number } from './number';
|
|
27
27
|
export { default as page } from './page';
|
|
28
28
|
export { default as root } from './root';
|
|
@@ -42,12 +42,16 @@ export default ({ attributes, hide }: { attributes?: Record<string, unknown>, hi
|
|
|
42
42
|
|
|
43
43
|
return {
|
|
44
44
|
html: html`
|
|
45
|
-
<div
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
<div
|
|
46
|
+
class='magnet'
|
|
47
|
+
style='${() => `
|
|
48
|
+
height: ${state.height ? `${state.height}px` : '100%'};
|
|
49
|
+
opacity: ${state.opacity};
|
|
50
|
+
transform: translate(${state.left}px, ${state.top}px);
|
|
51
|
+
width: ${state.width}px;
|
|
52
|
+
`}'
|
|
53
|
+
${attributes}
|
|
54
|
+
></div>
|
|
51
55
|
`,
|
|
52
56
|
sibling: {
|
|
53
57
|
attributes: events
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
|
+
import scrollbar from '~/components/scrollbar';
|
|
3
|
+
import './scss/index.scss';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default (data: Parameters<typeof scrollbar>[0], content: unknown) => {
|
|
7
|
+
if (!isArray(data.class)) {
|
|
8
|
+
data.class = data.class ? [data.class] : [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
(data.class as unknown[]).push('modal');
|
|
12
|
+
|
|
13
|
+
return scrollbar(data, content);
|
|
14
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
3
4
|
import './scss/index.scss';
|
|
4
5
|
|
|
5
6
|
|
|
@@ -7,19 +8,33 @@ let root = document.body,
|
|
|
7
8
|
width: number | undefined;
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
export default ({ attributes, fixed }: { attributes?: Record<string, unknown>, fixed?: boolean } = {}) => {
|
|
11
|
+
// TODO: Look into scrollbar customization options
|
|
12
|
+
export default (data: Record<string, unknown> & { scrollbar?: Record<string, unknown> }, content: unknown) => {
|
|
13
13
|
let state = reactive({
|
|
14
14
|
height: 100,
|
|
15
15
|
translate: 0
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
return
|
|
19
|
-
|
|
18
|
+
return html`
|
|
19
|
+
<div
|
|
20
|
+
onscroll='${function(this: HTMLElement) {
|
|
21
|
+
if (width === undefined) {
|
|
22
|
+
width = this.offsetWidth - this.clientWidth;
|
|
23
|
+
|
|
24
|
+
if (width && width !== 17) {
|
|
25
|
+
root.style.setProperty('--scrollbar-width', `${width}px`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state.height = (this.clientHeight / this.scrollHeight) * 100;
|
|
30
|
+
state.translate = (this.scrollTop / this.clientHeight) * 100;
|
|
31
|
+
}}'
|
|
32
|
+
${omit(data, ['scrollbar'])}
|
|
33
|
+
>
|
|
34
|
+
${content}
|
|
35
|
+
|
|
20
36
|
<div
|
|
21
37
|
class='
|
|
22
|
-
${fixed && 'scrollbar--fixed'}
|
|
23
38
|
${() => state.height >= 100 && 'scrollbar--hidden'}
|
|
24
39
|
scrollbar
|
|
25
40
|
'
|
|
@@ -27,26 +42,9 @@ export default ({ attributes, fixed }: { attributes?: Record<string, unknown>, f
|
|
|
27
42
|
--translate: translate3d(0, ${state.translate}%, 0);
|
|
28
43
|
--height: ${state.height}%;
|
|
29
44
|
`}'
|
|
30
|
-
${
|
|
45
|
+
${data.scrollbar}
|
|
31
46
|
>
|
|
32
47
|
</div>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
attributes: {
|
|
36
|
-
class: 'scrollbar-content',
|
|
37
|
-
onscroll: function(this: HTMLElement) {
|
|
38
|
-
if (width === undefined) {
|
|
39
|
-
width = this.offsetWidth - this.clientWidth;
|
|
40
|
-
|
|
41
|
-
if (width && width !== 17) {
|
|
42
|
-
root.style.setProperty('--scrollbar-width', `${width}px`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
state.height = (this.clientHeight / this.scrollHeight) * 100;
|
|
47
|
-
state.translate = (this.scrollTop / this.clientHeight) * 100;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
48
|
+
</div>
|
|
49
|
+
`;
|
|
52
50
|
};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
|
+
import scrollbar from '~/components/scrollbar';
|
|
3
|
+
import './scss/index.scss';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default (data: Parameters<typeof scrollbar>[0], content: unknown) => {
|
|
7
|
+
if (!isArray(data.class)) {
|
|
8
|
+
data.class = data.class ? [data.class] : [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
(data.class as unknown[]).push('sidebar');
|
|
12
|
+
|
|
13
|
+
return scrollbar(data, content);
|
|
14
|
+
};
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
2
|
import { onclick } from '~/components/root';
|
|
3
3
|
import scrollbar from '~/components/scrollbar';
|
|
4
4
|
import './scss/index.scss';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
content?: any;
|
|
10
|
-
scrollbar?: Parameters<typeof scrollbar>[0];
|
|
11
|
-
};
|
|
7
|
+
export default (data: Parameters<typeof scrollbar>[0], content: unknown) => {
|
|
8
|
+
data.style ??= '--background-default: var(--color-black-400);';
|
|
12
9
|
|
|
10
|
+
if (!isArray(data.class)) {
|
|
11
|
+
data.class = data.class ? [data.class] : [];
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
sb ??= {};
|
|
16
|
-
sb.attributes ??= {};
|
|
17
|
-
sb.attributes.style ??= '--background-default: var(--color-black-400);';
|
|
18
|
-
sb.fixed ??= true;
|
|
14
|
+
(data.class as unknown[]).push('site');
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
data.onclick = onclick;
|
|
21
17
|
|
|
22
|
-
return
|
|
23
|
-
<section class='site' ${attributes} ${{ onclick }} ${parent.attributes}>
|
|
24
|
-
${content || ''}
|
|
25
|
-
${h}
|
|
26
|
-
</section>
|
|
27
|
-
`;
|
|
18
|
+
return scrollbar(data, content);
|
|
28
19
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html } from '@esportsplus/template';
|
|
3
|
+
import { isArray, omit } from '@esportsplus/utilities';
|
|
2
4
|
import root from '~/components/root';
|
|
3
5
|
import './scss/index.scss';
|
|
4
6
|
|
|
@@ -25,17 +27,23 @@ function frame() {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
|
|
28
|
-
const onclick = (data: { active?: boolean, toggle?: boolean }
|
|
30
|
+
const onclick = (data: Record<string, unknown> & { active?: boolean, toggle?: boolean }, content: unknown) => {
|
|
29
31
|
let state = reactive({
|
|
30
32
|
active: data.active || false
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
if (!isArray(data.class)) {
|
|
36
|
+
data.class = data.class ? [data.class] : [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
(data.class as unknown[]).push(() => {
|
|
40
|
+
return state.active && '--active';
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return html`
|
|
44
|
+
<div
|
|
45
|
+
class='tooltip'
|
|
46
|
+
onclick='${function(this: HTMLElement, e: Event) {
|
|
39
47
|
let active = true,
|
|
40
48
|
node = e.target as Node | null;
|
|
41
49
|
|
|
@@ -57,29 +65,39 @@ const onclick = (data: { active?: boolean, toggle?: boolean } = {}) => {
|
|
|
57
65
|
});
|
|
58
66
|
scheduled = true;
|
|
59
67
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
}}}'
|
|
69
|
+
${omit(data, ['active', 'toggle'])}
|
|
70
|
+
>
|
|
71
|
+
${content}
|
|
72
|
+
</div>
|
|
73
|
+
`;
|
|
64
74
|
};
|
|
65
75
|
|
|
66
|
-
const onhover = (
|
|
67
|
-
let state = reactive({ active });
|
|
76
|
+
const onhover = (data: Record<string, unknown> & { active?: boolean }, content: unknown) => {
|
|
77
|
+
let state = reactive({ active: data.active || false });
|
|
78
|
+
|
|
79
|
+
if (!isArray(data.class)) {
|
|
80
|
+
data.class = data.class ? [data.class] : [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
(data.class as unknown[]).push(() => {
|
|
84
|
+
return state.active && '--active';
|
|
85
|
+
});
|
|
68
86
|
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
class
|
|
72
|
-
onmouseover
|
|
87
|
+
return html`
|
|
88
|
+
<div
|
|
89
|
+
class='tooltip'
|
|
90
|
+
onmouseover='${() => {
|
|
73
91
|
state.active = true;
|
|
74
|
-
}
|
|
75
|
-
onmouseout
|
|
92
|
+
}}}'
|
|
93
|
+
onmouseout='${() => {
|
|
76
94
|
state.active = false;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
}}'
|
|
96
|
+
${omit(data, ['active', 'toggle'])}
|
|
97
|
+
>
|
|
98
|
+
${content}
|
|
99
|
+
</div>
|
|
100
|
+
`;
|
|
83
101
|
};
|
|
84
102
|
|
|
85
103
|
|