@sheinx/hooks 3.2.0-rc.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/common/use-click-away/index.d.ts.map +1 -1
- package/cjs/common/use-click-away/index.js +4 -1
- package/cjs/common/use-transform/use-transform.d.ts.map +1 -1
- package/cjs/common/use-transform/use-transform.js +1 -0
- package/cjs/components/use-button/use-button.js +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.js +13 -1
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +10 -3
- package/cjs/components/use-menu/use-menu-item.d.ts +1 -0
- package/cjs/components/use-menu/use-menu-item.d.ts.map +1 -1
- package/cjs/components/use-menu/use-menu-item.js +44 -36
- package/cjs/components/use-menu/use-menu.d.ts.map +1 -1
- package/cjs/components/use-menu/use-menu.js +12 -2
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +20 -14
- package/cjs/components/use-tree/use-tree.type.d.ts +3 -1
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/cjs/components/use-upload/use-upload.d.ts.map +1 -1
- package/cjs/components/use-upload/use-upload.js +16 -18
- package/cjs/utils/rule/rule.type.d.ts +1 -1
- package/cjs/utils/rule/rule.type.d.ts.map +1 -1
- package/cjs/utils/validate/get-rule.d.ts.map +1 -1
- package/cjs/utils/validate/get-rule.js +2 -1
- package/esm/common/use-click-away/index.d.ts.map +1 -1
- package/esm/common/use-click-away/index.js +4 -1
- package/esm/common/use-transform/use-transform.d.ts.map +1 -1
- package/esm/common/use-transform/use-transform.js +1 -0
- package/esm/components/use-button/use-button.js +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.js +13 -1
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +10 -3
- package/esm/components/use-menu/use-menu-item.d.ts +1 -0
- package/esm/components/use-menu/use-menu-item.d.ts.map +1 -1
- package/esm/components/use-menu/use-menu-item.js +44 -36
- package/esm/components/use-menu/use-menu.d.ts.map +1 -1
- package/esm/components/use-menu/use-menu.js +12 -2
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +20 -14
- package/esm/components/use-tree/use-tree.type.d.ts +3 -1
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/components/use-upload/use-upload.d.ts.map +1 -1
- package/esm/components/use-upload/use-upload.js +16 -18
- package/esm/utils/rule/rule.type.d.ts +1 -1
- package/esm/utils/rule/rule.type.d.ts.map +1 -1
- package/esm/utils/validate/get-rule.d.ts.map +1 -1
- package/esm/utils/validate/get-rule.js +2 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,QAqCA;AAED,eAAe,YAAY,CAAC"}
|
@@ -45,7 +45,10 @@ function useClickAway(params) {
|
|
45
45
|
}
|
46
46
|
return function () {
|
47
47
|
// @ts-ignore
|
48
|
-
document.removeEventListener(event, handleClickAway
|
48
|
+
document.removeEventListener(event, handleClickAway, {
|
49
|
+
// 解决 点击后立刻删除dom导致获取不到元素; contains(target) 为 false 的问题
|
50
|
+
capture: true
|
51
|
+
});
|
49
52
|
};
|
50
53
|
}, [effect]);
|
51
54
|
}
|
@@ -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;;;
|
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"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"
|
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:
|
25
|
+
set: set,
|
14
26
|
get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
|
15
27
|
});
|
16
28
|
var datum = formFunc ? func : undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAiU7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -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,
|
@@ -384,6 +384,13 @@ var useForm = function useForm(props) {
|
|
384
384
|
size: size
|
385
385
|
};
|
386
386
|
}, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size]);
|
387
|
+
var updateValue = function updateValue() {
|
388
|
+
if (props.value !== context.lastValue && props.value !== context.value) {
|
389
|
+
context.value = (0, _utils.deepClone)(props.value) || emptyObj;
|
390
|
+
context.lastValue = props.value;
|
391
|
+
}
|
392
|
+
};
|
393
|
+
updateValue();
|
387
394
|
React.useEffect(function () {
|
388
395
|
// 服务端错误更新
|
389
396
|
if (!props.error) context.serverErrors = {};else {
|
@@ -400,8 +407,8 @@ var useForm = function useForm(props) {
|
|
400
407
|
// 默认值更新
|
401
408
|
React.useEffect(function () {
|
402
409
|
context.removeLock = false;
|
403
|
-
|
404
|
-
|
410
|
+
// 内部 onChange 改的 value, 不需要更新
|
411
|
+
if (props.value === context.value) return;
|
405
412
|
if (initValidate && !context.resetTime) {
|
406
413
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
407
414
|
var oldValue = (0, _utils.deepGet)(context.lastValue || emptyObj, key);
|
@@ -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;;;;;;;;
|
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
|
-
|
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
|
-
|
76
|
-
if (!isLeaf)
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
113
|
-
|
114
|
-
}
|
115
|
-
var
|
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
|
-
|
128
|
+
up = rect.bottom - topLine > (bottomLine - topLine) / 2;
|
124
129
|
}
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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:
|
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;;
|
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
|
-
|
88
|
+
updateWithThreshold();
|
79
89
|
});
|
80
90
|
return {
|
81
91
|
openKeys: value,
|
@@ -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;
|
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
|
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
|
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
|
231
|
-
_isDisabled =
|
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
|
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
|
-
|
314
|
-
|
315
|
-
|
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.
|
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,SAA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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"}
|
@@ -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;;;;;;
|
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
|
176
|
-
|
177
|
-
|
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
|
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
|
427
|
+
return function (_x3) {
|
430
428
|
return _ref2.apply(this, arguments);
|
431
429
|
};
|
432
|
-
}();
|
433
|
-
var removeFile = function
|
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
|
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)(
|
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
|
467
|
+
});
|
468
|
+
var recoverValue = (0, _usePersistFn.default)(function (index) {
|
471
469
|
if (props.disabled) return;
|
472
|
-
props.onChange((0, _immer.produce)(
|
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<
|
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,OAA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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;
|
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":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,QAqCA;AAED,eAAe,YAAY,CAAC"}
|
@@ -37,7 +37,10 @@ export function useClickAway(params) {
|
|
37
37
|
}
|
38
38
|
return function () {
|
39
39
|
// @ts-ignore
|
40
|
-
document.removeEventListener(event, handleClickAway
|
40
|
+
document.removeEventListener(event, handleClickAway, {
|
41
|
+
// 解决 点击后立刻删除dom导致获取不到元素; contains(target) 为 false 的问题
|
42
|
+
capture: true
|
43
|
+
});
|
41
44
|
};
|
42
45
|
}, [effect]);
|
43
46
|
}
|
@@ -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;;;
|
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"}
|