@esportsplus/ui 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.github/dependabot.yml +2 -0
  2. package/.github/workflows/bump.yml +2 -0
  3. package/.github/workflows/dependabot.yml +12 -0
  4. package/.github/workflows/publish.yml +2 -0
  5. package/build/components/accordion/index.d.ts +5 -15
  6. package/build/components/accordion/index.js +28 -20
  7. package/build/components/counter/index.d.ts +2 -2
  8. package/build/components/counter/index.js +10 -10
  9. package/build/components/ellipsis/index.d.ts +1 -1
  10. package/build/components/field/checkbox.d.ts +9 -339
  11. package/build/components/field/checkbox.js +24 -21
  12. package/build/components/field/description.d.ts +3 -3
  13. package/build/components/field/error.d.ts +3 -2
  14. package/build/components/field/index.d.ts +1721 -3152
  15. package/build/components/field/input.d.ts +18 -348
  16. package/build/components/field/input.js +33 -23
  17. package/build/components/field/select.d.ts +119 -226
  18. package/build/components/field/select.js +81 -69
  19. package/build/components/field/title.d.ts +114 -107
  20. package/build/components/field/title.js +15 -8
  21. package/build/components/form/action.d.ts +21 -6
  22. package/build/components/form/action.js +20 -9
  23. package/build/components/form/index.d.ts +130 -2
  24. package/build/components/frame/index.d.ts +3 -112
  25. package/build/components/frame/index.js +4 -6
  26. package/build/components/highlight/index.d.ts +5 -7
  27. package/build/components/highlight/index.js +23 -15
  28. package/build/components/icon/index.d.ts +3 -3
  29. package/build/components/index.d.ts +2 -2
  30. package/build/components/index.js +2 -2
  31. package/build/components/loader/index.d.ts +3 -3
  32. package/build/components/loader/index.js +13 -16
  33. package/build/components/loading/index.d.ts +1 -1
  34. package/build/components/overlay/index.d.ts +3 -112
  35. package/build/components/overlay/index.js +4 -6
  36. package/build/components/page/index.d.ts +0 -12
  37. package/build/components/page/index.js +0 -10
  38. package/build/components/root/onclick.js +4 -6
  39. package/build/components/scrollbar/index.d.ts +8 -112
  40. package/build/components/scrollbar/index.js +25 -20
  41. package/build/components/sidebar/index.d.ts +3 -112
  42. package/build/components/sidebar/index.js +4 -6
  43. package/build/components/site/index.d.ts +3 -112
  44. package/build/components/site/index.js +5 -8
  45. package/build/components/template/index.d.ts +8 -4
  46. package/build/components/template/index.js +5 -4
  47. package/build/components/tooltip/index.d.ts +235 -332
  48. package/build/components/tooltip/index.js +3 -106
  49. package/build/components/tooltip/menu.d.ts +20 -0
  50. package/build/components/tooltip/menu.js +28 -0
  51. package/build/components/tooltip/onclick.d.ts +124 -0
  52. package/build/components/tooltip/onclick.js +67 -0
  53. package/build/components/tooltip/onhover.d.ts +7 -0
  54. package/build/components/tooltip/onhover.js +25 -0
  55. package/build/components/typewriter/index.d.ts +4 -6
  56. package/build/components/typewriter/index.js +34 -33
  57. package/package.json +10 -9
  58. package/src/components/accordion/index.ts +41 -26
  59. package/src/components/counter/index.ts +15 -13
  60. package/src/components/field/checkbox.ts +31 -30
  61. package/src/components/field/description.ts +2 -2
  62. package/src/components/field/error.ts +2 -2
  63. package/src/components/field/input.ts +41 -33
  64. package/src/components/field/select.ts +123 -108
  65. package/src/components/field/title.ts +18 -8
  66. package/src/components/form/action.ts +75 -47
  67. package/src/components/frame/index.ts +4 -9
  68. package/src/components/highlight/index.ts +53 -39
  69. package/src/components/icon/index.ts +3 -3
  70. package/src/components/index.ts +2 -2
  71. package/src/components/loader/index.ts +15 -17
  72. package/src/components/overlay/index.ts +4 -9
  73. package/src/components/page/index.ts +1 -17
  74. package/src/components/root/onclick.ts +6 -7
  75. package/src/components/scrollbar/index.ts +34 -23
  76. package/src/components/sidebar/index.ts +4 -9
  77. package/src/components/site/index.ts +5 -13
  78. package/src/components/template/index.ts +18 -10
  79. package/src/components/tooltip/index.ts +4 -156
  80. package/src/components/tooltip/menu.ts +52 -0
  81. package/src/components/tooltip/onclick.ts +97 -0
  82. package/src/components/tooltip/onhover.ts +35 -0
  83. package/src/components/typewriter/index.ts +44 -41
  84. package/build/components/footer/index.d.ts +0 -22
  85. package/build/components/footer/index.js +0 -61
  86. package/build/components/footer/scss/index.scss +0 -2
  87. package/build/components/form/types.d.ts +0 -10
  88. package/build/components/form/types.js +0 -1
  89. package/src/components/footer/index.ts +0 -74
  90. package/src/components/footer/scss/index.scss +0 -26
  91. package/src/components/form/types.ts +0 -14
