@esportsplus/ui 0.35.1 → 0.35.2
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,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Response } from '@esportsplus/action';
|
|
2
2
|
import { Attributes } from '@esportsplus/template';
|
|
3
3
|
type A = Attributes & {
|
|
4
4
|
action: Action;
|
|
@@ -6,7 +6,7 @@ type A = Attributes & {
|
|
|
6
6
|
processing: boolean;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
type Action = <T extends Record<string, any>>(
|
|
9
|
+
type Action = <T extends Record<string, any>>(response: Response<T>) => Promise<Errors> | Errors;
|
|
10
10
|
type Errors = {
|
|
11
11
|
errors: Response<unknown>['errors'];
|
|
12
12
|
};
|
|
@@ -45,7 +45,7 @@ export default template.factory((attributes, content) => {
|
|
|
45
45
|
if (state) {
|
|
46
46
|
state.processing = true;
|
|
47
47
|
}
|
|
48
|
-
let { errors } = await action(parse(new FormData(this).entries())
|
|
48
|
+
let { errors } = await action(response(parse(new FormData(this).entries())));
|
|
49
49
|
for (let i = 0, n = errors.length; i < n; i++) {
|
|
50
50
|
let { message, path } = errors[i], reactive = input.get(this[path]);
|
|
51
51
|
if (!reactive) {
|
|
@@ -115,7 +115,7 @@ declare const _default: {
|
|
|
115
115
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
116
116
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
117
117
|
} & Record<PropertyKey, unknown> & {
|
|
118
|
-
action: <T extends Record<string, any>>(
|
|
118
|
+
action: <T extends Record<string, any>>(response: import("@esportsplus/action").Response<T>) => Promise<{
|
|
119
119
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
120
120
|
}> | {
|
|
121
121
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -239,7 +239,7 @@ declare const _default: {
|
|
|
239
239
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
240
240
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
241
241
|
} & Record<PropertyKey, unknown> & {
|
|
242
|
-
action: <T extends Record<string, any>>(
|
|
242
|
+
action: <T extends Record<string, any>>(response: import("@esportsplus/action").Response<T>) => Promise<{
|
|
243
243
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
244
244
|
}> | {
|
|
245
245
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -362,7 +362,7 @@ declare const _default: {
|
|
|
362
362
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
363
363
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
364
364
|
} & Record<PropertyKey, unknown> & {
|
|
365
|
-
action: <T_1 extends Record<string, any>>(
|
|
365
|
+
action: <T_1 extends Record<string, any>>(response: import("@esportsplus/action").Response<T_1>) => Promise<{
|
|
366
366
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
367
367
|
}> | {
|
|
368
368
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -485,7 +485,7 @@ declare const _default: {
|
|
|
485
485
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
486
486
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
487
487
|
} & Record<PropertyKey, unknown> & {
|
|
488
|
-
action: <T_1 extends Record<string, any>>(
|
|
488
|
+
action: <T_1 extends Record<string, any>>(response: import("@esportsplus/action").Response<T_1>) => Promise<{
|
|
489
489
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
490
490
|
}> | {
|
|
491
491
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -609,7 +609,7 @@ declare const _default: {
|
|
|
609
609
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
610
610
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
611
611
|
} & Record<PropertyKey, unknown> & {
|
|
612
|
-
action: <T_1 extends Record<string, any>>(
|
|
612
|
+
action: <T_1 extends Record<string, any>>(response: import("@esportsplus/action").Response<T_1>) => Promise<{
|
|
613
613
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
614
614
|
}> | {
|
|
615
615
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -733,7 +733,7 @@ declare const _default: {
|
|
|
733
733
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
734
734
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
735
735
|
} & Record<PropertyKey, unknown> & {
|
|
736
|
-
action: <T_1 extends Record<string, any>>(
|
|
736
|
+
action: <T_1 extends Record<string, any>>(response: import("@esportsplus/action").Response<T_1>) => Promise<{
|
|
737
737
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
738
738
|
}> | {
|
|
739
739
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -857,7 +857,7 @@ declare const _default: {
|
|
|
857
857
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
858
858
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
859
859
|
} & Record<PropertyKey, unknown> & {
|
|
860
|
-
action: <T_1 extends Record<string, any>>(
|
|
860
|
+
action: <T_1 extends Record<string, any>>(response: import("@esportsplus/action").Response<T_1>) => Promise<{
|
|
861
861
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
862
862
|
}> | {
|
|
863
863
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -980,7 +980,7 @@ declare const _default: {
|
|
|
980
980
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
981
981
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
982
982
|
} & Record<PropertyKey, unknown> & {
|
|
983
|
-
action: <T extends Record<string, any>>(
|
|
983
|
+
action: <T extends Record<string, any>>(response: import("@esportsplus/action").Response<T>) => Promise<{
|
|
984
984
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
985
985
|
}> | {
|
|
986
986
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -1103,7 +1103,7 @@ declare const _default: {
|
|
|
1103
1103
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
1104
1104
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
1105
1105
|
} & Record<PropertyKey, unknown> & {
|
|
1106
|
-
action: <T extends Record<string, any>>(
|
|
1106
|
+
action: <T extends Record<string, any>>(response: import("@esportsplus/action").Response<T>) => Promise<{
|
|
1107
1107
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
1108
1108
|
}> | {
|
|
1109
1109
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
@@ -1227,7 +1227,7 @@ declare const _default: {
|
|
|
1227
1227
|
onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
|
|
1228
1228
|
onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
|
|
1229
1229
|
} & Record<PropertyKey, unknown> & {
|
|
1230
|
-
action: <T extends Record<string, any>>(
|
|
1230
|
+
action: <T extends Record<string, any>>(response: import("@esportsplus/action").Response<T>) => Promise<{
|
|
1231
1231
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
|
1232
1232
|
}> | {
|
|
1233
1233
|
errors: import("@esportsplus/action").Response<unknown>["errors"];
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import input from './input';
|
|
|
7
7
|
|
|
8
8
|
type A = Attributes & { action: Action, state?: { processing: boolean } };
|
|
9
9
|
|
|
10
|
-
type Action = <T extends Record<string, any>>(
|
|
10
|
+
type Action = <T extends Record<string, any>>(response: Response<T>) => Promise<Errors> | Errors;
|
|
11
11
|
|
|
12
12
|
type Errors = { errors: Response<unknown>['errors'] };
|
|
13
13
|
|
|
@@ -75,8 +75,7 @@ export default template.factory<A>(
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
let { errors } = await action(
|
|
78
|
-
parse( new FormData( this as any as HTMLFormElement ).entries() )
|
|
79
|
-
response
|
|
78
|
+
response(parse( new FormData( this as any as HTMLFormElement ).entries() ))
|
|
80
79
|
);
|
|
81
80
|
|
|
82
81
|
for (let i = 0, n = errors.length; i < n; i++) {
|