@sheinx/hooks 3.6.0-beta.9 → 3.6.1-beta.1
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/common/use-pagination-list/index.d.ts.map +1 -1
- package/cjs/common/use-pagination-list/index.js +6 -1
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +7 -3
- package/cjs/components/use-check/use-check.d.ts +1 -1
- package/cjs/components/use-check/use-check.d.ts.map +1 -1
- package/cjs/components/use-check/use-check.js +10 -3
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +4 -0
- package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
- package/cjs/components/use-form/Provider.d.ts +1 -2
- package/cjs/components/use-form/Provider.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +2 -3
- package/cjs/components/use-form/use-form.d.ts +1 -2
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +20 -11
- package/cjs/components/use-form/use-form.type.d.ts +5 -3
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-format.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-number.js +1 -0
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +5 -0
- package/cjs/components/use-table/index.d.ts +2 -1
- package/cjs/components/use-table/index.d.ts.map +1 -1
- package/cjs/components/use-table/index.js +7 -0
- package/cjs/components/use-table/use-table-filter.d.ts +19 -0
- package/cjs/components/use-table/use-table-filter.d.ts.map +1 -0
- package/cjs/components/use-table/use-table-filter.js +96 -0
- package/cjs/components/use-table/use-table.type.d.ts +93 -0
- package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
- package/cjs/components/use-tabs/context.d.ts +1 -1
- package/cjs/components/use-tabs/context.d.ts.map +1 -1
- package/cjs/components/use-tabs/use-tabs.d.ts +1 -1
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +58 -13
- package/cjs/components/use-tree/use-tree.type.d.ts +4 -0
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/cjs/components/use-treeselect/use-tiled.d.ts +1 -1
- package/cjs/utils/dom/element.d.ts +1 -1
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +5 -3
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +2 -2
- package/esm/common/use-pagination-list/index.d.ts.map +1 -1
- package/esm/common/use-pagination-list/index.js +6 -1
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +7 -3
- package/esm/components/use-check/use-check.d.ts +1 -1
- package/esm/components/use-check/use-check.d.ts.map +1 -1
- package/esm/components/use-check/use-check.js +10 -3
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +4 -0
- package/esm/components/use-datepicker/use-datepicker-format.type.d.ts +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
- package/esm/components/use-form/Provider.d.ts +1 -2
- package/esm/components/use-form/Provider.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +2 -3
- package/esm/components/use-form/use-form.d.ts +1 -2
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +20 -11
- package/esm/components/use-form/use-form.type.d.ts +5 -3
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-format.d.ts +1 -1
- package/esm/components/use-input/use-input-number.d.ts +1 -1
- package/esm/components/use-input/use-input-number.d.ts.map +1 -1
- package/esm/components/use-input/use-input-number.js +1 -0
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +5 -0
- package/esm/components/use-table/index.d.ts +2 -1
- package/esm/components/use-table/index.d.ts.map +1 -1
- package/esm/components/use-table/index.js +1 -0
- package/esm/components/use-table/use-table-filter.d.ts +19 -0
- package/esm/components/use-table/use-table-filter.d.ts.map +1 -0
- package/esm/components/use-table/use-table-filter.js +89 -0
- package/esm/components/use-table/use-table.type.d.ts +93 -0
- package/esm/components/use-table/use-table.type.d.ts.map +1 -1
- package/esm/components/use-tabs/context.d.ts +1 -1
- package/esm/components/use-tabs/context.d.ts.map +1 -1
- package/esm/components/use-tabs/use-tabs.d.ts +1 -1
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +58 -13
- package/esm/components/use-tree/use-tree.type.d.ts +4 -0
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/components/use-treeselect/use-tiled.d.ts +1 -1
- package/esm/utils/dom/element.d.ts +1 -1
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +4 -2
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +3 -3
- package/package.json +1 -1
@@ -44,7 +44,6 @@ var useForm = function useForm(props) {
|
|
44
44
|
forceSet: true
|
45
45
|
};
|
46
46
|
var preValue = usePrevious(props.value);
|
47
|
-
var formDomRef = React.useRef();
|
48
47
|
var _React$useRef = React.useRef({
|
49
48
|
defaultValues: {},
|
50
49
|
validateMap: {},
|
@@ -70,7 +69,7 @@ var useForm = function useForm(props) {
|
|
70
69
|
Object.keys(context.updateMap).forEach(function (key) {
|
71
70
|
var _context$updateMap$ke;
|
72
71
|
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
73
|
-
update(context.value, context.errors, context.serverErrors
|
72
|
+
update(context.value, context.errors, context.serverErrors);
|
74
73
|
});
|
75
74
|
});
|
76
75
|
Object.keys(context.flowMap).forEach(function (key) {
|
@@ -88,12 +87,12 @@ var useForm = function useForm(props) {
|
|
88
87
|
var _context$updateMap$pa;
|
89
88
|
var parentKey = key.split('.')[0];
|
90
89
|
(_context$updateMap$pa = context.updateMap[parentKey]) === null || _context$updateMap$pa === void 0 || _context$updateMap$pa.forEach(function (update) {
|
91
|
-
update(context.value, context.errors, context.serverErrors
|
90
|
+
update(context.value, context.errors, context.serverErrors);
|
92
91
|
});
|
93
92
|
} else {
|
94
93
|
var _context$updateMap$ke2;
|
95
94
|
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
96
|
-
update(context.value, context.errors, context.serverErrors
|
95
|
+
update(context.value, context.errors, context.serverErrors);
|
97
96
|
});
|
98
97
|
}
|
99
98
|
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
@@ -118,9 +117,9 @@ var useForm = function useForm(props) {
|
|
118
117
|
onError === null || onError === void 0 || onError(err);
|
119
118
|
if (!props.scrollToError) return;
|
120
119
|
setTimeout(function () {
|
121
|
-
var
|
120
|
+
var _props$formElRef$curr;
|
122
121
|
var selector = "[".concat(getDataAttributeName('status'), "=\"error\"]");
|
123
|
-
var el = (
|
122
|
+
var el = (_props$formElRef$curr = props.formElRef.current) === null || _props$formElRef$curr === void 0 ? void 0 : _props$formElRef$curr.querySelector(selector);
|
124
123
|
if (el) {
|
125
124
|
el.scrollIntoView();
|
126
125
|
var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
|
@@ -244,10 +243,20 @@ var useForm = function useForm(props) {
|
|
244
243
|
var isVisibleX = elementRect.left >= parentRect.left && elementRect.right <= parentRect.right;
|
245
244
|
if (!isVisibleY || !isVisibleX) {
|
246
245
|
// 计算元素相对于父元素的偏移量
|
247
|
-
var offsetTop =
|
248
|
-
var offsetLeft =
|
249
|
-
|
250
|
-
|
246
|
+
var offsetTop = elementRect.top - parentRect.top;
|
247
|
+
var offsetLeft = elementRect.left - parentRect.left;
|
248
|
+
// 如果是往上滚动,那么只有当元素的偏移量小于0时才需要滚动
|
249
|
+
if (offsetTop < 0) {
|
250
|
+
parentEl.scrollTop = Math.max(parentEl.scrollTop + offsetTop, 0);
|
251
|
+
} else {
|
252
|
+
parentEl.scrollTop = Math.min(parentEl.scrollTop + offsetTop, parentEl.scrollHeight - parentEl.clientHeight);
|
253
|
+
}
|
254
|
+
// 如果是往左滚动,那么只有当元素的偏移量小于0时才需要滚动
|
255
|
+
if (offsetLeft < 0) {
|
256
|
+
parentEl.scrollLeft = Math.max(parentEl.scrollLeft + offsetLeft, 0);
|
257
|
+
} else {
|
258
|
+
parentEl.scrollLeft = Math.min(parentEl.scrollLeft + offsetLeft, parentEl.scrollWidth - parentEl.clientWidth);
|
259
|
+
}
|
251
260
|
}
|
252
261
|
} else {
|
253
262
|
// 如果没有找到可滚动的父元素,使用默认行为
|
@@ -451,7 +460,6 @@ var useForm = function useForm(props) {
|
|
451
460
|
var externalProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
452
461
|
var externalEventHandlers = extractEventHandlers(externalProps);
|
453
462
|
return _objectSpread(_objectSpread(_objectSpread({}, externalProps), externalEventHandlers), {}, {
|
454
|
-
ref: formDomRef,
|
455
463
|
disabled: !!disabled,
|
456
464
|
onSubmit: handleSubmit(externalEventHandlers),
|
457
465
|
onReset: handleReset(externalEventHandlers)
|
@@ -497,6 +505,7 @@ var useForm = function useForm(props) {
|
|
497
505
|
}
|
498
506
|
if (validateFieldSet.size === 0 && updateFieldSet.size === 0) {
|
499
507
|
context.names.delete(n);
|
508
|
+
delete context.errors[n];
|
500
509
|
delete context.defaultValues[n];
|
501
510
|
}
|
502
511
|
var finalReserveAble = (_props$reserveAble = props.reserveAble) !== null && _props$reserveAble !== void 0 ? _props$reserveAble : reserveAble;
|
@@ -17,7 +17,7 @@ export type ValidateFnConfig = {
|
|
17
17
|
ignoreChildren?: boolean;
|
18
18
|
};
|
19
19
|
export type ValidateFn = (name: string, value: any, formData: ObjectType, config?: ValidateFnConfig) => Promise<true | FormError>;
|
20
|
-
export type UpdateFn = (formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined
|
20
|
+
export type UpdateFn = (formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined>) => void;
|
21
21
|
export interface FormContextValueType {
|
22
22
|
func?: {
|
23
23
|
unbind: (n: string, reserveAble?: boolean, validate?: ValidateFn, update?: UpdateFn) => void;
|
@@ -185,7 +185,9 @@ export interface BaseFormProps<T> extends Omit<FormCommonConfig, 'formName'> {
|
|
185
185
|
*/
|
186
186
|
name?: string;
|
187
187
|
}
|
188
|
-
export type UseFormProps<T> = BaseFormProps<T
|
188
|
+
export type UseFormProps<T> = BaseFormProps<T> & {
|
189
|
+
formElRef: React.RefObject<HTMLFormElement>;
|
190
|
+
};
|
189
191
|
export type FormContext = {
|
190
192
|
defaultValues: ObjectType;
|
191
193
|
validateMap: ObjectType<Set<(name: string, v: any, formValue: ObjectType, config?: {
|
@@ -198,7 +200,7 @@ export type FormContext = {
|
|
198
200
|
lastValue: ObjectType | undefined;
|
199
201
|
resetTime: number;
|
200
202
|
mounted: boolean;
|
201
|
-
updateMap: ObjectType<Set<(formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined
|
203
|
+
updateMap: ObjectType<Set<(formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined>) => void>>;
|
202
204
|
flowMap: ObjectType<Set<() => void>>;
|
203
205
|
value: ObjectType;
|
204
206
|
errors: ObjectType<Error | undefined>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC;IACV,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,EAAE,CAAC;CACL;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,UAAU,EACpB,MAAM,CAAC,EAAE,gBAAgB,KACtB,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;AAE/B,MAAM,MAAM,QAAQ,GAAG,CACrB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,EACrC,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,
|
1
|
+
{"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE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: InputFormatProps) => {
|
|
5
5
|
onBlur: (e: React.FocusEvent) => void;
|
6
6
|
onFocus: (e: React.FocusEvent) => void;
|
7
7
|
value: string | undefined;
|
8
|
-
type: "search" |
|
8
|
+
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
|
9
9
|
};
|
10
10
|
export default useInputFormat;
|
11
11
|
//# sourceMappingURL=use-input-format.d.ts.map
|
@@ -7,7 +7,7 @@ declare const useNumberFormat: (props: InputNumberProps) => {
|
|
7
7
|
onBlur: (e: React.FocusEvent<Element, Element>) => void;
|
8
8
|
onFocus: (e: React.FocusEvent<Element, Element>) => void;
|
9
9
|
value: string | undefined;
|
10
|
-
type: "search" |
|
10
|
+
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
|
11
11
|
};
|
12
12
|
export default useNumberFormat;
|
13
13
|
//# sourceMappingURL=use-input-number.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;
|
1
|
+
{"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;CAwJ/C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -66,6 +66,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
66
66
|
var onInnerChange = usePersistFn(function (val) {
|
67
67
|
setInternalInputValue(getStringValue(val));
|
68
68
|
if (typeof val === 'string') {
|
69
|
+
if (val.endsWith('.')) return;
|
69
70
|
var num = parseFloat(val);
|
70
71
|
if (val === '') {
|
71
72
|
// 如果允许空值,则返回 null,否则返回 undefined
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;;
|
1
|
+
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;;0BA8HK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAM9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBA5B7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;2BA6ElD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAGxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CAsBpE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -72,6 +72,11 @@ var usePopup = function usePopup(props) {
|
|
72
72
|
updatePosition();
|
73
73
|
}
|
74
74
|
setOpenState(!!props.open);
|
75
|
+
|
76
|
+
// 外部传了open时,需要正常的触发onCollapse;触发了onCollapse才能让组件内部的edit状态正确,否则可能会出现弹出层打开了但是用户却无法选择的情况
|
77
|
+
if (props.open !== undefined) {
|
78
|
+
changeOpen(!!props.open);
|
79
|
+
}
|
75
80
|
}, [props.open]);
|
76
81
|
|
77
82
|
// const getPopUpHeight = () => {
|
@@ -2,9 +2,10 @@ export { default, default as useTableLayout } from './use-table-layout';
|
|
2
2
|
export { default as useTableColumns } from './use-table-columns';
|
3
3
|
export { default as useTableGroup } from './use-table-group';
|
4
4
|
export { default as useTableSort } from './use-table-sort';
|
5
|
+
export { default as useTableFilter } from './use-table-filter';
|
5
6
|
export { default as useTableRow } from './use-table-row';
|
6
7
|
export { default as useTableExpand } from './use-table-expand';
|
7
8
|
export { default as useTableTree } from './use-table-tree';
|
8
9
|
export { default as useTableVirtual } from './use-table-virtual';
|
9
|
-
export type { TableFormatColumn, TableColumnItem, TableHeadColumn, TableGroupColumn, TableSorterInfo, BaseTableProps, } from './use-table.type';
|
10
|
+
export type { TableFormatColumn, TableColumnItem, TableHeadColumn, TableGroupColumn, TableSorterInfo, BaseTableProps, TableColumnFilter, TableFilterData, } from './use-table.type';
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEjE,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEjE,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
@@ -3,6 +3,7 @@ export { default, default as useTableLayout } from "./use-table-layout";
|
|
3
3
|
export { default as useTableColumns } from "./use-table-columns";
|
4
4
|
export { default as useTableGroup } from "./use-table-group";
|
5
5
|
export { default as useTableSort } from "./use-table-sort";
|
6
|
+
export { default as useTableFilter } from "./use-table-filter";
|
6
7
|
export { default as useTableRow } from "./use-table-row";
|
7
8
|
export { default as useTableExpand } from "./use-table-expand";
|
8
9
|
export { default as useTableTree } from "./use-table-tree";
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { TableColumnItem, BaseTableProps } from './use-table.type';
|
3
|
+
import { KeygenResult } from '../../common/type';
|
4
|
+
export interface UseTableFilterProps<Item = any> extends Pick<BaseTableProps<Item>, 'onSortCancel' | 'sorter' | 'data'> {
|
5
|
+
columns?: TableColumnItem<Item>[];
|
6
|
+
}
|
7
|
+
export interface FilterInfo<T> {
|
8
|
+
value?: any;
|
9
|
+
onFilter?: (value: any, row: T) => boolean;
|
10
|
+
}
|
11
|
+
export type FilterMap<T> = Map<KeygenResult, FilterInfo<T>>;
|
12
|
+
declare const useTableFilter: <Item = any>(props: UseTableFilterProps<Item>) => {
|
13
|
+
filterInfo: FilterMap<Item>;
|
14
|
+
setFilterInfo: import("react").Dispatch<import("react").SetStateAction<FilterMap<Item>>>;
|
15
|
+
filteredData: Item[] | undefined;
|
16
|
+
onFilterChange: (columnKey: KeygenResult, value: any) => void;
|
17
|
+
};
|
18
|
+
export default useTableFilter;
|
19
|
+
//# sourceMappingURL=use-table-filter.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-table-filter.d.ts","sourceRoot":"","sources":["use-table-filter.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,mBAAmB,CAAC,IAAI,GAAG,GAAG,CAC7C,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtE,OAAO,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;CACnC;AACD,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;CAC5C;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5D,QAAA,MAAM,cAAc;;;;gCA6BH,YAAY,SAAS,GAAG;CAoDxC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
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; }
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
10
|
+
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; }
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
13
|
+
import { useState, useMemo, useEffect } from 'react';
|
14
|
+
import usePersistFn from "../../common/use-persist-fn";
|
15
|
+
import { isFunc } from "../../utils/is";
|
16
|
+
var useTableFilter = function useTableFilter(props) {
|
17
|
+
var _useState = useState(new Map()),
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
19
|
+
filterInfo = _useState2[0],
|
20
|
+
setFilterInfo = _useState2[1];
|
21
|
+
var activeFilters = useMemo(function () {
|
22
|
+
return Array.from(filterInfo.keys()).filter(function (key) {
|
23
|
+
var _filterInfo$get;
|
24
|
+
return ((_filterInfo$get = filterInfo.get(key)) === null || _filterInfo$get === void 0 ? void 0 : _filterInfo$get.value) !== undefined;
|
25
|
+
});
|
26
|
+
}, [filterInfo]);
|
27
|
+
var filteredData = useMemo(function () {
|
28
|
+
var _props$data;
|
29
|
+
if (activeFilters.length === 0) return props.data;
|
30
|
+
return (_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.filter(function (item) {
|
31
|
+
return activeFilters.every(function (key) {
|
32
|
+
var filter = filterInfo.get(key);
|
33
|
+
if ((filter === null || filter === void 0 ? void 0 : filter.value) === undefined) return true;
|
34
|
+
if (Array.isArray(filter.value) && filter.value.length === 0) return true;
|
35
|
+
if (filter !== null && filter !== void 0 && filter.onFilter && isFunc(filter.onFilter)) {
|
36
|
+
return filter.onFilter(filter.value, item);
|
37
|
+
}
|
38
|
+
return true;
|
39
|
+
});
|
40
|
+
});
|
41
|
+
}, [activeFilters, props.data]);
|
42
|
+
var onFilterChange = usePersistFn(function (columnKey, value) {
|
43
|
+
// TODO: 暂未开放reset全部筛选条件
|
44
|
+
if (columnKey === '__reset__') {
|
45
|
+
setFilterInfo(function (prev) {
|
46
|
+
var next = new Map(prev);
|
47
|
+
next.forEach(function (v, k) {
|
48
|
+
next.set(k, _objectSpread(_objectSpread({}, v), {}, {
|
49
|
+
value: undefined
|
50
|
+
}));
|
51
|
+
});
|
52
|
+
return next;
|
53
|
+
});
|
54
|
+
} else {
|
55
|
+
setFilterInfo(function (prev) {
|
56
|
+
var _prev$get;
|
57
|
+
var next = new Map(prev);
|
58
|
+
next.set(columnKey, {
|
59
|
+
value: value,
|
60
|
+
onFilter: (_prev$get = prev.get(columnKey)) === null || _prev$get === void 0 ? void 0 : _prev$get.onFilter
|
61
|
+
});
|
62
|
+
return next;
|
63
|
+
});
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
// 根据columns生成filterInfo
|
68
|
+
useEffect(function () {
|
69
|
+
var _props$columns;
|
70
|
+
var _filterInfo = props === null || props === void 0 || (_props$columns = props.columns) === null || _props$columns === void 0 ? void 0 : _props$columns.reduce(function (acc, column, index) {
|
71
|
+
var _column$filter;
|
72
|
+
if (!column.filter) return acc;
|
73
|
+
var columnKey = typeof column.render === 'string' ? column.render : String(index);
|
74
|
+
acc.set(columnKey, {
|
75
|
+
value: undefined,
|
76
|
+
onFilter: (_column$filter = column.filter) === null || _column$filter === void 0 ? void 0 : _column$filter.onFilter
|
77
|
+
});
|
78
|
+
return acc;
|
79
|
+
}, new Map());
|
80
|
+
if (_filterInfo) setFilterInfo(_filterInfo);
|
81
|
+
}, [props.columns]);
|
82
|
+
return {
|
83
|
+
filterInfo: filterInfo,
|
84
|
+
setFilterInfo: setFilterInfo,
|
85
|
+
filteredData: filteredData,
|
86
|
+
onFilterChange: onFilterChange
|
87
|
+
};
|
88
|
+
};
|
89
|
+
export default useTableFilter;
|
@@ -139,6 +139,93 @@ export interface TableColumnSorter {
|
|
139
139
|
export interface ColumnRenderFunc<DataItem> {
|
140
140
|
(data: DataItem, index: number, checkInstance?: React.ReactComponentElement<any>): React.ReactNode | (() => React.ReactNode);
|
141
141
|
}
|
142
|
+
export interface TableColumnFilterBase<DataItem> {
|
143
|
+
/**
|
144
|
+
* @cn 筛选模式: search 搜索模式, select 选择模式
|
145
|
+
* @en Filter mode: search search mode, select select mode
|
146
|
+
*/
|
147
|
+
mode: 'search' | 'select';
|
148
|
+
/**
|
149
|
+
* @cn 筛选数据的函数
|
150
|
+
* @en Filter data function
|
151
|
+
* @param value 筛选值
|
152
|
+
* @param row 行数据
|
153
|
+
* @returns 是否通过筛选
|
154
|
+
*/
|
155
|
+
onFilter: (value: any, row: DataItem) => boolean;
|
156
|
+
/**
|
157
|
+
* @cn 自定义的筛选项图标
|
158
|
+
* @en Custom filter icon
|
159
|
+
*/
|
160
|
+
icon?: React.ReactNode;
|
161
|
+
}
|
162
|
+
export type TableFilterData = {
|
163
|
+
label: string;
|
164
|
+
value: any;
|
165
|
+
icon?: React.ReactNode;
|
166
|
+
[key: string]: any;
|
167
|
+
children?: TableFilterData[];
|
168
|
+
};
|
169
|
+
export interface SelectModeColumnFilter<DataItem> extends TableColumnFilterBase<DataItem> {
|
170
|
+
/**
|
171
|
+
* @cn 筛选模式为 select 时
|
172
|
+
* @en Filter mode is select
|
173
|
+
*/
|
174
|
+
mode: 'select';
|
175
|
+
/**
|
176
|
+
* 必填的 `config` 字段
|
177
|
+
*/
|
178
|
+
config: {
|
179
|
+
/**
|
180
|
+
* @cn 筛选项数据
|
181
|
+
* @en Filter item data
|
182
|
+
*/
|
183
|
+
data: Array<TableFilterData>;
|
184
|
+
/**
|
185
|
+
* @cn 自定义渲染筛选项
|
186
|
+
* @en Custom rendering filter options
|
187
|
+
* @default (data) => data.label
|
188
|
+
*/
|
189
|
+
renderItem?: ((item: TableFilterData) => React.ReactNode) | ObjectKey<TableFilterData>;
|
190
|
+
/**
|
191
|
+
* @cn 是否多选
|
192
|
+
* @en Whether to multiple select
|
193
|
+
*/
|
194
|
+
multiple?: boolean;
|
195
|
+
/**
|
196
|
+
* @cn 是否开启顶部的搜索框
|
197
|
+
* @en Whether to open the top search box
|
198
|
+
*/
|
199
|
+
search?: boolean;
|
200
|
+
/**
|
201
|
+
* @cn 是否高亮命中的关键词,仅当 search 为 true 时有效
|
202
|
+
* @en Whether to highlight the hit keywords
|
203
|
+
*/
|
204
|
+
highlight?: boolean;
|
205
|
+
};
|
206
|
+
/**
|
207
|
+
* @cn 筛选数据的函数
|
208
|
+
* @en Filter data function
|
209
|
+
* @param value 筛选值,单选时为单个值,多选时为数组
|
210
|
+
* @param row 行数据
|
211
|
+
* @returns 是否通过筛选
|
212
|
+
*/
|
213
|
+
onFilter: (value: any, row: DataItem) => boolean;
|
214
|
+
}
|
215
|
+
export interface SearchModeColumnFilter<DataItem> extends TableColumnFilterBase<DataItem> {
|
216
|
+
/**
|
217
|
+
* 筛选模式为 search 时
|
218
|
+
*/
|
219
|
+
mode: 'search';
|
220
|
+
/**
|
221
|
+
* 此时不允许传 `config`
|
222
|
+
*/
|
223
|
+
config?: never;
|
224
|
+
}
|
225
|
+
/**
|
226
|
+
* 最终的联合类型
|
227
|
+
*/
|
228
|
+
export type TableColumnFilter<DataItem> = SelectModeColumnFilter<DataItem> | SearchModeColumnFilter<DataItem>;
|
142
229
|
/**
|
143
230
|
* @title TableColumn
|
144
231
|
*/
|
@@ -227,6 +314,12 @@ export interface TableColumnItem<DataItem> {
|
|
227
314
|
* @version 3.5.0
|
228
315
|
*/
|
229
316
|
sortDirections?: ('asc' | 'desc')[];
|
317
|
+
/**
|
318
|
+
* @cn 列的筛选配置
|
319
|
+
* @en Column filter configuration
|
320
|
+
* @version 3.6.0
|
321
|
+
*/
|
322
|
+
filter?: TableColumnFilter<DataItem>;
|
230
323
|
/**
|
231
324
|
* @en The content of the header
|
232
325
|
* @cn 表头显示内容
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table.type.d.ts","sourceRoot":"","sources":["use-table.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAC;AAC9C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAC9C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEnE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,MAAM,WAAW,cAAc,CAAC,IAAI;IAClC;;;;OAIG;IACH,YAAY,CAAC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,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAEnD;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,CAAE,SAAQ,eAAe,CAAC,QAAQ,CAAC;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { TabsProviderProps, TabsContextProps } from './context.type';
|
3
3
|
export declare const TabsContext: React.Context<TabsContextProps<any>>;
|
4
|
-
export declare const Provider: <TabData>(props: TabsProviderProps<TabData>) => JSX.Element;
|
4
|
+
export declare const Provider: <TabData>(props: TabsProviderProps<TabData>) => import("react/jsx-runtime").JSX.Element;
|
5
5
|
export declare const useTabsContext: <TabData>() => TabsContextProps<TabData>;
|
6
6
|
//# sourceMappingURL=context.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,WAAW,sCAA8E,CAAC;AAEvG,eAAO,MAAM,QAAQ,
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,WAAW,sCAA8E,CAAC;AAEvG,eAAO,MAAM,QAAQ,yFAGpB,CAAC;AAEF,eAAO,MAAM,cAAc,0CAA8E,CAAC"}
|
@@ -5,7 +5,7 @@ declare const useTabs: <TabData = any>(props: BaseTabsProps) => {
|
|
5
5
|
onChange: (key: string | number) => void;
|
6
6
|
tabs: TabData[];
|
7
7
|
setTabs: import("react").Dispatch<import("react").SetStateAction<TabData[]>>;
|
8
|
-
Provider: <TabData_1>(props: import("./context.type").TabsProviderProps<TabData_1>) => JSX.Element;
|
8
|
+
Provider: <TabData_1>(props: import("./context.type").TabsProviderProps<TabData_1>) => import("react/jsx-runtime").JSX.Element;
|
9
9
|
};
|
10
10
|
export default useTabs;
|
11
11
|
//# sourceMappingURL=use-tabs.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EAGV,MAAM,iBAAiB,CAAC;AAGzB,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,EAGV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiBjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CAurBZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -26,7 +26,6 @@ function toArray(value) {
|
|
26
26
|
if (!Array.isArray(value)) return [value];
|
27
27
|
return value;
|
28
28
|
}
|
29
|
-
var global_tree_map = new Map();
|
30
29
|
export var MODE = {
|
31
30
|
/**
|
32
31
|
* 返回全选数据,包含父节点和子节点
|
@@ -311,6 +310,34 @@ var useTree = function useTree(props) {
|
|
311
310
|
}
|
312
311
|
return ids;
|
313
312
|
};
|
313
|
+
var initFlatData = function initFlatData(data, path) {
|
314
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
315
|
+
var pid = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
316
|
+
var result = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
317
|
+
for (var i = 0; i < data.length; i++) {
|
318
|
+
var item = data[i];
|
319
|
+
var id = getKey(item, path[path.length - 1], i);
|
320
|
+
var node = {
|
321
|
+
id: id,
|
322
|
+
level: level,
|
323
|
+
data: item,
|
324
|
+
pid: pid
|
325
|
+
};
|
326
|
+
if (defaultExpandAll) {
|
327
|
+
result.push(node);
|
328
|
+
} else {
|
329
|
+
if (level === 1) {
|
330
|
+
result.push(node);
|
331
|
+
} else if (expanded && pid !== null && expanded.indexOf(pid) >= 0) {
|
332
|
+
result.push(node);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
if (Array.isArray(item[childrenKey])) {
|
336
|
+
initFlatData(item[childrenKey], [].concat(_toConsumableArray(path), [id]), level + 1, id, result);
|
337
|
+
}
|
338
|
+
}
|
339
|
+
return result;
|
340
|
+
};
|
314
341
|
var initValue = function initValue(ids_outer, forceCheck) {
|
315
342
|
var ids = ids_outer;
|
316
343
|
if (!context.data || !context.value) {
|
@@ -401,15 +428,6 @@ var useTree = function useTree(props) {
|
|
401
428
|
return 2;
|
402
429
|
};
|
403
430
|
var setData = function setData(data) {
|
404
|
-
// if(data && global_tree_map.get(data)){
|
405
|
-
// context.cachedValue = global_tree_map.get(data)?.cachedValue || []
|
406
|
-
// context.pathMap = global_tree_map.get(data)?.pathMap || new Map()
|
407
|
-
// context.dataMap = global_tree_map.get(data)?.dataMap || new Map()
|
408
|
-
// context.valueMap = global_tree_map.get(data)?.valueMap || new Map()
|
409
|
-
// context.unmatchedValueMap = global_tree_map.get(data)?.unmatchedValueMap || new Map()
|
410
|
-
// return
|
411
|
-
// }
|
412
|
-
|
413
431
|
var prevValue = context.value || [];
|
414
432
|
context.cachedValue = [];
|
415
433
|
context.pathMap = new Map();
|
@@ -430,8 +448,6 @@ var useTree = function useTree(props) {
|
|
430
448
|
}
|
431
449
|
initValue();
|
432
450
|
setValue(prevValue);
|
433
|
-
|
434
|
-
// global_tree_map.set(data, context)
|
435
451
|
};
|
436
452
|
var set = function set(id, checked, direction) {
|
437
453
|
if (!isDisabled(id)) {
|
@@ -473,6 +489,28 @@ var useTree = function useTree(props) {
|
|
473
489
|
}
|
474
490
|
return current;
|
475
491
|
};
|
492
|
+
var updateInnerCheckStatus = function updateInnerCheckStatus() {
|
493
|
+
var _context$value;
|
494
|
+
if (mode !== MODE.MODE_0) return;
|
495
|
+
(_context$value = context.value) === null || _context$value === void 0 || _context$value.forEach(function (id) {
|
496
|
+
var _ref3 = context.pathMap.get(id),
|
497
|
+
children = _ref3.children;
|
498
|
+
if (children.length) {
|
499
|
+
var noCheckedChildren = children.filter(function (cid) {
|
500
|
+
var _context$value2;
|
501
|
+
return !((_context$value2 = context.value) !== null && _context$value2 !== void 0 && _context$value2.includes(cid));
|
502
|
+
});
|
503
|
+
if (noCheckedChildren.length > 0) {
|
504
|
+
setTimeout(function () {
|
505
|
+
setValueMap(id, 2);
|
506
|
+
noCheckedChildren.forEach(function (cid) {
|
507
|
+
setValueMap(cid, 0);
|
508
|
+
});
|
509
|
+
}, 0);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
});
|
513
|
+
};
|
476
514
|
var appendChildrenExpanded = function appendChildrenExpanded(child, level, pid, insertData) {
|
477
515
|
if (!child) return;
|
478
516
|
child.forEach(function (item, i) {
|
@@ -558,7 +596,7 @@ var useTree = function useTree(props) {
|
|
558
596
|
expanded: true
|
559
597
|
}));
|
560
598
|
});
|
561
|
-
var _getExpandVirtualData = getExpandVirtualData(context.data, expanded, getKey, childrenKey),
|
599
|
+
var _getExpandVirtualData = getExpandVirtualData(props.tiledData || context.data, expanded, getKey, childrenKey),
|
562
600
|
treeDataInfo = _getExpandVirtualData.treeDataInfo;
|
563
601
|
if (!treeDataInfo) {
|
564
602
|
return;
|
@@ -583,11 +621,18 @@ var useTree = function useTree(props) {
|
|
583
621
|
if (props.datum) return;
|
584
622
|
if (!dataUpdate) return;
|
585
623
|
setData(data);
|
624
|
+
updateInnerCheckStatus();
|
586
625
|
}, [data]);
|
587
626
|
useEffect(function () {
|
588
627
|
if (props.datum) return;
|
589
628
|
setValue(value);
|
590
629
|
}, [value]);
|
630
|
+
useEffect(function () {
|
631
|
+
if (!virtual) return;
|
632
|
+
if (!props.tiledData) return;
|
633
|
+
var tiledFlatData = initFlatData(props.tiledData, [], 1);
|
634
|
+
setDataFlat(tiledFlatData);
|
635
|
+
}, [props.tiledData]);
|
591
636
|
useEffect(function () {
|
592
637
|
setInited(true);
|
593
638
|
}, []);
|