shineout 3.1.15 → 3.1.16-fix.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { FormFieldProps } from './form.type';
3
- declare const _default: <T>(props: FormFieldProps<T>) => JSX.Element;
3
+ declare const _default: <T extends unknown = any>(props: FormFieldProps<T>) => JSX.Element;
4
4
  export default _default;
@@ -13,7 +13,7 @@ declare const Reset: ((props: import("./interface").SubmitProps) => JSX.Element)
13
13
  declare const Item: ((props: import("./form.type").FormItemProps) => JSX.Element) & {
14
14
  displayName: string;
15
15
  };
16
- declare const Field: (<T>(props: import("./form.type").FormFieldProps<T>) => JSX.Element) & {
16
+ declare const Field: (<T extends unknown = any>(props: import("./form.type").FormFieldProps<T>) => JSX.Element) & {
17
17
  displayName: string;
18
18
  };
19
19
  declare const FieldSet: (<T>(props: import("./form.type").FormFieldSetProps<T>) => JSX.Element) & {
package/cjs/index.js CHANGED
@@ -476,5 +476,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
476
476
  // 此文件由脚本自动生成,请勿直接修改。
477
477
  // This file was generated automatically by a script. Please do not modify it directly.
478
478
  var _default = exports.default = {
479
- version: '3.1.15'
479
+ version: '3.1.16-fix.1'
480
480
  };
@@ -1,6 +1,6 @@
1
1
  import { UploadProps } from './upload.type';
2
2
  declare const useUploadCommon: (props: Pick<UploadProps<any>, 'rules'>) => {
3
3
  validateHook: (r: any) => void;
4
- rules: (import("../../../hooks/src/utils/rule/rule.type").RuleResultValue | import("../../../hooks/src/utils/rule/rule.type").FormItemObjectRule | ((value: any[] | undefined, formData: any, callback: (cbArgs: boolean | Error) => void, props?: any) => void))[];
4
+ rules: (import("../../../hooks/src/utils/rule/rule.type").RuleResultValue | import("../../../hooks/src/utils/rule/rule.type").FormItemObjectRule | ((value: any, formData: any, callback: (cbArgs: boolean | Error) => void, props?: any) => void))[];
5
5
  };
6
6
  export default useUploadCommon;
package/dist/shineout.js CHANGED
@@ -11949,7 +11949,7 @@ var handleStyle = function handleStyle(style) {
11949
11949
  };
11950
11950
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
11951
11951
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
11952
- /* harmony default export */ var version = ('3.1.15');
11952
+ /* harmony default export */ var version = ('3.1.16-fix.1');
11953
11953
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
11954
11954
 
11955
11955
 
@@ -30166,6 +30166,7 @@ var card_jssStyle = {
30166
30166
 
30167
30167
 
30168
30168
 
30169
+
30169
30170
  var CardHeader = function CardHeader(props) {
30170
30171
  var _props$jssStyle, _props$jssStyle$card;
30171
30172
  var align = props.align;
@@ -30188,18 +30189,22 @@ var CardHeader = function CardHeader(props) {
30188
30189
  };
30189
30190
  var alignClass = classnames_default()(align === 'center' && (cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.center), align === 'right' && (cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.right));
30190
30191
  var headerContentClassName = classnames_default()(cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.headerContent, alignClass);
30192
+ var commonHeaderProps = {
30193
+ onMouseDown: handleDragMouseDown,
30194
+ onClick: onCollapse,
30195
+ style: props.style
30196
+ };
30191
30197
  if (!props.extra && !collapsible) {
30192
30198
  var simpleHeaderClassName = classnames_default()(cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.header, cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.simpleHeader, alignClass, props.className);
30193
- return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
30194
- className: simpleHeaderClassName,
30199
+ return /*#__PURE__*/(0,jsx_runtime.jsx)("div", objectSpread2_default()(objectSpread2_default()({
30200
+ className: simpleHeaderClassName
30201
+ }, commonHeaderProps), {}, {
30195
30202
  children: props.children
30196
- });
30203
+ }));
30197
30204
  }
30198
- return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
30199
- onMouseDown: handleDragMouseDown,
30200
- onClick: onCollapse,
30201
- className: classnames_default()(props.className, cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.header),
30202
- style: props.style,
30205
+ return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", objectSpread2_default()(objectSpread2_default()({
30206
+ className: classnames_default()(props.className, cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.header)
30207
+ }, commonHeaderProps), {}, {
30203
30208
  children: [renderIndicator(), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
30204
30209
  className: headerContentClassName,
30205
30210
  children: props.children
@@ -30207,7 +30212,7 @@ var CardHeader = function CardHeader(props) {
30207
30212
  className: cardClasses === null || cardClasses === void 0 ? void 0 : cardClasses.headerExtra,
30208
30213
  children: props.extra
30209
30214
  })]
