shineout 3.9.12-beta.7 → 3.9.12-beta.9

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
@@ -522,5 +522,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
522
522
  // 此文件由脚本自动生成,请勿直接修改。
523
523
  // This file was generated automatically by a script. Please do not modify it directly.
524
524
  var _default = exports.default = {
525
- version: '3.9.12-beta.7'
525
+ version: '3.9.12-beta.9'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12408,7 +12408,7 @@ var handleStyle = function handleStyle(style) {
12408
12408
  };
12409
12409
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12410
12410
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12411
- /* harmony default export */ var version = ('3.9.12-beta.7');
12411
+ /* harmony default export */ var version = ('3.9.12-beta.9');
12412
12412
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12413
12413
 
12414
12414
 
@@ -40855,7 +40855,8 @@ var useTree = function useTree(props) {
40855
40855
  defaultExpandAll = props.defaultExpandAll,
40856
40856
  unmatch = props.unmatch,
40857
40857
  isControlled = props.isControlled,
40858
- onExpandProp = props.onExpand;
40858
+ onExpandProp = props.onExpand,
40859
+ sortBySelect = props.sortBySelect;
40859
40860
  var disabledProps = isOptionalDisabled(props.disabled) ? props.disabled.disabled : props.disabled;
40860
40861
  var isRealtime = isOptionalDisabled(props.disabled) ? props.disabled.isRealtime : false;
40861
40862
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
@@ -40883,7 +40884,8 @@ var useTree = function useTree(props) {
40883
40884
  value: undefined,
40884
40885
  data: [],
40885
40886
  cachedValue: [],
40886
- valueDataCache: new Map()
40887
+ valueDataCache: new Map(),
40888
+ selectOrder: []
40887
40889
  }),
40888
40890
  context = _useRef.current;
40889
40891
 
@@ -40983,10 +40985,21 @@ var useTree = function useTree(props) {
40983
40985
  context.unmatchedValueMap.forEach(function (unmatch, id) {
40984
40986
  if (unmatch) values.push(id);
40985
40987
  });
40988
+ if (sortBySelect && context.selectOrder.length > 0) {
40989
+ var orderMap = new Map();
40990
+ context.selectOrder.forEach(function (id, index) {
40991
+ orderMap.set(id, index);
40992
+ });
40993
+ values.sort(function (a, b) {
40994
+ var _orderMap$get, _orderMap$get2;
40995
+ return ((_orderMap$get = orderMap.get(a)) !== null && _orderMap$get !== void 0 ? _orderMap$get : Infinity) - ((_orderMap$get2 = orderMap.get(b)) !== null && _orderMap$get2 !== void 0 ? _orderMap$get2 : Infinity);
40996
+ });
40997
+ }
40986
40998
  context.cachedValue = values;
40987
- // why deep clone: 外部可能对数组做splice等操作,影响context.cachedValue在内部的判断逻辑
40999
+ // why slice: 外部可能对数组做splice等操作,影响context.cachedValue在内部的判断逻辑
40988
41000
  // 表现出来的bug现象是:外部删除了某个叶子结点,但是Tree的勾选情况没有同步更新; 另外是为了对齐老版本的表现
40989
- return deepClone(values);
41001
+ // 由于values是KeygenResult[](string|number等原始值),slice()浅拷贝即可隔离引用,无需deepClone
41002
+ return values.slice();
40990
41003
  };
40991
41004
  var getPath = function getPath(id) {
40992
41005
  return context.pathMap.get(id);
@@ -41028,6 +41041,21 @@ var useTree = function useTree(props) {
41028
41041
  return isUnMatchedData(data);
41029
41042
  });
41030
41043
  var setValueMap = function setValueMap(id, checked) {
41044
+ if (sortBySelect) {
41045
+ var prevChecked = context.valueMap.get(id);
41046
+ var wasChecked = prevChecked === 1 || prevChecked === 2;
41047
+ var isChecked = checked === 1 || checked === 2;
41048
+ if (!wasChecked && isChecked) {
41049
+ if (!context.selectOrder.includes(id)) {
41050
+ context.selectOrder.push(id);
41051
+ }
41052
+ } else if (wasChecked && !isChecked) {
41053
+ var idx = context.selectOrder.indexOf(id);
41054
+ if (idx >= 0) {
41055
+ context.selectOrder.splice(idx, 1);
41056
+ }
41057
+ }
41058
+ }
41031
41059
  context.valueMap.set(id, checked);
41032
41060
  var update = context.forceUpdateMap.get(id);
41033
41061
  if (update) update();
@@ -41188,6 +41216,12 @@ var useTree = function useTree(props) {
41188
41216
  initValue();
41189
41217
  }
41190
41218
  setUnmatedValue();
41219
+ if (sortBySelect) {
41220
+ context.selectOrder = (context.value || []).filter(function (id) {
41221
+ var status = context.valueMap.get(id);
41222
+ return status === 1 || status === 2 || context.unmatchedValueMap.get(id);
41223
+ });
41224
+ }
41191
41225
  };
41192
41226
  var isDisabled = function isDisabled(id) {
41193
41227
  if (isFunc(disabledProps)) {
@@ -41225,6 +41259,7 @@ var useTree = function useTree(props) {
41225
41259
  context.dataFlatStatusMap = new Map();
41226
41260
  context.valueMap = new Map();
41227
41261
  context.unmatchedValueMap = new Map();
41262
+ context.selectOrder = [];
41228
41263
  context.data = use_tree_toArray(data);
41229
41264
  if (virtual) {
41230
41265
  context.dataFlat = [];
@@ -41515,7 +41550,8 @@ var useCascader = function useCascader(props) {
41515
41550
  valueProp = props.value,
41516
41551
  onChangeProp = props.onChange,
41517
41552
  filterSameChange = props.filterSameChange,
41518
- childrenKey = props.childrenKey;
41553
+ childrenKey = props.childrenKey,
41554
+ sortBySelect = props.sortBySelect;
41519
41555
  var _useInputAble = useInputAble({
41520
41556
  value: valueProp,
41521
41557
  control: control,
@@ -41534,7 +41570,8 @@ var useCascader = function useCascader(props) {
41534
41570
  mode: mode,
41535
41571
  disabled: disabled,
41536
41572
  isControlled: control,
41537
- childrenKey: childrenKey
41573
+ childrenKey: childrenKey,
41574
+ sortBySelect: sortBySelect
41538
41575
  }),
41539
41576
  datum = _useTree.datum;
41540
41577
  return {
@@ -43814,7 +43851,8 @@ var Cascader = function Cascader(props0) {
43814
43851
  virtual = props.virtual,
43815
43852
  filterSameChange = props.filterSameChange,
43816
43853
  beforeChange = props.beforeChange,
43817
- checkOnFiltered = props.checkOnFiltered;
43854
+ checkOnFiltered = props.checkOnFiltered,
43855
+ sortBySelect = props.sortBySelect;
43818
43856
  var showInput = isFunc(onFilterProp);
43819
43857
  var isRealtime = cascader_isOptionalDisabled(props.disabled) ? props.disabled.isRealtime : false;
43820
43858
  var disabled = isOptionalDisabled(disabledProp) ? disabledProp.disabled : disabledProp;
@@ -43855,6 +43893,12 @@ var Cascader = function Cascader(props0) {
43855
43893
  FilterProvider = _useFilter.FilterProvider;
43856
43894
  var isDataEmpty = !filterData || filterData.length === 0;
43857
43895
  var isMultiple = multiple === true || mode !== undefined;
43896
+
43897
+ // fix: multiple=true 但未传 mode 时,mode 为 undefined 会导致 getValue() 的 switch-case
43898
+ // 走 default 分支返回空数组,进而在受控模式下 setValue → initValue 用空值重置勾选状态,
43899
+ // 表现为 checkbox 勾选后立即回弹。此问题由 #1364 引入 deepClone 后暴露。
43900
+ // 默认值 1 与 Tree、TreeSelect 组件的 mode 解构默认值保持一致。
43901
+ var resolvedMode = isMultiple && mode === undefined ? 1 : mode;
43858
43902
  var updateKey = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
43859
43903
  return path.join('-');
43860
43904
  }, [path]);
@@ -43864,13 +43908,14 @@ var Cascader = function Cascader(props0) {
43864
43908
  keygen: keygen,
43865
43909
  unmatch: unmatch,
43866
43910
  disabled: disabledProp,
43867
- mode: mode,
43911
+ mode: resolvedMode,
43868
43912
  defaultValue: defaultValue,
43869
43913
  childrenKey: childrenKey,
43870
43914
  value: valueProp,
43871
43915
  beforeChange: beforeChange,
43872
43916
  onChange: onChangeProp,
43873
- filterSameChange: filterSameChange
43917
+ filterSameChange: filterSameChange,
43918
+ sortBySelect: sortBySelect
43874
43919
  }),
43875
43920
  datum = _useCascader.datum,
43876
43921
  value = _useCascader.value,
@@ -44207,7 +44252,7 @@ var Cascader = function Cascader(props0) {
44207
44252
  parentId: "",
44208
44253
  virtual: virtual,
44209
44254
  path: [],
44210
- mode: mode,
44255
+ mode: resolvedMode,
44211
44256
  size: size
44212
44257
  }, 'root')];
44213
44258
  var childs = path.map(function (p, i) {
@@ -44292,7 +44337,7 @@ var Cascader = function Cascader(props0) {
44292
44337
  data: filterData,
44293
44338
  datum: datum,
44294
44339
  keygen: keygen,
44295
- mode: mode,
44340
+ mode: resolvedMode,
44296
44341
  height: height,
44297
44342
  size: size,
44298
44343
  isRealtime: isRealtime,
@@ -58303,7 +58348,7 @@ var TreeVirtual = function TreeVirtual(props) {
58303
58348
 
58304
58349
 
58305
58350
 
58306
- var tree_excluded = ["jssStyle", "line", "childrenKey", "data", "value", "mode", "keygen", "virtual", "expanded", "expandIcons", "iconClass", "leafClass", "nodeClass", "contentClass", "rootStyle", "renderItem", "defaultValue", "dataUpdate", "childrenClass", "defaultExpandAll", "defaultExpanded", "parentClickExpand", "doubleClickExpand", "dragImageSelector", "dragImageStyle", "dragSibling", "unmatch", "ignoreSetFlat", "dragHoverExpand", "active", "setActive", "disabled", "inlineNode", "highlight", "className", "onClick", "loader", "getDatum", "onDrop", "onExpand", "onChange", "onDragEnd", "onDragLeave", "onDragOver", "onDragStart", "datum", "rowsInView", "actionOnClick", "tiledData", "height", "leafIcon"];
58351
+ var tree_excluded = ["jssStyle", "line", "childrenKey", "data", "value", "mode", "keygen", "virtual", "expanded", "expandIcons", "iconClass", "leafClass", "nodeClass", "contentClass", "rootStyle", "renderItem", "defaultValue", "dataUpdate", "childrenClass", "defaultExpandAll", "defaultExpanded", "parentClickExpand", "doubleClickExpand", "dragImageSelector", "dragImageStyle", "dragSibling", "unmatch", "ignoreSetFlat", "dragHoverExpand", "active", "setActive", "disabled", "inlineNode", "highlight", "className", "onClick", "loader", "getDatum", "onDrop", "onExpand", "onChange", "onDragEnd", "onDragLeave", "onDragOver", "onDragStart", "datum", "rowsInView", "actionOnClick", "tiledData", "height", "leafIcon", "sortBySelect"];
58307
58352
 
58308
58353
 
58309
58354
 
@@ -58371,6 +58416,7 @@ var Tree = function Tree(props) {
58371
58416
  tiledData = props.tiledData,
58372
58417
  height = props.height,
58373
58418
  leafIcon = props.leafIcon,
58419
+ sortBySelect = props.sortBySelect,
58374
58420
  rest = objectWithoutProperties_default()(props, tree_excluded);
58375
58421
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(propActive),
58376
58422
  _useState2 = slicedToArray_default()(_useState, 2),
@@ -58406,7 +58452,8 @@ var Tree = function Tree(props) {
58406
58452
  virtual: virtual,
58407
58453
  onExpand: onExpandProp,
58408
58454
  datum: propsDatum,
58409
- tiledData: props.filteredData
58455
+ tiledData: props.filteredData,
58456
+ sortBySelect: sortBySelect
58410
58457
  }),
58411
58458
  datum = _useTree.datum,
58412
58459
  expanded = _useTree.expanded,
@@ -71278,7 +71325,8 @@ var TreeSelect = function TreeSelect(props0) {
71278
71325
  beforeChange = props.beforeChange,
71279
71326
  filterSameChange = props.filterSameChange,
71280
71327
  checkOnFiltered = props.checkOnFiltered,
71281
- renderOptionList = props.renderOptionList;
71328
+ renderOptionList = props.renderOptionList,
71329
+ sortBySelect = props.sortBySelect;
71282
71330
  var styles = jssStyle === null || jssStyle === void 0 || (_jssStyle$treeSelect = jssStyle.treeSelect) === null || _jssStyle$treeSelect === void 0 ? void 0 : _jssStyle$treeSelect.call(jssStyle);
71283
71331
  var rootStyle = Object.assign({
71284
71332
  width: width
@@ -71378,7 +71426,8 @@ var TreeSelect = function TreeSelect(props0) {
71378
71426
  expanded: controlExpanded,
71379
71427
  defaultExpanded: defaultExpanded,
71380
71428
  defaultExpandAll: defaultExpandAll,
71381
- isControlled: controlExpanded !== undefined
71429
+ isControlled: controlExpanded !== undefined,
71430
+ sortBySelect: sortBySelect
71382
71431
  }),
71383
71432
  datum = _useTree.datum,
71384
71433
  unControlExpanded = _useTree.expanded;
@@ -75611,7 +75660,7 @@ var upload_interface = __webpack_require__(8821);
75611
75660
 
75612
75661
 
75613
75662
  /* harmony default export */ var src_0 = ({
75614
- version: '3.9.12-beta.7'
75663
+ version: '3.9.12-beta.9'
75615
75664
  });
75616
75665
  }();
75617
75666
  /******/ return __webpack_exports__;