@esportsplus/ui 0.0.21 → 0.0.22

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 (46) hide show
  1. package/build/components/field/description.d.ts +8 -0
  2. package/build/components/field/description.js +9 -0
  3. package/build/components/field/error.d.ts +8 -0
  4. package/build/components/field/error.js +11 -0
  5. package/build/components/field/index.d.ts +66 -0
  6. package/build/components/field/index.js +4 -0
  7. package/build/components/field/select.d.ts +36 -0
  8. package/build/components/field/select.js +101 -0
  9. package/build/components/field/text.d.ts +22 -0
  10. package/build/components/field/text.js +45 -0
  11. package/build/components/field/title.d.ts +9 -0
  12. package/build/components/field/title.js +18 -0
  13. package/build/components/form/layout.d.ts +2 -2
  14. package/build/components/index.d.ts +3 -0
  15. package/build/components/index.js +3 -0
  16. package/build/components/overlay/index.d.ts +10 -0
  17. package/build/components/overlay/index.js +6 -0
  18. package/build/components/page/header.d.ts +2 -3
  19. package/build/components/page/header.js +8 -8
  20. package/build/components/page/index.d.ts +1 -1
  21. package/build/components/page/layout.d.ts +2 -3
  22. package/build/components/root/index.d.ts +1 -19
  23. package/build/components/root/index.js +2 -3
  24. package/build/components/site/index.d.ts +13 -0
  25. package/build/components/site/index.js +14 -0
  26. package/build/components/tooltip/index.d.ts +4 -6
  27. package/build/components/tooltip/index.js +1 -15
  28. package/build/components/tooltip/menu.d.ts +4 -1
  29. package/build/components/tooltip/menu.js +46 -29
  30. package/package.json +1 -1
  31. package/src/components/field/description.ts +12 -0
  32. package/src/components/field/error.ts +14 -0
  33. package/src/components/field/index.ts +6 -0
  34. package/src/components/field/select.ts +147 -0
  35. package/src/components/field/text.ts +64 -0
  36. package/src/components/field/title.ts +21 -0
  37. package/src/components/form/layout.ts +2 -2
  38. package/src/components/index.ts +3 -0
  39. package/src/components/overlay/index.ts +14 -0
  40. package/src/components/page/header.ts +8 -15
  41. package/src/components/page/layout.ts +1 -7
  42. package/src/components/root/index.ts +2 -3
  43. package/src/components/site/index.ts +26 -0
  44. package/src/components/tooltip/index.ts +1 -17
  45. package/src/components/tooltip/menu.ts +53 -31
  46. package/src/components/root/layout.ts +0 -36
