antd-mobile 5.40.0 → 5.41.0-alpha.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.
Files changed (66) hide show
  1. package/2x/bundle/antd-mobile.cjs.development.js +225 -85
  2. package/2x/bundle/antd-mobile.cjs.js +6 -6
  3. package/2x/bundle/antd-mobile.es.development.js +225 -85
  4. package/2x/bundle/antd-mobile.es.js +2218 -2144
  5. package/2x/bundle/antd-mobile.umd.development.js +225 -85
  6. package/2x/bundle/antd-mobile.umd.js +7 -7
  7. package/2x/bundle/style.css +4 -1
  8. package/2x/cjs/components/calendar/calendar.d.ts +4 -1
  9. package/2x/cjs/components/calendar/calendar.js +18 -11
  10. package/2x/cjs/components/date-picker/date-picker-week-utils.js +2 -1
  11. package/2x/cjs/components/ellipsis/ellipsis.d.ts +3 -0
  12. package/2x/cjs/components/ellipsis/ellipsis.js +10 -2
  13. package/2x/cjs/components/swiper/swiper.js +1 -1
  14. package/2x/cjs/components/tabs/tabs.js +45 -13
  15. package/2x/cjs/components/virtual-input/virtual-input.css +4 -1
  16. package/2x/cjs/components/virtual-input/virtual-input.d.ts +6 -0
  17. package/2x/cjs/components/virtual-input/virtual-input.js +105 -8
  18. package/2x/es/components/calendar/calendar.d.ts +4 -1
  19. package/2x/es/components/calendar/calendar.js +19 -12
  20. package/2x/es/components/date-picker/date-picker-week-utils.js +2 -1
  21. package/2x/es/components/ellipsis/ellipsis.d.ts +3 -0
  22. package/2x/es/components/ellipsis/ellipsis.js +10 -2
  23. package/2x/es/components/swiper/swiper.js +1 -1
  24. package/2x/es/components/tabs/tabs.js +44 -12
  25. package/2x/es/components/virtual-input/virtual-input.css +4 -1
  26. package/2x/es/components/virtual-input/virtual-input.d.ts +6 -0
  27. package/2x/es/components/virtual-input/virtual-input.js +105 -8
  28. package/2x/package.json +3 -3
  29. package/bundle/antd-mobile.cjs.development.js +225 -85
  30. package/bundle/antd-mobile.cjs.js +6 -6
  31. package/bundle/antd-mobile.compatible.umd.js +1 -1
  32. package/bundle/antd-mobile.es.development.js +225 -85
  33. package/bundle/antd-mobile.es.js +2218 -2144
  34. package/bundle/antd-mobile.umd.development.js +225 -85
  35. package/bundle/antd-mobile.umd.js +7 -7
  36. package/bundle/style.css +1 -1
  37. package/cjs/components/calendar/calendar.d.ts +4 -1
  38. package/cjs/components/calendar/calendar.js +18 -11
  39. package/cjs/components/date-picker/date-picker-week-utils.js +2 -1
  40. package/cjs/components/ellipsis/ellipsis.d.ts +3 -0
  41. package/cjs/components/ellipsis/ellipsis.js +10 -2
  42. package/cjs/components/swiper/swiper.js +1 -1
  43. package/cjs/components/tabs/tabs.js +45 -13
  44. package/cjs/components/virtual-input/virtual-input.css +3 -1
  45. package/cjs/components/virtual-input/virtual-input.d.ts +6 -0
  46. package/cjs/components/virtual-input/virtual-input.js +105 -8
  47. package/es/components/calendar/calendar.d.ts +4 -1
  48. package/es/components/calendar/calendar.js +19 -12
  49. package/es/components/date-picker/date-picker-week-utils.js +2 -1
  50. package/es/components/ellipsis/ellipsis.d.ts +3 -0
  51. package/es/components/ellipsis/ellipsis.js +10 -2
  52. package/es/components/swiper/swiper.js +1 -1
  53. package/es/components/tabs/tabs.js +44 -12
  54. package/es/components/virtual-input/virtual-input.css +3 -1
  55. package/es/components/virtual-input/virtual-input.d.ts +6 -0
  56. package/es/components/virtual-input/virtual-input.js +105 -8
  57. package/package.json +3 -3
  58. package/umd/antd-mobile.js +1 -1
  59. package/2x/cjs/components/ellipsis/~ellipsis.d.ts +0 -15
  60. package/2x/cjs/components/ellipsis/~ellipsis.js +0 -161
  61. package/2x/es/components/ellipsis/~ellipsis.d.ts +0 -15
  62. package/2x/es/components/ellipsis/~ellipsis.js +0 -151
  63. package/cjs/components/ellipsis/~ellipsis.d.ts +0 -15
  64. package/cjs/components/ellipsis/~ellipsis.js +0 -161
  65. package/es/components/ellipsis/~ellipsis.d.ts +0 -15
  66. package/es/components/ellipsis/~ellipsis.js +0 -151
