@sheinx/hooks 3.2.0-rc.3 → 3.2.0-rc.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/cjs/common/use-transform/use-transform.d.ts.map +1 -1
  2. package/cjs/common/use-transform/use-transform.js +1 -0
  3. package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +1 -1
  4. package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
  5. package/cjs/components/use-form/use-form-flow/use-form-datum.js +13 -1
  6. package/cjs/components/use-form/use-form.js +1 -1
  7. package/cjs/components/use-menu/use-menu-item.d.ts +1 -0
  8. package/cjs/components/use-menu/use-menu-item.d.ts.map +1 -1
  9. package/cjs/components/use-menu/use-menu-item.js +44 -36
  10. package/cjs/components/use-menu/use-menu.d.ts.map +1 -1
  11. package/cjs/components/use-menu/use-menu.js +12 -2
  12. package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
  13. package/cjs/components/use-table/use-table-layout.js +2 -1
  14. package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
  15. package/cjs/components/use-tree/use-tree.js +20 -14
  16. package/cjs/components/use-tree/use-tree.type.d.ts +3 -1
  17. package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
  18. package/cjs/components/use-treeselect/use-treeselect.js +3 -3
  19. package/cjs/components/use-upload/use-upload.d.ts.map +1 -1
  20. package/cjs/components/use-upload/use-upload.js +16 -18
  21. package/cjs/utils/rule/rule.type.d.ts +1 -1
  22. package/cjs/utils/rule/rule.type.d.ts.map +1 -1
  23. package/cjs/utils/validate/get-rule.d.ts.map +1 -1
  24. package/cjs/utils/validate/get-rule.js +2 -1
  25. package/esm/common/use-transform/use-transform.d.ts.map +1 -1
  26. package/esm/common/use-transform/use-transform.js +1 -0
  27. package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +1 -1
  28. package/esm/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
  29. package/esm/components/use-form/use-form-flow/use-form-datum.js +13 -1
  30. package/esm/components/use-form/use-form.js +1 -1
  31. package/esm/components/use-menu/use-menu-item.d.ts +1 -0
  32. package/esm/components/use-menu/use-menu-item.d.ts.map +1 -1
  33. package/esm/components/use-menu/use-menu-item.js +44 -36
  34. package/esm/components/use-menu/use-menu.d.ts.map +1 -1
  35. package/esm/components/use-menu/use-menu.js +12 -2
  36. package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
  37. package/esm/components/use-table/use-table-layout.js +2 -1
  38. package/esm/components/use-tree/use-tree.d.ts.map +1 -1
  39. package/esm/components/use-tree/use-tree.js +20 -14
  40. package/esm/components/use-tree/use-tree.type.d.ts +3 -1
  41. package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
  42. package/esm/components/use-treeselect/use-treeselect.js +3 -3
  43. package/esm/components/use-upload/use-upload.d.ts.map +1 -1
  44. package/esm/components/use-upload/use-upload.js +16 -18
  45. package/esm/utils/rule/rule.type.d.ts +1 -1
  46. package/esm/utils/rule/rule.type.d.ts.map +1 -1
  47. package/esm/utils/validate/get-rule.d.ts.map +1 -1
  48. package/esm/utils/validate/get-rule.js +2 -1
  49. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;CAqFxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;CAsFxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -103,6 +103,7 @@ var useTransform = function useTransform(props) {
103
103
  if (!containerDimension || !targetDimension) return;
104
104
  if (targetDimension <= containerDimension) {
105
105
  setShouldScroll(false);
106
+ setDelta(0);
106
107
  } else {
107
108
  setShouldScroll(true);
108
109
  }
@@ -1,7 +1,7 @@
1
1
  export interface FormDatum {
2
2
  set: (vals: {
3
3
  [name: string]: any;
4
- }) => void;
4
+ } | string, value?: any) => void;
5
5
  get: (name?: string) => any;
6
6
  }
7
7
  declare const useFormDatum: () => FormDatum | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AACD,QAAA,MAAM,YAAY,6BAQjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -5,12 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _useLatestObj = _interopRequireDefault(require("../../../common/use-latest-obj"));
