@chaoswise/ui 2.3.4 → 2.3.5

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.
@@ -125,9 +125,10 @@ export var echoRecentlyTimeTitle = function echoRecentlyTimeTitle(locale, captur
125
125
  };
126
126
  export var echoAbsoluteTimeTitle = function echoAbsoluteTimeTitle(value, format) {
127
127
  var hasTimeSpan = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
128
+ var timeSpanBoundary = arguments.length > 3 ? arguments[3] : undefined;
128
129
  var formatDate1 = value[0].format(format);
129
130
  var formatDate2 = value[1].format(format);
130
- var finalEchoValue = computeTimeSpan(value) && hasTimeSpan ? "[".concat(computeTimeSpan(value), "] ").concat(formatDate1, " - ").concat(formatDate2) : "".concat(formatDate1, " - ").concat(formatDate2);
131
+ var finalEchoValue = computeTimeSpan(value, timeSpanBoundary) && hasTimeSpan ? "[".concat(computeTimeSpan(value, timeSpanBoundary), "] ").concat(formatDate1, " - ").concat(formatDate2) : "".concat(formatDate1, " - ").concat(formatDate2);
131
132
  return finalEchoValue;
132
133
  };
133
134
  // 根据时间类型输入框按照格式回显
@@ -138,6 +139,7 @@ export var echoInputValue = function echoInputValue() {
138
139
  var format = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "YYYY/MM/DD HH:mm:ss";
139
140
  var forceRenderTitle = arguments.length > 4 ? arguments[4] : undefined;
140
141
  var isAutoRefresh = arguments.length > 5 ? arguments[5] : undefined;
142
+ var timeSpanBoundary = arguments.length > 6 ? arguments[6] : undefined;
141
143
  var values = recordDateValue.value,
142
144
  title = recordDateValue.title;
143
145
  var _judgeType = judgeType(recordDateValue),
@@ -156,7 +158,7 @@ export var echoInputValue = function echoInputValue() {
156
158
  return echoRecentlyTimeTitle(locale, captureUnit);
157
159
  }
158
160
  if (Array.isArray(value) && (_value2 = value) !== null && _value2 !== void 0 && _value2.length) {
159
- return echoAbsoluteTimeTitle(value, format);
161
+ return echoAbsoluteTimeTitle(value, format, true, timeSpanBoundary);
160
162
  }
161
163
  return "";
162
164
  }
@@ -170,7 +172,7 @@ export var echoInputValue = function echoInputValue() {
170
172
  return echoRecentlyTimeTitle(locale, captureUnit);
171
173
  }
172
174
  if (Array.isArray(value) && (_value3 = value) !== null && _value3 !== void 0 && _value3.length) {
173
- return echoAbsoluteTimeTitle(value, format);
175
+ return echoAbsoluteTimeTitle(value, format, true, timeSpanBoundary);
174
176
  }
175
177
  } else {
176
178
  var _value4;
@@ -181,31 +183,29 @@ export var echoInputValue = function echoInputValue() {
181
183
  return echoRecentlyTimeTitle(locale, captureUnit);
182
184
  }
183
185
  if (Array.isArray(value) && (_value4 = value) !== null && _value4 !== void 0 && _value4.length) {
184
- return echoAbsoluteTimeTitle(value, format);
186
+ return echoAbsoluteTimeTitle(value, format, true, timeSpanBoundary);
185
187
  }
186
188
  }
187
189
  };
188
190
 
189
191
  // 计算两个moment日期的时间差(时间戳)
190
192
  export var computeTimeDiff = function computeTimeDiff(value) {
191
- return value[1].diff(value[0]);
193
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ms";
194
+ return value[1].diff(value[0], unit);
195
+ };
196
+ export var getYears = function getYears(seconds) {
197
+ var yearInSeconds = 31536000; // 一年有 365 天 * 24 小时 * 60 分钟 * 60 秒 = 31536000 秒
198
+ var years = Math.floor(seconds / yearInSeconds);
199
+ return years;
192
200
  };
193
-
194
201
  // 计算输入框时间跨度
