@signal24/vue-foundation 4.14.0 → 4.15.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.14.0",
4
+ "version": "4.15.0",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -1,23 +1,37 @@
1
1
  import AlertModal from './alert-modal.vue';
2
2
  import { createOverlayInjection, presentOverlay, removeOverlayInjection } from './overlay-container';
3
3
 
4
- function resolveAlertParams(titleOrMessage: string | Error, message?: string | Error) {
5
- const title = message ? (titleOrMessage as string) : undefined;
6
- const resolvedMessage = message ?? titleOrMessage;
7
- return { title, message: resolvedMessage };
4
+ interface IAlertOptions {
5
+ title?: string;
6
+ message: string | Error;
7
+ classes?: string[];
8
+ }
9
+
10
+ function resolveAlertParams(arg0: string | Error | IAlertOptions, arg1?: string | Error) {
11
+ if (typeof arg0 === 'object' && !(arg0 instanceof Error)) {
12
+ return {
13
+ ...arg0,
14
+ classes: arg0.classes ?? []
15
+ };
16
+ }
17
+ const title = arg1 ? (arg0 as string) : undefined;
18
+ return { title, message: arg1 ?? arg0, classes: [] };
8
19
  }
9
20
 
10
21
  export async function showAlert(title: string, message: string | Error): Promise<void>;
11
22
  export async function showAlert(message: string | Error): Promise<void>;
12
- export async function showAlert(titleOrMessage: string | Error, message?: string | Error): Promise<void> {
13
- await presentOverlay(AlertModal, resolveAlertParams(titleOrMessage, message));
23
+ export async function showAlert(options: IAlertOptions): Promise<void>;
24
+ export async function showAlert(arg0: string | Error | IAlertOptions, arg1?: string | Error): Promise<void> {
25
+ await presentOverlay(AlertModal, resolveAlertParams(arg0, arg1));
14
26
  }
15
27
 
16
28
  export async function showConfirm(title: string, message: string): Promise<boolean>;
17
29
  export async function showConfirm(message: string): Promise<boolean>;
18
- export async function showConfirm(titleOrMessage: string, message?: string): Promise<boolean> {
30
+ export async function showConfirm(options: IAlertOptions): Promise<boolean>;
31
+ export async function showConfirm(arg0: string | IAlertOptions, arg1?: string): Promise<boolean> {
32
+ const params = resolveAlertParams(arg0, arg1);
19
33
  const result = await presentOverlay(AlertModal, {
20
- ...resolveAlertParams(titleOrMessage, message),
34
+ ...params,
21
35
  shouldConfirm: true
22
36
  });
23
37
  return result === true;
@@ -25,22 +39,26 @@ export async function showConfirm(titleOrMessage: string, message?: string): Pro
25
39
 
26
40
  export async function showConfirmDestroy(title: string, message: string): Promise<boolean>;
27
41
  export async function showConfirmDestroy(message: string): Promise<boolean>;
28
- export async function showConfirmDestroy(titleOrMessage: string, message?: string): Promise<boolean> {
42
+ export async function showConfirmDestroy(options: IAlertOptions): Promise<boolean>;
43
+ export async function showConfirmDestroy(arg0: string | IAlertOptions, arg1?: string): Promise<boolean> {
44
+ const params = resolveAlertParams(arg0, arg1);
29
45
  const result = await presentOverlay(AlertModal, {
30
- ...resolveAlertParams(titleOrMessage, message),
46
+ ...params,
31
47
  shouldConfirm: true,
32
- classes: ['destructive']
48
+ classes: ['destructive', ...params.classes]
33
49
  });
34
50
  return result === true;
35
51
  }
36
52
 
37
53
  export function showWait(title: string, message: string): () => void;
38
54
  export function showWait(message: string): () => void;
39
- export function showWait(titleOrMessage: string, message?: string): () => void {
55
+ export function showWait(options: IAlertOptions): () => void;
56
+ export function showWait(arg0: string | IAlertOptions, arg1?: string): () => void {
57
+ const params = resolveAlertParams(arg0, arg1);
40
58
  const injection = createOverlayInjection(AlertModal, {
41
- ...resolveAlertParams(titleOrMessage, message),
59
+ ...params,
42
60
  isBare: true,
43
- classes: ['wait'],
61
+ classes: ['wait', ...params.classes],
44
62
  callback: () => {}
45
63
  });
46
64
  return () => removeOverlayInjection(injection);
@@ -63,9 +63,8 @@ export type Vue__ComponentPublicInstanceConstructor<
63
63
  new (...args: any[]): T;
64
64
  };
65
65
 
66
- export type ObjectComponentConfig<T extends Vue__ComponentPublicInstanceConstructor> = T extends Vue__ComponentPublicInstanceConstructor<infer P>
67
- ? P
68
- : never;
66
+ export type ObjectComponentConfig<T extends Vue__ComponentPublicInstanceConstructor> =
67
+ T extends Vue__ComponentPublicInstanceConstructor<infer P> ? P : never;
69
68
  export type ObjectComponentProps<T extends Vue__ComponentPublicInstanceConstructor> = Writable<
70
69
  Omit<ObjectComponentConfig<T>['$props'], keyof VNodeProps | keyof AllowedComponentProps>
71
70
  >;
@@ -21,14 +21,22 @@ export function toError(err: any) {
21
21
  return err instanceof Error ? err : new Error(String(err));
22
22
  }
23
23
 
24
- export async function handleErrorAndAlert(errIn: any, alertTitle?: string) {
24
+ interface IErrorAlertOptions {
25
+ title?: string;
26
+ classes?: string[];
27
+ }
28
+ export async function handleErrorAndAlert(errIn: any, options?: IErrorAlertOptions) {
25
29
  const err = toError(errIn);
26
30
 
27
31
  if (!(err instanceof UserError)) {
28
32
  VfOptions.errorHandler(err);
29
33
  }
30
34
 
31
- return alertTitle ? showAlert(alertTitle, err) : showAlert(err);
35
+ return showAlert({
36
+ title: options?.title,
37
+ message: err,
38
+ classes: options?.classes
39
+ });
32
40
  }
33
41
 
34
42
  export async function handleError(errIn: any) {