@esportsplus/ui 0.24.4 → 0.25.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/build/components/checkbox/index.d.ts +11 -0
- package/build/components/checkbox/index.js +33 -0
- package/build/components/checkbox/scss/index.scss +2 -0
- package/build/components/index.d.ts +7 -1
- package/build/components/index.js +7 -1
- package/build/components/input/index.d.ts +21 -0
- package/build/components/input/index.js +38 -0
- package/build/components/input/scss/index.scss +2 -0
- package/build/components/radio/index.d.ts +11 -0
- package/build/components/radio/index.js +33 -0
- package/build/components/radio/scss/index.scss +2 -0
- package/build/components/range/index.d.ts +21 -0
- package/build/components/range/index.js +46 -0
- package/build/components/range/scss/index.scss +2 -0
- package/build/components/select/index.d.ts +44 -0
- package/build/components/{field/select.js → select/index.js} +43 -70
- package/build/components/select/scss/index.scss +2 -0
- package/build/components/switch/index.d.ts +11 -0
- package/build/components/switch/index.js +33 -0
- package/build/components/switch/scss/index.scss +2 -0
- package/build/components/text/scss/index.scss +1 -1
- package/build/components/textarea/index.d.ts +21 -0
- package/build/components/textarea/index.js +37 -0
- package/build/components/textarea/scss/index.scss +2 -0
- package/build/normalize/scss/index.scss +1 -1
- package/package.json +2 -2
- package/src/components/checkbox/index.ts +45 -0
- package/src/components/checkbox/scss/index.scss +50 -0
- package/src/components/checkbox/scss/variables.scss +72 -0
- package/src/components/index.ts +7 -1
- package/src/components/input/index.ts +52 -0
- package/src/components/input/scss/index.scss +37 -0
- package/src/components/input/scss/variables.scss +50 -0
- package/src/components/radio/index.ts +45 -0
- package/src/components/radio/scss/index.scss +50 -0
- package/src/components/radio/scss/variables.scss +67 -0
- package/src/components/range/index.ts +61 -0
- package/src/components/range/scss/index.scss +31 -0
- package/src/components/range/scss/variables.scss +8 -0
- package/src/components/select/index.ts +166 -0
- package/src/components/select/scss/index.scss +36 -0
- package/src/components/select/scss/variables.scss +12 -0
- package/src/components/switch/index.ts +45 -0
- package/src/components/switch/scss/index.scss +48 -0
- package/src/components/switch/scss/variables.scss +72 -0
- package/src/components/text/scss/index.scss +31 -0
- package/src/components/textarea/index.ts +51 -0
- package/src/components/textarea/scss/index.scss +26 -0
- package/src/components/textarea/scss/variables.scss +49 -0
- package/src/normalize/scss/index.scss +36 -1
- package/build/components/field/checkbox.d.ts +0 -73
- package/build/components/field/checkbox.js +0 -71
- package/build/components/field/description.d.ts +0 -19
- package/build/components/field/description.js +0 -7
- package/build/components/field/error.d.ts +0 -5
- package/build/components/field/error.js +0 -13
- package/build/components/field/index.d.ts +0 -18331
- package/build/components/field/index.js +0 -10
- package/build/components/field/input.d.ts +0 -156
- package/build/components/field/input.js +0 -97
- package/build/components/field/scss/index.scss +0 -2
- package/build/components/field/select.d.ts +0 -1321
- package/build/components/field/title.d.ts +0 -1169
- package/build/components/field/title.js +0 -20
- package/src/components/field/checkbox.ts +0 -97
- package/src/components/field/description.ts +0 -11
- package/src/components/field/error.ts +0 -16
- package/src/components/field/index.ts +0 -15
- package/src/components/field/input.ts +0 -134
- package/src/components/field/scss/check.scss +0 -227
- package/src/components/field/scss/index.scss +0 -133
- package/src/components/field/scss/normalize.scss +0 -34
- package/src/components/field/scss/range.scss +0 -46
- package/src/components/field/scss/text.scss +0 -120
- package/src/components/field/scss/variables.scss +0 -128
- package/src/components/field/select.ts +0 -220
- package/src/components/field/title.ts +0 -27
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
@mixin css() {
|
|
2
|
-
&-mask {
|
|
3
|
-
&--range {
|
|
4
|
-
margin: calc((var(--height) - var(--thumb-size)) / 2) 0;
|
|
5
|
-
|
|
6
|
-
.field-mask-tag {
|
|
7
|
-
background: var(--background);
|
|
8
|
-
border-radius: 240px;
|
|
9
|
-
border: 0px;
|
|
10
|
-
height: var(--height);
|
|
11
|
-
transition: opacity .2s;
|
|
12
|
-
width: var(--width);
|
|
13
|
-
|
|
14
|
-
&::-moz-range-thumb,
|
|
15
|
-
&::-webkit-slider-thumb {
|
|
16
|
-
background: var(--thumb-background);
|
|
17
|
-
border-radius: 100%;
|
|
18
|
-
border: var(--border-width) solid var(--border-color);
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
height: var(--thumb-size);
|
|
21
|
-
width: var(--thumb-size);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&,
|
|
25
|
-
&::-moz-range-thumb,
|
|
26
|
-
&::-webkit-slider-thumb {
|
|
27
|
-
appearance: none;
|
|
28
|
-
outline: none;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@mixin variables() {
|
|
36
|
-
&-mask {
|
|
37
|
-
&--range {
|
|
38
|
-
--background-default: var(--color-black-300);
|
|
39
|
-
--border-width: var(--border-width-700);
|
|
40
|
-
--height: var(--size-200);
|
|
41
|
-
--thumb-background: var(--color-white-400);
|
|
42
|
-
--thumb-size: var(--size-400);
|
|
43
|
-
--width: 100%;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
@use '/lib';
|
|
2
|
-
|
|
3
|
-
@mixin css() {
|
|
4
|
-
&-mask {
|
|
5
|
-
&--file,
|
|
6
|
-
&--input,
|
|
7
|
-
&--select,
|
|
8
|
-
&--textarea {
|
|
9
|
-
align-items: center;
|
|
10
|
-
background: var(--background);
|
|
11
|
-
border: var(--border-width) var(--border-style) var(--border-color);
|
|
12
|
-
border-radius: var(--border-radius);
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-wrap: wrap;
|
|
15
|
-
font-size: var(--font-size);
|
|
16
|
-
line-height: var(--line-height);
|
|
17
|
-
position: relative;
|
|
18
|
-
width: 100%;
|
|
19
|
-
|
|
20
|
-
&:invalid,
|
|
21
|
-
&:required {
|
|
22
|
-
box-shadow: none;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&,
|
|
26
|
-
.field-mask-tag {
|
|
27
|
-
color: var(--color);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Truncate Overflowing Text
|
|
31
|
-
&.field-text {
|
|
32
|
-
overflow: hidden;
|
|
33
|
-
text-overflow: ellipsis;
|
|
34
|
-
white-space: nowrap;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&--file,
|
|
39
|
-
&--input,
|
|
40
|
-
&--textarea {
|
|
41
|
-
cursor: text;
|
|
42
|
-
// Necessary To Maintain Height Of Hidden Password Fields In Floating Modals
|
|
43
|
-
// - Password Managers Cause Problems When Fields Are Not Using 'display:hidden' On Password Fields
|
|
44
|
-
min-height: calc((var(--padding-vertical) * 2) + var(--size));
|
|
45
|
-
|
|
46
|
-
.field-mask-tag {
|
|
47
|
-
flex: 1 1 auto;
|
|
48
|
-
padding: var(--padding-vertical) var(--padding-horizontal);
|
|
49
|
-
min-width: 0;
|
|
50
|
-
|
|
51
|
-
&[type='number'] {
|
|
52
|
-
appearance: textfield;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
textarea.field-mask-tag {
|
|
57
|
-
white-space: normal;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&--file {
|
|
62
|
-
cursor: pointer;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&--select {
|
|
66
|
-
cursor: pointer;
|
|
67
|
-
padding: var(--padding-vertical) calc((var(--padding-horizontal) / 1.5) + var(--arrow-size)) var(--padding-vertical) var(--padding-horizontal);
|
|
68
|
-
|
|
69
|
-
&.--padding {
|
|
70
|
-
padding-right: calc((var(--padding-horizontal) * 1.5) + var(--arrow-size));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Down Arrow
|
|
75
|
-
&-arrow {
|
|
76
|
-
@include lib.position(absolute, null calc(var(--padding-horizontal) + var(--arrow-spacer)) calc(50% + var(--arrow-spacer)) null);
|
|
77
|
-
border-color: var(--border-color);
|
|
78
|
-
border-style: var(--border-style);
|
|
79
|
-
border-width: 0 var(--border-width) var(--border-width) 0;
|
|
80
|
-
content: '';
|
|
81
|
-
height: var(--arrow-size);
|
|
82
|
-
transform: translateY(50%) rotate(45deg);
|
|
83
|
-
width: var(--arrow-size);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&-text {
|
|
87
|
-
padding-right: var(--padding-horizontal);
|
|
88
|
-
pointer-events: none;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@mixin variables() {
|
|
94
|
-
&-mask {
|
|
95
|
-
&--file,
|
|
96
|
-
&--input,
|
|
97
|
-
&--select,
|
|
98
|
-
&--textarea {
|
|
99
|
-
--font-size: var(--font-size-400);
|
|
100
|
-
--line-height: var(--line-height-400);
|
|
101
|
-
--padding-horizontal: var(--size-400);
|
|
102
|
-
--padding-vertical: var(--size-400);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&--file,
|
|
106
|
-
&--input,
|
|
107
|
-
&--textarea {
|
|
108
|
-
--size: var(--size-400);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
&--select {
|
|
112
|
-
--arrow-spacer: 1px;
|
|
113
|
-
--arrow-size: 6px;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
&-arrow {
|
|
117
|
-
--border-width: var(--border-width-500);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
@use '/tokens';
|
|
2
|
-
@use 'check' as check;
|
|
3
|
-
@use 'range' as range;
|
|
4
|
-
@use 'text' as text;
|
|
5
|
-
|
|
6
|
-
.field {
|
|
7
|
-
--margin-horizontal: 0px;
|
|
8
|
-
--margin-vertical: var(--size-300);
|
|
9
|
-
--width: 100%;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
&-description,
|
|
13
|
-
&-error {
|
|
14
|
-
--font-size: var(--font-size-300);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&-error {
|
|
18
|
-
--color: var(--color-red-400);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&-mask {
|
|
22
|
-
--background: var(--background-default);
|
|
23
|
-
--background-active: var(--background-default);
|
|
24
|
-
--background-default: transparent;
|
|
25
|
-
--background-hover: var(--background-default);
|
|
26
|
-
--background-pressed: var(--background-default);
|
|
27
|
-
--border-color: var(--border-color-default);
|
|
28
|
-
--border-color-default: var(--background);
|
|
29
|
-
--border-radius: var(--border-radius-400);
|
|
30
|
-
--border-style: solid;
|
|
31
|
-
--border-width: 0px;
|
|
32
|
-
--box-shadow: var(--box-shadow-default);
|
|
33
|
-
--box-shadow-default: none;
|
|
34
|
-
--color: var(--color-default);
|
|
35
|
-
--color-active: var(--color-default);
|
|
36
|
-
--color-default: var(--color-text-400);
|
|
37
|
-
--color-hover: var(--color-default);
|
|
38
|
-
--color-pressed: var(--color-default);
|
|
39
|
-
--outline-opacity: var(--outline-opacity-default);
|
|
40
|
-
--outline-opacity-active: 0.32;
|
|
41
|
-
--outline-opacity-default: 0;
|
|
42
|
-
--outline-opacity-hover: 0;
|
|
43
|
-
--outline-opacity-pressed: 0;
|
|
44
|
-
--outline-spacing: 0px;
|
|
45
|
-
--outline-width: var(--outline-width-default);
|
|
46
|
-
--outline-width-active: 4px;
|
|
47
|
-
--outline-width-default: 0px;
|
|
48
|
-
--outline-width-hover: 0px;
|
|
49
|
-
--outline-width-pressed: 0px;
|
|
50
|
-
--padding-horizontal: 0px;
|
|
51
|
-
--padding-vertical: var(--size-400);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#{tokens.state(active, '.field')} > &,
|
|
55
|
-
#{tokens.state(active, '.field')} *:not(.field) & {
|
|
56
|
-
--background: var(--background-active);
|
|
57
|
-
--border-color: var(--border-color-active);
|
|
58
|
-
--box-shadow: var(--box-shadow-active);
|
|
59
|
-
--color: var(--color-active);
|
|
60
|
-
--outline-opacity: var(--outline-opacity-active);
|
|
61
|
-
--outline-width: var(--outline-width-active);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
$inactive: tokens.state(inactive, '.field');
|
|
65
|
-
|
|
66
|
-
#{tokens.state(hover, 'label#{$inactive}')} > &,
|
|
67
|
-
#{tokens.state(hover, '#{$inactive}:not(label) &')} {
|
|
68
|
-
--background: var(--background-hover);
|
|
69
|
-
--border-color: var(--border-color-hover);
|
|
70
|
-
--box-shadow: var(--box-shadow-hover);
|
|
71
|
-
--color: var(--color-hover);
|
|
72
|
-
--outline-opacity: var(--outline-opacity-hover);
|
|
73
|
-
--outline-width: var(--outline-width-hover);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
#{tokens.state(pressed, 'label#{$inactive}')} > &,
|
|
77
|
-
#{tokens.state(pressed, '#{$inactive}:not(label) &')} {
|
|
78
|
-
--background: var(--background-pressed);
|
|
79
|
-
--border-color: var(--border-color-pressed);
|
|
80
|
-
--box-shadow: var(--box-shadow-pressed);
|
|
81
|
-
--color: var(--color-pressed);
|
|
82
|
-
--outline-opacity: var(--outline-opacity-pressed);
|
|
83
|
-
--outline-width: var(--outline-width-pressed);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&--outline {
|
|
87
|
-
@include tokens.state(pressed) {
|
|
88
|
-
--border-color: var(--border-color-default);
|
|
89
|
-
|
|
90
|
-
&::before {
|
|
91
|
-
--outline-width: 0px;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
&-required {
|
|
98
|
-
--border-radius: 100%;
|
|
99
|
-
--size: 6px;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&-title {
|
|
103
|
-
--color: var(--color-default);
|
|
104
|
-
--color-active: var(--color-default);
|
|
105
|
-
--color-default: var(--color-text-400);
|
|
106
|
-
--color-hover: var(--color-default);
|
|
107
|
-
--color-pressed: var(--color-default);
|
|
108
|
-
--font-size: var(--font-size-400);
|
|
109
|
-
--font-weight: var(--font-weight-500);
|
|
110
|
-
|
|
111
|
-
#{tokens.state(active, '.field')} & {
|
|
112
|
-
--color: var(--color-active);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#{tokens.state(hover, '.field')} & {
|
|
116
|
-
--color: var(--color-hover);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
#{tokens.state(pressed, '.field')} & {
|
|
120
|
-
--color: var(--color-pressed);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
@include check.variables();
|
|
126
|
-
@include range.variables();
|
|
127
|
-
@include text.variables();
|
|
128
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
-
import { html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
3
|
-
import { isObject, omit, toArray } from '@esportsplus/utilities';
|
|
4
|
-
import form from '~/components/form';
|
|
5
|
-
import root from '~/components/root';
|
|
6
|
-
import scrollbar, { Attributes as Attr } from '~/components/scrollbar';
|
|
7
|
-
import template from '~/components/template';
|
|
8
|
-
import error from './error';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const OMIT_FIELD = ['options', 'state'];
|
|
12
|
-
|
|
13
|
-
const OMIT_MASK = [
|
|
14
|
-
'field-mask-arrow',
|
|
15
|
-
'field-mask-text',
|
|
16
|
-
'field-mask-tag',
|
|
17
|
-
'scrollbar',
|
|
18
|
-
'scrollbar-container-content',
|
|
19
|
-
'tooltip-content',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const OMIT_OPTION = ['content'];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type A = {
|
|
26
|
-
'field-mask-arrow'?: Attributes;
|
|
27
|
-
'field-mask-tag'?: Attributes;
|
|
28
|
-
'field-mask-text'?: Attributes;
|
|
29
|
-
'tooltip-content'?: Attributes & { direction?: string };
|
|
30
|
-
} & Attributes & Attr;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let field: { active: boolean } | null = null;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function set(state: { active: boolean }, value: boolean) {
|
|
37
|
-
state.active = value;
|
|
38
|
-
|
|
39
|
-
if (state.active) {
|
|
40
|
-
root.onclick.push(() => state.active = false);
|
|
41
|
-
|
|
42
|
-
if (field) {
|
|
43
|
-
field.active = false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
field = state;
|
|
47
|
-
}
|
|
48
|
-
else if (field === state) {
|
|
49
|
-
field = null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const select = function(
|
|
55
|
-
this: {
|
|
56
|
-
options: { content: unknown } & Attributes;
|
|
57
|
-
option?: Attributes;
|
|
58
|
-
state: {
|
|
59
|
-
active: boolean;
|
|
60
|
-
error: string;
|
|
61
|
-
render: boolean;
|
|
62
|
-
selected: string | number;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
attributes: A,
|
|
66
|
-
content: Renderable<unknown>
|
|
67
|
-
) {
|
|
68
|
-
let { option, options, state } = this;
|
|
69
|
-
|
|
70
|
-
return html`
|
|
71
|
-
<label
|
|
72
|
-
class='field-mask field-mask--select'
|
|
73
|
-
${omit(attributes, OMIT_MASK)}
|
|
74
|
-
${{
|
|
75
|
-
onclick: () => {
|
|
76
|
-
if (state.render) {
|
|
77
|
-
set(state, !state.active);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
state.render = true;
|
|
81
|
-
}
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
<input class='field-mask-tag field-mask-tag--hidden'
|
|
85
|
-
${{
|
|
86
|
-
name: attributes.name,
|
|
87
|
-
onclick: () => { /* Prevent double click events from firing */ },
|
|
88
|
-
onrender: form.input.onrender(state),
|
|
89
|
-
value: () => state.selected
|
|
90
|
-
}}
|
|
91
|
-
${attributes['field-mask-tag']}
|
|
92
|
-
>
|
|
93
|
-
|
|
94
|
-
${content || html`
|
|
95
|
-
<div class='field-mask-text' ${attributes['field-mask-text']}>
|
|
96
|
-
${() => {
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
return (options[ state.selected ]?.content || '-');
|
|
99
|
-
}}
|
|
100
|
-
</div>
|
|
101
|
-
`}
|
|
102
|
-
|
|
103
|
-
<div class='field-mask-arrow' ${attributes['field-mask-arrow']}></div>
|
|
104
|
-
|
|
105
|
-
${() => {
|
|
106
|
-
if (!state.render) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let keys = Object.keys(options),
|
|
111
|
-
selected = reactive(
|
|
112
|
-
Object.fromEntries( keys.map(key => [key, false]) )
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
return scrollbar(
|
|
116
|
-
{
|
|
117
|
-
...attributes['tooltip-content'],
|
|
118
|
-
class: [
|
|
119
|
-
...toArray(attributes['tooltip-content']?.class),
|
|
120
|
-
`tooltip-content tooltip-content--${attributes['tooltip-content']?.direction || 's'} --flex-column --width-full`
|
|
121
|
-
],
|
|
122
|
-
onclick: (e: Event) => {
|
|
123
|
-
let key = (e?.target as HTMLElement)?.dataset?.key;
|
|
124
|
-
|
|
125
|
-
if (key === undefined) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
let previous = state.selected;
|
|
130
|
-
|
|
131
|
-
set(state, false);
|
|
132
|
-
state.selected = key;
|
|
133
|
-
|
|
134
|
-
selected[key] = true;
|
|
135
|
-
selected[previous] = false;
|
|
136
|
-
},
|
|
137
|
-
onconnect: () => {
|
|
138
|
-
set(state, true);
|
|
139
|
-
},
|
|
140
|
-
scrollbar: attributes['scrollbar'],
|
|
141
|
-
'scrollbar-container-content': attributes['scrollbar-container-content']
|
|
142
|
-
},
|
|
143
|
-
keys.map((key) => html`
|
|
144
|
-
<div class='link'
|
|
145
|
-
${omit(options[key] as Attributes, OMIT_OPTION)}
|
|
146
|
-
${option}
|
|
147
|
-
${{
|
|
148
|
-
class: () => selected[key] && '--active',
|
|
149
|
-
'data-key': key
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
<span class='--text-truncate --pointer-none'>
|
|
153
|
-
${(options[key] as any).content}
|
|
154
|
-
</span>
|
|
155
|
-
</div>
|
|
156
|
-
`)
|
|
157
|
-
);
|
|
158
|
-
}}
|
|
159
|
-
</label>
|
|
160
|
-
`;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
export default template.factory<
|
|
165
|
-
Attributes & {
|
|
166
|
-
options: Record<number | string, (number | string | Attributes & { content: unknown })>;
|
|
167
|
-
option?: Attributes;
|
|
168
|
-
} & (
|
|
169
|
-
{
|
|
170
|
-
selected?: number | string;
|
|
171
|
-
state?: never;
|
|
172
|
-
} |
|
|
173
|
-
{
|
|
174
|
-
state: {
|
|
175
|
-
active: boolean;
|
|
176
|
-
error: string;
|
|
177
|
-
render: boolean;
|
|
178
|
-
selected?: number | string;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
),
|
|
182
|
-
(mask: typeof select) => Renderable<unknown>
|
|
183
|
-
>((attributes, content) => {
|
|
184
|
-
let options = attributes.options,
|
|
185
|
-
state = attributes.state || reactive({
|
|
186
|
-
active: false,
|
|
187
|
-
error: '',
|
|
188
|
-
render: false,
|
|
189
|
-
selected: attributes.selected || Object.keys(options)[0]
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
for (let key in options) {
|
|
193
|
-
if (isObject(options[key])) {
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
options[key] = { content: options[key] };
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return html`
|
|
201
|
-
<div class='field tooltip'
|
|
202
|
-
${omit(attributes as any, OMIT_FIELD)}
|
|
203
|
-
${{
|
|
204
|
-
class: () => state.active && '--active'
|
|
205
|
-
}}
|
|
206
|
-
>
|
|
207
|
-
${content(
|
|
208
|
-
(...args: any[]) => (select.call as any)(
|
|
209
|
-
{
|
|
210
|
-
option: attributes.option,
|
|
211
|
-
options: attributes.options,
|
|
212
|
-
state
|
|
213
|
-
},
|
|
214
|
-
...args
|
|
215
|
-
)
|
|
216
|
-
)}
|
|
217
|
-
${error(state)}
|
|
218
|
-
</div>
|
|
219
|
-
`;
|
|
220
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { html, Attributes } from '@esportsplus/template';
|
|
2
|
-
import { omit } from '@esportsplus/utilities';
|
|
3
|
-
import tooltip from '~/components/tooltip';
|
|
4
|
-
import template from '~/components/template';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const OMIT = ['required'];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export default template.factory<Attributes & { required?: boolean }>(
|
|
11
|
-
(attributes, content) =>{
|
|
12
|
-
let required = attributes?.required;
|
|
13
|
-
|
|
14
|
-
return html`
|
|
15
|
-
<div
|
|
16
|
-
class='field-title --flex-horizontal-space-between --flex-vertical'
|
|
17
|
-
${omit(attributes, OMIT)}
|
|
18
|
-
>
|
|
19
|
-
${content}
|
|
20
|
-
|
|
21
|
-
${required && tooltip.onhover({ class: 'bubble --background-primary --margin-left' }, html`
|
|
22
|
-
<span class='tooltip-message tooltip-message--w'>Required</span>
|
|
23
|
-
`)}
|
|
24
|
-
</div>
|
|
25
|
-
`;
|
|
26
|
-
}
|
|
27
|
-
);
|