dry-ux 1.70.0 → 1.71.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.
@@ -1,5 +1,11 @@
1
1
  import { InputHTMLAttributes } from "react";
2
+ /**
3
+ * Type alias for validation, which can be a boolean or a string.
4
+ */
2
5
  export type IValidation = boolean | string;
6
+ /**
7
+ * Interface representing a value validation with an optional message.
8
+ */
3
9
  export interface IValueValidation<T> {
4
10
  /**
5
11
  * The value to be validated.
@@ -10,6 +16,9 @@ export interface IValueValidation<T> {
10
16
  */
11
17
  message?: string;
12
18
  }
19
+ /**
20
+ * Interface representing various validation rules for a field.
21
+ */
13
22
  export interface IValidations {
14
23
  /**
15
24
  * Indicates if the field is required.
@@ -80,6 +89,9 @@ export interface IValidations {
80
89
  */
81
90
  errorRef?: string;
82
91
  }
92
+ /**
93
+ * Interface representing enhanced properties for an input field.
94
+ */
83
95
  export interface IEnhancedProps {
84
96
  /**
85
97
  * Validation rules for the field.
@@ -106,4 +118,7 @@ export interface IEnhancedProps {
106
118
  */
107
119
  validateOnChange?: boolean;
108
120
  }
121
+ /**
122
+ * Type alias for input attributes, extending HTML input, select, and textarea attributes.
123
+ */
109
124
  export type InputAttributes = InputHTMLAttributes<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Interface representing a logger with various logging methods.
3
+ */
1
4
  export interface ILogger {
2
5
  /**
3
6
  * Logs a message with the info level.
@@ -20,6 +23,18 @@ export interface ILogger {
20
23
  */
21
24
  warn(...message: any[]): void;
22
25
  }
