@esportsplus/ui 0.0.117 → 0.0.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib.scss ADDED
@@ -0,0 +1,2 @@
1
+ // Dart sass doesn't support changing root directory for the package to 'src'
2
+ @forward './src/lib';
package/package.json CHANGED
@@ -12,18 +12,18 @@
12
12
  },
13
13
  "files": [
14
14
  "/build/**/*",
15
- "/src/components/**/*.ts"
15
+ "/lib.scss",
16
+ "/tokens.scss"
16
17
  ],
17
18
  "main": "build/index.js",
18
19
  "name": "@esportsplus/ui",
19
20
  "private": false,
20
21
  "scripts": {
21
- "build": "npm run build:ts && npm run build:web",
22
+ "build": "npm run build:ts && npm run build:assets",
22
23
  "build:ts": "tsc && tsc-alias",
23
- "build:web": "webpack build --env=production=true",
24
+ "build:assets": "webpack build --env=production=true",
24
25
  "-": "-",
25
26
  "prepublishOnly": "npm run build"
26
27
  },
27
- "types": "build/index.d.ts",
28
- "version": "0.0.117"
28
+ "version": "0.0.119"
29
29
  }
package/tokens.scss ADDED
@@ -0,0 +1,2 @@
1
+ // Dart sass doesn't support changing root directory for the package to 'src'
2
+ @forward './src/tokens';
package/build/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- require("@esportsplus/webpack/global.d.ts");
18
- __exportStar(require("./components"), exports);
@@ -1,157 +0,0 @@
1
- import { reactive } from '@esportsplus/reactivity';
2
- import { html } from '@esportsplus/template';
3
-
4
-
5
- type Type = 'error' | 'info' | 'success';
6
-
7
-
8
- let modifiers: Record<Type, string> = {
9
- error: 'red',
10
- info: 'black',
11
- success: 'green'
12
- },
13
- state = reactive({
14
- active: false,
15
- messages: new Set as Set<string>,
16
- seconds: 0,
17
- state: 'activating',
18
- type: '' as Type
19
- }),
20
- timeout = 250;
21
-
22
-
23
- function activate(key: Type, messages: string | string[], seconds: number = 0) {
24
- if (!Array.isArray(messages)) {
25
- messages = [messages];
26
- }
27
-
28
- if (!messages.length) {
29
- return;
30
- }
31
-
32
- if (state.type !== key) {
33
- state.messages.clear();
34
- }
35
- else {
36
- // @ts-ignore
37
- state.type = '';
38
- }
39
-
40
- for (let message of messages) {
41
- state.messages.add(message);
42
- }
43
-
44
- state.state = 'activating';
45
- state.type = key;
46
-
47
- // Slide in animation needs time
48
- if (state.active) {
49
- state.active = true;
50
-
51
- if (seconds) {
52
- if (!state.seconds) {
53
- state.seconds = seconds;
54
- }
55
-
56
- setTimeout(() => {
57
- if (messages && messages.length < (state?.messages?.size || 0)) {
58
- for (let message of messages) {
59
- state.messages.delete(message);
60
- }
61
-
62
- state.messages = state.messages;
63
- }
64
- else {
65
- deactivate();
66
- }
67
- }, 400 * seconds);
68
- }
69
- else {
70
- state.seconds = 0;
71
- }
72
- return;
73
- }
74
-
75
- setTimeout(() => {
76
- state.active = true;
77
-
78
- if (seconds) {
79
- if (!state.seconds) {
80
- state.seconds = seconds;
81
- }
82
-
83
- setTimeout(() => {
84
- if (messages && messages.length < (state?.messages?.size || 0)) {
85
- for (let message of messages) {
86
- state.messages.delete(message);
87
- }
88
-
89
- state.messages = state.messages;
90
- }
91
- else {
92
- deactivate();
93
- }
94
- }, 400 * seconds);
95
- }
96
- else {
97
- state.seconds = 0;
98
- }
99
- }, timeout);
100
- }
101
-
102
- function deactivate() {
103
- state.state = 'deactivating';
104
-
105
- setTimeout(() => {
106
- state.active = false;
107
- state.messages.clear();
108
- }, timeout);
109
- }
110
-
111
-
112
- const error = (messages: string | string[], seconds: number = 0) => activate('error', messages, seconds);
113
-
114
- const info = (messages: string | string[], seconds: number = 0) => activate('info', messages, seconds);
115
-
116
- const success = (messages: string | string[], seconds: number = 0) => activate('success', messages, seconds);
117
-
118
-
119
- const h = () => {
120
- // TODO: Fix importing close svg
121
- return () => state.active ? html`
122
- <div class='alert anchor anchor--ne ${() => state.active && '--active'} ${() => `alert--${state.state}`}'>
123
- <div class="alert-close --flex-start --margin-right --margin-100" onclick='${deactivate}'>
124
- <div class='button --background-state ${() => `--background-${modifiers[state.type] || 'black'}`} --color-state --color-white --flex-center --padding-300'>
125
- <div class="icon --size-300">
126
- ${html.inline`
127
- <svg width="16" height="16" viewBox="0 0 16 16">
128
- <path d="M3.527 14.948a.176.176 0 01-.248 0L1.051 12.72a.176.176 0 010-.248l11.42-11.419a.176.176 0 01.248 0l2.229 2.228a.174.174 0 010 .248L3.527 14.948z"/>
129
- <path d="M12.472 14.948c.068.068.18.068.248 0l2.229-2.229a.176.176 0 000-.248L3.528 1.052a.176.176 0 00-.248 0L1.052 3.28a.176.176 0 000 .248l11.42 11.42z"/>
130
- </svg>
131
- `}
132
- </div>
133
- </div>
134
- </div>
135
-
136
- <div class="card --overflow-hidden" style='--background: var(--color-white-400)'>
137
- <div class="alert-message --active --flex-row --padding --padding-horizontal-500 --padding-vertical-400">
138
- <div class='--flex-row --flex-fill --flex-vertical'>
139
- <div class="--flex-fill --flex-column --padding-right --padding-400">
140
- <h5 class="page-title">
141
- ${() => state.type.charAt(0).toUpperCase() + state.type.slice(1)}
142
- </h5>
143
- ${() => state.type && [...state.messages].map((message) => html`
144
- <p class='--margin-top --margin-border-width-500'>${message}</p>
145
- `)}
146
- </div>
147
- </div>
148
- </div>
149
- </div>
150
- </div>
151
- ` : '';
152
- };
153
-
154
- const types = ['error', 'info', 'success'] as const;
155
-
156
-
157
- export default { deactivate, error, html: h, info, success, types };
@@ -1,12 +0,0 @@
1
- export default (value: string) => {
2
- let input = document.createElement('INPUT') as HTMLInputElement;
3
-
4
- document.body.appendChild(input);
5
-
6
- input.setAttribute('value', value);
7
- input.select();
8
-
9
- document.execCommand('copy');
10
-
11
- document.body.removeChild(input);
12
- };
@@ -1,5 +0,0 @@
1
- import clipboard from './clipboard';
2
- import json from './json';
3
-
4
-
5
- export default { clipboard, json };
@@ -1,15 +0,0 @@
1
- export default (content: any[] | Record<string, any>, name: string) => {
2
- let link = document.createElement('a');
3
-
4
- link.download = name + '.json';
5
- link.href = window.URL.createObjectURL(new Blob(
6
- [ JSON.stringify(content) ],
7
- { type: 'application/json' }
8
- ));
9
-
10
- document.body.appendChild(link);
11
-
12
- link.click();
13
-
14
- document.body.removeChild(link);
15
- };
@@ -1,61 +0,0 @@
1
- import { reactive } from '@esportsplus/reactivity';
2
- import { html } from '@esportsplus/template';
3
- import description from './description';
4
-
5
-
6
- type Data = {
7
- class?: string;
8
- field?: {
9
- content?: any;
10
- };
11
- mask?: {
12
- class?: string;
13
- style?: string;
14
- };
15
- name?: string;
16
- style?: string;
17
- title: string;
18
- value?: any;
19
- } & Parameters<typeof description>[0];
20
-
21
-
22
- export default (data: Data) => {
23
- let state = reactive({
24
- active: false
25
- });
26
-
27
- return html`
28
- <div
29
- class="field --flex-column ${data?.class || ''} ${() => state.active ? '--active' : ''}"
30
- onchange='${(e: Event) => {
31
- if ((e.target as HTMLInputElement).type !== 'checkbox') {
32
- return;
33
- }
34
-
35
- state.active = (e.target as HTMLInputElement)?.checked;
36
- }}'
37
- style='${data?.style || ''}'
38
- >
39
- <div class="field-title --flex-horizontal-space-between --flex-vertical">
40
- ${data.title}
41
-
42
- <label
43
- class="field-mask ${(data?.mask?.class || '').indexOf('field-mask--switch') === -1 ? 'field-mask--checkbox' : ''} --margin-left --margin-400 ${data?.mask?.class || ''}"
44
- style='${data?.mask?.style || ''}'
45
- >
46
- <input
47
- class='field-tag field-tag--hidden'
48
- ${data.name ? `name='${data.name}'` : ''}
49
- type='checkbox'
50
- value='1'
51
- ${(data?.class || '').indexOf('--active') !== -1 || data?.value ? 'checked' : ''}
52
- >
53
- </label>
54
- </div>
55
-
56
- ${data?.field?.content || ''}
57
-
58
- ${description(data)}
59
- </div>
60
- `
61
- };
@@ -1,12 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
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
- }
@@ -1,64 +0,0 @@
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
- accept?: string;
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: false,
28
- error: ''
29
- });
30
-
31
- return html`
32
- <div
33
- class="field ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column"
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 || ''} cursor:pointer;'
47
- >
48
- <input
49
- ${data?.accept ? `accept='${data.accept}'` : ''}
50
- class='field-tag field-tag--hidden'
51
- name='${data.name}'
52
- onrender='${form.input.attributes(state)}'
53
- type='file'
54
- ${data?.value !== undefined ? `value='${data.value}'` : ''}
55
- >
56
-
57
- ${data?.mask?.content || ''}
58
- </label>
59
-
60
- ${description(data)}
61
- ${error(state)}
62
- </div>
63
- `;
64
- };
@@ -1,10 +0,0 @@
1
- import checkbox from './checkbox';
2
- import file from './file';
3
- import optional from './optional';
4
- import select from './select';
5
- import s from './switch';
6
- import textarea from './textarea';
7
- import text from './text';
8
-
9
-
10
- export default { checkbox, file, optional, select, switch: s, textarea, text };
@@ -1,27 +0,0 @@
1
- import sel from './select';
2
- import s from './switch';
3
- import tex from './text';
4
-
5
-
6
- const select = (data: Parameters<typeof s>[0] & { field: Parameters<typeof sel>[0] }) => {
7
- data.field.content = sel(
8
- Object.assign(data.field || {}, {
9
- class: `field--optional ${data?.field?.class || ''}`
10
- })
11
- );
12
-
13
- return s(data);
14
- };
15
-
16
- const text = (data: Parameters<typeof s>[0] & { field: Parameters<typeof tex>[0] }) => {
17
- data.field.content = tex(
18
- Object.assign(data.field || {}, {
19
- class: `field--optional ${data?.field?.class || ''}`
20
- })
21
- );
22
-
23
- return s(data);
24
- };
25
-
26
-
27
- export default { select, text };
@@ -1,149 +0,0 @@
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 parse(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 {
49
- options,
50
- selected: selected || keys[0]
51
- };
52
- }
53
-
54
- function template(data: Data, state: { active: boolean, options: Record<number | string, boolean>, selected: number | string }) {
55
- let { attributes: a, html: h } = scrollbar({
56
- fixed: true,
57
- style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
58
- });
59
-
60
- return html`
61
- <div
62
- class='tooltip-content tooltip-content--${data?.tooltip?.direction || 's'} ${data?.tooltip?.class || ''} --flex-column --width-full'
63
- style='${data?.tooltip?.style || ''}'
64
- >
65
- <div
66
- class='row --flex-column'
67
- onclick='${(e: Event) => {
68
- let key = (e?.target as HTMLElement)?.dataset?.key;
69
-
70
- if (key === undefined) {
71
- return;
72
- }
73
-
74
- // Swap active
75
- state.options[key] = true;
76
- state.options[state.selected] = false;
77
-
78
- state.active = false;
79
- state.selected = key;
80
-
81
- if (data.effect) {
82
- data.effect(key);
83
- }
84
- }}'
85
- ${a}
86
- >
87
- ${Object.keys( data.options || {} ).map((key: number | string) => html`
88
- <div
89
- class='link ${data?.option?.class || ''} ${() => state.options[key] ? '--active' : ''} --flex-vertical' data-key='${key}'
90
- style='${data?.option?.style || ''}'
91
- >
92
- <span class="--text-truncate">
93
- ${data.options[key]}
94
- </span>
95
- </div>
96
- `)}
97
- </div>
98
-
99
- ${h}
100
- </div>
101
- `;
102
- }
103
-
104
-
105
- export default (data: Data) => {
106
- let state = reactive(Object.assign({
107
- active: false,
108
- error: '',
109
- render: false,
110
- }, parse(Object.keys( data.options || {} ), data.selected)));
111
-
112
- return html`
113
- <div class="field tooltip ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column" style='${data?.style || ''}'>
114
- ${title(data)}
115
-
116
- <label
117
- 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"
118
- onclick='${() => {
119
- state.render = true;
120
- state.active = !state.active;
121
-
122
- if (state.active) {
123
- root.onclick.add(() => state.active = false);
124
- }
125
- }}'
126
- style='${data?.mask?.style || ''}'
127
- >
128
- <input
129
- class='field-tag field-tag--hidden'
130
- name='${data.name}'
131
- onclick='${() => { /* Prevent double click events from firing */ }}'
132
- onrender='${form.input.attributes(state)}'
133
- value='${() => state.selected}'
134
- >
135
-
136
- <div class="field-text ${data?.text?.class || ''}" style='pointer-events: none'>
137
- ${() => data.options[ state.selected ] || '-'}
138
- </div>
139
-
140
- <div class='field-mask-arrow'></div>
141
-
142
- ${() => state.render ? template(data, state) : ''}
143
- </label>
144
-
145
- ${description(data)}
146
- ${error(state)}
147
- </div>
148
- `;
149
- };
@@ -1,9 +0,0 @@
1
- import checkbox from './checkbox';
2
-
3
-
4
- export default (data: Parameters<typeof checkbox>[0]) => {
5
- data.mask = data.mask || {};
6
- data.mask.class = `field-mask--switch ${data.mask?.class || ''}`;
7
-
8
- return checkbox(data);
9
- };
@@ -1,68 +0,0 @@
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
- class?: string;
11
- mask?: {
12
- class?: string;
13
- content?: any;
14
- style?: string;
15
- };
16
- name?: string;
17
- placeholder?: string;
18
- style?: string;
19
- tag?: {
20
- class?: string;
21
- };
22
- textarea?: boolean;
23
- type?: string;
24
- value?: unknown;
25
- } & Parameters<typeof description>[0] & Parameters<typeof title>[0];
26
-
27
-
28
- export default (data: Data) => {
29
- let state = reactive({
30
- active: false,
31
- error: ''
32
- });
33
-
34
- return html`
35
- <div
36
- class="field ${data?.class || ''} ${() => state.active ? '--active' : ''} --flex-column"
37
- onfocusin='${() => {
38
- state.active = true;
39
- }}'
40
- onfocusout='${() => {
41
- state.active = false;
42
- }}'
43
- style='${data?.style || ''}'
44
- >
45
- ${title(data)}
46
-
47
- <label
48
- class='field-mask field-mask--input --flex-row ${data?.mask?.class || ''} ${(data?.title || (data?.class || '').indexOf('field--optional') !== -1) ? '--margin-top' : ''} --margin-300'
49
- style='${data?.mask?.style || ''}'
50
- >
51
- <${data?.textarea ? 'textarea' : 'input'}
52
- class='field-tag --padding-400 ${data?.tag?.class || ''}'
53
- name='${data?.name || ''}'
54
- placeholder='${data?.placeholder || ''}'
55
- onrender='${form.input.attributes(state)}'
56
- type='${data?.type || 'string'}'
57
- ${!data?.textarea && data?.value !== undefined ? html`value='${data.value}'` : ''}
58
- >
59
- ${data?.textarea ? html`${data?.value || ''}</textarea>` : ''}
60
-
61
- ${data?.mask?.content || ''}
62
- </label>
63
-
64
- ${description(data)}
65
- ${error(state)}
66
- </div>
67
- `;
68
- };
@@ -1,8 +0,0 @@
1
- import text from './text';
2
-
3
-
4
- export default (data: Parameters<typeof text>[0]) => {
5
- data.textarea = true;
6
-
7
- return text(data);
8
- };
@@ -1,23 +0,0 @@
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
- let { attributes } = tooltip.onhover();
11
-
12
- return html`
13
- <div class="field-title --flex-horizontal-space-between --flex-vertical">
14
- ${data.title}
15
-
16
- ${data?.required && html`
17
- <div class="bubble --background-primary --margin-left" ${attributes}>
18
- <span class="tooltip-message tooltip-message--w">Required</span>
19
- </div>
20
- `}
21
- </div>
22
- `;
23
- }
@@ -1,68 +0,0 @@
1
- import { response } from '@esportsplus/action';
2
- import { Action } from './types';
3
- import alert from '~/components/alert';
4
- import input from './input';
5
-
6
-
7
- function parse(input: Record<string, any>) {
8
- let data: Record<string, any> = {};
9
-
10
- for (let path in input) {
11
- let bucket = data,
12
- keys = path.indexOf('.') !== -1 ? path.split('.') : [path];
13
-
14
- for (let i = 0; i < keys.length - 1; i++) {
15
- bucket = bucket[keys[i]] = bucket[keys[i]] || {};
16
- }
17
-
18
- bucket[ keys[keys.length - 1] ] = input[path];
19
- }
20
-
21
- return data;
22
- };
23
-
24
-
25
- export default function(action: Action) {
26
- return {
27
- onclick: function(this: HTMLFormElement, event: Event) {
28
- let trigger = event.target as HTMLButtonElement;
29
-
30
- if (trigger?.type !== 'submit') {
31
- return;
32
- }
33
-
34
- // On initial page load both events will be dispatched without preventDefault
35
- event.preventDefault();
36
-
37
- this.dispatchEvent(
38
- new SubmitEvent('submit', { cancelable: true, bubbles:true, submitter: trigger })
39
- );
40
- },
41
- onsubmit: async function(this: HTMLFormElement, event: SubmitEvent) {
42
- // TODO: Figure out processing
43
- // - Could pass reactive value above and tie it to form layout handler
44
- event.preventDefault();
45
- event?.submitter?.classList.add('button--processing');
46
-
47
- let { errors } = await action({
48
- alert,
49
- input: parse( Object.fromEntries( new FormData( this )?.entries() ) ),
50
- response
51
- });
52
-
53
- for (let i = 0, n = errors.length; i < n; i++) {
54
- let { message, path } = errors[i],
55
- state = input.get( this[path] );
56
-
57
- if (!state) {
58
- continue;
59
- }
60
-
61
- state.error = `${message[0].toUpperCase()}${message.substring(1)}`;
62
- }
63
-
64
- // TODO: replace with signal
65
- event?.submitter?.classList.remove('button--processing');
66
- }
67
- };
68
- };
@@ -1,6 +0,0 @@
1
- import action from './action';
2
- import input from './input';
3
- import layout from './layout';
4
-
5
-
6
- export default { action, input, layout };
@@ -1,15 +0,0 @@
1
- let cache = new WeakMap<HTMLInputElement | HTMLSelectElement, { error: string }>();
2
-
3
-
4
- const attributes = (reactive: { error: string }) => {
5
- return (element: HTMLInputElement | HTMLSelectElement) => {
6
- cache.set(element, reactive);
7
- };
8
- };
9
-
10
- const get = (element?: HTMLInputElement | HTMLSelectElement) => {
11
- return element ? cache.get(element) : undefined;
12
- };
13
-
14
-
15
- export default { attributes, get };
@@ -1,26 +0,0 @@
1
- import { html } from '@esportsplus/template';
2
-
3
-
4
- type Data = {
5
- action?: any;
6
- button?: {
7
- class?: string;
8
- content?: any;
9
- style?: string;
10
- };
11
- class?: string;
12
- content?: any;
13
- };
14
-
15
-
16
- export default (data: Data) => html`
17
- <form class='${data?.class}' ${data?.action || ''}>
18
- ${data?.content || ''}
19
-
20
- ${data?.button?.content ? html`
21
- <button class="button ${data?.button?.class || ''}" style='${data?.button?.style || ''}'>
22
- ${data?.button?.content || ''}
23
- </button>
24
- ` : ''}
25
- </form>
26
- `;
@@ -1,16 +0,0 @@
1
- import { response, Response } from '@esportsplus/action';
2
- import alert from '~/components/alert';
3
-
4
-
5
- type Action = (data: Payload) => Promise<Errors> | Errors;
6
-
7
- type Errors = { errors: Response<unknown>['errors'] };
8
-
9
- type Payload = {
10
- alert: typeof alert;
11
- input: Record<string, any>;
12
- response: typeof response;
13
- };
14
-
15
-
16
- export { Action, Errors, Payload };
@@ -1,10 +0,0 @@
1
- export { default as alert }from './alert';
2
- export { default as export }from './export';
3
- export { default as field }from './field';
4
- export { default as form }from './form';
5
- export { default as number }from './number';
6
- export { default as page }from './page';
7
- export { default as root }from './root';
8
- export { default as scrollbar }from './scrollbar';
9
- export { default as site }from './site';
10
- export { default as tooltip }from './tooltip';
@@ -1,24 +0,0 @@
1
- let formatter: null | Intl.NumberFormat = null,
2
- suffixes = ['th', 'st', 'nd', 'rd'];
3
-
4
-
5
- const abbreviate = (number: number) => {
6
- if (formatter === null) {
7
- formatter = new Intl.NumberFormat('en-GB', {
8
- notation: 'compact',
9
- compactDisplay: 'short'
10
- });
11
- }
12
-
13
- return formatter.format(number);
14
- };
15
-
16
- const ordinal = (number: number) => {
17
- let value = number % 100;
18
-
19
- return suffixes[(value - 20) % 10] || suffixes[value] || suffixes[0];
20
- };
21
-
22
-
23
- export default { abbreviate, ordinal };
24
- export { abbreviate, ordinal };
@@ -1,15 +0,0 @@
1
- const subtitle = {
2
- class: 'page-subtitle --margin-200 --text-crop-bottom'
3
- };
4
-
5
- const suptitle = {
6
- class: 'page-suptitle --text-bold-600 --text-crop --text-uppercase --text-300'
7
- };
8
-
9
- const title = {
10
- class: 'page-title --line-height-200 --margin-400 --text-crop'
11
- };
12
-
13
-
14
- export default { subtitle, suptitle, title };
15
- export { subtitle, suptitle, title };
@@ -1,5 +0,0 @@
1
- import onclick from './onclick';
2
-
3
-
4
- export default { onclick };
5
- export { onclick };
@@ -1,21 +0,0 @@
1
- let queue: VoidFunction[] = [];
2
-
3
-
4
- const onclick = async () => {
5
- if (queue.length === 0) {
6
- return;
7
- }
8
-
9
- let item;
10
-
11
- while (item = queue.pop()) {
12
- await item();
13
- }
14
- };
15
-
16
- onclick.add = (fn: VoidFunction) => {
17
- queue.push(fn);
18
- };
19
-
20
-
21
- export default onclick;
@@ -1,44 +0,0 @@
1
- import { reactive } from '@esportsplus/reactivity';
2
- import { html } from '@esportsplus/template';
3
-
4
-
5
- let root = document.body,
6
- width: number | undefined;
7
-
8
-
9
- export default ({ fixed, style }: { fixed?: boolean, style?: string } = {}) => {
10
- let state = reactive({
11
- height: 100,
12
- translate: 0
13
- });
14
-
15
- return {
16
- attributes: {
17
- class: () => {
18
- return '--scrollbar-content';
19
- },
20
- onscroll: function(this: HTMLElement) {
21
- if (width === undefined) {
22
- width = this.offsetWidth - this.clientWidth;
23
-
24
- if (width && width !== 17) {
25
- root.style.setProperty('--scrollbar-width', `${width}px`);
26
- }
27
- }
28
-
29
- state.height = (this.clientHeight / this.scrollHeight) * 100;
30
- state.translate = (this.scrollTop / this.clientHeight) * 100;
31
- }
32
- },
33
- html: html`
34
- <div
35
- class='scrollbar ${fixed ? 'scrollbar--fixed' : ''} ${() => state.height >= 100 ? 'scrollbar--hidden' : ''}'
36
- style='${() => `
37
- ${style || ''}
38
- --translate: translate3d(0, ${state.translate}%, 0);
39
- --height: ${state.height}%;
40
- `}'
41
- ></div>
42
- `
43
- };
44
- };
@@ -1,27 +0,0 @@
1
- import { html } from '@esportsplus/template';
2
- import { scrollbar } from '~/components';
3
- import { onclick } from '~/components/root';
4
-
5
-
6
- type Data = {
7
- class?: string;
8
- content?: any;
9
- scrollbar?: {
10
- style?: string;
11
- };
12
- };
13
-
14
-
15
- export default (data: Data) => {
16
- let { attributes: a, html: h } = scrollbar({
17
- fixed: true,
18
- style: data?.scrollbar?.style || '--background-default: var(--color-black-400);'
19
- });
20
-
21
- return html`
22
- <section class='site ${data?.class || ''}' onclick='${onclick}' ${a}>
23
- ${data?.content || ''}
24
- ${h}
25
- </section>
26
- `;
27
- };
@@ -1,94 +0,0 @@
1
- import { reactive } from '@esportsplus/reactivity';
2
- import menu from './menu';
3
- import root from '~/components/root';
4
-
5
-
6
- let queue: VoidFunction[] = [],
7
- running = false,
8
- scheduled = false;
9
-
10
-
11
- async function frame() {
12
- if (running) {
13
- return;
14
- }
15
-
16
- running = true;
17
-
18
- let item;
19
-
20
- while (item = queue.pop()) {
21
- await item();
22
- }
23
-
24
- running = false;
25
- }
26
-
27
-
28
- const onclick = (data: { active?: boolean, menu?: Parameters<typeof menu>[0], toggle?: boolean } = {}) => {
29
- let content,
30
- state = reactive({
31
- active: data.active || false,
32
- render: undefined as boolean | undefined
33
- });
34
-
35
- if (data.menu) {
36
- content = menu(data.menu, state);
37
- }
38
-
39
- return {
40
- attributes: {
41
- class: () => {
42
- return `tooltip ${state.active ? '--active' : ''}`;
43
- },
44
- onclick: function(this: HTMLElement, e: Event) {
45
- let active = true,
46
- node = e.target as Node | null;
47
-
48
- if (data.toggle && ( this.contains(node) || this.isSameNode(node) )) {
49
- active = !state.active;
50
- }
51
-
52
- frame();
53
- state.active = active;
54
-
55
- if (active) {
56
- queue.push(() => state.active = false);
57
- }
58
-
59
- if (!scheduled) {
60
- root.onclick.add(() => {
61
- frame();
62
- scheduled = false;
63
- });
64
- scheduled = true;
65
- }
66
- }
67
- },
68
- content,
69
- state
70
- };
71
- };
72
-
73
- const onhover = (active: boolean = false) => {
74
- let state = reactive({
75
- active,
76
- render: undefined as boolean | undefined
77
- });
78
-
79
- return {
80
- attributes: {
81
- class: () => `tooltip ${state.active ? '--active' : ''}`,
82
- onmouseover: () => {
83
- state.active = true;
84
- },
85
- onmouseout: () => {
86
- state.active = false;
87
- }
88
- },
89
- state
90
- };
91
- };
92
-
93
-
94
- export default { onclick, onhover };
@@ -1,71 +0,0 @@
1
- import { effect } from '@esportsplus/reactivity';
2
- import { html } from '@esportsplus/template';
3
-
4
-
5
- type Data = {
6
- class?: string;
7
- direction?: string;
8
- items?: {
9
- border?: {
10
- class?: string;
11
- };
12
- class?: string;
13
- onclick?: (...args: any[]) => void;
14
- style?: string;
15
- svg?: string;
16
- target?: string;
17
- text: string;
18
- url?: string;
19
- }[];
20
- state?: { active?: boolean };
21
- style?: string;
22
- };
23
-
24
-
25
- function template(data: Data) {
26
- return html`
27
- <div class="tooltip-content tooltip-content--${data?.direction || 's'} --flex-column --width-full ${data?.class || ''}" style='${data?.style || ''}'>
28
- ${(data?.items || []).map(item => html`
29
- ${item?.border ? html`
30
- <div
31
- class="border ${item?.border?.class || ''}"
32
- style='
33
- margin-left: calc(var(--margin-horizontal) * -1);
34
- width: calc(100% + var(--margin-horizontal) * 2);
35
- '
36
- ></div>
37
- ` : ''}
38
-
39
- <${item?.url ? 'a' : 'div'}
40
- class='link --flex-vertical ${item?.class}' ${item?.onclick ? html`onclick='${item.onclick}'` : ''}
41
- style='${item?.style || ''}'
42
- ${item?.url ? `href='${item.url}' target='${item.target || '_blank'}'` : ''}
43
- >
44
- ${item?.svg ? html`
45
- <div class="icon --margin-right --margin-300" style='margin-left: var(--size-100)'>
46
- ${item.svg}
47
- </div>
48
- ` : ''}
49
-
50
- <div class="text --color-text --flex-fill">
51
- ${item.text}
52
- </div>
53
- </${item?.url ? 'a' : 'div'}>
54
- `)}
55
- </div>
56
- `;
57
- }
58
-
59
-
60
- // TODO: There's nothing binding activate to tooltip menu ( this is never called outside initial effect run )
61
- export default (data: Data, state: { active?: boolean, render?: boolean }) => {
62
- effect(() => {
63
- if (!state.active || state.render) {
64
- return;
65
- }
66
-
67
- state.render = true;
68
- });
69
-
70
- return () => state.render ? template(data) : '';
71
- };