195
- export var computeTimeSpan = function computeTimeSpan(value) {
196
- var getMilliseconds0 = moment(value[0].milliseconds())._i;
197
- var getMilliseconds1 = moment(value[1].milliseconds())._i;
202
+ export var computeTimeSpan = function computeTimeSpan(value, timeSpanBoundary) {
198
203
  // 当前传入日期的时间
199
- var timeDiff = computeTimeDiff(value);
200
- if (getMilliseconds0 > getMilliseconds1) {
201
- // 特殊情况处理忽略掉毫秒级别的变化影响时间跨度取值
202
- var diffMilliseconds = getMilliseconds0 - getMilliseconds1;
203
- timeDiff = Number(timeDiff + diffMilliseconds);
204
+ var timeDiff = computeTimeDiff(value, "s");
205
+ if (timeDiff >= 60) {
206
+ timeDiff = Number(timeDiff + 1);
204
207
  }
205
- if (timeDiff >= 60000) {
206
- timeDiff = Number(timeDiff + 1000);
207
- }
208
- var duration = moment.duration(timeDiff);
208
+ var duration = moment.duration(timeDiff, "s");
209
209
  var _duration$_data = duration._data,
210
210
  years = _duration$_data.years,
211
211
  months = _duration$_data.months,
@@ -213,7 +213,13 @@ export var computeTimeSpan = function computeTimeSpan(value) {
213
213
  hours = _duration$_data.hours,
214
214
  minutes = _duration$_data.minutes,
215
215
  seconds = _duration$_data.seconds;
216
- if (years) return "".concat(years, "y");
216
+ if (years) {
217
+ // todo:目前只处理了边界为年的跨度
218
+ if (timeDiff >= timeSpanBoundary) {
219
+ return "".concat(getYears(timeSpanBoundary), "y");
220
+ }
221
+ return "".concat(years, "y");
222
+ }
217
223
  if (months) return "".concat(months, "mo");
218
224
  if (days) return "".concat(days, "d");
219
225
  if (hours) return "".concat(hours, "h");
@@ -227,8 +233,8 @@ export var computeTimeSpan = function computeTimeSpan(value) {
227
233
  * @param {*} value date日期
228
234
  * @returns 根据日期获取时间跨度,最近时间返回内容
229
235
  */
230
- export var getTimeSpanFromValue = function getTimeSpanFromValue(value) {
231
- var timeDomain = computeTimeSpan(value);
236
+ export var getTimeSpanFromValue = function getTimeSpanFromValue(value, timeSpanBoundary) {
237
+ var timeDomain = computeTimeSpan(value, timeSpanBoundary);
232
238
  var _getUnit3 = getUnit(timeDomain),
233
239
  captureUnit = _getUnit3.captureUnit;
234
240
  return {
@@ -257,10 +263,10 @@ export var computedRecentlyValue = function computedRecentlyValue(value) {
257
263
  *
258
264
  * @returns 根据当前克隆时间返回变化之后的时间
259
265
  */
260
- export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate_1, direction, growSize, duration) {
266
+ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate_1, direction, growSize, duration, timeSpanBoundary) {
261
267
  var cloneCurrentDate_0 = currentDate_0.clone();
262
268
  var cloneCurrentDate_1 = currentDate_1.clone();
263
- // 是否回到初始值
269
+ // 是否切换到最近时间
264
270
  var switchInitial = false;
265
271
  if (direction == "left") {
266
272
  cloneCurrentDate_0.subtract(duration);
@@ -279,13 +285,34 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
279
285
  } else {
280
286
  cloneCurrentDate_0.subtract(duration * ((growSize - 1) / 2));
281
287
  cloneCurrentDate_1.add(duration * ((growSize - 1) / 2));
288
+ // 先要计算二者的时间跨度
289
+ var isExceedMaxTime = isExceedMaxTimeSpan([cloneCurrentDate_0, cloneCurrentDate_1], timeSpanBoundary);
282
290
  // 计算最大值的时间差
283
291
  var _maxTimeDiff = computeTimeDiff([cloneCurrentDate_1, moment()]);
284
- if (_maxTimeDiff <= 0) {
285
- switchInitial = true;
286
- var _finalValue = computedRecentlyValue([cloneCurrentDate_0, cloneCurrentDate_1]);
287
- cloneCurrentDate_0 = _finalValue[0];
288
- cloneCurrentDate_1 = _finalValue[1];
292
+ if (isExceedMaxTime) {
293
+ if (_maxTimeDiff <= 0) {
294
+ // 当前时间已经是极限了
295
+ // 已经是极限直接当前时间向前推进timeSpanBoundary即可
296
+ cloneCurrentDate_0 = moment().subtract(moment.duration(timeSpanBoundary, "s"));
297
+ cloneCurrentDate_1 = moment();
298
+ switchInitial = true;
299
+ } else {
300
+ // 非极限时间,但是超过最大的时间边界跨度
301
+ // 先将currentDate_0和currentDate_1二者进行相减在这个基础上增加(timeSpanBoundary - 二者相减) / 2 ,左右各增加减少这个数值
302
+ var initialTimeDiff = computeTimeDiff([cloneCurrentDate_0, cloneCurrentDate_1], "s");
303
+ var needChangeTimeDiff = Math.ceil(initialTimeDiff - timeSpanBoundary) / 2;
304
+ var clone0 = currentDate_0.clone();
305
+ var clone1 = currentDate_1.clone();
306
+ cloneCurrentDate_0 = clone0.subtract(moment.duration(needChangeTimeDiff, "s"));
307
+ cloneCurrentDate_1 = clone1.add(moment.duration(needChangeTimeDiff, "s"));
308
+ }
309
+ } else {
310
+ if (_maxTimeDiff <= 0) {
311
+ switchInitial = true;
312
+ var _finalValue = computedRecentlyValue([cloneCurrentDate_0, cloneCurrentDate_1]);
313
+ cloneCurrentDate_0 = _finalValue[0];
314
+ cloneCurrentDate_1 = _finalValue[1];
315
+ }
289
316
  }
290
317
  }
291
318
  return {
@@ -319,6 +346,7 @@ export var getChangeUnitDate = function getChangeUnitDate(unitFigure, unit) {
319
346
  */
320
347
  export var getChangeDate = function getChangeDate(recordDateValue, direction) {
321
348
  var growSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
349
+ var timeSpanBoundary = arguments.length > 3 ? arguments[3] : undefined;
322
350
  var key = recordDateValue.key,
323
351
  values = recordDateValue.value;
324
352
  var _getUnit4 = getUnit(key),
@@ -328,12 +356,12 @@ export var getChangeDate = function getChangeDate(recordDateValue, direction) {
328
356
  if (values) {
329
357
  value = funcValueChangeArrayValue(values);
330
358
  }
331
- if (isRule) {
359
+ if (isRule && !values) {
332
360
  value = getChangeUnitDate(captureUnit[0], ENUM_TimeUnit[captureUnit[1]][3]);
333
361
  }
334
362
  var timeDiff = value[1].diff(value[0]);
335
363
  var duration = moment.duration(timeDiff);
336
- var _cloneChangeDate = cloneChangeDate(value[0], value[1], direction, growSize, duration),
364
+ var _cloneChangeDate = cloneChangeDate(value[0], value[1], direction, growSize, duration, timeSpanBoundary),
337
365
  _value = _cloneChangeDate.value,
338
366
  switchInitial = _cloneChangeDate.switchInitial;
339
367
  var returnValue = {
@@ -341,7 +369,7 @@ export var getChangeDate = function getChangeDate(recordDateValue, direction) {
341
369
  isRecently: false
342
370
  };
343
371
  if (switchInitial) {
344
- returnValue = _objectSpread(_objectSpread(_objectSpread({}, returnValue), getTimeSpanFromValue(_value)), {}, {
372
+ returnValue = _objectSpread(_objectSpread(_objectSpread({}, returnValue), getTimeSpanFromValue(_value, timeSpanBoundary)), {}, {
345
373
  isRecently: true
346
374
  });
347
375
  }
@@ -410,7 +438,7 @@ export var getCorrectValue = function getCorrectValue(value) {
410
438
  * @param {Object} value
411
439
  * @returns
412
440
  */
413
- export var getHistoryInfo = function getHistoryInfo(recordValue, historyList, locale, format) {
441
+ export var getHistoryInfo = function getHistoryInfo(recordValue, historyList, locale, format, timeSpanBoundary) {
414
442
  var key = recordValue.key,
415
443
  value = recordValue.value,
416
444
  _recordValue$title = recordValue.title,
@@ -422,7 +450,7 @@ export var getHistoryInfo = function getHistoryInfo(recordValue, historyList, lo
422
450
  var values = funcValueChangeArrayValue(value);
423
451
  var _title = title;
424
452
  if (values && !_title) {
425
- _title = echoAbsoluteTimeTitle(values, format, false);
453
+ _title = echoAbsoluteTimeTitle(values, format, false, timeSpanBoundary);
426
454
  }
427
455
  if (isRule) {
428
456
  if (!title) {
@@ -649,4 +677,11 @@ export function getFinalDateOption(inputStr) {
649
677
  }
650
678
  }
651
679
  return finalDateOption;
652
- }
680
+ }
681
+
682
+ /**
683
+ * 是否超过了最大的时间跨度
684
+ */
685
+ export var isExceedMaxTimeSpan = function isExceedMaxTimeSpan(value, timeSpanBoundary) {
686
+ return computeTimeDiff(value, "s") > timeSpanBoundary;
687
+ };
@@ -0,0 +1,52 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useRef } from "react";
8
+ import Tag from "../Tag";
9
+ import { useDrag, useDrop } from "react-dnd";
10
+ var type = "dragableTag";
11
+ var DragTag = function DragTag(props) {
12
+ var maxTagTextLength = props.maxTagTextLength,
13
+ tagTooltipRender = props.tagTooltipRender,
14
+ tagLabelRender = props.tagLabelRender,
15
+ moveNode = props.moveNode,
16
+ propsItem = props.propsItem,
17
+ showTooltip = props.showTooltip,
18
+ disabled = props.disabled;
19
+ var index = propsItem.index;
20
+ var dragRef = useRef(null);
21
+ var _useDrop = useDrop({
22
+ accept: type,
23
+ drop: function drop(item) {
24
+ moveNode(item.index, index);
25
+ }
26
+ }, [index, moveNode]),
27
+ _useDrop2 = _slicedToArray(_useDrop, 2),
28
+ drop = _useDrop2[1];
29
+ var _useDrag = useDrag({
30
+ item: {
31
+ type: type,
32
+ index: index
33
+ }
34
+ }),
35
+ _useDrag2 = _slicedToArray(_useDrag, 2),
36
+ drag = _useDrag2[1];
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ ref: drag(drop(dragRef)),
39
+ onMouseDown: function onMouseDown(e) {
40
+ e.stopPropagation();
41
+ }
42
+ }, /*#__PURE__*/React.createElement(Tag, {
43
+ key: index,
44
+ maxTagTextLength: maxTagTextLength,
45
+ tagTooltipRender: tagTooltipRender,
46
+ tagLabelRender: tagLabelRender,
47
+ showTooltip: showTooltip,
48
+ props: propsItem,
49
+ disabled: disabled
50
+ }));
51
+ };
52
+ export default DragTag;
@@ -1,12 +1,4 @@
1
1
  import _Icon from "@chaoswise/ui/lib/Antd/Icon";
2
- /*
3
- * @Author: andrew.qiao andrew.qiao@cloudwise.com
4
- * @Date: 2022-09-13 17:59:38
5
- * @LastEditors: andrew.qiao andrew.qiao@cloudwise.com
6
- * @LastEditTime: 2023-03-14 17:57:33
7
- * @FilePath: /change_01/aops_web_commons/packages/ui/components/CWSelect/Tag.js
8
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
9
- */
10
2
  import React from 'react';
11
3
  function Tag(_ref) {
12
4
  var props = _ref.props,
@@ -19,14 +11,14 @@ function Tag(_ref) {
19
11
  if (typeof props.label === 'string') {
20
12
  tooltipLabel = props.label;
21
13
  } else {
22
- var _props$label, _props$label$props;
23
- tooltipLabel = props !== null && props !== void 0 && (_props$label = props.label) !== null && _props$label !== void 0 && (_props$label$props = _props$label.props) !== null && _props$label$props !== void 0 && _props$label$props.children ? props.label.props.children : '';
14
+ var _props$label;
15
+ tooltipLabel = props !== null && props !== void 0 && (_props$label = props.label) !== null && _props$label !== void 0 && (_props$label = _props$label.props) !== null && _props$label !== void 0 && _props$label.children ? props.label.props.children : '';
24
16
  }
25
17
  return /*#__PURE__*/React.createElement("span", {
26
18
  className: "cw-select-selection-item"
27
19
  }, /*#__PURE__*/React.createElement("span", {
28
20
  className: "cw-select-selection-item-content"
29
- }, tagLabelRender ? tagLabelRender(props.label, props) : maxTagTextLength && tooltipLabel.length > maxTagTextLength ? tooltipLabel.slice(0, maxTagTextLength) + "…" : props.label), !disabled && /*#__PURE__*/React.createElement("span", {
21
+ }, tagLabelRender ? tagLabelRender(props.label, props) : maxTagTextLength && tooltipLabel.length > maxTagTextLength ? tooltipLabel.slice(0, maxTagTextLength) + "…" : props.label), !(disabled || props.disabled) && /*#__PURE__*/React.createElement("span", {
30
22
  className: "cw-select-selection-item-remove"
31
23
  }, /*#__PURE__*/React.createElement(_Icon, {
32
24
  type: "close",
@@ -17,14 +17,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
17
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
18
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
19
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
21
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
22
20
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
21
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
22
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
23
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
26
24
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
27
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
28
28
  import React, { useEffect, useState, forwardRef, useRef, useCallback } from "react";
29
29
  import ReactDom from 'react-dom';
30
30
  import RCSelect from "./antd-select";
@@ -37,48 +37,9 @@ import update from 'immutability-helper';
37
37
  import { getLocale } from "./locale";
38
38
  import { getDefaultPaddingLeft } from './utils';
39
39
  import useConfigContext from '../useConfigContext';
40
+ import DragTag from './DragTag';
40
41
  var Option = RCSelect.Option,
41
42
  OptGroup = RCSelect.OptGroup;
42
- var type = 'dragableTag';
43
- var RenderTag = function RenderTag(props) {
44
- var maxTagTextLength = props.maxTagTextLength,
45
- tagTooltipRender = props.tagTooltipRender,
46
- tagLabelRender = props.tagLabelRender,
47
- moveNode = props.moveNode,
48
- propsItem = props.propsItem,
49
- showTooltip = props.showTooltip;
50
- var index = propsItem.index;
51
- var dragRef = useRef(null);
52
- var _useDrop = useDrop({
53
- accept: type,
54
- drop: function drop(item) {
55
- moveNode(item.index, index);
56
- }
57
- }, [index, moveNode]),
58
- _useDrop2 = _slicedToArray(_useDrop, 2),
59
- drop = _useDrop2[1];
60
- var _useDrag = useDrag({
61
- item: {
62
- type: type,
63
- index: index
64
- }
65
- }),
66
- _useDrag2 = _slicedToArray(_useDrag, 2),
67
- drag = _useDrag2[1];
68
- return /*#__PURE__*/React.createElement("div", {
69
- ref: drag(drop(dragRef)),
70
- onMouseDown: function onMouseDown(e) {
71
- e.stopPropagation();
72
- }
73
- }, /*#__PURE__*/React.createElement(Tag, {
74
- key: index,
75
- maxTagTextLength: maxTagTextLength,
76
- tagTooltipRender: tagTooltipRender,
77
- tagLabelRender: tagLabelRender,
78
- showTooltip: showTooltip,
79
- props: propsItem
80
- }));
81
- };
82
43
  /**
83
44
  * 使用方法同Select组件基本相同,在multiple和tag模式下对多tag展示不下的情况下进行了定制化开发,符合UE交互规范
84
45
  */
@@ -253,7 +214,8 @@ var CWSelect = /*#__PURE__*/forwardRef(function (props, ref) {
253
214
  maxTagTextLength: maxTagTextLength,
254
215
  tagTooltipRender: tagTooltipRender,
255
216
  showTooltip: showTooltip,
256
- tagLabelRender: tagLabelRender
217
+ tagLabelRender: tagLabelRender,
218
+ disabled: rest.disabled
257
219
  });
258
220
  }));
259
221
  }
@@ -320,14 +282,15 @@ var CWSelect = /*#__PURE__*/forwardRef(function (props, ref) {
320
282
  if (!finalProps) {
321
283
  return null;
322
284
  }
323
- return /*#__PURE__*/React.createElement(RenderTag, {
285
+ return /*#__PURE__*/React.createElement(DragTag, {
324
286
  key: key,
325
287
  maxTagTextLength: maxTagTextLength,
326
288
  tagTooltipRender: tagTooltipRender,
327
289
  tagLabelRender: tagLabelRender,
328
290
  moveNode: moveNode,
329
291
  propsItem: finalProps,
330
- showTooltip: showTooltip
292
+ showTooltip: showTooltip,
293
+ disabled: rest.disabled
331
294
  });
332
295
  }));
333
296
  } else {
@@ -101,7 +101,7 @@ var EditableRowCell = function EditableRowCell(props) {
101
101
  _useState2 = _slicedToArray(_useState, 2),
102
102
  editing = _useState2[0],
103
103
  setEditing = _useState2[1];
104
- var editMode = column === null || column === void 0 ? void 0 : (_column$form = column.form) === null || _column$form === void 0 ? void 0 : _column$form.editMode;
104
+ var editMode = column === null || column === void 0 || (_column$form = column.form) === null || _column$form === void 0 ? void 0 : _column$form.editMode;
105
105
  var _useConfigContext2 = useConfigContext(),
106
106
  getPrefixCls = _useConfigContext2.getPrefixCls;
107
107
  var prefixCls = getPrefixCls();
@@ -105,9 +105,9 @@ function CWTree(_ref) {
105
105
  });
106
106
  });
107
107
  }
108
- treeData = addRoot(treeData, "/");
109
- treeData = useMemo(function () {
110
- if (!searchHighlight) return treeData;
108
+ var _treeData = useMemo(function () {
109
+ var addRootTreeData = addRoot(treeData, "/");
110
+ if (!searchHighlight) return addRootTreeData;
111
111
  var loop = function loop(treeData) {
112
112
  return treeData.map(function (item) {
113
113
  var index = 0;
@@ -128,8 +128,13 @@ function CWTree(_ref) {
128
128
  return !!item.title;
129
129
  });
130
130
  };
131
- return loop(treeData);
132
- }, [searchHighlight, treeData, searchValue]);
131
+ addRootTreeData = loop(addRootTreeData);
132
+ return rest.checkable ? treeData.filter(function (i) {
133
+ return addRootTreeData.find(function (item) {
134
+ return item.key === i.key;
135
+ });
136
+ }) : addRootTreeData;
137
+ }, [searchHighlight, treeData, searchValue, rest.checkable]);
133
138
  function buildMenu(array) {
134
139
  // 递归构建菜单解构
135
140
  return array.map(function (item) {
@@ -288,7 +293,7 @@ function CWTree(_ref) {
288
293
  return hideExtend(e);
289
294
  },
290
295
  draggable: draggable
291
- }, rest), children ? children : creatTreeNode(treeData))))), /*#__PURE__*/React.createElement("div", {
296
+ }, rest), children ? children : creatTreeNode(_treeData))))), /*#__PURE__*/React.createElement("div", {
292
297
  className: "cw-tree-footer"
293
298
  }, extraFooter));
294
299
  }
@@ -64,10 +64,10 @@ var InputComponent = /*#__PURE__*/forwardRef(function (props, inputRef) {
64
64
  var inputLabelRef = useRef(null);
65
65
  useEffect(function () {
66
66
  if (label || inputLabel) {
67
- var _inputLabelRef$curren, _ref$current, _ref$current$input, _ref$current2;
67
+ var _inputLabelRef$curren, _ref$current, _ref$current2;
68
68
  var defaultPaddingLeft = getDefaultPaddingLeft(resProps.size);
69
69
  var paddingLeftWidth = ((_inputLabelRef$curren = inputLabelRef.current) === null || _inputLabelRef$curren === void 0 ? void 0 : _inputLabelRef$curren.clientWidth) + defaultPaddingLeft;
70
- var inputDom = componentType === "Search" ? (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : (_ref$current$input = _ref$current.input) === null || _ref$current$input === void 0 ? void 0 : _ref$current$input.input : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.input;
70
+ var inputDom = componentType === "Search" ? (_ref$current = ref.current) === null || _ref$current === void 0 || (_ref$current = _ref$current.input) === null || _ref$current === void 0 ? void 0 : _ref$current.input : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.input;
71
71
  if (inputDom) {
72
72
  inputDom.style.paddingLeft = "".concat(paddingLeftWidth, "px");
73
73
  }
@@ -10,7 +10,7 @@ import _Input from "@chaoswise/ui/lib/Input";
10
10
  import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
11
11
  import "@chaoswise/ui/lib/CWSelect/index.less";
12
12
  import _CWSelect from "@chaoswise/ui/lib/CWSelect";
13
- var _excluded = ["form", "total", "simple", "current", "size", "onShowSizeChange", "defaultCurrent", "pageSize", "defaultPageSize", "showTotal", "pageSizeOptions", "showQuickJumper", "showSizeChanger", "onChange", "disabled", "className", "itemRender", "hideOnSinglePage", "newLayout"];
13
+ var _excluded = ["form", "total", "simple", "current", "size", "onShowSizeChange", "defaultCurrent", "pageSize", "defaultPageSize", "showTotal", "pageSizeOptions", "showQuickJumper", "showSizeChanger", "onChange", "disabled", "className", "itemRender", "hideOnSinglePage", "newLayout", "getPopupContainer"];
14
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -67,6 +67,7 @@ function CWPagination(props) {
67
67
  hideOnSinglePage = _props$hideOnSinglePa === void 0 ? false : _props$hideOnSinglePa,
68
68
  _props$newLayout = props.newLayout,
69
69
  newLayout = _props$newLayout === void 0 ? false : _props$newLayout,
70
+ getPopupContainer = props.getPopupContainer,
70
71
  rest = _objectWithoutProperties(props, _excluded);
71
72
  var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
72
73
  _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
@@ -229,7 +230,8 @@ function CWPagination(props) {
229
230
  size: size === "small" ? "small" : "default",
230
231
  onChange: function onChange(pageSize) {
231
232
  return handleChangePageSize(pageSize);
232
- }
233
+ },
234
+ getPopupContainer: getPopupContainer
233
235
  }, pageSizeOptions.map(function (value) {
234
236
  return /*#__PURE__*/React.createElement(Option, {
235
237
  value: value,
@@ -372,6 +374,10 @@ CWPagination.propTypes = {
372
374
  /**
373
375
  * 每页条数改变的回调,参数是页码和改变后的每页条数 Function(current,pageSize)
374
376
  */
375
- onShowSizeChange: PropTypes.func
377
+ onShowSizeChange: PropTypes.func,
378
+ /**
379
+ * getPopupContainer分页选择器菜单渲染父节点,默认渲染到 body 上,如果你遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位。
380
+ */
381
+ getPopupContainer: PropTypes.func
376
382
  };
377
383
  export default _Form.create()(CWPagination);
@@ -25,7 +25,7 @@ var CheckList = function CheckList(props) {
25
25
  handlePreviewList(_toConsumableArray(checkValue)); //更新修改后的列表
26
26
  };
27
27
 
28
- var isLockSort = type === "list" && checkValue.filter(function (item) {
28
+ var isLockSort = checkValue.filter(function (item) {
29
29
  return item.disabled;
30
30
  }).length;
31
31
  var renderList = function renderList(item, index) {
@@ -23,7 +23,7 @@ var NoDrag = function NoDrag(props) {
23
23
  handlePreviewList(_toConsumableArray(checkValue)); //更新修改后的列表
24
24
  };
25
25
 
26
- var isLockSort = type === "list" && checkValue.filter(function (item) {
26
+ var isLockSort = checkValue.filter(function (item) {
27
27
  return item.disabled;
28
28
  }).length;
29
29
  var renderList = function renderList(item, index) {
@@ -2,7 +2,7 @@ import _Icon from "@chaoswise/ui/lib/Antd/Icon";
2
2
  import "@chaoswise/ui/lib/Tooltip/index.less";
3
3
  import _Tooltip from "@chaoswise/ui/lib/Tooltip";
4
4
  import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
5
- var _excluded = ["label", "value", "index", "handleDelete", "labelValue", "moveList", "type", "renderColumns", "render", "dragList", "disabled", "isLockSort"];
5
+ var _excluded = ["label", "value", "index", "handleDelete", "labelValue", "type", "renderColumns", "render", "dragList", "disabled", "isLockSort"];
6
6
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
7
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
8
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -17,7 +17,6 @@ var NotDragList = function NotDragList(_ref) {
17
17
  index = _ref.index,
18
18
  handleDelete = _ref.handleDelete,
19
19
  labelValue = _ref.labelValue,
20
- moveList = _ref.moveList,
21
20
  type = _ref.type,
22
21
  renderColumns = _ref.renderColumns,
23
22
  render = _ref.render,
@@ -48,7 +47,7 @@ var NotDragList = function NotDragList(_ref) {
48
47
  cursor: "move"
49
48
  }
50
49
  } : {};
51
- var listLockSortContent = /*#__PURE__*/React.createElement("div", {
50
+ var lockSortContent = /*#__PURE__*/React.createElement("div", {
52
51
  className: "cw-transfer-right-content-item"
53
52
  }, /*#__PURE__*/React.createElement("div", {
54
53
  className: "cw-transfer-right-content-item-drag-wrapper"
@@ -56,14 +55,14 @@ var NotDragList = function NotDragList(_ref) {
56
55
  title: localeObj["dragAndDrop"]
57
56
  }, /*#__PURE__*/React.createElement(DragSvg, null))), /*#__PURE__*/React.createElement("div", {
58
57
  className: "cw-transfer-right-content-item-text-wrapper"
59
- }, render(value)), !disabled && /*#__PURE__*/React.createElement(_Icon, {
58
+ }, type === "table" ? renderTable(labelValue) : render(value)), !disabled && /*#__PURE__*/React.createElement(_Icon, {
60
59
  type: "close",
61
60
  className: "cw-transfer-right-content-del",
62
61
  onClick: function onClick() {
63
62
  return handleDeleted(labelValue);
64
63
  }
65
64
  }));
66
- var renderItemContent = type == "list" && isLockSort ? listLockSortContent : /*#__PURE__*/React.createElement(Fragment, null, dragList && /*#__PURE__*/React.createElement(_Tooltip, {
65
+ var renderItemContent = isLockSort ? lockSortContent : /*#__PURE__*/React.createElement(Fragment, null, dragList && /*#__PURE__*/React.createElement(_Tooltip, {
67
66
  title: localeObj["dragAndDrop"]
68
67
  }, /*#__PURE__*/React.createElement(DragSvg, {
69
68
  className: "cw-transfer-right-content-drag"
@@ -120,7 +120,7 @@ var TopicList = function TopicList(_ref) {
120
120
  cursor: "move"
121
121
  }
122
122
  } : {};
123
- var listLockSortContent = /*#__PURE__*/React.createElement("div", {
123
+ var lockSortContent = /*#__PURE__*/React.createElement("div", {
124
124
  className: "cw-transfer-right-content-item"
125
125
  }, /*#__PURE__*/React.createElement("div", {
126
126
  className: "cw-transfer-right-content-item-drag-wrapper"
@@ -128,14 +128,14 @@ var TopicList = function TopicList(_ref) {
128
128
  title: localeObj["dragAndDrop"]
129
129
  }, /*#__PURE__*/React.createElement(DragSvg, null))), /*#__PURE__*/React.createElement("div", {
130
130
  className: "cw-transfer-right-content-item-text-wrapper"
131
- }, render(value)), !disabled && /*#__PURE__*/React.createElement(_Icon, {
131
+ }, type === "table" ? renderTable(labelValue) : render(value)), !disabled && /*#__PURE__*/React.createElement(_Icon, {
132
132
  type: "close",
133
133
  className: "cw-transfer-right-content-del",
134
134
  onClick: function onClick() {
135
135
  return handleDeleted(labelValue);
136
136
  }
137
137
  }));
138
- var renderItemContent = type == "list" && isLockSort ? listLockSortContent : /*#__PURE__*/React.createElement(Fragment, null, dragList && /*#__PURE__*/React.createElement(_Tooltip, {
138
+ var renderItemContent = isLockSort ? lockSortContent : /*#__PURE__*/React.createElement(Fragment, null, dragList && /*#__PURE__*/React.createElement(_Tooltip, {
139
139
  title: localeObj["dragAndDrop"]
140
140
  }, /*#__PURE__*/React.createElement(DragSvg, {
141
141
  className: "cw-transfer-right-content-drag"
@@ -251,6 +251,11 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
251
251
  });
252
252
  findValue && finalCheckValue.push(findValue);
253
253
  });
254
+ finalCheckValue = finalCheckValue.filter(function (i) {
255
+ return i.disabled;
256
+ }).concat(finalCheckValue.filter(function (i) {
257
+ return !i.disabled;
258
+ }));
254
259
  setCheckValue(finalCheckValue);
255
260
  }
256
261
  //回显table
@@ -684,7 +689,7 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
684
689
  }, treeRest));
685
690
  }
686
691
  };
687
- var list = searchCheckedValue.length === 0 ? /*#__PURE__*/React.createElement(_Empty, {
692
+ var renderRightList = searchCheckedValue.length === 0 ? /*#__PURE__*/React.createElement(_Empty, {
688
693
  description: localeObj["pleaseSelectFromLeft"]
689
694
  }) : useDndProvider ? /*#__PURE__*/React.createElement(CheckList, {
690
695
  checkValue: searchCheckedValue,
@@ -754,7 +759,7 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
754
759
  className: "cw-transfer-right-header-clear"
755
760
  }, localeObj.clear)) : /*#__PURE__*/React.createElement(Fragment, null, rightHeader)), /*#__PURE__*/React.createElement("div", {
756
761
  className: "cw-transfer-right-main-wrapper"
757
- }, list)), rightFooter && /*#__PURE__*/React.createElement("div", {
762
+ }, renderRightList)), rightFooter && /*#__PURE__*/React.createElement("div", {
758
763
  className: "cw-transfer-footer"
759
764
  }, rightFooter))));
760
765
  });