antd-mobile 5.23.0 → 5.24.0

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.
Files changed (72) hide show
  1. package/2x/bundle/antd-mobile.cjs.development.js +167 -15
  2. package/2x/bundle/antd-mobile.cjs.js +8 -8
  3. package/2x/bundle/antd-mobile.compatible.umd.js +5364 -5241
  4. package/2x/bundle/antd-mobile.es.development.js +167 -15
  5. package/2x/bundle/antd-mobile.es.js +4345 -4242
  6. package/2x/bundle/antd-mobile.umd.development.js +167 -15
  7. package/2x/bundle/antd-mobile.umd.js +8 -8
  8. package/2x/bundle/style.css +9 -4
  9. package/2x/cjs/components/calendar/calendar.d.ts +3 -5
  10. package/2x/cjs/components/calendar/calendar.js +27 -5
  11. package/2x/cjs/components/calendar/convert.d.ts +6 -0
  12. package/2x/cjs/components/calendar/convert.js +9 -0
  13. package/2x/cjs/components/ellipsis/ellipsis.js +16 -7
  14. package/2x/cjs/components/form/form-item.css +0 -1
  15. package/2x/cjs/components/form/form.css +9 -3
  16. package/2x/cjs/components/form/form.d.ts +2 -2
  17. package/2x/cjs/components/form/index.css +9 -4
  18. package/2x/cjs/components/form/index.d.ts +1 -1
  19. package/2x/cjs/components/popover/popover.js +2 -2
  20. package/2x/cjs/components/stepper/stepper.js +2 -1
  21. package/2x/cjs/components/swiper/swiper.js +9 -0
  22. package/2x/es/components/calendar/calendar.d.ts +3 -5
  23. package/2x/es/components/calendar/calendar.js +29 -6
  24. package/2x/es/components/calendar/convert.d.ts +6 -0
  25. package/2x/es/components/calendar/convert.js +4 -0
  26. package/2x/es/components/ellipsis/ellipsis.js +14 -8
  27. package/2x/es/components/form/form-item.css +0 -1
  28. package/2x/es/components/form/form.css +9 -3
  29. package/2x/es/components/form/form.d.ts +2 -2
  30. package/2x/es/components/form/index.css +9 -4
  31. package/2x/es/components/form/index.d.ts +1 -1
  32. package/2x/es/components/popover/popover.js +2 -2
  33. package/2x/es/components/stepper/stepper.js +2 -1
  34. package/2x/es/components/swiper/swiper.js +9 -0
  35. package/2x/package.json +2 -1
  36. package/2x/umd/antd-mobile.js +5364 -5241
  37. package/bundle/antd-mobile.cjs.development.js +167 -15
  38. package/bundle/antd-mobile.cjs.js +8 -8
  39. package/bundle/antd-mobile.compatible.umd.js +5364 -5241
  40. package/bundle/antd-mobile.es.development.js +167 -15
  41. package/bundle/antd-mobile.es.js +4345 -4242
  42. package/bundle/antd-mobile.umd.development.js +167 -15
  43. package/bundle/antd-mobile.umd.js +8 -8
  44. package/bundle/style.css +1 -1
  45. package/cjs/components/calendar/calendar.d.ts +3 -5
  46. package/cjs/components/calendar/calendar.js +27 -5
  47. package/cjs/components/calendar/convert.d.ts +6 -0
  48. package/cjs/components/calendar/convert.js +9 -0
  49. package/cjs/components/ellipsis/ellipsis.js +16 -7
  50. package/cjs/components/form/form-item.css +0 -1
  51. package/cjs/components/form/form.css +8 -3
  52. package/cjs/components/form/form.d.ts +2 -2
  53. package/cjs/components/form/index.css +8 -4
  54. package/cjs/components/form/index.d.ts +1 -1
  55. package/cjs/components/popover/popover.js +2 -2
  56. package/cjs/components/stepper/stepper.js +2 -1
  57. package/cjs/components/swiper/swiper.js +9 -0
  58. package/es/components/calendar/calendar.d.ts +3 -5
  59. package/es/components/calendar/calendar.js +29 -6
  60. package/es/components/calendar/convert.d.ts +6 -0
  61. package/es/components/calendar/convert.js +4 -0
  62. package/es/components/ellipsis/ellipsis.js +14 -8
  63. package/es/components/form/form-item.css +0 -1
  64. package/es/components/form/form.css +8 -3
  65. package/es/components/form/form.d.ts +2 -2
  66. package/es/components/form/index.css +8 -4
  67. package/es/components/form/index.d.ts +1 -1
  68. package/es/components/popover/popover.js +2 -2
  69. package/es/components/stepper/stepper.js +2 -1
  70. package/es/components/swiper/swiper.js +9 -0
  71. package/package.json +2 -1
  72. package/umd/antd-mobile.js +1 -1
@@ -8433,6 +8433,9 @@ function convertValueToRange(selectionMode, value) {
8433
8433
  }
8434
8434
  return [value, value];
8435
8435
  }
8436
+ function convertPageToDayjs(page) {
8437
+ return dayjs().year(page.year).month(page.month - 1).date(1);
8438
+ }
8436
8439
  dayjs.extend(isoWeek);
8437
8440
  const classPrefix$1b = "adm-calendar";
8438
8441
  const defaultProps$Y = {
@@ -8485,35 +8488,51 @@ const Calendar = forwardRef((p, ref) => {
8485
8488
  } else {
8486
8489
  page = pageOrPageGenerator;
8487
8490
  }
8488
- setCurrent(dayjs().year(page.year).month(page.month - 1).date(1));
8491
+ setCurrent(convertPageToDayjs(page));
8489
8492
  },
8490
8493
  jumpToToday: () => {
8491
8494
  setCurrent(dayjs().date(1));
8492
8495
  }
8493
8496
  }));
8497
+ const handlePageChange = (action, num, type4) => {
8498
+ const nxtCurrent = current[action](num, type4);
8499
+ if (action === "subtract" && props.minPage) {
8500
+ const minPage = convertPageToDayjs(props.minPage);
8501
+ if (nxtCurrent.isBefore(minPage, type4)) {
8502
+ return;
8503
+ }
8504
+ }
8505
+ if (action === "add" && props.maxPage) {
8506
+ const maxPage = convertPageToDayjs(props.maxPage);
8507
+ if (nxtCurrent.isAfter(maxPage, type4)) {
8508
+ return;
8509
+ }
8510
+ }
8511
+ setCurrent(current[action](num, type4));
8512
+ };
8494
8513
  const header = React__default.createElement("div", {
8495
8514
  className: `${classPrefix$1b}-header`
8496
8515
  }, React__default.createElement("a", {
8497
8516
  className: `${classPrefix$1b}-arrow-button ${classPrefix$1b}-arrow-button-year`,
8498
8517
  onClick: () => {
8499
- setCurrent(current.subtract(1, "year"));
8518
+ handlePageChange("subtract", 1, "year");
8500
8519
  }
8501
8520
  }, props.prevYearButton), React__default.createElement("a", {
8502
8521
  className: `${classPrefix$1b}-arrow-button ${classPrefix$1b}-arrow-button-month`,
8503
8522
  onClick: () => {
8504
- setCurrent(current.subtract(1, "month"));
8523
+ handlePageChange("subtract", 1, "month");
8505
8524
  }
8506
8525
  }, props.prevMonthButton), React__default.createElement("div", {
8507
8526
  className: `${classPrefix$1b}-title`
8508
8527
  }, locale.Calendar.renderYearAndMonth(current.year(), current.month() + 1)), React__default.createElement("a", {
8509
8528
  className: classNames(`${classPrefix$1b}-arrow-button`, `${classPrefix$1b}-arrow-button-right`, `${classPrefix$1b}-arrow-button-right-month`),
8510
8529
  onClick: () => {
8511
- setCurrent(current.add(1, "month"));
8530
+ handlePageChange("add", 1, "month");
8512
8531
  }
8513
8532
  }, props.nextMonthButton), React__default.createElement("a", {
8514
8533
  className: classNames(`${classPrefix$1b}-arrow-button`, `${classPrefix$1b}-arrow-button-right`, `${classPrefix$1b}-arrow-button-right-year`),
8515
8534
  onClick: () => {
8516
- setCurrent(current.add(1, "year"));
8535
+ handlePageChange("add", 1, "year");
8517
8536
  }
8518
8537
  }, props.nextYearButton));
8519
8538
  const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
@@ -13563,6 +13582,126 @@ const index$c = attachPropertiesToComponent(Dropdown, {
13563
13582
  Item
13564
13583
  });
13565
13584
  const ellipsis = "";
13585
+ var runes$1 = { exports: {} };
13586
+ const HIGH_SURROGATE_START = 55296;
13587
+ const HIGH_SURROGATE_END = 56319;
13588
+ const LOW_SURROGATE_START = 56320;
13589
+ const REGIONAL_INDICATOR_START = 127462;
13590
+ const REGIONAL_INDICATOR_END = 127487;
13591
+ const FITZPATRICK_MODIFIER_START = 127995;
13592
+ const FITZPATRICK_MODIFIER_END = 127999;
13593
+ const VARIATION_MODIFIER_START = 65024;
13594
+ const VARIATION_MODIFIER_END = 65039;
13595
+ const DIACRITICAL_MARKS_START = 8400;
13596
+ const DIACRITICAL_MARKS_END = 8447;
13597
+ const ZWJ = 8205;
13598
+ const GRAPHEMS = [
13599
+ 776,
13600
+ 2359,
13601
+ 2359,
13602
+ 2367,
13603
+ 2367,
13604
+ 2984,
13605
+ 3007,
13606
+ 3021,
13607
+ 3633,
13608
+ 3635,
13609
+ 3648,
13610
+ 3657,
13611
+ 4352,
13612
+ 4449,
13613
+ 4520
13614
+ ];
13615
+ function runes(string3) {
13616
+ if (typeof string3 !== "string") {
13617
+ throw new Error("string cannot be undefined or null");
13618
+ }
13619
+ const result2 = [];
13620
+ let i = 0;
13621
+ let increment = 0;
13622
+ while (i < string3.length) {
13623
+ increment += nextUnits(i + increment, string3);
13624
+ if (isGraphem(string3[i + increment])) {
13625
+ increment++;
13626
+ }
13627
+ if (isVariationSelector(string3[i + increment])) {
13628
+ increment++;
13629
+ }
13630
+ if (isDiacriticalMark(string3[i + increment])) {
13631
+ increment++;
13632
+ }
13633
+ if (isZeroWidthJoiner(string3[i + increment])) {
13634
+ increment++;
13635
+ continue;
13636
+ }
13637
+ result2.push(string3.substring(i, i + increment));
13638
+ i += increment;
13639
+ increment = 0;
13640
+ }
13641
+ return result2;
13642
+ }
13643
+ function nextUnits(i, string3) {
13644
+ const current = string3[i];
13645
+ if (!isFirstOfSurrogatePair(current) || i === string3.length - 1) {
13646
+ return 1;
13647
+ }
13648
+ const currentPair = current + string3[i + 1];
13649
+ let nextPair = string3.substring(i + 2, i + 5);
13650
+ if (isRegionalIndicator(currentPair) && isRegionalIndicator(nextPair)) {
13651
+ return 4;
13652
+ }
13653
+ if (isFitzpatrickModifier(nextPair)) {
13654
+ return 4;
13655
+ }
13656
+ return 2;
13657
+ }
13658
+ function isFirstOfSurrogatePair(string3) {
13659
+ return string3 && betweenInclusive(string3[0].charCodeAt(0), HIGH_SURROGATE_START, HIGH_SURROGATE_END);
13660
+ }
13661
+ function isRegionalIndicator(string3) {
13662
+ return betweenInclusive(codePointFromSurrogatePair(string3), REGIONAL_INDICATOR_START, REGIONAL_INDICATOR_END);
13663
+ }
13664
+ function isFitzpatrickModifier(string3) {
13665
+ return betweenInclusive(codePointFromSurrogatePair(string3), FITZPATRICK_MODIFIER_START, FITZPATRICK_MODIFIER_END);
13666
+ }
13667
+ function isVariationSelector(string3) {
13668
+ return typeof string3 === "string" && betweenInclusive(string3.charCodeAt(0), VARIATION_MODIFIER_START, VARIATION_MODIFIER_END);
13669
+ }
13670
+ function isDiacriticalMark(string3) {
13671
+ return typeof string3 === "string" && betweenInclusive(string3.charCodeAt(0), DIACRITICAL_MARKS_START, DIACRITICAL_MARKS_END);
13672
+ }
13673
+ function isGraphem(string3) {
13674
+ return typeof string3 === "string" && GRAPHEMS.indexOf(string3.charCodeAt(0)) !== -1;
13675
+ }
13676
+ function isZeroWidthJoiner(string3) {
13677
+ return typeof string3 === "string" && string3.charCodeAt(0) === ZWJ;
13678
+ }
13679
+ function codePointFromSurrogatePair(pair) {
13680
+ const highOffset = pair.charCodeAt(0) - HIGH_SURROGATE_START;
13681
+ const lowOffset = pair.charCodeAt(1) - LOW_SURROGATE_START;
13682
+ return (highOffset << 10) + lowOffset + 65536;
13683
+ }
13684
+ function betweenInclusive(value, lower, upper) {
13685
+ return value >= lower && value <= upper;
13686
+ }
13687
+ function substring(string3, start2, width) {
13688
+ const chars = runes(string3);
13689
+ if (start2 === void 0) {
13690
+ return string3;
13691
+ }
13692
+ if (start2 >= chars.length) {
13693
+ return "";
13694
+ }
13695
+ const rest = chars.length - start2;
13696
+ const stringWidth = width === void 0 ? rest : width;
13697
+ let endIndex = start2 + stringWidth;
13698
+ if (endIndex > start2 + rest) {
13699
+ endIndex = void 0;
13700
+ }
13701
+ return chars.slice(start2, endIndex).join("");
13702
+ }
13703
+ runes$1.exports = runes;
13704
+ runes$1.exports.substr = substring;
13566
13705
  const classPrefix$S = `adm-ellipsis`;
13567
13706
  const defaultProps$G = {
13568
13707
  direction: "end",
@@ -13579,6 +13718,10 @@ const Ellipsis = (p) => {
13579
13718
  const [ellipsised, setEllipsised] = useState({});
13580
13719
  const [expanded, setExpanded] = useState(false);
13581
13720
  const [exceeded, setExceeded] = useState(false);
13721
+ const chars = useMemo(() => runes$1.exports(props.content), [props.content]);
13722
+ function getSubString(start2, end) {
13723
+ return chars.slice(start2, end).join("");
13724
+ }
13582
13725
  function calcEllipsised() {
13583
13726
  const root2 = rootRef.current;
13584
13727
  if (!root2)
@@ -13613,19 +13756,19 @@ const Ellipsis = (p) => {
13613
13756
  if (right - left <= 1) {
13614
13757
  if (props.direction === "end") {
13615
13758
  return {
13616
- leading: props.content.slice(0, left) + "..."
13759
+ leading: getSubString(0, left) + "..."
13617
13760
  };
13618
13761
  } else {
13619
13762
  return {
13620
- tailing: "..." + props.content.slice(right, end)
13763
+ tailing: "..." + getSubString(right, end)
13621
13764
  };
13622
13765
  }
13623
13766
  }
13624
13767
  const middle2 = Math.round((left + right) / 2);
13625
13768
  if (props.direction === "end") {
13626
- container.innerText = props.content.slice(0, middle2) + "..." + actionText;
13769
+ container.innerText = getSubString(0, middle2) + "..." + actionText;
13627
13770
  } else {
13628
- container.innerText = actionText + "..." + props.content.slice(middle2, end);
13771
+ container.innerText = actionText + "..." + getSubString(middle2, end);
13629
13772
  }
13630
13773
  if (container.offsetHeight <= maxHeight) {
13631
13774
  if (props.direction === "end") {
@@ -13643,13 +13786,13 @@ const Ellipsis = (p) => {
13643
13786
  }, checkMiddle = function(leftPart, rightPart) {
13644
13787
  if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
13645
13788
  return {
13646
- leading: props.content.slice(0, leftPart[0]) + "...",
13647
- tailing: "..." + props.content.slice(rightPart[1], end)
13789
+ leading: getSubString(0, leftPart[0]) + "...",
13790
+ tailing: "..." + getSubString(rightPart[1], end)
13648
13791
  };
13649
13792
  }
13650
13793
  const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
13651
13794
  const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
13652
- container.innerText = props.content.slice(0, leftPartMiddle) + "..." + actionText + "..." + props.content.slice(rightPartMiddle, end);
13795
+ container.innerText = getSubString(0, leftPartMiddle) + "..." + actionText + "..." + getSubString(rightPartMiddle, end);
13653
13796
  if (container.offsetHeight <= maxHeight) {
13654
13797
  return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
13655
13798
  } else {
@@ -20216,10 +20359,10 @@ const Popover$1 = forwardRef((p, ref) => {
20216
20359
  if (!props.trigger)
20217
20360
  return;
20218
20361
  setVisible(false);
20219
- }, () => {
20362
+ }, [() => {
20220
20363
  var _a;
20221
20364
  return (_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.element;
20222
- });
20365
+ }, floatingRef], ["click", "touchmove"]);
20223
20366
  const shouldRender = useShouldRender(visible, false, props.destroyOnHide);
20224
20367
  return React__default.createElement(React__default.Fragment, null, React__default.createElement(Wrapper, {
20225
20368
  ref: targetRef
@@ -24139,7 +24282,8 @@ const Stepper = (p) => {
24139
24282
  role: "spinbutton",
24140
24283
  "aria-valuenow": Number(inputValue),
24141
24284
  "aria-valuemax": max2,
24142
- "aria-valuemin": min2
24285
+ "aria-valuemin": min2,
24286
+ inputMode: "decimal"
24143
24287
  })), React__default.createElement(Button, {
24144
24288
  className: `${classPrefix$e}-plus`,
24145
24289
  onClick: handlePlus,
@@ -24454,8 +24598,10 @@ const defaultProps$a = {
24454
24598
  stuckAtBoundary: true,
24455
24599
  rubberband: true
24456
24600
  };
24601
+ let currentUid;
24457
24602
  const Swiper = forwardRef(staged_1((p, ref) => {
24458
24603
  const props = mergeProps(defaultProps$a, p);
24604
+ const [uid] = useState({});
24459
24605
  const isVertical = props.direction === "vertical";
24460
24606
  const slideRatio = props.slideSize / 100;
24461
24607
  const offsetRatio = props.trackOffset / 100;
@@ -24545,6 +24691,12 @@ const Swiper = forwardRef(staged_1((p, ref) => {
24545
24691
  dragCancelRef.current = state.cancel;
24546
24692
  if (!state.intentional)
24547
24693
  return;
24694
+ if (state.first && !currentUid) {
24695
+ currentUid = uid;
24696
+ }
24697
+ if (currentUid !== uid)
24698
+ return;
24699
+ currentUid = state.last ? void 0 : uid;
24548
24700
  const slidePixels = getSlidePixels();
24549
24701
  if (!slidePixels)
24550
24702
  return;