@kdcloudjs/kdesign 1.8.48 → 1.8.49

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/es/tabs/tabs.d.ts CHANGED
@@ -14,6 +14,7 @@ export interface ITabsProps {
14
14
  size?: TabsSize;
15
15
  style?: Record<string, unknown>;
16
16
  className?: string;
17
+ tabsDropdownClassName?: string;
17
18
  disabled?: boolean;
18
19
  noContainer?: boolean;
19
20
  showScrollArrow?: boolean;
@@ -25,6 +26,7 @@ export interface ITabsProps {
25
26
  onChange?: TabChangeEventHandler;
26
27
  getActiveLinePosition?: (left: number, width: number) => void;
27
28
  getTriggerKey?: (key: any) => void;
29
+ paneItemOperation?: boolean;
28
30
  }
29
31
  declare const Tabs: React.FC<ITabsProps>;
30
32
  export default Tabs;
package/es/tabs/tabs.js CHANGED
@@ -50,8 +50,10 @@ var Tabs = function Tabs(props) {
50
50
  showScrollArrow = tabsProps.showScrollArrow,
51
51
  _tabsProps$effect = tabsProps.effect,
52
52
  effect = _tabsProps$effect === void 0 ? 'none' : _tabsProps$effect,
53
+ tabsDropdownClassName = tabsProps.tabsDropdownClassName,
53
54
  children = tabsProps.children,
54
- onChange = tabsProps.onChange;
55
+ onChange = tabsProps.onChange,
56
+ needPanelOpration = tabsProps.needPanelOpration;
55
57
  var tabsPrefixCls = getPrefixCls(prefixCls, 'tabs', customPrefixcls);
56
58
  var rtlCls = direction === 'rtl' ? "".concat(tabsPrefixCls, "-rtl") : null;
57
59
  var activeKey;
@@ -94,6 +96,13 @@ var Tabs = function Tabs(props) {
94
96
  var tabRef = useRef(null);
95
97
  var tabListRef = useRef(null);
96
98
  var carouselRef = useRef(null);
99
+ var touchStartX = useRef(0);
100
+ var lastListPosition = useRef(0);
101
+ var isDragging = useRef(false);
102
+ var _useState15 = useState(false),
103
+ _useState16 = _slicedToArray(_useState15, 2),
104
+ triggerState = _useState16[0],
105
+ setTriggerState = _useState16[1];
97
106
  var handleActive = function handleActive(id, e) {
98
107
  setCurActiveKey(id);
99
108
  onChange && onChange(id, e);
@@ -105,6 +114,30 @@ var Tabs = function Tabs(props) {
105
114
  var getTriggerKey = function getTriggerKey(key) {
106
115
  setTriggerKey(key);
107
116
  };
117
+ var handleTouchStart = function handleTouchStart(e) {
118
+ if (ListWidth <= boxWidth) return;
119
+ touchStartX.current = e.touches[0].clientX;
120
+ lastListPosition.current = ListPostion;
121
+ isDragging.current = true;
122
+ };
123
+ var handleTouchMove = function handleTouchMove(e) {
124
+ if (!isDragging.current || ListWidth <= boxWidth) return;
125
+ var currentX = e.touches[0].clientX;
126
+ var deltaX = currentX - touchStartX.current;
127
+ var newPosition = lastListPosition.current + deltaX;
128
+ var maxLeft = 0;
129
+ var maxRight = boxWidth - ListWidth;
130
+ if (newPosition > maxLeft) newPosition = maxLeft;
131
+ if (newPosition < maxRight) newPosition = maxRight;
132
+ setListPosition(newPosition);
133
+ };
134
+ var handleTouchEnd = function handleTouchEnd() {
135
+ if (ListWidth <= boxWidth) return;
136
+ isDragging.current = false;
137
+ };
138
+ var handleVisibleChange = function handleVisibleChange(visible) {
139
+ setTriggerState(visible);
140
+ };
108
141
  useEffect(function () {
109
142
  setCurActiveKey(activeKey);
110
143
  }, [activeKey]);
@@ -204,20 +237,18 @@ var Tabs = function Tabs(props) {
204
237
  }));
205
238
  };
206
239
  var renderRightArrows = function renderRightArrows(nodes) {
207
- var _context6, _context7, _classNames4;
240
+ var _context6, _context7, _classNames4, _context8;
208
241
  if (ListWidth < boxWidth || !ListWidth || !boxWidth || _includesInstanceProperty(_context6 = ['left', 'right']).call(_context6, position)) return null;
209
242
  var rightClasses = classNames("".concat(tabsPrefixCls, "-right-arrows"), (_classNames4 = {}, _defineProperty(_classNames4, _concatInstanceProperty(_context7 = "".concat(tabsPrefixCls, "-right-arrows-")).call(_context7, type), type), _defineProperty(_classNames4, "".concat(tabsPrefixCls, "-right-arrows-noshadow"), ListWidth + ListPostion === boxWidth), _classNames4));
210
- var menu = _mapInstanceProperty(nodes).call(nodes, function (node) {
211
- var tmp = {
212
- label: '',
213
- key: 0,
214
- disabled: false
215
- };
216
- tmp.label = node.props.tab;
217
- tmp.key = node.props.id;
218
- tmp.disabled = node.props.disabled;
219
- return tmp;
220
- });
243
+ var menu = React.createElement(Dropdown.Menu, {
244
+ className: classNames(tabsDropdownClassName, _defineProperty({}, "".concat(tabsPrefixCls, "-right-arrows-menu"), needPanelOpration))
245
+ }, _mapInstanceProperty(nodes).call(nodes, function (node) {
246
+ return React.createElement(Dropdown.Item, {
247
+ key: node.props.id,
248
+ disabled: node.props.disabled,
249
+ className: node.props.id === curActiveKey ? "".concat(tabsPrefixCls, "-right-arrows-menu-active") : undefined
250
+ }, React.createElement("span", null, node.props.tab));
251
+ }));
221
252
  var handleRight = function handleRight() {
222
253
  if (ListPostion === boxWidth - ListWidth) return;
223
254
  var offset = ListPostion - boxWidth > boxWidth - ListWidth ? ListPostion - boxWidth : boxWidth - ListWidth;
@@ -248,9 +279,10 @@ var Tabs = function Tabs(props) {
248
279
  }) : null, React.createElement(Dropdown, {
249
280
  menu: menu,
250
281
  trigger: ['click'],
251
- onItemClick: handleSelectItem
282
+ onItemClick: handleSelectItem,
283
+ onVisibleChange: handleVisibleChange
252
284
  }, React.createElement("span", {
253
- className: "".concat(tabsPrefixCls, "-more-btn")
285
+ className: classNames("".concat(tabsPrefixCls, "-more-btn"), _concatInstanceProperty(_context8 = "".concat(tabsPrefixCls, "-trigger-")).call(_context8, triggerState))
254
286
  }, React.createElement(Icon, {
255
287
  type: "arrow-down"
256
288
  }))));
@@ -341,7 +373,13 @@ var Tabs = function Tabs(props) {
341
373
  }, renderWrap);
342
374
  };
