dry-ux 1.51.0 → 1.52.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.
@@ -48,8 +48,8 @@ export declare const insertUrlParams: (params: {
48
48
  }) => void;
49
49
  export declare const getUrlParams: <T>() => T;
50
50
  export declare class Deferred<T> {
51
- _resolve: (result: T) => void;
52
- _reject: (error: any) => void;
51
+ private _resolve;
52
+ private _reject;
53
53
  readonly promise: Promise<T>;
54
54
  constructor();
55
55
  get resolve(): (result: T) => void;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { useUIUtilContext as useDryUxContext, UIUtilContext as DryUXContext } from "./ui-utils/UIUtilProvider";
2
2
  export { UIUtilRenderer as DryUXRenderer } from "./ui-utils/UIUtilRenderer";
3
3
  export { Money as Money } from "./ui-utils/Money";
4
- export * from "./ui-utils/uiUtil.interface";
4
+ export * from "./ui-utils/UIUtil.interface";
5
5
  export { DryUXProvider } from "./provider";
6
6
  export * from "./helpers/utilities";
7
7
  export * from "./helpers/logger";
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ var UIUtilRenderer_1 = require("./ui-utils/UIUtilRenderer");
22
22
  Object.defineProperty(exports, "DryUXRenderer", { enumerable: true, get: function () { return UIUtilRenderer_1.UIUtilRenderer; } });
23
23
  var Money_1 = require("./ui-utils/Money");
24
24
  Object.defineProperty(exports, "Money", { enumerable: true, get: function () { return Money_1.Money; } });
25
- __exportStar(require("./ui-utils/uiUtil.interface"), exports);
25
+ __exportStar(require("./ui-utils/UIUtil.interface"), exports);
26
26
  var provider_1 = require("./provider");
27
27
  Object.defineProperty(exports, "DryUXProvider", { enumerable: true, get: function () { return provider_1.DryUXProvider; } });
28
28
  __exportStar(require("./helpers/utilities"), exports);
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- import { ModalOptions } from "./uiUtil.interface";
2
+ import { PopUpOptions } from "./UIUtil.interface";
3
3
  export interface IModalProps {
4
- options: ModalOptions;
4
+ options: PopUpOptions;
5
5
  handleClose: () => void;
6
6
  shown: boolean;
7
7
  config: {
@@ -1,4 +1,6 @@
1
1
  import * as React from "react";
2
2
  export declare const RenderWhenVisible: React.FC<{
3
- content: string | JSX.Element;
3
+ children: JSX.Element;
4
+ onLoad?: () => void;
5
+ minHeight?: number;
4
6
  }>;
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RenderWhenVisible = void 0;
4
4
  const React = require("react");
5
5
  const utilities_1 = require("../helpers/utilities");
6
- exports.RenderWhenVisible = React.memo(({ content }) => {
6
+ exports.RenderWhenVisible = React.memo(({ children, minHeight, onLoad }) => {
7
7
  const [isLoaded, setIsLoaded] = React.useState(false);
8
8
  const ref = React.useRef(null);
9
9
  const isVisible = (0, utilities_1.useIsVisible)(ref);
10
10
  React.useEffect(() => {
11
11
  if (!isLoaded && isVisible) {
12
12
  setIsLoaded(true);
13
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad();
13
14
  }
14
15
  }, [isVisible]);
15
- return React.createElement("div", { ref: ref }, isLoaded && content);
16
+ return (React.createElement("div", { style: { minHeight }, ref: ref }, isLoaded && children));
16
17
  });
@@ -1,4 +1,4 @@
1
- export interface IModalCreate {
1
+ export type PopUp = {
2
2
  /**
3
3
  * Hides the modal.
4
4
  */
@@ -11,8 +11,8 @@ export interface IModalCreate {
11
11
  * Removes the modal.
12
12
  */
13
13
  remove: () => void;
14
- }
15
- export type ModalOptions = {
14
+ };
15
+ export type PopUpOptions = {
16
16
  /**
17
17
  * The content of the modal.
18
18
  */
@@ -50,9 +50,8 @@ export type ModalOptions = {
50
50
  */
51
51
  destroyOnClose?: boolean;
52
52
  };
53
- export type AlertType = "success" | "warning" | "error";
54
53
  export type ButtonType = "primary" | "info" | "success" | "warning" | "danger";
55
- export interface IUtilModalAction {
54
+ export type PopUpAction = {
56
55
  /**
57
56
  * The content to display in the modal.
58
57
  */
@@ -69,25 +68,25 @@ export interface IUtilModalAction {
69
68
  * If true, the modal will be closed when the button is clicked.
70
69
  */
71
70
  closeOnClick?: boolean;
72
- }
73
- export interface IUIUtilModal {
71
+ };
72
+ export type UIUtilModal = {
74
73
  /**
75
74
  * Creates a non-unique modal.
76
75
  * @param options The options for the modal.
77
76
  */
78
- show: (options: ModalOptions) => IModalCreate;
77
+ show: (options: PopUpOptions) => PopUp;
79
78
  /**
80
79
  * Creates a unique (by id) modal
81
80
  * @param id The id of the modal.
82
81
  * @param options The options for the modal.
83
82
  */
84
- create: (id: string, options: ModalOptions) => IModalCreate;
83
+ create: (id: string, options: PopUpOptions) => PopUp;
85
84
  /**
86
85
  * Dictionary of modal instances in memory.
87
86
  */
88
87
  instances: {
89
88
  [id: string]: {
90
- options: ModalOptions;
89
+ options: PopUpOptions;
91
90
  shown: boolean;
92
91
  handleClose: (id: string, shown: boolean, destroyOnClose: boolean) => void;
93
92
  };
@@ -95,26 +94,26 @@ export interface IUIUtilModal {
95
94
  /**
96
95
  * Gets the current modal instance.
97
96
  */
98
- getCurrent: () => IModalCreate;
97
+ getCurrent: () => PopUp;
99
98
  /**
100
99
  * Shows an alert style modal.
101
100
  * @param content The content to display in the modal.
102
101
  */
103
- showAlert: (content: ModalOptions["content"], onClose?: ModalOptions["onClose"]) => IModalCreate;
102
+ showAlert: (content: PopUpOptions["content"], onClose?: PopUpOptions["onClose"]) => PopUp;
104
103
  /**
105
104
  * Shows a confirm style modal.
106
105
  * @param options The options for the modal.
107
106
  * @param onYes The function to call when the yes button is clicked.
108
107
  * @param onNo The function to call when the no button is clicked.
109
108
  */
110
- showConfirm: (options: ModalOptions, onYes: () => void, onNo?: () => void) => IModalCreate;
109
+ showConfirm: (options: PopUpOptions, onYes: () => void, onNo?: () => void) => PopUp;
111
110
  /**
112
111
  * Shows a modal with custom actions.
113
112
  * @param options The options for the modal.
114
113
  * @param actions The actions to display in the modal.
115
114
  */
116
- showActions: (options: ModalOptions, actions: IUtilModalAction[]) => IModalCreate;
117
- }
115
+ showActions: (options: PopUpOptions, actions: PopUpAction[]) => PopUp;
116
+ };
118
117
  export interface IUIUtilLoader {
119
118
  /**
120
119
  * Status of the loader.
@@ -129,19 +128,4 @@ export interface IUIUtilLoader {
129
128
  */
130
129
  hide: () => void;
131
130
  }
132
- export interface IUIUtilAlert {
133
- /**
134
- * Shows an alert.
135
- * @param message The message to display in the alert.
136
- * @param alertType The type of alert to display.
137
- * @param position The position of the alert.
138
- * @param bindToElement The element to bind the alert to.
139
- */
140
- show: (message: string, alertType?: AlertType, position?: string, bindToElement?: any) => void;
141
- /**
142
- * Shows an alert using Noty library.
143
- * @param message The message to display in the alert.
144
- * @param alertType The type of alert to display.
145
- */
146
- showNoty: (message: string, alertType: AlertType) => void;
147
- }
131
+ export type UIUtilPrompt = Pick<UIUtilModal, "showConfirm" | "showActions" | "instances" | "getCurrent">;
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
- import { AlertType, IModalCreate, IUIUtilAlert, IUIUtilLoader, IUIUtilModal, IUtilModalAction, ModalOptions } from "./uiUtil.interface";
2
+ import { IUIUtilLoader, UIUtilModal, PopUp, PopUpAction, PopUpOptions, UIUtilPrompt } from "./UIUtil.interface";
3
3
  import "../types";
4
4
  export interface IUIUtilProviderState {
5
- modal: IUIUtilModal;
6
- alert: IUIUtilAlert;
5
+ modal: UIUtilModal;
6
+ prompt: UIUtilPrompt;
7
7
  customLoader: IUIUtilLoader;
8
8
  loader: Pick<IUIUtilLoader, "show" | "hide">;
9
9
  }
@@ -14,23 +14,19 @@ export declare class UIUtilProvider extends React.PureComponent<{}, IUIUtilProvi
14
14
  constructor(props: any);
15
15
  get modalDefaults(): {
16
16
  create: any;
17
- show: (options: ModalOptions) => IModalCreate;
18
- getCurrent: () => IModalCreate;
19
- showAlert: (content: ModalOptions["content"], onClose?: ModalOptions["onClose"]) => IModalCreate;
20
- showConfirm: (options: ModalOptions, onYes: () => void, onNo?: () => void) => IModalCreate;
21
- showActions: (options: ModalOptions, actions: IUtilModalAction[]) => IModalCreate;
17
+ show: (options: PopUpOptions) => PopUp;
18
+ getCurrent: () => PopUp;
19
+ showAlert: (content: PopUpOptions["content"], onClose?: PopUpOptions["onClose"]) => PopUp;
20
+ showConfirm: (options: PopUpOptions, onYes: () => void, onNo?: () => void) => PopUp;
21
+ showActions: (options: PopUpOptions, actions: PopUpAction[]) => PopUp;
22
22
  instances: {
23
23
  [id: string]: {
24
- options: ModalOptions;
24
+ options: PopUpOptions;
25
25
  shown: boolean;
26
26
  handleClose: (id: string, shown: boolean, destroyOnClose: boolean) => void;
27
27
  };
28
28
  };
29
29
  };
30
- get alertDefaults(): {
31
- show: any;
32
- showNoty: any;
33
- };
34
30
  get customLoaderDefaults(): {
35
31
  show: () => void;
36
32
  hide: () => void;
@@ -40,11 +36,21 @@ export declare class UIUtilProvider extends React.PureComponent<{}, IUIUtilProvi
40
36
  show: () => void;
41
37
  hide: () => void;
42
38
  };
43
- showNotifyAlert(message: string, alertType: AlertType, position?: string, bindToElement?: any): void;
44
- showNoty(message: string, alertType: AlertType): void;
39
+ get promptDefaults(): {
40
+ getCurrent: () => PopUp;
41
+ showConfirm: (options: PopUpOptions, onYes: () => void, onNo?: () => void) => PopUp;
42
+ showActions: (options: PopUpOptions, actions: PopUpAction[]) => PopUp;
43
+ instances: {
44
+ [id: string]: {
45
+ options: PopUpOptions;
46
+ shown: boolean;
47
+ handleClose: (id: string, shown: boolean, destroyOnClose: boolean) => void;
48
+ };
49
+ };
50
+ };
45
51
  toggleModalInstance(id: string, shown: boolean, destroyOnClose?: boolean): void;
46
52
  removeModalInstance(id: string): void;
47
- getCurrentModal(id: string): IModalCreate;
48
- createModal(id: string, options: ModalOptions): IModalCreate;
53
+ getCurrentModal(id: string): PopUp;
54
+ createModal(id: string, options: PopUpOptions): PopUp;
49
55
  render(): React.JSX.Element;
50
56
  }
@@ -15,9 +15,11 @@ const defaultState = {
15
15
  showConfirm: null,
16
16
  showActions: null,
17
17
  },
18
- alert: {
19
- show: null,
20
- showNoty: null,
18
+ prompt: {
19
+ showConfirm: null,
20
+ showActions: null,
21
+ instances: {},
22
+ getCurrent: null,
21
23
  },
22
24
  customLoader: {
23
25
  shown: false,
@@ -36,7 +38,7 @@ class UIUtilProvider extends React.PureComponent {
36
38
  constructor(props) {
37
39
  super(props);
38
40
  this.loader = Loader_1.Loader.getInstance();
39
- this.state = Object.assign(Object.assign({}, defaultState), { modal: this.modalDefaults, alert: this.alertDefaults, customLoader: this.customLoaderDefaults, loader: this.loaderDefaults });
41
+ this.state = Object.assign(Object.assign({}, defaultState), { modal: this.modalDefaults, customLoader: this.customLoaderDefaults, loader: this.loaderDefaults, prompt: this.promptDefaults });
40
42
  }
41
43
  get modalDefaults() {
42
44
  return Object.assign(Object.assign({}, defaultState.modal), { create: this.createModal.bind(this), show: (options) => this.createModal(null, options), getCurrent: () => {
@@ -59,12 +61,6 @@ class UIUtilProvider extends React.PureComponent {
59
61
  closeOnClick && this.toggleModalInstance("actions", false, true);
60
62
  } }, content))))) })) });
61
63
  }
62
- get alertDefaults() {
63
- return {
64
- show: this.showNotifyAlert.bind(this),
65
- showNoty: this.showNoty.bind(this),
66
- };
67
- }
68
64
  get customLoaderDefaults() {
69
65
  return Object.assign(Object.assign({}, defaultState.customLoader), { show: () => this.setState({
70
66
  customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: true }),
@@ -75,11 +71,12 @@ class UIUtilProvider extends React.PureComponent {
75
71
  get loaderDefaults() {
76
72
  return Object.assign(Object.assign({}, defaultState.loader), { show: () => this.loader.show(), hide: () => this.loader.hide() });
77
73
  }
78
- showNotifyAlert(message, alertType, position, bindToElement) {
79
- alert("Starting with 1.49.1, this is deprecated. Please use Notyf package directly.");
80
- }
81
- showNoty(message, alertType) {
82
- alert("Starting with 1.49.1, this is deprecated. Please use Notyf package directly.");
74
+ get promptDefaults() {
75
+ return Object.assign(Object.assign({}, defaultState.prompt), { getCurrent: () => {
76
+ const { prompt: { instances }, } = this.state;
77
+ const id = Object.keys(instances).find(id => instances[id].shown);
78
+ return this.getCurrentModal(id);
79
+ } });
83
80
  }
84
81
  toggleModalInstance(id, shown, destroyOnClose = false) {
85
82
  const { modal: { instances }, } = this.state;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.51.0",
3
+ "version": "1.52.0",
4
4
  "description": "",
5
5
  "main": "dist/index",
6
6
  "scripts": {