26
+ /**
27
+ * Initializes a logger factory with the specified path.
28
+ *
29
+ * @param {string} path - The endpoint to which log messages will be sent.
30
+ * @returns {Object} An object containing a useLogger method to create logger instances.
31
+ */
23
32
  export declare const initLoggerFactory: (path: string) => {
33
+ /**
34
+ * Creates a logger instance with the specified name.
35
+ *
36
+ * @param {string} name - The name of the logger.
37
+ * @returns {ILogger} The logger instance with methods to log messages at different levels.
38
+ */
24
39
  useLogger: (name: string) => ILogger;
25
40
  };
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initLoggerFactory = void 0;
4
+ /**
5
+ * Creates a logger instance with the specified path and name.
6
+ *
7
+ * @param {string} path - The endpoint to which log messages will be sent.
8
+ * @param {string} name - The name of the logger.
9
+ * @returns {ILogger} The logger instance with methods to log messages at different levels.
10
+ */
4
11
  const useLogger = (path, name) => {
5
12
  const convertMessage = (message) => message
6
13
  .map(m => {
@@ -35,7 +42,19 @@ const useLogger = (path, name) => {
35
42
  warn: (...message) => log("warn", message),
36
43
  };
37
44
  };
45
+ /**
46
+ * Initializes a logger factory with the specified path.
47
+ *
48
+ * @param {string} path - The endpoint to which log messages will be sent.
49
+ * @returns {Object} An object containing a useLogger method to create logger instances.
50
+ */
38
51
  const initLoggerFactory = (path) => ({
52
+ /**
53
+ * Creates a logger instance with the specified name.
54
+ *
55
+ * @param {string} name - The name of the logger.
56
+ * @returns {ILogger} The logger instance with methods to log messages at different levels.
57
+ */
39
58
  useLogger: (name) => useLogger(path, name),
40
59
  });
41
60
  exports.initLoggerFactory = initLoggerFactory;
@@ -1,9 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { UIUtilRendererProps } from "./ui-utils/UIUtilRenderer";
3
+ /**
4
+ * Props for the DryUXProvider component.
5
+ */
3
6
  interface IDryUXProviderProps {
4
7
  /**
5
8
  * Does not render the renderer for this provider. If this is set to true, then the renderer needs to be mounted
6
- * by explicitly.
9
+ * explicitly.
7
10
  */
8
11
  noRenderer?: boolean;
9
12
  /**
@@ -14,7 +17,16 @@ interface IDryUXProviderProps {
14
17
  * If true, the viewport detection will be enabled.
15
18
  */
16
19
  viewportDetect?: boolean;
20
+ /**
21
+ * The children elements to be rendered within the provider.
22
+ */
17
23
  children: React.ReactNode;
18
24
  }
25
+ /**
26
+ * DryUXProvider component that provides UI utilities and optionally renders a UIUtilRenderer.
27
+ *
28
+ * @param {IDryUXProviderProps} props - The props for the DryUXProvider component.
29
+ * @returns {JSX.Element} The DryUXProvider component.
30
+ */
19
31
  export declare const DryUXProvider: React.FC<IDryUXProviderProps>;
20
32
  export {};
package/dist/provider.js CHANGED
@@ -4,6 +4,12 @@ exports.DryUXProvider = void 0;
4
4
  const React = require("react");
5
5
  const UIUtilProvider_1 = require("./ui-utils/UIUtilProvider");
6
6
  const UIUtilRenderer_1 = require("./ui-utils/UIUtilRenderer");
7
+ /**
8
+ * DryUXProvider component that provides UI utilities and optionally renders a UIUtilRenderer.
9
+ *
10
+ * @param {IDryUXProviderProps} props - The props for the DryUXProvider component.
11
+ * @returns {JSX.Element} The DryUXProvider component.
12
+ */
7
13
  exports.DryUXProvider = React.memo(({ children, noRenderer = false, rendererProps, viewportDetect }) => (React.createElement(UIUtilProvider_1.UIUtilProvider, { viewportDetect: viewportDetect },
8
14
  children,
9
15
  !noRenderer && React.createElement(UIUtilRenderer_1.UIUtilRenderer, Object.assign({}, rendererProps)))));
@@ -1,6 +1,16 @@
1
1
  import * as React from "react";
2
2
  import { Content, PopUpAction } from "./UIUtil.interface";
3
3
  import { Omit } from "react-bootstrap";
4
+ /**
5
+ * ActionsOverlay component that displays a title, content, and a set of actions as buttons.
6
+ *
7
+ * @param {Object} props - The props for the ActionsOverlay component.
8
+ * @param {Content} props.title - The title to be displayed in the overlay.
9
+ * @param {Content} props.content - The content to be displayed in the overlay.
10
+ * @param {Function} props.hide - The function to hide the overlay.
11
+ * @param {Array<Omit<PopUpAction, "confirm">>} props.actions - The actions to be displayed as buttons.
12
+ * @returns {JSX.Element} The ActionsOverlay component.
13
+ */
4
14
  export declare const ActionsOverlay: React.FC<{
5
15
  title: Content;
6
16
  content: Content;
@@ -3,20 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActionsOverlay = void 0;
4
4
  const React = require("react");
5
5
  const react_bootstrap_1 = require("react-bootstrap");
6
- const ActionsOverlay = ({ title, content, actions, hide }) => {
7
- return (React.createElement("div", { style: { minWidth: 200 } },
8
- React.createElement("div", { style: {
9
- fontWeight: "bold",
10
- fontSize: 18,
11
- paddingLeft: 5,
12
- } }, title),
13
- React.createElement("hr", { style: { margin: 5 } }),
14
- React.createElement("div", null, typeof content == "string" ? (React.createElement("h4", { className: "text-center", style: { margin: 10 } }, content)) : (content)),
15
- React.createElement("hr", { style: { margin: 5 } }),
16
- React.createElement("div", { style: { textAlign: "right" } }, actions.map((action, index) => (React.createElement(react_bootstrap_1.Button, { key: index, bsClass: `btn btn-${action.type} btn-sm`, style: { marginRight: 10 }, onClick: () => {
17
- var _a;
18
- (_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action);
19
- action.closeOnClick && hide();
20
- } }, action.content))))));
21
- };
6
+ /**
7
+ * ActionsOverlay component that displays a title, content, and a set of actions as buttons.
8
+ *
9
+ * @param {Object} props - The props for the ActionsOverlay component.
10
+ * @param {Content} props.title - The title to be displayed in the overlay.
11
+ * @param {Content} props.content - The content to be displayed in the overlay.
12
+ * @param {Function} props.hide - The function to hide the overlay.
13
+ * @param {Array<Omit<PopUpAction, "confirm">>} props.actions - The actions to be displayed as buttons.
14
+ * @returns {JSX.Element} The ActionsOverlay component.
15
+ */
16
+ const ActionsOverlay = ({ title, content, actions, hide }) => (React.createElement("div", { style: { minWidth: 200 } },
17
+ React.createElement("div", { style: {
18
+ fontWeight: "bold",
19
+ fontSize: 18,
20
+ paddingLeft: 5,
21
+ } }, title),
22
+ React.createElement("hr", { style: { margin: 5 } }),
23
+ React.createElement("div", null, typeof content == "string" ? (React.createElement("h4", { className: "text-center", style: { margin: 10 } }, content)) : (content)),
24
+ React.createElement("hr", { style: { margin: 5 } }),
25
+ React.createElement("div", { style: { textAlign: "right" } }, actions.map((action, index) => (React.createElement(react_bootstrap_1.Button, { key: index, bsClass: `btn btn-${action.type} btn-sm`, style: { marginRight: 10 }, onClick: () => {
26
+ var _a;
27
+ (_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action);
28
+ action.closeOnClick && hide();
29
+ } }, action.content))))));
22
30
  exports.ActionsOverlay = ActionsOverlay;
@@ -1,18 +1,51 @@
1
1
  import * as React from "react";
2
2
  import { PopUpInstance, PopUpOptions } from "./UIUtil.interface";
3
3
  import "../styles/modal.css";
4
+ /**
5
+ * Props for the Modal component.
6
+ */
4
7
  export type ModalProps = {
8
+ /**
9
+ * The id of the modal.
10
+ */
5
11
  id: string;
12
+ /**
13
+ * The instance of the PopUp.
14
+ */
6
15
  instance: PopUpInstance;
16
+ /**
17
+ * Configuration options for the modal.
18
+ */
7
19
  config: {
20
+ /**
21
+ * Custom styles for the modal.
22
+ */
8
23
  styles?: {
9
24
  [selector: string]: React.CSSProperties;
10
25
  };
26
+ /**
27
+ * If true, applies default modal styles.
28
+ */
11
29
  defaultModalStyles?: boolean;
30
+ /**
31
+ * If true, centers the modal vertically.
32
+ */
12
33
  centered?: boolean;
34
+ /**
35
+ * Callback function to be called when the modal is opened.
36
+ */
13
37
  onOpen?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
38
+ /**
39
+ * Callback function to be called when the modal is closed.
40
+ */
14
41
  onClose?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
15
42
  };
16
43
  };
44
+ /**
45
+ * Modal component that renders a Bootstrap modal with custom configurations.
46
+ *
47
+ * @param {ModalProps} props - The props for the Modal component.
48
+ * @returns {JSX.Element} The Modal component.
49
+ */
17
50
  declare const Modal: React.FC<ModalProps>;
18
51
  export default Modal;
@@ -5,6 +5,12 @@ const react_bootstrap_1 = require("react-bootstrap");
5
5
  require("../styles/modal.css");
6
6
  const classSet_1 = require("../helpers/classSet");
7
7
  const ActionsOverlay_1 = require("./ActionsOverlay");
8
+ /**
9
+ * Modal component that renders a Bootstrap modal with custom configurations.
10
+ *
11
+ * @param {ModalProps} props - The props for the Modal component.
12
+ * @returns {JSX.Element} The Modal component.
13
+ */
8
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 }, }) => {
9
15
  const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
10
16
  const applyStyles = React.useCallback(() => {
@@ -1,5 +1,11 @@
1
1
  import { Omit } from "react-bootstrap";
2
+ /**
3
+ * Type alias for content, which can be a JSX element or a string.
4
+ */
2
5
  export type Content = JSX.Element | string;
6
+ /**
7
+ * Represents a PopUp with methods to control its visibility and content.
8
+ */
3
9
  export type PopUp = {
4
10
  /**
5
11
  * Hides the modal.
@@ -15,6 +21,7 @@ export type PopUp = {
15
21
  remove: () => void;
16
22
  /**
17
23
  * Updates the modal options.
24
+ * @param {Partial<PopUpOptions>} options - The options to update.
18
25
  */
19
26
  update: (options: Partial<PopUpOptions>) => void;
20
27
  /**
@@ -23,14 +30,21 @@ export type PopUp = {
23
30
  overlay: {
24
31
  /**
25
32
  * Shows the overlay.
33
+ * @param {Content} content - The content to display in the overlay.
26
34
  */
27
35
  show: (content: Content) => void;
28
36
  /**
29
37
  * Shows the overlay with yes/no buttons.
38
+ * @param {Content} content - The content to display in the overlay.
39
+ * @param {() => void} onYes - The function to call when the yes button is clicked.
40
+ * @param {() => void} [onNo] - The function to call when the no button is clicked.
30
41
  */
31
42
  showConfirm: (content: Content, onYes: () => void, onNo?: () => void) => void;
32
43
  /**
33
44
  * Shows the overlay with custom actions.
45
+ * @param {Content} title - The title of the overlay.
46
+ * @param {Content} content - The content to display in the overlay.
47
+ * @param {Omit<PopUpAction, "confirm">[]} actions - The actions to display in the overlay.
34
48
  */
35
49
  showActions: (title: Content, content: Content, actions: Omit<PopUpAction, "confirm">[]) => void;
36
50
  /**
@@ -39,14 +53,43 @@ export type PopUp = {
39
53
  hide: () => void;
40
54
  };
41
55
  };
56
+ /**
57
+ * Type alias for button types.
58
+ */
42
59
  export type ButtonType = "primary" | "secondary" | "info" | "success" | "warning" | "danger";
60
+ /**
61
+ * Represents an instance of a PopUp.
62
+ */
43
63
  export type PopUpInstance = {
64
+ /**
65
+ * The options for the PopUp.
66
+ */
44
67
  options: PopUpOptions;
68
+ /**
69
+ * Indicates whether the PopUp is shown.
70
+ */
45
71
  shown: boolean;
72
+ /**
73
+ * The overlay content for the PopUp.
74
+ */
46
75
  overlay?: Content;
76
+ /**
77
+ * Handles closing the PopUp.
78
+ * @param {string} id - The id of the PopUp.
79
+ * @param {boolean} shown - Indicates whether the PopUp is shown.
80
+ * @param {boolean} [destroyOnClose] - If true, the PopUp will be destroyed when closed.
81
+ */
47
82
  handleClose: (id: string, shown: boolean, destroyOnClose?: boolean) => void;
83
+ /**
84
+ * Toggles the overlay content for the PopUp.
85
+ * @param {string} id - The id of the PopUp.
86
+ * @param {Content} [content] - The content to display in the overlay.
87
+ */
48
88
  toggleOverlay: (id: string, content?: Content) => void;
49
89
  };
90
+ /**
91
+ * Represents an action for a PopUp.
92
+ */
50
93
  export type PopUpAction = {
51
94
  /**
52
95
  * The content to display in the modal.
@@ -69,6 +112,9 @@ export type PopUpAction = {
69
112
  */
70
113
  confirm?: Content;
71
114
  };
115
+ /**
116
+ * Represents the options for a PopUp.
117
+ */
72
118
  export type PopUpOptions = {
73
119
  /**
74
120
  * The content of the modal.
@@ -119,16 +165,21 @@ export type PopUpOptions = {
119
165
  */
120
166
  actions?: PopUpAction[];
121
167
  };
168
+ /**
169
+ * Represents a utility for managing UI modals.
170
+ */
122
171
  export type UIUtilModal = {
123
172
  /**
124
173
  * Creates a non-unique modal.
125
- * @param options The options for the modal.
174
+ * @param {PopUpOptions} options - The options for the modal.
175
+ * @returns {PopUp} The created PopUp.
126
176
  */
127
177
  show: (options: PopUpOptions) => PopUp;
128
178
  /**
129
- * Creates a unique (by id) modal
130
- * @param id The id of the modal.
131
- * @param options The options for the modal.
179
+ * Creates a unique (by id) modal.
180
+ * @param {string} id - The id of the modal.
181
+ * @param {PopUpOptions} options - The options for the modal.
182
+ * @returns {PopUp} The created PopUp.
132
183
  */
133
184
  create: (id: string, options: PopUpOptions) => PopUp;
134
185
  /**
@@ -139,27 +190,35 @@ export type UIUtilModal = {
139
190
  };
140
191
  /**
141
192
  * Gets the current modal instance.
193
+ * @returns {PopUp} The current PopUp.
142
194
  */
143
195
  getCurrent: () => PopUp;
144
196
  /**
145
197
  * Shows an alert style modal.
146
- * @param content The content to display in the modal.
198
+ * @param {Content} content - The content to display in the modal.
199
+ * @param {() => void} [onClose] - Function to call when the modal is closed.
200
+ * @returns {PopUp} The created PopUp.
147
201
  */
148
202
  showAlert: (content: Content, onClose?: PopUpOptions["onClose"]) => PopUp;
149
203
  /**
150
204
  * Shows a confirm style modal.
151
- * @param options The options for the modal.
152
- * @param onYes The function to call when the yes button is clicked.
153
- * @param onNo The function to call when the no button is clicked.
205
+ * @param {Omit<PopUpOptions, "actions">} options - The options for the modal.
206
+ * @param {() => void} onYes - The function to call when the yes button is clicked.
207
+ * @param {() => void} [onNo] - The function to call when the no button is clicked.
208
+ * @returns {PopUp} The created PopUp.
154
209
  */
155
210
  showConfirm: (options: Omit<PopUpOptions, "actions">, onYes: () => void, onNo?: () => void) => PopUp;
156
211
  /**
157
212
  * Shows a modal with custom actions.
158
- * @param options The options for the modal.
159
- * @param actions The actions to display in the modal.
213
+ * @param {Omit<PopUpOptions, "actions">} options - The options for the modal.
214
+ * @param {PopUpAction[]} actions - The actions to display in the modal.
215
+ * @returns {PopUp} The created PopUp.
160
216
  */
161
217
  showActions: (options: Omit<PopUpOptions, "actions">, actions: PopUpAction[]) => PopUp;
162
218
  };
219
+ /**
220
+ * Represents a loader utility.
221
+ */
163
222
  export interface IUIUtilLoader {
164
223
  /**
165
224
  * Status of the loader.
@@ -174,4 +233,7 @@ export interface IUIUtilLoader {
174
233
  */
175
234
  hide: () => void;
176
235
  }
236
+ /**
237
+ * Type alias for UIUtilPrompt, which includes specific methods from UIUtilModal.
238
+ */
177
239
  export type UIUtilPrompt = Pick<UIUtilModal, "showConfirm" | "showActions" | "instances" | "getCurrent">;
@@ -2,15 +2,44 @@ import * as React from "react";
2
2
  import { Content, IUIUtilLoader, PopUp, PopUpAction, PopUpInstance, PopUpOptions, UIUtilModal, UIUtilPrompt } from "./UIUtil.interface";
3
3
  import "../types";
4
4
  import { CurrentViewport } from "./ViewportDetect";
5
+ /**
6
+ * Interface representing the state of the UIUtilProvider.
7
+ */
5
8
  export interface IUIUtilProviderState {
9
+ /**
10
+ * Modal utility for managing modals.
11
+ */
6
12
  modal: UIUtilModal;
13
+ /**
14
+ * Prompt utility for managing prompts.
15
+ */
7
16
  prompt: UIUtilPrompt;
17
+ /**
18
+ * Custom loader utility.
19
+ */
8
20
  customLoader: IUIUtilLoader;
21
+ /**
22
+ * Loader utility with show and hide methods.
23
+ */
9
24
  loader: Pick<IUIUtilLoader, "show" | "hide">;
25
+ /**
26
+ * Current viewport information.
27
+ */
10
28
  viewport: CurrentViewport;
11
29
  }
30
+ /**
31
+ * React context for UI utilities.
32
+ */
12
33
  export declare const UIUtilContext: React.Context<IUIUtilProviderState>;
34
+ /**
35
+ * Hook to use the UIUtil context.
36
+ *
37
+ * @returns {IUIUtilProviderState} The current state of the UIUtil context.
38
+ */
13
39
  export declare const useUIUtilContext: () => IUIUtilProviderState;
40
+ /**
41
+ * Object containing modal IDs.
42
+ */
14
43
  declare const modalId: {
15
44
  actions: string;
16
45
  confirm: string;
@@ -18,11 +47,17 @@ declare const modalId: {
18
47
  modal: string;
19
48
  };
20
49
  type ModalId = (typeof modalId)[keyof typeof modalId];
50
+ /**
51
+ * UIUtilProvider component that provides UI utilities to its children.
52
+ */
21
53
  export declare class UIUtilProvider extends React.PureComponent<{
22
54
  viewportDetect?: boolean;
23
55
  }, IUIUtilProviderState> {
24
56
  private readonly loader;
25
57
  constructor(props: any);
58
+ /**
59
+ * Default modal utility methods.
60
+ */
26
61
  get modalDefaults(): {
27
62
  create: any;
28
63
  show: (options: PopUpOptions) => PopUp;
@@ -34,15 +69,24 @@ export declare class UIUtilProvider extends React.PureComponent<{
34
69
  [id: string]: PopUpInstance;
35
70
  };
36
71
  };
72
+ /**
73
+ * Default custom loader utility methods.
74
+ */
37
75
  get customLoaderDefaults(): {
38
76
  show: () => void;
39
77
  hide: () => void;
40
78
  shown: boolean;
41
79
  };
80
+ /**
81
+ * Default loader utility methods.
82
+ */
42
83
  get loaderDefaults(): {
43
84
  show: () => void;
44
85
  hide: () => void;
45
86
  };
87
+ /**
88
+ * Default prompt utility methods.
89
+ */
46
90
  get promptDefaults(): {
47
91
  getCurrent: () => PopUp;
48
92
  showConfirm: (options: import("react-bootstrap").Omit<PopUpOptions, "actions">, onYes: () => void, onNo?: () => void) => PopUp;
@@ -51,11 +95,47 @@ export declare class UIUtilProvider extends React.PureComponent<{
51
95
  [id: string]: PopUpInstance;
52
96
  };
53
97
  };
98
+ /**
99
+ * Toggles the visibility of a modal instance.
100
+ *
101
+ * @param {ModalId} id - The ID of the modal.
102
+ * @param {boolean} shown - Whether the modal should be shown.
103
+ * @param {boolean} [destroyOnClose=false] - Whether to destroy the modal on close.
104
+ */
54
105
  toggleModalInstance: PopUpInstance["handleClose"];
106
+ /**
107
+ * Toggles the overlay content of a modal instance.
108
+ *
109
+ * @param {ModalId} id - The ID of the modal.
110
+ * @param {Content} [content] - The content to display in the overlay.
111
+ */
55
112
  toggleModalOverlay: PopUpInstance["toggleOverlay"];
113
+ /**
114
+ * Removes a modal instance.
115
+ *
116
+ * @param {ModalId} id - The ID of the modal.
117
+ */
56
118
  removeModalInstance(id: ModalId): void;
119
+ /**
120
+ * Gets the current modal instance.
121
+ *
122
+ * @param {ModalId} id - The ID of the modal.
123
+ * @returns {PopUp} The current modal instance.
124
+ */
57
125
  getCurrentModal(id: ModalId): PopUp;
126
+ /**
127
+ * Creates a new modal instance.
128
+ *
129
+ * @param {ModalId} id - The ID of the modal.
130
+ * @param {PopUpOptions} options - The options for the modal.
131
+ * @returns {PopUp} The created modal instance.
132
+ */
58
133
  createModal(id: ModalId, options: PopUpOptions): PopUp;
134
+ /**
135
+ * Renders the UIUtilProvider component.
136
+ *
137
+ * @returns {JSX.Element} The rendered component.
138
+ */
59
139
  render(): React.JSX.Element;
60
140
  }
61
141
  export {};
@@ -6,6 +6,9 @@ require("../types");
6
6
  const Loader_1 = require("./Loader");
7
7
  const ActionsOverlay_1 = require("./ActionsOverlay");
8
8
  const ViewportDetect_1 = require("./ViewportDetect");
9
+ /**
10
+ * Default state for the UIUtilProvider.
11
+ */
9
12
  const defaultState = {
10
13
  modal: {
11
14
  show: null,
@@ -33,19 +36,40 @@ const defaultState = {
33
36
  },
34
37
  viewport: new ViewportDetect_1.CurrentViewport(undefined),
35
38
  };
39
+ /**
40
+ * React context for UI utilities.
41
+ */
36
42
  exports.UIUtilContext = React.createContext(defaultState);
43
+ /**
44
+ * Hook to use the UIUtil context.
45
+ *
46
+ * @returns {IUIUtilProviderState} The current state of the UIUtil context.
47
+ */
37
48
  const useUIUtilContext = () => React.useContext(exports.UIUtilContext);
38
49
  exports.useUIUtilContext = useUIUtilContext;
50
+ /**
51
+ * Object containing modal IDs.
52
+ */
39
53
  const modalId = {
40
54
  actions: "actions",
41
55
  confirm: "confirm",
42
56
  alert: "alert",
43
57
  modal: "modal",
44
58
  };
59
+ /**
60
+ * UIUtilProvider component that provides UI utilities to its children.
61
+ */
45
62
  class UIUtilProvider extends React.PureComponent {
46
63
  constructor(props) {
47
64
  super(props);
48
65
  this.loader = Loader_1.Loader.getInstance();
66
+ /**
67
+ * Toggles the visibility of a modal instance.
68
+ *
69
+ * @param {ModalId} id - The ID of the modal.
70
+ * @param {boolean} shown - Whether the modal should be shown.
71
+ * @param {boolean} [destroyOnClose=false] - Whether to destroy the modal on close.
72
+ */
49
73
  this.toggleModalInstance = (id, shown, destroyOnClose = false) => {
50
74
  var _a, _b;
51
75
  const { modal: { instances }, } = this.state;
@@ -68,6 +92,12 @@ class UIUtilProvider extends React.PureComponent {
68
92
  });
69
93
  }
70
94
  };
95
+ /**
96
+ * Toggles the overlay content of a modal instance.
97
+ *
98
+ * @param {ModalId} id - The ID of the modal.
99
+ * @param {Content} [content] - The content to display in the overlay.
100
+ */
71
101
  this.toggleModalOverlay = (id, content) => {
72
102
  const { modal: { instances }, } = this.state;
73
103
  instances[id].overlay = content;
@@ -77,6 +107,9 @@ class UIUtilProvider extends React.PureComponent {
77
107
  };
78
108
  this.state = Object.assign(Object.assign({}, defaultState), { modal: this.modalDefaults, customLoader: this.customLoaderDefaults, loader: this.loaderDefaults, prompt: this.promptDefaults });
79
109
  }
110
+ /**
111
+ * Default modal utility methods.
112
+ */
80
113
  get modalDefaults() {
81
114
  return Object.assign(Object.assign({}, defaultState.modal), { create: this.createModal.bind(this), show: (options) => this.createModal(modalId.modal, options), getCurrent: () => {
82
115
  const { modal: { instances }, } = this.state;
@@ -98,6 +131,9 @@ class UIUtilProvider extends React.PureComponent {
98
131
  },
99
132
  ] })), showActions: (options, actions) => this.createModal(modalId.actions, Object.assign(Object.assign({}, options), { actions })) });
100
133
  }
134
+ /**
135
+ * Default custom loader utility methods.
136
+ */
101
137
  get customLoaderDefaults() {
102
138
  return Object.assign(Object.assign({}, defaultState.customLoader), { show: () => this.setState({
103
139
  customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: true }),
@@ -105,9 +141,15 @@ class UIUtilProvider extends React.PureComponent {
105
141
  customLoader: Object.assign(Object.assign({}, this.state.customLoader), { shown: false }),
106
142
  }) });
107
143
  }
144
+ /**
145
+ * Default loader utility methods.
146
+ */
108
147
  get loaderDefaults() {
109
148
  return Object.assign(Object.assign({}, defaultState.loader), { show: () => this.loader.show(), hide: () => this.loader.hide() });
110
149
  }
150
+ /**
151
+ * Default prompt utility methods.
152
+ */
111
153
  get promptDefaults() {
112
154
  return Object.assign(Object.assign({}, defaultState.prompt), { getCurrent: () => {
113
155
  const { prompt: { instances }, } = this.state;
@@ -115,6 +157,11 @@ class UIUtilProvider extends React.PureComponent {
115
157
  return this.getCurrentModal(id);
116
158
  } });
117
159
  }
160
+ /**
161
+ * Removes a modal instance.
162
+ *
163
+ * @param {ModalId} id - The ID of the modal.
164
+ */
118
165
  removeModalInstance(id) {
119
166
  var _a, _b;
120
167
  const { modal: { instances }, } = this.state;
@@ -125,6 +172,12 @@ class UIUtilProvider extends React.PureComponent {
125
172
  modal: Object.assign(Object.assign({}, this.state.modal), { instances }),
126
173
  });
127
174
  }
175
+ /**
176
+ * Gets the current modal instance.
177
+ *
178
+ * @param {ModalId} id - The ID of the modal.
179
+ * @returns {PopUp} The current modal instance.
180
+ */
128
181
  getCurrentModal(id) {
129
182
  return {
130
183
  show: () => this.toggleModalInstance(id, true),
@@ -158,6 +211,13 @@ class UIUtilProvider extends React.PureComponent {
158
211
  },
159
212
  };
160
213
  }
214
+ /**
215
+ * Creates a new modal instance.
216
+ *
217
+ * @param {ModalId} id - The ID of the modal.
218
+ * @param {PopUpOptions} options - The options for the modal.
219
+ * @returns {PopUp} The created modal instance.
220
+ */
161
221
  createModal(id, options) {
162
222
  const { modal: { instances }, } = this.state;
163
223
  instances[id] = {
@@ -172,6 +232,11 @@ class UIUtilProvider extends React.PureComponent {
172
232
  this.toggleModalInstance(id, true);
173
233
  return this.getCurrentModal(id);
174
234
  }
235
+ /**
236
+ * Renders the UIUtilProvider component.
237
+ *
238
+ * @returns {JSX.Element} The rendered component.
239
+ */
175
240
  render() {
176
241
  return (React.createElement(exports.UIUtilContext.Provider, { value: this.state },
177
242
  this.props.children,
@@ -1,6 +1,18 @@
1
1
  import * as React from "react";
2
2
  import { ModalProps } from "./Modal";
3
+ /**
4
+ * Props for the UIUtilRenderer component.
5
+ */
3
6
  export type UIUtilRendererProps = {
7
+ /**
8
+ * Configuration for the modal.
9
+ */
4
10
  modalConfig?: ModalProps["config"];
5
11
  };
12
+ /**
13
+ * UIUtilRenderer component that renders modals based on the UIUtil context.
14
+ *
15
+ * @param {UIUtilRendererProps} props - The props for the UIUtilRenderer component.
16
+ * @returns {JSX.Element} The UIUtilRenderer component.
17
+ */
6
18
  export declare const UIUtilRenderer: React.FC<UIUtilRendererProps>;
@@ -4,6 +4,12 @@ exports.UIUtilRenderer = void 0;
4
4
  const React = require("react");
5
5
  const UIUtilProvider_1 = require("./UIUtilProvider");
6
6
  const Modal_1 = require("./Modal");
7
+ /**
8
+ * UIUtilRenderer component that renders modals based on the UIUtil context.
9
+ *
10
+ * @param {UIUtilRendererProps} props - The props for the UIUtilRenderer component.
11
+ * @returns {JSX.Element} The UIUtilRenderer component.
12
+ */
7
13
  exports.UIUtilRenderer = React.memo(({ modalConfig = {} }) => {
8
14
  const { modal: { instances }, } = (0, UIUtilProvider_1.useUIUtilContext)();
9
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 })))));
@@ -1,20 +1,60 @@
1
1
  import * as React from "react";
2
2
  import "../styles/viewport.css";
3
+ /**
4
+ * Enum representing different viewport sizes.
5
+ */
3
6
  export declare enum Viewport {
7
+ /** Extra small viewport size. (phones with smaller display) */
4
8
  XS = "xs",
9
+ /** Small viewport size. (phones) */
5
10
  SM = "sm",
11
+ /** Medium viewport size. (tablets) */
6
12
  MD = "md",
13
+ /** Large viewport size. (desktops) */
7
14
  LG = "lg"
8
15
  }
16
+ /**
17
+ * Class representing the current viewport.
18
+ */
9
19
  export declare class CurrentViewport {
10
20
  private _current;
21
+ /**
22
+ * Creates an instance of CurrentViewport.
23
+ * @param {Viewport} _current - The current viewport size.
24
+ */
11
25
  constructor(_current: Viewport);
26
+ /**
27
+ * Checks if the current viewport is extra small.
28
+ * @returns {boolean} True if the current viewport is extra small, otherwise false.
29
+ */
12
30
  get isXS(): boolean;
31
+ /**
32
+ * Checks if the current viewport is small.
33
+ * @returns {boolean} True if the current viewport is small, otherwise false.
34
+ */
13
35
  get isSM(): boolean;
36
+ /**
37
+ * Checks if the current viewport is medium.
38
+ * @returns {boolean} True if the current viewport is medium, otherwise false.
39
+ */
14
40
  get isMD(): boolean;
41
+ /**
42
+ * Checks if the current viewport is large.
43
+ * @returns {boolean} True if the current viewport is large, otherwise false.
44
+ */
15
45
  get isLG(): boolean;
46
+ /**
47
+ * Gets the current viewport size.
48
+ * @returns {Viewport} The current viewport size.
49
+ */
16
50
  get current(): Viewport;
17
51
  }
52
+ /**
53
+ * Component that detects the current viewport and triggers a callback on change.
54
+ * @param {Object} props - The component props.
55
+ * @param {function(CurrentViewport): void} props.onChange - Callback function to handle viewport change.
56
+ * @returns {JSX.Element} The viewport detection component.
57
+ */
18
58
  export declare const ViewportDetect: React.FC<{
19
59
  onChange: (current: CurrentViewport) => void;
20
60
  }>;
@@ -4,34 +4,75 @@ exports.ViewportDetect = exports.CurrentViewport = exports.Viewport = void 0;
4
4
  const React = require("react");
5
5
  require("../styles/viewport.css");
6
6
  const utilities_1 = require("../helpers/utilities");
7
+ /**
8
+ * Enum representing different viewport sizes.
9
+ */
7
10
  var Viewport;
8
11
  (function (Viewport) {
12
+ /** Extra small viewport size. (phones with smaller display) */
9
13
  Viewport["XS"] = "xs";
14
+ /** Small viewport size. (phones) */
10
15
  Viewport["SM"] = "sm";
16
+ /** Medium viewport size. (tablets) */
11
17
  Viewport["MD"] = "md";
18
+ /** Large viewport size. (desktops) */
12
19
  Viewport["LG"] = "lg";
13
20
  })(Viewport || (exports.Viewport = Viewport = {}));
21
+ /**
22
+ * Class representing the current viewport.
23
+ */
14
24
  class CurrentViewport {
25
+ /**
26
+ * Creates an instance of CurrentViewport.
27
+ * @param {Viewport} _current - The current viewport size.
28
+ */
15
29
  constructor(_current) {
16
30
  this._current = _current;
17
31
  }
32
+ /**
33
+ * Checks if the current viewport is extra small.
34
+ * @returns {boolean} True if the current viewport is extra small, otherwise false.
35
+ */
18
36
  get isXS() {
19
37
  return this._current === Viewport.XS;
20
38
  }
39
+ /**
40
+ * Checks if the current viewport is small.
41
+ * @returns {boolean} True if the current viewport is small, otherwise false.
42
+ */
21
43
  get isSM() {
22
44
  return this._current === Viewport.SM;
23
45
  }
46
+ /**
47
+ * Checks if the current viewport is medium.
48
+ * @returns {boolean} True if the current viewport is medium, otherwise false.
49
+ */
24
50
  get isMD() {
25
51
  return this._current === Viewport.MD;
26
52
  }
53
+ /**
54
+ * Checks if the current viewport is large.
55
+ * @returns {boolean} True if the current viewport is large, otherwise false.
56
+ */
27
57
  get isLG() {
28
58
  return this._current === Viewport.LG;
29
59
  }
60
+ /**
61
+ * Gets the current viewport size.
62
+ * @returns {Viewport} The current viewport size.
63
+ */
30
64
  get current() {
31
65
  return this._current;
32
66
  }
33
67
  }
34
68
  exports.CurrentViewport = CurrentViewport;
69
+ /**
70
+ * Component that detects the visibility of a viewport element.
71
+ * @param {Object} props - The component props.
72
+ * @param {Viewport} props.viewport - The viewport size.
73
+ * @param {function(boolean): void} props.onVisibilityChange - Callback function to handle visibility change.
74
+ * @returns {JSX.Element} The detection element.
75
+ */
35
76
  const DetectionElement = ({ viewport, onVisibilityChange, }) => {
36
77
  const ref = React.useRef(null);
37
78
  const isVisible = (0, utilities_1.useIsVisible)(ref);
@@ -40,6 +81,12 @@ const DetectionElement = ({ viewport, onVisibilityChange, }) => {
40
81
  }, [isVisible]);
41
82
  return React.createElement("div", { ref: ref, className: `dry-visible-${viewport}` });
42
83
  };
84
+ /**
85
+ * Component that detects the current viewport and triggers a callback on change.
86
+ * @param {Object} props - The component props.
87
+ * @param {function(CurrentViewport): void} props.onChange - Callback function to handle viewport change.
88
+ * @returns {JSX.Element} The viewport detection component.
89
+ */
43
90
  exports.ViewportDetect = React.memo(({ onChange }) => {
44
91
  const onVisibilityChange = (viewport, isVisible) => {
45
92
  if (isVisible) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.70.0",
3
+ "version": "1.71.0",
4
4
  "description": "",
5
5
  "main": "dist/index",
6
6
  "scripts": {
@@ -11,7 +11,8 @@
11
11
  "update:version": "npm version minor --no-git-tag-version",
12
12
  "prepub:npm": "npm run format && npm run build && npm run update:version",
13
13
  "publish:npm": "npm run prepub:npm && npm publish",
14
- "pack": "npm run build && npm pack --pack-destination pack/"
14
+ "pack": "npm run build && npm pack --pack-destination pack/",
15
+ "docs": "typedoc --options typedoc.json && cd test && npm run build:test && cp -r proddist ../htmldocs/demo"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -24,13 +25,16 @@
24
25
  "author": "Naved Rangwala",
25
26
  "license": "ISC",
26
27
  "devDependencies": {
27
- "copyfiles": "^2.4.1",
28
- "react": "^16.8.2",
29
- "react-dom": "^16.8.2",
30
28
  "@types/react": "^17.0.0",
31
29
  "@types/react-bootstrap": "^0.32.25",
30
+ "copyfiles": "^2.4.1",
31
+ "jsdoc": "^4.0.4",
32
32
  "prettier": "^2.2.1",
33
+ "react": "^16.8.2",
34
+ "react-dom": "^16.8.2",
33
35
  "rimraf": "^3.0.2",
36
+ "typedoc": "^0.27.9",
37
+ "typedoc-plugin-markdown": "^4.4.2",
34
38
  "typescript": "*"
35
39
  },
36
40
  "dependencies": {
package/README.md DELETED
File without changes