@sheinx/hooks 3.4.0-beta.4 → 3.4.0-beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/cjs/common/use-position-style/index.d.ts +4 -1
  2. package/cjs/common/use-position-style/index.d.ts.map +1 -1
  3. package/cjs/common/use-position-style/index.js +98 -11
  4. package/cjs/components/use-datepicker/use-date.d.ts +2 -2
  5. package/cjs/components/use-datepicker/use-date.d.ts.map +1 -1
  6. package/cjs/components/use-datepicker/use-date.js +2 -2
  7. package/cjs/components/use-datepicker/use-date.type.d.ts +1 -1
  8. package/cjs/components/use-datepicker/use-date.type.d.ts.map +1 -1
  9. package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  10. package/cjs/components/use-datepicker/use-datepicker-format.js +3 -1
  11. package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts +1 -0
  12. package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
  13. package/cjs/components/use-datepicker/use-month.d.ts +1 -1
  14. package/cjs/components/use-datepicker/use-quarter.d.ts +1 -1
  15. package/cjs/components/use-datepicker/use-year.d.ts +1 -1
  16. package/cjs/components/use-datepicker/util.d.ts +1 -1
  17. package/cjs/components/use-datepicker/util.d.ts.map +1 -1
  18. package/cjs/components/use-datepicker/util.js +2 -1
  19. package/cjs/components/use-form/use-form-control/use-form-control.js +2 -2
  20. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  21. package/cjs/components/use-form/use-form.js +40 -19
  22. package/cjs/components/use-form/use-form.type.d.ts +11 -6
  23. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  24. package/cjs/components/use-input/use-input-format.d.ts +1 -1
  25. package/cjs/components/use-input/use-input-number.d.ts +1 -1
  26. package/cjs/components/use-popup/use-popup.d.ts +1 -0
  27. package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
  28. package/cjs/components/use-popup/use-popup.js +7 -4
  29. package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
  30. package/cjs/components/use-table/use-table-virtual.js +28 -3
  31. package/cjs/utils/position.d.ts +1 -1
  32. package/cjs/utils/position.d.ts.map +1 -1
  33. package/cjs/utils/position.js +20 -5
  34. package/esm/common/use-position-style/index.d.ts +4 -1
  35. package/esm/common/use-position-style/index.d.ts.map +1 -1
  36. package/esm/common/use-position-style/index.js +99 -12
  37. package/esm/components/use-datepicker/use-date.d.ts +2 -2
  38. package/esm/components/use-datepicker/use-date.d.ts.map +1 -1
  39. package/esm/components/use-datepicker/use-date.js +2 -2
  40. package/esm/components/use-datepicker/use-date.type.d.ts +1 -1
  41. package/esm/components/use-datepicker/use-date.type.d.ts.map +1 -1
  42. package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  43. package/esm/components/use-datepicker/use-datepicker-format.js +3 -1
  44. package/esm/components/use-datepicker/use-datepicker-format.type.d.ts +1 -0
  45. package/esm/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
  46. package/esm/components/use-datepicker/use-month.d.ts +1 -1
  47. package/esm/components/use-datepicker/use-quarter.d.ts +1 -1
  48. package/esm/components/use-datepicker/use-year.d.ts +1 -1
  49. package/esm/components/use-datepicker/util.d.ts +1 -1
  50. package/esm/components/use-datepicker/util.d.ts.map +1 -1
  51. package/esm/components/use-datepicker/util.js +2 -1
  52. package/esm/components/use-form/use-form-control/use-form-control.js +2 -2
  53. package/esm/components/use-form/use-form.d.ts.map +1 -1
  54. package/esm/components/use-form/use-form.js +40 -19
  55. package/esm/components/use-form/use-form.type.d.ts +11 -6
  56. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  57. package/esm/components/use-input/use-input-format.d.ts +1 -1
  58. package/esm/components/use-input/use-input-number.d.ts +1 -1
  59. package/esm/components/use-popup/use-popup.d.ts +1 -0
  60. package/esm/components/use-popup/use-popup.d.ts.map +1 -1
  61. package/esm/components/use-popup/use-popup.js +7 -4
  62. package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
  63. package/esm/components/use-table/use-table-virtual.js +28 -3
  64. package/esm/utils/position.d.ts +1 -1
  65. package/esm/utils/position.d.ts.map +1 -1
  66. package/esm/utils/position.js +20 -5
  67. package/package.json +1 -1