@@ -1,159 +1,7 @@
1
- import { reactive } from '@esportsplus/reactivity';
2
- import { html, type Attributes } from '@esportsplus/template';
3
- import { omit, toArray } from '@esportsplus/utilities';
4
- import { root } from '@esportsplus/ui';
5
- import template from '~/components/template';
1
+ import menu from './menu';
2
+ import onclick from './onclick';
3
+ import onhover from './onhover';
6
4
  import './scss/index.scss';
7
5
 
8
6
 
9
- let parent: HTMLElement | null | undefined = null,
10
- queue: { fn: VoidFunction, tooltip: HTMLElement }[] = [],
11
- running = false,
12
- scheduled = false;
13
-
14
-
15
- function frame() {
16
- if (running) {
17
- return;
18
- }
19
-
20
- running = true;
21
-
22
- let item,
23
- keep;
24
-
25
- while (item = queue.pop()) {
26
- if (parent === item.tooltip) {
27
- keep = item;
28
- continue;
29
- }
30
-
31
- item.fn();
32
- }
33
-
34
- if (keep) {
35
- queue.push(keep);
36
- }
37
-
38
- running = false;
39
- }
40
-
41
-
42
- const menu = template.factory<
43
- Attributes & {
44
- options: (Attributes & { content: unknown })[],
45
- option?: Attributes,
46
- state?: { active: boolean },
47
- toggle?: boolean,
48
- 'tooltip-content': Attributes & { direction?: string }
49
- }
50
- >(
51
- (attributes, content) => onclick(
52
- omit(attributes, ['options', 'option', 'tooltip-content']),
53
- html`
54
- ${content}
55
-
56
- <div
57
- class='tooltip-content ${`tooltip-content--${attributes['tooltip-content']?.direction || 'nw'}`}'
58
- ${omit(attributes['tooltip-content'], ['direction'])}
59
- >
60
- ${attributes.options.map((option) => html`
61
- <div
62
- class='link --width-full'
63
- ${omit(option, ['content'])}
64
- ${attributes.option}
65
- >
66
- ${option.content}
67
- </div>
68
- `)}
69
- </div>
70
- `
71
- )
72
- );
73
-
74
- const onclick = template.factory<Attributes & { state?: { active: boolean }, toggle?: boolean }>(
75
- (attributes, content) => {
76
- let state = attributes.state || reactive({ active: false });
77
-
78
- attributes.class = toArray(attributes.class);
79
- attributes.class.push(() => {
80
- return state.active && '--active';
81
- });
82
-
83
- attributes.onclick = function(this: HTMLElement, e) {
84
- let active = true,
85
- node = e.target as Node | null;
86
-
87
- if (this === node || (attributes.toggle && this.contains(node))) {
88
- active = !state.active;
89
- }
90
-
91
- if (parent !== this && !parent?.contains(this)) {
92
- parent = this.parentElement?.closest('.tooltip');
93
- }
94
-
95
- frame();
96
-
97
- if (parent === this) {
98
- parent = null;
99
- return;
100
- }
101
-
102
- state.active = active;
103
-
104
- if (active) {
105
- queue.push({
106
- fn: () => state.active = false,
107
- tooltip: this
108
- });
109
- }
110
-
111
- if (!scheduled) {
112
- root.onclick.push(() => {
113
- frame();
114
- scheduled = false;
115
- });
116
- scheduled = true;
117
- }
118
- };
119
-
120
- return html`
121
- <div
122
- class='tooltip'
123
- ${omit(attributes, ['state', 'toggle'])}
124
- >
125
- ${content}
126
- </div>
127
- `;
128
- }
129
- );
130
-
131
- const onhover = template.factory<Attributes & { state?: { active: boolean } }>(
132
- (attributes, content) => {
133
- let state = attributes.state || reactive({ active: false });
134
-
135
- attributes.class = toArray(attributes.class);
136
- attributes.class.push(() => {
137
- return state.active && '--active';
138
- });
139
-
140
- attributes.onmouseover = () => {
141
- state.active = true;
142
- };
143
- attributes.onmouseout = () => {
144
- state.active = false;
145
- };
146
-
147
- return html`
148
- <div
149
- class='tooltip'
150
- ${omit(attributes, ['active', 'state', 'toggle'])}
151
- >
152
- ${content}
153
- </div>
154
- `;
155
- }
156
- );
157
-
158
-
159
- export default { menu, onclick, onhover };
7
+ export default { menu, onclick, onhover };
@@ -0,0 +1,52 @@
1
+ import { html, type Attributes, type Renderable } from '@esportsplus/template';
2
+ import { omit } from '@esportsplus/utilities';
3
+ import template from '~/components/template';
4
+ import onclick from './onclick';
5
+
6
+
7
+ type A = Attributes & {
8
+ options: (Attributes & { content: Renderable<unknown> })[],
9
+ option?: Attributes,
10
+ state?: { active: boolean },
11
+ toggle?: boolean,
12
+ 'tooltip-content': Attributes & { direction?: string }
13
+ };
14
+
15
+
16
+ const OMIT = ['options', 'option', 'state', 'toggle', 'tooltip-content'];
17
+
18
+ const OMIT_OPTION = ['content'];
19
+
20
+ const OMIT_TOOLTIP_CONTENT = ['direction'];
21
+
22
+
23
+ export default template.factory<A>(
24
+ (attributes, content) => {
25
+ let options = attributes.options,
26
+ option = attributes.option,
27
+ tooltipContent = attributes?.['tooltip-content'],
28
+ tooltipContentDirection = tooltipContent?.direction || 'nw';
29
+
30
+ return onclick(
31
+ omit(attributes, OMIT),
32
+ html`
33
+ ${content}
34
+
35
+ <div
36
+ class='tooltip-content ${`tooltip-content--${tooltipContentDirection}`}'
37
+ ${tooltipContent && omit(tooltipContent, OMIT_TOOLTIP_CONTENT)}
38
+ >
39
+ ${options.map((o) => html`
40
+ <div
41
+ class='link --width-full'
42
+ ${omit(o, OMIT_OPTION)}
43
+ ${option}
44
+ >
45
+ ${o.content}
46
+ </div>
47
+ `)}
48
+ </div>
49
+ `
50
+ );
51
+ }
52
+ );
@@ -0,0 +1,97 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html, type Attributes } from '@esportsplus/template';
3
+ import { omit } from '@esportsplus/utilities';
4
+ import { root } from '@esportsplus/ui';
5
+ import template from '~/components/template';
6
+
7
+
8
+ const OMIT = ['state', 'toggle'];
9
+
10
+
11
+ let parent: HTMLElement | null | undefined = null,
12
+ queue: { fn: VoidFunction, tooltip: HTMLElement }[] = [],
13
+ running = false,
14
+ scheduled = false;
15
+
16
+
17
+ function frame() {
18
+ if (running) {
19
+ return;
20
+ }
21
+
22
+ running = true;
23
+
24
+ let item,
25
+ keep;
26
+
27
+ while (item = queue.pop()) {
28
+ if (parent === item.tooltip) {
29
+ keep = item;
30
+ continue;
31
+ }
32
+
33
+ item.fn();
34
+ }
35
+
36
+ if (keep) {
37
+ queue.push(keep);
38
+ }
39
+
40
+ running = false;
41
+ }
42
+
43
+
44
+ export default template.factory<Attributes & { state?: { active: boolean }, toggle?: boolean }>(
45
+ (attributes, content) => {
46
+ let state = attributes.state || reactive({ active: false }),
47
+ toggle = attributes.toggle || false;
48
+
49
+ return html`
50
+ <div
51
+ class='tooltip'
52
+ ${omit(attributes, OMIT)}
53
+ ${{
54
+ class: () => state.active && '--active',
55
+ onclick: function(e) {
56
+ let active = true,
57
+ node = e.target as Node | null;
58
+
59
+ if (this === node || (toggle && this.contains(node))) {
60
+ active = !state.active;
61
+ }
62
+
63
+ if (parent !== this && !parent?.contains(this)) {
64
+ parent = this.parentElement?.closest('.tooltip');
65
+ }
66
+
67
+ frame();
68
+
69
+ if (parent === this) {
70
+ parent = null;
71
+ return;
72
+ }
73
+
74
+ state.active = active;
75
+
76
+ if (active) {
77
+ queue.push({
78
+ fn: () => state.active = false,
79
+ tooltip: this
80
+ });
81
+ }
82
+
83
+ if (!scheduled) {
84
+ root.onclick.push(() => {
85
+ frame();
86
+ scheduled = false;
87
+ });
88
+ scheduled = true;
89
+ }
90
+ }
91
+ }}
92
+ >
93
+ ${content}
94
+ </div>
95
+ `;
96
+ }
97
+ );
@@ -0,0 +1,35 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html, Attributes } from '@esportsplus/template';
3
+ import { omit } from '@esportsplus/utilities';
4
+ import template from '~/components/template';
5
+
6
+
7
+ type A = Attributes & { state?: { active: boolean } };
8
+
9
+
10
+ const OMIT = ['state'];
11
+
12
+
13
+ export default template.factory(
14
+ (attributes: A, content) => {
15
+ let state = attributes.state || reactive({ active: false });
16
+
17
+ return html`
18
+ <div
19
+ class='tooltip'
20
+ ${omit(attributes, OMIT)}
21
+ ${{
22
+ class: () => state.active && '--active',
23
+ onmouseover: () => {
24
+ state.active = true;
25
+ },
26
+ onmouseout: () => {
27
+ state.active = false;
28
+ }
29
+ }}
30
+ >
31
+ ${content}
32
+ </div>
33
+ `;
34
+ }
35
+ );
@@ -1,5 +1,6 @@
1
1
  import { html } from '@esportsplus/template';
