shineout 3.0.10 → 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/index.js CHANGED
@@ -476,5 +476,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
476
476
  // 此文件由脚本自动生成,请勿直接修改。
477
477
  // This file was generated automatically by a script. Please do not modify it directly.
478
478
  var _default = exports.default = {
479
- version: '3.0.10'
479
+ version: '3.0.11'
480
480
  };
package/dist/shineout.js CHANGED
@@ -12019,7 +12019,7 @@ var handleStyle = function handleStyle(style) {
12019
12019
  };
12020
12020
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12021
12021
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12022
- /* harmony default export */ var version = ('3.0.10');
12022
+ /* harmony default export */ var version = ('3.0.11');
12023
12023
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12024
12024
 
12025
12025
 
@@ -30285,12 +30285,13 @@ var Checkbox = function Checkbox(props) {
30285
30285
 
30286
30286
 
30287
30287
  function useInputAble(props) {
30288
+ var _props$value;
30288
30289
  var valuePo = props.value,
30289
30290
  onChange = props.onChange,
30290
30291
  control = props.control,
30291
30292
  beforeChange = props.beforeChange,
30292
30293
  delay = props.delay;
30293
- var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.value || props.defaultValue),
30294
+ var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : props.defaultValue),
30294
30295
  _useState2 = slicedToArray_default()(_useState, 2),
30295
30296
  stateValue = _useState2[0],
30296
30297
  changeStateValue = _useState2[1];