@@ -0,0 +1,8 @@
1
+ declare const _default: (data: {
2
+ description?: string;
3
+ }) => "" | {
4
+ content: string;
5
+ type: string;
6
+ values: never[];
7
+ };
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { html } from '@esportsplus/template';
2
+ export default (data) => {
3
+ if (!data?.description) {
4
+ return '';
5
+ }
6
+ return html `
7
+ <div class='field-description --margin-top --margin-300'>${data.description}</div>
8
+ `;
9
+ };
@@ -0,0 +1,8 @@
1
+ declare const _default: (data: {
2
+ error: string;
3
+ }) => () => "" | {
4
+ content: string;
5
+ type: string;
6
+ values: never[];
7
+ };
8
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { html } from '@esportsplus/template';
2
+ export default (data) => {
3
+ return () => {
4
+ if (!data.error) {
5
+ return '';
6
+ }
7
+ return html `
8
+ <div class='field-error --margin-top --margin-300 --text-bold'>${data.error}</div>
9
+ `;
10
+ };
11
+ };
@@ -0,0 +1,66 @@
1
+ import select from './select';
2
+ import text from './text';
3
+ declare const _default: {
4
+ select: (data: {
5
+ class?: string | undefined;
6
+ effect?: ((selected: string | number) => void) | undefined;
7
+ mask?: {
8
+ class?: string | undefined;
9
+ content?: any;
10
+ style?: string | undefined;
11
+ } | undefined;
12
+ name?: string | undefined;
13
+ options: Record<string | number, string | number>;
14
+ option?: {
15
+ class?: string | undefined;
16
+ style?: string | undefined;
17
+ } | undefined;
18
+ selected?: any;
19
+ scrollbar?: {
20
+ style?: string | undefined;
21
+ } | undefined;
22
+ style?: string | undefined;
23
+ text?: {
24
+ class?: string | undefined;
25
+ } | undefined;
26
+ tooltip?: {
27
+ class?: string | undefined;
28
+ direction?: any;
29
+ style?: string | undefined;
30
+ } | undefined;
31
+ } & {
32
+ description?: string | undefined;
33
+ } & {
34
+ required?: boolean | undefined;
35
+ title?: string | undefined;
36
+ }) => {
37
+ content: string;
38
+ type: string;
39
+ values: never[];
40
+ };
41
+ text: (data: {
42
+ active?: boolean | undefined;
43
+ class?: string | undefined;
44
+ mask?: {
45
+ class?: string | undefined;
46
+ content?: any;
47
+ style?: string | undefined;
48
+ } | undefined;
49
+ name?: string | undefined;
50
+ placeholder?: string | undefined;
51
+ style?: string | undefined;
52
+ type?: string | undefined;
53
+ value?: unknown;
54
+ } & {
55
+ description?: string | undefined;
56
+ } & {
57
+ required?: boolean | undefined;
58
+ title?: string | undefined;
59
+ }) => {
60
+ content: string;
61
+ type: string;
62
+ values: never[];
63
+ };
64
+ };
65
+ export default _default;
66
+ export { select, text };
@@ -0,0 +1,4 @@
1
+ import select from './select';
2
+ import text from './text';
3
+ export default { select, text };
4
+ export { select, text };
@@ -0,0 +1,36 @@
1
+ import description from './description';
2
+ import title from './title';
3
+ type Data = {
4
+ class?: string;
5
+ effect?: (selected: number | string) => void;
6
+ mask?: {
7
+ class?: string;
8
+ content?: any;
9
+ style?: string;
10
+ };
11
+ name?: string;
12
+ options: Record<number | string, number | string>;
13
+ option?: {
14
+ class?: string;
15
+ style?: string;
16
+ };
17
+ selected?: any;
18
+ scrollbar?: {
19
+ style?: string;
20
+ };
21
+ style?: string;
22
+ text?: {
23
+ class?: string;
24
+ };
25
+ tooltip?: {
26
+ class?: string;
27
+ direction?: any;
28
+ style?: string;
29
+ };
30
+ } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
31
+ declare const _default: (data: Data) => {
32
+ content: string;
33
+ type: string;
34
+ values: never[];
35
+ };
36
+ export default _default;
@@ -0,0 +1,101 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import { form, scrollbar, root } from '../../components';
4
+ import description from './description';
5
+ import error from './error';
6
+ import title from './title';
7
+ function options(keys, selected) {
8
+ let options = {};
9
+ for (let key of keys) {
10
+ options[key] = false;
11
+ }
12
+ options[selected] = true;
13
+ return options;
14
+ }
15
+ export default (data) => {
16
+ let { attributes: a, html: h } = scrollbar({
17
+ fixed: true,
18
+ style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
19
+ }), state = reactive({
20
+ active: false,
21
+ error: '',
22
+ options: options(Object.keys(data.options || {}), data.selected),
23
+ render: false,
24
+ selected: data.selected
25
+ });
26
+ return html `
27
+ <div class="field tooltip ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column" style='${data?.style || ''}'>
28
+ ${title(data)}
29
+
30
+ <label
31
+ class="field-mask field-mask--select --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) && '--margin-top'} --margin-300 --padding-400"
32
+ onclick='${() => {
33
+ state.render = true;
34
+ state.active = !state.active;
35
+ if (state.active) {
36
+ root.queue.onclick(() => state.active = false);
37
+ }
38
+ }}'
39
+ style='${data?.mask?.style || ''}'
40
+ >
41
+ <input
42
+ class='field-tag field-tag--hidden'
43
+ name='${data.name}'
44
+ onclick='${() => { }}'
45
+ value='${() => state.selected}'
46
+ ${form.input.attributes(state)}
47
+ >
48
+
49
+ <div class="field-text ${data?.text?.class || ''}" style='pointer-events: none'>
50
+ ${() => data.options[state.selected] || '-'}
51
+ </div>
52
+
53
+ <div class='field-mask-arrow'></div>
54
+
55
+ ${() => {
56
+ if (!state.render) {
57
+ return '';
58
+ }
59
+ return html `
60
+ <div class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'>
61
+ <div
62
+ class='row --flex-column'
63
+ onclick='${(e) => {
64
+ let key = e?.target?.dataset?.key;
65
+ if (key === undefined) {
66
+ return;
67
+ }
68
+ state.options[key] = true;
69
+ state.options[state.selected] = false;
70
+ state.active = false;
71
+ state.selected = key;
72
+ if (data.effect) {
73
+ data.effect(key);
74
+ }
75
+ }}'
76
+ style='${data?.tooltip?.style || ''}'
77
+ ${a}
78
+ >
79
+ ${Object.keys(state.options).map((key) => html `
80
+ <div
81
+ class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
82
+ style='${data?.option?.style || ''}'
83
+ >
84
+ <span class="--text-truncate">
85
+ ${data.options[key]}
86
+ </span>
87
+ </div>
88
+ `)}
89
+ </div>
90
+
91
+ ${h}
92
+ </div>
93
+ `;
94
+ }}
95
+ </label>
96
+
97
+ ${description(data)}
98
+ ${error(state)}
99
+ </div>
100
+ `;
101
+ };
@@ -0,0 +1,22 @@
1
+ import description from './description';
2
+ import title from './title';
3
+ type Data = {
4
+ active?: boolean;
5
+ class?: string;
6
+ mask?: {
7
+ class?: string;
8
+ content?: any;
9
+ style?: string;
10
+ };
11
+ name?: string;
12
+ placeholder?: string;
13
+ style?: string;
14
+ type?: string;
15
+ value?: unknown;
16
+ } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
17
+ declare const _default: (data: Data) => {
18
+ content: string;
19
+ type: string;
20
+ values: never[];
21
+ };
22
+ export default _default;
@@ -0,0 +1,45 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import { form } from '../../components';
4
+ import description from './description';
5
+ import error from './error';
6
+ import title from './title';
7
+ export default (data) => {
8
+ let state = reactive({
9
+ active: (data?.active || false),
10
+ error: ''
11
+ });
12
+ return html `
13
+ <div
14
+ class="field --flex-column ${data?.class || ''} ${() => state.active ? '--active' : ''}"
15
+ onfocusin='${() => {
16
+ state.active = true;
17
+ }}'
18
+ onfocusout='${() => {
19
+ state.active = false;
20
+ }}'
21
+ style='${data?.style || ''}'
22
+ >
23
+ ${title(data)}
24
+
25
+ <label
26
+ class='field-mask field-mask--input --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) && '--margin-top'} --margin-300'
27
+ style='${data?.mask?.style || ''}'
28
+ >
29
+ <input
30
+ class='field-tag --padding-400'
31
+ name='${data?.name || ''}'
32
+ placeholder='${data?.placeholder || ''}'
33
+ type='${data?.type || 'string'}'
34
+ ${data?.value !== undefined ? `value='${data.value}'` : ''}
35
+ ${form.input.attributes(state)}
36
+ >
37
+
38
+ ${data?.mask?.content || ''}
39
+ </label>
40
+
41
+ ${description(data)}
42
+ ${error(state)}
43
+ </div>
44
+ `;
45
+ };
@@ -0,0 +1,9 @@
1
+ declare const _default: (data: {
2
+ required?: boolean;
3
+ title?: string;
4
+ }) => "" | {
5
+ content: string;
6
+ type: string;
7
+ values: never[];
8
+ };
9
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { html } from '@esportsplus/template';
2
+ import { tooltip } from '../../components';
3
+ export default (data) => {
4
+ if (!data?.title) {
5
+ return '';
6
+ }
7
+ return html `
8
+ <div class="field-title --flex-horizontal-space-between --flex-vertical">
9
+ ${data.title}
10
+
11
+ ${data?.required && html `
12
+ <div class="bubble --background-primary --margin-left" ${tooltip.onhover()}>
13
+ <span class="tooltip-message tooltip-message--w">Required</span>
14
+ </div>
15
+ `}
16
+ </div>
17
+ `;
18
+ };
@@ -8,8 +8,8 @@ type Data = {
8
8
  };