2
2
  import { reactive } from '@esportsplus/reactivity';
3
+ import template from '~/components/template';
3
4
  import './scss/index.scss';
4
5
 
5
6
 
@@ -7,49 +8,51 @@ import './scss/index.scss';
7
8
  const EMPTY_NODE = html` `;
8
9
 
9
10
 
10
- export default (content: string[]) => {
11
- let state = reactive({ text: '' });
12
-
13
- return {
14
- attributes: {
15
- class: 'typewriter',
16
- onmount: () => {
17
- let character = 0,
18
- i = 0,
19
- isWriting = true,
20
- write = content[i];
21
-
22
- function play() {
23
- setTimeout(() => {
24
- state.text = write.slice(0, character);
25
-
26
- if (isWriting) {
27
- if (character > write.length) {
28
- isWriting = false;
29
- setTimeout(play, 2000);
30
- return;
31
- }
32
- else {
33
- character++;
34
- }
35
- }
36
- else {
37
- if (character === 0) {
38
- isWriting = true;
39
- write = content[++i] || content[i = 0];
11
+ export default template.factory(
12
+ function(_, content: string[]) {
13
+ let state = reactive({ text: '' });
14
+
15
+ return html`
16
+ <div class='typewriter' ${{
17
+ onconnect: () => {
18
+ let character = 0,
19
+ i = 0,
20
+ isWriting = true,
21
+ write = content[i];
22
+
23
+ function play() {
24
+ setTimeout(() => {
25
+ state.text = write.slice(0, character);
26
+
27
+ if (isWriting) {
28
+ if (character > write.length) {
29
+ isWriting = false;
30
+ setTimeout(play, 2000);
31
+ return;
32
+ }
33
+ else {
34
+ character++;
35
+ }
40
36
  }
41
37
  else {
42
- character--;
38
+ if (character === 0) {
39
+ isWriting = true;
40
+ write = content[++i] || content[i = 0];
41
+ }
42
+ else {
43
+ character--;
44
+ }
43
45
  }
44
- }
45
46
 
46
- play();
47
- }, isWriting ? 64 : 32);
48
- }
47
+ play();
48
+ }, isWriting ? 64 : 32);
49
+ }
49
50
 
50
- play();
51
- }
52
- },
53
- html: () => state.text || EMPTY_NODE
54
- };
55
- };
51
+ play();
52
+ }
53
+ }}>
54
+ ${() => state.text || EMPTY_NODE}
55
+ </div>
56
+ `;
57
+ }
58
+ );
@@ -1,22 +0,0 @@
1
- import { Attributes } from '@esportsplus/template';
2
- import './scss/index.scss';
3
- type Data = {
4
- copyright: Attributes & {
5
- brand: string;
6
- };
7
- footer?: Attributes;
8
- nav?: Attributes & {
9
- links: {
10
- text: string;
11
- url: string;
12
- }[];
13
- };
14
- social?: Attributes & {
15
- links: {
16
- icon: string;
17
- url: string;
18
- }[];
19
- };
20
- };
21
- declare const _default: ({ copyright, footer, nav, social }: Data) => import("@esportsplus/template/build/types").RenderableTemplate;
22
- export default _default;
@@ -1,61 +0,0 @@
1
- import { html, svg } from '@esportsplus/template';
2
- import './scss/index.scss';
3
- import { omit } from '@esportsplus/utilities';
4
- function copy(data) {
5
- return html `
6
- <div class='footer-copyright group-item --flex-center'>
7
- <div
8
- class='text --padding-vertical --padding-300 --text-300'
9
- style='--color-default: var(--color-grey-500);'
10
- ${omit(data, ['brand'])}
11
- >
12
- &copy; ${`${new Date().getFullYear()} ${data.brand}, All rights reserved`}
13
- </div>
14
- </div>
15
- `;
16
- }
17
- export default ({ copyright, footer, nav, social }) => {
18
- return html `
19
- <footer class='footer' ${footer}>
20
- <div class='container'>
21
- <div class='group group--offset-top --flex-center --margin-400'>
22
-
23
- ${nav
24
- ? nav.links.map(({ text, url }) => html `
25
- <div class='group-item'>
26
- <a
27
- class='link --color-white --padding-vertical-300 --text-300'
28
- href='${url}'
29
- style='--color-default: var(--color-grey-500);'
30
- ${omit(nav, ['links'])}
31
- >
32
- ${text}
33
- </a>
34
- </div>
35
- `)
36
- : copy(copyright)}
37
-
38
- <div class='footer-break'></div>
39
-
40
- ${social?.links && social.links.map(({ icon, url }) => html `
41
- <div class='group-item'>
42
- <a
43
- class='link --color-white --padding-0px'
44
- href='${url}'
45
- style='--color-default: var(--color-grey-500);'
46
- ${omit(social, ['links'])}
47
- >
48
- <div class='icon --size-500'>
49
- ${svg.sprite(icon)}
50
- </div>
51
- </a>
52
- </div>
53
- `)}
54
-
55
- ${nav && copy(copyright)}
56
-
57
- </div>
58
- </div>
59
- </footer>
60
- `;
61
- };
@@ -1,2 +0,0 @@
1
- @layer components {.footer,.footer-break{width:100%}@media (max-width:640px){.footer-copyright:first-child{--width:100%}}@media (min-width:640px){.footer-copyright:first-child{margin-right:auto}}.footer-copyright:first-child+.footer-break{display:none}.footer-copyright:last-child{--width:100%}}
2
- /*$vite$:1*/
@@ -1,10 +0,0 @@
1
- import response, { Response } from '@esportsplus/action';
2
- type Action = (data: Payload) => Promise<Errors> | Errors;
3
- type Errors = {
4
- errors: Response<unknown>['errors'];
5
- };
6
- type Payload = {
7
- input: Record<string, any>;
8
- response: typeof response;
9
- };
10
- export type { Action, Errors, Payload };
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
1
- import { html, Attributes, svg } from '@esportsplus/template';
2
- import './scss/index.scss';
3
- import { omit } from '@esportsplus/utilities';
4
-
5
-
6
- type Data = {
7
- copyright: Attributes & { brand: string };
8
- footer?: Attributes;
9
- nav?: Attributes & { links: { text: string, url: string }[] };
10
- social?: Attributes & { links: { icon: string, url: string }[] };
11
- };
12
-
13
-
14
- function copy(data: Data['copyright']) {
15
- return html`
16
- <div class='footer-copyright group-item --flex-center'>
17
- <div
18
- class='text --padding-vertical --padding-300 --text-300'
19
- style='--color-default: var(--color-grey-500);'
20
- ${omit(data, ['brand'])}
21
- >
22
- &copy; ${`${new Date().getFullYear()} ${data.brand}, All rights reserved`}
23
- </div>
24
- </div>
25
- `;
26
- }
27
-
28
-
29
- export default ({ copyright, footer, nav, social }: Data) => {
30
- return html`
31
- <footer class='footer' ${footer}>
32
- <div class='container'>
33
- <div class='group group--offset-top --flex-center --margin-400'>
34
-
35
- ${nav
36
- ? nav.links.map(({ text, url }) => html`
37
- <div class='group-item'>
38
- <a
39
- class='link --color-white --padding-vertical-300 --text-300'
40
- href='${url}'
41
- style='--color-default: var(--color-grey-500);'
42
- ${omit(nav, ['links'])}
43
- >
44
- ${text}
45
- </a>
46
- </div>
47
- `)
48
- : copy(copyright)
49
- }
50
-
51
- <div class='footer-break'></div>
52
-
53
- ${social?.links && social.links.map(({ icon, url }) => html`
54
- <div class='group-item'>
55
- <a
56
- class='link --color-white --padding-0px'
57
- href='${url}'
58
- style='--color-default: var(--color-grey-500);'
59
- ${omit(social, ['links'])}
60
- >
61
- <div class='icon --size-500'>
62
- ${svg.sprite(icon)}
63
- </div>
64
- </a>
65
- </div>
66
- `)}
67
-
68
- ${nav && copy(copyright)}
69
-
70
- </div>
71
- </div>
72
- </footer>
73
- `;
74
- };
@@ -1,26 +0,0 @@
1
- .footer {
2
- &,
3
- &-break {
4
- width: 100%;
5
- }
6
-
7
- &-copyright {
8
- &:first-child {
9
- @media (max-width: 640px) {
10
- --width: 100%;
11
- }
12
-
13
- @media (min-width: 640px) {
14
- margin-right: auto;
15
- }
16
-
17
- + .footer-break {
18
- display: none;
19
- }
20
- }
21
-
22
- &:last-child {
23
- --width: 100%;
24
- }
25
- }
26
- }
@@ -1,14 +0,0 @@
1
- import response, { Response } from '@esportsplus/action';
2
-
3
-
4
- type Action = (data: Payload) => Promise<Errors> | Errors;
5
-
6
- type Errors = { errors: Response<unknown>['errors'] };
7
-
8
- type Payload = {
9
- input: Record<string, any>;
10
- response: typeof response;
11
- };
12
-
13
-
14
- export type { Action, Errors, Payload };