@douyinfe/semi-foundation 2.19.0-beta.0 → 2.19.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/anchor/anchor.scss +1 -8
- package/anchor/rtl.scss +0 -1
- package/anchor/variables.scss +1 -0
- package/calendar/eventUtil.ts +8 -7
- package/calendar/foundation.ts +14 -14
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/dropdown/foundation.ts +2 -1
- package/dropdown/menuFoundation.ts +2 -1
- package/getBabelConfig.js +0 -12
- package/lib/cjs/anchor/anchor.css +1 -10
- package/lib/cjs/anchor/anchor.scss +1 -8
- package/lib/cjs/anchor/constants.js +1 -4
- package/lib/cjs/anchor/foundation.js +5 -12
- package/lib/cjs/anchor/linkFoundation.js +4 -9
- package/lib/cjs/anchor/rtl.scss +0 -1
- package/lib/cjs/anchor/variables.scss +1 -0
- package/lib/cjs/autoComplete/constants.js +1 -4
- package/lib/cjs/autoComplete/foundation.js +14 -33
- package/lib/cjs/autoComplete/optionFoundation.js +4 -9
- package/lib/cjs/avatar/constants.js +1 -4
- package/lib/cjs/avatar/foundation.js +4 -9
- package/lib/cjs/backtop/constants.js +1 -4
- package/lib/cjs/backtop/foundation.js +4 -9
- package/lib/cjs/badge/constants.js +1 -4
- package/lib/cjs/banner/constants.js +1 -4
- package/lib/cjs/banner/foundation.js +4 -9
- package/lib/cjs/base/constants.js +2 -6
- package/lib/cjs/base/env.js +1 -4
- package/lib/cjs/base/foundation.js +5 -10
- package/lib/cjs/base/index.js +3 -6
- package/lib/cjs/breadcrumb/constants.js +1 -4
- package/lib/cjs/breadcrumb/foundation.js +6 -13
- package/lib/cjs/breadcrumb/itemFoundation.js +4 -9
- package/lib/cjs/button/constants.js +1 -4
- package/lib/cjs/calendar/constants.js +1 -4
- package/lib/cjs/calendar/eventUtil.d.ts +3 -3
- package/lib/cjs/calendar/eventUtil.js +28 -53
- package/lib/cjs/calendar/foundation.js +63 -85
- package/lib/cjs/card/constants.js +1 -4
- package/lib/cjs/carousel/constants.js +1 -4
- package/lib/cjs/carousel/foundation.js +5 -12
- package/lib/cjs/cascader/constants.js +1 -4
- package/lib/cjs/cascader/foundation.js +55 -100
- package/lib/cjs/cascader/util.js +9 -30
- package/lib/cjs/checkbox/checkboxFoundation.js +6 -13
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +9 -18
- package/lib/cjs/checkbox/constants.js +1 -4
- package/lib/cjs/collapse/constants.js +1 -4
- package/lib/cjs/collapse/foundation.js +9 -20
- package/lib/cjs/collapsible/constants.js +1 -4
- package/lib/cjs/datePicker/_utils/formatter.js +3 -12
- package/lib/cjs/datePicker/_utils/getDayOfWeek.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +5 -10
- package/lib/cjs/datePicker/_utils/getFullDateOffset.js +3 -6
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +2 -11
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +1 -4
- package/lib/cjs/datePicker/_utils/getMonthTable.js +2 -11
- package/lib/cjs/datePicker/_utils/getMonthsInYear.js +3 -16
- package/lib/cjs/datePicker/_utils/getYears.js +2 -9
- package/lib/cjs/datePicker/_utils/index.js +16 -30
- package/lib/cjs/datePicker/_utils/isAfter.js +3 -6
- package/lib/cjs/datePicker/_utils/isBefore.js +3 -6
- package/lib/cjs/datePicker/_utils/isBetween.js +3 -6
- package/lib/cjs/datePicker/_utils/isDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isSameDay.js +3 -6
- package/lib/cjs/datePicker/_utils/isTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isValidDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isWithinInterval.js +3 -6
- package/lib/cjs/datePicker/_utils/parser.js +1 -4
- package/lib/cjs/datePicker/constants.js +3 -10
- package/lib/cjs/datePicker/foundation.js +42 -85
- package/lib/cjs/datePicker/inputFoundation.js +7 -20
- package/lib/cjs/datePicker/monthFoundation.js +5 -12
- package/lib/cjs/datePicker/monthsGridFoundation.js +47 -68
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +4 -9
- package/lib/cjs/descriptions/constants.js +1 -4
- package/lib/cjs/divider/constants.js +1 -4
- package/lib/cjs/dropdown/constants.js +1 -4
- package/lib/cjs/dropdown/foundation.js +7 -15
- package/lib/cjs/dropdown/menuFoundation.js +11 -31
- package/lib/cjs/empty/constants.js +1 -4
- package/lib/cjs/form/constants.js +1 -4
- package/lib/cjs/form/foundation.js +64 -104
- package/lib/cjs/form/interface.js +1 -3
- package/lib/cjs/form/utils.js +14 -29
- package/lib/cjs/grid/constants.js +1 -4
- package/lib/cjs/icons/constants.js +1 -4
- package/lib/cjs/input/constants.js +1 -4
- package/lib/cjs/input/foundation.js +7 -18
- package/lib/cjs/input/textareaFoundation.js +6 -13
- package/lib/cjs/input/util/calculateNodeHeight.js +3 -17
- package/lib/cjs/input/util/getSizingData.js +5 -10
- package/lib/cjs/inputNumber/constants.js +4 -11
- package/lib/cjs/inputNumber/foundation.js +11 -30
- package/lib/cjs/layout/constants.js +1 -4
- package/lib/cjs/list/constants.js +1 -4
- package/lib/cjs/modal/constants.js +1 -4
- package/lib/cjs/modal/modalContentFoundation.js +4 -9
- package/lib/cjs/modal/modalFoundation.js +4 -9
- package/lib/cjs/navigation/NavItem.js +6 -21
- package/lib/cjs/navigation/constants.js +1 -4
- package/lib/cjs/navigation/foundation.js +22 -37
- package/lib/cjs/navigation/itemFoundation.js +4 -9
- package/lib/cjs/navigation/subNavFoundation.js +10 -21
- package/lib/cjs/notification/constants.js +1 -4
- package/lib/cjs/notification/notificationFoundation.js +5 -12
- package/lib/cjs/notification/notificationListFoundation.js +4 -9
- package/lib/cjs/overflowList/constants.js +3 -10
- package/lib/cjs/overflowList/foundation.js +12 -29
- package/lib/cjs/pagination/constants.js +1 -4
- package/lib/cjs/pagination/foundation.js +18 -37
- package/lib/cjs/popconfirm/constants.js +1 -4
- package/lib/cjs/popconfirm/popconfirmFoundation.js +3 -6
- package/lib/cjs/popover/constants.js +2 -9
- package/lib/cjs/progress/constants.js +1 -4
- package/lib/cjs/radio/constants.js +1 -4
- package/lib/cjs/radio/radioFoundation.js +3 -6
- package/lib/cjs/radio/radioGroupFoundation.js +6 -11
- package/lib/cjs/radio/radioInnerFoundation.js +5 -10
- package/lib/cjs/rating/constants.js +1 -4
- package/lib/cjs/rating/foundation.js +7 -20
- package/lib/cjs/scrollList/constants.js +1 -4
- package/lib/cjs/scrollList/foundation.js +3 -6
- package/lib/cjs/scrollList/itemFoundation.js +8 -21
- package/lib/cjs/scrollList/scrollTo.js +1 -4
- package/lib/cjs/select/constants.js +1 -4
- package/lib/cjs/select/foundation.js +56 -98
- package/lib/cjs/select/optionFoundation.js +4 -9
- package/lib/cjs/sideSheet/constants.js +1 -4
- package/lib/cjs/sideSheet/sideSheetFoundation.js +6 -15
- package/lib/cjs/skeleton/constants.js +1 -4
- package/lib/cjs/slider/constants.js +1 -4
- package/lib/cjs/slider/foundation.js +13 -24
- package/lib/cjs/space/constants.js +1 -4
- package/lib/cjs/spin/constants.js +1 -4
- package/lib/cjs/spin/foundation.js +5 -12
- package/lib/cjs/steps/constants.js +1 -4
- package/lib/cjs/switch/constants.js +1 -4
- package/lib/cjs/switch/foundation.js +4 -9
- package/lib/cjs/table/bodyFoundation.js +9 -22
- package/lib/cjs/table/cellFoundation.js +3 -6
- package/lib/cjs/table/constants.js +1 -4
- package/lib/cjs/table/foundation.js +76 -117
- package/lib/cjs/table/tableRowFoundation.js +3 -6
- package/lib/cjs/table/tableSelectionCellFoundation.js +3 -6
- package/lib/cjs/table/utils.js +42 -71
- package/lib/cjs/tabs/constants.js +1 -4
- package/lib/cjs/tabs/foundation.js +8 -23
- package/lib/cjs/tag/constants.js +1 -4
- package/lib/cjs/tagInput/constants.js +1 -4
- package/lib/cjs/tagInput/foundation.js +12 -31
- package/lib/cjs/tagInput/utils/getSplitedArray.js +3 -6
- package/lib/cjs/timePicker/ComboxFoundation.js +10 -29
- package/lib/cjs/timePicker/constants.js +1 -4
- package/lib/cjs/timePicker/foundation.js +26 -45
- package/lib/cjs/timePicker/inputFoundation.js +4 -9
- package/lib/cjs/timePicker/utils/index.js +7 -14
- package/lib/cjs/timePicker/utils/localeDate.js +2 -9
- package/lib/cjs/timeline/constants.js +1 -4
- package/lib/cjs/toast/constants.js +1 -4
- package/lib/cjs/toast/toastFoundation.js +5 -12
- package/lib/cjs/toast/toastListFoundation.js +5 -12
- package/lib/cjs/tooltip/constants.js +1 -4
- package/lib/cjs/tooltip/foundation.js +29 -56
- package/lib/cjs/transfer/constants.js +1 -4
- package/lib/cjs/transfer/foundation.js +24 -47
- package/lib/cjs/transfer/transferUtils.js +16 -45
- package/lib/cjs/tree/constants.js +1 -4
- package/lib/cjs/tree/foundation.js +41 -76
- package/lib/cjs/tree/treeUtil.js +60 -107
- package/lib/cjs/treeSelect/constants.js +1 -4
- package/lib/cjs/treeSelect/foundation.js +49 -82
- package/lib/cjs/typography/constants.js +1 -4
- package/lib/cjs/upload/constants.js +1 -4
- package/lib/cjs/upload/foundation.js +56 -112
- package/lib/cjs/upload/utils.js +13 -32
- package/lib/cjs/utils/Event.js +9 -23
- package/lib/cjs/utils/FocusHandle.js +6 -15
- package/lib/cjs/utils/Logger.js +1 -4
- package/lib/cjs/utils/Store.js +5 -20
- package/lib/cjs/utils/a11y.js +8 -13
- package/lib/cjs/utils/array.js +6 -15
- package/lib/cjs/utils/arrayMove.js +3 -12
- package/lib/cjs/utils/classnames.js +6 -15
- package/lib/cjs/utils/date-fns-extra.js +7 -18
- package/lib/cjs/utils/dom.js +5 -12
- package/lib/cjs/utils/function.js +1 -4
- package/lib/cjs/utils/getDataAttr.js +2 -13
- package/lib/cjs/utils/getHighlight.js +7 -22
- package/lib/cjs/utils/getMotionObjFromProps.js +4 -9
- package/lib/cjs/utils/index.js +5 -15
- package/lib/cjs/utils/isBothNaN.js +1 -4
- package/lib/cjs/utils/isElement.js +1 -4
- package/lib/cjs/utils/isEnterPress.js +3 -6
- package/lib/cjs/utils/isEscPress.js +3 -6
- package/lib/cjs/utils/isNullOrUndefined.js +1 -4
- package/lib/cjs/utils/isNumber.js +1 -4
- package/lib/cjs/utils/isObject.js +1 -4
- package/lib/cjs/utils/isPromise.js +3 -6
- package/lib/cjs/utils/isString.js +1 -4
- package/lib/cjs/utils/keyCode.js +1 -4
- package/lib/cjs/utils/log.js +3 -6
- package/lib/cjs/utils/number.js +1 -4
- package/lib/cjs/utils/object.js +10 -27
- package/lib/cjs/utils/set.js +4 -9
- package/lib/cjs/utils/shallowEqualObjects.js +3 -10
- package/lib/cjs/utils/touchPolyfill.js +5 -12
- package/lib/cjs/utils/type.js +1 -3
- package/lib/cjs/utils/uuid.js +3 -14
- package/lib/cjs/utils/warning.js +1 -4
- package/lib/es/anchor/anchor.css +1 -10
- package/lib/es/anchor/anchor.scss +1 -8
- package/lib/es/anchor/foundation.js +2 -4
- package/lib/es/anchor/linkFoundation.js +1 -2
- package/lib/es/anchor/rtl.scss +0 -1
- package/lib/es/anchor/variables.scss +1 -0
- package/lib/es/autoComplete/foundation.js +11 -26
- package/lib/es/autoComplete/optionFoundation.js +1 -2
- package/lib/es/avatar/foundation.js +1 -2
- package/lib/es/backtop/foundation.js +1 -2
- package/lib/es/banner/foundation.js +1 -2
- package/lib/es/base/foundation.js +2 -3
- package/lib/es/breadcrumb/foundation.js +3 -6
- package/lib/es/breadcrumb/itemFoundation.js +1 -2
- package/lib/es/calendar/eventUtil.d.ts +3 -3
- package/lib/es/calendar/eventUtil.js +27 -56
- package/lib/es/calendar/foundation.js +60 -90
- package/lib/es/carousel/foundation.js +2 -4
- package/lib/es/cascader/foundation.js +49 -94
- package/lib/es/cascader/util.js +6 -21
- package/lib/es/checkbox/checkboxFoundation.js +3 -6
- package/lib/es/checkbox/checkboxGroupFoundation.js +6 -9
- package/lib/es/collapse/foundation.js +6 -10
- package/lib/es/datePicker/_utils/formatter.js +2 -5
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +2 -3
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +1 -4
- package/lib/es/datePicker/_utils/getMonthTable.js +1 -5
- package/lib/es/datePicker/_utils/getMonthsInYear.js +2 -9
- package/lib/es/datePicker/_utils/getYears.js +1 -3
- package/lib/es/datePicker/constants.js +2 -7
- package/lib/es/datePicker/foundation.js +39 -70
- package/lib/es/datePicker/inputFoundation.js +4 -11
- package/lib/es/datePicker/monthFoundation.js +2 -4
- package/lib/es/datePicker/monthsGridFoundation.js +40 -55
- package/lib/es/datePicker/yearAndMonthFoundation.js +1 -2
- package/lib/es/dropdown/foundation.js +4 -7
- package/lib/es/dropdown/menuFoundation.js +8 -21
- package/lib/es/form/foundation.js +59 -91
- package/lib/es/form/utils.js +11 -19
- package/lib/es/input/foundation.js +4 -9
- package/lib/es/input/textareaFoundation.js +3 -5
- package/lib/es/input/util/calculateNodeHeight.js +2 -10
- package/lib/es/input/util/getSizingData.js +2 -5
- package/lib/es/inputNumber/constants.js +3 -8
- package/lib/es/inputNumber/foundation.js +8 -18
- package/lib/es/modal/modalContentFoundation.js +1 -2
- package/lib/es/modal/modalFoundation.js +1 -2
- package/lib/es/navigation/NavItem.js +5 -11
- package/lib/es/navigation/foundation.js +19 -25
- package/lib/es/navigation/itemFoundation.js +1 -3
- package/lib/es/navigation/subNavFoundation.js +7 -13
- package/lib/es/notification/notificationFoundation.js +2 -4
- package/lib/es/notification/notificationListFoundation.js +1 -3
- package/lib/es/overflowList/constants.js +2 -3
- package/lib/es/overflowList/foundation.js +9 -23
- package/lib/es/pagination/foundation.js +15 -28
- package/lib/es/popover/constants.js +1 -2
- package/lib/es/radio/radioGroupFoundation.js +3 -4
- package/lib/es/radio/radioInnerFoundation.js +2 -3
- package/lib/es/rating/foundation.js +4 -13
- package/lib/es/scrollList/itemFoundation.js +5 -13
- package/lib/es/select/foundation.js +50 -88
- package/lib/es/select/optionFoundation.js +1 -2
- package/lib/es/sideSheet/sideSheetFoundation.js +3 -7
- package/lib/es/slider/foundation.js +10 -16
- package/lib/es/spin/foundation.js +2 -4
- package/lib/es/switch/foundation.js +1 -2
- package/lib/es/table/bodyFoundation.js +6 -11
- package/lib/es/table/foundation.js +67 -93
- package/lib/es/table/utils.js +33 -51
- package/lib/es/tabs/foundation.js +5 -18
- package/lib/es/tagInput/foundation.js +9 -21
- package/lib/es/timePicker/ComboxFoundation.js +7 -16
- package/lib/es/timePicker/foundation.js +23 -37
- package/lib/es/timePicker/inputFoundation.js +1 -2
- package/lib/es/timePicker/utils/index.js +4 -6
- package/lib/es/timePicker/utils/localeDate.js +1 -2
- package/lib/es/toast/toastFoundation.js +2 -4
- package/lib/es/toast/toastListFoundation.js +2 -4
- package/lib/es/tooltip/foundation.js +26 -46
- package/lib/es/transfer/foundation.js +21 -43
- package/lib/es/transfer/transferUtils.js +13 -33
- package/lib/es/tree/foundation.js +38 -70
- package/lib/es/tree/treeUtil.js +57 -109
- package/lib/es/treeSelect/foundation.js +45 -73
- package/lib/es/upload/foundation.js +52 -118
- package/lib/es/upload/utils.js +12 -25
- package/lib/es/utils/Event.js +5 -12
- package/lib/es/utils/FocusHandle.js +3 -7
- package/lib/es/utils/Store.js +4 -12
- package/lib/es/utils/a11y.js +5 -6
- package/lib/es/utils/array.js +3 -5
- package/lib/es/utils/arrayMove.js +2 -6
- package/lib/es/utils/classnames.js +3 -6
- package/lib/es/utils/date-fns-extra.js +6 -14
- package/lib/es/utils/dom.js +1 -2
- package/lib/es/utils/getDataAttr.js +1 -5
- package/lib/es/utils/getHighlight.js +4 -14
- package/lib/es/utils/getMotionObjFromProps.js +1 -2
- package/lib/es/utils/object.js +7 -15
- package/lib/es/utils/set.js +1 -2
- package/lib/es/utils/shallowEqualObjects.js +2 -5
- package/lib/es/utils/touchPolyfill.js +2 -6
- package/lib/es/utils/uuid.js +2 -7
- package/package.json +2 -4
- package/select/foundation.ts +2 -2
package/lib/es/tree/treeUtil.js
CHANGED
|
@@ -7,25 +7,10 @@ import _isObject from "lodash/isObject";
|
|
|
7
7
|
import _max from "lodash/max";
|
|
8
8
|
import _uniq from "lodash/uniq";
|
|
9
9
|
import _difference from "lodash/difference";
|
|
10
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
11
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
12
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
13
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
14
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
15
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
16
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
17
|
-
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
18
|
-
import _everyInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/every";
|
|
19
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
20
|
-
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
|
21
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
22
|
-
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
|
23
10
|
const DRAG_OFFSET = 0.45;
|
|
24
11
|
|
|
25
12
|
function getPosition(level, index) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return _concatInstanceProperty(_context = "".concat(level, "-")).call(_context, index);
|
|
13
|
+
return "".concat(level, "-").concat(index);
|
|
29
14
|
}
|
|
30
15
|
|
|
31
16
|
function isValid(val) {
|
|
@@ -48,18 +33,17 @@ export function flattenTreeData(treeNodeList, expandedKeys) {
|
|
|
48
33
|
|
|
49
34
|
function flatten(list) {
|
|
50
35
|
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
51
|
-
return
|
|
36
|
+
return list.map((treeNode, index) => {
|
|
52
37
|
const pos = getPosition(parent ? parent.pos : '0', index);
|
|
53
38
|
const mergedKey = treeNode.key; // Add FlattenDataNode into list
|
|
54
39
|
|
|
55
|
-
const flattenNode =
|
|
40
|
+
const flattenNode = Object.assign(Object.assign({}, _pick(treeNode, ['key', 'label', 'value', 'icon', 'disabled', 'isLeaf'])), {
|
|
56
41
|
parent,
|
|
57
42
|
pos,
|
|
58
43
|
children: null,
|
|
59
44
|
data: treeNode,
|
|
60
45
|
_innerDataTag: true
|
|
61
46
|
});
|
|
62
|
-
|
|
63
47
|
const isBooleanFilteredShownKeys = typeof filteredShownKeys === 'boolean';
|
|
64
48
|
|
|
65
49
|
if (!filterSearch || !isBooleanFilteredShownKeys && filteredShownKeys.has(mergedKey)) {
|
|
@@ -82,8 +66,6 @@ export function flattenTreeData(treeNodeList, expandedKeys) {
|
|
|
82
66
|
return flattenList;
|
|
83
67
|
}
|
|
84
68
|
export function convertJsonToData(treeJson) {
|
|
85
|
-
var _context3;
|
|
86
|
-
|
|
87
69
|
const treeData = [];
|
|
88
70
|
|
|
89
71
|
const traverseNode = (key, children, path, res) => {
|
|
@@ -96,22 +78,17 @@ export function convertJsonToData(treeJson) {
|
|
|
96
78
|
};
|
|
97
79
|
|
|
98
80
|
if (_isObject(children)) {
|
|
99
|
-
var _context2;
|
|
100
|
-
|
|
101
81
|
const newChildren = [];
|
|
102
|
-
|
|
103
|
-
_forEachInstanceProperty(_context2 = _Object$entries(children)).call(_context2, c => {
|
|
82
|
+
Object.entries(children).forEach(c => {
|
|
104
83
|
traverseNode(c[0], c[1], currPath, newChildren);
|
|
105
84
|
});
|
|
106
|
-
|
|
107
85
|
newNode.children = newChildren;
|
|
108
86
|
}
|
|
109
87
|
|
|
110
88
|
res.push(newNode);
|
|
111
89
|
};
|
|
112
90
|
|
|
113
|
-
|
|
114
|
-
|
|
91
|
+
Object.entries(treeJson).forEach(item => traverseNode(item[0], item[1], [], treeData));
|
|
115
92
|
return treeData;
|
|
116
93
|
}
|
|
117
94
|
/**
|
|
@@ -125,7 +102,7 @@ export function traverseDataNodes(treeNodes, callback) {
|
|
|
125
102
|
|
|
126
103
|
if (node) {
|
|
127
104
|
const data = {
|
|
128
|
-
data:
|
|
105
|
+
data: Object.assign({}, node),
|
|
129
106
|
ind,
|
|
130
107
|
pos,
|
|
131
108
|
key: node.key !== null ? node.key : pos,
|
|
@@ -137,7 +114,7 @@ export function traverseDataNodes(treeNodes, callback) {
|
|
|
137
114
|
|
|
138
115
|
|
|
139
116
|
if (children) {
|
|
140
|
-
|
|
117
|
+
children.forEach((subNode, subIndex) => {
|
|
141
118
|
processNode(subNode, subIndex, {
|
|
142
119
|
node,
|
|
143
120
|
pos,
|
|
@@ -166,8 +143,7 @@ export function convertDataToEntities(dataNodes) {
|
|
|
166
143
|
key,
|
|
167
144
|
parentPos
|
|
168
145
|
} = data;
|
|
169
|
-
|
|
170
|
-
const entity = _Object$assign({}, data);
|
|
146
|
+
const entity = Object.assign({}, data);
|
|
171
147
|
|
|
172
148
|
const value = _get(entity, 'data.value', null);
|
|
173
149
|
|
|
@@ -196,9 +172,9 @@ export function findKeysForValues(valueList, valueEntities) {
|
|
|
196
172
|
return [];
|
|
197
173
|
}
|
|
198
174
|
|
|
199
|
-
if (!isMultiple &&
|
|
175
|
+
if (!isMultiple && Array.isArray(valueList)) {
|
|
200
176
|
valueList = valueList.length ? [valueList[0]] : [];
|
|
201
|
-
} else if (!
|
|
177
|
+
} else if (!Array.isArray(valueList)) {
|
|
202
178
|
valueList = [valueList];
|
|
203
179
|
}
|
|
204
180
|
|
|
@@ -207,13 +183,11 @@ export function findKeysForValues(valueList, valueEntities) {
|
|
|
207
183
|
}
|
|
208
184
|
|
|
209
185
|
const res = [];
|
|
210
|
-
|
|
211
|
-
_forEachInstanceProperty(valueList).call(valueList, val => {
|
|
186
|
+
valueList.forEach(val => {
|
|
212
187
|
if (val in valueEntities) {
|
|
213
188
|
res.push(valueEntities[val]);
|
|
214
189
|
}
|
|
215
190
|
});
|
|
216
|
-
|
|
217
191
|
return res;
|
|
218
192
|
}
|
|
219
193
|
export function findDescendantKeys(selectedKeys, options) {
|
|
@@ -231,32 +205,29 @@ export function findDescendantKeys(selectedKeys, options) {
|
|
|
231
205
|
const hasChildren = isValid(children);
|
|
232
206
|
|
|
233
207
|
if (hasChildren) {
|
|
234
|
-
|
|
208
|
+
children.forEach(child => {
|
|
235
209
|
res.push(child.key);
|
|
236
210
|
findChild(options[child.key]);
|
|
237
211
|
});
|
|
238
212
|
}
|
|
239
213
|
};
|
|
240
214
|
|
|
241
|
-
|
|
215
|
+
selectedKeys.forEach(item => {
|
|
242
216
|
if (self) {
|
|
243
217
|
res.push(item);
|
|
244
218
|
}
|
|
245
219
|
|
|
246
220
|
findChild(options[item]);
|
|
247
221
|
});
|
|
248
|
-
|
|
249
222
|
return res;
|
|
250
223
|
}
|
|
251
224
|
export function findChildKeys(keys, options) {
|
|
252
225
|
let omitKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
253
226
|
const res = [];
|
|
254
|
-
keys &&
|
|
255
|
-
var _context4;
|
|
256
|
-
|
|
227
|
+
keys && keys.forEach(key => {
|
|
257
228
|
const opts = options[key];
|
|
258
|
-
opts && opts.children &&
|
|
259
|
-
if (!omitKeys.length || !
|
|
229
|
+
opts && opts.children && opts.children.forEach(child => {
|
|
230
|
+
if (!omitKeys.length || !omitKeys.includes(child.key)) {
|
|
260
231
|
res.push(child.key);
|
|
261
232
|
}
|
|
262
233
|
});
|
|
@@ -281,28 +252,25 @@ export function findLeafKeys(keys, options) {
|
|
|
281
252
|
if (isLeaf) {
|
|
282
253
|
res.push(item.key);
|
|
283
254
|
} else {
|
|
284
|
-
|
|
255
|
+
children.forEach(child => {
|
|
285
256
|
findChild(options[child.key]);
|
|
286
257
|
});
|
|
287
258
|
}
|
|
288
259
|
};
|
|
289
260
|
|
|
290
|
-
|
|
261
|
+
keys.forEach(item => {
|
|
291
262
|
findChild(options[item]);
|
|
292
263
|
});
|
|
293
|
-
|
|
294
264
|
return res;
|
|
295
265
|
}
|
|
296
266
|
export function findSiblingKeys(selectedKeys, options) {
|
|
297
267
|
let self = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
298
268
|
const par = [];
|
|
299
|
-
|
|
300
|
-
_forEachInstanceProperty(selectedKeys).call(selectedKeys, item => {
|
|
269
|
+
selectedKeys.forEach(item => {
|
|
301
270
|
if (options[item] && options[item].parent) {
|
|
302
271
|
par.push(options[item].parent.key);
|
|
303
272
|
}
|
|
304
273
|
});
|
|
305
|
-
|
|
306
274
|
const res = findChildKeys(_uniq(par), options, self ? [] : selectedKeys);
|
|
307
275
|
return res;
|
|
308
276
|
}
|
|
@@ -317,21 +285,19 @@ export function findAncestorKeys(selectedKeys, options) {
|
|
|
317
285
|
}
|
|
318
286
|
};
|
|
319
287
|
|
|
320
|
-
|
|
288
|
+
selectedKeys.forEach(item => {
|
|
321
289
|
options[item] && findPar(options[item]);
|
|
322
290
|
|
|
323
291
|
if (self) {
|
|
324
292
|
res.push(item);
|
|
325
293
|
}
|
|
326
294
|
});
|
|
327
|
-
|
|
328
295
|
return res;
|
|
329
296
|
}
|
|
330
297
|
|
|
331
298
|
function getSortedKeyList(keyList, keyEntities) {
|
|
332
299
|
const levelMap = {};
|
|
333
|
-
|
|
334
|
-
_forEachInstanceProperty(keyList).call(keyList, key => {
|
|
300
|
+
keyList.forEach(key => {
|
|
335
301
|
if (!keyEntities[key]) {
|
|
336
302
|
return;
|
|
337
303
|
}
|
|
@@ -346,12 +312,11 @@ function getSortedKeyList(keyList, keyEntities) {
|
|
|
346
312
|
levelMap[level] = [key];
|
|
347
313
|
}
|
|
348
314
|
});
|
|
349
|
-
|
|
350
315
|
return levelMap;
|
|
351
316
|
}
|
|
352
317
|
|
|
353
318
|
export function calcCheckedKeys(values, keyEntities) {
|
|
354
|
-
const keyList =
|
|
319
|
+
const keyList = Array.isArray(values) ? values : [values];
|
|
355
320
|
const descendantKeys = findDescendantKeys(keyList, keyEntities, true);
|
|
356
321
|
/**
|
|
357
322
|
* Recursively find the parent element. Because the incoming nodes are all checked,
|
|
@@ -359,8 +324,8 @@ export function calcCheckedKeys(values, keyEntities) {
|
|
|
359
324
|
* disabled+unchecked nodes, their ancestor nodes will definitely not be checked
|
|
360
325
|
*/
|
|
361
326
|
|
|
362
|
-
const checkedKeys = new
|
|
363
|
-
let halfCheckedKeys = new
|
|
327
|
+
const checkedKeys = new Set([...descendantKeys]);
|
|
328
|
+
let halfCheckedKeys = new Set([]);
|
|
364
329
|
let visited = [];
|
|
365
330
|
const levelMap = getSortedKeyList(keyList, keyEntities);
|
|
366
331
|
|
|
@@ -371,19 +336,18 @@ export function calcCheckedKeys(values, keyEntities) {
|
|
|
371
336
|
level
|
|
372
337
|
} = node; // If the node does not have a parent node, or the node has been processed just now, no processing is done
|
|
373
338
|
|
|
374
|
-
if (!parent ||
|
|
339
|
+
if (!parent || visited.includes(key)) {
|
|
375
340
|
return;
|
|
376
341
|
}
|
|
377
342
|
|
|
378
343
|
const siblingKeys = findSiblingKeys([key], keyEntities); // visited for caching to avoid double counting
|
|
379
344
|
|
|
380
345
|
visited = [...visited, ...siblingKeys];
|
|
381
|
-
|
|
382
|
-
const allChecked = _everyInstanceProperty(siblingKeys).call(siblingKeys, siblingKey => checkedKeys.has(siblingKey));
|
|
346
|
+
const allChecked = siblingKeys.every(siblingKey => checkedKeys.has(siblingKey));
|
|
383
347
|
|
|
384
348
|
if (!allChecked) {
|
|
385
349
|
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
386
|
-
halfCheckedKeys = new
|
|
350
|
+
halfCheckedKeys = new Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
387
351
|
} else {
|
|
388
352
|
checkedKeys.add(parent.key); // IMPORTANT! parent level may not exist in original level map; if add to the end directly may destroy the hierarchical order
|
|
389
353
|
|
|
@@ -397,12 +361,9 @@ export function calcCheckedKeys(values, keyEntities) {
|
|
|
397
361
|
|
|
398
362
|
|
|
399
363
|
while (!_isEmpty(levelMap)) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const maxLevel = _max(_mapInstanceProperty(_context5 = _Object$keys(levelMap)).call(_context5, key => Number(key)));
|
|
403
|
-
|
|
404
|
-
_forEachInstanceProperty(_context6 = levelMap[maxLevel]).call(_context6, key => calcCurrLevel(keyEntities[key]));
|
|
364
|
+
const maxLevel = _max(Object.keys(levelMap).map(key => Number(key)));
|
|
405
365
|
|
|
366
|
+
levelMap[maxLevel].forEach(key => calcCurrLevel(keyEntities[key]));
|
|
406
367
|
delete levelMap[maxLevel];
|
|
407
368
|
}
|
|
408
369
|
|
|
@@ -418,23 +379,23 @@ export function calcExpandedKeys() {
|
|
|
418
379
|
let keyEntities = arguments.length > 1 ? arguments[1] : undefined;
|
|
419
380
|
let autoExpandParent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
420
381
|
|
|
421
|
-
if (!
|
|
382
|
+
if (!Array.isArray(keyList)) {
|
|
422
383
|
keyList = [keyList];
|
|
423
384
|
}
|
|
424
385
|
|
|
425
386
|
if (autoExpandParent) {
|
|
426
387
|
const ancestorKeys = findAncestorKeys(keyList, keyEntities, true);
|
|
427
|
-
return new
|
|
388
|
+
return new Set(ancestorKeys);
|
|
428
389
|
}
|
|
429
390
|
|
|
430
|
-
return new
|
|
391
|
+
return new Set(keyList);
|
|
431
392
|
}
|
|
432
393
|
/* Calculate the expanded node by value */
|
|
433
394
|
// eslint-disable-next-line max-len
|
|
434
395
|
|
|
435
396
|
export function calcExpandedKeysForValues(value, keyEntities, isMultiple, valueEntities) {
|
|
436
397
|
const keys = findKeysForValues(value, valueEntities, isMultiple);
|
|
437
|
-
return new
|
|
398
|
+
return new Set(findAncestorKeys(keys, keyEntities, false));
|
|
438
399
|
}
|
|
439
400
|
export function calcMotionKeys(oldKeySet, newKeySet, keyEntities) {
|
|
440
401
|
let motionType = 'show';
|
|
@@ -477,10 +438,8 @@ export function filter(sugInput, option, filterTreeNode, filterProps) {
|
|
|
477
438
|
|
|
478
439
|
if (typeof filterTreeNode === 'boolean') {
|
|
479
440
|
filterFn = (targetVal, val) => {
|
|
480
|
-
var _context7;
|
|
481
|
-
|
|
482
441
|
const input = targetVal.toLowerCase();
|
|
483
|
-
return
|
|
442
|
+
return val.toString().toLowerCase().includes(input);
|
|
484
443
|
};
|
|
485
444
|
}
|
|
486
445
|
|
|
@@ -491,7 +450,7 @@ export function filter(sugInput, option, filterTreeNode, filterProps) {
|
|
|
491
450
|
return filterFn(sugInput, target);
|
|
492
451
|
}
|
|
493
452
|
export function normalizedArr(val) {
|
|
494
|
-
if (!
|
|
453
|
+
if (!Array.isArray(val)) {
|
|
495
454
|
return [val];
|
|
496
455
|
} else {
|
|
497
456
|
return val;
|
|
@@ -500,10 +459,10 @@ export function normalizedArr(val) {
|
|
|
500
459
|
export function normalizeKeyList(keyList, keyEntities) {
|
|
501
460
|
let leafOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
502
461
|
const res = [];
|
|
503
|
-
const keyListSet = new
|
|
462
|
+
const keyListSet = new Set(keyList);
|
|
504
463
|
|
|
505
464
|
if (!leafOnly) {
|
|
506
|
-
|
|
465
|
+
keyList.forEach(key => {
|
|
507
466
|
if (!keyEntities[key]) {
|
|
508
467
|
return;
|
|
509
468
|
}
|
|
@@ -519,7 +478,7 @@ export function normalizeKeyList(keyList, keyEntities) {
|
|
|
519
478
|
res.push(key);
|
|
520
479
|
});
|
|
521
480
|
} else {
|
|
522
|
-
|
|
481
|
+
keyList.forEach(key => {
|
|
523
482
|
if (keyEntities[key] && !isValid(keyEntities[key].children)) {
|
|
524
483
|
res.push(key);
|
|
525
484
|
}
|
|
@@ -532,9 +491,7 @@ export function getMotionKeys(eventKey, expandedKeys, keyEntities) {
|
|
|
532
491
|
const res = [];
|
|
533
492
|
|
|
534
493
|
const getChild = itemKey => {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
keyEntities[itemKey].children && _forEachInstanceProperty(_context8 = keyEntities[itemKey].children).call(_context8, item => {
|
|
494
|
+
keyEntities[itemKey].children && keyEntities[itemKey].children.forEach(item => {
|
|
538
495
|
const {
|
|
539
496
|
key
|
|
540
497
|
} = item;
|
|
@@ -553,7 +510,7 @@ export function getMotionKeys(eventKey, expandedKeys, keyEntities) {
|
|
|
553
510
|
export function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfCheckedKeys) {
|
|
554
511
|
const descendantKeys = findDescendantKeys([key], keyEntities, true);
|
|
555
512
|
const nodeItem = keyEntities[key];
|
|
556
|
-
checkedKeys = new
|
|
513
|
+
checkedKeys = new Set([...checkedKeys, key]);
|
|
557
514
|
|
|
558
515
|
const calcCurrLevel = node => {
|
|
559
516
|
if (!node.parent) {
|
|
@@ -566,11 +523,11 @@ export function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfChe
|
|
|
566
523
|
} = node;
|
|
567
524
|
const siblingKeys = findSiblingKeys([key], keyEntities); // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
568
525
|
|
|
569
|
-
const allChecked =
|
|
526
|
+
const allChecked = siblingKeys.every(key => checkedKeys.has(key));
|
|
570
527
|
|
|
571
528
|
if (!allChecked) {
|
|
572
529
|
const ancestorKeys = findAncestorKeys([key], keyEntities, false);
|
|
573
|
-
halfCheckedKeys = new
|
|
530
|
+
halfCheckedKeys = new Set([...halfCheckedKeys, ...ancestorKeys]);
|
|
574
531
|
} else {
|
|
575
532
|
const par = node.parent;
|
|
576
533
|
checkedKeys.add(par.key);
|
|
@@ -580,7 +537,7 @@ export function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfChe
|
|
|
580
537
|
|
|
581
538
|
calcCurrLevel(nodeItem);
|
|
582
539
|
return {
|
|
583
|
-
checkedKeys: new
|
|
540
|
+
checkedKeys: new Set([...checkedKeys, ...descendantKeys]),
|
|
584
541
|
halfCheckedKeys
|
|
585
542
|
};
|
|
586
543
|
} // eslint-disable-next-line max-len
|
|
@@ -588,8 +545,7 @@ export function calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfChe
|
|
|
588
545
|
export function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedKeys) {
|
|
589
546
|
const descendantKeys = findDescendantKeys([key], keyEntities, true);
|
|
590
547
|
const nodeItem = keyEntities[key];
|
|
591
|
-
|
|
592
|
-
_forEachInstanceProperty(descendantKeys).call(descendantKeys, descendantKey => {
|
|
548
|
+
descendantKeys.forEach(descendantKey => {
|
|
593
549
|
if (checkedKeys.has(descendantKey)) {
|
|
594
550
|
checkedKeys.delete(descendantKey);
|
|
595
551
|
}
|
|
@@ -618,18 +574,16 @@ export function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfC
|
|
|
618
574
|
} = node;
|
|
619
575
|
const siblingKeys = findSiblingKeys([key], keyEntities); // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
620
576
|
|
|
621
|
-
const anyChecked =
|
|
622
|
-
|
|
577
|
+
const anyChecked = siblingKeys.some(key => checkedKeys.has(key) || halfCheckedKeys.has(key));
|
|
623
578
|
const ancestorKeys = findAncestorKeys([key], keyEntities, false); // If there is checked or halfChecked in the sibling node, you need to change the parent node to halfChecked
|
|
624
579
|
|
|
625
580
|
if (anyChecked) {
|
|
626
|
-
|
|
581
|
+
ancestorKeys.forEach(itemKey => {
|
|
627
582
|
if (checkedKeys.has(itemKey)) {
|
|
628
583
|
checkedKeys.delete(itemKey);
|
|
629
584
|
halfCheckedKeys.add(itemKey);
|
|
630
585
|
}
|
|
631
586
|
}); // If there is no checked or halfChecked in the sibling node, you need to change the parent node to unchecked
|
|
632
|
-
|
|
633
587
|
} else {
|
|
634
588
|
if (checkedKeys.has(par.key)) {
|
|
635
589
|
checkedKeys.delete(par.key);
|
|
@@ -650,8 +604,6 @@ export function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfC
|
|
|
650
604
|
};
|
|
651
605
|
}
|
|
652
606
|
export function filterTreeData(info) {
|
|
653
|
-
var _context9, _context10;
|
|
654
|
-
|
|
655
607
|
const {
|
|
656
608
|
showFilteredOnly,
|
|
657
609
|
keyEntities,
|
|
@@ -662,29 +614,28 @@ export function filterTreeData(info) {
|
|
|
662
614
|
prevExpandedKeys
|
|
663
615
|
} = info;
|
|
664
616
|
let filteredOptsKeys = [];
|
|
665
|
-
filteredOptsKeys =
|
|
617
|
+
filteredOptsKeys = Object.values(keyEntities).filter(item => filter(inputValue, item.data, filterTreeNode, filterProps)).map(item => item.key);
|
|
666
618
|
let expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
667
619
|
|
|
668
620
|
if (prevExpandedKeys.length) {
|
|
669
|
-
const prevExpandedValidKeys =
|
|
670
|
-
|
|
671
|
-
expandedOptsKeys = _concatInstanceProperty(expandedOptsKeys).call(expandedOptsKeys, prevExpandedValidKeys);
|
|
621
|
+
const prevExpandedValidKeys = prevExpandedKeys.filter(key => Boolean(keyEntities[key]));
|
|
622
|
+
expandedOptsKeys = expandedOptsKeys.concat(prevExpandedValidKeys);
|
|
672
623
|
}
|
|
673
624
|
|
|
674
625
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
675
|
-
const filteredShownKeys = new
|
|
676
|
-
const flattenNodes = flattenTreeData(treeData, new
|
|
626
|
+
const filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
627
|
+
const flattenNodes = flattenTreeData(treeData, new Set(expandedOptsKeys), showFilteredOnly && filteredShownKeys);
|
|
677
628
|
return {
|
|
678
629
|
flattenNodes,
|
|
679
|
-
filteredKeys: new
|
|
680
|
-
filteredExpandedKeys: new
|
|
630
|
+
filteredKeys: new Set(filteredOptsKeys),
|
|
631
|
+
filteredExpandedKeys: new Set(expandedOptsKeys),
|
|
681
632
|
filteredShownKeys
|
|
682
633
|
};
|
|
683
634
|
} // return data.value if data.value exist else fall back to key
|
|
684
635
|
|
|
685
636
|
export function getValueOrKey(data) {
|
|
686
|
-
if (
|
|
687
|
-
return
|
|
637
|
+
if (Array.isArray(data)) {
|
|
638
|
+
return data.map(item => _get(item, 'value', item.key));
|
|
688
639
|
}
|
|
689
640
|
|
|
690
641
|
return _get(data, 'value', data.key);
|
|
@@ -700,13 +651,10 @@ export function normalizeValue(value, withObject) {
|
|
|
700
651
|
}
|
|
701
652
|
export function updateKeys(keySet, keyEntities) {
|
|
702
653
|
const keyArr = [...keySet];
|
|
703
|
-
return
|
|
654
|
+
return keyArr.filter(key => key in keyEntities);
|
|
704
655
|
}
|
|
705
656
|
export function calcDisabledKeys(keyEntities) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
const disabledKeys = _filterInstanceProperty(_context11 = _Object$keys(keyEntities)).call(_context11, key => keyEntities[key].data.disabled);
|
|
709
|
-
|
|
657
|
+
const disabledKeys = Object.keys(keyEntities).filter(key => keyEntities[key].data.disabled);
|
|
710
658
|
const {
|
|
711
659
|
checkedKeys
|
|
712
660
|
} = calcCheckedKeys(disabledKeys, keyEntities);
|