@@ -33720,14 +33721,15 @@ var useTree = function useTree(props) {
33720
33721
  mode = props.mode,
33721
33722
  activeProp = props.active,
33722
33723
  expandedProp = props.expanded,
33724
+ _props$dataUpdate = props.dataUpdate,
33725
+ dataUpdate = _props$dataUpdate === void 0 ? true : _props$dataUpdate,
33723
33726
  _props$defaultExpande = props.defaultExpanded,
33724
33727
  defaultExpanded = _props$defaultExpande === void 0 ? [] : _props$defaultExpande,
33725
33728
  defaultExpandAll = props.defaultExpandAll,
33726
33729
  disabledProps = props.disabled,
33727
33730
  unmatch = props.unmatch,
33728
33731
  isControlled = props.isControlled,
33729
- onExpandProp = props.onExpand,
33730
- keepCache = props.keepCache;
33732
+ onExpandProp = props.onExpand;
33731
33733
  var _useInputAble = useInputAble({
33732
33734
  value: expandedProp,
33733
33735
  defaultValue: defaultExpanded,
@@ -33764,7 +33766,7 @@ var useTree = function useTree(props) {
33764
33766
  var bindNode = function bindNode(id, update) {
33765
33767
  context.updateMap.set(id, update);
33766
33768
  var isActive = activeProp === id;
33767
- var expandeds = expanded || defaultExpanded;
33769
+ var expandeds = expanded;
33768
33770
  if (defaultExpandAll) {
33769
33771
  return {
33770
33772
  active: isActive,
@@ -33849,16 +33851,8 @@ var useTree = function useTree(props) {
33849
33851
  return checked;
33850
33852
  };
33851
33853
  var getDataById = function getDataById(id) {
33852
- if (keepCache) {
33853
- if (!context.valueDataCache) {
33854
- context.valueDataCache = new Map();
33855
- }
33856
- var cache = context.valueDataCache.get(id);
33857
- if (cache !== undefined) return cache;
33858
- }
33859
33854
  var oroginData = context.dataMap.get(id);
33860
33855
  if (oroginData) {
33861
- if (keepCache) context.valueDataCache.set(id, oroginData);
33862
33856
  return oroginData;
33863
33857
  }
33864
33858
  if (!unmatch) return null;
@@ -33873,6 +33867,9 @@ var useTree = function useTree(props) {
33873
33867
  }
33874
33868
  return getDataById(values);
33875
33869
  };
33870
+ var isUnMatched = usePersistFn(function (data) {
33871
+ return isUnMatchedData(data);
33872
+ });
33876
33873
  var setValueMap = function setValueMap(id, checked) {
33877
33874
  context.valueMap.set(id, checked);
33878
33875
  var update = context.forceUpdateMap.get(id);
@@ -34065,14 +34062,17 @@ var useTree = function useTree(props) {
34065
34062
  }
34066
34063
  }, []);
34067
34064
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
34068
- setValue(value);
34065
+ if (props.datum) return;
34066
+ if (!dataUpdate) return;
34069
34067
  setData(data);
34070
34068
  }, [data]);
34069
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
34070
+ if (props.datum) return;
34071
+ setValue(value);
34072
+ }, [value]);
34071
34073
  var datum = use_latest_obj({
34072
34074
  get: get,
34073
34075
  set: set,
34074
- childrenKey: childrenKey,
34075
- data: data,
34076
34076
  getPath: getPath,
34077
34077
  getValue: getValue,
34078
34078
  getChecked: getChecked,
@@ -34085,13 +34085,16 @@ var useTree = function useTree(props) {
34085
34085
  getDataById: getDataById,
34086
34086
  bindUpdate: bindUpdate,
34087
34087
  unBindUpdate: unBindUpdate,
34088
+ isUnMatched: isUnMatched,
34089
+ childrenKey: childrenKey,
34090
+ data: data,
34088
34091
  pathMap: context.pathMap,
34089
34092
  dataMap: context.dataMap,
34090
34093
  valueMap: context.valueMap,
34091
34094
  updateMap: context.updateMap
34092
34095
  });
34093
34096
  return {
34094
- datum: datum,
34097
+ datum: props.datum || datum,
34095
34098
  expanded: expanded,
34096
34099
  onExpand: onExpand
34097
34100
  };
@@ -35157,7 +35160,6 @@ var More = function More(props) {
35157
35160
  var result_isObject = is_isObject,
35158
35161
  result_isEmpty = is_isEmpty,
35159
35162
  result_isNumber = isNumber,
35160
- result_getKey = getKey,
35161
35163
  result_isUnMatchedData = isUnMatchedData,
35162
35164
  result_isFunc = isFunc,
35163
35165
  result_isArray = isArray;
@@ -35194,7 +35196,7 @@ var result_Result = function Result(props) {
35194
35196
  onRemove = props.onRemove,
35195
35197
  onResultItemClick = props.onResultItemClick,
35196
35198
  data = props.data;
35197
- var value = [null, undefined, ''].includes(valueProp) ? [] : multiple ? valueProp : [valueProp];
35199
+ var value = [null, undefined, ''].includes(valueProp) ? [] : Array.isArray(valueProp) ? valueProp : [valueProp];
35198
35200
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(-1),
35199
35201
  _useState2 = slicedToArray_default()(_useState, 2),
35200
35202
  more = _useState2[0],
@@ -35270,20 +35272,9 @@ var result_Result = function Result(props) {
35270
35272
  })
35271
35273
  }, 'input');
35272
35274
  };
35273
- var renderResultItem = function renderResultItem(item, index, nodes) {
35274
- var key;
35275
- if (result_isUnMatchedData(item)) {
35276
- if (result_isFunc(keygen)) {
35277
- key = keygen(item.value, index);
35278
- if (key === undefined) key = index;
35279
- } else {
35280
- key = item.value;
35281
- }
35282
- } else {
35283
- key = result_getKey(keygen, item, index);
35284
- }
35275
+ var renderResultItem = function renderResultItem(item, index, nodes, v) {
35285
35276
  var handleClose = function handleClose() {
35286
- onRemove === null || onRemove === void 0 || onRemove(item, key, index);
35277
+ onRemove === null || onRemove === void 0 || onRemove(item, v);
35287
35278
  };
35288
35279
  var isDisabled;
35289
35280
  if (isFunc(disabled)) {
@@ -35293,7 +35284,7 @@ var result_Result = function Result(props) {
35293
35284
  }
35294
35285
  var resultClassName;
35295
35286
  if (isFunc(props.resultClassName)) {
35296
- resultClassName = props.resultClassName(key);
35287
+ resultClassName = props.resultClassName(result_isUnMatchedData(item) ? item.value : item);
35297
35288
  } else {
35298
35289
  resultClassName = props.resultClassName;
35299
35290
  }
@@ -35303,8 +35294,9 @@ var result_Result = function Result(props) {
35303
35294
  var content = renderResultContent(item, index, nodes);
35304
35295
  if (!content) return null;
35305
35296
  if (renderResultContentProp) {
35297
+ // cascader 不渲染tag
35306
35298
  return renderResultContentProp(objectSpread2_default()({
35307
- key: key,
35299
+ key: index,
35308
35300
  size: size,
35309
35301
  disabled: isDisabled,
35310
35302
  className: classnames_default()(styles.tag, styles.hideTag, resultClassName),
@@ -35330,7 +35322,7 @@ var result_Result = function Result(props) {
35330
35322
  type: disabled === true ? 'dark' : undefined
35331
35323
  })), {}, {
35332
35324
  children: content
35333
- }), key);
35325
+ }), index);
35334
35326
  };
35335
35327
  var renderNbsp = function renderNbsp() {
35336
35328
  return /*#__PURE__*/(0,jsx_runtime.jsx)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
@@ -35361,22 +35353,28 @@ var result_Result = function Result(props) {
35361
35353
  children: content
35362
35354
  }, 'single');
35363
35355
  };