30210
- });
30215
+ }));
30211
30216
  };
30212
30217
  /* harmony default export */ var card_header = (CardHeader);
30213
30218
  ;// CONCATENATED MODULE: ./src/card/header.tsx
@@ -30895,19 +30900,18 @@ function useInputAble(props) {
30895
30900
  var render = useRender(syncValue);
30896
30901
  var shouldUseState = delay || !control;
30897
30902
  var value = shouldUseState ? stateValue : valuePo;
30898
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
30899
- if (context.timer) {
30900
- clearTimeout(context.timer);
30901
- context.timer = null;
30902
- }
30903
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useLayoutEffect)(function () {
30903
30904
  if (delay && props.value !== stateValue) {
30904
30905
  changeStateValue(props.value);
30906
+ } else if (context.timer) {
30907
+ clearTimeout(context.timer);
30908
+ context.timer = null;
30905
30909
  }
30906
30910
  }, [props.value, delay]);
30907
30911
  var forceDelayChange = use_persist_fn(function () {
30908
- if (context.timer && context.delayChange) {
30912
+ if (context.delayChange) context.delayChange();
30913
+ if (context.timer) {
30909
30914
  clearTimeout(context.timer);
30910
- context.delayChange();
30911
30915
  context.timer = null;
30912
30916
  context.delayChange = null;
30913
30917
  }
@@ -46210,7 +46214,9 @@ var input_input_Input = function Input(props) {
46210
46214
  });
46211
46215
  var _useWithFormConfig = use_with_form_config(props),
46212
46216
  size = _useWithFormConfig.size,
46213
- disabled = _useWithFormConfig.disabled;
46217
+ disabled = _useWithFormConfig.disabled,
46218
+ status = _useWithFormConfig.status,
46219
+ error = _useWithFormConfig.error;
46214
46220
  var getProps = function getProps(child) {
46215
46221
  ref.current.propsMap.set(child, {
46216
46222
  onFocus: child.props.onFocus,
@@ -46242,7 +46248,7 @@ var input_input_Input = function Input(props) {
46242
46248
  className = props.className,
46243
46249
  width = props.width,
46244
46250
  style = props.style;
46245
- var rootClass = classnames_default()(className, inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.group, size === 'small' && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupSmall), size === 'large' && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupLarge), !!disabled && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupDisabled), !!focus && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupFocus));
46251
+ var rootClass = classnames_default()(className, inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.group, size === 'small' && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupSmall), size === 'large' && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupLarge), !!disabled && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupDisabled), !!focus && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupFocus), (status === 'error' || error) && (inputStyle === null || inputStyle === void 0 ? void 0 : inputStyle.groupError));
46246
46252
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", objectSpread2_default()(objectSpread2_default()({}, getDataAttribute({
46247
46253
  role: 'input-group'
