dry-ux 1.79.0 → 1.80.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.
@@ -21,6 +21,14 @@ interface IDryUXProviderProps {
21
21
  * The children elements to be rendered within the provider.
22
22
  */
23
23
  children: React.ReactNode;
24
+ /**
25
+ * Optional identifier for the provider.
26
+ */
27
+ id?: string;
28
+ /**
29
+ * If true, enables debug mode.
30
+ */
31
+ debug?: boolean;
24
32
  }
25
33
  /**
26
34
  * DryUXProvider component that provides UI utilities and optionally renders a UIUtilRenderer.
package/dist/provider.js CHANGED
@@ -10,6 +10,6 @@ const UIUtilRenderer_1 = require("./ui-utils/UIUtilRenderer");
10
10
  * @param {IDryUXProviderProps} props - The props for the DryUXProvider component.
11
11
  * @returns {JSX.Element} The DryUXProvider component.
12
12
  */
13
- exports.DryUXProvider = React.memo(({ children, noRenderer = false, rendererProps, viewportDetect }) => (React.createElement(UIUtilProvider_1.UIUtilProvider, { viewportDetect: viewportDetect },
13
+ exports.DryUXProvider = React.memo(({ children, noRenderer = false, rendererProps, viewportDetect, id, debug }) => (React.createElement(UIUtilProvider_1.UIUtilProvider, { viewportDetect: viewportDetect, id: id, debug: debug },
14
14
  children,
15
- !noRenderer && React.createElement(UIUtilRenderer_1.UIUtilRenderer, Object.assign({}, rendererProps)))));
15
+ !noRenderer && React.createElement(UIUtilRenderer_1.UIUtilRenderer, Object.assign({}, rendererProps, { id: id, debug: debug })))));
@@ -40,6 +40,14 @@ export type ModalProps = {
40
40
  */
41
41
  onClose?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
42
42
  };
43
+ /**
44
+ * Provider ID
45
+ */
46
+ providerId?: string;
47
+ /**
48
+ * Debug flag
49
+ */
50
+ debug?: boolean;
43
51
  };
44
52
  /**
45
53
  * Modal component that renders a Bootstrap modal with custom configurations.
@@ -11,7 +11,7 @@ const ActionsOverlay_1 = require("./ActionsOverlay");
11
11
  * @param {ModalProps} props - The props for the Modal component.
12
12
  * @returns {JSX.Element} The Modal component.
13
13
  */
14
- const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, onOpen, onClose: globalOnClose }, }) => {
14
+ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, onOpen, onClose: globalOnClose }, providerId, debug, }) => {
15
15
  const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
16
16
  const applyStyles = React.useCallback(() => {
17
17
  document.querySelectorAll(".modal-dialog").forEach((el) => {
@@ -27,10 +27,12 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, opt
27
27
  }, [width, styles]);
28
28
  React.useEffect(() => {
29
29
  if (shown) {
30
+ debug && console.log(`[Modal] Opened modal`, { id, providerId });
30
31
  applyStyles();
31
32
  onOpen === null || onOpen === void 0 ? void 0 : onOpen({ title, trackingId });
32
33
  }
33
34
  else {
35
+ debug && console.log(`[Modal] Closed modal`, { id, providerId });
34
36
  globalOnClose === null || globalOnClose === void 0 ? void 0 : globalOnClose({ title, trackingId });
35
37
  }
36
38
  }, [shown, width, defaultModalStyles]);
@@ -52,8 +52,11 @@ type ModalId = (typeof modalId)[keyof typeof modalId];
52
52
  */
53
53
  export declare class UIUtilProvider extends React.PureComponent<{
54
54
  viewportDetect?: boolean;
55
+ id?: string;
56
+ debug?: boolean;
55
57
  }, IUIUtilProviderState> {
56
58
  private readonly loader;
59
+ private log;
57
60
  constructor(props: any);
58
61
  /**
59
62
  * Default modal utility methods.
@@ -63,6 +63,11 @@ class UIUtilProvider extends React.PureComponent {
63
63
  constructor(props) {
64
64
  super(props);
65
65
  this.loader = Loader_1.Loader.getInstance();
66
+ this.log = (message, data) => {
67
+ if (this.props.debug) {
68
+ console.log(`[UIUtilProvider:${this.props.id || "default"}] ${message}`, data || "");
69
+ }
70
+ };
66
71
  /**
67
72
  * Toggles the visibility of a modal instance.
68
73
  *
@@ -72,9 +77,11 @@ class UIUtilProvider extends React.PureComponent {
72
77
  */
73
78
  this.toggleModalInstance = (id, shown, destroyOnClose = false) => {
74
79
  var _a, _b;
80
+ this.log("toggleModalInstance", { id, shown, destroyOnClose });
75
81
  const { modal: { instances }, } = this.state;
76
82
  const instance = instances[id];
77
83
  if (!instance) {
84
+ this.log("toggleModalInstance: instance not found", { id });
78
85
  return;
79
86
  }
80
87
  // Hide all other instances
@@ -99,12 +106,16 @@ class UIUtilProvider extends React.PureComponent {
99
106
  * @param {Content} [content] - The content to display in the overlay.
100
107
  */
101
108
  this.toggleModalOverlay = (id, content) => {
109
+ this.log("toggleModalOverlay", { id, hasContent: !!content });
102
110
  const { modal: { instances }, } = this.state;
103
111
  instances[id].overlay = content;
104
112
  this.setState({
105
113
  modal: Object.assign(Object.assign({}, this.state.modal), { instances }),
106
114
  });
107
115
  };
116
+ if (props.debug) {
117
+ console.log(`[UIUtilProvider:${props.id || "default"}] Initializing`, { id: props.id, debug: props.debug });
118
+ }
108
119
  this.state = Object.assign(Object.assign({}, defaultState), { modal: this.modalDefaults, customLoader: this.customLoaderDefaults, loader: this.loaderDefaults, prompt: this.promptDefaults });
109
120
  }
110
121
  /**
@@ -135,17 +146,29 @@ class UIUtilProvider extends React.PureComponent {
135
146
  * Default custom loader utility methods.
136
147
  */
137
148
  get customLoaderDefaults() {
138
- return Object.assign(Object.assign({}, defaultState.customLoader), { show: () => this.setState({
139
- customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: true }),
140
- }), hide: () => this.setState({
141
- customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: false }),
142
- }) });
149
+ return Object.assign(Object.assign({}, defaultState.customLoader), { show: () => {
150
+ this.log("customLoader.show()");
151
+ this.setState({
152
+ customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: true }),
153
+ });
154
+ }, hide: () => {
155
+ this.log("customLoader.hide()");
156
+ this.setState({
157
+ customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: false }),
158
+ });
159
+ } });
143
160
  }
