@esportsplus/ui 0.24.5 → 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.
Files changed (76) hide show
  1. package/build/components/checkbox/index.d.ts +11 -0
  2. package/build/components/checkbox/index.js +33 -0
  3. package/build/components/checkbox/scss/index.scss +2 -0
  4. package/build/components/index.d.ts +7 -1
  5. package/build/components/index.js +7 -1
  6. package/build/components/input/index.d.ts +21 -0
  7. package/build/components/input/index.js +38 -0
  8. package/build/components/input/scss/index.scss +2 -0
  9. package/build/components/radio/index.d.ts +11 -0
  10. package/build/components/radio/index.js +33 -0
  11. package/build/components/radio/scss/index.scss +2 -0
  12. package/build/components/range/index.d.ts +21 -0
  13. package/build/components/range/index.js +46 -0
  14. package/build/components/range/scss/index.scss +2 -0
  15. package/build/components/select/index.d.ts +44 -0
  16. package/build/components/{field/select.js → select/index.js} +25 -52
  17. package/build/components/select/scss/index.scss +2 -0
  18. package/build/components/switch/index.d.ts +11 -0
  19. package/build/components/switch/index.js +33 -0
  20. package/build/components/switch/scss/index.scss +2 -0
  21. package/build/components/text/scss/index.scss +1 -1
  22. package/build/components/textarea/index.d.ts +21 -0
  23. package/build/components/textarea/index.js +37 -0
  24. package/build/components/textarea/scss/index.scss +2 -0
  25. package/build/normalize/scss/index.scss +1 -1
  26. package/package.json +2 -2
  27. package/src/components/checkbox/index.ts +45 -0
  28. package/src/components/checkbox/scss/index.scss +50 -0
  29. package/src/components/checkbox/scss/variables.scss +72 -0
  30. package/src/components/index.ts +7 -1
  31. package/src/components/input/index.ts +52 -0
  32. package/src/components/input/scss/index.scss +37 -0
  33. package/src/components/input/scss/variables.scss +50 -0
  34. package/src/components/radio/index.ts +45 -0
  35. package/src/components/radio/scss/index.scss +50 -0
  36. package/src/components/radio/scss/variables.scss +67 -0
  37. package/src/components/range/index.ts +61 -0
  38. package/src/components/range/scss/index.scss +31 -0
  39. package/src/components/range/scss/variables.scss +8 -0
  40. package/src/components/{field/select.ts → select/index.ts} +50 -106
  41. package/src/components/select/scss/index.scss +36 -0
  42. package/src/components/select/scss/variables.scss +12 -0
  43. package/src/components/switch/index.ts +45 -0
  44. package/src/components/switch/scss/index.scss +48 -0
  45. package/src/components/switch/scss/variables.scss +72 -0
  46. package/src/components/text/scss/index.scss +31 -0
  47. package/src/components/textarea/index.ts +51 -0
  48. package/src/components/textarea/scss/index.scss +26 -0
  49. package/src/components/textarea/scss/variables.scss +49 -0
  50. package/src/normalize/scss/index.scss +36 -1
  51. package/build/components/field/checkbox.d.ts +0 -73
  52. package/build/components/field/checkbox.js +0 -71
  53. package/build/components/field/description.d.ts +0 -19
  54. package/build/components/field/description.js +0 -7
  55. package/build/components/field/error.d.ts +0 -5
  56. package/build/components/field/error.js +0 -13
  57. package/build/components/field/index.d.ts +0 -17481
  58. package/build/components/field/index.js +0 -10
  59. package/build/components/field/input.d.ts +0 -156
  60. package/build/components/field/input.js +0 -97
  61. package/build/components/field/scss/index.scss +0 -2
  62. package/build/components/field/select.d.ts +0 -1350
  63. package/build/components/field/title.d.ts +0 -1169
  64. package/build/components/field/title.js +0 -20
  65. package/src/components/field/checkbox.ts +0 -97
  66. package/src/components/field/description.ts +0 -11
  67. package/src/components/field/error.ts +0 -16
  68. package/src/components/field/index.ts +0 -15
  69. package/src/components/field/input.ts +0 -134
  70. package/src/components/field/scss/check.scss +0 -227
  71. package/src/components/field/scss/index.scss +0 -133
  72. package/src/components/field/scss/normalize.scss +0 -34
  73. package/src/components/field/scss/range.scss +0 -46
  74. package/src/components/field/scss/text.scss +0 -120
  75. package/src/components/field/scss/variables.scss +0 -128
  76. package/src/components/field/title.ts +0 -27
