dry-ux 1.52.0 → 1.54.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/dist/dajaxice/Proxy.interface.d.ts +44 -0
- package/dist/enhanced-inputs/HTMLInputs.d.ts +15 -0
- package/dist/enhanced-inputs/HTMLInputs.js +56 -0
- package/dist/enhanced-inputs/Validaition.d.ts +142 -0
- package/dist/enhanced-inputs/Validaition.js +368 -0
- package/dist/enhanced-inputs/interface.d.ts +109 -0
- package/dist/enhanced-inputs/interface.js +2 -0
- package/dist/enhanced-inputs/styles.css +13 -0
- package/dist/enhanced-inputs/withEnhancements.d.ts +86 -0
- package/dist/enhanced-inputs/withEnhancements.js +74 -0
- package/dist/error/ErrorBoundary.d.ts +44 -0
- package/dist/error/ErrorBoundary.js +26 -0
- package/dist/error/ErrorScreen.d.ts +4 -0
- package/dist/error/ErrorScreen.js +4 -0
- package/dist/helpers/flat.d.ts +12 -0
- package/dist/helpers/logger.d.ts +16 -0
- package/dist/helpers/utilities.d.ts +55 -3
- package/dist/helpers/utilities.js +69 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -1
- package/dist/ui-utils/Loader.d.ts +20 -0
- package/dist/ui-utils/Loader.js +20 -0
- package/dist/ui-utils/Modal.d.ts +1 -0
- package/dist/ui-utils/Modal.js +14 -6
- package/dist/ui-utils/RenderWhenVisible.d.ts +7 -0
- package/dist/ui-utils/RenderWhenVisible.js +7 -0
- package/dist/ui-utils/Spinner.d.ts +5 -0
- package/dist/ui-utils/Spinner.js +5 -0
- package/dist/ui-utils/UIUtil.interface.d.ts +4 -0
- package/package.json +4 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from "react";
|
|
2
|
+
export type IValidation = boolean | string;
|
|
3
|
+
export interface IValueValidation<T> {
|
|
4
|
+
/**
|
|
5
|
+
* The value to be validated.
|
|
6
|
+
*/
|
|
7
|
+
value: T;
|
|
8
|
+
/**
|
|
9
|
+
* Optional message to be displayed if validation fails.
|
|
10
|
+
*/
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IValidations {
|
|
14
|
+
/**
|
|
15
|
+
* Indicates if the field is required.
|
|
16
|
+
*/
|
|
17
|
+
required?: IValidation;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates if the field should be validated as a number.
|
|
20
|
+
*/
|
|
21
|
+
number?: IValidation;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates if the field should be validated as a monetary value.
|
|
24
|
+
*/
|
|
25
|
+
money?: IValidation;
|
|
26
|
+
/**
|
|
27
|
+
* Indicates if the field should be validated as a positive number.
|
|
28
|
+
*/
|
|
29
|
+
positiveNumber?: IValidation;
|
|
30
|
+
/**
|
|
31
|
+
* Indicates if the field should be validated as an email.
|
|
32
|
+
*/
|
|
33
|
+
email?: IValidation;
|
|
34
|
+
/**
|
|
35
|
+
* Indicates if the field should be validated as digits.
|
|
36
|
+
*/
|
|
37
|
+
digits?: IValidation;
|
|
38
|
+
/**
|
|
39
|
+
* Indicates if the field should be validated as a date.
|
|
40
|
+
*/
|
|
41
|
+
date?: IValidation;
|
|
42
|
+
/**
|
|
43
|
+
* Compares the field with another field specified by its ID.
|
|
44
|
+
*/
|
|
45
|
+
compare?: IValueValidation<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Minimum length validation for the field.
|
|
48
|
+
*/
|
|
49
|
+
minLength?: IValueValidation<number>;
|
|
50
|
+
/**
|
|
51
|
+
* Minimum digits length validation for the field.
|
|
52
|
+
*/
|
|
53
|
+
minDigitsLength?: IValueValidation<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Maximum length validation for the field.
|
|
56
|
+
*/
|
|
57
|
+
maxLength?: IValueValidation<number>;
|
|
58
|
+
/**
|
|
59
|
+
* Maximum value validation for the field.
|
|
60
|
+
*/
|
|
61
|
+
maxValue?: IValueValidation<number>;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum date validation for the field.
|
|
64
|
+
*/
|
|
65
|
+
maxDate?: IValueValidation<Date>;
|
|
66
|
+
/**
|
|
67
|
+
* Minimum date validation for the field.
|
|
68
|
+
*/
|
|
69
|
+
minDate?: IValueValidation<Date>;
|
|
70
|
+
/**
|
|
71
|
+
* Disallowed days of the week for the field.
|
|
72
|
+
*/
|
|
73
|
+
disallowedDaysOfWeek?: number[];
|
|
74
|
+
/**
|
|
75
|
+
* Indicates if the field should be validated even if it is hidden.
|
|
76
|
+
*/
|
|
77
|
+
validateHidden?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* JQuery selector of the element to add the error after.
|
|
80
|
+
*/
|
|
81
|
+
errorRef?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface IEnhancedProps {
|
|
84
|
+
/**
|
|
85
|
+
* Validation rules for the field.
|
|
86
|
+
*/
|
|
87
|
+
validations?: IValidations;
|
|
88
|
+
/**
|
|
89
|
+
* Indicates if the field should have form control styling.
|
|
90
|
+
*/
|
|
91
|
+
formControl?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Maximum length for the field.
|
|
94
|
+
*/
|
|
95
|
+
eMaxLength?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Indicates if the field should select its content on focus.
|
|
98
|
+
*/
|
|
99
|
+
selectOnFocus?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Indicates if the field should not have error background styling.
|
|
102
|
+
*/
|
|
103
|
+
noErrorBackground?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Indicates if the field should validate on change (Default: true).
|
|
106
|
+
*/
|
|
107
|
+
validateOnChange?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export type InputAttributes = InputHTMLAttributes<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.error-background:not(.MuiFormControl-root),
|
|
2
|
+
.error-background.MuiFormControl-root .MuiInputBase-root
|
|
3
|
+
{
|
|
4
|
+
background-color: #F8DBDD !important;
|
|
5
|
+
border: 1px solid #E17984 !important;
|
|
6
|
+
}
|
|
7
|
+
div.error-message
|
|
8
|
+
{
|
|
9
|
+
font-size:7pt;
|
|
10
|
+
color:Red;
|
|
11
|
+
display:block;
|
|
12
|
+
line-height: 1.5;
|
|
13
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IEnhancedProps, InputAttributes, IValidations } from "./interface";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts enhanced properties from the passed props.
|
|
5
|
+
* @param passedProps The props passed to the component.
|
|
6
|
+
* @returns An object containing the extracted enhanced properties and the remaining props.
|
|
7
|
+
*/
|
|
8
|
+
export declare const extractEnhancedProps: <P>(passedProps: P & IEnhancedProps) => {
|
|
9
|
+
validations: IValidations;
|
|
10
|
+
formControl: boolean;
|
|
11
|
+
eMaxLength: number;
|
|
12
|
+
selectOnFocus: boolean;
|
|
13
|
+
noErrorBackground: boolean;
|
|
14
|
+
validateOnChange: boolean;
|
|
15
|
+
props: Omit<P & IEnhancedProps, "validations" | "formControl" | "eMaxLength" | "selectOnFocus" | "noErrorBackground" | "validateOnChange">;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Gets the enhanced attributes for an input element.
|
|
19
|
+
* @param className The class name of the input element.
|
|
20
|
+
* @param validations The validations to apply to the input element.
|
|
21
|
+
* @param formControl Whether the input element is a form control.
|
|
22
|
+
* @param noErrorBackground Whether to disable the error background.
|
|
23
|
+
* @returns An object containing the class name and attributes for the input element.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getEnhancedAttributes: (className: string, validations: IValidations, formControl: boolean, noErrorBackground: boolean) => {
|
|
26
|
+
className: string;
|
|
27
|
+
attributes: {};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Higher-order component that adds enhancements to an input component.
|
|
31
|
+
* @param Component The input component to enhance.
|
|
32
|
+
* @returns The enhanced input component.
|
|
33
|
+
*/
|
|
34
|
+
export declare const withEnhancements: <P extends InputAttributes>(Component: React.ComponentType<P>) => {
|
|
35
|
+
new (props: (P & IEnhancedProps) | Readonly<P & IEnhancedProps>): {
|
|
36
|
+
render(): React.JSX.Element;
|
|
37
|
+
context: any;
|
|
38
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<P & IEnhancedProps>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
|
39
|
+
forceUpdate(callback?: () => void): void;
|
|
40
|
+
readonly props: Readonly<P & IEnhancedProps> & Readonly<{
|
|
41
|
+
children?: React.ReactNode | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
state: Readonly<{}>;
|
|
44
|
+
refs: {
|
|
45
|
+
[key: string]: React.ReactInstance;
|
|
46
|
+
};
|
|
47
|
+
componentDidMount?(): void;
|
|
48
|
+
shouldComponentUpdate?(nextProps: Readonly<P & IEnhancedProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
49
|
+
componentWillUnmount?(): void;
|
|
50
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
51
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<P & IEnhancedProps>, prevState: Readonly<{}>): any;
|
|
52
|
+
componentDidUpdate?(prevProps: Readonly<P & IEnhancedProps>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
53
|
+
componentWillMount?(): void;
|
|
54
|
+
UNSAFE_componentWillMount?(): void;
|
|
55
|
+
componentWillReceiveProps?(nextProps: Readonly<P & IEnhancedProps>, nextContext: any): void;
|
|
56
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P & IEnhancedProps>, nextContext: any): void;
|
|
57
|
+
componentWillUpdate?(nextProps: Readonly<P & IEnhancedProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
58
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<P & IEnhancedProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
59
|
+
};
|
|
60
|
+
new (props: P & IEnhancedProps, context: any): {
|
|
61
|
+
render(): React.JSX.Element;
|
|
62
|
+
context: any;
|
|
63
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<P & IEnhancedProps>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
|
64
|
+
forceUpdate(callback?: () => void): void;
|
|
65
|
+
readonly props: Readonly<P & IEnhancedProps> & Readonly<{
|
|
66
|
+
children?: React.ReactNode | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
state: Readonly<{}>;
|
|
69
|
+
refs: {
|
|
70
|
+
[key: string]: React.ReactInstance;
|
|
71
|
+
};
|
|
72
|
+
componentDidMount?(): void;
|
|
73
|
+
shouldComponentUpdate?(nextProps: Readonly<P & IEnhancedProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
74
|
+
componentWillUnmount?(): void;
|
|
75
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
76
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<P & IEnhancedProps>, prevState: Readonly<{}>): any;
|
|
77
|
+
componentDidUpdate?(prevProps: Readonly<P & IEnhancedProps>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
78
|
+
componentWillMount?(): void;
|
|
79
|
+
UNSAFE_componentWillMount?(): void;
|
|
80
|
+
componentWillReceiveProps?(nextProps: Readonly<P & IEnhancedProps>, nextContext: any): void;
|
|
81
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P & IEnhancedProps>, nextContext: any): void;
|
|
82
|
+
componentWillUpdate?(nextProps: Readonly<P & IEnhancedProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
83
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<P & IEnhancedProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
84
|
+
};
|
|
85
|
+
contextType?: React.Context<any> | undefined;
|
|
86
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withEnhancements = exports.getEnhancedAttributes = exports.extractEnhancedProps = void 0;
|
|
15
|
+
const React = require("react");
|
|
16
|
+
/**
|
|
17
|
+
* Extracts enhanced properties from the passed props.
|
|
18
|
+
* @param passedProps The props passed to the component.
|
|
19
|
+
* @returns An object containing the extracted enhanced properties and the remaining props.
|
|
20
|
+
*/
|
|
21
|
+
const extractEnhancedProps = (passedProps) => {
|
|
22
|
+
const { validations, formControl, eMaxLength, selectOnFocus, noErrorBackground, validateOnChange } = passedProps, props = __rest(passedProps, ["validations", "formControl", "eMaxLength", "selectOnFocus", "noErrorBackground", "validateOnChange"]);
|
|
23
|
+
return { validations, formControl, eMaxLength, selectOnFocus, noErrorBackground, validateOnChange, props };
|
|
24
|
+
};
|
|
25
|
+
exports.extractEnhancedProps = extractEnhancedProps;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the enhanced attributes for an input element.
|
|
28
|
+
* @param className The class name of the input element.
|
|
29
|
+
* @param validations The validations to apply to the input element.
|
|
30
|
+
* @param formControl Whether the input element is a form control.
|
|
31
|
+
* @param noErrorBackground Whether to disable the error background.
|
|
32
|
+
* @returns An object containing the class name and attributes for the input element.
|
|
33
|
+
*/
|
|
34
|
+
const getEnhancedAttributes = (className, validations, formControl, noErrorBackground) => {
|
|
35
|
+
className = className || "";
|
|
36
|
+
className += (!className.length ? "" : " ") + "enhanced-input";
|
|
37
|
+
let attributes = {};
|
|
38
|
+
if (validations) {
|
|
39
|
+
const addValidation = (validation, name) => {
|
|
40
|
+
!!validation && (className += " validate-" + name);
|
|
41
|
+
return !!validation && typeof validation == "string" && { [`data-${name}-message`]: validation };
|
|
42
|
+
};
|
|
43
|
+
const addValueValidation = (validation, name) => {
|
|
44
|
+
!!validation && (className += " validate-" + name);
|
|
45
|
+
return (!!validation && Object.assign(Object.assign({}, (validation.message !== undefined && { [`data-${name}-message`]: validation.message })), { [`data-${name}`]: validation.value }));
|
|
46
|
+
};
|
|
47
|
+
const addGenericValidation = (validation, name) => {
|
|
48
|
+
!!validation && (className += " validate-" + name);
|
|
49
|
+
return !!validation && { [`data-${name}`]: validation };
|
|
50
|
+
};
|
|
51
|
+
attributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, addValidation(validations.required, "required")), addValidation(validations.number, "number")), addValidation(validations.positiveNumber, "positive-number")), addValidation(validations.email, "email")), addValidation(validations.digits, "digits")), addValidation(validations.date, "date")), addValidation(validations.money, "money")), addValidation(validations.validateHidden, "hidden")), (validations.errorRef && { [`data-validation-error-ref`]: validations.errorRef })), addValueValidation(validations.compare, "compare")), addValueValidation(validations.minLength, "min-length")), addValueValidation(validations.minDigitsLength, "min-digits-length")), addValueValidation(validations.maxLength, "max-length")), addValueValidation(validations.maxValue, "max-value")), addValueValidation(validations.maxDate, "max-date")), addValueValidation(validations.minDate, "min-date")), addGenericValidation(validations.disallowedDaysOfWeek, "disallowed-days-of-week"));
|
|
52
|
+
}
|
|
53
|
+
className.match("validate-") && (className += " validate");
|
|
54
|
+
formControl && (className += " form-control");
|
|
55
|
+
noErrorBackground && (className += " validation-no-error-background");
|
|
56
|
+
return {
|
|
57
|
+
className,
|
|
58
|
+
attributes,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.getEnhancedAttributes = getEnhancedAttributes;
|
|
62
|
+
/**
|
|
63
|
+
* Higher-order component that adds enhancements to an input component.
|
|
64
|
+
* @param Component The input component to enhance.
|
|
65
|
+
* @returns The enhanced input component.
|
|
66
|
+
*/
|
|
67
|
+
const withEnhancements = (Component) => class EnhancedInput extends React.Component {
|
|
68
|
+
render() {
|
|
69
|
+
const { validations, formControl, noErrorBackground, validateOnChange, props } = (0, exports.extractEnhancedProps)(this.props);
|
|
70
|
+
const { className, attributes } = (0, exports.getEnhancedAttributes)(props.className, validations, formControl, noErrorBackground);
|
|
71
|
+
return React.createElement(Component, Object.assign({}, props, attributes, { className: className }));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.withEnhancements = withEnhancements;
|
|
@@ -1,22 +1,66 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props for the ErrorBoundary component.
|
|
4
|
+
*/
|
|
2
5
|
export interface IErrorBoundaryProps {
|
|
6
|
+
/**
|
|
7
|
+
* An optional function to handle the error.
|
|
8
|
+
*/
|
|
3
9
|
errorHandler?: (error?: Error, info?: React.ErrorInfo) => void;
|
|
10
|
+
/**
|
|
11
|
+
* An optional callback function to call when an error is caught.
|
|
12
|
+
*/
|
|
4
13
|
onErrorCallback?: (error?: Error) => void;
|
|
14
|
+
/**
|
|
15
|
+
* If true, rethrows the error after handling it. Defaults to false.
|
|
16
|
+
*/
|
|
5
17
|
rethrowError?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* An optional function to render a fallback UI when an error is caught.
|
|
20
|
+
*/
|
|
6
21
|
fallback?: (error: Error, resetError: () => void) => JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* The child components to render.
|
|
24
|
+
*/
|
|
7
25
|
children: JSX.Element;
|
|
8
26
|
}
|
|
9
27
|
interface IErrorBoundaryInnerState {
|
|
10
28
|
error: Error | null;
|
|
11
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A React component that acts as an error boundary to catch JavaScript errors anywhere in its child component tree.
|
|
32
|
+
* It displays a fallback UI when an error is caught.
|
|
33
|
+
*/
|
|
12
34
|
export declare class ErrorBoundary extends React.PureComponent<IErrorBoundaryProps, IErrorBoundaryInnerState> {
|
|
13
35
|
constructor(props: IErrorBoundaryProps);
|
|
36
|
+
/**
|
|
37
|
+
* Updates the state with the error.
|
|
38
|
+
* @param error The error that was thrown.
|
|
39
|
+
* @returns The updated state.
|
|
40
|
+
*/
|
|
14
41
|
static getDerivedStateFromError(error: Error): {
|
|
15
42
|
error: Error;
|
|
16
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Handles the error and updates the state.
|
|
46
|
+
* @param error The error that was thrown.
|
|
47
|
+
* @param info Additional information about the error.
|
|
48
|
+
*/
|
|
17
49
|
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
50
|
+
/**
|
|
51
|
+
* Renders the component.
|
|
52
|
+
* @returns The rendered component.
|
|
53
|
+
*/
|
|
18
54
|
render: () => React.JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Handles the error based on the provided props.
|
|
57
|
+
* @param error The error that was thrown.
|
|
58
|
+
* @param info Additional information about the error.
|
|
59
|
+
*/
|
|
19
60
|
private handleError;
|
|
61
|
+
/**
|
|
62
|
+
* Resets the error state.
|
|
63
|
+
*/
|
|
20
64
|
private resetError;
|
|
21
65
|
}
|
|
22
66
|
export {};
|
|
@@ -3,9 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ErrorBoundary = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const ErrorScreen_1 = require("./ErrorScreen");
|
|
6
|
+
/**
|
|
7
|
+
* A React component that acts as an error boundary to catch JavaScript errors anywhere in its child component tree.
|
|
8
|
+
* It displays a fallback UI when an error is caught.
|
|
9
|
+
*/
|
|
6
10
|
class ErrorBoundary extends React.PureComponent {
|
|
7
11
|
constructor(props) {
|
|
8
12
|
super(props);
|
|
13
|
+
/**
|
|
14
|
+
* Renders the component.
|
|
15
|
+
* @returns The rendered component.
|
|
16
|
+
*/
|
|
9
17
|
this.render = () => {
|
|
10
18
|
const { children, fallback = null } = this.props;
|
|
11
19
|
const { error } = this.state;
|
|
@@ -14,6 +22,11 @@ class ErrorBoundary extends React.PureComponent {
|
|
|
14
22
|
}
|
|
15
23
|
return children;
|
|
16
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Handles the error based on the provided props.
|
|
27
|
+
* @param error The error that was thrown.
|
|
28
|
+
* @param info Additional information about the error.
|
|
29
|
+
*/
|
|
17
30
|
this.handleError = (error, info) => {
|
|
18
31
|
const { errorHandler, onErrorCallback, rethrowError } = this.props;
|
|
19
32
|
if (onErrorCallback) {
|
|
@@ -32,12 +45,25 @@ class ErrorBoundary extends React.PureComponent {
|
|
|
32
45
|
};
|
|
33
46
|
this.state = { error: null };
|
|
34
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Updates the state with the error.
|
|
50
|
+
* @param error The error that was thrown.
|
|
51
|
+
* @returns The updated state.
|
|
52
|
+
*/
|
|
35
53
|
static getDerivedStateFromError(error) {
|
|
36
54
|
return { error };
|
|
37
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Handles the error and updates the state.
|
|
58
|
+
* @param error The error that was thrown.
|
|
59
|
+
* @param info Additional information about the error.
|
|
60
|
+
*/
|
|
38
61
|
componentDidCatch(error, info) {
|
|
39
62
|
this.handleError(error, info);
|
|
40
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Resets the error state.
|
|
66
|
+
*/
|
|
41
67
|
resetError() {
|
|
42
68
|
this.setState({ error: null });
|
|
43
69
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A React component that displays an error screen with a message and a button to go back to the home page.
|
|
4
|
+
* @returns A JSX element representing the error screen.
|
|
5
|
+
*/
|
|
2
6
|
export declare const ErrorScreen: React.MemoExoticComponent<() => React.JSX.Element>;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErrorScreen = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* A React component that displays an error screen with a message and a button to go back to the home page.
|
|
7
|
+
* @returns A JSX element representing the error screen.
|
|
8
|
+
*/
|
|
5
9
|
exports.ErrorScreen = React.memo(() => (React.createElement("div", { className: "text-center", style: { marginTop: 70 } },
|
|
6
10
|
React.createElement("h1", { style: { fontSize: 70 } },
|
|
7
11
|
React.createElement("i", { className: "fa fa-exclamation-triangle" })),
|
package/dist/helpers/flat.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
type FlattenOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* The delimiter to use for separating keys. Defaults to ".".
|
|
4
|
+
*/
|
|
2
5
|
delimiter?: string;
|
|
6
|
+
/**
|
|
7
|
+
* The maximum depth to flatten the object to.
|
|
8
|
+
*/
|
|
3
9
|
maxDepth?: number;
|
|
10
|
+
/**
|
|
11
|
+
* A function to transform the keys.
|
|
12
|
+
*/
|
|
4
13
|
transformKey?: (key: any) => any;
|
|
14
|
+
/**
|
|
15
|
+
* If true, ensures arrays are not flattened.
|
|
16
|
+
*/
|
|
5
17
|
safe?: boolean;
|
|
6
18
|
};
|
|
7
19
|
/**
|
package/dist/helpers/logger.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
export interface ILogger {
|
|
2
|
+
/**
|
|
3
|
+
* Logs a message with the info level.
|
|
4
|
+
* @param {...any[]} message - The message to log.
|
|
5
|
+
*/
|
|
2
6
|
log(...message: any[]): void;
|
|
7
|
+
/**
|
|
8
|
+
* Logs a message with the error level.
|
|
9
|
+
* @param {...any[]} message - The message to log.
|
|
10
|
+
*/
|
|
3
11
|
error(...message: any[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Logs a message with the debug level.
|
|
14
|
+
* @param {...any[]} message - The message to log.
|
|
15
|
+
*/
|
|
4
16
|
debug(...message: any[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Logs a message with the warn level.
|
|
19
|
+
* @param {...any[]} message - The message to log.
|
|
20
|
+
*/
|
|
5
21
|
warn(...message: any[]): void;
|
|
6
22
|
}
|
|
7
23
|
export declare const initLoggerFactory: (path: string) => {
|
|
@@ -38,25 +38,77 @@ export declare const formatDollar: (amount: number, decimal_places?: boolean) =>
|
|
|
38
38
|
* @param authRedirectUrl The URL to redirect to if the user is not authenticated.
|
|
39
39
|
*/
|
|
40
40
|
export declare const fnWithAuthCheck: (fn: Function, authCheckUrl: string, authRedirectUrl: string) => Promise<void>;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Utility class for storage-related operations.
|
|
43
|
+
*/
|
|
44
|
+
export declare class StorageUtils {
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the storage is available.
|
|
47
|
+
* @returns A boolean indicating if the storage is available.
|
|
48
|
+
*/
|
|
49
|
+
static isStorageAvailable(): boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts a string to a hash code.
|
|
53
|
+
* @param input The string to convert.
|
|
54
|
+
* @returns The hash code of the input string.
|
|
55
|
+
*/
|
|
44
56
|
export declare const toHashCode: (input: string) => number;
|
|
57
|
+
/**
|
|
58
|
+
* Inserts a URL parameter.
|
|
59
|
+
* @param key The key of the parameter.
|
|
60
|
+
* @param value The value of the parameter.
|
|
61
|
+
*/
|
|
45
62
|
export declare const insertUrlParam: (key: string, value: any) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Inserts multiple URL parameters.
|
|
65
|
+
* @param params An object containing key-value pairs of parameters.
|
|
66
|
+
*/
|
|
46
67
|
export declare const insertUrlParams: (params: {
|
|
47
68
|
[key: string]: any;
|
|
48
69
|
}) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves URL parameters as an object.
|
|
72
|
+
* @returns An object containing the URL parameters.
|
|
73
|
+
*/
|
|
49
74
|
export declare const getUrlParams: <T>() => T;
|
|
75
|
+
/**
|
|
76
|
+
* A class representing a deferred promise.
|
|
77
|
+
*/
|
|
50
78
|
export declare class Deferred<T> {
|
|
51
79
|
private _resolve;
|
|
52
80
|
private _reject;
|
|
81
|
+
/**
|
|
82
|
+
* The promise object.
|
|
83
|
+
*/
|
|
53
84
|
readonly promise: Promise<T>;
|
|
54
85
|
constructor();
|
|
86
|
+
/**
|
|
87
|
+
* Resolves the promise with the given result.
|
|
88
|
+
*/
|
|
55
89
|
get resolve(): (result: T) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Rejects the promise with the given error.
|
|
92
|
+
*/
|
|
56
93
|
get reject(): (error: any) => void;
|
|
57
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Parses a JSON string and returns the corresponding object.
|
|
97
|
+
* @param json The JSON string to parse.
|
|
98
|
+
* @param errorValue The value to return if parsing fails.
|
|
99
|
+
* @returns The parsed object or the error value.
|
|
100
|
+
*/
|
|
58
101
|
export declare const tryParseJson: <T = any>(json: string, errorValue?: {}) => {};
|
|
102
|
+
/**
|
|
103
|
+
* Hook to check if an element is visible in the viewport.
|
|
104
|
+
* @param ref The reference to the element.
|
|
105
|
+
* @returns A boolean indicating if the element is visible.
|
|
106
|
+
*/
|
|
59
107
|
export declare const useIsVisible: (ref: React.MutableRefObject<any>) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Hook to publish and subscribe to custom events.
|
|
110
|
+
* @returns An object containing the usePub and useSub hooks.
|
|
111
|
+
*/
|
|
60
112
|
export declare const usePubSub: <T>() => {
|
|
61
113
|
usePub: () => <TName extends keyof T, TPayload extends T[TName]>(event: TName, data?: TPayload) => void;
|
|
62
114
|
useSub: <TName extends keyof T, TPayload_1 extends T[TName]>(event: TName, callback: (data: TPayload_1) => void) => () => void;
|