@@ -183,11 +183,11 @@ export default function useFormControl(props) {
183
183
  if (inForm && controlFunc) {
184
184
  if (isArray(name)) {
185
185
  name.forEach(function (n) {
186
- controlFunc.unbind(n, reserveAble);
186
+ controlFunc.unbind(n, reserveAble, validateFiled, update);
187
187
  updateError(n, undefined);
188
188
  });
189
189
  } else {
190
- controlFunc.unbind(name, reserveAble);
190
+ controlFunc.unbind(name, reserveAble, validateFiled, update);
191
191
  updateError(name, undefined);
192
192
  }
193
193
  }
@@ -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,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAmK8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCAuDD,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCAiI5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBA1CpB;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCAuDD,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCAiI5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA4P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
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, _context$updateMap;
69
- (_context$updateMap$ke = (_context$updateMap = context.updateMap)[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.call(_context$updateMap, context.value, context.errors, context.serverErrors);
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$updateMap2, _context$flowMap$key;
80
- (_context$updateMap$ke2 = (_context$updateMap2 = context.updateMap)[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.call(_context$updateMap2, context.value, context.errors, context.serverErrors);
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(key, deepGet(context.value, key), context.value, config);
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$, _context$validateMap;
184
- (_context$validateMap$ = (_context$validateMap = context.validateMap)[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.call(_context$validateMap, key, vals[key], current(draft));
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.error("name \"".concat(n, "\" already exist"));
329
- return;
336
+ console.warn("name \"".concat(n, "\" already exist"));
330
337
  }
331
338
  context.names.add(n);
332
- context.validateMap[n] = validate;
333
- context.updateMap[n] = updateFn;
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
- delete context.validateMap[n];
345
- delete context.defaultValues[n];
346
- delete context.updateMap[n];
347
- context.names.delete(n);
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 _errors = Object.keys(props.error).reduce(function (prev, cur) {
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 = _errors;
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: (name: string, value: any, formData: ObjectType, config: {
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;AAE1D,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;QACnD,IAAI,EAAE,CACJ,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,GAAG,EACP,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE;YACN,UAAU,CAAC,EAAE,OAAO,CAAC;SACtB,KACE,IAAI,EACT,MAAM,EAAE,CACN,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,EACzB,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,KAC5B,IAAI,KACN,IAAI,CAAC;QACV,YAAY,EAAE,CAAC,SAAS,EACtB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,KAC/B,YAAY,CAAC,SAAS,CAAC,CAAC;QAC7B,KAAK,EAA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AG,CAAC,MAAM,CAAC,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;IAElC,SAAS,EAAE,MAAM,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 & {}) | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "month" | "password" | "radio" | "week" | undefined;
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 & {}) | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "month" | "password" | "radio" | "week" | undefined;
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
@@ -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;;;;;;0BAoHK;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;;CAqBpE,CAAC;AAEF,eAAe,QAAQ,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
- var newPosition = getPosition(targetRef.current, props.priorityDirection, autoMode);
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,
@@ -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;AAErD,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;;;;;;;oBAiLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BA+InB,MAAM;CAmElD,CAAC;AAEF,eAAe,eAAe,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;;;;;;;oBAsLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAtFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAkJnB,MAAM;CAwFlD,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 < rowSpanInfos.length; 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
  }
@@ -244,6 +250,24 @@ var useTableVirtual = function useTableVirtual(props) {
244
250
  props.scrollRef.current.scrollTop = beforeHeight;
245
251
  }
246
252
  });
253
+ useEffect(function () {
254
+ var scrollRefHeight = props.scrollRef.current ? props.scrollRef.current.clientHeight : 0;
255
+ var tableRefHeight = props.innerRef.current ? props.innerRef.current.clientHeight : 0;
256
+ var remainHeight = scrollRefHeight - tableRefHeight;
257
+ if (remainHeight > 0) {
258
+ var addonHeight = 0;
259
+ var addonCount = 0;
260
+ for (var i = startIndex + rowsInView; i < props.data.length; i++) {
261
+ var height = context.cachedHeight[i] || props.rowHeight;
262
+ addonHeight += height;
263
+ addonCount += 1;
264
+ if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
265
+ }
266
+ if (addonCount > 0) {
267
+ context.autoAddRows = addonCount;
268
+ }
269
+ }
270
+ }, []);
247
271
  useEffect(function () {
248
272
  // 记录preIndex
249
273
  context.preIndex = startIndex;
@@ -278,7 +302,8 @@ var useTableVirtual = function useTableVirtual(props) {
278
302
  cb();
279
303
  }
280
304
  }, [scrollHeight]);
281
- var renderData = props.disabled ? props.data : _toConsumableArray(props.data).slice(startIndex, startIndex + rowsInView);
305
+ var finalRowsInView = rowsInView + context.rowSpanRows + context.autoAddRows;
306
+ var renderData = props.disabled ? props.data : _toConsumableArray(props.data).slice(startIndex, startIndex + finalRowsInView);
282
307
  return {
283
308
  scrollHeight: scrollHeight,
284
309
  startIndex: startIndex,
@@ -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":"AAgFA,eAAO,MAAM,WAAW,WACd,WAAW,GAAG,IAAI,2EAEpB,SAAS,GAAG,MAAM,GAAG,MAAM,gKAKlC,CAAC"}
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"}
@@ -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
- if (horizontalPoint > windowWidth * 0.6) {
61
- position += '-right';
62
- } else if (horizontalPoint < windowWidth * 0.4) {
63
- position += '-left';
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
- if (mode === 'popover') return getPopoverPosition(target, priorityDirection);
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.4.0-beta.4",
3
+ "version": "3.4.0-beta.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",