@ioca/react 1.5.24 → 1.5.26

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.
@@ -459,7 +459,11 @@ function Popup(props) {
459
459
  if (!triggerEl || !contentEl)
460
460
  return;
461
461
  const tar = e.target;
462
- if (triggerEl.contains(tar) || contentEl.contains(tar))
462
+ if (contentEl.contains(tar))
463
+ return;
464
+ if (triggerEl.contains(tar) && latestRef.current.trigger !== "contextmenu")
465
+ return;
466
+ if (triggerEl.contains(tar) && e.button !== 0)
463
467
  return;
464
468
  doHide();
465
469
  };
@@ -9,7 +9,7 @@ import Item from './item.js';
9
9
  import TabsNavs from './navs.js';
10
10
 
11
11
  const Tabs = ((props) => {
12
- const { ref, active, tabs: items, type = "default", prepend, append, children, className, vertical, toggable, loader, navsJustify = "start", navsClass, bar = true, hideMore, barClass, renderMore = defaultRenderMore, onTabChange, ...rest } = props;
12
+ const { ref, active, tabs: items, type = "default", prepend, append, children, className, vertical, toggable, loader, navsJustify = "start", navsClass, bar = true, hideMore, barClass, renderMore = defaultRenderMore, onTabChange, onClose, ...rest } = props;
13
13
  const navRefs = useRef([]);
14
14
  const navsRef = useRef(null);
15
15
  const contentsRef = useRef(new Map());
@@ -84,6 +84,7 @@ const Tabs = ((props) => {
84
84
  const i = currentTabs.findIndex((t) => t.key === key);
85
85
  if (i < 0)
86
86
  return;
87
+ onClose?.(key);
87
88
  if (sourceKeysRef.current.has(key)) {
88
89
  hiddenSourceKeysRef.current.add(key);
89
90
  }
package/lib/index.js CHANGED
@@ -2305,7 +2305,11 @@ function Popup(props) {
2305
2305
  if (!triggerEl || !contentEl)
2306
2306
  return;
2307
2307
  const tar = e.target;
2308
- if (triggerEl.contains(tar) || contentEl.contains(tar))
2308
+ if (contentEl.contains(tar))
2309
+ return;
2310
+ if (triggerEl.contains(tar) && latestRef.current.trigger !== "contextmenu")
2311
+ return;
2312
+ if (triggerEl.contains(tar) && e.button !== 0)
2309
2313
  return;
2310
2314
  doHide();
2311
2315
  };
@@ -6084,7 +6088,7 @@ const TabsNavs = (props) => {
6084
6088
  var TabsNavs$1 = memo(TabsNavs);
6085
6089
 
6086
6090
  const Tabs = ((props) => {
6087
- const { ref, active, tabs: items, type = "default", prepend, append, children, className, vertical, toggable, loader, navsJustify = "start", navsClass, bar = true, hideMore, barClass, renderMore = defaultRenderMore, onTabChange, ...rest } = props;
6091
+ const { ref, active, tabs: items, type = "default", prepend, append, children, className, vertical, toggable, loader, navsJustify = "start", navsClass, bar = true, hideMore, barClass, renderMore = defaultRenderMore, onTabChange, onClose, ...rest } = props;
6088
6092
  const navRefs = useRef([]);
6089
6093
  const navsRef = useRef(null);
6090
6094
  const contentsRef = useRef(new Map());
@@ -6159,6 +6163,7 @@ const Tabs = ((props) => {
6159
6163
  const i = currentTabs.findIndex((t) => t.key === key);
6160
6164
  if (i < 0)
6161
6165
  return;
6166
+ onClose?.(key);
6162
6167
  if (sourceKeysRef.current.has(key)) {
6163
6168
  hiddenSourceKeysRef.current.add(key);
6164
6169
  }
@@ -32,6 +32,7 @@ interface ITabs {
32
32
  renderMore?: (moreTabs: ITabItem[]) => ReactNode;
33
33
  loader?: ReactNode;
34
34
  onTabChange?: (to?: string, from?: string) => void;
35
+ onClose?: (key: string) => void;
35
36
  }
36
37
  interface RefTabs {
37
38
  open: (key: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ioca/react",
3
- "version": "1.5.24",
3
+ "version": "1.5.26",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",