@esportsplus/ui 0.54.0 → 0.55.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.
- package/build/components/accordion/index.d.ts +713 -5
- package/build/components/accordion/index.js +16 -5
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/checkbox/constants.d.ts +2 -0
- package/build/components/checkbox/constants.js +2 -0
- package/build/components/checkbox/index.d.ts +17 -11
- package/build/components/checkbox/index.js +22 -36
- package/build/components/clipboard/copy.d.ts +1 -1
- package/build/components/clipboard/copy.js +12 -7
- package/build/components/clipboard/index.d.ts +981 -981
- package/build/components/clipboard/onclick.js +4 -6
- package/build/components/counter/index.d.ts +1 -1
- package/build/components/counter/index.js +4 -8
- package/build/components/form/action.d.ts +1 -1
- package/build/components/form/action.js +2 -5
- package/build/components/form/index.d.ts +1 -1
- package/build/components/input/index.d.ts +1 -1
- package/build/components/input/index.js +2 -3
- package/build/components/radio/index.d.ts +3 -1442
- package/build/components/radio/index.js +2 -1
- package/build/components/select/constants.d.ts +4 -0
- package/build/components/select/constants.js +4 -0
- package/build/components/select/index.d.ts +12 -6
- package/build/components/select/index.js +43 -60
- package/build/components/switch/index.d.ts +3 -1442
- package/build/components/switch/index.js +2 -1
- package/build/components/textarea/index.d.ts +490 -490
- package/build/components/textarea/index.js +5 -8
- package/build/components/tooltip/constants.d.ts +3 -0
- package/build/components/tooltip/constants.js +3 -0
- package/build/components/tooltip/index.d.ts +8 -2153
- package/build/components/tooltip/index.js +2 -1
- package/build/components/tooltip/menu.d.ts +9 -5
- package/build/components/tooltip/menu.js +14 -17
- package/build/components/tooltip/onclick.d.ts +490 -490
- package/build/components/tooltip/onclick.js +17 -23
- package/build/components/tooltip/onhover.d.ts +497 -494
- package/build/components/tooltip/onhover.js +12 -17
- package/build/themes/dark/input.d.ts +491 -491
- package/build/themes/dark/select.d.ts +3 -735
- package/build/themes/dark/select.js +5 -4
- package/build/themes/dark/textarea.d.ts +490 -490
- package/package.json +2 -2
- package/pnpm-workspace.yaml +1 -1
- package/src/components/accordion/index.ts +7 -14
- package/src/components/accordion/scss/index.scss +3 -1
- package/src/components/checkbox/constants.ts +4 -0
- package/src/components/checkbox/index.ts +12 -23
- package/src/components/clipboard/copy.ts +7 -12
- package/src/components/clipboard/onclick.ts +4 -9
- package/src/components/counter/index.ts +5 -14
- package/src/components/form/action.ts +2 -8
- package/src/components/input/index.ts +7 -5
- package/src/components/radio/index.ts +5 -2
- package/src/components/select/constants.ts +8 -0
- package/src/components/select/index.ts +49 -53
- package/src/components/switch/index.ts +5 -2
- package/src/components/textarea/index.ts +13 -14
- package/src/components/tooltip/constants.ts +6 -0
- package/src/components/tooltip/index.ts +4 -1
- package/src/components/tooltip/menu.ts +18 -29
- package/src/components/tooltip/onclick.ts +22 -33
- package/src/components/tooltip/onhover.ts +18 -29
- package/src/themes/dark/select.ts +7 -4
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"dependencies": {
|
|
4
4
|
"@esportsplus/action": "^0.1.8",
|
|
5
5
|
"@esportsplus/reactivity": "^0.36.7",
|
|
6
|
-
"@esportsplus/template": "^0.
|
|
6
|
+
"@esportsplus/template": "^0.50.0",
|
|
7
7
|
"@esportsplus/utilities": "^0.28.5",
|
|
8
8
|
"modern-normalize": "^3.0.1"
|
|
9
9
|
},
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"**/*.scss"
|
|
59
59
|
],
|
|
60
60
|
"type": "module",
|
|
61
|
-
"version": "0.
|
|
61
|
+
"version": "0.55.0",
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "run-s build:vite build:ts",
|
|
64
64
|
"build:ts": "tsc",
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -15,7 +15,7 @@ minimumReleaseAgeExclude:
|
|
|
15
15
|
- '@esportsplus/action@0.1.7 || 0.1.8'
|
|
16
16
|
- '@esportsplus/queue@0.4.5 || 0.4.6'
|
|
17
17
|
- '@esportsplus/reactivity@0.36.4 || 0.36.6 || 0.36.7'
|
|
18
|
-
- '@esportsplus/template@0.44.4 || 0.44.6 || 0.45.0 || 0.45.1 || 0.45.3 || 0.46.1 || 0.46.2 || 0.46.3 || 0.46.4 || 0.46.5 || 0.46.6 || 0.48.1 || 0.49.0'
|
|
18
|
+
- '@esportsplus/template@0.44.4 || 0.44.6 || 0.45.0 || 0.45.1 || 0.45.3 || 0.46.1 || 0.46.2 || 0.46.3 || 0.46.4 || 0.46.5 || 0.46.6 || 0.48.1 || 0.49.0 || 0.50.0'
|
|
19
19
|
- '@esportsplus/utilities@0.28.3 || 0.28.4 || 0.28.5'
|
|
20
20
|
- '@esportsplus/vite@0.14.2 || 0.14.5 || 0.14.6'
|
|
21
21
|
- '@esportsplus/*'
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import { html, component, type Attributes } from '@esportsplus/template';
|
|
3
3
|
import './scss/index.scss';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const OMIT = ['state'];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default component<A>(
|
|
13
|
-
function(attributes: A, content) {
|
|
14
|
-
let state = attributes.state;
|
|
15
|
-
|
|
6
|
+
export default component<Attributes & { state?: { active: boolean | number } }>(
|
|
7
|
+
function({ state = reactive({ active: false }), ...attributes }, content) {
|
|
16
8
|
return html`
|
|
17
9
|
<div
|
|
18
10
|
class='accordion'
|
|
19
|
-
${
|
|
11
|
+
${attributes}
|
|
20
12
|
${{
|
|
13
|
+
class: () => state.active && '--active',
|
|
21
14
|
inert: () => !state.active
|
|
22
15
|
}}
|
|
23
16
|
>
|
|
@@ -25,4 +18,4 @@ export default component<A>(
|
|
|
25
18
|
</div>
|
|
26
19
|
`;
|
|
27
20
|
}
|
|
28
|
-
);
|
|
21
|
+
);
|
|
@@ -1,51 +1,40 @@
|
|
|
1
1
|
import { html, type Attributes } from '@esportsplus/template';
|
|
2
2
|
import { reactive } from '@esportsplus/reactivity';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import form from '~/components/form';
|
|
5
4
|
import icon from '~/components/icon';
|
|
5
|
+
import { CHECKBOX_INPUT } from './constants';
|
|
6
6
|
import check from './svg/check.svg';
|
|
7
7
|
import './scss/index.scss';
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
type A = Attributes & {
|
|
11
|
-
'aria-label'?: string;
|
|
12
|
-
checked?: boolean;
|
|
13
|
-
id?: string;
|
|
14
|
-
name?: string;
|
|
15
|
-
state?: { error: string };
|
|
16
|
-
value?: number | string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const OMIT = ['aria-label', 'checked', 'id', 'name', 'state', 'value'];
|
|
10
|
+
type A = Attributes & { [CHECKBOX_INPUT]?: Attributes };
|
|
21
11
|
|
|
22
12
|
|
|
23
13
|
const factory = (type: 'checkbox' | 'radio' | 'switch') => {
|
|
24
|
-
function template(
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
function template(
|
|
15
|
+
this: { attributes?: A } | void,
|
|
16
|
+
{ state = reactive({ error: '' }), ...attributes }: A & { state?: { error: string } } = {}
|
|
17
|
+
) {
|
|
27
18
|
return html`
|
|
28
19
|
<div
|
|
29
20
|
class='checkbox ${(type === 'radio' || type === 'switch') && `checkbox--${type}`}'
|
|
30
|
-
${this?.attributes
|
|
31
|
-
${attributes
|
|
21
|
+
${this?.attributes}
|
|
22
|
+
${attributes}
|
|
32
23
|
>
|
|
33
24
|
<input
|
|
34
|
-
aria-label=${attributes?.['aria-label'] ?? this?.attributes?.['aria-label']}
|
|
35
|
-
checked=${attributes?.checked}
|
|
36
25
|
class='checkbox-tag'
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
value='1'
|
|
27
|
+
${this?.attributes?.[CHECKBOX_INPUT]}
|
|
28
|
+
${attributes[CHECKBOX_INPUT]}
|
|
39
29
|
onrender=${form.input.onrender(state)}
|
|
40
30
|
type=${type === 'radio' ? 'radio' : 'checkbox'}
|
|
41
|
-
value=${attributes?.value ?? 1}
|
|
42
31
|
>
|
|
43
32
|
${type === 'checkbox' && icon({ 'aria-hidden': true, class: 'checkbox-check' }, check)}
|
|
44
33
|
</div>
|
|
45
34
|
`;
|
|
46
35
|
}
|
|
47
36
|
|
|
48
|
-
return template;
|
|
37
|
+
return Object.assign(template, { input: CHECKBOX_INPUT } as const);
|
|
49
38
|
};
|
|
50
39
|
|
|
51
40
|
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
2
2
|
import { reactive } from '@esportsplus/reactivity';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import write from './write';
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
type A = Attributes & {
|
|
8
|
-
onerror?: () => void;
|
|
9
7
|
timeout?: number;
|
|
10
8
|
value: string;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export default component<A, (state: { copied: boolean }) => Renderable<unknown>>(
|
|
18
|
-
(attributes, content) => {
|
|
19
|
-
let state = reactive({ copied: false }),
|
|
12
|
+
export default component<A, (state: { copied: boolean, failed: boolean }) => Renderable<unknown>>(
|
|
13
|
+
({ timeout = 3000, value, ...attributes }, content) => {
|
|
14
|
+
let state = reactive({ copied: false, failed: false }),
|
|
20
15
|
timer: ReturnType<typeof setTimeout> | undefined,
|
|
21
16
|
connected = true;
|
|
22
17
|
|
|
23
18
|
return html`
|
|
24
19
|
<button
|
|
25
20
|
type='button'
|
|
26
|
-
${
|
|
21
|
+
${attributes}
|
|
27
22
|
${{
|
|
28
23
|
onconnect: () => { connected = true; },
|
|
29
24
|
ondisconnect: () => {
|
|
@@ -35,7 +30,7 @@ export default component<A, (state: { copied: boolean }) => Renderable<unknown>>
|
|
|
35
30
|
event.preventDefault();
|
|
36
31
|
event.stopPropagation();
|
|
37
32
|
|
|
38
|
-
let copied = await write(
|
|
33
|
+
let copied = await write(value);
|
|
39
34
|
|
|
40
35
|
if (!connected) {
|
|
41
36
|
return;
|
|
@@ -45,11 +40,11 @@ export default component<A, (state: { copied: boolean }) => Renderable<unknown>>
|
|
|
45
40
|
state.copied = copied;
|
|
46
41
|
|
|
47
42
|
if (!copied) {
|
|
48
|
-
|
|
43
|
+
state.failed = true;
|
|
49
44
|
return;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
timer = setTimeout(() => { state.copied = false; },
|
|
47
|
+
timer = setTimeout(() => { state.copied = false; }, timeout);
|
|
53
48
|
}
|
|
54
49
|
}}
|
|
55
50
|
>
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
2
2
|
import { reactive } from '@esportsplus/reactivity';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import write from './write';
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
type A = { timeout?: number, value: string } & Attributes;
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
const OMIT = ['timeout', 'value'];
|
|
11
|
-
|
|
12
|
-
|
|
13
9
|
export default component<A, (state: { copied: boolean }) => Renderable<unknown>>(
|
|
14
|
-
function(attributes, content) {
|
|
10
|
+
function({ timeout = 1000 * 2, value, ...attributes }, content) {
|
|
15
11
|
let state = reactive({
|
|
16
12
|
copied: false
|
|
17
|
-
})
|
|
18
|
-
timeout = attributes.timeout || 1000 * 2;
|
|
13
|
+
});
|
|
19
14
|
|
|
20
15
|
return html`
|
|
21
16
|
<div
|
|
22
|
-
${
|
|
17
|
+
${attributes}
|
|
23
18
|
onclick=${(e: MouseEvent) => {
|
|
24
19
|
e.preventDefault();
|
|
25
20
|
e.stopPropagation();
|
|
26
21
|
|
|
27
|
-
void write(
|
|
22
|
+
void write(value).then(() => {
|
|
28
23
|
state.copied = true;
|
|
29
24
|
|
|
30
25
|
setTimeout(() => {
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { html, type Attributes } from '@esportsplus/template';
|
|
2
2
|
import { effect, onCleanup, reactive, untrack } from '@esportsplus/reactivity';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import './scss/index.scss';
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
const OMIT = ['currency', 'decimals', 'delay', 'max', 'state', 'suffix', 'value'];
|
|
8
|
-
|
|
9
|
-
|
|
10
6
|
let formatters: Record<string, Intl.NumberFormat> = {};
|
|
11
7
|
|
|
12
8
|
|
|
13
|
-
export default (attributes: Attributes & {
|
|
9
|
+
export default ({ currency, decimals = 2, delay, max, state: api = reactive({ value: -1 }), suffix, value, ...attributes }: Attributes & {
|
|
14
10
|
currency?: 'IGNORE' | 'EUR' | 'GBP' | 'USD';
|
|
15
11
|
decimals?: number;
|
|
16
12
|
delay?: number;
|
|
@@ -19,20 +15,15 @@ export default (attributes: Attributes & {
|
|
|
19
15
|
suffix?: string;
|
|
20
16
|
value: number;
|
|
21
17
|
}) => {
|
|
22
|
-
let
|
|
23
|
-
api = attributes.state || reactive({ value: -1 }),
|
|
24
|
-
formatter = currency === 'IGNORE'
|
|
18
|
+
let formatter = currency === 'IGNORE'
|
|
25
19
|
? undefined
|
|
26
20
|
: formatters[currency || 'USD'] ??= new Intl.NumberFormat('en-US', {
|
|
27
21
|
style: 'currency',
|
|
28
22
|
currency: currency || 'USD'
|
|
29
23
|
}),
|
|
30
24
|
animation = reactive({ started: false }),
|
|
31
|
-
render = reactive([] as { digit: boolean; value: string }[])
|
|
32
|
-
|
|
33
|
-
decimals ??= 2;
|
|
34
|
-
|
|
35
|
-
let stop = effect(() => {
|
|
25
|
+
render = reactive([] as { digit: boolean; value: string }[]),
|
|
26
|
+
stop = effect(() => {
|
|
36
27
|
let target = api.value === -1 ? value : api.value,
|
|
37
28
|
started = animation.started;
|
|
38
29
|
|
|
@@ -89,7 +80,7 @@ export default (attributes: Attributes & {
|
|
|
89
80
|
});
|
|
90
81
|
|
|
91
82
|
return html`
|
|
92
|
-
<div class='counter' ${
|
|
83
|
+
<div class='counter' ${attributes}>
|
|
93
84
|
${html.reactive(render, function (character) {
|
|
94
85
|
if (!character.digit) {
|
|
95
86
|
return html`
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import response, { Response } from '@esportsplus/action';
|
|
2
2
|
import { html, Attributes, Element, Renderable } from '@esportsplus/template';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import input from './input';
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
type Errors = { errors: Response<unknown>['errors'] };
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
const OMIT = ['action', 'state'];
|
|
11
|
-
|
|
12
|
-
|
|
13
9
|
function parse(input: ReturnType<FormData['entries']>) {
|
|
14
10
|
let data: Record<string, any> = {};
|
|
15
11
|
|
|
@@ -41,18 +37,16 @@ function parse(input: ReturnType<FormData['entries']>) {
|
|
|
41
37
|
|
|
42
38
|
|
|
43
39
|
export default <T extends Record<string, any>>(
|
|
44
|
-
attributes: {
|
|
40
|
+
{ action, state, ...attributes }: {
|
|
45
41
|
action: (data: { input: T, response: typeof response }) => (Promise<Errors> | Errors),
|
|
46
42
|
state?: { processing: boolean }
|
|
47
43
|
} & Attributes,
|
|
48
44
|
content: Renderable<any>
|
|
49
45
|
) => {
|
|
50
|
-
let { action, state } = attributes;
|
|
51
|
-
|
|
52
46
|
return html`
|
|
53
47
|
<form
|
|
54
48
|
class='form'
|
|
55
|
-
${
|
|
49
|
+
${attributes}
|
|
56
50
|
${{
|
|
57
51
|
onclick: function(event) {
|
|
58
52
|
let trigger = event.target as HTMLButtonElement;
|
|
@@ -6,12 +6,15 @@ import './scss/index.scss';
|
|
|
6
6
|
|
|
7
7
|
export default function (
|
|
8
8
|
this: { attributes?: Attributes } | void,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let state = attributes.state || reactive({
|
|
9
|
+
{
|
|
10
|
+
state = reactive({
|
|
12
11
|
active: false,
|
|
13
12
|
error: ''
|
|
14
|
-
})
|
|
13
|
+
}),
|
|
14
|
+
...attributes
|
|
15
|
+
}: Attributes & { state?: { active: boolean, error: string } }
|
|
16
|
+
) {
|
|
17
|
+
attributes.type ??= 'text';
|
|
15
18
|
|
|
16
19
|
return html`
|
|
17
20
|
<input
|
|
@@ -27,7 +30,6 @@ export default function (
|
|
|
27
30
|
state.active = false;
|
|
28
31
|
},
|
|
29
32
|
onrender: form.input.onrender(state),
|
|
30
|
-
type: (attributes.type || 'text') as string
|
|
31
33
|
}}
|
|
32
34
|
/>
|
|
33
35
|
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const SELECT_ARROW = Symbol.for('@esportsplus/ui/select.arrow');
|
|
2
|
+
|
|
3
|
+
const SELECT_OPTION = Symbol.for('@esportsplus/ui/select.option');
|
|
4
|
+
|
|
5
|
+
const SELECT_TOOLTIP_CONTENT = Symbol.for('@esportsplus/ui/select.tooltip-content');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export { SELECT_ARROW, SELECT_OPTION, SELECT_TOOLTIP_CONTENT };
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import { component, html, type Renderable, type Attributes } from '@esportsplus/template';
|
|
2
2
|
import { reactive } from '@esportsplus/reactivity';
|
|
3
|
-
import { EMPTY_ARRAY, omit, toArray } from '@esportsplus/utilities';
|
|
4
3
|
import form from '~/components/form';
|
|
4
|
+
import { SELECT_ARROW, SELECT_OPTION, SELECT_TOOLTIP_CONTENT } from './constants';
|
|
5
5
|
import './scss/index.scss';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
const OMIT = [
|
|
9
|
-
'arrow',
|
|
10
|
-
'options',
|
|
11
|
-
'option',
|
|
12
|
-
'tooltip-content',
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
|
|
16
8
|
type A = {
|
|
17
|
-
|
|
9
|
+
[SELECT_ARROW]?: Attributes;
|
|
10
|
+
[SELECT_OPTION]?: Attributes;
|
|
11
|
+
[SELECT_TOOLTIP_CONTENT]?: Attributes & { direction?: string };
|
|
18
12
|
options: Record<number | string, Renderable<unknown> | { content: Renderable<unknown>, selected: Renderable<unknown> }>;
|
|
19
|
-
option?: Attributes;
|
|
20
|
-
'tooltip-content'?: Attributes & { direction?: string };
|
|
21
13
|
} & (
|
|
22
14
|
{
|
|
23
15
|
selected?: number | string;
|
|
24
16
|
state?: never;
|
|
25
17
|
} | {
|
|
18
|
+
selected?: never;
|
|
26
19
|
state: {
|
|
27
20
|
active: boolean;
|
|
28
21
|
error: string;
|
|
@@ -33,38 +26,50 @@ type A = {
|
|
|
33
26
|
) & Attributes;
|
|
34
27
|
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
type D = Attributes & Pick<A, typeof SELECT_ARROW | typeof SELECT_OPTION | typeof SELECT_TOOLTIP_CONTENT>;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export default Object.assign(component<A, (state: { active: boolean, selected?: string | number }) => Renderable<unknown>>(
|
|
33
|
+
function(
|
|
34
|
+
this: { attributes?: D },
|
|
35
|
+
{
|
|
36
|
+
options,
|
|
37
|
+
selected,
|
|
38
|
+
state = reactive({
|
|
41
39
|
active: false,
|
|
42
40
|
error: '',
|
|
43
41
|
render: false,
|
|
44
|
-
selected:
|
|
45
|
-
})
|
|
42
|
+
selected: selected || Object.keys(options)[0]
|
|
43
|
+
}),
|
|
44
|
+
...attributes
|
|
45
|
+
}: A,
|
|
46
|
+
content
|
|
47
|
+
) {
|
|
48
|
+
let { direction: defaultDirection, ...defaultTooltipContent } = this?.attributes?.[SELECT_TOOLTIP_CONTENT] ?? {},
|
|
49
|
+
{ direction = defaultDirection || 's', ...tooltipContent } = attributes[SELECT_TOOLTIP_CONTENT] ?? {};
|
|
46
50
|
|
|
47
51
|
return html`
|
|
48
52
|
<div
|
|
49
53
|
class='select tooltip ${() => state.active && '--active'}'
|
|
50
|
-
${this?.attributes
|
|
51
|
-
${
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
${this?.attributes}
|
|
55
|
+
${attributes}
|
|
56
|
+
${{
|
|
57
|
+
onclick: () => {
|
|
58
|
+
if (state.render) {
|
|
59
|
+
state.active = !state.active;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
state.render = true;
|
|
63
|
+
},
|
|
64
|
+
ondocumentclick: function (this, event: MouseEvent) {
|
|
65
|
+
if (!state.active || !this?.isConnected) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!this.contains(event.target as Node | null)) {
|
|
70
|
+
state.active = false;
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
|
-
|
|
67
|
-
state.render = true;
|
|
68
73
|
}}
|
|
69
74
|
>
|
|
70
75
|
${content ? (() => content(state)) : (() => {
|
|
@@ -81,7 +86,7 @@ export default component<A, (state: { active: boolean, selected?: string | numbe
|
|
|
81
86
|
return selected;
|
|
82
87
|
})}
|
|
83
88
|
|
|
84
|
-
<div class='select-arrow' ${this?.attributes?.
|
|
89
|
+
<div class='select-arrow' ${this?.attributes?.[SELECT_ARROW]} ${attributes[SELECT_ARROW]}></div>
|
|
85
90
|
|
|
86
91
|
<input class='select-tag'
|
|
87
92
|
${{
|
|
@@ -104,15 +109,10 @@ export default component<A, (state: { active: boolean, selected?: string | numbe
|
|
|
104
109
|
|
|
105
110
|
return html`
|
|
106
111
|
<div
|
|
107
|
-
class='tooltip-content --flex-column --scrollbar'
|
|
112
|
+
class='tooltip-content tooltip-content--${direction} --flex-column --scrollbar'
|
|
113
|
+
${defaultTooltipContent}
|
|
114
|
+
${tooltipContent}
|
|
108
115
|
${{
|
|
109
|
-
...this?.attributes?.['tooltip-content'] || EMPTY_ARRAY,
|
|
110
|
-
...attributes['tooltip-content'],
|
|
111
|
-
class: [
|
|
112
|
-
...toArray(this?.attributes?.['tooltip-content']?.class),
|
|
113
|
-
...toArray(attributes['tooltip-content']?.class),
|
|
114
|
-
`tooltip-content--${attributes['tooltip-content']?.direction || 's'}`
|
|
115
|
-
],
|
|
116
116
|
inert: () => !state.active,
|
|
117
117
|
onclick: (e: Event) => {
|
|
118
118
|
let element = e.target as HTMLElement,
|
|
@@ -144,11 +144,7 @@ export default component<A, (state: { active: boolean, selected?: string | numbe
|
|
|
144
144
|
},
|
|
145
145
|
onconnect: () => {
|
|
146
146
|
state.active = true;
|
|
147
|
-
}
|
|
148
|
-
style: [
|
|
149
|
-
...toArray(this?.attributes?.['tooltip-content']?.style),
|
|
150
|
-
...toArray(attributes['tooltip-content']?.style)
|
|
151
|
-
],
|
|
147
|
+
}
|
|
152
148
|
}}
|
|
153
149
|
>
|
|
154
150
|
${keys.map((key) => {
|
|
@@ -161,8 +157,8 @@ export default component<A, (state: { active: boolean, selected?: string | numbe
|
|
|
161
157
|
return html`
|
|
162
158
|
<div
|
|
163
159
|
class='link select-option ${() => selected[key] && '--active'}'
|
|
164
|
-
${this?.attributes?.
|
|
165
|
-
${
|
|
160
|
+
${this?.attributes?.[SELECT_OPTION]}
|
|
161
|
+
${attributes[SELECT_OPTION]}
|
|
166
162
|
data-key='${key}'
|
|
167
163
|
>
|
|
168
164
|
${content}
|
|
@@ -175,4 +171,4 @@ export default component<A, (state: { active: boolean, selected?: string | numbe
|
|
|
175
171
|
</div>
|
|
176
172
|
`;
|
|
177
173
|
}
|
|
178
|
-
);
|
|
174
|
+
), { arrow: SELECT_ARROW, option: SELECT_OPTION, tooltipContent: SELECT_TOOLTIP_CONTENT } as const);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { component, html, type Attributes } from '@esportsplus/template';
|
|
2
2
|
import { reactive } from '@esportsplus/reactivity';
|
|
3
|
-
import { omit } from '@esportsplus/utilities';
|
|
4
3
|
import form from '~/components/form';
|
|
5
4
|
import './scss/index.scss';
|
|
6
5
|
|
|
@@ -8,9 +7,6 @@ import './scss/index.scss';
|
|
|
8
7
|
type Autoresize = { height: { max: `${number}px`, min: `${number}px` } };
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
const OMIT = ['autoresize', 'state'];
|
|
12
|
-
|
|
13
|
-
|
|
14
10
|
function autoresize({ height }: Autoresize) {
|
|
15
11
|
let attributes = {
|
|
16
12
|
class: 'textarea--autoresize',
|
|
@@ -39,22 +35,26 @@ function autoresize({ height }: Autoresize) {
|
|
|
39
35
|
|
|
40
36
|
export default component(function(
|
|
41
37
|
this: { attributes?: Attributes },
|
|
42
|
-
|
|
38
|
+
{
|
|
39
|
+
autoresize: resize,
|
|
40
|
+
state = reactive({
|
|
41
|
+
active: false,
|
|
42
|
+
error: ''
|
|
43
|
+
}),
|
|
44
|
+
...attributes
|
|
45
|
+
}: Attributes & {
|
|
43
46
|
autoresize?: Autoresize,
|
|
44
47
|
state?: { active: boolean, error: string }
|
|
45
48
|
}
|
|
46
49
|
) {
|
|
47
|
-
|
|
48
|
-
active: false,
|
|
49
|
-
error: ''
|
|
50
|
-
});
|
|
50
|
+
attributes.value ??= '';
|
|
51
51
|
|
|
52
52
|
return html`
|
|
53
53
|
<textarea
|
|
54
54
|
class='textarea'
|
|
55
|
-
${this?.attributes
|
|
56
|
-
${
|
|
57
|
-
${
|
|
55
|
+
${this?.attributes}
|
|
56
|
+
${attributes}
|
|
57
|
+
${resize && autoresize(resize)}
|
|
58
58
|
${{
|
|
59
59
|
class: () => state.active && '--active',
|
|
60
60
|
onfocusin: () => {
|
|
@@ -63,8 +63,7 @@ export default component(function(
|
|
|
63
63
|
onfocusout: () => {
|
|
64
64
|
state.active = false;
|
|
65
65
|
},
|
|
66
|
-
onrender: form.input.onrender(state)
|
|
67
|
-
value: attributes?.value || ''
|
|
66
|
+
onrender: form.input.onrender(state)
|
|
68
67
|
}}
|
|
69
68
|
></textarea>
|
|
70
69
|
`;
|