46248
46254
  })), {}, {
@@ -53259,6 +53265,7 @@ StepsComp.Step = StepsStep;
53259
53265
 
53260
53266
 
53261
53267
 
53268
+
53262
53269
  var sticky_cssSupport = cssSupport;
53263
53270
  var supportSticky = sticky_cssSupport('position', 'sticky');
53264
53271
  var defaultZIndex = 900;
@@ -53284,14 +53291,16 @@ var Sticky = function Sticky(props) {
53284
53291
  var children = props.children,
53285
53292
  top = props.top,
53286
53293
  bottom = props.bottom;
53287
- var css = props.css || props.target;
53294
+ // 是否使用css sticky
53295
+ var css = (props.css || props.target) && supportSticky;
53296
+ var forceUpdate = useRender();
53288
53297
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
53289
53298
  target: null,
53290
53299
  div: null,
53291
- observer: null,
53300
+ position: '',
53301
+ targetObserver: null,
53292
53302
  parentObserver: null,
53293
- isTop: false,
53294
- bodyObserver: null
53303
+ fixedObserver: null
53295
53304
  }),
53296
53305
  context = _useRef.current;
53297
53306
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
@@ -53306,7 +53315,6 @@ var Sticky = function Sticky(props) {
53306
53315
  _useState6 = slicedToArray_default()(_useState5, 2),
53307
53316
  parentVisible = _useState6[0],
53308
53317
  setParentVisible = _useState6[1];
53309
- var forceRender = useRender();
53310
53318
  var elementRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
53311
53319
  var getTarget = function getTarget() {
53312
53320
  var scrollContainer = props.scrollContainer;
@@ -53319,19 +53327,17 @@ var Sticky = function Sticky(props) {
53319
53327
  }
53320
53328
  return null;
53321
53329
  };
53330
+
53331
+ // window resize 时需要重新计算底部附着的位置
53322
53332
  var updateStyle = usePersistFn(function () {
53323
- if (context.div && !context.isTop && show) {
53333
+ if (context.div && context.position === 'bottom' && show) {
53324
53334
  var scrollRect = context.target.getBoundingClientRect();
53325
53335
  var targetRect = elementRef.current.getBoundingClientRect();
53326
53336
  var targetLeft = targetRect.left;
53327
- var width = targetRect.width,
53328
- height = targetRect.height;
53329
53337
  if (typeof bottom === 'number') {
53330
53338
  var outRootRect = context.target.getBoundingClientRect();
53331
53339
  var _style = {
53332
53340
  position: 'absolute',
53333
- width: "".concat(width, "px"),
53334
- height: "".concat(height, "px"),
53335
53341
  top: "".concat(scrollRect.bottom - (props.bottom || 0) - outRootRect.top, "px"),
53336
53342
  left: "".concat(targetLeft - outRootRect.left, "px"),
53337
53343
  transform: 'translateY(-100%)'
@@ -53340,6 +53346,8 @@ var Sticky = function Sticky(props) {
53340
53346
  }
53341
53347
  }
53342
53348
  });
53349
+
53350
+ // 有滚动容器时的定位
53343
53351
  var handleTargetPosition = usePersistFn(function (entries) {
53344
53352
  var entry = entries[0];
53345
53353
  var scrollRect = entry.rootBounds;
@@ -53347,17 +53355,13 @@ var Sticky = function Sticky(props) {
53347
53355
  if (!entry.isIntersecting) {
53348
53356
  var targetLeft = targetRect.left;
53349
53357
  var outRootRect = context.div.getBoundingClientRect();
53350
- var width = targetRect.width,
53351
- height = targetRect.height;
53352
53358
  if (scrollRect && targetRect.bottom < scrollRect.bottom) {
53353
53359
  // top in
53354
- context.isTop = true;
53360
+ context.position = 'top';
53355
53361
  if (typeof top === 'number') {
53356
53362
  setShow(true);
53357
53363
  var _style2 = {
53358
53364
  position: 'absolute',
53359
- width: "".concat(width, "px"),
53360
- height: "".concat(height, "px"),
53361
53365
  top: "".concat(scrollRect.top - outRootRect.top, "px"),
53362
53366
  left: "".concat(targetLeft - outRootRect.left, "px")
53363
53367
  };
@@ -53365,16 +53369,13 @@ var Sticky = function Sticky(props) {
53365
53369
  }
53366
53370
  } else if (scrollRect) {
53367
53371
  // bottom in
53368
- context.isTop = false;
53372
+ context.position = 'bottom';
53369
53373
  if (typeof bottom === 'number') {
53370
53374
  setShow(true);
53371
- var _outRootRect = context.target.getBoundingClientRect();
53372
53375
  var _style3 = {
53373
53376
  position: 'absolute',
53374
- width: "".concat(width, "px"),
53375
- height: "".concat(height, "px"),
53376
- top: "".concat(scrollRect.bottom - _outRootRect.top, "px"),
53377
- left: "".concat(targetLeft - _outRootRect.left, "px"),
53377
+ top: "".concat(scrollRect.bottom - outRootRect.top, "px"),
53378
+ left: "".concat(targetLeft - outRootRect.left, "px"),
53378
53379
  transform: 'translateY(-100%)'
53379
53380
  };
53380
53381
  setStyle(_style3);
@@ -53383,8 +53384,11 @@ var Sticky = function Sticky(props) {
53383
53384
  }
53384
53385
  if (entry.isIntersecting) {
53385
53386
  setShow(false);
53387
+ context.position = '';
53386
53388
  }
53387
53389
  });
53390
+
53391
+ // 父元素是否可见
53388
53392
  var handleParentVisible = usePersistFn(function (entries) {
53389
53393
  var entry = entries[0];
53390
53394
  if (entry.isIntersecting) {
@@ -53393,83 +53397,118 @@ var Sticky = function Sticky(props) {
53393
53397
  setParentVisible(false);
53394
53398
  }
53395
53399
  });
53400
+ var setFixedStyle = usePersistFn(function (s, m) {
53401
+ var l = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
53402
+ if (s !== show) {
53403
+ setShow(s);
53404
+ }
53405
+ if (s && m) {
53406
+ var newStyle = defineProperty_default()(defineProperty_default()({
53407
+ position: 'fixed'
53408
+ }, m, m === 'top' ? top : bottom), "left", l);
53409
+ if (!shallowEqual(style, newStyle)) {
53410
+ setStyle(newStyle);
53411
+ }
53412
+ }
53413
+ });
53414
+
53415
+ // 无滚动容器的时候,body 滚动 resize 计算
53396
53416
  var handleFixedPosition = usePersistFn(function () {
53417
+ if (css || context.target) return;
53397
53418
  var element = elementRef.current;
53419
+ if (!parentVisible) {
53420
+ setFixedStyle(false);
53421
+ return;
53422
+ }
53398
53423
  if (!element) return;
53399
53424
  var selfRect = element.getBoundingClientRect();
53400
53425
  if (selfRect === null) return;
53401
53426
  // If the element is hidden, the width and height will be 0
53402
53427
  if (selfRect && selfRect.width === 0 && selfRect.height === 0) return;
53403
- // const { marginBottom, marginTop } = getComputedStyle(element);
53404
- // selfRect.height += parseFloat(marginBottom) + parseFloat(marginTop);
53405
- var scrollElement = document.body;
53406
- var scrollRect = scrollElement.getBoundingClientRect();
53428
+ var scrollRect = document.body.getBoundingClientRect();
53407
53429
  var top = props.top,
53408
53430
  bottom = props.bottom;
53409
53431
  if (top !== undefined && Math.ceil(selfRect.top) <= top) {
53410
- setShow(true);
53411
- setStyle({
53412
- position: 'fixed',
53413
- top: top,
53414
- left: "".concat(selfRect.left, "px"),
53415
- width: "".concat(selfRect.width, "px")
53416
- });
53432
+ setFixedStyle(true, 'top', selfRect.left);
53417
53433
  return;
53418
53434
  } else if (bottom !== undefined && Math.ceil(selfRect.bottom) + bottom > scrollRect.bottom) {
53419
- setShow(true);
53420
- setStyle({
53421
- position: 'fixed',
53422
- bottom: bottom,
53423
- left: "".concat(selfRect.left, "px"),
53424
- width: "".concat(selfRect.width, "px")
53425
- });
53435
+ setFixedStyle(true, 'bottom', selfRect.left);
53426
53436
  return;
53427
53437
  } else {
53428
- setShow(false);
53438
+ setFixedStyle(false);
53439
+ }
53440
+ });
53441
+
53442
+ // 无滚动容器时内滚场景触发
53443
+ var handleFixedInter = usePersistFn(function (entries) {
53444
+ if (!parentVisible) {
53445
+ setFixedStyle(false);
53446
+ return;
53447
+ }
53448
+ var entry = entries[0];
53449
+ var scrollRect = entry.rootBounds;
53450
+ var targetRect = entry.boundingClientRect;
53451
+ if (scrollRect && scrollRect.top === 0 && scrollRect.bottom === 0) {
53452
+ return;
53453
+ }
53454
+ if (!entry.isIntersecting) {
53455
+ var targetLeft = targetRect.left;
53456
+ var outRootRect = document.body.getBoundingClientRect();
53457
+ if (scrollRect && targetRect.bottom < scrollRect.bottom) {
53458
+ // top in
53459
+ if (typeof top === 'number') {
53460
+ setFixedStyle(true, 'top', targetLeft - outRootRect.left);
53461
+ }
53462
+ } else if (scrollRect) {
53463
+ // bottom in
53464
+ if (typeof bottom === 'number') {
53465
+ setFixedStyle(true, 'bottom', targetLeft - outRootRect.left);
53466
+ }
53467
+ }
53468
+ }
53469
+ if (entry.isIntersecting) {
53470
+ setFixedStyle(false);
53429
53471
  }
53430
53472
  });
53431
53473
  var elementSize = useResize({
53432
53474
  targetRef: elementRef,
53433
- timer: 0,
53475
+ timer: 10,
53434
53476
  cb: handleFixedPosition
53435
53477
  });
53436
- var createBodyObserver = function createBodyObserver() {
53437
- if (context.bodyObserver) {
53438
- context.bodyObserver.disconnect();
53478
+ var cancelFixedObserver = function cancelFixedObserver() {
53479
+ if (context.fixedObserver) {
53480
+ context.fixedObserver.disconnect();
53481
+ context.fixedObserver = null;
53439
53482
  }
53440
- context.bodyObserver = new IntersectionObserver(handleFixedPosition, {
53483
+ };
53484
+ var createFixedObserver = function createFixedObserver() {
53485
+ cancelFixedObserver();
53486
+ context.fixedObserver = new IntersectionObserver(handleFixedInter, {
53441
53487
  root: null,
53442
53488
  rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53443
53489
  threshold: 1.0
53444
53490
  });
53445
- context.bodyObserver.observe(elementRef.current);
53446
53491
  };
53447
53492
  var cancelObserver = function cancelObserver() {
53448
- if (context.observer) {
53449
- context.observer.disconnect();
53450
- context.observer = null;
53451
- }
53452
- if (context.parentObserver) {
53453
- context.parentObserver.disconnect();
53454
- context.parentObserver = null;
53493
+ if (context.targetObserver) {
53494
+ context.targetObserver.disconnect();
53495
+ context.targetObserver = null;
53455
53496
  }
53456
53497
  };
53457
- var createObserver = function createObserver(target) {
53498
+ var createObserver = function createObserver() {
53458
53499
  if (!context.div) {
53459
53500
  context.div = document.createElement('div');
53460
53501
  context.div.style.position = 'relative';
53461
53502
  }
53462
- if (target) {
53463
- forceRender();
53464
- cancelObserver();
53503
+ if (context.target) {
53465
53504
  if (context.div) {
53466
53505
  // append div
53467
- if (target === document.body) {
53468
- document.body.appendChild(context.div);
53506
+ if (context.target === document.body) {
53507
+ document.body.insertBefore(context.div, document.body.firstChild);
53469
53508
  } else {
53470
- target.parentNode.insertBefore(context.div, target);
53509
+ context.target.parentNode.insertBefore(context.div, context.target);
53471
53510
  }
53472
- var _style4 = window.getComputedStyle(target);
53511
+ var _style4 = window.getComputedStyle(context.target);
53473
53512
  if (_style4.position === 'absolute' || _style4.position === 'fixed') {
53474
53513
  context.div.style.position = _style4.position;
53475
53514
  context.div.style.top = _style4.top;
@@ -53478,76 +53517,109 @@ var Sticky = function Sticky(props) {
53478
53517
  context.div.style.bottom = _style4.bottom;
53479
53518
  }
53480
53519
  }
53520
+ cancelFixedObserver();
53481
53521
  if (window.IntersectionObserver) {
53482
53522
  var observer = new IntersectionObserver(handleTargetPosition, {
53483
- root: target,
53523
+ root: context.target,
53484
53524
  rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53485
53525
  threshold: 1.0
53486
53526
  });
53487
- context.observer = observer;
53488
- context.parentObserver = new IntersectionObserver(handleParentVisible, {
53489
- root: target,
53490
- rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53491
- threshold: 0
53492
- });
53527
+ context.targetObserver = observer;
53493
53528
  }
53494
53529
  }
53495
53530
  };
53531
+ var cancelParentObserver = function cancelParentObserver() {
53532
+ if (context.parentObserver) {
53533
+ context.parentObserver.disconnect();
53534
+ context.parentObserver = null;
53535
+ }
53536
+ };
53537
+ var createParentObserver = function createParentObserver() {
53538
+ if (!props.parent) return;
53539
+ cancelParentObserver();
53540
+ context.parentObserver = new IntersectionObserver(handleParentVisible, {
53541
+ root: context.target,
53542
+ rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53543
+ threshold: 0
53544
+ });
53545
+ context.parentObserver.observe(props.parent);
53546
+ };
53547
+
53548
+ // 存在滚动容器时的定位
53549
+ var createTargetEvents = function createTargetEvents() {
53550
+ createObserver();
53551
+ window.addEventListener('resize', updateStyle);
53552
+ };
53553
+ var cancelTargetEvents = function cancelTargetEvents() {
53554
+ cancelObserver();
53555
+ window.removeEventListener('resize', updateStyle);
53556
+ if (context.div) {
53557
+ context.div.remove();
53558
+ context.div = null;
53559
+ }
53560
+ };
53561
+ var createFixedEvents = function createFixedEvents() {
53562
+ createFixedObserver();
53563
+ events.forEach(function (event) {
53564
+ window.addEventListener(event, handleFixedPosition);
53565
+ });
53566
+ };
53567
+ var cancelFixedEvents = function cancelFixedEvents() {
53568
+ cancelFixedObserver();
53569
+ events.forEach(function (event) {
53570
+ window.removeEventListener(event, handleFixedPosition);
53571
+ });
53572
+ };
53496
53573
  var handleElementRef = function handleElementRef(el) {
53497
53574
  if (el) {
53498
53575
  elementRef.current = el;
53499
- if (el && context.observer) {
53500
- context.observer.observe(el);
53576
+ if (context.targetObserver) {
53577
+ if (!el) {
53578
+ context.targetObserver.disconnect();
53579
+ } else {
53580
+ context.targetObserver.observe(el);
53581
+ }
53582
+ }
53583
+ if (context.fixedObserver) {
53584
+ if (!el) {
53585
+ context.fixedObserver.disconnect();
53586
+ } else {
53587
+ context.fixedObserver.observe(el);
53588
+ }
53501
53589
  }
53502
53590
  }
53503
53591
  };
53504
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
53592
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useLayoutEffect)(function () {
53505
53593
  if (css) return;
53506
53594
  var target = getTarget();
53507
- context.target = target;
53508
- if (target) {
53509
- createObserver(target);
53510
- window.addEventListener('resize', updateStyle);
53511
- return function () {
53512
- cancelObserver();
53513
- window.removeEventListener('resize', updateStyle);
53514
- if (context.div) {
53515
- context.div.remove();
53516
- }
53517
- };
53595
+ if (context.target !== target) {
53596
+ context.target = target;
53597
+ forceUpdate();
53598
+ }
53599
+ if (context.target) {
53600
+ createTargetEvents();
53601
+ return cancelTargetEvents;
53518
53602
  } else {
53519
53603
  // fixed 布局
53520
- createBodyObserver();
53521
- events.forEach(function (event) {
53522
- window.addEventListener(event, handleFixedPosition);
53523
- });
53524
- return function () {
53525
- if (context.bodyObserver) {
53526
- context.bodyObserver.disconnect();
53527
- }
53528
- events.forEach(function (event) {
53529
- window.removeEventListener(event, handleFixedPosition);
53530
- });
53531
- };
53604
+ createFixedEvents();
53605
+ return cancelFixedEvents;
53532
53606
  }
53533
- }, [css]);
53534
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
53535
- if (props.parent && context.parentObserver) {
53607
+ }, [css, top, bottom]);
53608
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useLayoutEffect)(function () {
53609
+ if (props.parent && !css) {
53610
+ // createParentObserver 用到context.target
53611
+ createParentObserver();
53536
53612
  context.parentObserver.observe(props.parent);
53537
53613
  }
53538
- return function () {
53539
- if (context.parentObserver) {
53540
- context.parentObserver.disconnect();
53541
- }
53542
- };
53543
- }, [props.parent]);
53614
+ return cancelParentObserver;
53615
+ }, [props.parent, css, context.target, top, bottom]);
53544
53616
 
53545
53617
  // 纯css方法 直接使用css
53546
53618
  // js方法
53547
53619
  // 1. 不指定滚动容器 基于document.body 使用fixed + js计算
53548
53620
  // 2. 指定滚动容器 在滚动容器上方插入一个dom占位 基于该dom渲染和定位
53549
53621
  // 3. 使用 intersectionObserver 来判断是否需要sticky
53550
- if (css && supportSticky) {
53622
+ if (css) {
53551
53623
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
53552
53624
  className: props.className,
53553
53625
  style: objectSpread2_default()(objectSpread2_default()({
@@ -58954,10 +59026,9 @@ var useUpload = function useUpload(props) {
58954
59026
  });
58955
59027
  });
58956
59028
  };
58957
- var getCurrent = use_persist_fn(function () {
58958
- return {
58959
- filesState: filesState
58960
- };
59029
+ var latestState = use_latest_obj({
59030
+ filesState: filesState,
59031
+ value: value
58961
59032
  });
58962
59033
  var uploadFile = function uploadFile(id, file, data) {
58963
59034
  var request = props.request || xhr;
@@ -58978,8 +59049,7 @@ var useUpload = function useUpload(props) {
58978
59049
  throttle = false;
58979
59050
  }, 16);
58980
59051
  var percent = typeof e.percent === 'number' ? e.percent : e.loaded / e.total * 100;
58981
- var _getCurrent = getCurrent(),
58982
- filesState = _getCurrent.filesState;
59052
+ var filesState = latestState.filesState;
58983
59053
  var newFiles = objectSpread2_default()({}, filesState);
58984
59054
  if (!newFiles[id]) return;
58985
59055
  newFiles[id].process = percent;
@@ -59016,7 +59086,7 @@ var useUpload = function useUpload(props) {
59016
59086
  });
59017
59087
  });
59018
59088
  // add value
59019
- var values = utils_immer_produce(value, function (draft) {
59089
+ var values = utils_immer_produce(latestState.value, function (draft) {
59020
59090
  draft.push(result);
59021
59091
  });
59022
59092
  props.onChange(values);
@@ -59069,7 +59139,7 @@ var useUpload = function useUpload(props) {
59069
59139
  reader.readAsDataURL(blob);
59070
59140
  });
59071
59141
  };
59072
- var addFiles = /*#__PURE__*/function () {
59142
+ var addFiles = use_persist_fn( /*#__PURE__*/function () {
59073
59143
  var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(files) {
59074
59144
  var fileList, newFiles, resetLength, list, _loop, _ret, i;
59075
59145
  return regeneratorRuntime_default()().wrap(function _callee2$(_context3) {
@@ -59208,11 +59278,11 @@ var useUpload = function useUpload(props) {
59208
59278
  }
59209
59279
  }, _callee2);
59210
59280
  }));
59211
- return function addFiles(_x3) {
59281
+ return function (_x3) {
59212
59282
  return _ref2.apply(this, arguments);
59213
59283
  };
59214
- }();
59215
- var removeFile = function removeFile(id) {
59284
+ }());
59285
+ var removeFile = use_persist_fn(function (id) {
59216
59286
  var beforeCancel = props.beforeCancel,
59217
59287
  onErrorRemove = props.onErrorRemove;
59218
59288
  var file = filesState[id];
@@ -59230,8 +59300,8 @@ var useUpload = function useUpload(props) {
59230
59300
  onErrorRemove(file.xhr, file.blob, file);
59231
59301
  }
59232
59302
  }
59233
- };
59234
- var removeValue = function removeValue(index) {
59303
+ });
59304
+ var removeValue = use_persist_fn(function (index) {
59235
59305
  if (props.disabled) return;
59236
59306
  var recoverAble = props.recoverAble,
59237
59307
  beforeRemove = props.beforeRemove;
@@ -59243,15 +59313,15 @@ var useUpload = function useUpload(props) {
59243
59313
  newRecycle.push(value[index]);
59244
59314
  }
59245
59315
  setRecycleValues(newRecycle);
59246
- var newValue = utils_immer_produce(props.value, function (draft) {
59316
+ var newValue = utils_immer_produce(latestState.value, function (draft) {
59247
59317
  draft.splice(index, 1);
59248
59318
  });
59249
59319
  props.onChange(newValue);
59250
59320
  }).catch(function () {});
59251
- };
59252
- var recoverValue = function recoverValue(index) {
59321
+ });
59322
+ var recoverValue = use_persist_fn(function (index) {
59253
59323
  if (props.disabled) return;
59254
- props.onChange(utils_immer_produce(props.value, function (draft) {
59324
+ props.onChange(utils_immer_produce(latestState.value, function (draft) {
59255
59325
  draft.push(recycleValues[index]);
59256
59326
  }));
59257
59327
  setRecycleValues(function (pre) {
@@ -59259,7 +59329,7 @@ var useUpload = function useUpload(props) {
59259
59329
  newRecycle.splice(index, 1);
59260
59330
  return newRecycle;
59261
59331
  });
59262
- };
59332
+ });
59263
59333
  var func = use_latest_obj({
59264
59334
  addFiles: addFiles,
59265
59335
  removeFile: removeFile,
@@ -62264,7 +62334,7 @@ var upload_interface = __webpack_require__(4412);
62264
62334
 
62265
62335
 
62266
62336
  /* harmony default export */ var src_0 = ({
62267
- version: '3.1.15'
62337
+ version: '3.1.16-fix.1'
62268
62338
  });
62269
62339
  }();
62270
62340
  /******/ return __webpack_exports__;