@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
@@ -74,8 +74,10 @@ var useForm = function useForm(props) {
|
|
74
74
|
var _context$flowMap$glob;
|
75
75
|
if (!name) {
|
76
76
|
Object.keys(context.updateMap).forEach(function (key) {
|
77
|
-
var _context$updateMap$ke
|
78
|
-
(_context$updateMap$ke =
|
77
|
+
var _context$updateMap$ke;
|
78
|
+
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
79
|
+
update(context.value, context.errors, context.serverErrors);
|
80
|
+
});
|
79
81
|
});
|
80
82
|
Object.keys(context.flowMap).forEach(function (key) {
|
81
83
|
context.flowMap[key].forEach(function (update) {
|
@@ -85,8 +87,10 @@ var useForm = function useForm(props) {
|
|
85
87
|
} else {
|
86
88
|
var names = (0, _utils.isArray)(name) ? name : [name];
|
87
89
|
names.forEach(function (key) {
|
88
|
-
var _context$updateMap$ke2, _context$
|
89
|
-
(_context$updateMap$ke2 =
|
90
|
+
var _context$updateMap$ke2, _context$flowMap$key;
|
91
|
+
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
92
|
+
update(context.value, context.errors, context.serverErrors);
|
93
|
+
});
|
90
94
|
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
91
95
|
update();
|
92
96
|
});
|
@@ -142,9 +146,11 @@ var useForm = function useForm(props) {
|
|
142
146
|
}) : Object.keys(context.validateMap);
|
143
147
|
var validates = files2.map(function (key) {
|
144
148
|
var validateField = context.validateMap[key];
|
145
|
-
return validateField(
|
149
|
+
return Array.from(validateField).map(function (validate) {
|
150
|
+
return validate(key, (0, _utils.deepGet)(context.value, key), context.value, config);
|
151
|
+
});
|
146
152
|
});
|
147
|
-
Promise.all(validates).then(function (results) {
|
153
|
+
Promise.all(validates.flat()).then(function (results) {
|
148
154
|
var error = results.find(function (n) {
|
149
155
|
return n !== true;
|
150
156
|
});
|
@@ -189,8 +195,10 @@ var useForm = function useForm(props) {
|
|
189
195
|
Object.keys(vals).forEach(function (key) {
|
190
196
|
(0, _utils.deepSet)(draft, key, vals[key], deepSetOptions);
|
191
197
|
if (option.validate) {
|
192
|
-
var _context$validateMap
|
193
|
-
(_context$validateMap$ =
|
198
|
+
var _context$validateMap$;
|
199
|
+
(_context$validateMap$ = context.validateMap[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.forEach(function (validate) {
|
200
|
+
validate(key, vals[key], (0, _immer.current)(draft));
|
201
|
+
});
|
194
202
|
}
|
195
203
|
});
|
196
204
|
});
|
@@ -334,12 +342,17 @@ var useForm = function useForm(props) {
|
|
334
342
|
var controlFunc = (0, _useLatestObj.default)({
|
335
343
|
bind: function bind(n, df, validate, updateFn) {
|
336
344
|
if (context.names.has(n)) {
|
337
|
-
console.
|
338
|
-
return;
|
345
|
+
console.warn("name \"".concat(n, "\" already exist"));
|
339
346
|
}
|
340
347
|
context.names.add(n);
|
341
|
-
context.validateMap[n]
|
342
|
-
|
348
|
+
if (!context.validateMap[n]) {
|
349
|
+
context.validateMap[n] = new Set();
|
350
|
+
}
|
351
|
+
context.validateMap[n].add(validate);
|
352
|
+
if (!context.updateMap[n]) {
|
353
|
+
context.updateMap[n] = new Set();
|
354
|
+
}
|
355
|
+
context.updateMap[n].add(updateFn);
|
343
356
|
context.removeArr.delete(n);
|
344
357
|
if (df !== undefined && (0, _utils.deepGet)(context.value, n) === undefined) {
|
345
358
|
if (!context.mounted) context.defaultValues[n] = df;
|
@@ -349,11 +362,19 @@ var useForm = function useForm(props) {
|
|
349
362
|
}
|
350
363
|
update(n);
|
351
364
|
},
|
352
|
-
unbind: function unbind(n, reserveAble) {
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
365
|
+
unbind: function unbind(n, reserveAble, validateFiled, update) {
|
366
|
+
var validateFieldSet = context.validateMap[n];
|
367
|
+
if (validateFiled && validateFieldSet.has(validateFiled)) {
|
368
|
+
validateFieldSet.delete(validateFiled);
|
369
|
+
}
|
370
|
+
var updateFieldSet = context.updateMap[n];
|
371
|
+
if (update && updateFieldSet.has(update)) {
|
372
|
+
updateFieldSet.delete(update);
|
373
|
+
}
|
374
|
+
if (validateFieldSet.size === 0 && updateFieldSet.size === 0) {
|
375
|
+
context.names.delete(n);
|
376
|
+
delete context.defaultValues[n];
|
377
|
+
}
|
357
378
|
if (!reserveAble && !context.removeLock) {
|
358
379
|
addRemove(n);
|
359
380
|
}
|
@@ -428,12 +449,12 @@ var useForm = function useForm(props) {
|
|
428
449
|
React.useEffect(function () {
|
429
450
|
// 服务端错误更新
|
430
451
|
if (!props.error) context.serverErrors = {};else {
|
431
|
-
var
|
452
|
+
var errors = Object.keys(props.error).reduce(function (prev, cur) {
|
432
453
|
var item = props.error[cur];
|
433
454
|
var error = item instanceof Error ? item : new Error(item);
|
434
455
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, cur, error));
|
435
456
|
}, {});
|
436
|
-
context.serverErrors =
|
457
|
+
context.serverErrors = errors;
|
437
458
|
}
|
438
459
|
update();
|
439
460
|
}, [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":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M,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IAEjB,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAEhJ,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,IAAI,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"}
|
@@ -1,20 +1,29 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
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); }
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.default = void 0;
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
7
9
|
var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"));
|
8
10
|
var _useInputFormat = _interopRequireDefault(require("./use-input-format"));
|
9
11
|
var _number = require("../../utils/number");
|
10
12
|
var _is = require("../../utils/is");
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
|
-
function
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
13
16
|
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; }
|
14
17
|
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; }
|
15
18
|
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; }
|
16
19
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
17
20
|
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); }
|
21
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
22
|
+
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."); }
|
23
|
+
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); }
|
24
|
+
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; }
|
25
|
+
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; } }
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
18
27
|
var useNumberFormat = function useNumberFormat(props) {
|
19
28
|
var onChange = props.onChange,
|
20
29
|
value = props.value,
|
@@ -37,6 +46,15 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
37
46
|
}
|
38
47
|
return value || '';
|
39
48
|
};
|
49
|
+
var _React$useState = _react.default.useState(getStringValue(props.value)),
|
50
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
51
|
+
inernalInputValue = _React$useState2[0],
|
52
|
+
setInternalInputValue = _React$useState2[1];
|
53
|
+
(0, _react.useEffect)(function () {
|
54
|
+
if (props.value !== inernalInputValue) {
|
55
|
+
setInternalInputValue(getStringValue(props.value));
|
56
|
+
}
|
57
|
+
}, [props.value]);
|
40
58
|
var getNumberValue = function getNumberValue(value) {
|
41
59
|
if (isNaN(value)) return 0;
|
42
60
|
if (typeof value === 'number') {
|
@@ -54,6 +72,17 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
54
72
|
}
|
55
73
|
return num;
|
56
74
|
};
|
75
|
+
var onInnerChange = (0, _usePersistFn.default)(function (val) {
|
76
|
+
setInternalInputValue(getStringValue(val));
|
77
|
+
if (typeof val === 'string') {
|
78
|
+
var num = parseFloat(val);
|
79
|
+
if (isNaN(num)) return;
|
80
|
+
onChange === null || onChange === void 0 || onChange(num);
|
81
|
+
} else {
|
82
|
+
onChange === null || onChange === void 0 || onChange(val);
|
83
|
+
}
|
84
|
+
;
|
85
|
+
});
|
57
86
|
var onNumberBlur = (0, _usePersistFn.default)(function (e) {
|
58
87
|
var target = e.target;
|
59
88
|
var newValue = target.value;
|
@@ -64,7 +93,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
64
93
|
return;
|
65
94
|
}
|
66
95
|
if (newValue === '' && allowNull) {
|
67
|
-
|
96
|
+
onInnerChange(null);
|
68
97
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
69
98
|
return;
|
70
99
|
}
|
@@ -79,15 +108,18 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
79
108
|
num = parseFloat(num.toFixed(digits));
|
80
109
|
}
|
81
110
|
num = commonFormat(num);
|
111
|
+
|
112
|
+
// 失焦时,将非法值转换为合法值
|
113
|
+
setInternalInputValue(getStringValue(num));
|
82
114
|
if (num !== value) {
|
83
115
|
target.value = typeof num === 'number' ? String(num) : '';
|
84
|
-
if (!cancelBlurChange)
|
116
|
+
if (!cancelBlurChange) onInnerChange(num);
|
85
117
|
}
|
86
118
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
87
119
|
});
|
88
120
|
var onNumberChange = (0, _usePersistFn.default)(function (value) {
|
89
121
|
var result = value;
|
90
|
-
|
122
|
+
onInnerChange(result);
|
91
123
|
});
|
92
124
|
var changeValue = function changeValue(mod) {
|
93
125
|
var num = getNumberValue(props.value);
|
@@ -113,7 +145,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
113
145
|
changeValue(-step);
|
114
146
|
});
|
115
147
|
return _objectSpread(_objectSpread({}, (0, _useInputFormat.default)({
|
116
|
-
value:
|
148
|
+
value: inernalInputValue,
|
117
149
|
type: 'number',
|
118
150
|
numType: numType,
|
119
151
|
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"}
|
@@ -37,6 +37,7 @@ var usePopup = function usePopup(props) {
|
|
37
37
|
removeChild = _useContext.removeChild;
|
38
38
|
var targetRef = (0, _react.useRef)(null);
|
39
39
|
var popupRef = (0, _react.useRef)(null);
|
40
|
+
var arrowRef = (0, _react.useRef)(null);
|
40
41
|
(0, _react.useEffect)(function () {
|
41
42
|
bindChild(popupRef);
|
42
43
|
return function () {
|
@@ -68,11 +69,12 @@ var usePopup = function usePopup(props) {
|
|
68
69
|
setPositionState = _useState4[1];
|
69
70
|
var position = isPositionControl ? props.position : positionState;
|
70
71
|
var updatePosition = (0, _usePersistFn.default)(function () {
|
71
|
-
if (isPositionControl) return;
|
72
|
-
if (props.position === 'auto' || !props.position) {
|
73
|
-
|
72
|
+
// if (isPositionControl) return;
|
73
|
+
// if (props.position === 'auto' || !props.position) {
|
74
|
+
setTimeout(function () {
|
75
|
+
var newPosition = (0, _position.getPosition)(targetRef.current, props.priorityDirection, autoMode, popupRef.current || undefined);
|
74
76
|
if (newPosition !== position) setPositionState(newPosition);
|
75
|
-
}
|
77
|
+
}, 10);
|
76
78
|
});
|
77
79
|
(0, _react.useEffect)(function () {
|
78
80
|
if (props.open) {
|
@@ -201,6 +203,7 @@ var usePopup = function usePopup(props) {
|
|
201
203
|
position: position,
|
202
204
|
targetRef: targetRef,
|
203
205
|
popupRef: popupRef,
|
206
|
+
arrowRef: arrowRef,
|
204
207
|
getTargetProps: getTargetProps,
|
205
208
|
openPop: openPop,
|
206
209
|
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"}
|
@@ -16,6 +16,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
16
16
|
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; }
|
17
17
|
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; } }
|
18
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
19
|
+
var MAX_ROW_SPAN = 200;
|
19
20
|
var useTableVirtual = function useTableVirtual(props) {
|
20
21
|
var _useState = (0, _react.useState)(0),
|
21
22
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -98,7 +99,9 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
98
99
|
topTimer: null,
|
99
100
|
controlScrollRate: null,
|
100
101
|
heightCallback: null,
|
101
|
-
preIndex: null
|
102
|
+
preIndex: null,
|
103
|
+
rowSpanRows: 0,
|
104
|
+
autoAddRows: 0
|
102
105
|
}),
|
103
106
|
context = _useRef.current;
|
104
107
|
var getTranslate = (0, _usePersistFn.usePersistFn)(function (left, top) {
|
@@ -149,17 +152,20 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
149
152
|
var top = 0;
|
150
153
|
var maxIndex = Math.max(props.data.length - rowsInView, 0);
|
151
154
|
for (var i = 0; i <= maxIndex; i++) {
|
155
|
+
context.rowSpanRows = 0;
|
152
156
|
sum += context.cachedHeight[i] || props.rowHeight;
|
153
157
|
var rowSpanHeight = 0;
|
154
158
|
if (rowSpanInfos) {
|
159
|
+
var maxRowSpanLenth = Math.min(rowSpanInfos.length, props.rowsInView > MAX_ROW_SPAN ? props.rowsInView : props.rowsInView || MAX_ROW_SPAN);
|
155
160
|
var siblingsIndexs = [];
|
156
|
-
for (var k = 0; k <
|
161
|
+
for (var k = 0; k < maxRowSpanLenth; k++) {
|
157
162
|
if (rowSpanInfos[k] <= i && k > i) {
|
158
163
|
siblingsIndexs.push(k);
|
159
164
|
}
|
160
165
|
}
|
161
166
|
for (var j = 0; j < siblingsIndexs.length; j++) {
|
162
167
|
var index = siblingsIndexs[j];
|
168
|
+
context.rowSpanRows += 1;
|
163
169
|
rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
|
164
170
|
}
|
165
171
|
}
|
@@ -235,7 +241,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
235
241
|
updateIndexAndTopFromTop(scrollTop);
|
236
242
|
}
|
237
243
|
};
|
238
|
-
var scrollToIndex = (0, _usePersistFn.usePersistFn)(function (index) {
|
244
|
+
var scrollToIndex = (0, _usePersistFn.usePersistFn)(function (index, callback) {
|
239
245
|
if (props.disabled) return;
|
240
246
|
if (props.scrollRef.current) {
|
241
247
|
context.shouldUpdateHeight = true;
|
@@ -246,16 +252,39 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
246
252
|
if (beforeHeight2 !== beforeHeight) {
|
247
253
|
scrollToIndex(index);
|
248
254
|
}
|
255
|
+
if (callback && typeof callback === 'function') {
|
256
|
+
callback();
|
257
|
+
}
|
249
258
|
};
|
250
259
|
props.scrollRef.current.scrollTop = beforeHeight;
|
251
260
|
}
|
252
261
|
});
|
262
|
+
(0, _react.useEffect)(function () {
|
263
|
+
var scrollRefHeight = props.scrollRef.current ? props.scrollRef.current.clientHeight : 0;
|
264
|
+
var tableRefHeight = props.innerRef.current ? props.innerRef.current.clientHeight : 0;
|
265
|
+
var remainHeight = scrollRefHeight - tableRefHeight;
|
266
|
+
if (remainHeight > 0) {
|
267
|
+
var addonHeight = 0;
|
268
|
+
var addonCount = 0;
|
269
|
+
for (var i = startIndex + rowsInView; i < props.data.length; i++) {
|
270
|
+
var height = context.cachedHeight[i] || props.rowHeight;
|
271
|
+
addonHeight += height;
|
272
|
+
addonCount += 1;
|
273
|
+
if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
|
274
|
+
}
|
275
|
+
if (addonCount > 0) {
|
276
|
+
context.autoAddRows = addonCount;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}, []);
|
253
280
|
(0, _react.useEffect)(function () {
|
254
281
|
// 记录preIndex
|
255
282
|
context.preIndex = startIndex;
|
256
283
|
}, [startIndex]);
|
257
284
|
(0, _react.useEffect)(function () {
|
258
285
|
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
286
|
+
setTop(0);
|
287
|
+
setStartIndex(0);
|
259
288
|
return function () {
|
260
289
|
context.preIndex = null;
|
261
290
|
};
|
@@ -284,7 +313,8 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
284
313
|
cb();
|
285
314
|
}
|
286
315
|
}, [scrollHeight]);
|
287
|
-
var
|
316
|
+
var finalRowsInView = rowsInView + context.rowSpanRows + context.autoAddRows;
|
317
|
+
var renderData = props.disabled ? props.data : _toConsumableArray(props.data).slice(startIndex, startIndex + finalRowsInView);
|
288
318
|
return {
|
289
319
|
scrollHeight: scrollHeight,
|
290
320
|
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"}
|
@@ -43,12 +43,15 @@ var useTransfer = function useTransfer(props) {
|
|
43
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
44
44
|
filterTargetText = _useState4[0],
|
45
45
|
setFilterTargetText = _useState4[1];
|
46
|
+
var handleSelectedChange = function handleSelectedChange(_value, source, target) {
|
47
|
+
onSelectChangeProp === null || onSelectChangeProp === void 0 || onSelectChangeProp(source, target);
|
48
|
+
};
|
46
49
|
var _useInputAble = (0, _useInputAble3.useInputAble)({
|
47
50
|
value: selectValue,
|
48
51
|
defaultValue: defaultSelectValue,
|
49
52
|
control: selectControl,
|
50
53
|
beforeChange: undefined,
|
51
|
-
onChange:
|
54
|
+
onChange: handleSelectedChange
|
52
55
|
}),
|
53
56
|
selectedKeys = _useInputAble.value,
|
54
57
|
onSelectChange = _useInputAble.onChange;
|
@@ -105,24 +108,12 @@ var useTransfer = function useTransfer(props) {
|
|
105
108
|
return keygen;
|
106
109
|
};
|
107
110
|
var handleSourceSelectedChange = function handleSourceSelectedChange(value) {
|
108
|
-
|
109
|
-
|
110
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(value, targetSelectedKeys);
|
111
|
-
} else {
|
112
|
-
// 非受控内部直接整合 source target
|
113
|
-
var next = [].concat(_toConsumableArray(value), _toConsumableArray(targetSelectedKeys));
|
114
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next);
|
115
|
-
}
|
111
|
+
var next = [].concat(_toConsumableArray(value), _toConsumableArray(targetSelectedKeys));
|
112
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next, value, targetSelectedKeys);
|
116
113
|
};
|
117
114
|
var handleTargetSelectedChange = function handleTargetSelectedChange(value) {
|
118
|
-
|
119
|
-
|
120
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(sourceSelectedKeys, value);
|
121
|
-
} else {
|
122
|
-
// 非受控内部直接整合 source target
|
123
|
-
var next = [].concat(_toConsumableArray(sourceSelectedKeys), _toConsumableArray(value));
|
124
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next);
|
125
|
-
}
|
115
|
+
var next = [].concat(_toConsumableArray(sourceSelectedKeys), _toConsumableArray(value));
|
116
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange(next, sourceSelectedKeys, value);
|
126
117
|
};
|
127
118
|
var sourceDatum = (0, _useListSelect.useListSelectMultiple)({
|
128
119
|
value: sourceSelectedKeys,
|
package/cjs/utils/dom/element.js
CHANGED
@@ -82,7 +82,7 @@ var addResizeObserver = exports.addResizeObserver = function addResizeObserver(e
|
|
82
82
|
if (height && lastHeight !== height) {
|
83
83
|
debounceHandler(entry);
|
84
84
|
}
|
85
|
-
} else if (width
|
85
|
+
} else if (lastWidth !== width || lastHeight !== height) {
|
86
86
|
debounceHandler(entry, {
|
87
87
|
x: lastWidth !== width,
|
88
88
|
y: lastHeight !== height
|
package/cjs/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/cjs/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,gBAAuC,CAAC;AAC3E,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAAgC,CAAC;AACzE,eAAO,MAAM,QAAQ,MAAO,OAAO,gBAAuC,CAAC;AAC3E,eAAO,MAAM,WAAW,QAAS,GAAG,qBAAwC,CAAC;AAC7E,eAAO,MAAM,KAAK,QAjBsB,OAAO,mBAiBb,CAAC;AACnC,eAAO,MAAM,KAAK,QA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O,KAAG,OAAgC,CAAC;AACzE,eAAO,MAAM,QAAQ,MAAO,OAAO,gBAAuC,CAAC;AAC3E,eAAO,MAAM,WAAW,QAAS,GAAG,qBAAwC,CAAC;AAC7E,eAAO,MAAM,KAAK,QAjBsB,OAAO,mBAiBb,CAAC;AACnC,eAAO,MAAM,KAAK,QAlBsB,OAAO,mBAkBb,CAAC;AACnC,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAUvC,CAAC;AACF,eAAO,MAAM,eAAe,QAAS,OAAO,yBAE3C,CAAC;AACF,eAAO,MAAM,WAAW,QAAS,OAAO,KAAG,OAS1C,CAAC;AAEF,eAAO,MAAM,MAAM,MAAO,OAAO,kBAA2C,CAAC;AAE7E,eAAO,MAAM,SAAS,MAAO,OAAO,YACiC,CAAC;AAGtE,eAAO,MAAM,KAAK,MAAO,OAAO,KAAG,OAAkB,CAAC;AAEtD,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,OActC,CAAC;AAEF,eAAO,MAAM,MAAM,OAAQ,OAAO,6EASjC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAE5F;AAED,eAAO,MAAM,OAAO,QAAO,OACqC,CAAC;AAEjE,eAAO,MAAM,SAAS,QAAO,OAG5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,OASnD,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,WAAW,CAQjE"}
|
package/cjs/utils/is.js
CHANGED
@@ -7,7 +7,9 @@ exports.isBoolean = exports.isArray = void 0;
|
|
7
7
|
exports.isBrowser = isBrowser;
|
8
8
|
exports.isDate = exports.isChromeLowerThan = exports.isBuffer = void 0;
|
9
9
|
exports.isDomElement = isDomElement;
|
10
|
-
exports.
|
10
|
+
exports.isMergeable = exports.isMap = exports.isMacOS = exports.isLink = exports.isFunc = exports.isFirefox = exports.isError = exports.isEmpty = void 0;
|
11
|
+
exports.isNamedComponent = isNamedComponent;
|
12
|
+
exports.isUndefined = exports.isUnMatchedData = exports.isString = exports.isSet = exports.isRegexp = exports.isPromise = exports.isObject = exports.isNumber = exports.isNan = void 0;
|
11
13
|
var _react = _interopRequireDefault(require("react"));
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
15
|
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); }
|
@@ -96,6 +98,9 @@ var isLink = exports.isLink = function isLink(el) {
|
|
96
98
|
}
|
97
99
|
return false;
|
98
100
|
};
|
101
|
+
function isNamedComponent(type) {
|
102
|
+
return (isObject(type) || isFunc(type)) && type.hasOwnProperty('displayName');
|
103
|
+
}
|
99
104
|
var isMacOS = exports.isMacOS = function isMacOS() {
|
100
105
|
return isBrowser() && /macintosh|mac os x/i.test(navigator.userAgent);
|
101
106
|
};
|
package/cjs/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"}
|