@esportsplus/ui 0.0.63 → 0.0.64

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.
@@ -26,20 +26,10 @@ export default function (action) {
26
26
  },
27
27
  onsubmit: async function (event) {
28
28
  event.preventDefault();
29
+ event?.submitter?.classList.add('button--processing');
29
30
  let { errors } = await action({
30
31
  alert,
31
32
  input: parse(Object.fromEntries(new FormData(this)?.entries())),
32
- processing: {
33
- end: (deactivate) => {
34
- if (deactivate) {
35
- alert.deactivate();
36
- }
37
- event?.submitter?.classList.remove('button--processing');
38
- },
39
- start: () => {
40
- event?.submitter?.classList.add('button--processing');
41
- }
42
- },
43
33
  response
44
34
  });
45
35
  for (let i = 0, n = errors.length; i < n; i++) {
@@ -49,6 +39,7 @@ export default function (action) {
49
39
  }
50
40
  state.error = `${message[0].toUpperCase()}${message.substring(1)}`;
51
41
  }
42
+ event?.submitter?.classList.remove('button--processing');
52
43
  }
53
44
  });
54
45
  }
@@ -1,16 +1,6 @@
1
- import { response, Response } from '@esportsplus/action';
2
- import alert from '../../components/alert';
3
- type Action = (data: Payload) => Promise<Errors> | Errors;
1
+ import { Response } from '@esportsplus/action';
2
+ type Action = <T>(data: T) => Promise<Errors> | Errors;
4
3
  type Errors = {
5
4
  errors: Response<unknown>['errors'];
6
5
  };
7
- type Payload = {
8
- alert: typeof alert;
9
- input: Record<string, any>;
10
- response: typeof response;
11
- processing: {
12
- end: (deactivate: boolean) => void;
13
- start: VoidFunction;
14
- };
15
- };
16
- export { Action, Errors, Payload };
6
+ export { Action, Errors };
package/package.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "prepublishOnly": "npm run build"
23
23
  },
24
24
  "types": "build/index.d.ts",
25
- "version": "0.0.63"
25
+ "version": "0.0.64"
26
26
  }
@@ -41,23 +41,11 @@ export default function(action: Action) {
41
41
  },
42
42
  onsubmit: async function(this: HTMLFormElement, event: SubmitEvent) {
43
43
  event.preventDefault();
44
+ event?.submitter?.classList.add('button--processing');
44
45
 
45
46
  let { errors } = await action({
46
47
  alert,
47
48
  input: parse( Object.fromEntries( new FormData( this )?.entries() ) ),
48
- processing: {
49
- end: (deactivate?: boolean) => {
50
- if (deactivate) {
51
- alert.deactivate();
52
- }
53
-
54
- // TODO: replace with signal
55
- event?.submitter?.classList.remove('button--processing');
56
- },
57
- start: () => {
58
- event?.submitter?.classList.add('button--processing');
59
- }
60
- },
61
49
  response
62
50
  });
63
51
 
@@ -71,6 +59,9 @@ export default function(action: Action) {
71
59
 
72
60
  state.error = `${message[0].toUpperCase()}${message.substring(1)}`;
73
61
  }
62
+
63
+ // TODO: replace with signal
64
+ event?.submitter?.classList.remove('button--processing');
74
65
  }
75
66
  });
76
67
  };
@@ -1,20 +1,9 @@
1
- import { response, Response } from '@esportsplus/action';
2
- import alert from '~/components/alert';
1
+ import { Response } from '@esportsplus/action';
3
2
 
4
3
 
5
- type Action = (data: Payload) => Promise<Errors> | Errors;
4
+ type Action = <T>(data: T) => Promise<Errors> | Errors;
6
5
 
7
6
  type Errors = { errors: Response<unknown>['errors'] };
8
7
 
9
- type Payload = {
10
- alert: typeof alert;
11
- input: Record<string, any>;
12
- response: typeof response;
13
- processing: {
14
- end: (deactivate: boolean) => void;
15
- start: VoidFunction;
16
- }
17
- };
18
8
 
19
-
20
- export { Action, Errors, Payload };
9
+ export { Action, Errors };