dry-ux 1.86.0 → 1.87.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.
@@ -12,11 +12,11 @@ const useDraggable_1 = require("./useDraggable");
12
12
  * @param {ModalProps} props - The props for the Modal component.
13
13
  * @returns {JSX.Element} The Modal component.
14
14
  */
15
- const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, draggable, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, draggable: globalDraggable, onOpen, onClose: globalOnClose, }, providerId, debug, }) => {
15
+ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, key: instanceKey, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, draggable, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, draggable: globalDraggable, onOpen, onClose: globalOnClose, }, providerId, debug, }) => {
16
16
  const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
17
17
  const isDraggable = !!(draggable !== null && draggable !== void 0 ? draggable : globalDraggable) && !!title;
18
18
  const draggableClass = isDraggable ? `dry-ux-draggable-${id}` : "";
19
- (0, useDraggable_1.useDraggable)(isDraggable, shown, `dry-ux-draggable-${id}`);
19
+ (0, useDraggable_1.useDraggable)(isDraggable, shown, `dry-ux-draggable-${id}`, instanceKey);
20
20
  const applyStyles = React.useCallback(() => {
21
21
  document.querySelectorAll(".modal-dialog").forEach((el) => {
22
22
  el.style.width = typeof width == "number" ? `${width}px` : width;
@@ -69,6 +69,10 @@ export type PopUpInstance = {
69
69
  * Indicates whether the PopUp is shown.
70
70
  */
71
71
  shown: boolean;
72
+ /**
73
+ * @internal Unique key that changes each time the instance is created/replaced.
74
+ */
75
+ key?: number;
72
76
  /**
73
77
  * The overlay content for the PopUp.
74
78
  */
@@ -248,6 +248,7 @@ class UIUtilProvider extends React.PureComponent {
248
248
  instances[id] = {
249
249
  options,
250
250
  shown: false,
251
+ key: Date.now(),
251
252
  handleClose: this.toggleModalInstance.bind(this),
252
253
  toggleOverlay: this.toggleModalOverlay.bind(this),
253
254
  };
@@ -6,5 +6,6 @@
6
6
  * @param enabled - Whether dragging is enabled.
7
7
  * @param shown - Current shown state; position resets when modal reopens.
8
8
  * @param modalClass - Unique CSS class on the modal to identify it.
9
+ * @param modalKey - When this value changes, drag position resets (e.g. when one modal replaces another).
9
10
  */
10
- export declare const useDraggable: (enabled: boolean, shown: boolean, modalClass: string) => void;
11
+ export declare const useDraggable: (enabled: boolean, shown: boolean, modalClass: string, modalKey: number) => void;
@@ -10,8 +10,9 @@ const React = require("react");
10
10
  * @param enabled - Whether dragging is enabled.
11
11
  * @param shown - Current shown state; position resets when modal reopens.
12
12
  * @param modalClass - Unique CSS class on the modal to identify it.
13
+ * @param modalKey - When this value changes, drag position resets (e.g. when one modal replaces another).
13
14
  */
14
- const useDraggable = (enabled, shown, modalClass) => {
15
+ const useDraggable = (enabled, shown, modalClass, modalKey) => {
15
16
  const cleanupRef = React.useRef(null);
16
17
  React.useEffect(() => {
17
18
  if (cleanupRef.current) {
@@ -69,6 +70,6 @@ const useDraggable = (enabled, shown, modalClass) => {
69
70
  cleanupRef.current = null;
70
71
  }
71
72
  };
72
- }, [enabled, shown, modalClass]);
73
+ }, [enabled, shown, modalClass, modalKey]);
73
74
  };
74
75
  exports.useDraggable = useDraggable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.86.0",
3
+ "version": "1.87.0",
4
4
  "description": "",
5
5
  "main": "dist/index",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "watch": "rimraf dist/ && tsc --watch",
10
10
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
11
11
  "update:version": "npm version minor --no-git-tag-version",
12
- "prepub:npm": "npm run format && npm run build && npm run update:version && npm run docs",
12
+ "prepub:npm": "npm run format && npm run build && npm run update:version",
13
13
  "publish:npm": "npm run prepub:npm && npm publish",
14
14
  "pack": "npm run build && npm pack --pack-destination pack/",
15
15
  "docs": "typedoc --options typedoc.json && cd test && npm run build:test && cp -r proddist ../htmldocs/demo",