@sheinx/base 3.0.9 → 3.0.11
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/cjs/cascader/cascader.d.ts.map +1 -1
- package/cjs/cascader/cascader.js +2 -2
- package/cjs/date-picker/date-picker.type.d.ts +1 -0
- package/cjs/date-picker/date-picker.type.d.ts.map +1 -1
- package/cjs/date-picker/result.d.ts.map +1 -1
- package/cjs/date-picker/result.js +5 -3
- package/cjs/select/list-option.d.ts.map +1 -1
- package/cjs/select/list-option.js +1 -0
- package/cjs/select/result-input.d.ts.map +1 -1
- package/cjs/select/result-input.js +1 -4
- package/cjs/select/result.d.ts.map +1 -1
- package/cjs/select/result.js +19 -24
- package/cjs/select/select.d.ts.map +1 -1
- package/cjs/select/select.js +4 -15
- package/cjs/textarea/use-auto-size.d.ts.map +1 -1
- package/cjs/textarea/use-auto-size.js +1 -0
- package/cjs/tree/tree-checkbox.d.ts.map +1 -1
- package/cjs/tree/tree-checkbox.js +8 -1
- package/cjs/tree/tree-content.d.ts.map +1 -1
- package/cjs/tree/tree-content.js +4 -1
- package/cjs/tree/tree-context.d.ts +3 -3
- package/cjs/tree/tree-context.d.ts.map +1 -1
- package/cjs/tree/tree.d.ts.map +1 -1
- package/cjs/tree/tree.js +3 -14
- package/cjs/tree-select/tree-select.d.ts.map +1 -1
- package/cjs/tree-select/tree-select.js +99 -67
- package/esm/cascader/cascader.d.ts.map +1 -1
- package/esm/cascader/cascader.js +2 -2
- package/esm/date-picker/date-picker.type.d.ts +1 -0
- package/esm/date-picker/date-picker.type.d.ts.map +1 -1
- package/esm/date-picker/result.d.ts.map +1 -1
- package/esm/date-picker/result.js +5 -3
- package/esm/select/list-option.d.ts.map +1 -1
- package/esm/select/list-option.js +1 -0
- package/esm/select/result-input.d.ts.map +1 -1
- package/esm/select/result-input.js +1 -4
- package/esm/select/result.d.ts.map +1 -1
- package/esm/select/result.js +19 -24
- package/esm/select/select.d.ts.map +1 -1
- package/esm/select/select.js +4 -15
- package/esm/textarea/use-auto-size.d.ts.map +1 -1
- package/esm/textarea/use-auto-size.js +1 -0
- package/esm/tree/tree-checkbox.d.ts.map +1 -1
- package/esm/tree/tree-checkbox.js +8 -1
- package/esm/tree/tree-content.d.ts.map +1 -1
- package/esm/tree/tree-content.js +5 -2
- package/esm/tree/tree-context.d.ts +3 -3
- package/esm/tree/tree-context.d.ts.map +1 -1
- package/esm/tree/tree.d.ts.map +1 -1
- package/esm/tree/tree.js +4 -15
- package/esm/tree-select/tree-select.d.ts.map +1 -1
- package/esm/tree-select/tree-select.js +100 -68
- package/package.json +2 -2
package/esm/tree/tree-content.js
CHANGED
|
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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); }
|
|
7
7
|
import classNames from 'classnames';
|
|
8
|
-
import { util } from '@sheinx/hooks';
|
|
8
|
+
import { util, useRender } from '@sheinx/hooks';
|
|
9
9
|
import Checkbox from "./tree-checkbox";
|
|
10
10
|
import { useTreeContext } from "./tree-context";
|
|
11
11
|
import Icons from "../icons";
|
|
@@ -36,9 +36,12 @@ var NodeContent = function NodeContent(props) {
|
|
|
36
36
|
onToggle = props.onToggle,
|
|
37
37
|
onDragOver = props.onDragOver,
|
|
38
38
|
onNodeClick = props.onNodeClick;
|
|
39
|
+
var forceUpdate = useRender();
|
|
39
40
|
var _useTreeContext = useTreeContext(),
|
|
40
|
-
isDisabled = _useTreeContext.isDisabled
|
|
41
|
+
isDisabled = _useTreeContext.isDisabled,
|
|
42
|
+
bindUpdate = _useTreeContext.bindUpdate;
|
|
41
43
|
var disabled = isDisabled(id);
|
|
44
|
+
bindUpdate(id, forceUpdate);
|
|
42
45
|
var contentStyle = (jssStyle === null || jssStyle === void 0 ? void 0 : jssStyle.tree()) || {};
|
|
43
46
|
var rootClass = classNames(contentStyle.contentWrapper, _defineProperty(_defineProperty({}, contentStyle.childnode, data[childrenKey] && data[childrenKey].length > 0), contentStyle.inlineContent, inlineNode));
|
|
44
47
|
var contentClass = classNames(contentStyle.content, util.isString(contentClassProp) && contentClassProp, util.isFunc(contentClassProp) && contentClassProp(data));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const TreeContext: React.Context<
|
|
2
|
+
import { TreeProviderProps } from './tree-context.type';
|
|
3
|
+
export declare const TreeContext: React.Context<import("../../../hooks/src/components/use-tree/use-tree.type").TreeDatum<any>>;
|
|
4
4
|
export declare const Provider: <DataItem>(props: TreeProviderProps<DataItem>) => JSX.Element;
|
|
5
|
-
export declare const useTreeContext: () =>
|
|
5
|
+
export declare const useTreeContext: () => import("../../../hooks/src/components/use-tree/use-tree.type").TreeDatum<any>;
|
|
6
6
|
//# sourceMappingURL=tree-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-context.d.ts","sourceRoot":"","sources":["tree-context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"tree-context.d.ts","sourceRoot":"","sources":["tree-context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAoB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,eAAO,MAAM,WAAW,8FAA0E,CAAC;AAEnG,eAAO,MAAM,QAAQ,+DAGpB,CAAC;AAEF,eAAO,MAAM,cAAc,qFAAsC,CAAC"}
|
package/esm/tree/tree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,QAAA,MAAM,IAAI,4FA8NT,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/esm/tree/tree.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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
|
-
var _excluded = ["jssStyle", "line", "childrenKey", "data", "value", "mode", "keygen", "expanded", "expandIcons", "iconClass", "leafClass", "nodeClass", "contentClass", "renderItem", "defaultValue", "dataUpdate", "childrenClass", "defaultExpandAll", "defaultExpanded", "parentClickExpand", "doubleClickExpand", "dragImageSelector", "dragImageStyle", "dragSibling", "unmatch", "dragHoverExpand", "active", "disabled", "inlineNode", "highlight", "className", "onClick", "loader", "getDatum", "onDrop", "onExpand", "onChange", "onDragEnd", "onDragLeave", "onDragOver", "onDragStart", "
|
|
2
|
+
var _excluded = ["jssStyle", "line", "childrenKey", "data", "value", "mode", "keygen", "expanded", "expandIcons", "iconClass", "leafClass", "nodeClass", "contentClass", "renderItem", "defaultValue", "dataUpdate", "childrenClass", "defaultExpandAll", "defaultExpanded", "parentClickExpand", "doubleClickExpand", "dragImageSelector", "dragImageStyle", "dragSibling", "unmatch", "dragHoverExpand", "active", "disabled", "inlineNode", "highlight", "className", "onClick", "loader", "getDatum", "onDrop", "onExpand", "onChange", "onDragEnd", "onDragLeave", "onDragOver", "onDragStart", "datum"];
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
@@ -15,7 +15,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
15
15
|
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; }
|
|
16
16
|
import { useEffect } from 'react';
|
|
17
17
|
import classNames from 'classnames';
|
|
18
|
-
import { useTree, util
|
|
18
|
+
import { useTree, util } from '@sheinx/hooks';
|
|
19
19
|
import RootTree from "./tree-root";
|
|
20
20
|
import { Provider } from "./tree-context";
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -66,9 +66,8 @@ var Tree = function Tree(props) {
|
|
|
66
66
|
onDragLeave = props.onDragLeave,
|
|
67
67
|
onDragOver = props.onDragOver,
|
|
68
68
|
onDragStart = props.onDragStart,
|
|
69
|
-
|
|
69
|
+
propsDatum = props.datum,
|
|
70
70
|
rest = _objectWithoutProperties(props, _excluded);
|
|
71
|
-
var prevData = usePrevious(data);
|
|
72
71
|
var _useTree = useTree({
|
|
73
72
|
mode: mode,
|
|
74
73
|
value: value,
|
|
@@ -85,7 +84,7 @@ var Tree = function Tree(props) {
|
|
|
85
84
|
childrenKey: childrenKey,
|
|
86
85
|
keygen: keygen,
|
|
87
86
|
onExpand: onExpandProp,
|
|
88
|
-
|
|
87
|
+
datum: propsDatum
|
|
89
88
|
}),
|
|
90
89
|
datum = _useTree.datum,
|
|
91
90
|
expanded = _useTree.expanded,
|
|
@@ -186,16 +185,6 @@ var Tree = function Tree(props) {
|
|
|
186
185
|
useEffect(function () {
|
|
187
186
|
handleUpdateExpanded(expanded);
|
|
188
187
|
}, [expanded]);
|
|
189
|
-
useEffect(function () {
|
|
190
|
-
if (!prevData) return;
|
|
191
|
-
if (prevData !== data && dataUpdate) {
|
|
192
|
-
datum.setData(data);
|
|
193
|
-
}
|
|
194
|
-
}, [data]);
|
|
195
|
-
useEffect(function () {
|
|
196
|
-
if (!value) return;
|
|
197
|
-
datum.setValue(value);
|
|
198
|
-
}, [value]);
|
|
199
188
|
useEffect(function () {
|
|
200
189
|
if (getDatum) getDatum(datum);
|
|
201
190
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-select.d.ts","sourceRoot":"","sources":["tree-select.tsx"],"names":[],"mappings":";AACA,OAAO,EAQL,YAAY,EAEb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAc,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tree-select.d.ts","sourceRoot":"","sources":["tree-select.tsx"],"names":[],"mappings":";AACA,OAAO,EAQL,YAAY,EAEb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAc,MAAM,oBAAoB,CAAC;AAajE,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC;AAIhE,QAAA,MAAM,UAAU,wGA8oBf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import React, { useRef, useEffect, useState } from 'react';
|
|
14
|
-
import { util, usePersistFn, useTiled, usePopup, useTreeSelect, useFilter,
|
|
14
|
+
import { util, usePersistFn, useTiled, usePopup, useTreeSelect, useFilter, useTree } from '@sheinx/hooks';
|
|
15
15
|
import classNames from 'classnames';
|
|
16
16
|
import { AbsoluteList } from "../absolute-list";
|
|
17
17
|
import useInnerTitle from "../common/use-inner-title";
|
|
@@ -32,7 +32,6 @@ var preventDefault = function preventDefault(e) {
|
|
|
32
32
|
var TreeSelect = function TreeSelect(props0) {
|
|
33
33
|
var _jssStyle$treeSelect;
|
|
34
34
|
var props = useWithFormConfig(props0);
|
|
35
|
-
var render = useRender();
|
|
36
35
|
var _useConfig = useConfig(),
|
|
37
36
|
locale = _useConfig.locale;
|
|
38
37
|
var jssStyle = props.jssStyle,
|
|
@@ -40,9 +39,11 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
40
39
|
size = props.size,
|
|
41
40
|
valueProp = props.value,
|
|
42
41
|
defaultValue = props.defaultValue,
|
|
43
|
-
data = props.data,
|
|
42
|
+
_props$data = props.data,
|
|
43
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
44
44
|
multiple = props.multiple,
|
|
45
|
-
mode = props.mode,
|
|
45
|
+
_props$mode = props.mode,
|
|
46
|
+
mode = _props$mode === void 0 ? 1 : _props$mode,
|
|
46
47
|
_props$line = props.line,
|
|
47
48
|
line = _props$line === void 0 ? false : _props$line,
|
|
48
49
|
innerTitle = props.innerTitle,
|
|
@@ -102,9 +103,12 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
102
103
|
width: width
|
|
103
104
|
}, style);
|
|
104
105
|
var showInput = util.isFunc(props.onAdvancedFilter || onFilterProp);
|
|
105
|
-
var datum = useRef();
|
|
106
106
|
var blurEvent = useRef();
|
|
107
107
|
var inputRef = useRef();
|
|
108
|
+
var _useRef = useRef({
|
|
109
|
+
cachedMap: new Map()
|
|
110
|
+
}),
|
|
111
|
+
context = _useRef.current;
|
|
108
112
|
var _useState = useState(false),
|
|
109
113
|
_useState2 = _slicedToArray(_useState, 2),
|
|
110
114
|
focused = _useState2[0],
|
|
@@ -114,7 +118,8 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
114
118
|
onChange: onChangeProp,
|
|
115
119
|
defaultValue: defaultValue,
|
|
116
120
|
control: 'value' in props,
|
|
117
|
-
filterSameChange: filterSameChange
|
|
121
|
+
filterSameChange: filterSameChange,
|
|
122
|
+
multiple: multiple
|
|
118
123
|
}),
|
|
119
124
|
value = _useTreeSelect.value,
|
|
120
125
|
onChange = _useTreeSelect.onChange;
|
|
@@ -145,6 +150,23 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
145
150
|
onFilter = _useFilter.onFilter,
|
|
146
151
|
onClearCreatedData = _useFilter.onClearCreatedData,
|
|
147
152
|
setInputText = _useFilter.setInputText;
|
|
153
|
+
var controlExpanded = 'expanded' in props || expanded !== null && expanded !== void 0 && expanded.length ? expanded : undefined;
|
|
154
|
+
var _useTree = useTree({
|
|
155
|
+
mode: mode,
|
|
156
|
+
value: value,
|
|
157
|
+
data: data,
|
|
158
|
+
unmatch: unmatch,
|
|
159
|
+
disabled: disabled,
|
|
160
|
+
childrenKey: childrenKey,
|
|
161
|
+
keygen: keygen,
|
|
162
|
+
onExpand: onExpand,
|
|
163
|
+
expanded: controlExpanded,
|
|
164
|
+
defaultExpanded: defaultExpanded,
|
|
165
|
+
defaultExpandAll: defaultExpandAll,
|
|
166
|
+
isControlled: controlExpanded !== undefined
|
|
167
|
+
}),
|
|
168
|
+
datum = _useTree.datum,
|
|
169
|
+
onExpandTree = _useTree.onExpand;
|
|
148
170
|
var renderMoreIcon = function renderMoreIcon() {
|
|
149
171
|
return Icons.treeSelect.More;
|
|
150
172
|
};
|
|
@@ -195,10 +217,6 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
195
217
|
jssStyle: props.jssStyle
|
|
196
218
|
});
|
|
197
219
|
var rootClass = classNames(className, isEmpty && styles.wrapperEmpty, styles === null || styles === void 0 ? void 0 : styles.wrapper, open && (styles === null || styles === void 0 ? void 0 : styles.wrapperOpen), disabled === true && (styles === null || styles === void 0 ? void 0 : styles.wrapperDisabled), !!open && (styles === null || styles === void 0 ? void 0 : styles.wrapperFocus), disabled !== true && focused && (styles === null || styles === void 0 ? void 0 : styles.wrapperFocus), innerTitle && (styles === null || styles === void 0 ? void 0 : styles.wrapperInnerTitle), size === 'small' && (styles === null || styles === void 0 ? void 0 : styles.wrapperSmall), size === 'large' && (styles === null || styles === void 0 ? void 0 : styles.wrapperLarge), (!!props.error || props.status === 'error') && (styles === null || styles === void 0 ? void 0 : styles.wrapperError), clearable && (styles === null || styles === void 0 ? void 0 : styles.clearable), !border && (styles === null || styles === void 0 ? void 0 : styles.wrapperNoBorder), !!underline && (styles === null || styles === void 0 ? void 0 : styles.wrapperUnderline), _defineProperty({}, styles === null || styles === void 0 ? void 0 : styles.multiple, multiple));
|
|
198
|
-
var bindTreeDatum = function bindTreeDatum(treeDatum) {
|
|
199
|
-
datum.current = treeDatum;
|
|
200
|
-
render();
|
|
201
|
-
};
|
|
202
220
|
var getRenderItem = function getRenderItem(data, expanded, active, id) {
|
|
203
221
|
return typeof renderItemProp === 'function' ? renderItemProp(data, expanded, active, id) : data[renderItemProp];
|
|
204
222
|
};
|
|
@@ -254,9 +272,9 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
254
272
|
};
|
|
255
273
|
var handleClear = function handleClear(e) {
|
|
256
274
|
e.stopPropagation();
|
|
257
|
-
if (!datum
|
|
258
|
-
datum.
|
|
259
|
-
onChange(multiple ? [] : '');
|
|
275
|
+
if (!datum) return;
|
|
276
|
+
datum.setValue([]);
|
|
277
|
+
onChange(multiple ? [] : ['']);
|
|
260
278
|
if (onChangeAddition) {
|
|
261
279
|
onChangeAddition({
|
|
262
280
|
data: multiple ? [] : null
|
|
@@ -264,9 +282,6 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
264
282
|
}
|
|
265
283
|
if (open) closePop();
|
|
266
284
|
};
|
|
267
|
-
var handleExpand = function handleExpand(expands) {
|
|
268
|
-
onExpand === null || onExpand === void 0 || onExpand(expands);
|
|
269
|
-
};
|
|
270
285
|
var renderClearable = function renderClearable() {
|
|
271
286
|
if (!multiple !== undefined && !showArrow) return null;
|
|
272
287
|
var defaultIcon = multiple ? Icons.treeSelect.More : Icons.treeSelect.DropdownArrow;
|
|
@@ -296,37 +311,43 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
296
311
|
children: defaultIcon
|
|
297
312
|
});
|
|
298
313
|
};
|
|
314
|
+
var getDataById = usePersistFn(function (id) {
|
|
315
|
+
if (!props.noCache) {
|
|
316
|
+
if (context.cachedMap.has(id)) {
|
|
317
|
+
return context.cachedMap.get(id);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (!datum) return undefined;
|
|
321
|
+
var origin = datum === null || datum === void 0 ? void 0 : datum.getDataById(id);
|
|
322
|
+
if (!props.noCache && !(datum !== null && datum !== void 0 && datum.isUnMatched(origin))) {
|
|
323
|
+
context.cachedMap.set(id, origin);
|
|
324
|
+
}
|
|
325
|
+
return origin;
|
|
326
|
+
});
|
|
299
327
|
var getDataByValues = function getDataByValues(values) {
|
|
300
|
-
if (!datum
|
|
301
|
-
return datum.
|
|
328
|
+
if (!datum || !values) return [];
|
|
329
|
+
return datum.getDataByValues(values);
|
|
302
330
|
};
|
|
303
331
|
var getDataByValuesRef = function getDataByValuesRef(values) {
|
|
304
|
-
var _datum$current2;
|
|
305
332
|
if (util.isArray(values)) {
|
|
306
333
|
return values.map(function (id) {
|
|
307
|
-
|
|
308
|
-
return (_datum$current = datum.current) === null || _datum$current === void 0 ? void 0 : _datum$current.getDataById(id);
|
|
334
|
+
return datum === null || datum === void 0 ? void 0 : datum.getDataById(id);
|
|
309
335
|
});
|
|
310
336
|
}
|
|
311
|
-
return
|
|
337
|
+
return datum === null || datum === void 0 ? void 0 : datum.getDataById(values);
|
|
312
338
|
};
|
|
313
339
|
var getValue = function getValue() {
|
|
314
|
-
if (!datum
|
|
315
|
-
var nextValue = datum.
|
|
340
|
+
if (!datum) return;
|
|
341
|
+
var nextValue = datum.getValue();
|
|
316
342
|
if (multiple) return nextValue;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var getValueArray = function getValueArray(value) {
|
|
320
|
-
if (!value) return [];
|
|
321
|
-
if (!Array.isArray(value)) return [value];
|
|
322
|
-
return value;
|
|
343
|
+
if (nextValue.length === 0) return [];
|
|
344
|
+
return [nextValue[0]];
|
|
323
345
|
};
|
|
324
346
|
var getContentClass = function getContentClass(data) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
var isCheck = (_datum$current4 = datum.current) === null || _datum$current4 === void 0 ? void 0 : _datum$current4.getChecked(key);
|
|
347
|
+
if (!datum) return '';
|
|
348
|
+
var key = datum.getKey(data);
|
|
349
|
+
var isDisabled = datum === null || datum === void 0 ? void 0 : datum.isDisabled(key);
|
|
350
|
+
var isCheck = datum === null || datum === void 0 ? void 0 : datum.getChecked(key);
|
|
330
351
|
if (isDisabled) {
|
|
331
352
|
return classNames(styles.optionDisabled);
|
|
332
353
|
}
|
|
@@ -357,46 +378,62 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
357
378
|
onTiledFilter === null || onTiledFilter === void 0 || onTiledFilter(trim ? text.trim() : text);
|
|
358
379
|
};
|
|
359
380
|
var handleChange = function handleChange(item, id) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (disabled === true || (_datum$current5 = datum.current) !== null && _datum$current5 !== void 0 && _datum$current5.isDisabled(id)) return;
|
|
363
|
-
var currentData = datum.current.getDataById(id);
|
|
381
|
+
if (disabled === true || datum !== null && datum !== void 0 && datum.isDisabled(id)) return;
|
|
382
|
+
var currentData = datum.getDataById(id);
|
|
364
383
|
if (!multiple) {
|
|
365
|
-
datum.
|
|
366
|
-
datum.
|
|
384
|
+
datum.setValue([]);
|
|
385
|
+
datum.set(datum.getKey(item), 1);
|
|
367
386
|
}
|
|
368
387
|
var nextValue = getValue();
|
|
369
388
|
if (onChange) {
|
|
370
|
-
onChange(nextValue, currentData, id ? (datum.
|
|
389
|
+
onChange(nextValue, currentData, id ? (datum.getPath(id) || {}).path : undefined);
|
|
371
390
|
}
|
|
372
391
|
if (typeof onChangeAddition === 'function') {
|
|
373
392
|
onChangeAddition({
|
|
374
393
|
data: getDataByValues(nextValue),
|
|
375
|
-
checked: multiple ? datum.
|
|
394
|
+
checked: multiple ? datum.get(id) : undefined,
|
|
376
395
|
current: currentData
|
|
377
396
|
});
|
|
378
397
|
}
|
|
379
398
|
};
|
|
380
|
-
var
|
|
399
|
+
var handleTreeClick = function handleTreeClick(item, id) {
|
|
381
400
|
handleChange(item, id);
|
|
382
|
-
|
|
401
|
+
closePop();
|
|
383
402
|
};
|
|
384
|
-
var
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
403
|
+
var handleTreeChange = function handleTreeChange(_value, id) {
|
|
404
|
+
var item = datum.getDataById(id);
|
|
405
|
+
handleChange(item, id);
|
|
406
|
+
};
|
|
407
|
+
var handleRemove = function handleRemove(item, key) {
|
|
408
|
+
if (!datum) return;
|
|
409
|
+
var dataKey = key !== null && key !== void 0 ? key : util.isUnMatchedData(item) ? item.value : datum.getKey(item);
|
|
410
|
+
var isDisabled = datum.isDisabled(dataKey);
|
|
388
411
|
if (isDisabled) return;
|
|
389
|
-
datum.
|
|
390
|
-
handleChange(item,
|
|
412
|
+
datum.set(dataKey, 0);
|
|
413
|
+
handleChange(item, dataKey);
|
|
391
414
|
};
|
|
392
415
|
|
|
393
416
|
// innerTitle 模式
|
|
394
417
|
var renderInnerTitle = useInnerTitle({
|
|
395
|
-
open: open || !!value,
|
|
418
|
+
open: open || !!(value && value.length),
|
|
396
419
|
size: size,
|
|
397
420
|
jssStyle: jssStyle,
|
|
398
421
|
innerTitle: innerTitle
|
|
399
422
|
});
|
|
423
|
+
var getResultByValue = usePersistFn(function (arr) {
|
|
424
|
+
var result = (Array.isArray(arr) ? arr : [arr]).map(function (id) {
|
|
425
|
+
return getDataById(id);
|
|
426
|
+
}).filter(function (item) {
|
|
427
|
+
return item !== undefined;
|
|
428
|
+
});
|
|
429
|
+
return result;
|
|
430
|
+
});
|
|
431
|
+
var getResultValue = function getResultValue() {
|
|
432
|
+
if (!multiple && Array.isArray(value)) {
|
|
433
|
+
return value[0];
|
|
434
|
+
}
|
|
435
|
+
return value;
|
|
436
|
+
};
|
|
400
437
|
var renderResult = function renderResult() {
|
|
401
438
|
var result = /*#__PURE__*/_jsx("div", {
|
|
402
439
|
className: classNames(styles === null || styles === void 0 ? void 0 : styles.result),
|
|
@@ -404,13 +441,11 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
404
441
|
trim: trim,
|
|
405
442
|
jssStyle: jssStyle,
|
|
406
443
|
size: size,
|
|
407
|
-
value:
|
|
408
|
-
data:
|
|
444
|
+
value: getResultValue(),
|
|
445
|
+
data: data,
|
|
409
446
|
focus: open,
|
|
410
447
|
keygen: keygen,
|
|
411
|
-
disabled: disabled
|
|
412
|
-
// maxLength={maxLength}
|
|
413
|
-
,
|
|
448
|
+
disabled: disabled,
|
|
414
449
|
compressed: compressed,
|
|
415
450
|
compressedBound: compressedBound,
|
|
416
451
|
compressedClassName: compressedClassName,
|
|
@@ -429,7 +464,7 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
429
464
|
onRef: inputRef,
|
|
430
465
|
checkUnMatched: checkUnMatched,
|
|
431
466
|
onClearCreatedData: onClearCreatedData,
|
|
432
|
-
getDataByValues:
|
|
467
|
+
getDataByValues: getResultByValue,
|
|
433
468
|
onRemove: handleRemove,
|
|
434
469
|
classes: styles,
|
|
435
470
|
setInputText: setInputText
|
|
@@ -485,14 +520,13 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
485
520
|
if (multiple) {
|
|
486
521
|
treeProps.onChange = handleTreeChange;
|
|
487
522
|
} else {
|
|
488
|
-
treeProps.onClick =
|
|
523
|
+
treeProps.onClick = handleTreeClick;
|
|
489
524
|
treeProps.renderItem = renderActive;
|
|
490
525
|
treeProps.active = value;
|
|
491
526
|
}
|
|
492
527
|
if ('expanded' in props) {
|
|
493
528
|
treeProps.expanded = expanded;
|
|
494
529
|
}
|
|
495
|
-
var nextValue = getValueArray(value);
|
|
496
530
|
return /*#__PURE__*/_jsx("div", {
|
|
497
531
|
className: classNames(styles.tree),
|
|
498
532
|
style: {
|
|
@@ -500,30 +534,28 @@ var TreeSelect = function TreeSelect(props0) {
|
|
|
500
534
|
},
|
|
501
535
|
children: /*#__PURE__*/_jsx(Tree, _objectSpread(_objectSpread({
|
|
502
536
|
jssStyle: jssStyle,
|
|
503
|
-
getDatum: bindTreeDatum,
|
|
504
537
|
renderItem: renderItem
|
|
505
538
|
}, treeProps), {}, {
|
|
506
|
-
keepCache: !props.noCache,
|
|
507
539
|
line: line,
|
|
508
540
|
mode: mode,
|
|
509
541
|
data: tiledData,
|
|
510
542
|
keygen: keygen,
|
|
511
543
|
unmatch: unmatch,
|
|
512
|
-
value:
|
|
544
|
+
value: value,
|
|
513
545
|
loader: loader,
|
|
514
|
-
|
|
546
|
+
onExpand: onExpandTree,
|
|
547
|
+
expanded: controlExpanded,
|
|
548
|
+
defaultExpandAll: defaultExpandAll,
|
|
515
549
|
expandIcons: tiledExpandIcons,
|
|
516
550
|
disabled: disabled,
|
|
517
551
|
parentClickExpand: parentClickExpand,
|
|
518
|
-
defaultExpanded: defaultExpanded,
|
|
519
|
-
defaultExpandAll: defaultExpandAll,
|
|
520
552
|
contentClass: getContentClass,
|
|
521
|
-
|
|
553
|
+
datum: datum
|
|
522
554
|
}))
|
|
523
555
|
});
|
|
524
556
|
};
|
|
525
557
|
useEffect(function () {
|
|
526
|
-
if (getComponentRef && datum
|
|
558
|
+
if (getComponentRef && datum) {
|
|
527
559
|
if (util.isFunc(getComponentRef)) {
|
|
528
560
|
getComponentRef({
|
|
529
561
|
getDataByValues: getDataByValuesRef
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/base",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"module": "./esm/index.js",
|
|
11
11
|
"typings": "./cjs/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@sheinx/hooks": "3.0.
|
|
13
|
+
"@sheinx/hooks": "3.0.11",
|
|
14
14
|
"immer": "^10.0.0",
|
|
15
15
|
"classnames": "^2.0.0",
|
|
16
16
|
"@shined/reactive": "^0.1.2"
|