144
161
  /**
145
162
  * Default loader utility methods.
146
163
  */
147
164
  get loaderDefaults() {
148
- return Object.assign(Object.assign({}, defaultState.loader), { show: () => this.loader.show(), hide: () => this.loader.hide() });
165
+ return Object.assign(Object.assign({}, defaultState.loader), { show: () => {
166
+ this.log("loader.show()");
167
+ this.loader.show();
168
+ }, hide: () => {
169
+ this.log("loader.hide()");
170
+ this.loader.hide();
171
+ } });
149
172
  }
150
173
  /**
151
174
  * Default prompt utility methods.
@@ -164,6 +187,7 @@ class UIUtilProvider extends React.PureComponent {
164
187
  */
165
188
  removeModalInstance(id) {
166
189
  var _a, _b;
190
+ this.log("removeModalInstance", { id });
167
191
  const { modal: { instances }, } = this.state;
168
192
  const instance = instances[id];
169
193
  (_b = (_a = instance.options).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
@@ -219,6 +243,7 @@ class UIUtilProvider extends React.PureComponent {
219
243
  * @returns {PopUp} The created modal instance.
220
244
  */
221
245
  createModal(id, options) {
246
+ this.log("createModal", { id, options });
222
247
  const { modal: { instances }, } = this.state;
223
248
  instances[id] = {
224
249
  options,
@@ -238,6 +263,10 @@ class UIUtilProvider extends React.PureComponent {
238
263
  * @returns {JSX.Element} The rendered component.
239
264
  */
240
265
  render() {
266
+ this.log("render", {
267
+ modalInstances: Object.keys(this.state.modal.instances),
268
+ customLoaderShown: this.state.customLoader.shown,
269
+ });
241
270
  return (React.createElement(exports.UIUtilContext.Provider, { value: this.state },
242
271
  this.props.children,
243
272
  this.props.viewportDetect && React.createElement(ViewportDetect_1.ViewportDetect, { onChange: viewport => this.setState({ viewport }) })));
@@ -15,4 +15,7 @@ export type UIUtilRendererProps = {
15
15
  * @param {UIUtilRendererProps} props - The props for the UIUtilRenderer component.
16
16
  * @returns {JSX.Element} The UIUtilRenderer component.
17
17
  */
18
- export declare const UIUtilRenderer: React.FC<UIUtilRendererProps>;
18
+ export declare const UIUtilRenderer: React.FC<UIUtilRendererProps & {
19
+ id?: string;
20
+ debug?: boolean;
21
+ }>;
@@ -10,7 +10,8 @@ const Modal_1 = require("./Modal");
10
10
  * @param {UIUtilRendererProps} props - The props for the UIUtilRenderer component.
11
11
  * @returns {JSX.Element} The UIUtilRenderer component.
12
12
  */
13
- exports.UIUtilRenderer = React.memo(({ modalConfig = {} }) => {
13
+ exports.UIUtilRenderer = React.memo(({ modalConfig = {}, id: providerId, debug }) => {
14
14
  const { modal: { instances }, } = (0, UIUtilProvider_1.useUIUtilContext)();
15
- return (React.createElement(React.Fragment, null, Object.keys(instances).map(id => (React.createElement(Modal_1.default, { key: id, id: id, instance: instances[id], config: modalConfig })))));
15
+ debug && console.log(`[UIUtilRenderer${providerId ? `:${providerId}` : ""}] Rendering modals`, instances);
16
+ return (React.createElement(React.Fragment, null, Object.keys(instances).map(id => (React.createElement(Modal_1.default, { key: id, id: id, instance: instances[id], config: modalConfig, providerId: providerId, debug: debug })))));
16
17
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.79.0",
3
+ "version": "1.80.0",
4
4
  "description": "",
5
5
  "main": "dist/index",
6
6
  "scripts": {