@xfe-repo/web-components 1.7.6 → 1.8.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.
package/dist/index.js CHANGED
@@ -947,6 +947,11 @@ var import_modifiers = require("@dnd-kit/modifiers");
947
947
  var import_utilities = require("@dnd-kit/utilities");
948
948
  var import_jsx_runtime4 = require("react/jsx-runtime");
949
949
  var import_react5 = require("react");
950
+ var getMiddleClickCloseTargetKey = function getMiddleClickCloseTargetKey(event, data) {
951
+ if (event.button !== 1) return void 0;
952
+ if (!data || data.disabled || data.closable === false) return void 0;
953
+ return data.key;
954
+ };
950
955
  var MultiWindowTabs = (0, import_react4.memo)(function(props) {
951
956
  var pathKey = props.pathKey, pagePaths = props.pagePaths, className = props.className, onChange = props.onChange, onClose = props.onClose, onSort = props.onSort, onCollectionChange = props.onCollectionChange, sortAutoActive = props.sortAutoActive;
952
957
  var sensor = (0, import_core.useSensor)(import_core.PointerSensor, {
@@ -1022,6 +1027,7 @@ var MultiWindowTabs = (0, import_react4.memo)(function(props) {
1022
1027
  key: node.key,
1023
1028
  data: pagePathsHelperData.map.get(String(node.key)),
1024
1029
  onCollectionChange: onCollectionChange,
1030
+ onClose: onClose,
1025
1031
  isActivated: pathKey === String(node.key)
1026
1032
  }), node);
1027
1033
  }
@@ -1033,6 +1039,8 @@ var MultiWindowTabs = (0, import_react4.memo)(function(props) {
1033
1039
  onDragStart,
1034
1040
  onDragEnd,
1035
1041
  onCollectionChange,
1042
+ onClose,
1043
+ pathKey,
1036
1044
  sensor
1037
1045
  ]);
1038
1046
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Tabs, {
@@ -1048,15 +1056,26 @@ var MultiWindowTabs = (0, import_react4.memo)(function(props) {
1048
1056
  });
1049
1057
  });
1050
1058
  var TabItem = (0, import_react4.memo)(function(props) {
1051
- var data = props.data, children = props.children, style = props.style, isActivated = props.isActivated, onCollectionChange = props.onCollectionChange;
1059
+ var data = props.data, children = props.children, style = props.style, isActivated = props.isActivated, onCollectionChange = props.onCollectionChange, onClose = props.onClose;
1052
1060
  var _ref = (0, import_sortable.useSortable)({
1053
1061
  id: props["data-node-key"]
1054
1062
  }), attributes = _ref.attributes, listeners = _ref.listeners, setNodeRef = _ref.setNodeRef, transform = _ref.transform, transition = _ref.transition, isDragging = _ref.isDragging;
1063
+ var handleAuxClick = (0, import_react4.useCallback)(function(event) {
1064
+ var targetKey = getMiddleClickCloseTargetKey(event, data);
1065
+ if (!targetKey) return;
1066
+ event.preventDefault();
1067
+ event.stopPropagation();
1068
+ onClose === null || onClose === void 0 ? void 0 : onClose(targetKey);
1069
+ }, [
1070
+ data,
1071
+ onClose
1072
+ ]);
1055
1073
  var handleCollectionChange = (0, import_react4.useCallback)(function(collectionKey) {
1056
1074
  if (!data) return;
1057
1075
  onCollectionChange === null || onCollectionChange === void 0 ? void 0 : onCollectionChange(data.key, collectionKey);
1058
1076
  }, [
1059
- data
1077
+ data,
1078
+ onCollectionChange
1060
1079
  ]);
1061
1080
  var collectionSelect = (0, import_react4.useMemo)(function() {
1062
1081
  var _data_searchCollection;
@@ -1093,7 +1112,7 @@ var TabItem = (0, import_react4.memo)(function(props) {
1093
1112
  children,
1094
1113
  collectionSelect
1095
1114
  ]);
1096
- return import_react4.default.cloneElement(children, _object_spread({
1115
+ return import_react4.default.cloneElement(children, _object_spread_props(_object_spread({
1097
1116
  ref: setNodeRef,
1098
1117
  style: _object_spread_props(_object_spread({}, style), {
1099
1118
  transform: import_utilities.CSS.Translate.toString(transform && _object_spread_props(_object_spread({}, transform), {
@@ -1104,7 +1123,9 @@ var TabItem = (0, import_react4.memo)(function(props) {
1104
1123
  cursor: "pointer"
1105
1124
  }),
1106
1125
  children: childrenWithCollectionSelect
1107
- }, attributes, listeners));
1126
+ }, attributes, listeners), {
1127
+ onAuxClick: handleAuxClick
1128
+ }));
1108
1129
  });
1109
1130
  // src/MultiWindow/MultiWindow.tsx
1110
1131
  var import_jsx_runtime5 = require("react/jsx-runtime");
package/dist/index.mjs CHANGED
@@ -653,6 +653,11 @@ import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
653
653
  import { CSS } from "@dnd-kit/utilities";
654
654
  import { jsx as jsx4 } from "react/jsx-runtime";
655
655
  import { createElement } from "react";
656
+ var getMiddleClickCloseTargetKey = function getMiddleClickCloseTargetKey(event, data) {
657
+ if (event.button !== 1) return void 0;
658
+ if (!data || data.disabled || data.closable === false) return void 0;
659
+ return data.key;
660
+ };
656
661
  var MultiWindowTabs = memo3(function(props) {
657
662
  var pathKey = props.pathKey, pagePaths = props.pagePaths, className = props.className, onChange = props.onChange, onClose = props.onClose, onSort = props.onSort, onCollectionChange = props.onCollectionChange, sortAutoActive = props.sortAutoActive;
658
663
  var sensor = useSensor(PointerSensor, {
@@ -728,6 +733,7 @@ var MultiWindowTabs = memo3(function(props) {
728
733
  key: node.key,
729
734
  data: pagePathsHelperData.map.get(String(node.key)),
730
735
  onCollectionChange: onCollectionChange,
736
+ onClose: onClose,
731
737
  isActivated: pathKey === String(node.key)
732
738
  }), node);
733
739
  }
@@ -739,6 +745,8 @@ var MultiWindowTabs = memo3(function(props) {
739
745
  onDragStart,
740
746
  onDragEnd,
741
747
  onCollectionChange,
748
+ onClose,
749
+ pathKey,
742
750
  sensor
743
751
  ]);
744
752
  return /* @__PURE__ */ jsx4(Tabs, {
@@ -754,15 +762,26 @@ var MultiWindowTabs = memo3(function(props) {
754
762
  });
755
763
  });
756
764
  var TabItem = memo3(function(props) {
757
- var data = props.data, children = props.children, style = props.style, isActivated = props.isActivated, onCollectionChange = props.onCollectionChange;
765
+ var data = props.data, children = props.children, style = props.style, isActivated = props.isActivated, onCollectionChange = props.onCollectionChange, onClose = props.onClose;
758
766
  var _useSortable = useSortable({
759
767
  id: props["data-node-key"]
760
768
  }), attributes = _useSortable.attributes, listeners = _useSortable.listeners, setNodeRef = _useSortable.setNodeRef, transform = _useSortable.transform, transition = _useSortable.transition, isDragging = _useSortable.isDragging;
769
+ var handleAuxClick = useCallback2(function(event) {
770
+ var targetKey = getMiddleClickCloseTargetKey(event, data);
771
+ if (!targetKey) return;
772
+ event.preventDefault();
773
+ event.stopPropagation();
774
+ onClose === null || onClose === void 0 ? void 0 : onClose(targetKey);
775
+ }, [
776
+ data,
777
+ onClose
778
+ ]);
761
779
  var handleCollectionChange = useCallback2(function(collectionKey) {
762
780
  if (!data) return;
763
781
  onCollectionChange === null || onCollectionChange === void 0 ? void 0 : onCollectionChange(data.key, collectionKey);
764
782
  }, [
765
- data
783
+ data,
784
+ onCollectionChange
766
785
  ]);
767
786
  var collectionSelect = useMemo3(function() {
768
787
  var _data_searchCollection;
@@ -799,7 +818,7 @@ var TabItem = memo3(function(props) {
799
818
  children,
800
819
  collectionSelect
801
820
  ]);
802
- return React3.cloneElement(children, _object_spread({
821
+ return React3.cloneElement(children, _object_spread_props(_object_spread({
803
822
  ref: setNodeRef,
804
823
  style: _object_spread_props(_object_spread({}, style), {
805
824
  transform: CSS.Translate.toString(transform && _object_spread_props(_object_spread({}, transform), {
@@ -810,7 +829,9 @@ var TabItem = memo3(function(props) {
810
829
  cursor: "pointer"
811
830
  }),
812
831
  children: childrenWithCollectionSelect
813
- }, attributes, listeners));
832
+ }, attributes, listeners), {
833
+ onAuxClick: handleAuxClick
834
+ }));
814
835
  });
815
836
  // src/MultiWindow/MultiWindow.tsx
816
837
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-components",
3
- "version": "1.7.6",
3
+ "version": "1.8.0",
4
4
  "module": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": [
@@ -51,6 +51,7 @@
51
51
  "@types/react": "^18",
52
52
  "esbuild-plugin-less": "^1.3.9",
53
53
  "eslint": "8.57.1",
54
+ "vitest": "^4.0.14",
54
55
  "@xfe-repo/eslint-config": "1.6.0",
55
56
  "@xfe-repo/typescript-config": "1.6.1"
56
57
  },
@@ -62,9 +63,9 @@
62
63
  "react-dom": "18.2.0",
63
64
  "react-use": "^17.5.1",
64
65
  "swr": "^2.2.5",
65
- "@xfe-repo/web-service": "1.6.0",
66
66
  "@xfe-repo/web-micro": "1.7.0",
67
67
  "@xfe-repo/web-router": "1.6.1",
68
+ "@xfe-repo/web-service": "1.6.0",
68
69
  "@xfe-repo/web-utils": "1.6.0"
69
70
  },
70
71
  "publishConfig": {
@@ -74,6 +75,7 @@
74
75
  "build": "tsup",
75
76
  "dev": "tsup --watch",
76
77
  "lint": "eslint \"src/**/*.ts*\" --fix",
78
+ "test": "vitest run",
77
79
  "clean": "rm -rf .turbo coverage dist node_modules"
78
80
  }
79
81
  }