35356
+ var getValueArr = function getValueArr(v) {
35357
+ return (result_isArray(v) ? v : [v]).filter(function (v) {
35358
+ return v !== undefined && v !== null;
35359
+ });
35360
+ };
35364
35361
  var renderMultipleResult = function renderMultipleResult() {
35365
35362
  if (isEmptyResult()) return renderNbsp();
35366
35363
  // [TODO] separator 处理逻辑后续交给 hooks 处理,此处临时处理
35367
- var nextValue = value;
35364
+ var nextValue = getValueArr(value);
35368
35365
  if (separator && isString(valueProp)) {
35369
35366
  nextValue = valueProp.split(separator);
35370
35367
  }
35371
- var values = getDataByValues(nextValue);
35372
- var result = values.map(function (v, i) {
35373
- if (renderResultContentProp && i !== values.length - 1) {
35374
- return [renderResultItem(v, i, values), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
35368
+ var datas = getDataByValues(nextValue);
35369
+ var result = datas.map(function (d, i) {
35370
+ var v = nextValue[i];
35371
+ if (renderResultContentProp && i !== datas.length - 1) {
35372
+ return [renderResultItem(d, i, datas, v), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
35375
35373
  className: classnames_default()(styles.tag, styles.hideTag),
35376
35374
  children: "/"
35377
35375
  }, "separator-".concat(i))];
35378
35376
  }
35379
- return renderResultItem(v, i, values);
35377
+ return renderResultItem(d, i, datas, v);
35380
35378
  });
35381
35379
  return result;
35382
35380
  };
@@ -35782,8 +35780,8 @@ var Cascader = function Cascader(props0) {
35782
35780
  if (!path) return;
35783
35781
  handlePathChange(id, null, path);
35784
35782
  };
35785
- var handleRemove = function handleRemove(item, key, index) {
35786
- var dataKey = isUnMatchedData(item) ? item.value : datum.getKey(item, key, index);
35783
+ var handleRemove = function handleRemove(item, key) {
35784
+ var dataKey = key !== null && key !== void 0 ? key : isUnMatchedData(item) ? item.value : datum.getKey(item);
35787
35785
  var isDisabled = datum.isDisabled(dataKey);
35788
35786
  if (isDisabled) return;
35789
35787
  datum.set(dataKey, 0);
@@ -47360,7 +47358,7 @@ var Root = function Root(props) {
47360
47358
 
47361
47359
 
47362
47360
 
47363
- var tree_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", "keepCache"];
47361
+ var tree_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"];
47364
47362
 
47365
47363
 
47366
47364
 
@@ -47414,9 +47412,8 @@ var Tree = function Tree(props) {
47414
47412
  onDragLeave = props.onDragLeave,
47415
47413
  onDragOver = props.onDragOver,
47416
47414
  onDragStart = props.onDragStart,
47417
- keepCache = props.keepCache,
47415
+ propsDatum = props.datum,
47418
47416
  rest = objectWithoutProperties_default()(props, tree_excluded);
47419
- var prevData = usePrevious(data);
47420
47417
  var _useTree = use_tree({
47421
47418
  mode: mode,
47422
47419
  value: value,
@@ -47433,7 +47430,7 @@ var Tree = function Tree(props) {
47433
47430
  childrenKey: childrenKey,
47434
47431
  keygen: keygen,
47435
47432
  onExpand: onExpandProp,
47436
- keepCache: keepCache
47433
+ datum: propsDatum
47437
47434
  }),
47438
47435
  datum = _useTree.datum,
47439
47436
  expanded = _useTree.expanded,
@@ -47534,16 +47531,6 @@ var Tree = function Tree(props) {
47534
47531
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
47535
47532
  handleUpdateExpanded(expanded);
47536
47533
  }, [expanded]);
47537
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
47538
- if (!prevData) return;
47539
- if (prevData !== data && dataUpdate) {
47540
- datum.setData(data);
47541
- }
47542
- }, [data]);
47543
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
47544
- if (!value) return;
47545
- datum.setValue(value);
47546
- }, [value]);
47547
47534
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
47548
47535
  if (getDatum) getDatum(datum);
47549
47536
  }, []);