343
375
  return React.createElement("div", _extends({}, omit(tabsProps, ['activeKey', 'defaultActiveKey', 'showScrollArrow', 'noContainer']), {
344
- className: tabNavsClasses
376
+ className: tabNavsClasses,
377
+ onTouchStart: handleTouchStart,
378
+ onTouchMove: handleTouchMove,
379
+ onTouchEnd: handleTouchEnd,
380
+ style: {
381
+ touchAction: 'pan-y'
382
+ }
345
383
  }), renderLeftOperations(), renderLeftArrow(), React.createElement("div", {
346
384
  ref: tabRef,
347
385
  className: "".concat(tabsPrefixCls, "-tab-wrap")
@@ -14,6 +14,7 @@ export interface ITabsProps {
14
14
  size?: TabsSize;
15
15
  style?: Record<string, unknown>;
16
16
  className?: string;
17
+ tabsDropdownClassName?: string;
17
18
  disabled?: boolean;
18
19
  noContainer?: boolean;
19
20
  showScrollArrow?: boolean;
@@ -25,6 +26,7 @@ export interface ITabsProps {
25
26
  onChange?: TabChangeEventHandler;
26
27
  getActiveLinePosition?: (left: number, width: number) => void;
27
28
  getTriggerKey?: (key: any) => void;
29
+ paneItemOperation?: boolean;
28
30
  }
29
31
  declare const Tabs: React.FC<ITabsProps>;
30
32
  export default Tabs;
package/lib/tabs/tabs.js CHANGED
@@ -18,7 +18,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/hel
18
18
  var _react = _interopRequireWildcard(require("react"));
19
19
  var _classnames = _interopRequireDefault(require("classnames"));
20
20
  var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));
21
- var _context8 = require("./context");
21
+ var _context9 = require("./context");
22
22
  var _utils = require("../_utils");
23
23
  var _omit = require("../_utils/omit");
24
24
  var _type = require("../_utils/type");
@@ -66,8 +66,10 @@ var Tabs = function Tabs(props) {
66
66
  showScrollArrow = tabsProps.showScrollArrow,
67
67
  _tabsProps$effect = tabsProps.effect,
68
68
  effect = _tabsProps$effect === void 0 ? 'none' : _tabsProps$effect,
69
+ tabsDropdownClassName = tabsProps.tabsDropdownClassName,
69
70
  children = tabsProps.children,
70
- onChange = tabsProps.onChange;
71
+ onChange = tabsProps.onChange,
72
+ needPanelOpration = tabsProps.needPanelOpration;
71
73
  var tabsPrefixCls = getPrefixCls(prefixCls, 'tabs', customPrefixcls);
72
74
  var rtlCls = direction === 'rtl' ? "".concat(tabsPrefixCls, "-rtl") : null;
73
75
  var activeKey;
@@ -110,6 +112,13 @@ var Tabs = function Tabs(props) {
110
112
  var tabRef = (0, _react.useRef)(null);
111
113
  var tabListRef = (0, _react.useRef)(null);
112
114
  var carouselRef = (0, _react.useRef)(null);
115
+ var touchStartX = (0, _react.useRef)(0);
116
+ var lastListPosition = (0, _react.useRef)(0);
117
+ var isDragging = (0, _react.useRef)(false);
118
+ var _useState15 = (0, _react.useState)(false),
119
+ _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
120
+ triggerState = _useState16[0],
121
+ setTriggerState = _useState16[1];
113
122
  var handleActive = function handleActive(id, e) {
114
123
  setCurActiveKey(id);
115
124
  onChange && onChange(id, e);
@@ -121,6 +130,30 @@ var Tabs = function Tabs(props) {
121
130
  var getTriggerKey = function getTriggerKey(key) {
122
131
  setTriggerKey(key);
123
132
  };
133
+ var handleTouchStart = function handleTouchStart(e) {
134
+ if (ListWidth <= boxWidth) return;
135
+ touchStartX.current = e.touches[0].clientX;
136
+ lastListPosition.current = ListPostion;
137
+ isDragging.current = true;
138
+ };
139
+ var handleTouchMove = function handleTouchMove(e) {
140
+ if (!isDragging.current || ListWidth <= boxWidth) return;
141
+ var currentX = e.touches[0].clientX;
142
+ var deltaX = currentX - touchStartX.current;
143
+ var newPosition = lastListPosition.current + deltaX;
144
+ var maxLeft = 0;
145
+ var maxRight = boxWidth - ListWidth;
146
+ if (newPosition > maxLeft) newPosition = maxLeft;
147
+ if (newPosition < maxRight) newPosition = maxRight;
148
+ setListPosition(newPosition);
149
+ };
150
+ var handleTouchEnd = function handleTouchEnd() {
151
+ if (ListWidth <= boxWidth) return;
152
+ isDragging.current = false;
153
+ };
154
+ var handleVisibleChange = function handleVisibleChange(visible) {
155
+ setTriggerState(visible);
156
+ };
124
157
  (0, _react.useEffect)(function () {
125
158
  setCurActiveKey(activeKey);
126
159
  }, [activeKey]);
@@ -220,20 +253,18 @@ var Tabs = function Tabs(props) {
220
253
  }));
221
254
  };
222
255
  var renderRightArrows = function renderRightArrows(nodes) {
223
- var _context6, _context7, _classNames4;
256
+ var _context6, _context7, _classNames4, _context8;
224
257
  if (ListWidth < boxWidth || !ListWidth || !boxWidth || (0, _includes.default)(_context6 = ['left', 'right']).call(_context6, position)) return null;
225
258
  var rightClasses = (0, _classnames.default)("".concat(tabsPrefixCls, "-right-arrows"), (_classNames4 = {}, (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context7 = "".concat(tabsPrefixCls, "-right-arrows-")).call(_context7, type), type), (0, _defineProperty2.default)(_classNames4, "".concat(tabsPrefixCls, "-right-arrows-noshadow"), ListWidth + ListPostion === boxWidth), _classNames4));
226
- var menu = (0, _map.default)(nodes).call(nodes, function (node) {
227
- var tmp = {
228
- label: '',
229
- key: 0,
230
- disabled: false
231
- };
232
- tmp.label = node.props.tab;
233
- tmp.key = node.props.id;
234
- tmp.disabled = node.props.disabled;
235
- return tmp;
236
- });
259
+ var menu = _react.default.createElement(_dropdown.default.Menu, {
260
+ className: (0, _classnames.default)(tabsDropdownClassName, (0, _defineProperty2.default)({}, "".concat(tabsPrefixCls, "-right-arrows-menu"), needPanelOpration))
261
+ }, (0, _map.default)(nodes).call(nodes, function (node) {
262
+ return _react.default.createElement(_dropdown.default.Item, {
263
+ key: node.props.id,
264
+ disabled: node.props.disabled,
265
+ className: node.props.id === curActiveKey ? "".concat(tabsPrefixCls, "-right-arrows-menu-active") : undefined
266
+ }, _react.default.createElement("span", null, node.props.tab));
267
+ }));
237
268
  var handleRight = function handleRight() {
238
269
  if (ListPostion === boxWidth - ListWidth) return;
239
270
  var offset = ListPostion - boxWidth > boxWidth - ListWidth ? ListPostion - boxWidth : boxWidth - ListWidth;
@@ -264,9 +295,10 @@ var Tabs = function Tabs(props) {
264
295
  }) : null, _react.default.createElement(_dropdown.default, {
265
296
  menu: menu,
266
297
  trigger: ['click'],
267
- onItemClick: handleSelectItem
298
+ onItemClick: handleSelectItem,
299
+ onVisibleChange: handleVisibleChange
268
300
  }, _react.default.createElement("span", {
269
- className: "".concat(tabsPrefixCls, "-more-btn")
301
+ className: (0, _classnames.default)("".concat(tabsPrefixCls, "-more-btn"), (0, _concat.default)(_context8 = "".concat(tabsPrefixCls, "-trigger-")).call(_context8, triggerState))
270
302
  }, _react.default.createElement(_icon.default, {
271
303
  type: "arrow-down"
272
304
  }))));
@@ -357,7 +389,13 @@ var Tabs = function Tabs(props) {
357
389
  }, renderWrap);
358
390
  };
359
391
  return _react.default.createElement("div", (0, _extends2.default)({}, (0, _omit.omit)(tabsProps, ['activeKey', 'defaultActiveKey', 'showScrollArrow', 'noContainer']), {
360
- className: tabNavsClasses
392
+ className: tabNavsClasses,
393
+ onTouchStart: handleTouchStart,
394
+ onTouchMove: handleTouchMove,
395
+ onTouchEnd: handleTouchEnd,
396
+ style: {
397
+ touchAction: 'pan-y'
398
+ }
361
399
  }), renderLeftOperations(), renderLeftArrow(), _react.default.createElement("div", {
362
400
  ref: tabRef,
363
401
  className: "".concat(tabsPrefixCls, "-tab-wrap")
@@ -390,7 +428,7 @@ var Tabs = function Tabs(props) {
390
428
  }, item.content);
391
429
  }));
392
430
  };
393
- return _react.default.createElement(_context8.TabsContextProvider, {
431
+ return _react.default.createElement(_context9.TabsContextProvider, {
394
432
  value: {
395
433
  type: type,
396
434
  size: size,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.8.48",
3
+ "version": "1.8.49",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [