shineout 3.9.0-beta.11 → 3.9.0-beta.12

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.
package/cjs/index.js CHANGED
@@ -522,5 +522,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
522
522
  // 此文件由脚本自动生成,请勿直接修改。
523
523
  // This file was generated automatically by a script. Please do not modify it directly.
524
524
  var _default = exports.default = {
525
- version: '3.9.0-beta.11'
525
+ version: '3.9.0-beta.12'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12386,7 +12386,7 @@ var handleStyle = function handleStyle(style) {
12386
12386
  };
12387
12387
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12388
12388
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12389
- /* harmony default export */ var version = ('3.9.0-beta.11');
12389
+ /* harmony default export */ var version = ('3.9.0-beta.12');
12390
12390
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12391
12391
 
12392
12392
 
@@ -33720,7 +33720,15 @@ var BreadcrumbItem = function BreadcrumbItem(_ref) {
33720
33720
  }
33721
33721
  }
33722
33722
  if (renderItem) {
33723
- return renderItem(dataItem);
33723
+ if (max !== undefined) {
33724
+ item = /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
33725
+ className: contentClass,
33726
+ ref: contentRef,
33727
+ children: renderItem(dataItem)
33728
+ });
33729
+ } else {
33730
+ return renderItem(dataItem);
33731
+ }
33724
33732
  }