@@ -57176,13 +57163,17 @@ src_tree_tree_0.displayName = 'ShineoutTree';
57176
57163
  /* harmony default export */ var src_tree_0 = (src_tree_tree_0);
57177
57164
  ;// CONCATENATED MODULE: ../hooks/src/components/use-treeselect/use-treeselect.ts
57178
57165
 
57166
+
57167
+
57168
+
57179
57169
  var useTreeSelect = function useTreeSelect(props) {
57180
57170
  var valueProp = props.value,
57181
57171
  defaultValue = props.defaultValue,
57182
57172
  control = props.control,
57183
57173
  beforeChange = props.beforeChange,
57184
57174
  onChangeProp = props.onChange,
57185
- filterSameChange = props.filterSameChange;
57175
+ filterSameChange = props.filterSameChange,
57176
+ multiple = props.multiple;
57186
57177
  var _useInputAble = useInputAble({
57187
57178
  value: valueProp,
57188
57179
  control: control,
@@ -57193,9 +57184,27 @@ var useTreeSelect = function useTreeSelect(props) {
57193
57184
  }),
57194
57185
  value = _useInputAble.value,
57195
57186
  onChange = _useInputAble.onChange;
57187
+ var valueArr = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
57188
+ if (value === undefined || value === null || value === '') return [];
57189
+ return Array.isArray(value) ? value : [value];
57190
+ }, [value, multiple]);
57191
+ var handleChange = use_persist_fn(function (v) {
57192
+ for (var _len = arguments.length, reset = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
57193
+ reset[_key - 1] = arguments[_key];
57194
+ }
57195
+ if (!multiple && isArray(v)) {
57196
+ onChange === null || onChange === void 0 || onChange.apply(void 0, [v[0]].concat(reset));
57197
+ }
57198
+ if (multiple && !isArray(v)) {
57199
+ if (v === undefined || v === null) {
57200
+ onChange === null || onChange === void 0 || onChange.apply(void 0, [[]].concat(reset));
57201
+ } else onChange === null || onChange === void 0 || onChange.apply(void 0, [[v]].concat(reset));
57202
+ }
57203
+ onChange === null || onChange === void 0 || onChange.apply(void 0, [v].concat(reset));
57204
+ });
57196
57205
  return {
57197
- value: value,
57198
- onChange: onChange
57206
+ value: valueArr,
57207
+ onChange: handleChange
57199
57208
  };
57200
57209
  };
57201
57210
  /* harmony default export */ var use_treeselect = (useTreeSelect);
