@sheinx/hooks 3.4.0-beta.1 → 3.4.0-beta.11
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/common/use-input-able/use-Input-able.js +2 -2
- package/cjs/common/use-position-style/index.d.ts +4 -1
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +98 -11
- package/cjs/components/use-datepicker/use-date.d.ts +2 -2
- package/cjs/components/use-datepicker/use-date.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-date.js +2 -2
- package/cjs/components/use-datepicker/use-date.type.d.ts +1 -1
- package/cjs/components/use-datepicker/use-date.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +4 -2
- package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts +1 -0
- package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-month.d.ts +2 -2
- package/cjs/components/use-datepicker/use-month.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-month.js +2 -2
- package/cjs/components/use-datepicker/use-month.type.d.ts +1 -1
- package/cjs/components/use-datepicker/use-month.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-quarter.d.ts +2 -2
- package/cjs/components/use-datepicker/use-quarter.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-quarter.js +2 -2
- package/cjs/components/use-datepicker/use-year.d.ts +2 -2
- package/cjs/components/use-datepicker/use-year.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-year.js +2 -2
- package/cjs/components/use-datepicker/use-year.type.d.ts +1 -1
- package/cjs/components/use-datepicker/use-year.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.d.ts +1 -1
- package/cjs/components/use-datepicker/util.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.js +2 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +2 -2
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +40 -19
- package/cjs/components/use-form/use-form.type.d.ts +11 -6
- 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 +37 -5
- package/cjs/components/use-popup/use-popup.d.ts +1 -0
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +7 -4
- package/cjs/components/use-table/use-table-virtual.d.ts +1 -1
- package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +34 -4
- package/cjs/components/use-transfer/use-transfer.d.ts +1 -1
- package/cjs/components/use-transfer/use-transfer.d.ts.map +1 -1
- package/cjs/components/use-transfer/use-transfer.js +8 -17
- package/cjs/utils/dom/element.js +1 -1
- package/cjs/utils/is.d.ts +1 -0
- package/cjs/utils/is.d.ts.map +1 -1
- package/cjs/utils/is.js +6 -1
- package/cjs/utils/position.d.ts +1 -1
- package/cjs/utils/position.d.ts.map +1 -1
- package/cjs/utils/position.js +20 -5
- package/esm/common/use-input-able/use-Input-able.js +2 -2
- package/esm/common/use-position-style/index.d.ts +4 -1
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +99 -12
- package/esm/components/use-datepicker/use-date.d.ts +2 -2
- package/esm/components/use-datepicker/use-date.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-date.js +2 -2
- package/esm/components/use-datepicker/use-date.type.d.ts +1 -1
- package/esm/components/use-datepicker/use-date.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +4 -2
- package/esm/components/use-datepicker/use-datepicker-format.type.d.ts +1 -0
- package/esm/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-month.d.ts +2 -2
- package/esm/components/use-datepicker/use-month.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-month.js +2 -2
- package/esm/components/use-datepicker/use-month.type.d.ts +1 -1
- package/esm/components/use-datepicker/use-month.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-quarter.d.ts +2 -2
- package/esm/components/use-datepicker/use-quarter.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-quarter.js +2 -2
- package/esm/components/use-datepicker/use-year.d.ts +2 -2
- package/esm/components/use-datepicker/use-year.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-year.js +2 -2
- package/esm/components/use-datepicker/use-year.type.d.ts +1 -1
- package/esm/components/use-datepicker/use-year.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.d.ts +1 -1
- package/esm/components/use-datepicker/util.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.js +2 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +2 -2
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +40 -19
- package/esm/components/use-form/use-form.type.d.ts +11 -6
- 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 +34 -4
- package/esm/components/use-popup/use-popup.d.ts +1 -0
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +7 -4
- package/esm/components/use-table/use-table-virtual.d.ts +1 -1
- package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +34 -4
- package/esm/components/use-transfer/use-transfer.d.ts +1 -1
- package/esm/components/use-transfer/use-transfer.d.ts.map +1 -1
- package/esm/components/use-transfer/use-transfer.js +8 -17
- package/esm/utils/dom/element.js +1 -1
- package/esm/utils/is.d.ts +1 -0
- package/esm/utils/is.d.ts.map +1 -1
- package/esm/utils/is.js +3 -0
- package/esm/utils/position.d.ts +1 -1
- package/esm/utils/position.d.ts.map +1 -1
- package/esm/utils/position.js +20 -5
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAwB,MAAM,iBAAiB,CAAC;AACnH,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAuK8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCAyDD,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAvEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCAmI5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBA5CpB;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCAyDD,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAvEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCAmI5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CAoQ9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -65,8 +65,10 @@ var useForm = function useForm(props) {
|
|
65
65
|
var _context$flowMap$glob;
|
66
66
|
if (!name) {
|
67
67
|
Object.keys(context.updateMap).forEach(function (key) {
|
68
|
-
var _context$updateMap$ke
|
69
|
-
(_context$updateMap$ke =
|
68
|
+
var _context$updateMap$ke;
|
69
|
+
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
70
|
+
update(context.value, context.errors, context.serverErrors);
|
71
|
+
});
|
70
72
|
});
|
71
73
|
Object.keys(context.flowMap).forEach(function (key) {
|
72
74
|
context.flowMap[key].forEach(function (update) {
|
@@ -76,8 +78,10 @@ var useForm = function useForm(props) {
|
|
76
78
|
} else {
|
77
79
|
var names = isArray(name) ? name : [name];
|
78
80
|
names.forEach(function (key) {
|
79
|
-
var _context$updateMap$ke2, _context$
|
80
|
-
(_context$updateMap$ke2 =
|
81
|
+
var _context$updateMap$ke2, _context$flowMap$key;
|
82
|
+
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
83
|
+
update(context.value, context.errors, context.serverErrors);
|
84
|
+
});
|
81
85
|
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
82
86
|
update();
|
83
87
|
});
|
@@ -133,9 +137,11 @@ var useForm = function useForm(props) {
|
|
133
137
|
}) : Object.keys(context.validateMap);
|
134
138
|
var validates = files2.map(function (key) {
|
135
139
|
var validateField = context.validateMap[key];
|
136
|
-
return validateField(
|
140
|
+
return Array.from(validateField).map(function (validate) {
|
141
|
+
return validate(key, deepGet(context.value, key), context.value, config);
|
142
|
+
});
|
137
143
|
});
|
138
|
-
Promise.all(validates).then(function (results) {
|
144
|
+
Promise.all(validates.flat()).then(function (results) {
|
139
145
|
var error = results.find(function (n) {
|
140
146
|
return n !== true;
|
141
147
|
});
|
@@ -180,8 +186,10 @@ var useForm = function useForm(props) {
|
|
180
186
|
Object.keys(vals).forEach(function (key) {
|
181
187
|
deepSet(draft, key, vals[key], deepSetOptions);
|
182
188
|
if (option.validate) {
|
183
|
-
var _context$validateMap
|
184
|
-
(_context$validateMap$ =
|
189
|
+
var _context$validateMap$;
|
190
|
+
(_context$validateMap$ = context.validateMap[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.forEach(function (validate) {
|
191
|
+
validate(key, vals[key], current(draft));
|
192
|
+
});
|
185
193
|
}
|
186
194
|
});
|
187
195
|
});
|
@@ -325,12 +333,17 @@ var useForm = function useForm(props) {
|
|
325
333
|
var controlFunc = useLatestObj({
|
326
334
|
bind: function bind(n, df, validate, updateFn) {
|
327
335
|
if (context.names.has(n)) {
|
328
|
-
console.
|
329
|
-
return;
|
336
|
+
console.warn("name \"".concat(n, "\" already exist"));
|
330
337
|
}
|
331
338
|
context.names.add(n);
|
332
|
-
context.validateMap[n]
|
333
|
-
|
339
|
+
if (!context.validateMap[n]) {
|
340
|
+
context.validateMap[n] = new Set();
|
341
|
+
}
|
342
|
+
context.validateMap[n].add(validate);
|
343
|
+
if (!context.updateMap[n]) {
|
344
|
+
context.updateMap[n] = new Set();
|
345
|
+
}
|
346
|
+
context.updateMap[n].add(updateFn);
|
334
347
|
context.removeArr.delete(n);
|
335
348
|
if (df !== undefined && deepGet(context.value, n) === undefined) {
|
336
349
|
if (!context.mounted) context.defaultValues[n] = df;
|
@@ -340,11 +353,19 @@ var useForm = function useForm(props) {
|
|
340
353
|
}
|
341
354
|
update(n);
|
342
355
|
},
|
343
|
-
unbind: function unbind(n, reserveAble) {
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
356
|
+
unbind: function unbind(n, reserveAble, validateFiled, update) {
|
357
|
+
var validateFieldSet = context.validateMap[n];
|
358
|
+
if (validateFiled && validateFieldSet.has(validateFiled)) {
|
359
|
+
validateFieldSet.delete(validateFiled);
|
360
|
+
}
|
361
|
+
var updateFieldSet = context.updateMap[n];
|
362
|
+
if (update && updateFieldSet.has(update)) {
|
363
|
+
updateFieldSet.delete(update);
|
364
|
+
}
|
365
|
+
if (validateFieldSet.size === 0 && updateFieldSet.size === 0) {
|
366
|
+
context.names.delete(n);
|
367
|
+
delete context.defaultValues[n];
|
368
|
+
}
|
348
369
|
if (!reserveAble && !context.removeLock) {
|
349
370
|
addRemove(n);
|
350
371
|
}
|
@@ -419,12 +440,12 @@ var useForm = function useForm(props) {
|
|
419
440
|
React.useEffect(function () {
|
420
441
|
// 服务端错误更新
|
421
442
|
if (!props.error) context.serverErrors = {};else {
|
422
|
-
var
|
443
|
+
var errors = Object.keys(props.error).reduce(function (prev, cur) {
|
423
444
|
var item = props.error[cur];
|
424
445
|
var error = item instanceof Error ? item : new Error(item);
|
425
446
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, cur, error));
|
426
447
|
}, {});
|
427
|
-
context.serverErrors =
|
448
|
+
context.serverErrors = errors;
|
428
449
|
}
|
429
450
|
update();
|
430
451
|
}, [props.error]);
|
@@ -2,12 +2,15 @@
|
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
import { AddNoProps, ObjectType } from '../../common/type';
|
4
4
|
import { FormItemRule } from '../../utils/rule/rule.type';
|
5
|
+
import { FormError } from '../../utils';
|
6
|
+
export type ValidateFn = (name: string, value: any, formData: ObjectType, config?: {
|
7
|
+
ignoreBind?: boolean;
|
8
|
+
}) => Promise<boolean | FormError>;
|
9
|
+
export type UpdateFn = (formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined>) => void;
|
5
10
|
export interface FormContextValueType {
|
6
11
|
func?: {
|
7
|
-
unbind: (n: string, reserveAble?: boolean) => void;
|
8
|
-
bind: (n: string, df: any, validate:
|
9
|
-
ignoreBind?: boolean;
|
10
|
-
}) => void, update: (formValue: ObjectType, errors: ObjectType<Error>, serverErrors: ObjectType<Error>) => void) => void;
|
12
|
+
unbind: (n: string, reserveAble?: boolean, validate?: ValidateFn, update?: UpdateFn) => void;
|
13
|
+
bind: (n: string, df: any, validate: ValidateFn, update: UpdateFn) => void;
|
11
14
|
combineRules: <ValueItem>(name: string, propRules: FormItemRule<ValueItem>) => FormItemRule<ValueItem>;
|
12
15
|
watch: (names: string[] | undefined, update: () => void) => void;
|
13
16
|
unWatch: (names: string[] | undefined, update: () => void) => void;
|
@@ -149,7 +152,9 @@ export interface BaseFormProps<T> extends FormCommonConfig {
|
|
149
152
|
export type UseFormProps<T> = BaseFormProps<T>;
|
150
153
|
export type FormContext = {
|
151
154
|
defaultValues: ObjectType;
|
152
|
-
validateMap: ObjectType
|
155
|
+
validateMap: ObjectType<Set<(name: string, v: any, formValue: ObjectType, config?: {
|
156
|
+
ignoreBind?: boolean;
|
157
|
+
}) => Promise<boolean | FormError>>>;
|
153
158
|
removeArr: Set<string>;
|
154
159
|
removeTimer?: number | NodeJS.Timeout;
|
155
160
|
names: Set<string>;
|
@@ -157,7 +162,7 @@ export type FormContext = {
|
|
157
162
|
lastValue: ObjectType | undefined;
|
158
163
|
resetTime: number;
|
159
164
|
mounted: boolean;
|
160
|
-
updateMap: ObjectType
|
165
|
+
updateMap: ObjectType<Set<(formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined>) => void>>;
|
161
166
|
flowMap: ObjectType<Set<() => void>>;
|
162
167
|
value: ObjectType;
|
163
168
|
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;
|
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,O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AAI,CAAC,CAAC,CAAC;IACrC,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IACtC,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CACzE,mBAAmB,EACnB,MAAM,CACP,CAAC"}
|
@@ -5,7 +5,7 @@ declare const useInputFormat: (props: InputFormatProps) => {
|
|
5
5
|
onBlur: (e: React.FocusEvent) => void;
|
6
6
|
onFocus: (e: React.FocusEvent) => void;
|
7
7
|
value: string | undefined;
|
8
|
-
type: "search" | "color" | "button" | "time" | "image" | "text" | "reset" | "submit" | "email" | "url" | "range" | "tel" | (string & {}) | "
|
8
|
+
type: "search" | "color" | "button" | "time" | "image" | "text" | "reset" | "submit" | "email" | "url" | "range" | "tel" | (string & {}) | "checkbox" | "radio" | "hidden" | "date" | "datetime-local" | "file" | "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" | "color" | "button" | "time" | "image" | "text" | "reset" | "submit" | "email" | "url" | "range" | "tel" | (string & {}) | "
|
10
|
+
type: "search" | "color" | "button" | "time" | "image" | "text" | "reset" | "submit" | "email" | "url" | "range" | "tel" | (string & {}) | "checkbox" | "radio" | "hidden" | "date" | "datetime-local" | "file" | "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,
|
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;;;;;;;;CAkJ/C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -4,6 +4,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
4
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
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 React, { useEffect } from 'react';
|
7
14
|
import usePersistFn from "../../common/use-persist-fn";
|
8
15
|
import useInputFormat from "./use-input-format";
|
9
16
|
import { sub } from "../../utils/number";
|
@@ -30,6 +37,15 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
30
37
|
}
|
31
38
|
return value || '';
|
32
39
|
};
|
40
|
+
var _React$useState = React.useState(getStringValue(props.value)),
|
41
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
42
|
+
inernalInputValue = _React$useState2[0],
|
43
|
+
setInternalInputValue = _React$useState2[1];
|
44
|
+
useEffect(function () {
|
45
|
+
if (props.value !== inernalInputValue) {
|
46
|
+
setInternalInputValue(getStringValue(props.value));
|
47
|
+
}
|
48
|
+
}, [props.value]);
|
33
49
|
var getNumberValue = function getNumberValue(value) {
|
34
50
|
if (isNaN(value)) return 0;
|
35
51
|
if (typeof value === 'number') {
|
@@ -47,6 +63,17 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
47
63
|
}
|
48
64
|
return num;
|
49
65
|
};
|
66
|
+
var onInnerChange = usePersistFn(function (val) {
|
67
|
+
setInternalInputValue(getStringValue(val));
|
68
|
+
if (typeof val === 'string') {
|
69
|
+
var num = parseFloat(val);
|
70
|
+
if (isNaN(num)) return;
|
71
|
+
onChange === null || onChange === void 0 || onChange(num);
|
72
|
+
} else {
|
73
|
+
onChange === null || onChange === void 0 || onChange(val);
|
74
|
+
}
|
75
|
+
;
|
76
|
+
});
|
50
77
|
var onNumberBlur = usePersistFn(function (e) {
|
51
78
|
var target = e.target;
|
52
79
|
var newValue = target.value;
|
@@ -57,7 +84,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
57
84
|
return;
|
58
85
|
}
|
59
86
|
if (newValue === '' && allowNull) {
|
60
|
-
|
87
|
+
onInnerChange(null);
|
61
88
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
62
89
|
return;
|
63
90
|
}
|
@@ -72,15 +99,18 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
72
99
|
num = parseFloat(num.toFixed(digits));
|
73
100
|
}
|
74
101
|
num = commonFormat(num);
|
102
|
+
|
103
|
+
// 失焦时,将非法值转换为合法值
|
104
|
+
setInternalInputValue(getStringValue(num));
|
75
105
|
if (num !== value) {
|
76
106
|
target.value = typeof num === 'number' ? String(num) : '';
|
77
|
-
if (!cancelBlurChange)
|
107
|
+
if (!cancelBlurChange) onInnerChange(num);
|
78
108
|
}
|
79
109
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
80
110
|
});
|
81
111
|
var onNumberChange = usePersistFn(function (value) {
|
82
112
|
var result = value;
|
83
|
-
|
113
|
+
onInnerChange(result);
|
84
114
|
});
|
85
115
|
var changeValue = function changeValue(mod) {
|
86
116
|
var num = getNumberValue(props.value);
|
@@ -106,7 +136,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
106
136
|
changeValue(-step);
|
107
137
|
});
|
108
138
|
return _objectSpread(_objectSpread({}, useInputFormat({
|
109
|
-
value:
|
139
|
+
value: inernalInputValue,
|
110
140
|
type: 'number',
|
111
141
|
numType: numType,
|
112
142
|
integerLimit: integerLimit,
|
@@ -5,6 +5,7 @@ declare const usePopup: (props: BasePopupProps) => {
|
|
5
5
|
position: PositionType;
|
6
6
|
targetRef: React.MutableRefObject<HTMLDivElement | null>;
|
7
7
|
popupRef: React.MutableRefObject<HTMLDivElement | null>;
|
8
|
+
arrowRef: React.MutableRefObject<HTMLSpanElement | null>;
|
8
9
|
getTargetProps: () => {
|
9
10
|
onMouseEnter: (e: {
|
10
11
|
target: EventTarget | null;
|
@@ -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;AAMhE,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;AAMhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;;0BA2HK;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"}
|
@@ -30,6 +30,7 @@ var usePopup = function usePopup(props) {
|
|
30
30
|
removeChild = _useContext.removeChild;
|
31
31
|
var targetRef = useRef(null);
|
32
32
|
var popupRef = useRef(null);
|
33
|
+
var arrowRef = useRef(null);
|
33
34
|
useEffect(function () {
|
34
35
|
bindChild(popupRef);
|
35
36
|
return function () {
|
@@ -61,11 +62,12 @@ var usePopup = function usePopup(props) {
|
|
61
62
|
setPositionState = _useState4[1];
|
62
63
|
var position = isPositionControl ? props.position : positionState;
|
63
64
|
var updatePosition = usePersistFn(function () {
|
64
|
-
if (isPositionControl) return;
|
65
|
-
if (props.position === 'auto' || !props.position) {
|
66
|
-
|
65
|
+
// if (isPositionControl) return;
|
66
|
+
// if (props.position === 'auto' || !props.position) {
|
67
|
+
setTimeout(function () {
|
68
|
+
var newPosition = getPosition(targetRef.current, props.priorityDirection, autoMode, popupRef.current || undefined);
|
67
69
|
if (newPosition !== position) setPositionState(newPosition);
|
68
|
-
}
|
70
|
+
}, 10);
|
69
71
|
});
|
70
72
|
useEffect(function () {
|
71
73
|
if (props.open) {
|
@@ -194,6 +196,7 @@ var usePopup = function usePopup(props) {
|
|
194
196
|
position: position,
|
195
197
|
targetRef: targetRef,
|
196
198
|
popupRef: popupRef,
|
199
|
+
arrowRef: arrowRef,
|
197
200
|
getTargetProps: getTargetProps,
|
198
201
|
openPop: openPop,
|
199
202
|
closePop: closePop,
|
@@ -26,7 +26,7 @@ declare const useTableVirtual: (props: UseTableVirtualProps) => {
|
|
26
26
|
}) => void;
|
27
27
|
setRowHeight: (index: number, height: number) => void;
|
28
28
|
getTranslate: (left?: number, top?: number) => string;
|
29
|
-
scrollToIndex: (index: number) => void;
|
29
|
+
scrollToIndex: (index: number, callback?: () => void) => void;
|
30
30
|
};
|
31
31
|
export default useTableVirtual;
|
32
32
|
//# sourceMappingURL=use-table-virtual.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAzFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAqJnB,MAAM,aAAa,MAAM,IAAI;CA8FzE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -10,6 +10,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
11
11
|
import { usePersistFn } from "../../common/use-persist-fn";
|
12
12
|
import { useState, useRef, useEffect, useMemo } from 'react';
|
13
|
+
var MAX_ROW_SPAN = 200;
|
13
14
|
var useTableVirtual = function useTableVirtual(props) {
|
14
15
|
var _useState = useState(0),
|
15
16
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -92,7 +93,9 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
92
93
|
topTimer: null,
|
93
94
|
controlScrollRate: null,
|
94
95
|
heightCallback: null,
|
95
|
-
preIndex: null
|
96
|
+
preIndex: null,
|
97
|
+
rowSpanRows: 0,
|
98
|
+
autoAddRows: 0
|
96
99
|
}),
|
97
100
|
context = _useRef.current;
|
98
101
|
var getTranslate = usePersistFn(function (left, top) {
|
@@ -143,17 +146,20 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
143
146
|
var top = 0;
|
144
147
|
var maxIndex = Math.max(props.data.length - rowsInView, 0);
|
145
148
|
for (var i = 0; i <= maxIndex; i++) {
|
149
|
+
context.rowSpanRows = 0;
|
146
150
|
sum += context.cachedHeight[i] || props.rowHeight;
|
147
151
|
var rowSpanHeight = 0;
|
148
152
|
if (rowSpanInfos) {
|
153
|
+
var maxRowSpanLenth = Math.min(rowSpanInfos.length, props.rowsInView > MAX_ROW_SPAN ? props.rowsInView : props.rowsInView || MAX_ROW_SPAN);
|
149
154
|
var siblingsIndexs = [];
|
150
|
-
for (var k = 0; k <
|
155
|
+
for (var k = 0; k < maxRowSpanLenth; k++) {
|
151
156
|
if (rowSpanInfos[k] <= i && k > i) {
|
152
157
|
siblingsIndexs.push(k);
|
153
158
|
}
|
154
159
|
}
|
155
160
|
for (var j = 0; j < siblingsIndexs.length; j++) {
|
156
161
|
var index = siblingsIndexs[j];
|
162
|
+
context.rowSpanRows += 1;
|
157
163
|
rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
|
158
164
|
}
|
159
165
|
}
|
@@ -229,7 +235,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
229
235
|
updateIndexAndTopFromTop(scrollTop);
|
230
236
|
}
|
231
237
|
};
|
232
|
-
var scrollToIndex = usePersistFn(function (index) {
|
238
|
+
var scrollToIndex = usePersistFn(function (index, callback) {
|
233
239
|
if (props.disabled) return;
|
234
240
|
if (props.scrollRef.current) {
|
235
241
|
context.shouldUpdateHeight = true;
|
@@ -240,16 +246,39 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
240
246
|
if (beforeHeight2 !== beforeHeight) {
|
241
247
|
scrollToIndex(index);
|
242
248
|
}
|
249
|
+
if (callback && typeof callback === 'function') {
|
250
|
+
callback();
|
251
|
+
}
|
243
252
|
};
|
244
253
|
props.scrollRef.current.scrollTop = beforeHeight;
|
245
254
|
}
|
246
255
|
});
|
256
|
+
useEffect(function () {
|
257
|
+
var scrollRefHeight = props.scrollRef.current ? props.scrollRef.current.clientHeight : 0;
|
258
|
+
var tableRefHeight = props.innerRef.current ? props.innerRef.current.clientHeight : 0;
|
259
|
+
var remainHeight = scrollRefHeight - tableRefHeight;
|
260
|
+
if (remainHeight > 0) {
|
261
|
+
var addonHeight = 0;
|
262
|
+
var addonCount = 0;
|
263
|
+
for (var i = startIndex + rowsInView; i < props.data.length; i++) {
|
264
|
+
var height = context.cachedHeight[i] || props.rowHeight;
|
265
|
+
addonHeight += height;
|
266
|
+
addonCount += 1;
|
267
|
+
if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
|
268
|
+
}
|
269
|
+
if (addonCount > 0) {
|
270
|
+
context.autoAddRows = addonCount;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
}, []);
|
247
274
|
useEffect(function () {
|
248
275
|
// 记录preIndex
|
249
276
|
context.preIndex = startIndex;
|
250
277
|
}, [startIndex]);
|
251
278
|
useEffect(function () {
|
252
279
|
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
280
|
+
setTop(0);
|
281
|
+
setStartIndex(0);
|
253
282
|
return function () {
|
254
283
|
context.preIndex = null;
|
255
284
|
};
|
@@ -278,7 +307,8 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
278
307
|
cb();
|
279
308
|
}
|
280
309
|
}, [scrollHeight]);
|
281
|
-
var
|
310
|
+
var finalRowsInView = rowsInView + context.rowSpanRows + context.autoAddRows;
|
311
|
+
var renderData = props.disabled ? props.data : _toConsumableArray(props.data).slice(startIndex, startIndex + finalRowsInView);
|
282
312
|
return {
|
283
313
|
scrollHeight: scrollHeight,
|
284
314
|
startIndex: startIndex,
|
@@ -87,7 +87,7 @@ declare const useTransfer: <DataItem, Value extends KeygenResult[]>(props: BaseT
|
|
87
87
|
filterTargetText: string;
|
88
88
|
sourceSelectedKeys: KeygenResult[];
|
89
89
|
targetSelectedKeys: KeygenResult[];
|
90
|
-
onSelectChange: (
|
90
|
+
onSelectChange: (_value: KeygenResult[], source: KeygenResult[], target: KeygenResult[]) => void;
|
91
91
|
onFilter: (text: string, listType: TransferListType) => void;
|
92
92
|
};
|
93
93
|
export default useTransfer;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-transfer.d.ts","sourceRoot":"","sources":["use-transfer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,QAAA,MAAM,WAAW
|
1
|
+
{"version":3,"file":"use-transfer.d.ts","sourceRoot":"","sources":["use-transfer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA0BL,YAAY,EAAE,UACd,YAAY,EAAE,UACd,YAAY,EAAE;qBAqFI,MAAM,YAAY,gBAAgB;CAsB/D,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
@@ -37,12 +37,15 @@ var useTransfer = function useTransfer(props) {
|
|
37
37
|
_useState4 = _slicedToArray(_useState3, 2),
|
38
38
|
filterTargetText = _useState4[0],
|
39
39
|
setFilterTargetText = _useState4[1];
|
40
|
+
var handleSelectedChange = function handleSelectedChange(_value, source, target) {
|
41
|
+
onSelectChangeProp === null || onSelectChangeProp === void 0 || onSelectChangeProp(source, target);
|
42
|
+
};
|
40
43
|
var _useInputAble = useInputAble({
|
41
44
|
value: selectValue,
|
42
45
|
defaultValue: defaultSelectValue,
|
43
46
|
control: selectControl,
|
44
47
|
beforeChange: undefined,
|
45
|
-
onChange:
|
48
|
+
onChange: handleSelectedChange
|
46
49
|
}),
|
47
50
|
selectedKeys = _useInputAble.value,
|
48
51
|
onSelectChange = _useInputAble.onChange;
|
@@ -99,24 +102,12 @@ var useTransfer = function useTransfer(props) {
|
|
99
102
|
return keygen;
|
100
103
|
};
|
101
104
|
var handleSourceSelectedChange = function handleSourceSelectedChange(value) {
|
102
|
-
|
103
|
-
|
104
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(value, targetSelectedKeys);
|
105
|
-
} else {
|
106
|
-
// 非受控内部直接整合 source target
|
107
|
-
var next = [].concat(_toConsumableArray(value), _toConsumableArray(targetSelectedKeys));
|
108
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next);
|
109
|
-
}
|
105
|
+
var next = [].concat(_toConsumableArray(value), _toConsumableArray(targetSelectedKeys));
|
106
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next, value, targetSelectedKeys);
|
110
107
|
};
|
111
108
|
var handleTargetSelectedChange = function handleTargetSelectedChange(value) {
|
112
|
-
|
113
|
-
|
114
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(sourceSelectedKeys, value);
|
115
|
-
} else {
|
116
|
-
// 非受控内部直接整合 source target
|
117
|
-
var next = [].concat(_toConsumableArray(sourceSelectedKeys), _toConsumableArray(value));
|
118
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next);
|
119
|
-
}
|
109
|
+
var next = [].concat(_toConsumableArray(sourceSelectedKeys), _toConsumableArray(value));
|
110
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next, sourceSelectedKeys, value);
|
120
111
|
};
|
121
112
|
var sourceDatum = useListSelectMultiple({
|
122
113
|
value: sourceSelectedKeys,
|
package/esm/utils/dom/element.js
CHANGED
@@ -72,7 +72,7 @@ export var addResizeObserver = function addResizeObserver(el, handler) {
|
|
72
72
|
if (height && lastHeight !== height) {
|
73
73
|
debounceHandler(entry);
|
74
74
|
}
|
75
|
-
} else if (width
|
75
|
+
} else if (lastWidth !== width || lastHeight !== height) {
|
76
76
|
debounceHandler(entry, {
|
77
77
|
x: lastWidth !== width,
|
78
78
|
y: lastHeight !== height
|
package/esm/utils/is.d.ts
CHANGED
@@ -21,6 +21,7 @@ export declare const isPromise: (p: unknown) => unknown;
|
|
21
21
|
export declare const isNan: (a: unknown) => boolean;
|
22
22
|
export declare const isEmpty: (val: unknown) => boolean;
|
23
23
|
export declare const isLink: (el: unknown) => el is React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
24
|
+
export declare function isNamedComponent(type: any): type is React.ForwardRefExoticComponent<unknown>;
|
24
25
|
export declare const isMacOS: () => boolean;
|
25
26
|
export declare const isFirefox: () => boolean;
|
26
27
|
export declare const isChromeLowerThan: (version: number) => boolean;
|
package/esm/utils/is.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["is.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,SAAS,YAExB;AASD,eAAO,MAAM,OAAO,4BAAgB,CAAC;AACrC,eAAO,MAAM,QAAQ,QAAS,OAAO,sBACc,CAAC;AACpD,eAAO,MAAM,MAAM,QAAS,OAAO,gBAAqC,CAAC;AACzE,eAAO,MAAM,SAAS,QAAS,OAAO,mBAA2C,CAAC;AAClF,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,OAA+B,CAAC;AACvE,eAAO,MAAM,QAAQ,MAAO,OAAO,gBA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E"}
|
package/esm/utils/is.js
CHANGED
@@ -85,6 +85,9 @@ export var isLink = function isLink(el) {
|
|
85
85
|
}
|
86
86
|
return false;
|
87
87
|
};
|
88
|
+
export function isNamedComponent(type) {
|
89
|
+
return (isObject(type) || isFunc(type)) && type.hasOwnProperty('displayName');
|
90
|
+
}
|
88
91
|
export var isMacOS = function isMacOS() {
|
89
92
|
return isBrowser() && /macintosh|mac os x/i.test(navigator.userAgent);
|
90
93
|
};
|
package/esm/utils/position.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const getPosition: (target: HTMLElement | null, priorityDirection: "vertical" | "horizontal" | "auto" | undefined, mode: 'popover' | 'menu' | 'list') => "bottom" | "left" | "right" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
|
1
|
+
export declare const getPosition: (target: HTMLElement | null, priorityDirection: "vertical" | "horizontal" | "auto" | undefined, mode: 'popover' | 'menu' | 'list', popup?: HTMLElement) => "bottom" | "left" | "right" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
|
2
2
|
//# sourceMappingURL=position.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":"AAiGA,eAAO,MAAM,WAAW,WACd,WAAW,GAAG,IAAI,2EAEpB,SAAS,GAAG,MAAM,GAAG,MAAM,UACzB,WAAW,gKAKpB,CAAC"}
|
package/esm/utils/position.js
CHANGED
@@ -35,6 +35,7 @@ var getMenuPosition = function getMenuPosition(target) {
|
|
35
35
|
};
|
36
36
|
var getPopoverPosition = function getPopoverPosition(target) {
|
37
37
|
var priorityDirection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'vertical';
|
38
|
+
var popup = arguments.length > 2 ? arguments[2] : undefined;
|
38
39
|
var position = 'bottom-left';
|
39
40
|
if (!target) return position;
|
40
41
|
var rect = target.getBoundingClientRect();
|
@@ -56,11 +57,24 @@ var getPopoverPosition = function getPopoverPosition(target) {
|
|
56
57
|
position += '-top';
|
57
58
|
}
|
58
59
|
} else {
|
60
|
+
var popupRect = popup === null || popup === void 0 ? void 0 : popup.getBoundingClientRect();
|
59
61
|
if (verticalPoint > windowHeight / 2) position = 'top';else position = 'bottom';
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
|
63
|
+
// 如果渲染了弹出内容,则根据弹出内容宽度计算是否自动调整位置
|
64
|
+
if (popupRect) {
|
65
|
+
if ((popupRect === null || popupRect === void 0 ? void 0 : popupRect.width) / 2 > rect.left) {
|
66
|
+
position += '-left';
|
67
|
+
}
|
68
|
+
if ((popupRect === null || popupRect === void 0 ? void 0 : popupRect.width) / 2 > windowWidth - rect.right) {
|
69
|
+
position += '-right';
|
70
|
+
}
|
71
|
+
} else {
|
72
|
+
// 兜底计算
|
73
|
+
if (horizontalPoint > windowWidth * 0.6) {
|
74
|
+
position += '-right';
|
75
|
+
} else if (horizontalPoint < windowWidth * 0.4) {
|
76
|
+
position += '-left';
|
77
|
+
}
|
64
78
|
}
|
65
79
|
}
|
66
80
|
return position;
|
@@ -68,7 +82,8 @@ var getPopoverPosition = function getPopoverPosition(target) {
|
|
68
82
|
export var getPosition = function getPosition(target) {
|
69
83
|
var priorityDirection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'vertical';
|
70
84
|
var mode = arguments.length > 2 ? arguments[2] : undefined;
|
71
|
-
|
85
|
+
var popup = arguments.length > 3 ? arguments[3] : undefined;
|
86
|
+
if (mode === 'popover') return getPopoverPosition(target, priorityDirection, popup);
|
72
87
|
if (mode === 'menu') return getMenuPosition(target, priorityDirection);
|
73
88
|
return 'bottom-left';
|
74
89
|
};
|