shineout 3.1.15 → 3.1.16

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'
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');
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
@@ -46210,7 +46215,9 @@ var input_input_Input = function Input(props) {
46210
46215
  });
46211
46216
  var _useWithFormConfig = use_with_form_config(props),
46212
46217
  size = _useWithFormConfig.size,
46213
- disabled = _useWithFormConfig.disabled;
46218
+ disabled = _useWithFormConfig.disabled,
46219
+ status = _useWithFormConfig.status,
46220
+ error = _useWithFormConfig.error;
46214
46221
  var getProps = function getProps(child) {
46215
46222
  ref.current.propsMap.set(child, {
46216
46223
  onFocus: child.props.onFocus,
@@ -46242,7 +46249,7 @@ var input_input_Input = function Input(props) {
46242
46249
  className = props.className,
46243
46250
  width = props.width,
46244
46251
  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));
46252
+ 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
46253
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", objectSpread2_default()(objectSpread2_default()({}, getDataAttribute({
46247
46254
  role: 'input-group'
46248
46255
  })), {}, {
@@ -53259,6 +53266,7 @@ StepsComp.Step = StepsStep;
53259
53266
 
53260
53267
 
53261
53268
 
53269
+
53262
53270
  var sticky_cssSupport = cssSupport;
53263
53271
  var supportSticky = sticky_cssSupport('position', 'sticky');
53264
53272
  var defaultZIndex = 900;
@@ -53284,14 +53292,16 @@ var Sticky = function Sticky(props) {
53284
53292
  var children = props.children,
53285
53293
  top = props.top,
53286
53294
  bottom = props.bottom;
53287
- var css = props.css || props.target;
53295
+ // 是否使用css sticky
53296
+ var css = (props.css || props.target) && supportSticky;
53297
+ var forceUpdate = useRender();
53288
53298
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
53289
53299
  target: null,
53290
53300
  div: null,
53291
- observer: null,
53301
+ position: '',
53302
+ targetObserver: null,
53292
53303
  parentObserver: null,
53293
- isTop: false,
53294
- bodyObserver: null
53304
+ fixedObserver: null
53295
53305
  }),
53296
53306
  context = _useRef.current;