33725
33733
  if (isOverflow && d.title && max !== undefined) {
33726
33734
  return /*#__PURE__*/(0,jsx_runtime.jsx)(src_tooltip_tooltip, {
@@ -33798,17 +33806,18 @@ var Breadcrumb = function Breadcrumb(props) {
33798
33806
  };
33799
33807
  return [first, more].concat(toConsumableArray_default()(reset));
33800
33808
  };
33809
+ var lastIndex = Math.min(data.length - 1, maxCount !== undefined ? maxCount : data.length - 1);
33801
33810
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
33802
33811
  className: className,
33803
33812
  style: props.style,
33804
33813
  children: data && getRenderData().map(function (d, index) {
33805
33814
  var itemFirst = Array.isArray(d) ? d[0] : d;
33806
- var isLastItem = index === (maxCount !== undefined ? maxCount : data.length - 1);
33815
+ var isLastItem = index === lastIndex;
33807
33816
  return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
33808
33817
  className: breadcrumbClasses === null || breadcrumbClasses === void 0 ? void 0 : breadcrumbClasses.item,
33809
33818
  children: [Array.isArray(d) ? renderArray(d) : /*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb_item, {
33810
33819
  dataItem: d,
33811
- renderItem: renderItem,
33820
+ renderItem: props.renderItem,
33812
33821
  jssStyle: props.jssStyle,
33813
33822
  max: maxCount
33814
33823
  }), !isLastItem && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
@@ -37757,9 +37766,21 @@ CardGroupComp.Item = card_group_Item;
37757
37766
  var useCarousel = function useCarousel(props) {
37758
37767
  var total = props.total,
37759
37768
  _props$interval = props.interval,
37760
- interval = _props$interval === void 0 ? 0 : _props$interval;
37769
+ interval = _props$interval === void 0 ? 0 : _props$interval,
37770
+ _props$defaultValue = props.defaultValue,
37771
+ defaultValue = _props$defaultValue === void 0 ? 0 : _props$defaultValue,
37772
+ valueProp = props.value,
37773
+ onChange = props.onChange;
37774
+
37775
+ // 规范化初始值,确保在有效范围内
37776
+ var normalizeIndex = function normalizeIndex(index) {
37777
+ if (index < 0) return 0;
37778
+ if (index >= total) return Math.max(0, total - 1);
37779
+ return index;
37780
+ };
37781
+ var initialValue = normalizeIndex(valueProp !== undefined ? valueProp : defaultValue);
37761
37782
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
37762
- current: 0,
37783
+ current: initialValue,
37763
37784
  pre: -1,
37764
37785
  direction: 'stop'
37765
37786
  }),
@@ -37772,14 +37793,32 @@ var useCarousel = function useCarousel(props) {
37772
37793
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
37773
37794
  timer: null,
37774
37795
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
37775
- setNext: function setNext(next) {}
37796
+ setNext: function setNext(next) {},
37797
+ prevValue: initialValue // 用于追踪上一次的值
37776
37798
  }),
37777
37799
  context = _useRef.current;
37800
+
37801
+ // 判断是否为受控模式
37802
+ var isControlled = valueProp !== undefined;
37803
+ // 获取实际使用的 current 值
37804
+ var actualCurrent = isControlled ? normalizeIndex(valueProp) : current;
37805
+
37806
+ // 在受控模式下,计算 direction 和 pre
37807
+ var actualPre = pre;
37808
+ var actualDirection = direction;
37809
+ if (isControlled) {
37810
+ if (actualCurrent !== context.prevValue) {
37811
+ actualPre = context.prevValue;
37812
+ actualDirection = actualCurrent > context.prevValue ? 'forward' : 'backward';
37813
+ context.prevValue = actualCurrent;
37814
+ }
37815
+ }
37778
37816
  var autoPlay = interval > 0 && total > 1;
37779
37817
  var moveTo = usePersistFn(function (i) {
37780
37818
  var next = i;
37781
- if (next === current) return;
37782
- var dir = next > current ? 'forward' : 'backward';
37819
+ var prevCurrent = actualCurrent;
37820
+ if (next === prevCurrent) return;
37821
+ var dir = next > prevCurrent ? 'forward' : 'backward';
37783
37822
  if (next >= total) {
37784
37823
  dir = 'forward';
37785
37824
  next = 0;
@@ -37787,14 +37826,26 @@ var useCarousel = function useCarousel(props) {
37787
37826
  dir = 'backward';
37788
37827
  next = total - 1;
37789
37828
  }
37790
- setState({
37791
- current: next,
37792
- pre: current,
37793
- direction: dir
37794
- });
37829
+
37830
+ // 非受控模式下更新内部状态
37831
+ if (!isControlled) {
37832
+ setState({
37833
+ current: next,
37834
+ pre: prevCurrent,
37835
+ direction: dir
37836
+ });
37837
+ }
37838
+ // 受控模式下不更新内部状态,由外部 value 控制
37839
+
37840
+ // 触发 onChange 回调
37841
+ if (onChange) {
37842
+ onChange(next);
37843
+ }
37844
+
37845
+ // 触发 onMove 回调(向后兼容)
37795
37846
  if (props.onMove) {
37796
37847
  props.onMove(next, {
37797
- prev: current,
37848
+ prev: prevCurrent,
37798
37849
  direction: dir,
37799
37850
  moveTo: moveTo
37800
37851
  });
@@ -37816,13 +37867,13 @@ var useCarousel = function useCarousel(props) {
37816
37867
  });
37817
37868
  context.setNext = setNext;
37818
37869
  var start = usePersistFn(function () {
37819
- setNext(current + 1);
37870
+ setNext(actualCurrent + 1);
37820
37871
  });
37821
37872
  var forward = usePersistFn(function () {
37822
- moveTo(current + 1);
37873
+ moveTo(actualCurrent + 1);
37823
37874
  });
37824
37875
  var backward = usePersistFn(function () {
37825
- moveTo(current - 1);
37876
+ moveTo(actualCurrent - 1);
37826
37877
  });
37827
37878
  var func = use_latest_obj({
37828
37879
  start: start,
@@ -37836,10 +37887,18 @@ var useCarousel = function useCarousel(props) {
37836
37887
  start();
37837
37888
  }
37838
37889
  }, []);
37890
+
37891
+ // 受控模式下,当外部 value 变化时,重置自动轮播定时器
37892
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
37893
+ if (isControlled && autoPlay && valueProp !== undefined) {
37894
+ stop();
37895
+ context.setNext(actualCurrent + 1);
37896
+ }
37897
+ }, [valueProp]);
37839
37898
  return {
37840
- current: current,
37841
- pre: pre,
37842
- direction: direction,
37899
+ current: actualCurrent,
37900
+ pre: actualPre,
37901
+ direction: actualDirection,
37843
37902
  func: func
37844
37903
  };
37845
37904
  };
@@ -37871,6 +37930,9 @@ var Carousel = function Carousel(props) {
37871
37930
  var _useCarousel = use_carousel({
37872
37931
  total: total,
37873
37932
  interval: props.interval,
37933
+ defaultValue: props.defaultValue,
37934
+ value: props.value,
37935
+ onChange: props.onChange,
37874
37936
  onMove: props.onMove
37875
37937
  }),
37876
37938
  current = _useCarousel.current,
@@ -43608,7 +43670,7 @@ function getRule(rule, props) {
43608
43670
  return;
43609
43671
  }
43610
43672
  if (reg.global) reg.lastIndex = 0;
43611
- if (typeof value === 'string' && reg.test(value)) {
43673
+ if (reg.test(value)) {
43612
43674
  callback(true);
43613
43675
  } else {
43614
43676
  callback(new FormError(po.message, po));
@@ -66595,7 +66657,7 @@ var emptyRef = {
66595
66657
  columns: columns,
66596
66658
  colgroup: colgroup,
66597
66659
  rowsInView: props.rowsInView || 20,
66598
- rowHeight: props.rowHeight || 100,
66660
+ rowHeight: props.rowHeight || 40,
66599
66661
  strictRowHeight: props.strictRowHeight,
66600
66662
  scrollRef: scrollRef,
66601
66663
  innerRef: tbodyRef,
@@ -73549,7 +73611,7 @@ var upload_interface = __webpack_require__(8821);
73549
73611
 
73550
73612
 
73551
73613
  /* harmony default export */ var src_0 = ({
73552
- version: '3.9.0-beta.11'
73614
+ version: '3.9.0-beta.12'
73553
73615
  });
73554
73616
  }();
73555
73617
  /******/ return __webpack_exports__;