@@ -1,20 +0,0 @@
1
- import { html } from '@esportsplus/template';
2
- import { omit } from '@esportsplus/utilities';
3
- import tooltip from '../../components/tooltip/index.js';
4
- import template from '../../components/template/index.js';
5
- const OMIT = ['required'];
6
- export default template.factory((attributes, content) => {
7
- let required = attributes?.required;
8
- return html `
9
- <div
10
- class='field-title --flex-horizontal-space-between --flex-vertical'
11
- ${omit(attributes, OMIT)}
12
- >
13
- ${content}
14
-
15
- ${required && tooltip.onhover({ class: 'bubble --background-primary --margin-left' }, html `
16
- <span class='tooltip-message tooltip-message--w'>Required</span>
17
- `)}
18
- </div>
19
- `;
20
- });
@@ -1,97 +0,0 @@
1
- import { reactive, root } from '@esportsplus/reactivity';
2
- import { html, type Attributes, type Renderable } from '@esportsplus/template';
3
- import { omit } from '@esportsplus/utilities';
4
- import template from '~/components/template';
5
-
6
-
7
- type A = Attributes & {
8
- 'field-mask-tag'?: Attributes
9
- };
10
-
11
-
12
- const OMIT_FIELD = ['state'];
13
-
14
- const OMIT_TAG = ['field-mask-tag'];
15
-
16
-
17
- function mask(attributes: A, modifier: string, state: { active: boolean }) {
18
- let a = attributes['field-mask-tag'] || {};
19
-
20
- if (a.checked) {
21
- state.active = true;
22
- }
23
-
24
- return html`
25
- <div
26
- class='field-mask'
27
- ${omit(attributes, OMIT_TAG)}
28
- ${{
29
- class: `field-mask--${modifier}`
30
- }}
31
- >
32
- <input
33
- class='field-mask-tag field-mask-tag--hidden'
34
- ${{
35
- checked: a.checked || root(() => state.active),
36
- type: modifier === 'radio' ? 'radio' : 'checkbox',
37
- value: a.value || 1
38
- }}
39
- ${a}
40
- >
41
- </div>
42
- `;
43
- }
44
-
45
-
46
- const field = template.factory(
47
- function(
48
- this: { mask: (attributes: A, state: { active: boolean }) => Renderable<unknown> },
49
- attributes: Attributes & { state?: { active: boolean } },
50
- content: (mask: ((attributes: A) => Renderable<unknown>)) => Renderable<unknown>
51
- ) {
52
- let state = attributes?.state || reactive({
53
- active: false
54
- });
55
-
56
- return html`
57
- <label
58
- class='field'
59
- ${omit(attributes, OMIT_FIELD)}
60
- ${{
61
- class: () => state.active && '--active',
62
- onchange: (e) => {
63
- let target = (e.target as HTMLInputElement),
64
- type = target.type;
65
-
66
- if (type !== 'checkbox' && type !== 'radio') {
67
- return;
68
- }
69
-
70
- state.active = target.checked;
71
- }
72
- }}
73
- >
74
- ${content((attributes) => this.mask(attributes, state))}
75
- </label>
76
- `
77
- }
78
- );
79
-
80
-
81
- export default {
82
- checkbox: field.bind({
83
- mask: (attributes: A, state: { active: boolean }) => {
84
- return mask(attributes, 'checkbox', state);
85
- }
86
- }),
87
- radio: field.bind({
88
- mask: (attributes: A, state: { active: boolean }) => {
89
- return mask(attributes, 'radio', state);
90
- }
91
- }),
92
- switch: field.bind({
93
- mask: (attributes: A, state: { active: boolean }) => {
94
- return mask(attributes, 'switch', state);
95
- }
96
- }),
97
- };
@@ -1,11 +0,0 @@
1
- import { html } from '@esportsplus/template';
2
- import template from '~/components/template';
3
-
4
-
5
- export default template.factory(
6
- (attributes, content) => html`
7
- <div class='field-description' ${attributes}>
8
- ${content}
9
- </div>
10
- `
11
- );
@@ -1,16 +0,0 @@
1
- import { html, Renderable } from '@esportsplus/template';
2
-
3
-
4
- export default (state: { error: Renderable<unknown> }) => {
5
- return () => {
6
- if (!state.error) {
7
- return '';
8
- }
9
-
10
- return html`
11
- <div class='field-error --text-bold'>
12
- ${state.error}
13
- </div>
14
- `;
15
- };
16
- }
@@ -1,15 +0,0 @@
1
- import checkbox from './checkbox';
2
- import description from './description';
3
- import input from './input';
4
- import select from './select';
5
- import title from './title';
6
- import './scss/index.scss';
7
-
8
-
9
- const { checkbox: cb, radio, switch: sw } = checkbox;
10
-
11
- const { file, range, text, textarea } = input;
12
-
13
-
14
- export default { checkbox: cb, description, file, radio, range, select, switch: sw, textarea, text, title };
15
- export { cb as checkbox, description, file, radio, range, select, sw as switch, textarea, text, title };
@@ -1,134 +0,0 @@
1
- import { reactive, root } from '@esportsplus/reactivity';
2
- import { html, type Attributes, type Renderable } from '@esportsplus/template';
3
- import { omit } from '@esportsplus/utilities';
4
- import form from '~/components/form';
5
- import template from '~/components/template';
6
- import error from './error';
7
-
8
-
9
- type A = Attributes & {
10
- 'field-mask-tag'?: Attributes
11
- };
12
-
13
-
14
- const OMIT_FIELD = ['state'];
15
-
16
- const OMIT_TAG = ['field-mask-tag'];
17
-
18
-
19
- const field = template.factory(
20
- function(
21
- this: { mask: typeof file | typeof range | typeof text | typeof textarea },
22
- attributes: Attributes & { state?: { active: boolean, error: string } },
23
- content: (mask: typeof file | typeof range | typeof text | typeof textarea) => Renderable<unknown>
24
- ) {
25
- let state = attributes.state || reactive({
26
- active: false,
27
- error: ''
28
- });
29
-
30
- return html`
31
- <div class='field'
32
- ${omit(attributes, OMIT_FIELD)}
33
- ${{
34
- class: () => state.active && '--active',
35
- onfocusin: () => {
36
- state.active = true;
37
- },
38
- onfocusout: () => {
39
- state.active = false;
40
- }
41
- }}
42
- >
43
- ${content(
44
- // @ts-ignore
45
- (...args: any[]) => this.mask.call({ state }, ...args)
46
- )}
47
- ${error(state)}
48
- </div>
49
- `;
50
- }
51
- );
52
-
53
- const file = template.factory(
54
- function(this: { state: { active: boolean, error: string } }, attributes: A, content) {
55
- return html`
56
- <label class='field-mask field-mask--file' ${omit(attributes, OMIT_TAG)}>
57
- <input
58
- class='field-mask-tag field-mask-tag--hidden'
59
- onrender=${form.input.onrender(this.state)}
60
- type='file'
61
- ${attributes['field-mask-tag']}
62
- >
63
- ${content}
64
- </label>
65
- `;
66
- }
67
- );
68
-
69
- const range = template.factory(
70
- function(attributes: A & { state?: { value: number } }, content) {
71
- let a = (attributes['field-mask-tag'] || {}) as Attributes,
72
- state = attributes.state || reactive({ value: 0 });
73
-
74
- return html`
75
- <div class='field-mask field-mask--range --border-state --border-black' ${omit(attributes, OMIT_TAG)}>
76
- <input
77
- class='field-mask-tag'
78
- oninput=${(e: InputEvent) => {
79
- state.value = Number((e.target as HTMLInputElement).value);
80
- }}
81
- type='range'
82
- value='${root(() => (a.value as number) || state.value || 0)}'
83
- ${a}
84
- >
85
- ${content}
86
- </div>
87
- `;
88
- }
89
- );
90
-
91
- const text = template.factory(
92
- function(this: { state: { active: boolean, error: string } }, attributes: A, content) {
93
- return html`
94
- <label class='field-mask field-mask--input' ${omit(attributes, OMIT_TAG)}>
95
- <input
96
- class='field-mask-tag'
97
- ${attributes['field-mask-tag']}
98
- ${{
99
- onrender: form.input.onrender(this.state),
100
- type: attributes.type || 'text'
101
- }}
102
- >
103
- ${content}
104
- </label>
105
- `;
106
- }
107
- );
108
-
109
- const textarea = template.factory(
110
- function(this: { state: { active: boolean, error: string } }, attributes: A, content) {
111
- let a = (attributes['field-mask-tag'] || {}) as Attributes;
112
-
113
- return html`
114
- <label class='field-mask field-mask--textarea' ${omit(attributes, OMIT_TAG)}>
115
- <textarea
116
- class='field-mask-tag'
117
- onrender=${form.input.onrender(this.state)}
118
- ${a}
119
- >
120
- ${a.value as string}
121
- </textarea>
122
- ${content}
123
- </label>
124
- `;
125
- }
126
- );
127
-
128
-
129
- export default {
130
- file: field.bind({ mask: file }),
131
- range: field.bind({ mask: range }),
132
- text: field.bind({ mask: text }),
133
- textarea: field.bind({ mask: textarea })
134
- };
@@ -1,227 +0,0 @@
1
- @use '/lib';
2
- @use '/tokens';
3
-
4
- @mixin css() {
5
- &-mask {
6
- &--checkbox,
7
- &--radio,
8
- &--switch {
9
- background: var(--background);
10
- border-color: var(--border-color);
11
- border-radius: var(--border-radius);
12
- border-style: var(--border-style);
13
- border-width: var(--border-width);
14
- flex: 0 0 var(--width);
15
- height: var(--height);
16
- position: relative;
17
- transition:
18
- background var(--transition-duration) ease-in-out,
19
- border-color var(--transition-duration) ease-in-out,
20
- box-shadow var(--transition-duration) ease-in-out,
21
- opacity var(--transition-duration) ease-in-out,
22
- transform var(--transition-duration) ease-in-out;
23
- width: var(--width);
24
-
25
- &:invalid,
26
- &:required {
27
- box-shadow: none;
28
- }
29
-
30
- &::before {
31
- box-shadow: var(--box-shadow);
32
- content: '';
33
- height: var(--height);
34
- opacity: var(--opacity);
35
- transform: translate(var(--translateX), var(--translateY)) rotate(var(--rotate)) scale(var(--scale));
36
- width: var(--width);
37
- }
38
-
39
- // Hide HTML Field Element
40
- .field-mask-tag {
41
- @include lib.position(absolute, 0 null null 0);
42
- height: 0px;
43
- opacity: 0;
44
- pointer-events: none;
45
- width: 0px;
46
- z-index: 0;
47
- }
48
- }
49
-
50
- &--radio,
51
- &--switch {
52
- &::before {
53
- background: var(--accent);
54
- border-radius: inherit;
55
- transform-origin: center;
56
- }
57
- }
58
-
59
- &--checkbox {
60
- &::before {
61
- border-bottom: var(--border-width) solid var(--accent);
62
- border-right: var(--border-width) solid var(--accent);
63
- transform-origin: bottom center;
64
- position: absolute;
65
- bottom: 50%;
66
- right: 92%;
67
- }
68
- }
69
-
70
- &--radio {
71
- &::before {
72
- position: absolute;
73
- bottom: 50%;
74
- right: 50%;
75
- }
76
- }
77
-
78
- &--switch {
79
- &::before {
80
- @include lib.position(absolute, var(--padding-vertical) null null var(--padding-horizontal));
81
- }
82
- }
83
- }
84
- }
85
-
86
- @mixin variables() {
87
- label#{&},
88
- #{tokens.state(inactive, '.field:not(label)')} &-mask {
89
- @include tokens.state(hover) {
90
- --background: var(--background-hover);
91
- --border-color: var(--border-color-hover);
92
- --box-shadow: var(--box-shadow-hover);
93
- --color: var(--color-hover);
94
- --outline-opacity: var(--outline-opacity-hover);
95
- --outline-width: var(--outline-width-hover);
96
- }
97
-
98
- @include tokens.state(pressed) {
99
- --background: var(--background-pressed);
100
- --border-color: var(--border-color-pressed);
101
- --box-shadow: var(--box-shadow-pressed);
102
- --color: var(--color-pressed);
103
- --outline-opacity: var(--outline-opacity-pressed);
104
- --outline-width: var(--outline-width-pressed);
105
- }
106
- }
107
-
108
- &-mask {
109
- &--checkbox,
110
- &--radio,
111
- &--switch {
112
- --accent: var(--accent-default);
113
- --accent-active: var(--accent-default);
114
- --accent-default: var(--color-white-400);
115
- --accent-hover: var(--accent-default);
116
- --accent-pressed: var(--accent-default);
117
- --height: var(--size);
118
- --opacity: var(--opacity-default);
119
- --opacity-active: var(--opacity-default);
120
- --opacity-default: 1;
121
- --opacity-hover: var(--opacity-default);
122
- --opacity-pressed: var(--opacity-default);
123
- --rotate: 0deg;
124
- --scale: var(--scale-default);
125
- --scale-active: var(--scale-default);
126
- --scale-default: 1;
127
- --scale-hover: var(--scale-default);
128
- --scale-pressed: var(--scale-default);
129
- --size: var(--size-600);
130
- --width-switch: 40px;
131
-
132
- &::before {
133
- --translateX: 0px;
134
- --translateY: 0px;
135
- }
136
-
137
- #{tokens.state(inactive, 'label.field')},
138
- #{tokens.state(inactive, '.field:not(label)')} & {
139
- @include tokens.state(hover) {
140
- --accent: var(--accent-hover);
141
- --opacity: var(--opacity-hover);
142
- --scale: var(--scale-hover);
143
- }
144
-
145
- @include tokens.state(pressed) {
146
- --accent: var(--accent-pressed);
147
- --opacity: var(--opacity-pressed);
148
- --scale: var(--scale-pressed);
149
- }
150
- }
151
-
152
- #{tokens.state(active, '.field')} & {
153
- --accent: var(--accent-active);
154
- --opacity: var(--opacity-active);
155
- --scale: var(--scale-active);
156
- }
157
- }
158
-
159
- &--checkbox,
160
- &--radio {
161
- --margin-horizontal: calc(var(--width-switch) - var(--width));
162
- --width: var(--height);
163
- }
164
-
165
- &--radio,
166
- &--switch {
167
- &::before {
168
- --box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
169
- }
170
- }
171
-
172
- &--checkbox {
173
- --border-radius: var(--border-radius-300);
174
- --rotate: 45deg;
175
- --scale-active: 1;
176
- --scale-default: 0;
177
- --scale-hover: 1.08;
178
- --scale-pressed: 0.98;
179
-
180
- &::before {
181
- --box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.16);
182
- --border-width: 5px;
183
- --height: 110%;
184
- --translateX: 108%;
185
- --translateY: 8%;
186
- --width: 50%;
187
-
188
- #{tokens.state(default, '.field')} & {
189
- --translateY: 100%;
190
- }
191
- }
192
- }
193
-
194
- &--radio {
195
- --border-radius: 100%;
196
- --opacity-active: 1;
197
- --opacity-default: 0.4;
198
- --scale-active: 0.9;
199
- --scale-default: 0;
200
- --scale-hover: 0.8;
201
- --scale-pressed: 0.7;
202
-
203
- &::before {
204
- --height: calc((var(--size) / 2) - (var(--border-width) * 2));
205
- --translateX: 50%;
206
- --translateY: 50%;
207
- --width: var(--height);
208
- }
209
- }
210
-
211
- &--switch {
212
- --border-radius: 240px;
213
- --padding-horizontal: var(--border-width-400);
214
- --padding-vertical: var(--border-width-400);
215
- --width: var(--width-switch);
216
-
217
- &::before {
218
- --height: calc(var(--size) - (var(--border-width) * 2) - (var(--padding-vertical) * 2));
219
- --width: var(--height);
220
-
221
- #{tokens.state(active, '.field')} & {
222
- --translateX: calc(var(--width-switch) - (var(--border-width) * 2) - var(--height) - (var(--padding-horizontal) * 2));
223
- }
224
- }
225
- }
226
- }
227
- }
@@ -1,133 +0,0 @@
1
- @use '/lib';
2
- @use '/tokens';
3
- @use 'check' as check;
4
- @use 'normalize';
5
- @use 'range' as range;
6
- @use 'text' as text;
7
- @use 'variables';
8
-
9
- .field {
10
- display: flex;
11
- flex-flow: column;
12
- gap: var(--margin-vertical) var(--margin-horizontal);
13
- position: relative;
14
- transition:
15
- background var(--transition-duration) ease-in-out,
16
- border-color var(--transition-duration) ease-in-out,
17
- box-shadow var(--transition-duration) ease-in-out,
18
- color var(--transition-duration) ease-in-out,
19
- opacity var(--transition-duration) ease-in-out;
20
- width: var(--width);
21
-
22
-
23
- &-description,
24
- &-error,
25
- &-title {
26
- color: var(--color);
27
- font-size: var(--font-size);
28
- position: relative;
29
- width: 100%;
30
- word-wrap: break-word;
31
-
32
- &:empty {
33
- height: 0px;
34
- margin: 0;
35
- }
36
- }
37
-
38
- &-error {
39
- animation: fieldError 0.32s 1 linear;
40
-
41
- @keyframes fieldError {
42
- 0% {
43
- transform: translate(8px);
44
- }
45
-
46
- 20% {
47
- transform: translate(-8px);
48
- }
49
-
50
- 40% {
51
- transform: translate(4px);
52
- }
53
-
54
- 60% {
55
- transform: translate(-4px);
56
- }
57
-
58
- 80% {
59
- transform: translate(2px);
60
- }
61
-
62
- 100% {
63
- transform: translate(0px);
64
- }
65
- }
66
- }
67
-
68
- &-mask {
69
- // Pseudo Element Box Shadow
70
- &::after {
71
- @include lib.position(absolute, full);
72
- border-radius: inherit;
73
- box-shadow: var(--box-shadow);
74
- content: '';
75
- pointer-events: none;
76
- transition:
77
- box-shadow var(--transition-duration) ease-in-out,
78
- opacity var(--transition-duration) ease-in-out,
79
- transform var(--transition-duration) ease-in-out;
80
- z-index: -1;
81
- }
82
-
83
- &--flat {
84
- &::after {
85
- display: none;
86
- }
87
- }
88
-
89
- &--outline {
90
- &::before {
91
- @include lib.position(absolute, full);
92
- box-shadow: 0 0 0 var(--outline-width) var(--border-color);
93
- border-radius: var(--border-radius);
94
- content: '';
95
- opacity: var(--outline-opacity);
96
- pointer-events: none;
97
- transition:
98
- box-shadow var(--transition-duration) ease-in-out,
99
- opacity var(--transition-duration) ease-in-out;
100
- z-index: 1;
101
- }
102
- }
103
-
104
- &-tag {
105
- &--hidden {
106
- @include lib.position(absolute, 0 null null 0);
107
- appearance: none;
108
- height: 0px;
109
- opacity: 0;
110
- pointer-events: none;
111
- width: 0px;
112
- z-index: -1;
113
- }
114
- }
115
- }
116
-
117
- &-required {
118
- background: var(--background);
119
- border-radius: var(--border-radius);
120
- height: var(--size);
121
- width: var(--size);
122
- }
123
-
124
- &-title {
125
- font-weight: var(--font-weight);
126
- z-index: 1;
127
- }
128
-
129
-
130
- @include check.css();
131
- @include range.css();
132
- @include text.css();
133
- }
@@ -1,34 +0,0 @@
1
- button,
2
- input,
3
- select,
4
- textarea {
5
- background: transparent;
6
- border-radius: 0;
7
- border: 0;
8
- font-family: inherit;
9
- font-size: inherit;
10
- line-height: inherit;
11
- margin: 0;
12
- padding: 0;
13
-
14
- &,
15
- &:active,
16
- &:focus,
17
- &:hover {
18
- outline: none;
19
- }
20
-
21
- &:invalid {
22
- box-shadow: none;
23
- }
24
- }
25
-
26
- form {
27
- margin: 0;
28
- padding: 0;
29
- width: 100%;
30
- }
31
-
32
- label {
33
- cursor: pointer;
34
- }