dry-ux 1.44.0 → 1.46.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.
@@ -3,7 +3,8 @@ export interface IErrorBoundaryProps {
3
3
  errorHandler?: (error?: Error, info?: React.ErrorInfo) => void;
4
4
  onErrorCallback?: (error?: Error) => void;
5
5
  rethrowError?: boolean;
6
- fallbackUI?: React.ReactNode | ((error: Error, resetError: () => void) => JSX.Element);
6
+ fallback?: (error: Error, resetError: () => void) => JSX.Element;
7
+ children: JSX.Element;
7
8
  }
8
9
  interface IErrorBoundaryInnerState {
9
10
  error: Error | null;
@@ -14,7 +15,7 @@ export declare class ErrorBoundary extends React.PureComponent<IErrorBoundaryPro
14
15
  error: Error;
15
16
  };
16
17
  componentDidCatch(error: Error, info: React.ErrorInfo): void;
17
- render: () => any;
18
+ render: () => JSX.Element & React.ReactNode;
18
19
  private handleError;
19
20
  private resetError;
20
21
  }
@@ -7,13 +7,10 @@ class ErrorBoundary extends React.PureComponent {
7
7
  constructor(props) {
8
8
  super(props);
9
9
  this.render = () => {
10
- const { children, fallbackUI = null } = this.props;
10
+ const { children, fallback = null } = this.props;
11
11
  const { error } = this.state;
12
12
  if (error) {
13
- if (typeof fallbackUI === "function") {
14
- return fallbackUI(error, this.resetError.bind(this));
15
- }
16
- return fallbackUI || React.createElement(ErrorScreen_1.ErrorScreen, null);
13
+ return fallback ? fallback(error, this.resetError.bind(this)) : React.createElement(ErrorScreen_1.ErrorScreen, null);
17
14
  }
18
15
  return children;
19
16
  };
@@ -1,3 +1,4 @@
1
+ import * as React from "react";
1
2
  /**
2
3
  * Returns a function that will call the given handler and prevent the default event behavior.
3
4
  * @param handler: The handler to call.
@@ -55,3 +56,4 @@ export declare class Deferred<T> {
55
56
  get reject(): (error: any) => void;
56
57
  }
57
58
  export declare const tryParseJson: <T = any>(json: string, errorValue?: {}) => {};
59
+ export declare const useIsVisible: (ref: React.MutableRefObject<any>) => boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryParseJson = exports.Deferred = exports.getUrlParams = exports.insertUrlParams = exports.insertUrlParam = exports.toHashCode = exports.StorageUtils = exports.fnWithAuthCheck = exports.formatDollar = exports.useCountdown = exports.importStyleSheet = exports.importScript = exports.preventDefault = void 0;
3
+ exports.useIsVisible = exports.tryParseJson = exports.Deferred = exports.getUrlParams = exports.insertUrlParams = exports.insertUrlParam = exports.toHashCode = exports.StorageUtils = exports.fnWithAuthCheck = exports.formatDollar = exports.useCountdown = exports.importStyleSheet = exports.importScript = exports.preventDefault = void 0;
4
4
  const React = require("react");
5
5
  /**
6
6
  * Returns a function that will call the given handler and prevent the default event behavior.
@@ -184,3 +184,15 @@ const tryParseJson = (json, errorValue = {}) => {
184
184
  }
185
185
  };
186
186
  exports.tryParseJson = tryParseJson;
187
+ const useIsVisible = (ref) => {
188
+ const [isIntersecting, setIntersecting] = React.useState(false);
189
+ React.useEffect(() => {
190
+ const observer = new IntersectionObserver(([entry]) => setIntersecting(entry.isIntersecting));
191
+ observer.observe(ref.current);
192
+ return () => {
193
+ observer.disconnect();
194
+ };
195
+ }, [ref]);
196
+ return isIntersecting;
197
+ };
198
+ exports.useIsVisible = useIsVisible;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.44.0",
3
+ "version": "1.46.0",
4
4
  "description": "",
5
5
  "main": "dist/index",
6
6
  "scripts": {