@chaoswise/ui 2.7.6 → 2.7.8

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.
Files changed (58) hide show
  1. package/lib/BasicLayout/locale/index.js +2 -0
  2. package/lib/BasicLayout/locale/ja_JP.js +4 -0
  3. package/lib/CWMessage/locale/index.js +2 -0
  4. package/lib/CWMessage/locale/ja_JP.js +8 -0
  5. package/lib/CWRangePicker/locale/index.js +2 -0
  6. package/lib/CWRangePicker/locale/ja_JP.js +29 -0
  7. package/lib/CWRangePicker/utils/index.js +108 -18
  8. package/lib/CWSelect/locale/index.js +2 -0
  9. package/lib/CWSelect/locale/ja_JP.js +4 -0
  10. package/lib/CWTable/locale/index.js +2 -0
  11. package/lib/CWTable/locale/ja_JP.js +6 -0
  12. package/lib/CWTree/index.js +1 -20
  13. package/lib/CWTree/locale/index.js +2 -0
  14. package/lib/CWTree/locale/ja_JP.js +3 -0
  15. package/lib/CWUpload/locale/index.js +2 -0
  16. package/lib/CWUpload/locale/ja_JP.js +6 -0
  17. package/lib/Card/index.less +10 -0
  18. package/lib/ColorPicker/locale/index.js +2 -0
  19. package/lib/ColorPicker/locale/ja_JP.js +4 -0
  20. package/lib/ConfigProvider/ConfigProvider.js +11 -3
  21. package/lib/DateRangePicker/locale/index.js +2 -0
  22. package/lib/DateRangePicker/locale/ja_JP.js +5 -0
  23. package/lib/DropdownDatePicker/locale/index.js +2 -0
  24. package/lib/DropdownDatePicker/locale/ja_JP.js +21 -0
  25. package/lib/DropdownDatePicker/utils/index.js +123 -39
  26. package/lib/Empty/locale/index.js +2 -0
  27. package/lib/Empty/locale/ja_JP.js +3 -0
  28. package/lib/ErrorBoundary/index.less +15 -0
  29. package/lib/ErrorBoundary/locale/index.js +2 -0
  30. package/lib/ErrorBoundary/locale/ja_JP.js +5 -0
  31. package/lib/Exception/locale/index.js +2 -0
  32. package/lib/Exception/locale/ja_JP.js +9 -0
  33. package/lib/FilterDropDown/locale/index.js +2 -0
  34. package/lib/FilterDropDown/locale/ja_JP.js +3 -0
  35. package/lib/IconSelect/locale/index.js +2 -0
  36. package/lib/IconSelect/locale/ja_JP.js +11 -0
  37. package/lib/Joyride/locale/index.js +2 -0
  38. package/lib/Joyride/locale/ja_JP.js +25 -0
  39. package/lib/Pagination/locale/index.js +2 -0
  40. package/lib/Pagination/locale/ja_JP.js +8 -0
  41. package/lib/Progress/locale/index.js +2 -0
  42. package/lib/Progress/locale/ja_JP.js +3 -0
  43. package/lib/QuickTransfer/locale/index.js +2 -0
  44. package/lib/QuickTransfer/locale/ja_JP.js +8 -0
  45. package/lib/QuickTransfer/utils.js +7 -6
  46. package/lib/RangePicker/locale/index.js +2 -0
  47. package/lib/RangePicker/locale/ja_JP.js +5 -0
  48. package/lib/SearchBar/locale/index.js +2 -0
  49. package/lib/SearchBar/locale/ja_JP.js +6 -0
  50. package/lib/TimeRangeSlider/locale/index.js +2 -0
  51. package/lib/TimeRangeSlider/locale/ja_JP.js +31 -0
  52. package/lib/TimeRangeSlider/utils/index.js +112 -60
  53. package/lib/TreeSelect111/locale/index.js +2 -0
  54. package/lib/TreeSelect111/locale/ja_JP.js +3 -0
  55. package/lib/WangEditor/index.js +2 -1
  56. package/lib/WangEditor/locale/index.js +31 -0
  57. package/lib/treeLoad/index.js +57 -24
  58. package/package.json +3 -4
@@ -15,49 +15,60 @@ var _require = require("uuid"),
15
15
  uuidv4 = _require.v4;
16
16
  // 枚举时间单位
