@esportsplus/ui 0.0.64 → 0.0.66

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,6 +1,12 @@
1
- import { Response } from '@esportsplus/action';
2
- type Action = <T>(data: T) => Promise<Errors> | Errors;
1
+ import { response, Response } from '@esportsplus/action';
2
+ import alert from '../../components/alert';
3
+ type Action = (data: Payload) => Promise<Errors> | Errors;
3
4
  type Errors = {
4
5
  errors: Response<unknown>['errors'];
5
6
  };
6
- export { Action, Errors };
7
+ type Payload = {
8
+ alert: typeof alert;
9
+ input: Record<string, any>;
10
+ response: typeof response;
11
+ };
12
+ export { Action, Errors, Payload };
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- onclick: ({ active, toggle }: {
2
+ onclick: ({ active, toggle }?: {
3
3
  active?: boolean | undefined;
4
4
  toggle?: boolean | undefined;
5
5
  }) => {
@@ -27,9 +27,9 @@ declare const _default: {
27
27
  text: string;
28
28
  url?: string | undefined;
29
29
  }[] | undefined;
30
- state: {
31
- active: boolean;
32
- };
30
+ state?: {
31
+ active?: boolean | undefined;
32
+ } | undefined;
33
33
  style?: string | undefined;
34
34
  }) => () => "" | {
35
35
  content: string;
@@ -2,7 +2,7 @@ import { reactive } from '@esportsplus/reactivity';
2
2
  import { html } from '@esportsplus/template';
3
3
  import { root } from '../../components';
4
4
  import menu from './menu';
5
- const onclick = ({ active, toggle }) => {
5
+ const onclick = ({ active, toggle } = {}) => {
6
6
  let state = reactive({
7
7
  active: active || false
8
8
  });
@@ -13,8 +13,8 @@ type Data = {
13
13
  text: string;
14
14
  url?: string;
15
15
  }[];
16
- state: {
17
- active: boolean;
16
+ state?: {
17
+ active?: boolean;
18
18
  };
19
19
  style?: string;
20
20
  };
@@ -38,7 +38,7 @@ export default (data) => {
38
38
  render: false
39
39
  });
40
40
  effect(() => {
41
- if (!data.state.active || state.render) {
41
+ if (!data?.state?.active || state.render) {
42
42
  return;
43
43
  }
44
44
  state.render = true;
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.64"
25
+ "version": "0.0.66"
26
26
  }
@@ -39,6 +39,8 @@ export default function(action: Action) {
39
39
  new SubmitEvent('submit', { cancelable: true, bubbles:true, submitter: trigger })
40
40
  );
41
41
  },
42
+ // TODO: Figure out processing
43
+ // - Could pass reactive value above and tie it to form layout handler
42
44
  onsubmit: async function(this: HTMLFormElement, event: SubmitEvent) {
43
45
  event.preventDefault();
44
46
  event?.submitter?.classList.add('button--processing');
@@ -1,9 +1,16 @@
1
- import { Response } from '@esportsplus/action';
1
+ import { response, Response } from '@esportsplus/action';
2
+ import alert from '~/components/alert';
2
3
 
3
4
 
4
- type Action = <T>(data: T) => Promise<Errors> | Errors;
5
+ type Action = (data: Payload) => Promise<Errors> | Errors;
5
6
 
6
7
  type Errors = { errors: Response<unknown>['errors'] };
7
8
 
9
+ type Payload = {
10
+ alert: typeof alert;
11
+ input: Record<string, any>;
12
+ response: typeof response;
13
+ };
8
14
 
9
- export { Action, Errors };
15
+
16
+ export { Action, Errors, Payload };
@@ -4,7 +4,7 @@ import { root } from '~/components';
4
4
  import menu from './menu';
5
5
 
6
6
 
7
- const onclick = ({ active, toggle }: { active?: boolean, toggle?: boolean }) => {
7
+ const onclick = ({ active, toggle }: { active?: boolean, toggle?: boolean } = {}) => {
8
8
  let state = reactive({
9
9
  active: active || false
10
10
  });
@@ -17,7 +17,7 @@ type Data = {
17
17
  text: string;
18
18
  url?: string;
19
19
  }[];
20
- state: { active: boolean };
20
+ state?: { active?: boolean };
21
21
  style?: string;
22
22
  };
23
23
 
@@ -63,7 +63,7 @@ export default (data: Data) => {
63
63
  });
64
64
 
65
65
  effect(() => {
66
- if (!data.state.active || state.render) {
66
+ if (!data?.state?.active || state.render) {
67
67
  return;
68
68
  }
69
69