@esportsplus/ui 0.18.0 → 0.19.0
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/.github/dependabot.yml +2 -0
- package/.github/workflows/bump.yml +2 -0
- package/.github/workflows/dependabot.yml +12 -0
- package/.github/workflows/publish.yml +2 -0
- package/build/components/accordion/index.d.ts +5 -15
- package/build/components/accordion/index.js +28 -20
- package/build/components/counter/index.d.ts +2 -2
- package/build/components/counter/index.js +10 -10
- package/build/components/ellipsis/index.d.ts +1 -1
- package/build/components/field/checkbox.d.ts +9 -339
- package/build/components/field/checkbox.js +24 -21
- package/build/components/field/description.d.ts +3 -3
- package/build/components/field/error.d.ts +3 -2
- package/build/components/field/index.d.ts +1912 -0
- package/build/components/field/index.js +9 -0
- package/build/components/field/input.d.ts +18 -348
- package/build/components/field/input.js +33 -23
- package/build/components/field/select.d.ts +119 -226
- package/build/components/field/select.js +81 -69
- package/build/components/field/title.d.ts +114 -107
- package/build/components/field/title.js +15 -8
- package/build/components/form/action.d.ts +21 -6
- package/build/components/form/action.js +20 -9
- package/build/components/form/index.d.ts +130 -2
- package/build/components/frame/index.d.ts +3 -112
- package/build/components/frame/index.js +4 -6
- package/build/components/highlight/index.d.ts +5 -7
- package/build/components/highlight/index.js +23 -15
- package/build/components/icon/index.d.ts +3 -3
- package/build/components/index.d.ts +2 -2
- package/build/components/index.js +2 -2
- package/build/components/loader/index.d.ts +3 -3
- package/build/components/loader/index.js +13 -16
- package/build/components/loading/index.d.ts +1 -1
- package/build/components/overlay/index.d.ts +3 -112
- package/build/components/overlay/index.js +4 -6
- package/build/components/page/index.d.ts +0 -12
- package/build/components/page/index.js +0 -10
- package/build/components/root/onclick.js +4 -6
- package/build/components/scrollbar/index.d.ts +8 -112
- package/build/components/scrollbar/index.js +25 -20
- package/build/components/sidebar/index.d.ts +3 -112
- package/build/components/sidebar/index.js +4 -6
- package/build/components/site/index.d.ts +3 -112
- package/build/components/site/index.js +5 -8
- package/build/components/template/index.d.ts +8 -4
- package/build/components/template/index.js +5 -4
- package/build/components/tooltip/index.d.ts +235 -332
- package/build/components/tooltip/index.js +3 -106
- package/build/components/tooltip/menu.d.ts +20 -0
- package/build/components/tooltip/menu.js +28 -0
- package/build/components/tooltip/onclick.d.ts +124 -0
- package/build/components/tooltip/onclick.js +67 -0
- package/build/components/tooltip/onhover.d.ts +7 -0
- package/build/components/tooltip/onhover.js +25 -0
- package/build/components/typewriter/index.d.ts +4 -6
- package/build/components/typewriter/index.js +34 -33
- package/package.json +10 -9
- package/src/components/accordion/index.ts +41 -26
- package/src/components/counter/index.ts +15 -13
- package/src/components/field/checkbox.ts +31 -30
- package/src/components/field/description.ts +2 -2
- package/src/components/field/error.ts +2 -2
- package/src/components/field/index.ts +8 -3
- package/src/components/field/input.ts +41 -33
- package/src/components/field/select.ts +123 -108
- package/src/components/field/title.ts +18 -8
- package/src/components/form/action.ts +75 -47
- package/src/components/frame/index.ts +4 -9
- package/src/components/highlight/index.ts +53 -39
- package/src/components/icon/index.ts +3 -3
- package/src/components/index.ts +2 -2
- package/src/components/loader/index.ts +15 -17
- package/src/components/overlay/index.ts +4 -9
- package/src/components/page/index.ts +1 -17
- package/src/components/root/onclick.ts +6 -7
- package/src/components/scrollbar/index.ts +34 -23
- package/src/components/sidebar/index.ts +4 -9
- package/src/components/site/index.ts +5 -13
- package/src/components/template/index.ts +18 -10
- package/src/components/tooltip/index.ts +4 -156
- package/src/components/tooltip/menu.ts +52 -0
- package/src/components/tooltip/onclick.ts +97 -0
- package/src/components/tooltip/onhover.ts +35 -0
- package/src/components/typewriter/index.ts +44 -41
- package/build/components/footer/index.d.ts +0 -22
- package/build/components/footer/index.js +0 -61
- package/build/components/footer/scss/index.scss +0 -2
- package/build/components/form/types.d.ts +0 -10
- package/build/components/form/types.js +0 -1
- package/src/components/footer/index.ts +0 -74
- package/src/components/footer/scss/index.scss +0 -26
- package/src/components/form/types.ts +0 -14
|
@@ -4,10 +4,13 @@ import { omit } from '@esportsplus/utilities';
|
|
|
4
4
|
import './scss/index.scss';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
const OMIT = ['currency', 'decimals', 'delay', 'max', 'state', 'suffix', 'value'];
|
|
8
|
+
|
|
9
|
+
|
|
7
10
|
let formatters: Record<string, Intl.NumberFormat> = {};
|
|
8
11
|
|
|
9
12
|
|
|
10
|
-
export default (
|
|
13
|
+
export default (attributes: Attributes & {
|
|
11
14
|
currency?: 'IGNORE' | 'EUR' | 'GBP' | 'USD';
|
|
12
15
|
decimals?: number;
|
|
13
16
|
delay?: number;
|
|
@@ -16,8 +19,8 @@ export default (data: Attributes & {
|
|
|
16
19
|
suffix?: string;
|
|
17
20
|
value: number;
|
|
18
21
|
}) => {
|
|
19
|
-
let { currency, decimals, delay, max, suffix, value } =
|
|
20
|
-
api =
|
|
22
|
+
let { currency, decimals, delay, max, suffix, value } = attributes,
|
|
23
|
+
api = attributes.state || reactive({ value: -1 }),
|
|
21
24
|
formatter = currency === 'IGNORE'
|
|
22
25
|
? undefined
|
|
23
26
|
: formatters[currency || 'USD'] ??= new Intl.NumberFormat('en-US', {
|
|
@@ -76,7 +79,7 @@ export default (data: Attributes & {
|
|
|
76
79
|
});
|
|
77
80
|
|
|
78
81
|
return html`
|
|
79
|
-
<div class='counter' ${omit(
|
|
82
|
+
<div class='counter' ${omit(attributes, OMIT)}>
|
|
80
83
|
${() => {
|
|
81
84
|
let n = state.length;
|
|
82
85
|
|
|
@@ -85,7 +88,7 @@ export default (data: Attributes & {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
return html.reactive(state.render, function (value, i) {
|
|
88
|
-
if (isNaN(parseInt(value
|
|
91
|
+
if (isNaN(parseInt(value, 10))) {
|
|
89
92
|
return html`
|
|
90
93
|
<span class='counter-character counter-character--symbol'>
|
|
91
94
|
${value}
|
|
@@ -94,20 +97,19 @@ export default (data: Attributes & {
|
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
return html`
|
|
97
|
-
<div
|
|
98
|
-
class
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
<div class='counter-character-track' style='${() => `--value: ${this[i]}`}'>
|
|
100
|
+
<div class=' counter-character' ${{
|
|
101
|
+
class: i > n - 3 && 'counter-character--fraction'
|
|
102
|
+
}}>
|
|
103
|
+
<div class='counter-character-track' ${{
|
|
104
|
+
style: `--value: ${this[i]}`}
|
|
105
|
+
}}>
|
|
104
106
|
<span>9</span>
|
|
105
107
|
${[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((value) => html`<span>${value}</span>`)}
|
|
106
108
|
<span>0</span>
|
|
107
109
|
</div>
|
|
108
110
|
</div>
|
|
109
111
|
`;
|
|
110
|
-
})
|
|
112
|
+
});
|
|
111
113
|
}}
|
|
112
114
|
</div>
|
|
113
115
|
`;
|
|
@@ -14,59 +14,60 @@ type A = Attributes & {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const OMIT_FIELD = ['state'];
|
|
18
|
+
|
|
19
|
+
const TAG = ['checked', 'disabled', 'name', 'required'];
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
function mask(attributes: A, modifier: string, state: { active: boolean }) {
|
|
21
23
|
return html`
|
|
22
24
|
<div
|
|
23
|
-
class='
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
class='field-mask'
|
|
26
|
+
${omit(attributes, TAG)}
|
|
27
|
+
${{
|
|
28
|
+
class: `field-mask--${modifier}`
|
|
29
|
+
}}
|
|
28
30
|
>
|
|
29
31
|
<input
|
|
30
|
-
${attributes.checked || attributes.value || state.active && 'checked'}
|
|
31
32
|
class='field-mask-tag field-mask-tag--hidden'
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
${{
|
|
34
|
+
checked: attributes.checked || attributes.value || state.active,
|
|
35
|
+
type: modifier === 'radio' ? 'radio' : 'checkbox',
|
|
36
|
+
value: attributes.value || 1
|
|
37
|
+
}}
|
|
38
|
+
${pick(attributes, TAG) as Attributes}
|
|
35
39
|
>
|
|
36
40
|
</div>
|
|
37
41
|
`;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
|
|
41
|
-
const field = template.factory
|
|
42
|
-
Attributes & { state?: { active: boolean } },
|
|
43
|
-
(mask: ((attributes: A) => Renderable)) => Renderable
|
|
44
|
-
>(
|
|
45
|
+
const field = template.factory(
|
|
45
46
|
function(
|
|
46
|
-
this: ((attributes: A, state: { active: boolean }) => Renderable),
|
|
47
|
-
attributes,
|
|
48
|
-
content
|
|
47
|
+
this: ((attributes: A, state: { active: boolean }) => Renderable<unknown>),
|
|
48
|
+
attributes: Attributes & { state?: { active: boolean } },
|
|
49
|
+
content: (mask: ((attributes: A) => Renderable<unknown>)) => Renderable<unknown>
|
|
49
50
|
) {
|
|
50
|
-
let state = attributes
|
|
51
|
+
let state = attributes?.state || reactive({
|
|
51
52
|
active: false
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
return html`
|
|
55
56
|
<label
|
|
56
|
-
class='
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
class='field'
|
|
58
|
+
${omit(attributes, OMIT_FIELD)}
|
|
59
|
+
${{
|
|
60
|
+
class: () => state.active && '--active',
|
|
61
|
+
onchange: (e) => {
|
|
62
|
+
if ((e.target as HTMLInputElement).type !== 'checkbox') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
state.active = (e.target as HTMLInputElement)?.checked;
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
68
69
|
>
|
|
69
|
-
${content((attributes
|
|
70
|
+
${content((attributes) => this(attributes, state))}
|
|
70
71
|
</label>
|
|
71
72
|
`
|
|
72
73
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from '@esportsplus/template';
|
|
2
2
|
import template from '~/components/template';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
export default template.factory
|
|
5
|
+
export default template.factory(
|
|
6
6
|
(attributes, content) => html`
|
|
7
7
|
<div class='field-description' ${attributes}>
|
|
8
8
|
${content}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { html } from '@esportsplus/template';
|
|
1
|
+
import { html, Renderable } from '@esportsplus/template';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export default (state: { error: unknown }) => {
|
|
4
|
+
export default (state: { error: Renderable<unknown> }) => {
|
|
5
5
|
return () => {
|
|
6
6
|
if (!state.error) {
|
|
7
7
|
return '';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import checkbox from './checkbox';
|
|
2
2
|
import description from './description';
|
|
3
|
-
import select from './select';
|
|
4
3
|
import input from './input';
|
|
4
|
+
import select from './select';
|
|
5
5
|
import title from './title';
|
|
6
6
|
import './scss/index.scss';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const { checkbox: cb, radio, switch: sw } = checkbox;
|
|
10
|
+
|
|
11
|
+
const { file, text, textarea } = input;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export default { checkbox: cb, description, file, radio, select, switch: sw, textarea, text, title };
|
|
15
|
+
export { cb as checkbox, description, file, radio, select, sw as switch, textarea, text, title };
|
|
@@ -6,9 +6,11 @@ import template from '~/components/template';
|
|
|
6
6
|
import error from './error';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const FILE_TAG = ['accept', 'disabled', 'name', 'required', 'value'];
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const OMIT = ['state'];
|
|
12
|
+
|
|
13
|
+
const TEXT_TAG = [
|
|
12
14
|
'autocapitalize',
|
|
13
15
|
'autocomplete',
|
|
14
16
|
'autocorrect',
|
|
@@ -27,14 +29,11 @@ const TEXT_TAG_KEYS = [
|
|
|
27
29
|
];
|
|
28
30
|
|
|
29
31
|
|
|
30
|
-
const field = template.factory
|
|
31
|
-
Attributes & { state?: { active: boolean, error: string } },
|
|
32
|
-
(mask: typeof file | typeof text | typeof textarea) => Renderable
|
|
33
|
-
>(
|
|
32
|
+
const field = template.factory(
|
|
34
33
|
function(
|
|
35
34
|
this: typeof text | typeof textarea,
|
|
36
|
-
attributes,
|
|
37
|
-
content
|
|
35
|
+
attributes: Attributes & { state?: { active: boolean, error: string } },
|
|
36
|
+
content: (mask: typeof file | typeof text | typeof textarea) => Renderable<unknown>
|
|
38
37
|
) {
|
|
39
38
|
let state = attributes.state || reactive({
|
|
40
39
|
active: false,
|
|
@@ -43,17 +42,17 @@ const field = template.factory<
|
|
|
43
42
|
|
|
44
43
|
return html`
|
|
45
44
|
<div
|
|
46
|
-
class='
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
class='field'
|
|
46
|
+
${omit(attributes, OMIT)}
|
|
47
|
+
${{
|
|
48
|
+
class: () => state.active && '--active',
|
|
49
|
+
onfocusin: () => {
|
|
50
|
+
state.active = true;
|
|
51
|
+
},
|
|
52
|
+
onfocusout: () => {
|
|
53
|
+
state.active = false;
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
57
56
|
>
|
|
58
57
|
${content(
|
|
59
58
|
((...args: any[]) => (this.call as any)(state, ...args))
|
|
@@ -64,18 +63,20 @@ const field = template.factory<
|
|
|
64
63
|
}
|
|
65
64
|
);
|
|
66
65
|
|
|
67
|
-
const file = template.factory
|
|
66
|
+
const file = template.factory(
|
|
68
67
|
function(this: { active: boolean, error: string }, attributes, content) {
|
|
69
68
|
return html`
|
|
70
69
|
<label
|
|
71
70
|
class='field-mask field-mask--file'
|
|
72
|
-
${omit(attributes,
|
|
71
|
+
${omit(attributes, FILE_TAG)}
|
|
73
72
|
>
|
|
74
73
|
<input
|
|
75
74
|
class='field-mask-tag field-mask-tag--hidden'
|
|
76
|
-
onrender='${form.input.onrender(this)}'
|
|
77
75
|
type='file'
|
|
78
|
-
${pick(attributes,
|
|
76
|
+
${pick(attributes, FILE_TAG) as Attributes}
|
|
77
|
+
${{
|
|
78
|
+
onrender: form.input.onrender(this)
|
|
79
|
+
}}
|
|
79
80
|
>
|
|
80
81
|
|
|
81
82
|
${content}
|
|
@@ -84,15 +85,17 @@ const file = template.factory<Attributes>(
|
|
|
84
85
|
}
|
|
85
86
|
);
|
|
86
87
|
|
|
87
|
-
const text = template.factory
|
|
88
|
+
const text = template.factory(
|
|
88
89
|
function(this: { active: boolean, error: string }, attributes, content) {
|
|
89
90
|
return html`
|
|
90
|
-
<label class='field-mask field-mask--input' ${omit(attributes,
|
|
91
|
+
<label class='field-mask field-mask--input' ${omit(attributes, TEXT_TAG)}>
|
|
91
92
|
<input
|
|
92
93
|
class='field-mask-tag'
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
${pick(attributes, TEXT_TAG) as Attributes}
|
|
95
|
+
${{
|
|
96
|
+
onrender: form.input.onrender(this),
|
|
97
|
+
type: attributes.type || 'text'
|
|
98
|
+
}}
|
|
96
99
|
>
|
|
97
100
|
${content}
|
|
98
101
|
</label>
|
|
@@ -100,14 +103,19 @@ const text = template.factory<Attributes>(
|
|
|
100
103
|
}
|
|
101
104
|
);
|
|
102
105
|
|
|
103
|
-
const textarea = template.factory
|
|
104
|
-
function(this: { active: boolean, error: string }, attributes, content) {
|
|
106
|
+
const textarea = template.factory(
|
|
107
|
+
function(this: { active: boolean, error: string }, attributes: Attributes & { value?: string }, content) {
|
|
105
108
|
return html`
|
|
106
|
-
<label
|
|
109
|
+
<label
|
|
110
|
+
class='field-mask field-mask--textarea'
|
|
111
|
+
${omit(attributes, TEXT_TAG)}
|
|
112
|
+
>
|
|
107
113
|
<textarea
|
|
108
114
|
class='field-mask-tag'
|
|
109
|
-
|
|
110
|
-
${
|
|
115
|
+
${pick(attributes, TEXT_TAG) as Attributes}
|
|
116
|
+
${{
|
|
117
|
+
onrender: form.input.onrender(this)
|
|
118
|
+
}}
|
|
111
119
|
>
|
|
112
120
|
${attributes.value}
|
|
113
121
|
</textarea>
|
|
@@ -3,12 +3,12 @@ import { html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
|
3
3
|
import { isObject, omit, pick, toArray } from '@esportsplus/utilities';
|
|
4
4
|
import form from '~/components/form';
|
|
5
5
|
import root from '~/components/root';
|
|
6
|
-
import scrollbar from '~/components/scrollbar';
|
|
6
|
+
import scrollbar, { Attributes as A } from '~/components/scrollbar';
|
|
7
7
|
import template from '~/components/template';
|
|
8
8
|
import error from './error';
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const PICK_TAG = [
|
|
12
12
|
'autocomplete',
|
|
13
13
|
'autofocus',
|
|
14
14
|
'disabled',
|
|
@@ -17,15 +17,23 @@ const TAG_KEYS = [
|
|
|
17
17
|
'type'
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
+
const OMIT_FIELD = ['options', 'state'];
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const OMIT_MASK = [
|
|
23
|
+
...PICK_TAG,
|
|
24
|
+
'field-mask-arrow',
|
|
25
|
+
'field-mask-text',
|
|
26
|
+
'scrollbar',
|
|
27
|
+
'scrollbar-container-content',
|
|
28
|
+
'tooltip-content',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const OMIT_OPTION = ['content'];
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const select = template.factory(
|
|
27
35
|
function(
|
|
28
|
-
this:
|
|
36
|
+
this: {
|
|
29
37
|
options: Record<number | string, Attributes & { content: unknown }>;
|
|
30
38
|
option?: Attributes;
|
|
31
39
|
state: {
|
|
@@ -35,7 +43,11 @@ const select = template.factory<
|
|
|
35
43
|
selected: string | number;
|
|
36
44
|
}
|
|
37
45
|
},
|
|
38
|
-
|
|
46
|
+
attributes: Attributes & A & {
|
|
47
|
+
'field-mask-arrow'?: Attributes;
|
|
48
|
+
'field-mask-text'?: Attributes;
|
|
49
|
+
'tooltip-content'?: Attributes & { direction?: string };
|
|
50
|
+
},
|
|
39
51
|
content
|
|
40
52
|
) {
|
|
41
53
|
let { option, options, state } = this;
|
|
@@ -43,82 +55,86 @@ const select = template.factory<
|
|
|
43
55
|
return html`
|
|
44
56
|
<label
|
|
45
57
|
class='field-mask field-mask--select'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
${omit(attributes, OMIT_MASK)}
|
|
59
|
+
${{
|
|
60
|
+
onclick: () => {
|
|
61
|
+
state.active = !state.active;
|
|
62
|
+
state.render = true;
|
|
63
|
+
|
|
64
|
+
if (state.active) {
|
|
65
|
+
root.onclick.push(() => state.active = false);
|
|
66
|
+
}
|
|
52
67
|
}
|
|
53
|
-
}}
|
|
54
|
-
${omit(data, TAG_KEYS)}
|
|
68
|
+
}}
|
|
55
69
|
>
|
|
56
|
-
<input
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
<input class='field-mask-tag field-mask-tag--hidden'
|
|
71
|
+
${{
|
|
72
|
+
name: attributes.name,
|
|
73
|
+
onclick: () => { /* Prevent double click events from firing */ },
|
|
74
|
+
onrender: form.input.onrender(state),
|
|
75
|
+
value: () => state.selected
|
|
76
|
+
}}
|
|
77
|
+
${pick(attributes, PICK_TAG) as Attributes}
|
|
63
78
|
>
|
|
64
79
|
|
|
65
80
|
${content || html`
|
|
66
|
-
<div class='field-mask-text' ${
|
|
67
|
-
${() => options[ state.selected ] || '-'}
|
|
81
|
+
<div class='field-mask-text' ${attributes['field-mask-text']}>
|
|
82
|
+
${() => (options[ state.selected ] || '-') as any}
|
|
68
83
|
</div>
|
|
69
84
|
`}
|
|
70
85
|
|
|
71
|
-
<div class='field-mask-arrow'></div>
|
|
86
|
+
<div class='field-mask-arrow' ${attributes['field-mask-arrow']}></div>
|
|
72
87
|
|
|
73
88
|
${() => {
|
|
74
89
|
if (!state.render) {
|
|
75
90
|
return;
|
|
76
91
|
}
|
|
77
92
|
|
|
78
|
-
let
|
|
79
|
-
...data['tooltip-content'],
|
|
80
|
-
scrollbar: { ...data['scrollbar'] },
|
|
81
|
-
'scrollbar-container-content': { ...data['scrollbar-container-content'] }
|
|
82
|
-
},
|
|
83
|
-
keys = Object.keys(options),
|
|
93
|
+
let keys = Object.keys(options),
|
|
84
94
|
selected = reactive(
|
|
85
95
|
Object.fromEntries( keys.map(key => [key, false]) )
|
|
86
96
|
);
|
|
87
97
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
return scrollbar(
|
|
99
|
+
{
|
|
100
|
+
...attributes['tooltip-content'],
|
|
101
|
+
class: [
|
|
102
|
+
...toArray(attributes['tooltip-content']?.class),
|
|
103
|
+
`tooltip-content tooltip-content--${attributes['tooltip-content']?.direction || 's'} --flex-column --width-full`
|
|
104
|
+
],
|
|
105
|
+
onclick: (e: Event) => {
|
|
106
|
+
let key = (e?.target as HTMLElement)?.dataset?.key;
|
|
107
|
+
|
|
108
|
+
if (key === undefined) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let previous = state.selected;
|
|
113
|
+
|
|
114
|
+
state.selected = key;
|
|
115
|
+
state.active = false;
|
|
116
|
+
|
|
117
|
+
selected[key] = true;
|
|
118
|
+
selected[previous] = false;
|
|
119
|
+
},
|
|
120
|
+
scrollbar: attributes['scrollbar'],
|
|
121
|
+
'scrollbar-container-content': attributes['scrollbar-container-content']
|
|
122
|
+
},
|
|
123
|
+
keys.map((key) => html`
|
|
124
|
+
<div class='link'
|
|
125
|
+
${omit(options[key], OMIT_OPTION)}
|
|
126
|
+
${option}
|
|
127
|
+
${{
|
|
128
|
+
class: () => selected[key] && '--active',
|
|
129
|
+
'data-key': key
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<span class='--text-truncate'>
|
|
133
|
+
${options[key]}
|
|
134
|
+
</span>
|
|
135
|
+
</div>
|
|
136
|
+
`)
|
|
137
|
+
);
|
|
122
138
|
}}
|
|
123
139
|
</label>
|
|
124
140
|
`;
|
|
@@ -126,9 +142,12 @@ const select = template.factory<
|
|
|
126
142
|
);
|
|
127
143
|
|
|
128
144
|
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
129
148
|
export default template.factory<
|
|
130
149
|
Attributes & {
|
|
131
|
-
options: Record<number | string, number | string | Attributes & { content: unknown }>;
|
|
150
|
+
options: Record<number | string, (number | string | Attributes & { content: unknown })>;
|
|
132
151
|
option?: Attributes;
|
|
133
152
|
} & (
|
|
134
153
|
{
|
|
@@ -143,45 +162,41 @@ export default template.factory<
|
|
|
143
162
|
}
|
|
144
163
|
}
|
|
145
164
|
),
|
|
146
|
-
(mask: typeof select) => Renderable
|
|
147
|
-
>(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
options[key] = { content: options[key] };
|
|
165
|
+
(mask: typeof select) => Renderable<unknown>
|
|
166
|
+
>((attributes, content) => {
|
|
167
|
+
let options = attributes.options,
|
|
168
|
+
state = attributes.state || reactive({
|
|
169
|
+
active: false,
|
|
170
|
+
error: '',
|
|
171
|
+
selected: attributes.selected || Object.keys(options)[0]
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
for (let key in options) {
|
|
175
|
+
if (isObject(options[key])) {
|
|
176
|
+
continue;
|
|
162
177
|
}
|
|
163
178
|
|
|
164
|
-
|
|
165
|
-
<div
|
|
166
|
-
class='
|
|
167
|
-
${() => state.active && '--active'}
|
|
168
|
-
field
|
|
169
|
-
tooltip
|
|
170
|
-
'
|
|
171
|
-
${omit(data, ['options', 'state'])}
|
|
172
|
-
>
|
|
173
|
-
${content(
|
|
174
|
-
(...args: any[]) => (select.call as any)(
|
|
175
|
-
{
|
|
176
|
-
option: data.option,
|
|
177
|
-
options: data.options,
|
|
178
|
-
state
|
|
179
|
-
},
|
|
180
|
-
...args
|
|
181
|
-
)
|
|
182
|
-
)}
|
|
183
|
-
${error(state)}
|
|
184
|
-
</div>
|
|
185
|
-
`;
|
|
179
|
+
options[key] = { content: options[key] };
|
|
186
180
|
}
|
|
187
|
-
|
|
181
|
+
|
|
182
|
+
return html`
|
|
183
|
+
<div class='field tooltip'
|
|
184
|
+
${omit(attributes as any, OMIT_FIELD)}
|
|
185
|
+
${{
|
|
186
|
+
class: () => state.active && '--active'
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
${content(
|
|
190
|
+
(...args: any[]) => (select.call as any)(
|
|
191
|
+
{
|
|
192
|
+
option: attributes.option,
|
|
193
|
+
options: attributes.options,
|
|
194
|
+
state
|
|
195
|
+
},
|
|
196
|
+
...args
|
|
197
|
+
)
|
|
198
|
+
)}
|
|
199
|
+
${error(state)}
|
|
200
|
+
</div>
|
|
201
|
+
`;
|
|
202
|
+
});
|