@esportsplus/ui 0.34.9 → 0.35.1

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.
@@ -6,14 +6,10 @@ type A = Attributes & {
6
6
  processing: boolean;
7
7
  };
8
8
  };
9
- type Action = (data: Payload) => Promise<Errors> | Errors;
9
+ type Action = <T extends Record<string, any>>(input: T, r: typeof response) => Promise<Errors> | Errors;
10
10
  type Errors = {
11
11
  errors: Response<unknown>['errors'];
12
12
  };
13
- type Payload = {
14
- input: Record<string, any>;
15
- response: typeof response;
16
- };
17
13
  declare const _default: {
18
14
  (): ReturnType<(this: {
19
15
  attributes?: A | undefined;
@@ -45,10 +45,7 @@ export default template.factory((attributes, content) => {
45
45
  if (state) {
46
46
  state.processing = true;
47
47
  }
48
- let { errors } = await action({
49
- input: parse(new FormData(this).entries()),
50
- response
51
- });
48
+ let { errors } = await action(parse(new FormData(this).entries()), response);
52
49
  for (let i = 0, n = errors.length; i < n; i++) {
53
50
  let { message, path } = errors[i], reactive = input.get(this[path]);
54
51
  if (!reactive) {
@@ -115,10 +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: (data: {
119
- input: Record<string, any>;
120
- response: typeof import("@esportsplus/action").default;
121
- }) => Promise<{
118
+ action: <T extends Record<string, any>>(input: T, r: typeof import("@esportsplus/action").default) => Promise<{
122
119
  errors: import("@esportsplus/action").Response<unknown>["errors"];
123
120
  }> | {
124
121
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -242,10 +239,7 @@ declare const _default: {
242
239
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
243
240
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
244
241
  } & Record<PropertyKey, unknown> & {
245
- action: (data: {
246
- input: Record<string, any>;
247
- response: typeof import("@esportsplus/action").default;
248
- }) => Promise<{
242
+ action: <T extends Record<string, any>>(input: T, r: typeof import("@esportsplus/action").default) => Promise<{
249
243
  errors: import("@esportsplus/action").Response<unknown>["errors"];
250
244
  }> | {
251
245
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -368,10 +362,7 @@ declare const _default: {
368
362
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
369
363
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
370
364
  } & Record<PropertyKey, unknown> & {
371
- action: (data: {
372
- input: Record<string, any>;
373
- response: typeof import("@esportsplus/action").default;
374
- }) => Promise<{
365
+ action: <T_1 extends Record<string, any>>(input: T_1, r: typeof import("@esportsplus/action").default) => Promise<{
375
366
  errors: import("@esportsplus/action").Response<unknown>["errors"];
376
367
  }> | {
377
368
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -494,10 +485,7 @@ declare const _default: {
494
485
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
495
486
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
496
487
  } & Record<PropertyKey, unknown> & {
497
- action: (data: {
498
- input: Record<string, any>;
499
- response: typeof import("@esportsplus/action").default;
500
- }) => Promise<{
488
+ action: <T_1 extends Record<string, any>>(input: T_1, r: typeof import("@esportsplus/action").default) => Promise<{
501
489
  errors: import("@esportsplus/action").Response<unknown>["errors"];
502
490
  }> | {
503
491
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -621,10 +609,7 @@ declare const _default: {
621
609
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
622
610
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
623
611
  } & Record<PropertyKey, unknown> & {
624
- action: (data: {
625
- input: Record<string, any>;
626
- response: typeof import("@esportsplus/action").default;
627
- }) => Promise<{
612
+ action: <T_1 extends Record<string, any>>(input: T_1, r: typeof import("@esportsplus/action").default) => Promise<{
628
613
  errors: import("@esportsplus/action").Response<unknown>["errors"];
629
614
  }> | {
630
615
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -748,10 +733,7 @@ declare const _default: {
748
733
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
749
734
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
750
735
  } & Record<PropertyKey, unknown> & {
751
- action: (data: {
752
- input: Record<string, any>;
753
- response: typeof import("@esportsplus/action").default;
754
- }) => Promise<{
736
+ action: <T_1 extends Record<string, any>>(input: T_1, r: typeof import("@esportsplus/action").default) => Promise<{
755
737
  errors: import("@esportsplus/action").Response<unknown>["errors"];
756
738
  }> | {
757
739
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -875,10 +857,7 @@ declare const _default: {
875
857
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
876
858
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
877
859
  } & Record<PropertyKey, unknown> & {
878
- action: (data: {
879
- input: Record<string, any>;
880
- response: typeof import("@esportsplus/action").default;
881
- }) => Promise<{
860
+ action: <T_1 extends Record<string, any>>(input: T_1, r: typeof import("@esportsplus/action").default) => Promise<{
882
861
  errors: import("@esportsplus/action").Response<unknown>["errors"];
883
862
  }> | {
884
863
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -1001,10 +980,7 @@ declare const _default: {
1001
980
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
1002
981
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
1003
982
  } & Record<PropertyKey, unknown> & {
1004
- action: (data: {
1005
- input: Record<string, any>;
1006
- response: typeof import("@esportsplus/action").default;
1007
- }) => Promise<{
983
+ action: <T extends Record<string, any>>(input: T, r: typeof import("@esportsplus/action").default) => Promise<{
1008
984
  errors: import("@esportsplus/action").Response<unknown>["errors"];
1009
985
  }> | {
1010
986
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -1127,10 +1103,7 @@ declare const _default: {
1127
1103
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
1128
1104
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
1129
1105
  } & Record<PropertyKey, unknown> & {
1130
- action: (data: {
1131
- input: Record<string, any>;
1132
- response: typeof import("@esportsplus/action").default;
1133
- }) => Promise<{
1106
+ action: <T extends Record<string, any>>(input: T, r: typeof import("@esportsplus/action").default) => Promise<{
1134
1107
  errors: import("@esportsplus/action").Response<unknown>["errors"];
1135
1108
  }> | {
1136
1109
  errors: import("@esportsplus/action").Response<unknown>["errors"];
@@ -1254,10 +1227,7 @@ declare const _default: {
1254
1227
  onwebkittransitionend?: ((this: import("@esportsplus/template").Element, event: Event) => void) | undefined;
1255
1228
  onwheel?: ((this: import("@esportsplus/template").Element, event: WheelEvent) => void) | undefined;
1256
1229
  } & Record<PropertyKey, unknown> & {
1257
- action: (data: {
1258
- input: Record<string, any>;
1259
- response: typeof import("@esportsplus/action").default;
1260
- }) => Promise<{
1230
+ action: <T extends Record<string, any>>(input: T, r: typeof import("@esportsplus/action").default) => Promise<{
1261
1231
  errors: import("@esportsplus/action").Response<unknown>["errors"];
1262
1232
  }> | {
1263
1233
  errors: import("@esportsplus/action").Response<unknown>["errors"];
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "private": false,
43
43
  "sideEffects": false,
44
44
  "type": "module",
45
- "version": "0.34.9",
45
+ "version": "0.35.1",
46
46
  "scripts": {
47
47
  "build": "run-s build:vite build:ts",
48
48
  "build:ts": "tsc && tsc-alias",
@@ -7,15 +7,10 @@ import input from './input';
7
7
 
8
8
  type A = Attributes & { action: Action, state?: { processing: boolean } };
9
9
 
10
- type Action = (data: Payload) => Promise<Errors> | Errors;
10
+ type Action = <T extends Record<string, any>>(input: T, r: typeof response) => Promise<Errors> | Errors;
11
11
 
12
12
  type Errors = { errors: Response<unknown>['errors'] };
13
13
 
14
- type Payload = {
15
- input: Record<string, any>;
16
- response: typeof response;
17
- };
18
-
19
14
 
20
15
  const OMIT = ['action', 'state'];
21
16
 
@@ -79,10 +74,10 @@ export default template.factory<A>(
79
74
  state.processing = true;
80
75
  }
81
76
 
82
- let { errors } = await action({
83
- input: parse( new FormData( this as any as HTMLFormElement ).entries() ),
77
+ let { errors } = await action(
78
+ parse( new FormData( this as any as HTMLFormElement ).entries() ),
84
79
  response
85
- });
80
+ );
86
81
 
87
82
  for (let i = 0, n = errors.length; i < n; i++) {
88
83
  let { message, path } = errors[i],