@esportsplus/ui 0.0.20 → 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 (58) 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/action.d.ts +2 -2
  14. package/build/components/form/action.js +7 -7
  15. package/build/components/form/index.d.ts +8 -0
  16. package/build/components/form/index.js +2 -1
  17. package/build/components/form/input.d.ts +9 -0
  18. package/build/components/form/input.js +10 -0
  19. package/build/components/form/layout.d.ts +2 -2
  20. package/build/components/form/types.d.ts +2 -5
  21. package/build/components/index.d.ts +3 -1
  22. package/build/components/index.js +3 -1
  23. package/build/components/overlay/index.d.ts +10 -0
  24. package/build/components/overlay/index.js +6 -0
  25. package/build/components/page/header.d.ts +2 -3
  26. package/build/components/page/header.js +8 -8
  27. package/build/components/page/index.d.ts +1 -1
  28. package/build/components/page/layout.d.ts +2 -3
  29. package/build/components/root/index.d.ts +1 -19
  30. package/build/components/root/index.js +2 -3
  31. package/build/components/site/index.d.ts +13 -0
  32. package/build/components/site/index.js +14 -0
  33. package/build/components/tooltip/index.d.ts +4 -6
  34. package/build/components/tooltip/index.js +1 -15
  35. package/build/components/tooltip/menu.d.ts +4 -1
  36. package/build/components/tooltip/menu.js +46 -29
  37. package/package.json +1 -1
  38. package/src/components/field/description.ts +12 -0
  39. package/src/components/field/error.ts +14 -0
  40. package/src/components/field/index.ts +6 -0
  41. package/src/components/field/select.ts +147 -0
  42. package/src/components/field/text.ts +64 -0
  43. package/src/components/field/title.ts +21 -0
  44. package/src/components/form/action.ts +9 -9
  45. package/src/components/form/index.ts +2 -1
  46. package/src/components/form/input.ts +15 -0
  47. package/src/components/form/layout.ts +2 -2
  48. package/src/components/form/types.ts +2 -6
  49. package/src/components/index.ts +3 -1
  50. package/src/components/overlay/index.ts +14 -0
  51. package/src/components/page/header.ts +8 -15
  52. package/src/components/page/layout.ts +1 -7
  53. package/src/components/root/index.ts +2 -3
  54. package/src/components/site/index.ts +26 -0
  55. package/src/components/tooltip/index.ts +1 -17
  56. package/src/components/tooltip/menu.ts +53 -31
  57. package/src/components/root/layout.ts +0 -36
  58. package/src/components/state/index.ts +0 -22
@@ -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
+ };
@@ -1,5 +1,5 @@
1
- import { Action, Reactive } from './types';
2
- export default function (action: Action, reactive?: Reactive): {
1
+ import { Action } from './types';
2
+ export default function (action: Action): {
3
3
  content: string;
4
4
  type: string;
5
5
  values: never[];
@@ -1,6 +1,7 @@
1
1
  import { response } from '@esportsplus/action';
2
2
  import { html } from '@esportsplus/template';
3
3
  import alert from '../../components/alert';
4
+ import input from './input';
4
5
  function parse(input) {
5
6
  let data = {};
6
7
  for (let path in input) {
@@ -13,7 +14,7 @@ function parse(input) {
13
14
  return data;
14
15
  }
15
16
  ;
16
- export default function (action, reactive = {}) {
17
+ export default function (action) {
17
18
  return html({
18
19
  onclick: function (event) {
19
20
  let trigger = event.target;
@@ -42,13 +43,12 @@ export default function (action, reactive = {}) {
42
43
  },
43
44
  response
44
45
  });
45
- if (errors && 'errors' in reactive) {
46
- let messages = {};
47
- for (let i = 0, n = errors.length; i < n; i++) {
48
- let { message, path } = errors[i];
49
- messages[path] = `${message[0].toUpperCase()}${message.substring(1)}`;
46
+ for (let i = 0, n = errors.length; i < n; i++) {
47
+ let { message, path } = errors[i], state = input.get(this[path]);
48
+ if (!state) {
49
+ continue;
50
50
  }
51
- reactive.errors = messages;
51
+ state.error = `${message[0].toUpperCase()}${message.substring(1)}`;
52
52
  }
53
53
  }
54
54
  });
@@ -1,6 +1,14 @@
1
1
  import action from './action';
2
2
  declare const _default: {
3
3
  action: typeof action;
4
+ input: {
5
+ attributes: (reactive: {
6
+ error: string;
7
+ }) => (element: HTMLInputElement | HTMLSelectElement) => void;
8
+ get: (element?: HTMLInputElement | HTMLSelectElement | undefined) => {
9
+ error: string;
10
+ } | undefined;
11
+ };
4
12
  layout: (data: {
5
13
  action?: any;
6
14
  button?: {
@@ -1,3 +1,4 @@
1
1
  import action from './action';
2
+ import input from './input';
2
3
  import layout from './layout';
3
- export default { action, layout };
4
+ export default { action, input, layout };
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ attributes: (reactive: {
3
+ error: string;
4
+ }) => (element: HTMLInputElement | HTMLSelectElement) => void;
5
+ get: (element?: HTMLInputElement | HTMLSelectElement | undefined) => {
6
+ error: string;
7
+ } | undefined;
8
+ };
9
+ export default _default;
@@ -0,0 +1,10 @@
1
+ let cache = new WeakMap();
2
+ const attributes = (reactive) => {
3
+ return (element) => {
4
+ cache.set(element, reactive);
5
+ };
6
+ };
7
+ const get = (element) => {
8
+ return element ? cache.get(element) : undefined;
9
+ };
10
+ export default { attributes, get };
@@ -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[];
@@ -2,7 +2,7 @@ import { response, Response } from '@esportsplus/action';
2
2
  import alert from '../../components/alert';
3
3
  type Action = (data: Payload) => Promise<Errors> | Errors;
4
4
  type Errors = {
5
- errors?: Response<unknown>['errors'];
5
+ errors: Response<unknown>['errors'];
6
6
  };
7
7
  type Payload = {
8
8
  alert: typeof alert;
@@ -13,7 +13,4 @@ type Payload = {
13
13
  start: VoidFunction;
14
14
  };
15
15
  };
16
- type Reactive = {
17
- errors?: Record<string, string>;
18
- };
19
- export { Action, Errors, Payload, Reactive };
16
+ export { Action, Errors, Payload };
@@ -1,7 +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';
6
- export { default as state } from './state';
8
+ export { default as site } from './site';
7
9
  export { default as tooltip } from './tooltip';
@@ -1,7 +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';
6
- export { default as state } from './state';
8
+ export { default as site } from './site';
7
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
+ };