17
17
  var ENUM_TimeUnit = {
18
- s: ["Second", "Seconds", "秒", "seconds"],
19
- m: ["Minute", "Minutes", "分钟", "minutes"],
20
- h: ["Hour", "Hours", "小时", "hours"],
21
- d: ["Day", "Days", "天", "days"],
22
- mo: ["Month", "Months", "月", "mo"],
23
- y: ["Year", "Years", "年", "years"]
24
- };
25
- var EnumTimeType = {
26
- recently: "recentlyArray",
27
- relative: "relativeArray",
28
- absolute: "absoluteArray",
29
- unixTimestamp: "unixTimestampArray",
30
- other: "otherArray"
31
- };
32
-
33
- /**
34
- * 变换数据源格式
35
- * @param {Array} 数据源
36
- * @returns 重新编排组合的数据源
37
- */
38
- export var regroupDataSourceFn = function regroupDataSourceFn(dataSource) {
39
- var recentlyArray = [];
40
- var relativeArray = [];
41
- var absoluteArray = [];
42
- var unixTimestampArray = [];
43
- var otherArray = [];
44
- var regroupDataSource = [];
45
- dataSource.forEach(function (item) {
46
- if (EnumTimeType[item.type]) {
47
- eval(EnumTimeType[item.type]).push(item);
48
- } else {
49
- eval(EnumTimeType["other"]).push(item);
50
- }
51
- });
52
- Object.entries(EnumTimeType).map(function (item) {
53
- if (eval(item[1]).length) {
54
- var newObj = {};
55
- newObj.type = item[0];
56
- newObj.timeList = eval(item[1]);
57
- regroupDataSource.push(newObj);
58
- }
59
- });
60
- return regroupDataSource;
18
+ s: {
19
+ zh_CN: "秒",
20
+ en_US: {
21
+ singular: "Second",
22
+ plural: "Seconds"
23
+ },
24
+ zh_TW: "秒",
25
+ unit: "seconds"
26
+ },
27
+ m: {
28
+ zh_CN: "分钟",
29
+ en_US: {
30
+ singular: "Minute",
31
+ plural: "Minutes"
32
+ },
33
+ zh_TW: "分鐘",
34
+ unit: "minutes"
35
+ },
36
+ h: {
37
+ zh_CN: "小时",
38
+ en_US: {
39
+ singular: "Hour",
40
+ plural: "Hours"
41
+ },
42
+ zh_TW: "小時",
43
+ unit: "hours"
44
+ },
45
+ d: {
46
+ zh_CN: "天",
47
+ en_US: {
48
+ singular: "Day",
49
+ plural: "Days"
50
+ },
51
+ zh_TW: "天",
52
+ unit: "days"
53
+ },
54
+ mo: {
55
+ zh_CN: "月",
56
+ en_US: {
57
+ singular: "Month",
58
+ plural: "Months"
59
+ },
60
+ zh_TW: "月",
61
+ unit: "mo"
62
+ },
63
+ y: {
64
+ zh_CN: "年",
65
+ en_US: {
66
+ singular: "Year",
67
+ plural: "Years"
68
+ },
69
+ zh_TW: "年",
70
+ unit: "years"
71
+ }
61
72
  };
62
73
 
63
74
  // 捕获匹配值
@@ -111,18 +122,60 @@ export var judgeType = function judgeType(recordDateValue) {
111
122
  return [isRule, captureUnit, recordUnit];
112
123
  };