9
9
  class?: string;
10
10
  content?: any;
11
- };
12
- declare const _default: (data: Data & Parameters<typeof header>[0]) => {
11
+ } & Parameters<typeof header>[0];
12
+ declare const _default: (data: Data) => {
13
13
  content: string;
14
14
  type: string;
15
15
  values: never[];
@@ -1,6 +1,9 @@
1
1
  export { default as alert } from './alert';
2
+ export { default as field } from './field';
2
3
  export { default as form } from './form';
4
+ export { default as overlay } from './overlay';
3
5
  export { default as page } from './page';
4
6
  export { default as root } from './root';
5
7
  export { default as scrollbar } from './scrollbar';
8
+ export { default as site } from './site';
6
9
  export { default as tooltip } from './tooltip';
@@ -1,6 +1,9 @@
1
1
  export { default as alert } from './alert';
2
+ export { default as field } from './field';
2
3
  export { default as form } from './form';
4
+ export { default as overlay } from './overlay';
3
5
  export { default as page } from './page';
4
6
  export { default as root } from './root';
5
7
  export { default as scrollbar } from './scrollbar';
8
+ export { default as site } from './site';
6
9
  export { default as tooltip } from './tooltip';
@@ -0,0 +1,10 @@
1
+ type Data = {
2
+ class?: string;
3
+ content?: any;
4
+ };
5
+ declare const _default: (data?: Data) => {
6
+ content: string;
7
+ type: string;
8
+ values: never[];
9
+ };
10
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { html } from '@esportsplus/template';
2
+ export default (data = {}) => html `
3
+ <section class='overlay ${data?.class || ''}'>
4
+ ${data?.content || ''}
5
+ </section>
6
+ `;
@@ -1,9 +1,8 @@
1
- type Data = {
1
+ declare const _default: (data: {
2
2
  subtitle?: string;
3
3
  suptitle?: string;
4
4
  title?: string;
5
- };
6
- declare const _default: ({ subtitle, suptitle, title }: Data) => {
5
+ }) => {
7
6
  content: string;
8
7
  type: string;
9
8
  values: never[];
@@ -1,20 +1,20 @@
1
1
  import { html } from '@esportsplus/template';
2
- export default ({ subtitle, suptitle, title }) => html `
3
- ${suptitle ? html `
2
+ export default (data) => html `
3
+ ${data?.suptitle ? html `
4
4
  <span class="page-suptitle --text-bold --text-crop --text-uppercase --text-200" style="--color-default: var(--color-primary-400);letter-spacing: 0.24px;">
5
- ${suptitle}
5
+ ${data?.suptitle}
6
6
  </span>
7
7
  ` : ''}
8
8
 
9
- ${title ? html `
10
- <h1 class="page-title --line-height-200 --margin-300 ${!subtitle && '--text-crop-bottom'} ${suptitle ? '--margin-top' : '--text-crop-top'}">
11
- ${title}
9
+ ${data?.title ? html `
10
+ <h1 class="page-title --line-height-200 --margin-300 ${!data?.subtitle && '--text-crop-bottom'} ${data?.suptitle ? '--margin-top' : '--text-crop-top'}">
11
+ ${data?.title}
12
12
  </h1>
13
13
  ` : ''}
14
14
 
15
- ${subtitle ? html `
15
+ ${data?.subtitle ? html `
16
16
  <span class="page-subtitle --margin-top --margin-300 --text-crop-bottom">
17
- ${subtitle}
17
+ ${data?.subtitle}
18
18
  </span>
19
19
  ` : ''}
20
20
  `;
@@ -1,7 +1,7 @@
1
1
  import header from './header';
2
2
  import layout from './layout';
3
3
  declare const _default: {
4
- header: ({ subtitle, suptitle, title }: {
4
+ header: (data: {
5
5
  subtitle?: string | undefined;
6
6
  suptitle?: string | undefined;
7
7
  title?: string | undefined;
@@ -1,8 +1,7 @@
1
- type Data = {
1
+ declare const _default: (data?: {
2
2
  class?: string;
3
3
  content?: any;
4
- };
5
- declare const _default: (data?: Data) => {
4
+ }) => {
6
5
  content: string;
7
6
  type: string;
8
7
  values: never[];
@@ -1,26 +1,8 @@
1
- import layout from './layout';
2
1
  import queue from './queue';
3
2
  declare const _default: {
4
- layout: (data?: {
5
- overlay?: {
6
- class?: string | undefined;
7
- content?: any;
8
- } | undefined;
9
- site?: {
10
- class?: string | undefined;
11
- content?: any;
12
- scrollbar?: {
13
- style?: string | undefined;
14
- } | undefined;
15
- } | undefined;
16
- }) => {
17
- content: string;
18
- type: string;
19
- values: never[];
20
- };
21
3
  queue: {
22
4
  onclick: (fn: VoidFunction) => void;
23
5
  };
24
6
  };
25
7
  export default _default;
26
- export { layout, queue };
8
+ export { queue };
@@ -1,4 +1,3 @@
1
- import layout from './layout';
2
1
  import queue from './queue';
3
- export default { layout, queue };
4
- export { layout, queue };
2
+ export default { queue };
3
+ export { queue };
@@ -0,0 +1,13 @@
1
+ type Data = {
2
+ class?: string;
3
+ content?: any;
4
+ scrollbar?: {
5
+ style?: string;
6
+ };
7
+ };
8
+ declare const _default: (data: Data) => {
9
+ content: string;
10
+ type: string;
11
+ values: never[];
12
+ };
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { html } from '@esportsplus/template';
2
+ import { scrollbar } from '../../components';
3
+ export default (data) => {
4
+ let { attributes: a, html: h } = scrollbar({
5
+ fixed: true,
6
+ style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
7
+ });
8
+ return html `
9
+ <section class='site ${data?.class || ''}' ${a}>
10
+ ${data?.content || ''}
11
+ ${h}
12
+ </section>
13
+ `;
14
+ };
@@ -7,11 +7,6 @@ declare const _default: {
7
7
  type: string;
8
8
  values: never[];
9
9
  };
10
- onfocus: (active?: boolean) => {
11
- content: string;
12
- type: string;
13
- values: never[];
14
- };
15
10
  onhover: (active?: boolean) => {
16
11
  content: string;
17
12
  type: string;
@@ -32,8 +27,11 @@ declare const _default: {
32
27
  text: string;
33
28
  url?: string | undefined;
34
29
  }[] | undefined;
30
+ state: {
31
+ active: boolean;
32
+ };
35
33
  style?: string | undefined;
36
- }) => {
34
+ }) => () => "" | {
37
35
  content: string;
38
36
  type: string;
39
37
  values: never[];
@@ -22,20 +22,6 @@ const onclick = ({ active, toggle }) => {
22
22
  }
23
23
  });
24
24
  };
25
- const onfocus = (active = false) => {
26
- let state = reactive({ active });
27
- return html({
28
- class: () => {
29
- return `tooltip ${state.active ? '--active' : ''}`;
30
- },
31
- onfocusin: () => {
32
- state.active = true;
33
- },
34
- onfocusout: () => {
35
- state.active = false;
36
- }
37
- });
38
- };
39
25
  const onhover = (active = false) => {
40
26
  let state = reactive({ active });
41
27
  return html({
@@ -50,4 +36,4 @@ const onhover = (active = false) => {
50
36
  }
51
37
  });
52
38
  };
53
- export default { onclick, onfocus, onhover, menu };
39
+ export default { onclick, onhover, menu };
@@ -13,9 +13,12 @@ type Data = {
13
13
  text: string;
14
14
  url?: string;
15
15
  }[];
16
+ state: {
17
+ active: boolean;
18
+ };
16
19
  style?: string;
17
20
  };
18
- declare const _default: (data: Data) => {
21
+ declare const _default: (data: Data) => () => "" | {
19
22
  content: string;
20
23
  type: string;
21
24
  values: never[];
@@ -1,32 +1,49 @@
1
+ import { effect, reactive } from '@esportsplus/reactivity';
1
2
  import { html } from '@esportsplus/template';
2
- export default (data) => html `
3
- <div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
4
- ${(data?.items || []).map(item => html `
5
- ${item?.border ? html `
6
- <div
7
- class="border ${item?.border?.class || ''}"
8
- style='
9
- margin-left: calc(var(--margin-horizontal) * -1);
10
- width: calc(100% + var(--margin-horizontal) * 2);
11
- '
12
- ></div>
13
- ` : ''}
3
+ export default (data) => {
4
+ let state = reactive({
5
+ render: false
6
+ });
7
+ effect(() => {
8
+ if (!data.state.active || state.render) {
9
+ return;
10
+ }
11
+ state.render = true;
12
+ });
13
+ return () => {
14
+ if (!state.render) {
15
+ return '';
16
+ }
17
+ return html `
18
+ <div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
19
+ ${(data?.items || []).map(item => html `
20
+ ${item?.border ? html `
21
+ <div
22
+ class="border ${item?.border?.class || ''}"
23
+ style='
24
+ margin-left: calc(var(--margin-horizontal) * -1);
25
+ width: calc(100% + var(--margin-horizontal) * 2);
26
+ '
27
+ ></div>
28
+ ` : ''}
14
29
 
15
- <${item.url ? 'a' : 'div'}
16
- class='link --flex-vertical ${item?.class}' ${item?.onclick ? html `onclick='${item.onclick}'` : ''}
17
- style='${item?.style || ''}'
18
- ${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
19
- >
20
- ${item?.svg ? html `
21
- <div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
22
- ${item.svg}
23
- </div>
24
- ` : ''}
30
+ <${item?.url ? 'a' : 'div'}
31
+ class='link --flex-vertical ${item?.class}' ${item?.onclick ? html({ onclick: item.onclick }) : ''}
32
+ style='${item?.style || ''}'
33
+ ${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
34
+ >
35
+ ${item?.svg ? html `
36
+ <div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
37
+ ${item.svg}
38
+ </div>
39
+ ` : ''}
25
40
 
26
- <div class="text --color-text --flex-fill">
27
- ${item.text}
28
- </div>
29
- </${item.url ? 'a' : 'div'}>
30
- `)}
31
- </div>
32
- `;
41
+ <div class="text --color-text --flex-fill">
42
+ ${item.text}
43
+ </div>
44
+ </${item?.url ? 'a' : 'div'}>
45
+ `)}
46
+ </div>
47
+ `;
48
+ };
49
+ };
package/package.json CHANGED
@@ -37,5 +37,5 @@
37
37
  "prepublishOnly": "npm run build"
38
38
  },
39
39
  "types": "./build/index.d.ts",
40
- "version": "0.0.21"
40
+ "version": "0.0.22"
41
41
  }
@@ -0,0 +1,12 @@
1
+ import { html } from '@esportsplus/template';
2
+
3
+
4
+ export default (data: { description?: string }) => {
5
+ if (!data?.description) {
6
+ return '';
7
+ }
8
+
9
+ return html`
10
+ <div class='field-description --margin-top --margin-300'>${data.description}</div>
11
+ `;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { html } from '@esportsplus/template';
2
+
3
+
4
+ export default (data: { error: string }) => {
5
+ return () => {
6
+ if (!data.error) {
7
+ return '';
8
+ }
9
+
10
+ return html`
11
+ <div class='field-error --margin-top --margin-300 --text-bold'>${data.error}</div>
12
+ `;
13
+ };
14
+ }
@@ -0,0 +1,6 @@
1
+ import select from './select';
2
+ import text from './text';
3
+
4
+
5
+ export default { select, text };
6
+ export { select, text };
@@ -0,0 +1,147 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import { form, scrollbar, root } from '~/components';
4
+ import description from './description';
5
+ import error from './error';
6
+ import title from './title';
7
+
8
+
9
+ type Data = {
10
+ class?: string;
11
+ effect?: (selected: number | string) => void;
12
+ mask?: {
13
+ class?: string;
14
+ content?: any;
15
+ style?: string;
16
+ };
17
+ name?: string;
18
+ options: Record<number | string, number | string>;
19
+ option?: {
20
+ class?: string;
21
+ style?: string;
22
+ };
23
+ selected?: any;
24
+ scrollbar?: {
25
+ style?: string;
26
+ };
27
+ style?: string;
28
+ text?: {
29
+ class?: string;
30
+ };
31
+ tooltip?: {
32
+ class?: string;
33
+ direction?: any;
34
+ style?: string;
35
+ };
36
+ } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
37
+
38
+
39
+ function options(keys: (number | string)[], selected: number | string) {
40
+ let options: Record<string, boolean> = {};
41
+
42
+ for (let key of keys) {
43
+ options[key] = false;
44
+ }
45
+
46
+ options[selected] = true;
47
+
48
+ return options;
49
+ }
50
+
51
+
52
+ export default (data: Data) => {
53
+ let { attributes: a, html: h } = scrollbar({
54
+ fixed: true,
55
+ style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
56
+ }),
57
+ state = reactive({
58
+ active: false,
59
+ error: '',
60
+ options: options(Object.keys( data.options || {} ), data.selected),
61
+ render: false,
62
+ selected: data.selected
63
+ });
64
+
65
+ return html`
66
+ <div class="field tooltip ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column" style='${data?.style || ''}'>
67
+ ${title(data)}
68
+
69
+ <label
70
+ class="field-mask field-mask--select --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) && '--margin-top'} --margin-300 --padding-400"
71
+ onclick='${() => {
72
+ state.render = true;
73
+ state.active = !state.active;
74
+
75
+ if (state.active) {
76
+ root.queue.onclick(() => state.active = false);
77
+ }
78
+ }}'
79
+ style='${data?.mask?.style || ''}'
80
+ >
81
+ <input
82
+ class='field-tag field-tag--hidden'
83
+ name='${data.name}'
84
+ onclick='${() => { /* Prevent double click events from firing */ }}'
85
+ value='${() => state.selected}'
86
+ ${form.input.attributes(state)}
87
+ >
88
+
89
+ <div class="field-text ${data?.text?.class || ''}" style='pointer-events: none'>
90
+ ${() => data.options[ state.selected ] || '-'}
91
+ </div>
92
+
93
+ <div class='field-mask-arrow'></div>
94
+
95
+ ${() => {
96
+ if (!state.render) {
97
+ return '';
98
+ }
99
+
100
+ return html`
101
+ <div class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'>
102
+ <div
103
+ class='row --flex-column'
104
+ onclick='${(e: Event) => {
105
+ let key = (e?.target as HTMLElement)?.dataset?.key;
106
+
107
+ if (key === undefined) {
108
+ return;
109
+ }
110
+
111
+ // Swap active
112
+ state.options[key] = true;
113
+ state.options[state.selected] = false;
114
+
115
+ state.active = false;
116
+ state.selected = key;
117
+
118
+ if (data.effect) {
119
+ data.effect(key);
120
+ }
121
+ }}'
122
+ style='${data?.tooltip?.style || ''}'
123
+ ${a}
124
+ >
125
+ ${Object.keys( state.options ).map((key: number | string) => html`
126
+ <div
127
+ class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
128
+ style='${data?.option?.style || ''}'
129
+ >
130
+ <span class="--text-truncate">
131
+ ${data.options[key]}
132
+ </span>
133
+ </div>
134
+ `)}
135
+ </div>
136
+
137
+ ${h}
138
+ </div>
139
+ `;
140
+ }}
141
+ </label>
142
+
143
+ ${description(data)}
144
+ ${error(state)}
145
+ </div>
146
+ `;
147
+ };
@@ -0,0 +1,64 @@
1
+ import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import { form } from '~/components';
4
+ import description from './description';
5
+ import error from './error';
6
+ import title from './title';
7
+
8
+
9
+ type Data = {
10
+ active?: boolean;
11
+ class?: string;
12
+ mask?: {
13
+ class?: string;
14
+ content?: any;
15
+ style?: string;
16
+ };
17
+ name?: string;
18
+ placeholder?: string;
19
+ style?: string;
20
+ type?: string;
21
+ value?: unknown;
22
+ } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
23
+
24
+
25
+ export default (data: Data) => {
26
+ let state = reactive({
27
+ active: (data?.active || false),
28
+ error: ''
29
+ });
30
+
31
+ return html`
32
+ <div
33
+ class="field --flex-column ${data?.class || ''} ${() => state.active ? '--active' : ''}"
34
+ onfocusin='${() => {
35
+ state.active = true;
36
+ }}'
37
+ onfocusout='${() => {
38
+ state.active = false;
39
+ }}'
40
+ style='${data?.style || ''}'
41
+ >
42
+ ${title(data)}
43
+
44
+ <label
45
+ class='field-mask field-mask--input --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) && '--margin-top'} --margin-300'
46
+ style='${data?.mask?.style || ''}'
47
+ >
48
+ <input
49
+ class='field-tag --padding-400'
50
+ name='${data?.name || ''}'
51
+ placeholder='${data?.placeholder || ''}'
52
+ type='${data?.type || 'string'}'
53
+ ${data?.value !== undefined ? `value='${data.value}'` : ''}
54
+ ${form.input.attributes(state)}
55
+ >
56
+
57
+ ${data?.mask?.content || ''}
58
+ </label>
59
+
60
+ ${description(data)}
61
+ ${error(state)}
62
+ </div>
63
+ `;
64
+ };
@@ -0,0 +1,21 @@
1
+ import { html } from '@esportsplus/template';
2
+ import { tooltip } from '~/components';
3
+
4
+
5
+ export default (data: { required?: boolean, title?: string }) => {
6
+ if (!data?.title) {
7
+ return '';
8
+ }
9
+
10
+ return html`
11
+ <div class="field-title --flex-horizontal-space-between --flex-vertical">
12
+ ${data.title}
13
+
14
+ ${data?.required && html`
15
+ <div class="bubble --background-primary --margin-left" ${tooltip.onhover()}>
16
+ <span class="tooltip-message tooltip-message--w">Required</span>
17
+ </div>
18
+ `}
19
+ </div>
20
+ `;
21
+ }
@@ -11,10 +11,10 @@ type Data = {
11
11
  };
12
12
  class?: string;
13
13
  content?: any;
14
- };
14
+ } & Parameters<typeof header>[0];
15
15
 
16
16
 
17
- export default (data: Data & Parameters<typeof header>[0]) => html`
17
+ export default (data: Data) => html`
18
18
  ${header(data)}
19
19
 
20
20
  <form class='${data?.class}' ${data?.action || ''}>
@@ -1,6 +1,9 @@
1
1
  export { default as alert }from './alert';
2
+ export { default as field }from './field';
2
3
  export { default as form }from './form';
4
+ export { default as overlay }from './overlay';
3
5
  export { default as page }from './page';
4
6
  export { default as root }from './root';
5
7
  export { default as scrollbar }from './scrollbar';
8
+ export { default as site }from './site';
6
9
  export { default as tooltip }from './tooltip';
@@ -0,0 +1,14 @@
1
+ import { html } from '@esportsplus/template';
2
+
3
+
4
+ type Data = {
5
+ class?: string;
6
+ content?: any;
7
+ };
8
+
9
+
10
+ export default (data: Data = {}) => html`
11
+ <section class='overlay ${data?.class || ''}'>
12
+ ${data?.content || ''}
13
+ </section>
14
+ `;
@@ -1,29 +1,22 @@
1
1
  import { html } from '@esportsplus/template';
2
2
 
3
3
 
4
- type Data = {
5
- subtitle?: string;
6
- suptitle?: string;
7
- title?: string;
8
- };
9
-
10
-
11
- export default ({ subtitle, suptitle, title }: Data) => html`
12
- ${suptitle ? html`
4
+ export default (data: { subtitle?: string, suptitle?: string, title?: string }) => html`
5
+ ${data?.suptitle ? html`
13
6
  <span class="page-suptitle --text-bold --text-crop --text-uppercase --text-200" style="--color-default: var(--color-primary-400);letter-spacing: 0.24px;">
14
- ${suptitle}
7
+ ${data?.suptitle}
15
8
  </span>
16
9
  ` : ''}
17
10
 
18
- ${title ? html`
19
- <h1 class="page-title --line-height-200 --margin-300 ${!subtitle && '--text-crop-bottom'} ${suptitle ? '--margin-top' : '--text-crop-top'}">
20
- ${title}
11
+ ${data?.title ? html`
12
+ <h1 class="page-title --line-height-200 --margin-300 ${!data?.subtitle && '--text-crop-bottom'} ${data?.suptitle ? '--margin-top' : '--text-crop-top'}">
13
+ ${data?.title}
21
14
  </h1>
22
15
  ` : ''}
23
16
 
24
- ${subtitle ? html`
17
+ ${data?.subtitle ? html`
25
18
  <span class="page-subtitle --margin-top --margin-300 --text-crop-bottom">
26
- ${subtitle}
19
+ ${data?.subtitle}
27
20
  </span>
28
21
  ` : ''}
29
22
  `;
@@ -1,13 +1,7 @@
1
1
  import { html } from '@esportsplus/template';
2
2
 
3
3
 
4
- type Data = {
5
- class?: string;
6
- content?: any;
7
- };
8
-
9
-
10
- export default (data: Data = {}) => html`
4
+ export default (data: { class?: string, content?: any } = {}) => html`
11
5
  <section class='page ${data?.class}'>
12
6
  ${data?.content}
13
7
  </section>
@@ -1,6 +1,5 @@
1
- import layout from './layout';
2
1
  import queue from './queue';
3
2
 
4
3
 
5
- export default { layout, queue };
6
- export { layout, queue };
4
+ export default { queue };
5
+ export { queue };
@@ -0,0 +1,26 @@
1
+ import { html } from '@esportsplus/template';
2
+ import { scrollbar } from '~/components';
3
+
4
+
5
+ type Data = {
6
+ class?: string;
7
+ content?: any;
8
+ scrollbar?: {
9
+ style?: string;
10
+ };
11
+ };
12
+
13
+
14
+ export default (data: Data) => {
15
+ let { attributes: a, html: h } = scrollbar({
16
+ fixed: true,
17
+ style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
18
+ });
19
+
20
+ return html`
21
+ <section class='site ${data?.class || ''}' ${a}>
22
+ ${data?.content || ''}
23
+ ${h}
24
+ </section>
25
+ `;
26
+ };
@@ -29,22 +29,6 @@ const onclick = ({ active, toggle }: { active?: boolean, toggle?: boolean }) =>
29
29
  });
30
30
  };
31
31
 
32
- const onfocus = (active: boolean = false) => {
33
- let state = reactive({ active });
34
-
35
- return html({
36
- class: () => {
37
- return `tooltip ${state.active ? '--active' : ''}`;
38
- },
39
- onfocusin: () => {
40
- state.active = true;
41
- },
42
- onfocusout: () => {
43
- state.active = false;
44
- }
45
- });
46
- };
47
-
48
32
  const onhover = (active: boolean = false) => {
49
33
  let state = reactive({ active });
50
34
 
@@ -62,4 +46,4 @@ const onhover = (active: boolean = false) => {
62
46
  };
63
47
 
64
48
 
65
- export default { onclick, onfocus, onhover, menu };
49
+ export default { onclick, onhover, menu };
@@ -1,3 +1,4 @@
1
+ import { effect, reactive } from '@esportsplus/reactivity';
1
2
  import { html } from '@esportsplus/template';
2
3
 
3
4
 
@@ -16,38 +17,59 @@ type Data = {
16
17
  text: string;
17
18
  url?: string;
18
19
  }[];
20
+ state: { active: boolean };
19
21
  style?: string;
20
22
  };
21
23
 
22
24
 
23
- export default (data: Data) => html`
24
- <div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
25
- ${(data?.items || []).map(item => html`
26
- ${item?.border ? html`
27
- <div
28
- class="border ${item?.border?.class || ''}"
29
- style='
30
- margin-left: calc(var(--margin-horizontal) * -1);
31
- width: calc(100% + var(--margin-horizontal) * 2);
32
- '
33
- ></div>
34
- ` : ''}
35
-
36
- <${item.url ? 'a' : 'div'}
37
- class='link --flex-vertical ${item?.class}' ${item?.onclick ? html`onclick='${item.onclick}'` : ''}
38
- style='${item?.style || ''}'
39
- ${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
40
- >
41
- ${item?.svg ? html`
42
- <div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
43
- ${item.svg}
44
- </div>
45
- ` : ''}
46
-
47
- <div class="text --color-text --flex-fill">
48
- ${item.text}
49
- </div>
50
- </${item.url ? 'a' : 'div'}>
51
- `)}
52
- </div>
53
- `;
25
+ export default (data: Data) => {
26
+ let state = reactive({
27
+ render: false
28
+ });
29
+
30
+ effect(() => {
31
+ if (!data.state.active || state.render) {
32
+ return;
33
+ }
34
+
35
+ state.render = true;
36
+ });
37
+
38
+ return () => {
39
+ if (!state.render) {
40
+ return '';
41
+ }
42
+
43
+ return html`
44
+ <div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
45
+ ${(data?.items || []).map(item => html`
46
+ ${item?.border ? html`
47
+ <div
48
+ class="border ${item?.border?.class || ''}"
49
+ style='
50
+ margin-left: calc(var(--margin-horizontal) * -1);
51
+ width: calc(100% + var(--margin-horizontal) * 2);
52
+ '
53
+ ></div>
54
+ ` : ''}
55
+
56
+ <${item?.url ? 'a' : 'div'}
57
+ class='link --flex-vertical ${item?.class}' ${item?.onclick ? html({ onclick: item.onclick }) : ''}
58
+ style='${item?.style || ''}'
59
+ ${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
60
+ >
61
+ ${item?.svg ? html`
62
+ <div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
63
+ ${item.svg}
64
+ </div>
65
+ ` : ''}
66
+
67
+ <div class="text --color-text --flex-fill">
68
+ ${item.text}
69
+ </div>
70
+ </${item?.url ? 'a' : 'div'}>
71
+ `)}
72
+ </div>
73
+ `;
74
+ };
75
+ };
@@ -1,36 +0,0 @@
1
- import { html } from '@esportsplus/template';
2
- import { scrollbar } from '~/components';
3
-
4
-
5
- type Data = {
6
- overlay?: {
7
- class?: string;
8
- content?: any;
9
- };
10
- site?: {
11
- class?: string;
12
- content?: any;
13
- scrollbar?: {
14
- style?: string;
15
- };
16
- };
17
- };
18
-
19
-
20
- export default (data: Data = {}) => {
21
- let s = scrollbar({
22
- fixed: true,
23
- style: data?.site?.scrollbar?.style || '--background-default: var(--color-black-400);'
24
- });
25
-
26
- return html`
27
- <section class='site ${data?.site?.class || ''}' ${s.attributes}>
28
- ${data?.site?.content || ''}
29
- ${s.html}
30
- </section>
31
-
32
- <section class='overlay ${data?.overlay?.class || ''}'>
33
- ${data?.overlay?.content || ''}
34
- </section>
35
- `;
36
- };