@signal24/vue-foundation 4.30.0 → 4.30.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.30.0",
4
+ "version": "4.30.2",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -5,8 +5,10 @@ const ObserverMap = new WeakMap<HTMLElement, ResizeObserver>();
5
5
  export const vStickyMinWidth: ObjectDirective<HTMLElement> = {
6
6
  beforeMount(el) {
7
7
  const observer = new ResizeObserver(() => {
8
- const minWidth = el.clientWidth;
9
- el.style.minWidth = `${minWidth}px`;
8
+ const computedMinWidthStr = window.getComputedStyle(el).minWidth.match(/^(\d+)px$/)?.[1];
9
+ const computedMinWidth = computedMinWidthStr ? parseInt(computedMinWidthStr, 10) : 0;
10
+ if (el.clientWidth <= computedMinWidth) return;
11
+ el.style.minWidth = `${el.clientWidth}px`;
10
12
  });
11
13
  ObserverMap.set(el, observer);
12
14
  observer.observe(el);
@@ -8,6 +8,10 @@ export class UserError extends Error {
8
8
  }
9
9
  }
10
10
 
11
+ interface ErrorWithCause extends Error {
12
+ cause?: Error;
13
+ }
14
+
11
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
16
  export function formatError(err: any): string {
13
17
  if (err instanceof UserError) {
@@ -19,9 +23,12 @@ export function formatError(err: any): string {
19
23
  }
20
24
 
21
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- export function toError(err: any) {
23
- if (isError(err)) return err;
24
- return new Error(String(err));
26
+ export function toError(err: any, cause?: any): ErrorWithCause {
27
+ const error = (isError(err) ? err : new Error(String(err))) as ErrorWithCause;
28
+ if (cause) {
29
+ error.cause = toError(cause);
30
+ }
31
+ return error;
25
32
  }
26
33
 
27
34
  export function isError(err: unknown): err is Error {
@@ -31,12 +38,14 @@ export function isError(err: unknown): err is Error {
31
38
  }
32
39
 
33
40
  interface IErrorAlertOptions {
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ cause?: any;
34
43
  title?: string;
35
44
  classes?: string[];
36
45
  }
37
46
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
47
  export async function handleErrorAndAlert(errIn: any, options?: IErrorAlertOptions) {
39
- const err = toError(errIn);
48
+ const err = toError(errIn, options?.cause);
40
49
 
41
50
  if (!(err instanceof UserError)) {
42
51
  VfOptions.errorHandler(err);
@@ -50,8 +59,8 @@ export async function handleErrorAndAlert(errIn: any, options?: IErrorAlertOptio
50
59
  }
51
60
 
52
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
- export async function handleError(errIn: any) {
54
- const err = toError(errIn);
62
+ export async function handleError(errIn: any, cause?: any) {
63
+ const err = toError(errIn, cause);
55
64
 
56
65
  if (!(err instanceof UserError)) {
57
66
  VfOptions.errorHandler(err);