@esportsplus/ui 0.35.7 → 0.35.9
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.
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import response, { Response } from '@esportsplus/action';
|
|
2
|
-
import { Attributes } from '@esportsplus/template';
|
|
3
|
-
type A = {
|
|
4
|
-
action: (input: Record<string, any>, r: typeof response) => (Promise<Errors> | Errors);
|
|
5
|
-
state?: {
|
|
6
|
-
processing: boolean;
|
|
7
|
-
};
|
|
8
|
-
} & Attributes;
|
|
2
|
+
import { Attributes, Renderable } from '@esportsplus/template';
|
|
9
3
|
type Errors = {
|
|
10
4
|
errors: Response<unknown>['errors'];
|
|
11
5
|
};
|
|
12
|
-
declare const _default: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<T extends import("@esportsplus/template").Renderable<any>>(content: T): ReturnType<(this: {
|
|
22
|
-
attributes?: A | undefined;
|
|
23
|
-
content?: import("@esportsplus/template").Renderable<any>;
|
|
24
|
-
}, attributes: Readonly<A>, content: import("@esportsplus/template").Renderable<any>) => import("@esportsplus/template").Renderable<any>>;
|
|
25
|
-
(attributes: A, content: import("@esportsplus/template").Renderable<any>): ReturnType<(this: {
|
|
26
|
-
attributes?: A | undefined;
|
|
27
|
-
content?: import("@esportsplus/template").Renderable<any>;
|
|
28
|
-
}, attributes: Readonly<A>, content: import("@esportsplus/template").Renderable<any>) => import("@esportsplus/template").Renderable<any>>;
|
|
29
|
-
};
|
|
6
|
+
declare const _default: <T extends Record<string, any>>(attributes: {
|
|
7
|
+
action: (data: {
|
|
8
|
+
input: T;
|
|
9
|
+
response: typeof response;
|
|
10
|
+
}) => (Promise<Errors> | Errors);
|
|
11
|
+
state?: {
|
|
12
|
+
processing: boolean;
|
|
13
|
+
};
|
|
14
|
+
} & Attributes, content: Renderable<any>) => Node;
|
|
30
15
|
export default _default;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import response from '@esportsplus/action';
|
|
2
2
|
import { html } from '@esportsplus/template';
|
|
3
3
|
import { omit } from '@esportsplus/utilities';
|
|
4
|
-
import template from '../../components/template/index.js';
|
|
5
4
|
import input from './input.js';
|
|
6
5
|
const OMIT = ['action', 'state'];
|
|
7
6
|
function parse(input) {
|
|
@@ -26,12 +25,12 @@ function parse(input) {
|
|
|
26
25
|
return data;
|
|
27
26
|
}
|
|
28
27
|
;
|
|
29
|
-
export default
|
|
28
|
+
export default (attributes, content) => {
|
|
30
29
|
let { action, state } = attributes;
|
|
31
30
|
return html `
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
<form
|
|
32
|
+
${omit(attributes, OMIT)}
|
|
33
|
+
${{
|
|
35
34
|
onclick: function (event) {
|
|
36
35
|
let trigger = event.target;
|
|
37
36
|
if (trigger?.type !== 'submit') {
|
|
@@ -45,7 +44,10 @@ export default template.factory((attributes, content) => {
|
|
|
45
44
|
if (state) {
|
|
46
45
|
state.processing = true;
|
|
47
46
|
}
|
|
48
|
-
let { errors } = await action(
|
|
47
|
+
let { errors } = await action({
|
|
48
|
+
input: parse(new FormData(this).entries()),
|
|
49
|
+
response
|
|
50
|
+
});
|
|
49
51
|
for (let i = 0, n = errors.length; i < n; i++) {
|
|
50
52
|
let { message, path } = errors[i], reactive = input.get(this[path]);
|
|
51
53
|
if (!reactive) {
|
|
@@ -58,8 +60,8 @@ export default template.factory((attributes, content) => {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
}}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
63
|
+
>
|
|
64
|
+
${content}
|
|
65
|
+
</form>
|
|
66
|
+
`;
|
|
67
|
+
};
|