@@ -9685,6 +9685,73 @@ const Button = React$2.forwardRef((p, ref2) => {
9685
9685
  className: `${classPrefix$1h}-loading-wrapper`
9686
9686
  }, props.loadingIcon, props.loadingText) : React$2.createElement("span", null, props.children)));
9687
9687
  });
9688
+ var isoWeek$1 = { exports: {} };
9689
+ (function(module2, exports2) {
9690
+ !function(e2, t) {
9691
+ module2.exports = t();
9692
+ }(commonjsGlobal, function() {
9693
+ var e2 = "day";
9694
+ return function(t, i2, s) {
9695
+ var a = function(t2) {
9696
+ return t2.add(4 - t2.isoWeekday(), e2);
9697
+ }, d = i2.prototype;
9698
+ d.isoWeekYear = function() {
9699
+ return a(this).year();
9700
+ }, d.isoWeek = function(t2) {
9701
+ if (!this.$utils().u(t2))
9702
+ return this.add(7 * (t2 - this.isoWeek()), e2);
9703
+ var i3, d2, n3, o, r = a(this), u = (i3 = this.isoWeekYear(), d2 = this.$u, n3 = (d2 ? s.utc : s)().year(i3).startOf("year"), o = 4 - n3.isoWeekday(), n3.isoWeekday() > 4 && (o += 7), n3.add(o, e2));
9704
+ return r.diff(u, "week") + 1;
9705
+ }, d.isoWeekday = function(e3) {
9706
+ return this.$utils().u(e3) ? this.day() || 7 : this.day(this.day() % 7 ? e3 : e3 - 7);
9707
+ };
9708
+ var n2 = d.startOf;
9709
+ d.startOf = function(e3, t2) {
9710
+ var i3 = this.$utils(), s2 = !!i3.u(t2) || t2;
9711
+ return "isoweek" === i3.p(e3) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n2.bind(this)(e3, t2);
9712
+ };
9713
+ };
9714
+ });
9715
+ })(isoWeek$1);
9716
+ var isoWeekExports = isoWeek$1.exports;
9717
+ const isoWeek = /* @__PURE__ */ getDefaultExportFromCjs(isoWeekExports);
9718
+ function devWarning(component, message) {
9719
+ {
9720
+ console.warn(`[antd-mobile: ${component}] ${message}`);
9721
+ }
9722
+ }
9723
+ function devError(component, message) {
9724
+ {
9725
+ console.error(`[antd-mobile: ${component}] ${message}`);
9726
+ }
9727
+ }
9728
+ function replaceMessage$1(template, kv) {
9729
+ return template.replace(/\$\{\w+\}/g, (str) => {
9730
+ const key = str.slice(2, -1);
9731
+ return kv[key];
9732
+ });
9733
+ }
9734
+ function usePropsValue(options) {
9735
+ const {
9736
+ value,
9737
+ defaultValue,
9738
+ onChange
9739
+ } = options;
9740
+ const update2 = useUpdate$1();
9741
+ const stateRef = React$2.useRef(value !== void 0 ? value : defaultValue);
9742
+ if (value !== void 0) {
9743
+ stateRef.current = value;
9744
+ }
9745
+ const setState = useMemoizedFn((v, forceTrigger = false) => {
9746
+ const nextValue = typeof v === "function" ? v(stateRef.current) : v;
9747
+ if (!forceTrigger && nextValue === stateRef.current)
9748
+ return;
9749
+ stateRef.current = nextValue;
9750
+ update2();
9751
+ return onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
9752
+ });
9753
+ return [stateRef.current, setState];
9754
+ }
9688
9755
  const ArrowLeft = () => {
9689
9756
  return React$2.createElement("svg", {
9690
9757
  height: "1em",
@@ -9739,73 +9806,6 @@ const ArrowLeftDouble = () => {
9739
9806
  d: "M19.5305114,17.0699744 C19.0173831,17.5315665 18.9752295,18.3220903 19.436308,18.8357433 C19.4660129,18.8688164 19.4974585,18.9002801 19.5305113,18.9300007 L29.4833057,27.2801611 C30.1234001,27.8559077 30.1759552,28.8420707 29.6007967,29.4827774 C29.0256382,30.1235263 28.0404824,30.1761351 27.400388,29.6003885 L17.4475937,21.2502703 C17.3320874,21.1463692 17.2222026,21.036372 17.1184079,20.920748 C15.5069703,19.1256817 15.6543605,16.3628317 17.4475933,14.7497465 L27.4003877,6.39962828 C28.0404821,5.82383957 29.0256378,5.87649058 29.6007963,6.51723942 C30.1759548,7.1579461 30.1233997,8.14410915 29.4833053,8.7198557 L19.5305114,17.0699744 Z"
9740
9807
  }))))));
