@esportsplus/ui 0.0.22 → 0.0.24
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/checkbox.d.ts +21 -0
- package/build/components/field/checkbox.js +41 -0
- package/build/components/field/index.d.ts +136 -3
- package/build/components/field/index.js +4 -2
- package/build/components/field/optional.d.ts +97 -0
- package/build/components/field/optional.js +20 -0
- package/build/components/field/select.js +41 -42
- package/build/components/field/switch.d.ts +7 -0
- package/build/components/field/switch.js +6 -0
- package/build/components/tooltip/menu.js +34 -36
- package/package.json +1 -1
- package/src/components/field/checkbox.ts +61 -0
- package/src/components/field/index.ts +4 -2
- package/src/components/field/optional.ts +25 -0
- package/src/components/field/select.ts +49 -50
- package/src/components/field/switch.ts +9 -0
- package/src/components/tooltip/menu.ts +36 -37
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import description from './description';
|
|
2
|
+
type Data = {
|
|
3
|
+
class?: string;
|
|
4
|
+
field?: {
|
|
5
|
+
content?: any;
|
|
6
|
+
};
|
|
7
|
+
mask?: {
|
|
8
|
+
class?: string;
|
|
9
|
+
style?: string;
|
|
10
|
+
};
|
|
11
|
+
name?: string;
|
|
12
|
+
style?: string;
|
|
13
|
+
title: string;
|
|
14
|
+
value?: any;
|
|
15
|
+
} & Parameters<typeof description>[0];
|
|
16
|
+
declare const _default: (data: Data) => {
|
|
17
|
+
content: string;
|
|
18
|
+
type: string;
|
|
19
|
+
values: never[];
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html } from '@esportsplus/template';
|
|
3
|
+
import description from './description';
|
|
4
|
+
export default (data) => {
|
|
5
|
+
let state = reactive({
|
|
6
|
+
active: false
|
|
7
|
+
});
|
|
8
|
+
return html `
|
|
9
|
+
<div
|
|
10
|
+
class="field --flex-column ${data?.class || ''} ${() => state.active ? '--active' : ''}"
|
|
11
|
+
onchange='${(e) => {
|
|
12
|
+
if (e.target.type !== 'checkbox') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
state.active = e.target?.checked;
|
|
16
|
+
}}'
|
|
17
|
+
style='${data?.style || ''}'
|
|
18
|
+
>
|
|
19
|
+
<div class="field-title --flex-horizontal-space-between --flex-vertical">
|
|
20
|
+
${data.title}
|
|
21
|
+
|
|
22
|
+
<label
|
|
23
|
+
class="field-mask ${(data?.mask?.class || '').indexOf('field-mask--switch') === -1 ? 'field-mask--checkbox' : ''} --margin-left --margin-400 ${data?.mask?.class || ''}"
|
|
24
|
+
style='${data?.mask?.style || ''}'
|
|
25
|
+
>
|
|
26
|
+
<input
|
|
27
|
+
class='field-tag field-tag--hidden'
|
|
28
|
+
${data.name ? `name='${data.name}'` : ''}
|
|
29
|
+
type='checkbox'
|
|
30
|
+
value='1'
|
|
31
|
+
${(data?.class || '').indexOf('--active') !== -1 || data?.value ? 'checked' : ''}
|
|
32
|
+
>
|
|
33
|
+
</label>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
${data?.field?.content || ''}
|
|
37
|
+
|
|
38
|
+
${description(data)}
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
};
|
|
@@ -1,6 +1,120 @@
|
|
|
1
|
-
import select from './select';
|
|
2
|
-
import text from './text';
|
|
3
1
|
declare const _default: {
|
|
2
|
+
checkbox: (data: {
|
|
3
|
+
class?: string | undefined;
|
|
4
|
+
field?: {
|
|
5
|
+
content?: any;
|
|
6
|
+
} | undefined;
|
|
7
|
+
mask?: {
|
|
8
|
+
class?: string | undefined;
|
|
9
|
+
style?: string | undefined;
|
|
10
|
+
} | undefined;
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
style?: string | undefined;
|
|
13
|
+
title: string;
|
|
14
|
+
value?: any;
|
|
15
|
+
} & {
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
}) => {
|
|
18
|
+
content: string;
|
|
19
|
+
type: string;
|
|
20
|
+
values: never[];
|
|
21
|
+
};
|
|
22
|
+
optional: {
|
|
23
|
+
select: (data: {
|
|
24
|
+
class?: string | undefined;
|
|
25
|
+
field?: {
|
|
26
|
+
content?: any;
|
|
27
|
+
} | undefined;
|
|
28
|
+
mask?: {
|
|
29
|
+
class?: string | undefined;
|
|
30
|
+
style?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
name?: string | undefined;
|
|
33
|
+
style?: string | undefined;
|
|
34
|
+
title: string;
|
|
35
|
+
value?: any;
|
|
36
|
+
} & {
|
|
37
|
+
description?: string | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
field: {
|
|
40
|
+
class?: string | undefined;
|
|
41
|
+
effect?: ((selected: string | number) => void) | undefined;
|
|
42
|
+
mask?: {
|
|
43
|
+
class?: string | undefined;
|
|
44
|
+
content?: any;
|
|
45
|
+
style?: string | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
options: Record<string | number, string | number>;
|
|
49
|
+
option?: {
|
|
50
|
+
class?: string | undefined;
|
|
51
|
+
style?: string | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
selected?: any;
|
|
54
|
+
scrollbar?: {
|
|
55
|
+
style?: string | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
style?: string | undefined;
|
|
58
|
+
text?: {
|
|
59
|
+
class?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
tooltip?: {
|
|
62
|
+
class?: string | undefined;
|
|
63
|
+
direction?: any;
|
|
64
|
+
style?: string | undefined;
|
|
65
|
+
} | undefined;
|
|
66
|
+
} & {
|
|
67
|
+
description?: string | undefined;
|
|
68
|
+
} & {
|
|
69
|
+
required?: boolean | undefined;
|
|
70
|
+
title?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
}) => {
|
|
73
|
+
content: string;
|
|
74
|
+
type: string;
|
|
75
|
+
values: never[];
|
|
76
|
+
};
|
|
77
|
+
text: (data: {
|
|
78
|
+
class?: string | undefined;
|
|
79
|
+
field?: {
|
|
80
|
+
content?: any;
|
|
81
|
+
} | undefined;
|
|
82
|
+
mask?: {
|
|
83
|
+
class?: string | undefined;
|
|
84
|
+
style?: string | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
name?: string | undefined;
|
|
87
|
+
style?: string | undefined;
|
|
88
|
+
title: string;
|
|
89
|
+
value?: any;
|
|
90
|
+
} & {
|
|
91
|
+
description?: string | undefined;
|
|
92
|
+
} & {
|
|
93
|
+
field: {
|
|
94
|
+
active?: boolean | undefined;
|
|
95
|
+
class?: string | undefined;
|
|
96
|
+
mask?: {
|
|
97
|
+
class?: string | undefined;
|
|
98
|
+
content?: any;
|
|
99
|
+
style?: string | undefined;
|
|
100
|
+
} | undefined;
|
|
101
|
+
name?: string | undefined;
|
|
102
|
+
placeholder?: string | undefined;
|
|
103
|
+
style?: string | undefined;
|
|
104
|
+
type?: string | undefined;
|
|
105
|
+
value?: unknown;
|
|
106
|
+
} & {
|
|
107
|
+
description?: string | undefined;
|
|
108
|
+
} & {
|
|
109
|
+
required?: boolean | undefined;
|
|
110
|
+
title?: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
}) => {
|
|
113
|
+
content: string;
|
|
114
|
+
type: string;
|
|
115
|
+
values: never[];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
4
118
|
select: (data: {
|
|
5
119
|
class?: string | undefined;
|
|
6
120
|
effect?: ((selected: string | number) => void) | undefined;
|
|
@@ -38,6 +152,26 @@ declare const _default: {
|
|
|
38
152
|
type: string;
|
|
39
153
|
values: never[];
|
|
40
154
|
};
|
|
155
|
+
switch: (data: {
|
|
156
|
+
class?: string | undefined;
|
|
157
|
+
field?: {
|
|
158
|
+
content?: any;
|
|
159
|
+
} | undefined;
|
|
160
|
+
mask?: {
|
|
161
|
+
class?: string | undefined;
|
|
162
|
+
style?: string | undefined;
|
|
163
|
+
} | undefined;
|
|
164
|
+
name?: string | undefined;
|
|
165
|
+
style?: string | undefined;
|
|
166
|
+
title: string;
|
|
167
|
+
value?: any;
|
|
168
|
+
} & {
|
|
169
|
+
description?: string | undefined;
|
|
170
|
+
}) => {
|
|
171
|
+
content: string;
|
|
172
|
+
type: string;
|
|
173
|
+
values: never[];
|
|
174
|
+
};
|
|
41
175
|
text: (data: {
|
|
42
176
|
active?: boolean | undefined;
|
|
43
177
|
class?: string | undefined;
|
|
@@ -63,4 +197,3 @@ declare const _default: {
|
|
|
63
197
|
};
|
|
64
198
|
};
|
|
65
199
|
export default _default;
|
|
66
|
-
export { select, text };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import checkbox from './checkbox';
|
|
2
|
+
import optional from './optional';
|
|
1
3
|
import select from './select';
|
|
4
|
+
import s from './switch';
|
|
2
5
|
import text from './text';
|
|
3
|
-
export default { select, text };
|
|
4
|
-
export { select, text };
|
|
6
|
+
export default { checkbox, optional, select, switch: s, text };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
select: (data: {
|
|
3
|
+
class?: string | undefined;
|
|
4
|
+
field?: {
|
|
5
|
+
content?: any;
|
|
6
|
+
} | undefined;
|
|
7
|
+
mask?: {
|
|
8
|
+
class?: string | undefined;
|
|
9
|
+
style?: string | undefined;
|
|
10
|
+
} | undefined;
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
style?: string | undefined;
|
|
13
|
+
title: string;
|
|
14
|
+
value?: any;
|
|
15
|
+
} & {
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
field: {
|
|
19
|
+
class?: string | undefined;
|
|
20
|
+
effect?: ((selected: string | number) => void) | undefined;
|
|
21
|
+
mask?: {
|
|
22
|
+
class?: string | undefined;
|
|
23
|
+
content?: any;
|
|
24
|
+
style?: string | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
name?: string | undefined;
|
|
27
|
+
options: Record<string | number, string | number>;
|
|
28
|
+
option?: {
|
|
29
|
+
class?: string | undefined;
|
|
30
|
+
style?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
selected?: any;
|
|
33
|
+
scrollbar?: {
|
|
34
|
+
style?: string | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
style?: string | undefined;
|
|
37
|
+
text?: {
|
|
38
|
+
class?: string | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
tooltip?: {
|
|
41
|
+
class?: string | undefined;
|
|
42
|
+
direction?: any;
|
|
43
|
+
style?: string | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} & {
|
|
46
|
+
description?: string | undefined;
|
|
47
|
+
} & {
|
|
48
|
+
required?: boolean | undefined;
|
|
49
|
+
title?: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
}) => {
|
|
52
|
+
content: string;
|
|
53
|
+
type: string;
|
|
54
|
+
values: never[];
|
|
55
|
+
};
|
|
56
|
+
text: (data: {
|
|
57
|
+
class?: string | undefined;
|
|
58
|
+
field?: {
|
|
59
|
+
content?: any;
|
|
60
|
+
} | undefined;
|
|
61
|
+
mask?: {
|
|
62
|
+
class?: string | undefined;
|
|
63
|
+
style?: string | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
name?: string | undefined;
|
|
66
|
+
style?: string | undefined;
|
|
67
|
+
title: string;
|
|
68
|
+
value?: any;
|
|
69
|
+
} & {
|
|
70
|
+
description?: string | undefined;
|
|
71
|
+
} & {
|
|
72
|
+
field: {
|
|
73
|
+
active?: boolean | undefined;
|
|
74
|
+
class?: string | undefined;
|
|
75
|
+
mask?: {
|
|
76
|
+
class?: string | undefined;
|
|
77
|
+
content?: any;
|
|
78
|
+
style?: string | undefined;
|
|
79
|
+
} | undefined;
|
|
80
|
+
name?: string | undefined;
|
|
81
|
+
placeholder?: string | undefined;
|
|
82
|
+
style?: string | undefined;
|
|
83
|
+
type?: string | undefined;
|
|
84
|
+
value?: unknown;
|
|
85
|
+
} & {
|
|
86
|
+
description?: string | undefined;
|
|
87
|
+
} & {
|
|
88
|
+
required?: boolean | undefined;
|
|
89
|
+
title?: string | undefined;
|
|
90
|
+
};
|
|
91
|
+
}) => {
|
|
92
|
+
content: string;
|
|
93
|
+
type: string;
|
|
94
|
+
values: never[];
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import sel from './select';
|
|
2
|
+
import s from './switch';
|
|
3
|
+
import tex from './text';
|
|
4
|
+
const select = (data) => {
|
|
5
|
+
return s(Object.assign(data, {
|
|
6
|
+
class: `field--optional ${data?.class || ''}`,
|
|
7
|
+
field: {
|
|
8
|
+
content: sel(data.field)
|
|
9
|
+
}
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
const text = (data) => {
|
|
13
|
+
return s(Object.assign(data, {
|
|
14
|
+
class: `field--optional ${data?.class || ''}`,
|
|
15
|
+
field: {
|
|
16
|
+
content: tex(data.field)
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
export default { select, text };
|
|
@@ -12,11 +12,49 @@ function options(keys, selected) {
|
|
|
12
12
|
options[selected] = true;
|
|
13
13
|
return options;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
function template(data, state) {
|
|
16
16
|
let { attributes: a, html: h } = scrollbar({
|
|
17
17
|
fixed: true,
|
|
18
18
|
style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
|
|
19
|
-
})
|
|
19
|
+
});
|
|
20
|
+
return html `
|
|
21
|
+
<div class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'>
|
|
22
|
+
<div
|
|
23
|
+
class='row --flex-column'
|
|
24
|
+
onclick='${(e) => {
|
|
25
|
+
let key = e?.target?.dataset?.key;
|
|
26
|
+
if (key === undefined) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
state.options[key] = true;
|
|
30
|
+
state.options[state.selected] = false;
|
|
31
|
+
state.active = false;
|
|
32
|
+
state.selected = key;
|
|
33
|
+
if (data.effect) {
|
|
34
|
+
data.effect(key);
|
|
35
|
+
}
|
|
36
|
+
}}'
|
|
37
|
+
style='${data?.tooltip?.style || ''}'
|
|
38
|
+
${a}
|
|
39
|
+
>
|
|
40
|
+
${Object.keys(state.options).map((key) => html `
|
|
41
|
+
<div
|
|
42
|
+
class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
|
|
43
|
+
style='${data?.option?.style || ''}'
|
|
44
|
+
>
|
|
45
|
+
<span class="--text-truncate">
|
|
46
|
+
${data.options[key]}
|
|
47
|
+
</span>
|
|
48
|
+
</div>
|
|
49
|
+
`)}
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
${h}
|
|
53
|
+
</div>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
export default (data) => {
|
|
57
|
+
let state = reactive({
|
|
20
58
|
active: false,
|
|
21
59
|
error: '',
|
|
22
60
|
options: options(Object.keys(data.options || {}), data.selected),
|
|
@@ -52,46 +90,7 @@ export default (data) => {
|
|
|
52
90
|
|
|
53
91
|
<div class='field-mask-arrow'></div>
|
|
54
92
|
|
|
55
|
-
${() =>
|
|
56
|
-
if (!state.render) {
|
|
57
|
-
return '';
|
|
58
|
-
}
|
|
59
|
-
return html `
|
|
60
|
-
<div class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'>
|
|
61
|
-
<div
|
|
62
|
-
class='row --flex-column'
|
|
63
|
-
onclick='${(e) => {
|
|
64
|
-
let key = e?.target?.dataset?.key;
|
|
65
|
-
if (key === undefined) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
state.options[key] = true;
|
|
69
|
-
state.options[state.selected] = false;
|
|
70
|
-
state.active = false;
|
|
71
|
-
state.selected = key;
|
|
72
|
-
if (data.effect) {
|
|
73
|
-
data.effect(key);
|
|
74
|
-
}
|
|
75
|
-
}}'
|
|
76
|
-
style='${data?.tooltip?.style || ''}'
|
|
77
|
-
${a}
|
|
78
|
-
>
|
|
79
|
-
${Object.keys(state.options).map((key) => html `
|
|
80
|
-
<div
|
|
81
|
-
class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
|
|
82
|
-
style='${data?.option?.style || ''}'
|
|
83
|
-
>
|
|
84
|
-
<span class="--text-truncate">
|
|
85
|
-
${data.options[key]}
|
|
86
|
-
</span>
|
|
87
|
-
</div>
|
|
88
|
-
`)}
|
|
89
|
-
</div>
|
|
90
|
-
|
|
91
|
-
${h}
|
|
92
|
-
</div>
|
|
93
|
-
`;
|
|
94
|
-
}}
|
|
93
|
+
${() => state.render ? template(data, state) : ''}
|
|
95
94
|
</label>
|
|
96
95
|
|
|
97
96
|
${description(data)}
|
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import { effect, reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
+
function template(data) {
|
|
4
|
+
return html `
|
|
5
|
+
<div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
|
|
6
|
+
${(data?.items || []).map(item => html `
|
|
7
|
+
${item?.border ? html `
|
|
8
|
+
<div
|
|
9
|
+
class="border ${item?.border?.class || ''}"
|
|
10
|
+
style='
|
|
11
|
+
margin-left: calc(var(--margin-horizontal) * -1);
|
|
12
|
+
width: calc(100% + var(--margin-horizontal) * 2);
|
|
13
|
+
'
|
|
14
|
+
></div>
|
|
15
|
+
` : ''}
|
|
16
|
+
|
|
17
|
+
<${item?.url ? 'a' : 'div'}
|
|
18
|
+
class='link --flex-vertical ${item?.class}' ${item?.onclick ? html({ onclick: item.onclick }) : ''}
|
|
19
|
+
style='${item?.style || ''}'
|
|
20
|
+
${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
|
|
21
|
+
>
|
|
22
|
+
${item?.svg ? html `
|
|
23
|
+
<div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
|
|
24
|
+
${item.svg}
|
|
25
|
+
</div>
|
|
26
|
+
` : ''}
|
|
27
|
+
|
|
28
|
+
<div class="text --color-text --flex-fill">
|
|
29
|
+
${item.text}
|
|
30
|
+
</div>
|
|
31
|
+
</${item?.url ? 'a' : 'div'}>
|
|
32
|
+
`)}
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
3
36
|
export default (data) => {
|
|
4
37
|
let state = reactive({
|
|
5
38
|
render: false
|
|
@@ -10,40 +43,5 @@ export default (data) => {
|
|
|
10
43
|
}
|
|
11
44
|
state.render = true;
|
|
12
45
|
});
|
|
13
|
-
return () =>
|
|
14
|
-
if (!state.render) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
return html `
|
|
18
|
-
<div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
|
|
19
|
-
${(data?.items || []).map(item => html `
|
|
20
|
-
${item?.border ? html `
|
|
21
|
-
<div
|
|
22
|
-
class="border ${item?.border?.class || ''}"
|
|
23
|
-
style='
|
|
24
|
-
margin-left: calc(var(--margin-horizontal) * -1);
|
|
25
|
-
width: calc(100% + var(--margin-horizontal) * 2);
|
|
26
|
-
'
|
|
27
|
-
></div>
|
|
28
|
-
` : ''}
|
|
29
|
-
|
|
30
|
-
<${item?.url ? 'a' : 'div'}
|
|
31
|
-
class='link --flex-vertical ${item?.class}' ${item?.onclick ? html({ onclick: item.onclick }) : ''}
|
|
32
|
-
style='${item?.style || ''}'
|
|
33
|
-
${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
|
|
34
|
-
>
|
|
35
|
-
${item?.svg ? html `
|
|
36
|
-
<div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
|
|
37
|
-
${item.svg}
|
|
38
|
-
</div>
|
|
39
|
-
` : ''}
|
|
40
|
-
|
|
41
|
-
<div class="text --color-text --flex-fill">
|
|
42
|
-
${item.text}
|
|
43
|
-
</div>
|
|
44
|
-
</${item?.url ? 'a' : 'div'}>
|
|
45
|
-
`)}
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
};
|
|
46
|
+
return () => state.render ? template(data) : '';
|
|
49
47
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html } from '@esportsplus/template';
|
|
3
|
+
import description from './description';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type Data = {
|
|
7
|
+
class?: string;
|
|
8
|
+
field?: {
|
|
9
|
+
content?: any;
|
|
10
|
+
};
|
|
11
|
+
mask?: {
|
|
12
|
+
class?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
};
|
|
15
|
+
name?: string;
|
|
16
|
+
style?: string;
|
|
17
|
+
title: string;
|
|
18
|
+
value?: any;
|
|
19
|
+
} & Parameters<typeof description>[0];
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export default (data: Data) => {
|
|
23
|
+
let state = reactive({
|
|
24
|
+
active: false
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return html`
|
|
28
|
+
<div
|
|
29
|
+
class="field --flex-column ${data?.class || ''} ${() => state.active ? '--active' : ''}"
|
|
30
|
+
onchange='${(e: Event) => {
|
|
31
|
+
if ((e.target as HTMLInputElement).type !== 'checkbox') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
state.active = (e.target as HTMLInputElement)?.checked;
|
|
36
|
+
}}'
|
|
37
|
+
style='${data?.style || ''}'
|
|
38
|
+
>
|
|
39
|
+
<div class="field-title --flex-horizontal-space-between --flex-vertical">
|
|
40
|
+
${data.title}
|
|
41
|
+
|
|
42
|
+
<label
|
|
43
|
+
class="field-mask ${(data?.mask?.class || '').indexOf('field-mask--switch') === -1 ? 'field-mask--checkbox' : ''} --margin-left --margin-400 ${data?.mask?.class || ''}"
|
|
44
|
+
style='${data?.mask?.style || ''}'
|
|
45
|
+
>
|
|
46
|
+
<input
|
|
47
|
+
class='field-tag field-tag--hidden'
|
|
48
|
+
${data.name ? `name='${data.name}'` : ''}
|
|
49
|
+
type='checkbox'
|
|
50
|
+
value='1'
|
|
51
|
+
${(data?.class || '').indexOf('--active') !== -1 || data?.value ? 'checked' : ''}
|
|
52
|
+
>
|
|
53
|
+
</label>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
${data?.field?.content || ''}
|
|
57
|
+
|
|
58
|
+
${description(data)}
|
|
59
|
+
</div>
|
|
60
|
+
`
|
|
61
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import checkbox from './checkbox';
|
|
2
|
+
import optional from './optional';
|
|
1
3
|
import select from './select';
|
|
4
|
+
import s from './switch';
|
|
2
5
|
import text from './text';
|
|
3
6
|
|
|
4
7
|
|
|
5
|
-
export default { select, text };
|
|
6
|
-
export { select, text };
|
|
8
|
+
export default { checkbox, optional, select, switch: s, text };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import sel from './select';
|
|
2
|
+
import s from './switch';
|
|
3
|
+
import tex from './text';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const select = (data: Parameters<typeof s>[0] & { field: Parameters<typeof sel>[0] }) => {
|
|
7
|
+
return s(Object.assign(data, {
|
|
8
|
+
class: `field--optional ${data?.class || ''}`,
|
|
9
|
+
field: {
|
|
10
|
+
content: sel( data.field )
|
|
11
|
+
}
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const text = (data: Parameters<typeof s>[0] & { field: Parameters<typeof tex>[0] }) => {
|
|
16
|
+
return s(Object.assign(data, {
|
|
17
|
+
class: `field--optional ${data?.class || ''}`,
|
|
18
|
+
field: {
|
|
19
|
+
content: tex( data.field )
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export default { select, text };
|
|
@@ -48,13 +48,57 @@ function options(keys: (number | string)[], selected: number | string) {
|
|
|
48
48
|
return options;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
export default (data: Data) => {
|
|
51
|
+
function template(data: Data, state: { active: boolean, options: Record<number | string, boolean>, selected: number | string }) {
|
|
53
52
|
let { attributes: a, html: h } = scrollbar({
|
|
54
53
|
fixed: true,
|
|
55
54
|
style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
|
|
56
|
-
})
|
|
57
|
-
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return html`
|
|
58
|
+
<div class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'>
|
|
59
|
+
<div
|
|
60
|
+
class='row --flex-column'
|
|
61
|
+
onclick='${(e: Event) => {
|
|
62
|
+
let key = (e?.target as HTMLElement)?.dataset?.key;
|
|
63
|
+
|
|
64
|
+
if (key === undefined) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Swap active
|
|
69
|
+
state.options[key] = true;
|
|
70
|
+
state.options[state.selected] = false;
|
|
71
|
+
|
|
72
|
+
state.active = false;
|
|
73
|
+
state.selected = key;
|
|
74
|
+
|
|
75
|
+
if (data.effect) {
|
|
76
|
+
data.effect(key);
|
|
77
|
+
}
|
|
78
|
+
}}'
|
|
79
|
+
style='${data?.tooltip?.style || ''}'
|
|
80
|
+
${a}
|
|
81
|
+
>
|
|
82
|
+
${Object.keys( state.options ).map((key: number | string) => html`
|
|
83
|
+
<div
|
|
84
|
+
class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
|
|
85
|
+
style='${data?.option?.style || ''}'
|
|
86
|
+
>
|
|
87
|
+
<span class="--text-truncate">
|
|
88
|
+
${data.options[key]}
|
|
89
|
+
</span>
|
|
90
|
+
</div>
|
|
91
|
+
`)}
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
${h}
|
|
95
|
+
</div>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
export default (data: Data) => {
|
|
101
|
+
let state = reactive({
|
|
58
102
|
active: false,
|
|
59
103
|
error: '',
|
|
60
104
|
options: options(Object.keys( data.options || {} ), data.selected),
|
|
@@ -92,52 +136,7 @@ export default (data: Data) => {
|
|
|
92
136
|
|
|
93
137
|
<div class='field-mask-arrow'></div>
|
|
94
138
|
|
|
95
|
-
${() =>
|
|
96
|
-
if (!state.render) {
|
|
97
|
-
return '';
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return html`
|
|
101
|
-
<div class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'>
|
|
102
|
-
<div
|
|
103
|
-
class='row --flex-column'
|
|
104
|
-
onclick='${(e: Event) => {
|
|
105
|
-
let key = (e?.target as HTMLElement)?.dataset?.key;
|
|
106
|
-
|
|
107
|
-
if (key === undefined) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Swap active
|
|
112
|
-
state.options[key] = true;
|
|
113
|
-
state.options[state.selected] = false;
|
|
114
|
-
|
|
115
|
-
state.active = false;
|
|
116
|
-
state.selected = key;
|
|
117
|
-
|
|
118
|
-
if (data.effect) {
|
|
119
|
-
data.effect(key);
|
|
120
|
-
}
|
|
121
|
-
}}'
|
|
122
|
-
style='${data?.tooltip?.style || ''}'
|
|
123
|
-
${a}
|
|
124
|
-
>
|
|
125
|
-
${Object.keys( state.options ).map((key: number | string) => html`
|
|
126
|
-
<div
|
|
127
|
-
class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
|
|
128
|
-
style='${data?.option?.style || ''}'
|
|
129
|
-
>
|
|
130
|
-
<span class="--text-truncate">
|
|
131
|
-
${data.options[key]}
|
|
132
|
-
</span>
|
|
133
|
-
</div>
|
|
134
|
-
`)}
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
${h}
|
|
138
|
-
</div>
|
|
139
|
-
`;
|
|
140
|
-
}}
|
|
139
|
+
${() => state.render ? template(data, state) : ''}
|
|
141
140
|
</label>
|
|
142
141
|
|
|
143
142
|
${description(data)}
|
|
@@ -22,6 +22,41 @@ type Data = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
function template(data: Data) {
|
|
26
|
+
return html`
|
|
27
|
+
<div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
|
|
28
|
+
${(data?.items || []).map(item => html`
|
|
29
|
+
${item?.border ? html`
|
|
30
|
+
<div
|
|
31
|
+
class="border ${item?.border?.class || ''}"
|
|
32
|
+
style='
|
|
33
|
+
margin-left: calc(var(--margin-horizontal) * -1);
|
|
34
|
+
width: calc(100% + var(--margin-horizontal) * 2);
|
|
35
|
+
'
|
|
36
|
+
></div>
|
|
37
|
+
` : ''}
|
|
38
|
+
|
|
39
|
+
<${item?.url ? 'a' : 'div'}
|
|
40
|
+
class='link --flex-vertical ${item?.class}' ${item?.onclick ? html({ onclick: item.onclick }) : ''}
|
|
41
|
+
style='${item?.style || ''}'
|
|
42
|
+
${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
|
|
43
|
+
>
|
|
44
|
+
${item?.svg ? html`
|
|
45
|
+
<div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
|
|
46
|
+
${item.svg}
|
|
47
|
+
</div>
|
|
48
|
+
` : ''}
|
|
49
|
+
|
|
50
|
+
<div class="text --color-text --flex-fill">
|
|
51
|
+
${item.text}
|
|
52
|
+
</div>
|
|
53
|
+
</${item?.url ? 'a' : 'div'}>
|
|
54
|
+
`)}
|
|
55
|
+
</div>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
25
60
|
export default (data: Data) => {
|
|
26
61
|
let state = reactive({
|
|
27
62
|
render: false
|
|
@@ -35,41 +70,5 @@ export default (data: Data) => {
|
|
|
35
70
|
state.render = true;
|
|
36
71
|
});
|
|
37
72
|
|
|
38
|
-
return () =>
|
|
39
|
-
if (!state.render) {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return html`
|
|
44
|
-
<div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
|
|
45
|
-
${(data?.items || []).map(item => html`
|
|
46
|
-
${item?.border ? html`
|
|
47
|
-
<div
|
|
48
|
-
class="border ${item?.border?.class || ''}"
|
|
49
|
-
style='
|
|
50
|
-
margin-left: calc(var(--margin-horizontal) * -1);
|
|
51
|
-
width: calc(100% + var(--margin-horizontal) * 2);
|
|
52
|
-
'
|
|
53
|
-
></div>
|
|
54
|
-
` : ''}
|
|
55
|
-
|
|
56
|
-
<${item?.url ? 'a' : 'div'}
|
|
57
|
-
class='link --flex-vertical ${item?.class}' ${item?.onclick ? html({ onclick: item.onclick }) : ''}
|
|
58
|
-
style='${item?.style || ''}'
|
|
59
|
-
${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
|
|
60
|
-
>
|
|
61
|
-
${item?.svg ? html`
|
|
62
|
-
<div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
|
|
63
|
-
${item.svg}
|
|
64
|
-
</div>
|
|
65
|
-
` : ''}
|
|
66
|
-
|
|
67
|
-
<div class="text --color-text --flex-fill">
|
|
68
|
-
${item.text}
|
|
69
|
-
</div>
|
|
70
|
-
</${item?.url ? 'a' : 'div'}>
|
|
71
|
-
`)}
|
|
72
|
-
</div>
|
|
73
|
-
`;
|
|
74
|
-
};
|
|
73
|
+
return () => state.render ? template(data) : '';
|
|
75
74
|
};
|