@irozon/design-system-react 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/Dialog.js +16 -0
  2. package/package.json +1 -1
package/dist/Dialog.js CHANGED
@@ -26,6 +26,22 @@ export function Dialog({ open, onClose, variant, className, children, ...rest })
26
26
  dialog.addEventListener("cancel", handleCancel);
27
27
  return () => dialog.removeEventListener("cancel", handleCancel);
28
28
  }, [onClose]);
29
+ useEffect(() => {
30
+ const dialog = ref.current;
31
+ if (!dialog)
32
+ return;
33
+ // Native <dialog> has no built-in click-outside-to-close: a click
34
+ // anywhere in the viewport bubbles to the dialog element itself
35
+ // (event.target === dialog) unless it landed on real content inside
36
+ // it, in which case the target is that content element instead — the
37
+ // standard idiom for detecting a backdrop click on this element.
38
+ const handleClick = (event) => {
39
+ if (event.target === dialog)
40
+ onClose();
41
+ };
42
+ dialog.addEventListener("click", handleClick);
43
+ return () => dialog.removeEventListener("click", handleClick);
44
+ }, [onClose]);
29
45
  return (_jsx("dialog", { ref: ref, className: cx("iz-dialog", className), "data-variant": variant, ...rest, children: children }));
30
46
  }
31
47
  export function DialogHeader({ children }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irozon/design-system-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Canonical React components for the Irozon Design System — thin, accessible wrappers over @irozon/design-system's framework-neutral iz-* CSS. No independent visual styling of its own; the CSS package stays the single source of truth for how these look.",
5
5
  "license": "MIT",
6
6
  "keywords": [