53297
53307
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
@@ -53306,7 +53316,6 @@ var Sticky = function Sticky(props) {
53306
53316
  _useState6 = slicedToArray_default()(_useState5, 2),
53307
53317
  parentVisible = _useState6[0],
53308
53318
  setParentVisible = _useState6[1];
53309
- var forceRender = useRender();
53310
53319
  var elementRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
53311
53320
  var getTarget = function getTarget() {
53312
53321
  var scrollContainer = props.scrollContainer;
@@ -53319,19 +53328,17 @@ var Sticky = function Sticky(props) {
53319
53328
  }
53320
53329
  return null;
53321
53330
  };
53331
+
53332
+ // window resize 时需要重新计算底部附着的位置
53322
53333
  var updateStyle = usePersistFn(function () {
53323
- if (context.div && !context.isTop && show) {
53334
+ if (context.div && context.position === 'bottom' && show) {
53324
53335
  var scrollRect = context.target.getBoundingClientRect();
53325
53336
  var targetRect = elementRef.current.getBoundingClientRect();
53326
53337
  var targetLeft = targetRect.left;
53327
- var width = targetRect.width,
53328
- height = targetRect.height;
53329
53338
  if (typeof bottom === 'number') {
53330
53339
  var outRootRect = context.target.getBoundingClientRect();
53331
53340
  var _style = {
53332
53341
  position: 'absolute',
53333
- width: "".concat(width, "px"),
53334
- height: "".concat(height, "px"),
53335
53342
  top: "".concat(scrollRect.bottom - (props.bottom || 0) - outRootRect.top, "px"),
53336
53343
  left: "".concat(targetLeft - outRootRect.left, "px"),
53337
53344
  transform: 'translateY(-100%)'
@@ -53340,6 +53347,8 @@ var Sticky = function Sticky(props) {
53340
53347
  }
53341
53348
  }
53342
53349
  });
53350
+
53351
+ // 有滚动容器时的定位
53343
53352
  var handleTargetPosition = usePersistFn(function (entries) {
53344
53353
  var entry = entries[0];
53345
53354
  var scrollRect = entry.rootBounds;
@@ -53347,17 +53356,13 @@ var Sticky = function Sticky(props) {
53347
53356
  if (!entry.isIntersecting) {
53348
53357
  var targetLeft = targetRect.left;
53349
53358
  var outRootRect = context.div.getBoundingClientRect();
53350
- var width = targetRect.width,
53351
- height = targetRect.height;
53352
53359
  if (scrollRect && targetRect.bottom < scrollRect.bottom) {
53353
53360
  // top in
53354
- context.isTop = true;
53361
+ context.position = 'top';
53355
53362
  if (typeof top === 'number') {
53356
53363
  setShow(true);
53357
53364
  var _style2 = {
53358
53365
  position: 'absolute',
53359
- width: "".concat(width, "px"),
53360
- height: "".concat(height, "px"),
53361
53366
  top: "".concat(scrollRect.top - outRootRect.top, "px"),
53362
53367
  left: "".concat(targetLeft - outRootRect.left, "px")
53363
53368
  };
@@ -53365,16 +53370,13 @@ var Sticky = function Sticky(props) {
53365
53370
  }
53366
53371
  } else if (scrollRect) {
53367
53372
  // bottom in
53368
- context.isTop = false;
53373
+ context.position = 'bottom';
53369
53374
  if (typeof bottom === 'number') {
53370
53375
  setShow(true);
53371
- var _outRootRect = context.target.getBoundingClientRect();
53372
53376
  var _style3 = {
53373
53377
  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"),
53378
+ top: "".concat(scrollRect.bottom - outRootRect.top, "px"),
53379
+ left: "".concat(targetLeft - outRootRect.left, "px"),
53378
53380
  transform: 'translateY(-100%)'
53379
53381
  };
53380
53382
  setStyle(_style3);
@@ -53383,8 +53385,11 @@ var Sticky = function Sticky(props) {
53383
53385
  }
53384
53386
  if (entry.isIntersecting) {
53385
53387
  setShow(false);
53388
+ context.position = '';
53386
53389
  }
53387
53390
  });
53391
+
53392
+ // 父元素是否可见
53388
53393
  var handleParentVisible = usePersistFn(function (entries) {
53389
53394
  var entry = entries[0];
53390
53395
  if (entry.isIntersecting) {
@@ -53393,83 +53398,118 @@ var Sticky = function Sticky(props) {
53393
53398
  setParentVisible(false);
53394
53399
  }
53395
53400
  });
53401
+ var setFixedStyle = usePersistFn(function (s, m) {
53402
+ var l = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
53403
+ if (s !== show) {
53404
+ setShow(s);
53405
+ }
53406
+ if (s && m) {
53407
+ var newStyle = defineProperty_default()(defineProperty_default()({
53408
+ position: 'fixed'
53409
+ }, m, m === 'top' ? top : bottom), "left", l);
53410
+ if (!shallowEqual(style, newStyle)) {
53411
+ setStyle(newStyle);
53412
+ }
53413
+ }
53414
+ });
53415
+
53416
+ // 无滚动容器的时候,body 滚动 resize 计算
53396
53417
  var handleFixedPosition = usePersistFn(function () {
53418
+ if (css || context.target) return;
53397
53419
  var element = elementRef.current;
53420
+ if (!parentVisible) {
53421
+ setFixedStyle(false);
53422
+ return;
53423
+ }
53398
53424
  if (!element) return;
53399
53425
  var selfRect = element.getBoundingClientRect();
53400
53426
  if (selfRect === null) return;
53401
53427
  // If the element is hidden, the width and height will be 0
53402
53428
  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();
53429
+ var scrollRect = document.body.getBoundingClientRect();
53407
53430
  var top = props.top,
53408
53431
  bottom = props.bottom;
53409
53432
  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
- });
53433
+ setFixedStyle(true, 'top', selfRect.left);
53417
53434
  return;
53418
53435
  } 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
- });
53436
+ setFixedStyle(true, 'bottom', selfRect.left);
53426
53437
  return;
53427
53438
  } else {
53428
- setShow(false);
53439
+ setFixedStyle(false);
53440
+ }
53441
+ });
53442
+
53443
+ // 无滚动容器时内滚场景触发
53444
+ var handleFixedInter = usePersistFn(function (entries) {
53445
+ if (!parentVisible) {
53446
+ setFixedStyle(false);
53447
+ return;
53448
+ }
53449
+ var entry = entries[0];
53450
+ var scrollRect = entry.rootBounds;
53451
+ var targetRect = entry.boundingClientRect;
53452
+ if (scrollRect && scrollRect.top === 0 && scrollRect.bottom === 0) {
53453
+ return;
53454
+ }
53455
+ if (!entry.isIntersecting) {
53456
+ var targetLeft = targetRect.left;
53457
+ var outRootRect = document.body.getBoundingClientRect();
53458
+ if (scrollRect && targetRect.bottom < scrollRect.bottom) {
53459
+ // top in
53460
+ if (typeof top === 'number') {
53461
+ setFixedStyle(true, 'top', targetLeft - outRootRect.left);
53462
+ }
53463
+ } else if (scrollRect) {
53464
+ // bottom in
53465
+ if (typeof bottom === 'number') {
53466
+ setFixedStyle(true, 'bottom', targetLeft - outRootRect.left);
53467
+ }
53468
+ }
53469
+ }
53470
+ if (entry.isIntersecting) {
53471
+ setFixedStyle(false);
53429
53472
  }
53430
53473
  });
53431
53474
  var elementSize = useResize({
53432
53475
  targetRef: elementRef,
53433
- timer: 0,
53476
+ timer: 10,
53434
53477
  cb: handleFixedPosition
53435
53478
  });
53436
- var createBodyObserver = function createBodyObserver() {
53437
- if (context.bodyObserver) {
53438
- context.bodyObserver.disconnect();
53479
+ var cancelFixedObserver = function cancelFixedObserver() {
53480
+ if (context.fixedObserver) {
53481
+ context.fixedObserver.disconnect();
53482
+ context.fixedObserver = null;
53439
53483
  }
53440
- context.bodyObserver = new IntersectionObserver(handleFixedPosition, {
53484
+ };
53485
+ var createFixedObserver = function createFixedObserver() {
53486
+ cancelFixedObserver();
53487
+ context.fixedObserver = new IntersectionObserver(handleFixedInter, {
53441
53488
  root: null,
53442
53489
  rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53443
53490
  threshold: 1.0
53444
53491
  });
53445
- context.bodyObserver.observe(elementRef.current);
53446
53492
  };
53447
53493
  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;
53494
+ if (context.targetObserver) {
53495
+ context.targetObserver.disconnect();
53496
+ context.targetObserver = null;
53455
53497
  }
53456
53498
  };
53457
- var createObserver = function createObserver(target) {
53499
+ var createObserver = function createObserver() {
53458
53500
  if (!context.div) {
53459
53501
  context.div = document.createElement('div');
53460
53502
  context.div.style.position = 'relative';
53461
53503
  }
53462
- if (target) {
53463
- forceRender();
53464
- cancelObserver();
53504
+ if (context.target) {
53465
53505
  if (context.div) {
53466
53506
  // append div
53467
- if (target === document.body) {
53468
- document.body.appendChild(context.div);
53507
+ if (context.target === document.body) {
53508
+ document.body.insertBefore(context.div, document.body.firstChild);
53469
53509
  } else {
53470
- target.parentNode.insertBefore(context.div, target);
53510
+ context.target.parentNode.insertBefore(context.div, context.target);
53471
53511
  }
53472
- var _style4 = window.getComputedStyle(target);
53512
+ var _style4 = window.getComputedStyle(context.target);
53473
53513
  if (_style4.position === 'absolute' || _style4.position === 'fixed') {
53474
53514
  context.div.style.position = _style4.position;
53475
53515
  context.div.style.top = _style4.top;
@@ -53478,76 +53518,109 @@ var Sticky = function Sticky(props) {
53478
53518
  context.div.style.bottom = _style4.bottom;
53479
53519
  }
53480
53520
  }
53521
+ cancelFixedObserver();
53481
53522
  if (window.IntersectionObserver) {
53482
53523
  var observer = new IntersectionObserver(handleTargetPosition, {
53483
- root: target,
53524
+ root: context.target,
53484
53525
  rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53485
53526
  threshold: 1.0
53486
53527
  });
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
- });
53528
+ context.targetObserver = observer;
53493
53529
  }
53494
53530
  }
53495
53531
  };
53532
+ var cancelParentObserver = function cancelParentObserver() {
53533
+ if (context.parentObserver) {
53534
+ context.parentObserver.disconnect();
53535
+ context.parentObserver = null;
53536
+ }
53537
+ };
53538
+ var createParentObserver = function createParentObserver() {
53539
+ if (!props.parent) return;
53540
+ cancelParentObserver();
53541
+ context.parentObserver = new IntersectionObserver(handleParentVisible, {
53542
+ root: context.target,
53543
+ rootMargin: "-".concat(top || 0, "px 0px -").concat(bottom || 0, "px 0px"),
53544
+ threshold: 0
53545
+ });
53546
+ context.parentObserver.observe(props.parent);
53547
+ };
53548
+
53549
+ // 存在滚动容器时的定位
53550
+ var createTargetEvents = function createTargetEvents() {
53551
+ createObserver();
53552
+ window.addEventListener('resize', updateStyle);
53553
+ };
53554
+ var cancelTargetEvents = function cancelTargetEvents() {
53555
+ cancelObserver();
53556
+ window.removeEventListener('resize', updateStyle);
53557
+ if (context.div) {
53558
+ context.div.remove();
53559
+ context.div = null;
53560
+ }
53561
+ };
53562
+ var createFixedEvents = function createFixedEvents() {
53563
+ createFixedObserver();
53564
+ events.forEach(function (event) {
53565
+ window.addEventListener(event, handleFixedPosition);
53566
+ });
53567
+ };
53568
+ var cancelFixedEvents = function cancelFixedEvents() {
53569
+ cancelFixedObserver();
53570
+ events.forEach(function (event) {
53571
+ window.removeEventListener(event, handleFixedPosition);
53572
+ });
53573
+ };
53496
53574
  var handleElementRef = function handleElementRef(el) {
53497
53575
  if (el) {
53498
53576
  elementRef.current = el;
53499
- if (el && context.observer) {
53500
- context.observer.observe(el);
53577
+ if (context.targetObserver) {
53578
+ if (!el) {
53579
+ context.targetObserver.disconnect();
53580
+ } else {
53581
+ context.targetObserver.observe(el);
53582
+ }
53583
+ }
53584
+ if (context.fixedObserver) {
53585
+ if (!el) {
53586
+ context.fixedObserver.disconnect();
53587
+ } else {
53588
+ context.fixedObserver.observe(el);
53589
+ }
53501
53590
  }
53502
53591
  }
53503
53592
  };
53504
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
53593
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useLayoutEffect)(function () {
53505
53594
  if (css) return;
53506
53595
  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
- };
53596
+ if (context.target !== target) {
53597
+ context.target = target;
53598
+ forceUpdate();
53599
+ }
53600
+ if (context.target) {
53601
+ createTargetEvents();
53602
+ return cancelTargetEvents;
53518
53603
  } else {
53519
53604
  // 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
- };
53605
+ createFixedEvents();
53606
+ return cancelFixedEvents;
53532
53607
  }
53533
- }, [css]);
53534
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
53535
- if (props.parent && context.parentObserver) {
53608
+ }, [css, top, bottom]);
53609
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useLayoutEffect)(function () {
53610
+ if (props.parent && !css) {
53611
+ // createParentObserver 用到context.target
53612
+ createParentObserver();
53536
53613
  context.parentObserver.observe(props.parent);
53537
53614
  }
53538
- return function () {
53539
- if (context.parentObserver) {
53540
- context.parentObserver.disconnect();
53541
- }
53542
- };
53543
- }, [props.parent]);
53615
+ return cancelParentObserver;
53616
+ }, [props.parent, css, context.target, top, bottom]);
53544
53617
 
53545
53618
  // 纯css方法 直接使用css
53546
53619
  // js方法
53547
53620
  // 1. 不指定滚动容器 基于document.body 使用fixed + js计算
53548
53621
  // 2. 指定滚动容器 在滚动容器上方插入一个dom占位 基于该dom渲染和定位
53549
53622
  // 3. 使用 intersectionObserver 来判断是否需要sticky
53550
- if (css && supportSticky) {
53623
+ if (css) {
53551
53624
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
53552
53625
  className: props.className,
53553
53626
  style: objectSpread2_default()(objectSpread2_default()({
@@ -58954,10 +59027,9 @@ var useUpload = function useUpload(props) {
58954
59027
  });
58955
59028
  });
58956
59029
  };
58957
- var getCurrent = use_persist_fn(function () {
58958
- return {
58959
- filesState: filesState
58960
- };
59030
+ var latestState = use_latest_obj({
59031
+ filesState: filesState,
59032
+ value: value
58961
59033
  });
58962
59034
  var uploadFile = function uploadFile(id, file, data) {
58963
59035
  var request = props.request || xhr;
@@ -58978,8 +59050,7 @@ var useUpload = function useUpload(props) {
58978
59050
  throttle = false;
58979
59051
  }, 16);
58980
59052
  var percent = typeof e.percent === 'number' ? e.percent : e.loaded / e.total * 100;
58981
- var _getCurrent = getCurrent(),
58982
- filesState = _getCurrent.filesState;
59053
+ var filesState = latestState.filesState;
58983
59054
  var newFiles = objectSpread2_default()({}, filesState);
58984
59055
  if (!newFiles[id]) return;
58985
59056
  newFiles[id].process = percent;
@@ -59016,7 +59087,7 @@ var useUpload = function useUpload(props) {
59016
59087
  });
59017
59088
  });
59018
59089
  // add value
59019
- var values = utils_immer_produce(value, function (draft) {
59090
+ var values = utils_immer_produce(latestState.value, function (draft) {
59020
59091
  draft.push(result);
59021
59092
  });
59022
59093
  props.onChange(values);
@@ -59069,7 +59140,7 @@ var useUpload = function useUpload(props) {
59069
59140
  reader.readAsDataURL(blob);
59070
59141
  });
59071
59142
  };
59072
- var addFiles = /*#__PURE__*/function () {
59143
+ var addFiles = use_persist_fn( /*#__PURE__*/function () {
59073
59144
  var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(files) {
59074
59145
  var fileList, newFiles, resetLength, list, _loop, _ret, i;
59075
59146
  return regeneratorRuntime_default()().wrap(function _callee2$(_context3) {
@@ -59208,11 +59279,11 @@ var useUpload = function useUpload(props) {
59208
59279
  }
59209
59280
  }, _callee2);
59210
59281
  }));
59211
- return function addFiles(_x3) {
59282
+ return function (_x3) {
59212
59283
  return _ref2.apply(this, arguments);
59213
59284
  };
59214
- }();
59215
- var removeFile = function removeFile(id) {
59285
+ }());
59286
+ var removeFile = use_persist_fn(function (id) {
59216
59287
  var beforeCancel = props.beforeCancel,
59217
59288
  onErrorRemove = props.onErrorRemove;
59218
59289
  var file = filesState[id];
@@ -59230,8 +59301,8 @@ var useUpload = function useUpload(props) {
59230
59301
  onErrorRemove(file.xhr, file.blob, file);
59231
59302
  }
59232
59303
  }
59233
- };
59234
- var removeValue = function removeValue(index) {
59304
+ });
59305
+ var removeValue = use_persist_fn(function (index) {
59235
59306
  if (props.disabled) return;
59236
59307
  var recoverAble = props.recoverAble,
59237
59308
  beforeRemove = props.beforeRemove;
@@ -59243,15 +59314,15 @@ var useUpload = function useUpload(props) {
59243
59314
  newRecycle.push(value[index]);
59244
59315
  }
59245
59316
  setRecycleValues(newRecycle);
59246
- var newValue = utils_immer_produce(props.value, function (draft) {
59317
+ var newValue = utils_immer_produce(latestState.value, function (draft) {
59247
59318
  draft.splice(index, 1);
59248
59319
  });
59249
59320
  props.onChange(newValue);
59250
59321
  }).catch(function () {});
59251
- };
59252
- var recoverValue = function recoverValue(index) {
59322
+ });
59323
+ var recoverValue = use_persist_fn(function (index) {
59253
59324
  if (props.disabled) return;
59254
- props.onChange(utils_immer_produce(props.value, function (draft) {
59325
+ props.onChange(utils_immer_produce(latestState.value, function (draft) {
59255
59326
  draft.push(recycleValues[index]);
59256
59327
  }));
59257
59328
  setRecycleValues(function (pre) {
@@ -59259,7 +59330,7 @@ var useUpload = function useUpload(props) {
59259
59330
  newRecycle.splice(index, 1);
59260
59331
  return newRecycle;
59261
59332
  });
59262
- };
59333
+ });
59263
59334
  var func = use_latest_obj({
59264
59335
  addFiles: addFiles,
59265
59336
  removeFile: removeFile,
@@ -62264,7 +62335,7 @@ var upload_interface = __webpack_require__(4412);
62264
62335
 
62265
62336
 
62266
62337
  /* harmony default export */ var src_0 = ({
62267
- version: '3.1.15'
62338
+ version: '3.1.16'
62268
62339
  });
62269
62340
  }();
62270
62341
  /******/ return __webpack_exports__;