@@ -57225,7 +57234,6 @@ var tree_select_preventDefault = function preventDefault(e) {
57225
57234
  var TreeSelect = function TreeSelect(props0) {
57226
57235
  var _jssStyle$treeSelect;
57227
57236
  var props = use_with_form_config(props0);
57228
- var render = useRender();
57229
57237
  var _useConfig = useConfig(),
57230
57238
  locale = _useConfig.locale;
57231
57239
  var jssStyle = props.jssStyle,
@@ -57233,9 +57241,11 @@ var TreeSelect = function TreeSelect(props0) {
57233
57241
  size = props.size,
57234
57242
  valueProp = props.value,
57235
57243
  defaultValue = props.defaultValue,
57236
- data = props.data,
57244
+ _props$data = props.data,
57245
+ data = _props$data === void 0 ? [] : _props$data,
57237
57246
  multiple = props.multiple,
57238
- mode = props.mode,
57247
+ _props$mode = props.mode,
57248
+ mode = _props$mode === void 0 ? 1 : _props$mode,
57239
57249
  _props$line = props.line,
57240
57250
  line = _props$line === void 0 ? false : _props$line,
57241
57251
  innerTitle = props.innerTitle,
@@ -57295,9 +57305,12 @@ var TreeSelect = function TreeSelect(props0) {
57295
57305
  width: width
57296
57306
  }, style);
57297
57307
  var showInput = isFunc(props.onAdvancedFilter || onFilterProp);
57298
- var datum = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
57299
57308
  var blurEvent = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
57300
57309
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
57310
+ var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
57311
+ cachedMap: new Map()
57312
+ }),
57313
+ context = _useRef.current;
57301
57314
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
57302
57315
  _useState2 = slicedToArray_default()(_useState, 2),
57303
57316
  focused = _useState2[0],
@@ -57307,7 +57320,8 @@ var TreeSelect = function TreeSelect(props0) {
57307
57320
  onChange: onChangeProp,
57308
57321
  defaultValue: defaultValue,
57309
57322
  control: 'value' in props,
57310
- filterSameChange: filterSameChange
57323
+ filterSameChange: filterSameChange,
57324
+ multiple: multiple
57311
57325
  }),
57312
57326
  value = _useTreeSelect.value,
57313
57327
  onChange = _useTreeSelect.onChange;
@@ -57338,6 +57352,23 @@ var TreeSelect = function TreeSelect(props0) {
57338
57352
  onFilter = _useFilter.onFilter,
57339
57353
  onClearCreatedData = _useFilter.onClearCreatedData,
57340
57354
  setInputText = _useFilter.setInputText;
57355
+ var controlExpanded = 'expanded' in props || expanded !== null && expanded !== void 0 && expanded.length ? expanded : undefined;
57356
+ var _useTree = use_tree({
57357
+ mode: mode,
57358
+ value: value,
57359
+ data: data,
57360
+ unmatch: unmatch,
57361
+ disabled: disabled,
57362
+ childrenKey: childrenKey,
57363
+ keygen: keygen,
57364
+ onExpand: onExpand,
57365
+ expanded: controlExpanded,
57366
+ defaultExpanded: defaultExpanded,
57367
+ defaultExpandAll: defaultExpandAll,
57368
+ isControlled: controlExpanded !== undefined
57369
+ }),
57370
+ datum = _useTree.datum,
57371
+ onExpandTree = _useTree.onExpand;
57341
57372
  var renderMoreIcon = function renderMoreIcon() {
57342
57373
  return icons_config.treeSelect.More;
57343
57374
  };
@@ -57388,10 +57419,6 @@ var TreeSelect = function TreeSelect(props0) {
57388
57419
  jssStyle: props.jssStyle
57389
57420
  });
57390
57421
  var rootClass = classnames_default()(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_default()({}, styles === null || styles === void 0 ? void 0 : styles.multiple, multiple));
57391
- var bindTreeDatum = function bindTreeDatum(treeDatum) {
57392
- datum.current = treeDatum;
57393
- render();
57394
- };
57395
57422
  var getRenderItem = function getRenderItem(data, expanded, active, id) {
57396
57423
  return typeof renderItemProp === 'function' ? renderItemProp(data, expanded, active, id) : data[renderItemProp];
57397
57424
  };
@@ -57447,9 +57474,9 @@ var TreeSelect = function TreeSelect(props0) {
57447
57474
  };