8
+ var _usePersistFn = require("../../../common/use-persist-fn");
8
9
  var _formFuncContext = require("../form-func-context");
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
14
+ 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); }
10
15
  var useFormDatum = function useFormDatum() {
11
16
  var formFunc = (0, _formFuncContext.useFormFunc)();
17
+ var set = (0, _usePersistFn.usePersistFn)(function (vals, value) {
18
+ if (_typeof(vals) === 'object') {
19
+ formFunc === null || formFunc === void 0 || formFunc.setValue(vals);
20
+ } else {
21
+ formFunc === null || formFunc === void 0 || formFunc.setValue(_defineProperty({}, vals, value));
22
+ }
23
+ });
12
24
  var func = (0, _useLatestObj.default)({
13
- set: formFunc === null || formFunc === void 0 ? void 0 : formFunc.setValue,
25
+ set: set,
14
26
  get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
15
27
  });
16
28
  var datum = formFunc ? func : undefined;
@@ -57,7 +57,7 @@ var useForm = function useForm(props) {
57
57
  removeArr: new Set(),
58
58
  names: new Set(),
59
59
  submitLock: false,
60
- value: props.value || emptyObj,
60
+ value: (0, _utils.deepClone)(props.value) || emptyObj,
61
61
  errors: {},
62
62
  serverErrors: {},
63
63
  lastValue: props.value || emptyObj,
@@ -11,6 +11,7 @@ declare const useMenuItem: (props: UseMenuItemProps) => {
11
11
  handleMouseEnter: (e: React.MouseEvent) => void;
12
12
  handleMouseLeave: () => void;
13
13
  handleExpandClick: (e: React.MouseEvent) => void;
14
+ isLeaf: boolean;
14
15
  };
15
16
  export default useMenuItem;
16
17
  //# sourceMappingURL=use-menu-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu-item.d.ts","sourceRoot":"","sources":["use-menu-item.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,QAAA,MAAM,WAAW,UAAW,gBAAgB;;;;;;;;yBA4BD,gBAAgB;0BA2Df,gBAAgB;;2BAhCf,gBAAgB;CA6E5D,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"use-menu-item.d.ts","sourceRoot":"","sources":["use-menu-item.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,QAAA,MAAM,WAAW,UAAW,gBAAgB;;;;;;;;yBA8BD,gBAAgB;0BA8Df,gBAAgB;;2BAhCf,gBAAgB;;CAgF5D,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -17,15 +17,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  var useMenuItem = function useMenuItem(props) {
18
18
  var _useRef = (0, _react.useRef)({
19
19
  id: '',
20
- timer: null,
21
- isUp: false
20
+ timer: null
22
21
  }),
23
22
  context = _useRef.current;
24
23
  var _props$parentId = props.parentId,
25
24
  parentId = _props$parentId === void 0 ? '' : _props$parentId,
26
- dataItem = props.dataItem,
27
- _props$toggleDuration = props.toggleDuration,
28
- toggleDuration = _props$toggleDuration === void 0 ? 200 : _props$toggleDuration;
25
+ dataItem = props.dataItem;
26
+ var isLeaf = ((dataItem || {}).children || []).length === 0;
29
27
  if (!context.id) {
30
28
  context.id = "".concat(parentId, ",").concat((0, _uid.getUidStr)());
31
29
  }
@@ -40,6 +38,10 @@ var useMenuItem = function useMenuItem(props) {
40
38
  _useState4 = _slicedToArray(_useState3, 2),
41
39
  isInPath = _useState4[0],
42
40
  setInPath = _useState4[1];
41
+ var _useState5 = (0, _react.useState)(false),
42
+ _useState6 = _slicedToArray(_useState5, 2),
43
+ isUp = _useState6[0],
44
+ setIsUp = _useState6[1];
43
45
  var update = (0, _usePersistFn.default)(function (getStatus) {
44
46
  var status = getStatus(context.id, props.dataItem);
45
47
  if (isChecked !== status.isChecked) {
@@ -72,8 +74,11 @@ var useMenuItem = function useMenuItem(props) {
72
74
  props.onClick(dataItem);
73
75
  }
74
76
  }
75
- var isLeaf = ((dataItem || {}).children || []).length === 0;
76
- if (!isLeaf) e.nativeEvent.stopImmediatePropagation();
77
+ // 阻止冒泡
78
+ if (!isLeaf) {
79
+ e.stopPropagation();
80
+ e.nativeEvent.stopImmediatePropagation();
81
+ }
77
82
  });
78
83
  var handleExpandClick = (0, _usePersistFn.default)(function (e) {
79
84
  e.stopPropagation();
@@ -90,29 +95,29 @@ var useMenuItem = function useMenuItem(props) {
90
95
  }
91
96
  });
92
97
  var handleMouseLeave = (0, _usePersistFn.default)(function () {
93
- if (expandAble && props.mode !== 'inline') {
94
- if (context.timer) {
95
- clearTimeout(context.timer);
96
- context.timer = null;
97
- }
98
- context.timer = setTimeout(function () {
99
- props.onOpenChange(function (before) {
100
- var openKeySet = new Set(before);
101
- openKeySet.delete(props.keyResult);
102
- return Array.from(openKeySet);
103
- });
104
- }, toggleDuration);
105
- document.removeEventListener('click', handleMouseLeave);
106
- }
98
+ // if (expandAble && props.mode !== 'inline') {
99
+ // if (context.timer) {
100
+ // clearTimeout(context.timer);
101
+ // context.timer = null;
102
+ // }
103
+ // context.timer = setTimeout(() => {
104
+ // props.onOpenChange((before) => {
105
+ // const openKeySet = new Set(before);
106
+ // openKeySet.delete(props.keyResult);
107
+ // return Array.from(openKeySet);
108
+ // });
109
+ // }, toggleDuration);
110
+ // document.removeEventListener('click', handleMouseLeave);
111
+ // }
107
112
  });
108
113
  var handleMouseEnter = (0, _usePersistFn.default)(function (e) {
109
114
  if (expandAble && props.mode !== 'inline') {
110
115
  var _props$scrollRef;
111
- if (context.timer) {
112
- clearTimeout(context.timer);
113
- context.timer = null;
114
- }
115
- var isUp = false;
116
+ // if (context.timer) {
117
+ // clearTimeout(context.timer);
118
+ // context.timer = null;
119
+ // }
120
+ var up = false;
116
121
  if (props.mode === 'vertical-auto' && (_props$scrollRef = props.scrollRef) !== null && _props$scrollRef !== void 0 && _props$scrollRef.current) {
117
122
  var _props$scrollRef$curr;
118
123
  var target = e.currentTarget;
@@ -120,15 +125,17 @@ var useMenuItem = function useMenuItem(props) {
120
125
  var scrollRect = (_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.getBoundingClientRect();
121
126
  var topLine = scrollRect === null || scrollRect === void 0 ? void 0 : scrollRect.top;
122
127
  var bottomLine = scrollRect === null || scrollRect === void 0 ? void 0 : scrollRect.bottom;
123
- isUp = rect.bottom - topLine > (bottomLine - topLine) / 2;
128
+ up = rect.bottom - topLine > (bottomLine - topLine) / 2;
124
129
  }
125
- context.isUp = isUp;
126
- props.onOpenChange(function (before) {
127
- var openKeySet = new Set(before);
128
- openKeySet.add(props.keyResult);
129
- return Array.from(openKeySet);
130
- });
131
- document.addEventListener('click', handleMouseLeave);
130
+ if (isUp !== up) {
131
+ setIsUp(up);
132
+ }
133
+ // props.onOpenChange((before) => {
134
+ // const openKeySet = new Set(before);
135
+ // openKeySet.add(props.keyResult);
136
+ // return Array.from(openKeySet);
137
+ // });
138
+ // document.addEventListener('click', handleMouseLeave);
132
139
  }
133
140
  });
134
141
  (0, _react.useEffect)(function () {
@@ -144,11 +151,12 @@ var useMenuItem = function useMenuItem(props) {
144
151
  isOpen: gopenKeySet.has(props.keyResult),
145
152
  isDisabled: isDisabled,
146
153
  expandAble: expandAble,
147
- isUp: context.isUp,
154
+ isUp: isUp,
148
155
  handleItemClick: handleItemClick,
149
156
  handleMouseEnter: handleMouseEnter,
150
157
  handleMouseLeave: handleMouseLeave,
151
- handleExpandClick: handleExpandClick
158
+ handleExpandClick: handleExpandClick,
159
+ isLeaf: isLeaf
152
160
  };
153
161
  };
154
162
  var _default = exports.default = useMenuItem;
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu.d.ts","sourceRoot":"","sources":["use-menu.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,QAAA,MAAM,OAAO,UAAW,YAAY;;gCAwBgB,YAAY,EAAE,KAAK,YAAY,EAAE;qBAyC3D,MAAM,cAAc,UAAU;uBAI5B,MAAM;yBA5DS,MAAM;CA0EhD,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-menu.d.ts","sourceRoot":"","sources":["use-menu.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,QAAA,MAAM,OAAO,UAAW,YAAY;;gCAyBgB,YAAY,EAAE,KAAK,YAAY,EAAE;qBAkD3D,MAAM,cAAc,UAAU;uBAK5B,MAAM;yBAtES,MAAM;CAqFhD,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -13,7 +13,8 @@ var useMenu = function useMenu(props) {
13
13
  var _useRef = (0, _react.useRef)({
14
14
  updateMap: new Map(),
15
15
  activeId: '',
16
- cachedOpenKeys: props.openKeys || []
16
+ cachedOpenKeys: props.openKeys || [],
17
+ updateTimer: 0
17
18
  }),
18
19
  context = _useRef.current;
19
20
  var render = (0, _useRender.default)();
@@ -68,14 +69,23 @@ var useMenu = function useMenu(props) {
68
69
  updateItem(getStatus);
69
70
  });
70
71
  });
72
+ var updateWithThreshold = (0, _usePersistFn.default)(function () {
73
+ if (context.updateTimer) clearTimeout(context.updateTimer);
74
+ context.updateTimer = window.setTimeout(function () {
75
+ update();
76
+ // 需要更新两次 否则 inPath 状态错误
77
+ update();
78
+ }, 50);
79
+ });
71
80
  var bindUpdate = function bindUpdate(id, updateItem) {
72
81
  context.updateMap.set(id, updateItem);
82
+ updateWithThreshold();
73
83
  };
74
84
  var unbindUpdate = function unbindUpdate(id) {
75
85
  context.updateMap.delete(id);
76
86
  };
77
87
  (0, _react.useEffect)(function () {
78
- update();
88
+ updateWithThreshold();
79
89
  });
80
90
  return {
81
91
  openKeys: value,
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA8N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA+N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -263,7 +263,8 @@ var useTableLayout = function useTableLayout(props) {
263
263
  changeColGroup(newCols, false);
264
264
  });
265
265
  var checkFloat = (0, _usePersistFn.default)(function () {
266
- var scrollEl = scrollRef.current;
266
+ var scrollEl = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current;
267
+ if (!scrollEl) return;
267
268
  var max = scrollEl.scrollWidth - scrollEl.clientWidth;
268
269
  var min = 0;
269
270
  var left = scrollEl.scrollLeft;
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -16,6 +16,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
17
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
18
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
+ function toArray(value) {
20
+ if (!value) return [];
21
+ if (!Array.isArray(value)) return [value];
22
+ return value;
23
+ }
19
24
  var MODE = exports.MODE = {
20
25
  /**
21
26
  * 返回全选数据,包含父节点和子节点
@@ -75,7 +80,6 @@ var useTree = function useTree(props) {
75
80
  valueMap: new Map(),
76
81
  updateMap: new Map(),
77
82
  unmatchedValueMap: new Map(),
78
- disabled: false,
79
83
  value: undefined,
80
84
  data: [],
81
85
  cachedValue: [],
@@ -165,14 +169,14 @@ var useTree = function useTree(props) {
165
169
  var getPath = function getPath(id) {
166
170
  return context.pathMap.get(id);
167
171
  };
168
- var getDisabled = function getDisabled() {
172
+ var getDisabled = (0, _usePersistFn.usePersistFn)(function () {
169
173
  if ((0, _is.isFunc)(disabledProps)) {
170
174
  return disabledProps;
171
175
  }
172
176
  return function () {
173
- return !!disabledProps;
177
+ return false;
174
178
  };
175
- };
179
+ });
176
180
  var getChecked = function getChecked(id) {
177
181
  var value = get(id);
178
182
  var checked = value === 1;
@@ -227,8 +231,8 @@ var useTree = function useTree(props) {
227
231
  // 制作 data mapping
228
232
  context.dataMap.set(id, item);
229
233
  var _isDisabled = !!disabled;
230
- if (_isDisabled === false && (0, _is.isFunc)(context.disabled)) {
231
- _isDisabled = context.disabled(item);
234
+ if (_isDisabled === false) {
235
+ _isDisabled = getDisabled()(item);
232
236
  }
233
237
  var indexPath = [].concat(_toConsumableArray(index), [i]);
234
238
  ids.push(id);
@@ -303,16 +307,19 @@ var useTree = function useTree(props) {
303
307
  return checked;
304
308
  };
305
309
  var setValue = function setValue(value) {
306
- context.value = value;
307
- if (value && value !== context.cachedValue) {
310
+ context.value = toArray(value);
311
+ if (value !== context.cachedValue) {
308
312
  initValue();
309
313
  }
310
314
  setUnmatedValue();
311
315
  };
312
316
  var isDisabled = function isDisabled(id) {
313
- var node = context.pathMap.get(id);
314
- if (node) return node.isDisabled;
315
- return false;
317
+ if ((0, _is.isFunc)(disabledProps)) {
318
+ var node = context.pathMap.get(id);
319
+ if (node) return node.isDisabled;
320
+ return false;
321
+ }
322
+ return !!disabledProps;
316
323
  };
317
324
  var checkStatusStack = function checkStatusStack(stack, defaultStatus) {
318
325
  if (!stack || stack.length <= 0) return defaultStatus;
@@ -332,10 +339,9 @@ var useTree = function useTree(props) {
332
339
  context.dataMap = new Map();
333
340
  context.valueMap = new Map();
334
341
  context.unmatchedValueMap = new Map();
335
- context.disabled = getDisabled();
336
- context.data = data;
342
+ context.data = toArray(data);
337
343
  if (!data) return;
338
- initData(data, []);
344
+ initData(context.data, []);
339
345
  initValue();
340
346
  setValue(prevValue);
341
347
  };
@@ -9,7 +9,6 @@ export interface TreeContext<DataItem> {
9
9
  unmatchedValueMap: Map<any, any>;
10
10
  updateMap: Map<KeygenResult, UpdateFunc>;
11
11
  forceUpdateMap: Map<KeygenResult, () => void>;
12
- disabled: boolean | ((item: DataItem) => boolean);
13
12
  value?: KeygenResult[];
14
13
  cachedValue: KeygenResult[];
15
14
  data?: DataItem[];
@@ -103,6 +102,9 @@ export interface BaseTreeProps<DataItem> {
103
102
  * @private 保持数据缓存
104
103
  */
105
104
  keepCache?: boolean;
105
+ /**
106
+ * @private 内部数据处理
107
+ */
106
108
  datum?: TreeDatum<DataItem>;
107
109
  }
108
110
  export interface TreeDatum<DataItem> {
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.type.d.ts","sourceRoot":"","sources":["use-tree.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,WAAW,CAAC,QAAQ;IACnC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAC/C,iBAAiB,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzC,cAAc,EAAE,GAAG,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC;IAC9C,QAAQ,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;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Q,EAAE,KAAK,IAAI,CAAC;IACrC,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC;IAC1C,QAAQ,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,KAAK;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3F,WAAW,EAAE,CACX,EAAE,EAAE,YAAY,KACb,QAAQ,GAAG;QAAE,oBAAoB,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9E,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAC3D,YAAY,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACpC,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;CAChD"}
@@ -37,13 +37,13 @@ var useTreeSelect = function useTreeSelect(props) {
37
37
  }
38
38
  if (!multiple && (0, _is.isArray)(v)) {
39
39
  onChange === null || onChange === void 0 || onChange.apply(void 0, [v[0]].concat(reset));
40
- }
41
- if (multiple && !(0, _is.isArray)(v)) {
40
+ } else if (multiple && !(0, _is.isArray)(v)) {
42
41
  if (v === undefined || v === null) {
43
42
  onChange === null || onChange === void 0 || onChange.apply(void 0, [[]].concat(reset));
44
43
  } else onChange === null || onChange === void 0 || onChange.apply(void 0, [[v]].concat(reset));
44
+ } else {
45
+ onChange === null || onChange === void 0 || onChange.apply(void 0, [v].concat(reset));
45
46
  }
46
- onChange === null || onChange === void 0 || onChange.apply(void 0, [v].concat(reset));
47
47
  });
48
48
  return {
49
49
  value: valueArr,
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAyLkB,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BpC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAuL+B,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BjD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -172,10 +172,9 @@ var useUpload = function useUpload(props) {
172
172
  });
173
173
  });
174
174
  };
175
- var getCurrent = (0, _usePersistFn.default)(function () {
176
- return {
177
- filesState: filesState
178
- };
175
+ var latestState = (0, _useLatestObj.default)({
176
+ filesState: filesState,
177
+ value: value
179
178
  });
180
179
  var uploadFile = function uploadFile(id, file, data) {
181
180
  var request = props.request || _xhr.default;
@@ -196,8 +195,7 @@ var useUpload = function useUpload(props) {
196
195
  throttle = false;
197
196
  }, 16);
198
197
  var percent = typeof e.percent === 'number' ? e.percent : e.loaded / e.total * 100;
199
- var _getCurrent = getCurrent(),
200
- filesState = _getCurrent.filesState;
198
+ var filesState = latestState.filesState;
201
199
  var newFiles = _objectSpread({}, filesState);
202
200
  if (!newFiles[id]) return;
203
201
  newFiles[id].process = percent;
@@ -234,7 +232,7 @@ var useUpload = function useUpload(props) {
234
232
  });
235
233
  });
236
234
  // add value
237
- var values = (0, _immer.produce)(value, function (draft) {
235
+ var values = (0, _immer.produce)(latestState.value, function (draft) {
238
236
  draft.push(result);
239
237
  });
240
238
  props.onChange(values);
@@ -287,7 +285,7 @@ var useUpload = function useUpload(props) {
287
285
  reader.readAsDataURL(blob);
288
286
  });
289
287
  };
290
- var addFiles = /*#__PURE__*/function () {
288
+ var addFiles = (0, _usePersistFn.default)( /*#__PURE__*/function () {
291
289
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(files) {
292
290
  var fileList, newFiles, resetLength, list, _loop, _ret, i;
293
291
  return _regeneratorRuntime().wrap(function _callee2$(_context3) {
@@ -426,11 +424,11 @@ var useUpload = function useUpload(props) {
426
424
  }
427
425
  }, _callee2);
428
426
  }));
429
- return function addFiles(_x3) {
427
+ return function (_x3) {
430
428
  return _ref2.apply(this, arguments);
431
429
  };
432
- }();
433
- var removeFile = function removeFile(id) {
430
+ }());
431
+ var removeFile = (0, _usePersistFn.default)(function (id) {
434
432
  var beforeCancel = props.beforeCancel,
435
433
  onErrorRemove = props.onErrorRemove;
436
434
  var file = filesState[id];
@@ -448,8 +446,8 @@ var useUpload = function useUpload(props) {
448
446
  onErrorRemove(file.xhr, file.blob, file);
449
447
  }
450
448
  }
451
- };
452
- var removeValue = function removeValue(index) {
449
+ });
450
+ var removeValue = (0, _usePersistFn.default)(function (index) {
453
451
  if (props.disabled) return;
454
452
  var recoverAble = props.recoverAble,
455
453
  beforeRemove = props.beforeRemove;
@@ -461,15 +459,15 @@ var useUpload = function useUpload(props) {
461
459
  newRecycle.push(value[index]);
462
460
  }
463
461
  setRecycleValues(newRecycle);
464
- var newValue = (0, _immer.produce)(props.value, function (draft) {
462
+ var newValue = (0, _immer.produce)(latestState.value, function (draft) {
465
463
  draft.splice(index, 1);
466
464
  });
467
465
  props.onChange(newValue);
468
466
  }).catch(function () {});
469
- };
470
- var recoverValue = function recoverValue(index) {
467
+ });
468
+ var recoverValue = (0, _usePersistFn.default)(function (index) {
471
469
  if (props.disabled) return;
472
- props.onChange((0, _immer.produce)(props.value, function (draft) {
470
+ props.onChange((0, _immer.produce)(latestState.value, function (draft) {
473
471
  draft.push(recycleValues[index]);
474
472
  }));
475
473
  setRecycleValues(function (pre) {
@@ -477,7 +475,7 @@ var useUpload = function useUpload(props) {
477
475
  newRecycle.splice(index, 1);
478
476
  return newRecycle;
479
477
  });
480
- };
478
+ });
481
479
  var func = (0, _useLatestObj.default)({
482
480
  addFiles: addFiles,
483
481
  removeFile: removeFile,
@@ -105,7 +105,7 @@ export interface RuleFuncResult {
105
105
  export type RuleResult = {
106
106
  [key: string]: RuleFuncResult;
107
107
  } | RuleCommonResult;
108
- export type RuleResultValue = ValueOf<RuleResult>;
108
+ export type RuleResultValue = RuleFuncResult | ValueOf<RuleCommonResult>;
109
109
  export type FormItemObjectRule = Type & RegExpParams & Range & Min & Max & Required & {
110
110
  func?: ValidFunc;
111
111
  args?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"rule.type.d.ts","sourceRoot":"","sources":["rule.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpC,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,GAAG;IAChC,CACE,KAAK,EAAE,CAAC,GAAG,SAAS,EACpB,SAAS,EAAE,UAAU,EACrB,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,EAClC,KAAK,EAAE,GAAG,GACT,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,G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AK,CAAC,EAAE,KAAK,KACV,IAAI,CAAC,CACb,CAAC;AAGF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,CAAC,QAAQ,EAAE,MAAM,GACb;QACE,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB,GACD,SAAS,GACT,SAAS,CAAC;CACf;AAGD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,gBAAgB,EAAE,IAAI,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
1
+ {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
@@ -8,6 +8,7 @@ var _nullable = _interopRequireDefault(require("./nullable"));
8
8
  var _is = require("../is");
9
9
  var _type = _interopRequireDefault(require("./type"));
10
10
  var _error = require("./error");
11
+ var _string = require("../string");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  function getRule(rule, props) {
13
14
  var po = props;
@@ -30,7 +31,7 @@ function getRule(rule, props) {
30
31
  max: max,
31
32
  args: args
32
33
  });
33
- po.message = typeof message === 'function' ? message(po) : message;
34
+ po.message = typeof message === 'function' ? message(po) : (0, _string.substitute)(message, po);
34
35
  var cb = function cb() {};
35
36
  if (func) {
36
37
  cb = function cb(value, formData, callback) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;CAqFxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;CAsFxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -97,6 +97,7 @@ var useTransform = function useTransform(props) {
97
97
  if (!containerDimension || !targetDimension) return;
98
98
  if (targetDimension <= containerDimension) {
99
99
  setShouldScroll(false);
100
+ setDelta(0);
100
101
  } else {
101
102
  setShouldScroll(true);
102
103
  }
@@ -1,7 +1,7 @@
1
1
  export interface FormDatum {
2
2
  set: (vals: {
3
3
  [name: string]: any;
4
- }) => void;
4
+ } | string, value?: any) => void;
5
5
  get: (name?: string) => any;
6
6
  }
7
7
  declare const useFormDatum: () => FormDatum | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AACD,QAAA,MAAM,YAAY,6BAQjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,9 +1,21 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
3
+ 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); }
4
+ 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); }
1
5
  import useLatestObj from "../../../common/use-latest-obj";
6
+ import { usePersistFn } from "../../../common/use-persist-fn";
2
7
  import { useFormFunc } from "../form-func-context";
3
8
  var useFormDatum = function useFormDatum() {
4
9
  var formFunc = useFormFunc();
10
+ var set = usePersistFn(function (vals, value) {
11
+ if (_typeof(vals) === 'object') {
12
+ formFunc === null || formFunc === void 0 || formFunc.setValue(vals);
13
+ } else {
14
+ formFunc === null || formFunc === void 0 || formFunc.setValue(_defineProperty({}, vals, value));
15
+ }
16
+ });
5
17
  var func = useLatestObj({
6
- set: formFunc === null || formFunc === void 0 ? void 0 : formFunc.setValue,
18
+ set: set,
7
19
  get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
8
20
  });
9
21
  var datum = formFunc ? func : undefined;
@@ -48,7 +48,7 @@ var useForm = function useForm(props) {
48
48
  removeArr: new Set(),
49
49
  names: new Set(),
50
50
  submitLock: false,
51
- value: props.value || emptyObj,
51
+ value: deepClone(props.value) || emptyObj,
52
52
  errors: {},
53
53
  serverErrors: {},
54
54
  lastValue: props.value || emptyObj,
@@ -11,6 +11,7 @@ declare const useMenuItem: (props: UseMenuItemProps) => {
11
11
  handleMouseEnter: (e: React.MouseEvent) => void;
12
12
  handleMouseLeave: () => void;
13
13
  handleExpandClick: (e: React.MouseEvent) => void;
14
+ isLeaf: boolean;
14
15
  };
15
16
  export default useMenuItem;
16
17
  //# sourceMappingURL=use-menu-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu-item.d.ts","sourceRoot":"","sources":["use-menu-item.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,QAAA,MAAM,WAAW,UAAW,gBAAgB;;;;;;;;yBA4BD,gBAAgB;0BA2Df,gBAAgB;;2BAhCf,gBAAgB;CA6E5D,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"use-menu-item.d.ts","sourceRoot":"","sources":["use-menu-item.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,QAAA,MAAM,WAAW,UAAW,gBAAgB;;;;;;;;yBA8BD,gBAAgB;0BA8Df,gBAAgB;;2BAhCf,gBAAgB;;CAgF5D,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -10,15 +10,13 @@ import { getUidStr } from "../../utils/uid";
10
10
  var useMenuItem = function useMenuItem(props) {
11
11
  var _useRef = useRef({
12
12
  id: '',
13
- timer: null,
14
- isUp: false
13
+ timer: null
15
14
  }),
16
15
  context = _useRef.current;
17
16
  var _props$parentId = props.parentId,
18
17
  parentId = _props$parentId === void 0 ? '' : _props$parentId,
19
- dataItem = props.dataItem,
20
- _props$toggleDuration = props.toggleDuration,
21
- toggleDuration = _props$toggleDuration === void 0 ? 200 : _props$toggleDuration;
18
+ dataItem = props.dataItem;
19
+ var isLeaf = ((dataItem || {}).children || []).length === 0;
22
20
  if (!context.id) {
23
21
  context.id = "".concat(parentId, ",").concat(getUidStr());
24
22
  }
@@ -33,6 +31,10 @@ var useMenuItem = function useMenuItem(props) {
33
31
  _useState4 = _slicedToArray(_useState3, 2),
34
32
  isInPath = _useState4[0],
35
33
  setInPath = _useState4[1];
34
+ var _useState5 = useState(false),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ isUp = _useState6[0],
37
+ setIsUp = _useState6[1];
36
38
  var update = usePersistFn(function (getStatus) {
37
39
  var status = getStatus(context.id, props.dataItem);
38
40
  if (isChecked !== status.isChecked) {
@@ -65,8 +67,11 @@ var useMenuItem = function useMenuItem(props) {
65
67
  props.onClick(dataItem);
66
68
  }
67
69
  }
68
- var isLeaf = ((dataItem || {}).children || []).length === 0;
69
- if (!isLeaf) e.nativeEvent.stopImmediatePropagation();
70
+ // 阻止冒泡
71
+ if (!isLeaf) {
72
+ e.stopPropagation();
73
+ e.nativeEvent.stopImmediatePropagation();
74
+ }
70
75
  });
71
76
  var handleExpandClick = usePersistFn(function (e) {
72
77
  e.stopPropagation();
@@ -83,29 +88,29 @@ var useMenuItem = function useMenuItem(props) {
83
88
  }
84
89
  });
85
90
  var handleMouseLeave = usePersistFn(function () {
86
- if (expandAble && props.mode !== 'inline') {
87
- if (context.timer) {
88
- clearTimeout(context.timer);
89
- context.timer = null;
90
- }
91
- context.timer = setTimeout(function () {
92
- props.onOpenChange(function (before) {
93
- var openKeySet = new Set(before);
94
- openKeySet.delete(props.keyResult);
95
- return Array.from(openKeySet);
96
- });
97
- }, toggleDuration);
98
- document.removeEventListener('click', handleMouseLeave);
99
- }
91
+ // if (expandAble && props.mode !== 'inline') {
92
+ // if (context.timer) {
93
+ // clearTimeout(context.timer);
94
+ // context.timer = null;
95
+ // }
96
+ // context.timer = setTimeout(() => {
97
+ // props.onOpenChange((before) => {
98
+ // const openKeySet = new Set(before);
99
+ // openKeySet.delete(props.keyResult);
100
+ // return Array.from(openKeySet);
101
+ // });
102
+ // }, toggleDuration);
103
+ // document.removeEventListener('click', handleMouseLeave);
104
+ // }
100
105
  });
101
106
  var handleMouseEnter = usePersistFn(function (e) {
102
107
  if (expandAble && props.mode !== 'inline') {
103
108
  var _props$scrollRef;
104
- if (context.timer) {
105
- clearTimeout(context.timer);
106
- context.timer = null;
107
- }
108
- var isUp = false;
109
+ // if (context.timer) {
110
+ // clearTimeout(context.timer);
111
+ // context.timer = null;
112
+ // }
113
+ var up = false;
109
114
  if (props.mode === 'vertical-auto' && (_props$scrollRef = props.scrollRef) !== null && _props$scrollRef !== void 0 && _props$scrollRef.current) {
110
115
  var _props$scrollRef$curr;
111
116
  var target = e.currentTarget;
@@ -113,15 +118,17 @@ var useMenuItem = function useMenuItem(props) {
113
118
  var scrollRect = (_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.getBoundingClientRect();
114
119
  var topLine = scrollRect === null || scrollRect === void 0 ? void 0 : scrollRect.top;
115
120
  var bottomLine = scrollRect === null || scrollRect === void 0 ? void 0 : scrollRect.bottom;
116
- isUp = rect.bottom - topLine > (bottomLine - topLine) / 2;
121
+ up = rect.bottom - topLine > (bottomLine - topLine) / 2;
117
122
  }
118
- context.isUp = isUp;
119
- props.onOpenChange(function (before) {
120
- var openKeySet = new Set(before);
121
- openKeySet.add(props.keyResult);
122
- return Array.from(openKeySet);
123
- });
124
- document.addEventListener('click', handleMouseLeave);
123
+ if (isUp !== up) {
124
+ setIsUp(up);
125
+ }
126
+ // props.onOpenChange((before) => {
127
+ // const openKeySet = new Set(before);
128
+ // openKeySet.add(props.keyResult);
129
+ // return Array.from(openKeySet);
130
+ // });
131
+ // document.addEventListener('click', handleMouseLeave);
125
132
  }
126
133
  });
127
134
  useEffect(function () {
@@ -137,11 +144,12 @@ var useMenuItem = function useMenuItem(props) {
137
144
  isOpen: gopenKeySet.has(props.keyResult),
138
145
  isDisabled: isDisabled,
139
146
  expandAble: expandAble,
140
- isUp: context.isUp,
147
+ isUp: isUp,
141
148
  handleItemClick: handleItemClick,
142
149
  handleMouseEnter: handleMouseEnter,
143
150
  handleMouseLeave: handleMouseLeave,
144
- handleExpandClick: handleExpandClick
151
+ handleExpandClick: handleExpandClick,
152
+ isLeaf: isLeaf
145
153
  };
146
154
  };
147
155
  export default useMenuItem;
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu.d.ts","sourceRoot":"","sources":["use-menu.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,QAAA,MAAM,OAAO,UAAW,YAAY;;gCAwBgB,YAAY,EAAE,KAAK,YAAY,EAAE;qBAyC3D,MAAM,cAAc,UAAU;uBAI5B,MAAM;yBA5DS,MAAM;CA0EhD,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-menu.d.ts","sourceRoot":"","sources":["use-menu.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,QAAA,MAAM,OAAO,UAAW,YAAY;;gCAyBgB,YAAY,EAAE,KAAK,YAAY,EAAE;qBAkD3D,MAAM,cAAc,UAAU;uBAK5B,MAAM;yBAtES,MAAM;CAqFhD,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -6,7 +6,8 @@ var useMenu = function useMenu(props) {
6
6
  var _useRef = useRef({
7
7
  updateMap: new Map(),
8
8
  activeId: '',
9
- cachedOpenKeys: props.openKeys || []
9
+ cachedOpenKeys: props.openKeys || [],
10
+ updateTimer: 0
10
11
  }),
11
12
  context = _useRef.current;
12
13
  var render = useRender();
@@ -61,14 +62,23 @@ var useMenu = function useMenu(props) {
61
62
  updateItem(getStatus);
62
63
  });
63
64
  });
65
+ var updateWithThreshold = usePersistFn(function () {
66
+ if (context.updateTimer) clearTimeout(context.updateTimer);
67
+ context.updateTimer = window.setTimeout(function () {
68
+ update();
69
+ // 需要更新两次 否则 inPath 状态错误
70
+ update();
71
+ }, 50);
72
+ });
64
73
  var bindUpdate = function bindUpdate(id, updateItem) {
65
74
  context.updateMap.set(id, updateItem);
75
+ updateWithThreshold();
66
76
  };
67
77
  var unbindUpdate = function unbindUpdate(id) {
68
78
  context.updateMap.delete(id);
69
79
  };
70
80
  useEffect(function () {
71
- update();
81
+ updateWithThreshold();
72
82
  });
73
83
  return {
74
84
  openKeys: value,
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA8N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA+N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -254,7 +254,8 @@ var useTableLayout = function useTableLayout(props) {
254
254
  changeColGroup(newCols, false);
255
255
  });
256
256
  var checkFloat = usePersistFn(function () {
257
- var scrollEl = scrollRef.current;
257
+ var scrollEl = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current;
258
+ if (!scrollEl) return;
258
259
  var max = scrollEl.scrollWidth - scrollEl.clientWidth;
259
260
  var min = 0;
260
261
  var left = scrollEl.scrollLeft;
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -9,6 +9,11 @@ import useLatestObj from "../../common/use-latest-obj";
9
9
  import { useInputAble } from "../../common/use-input-able";
10
10
  import { usePersistFn } from "../../common/use-persist-fn";
11
11
  import { isFunc, isString, isNumber, isArray, isUnMatchedData } from "../../utils/is";
12
+ function toArray(value) {
13
+ if (!value) return [];
14
+ if (!Array.isArray(value)) return [value];
15
+ return value;
16
+ }
12
17
  export var MODE = {
13
18
  /**
14
19
  * 返回全选数据,包含父节点和子节点
@@ -68,7 +73,6 @@ var useTree = function useTree(props) {
68
73
  valueMap: new Map(),
69
74
  updateMap: new Map(),
70
75
  unmatchedValueMap: new Map(),
71
- disabled: false,
72
76
  value: undefined,
73
77
  data: [],
74
78
  cachedValue: [],
@@ -158,14 +162,14 @@ var useTree = function useTree(props) {
158
162
  var getPath = function getPath(id) {
159
163
  return context.pathMap.get(id);
160
164
  };
161
- var getDisabled = function getDisabled() {
165
+ var getDisabled = usePersistFn(function () {
162
166
  if (isFunc(disabledProps)) {
163
167
  return disabledProps;
164
168
  }
165
169
  return function () {
166
- return !!disabledProps;
170
+ return false;
167
171
  };
168
- };
172
+ });
169
173
  var getChecked = function getChecked(id) {
170
174
  var value = get(id);
171
175
  var checked = value === 1;
@@ -220,8 +224,8 @@ var useTree = function useTree(props) {
220
224
  // 制作 data mapping
221
225
  context.dataMap.set(id, item);
222
226
  var _isDisabled = !!disabled;
223
- if (_isDisabled === false && isFunc(context.disabled)) {
224
- _isDisabled = context.disabled(item);
227
+ if (_isDisabled === false) {
228
+ _isDisabled = getDisabled()(item);
225
229
  }
226
230
  var indexPath = [].concat(_toConsumableArray(index), [i]);
227
231
  ids.push(id);
@@ -296,16 +300,19 @@ var useTree = function useTree(props) {
296
300
  return checked;
297
301
  };
298
302
  var setValue = function setValue(value) {
299
- context.value = value;
300
- if (value && value !== context.cachedValue) {
303
+ context.value = toArray(value);
304
+ if (value !== context.cachedValue) {
301
305
  initValue();
302
306
  }
303
307
  setUnmatedValue();
304
308
  };
305
309
  var isDisabled = function isDisabled(id) {
306
- var node = context.pathMap.get(id);
307
- if (node) return node.isDisabled;
308
- return false;
310
+ if (isFunc(disabledProps)) {
311
+ var node = context.pathMap.get(id);
312
+ if (node) return node.isDisabled;
313
+ return false;
314
+ }
315
+ return !!disabledProps;
309
316
  };
310
317
  var checkStatusStack = function checkStatusStack(stack, defaultStatus) {
311
318
  if (!stack || stack.length <= 0) return defaultStatus;
@@ -325,10 +332,9 @@ var useTree = function useTree(props) {
325
332
  context.dataMap = new Map();
326
333
  context.valueMap = new Map();
327
334
  context.unmatchedValueMap = new Map();
328
- context.disabled = getDisabled();
329
- context.data = data;
335
+ context.data = toArray(data);
330
336
  if (!data) return;
331
- initData(data, []);
337
+ initData(context.data, []);
332
338
  initValue();
333
339
  setValue(prevValue);
334
340
  };
@@ -9,7 +9,6 @@ export interface TreeContext<DataItem> {
9
9
  unmatchedValueMap: Map<any, any>;
10
10
  updateMap: Map<KeygenResult, UpdateFunc>;
11
11
  forceUpdateMap: Map<KeygenResult, () => void>;
12
- disabled: boolean | ((item: DataItem) => boolean);
13
12
  value?: KeygenResult[];
14
13
  cachedValue: KeygenResult[];
15
14
  data?: DataItem[];
@@ -103,6 +102,9 @@ export interface BaseTreeProps<DataItem> {
103
102
  * @private 保持数据缓存
104
103
  */
105
104
  keepCache?: boolean;
105
+ /**
106
+ * @private 内部数据处理
107
+ */
106
108
  datum?: TreeDatum<DataItem>;
107
109
  }
108
110
  export interface TreeDatum<DataItem> {
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.type.d.ts","sourceRoot":"","sources":["use-tree.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,C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AAE,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACpC,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;CAChD"}
@@ -30,13 +30,13 @@ var useTreeSelect = function useTreeSelect(props) {
30
30
  }
31
31
  if (!multiple && isArray(v)) {
32
32
  onChange === null || onChange === void 0 || onChange.apply(void 0, [v[0]].concat(reset));
33
- }
34
- if (multiple && !isArray(v)) {
33
+ } else if (multiple && !isArray(v)) {
35
34
  if (v === undefined || v === null) {
36
35
  onChange === null || onChange === void 0 || onChange.apply(void 0, [[]].concat(reset));
37
36
  } else onChange === null || onChange === void 0 || onChange.apply(void 0, [[v]].concat(reset));
37
+ } else {
38
+ onChange === null || onChange === void 0 || onChange.apply(void 0, [v].concat(reset));
38
39
  }
39
- onChange === null || onChange === void 0 || onChange.apply(void 0, [v].concat(reset));
40
40
  });
41
41
  return {
42
42
  value: valueArr,
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAyLkB,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BpC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAuL+B,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BjD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -165,10 +165,9 @@ var useUpload = function useUpload(props) {
165
165
  });
166
166
  });
167
167
  };
168
- var getCurrent = usePersistFn(function () {
169
- return {
170
- filesState: filesState
171
- };
168
+ var latestState = useLatestObj({
169
+ filesState: filesState,
170
+ value: value
172
171
  });
173
172
  var uploadFile = function uploadFile(id, file, data) {
174
173
  var request = props.request || xhrUpload;
@@ -189,8 +188,7 @@ var useUpload = function useUpload(props) {
189
188
  throttle = false;
190
189
  }, 16);
191
190
  var percent = typeof e.percent === 'number' ? e.percent : e.loaded / e.total * 100;
192
- var _getCurrent = getCurrent(),
193
- filesState = _getCurrent.filesState;
191
+ var filesState = latestState.filesState;
194
192
  var newFiles = _objectSpread({}, filesState);
195
193
  if (!newFiles[id]) return;
196
194
  newFiles[id].process = percent;
@@ -227,7 +225,7 @@ var useUpload = function useUpload(props) {
227
225
  });
228
226
  });
229
227
  // add value
230
- var values = produce(value, function (draft) {
228
+ var values = produce(latestState.value, function (draft) {
231
229
  draft.push(result);
232
230
  });
233
231
  props.onChange(values);
@@ -280,7 +278,7 @@ var useUpload = function useUpload(props) {
280
278
  reader.readAsDataURL(blob);
281
279
  });
282
280
  };
283
- var addFiles = /*#__PURE__*/function () {
281
+ var addFiles = usePersistFn( /*#__PURE__*/function () {
284
282
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(files) {
285
283
  var fileList, newFiles, resetLength, list, _loop, _ret, i;
286
284
  return _regeneratorRuntime().wrap(function _callee2$(_context3) {
@@ -419,11 +417,11 @@ var useUpload = function useUpload(props) {
419
417
  }
420
418
  }, _callee2);
421
419
  }));
422
- return function addFiles(_x3) {
420
+ return function (_x3) {
423
421
  return _ref2.apply(this, arguments);
424
422
  };
425
- }();
426
- var removeFile = function removeFile(id) {
423
+ }());
424
+ var removeFile = usePersistFn(function (id) {
427
425
  var beforeCancel = props.beforeCancel,
428
426
  onErrorRemove = props.onErrorRemove;
429
427
  var file = filesState[id];
@@ -441,8 +439,8 @@ var useUpload = function useUpload(props) {
441
439
  onErrorRemove(file.xhr, file.blob, file);
442
440
  }
443
441
  }
444
- };
445
- var removeValue = function removeValue(index) {
442
+ });
443
+ var removeValue = usePersistFn(function (index) {
446
444
  if (props.disabled) return;
447
445
  var recoverAble = props.recoverAble,
448
446
  beforeRemove = props.beforeRemove;
@@ -454,15 +452,15 @@ var useUpload = function useUpload(props) {
454
452
  newRecycle.push(value[index]);
455
453
  }
456
454
  setRecycleValues(newRecycle);
457
- var newValue = produce(props.value, function (draft) {
455
+ var newValue = produce(latestState.value, function (draft) {
458
456
  draft.splice(index, 1);
459
457
  });
460
458
  props.onChange(newValue);
461
459
  }).catch(function () {});
462
- };
463
- var recoverValue = function recoverValue(index) {
460
+ });
461
+ var recoverValue = usePersistFn(function (index) {
464
462
  if (props.disabled) return;
465
- props.onChange(produce(props.value, function (draft) {
463
+ props.onChange(produce(latestState.value, function (draft) {
466
464
  draft.push(recycleValues[index]);
467
465
  }));
468
466
  setRecycleValues(function (pre) {
@@ -470,7 +468,7 @@ var useUpload = function useUpload(props) {
470
468
  newRecycle.splice(index, 1);
471
469
  return newRecycle;
472
470
  });
473
- };
471
+ });
474
472
  var func = useLatestObj({
475
473
  addFiles: addFiles,
476
474
  removeFile: removeFile,
@@ -105,7 +105,7 @@ export interface RuleFuncResult {
105
105
  export type RuleResult = {
106
106
  [key: string]: RuleFuncResult;
107
107
  } | RuleCommonResult;
108
- export type RuleResultValue = ValueOf<RuleResult>;
108
+ export type RuleResultValue = RuleFuncResult | ValueOf<RuleCommonResult>;
109
109
  export type FormItemObjectRule = Type & RegExpParams & Range & Min & Max & Required & {
110
110
  func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E,WAAW,CAAC;KACvB,GACD,SAAS,GACT,SAAS,CAAC;CACf;AAGD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,gBAAgB,EAAE,IAAI,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
1
+ {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
@@ -2,6 +2,7 @@ import nullable from "./nullable";
2
2
  import { isEmpty } from "../is";
3
3
  import typeOf from "./type";
4
4
  import { FormError } from "./error";
5
+ import { substitute } from "../string";
5
6
  export default function getRule(rule, props) {
6
7
  var po = props;
7
8
  var rulePo = rule;
@@ -23,7 +24,7 @@ export default function getRule(rule, props) {
23
24
  max: max,
24
25
  args: args
25
26
  });
26
- po.message = typeof message === 'function' ? message(po) : message;
27
+ po.message = typeof message === 'function' ? message(po) : substitute(message, po);
27
28
  var cb = function cb() {};
28
29
  if (func) {
29
30
  cb = function cb(value, formData, callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.2.0-rc.3",
3
+ "version": "3.2.0-rc.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",