@esportsplus/ui 0.25.9 → 0.27.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 +125 -5
- package/build/components/checkbox/index.js +12 -12
- package/build/components/input/index.d.ts +21 -15
- package/build/components/input/index.js +6 -16
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/radio/index.d.ts +116 -6
- package/build/components/radio/index.js +2 -32
- package/build/components/range/index.d.ts +22 -15
- package/build/components/range/index.js +10 -20
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/select/index.d.ts +24 -8
- package/build/components/select/index.js +34 -38
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/switch/index.d.ts +116 -6
- package/build/components/switch/index.js +2 -32
- package/build/components/textarea/index.d.ts +21 -15
- package/build/components/textarea/index.js +9 -15
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/css-utilities/flex/scss/index.scss +1 -1
- package/package.json +1 -1
- package/src/components/checkbox/index.ts +17 -18
- package/src/components/input/index.ts +10 -26
- package/src/components/input/scss/index.scss +13 -10
- package/src/components/input/scss/variables.scss +1 -1
- package/src/components/radio/index.ts +2 -42
- package/src/components/range/index.ts +16 -32
- package/src/components/range/scss/index.scss +26 -27
- package/src/components/range/scss/variables.scss +2 -0
- package/src/components/root/scss/variables.scss +1 -1
- package/src/components/select/index.ts +46 -46
- package/src/components/select/scss/index.scss +22 -13
- package/src/components/select/scss/variables.scss +39 -1
- package/src/components/switch/index.ts +2 -42
- package/src/components/textarea/index.ts +11 -21
- package/src/components/textarea/scss/index.scss +11 -8
- package/src/css-utilities/flex/scss/index.scss +7 -0
- package/src/css-utilities/flex/scss/variables.scss +39 -0
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import { reactive } from '@esportsplus/reactivity';
|
|
2
2
|
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import form from '~/components/form';
|
|
5
4
|
import template from '~/components/template';
|
|
6
5
|
import './scss/index.scss';
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
type A = Attributes & {
|
|
10
|
-
'input-tag'?: Attributes,
|
|
11
|
-
state?: { active: boolean, error: string }
|
|
12
|
-
};
|
|
8
|
+
type A = Attributes & { state?: { active: boolean, error: string } };
|
|
13
9
|
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default template.factory(
|
|
19
|
-
function(attributes: A, content) {
|
|
20
|
-
let a = attributes['input-tag'],
|
|
21
|
-
state = attributes.state || reactive({
|
|
11
|
+
export default template.factory<A, never>(
|
|
12
|
+
function(attributes) {
|
|
13
|
+
let state = attributes.state || reactive({
|
|
22
14
|
active: false,
|
|
23
15
|
error: ''
|
|
24
16
|
});
|
|
25
17
|
|
|
26
18
|
return html`
|
|
27
|
-
<
|
|
19
|
+
<input
|
|
28
20
|
class='input'
|
|
29
21
|
${{
|
|
30
22
|
class: () => state.active && '--active',
|
|
@@ -33,20 +25,12 @@ export default template.factory(
|
|
|
33
25
|
},
|
|
34
26
|
onfocusout: () => {
|
|
35
27
|
state.active = false;
|
|
36
|
-
}
|
|
28
|
+
},
|
|
29
|
+
onrender: form.input.onrender(state),
|
|
30
|
+
type: (attributes.type || 'text') as string
|
|
37
31
|
}}
|
|
38
|
-
${
|
|
39
|
-
|
|
40
|
-
<input
|
|
41
|
-
class='input-tag'
|
|
42
|
-
${{
|
|
43
|
-
onrender: form.input.onrender(state),
|
|
44
|
-
type: (attributes.type || 'text') as string
|
|
45
|
-
}}
|
|
46
|
-
${a}
|
|
47
|
-
>
|
|
48
|
-
${content}
|
|
49
|
-
</label>
|
|
32
|
+
${attributes}
|
|
33
|
+
/>
|
|
50
34
|
`;
|
|
51
35
|
}
|
|
52
36
|
);
|
|
@@ -5,17 +5,27 @@
|
|
|
5
5
|
background: var(--background);
|
|
6
6
|
border: var(--border-width) var(--border-style) var(--border-color);
|
|
7
7
|
border-radius: var(--border-radius);
|
|
8
|
+
color: var(--color);
|
|
8
9
|
cursor: text;
|
|
9
10
|
display: flex;
|
|
10
|
-
|
|
11
|
+
flex: 1 1 auto;
|
|
11
12
|
flex-wrap: wrap;
|
|
12
13
|
font-size: var(--font-size);
|
|
13
14
|
line-height: var(--line-height);
|
|
14
15
|
// Necessary To Maintain Height Of Hidden Password Fields In Floating Modals
|
|
15
16
|
// - Password Managers Cause Problems When Fields Are Not Using 'display:hidden' On Password Fields
|
|
16
17
|
min-height: calc((var(--padding-vertical) * 2) + var(--size));
|
|
18
|
+
min-width: 0;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
padding: var(--padding-vertical) var(--padding-horizontal);
|
|
17
21
|
position: relative;
|
|
18
22
|
text-overflow: ellipsis;
|
|
23
|
+
transition:
|
|
24
|
+
background var(--transition-duration) ease-in-out,
|
|
25
|
+
border-color var(--transition-duration) ease-in-out,
|
|
26
|
+
box-shadow var(--transition-duration) ease-in-out,
|
|
27
|
+
opacity var(--transition-duration) ease-in-out,
|
|
28
|
+
transform var(--transition-duration) ease-in-out;
|
|
19
29
|
white-space: nowrap;
|
|
20
30
|
width: 100%;
|
|
21
31
|
|
|
@@ -24,14 +34,7 @@
|
|
|
24
34
|
box-shadow: none;
|
|
25
35
|
}
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
flex: 1 1 auto;
|
|
30
|
-
padding: var(--padding-vertical) var(--padding-horizontal);
|
|
31
|
-
min-width: 0;
|
|
32
|
-
|
|
33
|
-
&[type='number'] {
|
|
34
|
-
appearance: textfield;
|
|
35
|
-
}
|
|
37
|
+
&[type='number'] {
|
|
38
|
+
appearance: textfield;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
#{tokens.state(inactive)} {
|
|
29
29
|
@include tokens.state(hover) {
|
|
30
|
-
|
|
30
|
+
--background: var(--background-hover);
|
|
31
31
|
--border-color: var(--border-color-hover);
|
|
32
32
|
--box-shadow: var(--box-shadow-hover);
|
|
33
33
|
--color: var(--color-hover);
|
|
@@ -1,45 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
|
-
import form from '~/components/form';
|
|
1
|
+
import { template } from '~/components/checkbox';
|
|
5
2
|
import './scss/index.scss';
|
|
6
3
|
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
'radio-tag'?: Attributes,
|
|
10
|
-
state?: { active: boolean, error: string }
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const OMIT = ['radio-tag'];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export default function(attributes?: A) {
|
|
18
|
-
let a = attributes?.['radio-tag'],
|
|
19
|
-
state = attributes?.state || reactive({
|
|
20
|
-
active: false,
|
|
21
|
-
error: ''
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (a?.checked) {
|
|
25
|
-
state.active = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return html`
|
|
29
|
-
<div class='radio ${() => state.active && '--active'}' ${a ? omit(attributes!, OMIT) : attributes}>
|
|
30
|
-
<input
|
|
31
|
-
class='radio-tag'
|
|
32
|
-
type='radio'
|
|
33
|
-
${{
|
|
34
|
-
checked: a?.checked || root(() => state.active),
|
|
35
|
-
onchange: (e: Event) => {
|
|
36
|
-
state.active = (e.target as HTMLInputElement).checked;
|
|
37
|
-
},
|
|
38
|
-
onrender: form.input.onrender(state),
|
|
39
|
-
value: a?.value || 1
|
|
40
|
-
}}
|
|
41
|
-
${a}
|
|
42
|
-
>
|
|
43
|
-
</div>
|
|
44
|
-
`;
|
|
45
|
-
};
|
|
5
|
+
export default template.bind({ type: 'radio' });
|
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
import { reactive, root } from '@esportsplus/reactivity';
|
|
2
2
|
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import form from '~/components/form';
|
|
5
4
|
import template from '~/components/template';
|
|
6
5
|
import './scss/index.scss';
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
type A = Attributes & {
|
|
10
|
-
'range-tag'?: Attributes,
|
|
11
|
-
state?: { active: boolean, error: string, value: number }
|
|
12
|
-
};
|
|
8
|
+
type A = Attributes & { state?: { active: boolean, error: string, value: number } };
|
|
13
9
|
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default template.factory(
|
|
19
|
-
function(attributes: A, content) {
|
|
20
|
-
let a = attributes['range-tag'],
|
|
21
|
-
state = attributes.state || reactive({
|
|
11
|
+
export default template.factory<A, never>(
|
|
12
|
+
function(attributes) {
|
|
13
|
+
let state = attributes.state || reactive({
|
|
22
14
|
active: false,
|
|
23
15
|
error: '',
|
|
24
16
|
value: 0
|
|
25
17
|
});
|
|
26
18
|
|
|
27
|
-
if (
|
|
28
|
-
state.value = Number(
|
|
19
|
+
if (attributes?.value) {
|
|
20
|
+
state.value = Number( attributes.value );
|
|
29
21
|
}
|
|
30
22
|
|
|
31
23
|
return html`
|
|
32
|
-
<
|
|
24
|
+
<input
|
|
33
25
|
class='range --border-state --border-black'
|
|
26
|
+
type='range'
|
|
34
27
|
${{
|
|
35
28
|
class: () => state.active && '--active',
|
|
36
29
|
onfocusin: () => {
|
|
@@ -38,24 +31,15 @@ export default template.factory(
|
|
|
38
31
|
},
|
|
39
32
|
onfocusout: () => {
|
|
40
33
|
state.active = false;
|
|
41
|
-
}
|
|
34
|
+
},
|
|
35
|
+
oninput: (e) => {
|
|
36
|
+
state.value = Number((e.target as HTMLInputElement).value);
|
|
37
|
+
},
|
|
38
|
+
onrender: form.input.onrender(state),
|
|
39
|
+
value: root(() => (attributes?.value as number) || state.value || 0)
|
|
42
40
|
}}
|
|
43
|
-
${
|
|
44
|
-
|
|
45
|
-
<input
|
|
46
|
-
class='range-tag'
|
|
47
|
-
type='range'
|
|
48
|
-
${{
|
|
49
|
-
oninput: (e) => {
|
|
50
|
-
state.value = Number((e.target as HTMLInputElement).value);
|
|
51
|
-
},
|
|
52
|
-
onrender: form.input.onrender(state),
|
|
53
|
-
value: root(() => (a?.value as number) || state.value || 0)
|
|
54
|
-
}}
|
|
55
|
-
${a}
|
|
56
|
-
>
|
|
57
|
-
${content}
|
|
58
|
-
</div>
|
|
41
|
+
${attributes}
|
|
42
|
+
/>
|
|
59
43
|
`;
|
|
60
44
|
}
|
|
61
45
|
);
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
@use 'variables';
|
|
2
2
|
|
|
3
3
|
.range {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
background
|
|
11
|
-
border-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
background: var(--background);
|
|
5
|
+
border-radius: 240px;
|
|
6
|
+
border: 0px;
|
|
7
|
+
height: var(--height);
|
|
8
|
+
margin: calc(var(--margin-vertical) + ((var(--thumb-size) - var(--height)) / 2)) var(--margin-horizontal);
|
|
9
|
+
transition:
|
|
10
|
+
background var(--transition-duration) ease-in-out,
|
|
11
|
+
border-color var(--transition-duration) ease-in-out,
|
|
12
|
+
box-shadow var(--transition-duration) ease-in-out,
|
|
13
|
+
opacity var(--transition-duration) ease-in-out,
|
|
14
|
+
transform var(--transition-duration) ease-in-out;
|
|
15
|
+
width: var(--width);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
&::-moz-range-thumb,
|
|
18
|
+
&::-webkit-slider-thumb {
|
|
19
|
+
background: var(--thumb-background);
|
|
20
|
+
border-radius: 100%;
|
|
21
|
+
border: var(--border-width) solid var(--border-color);
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
height: var(--thumb-size);
|
|
24
|
+
width: var(--thumb-size);
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
27
|
+
&,
|
|
28
|
+
&::-moz-range-thumb,
|
|
29
|
+
&::-webkit-slider-thumb {
|
|
30
|
+
appearance: none;
|
|
31
|
+
outline: none;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
--background-pressed: var(--background-default);
|
|
9
9
|
--border-width: var(--border-width-700);
|
|
10
10
|
--height: var(--size-200);
|
|
11
|
+
--margin-horizontal: 0;
|
|
12
|
+
--margin-vertical: 0;
|
|
11
13
|
--thumb-background: var(--color-white-400);
|
|
12
14
|
--thumb-size: var(--size-400);
|
|
13
15
|
--width: 100%;
|
|
@@ -9,10 +9,9 @@ import './scss/index.scss';
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
const OMIT = [
|
|
12
|
+
'arrow',
|
|
12
13
|
'options',
|
|
13
|
-
'
|
|
14
|
-
'select-tag',
|
|
15
|
-
'select-text',
|
|
14
|
+
'option',
|
|
16
15
|
'scrollbar',
|
|
17
16
|
'scrollbar-container-content',
|
|
18
17
|
'tooltip-content',
|
|
@@ -20,14 +19,12 @@ const OMIT = [
|
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
type A = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
arrow?: Renderable<unknown>;
|
|
23
|
+
options: Record<number | string, Renderable<unknown>>;
|
|
24
|
+
option?: typeof option;
|
|
25
|
+
scrollbar?: Attributes;
|
|
27
26
|
'scrollbar-container-content'?: Attributes;
|
|
28
27
|
'tooltip-content'?: Attributes & { direction?: string };
|
|
29
|
-
options: Record<number | string, Renderable<unknown>>;
|
|
30
|
-
option?: Attributes;
|
|
31
28
|
} & (
|
|
32
29
|
{
|
|
33
30
|
selected?: number | string;
|
|
@@ -64,9 +61,19 @@ function set(state: { active: boolean }, value: boolean) {
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
const option = template.factory(
|
|
65
|
+
function(attributes, content) {
|
|
66
|
+
return html`
|
|
67
|
+
<div class='link --padding-400' ${attributes}>
|
|
68
|
+
${content}
|
|
69
|
+
</div>
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const select = template.factory<A>(
|
|
68
75
|
function(attributes: A, content) {
|
|
69
|
-
let
|
|
76
|
+
let options = attributes.options,
|
|
70
77
|
state = attributes.state || reactive({
|
|
71
78
|
active: false,
|
|
72
79
|
error: '',
|
|
@@ -77,17 +84,23 @@ export default template.factory<A>(
|
|
|
77
84
|
return html`
|
|
78
85
|
<label
|
|
79
86
|
class='select'
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (state.render) {
|
|
84
|
-
set(state, !state.active);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
state.render = true;
|
|
87
|
+
onclick=${() => {
|
|
88
|
+
if (state.render) {
|
|
89
|
+
set(state, !state.active);
|
|
88
90
|
}
|
|
91
|
+
|
|
92
|
+
state.render = true;
|
|
89
93
|
}}
|
|
94
|
+
${omit(attributes, OMIT)}
|
|
90
95
|
>
|
|
96
|
+
${content || html`
|
|
97
|
+
<div class='select-content text'>
|
|
98
|
+
${() => options[ state.selected! ] || '-'}
|
|
99
|
+
</div>
|
|
100
|
+
`}
|
|
101
|
+
|
|
102
|
+
${attributes['arrow'] || html`<div class='select-arrow'></div>`}
|
|
103
|
+
|
|
91
104
|
<input class='select-tag'
|
|
92
105
|
${{
|
|
93
106
|
name: attributes.name,
|
|
@@ -95,16 +108,7 @@ export default template.factory<A>(
|
|
|
95
108
|
onrender: form.input.onrender(state),
|
|
96
109
|
value: () => state.selected
|
|
97
110
|
}}
|
|
98
|
-
|
|
99
|
-
>
|
|
100
|
-
|
|
101
|
-
${content || html`
|
|
102
|
-
<div class='select-text' ${attributes['select-text']}>
|
|
103
|
-
${() => options[ state.selected! ] || '-'}
|
|
104
|
-
</div>
|
|
105
|
-
`}
|
|
106
|
-
|
|
107
|
-
<div class='select-arrow' ${attributes['select-arrow']}></div>
|
|
111
|
+
/>
|
|
108
112
|
|
|
109
113
|
${() => {
|
|
110
114
|
if (!state.render) {
|
|
@@ -114,7 +118,8 @@ export default template.factory<A>(
|
|
|
114
118
|
let keys = Object.keys(options),
|
|
115
119
|
selected = reactive(
|
|
116
120
|
Object.fromEntries( keys.map(key => [key, false]) )
|
|
117
|
-
)
|
|
121
|
+
),
|
|
122
|
+
template = attributes.option || option;
|
|
118
123
|
|
|
119
124
|
return scrollbar(
|
|
120
125
|
{
|
|
@@ -141,26 +146,21 @@ export default template.factory<A>(
|
|
|
141
146
|
onconnect: () => {
|
|
142
147
|
set(state, true);
|
|
143
148
|
},
|
|
144
|
-
scrollbar: attributes
|
|
149
|
+
scrollbar: attributes.scrollbar,
|
|
145
150
|
'scrollbar-container-content': attributes['scrollbar-container-content']
|
|
146
151
|
},
|
|
147
|
-
keys.map((key) =>
|
|
148
|
-
|
|
149
|
-
class
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
class: () => selected[key] && '--active',
|
|
154
|
-
}}
|
|
155
|
-
>
|
|
156
|
-
<span class='--text-truncate --pointer-none'>
|
|
157
|
-
${options[key]}
|
|
158
|
-
</span>
|
|
159
|
-
</div>
|
|
160
|
-
`)
|
|
152
|
+
keys.map((key) => {
|
|
153
|
+
return template({
|
|
154
|
+
class: () => selected[key] && '--active',
|
|
155
|
+
'data-key': key
|
|
156
|
+
}, options[key]);
|
|
157
|
+
})
|
|
161
158
|
);
|
|
162
159
|
}}
|
|
163
160
|
</label>
|
|
164
161
|
`;
|
|
165
162
|
}
|
|
166
|
-
);
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
export default select;
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
@use '/lib';
|
|
2
2
|
|
|
3
3
|
.select {
|
|
4
|
-
align-items: center;
|
|
5
|
-
background: var(--background);
|
|
6
|
-
border: var(--border-width) var(--border-style) var(--border-color);
|
|
7
|
-
border-radius: var(--border-radius);
|
|
8
4
|
cursor: pointer;
|
|
9
5
|
display: flex;
|
|
10
6
|
flex-wrap: wrap;
|
|
11
|
-
font-size: var(--font-size);
|
|
12
|
-
line-height: var(--line-height);
|
|
13
|
-
padding: var(--padding-vertical) calc((var(--padding-horizontal) / 1.5) + var(--arrow-size)) var(--padding-vertical) var(--padding-horizontal);
|
|
14
7
|
position: relative;
|
|
8
|
+
transition:
|
|
9
|
+
background var(--transition-duration) ease-in-out,
|
|
10
|
+
border-color var(--transition-duration) ease-in-out,
|
|
11
|
+
box-shadow var(--transition-duration) ease-in-out,
|
|
12
|
+
opacity var(--transition-duration) ease-in-out,
|
|
13
|
+
transform var(--transition-duration) ease-in-out;
|
|
15
14
|
width: 100%;
|
|
16
15
|
|
|
17
|
-
&:invalid,
|
|
18
|
-
&:required {
|
|
19
|
-
box-shadow: none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
&-arrow {
|
|
23
17
|
@include lib.position(absolute, null calc(var(--padding-horizontal) + var(--arrow-spacer)) calc(50% + var(--arrow-spacer)) null);
|
|
24
18
|
border-color: var(--border-color);
|
|
@@ -30,7 +24,22 @@
|
|
|
30
24
|
width: var(--arrow-size);
|
|
31
25
|
}
|
|
32
26
|
|
|
27
|
+
&-content {
|
|
28
|
+
background: var(--background);
|
|
29
|
+
border: var(--border-width) var(--border-style) var(--border-color);
|
|
30
|
+
border-radius: var(--border-radius);
|
|
31
|
+
font-size: var(--font-size);
|
|
32
|
+
line-height: var(--line-height);
|
|
33
|
+
padding: var(--padding-vertical) calc((var(--padding-horizontal) / 1.5) + var(--arrow-size)) var(--padding-vertical) var(--padding-horizontal);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Hide HTML Field Element
|
|
33
37
|
&-tag {
|
|
34
|
-
|
|
38
|
+
@include lib.position(absolute, 0 null null 0);
|
|
39
|
+
height: 0px;
|
|
40
|
+
opacity: 0;
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
width: 0px;
|
|
43
|
+
z-index: 0;
|
|
35
44
|
}
|
|
36
45
|
}
|
|
@@ -1,11 +1,49 @@
|
|
|
1
1
|
.select {
|
|
2
|
-
--arrow-spacer: 1px;
|
|
3
2
|
--arrow-size: 6px;
|
|
3
|
+
--arrow-spacer: 1px;
|
|
4
|
+
--background: var(--background-default);
|
|
5
|
+
--background-active: var(--background-default);
|
|
6
|
+
--background-default: transparent;
|
|
7
|
+
--background-hover: var(--background-default);
|
|
8
|
+
--background-pressed: var(--background-default);
|
|
9
|
+
--border-color: var(--border-color-default);
|
|
10
|
+
--border-color-default: var(--background);
|
|
11
|
+
--border-radius: var(--border-radius-400);
|
|
12
|
+
--border-style: solid;
|
|
13
|
+
--border-width: 0px;
|
|
14
|
+
--color: var(--color-default);
|
|
15
|
+
--color-active: var(--color-default);
|
|
16
|
+
--color-default: var(--color-text-400);
|
|
17
|
+
--color-hover: var(--color-default);
|
|
18
|
+
--color-pressed: var(--color-default);
|
|
4
19
|
--font-size: var(--font-size-400);
|
|
5
20
|
--line-height: var(--line-height-400);
|
|
6
21
|
--padding-horizontal: var(--size-400);
|
|
7
22
|
--padding-vertical: var(--size-400);
|
|
8
23
|
|
|
24
|
+
#{tokens.state(inactive)} {
|
|
25
|
+
@include tokens.state(hover) {
|
|
26
|
+
--background: var(--background-hover);
|
|
27
|
+
--border-color: var(--border-color-hover);
|
|
28
|
+
--box-shadow: var(--box-shadow-hover);
|
|
29
|
+
--color: var(--color-hover);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include tokens.state(pressed) {
|
|
33
|
+
--background: var(--background-pressed);
|
|
34
|
+
--border-color: var(--border-color-pressed);
|
|
35
|
+
--box-shadow: var(--box-shadow-pressed);
|
|
36
|
+
--color: var(--color-pressed);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#{tokens.state(active)} {
|
|
41
|
+
--background: var(--background-active);
|
|
42
|
+
--border-color: var(--border-color-active);
|
|
43
|
+
--box-shadow: var(--box-shadow-active);
|
|
44
|
+
--color: var(--color-active);
|
|
45
|
+
}
|
|
46
|
+
|
|
9
47
|
&-arrow {
|
|
10
48
|
--border-width: var(--border-width-500);
|
|
11
49
|
}
|
|
@@ -1,45 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
|
-
import form from '~/components/form';
|
|
1
|
+
import { template } from '~/components/checkbox';
|
|
5
2
|
import './scss/index.scss';
|
|
6
3
|
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
'switch-tag'?: Attributes,
|
|
10
|
-
state?: { active: boolean, error: string }
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const OMIT = ['switch-tag'];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export default function(attributes?: A) {
|
|
18
|
-
let a = attributes?.['switch-tag'],
|
|
19
|
-
state = attributes?.state || reactive({
|
|
20
|
-
active: false,
|
|
21
|
-
error: ''
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (a?.checked) {
|
|
25
|
-
state.active = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return html`
|
|
29
|
-
<div class='switch' ${a ? omit(attributes!, OMIT) : attributes}>
|
|
30
|
-
<input
|
|
31
|
-
class='switch-tag'
|
|
32
|
-
type='checkbox'
|
|
33
|
-
${{
|
|
34
|
-
checked: a?.checked || root(() => state.active),
|
|
35
|
-
onchange: (e: Event) => {
|
|
36
|
-
state.active = (e.target as HTMLInputElement).checked;
|
|
37
|
-
},
|
|
38
|
-
onrender: form.input.onrender(state),
|
|
39
|
-
value: a?.value || 1
|
|
40
|
-
}}
|
|
41
|
-
${a}
|
|
42
|
-
>
|
|
43
|
-
</div>
|
|
44
|
-
`;
|
|
45
|
-
};
|
|
5
|
+
export default template.bind({ type: 'switch' });
|