@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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
4
|
+
import form from '../../components/form/index.js';
|
|
5
|
+
import template from '../../components/template/index.js';
|
|
6
|
+
import './scss/index.scss';
|
|
7
|
+
const OMIT = ['textarea-tag'];
|
|
8
|
+
export default template.factory(function (attributes, content) {
|
|
9
|
+
let a = attributes['textarea-tag'], state = attributes.state || reactive({
|
|
10
|
+
active: false,
|
|
11
|
+
error: ''
|
|
12
|
+
});
|
|
13
|
+
return html `
|
|
14
|
+
<label
|
|
15
|
+
class='textarea'
|
|
16
|
+
${{
|
|
17
|
+
class: () => state.active && '--active',
|
|
18
|
+
onfocusin: () => {
|
|
19
|
+
state.active = true;
|
|
20
|
+
},
|
|
21
|
+
onfocusout: () => {
|
|
22
|
+
state.active = false;
|
|
23
|
+
}
|
|
24
|
+
}}
|
|
25
|
+
${a ? omit(attributes, OMIT) : attributes}
|
|
26
|
+
>
|
|
27
|
+
<textarea
|
|
28
|
+
class='textarea-tag'
|
|
29
|
+
onrender=${form.input.onrender(state)}
|
|
30
|
+
${a}
|
|
31
|
+
>
|
|
32
|
+
${a?.value}
|
|
33
|
+
</textarea>
|
|
34
|
+
${content}
|
|
35
|
+
</label>
|
|
36
|
+
`;
|
|
37
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
@layer components {.textarea{background:var(--background);border:var(--border-width)var(--border-style)var(--border-color);border-radius:var(--border-radius);cursor:text;font-size:var(--font-size);line-height:var(--line-height);flex-wrap:wrap;align-items:center;width:100%;display:flex;position:relative}.textarea:invalid,.textarea:required{box-shadow:none}.textarea-tag{color:var(--color);padding:var(--padding-vertical)var(--padding-horizontal);white-space:normal;flex:auto;min-width:0}}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
@layer normalize {/*! modern-normalize v3.0.1 | MIT License | https://github.com/sindresorhus/modern-normalize */}
|
|
2
|
-
*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;tab-size:4;font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;line-height:1.15}body{margin:0}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{border-color:currentColor}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:100%;line-height:1.15}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}
|
|
2
|
+
*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;tab-size:4;font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;line-height:1.15}body{margin:0}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{border-color:currentColor}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:100%;line-height:1.15}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit;background:0 0;border:0;border-radius:0;margin:0;padding:0}button,button:active,button:focus,button:hover,input,input:active,input:focus,input:hover,select,select:active,select:focus,select:hover,textarea,textarea:active,textarea:focus,textarea:hover{outline:none}button:invalid,input:invalid,select:invalid,textarea:invalid{box-shadow:none}form{width:100%;margin:0;padding:0}label{cursor:pointer}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"@esportsplus/action": "^0.0.58",
|
|
5
5
|
"@esportsplus/queue": "^0.1.0",
|
|
6
6
|
"@esportsplus/reactivity": "^0.16.7",
|
|
7
|
-
"@esportsplus/template": "^0.23.
|
|
7
|
+
"@esportsplus/template": "^0.23.1",
|
|
8
8
|
"@esportsplus/utilities": "^0.22.1",
|
|
9
9
|
"modern-normalize": "^3.0.1"
|
|
10
10
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"private": false,
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"type": "module",
|
|
51
|
-
"version": "0.
|
|
51
|
+
"version": "0.25.0",
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "run-s build:vite build:ts",
|
|
54
54
|
"build:ts": "tsc && tsc-alias",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { reactive, root } from '@esportsplus/reactivity';
|
|
2
|
+
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
4
|
+
import form from '~/components/form';
|
|
5
|
+
import './scss/index.scss';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type A = Attributes & {
|
|
9
|
+
'checkbox-tag'?: Attributes,
|
|
10
|
+
state?: { active: boolean, error: string }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const OMIT = ['checkbox-tag'];
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export default function(attributes?: A) {
|
|
18
|
+
let a = attributes?.['checkbox-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='checkbox ${() => state.active && '--active'}' ${a ? omit(attributes!, OMIT) : attributes}>
|
|
30
|
+
<input
|
|
31
|
+
class='checkbox-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
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@use '/lib';
|
|
2
|
+
@use 'variables';
|
|
3
|
+
|
|
4
|
+
.checkbox {
|
|
5
|
+
background: var(--background);
|
|
6
|
+
border-color: var(--border-color);
|
|
7
|
+
border-radius: var(--border-radius);
|
|
8
|
+
border-style: var(--border-style);
|
|
9
|
+
border-width: var(--border-width);
|
|
10
|
+
flex: 0 0 var(--width);
|
|
11
|
+
height: var(--height);
|
|
12
|
+
position: relative;
|
|
13
|
+
transition:
|
|
14
|
+
background var(--transition-duration) ease-in-out,
|
|
15
|
+
border-color var(--transition-duration) ease-in-out,
|
|
16
|
+
box-shadow var(--transition-duration) ease-in-out,
|
|
17
|
+
opacity var(--transition-duration) ease-in-out,
|
|
18
|
+
transform var(--transition-duration) ease-in-out;
|
|
19
|
+
width: var(--width);
|
|
20
|
+
|
|
21
|
+
&:invalid,
|
|
22
|
+
&:required {
|
|
23
|
+
box-shadow: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&::before {
|
|
27
|
+
border-bottom: var(--border-width) solid var(--accent);
|
|
28
|
+
border-right: var(--border-width) solid var(--accent);
|
|
29
|
+
bottom: 50%;
|
|
30
|
+
box-shadow: var(--box-shadow);
|
|
31
|
+
content: '';
|
|
32
|
+
height: var(--height);
|
|
33
|
+
opacity: var(--opacity);
|
|
34
|
+
position: absolute;
|
|
35
|
+
right: 92%;
|
|
36
|
+
transform: translate(var(--translateX), var(--translateY)) rotate(var(--rotate)) scale(var(--scale));
|
|
37
|
+
transform-origin: bottom center;
|
|
38
|
+
width: var(--width);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Hide HTML Field Element
|
|
42
|
+
&-tag {
|
|
43
|
+
@include lib.position(absolute, 0 null null 0);
|
|
44
|
+
height: 0px;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
width: 0px;
|
|
48
|
+
z-index: 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@use '/lib';
|
|
2
|
+
@use '/tokens';
|
|
3
|
+
|
|
4
|
+
.checkbox {
|
|
5
|
+
--background: var(--background-default);
|
|
6
|
+
--background-active: var(--background-default);
|
|
7
|
+
--background-default: transparent;
|
|
8
|
+
--background-hover: var(--background-default);
|
|
9
|
+
--background-pressed: var(--background-default);
|
|
10
|
+
--border-color: var(--border-color-default);
|
|
11
|
+
--border-color-default: var(--background);
|
|
12
|
+
--border-radius: var(--border-radius-300);
|
|
13
|
+
--border-style: solid;
|
|
14
|
+
--border-width: 0px;
|
|
15
|
+
--box-shadow: var(--box-shadow-default);
|
|
16
|
+
--box-shadow-default: none;
|
|
17
|
+
--height: var(--size);
|
|
18
|
+
--margin-horizontal: calc(var(--width-switch) - var(--width));
|
|
19
|
+
--opacity: var(--opacity-default);
|
|
20
|
+
--opacity-active: var(--opacity-default);
|
|
21
|
+
--opacity-default: 1;
|
|
22
|
+
--opacity-hover: var(--opacity-default);
|
|
23
|
+
--opacity-pressed: var(--opacity-default);
|
|
24
|
+
--rotate: 45deg;
|
|
25
|
+
--scale: var(--scale-default);
|
|
26
|
+
--scale-active: 1;
|
|
27
|
+
--scale-default: 0;
|
|
28
|
+
--scale-hover: 1.08;
|
|
29
|
+
--scale-pressed: 0.98;
|
|
30
|
+
--size: var(--size-600);
|
|
31
|
+
--width: var(--height);
|
|
32
|
+
--width-switch: 40px;
|
|
33
|
+
|
|
34
|
+
&::before {
|
|
35
|
+
--border-width: 5px;
|
|
36
|
+
--box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.16);
|
|
37
|
+
--height: 110%;
|
|
38
|
+
--translateX: 108%;
|
|
39
|
+
--translateY: 8%;
|
|
40
|
+
--width: 50%;
|
|
41
|
+
|
|
42
|
+
#{tokens.state(default, '.field')} & {
|
|
43
|
+
--translateY: 100%;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#{tokens.state(inactive, 'label')},
|
|
48
|
+
#{tokens.state(inactive)} {
|
|
49
|
+
@include tokens.state(hover) {
|
|
50
|
+
--background: var(--background-hover);
|
|
51
|
+
--border-color: var(--border-color-hover);
|
|
52
|
+
--box-shadow: var(--box-shadow-hover);
|
|
53
|
+
--color: var(--color-hover);
|
|
54
|
+
--opacity: var(--opacity-hover);
|
|
55
|
+
--scale: var(--scale-hover);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@include tokens.state(pressed) {
|
|
59
|
+
--background: var(--background-pressed);
|
|
60
|
+
--border-color: var(--border-color-pressed);
|
|
61
|
+
--box-shadow: var(--box-shadow-pressed);
|
|
62
|
+
--color: var(--color-pressed);
|
|
63
|
+
--opacity: var(--opacity-pressed);
|
|
64
|
+
--scale: var(--scale-pressed);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#{tokens.state(active)} {
|
|
69
|
+
--opacity: var(--opacity-active);
|
|
70
|
+
--scale: var(--scale-active);
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -5,17 +5,18 @@ export * as border from './border';
|
|
|
5
5
|
export * as bubble from './bubble';
|
|
6
6
|
export * as button from './button';
|
|
7
7
|
export * as card from './card';
|
|
8
|
+
export { default as checkbox } from './checkbox';
|
|
8
9
|
export { default as clipboard } from './clipboard';
|
|
9
10
|
export * as container from './container';
|
|
10
11
|
export { default as counter } from './counter';
|
|
11
12
|
export { default as ellipsis } from './ellipsis';
|
|
12
|
-
export { default as field } from './field';
|
|
13
13
|
export { default as form } from './form';
|
|
14
14
|
export * as frame from './frame';
|
|
15
15
|
export * as grid from './grid';
|
|
16
16
|
export * as group from './group';
|
|
17
17
|
export { default as highlight } from './highlight';
|
|
18
18
|
export { default as icon } from './icon';
|
|
19
|
+
export { default as input } from './input';
|
|
19
20
|
export { default as json } from './json';
|
|
20
21
|
export * as link from './link';
|
|
21
22
|
export { default as loader } from './loader';
|
|
@@ -24,13 +25,18 @@ export * as modal from './modal';
|
|
|
24
25
|
export { default as number } from './number';
|
|
25
26
|
export { default as overlay } from './overlay';
|
|
26
27
|
export * from './page';
|
|
28
|
+
export { default as radio } from './radio';
|
|
29
|
+
export { default as range } from './range';
|
|
27
30
|
export { default as root } from './root';
|
|
28
31
|
export * as row from './row';
|
|
32
|
+
export { default as select } from './select';
|
|
33
|
+
export { default as switch } from './switch';
|
|
29
34
|
export { default as scrollbar } from './scrollbar';
|
|
30
35
|
export { default as sidebar } from './sidebar';
|
|
31
36
|
export { default as site } from './site';
|
|
32
37
|
export { default as template } from './template';
|
|
33
38
|
export * as text from './text';
|
|
39
|
+
export { default as textarea } from './textarea';
|
|
34
40
|
export * as thumbnail from './thumbnail';
|
|
35
41
|
export { default as tooltip } from './tooltip';
|
|
36
42
|
export { default as truncate } from './truncate';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
4
|
+
import form from '~/components/form';
|
|
5
|
+
import template from '~/components/template';
|
|
6
|
+
import './scss/index.scss';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
type A = Attributes & {
|
|
10
|
+
'input-tag'?: Attributes,
|
|
11
|
+
state?: { active: boolean, error: string }
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const OMIT = ['input-tag'];
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default template.factory(
|
|
19
|
+
function(attributes: A, content) {
|
|
20
|
+
let a = attributes['input-tag'],
|
|
21
|
+
state = attributes.state || reactive({
|
|
22
|
+
active: false,
|
|
23
|
+
error: ''
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return html`
|
|
27
|
+
<label
|
|
28
|
+
class='input'
|
|
29
|
+
${{
|
|
30
|
+
class: () => state.active && '--active',
|
|
31
|
+
onfocusin: () => {
|
|
32
|
+
state.active = true;
|
|
33
|
+
},
|
|
34
|
+
onfocusout: () => {
|
|
35
|
+
state.active = false;
|
|
36
|
+
}
|
|
37
|
+
}}
|
|
38
|
+
${a ? omit(attributes, OMIT) : attributes}
|
|
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>
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@use 'variables';
|
|
2
|
+
|
|
3
|
+
.input {
|
|
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
|
+
cursor: text;
|
|
9
|
+
display: flex;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
font-size: var(--font-size);
|
|
13
|
+
line-height: var(--line-height);
|
|
14
|
+
// Necessary To Maintain Height Of Hidden Password Fields In Floating Modals
|
|
15
|
+
// - Password Managers Cause Problems When Fields Are Not Using 'display:hidden' On Password Fields
|
|
16
|
+
min-height: calc((var(--padding-vertical) * 2) + var(--size));
|
|
17
|
+
position: relative;
|
|
18
|
+
text-overflow: ellipsis;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
width: 100%;
|
|
21
|
+
|
|
22
|
+
&:invalid,
|
|
23
|
+
&:required {
|
|
24
|
+
box-shadow: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-tag {
|
|
28
|
+
color: var(--color);
|
|
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
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@use '/lib';
|
|
2
|
+
@use '/tokens';
|
|
3
|
+
|
|
4
|
+
.input {
|
|
5
|
+
--background: var(--background-default);
|
|
6
|
+
--background-active: var(--background-default);
|
|
7
|
+
--background-default: transparent;
|
|
8
|
+
--background-hover: var(--background-default);
|
|
9
|
+
--background-pressed: var(--background-default);
|
|
10
|
+
--border-color: var(--border-color-default);
|
|
11
|
+
--border-color-default: var(--background);
|
|
12
|
+
--border-radius: var(--border-radius-400);
|
|
13
|
+
--border-style: solid;
|
|
14
|
+
--border-width: 0px;
|
|
15
|
+
--box-shadow: var(--box-shadow-default);
|
|
16
|
+
--box-shadow-default: none;
|
|
17
|
+
--color: var(--color-default);
|
|
18
|
+
--color-active: var(--color-default);
|
|
19
|
+
--color-default: var(--color-text-400);
|
|
20
|
+
--color-hover: var(--color-default);
|
|
21
|
+
--color-pressed: var(--color-default);
|
|
22
|
+
--font-size: var(--font-size-400);
|
|
23
|
+
--line-height: var(--line-height-400);
|
|
24
|
+
--padding-horizontal: var(--size-400);
|
|
25
|
+
--padding-vertical: var(--size-400);
|
|
26
|
+
--size: var(--size-400);
|
|
27
|
+
|
|
28
|
+
#{tokens.state(inactive)} {
|
|
29
|
+
@include tokens.state(hover) {
|
|
30
|
+
--background: var(--background-hover);
|
|
31
|
+
--border-color: var(--border-color-hover);
|
|
32
|
+
--box-shadow: var(--box-shadow-hover);
|
|
33
|
+
--color: var(--color-hover);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@include tokens.state(pressed) {
|
|
37
|
+
--background: var(--background-pressed);
|
|
38
|
+
--border-color: var(--border-color-pressed);
|
|
39
|
+
--box-shadow: var(--box-shadow-pressed);
|
|
40
|
+
--color: var(--color-pressed);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#{tokens.state(active)} {
|
|
45
|
+
--background: var(--background-active);
|
|
46
|
+
--border-color: var(--border-color-active);
|
|
47
|
+
--box-shadow: var(--box-shadow-active);
|
|
48
|
+
--color: var(--color-active);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { reactive, root } from '@esportsplus/reactivity';
|
|
2
|
+
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
4
|
+
import form from '~/components/form';
|
|
5
|
+
import './scss/index.scss';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type A = Attributes & {
|
|
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
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@use '/lib';
|
|
2
|
+
@use 'variables';
|
|
3
|
+
|
|
4
|
+
.radio {
|
|
5
|
+
background: var(--background);
|
|
6
|
+
border-color: var(--border-color);
|
|
7
|
+
border-radius: var(--border-radius);
|
|
8
|
+
border-style: var(--border-style);
|
|
9
|
+
border-width: var(--border-width);
|
|
10
|
+
flex: 0 0 var(--width);
|
|
11
|
+
height: var(--height);
|
|
12
|
+
position: relative;
|
|
13
|
+
transition:
|
|
14
|
+
background var(--transition-duration) ease-in-out,
|
|
15
|
+
border-color var(--transition-duration) ease-in-out,
|
|
16
|
+
box-shadow var(--transition-duration) ease-in-out,
|
|
17
|
+
opacity var(--transition-duration) ease-in-out,
|
|
18
|
+
transform var(--transition-duration) ease-in-out;
|
|
19
|
+
width: var(--width);
|
|
20
|
+
|
|
21
|
+
&:invalid,
|
|
22
|
+
&:required {
|
|
23
|
+
box-shadow: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&::before {
|
|
27
|
+
background: var(--accent);
|
|
28
|
+
border-radius: inherit;
|
|
29
|
+
bottom: 50%;
|
|
30
|
+
box-shadow: var(--box-shadow);
|
|
31
|
+
content: '';
|
|
32
|
+
height: var(--height);
|
|
33
|
+
opacity: var(--opacity);
|
|
34
|
+
right: 50%;
|
|
35
|
+
position: absolute;
|
|
36
|
+
transform: translate(var(--translateX), var(--translateY)) rotate(var(--rotate)) scale(var(--scale));
|
|
37
|
+
transform-origin: center;
|
|
38
|
+
width: var(--width);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Hide HTML Field Element
|
|
42
|
+
&-tag {
|
|
43
|
+
@include lib.position(absolute, 0 null null 0);
|
|
44
|
+
height: 0px;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
width: 0px;
|
|
48
|
+
z-index: 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@use '/lib';
|
|
2
|
+
@use '/tokens';
|
|
3
|
+
|
|
4
|
+
.radio {
|
|
5
|
+
--background: var(--background-default);
|
|
6
|
+
--background-active: var(--background-default);
|
|
7
|
+
--background-default: transparent;
|
|
8
|
+
--background-hover: var(--background-default);
|
|
9
|
+
--background-pressed: var(--background-default);
|
|
10
|
+
--border-color: var(--border-color-default);
|
|
11
|
+
--border-color-default: var(--background);
|
|
12
|
+
--border-radius: 100%;
|
|
13
|
+
--border-style: solid;
|
|
14
|
+
--border-width: 0px;
|
|
15
|
+
--box-shadow: var(--box-shadow-default);
|
|
16
|
+
--box-shadow-default: none;
|
|
17
|
+
--height: var(--size);
|
|
18
|
+
--margin-horizontal: calc(var(--width-switch) - var(--width));
|
|
19
|
+
--opacity: var(--opacity-default);
|
|
20
|
+
--opacity-active: 1;
|
|
21
|
+
--opacity-default: 0.4;
|
|
22
|
+
--opacity-hover: var(--opacity-default);
|
|
23
|
+
--opacity-pressed: var(--opacity-default);
|
|
24
|
+
--rotate: 0deg;
|
|
25
|
+
--scale: var(--scale-default);
|
|
26
|
+
--scale-active: 0.9;
|
|
27
|
+
--scale-default: 0;
|
|
28
|
+
--scale-hover: 0.8;
|
|
29
|
+
--scale-pressed: 0.7;
|
|
30
|
+
--size: var(--size-600);
|
|
31
|
+
--width: var(--height);
|
|
32
|
+
--width-switch: 40px;
|
|
33
|
+
|
|
34
|
+
&::before {
|
|
35
|
+
--height: calc((var(--size) / 2) - (var(--border-width) * 2));
|
|
36
|
+
--box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
|
|
37
|
+
--translateX: 50%;
|
|
38
|
+
--translateY: 50%;
|
|
39
|
+
--width: var(--height);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#{tokens.state(inactive, 'label')},
|
|
43
|
+
#{tokens.state(inactive)} {
|
|
44
|
+
@include tokens.state(hover) {
|
|
45
|
+
--background: var(--background-hover);
|
|
46
|
+
--border-color: var(--border-color-hover);
|
|
47
|
+
--box-shadow: var(--box-shadow-hover);
|
|
48
|
+
--color: var(--color-hover);
|
|
49
|
+
--opacity: var(--opacity-hover);
|
|
50
|
+
--scale: var(--scale-hover);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@include tokens.state(pressed) {
|
|
54
|
+
--background: var(--background-pressed);
|
|
55
|
+
--border-color: var(--border-color-pressed);
|
|
56
|
+
--box-shadow: var(--box-shadow-pressed);
|
|
57
|
+
--color: var(--color-pressed);
|
|
58
|
+
--opacity: var(--opacity-pressed);
|
|
59
|
+
--scale: var(--scale-pressed);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#{tokens.state(active)} {
|
|
64
|
+
--opacity: var(--opacity-active);
|
|
65
|
+
--scale: var(--scale-active);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { reactive, root } from '@esportsplus/reactivity';
|
|
2
|
+
import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
+
import { omit } from '@esportsplus/utilities';
|
|
4
|
+
import form from '~/components/form';
|
|
5
|
+
import template from '~/components/template';
|
|
6
|
+
import './scss/index.scss';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
type A = Attributes & {
|
|
10
|
+
'range-tag'?: Attributes,
|
|
11
|
+
state?: { active: boolean, error: string, value: number }
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const OMIT = ['range-tag'];
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default template.factory(
|
|
19
|
+
function(attributes: A, content) {
|
|
20
|
+
let a = attributes['range-tag'],
|
|
21
|
+
state = attributes.state || reactive({
|
|
22
|
+
active: false,
|
|
23
|
+
error: '',
|
|
24
|
+
value: 0
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (a?.value) {
|
|
28
|
+
state.value = Number( a.value );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return html`
|
|
32
|
+
<div
|
|
33
|
+
class='range --border-state --border-black'
|
|
34
|
+
${{
|
|
35
|
+
class: () => state.active && '--active',
|
|
36
|
+
onfocusin: () => {
|
|
37
|
+
state.active = true;
|
|
38
|
+
},
|
|
39
|
+
onfocusout: () => {
|
|
40
|
+
state.active = false;
|
|
41
|
+
}
|
|
42
|
+
}}
|
|
43
|
+
${a ? omit(attributes, OMIT) : attributes}
|
|
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>
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@use 'variables';
|
|
2
|
+
|
|
3
|
+
.range {
|
|
4
|
+
margin: calc((var(--height) - var(--thumb-size)) / 2) 0;
|
|
5
|
+
|
|
6
|
+
&-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
|
+
}
|