113
124
  export var echoRecentlyTimeTitle = function echoRecentlyTimeTitle(locale, captureUnit) {
114
- // todo: 需要优化
115
- if (locale == "zh_CN" || locale == "zh" || locale == "zh_TW") {
116
- if (captureUnit[1] === "mo") {
117
- return "\u6700\u8FD1".concat(captureUnit[0], "\u4E2A").concat(ENUM_TimeUnit.mo[2]);
118
- }
119
- return "\u6700\u8FD1".concat(captureUnit[0]).concat(ENUM_TimeUnit[captureUnit[1]][2]);
120
- } else {
121
- if (captureUnit[0] == 1) {
122
- return "Past ".concat(captureUnit[0], " ").concat(ENUM_TimeUnit[captureUnit[1]][0]);
123
- }
124
- return "Past ".concat(captureUnit[0], " ").concat(ENUM_TimeUnit[captureUnit[1]][1]);
125
+ // 参数验证
126
+ if (!captureUnit || !Array.isArray(captureUnit) || captureUnit.length < 2) {
127
+ return "";
128
+ }
129
+ var _captureUnit3 = _slicedToArray(captureUnit, 2),
130
+ count = _captureUnit3[0],
131
+ unit = _captureUnit3[1];
132
+ var timeUnit = ENUM_TimeUnit[unit];
133
+ if (!timeUnit) {
134
+ return "";
125
135
  }
136
+ var countNum = parseInt(count, 10);
137
+
138
+ // 语言配置映射
139
+ var localeConfig = {
140
+ zh_CN: {
141
+ template: function template(count, unitText) {
142
+ return "\u6700\u8FD1".concat(count).concat(unit === "mo" ? "个" : "").concat(unitText);
143
+ },
144
+ getUnitText: function getUnitText() {
145
+ return timeUnit.zh_CN;
146
+ }
147
+ },
148
+ zh: {
149
+ template: function template(count, unitText) {
150
+ return "\u6700\u8FD1".concat(count).concat(unit === "mo" ? "个" : "").concat(unitText);
151
+ },
152
+ getUnitText: function getUnitText() {
153
+ return timeUnit.zh_CN;
154
+ }
155
+ },
156
+ zh_TW: {
157
+ template: function template(count, unitText) {
158
+ return "\u6700\u8FD1".concat(count).concat(unit === "mo" ? "個" : "").concat(unitText);
159
+ },
160
+ getUnitText: function getUnitText() {
161
+ return timeUnit.zh_TW;
162
+ }
163
+ },
164
+ "default": {
165
+ template: function template(count, unitText) {
166
+ return "Past ".concat(count, " ").concat(unitText);
167
+ },
168
+ getUnitText: function getUnitText() {
169
+ var isPlural = countNum !== 1;
170
+ return isPlural ? timeUnit.en_US.plural : timeUnit.en_US.singular;
171
+ }
172
+ }
173
+ };
174
+
175
+ // 获取当前语言配置,如果不存在则使用默认配置
176
+ var config = localeConfig[locale] || localeConfig["default"];
177
+ var unitText = config.getUnitText();
178
+ return config.template(count, unitText);
126
179
  };
127
180
  export var echoAbsoluteTimeTitle = function echoAbsoluteTimeTitle(value, format) {
128
181
  var hasTimeSpan = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
@@ -230,7 +283,7 @@ export var computeTimeSpan = function computeTimeSpan(value, timeSpanBoundary) {
230
283
  };
231
284
 
232
285
  /**
233
- *
286
+ *
234
287
  * @param {*} value date日期
235
288
  * @returns 根据日期获取时间跨度,最近时间返回内容
236
289
  */
@@ -247,7 +300,7 @@ export var getTimeSpanFromValue = function getTimeSpanFromValue(value, timeSpanB
247
300
  };
248
301
 
249
302
  /**
250
- *
303
+ *
251
304
  * @param {*} value date日期
252
305
  * @returns 根据日期计算最近的时间
253
306
  */
@@ -353,7 +406,6 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
353
406
  */
354
407
  export var getChangeUnitDate = function getChangeUnitDate(unitFigure, unit) {
355
408
  var value = [moment().subtract(unitFigure, unit), moment()];
356
- ;
357
409
  if (unit === "mo") {
358
410
  value[0] = moment().subtract(unitFigure * 31, "d");
359
411
  }
@@ -380,7 +432,7 @@ export var getChangeDate = function getChangeDate(recordDateValue, direction) {
380
432
  value = funcValueChangeArrayValue(values);
381
433
  }
382
434
  if (isRule && !values) {
383
- value = getChangeUnitDate(captureUnit[0], ENUM_TimeUnit[captureUnit[1]][3]);
435
+ value = getChangeUnitDate(captureUnit[0], ENUM_TimeUnit[captureUnit[1]].unit);
384
436
  }
385
437
  var timeDiff = value[1].diff(value[0]);
386
438
  var duration = moment.duration(timeDiff);
@@ -429,7 +481,7 @@ export var funcValueChangeArrayValue = function funcValueChangeArrayValue(value)
429
481
 
430
482
  // 判断是否为最近时间规则,并返回矫正之后的value值
431
483
  export var getCorrectValue = function getCorrectValue(value) {
432
- var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
484
+ var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
433
485
  var _getUnit5 = getUnit(key),
434
486
  isRule = _getUnit5.isRule,
435
487
  captureUnit = _getUnit5.captureUnit;
@@ -632,7 +684,7 @@ var parseInputDate = function parseInputDate(text) {
632
684
  if (format === "X") {
633
685
  if (text.length !== 10) {
634
686
  finalDate = null;
635
- finalFormat = '';
687
+ finalFormat = "";
636
688
  }
637
689
  }
638
690
  return {
@@ -1,10 +1,12 @@
1
1
  import zh_CN from './zh_CN.js';
2
2
  import en_US from './en_US.js';
3
3
  import zh_TW from './zh_TW.js';
4
+ import ja_JP from './ja_JP.js';
4
5
  export default {
5
6
  zh_CN: zh_CN,
6
7
  en_US: en_US,
7
8
  zh_TW: zh_TW,
9
+ ja_JP: ja_JP,
8
10
  // 兼容
9
11
  zh: zh_CN,
10
12
  en: en_US
@@ -0,0 +1,3 @@
1
+ export default {
2
+ "checkAll": "すべて選択"
3
+ };
@@ -6,13 +6,14 @@ import React, { useEffect, Fragment, useRef, forwardRef } from "react";
6
6
  import E from "./wangEditor";
7
7
  import PropTypes from "prop-types";
8
8
  import "./index.less";
9
- import { localeObj, localObjTW } from "./locale/index";
9
+ import { localeObj, localObjTW, localObjJA } from "./locale/index";
10
10
  import usePreview from "../usePreview";
11
11
  import resizeable from "./resizeable";
12
12
  var localOptionsMap = {
13
13
  en: localeObj,
14
14
  en_US: localeObj,
15
15
  zh_TW: localObjTW,
16
+ ja_JP: localObjJA,
16
17
  zh: {},
17
18
  zh_CN: {}
18
19
  };
@@ -59,4 +59,35 @@ export var localObjTW = {
59
59
  插入: "插入",
60
60
  创建: "創建",
61
61
  图片: "圖片"
62
+ };
63
+ export var localObjJA = {
64
+ 设置标题: "見出し",
65
+ 正文: "本文",
66
+ 链接文字: "リンクテキスト",
67
+ 链接: "リンク",
68
+ 上传图片: "ローカル",
69
+ 上传: "アップロード",
70
+ 有序列表: "順序付きリスト",
71
+ 无序列表: "順序なしリスト",
72
+ 靠左: "左揃え",
73
+ 居中: "中央揃え",
74
+ 靠右: "右揃え",
75
+ 字号: "フォントサイズ",
76
+ 字体: "フォント",
77
+ 文字颜色: "文字色",
78
+ 背景色: "背景色",
79
+ 设置列表: "リスト",
80
+ 插入代码: "コード",
81
+ 插入视频: "動画",
82
+ 格式如: "形式例",
83
+ 插入表格: "テーブル",
84
+ 列的表格: "列",
85
+ 行: "行",
86
+ 默认: "デフォルト",
87
+ 新浪: "Sina",
88
+ 对齐方式: "配置",
89
+ 网络图片: "Web",
90
+ 插入: "挿入",
91
+ 创建: "作成",
92
+ 图片: "画像"
62
93
  };
@@ -1,46 +1,79 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
7
  import React from "react";
2
- import PropTypes from 'prop-types';
8
+ import PropTypes from "prop-types";
9
+
3
10
  /**
4
- *
5
11
  * 封装的树形结构懒加载组件
6
12
  */
7
13
  function fetchTreeNode(oldData, parentId, childNode) {
14
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
15
+ var _options$keyField = options.keyField,
16
+ keyField = _options$keyField === void 0 ? "value" : _options$keyField,
17
+ compareFn = options.compareFn;
8
18
  return oldData.map(function (item) {
9
- if (item.value === parentId) {
10
- item.children = childNode;
19
+ var isMatch = false;
20
+ if (compareFn) {
21
+ isMatch = compareFn(item, parentId);
22
+ } else {
23
+ var itemKey = item[keyField];
24
+ isMatch = itemKey === parentId;
25
+ }
26
+ if (isMatch) {
27
+ return _objectSpread(_objectSpread({}, item), {}, {
28
+ children: childNode
29
+ });
11
30
  } else if (item.children) {
12
- item.children = fetchTreeNode(item.children, parentId, childNode);
31
+ return _objectSpread(_objectSpread({}, item), {}, {
32
+ children: fetchTreeNode(item.children, parentId, childNode, options)
33
+ });
13
34
  }
14
35
  return item;
15
36
  });
16
37
  }
17
- function treeLoad(oldData, treeNodeKey, fetchData, getChildNode) {
38
+ // 1. 旧版API: treeLoad(oldData, treeNodeKey, fetchData, getChildNode)
39
+ // 2. 新版API: treeLoad(oldData, treeNodeKey, fetchData, options)
40
+ // 3. 混合API-1: treeLoad(oldData, treeNodeKey, fetchData, getChildNode, options) - 第四个参数是函数,第五个是对象
41
+ // 4. 混合API-2: treeLoad(oldData, treeNodeKey, fetchData, options, getChildNode) - 第四个参数是对象,第五个是函数
42
+
43
+ function treeLoad(oldData, treeNodeKey, fetchData, getChildNodeOrOptions, maybeOptions) {
44
+ // 兼容旧版API: 第四个参数可能是getChildNode回调函数或options对象
45
+ var getChildNode;
46
+ var options = {};
47
+ if (typeof getChildNodeOrOptions === "function") {
48
+ // 旧版API: 第四个参数是getChildNode回调函数
49
+ getChildNode = getChildNodeOrOptions;
50
+ // 如果第五个参数是对象,则作为options
51
+ if (maybeOptions && _typeof(maybeOptions) === "object") {
52
+ options = maybeOptions;
53
+ }
54
+ } else if (getChildNodeOrOptions && _typeof(getChildNodeOrOptions) === "object") {
55
+ // 新版API: 第四个参数是options对象
56
+ options = getChildNodeOrOptions;
57
+ // 如果提供了第五个参数且为函数,则视为getChildNode
58
+ if (typeof maybeOptions === "function") {
59
+ getChildNode = maybeOptions;
60
+ }
61
+ }
18
62
  fetchData(treeNodeKey, function (childNode) {
19
- var newData = fetchTreeNode(oldData, treeNodeKey, childNode);
63
+ var newData = fetchTreeNode(oldData, treeNodeKey, childNode, options);
20
64
  getChildNode && getChildNode();
21
65
  return newData;
22
66
  });
23
67
  }
24
- treeLoad.defaultProps = {
25
- //
26
- };
27
68
  treeLoad.propTypes = {
28
- /**
29
- * 获取子节点的数据,并通过回调函数返回最终渲染的数据。
30
- * function(pageNum,callback(res):Data)
31
- */
32
69
  fetchData: PropTypes.func,
33
- /**
34
- * 加载前的树形结构数据,结构中把value作为唯一键值
35
- */
36
70
  oldData: PropTypes.array,
37
- /**
38
- * 要展开的树节点
39
- */
40
71
  treeNodeKey: PropTypes.string,
41
- /**
42
- * 获取子树数据时额外执行的回调函数。
43
- */
44
- getChildNode: PropTypes.func
72
+ getChildNode: PropTypes.func,
73
+ options: PropTypes.shape({
74
+ keyField: PropTypes.string,
75
+ // 指定用于匹配的字段名
76
+ compareFn: PropTypes.func // 自定义比较函数
77
+ })
45
78
  };
46
79
  export default treeLoad;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaoswise/ui",
3
- "version": "2.7.6",
3
+ "version": "2.7.8",
4
4
  "description": "公共UI库",
5
5
  "keywords": [
6
6
  "ui",
@@ -107,7 +107,7 @@
107
107
  "react-custom-scrollbars": "^4.2.1",
108
108
  "react-dnd": "^13.1.1",
109
109
  "react-dnd-html5-backend": "^12.1.1",
110
- "react-draggable": "^4.4.3",
110
+ "react-draggable": "4.4.6",
111
111
  "react-infinite-scroller": "^1.2.4",
112
112
  "react-intl": "^6.0.5",
113
113
  "react-joyride": "2.3.2",
@@ -151,6 +151,5 @@
151
151
  "license": "MIT",
152
152
  "overrides": {
153
153
  "node-fetch": "^2.7.0"
154
- },
155
- "gitHead": "54db53013c7d2b04e8cfc7f336eb71fa54da5024"
154
+ }
156
155
  }