9741
9808
  };
9742
- var isoWeek$1 = { exports: {} };
9743
- (function(module2, exports2) {
9744
- !function(e2, t) {
9745
- module2.exports = t();
9746
- }(commonjsGlobal, function() {
9747
- var e2 = "day";
9748
- return function(t, i2, s) {
9749
- var a = function(t2) {
9750
- return t2.add(4 - t2.isoWeekday(), e2);
9751
- }, d = i2.prototype;
9752
- d.isoWeekYear = function() {
9753
- return a(this).year();
9754
- }, d.isoWeek = function(t2) {
9755
- if (!this.$utils().u(t2))
9756
- return this.add(7 * (t2 - this.isoWeek()), e2);
9757
- var i3, d2, n3, o, r = a(this), u = (i3 = this.isoWeekYear(), d2 = this.$u, n3 = (d2 ? s.utc : s)().year(i3).startOf("year"), o = 4 - n3.isoWeekday(), n3.isoWeekday() > 4 && (o += 7), n3.add(o, e2));
9758
- return r.diff(u, "week") + 1;
9759
- }, d.isoWeekday = function(e3) {
9760
- return this.$utils().u(e3) ? this.day() || 7 : this.day(this.day() % 7 ? e3 : e3 - 7);
9761
- };
9762
- var n2 = d.startOf;
9763
- d.startOf = function(e3, t2) {
9764
- var i3 = this.$utils(), s2 = !!i3.u(t2) || t2;
9765
- return "isoweek" === i3.p(e3) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n2.bind(this)(e3, t2);
9766
- };
9767
- };
9768
- });
9769
- })(isoWeek$1);
9770
- var isoWeekExports = isoWeek$1.exports;
9771
- const isoWeek = /* @__PURE__ */ getDefaultExportFromCjs(isoWeekExports);
9772
- function usePropsValue(options) {
9773
- const {
9774
- value,
9775
- defaultValue,
9776
- onChange
9777
- } = options;
9778
- const update2 = useUpdate$1();
9779
- const stateRef = React$2.useRef(value !== void 0 ? value : defaultValue);
9780
- if (value !== void 0) {
9781
- stateRef.current = value;
9782
- }
9783
- const setState = useMemoizedFn((v, forceTrigger = false) => {
9784
- const nextValue = typeof v === "function" ? v(stateRef.current) : v;
9785
- if (!forceTrigger && nextValue === stateRef.current)
9786
- return;
9787
- stateRef.current = nextValue;
9788
- update2();
9789
- return onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
9790
- });
9791
- return [stateRef.current, setState];
9792
- }
9793
- function replaceMessage$1(template, kv) {
9794
- return template.replace(/\$\{\w+\}/g, (str) => {
9795
- const key = str.slice(2, -1);
9796
- return kv[key];
9797
- });
9798
- }
9799
- function devWarning(component, message) {
9800
- {
9801
- console.warn(`[antd-mobile: ${component}] ${message}`);
9802
- }
9803
- }
9804
- function devError(component, message) {
9805
- {
9806
- console.error(`[antd-mobile: ${component}] ${message}`);
9807
- }
9808
- }
9809
9809
  function convertValueToRange$1(selectionMode, value) {
9810
9810
  if (selectionMode === void 0 || value === null)
9811
9811
  return null;
@@ -9947,7 +9947,7 @@ const Calendar = React$2.forwardRef((p, ref2) => {
9947
9947
  }
9948
9948
  const inThisMonth = d.month() === current.month();
9949
9949
  const disabled = props.shouldDisableDate ? props.shouldDisableDate(d.toDate()) : maxDay && d.isAfter(maxDay, "day") || minDay && d.isBefore(minDay, "day");
9950
- cells.push(React$2.createElement("div", {
9950
+ const originalCell = React$2.createElement("div", {
9951
9951
  key: d.valueOf(),
9952
9952
  className: classNames(`${classPrefix$1g}-cell`, (disabled || !inThisMonth) && `${classPrefix$1g}-cell-disabled`, inThisMonth && {
9953
9953
  [`${classPrefix$1g}-cell-today`]: d.isSame(today, "day"),
@@ -10005,7 +10005,13 @@ const Calendar = React$2.forwardRef((p, ref2) => {
10005
10005
  className: `${classPrefix$1g}-cell-top`
10006
10006
  }, props.renderDate ? props.renderDate(d.toDate()) : d.date()), React$2.createElement("div", {
10007
10007
  className: `${classPrefix$1g}-cell-bottom`
10008
- }, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate()))));
10008
+ }, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate())));
10009
+ const cellWithKey = props.cellRender ? React$2.createElement(React$2.Fragment, {
10010
+ key: d.valueOf()
10011
+ }, props.cellRender(originalCell, {
10012
+ date: d.toDate()
10013
+ })) : originalCell;
10014
+ cells.push(cellWithKey);
10009
10015
  iterator = iterator.add(1, "day");
10010
10016
  }
10011
10017
  return cells;
@@ -12250,6 +12256,7 @@ const Tabs$1 = (p) => {
12250
12256
  const props = mergeProps(defaultProps$S, p);
12251
12257
  const tabListContainerRef = React$2.useRef(null);
12252
12258
  const activeLineRef = React$2.useRef(null);
12259
+ const tabRefs = React$2.useRef({});
12253
12260
  const keyToIndexRecord = {};
12254
12261
  let firstActiveKey = null;
12255
12262
  const panes = [];
@@ -12389,7 +12396,7 @@ const Tabs$1 = (p) => {
12389
12396
  });
12390
12397
  const {
12391
12398
  run: updateMask
12392
- } = useThrottleFn((immediate = false) => {
12399
+ } = useThrottleFn((immediate) => {
12393
12400
  const container = tabListContainerRef.current;
12394
12401
  if (!container)
12395
12402
  return;
@@ -12416,6 +12423,35 @@ const Tabs$1 = (p) => {
12416
12423
  useIsomorphicLayoutEffect$3(() => {
12417
12424
  updateMask(true);
12418
12425
  }, []);
12426
+ const handleKeyDown = (e2) => {
12427
+ const keys2 = Object.keys(keyToIndexRecord);
12428
+ const currentIndex = keyToIndexRecord[activeKey];
12429
+ const isNext = isRTL2 ? e2.key === "ArrowLeft" : e2.key === "ArrowRight";
12430
+ const isPrev = isRTL2 ? e2.key === "ArrowRight" : e2.key === "ArrowLeft";
12431
+ const offsetDirection = isNext ? 1 : -1;
12432
+ const findNextEnabledTab = (startIndex, direction) => {
12433
+ const length = keys2.length;
12434
+ for (let i2 = 0; i2 < length; i2++) {
12435
+ const index2 = (startIndex + direction * (i2 + 1) + length) % length;
12436
+ const key = keys2[index2];
12437
+ const pane = panes.find((p2) => p2.key === key);
12438
+ if (!(pane === null || pane === void 0 ? void 0 : pane.props.disabled))
12439
+ return key;
12440
+ }
12441
+ return keys2[startIndex];
12442
+ };
12443
+ const currentKey = findNextEnabledTab(currentIndex, offsetDirection);
12444
+ if (isNext || isPrev) {
12445
+ e2.preventDefault();
12446
+ setActiveKey(currentKey);
12447
+ }
12448
+ };
12449
+ React$2.useEffect(() => {
12450
+ var _a2;
12451
+ if (activeKey && tabRefs.current[activeKey]) {
12452
+ (_a2 = tabRefs.current[activeKey]) === null || _a2 === void 0 ? void 0 : _a2.focus();
12453
+ }
12454
+ }, [activeKey]);
12419
12455
  return withNativeProps(props, React$2.createElement("div", {
12420
12456
  className: classPrefix$15,
12421
12457
  style: {
@@ -12438,6 +12474,7 @@ const Tabs$1 = (p) => {
12438
12474
  ref: tabListContainerRef,
12439
12475
  scrollLeft,
12440
12476
  onScroll: updateMask,
12477
+ onKeyDown: handleKeyDown,
12441
12478
  role: "tablist"
12442
12479
  }, React$2.createElement(animated.div, {
12443
12480
  ref: activeLineRef,
@@ -12452,6 +12489,10 @@ const Tabs$1 = (p) => {
12452
12489
  [`${classPrefix$15}-tab-wrapper-stretch`]: props.stretch
12453
12490
  })
12454
12491
  }, React$2.createElement("div", {
12492
+ role: "tab",
12493
+ "aria-selected": pane.key === activeKey,
12494
+ tabIndex: pane.key === activeKey ? 0 : -1,
12495
+ ref: (el) => tabRefs.current[pane.key] = el,
12455
12496
  onClick: () => {
12456
12497
  const {
12457
12498
  key
@@ -12466,9 +12507,7 @@ const Tabs$1 = (p) => {
12466
12507
  className: classNames(`${classPrefix$15}-tab`, {
12467
12508
  [`${classPrefix$15}-tab-active`]: pane.key === activeKey,
12468
12509
  [`${classPrefix$15}-tab-disabled`]: pane.props.disabled
12469
- }),
12470
- role: "tab",
12471
- "aria-selected": pane.key === activeKey
12510
+ })
12472
12511
  }, pane.props.title)))))), panes.map((pane) => {
12473
12512
  if (pane.props.children === void 0) {
12474
12513
  return null;
@@ -13856,7 +13895,7 @@ function convertStringArrayToDate$1(value) {
13856
13895
  const yearString = (_a = value[0]) !== null && _a !== void 0 ? _a : "1900";
13857
13896
  const weekString = (_b = value[1]) !== null && _b !== void 0 ? _b : "1";
13858
13897
  const weekdayString = (_c = value[2]) !== null && _c !== void 0 ? _c : "1";
13859
- const day = dayjs(`${parseInt(yearString)}-01-01`).isoWeek(parseInt(weekString)).isoWeekday(parseInt(weekdayString)).hour(0).minute(0).second(0);
13898
+ const day = dayjs(`${parseInt(yearString)}-01-04`).isoWeek(parseInt(weekString)).isoWeekday(parseInt(weekdayString)).hour(0).minute(0).second(0);
13860
13899
  return day.toDate();
13861
13900
  }
13862
13901
  const precisionLengthRecord = {
@@ -14583,13 +14622,21 @@ const Ellipsis = (p) => {
14583
14622
  const rootRef = React$2.useRef(null);
14584
14623
  const [expanded, setExpanded] = React$2.useState(defaultExpanded);
14585
14624
  const expandNode = expandText ? withStopPropagation(stopPropagationForActionButtons, React$2.createElement("a", {
14586
- onClick: () => {
14625
+ onClick: (e2) => {
14626
+ var _a;
14587
14627
  setExpanded(true);
14628
+ (_a = props.onExpand) === null || _a === void 0 ? void 0 : _a.call(props, true, {
14629
+ event: e2
14630
+ });
14588
14631
  }
14589
14632
  }, expandText)) : null;
14590
14633
  const collapseNode = collapseText ? withStopPropagation(stopPropagationForActionButtons, React$2.createElement("a", {
14591
- onClick: () => {
14634
+ onClick: (e2) => {
14635
+ var _a;
14592
14636
  setExpanded(false);
14637
+ (_a = props.onExpand) === null || _a === void 0 ? void 0 : _a.call(props, false, {
14638
+ event: e2
14639
+ });
14593
14640
  }
14594
14641
  }, collapseText)) : null;
14595
14642
  const [measureNodes, forceResize] = useMeasure(rootRef, content, rows, direction, expanded, expandNode, collapseNode);
@@ -26606,7 +26653,7 @@ const Swiper = React$2.forwardRef(staged_1((p, ref2) => {
26606
26653
  return React$2.createElement(React$2.Fragment, null, React$2.createElement("div", {
26607
26654
  className: `${classPrefix$a}-slide-placeholder`,
26608
26655
  style: {
26609
- width: `${startIndex * 100}%`
26656
+ [isVertical ? "height" : "width"]: `${startIndex * 100}%`
26610
26657
  }
26611
26658
  }), items);
26612
26659
  }
@@ -27477,7 +27524,10 @@ const index = attachPropertiesToComponent(TreeSelect, {
27477
27524
  });
27478
27525
  const classPrefix$2 = "adm-virtual-input";
27479
27526
  const defaultProps$2 = {
27480
- defaultValue: ""
27527
+ defaultValue: "",
27528
+ cursor: {
27529
+ movable: false
27530
+ }
27481
27531
  };
27482
27532
  const VirtualInput = React$2.forwardRef((props, ref2) => {
27483
27533
  const {
@@ -27490,6 +27540,13 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27490
27540
  const contentRef = React$2.useRef(null);
27491
27541
  const [hasFocus, setHasFocus] = React$2.useState(false);
27492
27542
  const [caretPosition, setCaretPosition] = React$2.useState(value.length);
27543
+ const keyboardDataRef = React$2.useRef({});
27544
+ const touchDataRef = React$2.useRef();
27545
+ const charRef = React$2.useRef(null);
27546
+ const charWidthRef = React$2.useRef(0);
27547
+ const caretRef = React$2.useRef(null);
27548
+ const [isCaretDragging, setIsCaretDragging] = React$2.useState(false);
27549
+ const touchMoveTimeoutRef = React$2.useRef();
27493
27550
  const clearIcon = mergeProp(React$2.createElement(CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
27494
27551
  function scrollToEnd() {
27495
27552
  const root2 = rootRef.current;
@@ -27503,6 +27560,22 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27503
27560
  return;
27504
27561
  content.scrollLeft = content.clientWidth;
27505
27562
  }
27563
+ React$2.useEffect(() => {
27564
+ if (charRef.current) {
27565
+ charWidthRef.current = charRef.current.getBoundingClientRect().width;
27566
+ }
27567
+ }, [value]);
27568
+ React$2.useEffect(() => {
27569
+ if (value === keyboardDataRef.current.newValue) {
27570
+ if (keyboardDataRef.current.mode === "input") {
27571
+ setCaretPosition((c) => c + 1);
27572
+ } else if (keyboardDataRef.current.mode === "delete") {
27573
+ setCaretPosition((c) => c - 1);
27574
+ }
27575
+ } else {
27576
+ setCaretPosition(value.length);
27577
+ }
27578
+ }, [value]);
27506
27579
  useIsomorphicLayoutEffect$3(() => {
27507
27580
  scrollToEnd();
27508
27581
  }, [value]);
@@ -27536,8 +27609,11 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27536
27609
  onInput: (v) => {
27537
27610
  var _a, _b;
27538
27611
  const newValue = value.substring(0, caretPosition) + v + value.substring(caretPosition);
27612
+ keyboardDataRef.current = {
27613
+ newValue,
27614
+ mode: "input"
27615
+ };
27539
27616
  setValue(newValue);
27540
- setCaretPosition((c) => c + 1);
27541
27617
  (_b = (_a = keyboard.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v);
27542
27618
  },
27543
27619
  onDelete: () => {
@@ -27545,8 +27621,11 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27545
27621
  if (caretPosition === 0)
27546
27622
  return;
27547
27623
  const newValue = value.substring(0, caretPosition - 1) + value.substring(caretPosition);
27624
+ keyboardDataRef.current = {
27625
+ newValue,
27626
+ mode: "delete"
27627
+ };
27548
27628
  setValue(newValue);
27549
- setCaretPosition(caretPosition - 1);
27550
27629
  (_b = (_a = keyboard.props).onDelete) === null || _b === void 0 ? void 0 : _b.call(_a);
27551
27630
  },
27552
27631
  visible: hasFocus,
@@ -27563,21 +27642,78 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27563
27642
  getContainer: null
27564
27643
  });
27565
27644
  const setCaretPositionToEnd = () => {
27566
- setCaretPosition(value.length);
27645
+ var _a, _b;
27646
+ if (caretPosition !== value.length) {
27647
+ setCaretPosition(value.length);
27648
+ (_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
27649
+ }
27567
27650
  };
27568
27651
  const changeCaretPosition = (index2) => (e2) => {
27652
+ var _a, _b, _c;
27653
+ if (mergedProps.disabled || !((_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.movable))
27654
+ return;
27569
27655
  e2.stopPropagation();
27570
27656
  const rect = e2.target.getBoundingClientRect();
27571
27657
  const midX = rect.left + rect.width / 2;
27572
27658
  const clickX = e2.clientX;
27573
27659
  const isRight = clickX > midX;
27574
- setCaretPosition(isRight ? index2 + 1 : index2);
27660
+ const newCaretPosition = isRight ? index2 + 1 : index2;
27661
+ setCaretPosition(newCaretPosition);
27662
+ (_c = (_b = mergedProps.cursor) === null || _b === void 0 ? void 0 : _b.onMove) === null || _c === void 0 ? void 0 : _c.call(_b, newCaretPosition);
27663
+ };
27664
+ const handleTouchStart = (e2) => {
27665
+ var _a;
27666
+ if (mergedProps.disabled || !((_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.movable))
27667
+ return;
27668
+ if (!caretRef.current)
27669
+ return;
27670
+ const touch = e2.touches[0];
27671
+ const caretRect = caretRef.current.getBoundingClientRect();
27672
+ const distance = Math.abs(touch.clientX - (caretRect.left + caretRect.width / 2));
27673
+ if (distance < 20) {
27674
+ touchDataRef.current = {
27675
+ startX: touch.clientX,
27676
+ startCaretPosition: caretPosition
27677
+ };
27678
+ } else {
27679
+ touchDataRef.current = null;
27680
+ }
27681
+ };
27682
+ const handleTouchMove = (e2) => {
27683
+ var _a, _b, _c;
27684
+ if (!touchDataRef.current || !((_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.movable))
27685
+ return;
27686
+ setIsCaretDragging(true);
27687
+ const touch = e2.touches[0];
27688
+ const deltaX = touch.clientX - touchDataRef.current.startX;
27689
+ const charWidth = charWidthRef.current;
27690
+ const moveChars = Math.round(deltaX / charWidth);
27691
+ let newCaretPosition = touchDataRef.current.startCaretPosition + moveChars;
27692
+ newCaretPosition = Math.max(0, Math.min(newCaretPosition, value.length));
27693
+ setCaretPosition(newCaretPosition);
27694
+ (_c = (_b = mergedProps.cursor) === null || _b === void 0 ? void 0 : _b.onMove) === null || _c === void 0 ? void 0 : _c.call(_b, newCaretPosition);
27695
+ if (touchMoveTimeoutRef.current) {
27696
+ clearTimeout(touchMoveTimeoutRef.current);
27697
+ }
27698
+ touchMoveTimeoutRef.current = setTimeout(() => {
27699
+ setIsCaretDragging(false);
27700
+ touchMoveTimeoutRef.current = null;
27701
+ }, 500);
27702
+ };
27703
+ const handleTouchEnd = () => {
27704
+ touchDataRef.current = null;
27705
+ setIsCaretDragging(false);
27706
+ if (touchMoveTimeoutRef.current) {
27707
+ clearTimeout(touchMoveTimeoutRef.current);
27708
+ touchMoveTimeoutRef.current = null;
27709
+ }
27575
27710
  };
27576
27711
  const chars = (value + "").split("");
27577
27712
  return withNativeProps(mergedProps, React$2.createElement("div", {
27578
27713
  ref: rootRef,
27579
27714
  className: classNames(classPrefix$2, {
27580
- [`${classPrefix$2}-disabled`]: mergedProps.disabled
27715
+ [`${classPrefix$2}-disabled`]: mergedProps.disabled,
27716
+ [`${classPrefix$2}-caret-dragging`]: isCaretDragging
27581
27717
  }),
27582
27718
  tabIndex: mergedProps.disabled ? void 0 : 0,
27583
27719
  role: "textbox",
@@ -27589,13 +27725,18 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27589
27725
  ref: contentRef,
27590
27726
  "aria-disabled": mergedProps.disabled,
27591
27727
  "aria-label": mergedProps.placeholder,
27592
- onClick: setCaretPositionToEnd
27728
+ onClick: setCaretPositionToEnd,
27729
+ onTouchStart: handleTouchStart,
27730
+ onTouchMove: handleTouchMove,
27731
+ onTouchEnd: handleTouchEnd
27593
27732
  }, chars.slice(0, caretPosition).map((i2, index2) => React$2.createElement("span", {
27733
+ ref: index2 === 0 ? charRef : void 0,
27594
27734
  key: index2,
27595
27735
  onClick: changeCaretPosition(index2)
27596
27736
  }, i2)), React$2.createElement("div", {
27597
27737
  className: `${classPrefix$2}-caret-container`
27598
27738
  }, hasFocus && React$2.createElement("div", {
27739
+ ref: caretRef,
27599
27740
  className: `${classPrefix$2}-caret`
27600
27741
  })), chars.slice(caretPosition).map((i2, index2) => React$2.createElement("span", {
27601
27742
  key: index2,
@@ -27606,7 +27747,6 @@ const VirtualInput = React$2.forwardRef((props, ref2) => {
27606
27747
  var _a;
27607
27748
  e2.stopPropagation();
27608
27749
  setValue("");
27609
- setCaretPosition(0);
27610
27750
  (_a = mergedProps.onClear) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
27611
27751
  },
27612
27752
  role: "button",