57448
57475
  var handleClear = function handleClear(e) {
57449
57476
  e.stopPropagation();
57450
- if (!datum.current) return;
57451
- datum.current.setValue([]);
57452
- onChange(multiple ? [] : '');
57477
+ if (!datum) return;
57478
+ datum.setValue([]);
57479
+ onChange(multiple ? [] : ['']);
57453
57480
  if (onChangeAddition) {
57454
57481
  onChangeAddition({
57455
57482
  data: multiple ? [] : null
@@ -57457,9 +57484,6 @@ var TreeSelect = function TreeSelect(props0) {
57457
57484
  }
57458
57485
  if (open) closePop();
57459
57486
  };
57460
- var handleExpand = function handleExpand(expands) {
57461
- onExpand === null || onExpand === void 0 || onExpand(expands);
57462
- };
57463
57487
  var renderClearable = function renderClearable() {
57464
57488
  if (!multiple !== undefined && !showArrow) return null;
57465
57489
  var defaultIcon = multiple ? icons_config.treeSelect.More : icons_config.treeSelect.DropdownArrow;
@@ -57489,37 +57513,43 @@ var TreeSelect = function TreeSelect(props0) {
57489
57513
  children: defaultIcon
57490
57514
  });
57491
57515
  };
57516
+ var getDataById = usePersistFn(function (id) {
57517
+ if (!props.noCache) {
57518
+ if (context.cachedMap.has(id)) {
57519
+ return context.cachedMap.get(id);
57520
+ }
57521
+ }
57522
+ if (!datum) return undefined;
57523
+ var origin = datum === null || datum === void 0 ? void 0 : datum.getDataById(id);
57524
+ if (!props.noCache && !(datum !== null && datum !== void 0 && datum.isUnMatched(origin))) {
57525
+ context.cachedMap.set(id, origin);
57526
+ }
57527
+ return origin;
57528
+ });
57492
57529
  var getDataByValues = function getDataByValues(values) {
57493
- if (!datum.current || !values) return [];
57494
- return datum.current.getDataByValues(values);
57530
+ if (!datum || !values) return [];
57531
+ return datum.getDataByValues(values);
57495
57532
  };
57496
57533
  var getDataByValuesRef = function getDataByValuesRef(values) {
57497
- var _datum$current2;
57498
57534
  if (isArray(values)) {
57499
57535
  return values.map(function (id) {
57500
- var _datum$current;
57501
- return (_datum$current = datum.current) === null || _datum$current === void 0 ? void 0 : _datum$current.getDataById(id);
57536
+ return datum === null || datum === void 0 ? void 0 : datum.getDataById(id);
57502
57537
  });
57503
57538
  }
57504
- return (_datum$current2 = datum.current) === null || _datum$current2 === void 0 ? void 0 : _datum$current2.getDataById(values);
57539
+ return datum === null || datum === void 0 ? void 0 : datum.getDataById(values);
57505
57540
  };
57506
57541
  var getValue = function getValue() {
57507
- if (!datum.current) return;
57508
- var nextValue = datum.current.getValue();
57542
+ if (!datum) return;
57543
+ var nextValue = datum.getValue();
57509
57544
  if (multiple) return nextValue;
57510
- return nextValue.length ? nextValue[0] : '';
57511
- };
57512
- var getValueArray = function getValueArray(value) {
57513
- if (!value) return [];
57514
- if (!Array.isArray(value)) return [value];
57515
- return value;
57545
+ if (nextValue.length === 0) return [];
57546
+ return [nextValue[0]];
57516
57547
  };
57517
57548
  var getContentClass = function getContentClass(data) {
57518
- var _datum$current3, _datum$current4;
57519
- if (!datum.current) return '';
57520
- var key = datum.current.getKey(data);
57521
- var isDisabled = (_datum$current3 = datum.current) === null || _datum$current3 === void 0 ? void 0 : _datum$current3.isDisabled(key);
57522
- var isCheck = (_datum$current4 = datum.current) === null || _datum$current4 === void 0 ? void 0 : _datum$current4.getChecked(key);
57549
+ if (!datum) return '';
57550
+ var key = datum.getKey(data);
57551
+ var isDisabled = datum === null || datum === void 0 ? void 0 : datum.isDisabled(key);
57552
+ var isCheck = datum === null || datum === void 0 ? void 0 : datum.getChecked(key);
57523
57553
  if (isDisabled) {
57524
57554
  return classnames_default()(styles.optionDisabled);
57525
57555
  }
@@ -57550,46 +57580,62 @@ var TreeSelect = function TreeSelect(props0) {
57550
57580
  onTiledFilter === null || onTiledFilter === void 0 || onTiledFilter(trim ? text.trim() : text);
57551
57581
  };
57552
57582
  var handleChange = function handleChange(item, id) {
57553
- var _datum$current5;
57554
- if (!datum.current) return;
57555
- if (disabled === true || (_datum$current5 = datum.current) !== null && _datum$current5 !== void 0 && _datum$current5.isDisabled(id)) return;
57556
- var currentData = datum.current.getDataById(id);
57583
+ if (disabled === true || datum !== null && datum !== void 0 && datum.isDisabled(id)) return;
57584
+ var currentData = datum.getDataById(id);
57557
57585
  if (!multiple) {
57558
- datum.current.setValue([]);
57559
- datum.current.set(datum.current.getKey(item), 1);
57586
+ datum.setValue([]);
57587
+ datum.set(datum.getKey(item), 1);
57560
57588
  }
57561
57589
  var nextValue = getValue();
57562
57590
  if (onChange) {
57563
- onChange(nextValue, currentData, id ? (datum.current.getPath(id) || {}).path : undefined);
57591
+ onChange(nextValue, currentData, id ? (datum.getPath(id) || {}).path : undefined);
57564
57592
  }
57565
57593
  if (typeof onChangeAddition === 'function') {
57566
57594
  onChangeAddition({
57567
57595
  data: getDataByValues(nextValue),
57568
- checked: multiple ? datum.current.get(id) : undefined,
57596
+ checked: multiple ? datum.get(id) : undefined,
57569
57597
  current: currentData
57570
57598
  });
57571
57599
  }
57572
57600
  };
57573
- var handleTreeChange = function handleTreeChange(item, id) {
57601
+ var handleTreeClick = function handleTreeClick(item, id) {
57602
+ handleChange(item, id);
57603
+ closePop();
57604
+ };
57605
+ var handleTreeChange = function handleTreeChange(_value, id) {
57606
+ var item = datum.getDataById(id);
57574
57607
  handleChange(item, id);
57575
- if (!multiple) closePop();
57576
57608
  };
57577
- var handleRemove = function handleRemove(item, key, index) {
57578
- if (!datum.current) return;
57579
- var dataKey = isUnMatchedData(item) ? item.value : datum.current.getKey(item, key, index);
57580
- var isDisabled = datum.current.isDisabled(dataKey);
57609
+ var handleRemove = function handleRemove(item, key) {
57610
+ if (!datum) return;
57611
+ var dataKey = key !== null && key !== void 0 ? key : isUnMatchedData(item) ? item.value : datum.getKey(item);
57612
+ var isDisabled = datum.isDisabled(dataKey);
57581
57613
  if (isDisabled) return;
57582
- datum.current.set(dataKey, 0);
57583
- handleChange(item, datum.current.getKey(item, key, index));
57614
+ datum.set(dataKey, 0);
57615
+ handleChange(item, dataKey);
57584
57616
  };
57585
57617
 
57586
57618
  // innerTitle 模式
57587
57619
  var renderInnerTitle = use_inner_title({
57588
- open: open || !!value,
57620
+ open: open || !!(value && value.length),
57589
57621
  size: size,
57590
57622
  jssStyle: jssStyle,
57591
57623
  innerTitle: innerTitle
57592
57624
  });
57625
+ var getResultByValue = usePersistFn(function (arr) {
57626
+ var result = (Array.isArray(arr) ? arr : [arr]).map(function (id) {
57627
+ return getDataById(id);
57628
+ }).filter(function (item) {
57629
+ return item !== undefined;
57630
+ });
57631
+ return result;
57632
+ });
57633
+ var getResultValue = function getResultValue() {
57634
+ if (!multiple && Array.isArray(value)) {
57635
+ return value[0];
57636
+ }
57637
+ return value;
57638
+ };
57593
57639
  var renderResult = function renderResult() {
57594
57640
  var result = /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
57595
57641
  className: classnames_default()(styles === null || styles === void 0 ? void 0 : styles.result),
@@ -57597,13 +57643,11 @@ var TreeSelect = function TreeSelect(props0) {
57597
57643
  trim: trim,
57598
57644
  jssStyle: jssStyle,
57599
57645
  size: size,
57600
- value: value,
57601
- data: tiledData,
57646
+ value: getResultValue(),
57647
+ data: data,
57602
57648
  focus: open,
57603
57649
  keygen: keygen,
57604
- disabled: disabled
57605
- // maxLength={maxLength}
57606
- ,
57650
+ disabled: disabled,
57607
57651
  compressed: compressed,
57608
57652
  compressedBound: compressedBound,
57609
57653
  compressedClassName: compressedClassName,
@@ -57622,7 +57666,7 @@ var TreeSelect = function TreeSelect(props0) {
57622
57666
  onRef: inputRef,
57623
57667
  checkUnMatched: checkUnMatched,
57624
57668
  onClearCreatedData: onClearCreatedData,
57625
- getDataByValues: getDataByValues,
57669
+ getDataByValues: getResultByValue,
57626
57670
  onRemove: handleRemove,
57627
57671
  classes: styles,
57628
57672
  setInputText: setInputText
@@ -57678,14 +57722,13 @@ var TreeSelect = function TreeSelect(props0) {
57678
57722
  if (multiple) {
57679
57723
  treeProps.onChange = handleTreeChange;
57680
57724
  } else {
57681
- treeProps.onClick = handleTreeChange;
57725
+ treeProps.onClick = handleTreeClick;
57682
57726
  treeProps.renderItem = renderActive;
57683
57727
  treeProps.active = value;
57684
57728
  }
57685
57729
  if ('expanded' in props) {
57686
57730
  treeProps.expanded = expanded;
57687
57731
  }
57688
- var nextValue = getValueArray(value);
57689
57732
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
57690
57733
  className: classnames_default()(styles.tree),
57691
57734
  style: {
@@ -57693,30 +57736,28 @@ var TreeSelect = function TreeSelect(props0) {
57693
57736
  },
57694
57737
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(src_tree_tree, objectSpread2_default()(objectSpread2_default()({
57695
57738
  jssStyle: jssStyle,
57696
- getDatum: bindTreeDatum,
57697
57739
  renderItem: renderItem
57698
57740
  }, treeProps), {}, {
57699
- keepCache: !props.noCache,
57700
57741
  line: line,
57701
57742
  mode: mode,
57702
57743
  data: tiledData,
57703
57744
  keygen: keygen,
57704
57745
  unmatch: unmatch,
57705
- value: nextValue,
57746
+ value: value,
57706
57747
  loader: loader,
57707
- expanded: 'expanded' in props || expanded !== null && expanded !== void 0 && expanded.length ? expanded : undefined,
57748
+ onExpand: onExpandTree,
57749
+ expanded: controlExpanded,
57750
+ defaultExpandAll: defaultExpandAll,
57708
57751
  expandIcons: tiledExpandIcons,
57709
57752
  disabled: disabled,
57710
57753
  parentClickExpand: parentClickExpand,
57711
- defaultExpanded: defaultExpanded,
57712
- defaultExpandAll: defaultExpandAll,
57713
57754
  contentClass: getContentClass,
57714
- onExpand: handleExpand
57755
+ datum: datum
57715
57756
  }))
57716
57757
  });
57717
57758
  };
57718
57759
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
57719
- if (getComponentRef && datum.current) {
57760
+ if (getComponentRef && datum) {
57720
57761
  if (isFunc(getComponentRef)) {
57721
57762
  getComponentRef({
57722
57763
  getDataByValues: getDataByValuesRef
@@ -61334,7 +61375,7 @@ var upload_interface = __webpack_require__(4412);
61334
61375
 
61335
61376
 
61336
61377
  /* harmony default export */ var src_0 = ({
61337
- version: '3.0.10'
61378
+ version: '3.0.11'
61338
61379
  });
61339
61380
  }();
61340
61381
  /******/ return __webpack_exports__;