@tabula/ui-menu
Advanced tools
Comparing version 1.0.0-next.1 to 1.0.0-next.2
@@ -24,2 +24,3 @@ // src/UiMenu/UiMenu.tsx | ||
import clsx from "clsx"; | ||
import { stopEvent } from "@tabula/dom-utils"; | ||
@@ -30,29 +31,2 @@ // src/Divider/Divider.css.ts | ||
// src/helpers.ts | ||
function stopEvent(event) { | ||
const options = event.currentTarget.dataset; | ||
if (options.stopPropagation) { | ||
event.stopPropagation(); | ||
} | ||
if (options.preventDefault) { | ||
event.preventDefault(); | ||
} | ||
} | ||
function isClickByButton(event) { | ||
if (!(event.target instanceof Element)) { | ||
throw new TypeError("Target must be an Element"); | ||
} | ||
let current = event.target; | ||
while (current !== event.currentTarget) { | ||
if (current == null) { | ||
return false; | ||
} | ||
if (current.tagName === "BUTTON") { | ||
return true; | ||
} | ||
current = current.parentElement; | ||
} | ||
return false; | ||
} | ||
// src/Divider/Divider.tsx | ||
@@ -71,2 +45,3 @@ import { jsx as jsx2 } from "react/jsx-runtime"; | ||
import clsx3 from "clsx"; | ||
import { stopEvent as stopEvent2 } from "@tabula/dom-utils"; | ||
@@ -127,3 +102,3 @@ // src/Item/Item.css.ts | ||
(event) => { | ||
stopEvent(event); | ||
stopEvent2(event); | ||
if (onSelect != null) { | ||
@@ -195,2 +170,3 @@ onSelect(id); | ||
} from "@floating-ui/react"; | ||
import { isButtonTarget } from "@tabula/dom-utils"; | ||
import { useFlag } from "@tabula/use-flag"; | ||
@@ -239,3 +215,3 @@ import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime"; | ||
(event) => { | ||
if (isClickByButton(event)) { | ||
if (isButtonTarget(event)) { | ||
onClose(); | ||
@@ -242,0 +218,0 @@ } |
{ | ||
"name": "@tabula/ui-menu", | ||
"version": "1.0.0-next.1", | ||
"version": "1.0.0-next.2", | ||
"description": "Menus display a list of actions or options that a user can choose", | ||
@@ -49,2 +49,3 @@ "type": "module", | ||
"clsx": "^2.1.0", | ||
"@tabula/dom-utils": "^0.1.0-next.0", | ||
"@tabula/use-flag": "^0.1.0-next.0" | ||
@@ -51,0 +52,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54193
6
26
618
+ Added@tabula/dom-utils@0.1.0(transitive)