@esportsplus/ui 0.0.20 → 0.0.21
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/form/action.d.ts +2 -2
- package/build/components/form/action.js +7 -7
- package/build/components/form/index.d.ts +8 -0
- package/build/components/form/index.js +2 -1
- package/build/components/form/input.d.ts +9 -0
- package/build/components/form/input.js +10 -0
- package/build/components/form/types.d.ts +2 -5
- package/build/components/index.d.ts +0 -1
- package/build/components/index.js +0 -1
- package/package.json +1 -1
- package/src/components/form/action.ts +9 -9
- package/src/components/form/index.ts +2 -1
- package/src/components/form/input.ts +15 -0
- package/src/components/form/types.ts +2 -6
- package/src/components/index.ts +0 -1
- package/src/components/state/index.ts +0 -22
|
@@ -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
|
|
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
|
-
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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?: {
|
|
@@ -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;
|
|
@@ -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
|
|
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
|
-
|
|
17
|
-
errors?: Record<string, string>;
|
|
18
|
-
};
|
|
19
|
-
export { Action, Errors, Payload, Reactive };
|
|
16
|
+
export { Action, Errors, Payload };
|
|
@@ -3,5 +3,4 @@ export { default as form } from './form';
|
|
|
3
3
|
export { default as page } from './page';
|
|
4
4
|
export { default as root } from './root';
|
|
5
5
|
export { default as scrollbar } from './scrollbar';
|
|
6
|
-
export { default as state } from './state';
|
|
7
6
|
export { default as tooltip } from './tooltip';
|
|
@@ -3,5 +3,4 @@ export { default as form } from './form';
|
|
|
3
3
|
export { default as page } from './page';
|
|
4
4
|
export { default as root } from './root';
|
|
5
5
|
export { default as scrollbar } from './scrollbar';
|
|
6
|
-
export { default as state } from './state';
|
|
7
6
|
export { default as tooltip } from './tooltip';
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { response } from '@esportsplus/action';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
|
+
import { Action } from './types';
|
|
3
4
|
import alert from '~/components/alert';
|
|
4
|
-
import
|
|
5
|
+
import input from './input';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
function parse(input: Record<string, any>) {
|
|
@@ -22,7 +23,7 @@ function parse(input: Record<string, any>) {
|
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
export default function(action: Action
|
|
26
|
+
export default function(action: Action) {
|
|
26
27
|
return html({
|
|
27
28
|
onclick: function(this: HTMLFormElement, event: Event) {
|
|
28
29
|
let trigger = event.target as HTMLButtonElement;
|
|
@@ -60,16 +61,15 @@ export default function(action: Action, reactive: Reactive = {}) {
|
|
|
60
61
|
response
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
let
|
|
64
|
+
for (let i = 0, n = errors.length; i < n; i++) {
|
|
65
|
+
let { message, path } = errors[i],
|
|
66
|
+
state = input.get( this[path] );
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
messages[path] = `${message[0].toUpperCase()}${message.substring(1)}`;
|
|
68
|
+
if (!state) {
|
|
69
|
+
continue;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
state.error = `${message[0].toUpperCase()}${message.substring(1)}`;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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 };
|
|
@@ -4,7 +4,7 @@ import alert from '~/components/alert';
|
|
|
4
4
|
|
|
5
5
|
type Action = (data: Payload) => Promise<Errors> | Errors;
|
|
6
6
|
|
|
7
|
-
type Errors = { errors
|
|
7
|
+
type Errors = { errors: Response<unknown>['errors'] };
|
|
8
8
|
|
|
9
9
|
type Payload = {
|
|
10
10
|
alert: typeof alert;
|
|
@@ -16,9 +16,5 @@ type Payload = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
type Reactive = {
|
|
20
|
-
errors?: Record<string, string>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
19
|
|
|
24
|
-
export { Action, Errors, Payload
|
|
20
|
+
export { Action, Errors, Payload };
|
package/src/components/index.ts
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
-
import { html } from '@esportsplus/template';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const onfocus = (active: boolean = false) => {
|
|
6
|
-
let state = reactive({ active });
|
|
7
|
-
|
|
8
|
-
return html({
|
|
9
|
-
class: () => {
|
|
10
|
-
return state.active ? '--active' : '';
|
|
11
|
-
},
|
|
12
|
-
onfocusin: () => {
|
|
13
|
-
state.active = true;
|
|
14
|
-
},
|
|
15
|
-
onfocusout: () => {
|
|
16
|
-
state.active = false;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export default { onfocus };
|