naive-ui 2.30.3 → 2.30.4

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 (226) hide show
  1. package/dist/index.js +1385 -901
  2. package/dist/index.prod.js +2 -2
  3. package/es/_internal/scrollbar/src/Scrollbar.js +5 -17
  4. package/es/_internal/select-menu/src/SelectGroupHeader.d.ts +1 -0
  5. package/es/_internal/select-menu/src/SelectGroupHeader.js +5 -3
  6. package/es/_internal/select-menu/src/SelectMenu.d.ts +3 -3
  7. package/es/_internal/select-menu/src/SelectMenu.js +6 -8
  8. package/es/_internal/select-menu/src/SelectOption.d.ts +1 -0
  9. package/es/_internal/select-menu/src/SelectOption.js +11 -5
  10. package/es/_internal/select-menu/src/interface.d.ts +3 -1
  11. package/es/_internal/selection/src/Selection.d.ts +0 -2
  12. package/es/_internal/selection/src/Selection.js +2 -2
  13. package/es/_mixins/use-theme.js +1 -1
  14. package/es/_utils/composable/index.d.ts +3 -5
  15. package/es/_utils/composable/index.js +3 -111
  16. package/es/_utils/composable/use-collection.d.ts +4 -0
  17. package/es/_utils/composable/use-collection.js +87 -0
  18. package/es/_utils/composable/use-deferred-true.d.ts +2 -0
  19. package/es/_utils/composable/use-deferred-true.js +25 -0
  20. package/es/_utils/composable/use-reactivated.d.ts +3 -0
  21. package/es/_utils/composable/use-reactivated.js +20 -0
  22. package/es/_utils/event/index.d.ts +2 -0
  23. package/es/_utils/event/index.js +7 -0
  24. package/es/_utils/index.d.ts +2 -1
  25. package/es/_utils/index.js +2 -1
  26. package/es/_utils/vue/index.d.ts +1 -0
  27. package/es/_utils/vue/index.js +1 -0
  28. package/es/_utils/vue/merge-handlers.d.ts +1 -0
  29. package/es/_utils/vue/merge-handlers.js +15 -0
  30. package/es/button/src/Button.js +7 -2
  31. package/es/cascader/src/Cascader.d.ts +2 -3
  32. package/es/cascader/src/Cascader.js +26 -22
  33. package/es/cascader/src/CascaderMenu.d.ts +2 -2
  34. package/es/cascader/src/CascaderMenu.js +2 -4
  35. package/es/data-table/src/DataTable.d.ts +787 -0
  36. package/es/data-table/src/DataTable.js +7 -3
  37. package/es/data-table/src/HeaderButton/FilterButton.d.ts +142 -0
  38. package/es/data-table/src/HeaderButton/FilterMenu.d.ts +142 -0
  39. package/es/data-table/src/MainTable.d.ts +2 -0
  40. package/es/data-table/src/MainTable.js +5 -1
  41. package/es/data-table/src/TableParts/Body.d.ts +143 -0
  42. package/es/data-table/src/TableParts/Body.js +11 -2
  43. package/es/data-table/src/TableParts/Cell.d.ts +284 -0
  44. package/es/data-table/src/TableParts/Header.d.ts +143 -0
  45. package/es/data-table/src/TableParts/Header.js +6 -2
  46. package/es/data-table/src/interface.d.ts +9 -5
  47. package/es/data-table/src/use-expand.d.ts +5 -3
  48. package/es/data-table/src/use-expand.js +22 -2
  49. package/es/data-table/src/utils.d.ts +2 -2
  50. package/es/data-table/src/utils.js +10 -8
  51. package/es/data-table/styles/light.d.ts +71 -0
  52. package/es/date-picker/src/DatePicker.d.ts +2 -1
  53. package/es/date-picker/src/DatePicker.js +20 -9
  54. package/es/date-picker/src/panel/month.js +3 -2
  55. package/es/drawer/src/Drawer.d.ts +1 -1
  56. package/es/drawer/src/Drawer.js +3 -3
  57. package/es/drawer/src/DrawerBodyWrapper.d.ts +2 -2
  58. package/es/dropdown/src/Dropdown.d.ts +4 -0
  59. package/es/dynamic-tags/src/DynamicTags.js +1 -1
  60. package/es/input/src/Input.d.ts +6 -3
  61. package/es/input/src/Input.js +56 -31
  62. package/es/input/src/utils.d.ts +7 -1
  63. package/es/input/src/utils.js +57 -2
  64. package/es/layout/src/Layout.d.ts +3 -1
  65. package/es/layout/src/Layout.js +22 -4
  66. package/es/layout/src/LayoutContent.d.ts +1 -0
  67. package/es/layout/src/LayoutSider.d.ts +1 -0
  68. package/es/layout/src/LayoutSider.js +22 -3
  69. package/es/menu/src/Menu.d.ts +1 -1
  70. package/es/modal/src/BodyWrapper.d.ts +2 -2
  71. package/es/modal/src/Modal.js +2 -2
  72. package/es/pagination/src/Pagination.d.ts +806 -20
  73. package/es/pagination/src/Pagination.js +115 -52
  74. package/es/pagination/src/interface.d.ts +2 -2
  75. package/es/pagination/src/styles/index.cssr.js +12 -10
  76. package/es/pagination/src/utils.d.ts +15 -5
  77. package/es/pagination/src/utils.js +117 -50
  78. package/es/pagination/styles/dark.js +3 -1
  79. package/es/pagination/styles/light.d.ts +71 -0
  80. package/es/pagination/styles/light.js +3 -1
  81. package/es/popconfirm/src/Popconfirm.d.ts +4 -0
  82. package/es/popover/src/Popover.d.ts +5 -0
  83. package/es/popover/src/Popover.js +1 -0
  84. package/es/popover/src/PopoverBody.d.ts +4 -0
  85. package/es/popover/src/PopoverBody.js +18 -10
  86. package/es/popselect/src/Popselect.d.ts +24 -0
  87. package/es/popselect/src/Popselect.js +12 -7
  88. package/es/popselect/src/PopselectPanel.d.ts +22 -2
  89. package/es/popselect/src/PopselectPanel.js +12 -1
  90. package/es/select/src/Select.d.ts +1 -1
  91. package/es/select/src/Select.js +5 -2
  92. package/es/slider/src/Slider.d.ts +1 -1
  93. package/es/slider/src/Slider.js +13 -5
  94. package/es/slider/src/styles/index.cssr.js +26 -31
  95. package/es/time-picker/src/TimePicker.d.ts +2 -1
  96. package/es/time-picker/src/TimePicker.js +18 -8
  97. package/es/tooltip/src/Tooltip.d.ts +4 -0
  98. package/es/tree/src/Tree.d.ts +2 -3
  99. package/es/tree/src/Tree.js +6 -8
  100. package/es/tree/src/TreeNode.js +4 -1
  101. package/es/tree/src/interface.d.ts +0 -1
  102. package/es/tree/src/keyboard.d.ts +0 -1
  103. package/es/tree/src/keyboard.js +6 -9
  104. package/es/tree-select/src/TreeSelect.d.ts +1 -3
  105. package/es/tree-select/src/TreeSelect.js +14 -16
  106. package/es/upload/src/UploadDragger.js +2 -2
  107. package/es/upload/src/UploadFile.d.ts +2 -2
  108. package/es/upload/src/UploadFile.js +9 -4
  109. package/es/upload/src/UploadTrigger.js +4 -3
  110. package/es/upload/src/styles/index.cssr.js +2 -2
  111. package/es/upload/src/utils.js +1 -15
  112. package/es/version.d.ts +1 -1
  113. package/es/version.js +1 -1
  114. package/lib/_internal/scrollbar/src/Scrollbar.js +4 -16
  115. package/lib/_internal/select-menu/src/SelectGroupHeader.d.ts +1 -0
  116. package/lib/_internal/select-menu/src/SelectGroupHeader.js +5 -3
  117. package/lib/_internal/select-menu/src/SelectMenu.d.ts +3 -3
  118. package/lib/_internal/select-menu/src/SelectMenu.js +5 -7
  119. package/lib/_internal/select-menu/src/SelectOption.d.ts +1 -0
  120. package/lib/_internal/select-menu/src/SelectOption.js +10 -4
  121. package/lib/_internal/select-menu/src/interface.d.ts +3 -1
  122. package/lib/_internal/selection/src/Selection.d.ts +0 -2
  123. package/lib/_internal/selection/src/Selection.js +2 -2
  124. package/lib/_mixins/use-theme.js +1 -1
  125. package/lib/_utils/composable/index.d.ts +3 -5
  126. package/lib/_utils/composable/index.js +9 -116
  127. package/lib/_utils/composable/use-collection.d.ts +4 -0
  128. package/lib/_utils/composable/use-collection.js +93 -0
  129. package/lib/_utils/composable/use-deferred-true.d.ts +2 -0
  130. package/lib/_utils/composable/use-deferred-true.js +29 -0
  131. package/lib/_utils/composable/use-reactivated.d.ts +3 -0
  132. package/lib/_utils/composable/use-reactivated.js +24 -0
  133. package/lib/_utils/event/index.d.ts +2 -0
  134. package/lib/_utils/event/index.js +12 -0
  135. package/lib/_utils/index.d.ts +2 -1
  136. package/lib/_utils/index.js +5 -1
  137. package/lib/_utils/vue/index.d.ts +1 -0
  138. package/lib/_utils/vue/index.js +3 -1
  139. package/lib/_utils/vue/merge-handlers.d.ts +1 -0
  140. package/lib/_utils/vue/merge-handlers.js +19 -0
  141. package/lib/button/src/Button.js +7 -2
  142. package/lib/cascader/src/Cascader.d.ts +2 -3
  143. package/lib/cascader/src/Cascader.js +25 -21
  144. package/lib/cascader/src/CascaderMenu.d.ts +2 -2
  145. package/lib/cascader/src/CascaderMenu.js +2 -4
  146. package/lib/data-table/src/DataTable.d.ts +787 -0
  147. package/lib/data-table/src/DataTable.js +7 -3
  148. package/lib/data-table/src/HeaderButton/FilterButton.d.ts +142 -0
  149. package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +142 -0
  150. package/lib/data-table/src/MainTable.d.ts +2 -0
  151. package/lib/data-table/src/MainTable.js +5 -1
  152. package/lib/data-table/src/TableParts/Body.d.ts +143 -0
  153. package/lib/data-table/src/TableParts/Body.js +11 -2
  154. package/lib/data-table/src/TableParts/Cell.d.ts +284 -0
  155. package/lib/data-table/src/TableParts/Header.d.ts +143 -0
  156. package/lib/data-table/src/TableParts/Header.js +6 -2
  157. package/lib/data-table/src/interface.d.ts +9 -5
  158. package/lib/data-table/src/use-expand.d.ts +5 -3
  159. package/lib/data-table/src/use-expand.js +22 -2
  160. package/lib/data-table/src/utils.d.ts +2 -2
  161. package/lib/data-table/src/utils.js +11 -9
  162. package/lib/data-table/styles/light.d.ts +71 -0
  163. package/lib/date-picker/src/DatePicker.d.ts +2 -1
  164. package/lib/date-picker/src/DatePicker.js +19 -8
  165. package/lib/date-picker/src/panel/month.js +3 -2
  166. package/lib/drawer/src/Drawer.d.ts +1 -1
  167. package/lib/drawer/src/Drawer.js +2 -2
  168. package/lib/drawer/src/DrawerBodyWrapper.d.ts +2 -2
  169. package/lib/dropdown/src/Dropdown.d.ts +4 -0
  170. package/lib/dynamic-tags/src/DynamicTags.js +1 -1
  171. package/lib/input/src/Input.d.ts +6 -3
  172. package/lib/input/src/Input.js +55 -30
  173. package/lib/input/src/utils.d.ts +7 -1
  174. package/lib/input/src/utils.js +60 -4
  175. package/lib/layout/src/Layout.d.ts +3 -1
  176. package/lib/layout/src/Layout.js +22 -4
  177. package/lib/layout/src/LayoutContent.d.ts +1 -0
  178. package/lib/layout/src/LayoutSider.d.ts +1 -0
  179. package/lib/layout/src/LayoutSider.js +21 -2
  180. package/lib/menu/src/Menu.d.ts +1 -1
  181. package/lib/modal/src/BodyWrapper.d.ts +2 -2
  182. package/lib/modal/src/Modal.js +1 -1
  183. package/lib/pagination/src/Pagination.d.ts +806 -20
  184. package/lib/pagination/src/Pagination.js +114 -51
  185. package/lib/pagination/src/interface.d.ts +2 -2
  186. package/lib/pagination/src/styles/index.cssr.js +13 -11
  187. package/lib/pagination/src/utils.d.ts +15 -5
  188. package/lib/pagination/src/utils.js +118 -53
  189. package/lib/pagination/styles/dark.js +6 -4
  190. package/lib/pagination/styles/light.d.ts +71 -0
  191. package/lib/pagination/styles/light.js +6 -4
  192. package/lib/popconfirm/src/Popconfirm.d.ts +4 -0
  193. package/lib/popover/src/Popover.d.ts +5 -0
  194. package/lib/popover/src/Popover.js +1 -0
  195. package/lib/popover/src/PopoverBody.d.ts +4 -0
  196. package/lib/popover/src/PopoverBody.js +18 -10
  197. package/lib/popselect/src/Popselect.d.ts +24 -0
  198. package/lib/popselect/src/Popselect.js +10 -5
  199. package/lib/popselect/src/PopselectPanel.d.ts +22 -2
  200. package/lib/popselect/src/PopselectPanel.js +12 -1
  201. package/lib/select/src/Select.d.ts +1 -1
  202. package/lib/select/src/Select.js +4 -1
  203. package/lib/slider/src/Slider.d.ts +1 -1
  204. package/lib/slider/src/Slider.js +12 -4
  205. package/lib/slider/src/styles/index.cssr.js +26 -31
  206. package/lib/time-picker/src/TimePicker.d.ts +2 -1
  207. package/lib/time-picker/src/TimePicker.js +17 -7
  208. package/lib/tooltip/src/Tooltip.d.ts +4 -0
  209. package/lib/tree/src/Tree.d.ts +2 -3
  210. package/lib/tree/src/Tree.js +6 -8
  211. package/lib/tree/src/TreeNode.js +4 -1
  212. package/lib/tree/src/interface.d.ts +0 -1
  213. package/lib/tree/src/keyboard.d.ts +0 -1
  214. package/lib/tree/src/keyboard.js +6 -9
  215. package/lib/tree-select/src/TreeSelect.d.ts +1 -3
  216. package/lib/tree-select/src/TreeSelect.js +13 -15
  217. package/lib/upload/src/UploadDragger.js +2 -2
  218. package/lib/upload/src/UploadFile.d.ts +2 -2
  219. package/lib/upload/src/UploadFile.js +9 -4
  220. package/lib/upload/src/UploadTrigger.js +3 -2
  221. package/lib/upload/src/styles/index.cssr.js +2 -2
  222. package/lib/upload/src/utils.js +1 -15
  223. package/lib/version.d.ts +1 -1
  224. package/lib/version.js +1 -1
  225. package/package.json +2 -2
  226. package/web-types.json +37 -1
@@ -626,6 +626,77 @@ declare const dataTableLight: import("../../_mixins").Theme<"DataTable", {
626
626
  paddingLarge: string;
627
627
  clearSize: string;
628
628
  }, any>;
629
+ Popselect: import("../../_mixins").Theme<"Popselect", {
630
+ menuBoxShadow: string;
631
+ }, {
632
+ Popover: import("../../_mixins").Theme<"Popover", {
633
+ fontSize: string;
634
+ borderRadius: string;
635
+ color: string;
636
+ dividerColor: string;
637
+ textColor: string;
638
+ boxShadow: string;
639
+ space: string;
640
+ spaceArrow: string;
641
+ arrowOffset: string;
642
+ arrowOffsetVertical: string;
643
+ arrowHeight: string;
644
+ padding: string;
645
+ }, any>;
646
+ InternalSelectMenu: import("../../_mixins").Theme<"InternalSelectMenu", {
647
+ optionFontSizeSmall: string;
648
+ optionFontSizeMedium: string;
649
+ optionFontSizeLarge: string;
650
+ optionFontSizeHuge: string;
651
+ optionHeightSmall: string;
652
+ optionHeightMedium: string;
653
+ optionHeightLarge: string;
654
+ optionHeightHuge: string;
655
+ borderRadius: string;
656
+ color: string;
657
+ groupHeaderTextColor: string;
658
+ actionDividerColor: string;
659
+ optionTextColor: string;
660
+ optionTextColorPressed: string;
661
+ optionTextColorDisabled: string;
662
+ optionTextColorActive: string;
663
+ optionOpacityDisabled: string;
664
+ optionCheckColor: string;
665
+ optionColorPending: string;
666
+ optionColorActive: string;
667
+ optionColorActivePending: string;
668
+ actionTextColor: string;
669
+ loadingColor: string;
670
+ height: string;
671
+ paddingSmall: string;
672
+ paddingMedium: string;
673
+ paddingLarge: string;
674
+ paddingHuge: string;
675
+ optionPaddingSmall: string;
676
+ optionPaddingMedium: string;
677
+ optionPaddingLarge: string;
678
+ optionPaddingHuge: string;
679
+ loadingSize: string;
680
+ }, {
681
+ Scrollbar: import("../../_mixins").Theme<"Scrollbar", {
682
+ color: string;
683
+ colorHover: string;
684
+ }, any>;
685
+ Empty: import("../../_mixins").Theme<"Empty", {
686
+ fontSizeSmall: string;
687
+ fontSizeMedium: string;
688
+ fontSizeLarge: string;
689
+ fontSizeHuge: string;
690
+ textColor: string;
691
+ iconColor: string;
692
+ extraTextColor: string;
693
+ iconSizeSmall: string;
694
+ iconSizeMedium: string;
695
+ iconSizeLarge: string;
696
+ iconSizeHuge: string;
697
+ }, any>;
698
+ }>;
699
+ }>;
629
700
  }>;
630
701
  Scrollbar: import("../../_mixins").Theme<"Scrollbar", {
631
702
  color: string;
@@ -3948,8 +3948,9 @@ declare const _default: import("vue").DefineComponent<{
3948
3948
  isValueInvalid: import("vue").ComputedRef<boolean>;
3949
3949
  isStartValueInvalid: import("vue").ComputedRef<boolean>;
3950
3950
  isEndValueInvalid: import("vue").ComputedRef<boolean>;
3951
+ handleInputKeydown: (e: KeyboardEvent) => void;
3951
3952
  handleClickOutside: (e: MouseEvent) => void;
3952
- handleKeyDown: (e: KeyboardEvent) => void;
3953
+ handleKeydown: (e: KeyboardEvent) => void;
3953
3954
  handleClear: () => void;
3954
3955
  handlePanelClear: () => void;
3955
3956
  handleTriggerClick: (e: MouseEvent) => void;
@@ -307,11 +307,14 @@ exports.default = (0, vue_1.defineComponent)({
307
307
  (0, _utils_1.call)(onUpdateShow, show);
308
308
  uncontrolledShowRef.value = show;
309
309
  }
310
- function handleKeyDown(e) {
310
+ function handleKeydown(e) {
311
311
  if (e.key === 'Escape') {
312
- closeCalendar({
313
- returnFocus: true
314
- });
312
+ if (mergedShowRef.value) {
313
+ (0, _utils_1.markEventEffectPerformed)(e);
314
+ closeCalendar({
315
+ returnFocus: true
316
+ });
317
+ }
315
318
  }
316
319
  // We need to handle the conflict with normal date value input
317
320
  // const { value: mergedValue } = mergedValueRef
@@ -320,6 +323,12 @@ exports.default = (0, vue_1.defineComponent)({
320
323
  // doUpdateValue(nextValue)
321
324
  // }
322
325
  }
326
+ function handleInputKeydown(e) {
327
+ if (e.key === 'Escape' && mergedShowRef.value) {
328
+ (0, _utils_1.markEventEffectPerformed)(e);
329
+ // closeCalendar will be called in handleDeactivated
330
+ }
331
+ }
323
332
  function handleClear() {
324
333
  var _a;
325
334
  doUpdateShow(false);
@@ -600,8 +609,9 @@ exports.default = (0, vue_1.defineComponent)({
600
609
  : undefined;
601
610
  return Object.assign(Object.assign({}, exposedMethods), { mergedStatus: mergedStatusRef, mergedClsPrefix: mergedClsPrefixRef, mergedBordered: mergedBorderedRef, namespace: namespaceRef, uncontrolledValue: uncontrolledValueRef, pendingValue: pendingValueRef, panelInstRef,
602
611
  triggerElRef,
603
- inputInstRef, isMounted: (0, vooks_1.useIsMounted)(), displayTime: singleInputValueRef, displayStartTime: rangeStartInputValueRef, displayEndTime: rangeEndInputValueRef, mergedShow: mergedShowRef, adjustedTo: (0, _utils_1.useAdjustedTo)(props), isRange: isRangeRef, localizedStartPlaceholder: localizedStartPlaceholderRef, localizedEndPlaceholder: localizedEndPlaceholderRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, localizedPlacehoder: localizedPlacehoderRef, isValueInvalid: uniVaidation.isValueInvalidRef, isStartValueInvalid: dualValidation.isStartValueInvalidRef, isEndValueInvalid: dualValidation.isEndValueInvalidRef, handleClickOutside,
604
- handleKeyDown,
612
+ inputInstRef, isMounted: (0, vooks_1.useIsMounted)(), displayTime: singleInputValueRef, displayStartTime: rangeStartInputValueRef, displayEndTime: rangeEndInputValueRef, mergedShow: mergedShowRef, adjustedTo: (0, _utils_1.useAdjustedTo)(props), isRange: isRangeRef, localizedStartPlaceholder: localizedStartPlaceholderRef, localizedEndPlaceholder: localizedEndPlaceholderRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, localizedPlacehoder: localizedPlacehoderRef, isValueInvalid: uniVaidation.isValueInvalidRef, isStartValueInvalid: dualValidation.isStartValueInvalidRef, isEndValueInvalid: dualValidation.isEndValueInvalidRef, handleInputKeydown,
613
+ handleClickOutside,
614
+ handleKeydown,
605
615
  handleClear,
606
616
  handlePanelClear,
607
617
  handleTriggerClick,
@@ -623,7 +633,7 @@ exports.default = (0, vue_1.defineComponent)({
623
633
  onTabOut: this.handlePanelTabOut,
624
634
  onClose: this.handlePanelClose,
625
635
  onClear: this.handlePanelClear,
626
- onKeydown: this.handleKeyDown,
636
+ onKeydown: this.handleKeydown,
627
637
  onConfirm: this.handlePanelConfirm,
628
638
  ref: 'panelInstRef',
629
639
  value: this.pendingValue,
@@ -653,6 +663,7 @@ exports.default = (0, vue_1.defineComponent)({
653
663
  clearable,
654
664
  onClear: this.handleClear,
655
665
  onClick: this.handleTriggerClick,
666
+ onKeydown: this.handleInputKeydown,
656
667
  onActivate: this.handleInputActivate,
657
668
  onDeactivate: this.handleInputDeactivate,
658
669
  onFocus: this.handleInputFocus,
@@ -663,7 +674,7 @@ exports.default = (0, vue_1.defineComponent)({
663
674
  this.mergedDisabled && `${mergedClsPrefix}-date-picker--disabled`,
664
675
  this.isRange && `${mergedClsPrefix}-date-picker--range`,
665
676
  this.triggerThemeClass
666
- ], style: this.triggerCssVars, onKeydown: this.handleKeyDown },
677
+ ], style: this.triggerCssVars, onKeydown: this.handleKeydown },
667
678
  (0, vue_1.h)(vueuc_1.VBinder, null, {
668
679
  default: () => [
669
680
  (0, vue_1.h)(vueuc_1.VTarget, null, {
@@ -32,6 +32,7 @@ exports.default = (0, vue_1.defineComponent)({
32
32
  return `Q ${item.dateObject.quarter}`;
33
33
  }
34
34
  };
35
+ const { useAsQuickJump } = props;
35
36
  const renderItem = (item, i, mergedClsPrefix) => {
36
37
  const { mergedIsDateDisabled, handleDateClick, handleQuickMonthClick } = useCalendarRef;
37
38
  return ((0, vue_1.h)("div", { "data-n-date": true, key: i, class: [
@@ -39,10 +40,10 @@ exports.default = (0, vue_1.defineComponent)({
39
40
  {
40
41
  [`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--current`]: item.isCurrent,
41
42
  [`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--selected`]: item.selected,
42
- [`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--disabled`]: mergedIsDateDisabled(item.ts)
43
+ [`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--disabled`]: !useAsQuickJump && mergedIsDateDisabled(item.ts)
43
44
  }
44
45
  ], onClick: () => {
45
- props.useAsQuickJump
46
+ useAsQuickJump
46
47
  ? handleQuickMonthClick(item, (value) => props.onUpdateValue(value, false))
47
48
  : handleDateClick(item);
48
49
  } }, getRenderContent(item)));
@@ -295,7 +295,7 @@ declare const _default: import("vue").DefineComponent<{
295
295
  namespace: import("vue").ComputedRef<string | undefined>;
296
296
  mergedBodyStyle: import("vue").ComputedRef<(string | CSSProperties)[]>;
297
297
  handleMaskClick: (e: MouseEvent) => void;
298
- handleEsc: () => void;
298
+ handleEsc: (e: KeyboardEvent) => void;
299
299
  mergedTheme: import("vue").ComputedRef<{
300
300
  common: {
301
301
  baseColor: string;
@@ -108,10 +108,10 @@ exports.default = (0, vue_1.defineComponent)({
108
108
  onMaskClick(e);
109
109
  }
110
110
  const isComposingRef = (0, _utils_1.useIsComposing)();
111
- function handleEsc() {
111
+ function handleEsc(e) {
112
112
  var _a;
113
113
  (_a = props.onEsc) === null || _a === void 0 ? void 0 : _a.call(props);
114
- if (props.closeOnEsc) {
114
+ if (props.show && props.closeOnEsc && (0, _utils_1.eventEffectNotPerformed)(e)) {
115
115
  !isComposingRef.value && doUpdateShow(false);
116
116
  }
117
117
  }
@@ -36,7 +36,7 @@ declare const _default: import("vue").DefineComponent<{
36
36
  onClickoutside: PropType<(e: MouseEvent) => void>;
37
37
  onAfterLeave: PropType<() => void>;
38
38
  onAfterEnter: PropType<() => void>;
39
- onEsc: PropType<() => void>;
39
+ onEsc: PropType<(e: KeyboardEvent) => void>;
40
40
  }, {
41
41
  bodyRef: import("vue").Ref<HTMLElement | null>;
42
42
  mergedClsPrefix: import("vue").Ref<string>;
@@ -222,7 +222,7 @@ declare const _default: import("vue").DefineComponent<{
222
222
  onClickoutside: PropType<(e: MouseEvent) => void>;
223
223
  onAfterLeave: PropType<() => void>;
224
224
  onAfterEnter: PropType<() => void>;
225
- onEsc: PropType<() => void>;
225
+ onEsc: PropType<(e: KeyboardEvent) => void>;
226
226
  }>>, {
227
227
  show: boolean | undefined;
228
228
  autoFocus: boolean;
@@ -323,6 +323,7 @@ declare const dropdownProps: {
323
323
  readonly onClickoutside: PropType<(e: MouseEvent) => void>;
324
324
  readonly 'onUpdate:show': PropType<MaybeArray<(value: boolean) => void>>;
325
325
  readonly onUpdateShow: PropType<MaybeArray<(value: boolean) => void>>;
326
+ readonly internalDeactivateImmediately: BooleanConstructor;
326
327
  readonly internalSyncTargetWithParent: BooleanConstructor;
327
328
  readonly internalInheritedEventHandlers: {
328
329
  type: PropType<import("../../popover/src/Popover").TriggerEventHandlers[]>;
@@ -646,6 +647,7 @@ declare const _default: import("vue").DefineComponent<{
646
647
  readonly onClickoutside: PropType<(e: MouseEvent) => void>;
647
648
  readonly 'onUpdate:show': PropType<MaybeArray<(value: boolean) => void>>;
648
649
  readonly onUpdateShow: PropType<MaybeArray<(value: boolean) => void>>;
650
+ readonly internalDeactivateImmediately: BooleanConstructor;
649
651
  readonly internalSyncTargetWithParent: BooleanConstructor;
650
652
  readonly internalInheritedEventHandlers: {
651
653
  type: PropType<import("../../popover/src/Popover").TriggerEventHandlers[]>;
@@ -1160,6 +1162,7 @@ declare const _default: import("vue").DefineComponent<{
1160
1162
  readonly onClickoutside: PropType<(e: MouseEvent) => void>;
1161
1163
  readonly 'onUpdate:show': PropType<MaybeArray<(value: boolean) => void>>;
1162
1164
  readonly onUpdateShow: PropType<MaybeArray<(value: boolean) => void>>;
1165
+ readonly internalDeactivateImmediately: BooleanConstructor;
1163
1166
  readonly internalSyncTargetWithParent: BooleanConstructor;
1164
1167
  readonly internalInheritedEventHandlers: {
1165
1168
  type: PropType<import("../../popover/src/Popover").TriggerEventHandlers[]>;
@@ -1199,6 +1202,7 @@ declare const _default: import("vue").DefineComponent<{
1199
1202
  readonly arrowPointToCenter: boolean;
1200
1203
  readonly displayDirective: "show" | "if";
1201
1204
  readonly keepAliveOnHover: boolean;
1205
+ readonly internalDeactivateImmediately: boolean;
1202
1206
  readonly animated: boolean;
1203
1207
  readonly internalTrapFocus: boolean;
1204
1208
  readonly defaultShow: boolean;
@@ -92,7 +92,7 @@ exports.default = (0, vue_1.defineComponent)({
92
92
  const nextValue = externalValue !== null && externalValue !== void 0 ? externalValue : inputValueRef.value;
93
93
  if (nextValue) {
94
94
  const tags = mergedValueRef.value.slice(0);
95
- tags.push(nextValue);
95
+ tags.push(props.onCreate(nextValue));
96
96
  doChange(tags);
97
97
  }
98
98
  showInputRef.value = false;
@@ -61,6 +61,7 @@ declare const inputProps: {
61
61
  type: BooleanConstructor;
62
62
  default: undefined;
63
63
  };
64
+ allowInput: PropType<(value: string) => boolean>;
64
65
  onMousedown: PropType<(e: MouseEvent) => void>;
65
66
  onKeydown: PropType<(e: KeyboardEvent) => void>;
66
67
  onKeyup: PropType<(e: KeyboardEvent) => void>;
@@ -330,6 +331,7 @@ declare const _default: import("vue").DefineComponent<{
330
331
  type: BooleanConstructor;
331
332
  default: undefined;
332
333
  };
334
+ allowInput: PropType<(value: string) => boolean>;
333
335
  onMousedown: PropType<(e: MouseEvent) => void>;
334
336
  onKeydown: PropType<(e: KeyboardEvent) => void>;
335
337
  onKeyup: PropType<(e: KeyboardEvent) => void>;
@@ -587,7 +589,7 @@ declare const _default: import("vue").DefineComponent<{
587
589
  handleCompositionEnd: (e: CompositionEvent) => void;
588
590
  handleInput: (e: InputEvent | CompositionEvent | Event, index?: 0 | 1, event?: string) => void;
589
591
  handleInputBlur: (e: FocusEvent) => void;
590
- handleInputFocus: (e: FocusEvent) => void;
592
+ handleInputFocus: (e: FocusEvent, index: number) => void;
591
593
  handleWrapperBlur: (e: FocusEvent) => void;
592
594
  handleWrapperFocus: (e: FocusEvent) => void;
593
595
  handleMouseEnter: () => void;
@@ -598,7 +600,7 @@ declare const _default: import("vue").DefineComponent<{
598
600
  handleClear: (e: MouseEvent) => void;
599
601
  handlePasswordToggleClick: () => void;
600
602
  handlePasswordToggleMousedown: (e: MouseEvent) => void;
601
- handleWrapperKeyDown: (e: KeyboardEvent) => void;
603
+ handleWrapperKeydown: (e: KeyboardEvent) => void;
602
604
  handleTextAreaMirrorResize: () => void;
603
605
  getTextareaScrollContainer: () => HTMLTextAreaElement | null;
604
606
  mergedTheme: import("vue").ComputedRef<{
@@ -655,7 +657,7 @@ declare const _default: import("vue").DefineComponent<{
655
657
  scrollbarWidth: string;
656
658
  scrollbarHeight: string;
657
659
  scrollbarBorderRadius: string;
658
- progressRailColor: string; /** deprecated */
660
+ progressRailColor: string;
659
661
  railColor: string;
660
662
  popoverColor: string;
661
663
  tableColor: string;
@@ -887,6 +889,7 @@ declare const _default: import("vue").DefineComponent<{
887
889
  type: BooleanConstructor;
888
890
  default: undefined;
889
891
  };
892
+ allowInput: PropType<(value: string) => boolean>;
890
893
  onMousedown: PropType<(e: MouseEvent) => void>;
891
894
  onKeydown: PropType<(e: KeyboardEvent) => void>;
892
895
  onKeyup: PropType<(e: KeyboardEvent) => void>;
@@ -9,6 +9,7 @@ const seemly_1 = require("seemly");
9
9
  const vueuc_1 = require("vueuc");
10
10
  const evtd_1 = require("evtd");
11
11
  const icons_1 = require("../../_internal/icons");
12
+ const use_rtl_1 = __importDefault(require("../../_mixins/use-rtl"));
12
13
  const _internal_1 = require("../../_internal");
13
14
  const _mixins_1 = require("../../_mixins");
14
15
  const _utils_1 = require("../../_utils");
@@ -17,7 +18,6 @@ const interface_1 = require("./interface");
17
18
  const utils_1 = require("./utils");
18
19
  const WordCount_1 = __importDefault(require("./WordCount"));
19
20
  const input_cssr_1 = __importDefault(require("./styles/input.cssr"));
20
- const use_rtl_1 = __importDefault(require("../../_mixins/use-rtl"));
21
21
  const inputProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), { bordered: {
22
22
  type: Boolean,
23
23
  default: undefined
@@ -48,7 +48,7 @@ const inputProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), {
48
48
  }, showCount: Boolean, loading: {
49
49
  type: Boolean,
50
50
  default: undefined
51
- }, onMousedown: Function, onKeydown: Function, onKeyup: Function, onInput: [Function, Array], onFocus: [Function, Array], onBlur: [Function, Array], onClick: [Function, Array], onChange: [Function, Array], onClear: [Function, Array], status: String, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array],
51
+ }, allowInput: Function, onMousedown: Function, onKeydown: Function, onKeyup: Function, onInput: [Function, Array], onFocus: [Function, Array], onBlur: [Function, Array], onClick: [Function, Array], onChange: [Function, Array], onClear: [Function, Array], status: String, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array],
52
52
  /** private */
53
53
  textDecoration: [String, Array], attrSize: {
54
54
  type: Number,
@@ -76,6 +76,8 @@ exports.default = (0, vue_1.defineComponent)({
76
76
  const inputMirrorElRef = (0, vue_1.ref)(null);
77
77
  const inputElRef = (0, vue_1.ref)(null);
78
78
  const inputEl2Ref = (0, vue_1.ref)(null);
79
+ const currentFocusedInputRef = (0, vue_1.ref)(null);
80
+ const focusedInputCursorControl = (0, utils_1.useCursor)(currentFocusedInputRef);
79
81
  const textareaScrollbarInstRef = (0, vue_1.ref)(null);
80
82
  // local
81
83
  const { localeRef } = (0, _mixins_1.useLocale)('Input');
@@ -116,8 +118,8 @@ exports.default = (0, vue_1.defineComponent)({
116
118
  const { value: mergedValue } = mergedValueRef;
117
119
  const { value: mergedPlaceholder } = mergedPlaceholderRef;
118
120
  return (!isComposing &&
119
- ((0, utils_1.isEmptyValue)(mergedValue) ||
120
- (Array.isArray(mergedValue) && (0, utils_1.isEmptyValue)(mergedValue[0]))) &&
121
+ ((0, utils_1.isEmptyInputValue)(mergedValue) ||
122
+ (Array.isArray(mergedValue) && (0, utils_1.isEmptyInputValue)(mergedValue[0]))) &&
121
123
  mergedPlaceholder[0]);
122
124
  });
123
125
  const showPlaceholder2Ref = (0, vue_1.computed)(() => {
@@ -126,8 +128,8 @@ exports.default = (0, vue_1.defineComponent)({
126
128
  const { value: mergedPlaceholder } = mergedPlaceholderRef;
127
129
  return (!isComposing &&
128
130
  mergedPlaceholder[1] &&
129
- ((0, utils_1.isEmptyValue)(mergedValue) ||
130
- (Array.isArray(mergedValue) && (0, utils_1.isEmptyValue)(mergedValue[1]))));
131
+ ((0, utils_1.isEmptyInputValue)(mergedValue) ||
132
+ (Array.isArray(mergedValue) && (0, utils_1.isEmptyInputValue)(mergedValue[1]))));
131
133
  });
132
134
  // focus
133
135
  const mergedFocusRef = (0, vooks_1.useMemo)(() => {
@@ -325,24 +327,37 @@ exports.default = (0, vue_1.defineComponent)({
325
327
  syncSource = targetValue;
326
328
  if (isComposingRef.value)
327
329
  return;
328
- const changedValue = targetValue;
329
- if (!props.pair) {
330
- event === 'input' ? doUpdateValue(changedValue) : doChange(changedValue);
331
- }
332
- else {
333
- let { value } = mergedValueRef;
334
- if (!Array.isArray(value)) {
335
- value = ['', ''];
330
+ focusedInputCursorControl.recordCursor();
331
+ const isIncomingValueValid = allowInput(targetValue);
332
+ if (isIncomingValueValid) {
333
+ if (!props.pair) {
334
+ event === 'input' ? doUpdateValue(targetValue) : doChange(targetValue);
336
335
  }
337
336
  else {
338
- value = [...value];
337
+ let { value } = mergedValueRef;
338
+ if (!Array.isArray(value)) {
339
+ value = ['', ''];
340
+ }
341
+ else {
342
+ value = [value[0], value[1]];
343
+ }
344
+ value[index] = targetValue;
345
+ event === 'input' ? doUpdateValue(value) : doChange(value);
339
346
  }
340
- value[index] = changedValue;
341
- event === 'input' ? doUpdateValue(value) : doChange(value);
342
347
  }
343
348
  // force update to sync input's view with value
344
349
  // if not set, after input, input value won't sync with dom input value
345
350
  vm.$forceUpdate();
351
+ if (!isIncomingValueValid) {
352
+ void (0, vue_1.nextTick)(focusedInputCursorControl.restoreCursor);
353
+ }
354
+ }
355
+ function allowInput(value) {
356
+ const { allowInput } = props;
357
+ if (typeof allowInput === 'function') {
358
+ return allowInput(value);
359
+ }
360
+ return true;
346
361
  }
347
362
  function handleInputBlur(e) {
348
363
  doUpdateValueBlur(e);
@@ -356,13 +371,23 @@ exports.default = (0, vue_1.defineComponent)({
356
371
  activatedRef.value = false;
357
372
  }
358
373
  dealWithEvent(e, 'blur');
374
+ currentFocusedInputRef.value = null;
359
375
  }
360
- function handleInputFocus(e) {
376
+ function handleInputFocus(e, index) {
361
377
  doUpdateValueFocus(e);
362
378
  focusedRef.value = true;
363
379
  activatedRef.value = true;
364
380
  doActivate();
365
381
  dealWithEvent(e, 'focus');
382
+ if (index === 0) {
383
+ currentFocusedInputRef.value = inputElRef.value;
384
+ }
385
+ else if (index === 1) {
386
+ currentFocusedInputRef.value = inputEl2Ref.value;
387
+ }
388
+ else if (index === 2) {
389
+ currentFocusedInputRef.value = textareaElRef.value;
390
+ }
366
391
  }
367
392
  function handleWrapperBlur(e) {
368
393
  if (props.passivelyActivated) {
@@ -482,25 +507,25 @@ exports.default = (0, vue_1.defineComponent)({
482
507
  };
483
508
  (0, evtd_1.on)('mouseup', document, hidePassword);
484
509
  }
485
- function handleWrapperKeyDown(e) {
510
+ function handleWrapperKeydown(e) {
486
511
  var _a;
487
512
  (_a = props.onKeydown) === null || _a === void 0 ? void 0 : _a.call(props, e);
488
513
  switch (e.key) {
489
514
  case 'Escape':
490
- handleWrapperKeyDownEsc();
515
+ handleWrapperKeydownEsc();
491
516
  break;
492
517
  case 'Enter':
493
- handleWrapperKeyDownEnter(e);
518
+ handleWrapperKeydownEnter(e);
494
519
  break;
495
520
  }
496
521
  }
497
- function handleWrapperKeyDownEnter(e) {
522
+ function handleWrapperKeydownEnter(e) {
498
523
  var _a, _b;
499
524
  if (props.passivelyActivated) {
500
525
  const { value: focused } = activatedRef;
501
526
  if (focused) {
502
527
  if (props.internalDeactivateOnEnter) {
503
- handleWrapperKeyDownEsc();
528
+ handleWrapperKeydownEsc();
504
529
  }
505
530
  return;
506
531
  }
@@ -513,7 +538,7 @@ exports.default = (0, vue_1.defineComponent)({
513
538
  }
514
539
  }
515
540
  }
516
- function handleWrapperKeyDownEsc() {
541
+ function handleWrapperKeydownEsc() {
517
542
  if (props.passivelyActivated) {
518
543
  activatedRef.value = false;
519
544
  void (0, vue_1.nextTick)(() => {
@@ -558,7 +583,7 @@ exports.default = (0, vue_1.defineComponent)({
558
583
  const { value: wrapperEl } = wrapperElRef;
559
584
  if ((wrapperEl === null || wrapperEl === void 0 ? void 0 : wrapperEl.contains(document.activeElement)) &&
560
585
  wrapperEl !== document.activeElement) {
561
- handleWrapperKeyDownEsc();
586
+ handleWrapperKeydownEsc();
562
587
  }
563
588
  }
564
589
  function syncMirror(value) {
@@ -731,7 +756,7 @@ exports.default = (0, vue_1.defineComponent)({
731
756
  handleClear,
732
757
  handlePasswordToggleClick,
733
758
  handlePasswordToggleMousedown,
734
- handleWrapperKeyDown,
759
+ handleWrapperKeydown,
735
760
  handleTextAreaMirrorResize, getTextareaScrollContainer: () => {
736
761
  return textareaElRef.value;
737
762
  }, mergedTheme: themeRef, cssVars: inlineThemeDisabled ? undefined : cssVarsRef, themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass, onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender });
@@ -758,7 +783,7 @@ exports.default = (0, vue_1.defineComponent)({
758
783
  }
759
784
  ], style: this.cssVars, tabindex: !this.mergedDisabled && this.passivelyActivated && !this.activated
760
785
  ? 0
761
- : undefined, onFocus: this.handleWrapperFocus, onBlur: this.handleWrapperBlur, onClick: this.handleClick, onMousedown: this.handleMouseDown, onMouseenter: this.handleMouseEnter, onMouseleave: this.handleMouseLeave, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, onKeyup: this.onKeyup, onKeydown: this.handleWrapperKeyDown },
786
+ : undefined, onFocus: this.handleWrapperFocus, onBlur: this.handleWrapperBlur, onClick: this.handleClick, onMousedown: this.handleMouseDown, onMouseenter: this.handleMouseEnter, onMouseleave: this.handleMouseLeave, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, onKeyup: this.onKeyup, onKeydown: this.handleWrapperKeydown },
762
787
  (0, vue_1.h)("div", { class: `${mergedClsPrefix}-input-wrapper` },
763
788
  (0, _utils_1.resolveWrappedSlot)($slots.prefix, (children) => children && ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-input__prefix` }, children))),
764
789
  this.type === 'textarea' ? ((0, vue_1.h)(_internal_1.NScrollbar, { ref: "textareaScrollbarInstRef", class: `${mergedClsPrefix}-input__textarea`, container: this.getTextareaScrollContainer, triggerDisplayManually: true, useUnifiedContainer: true }, {
@@ -780,7 +805,7 @@ exports.default = (0, vue_1.defineComponent)({
780
805
  this.textDecorationStyle[0],
781
806
  (_b = this.inputProps) === null || _b === void 0 ? void 0 : _b.style,
782
807
  scrollContainerWidthStyle
783
- ], onBlur: this.handleInputBlur, onFocus: this.handleInputFocus, onInput: this.handleInput, onChange: this.handleChange, onScroll: this.handleTextAreaScroll })),
808
+ ], onBlur: this.handleInputBlur, onFocus: (e) => this.handleInputFocus(e, 2), onInput: this.handleInput, onChange: this.handleChange, onScroll: this.handleTextAreaScroll })),
784
809
  this.showPlaceholder1 ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-input__placeholder`, style: [
785
810
  this.placeholderStyle,
786
811
  scrollContainerWidthStyle
@@ -802,7 +827,7 @@ exports.default = (0, vue_1.defineComponent)({
802
827
  (_b = this.inputProps) === null || _b === void 0 ? void 0 : _b.style
803
828
  ], tabindex: this.passivelyActivated && !this.activated ? -1 : undefined, placeholder: this.mergedPlaceholder[0], disabled: this.mergedDisabled, maxlength: this.maxlength, minlength: this.minlength, value: Array.isArray(this.mergedValue)
804
829
  ? this.mergedValue[0]
805
- : this.mergedValue, readonly: this.readonly, autofocus: this.autofocus, size: this.attrSize, onBlur: this.handleInputBlur, onFocus: this.handleInputFocus, onInput: (e) => this.handleInput(e, 0), onChange: (e) => this.handleChange(e, 0) })),
830
+ : this.mergedValue, readonly: this.readonly, autofocus: this.autofocus, size: this.attrSize, onBlur: this.handleInputBlur, onFocus: (e) => this.handleInputFocus(e, 0), onInput: (e) => this.handleInput(e, 0), onChange: (e) => this.handleChange(e, 0) })),
806
831
  this.showPlaceholder1 ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-input__placeholder` },
807
832
  (0, vue_1.h)("span", null, this.mergedPlaceholder[0]))) : null,
808
833
  this.autosize ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-input__input-mirror`, key: "mirror", ref: "inputMirrorElRef" }, "\u00A0")) : null)),
@@ -839,7 +864,7 @@ exports.default = (0, vue_1.defineComponent)({
839
864
  (0, vue_1.h)("div", { class: `${mergedClsPrefix}-input__input` },
840
865
  (0, vue_1.h)("input", { ref: "inputEl2Ref", type: this.type, class: `${mergedClsPrefix}-input__input-el`, tabindex: this.passivelyActivated && !this.activated ? -1 : undefined, placeholder: this.mergedPlaceholder[1], disabled: this.mergedDisabled, maxlength: this.maxlength, minlength: this.minlength, value: Array.isArray(this.mergedValue)
841
866
  ? this.mergedValue[1]
842
- : undefined, readonly: this.readonly, style: this.textDecorationStyle[1], onBlur: this.handleInputBlur, onFocus: this.handleInputFocus, onInput: (e) => this.handleInput(e, 1), onChange: (e) => this.handleChange(e, 1) }),
867
+ : undefined, readonly: this.readonly, style: this.textDecorationStyle[1], onBlur: this.handleInputBlur, onFocus: (e) => this.handleInputFocus(e, 1), onInput: (e) => this.handleInput(e, 1), onChange: (e) => this.handleChange(e, 1) }),
843
868
  this.showPlaceholder2 ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-input__placeholder` },
844
869
  (0, vue_1.h)("span", null, this.mergedPlaceholder[1]))) : null),
845
870
  (0, _utils_1.resolveWrappedSlot)($slots.suffix, (children) => {
@@ -1,2 +1,8 @@
1
+ import type { Ref } from 'vue';
1
2
  export declare function len(s: string): number;
2
- export declare function isEmptyValue(value: any): boolean;
3
+ export declare function isEmptyInputValue(value: unknown): boolean;
4
+ export interface UseCursorControl {
5
+ recordCursor: () => void;
6
+ restoreCursor: () => void;
7
+ }
8
+ export declare function useCursor(inputElRef: Ref<HTMLInputElement | HTMLTextAreaElement | null>): UseCursorControl;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmptyValue = exports.len = void 0;
3
+ exports.useCursor = exports.isEmptyInputValue = exports.len = void 0;
4
+ const vue_1 = require("vue");
4
5
  function len(s) {
5
6
  let count = 0;
6
7
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -10,7 +11,62 @@ function len(s) {
10
11
  return count;
11
12
  }
12
13
  exports.len = len;
13
- function isEmptyValue(value) {
14
- return ['', undefined, null].includes(value);
14
+ function isEmptyInputValue(value) {
15
+ return value === '' || value == null;
15
16
  }
16
- exports.isEmptyValue = isEmptyValue;
17
+ exports.isEmptyInputValue = isEmptyInputValue;
18
+ function useCursor(inputElRef) {
19
+ const selectionRef = (0, vue_1.ref)(null);
20
+ function recordCursor() {
21
+ const { value: input } = inputElRef;
22
+ if (!input || !input.focus) {
23
+ reset();
24
+ return;
25
+ }
26
+ const { selectionStart, selectionEnd, value } = input;
27
+ if (selectionStart == null || selectionEnd == null) {
28
+ reset();
29
+ return;
30
+ }
31
+ selectionRef.value = {
32
+ start: selectionStart,
33
+ end: selectionEnd,
34
+ beforeText: value.slice(0, selectionStart),
35
+ afterText: value.slice(selectionEnd)
36
+ };
37
+ }
38
+ function restoreCursor() {
39
+ var _a;
40
+ const { value: selection } = selectionRef;
41
+ const { value: inputEl } = inputElRef;
42
+ if (!selection || !inputEl) {
43
+ return;
44
+ }
45
+ const { value } = inputEl;
46
+ const { start, beforeText, afterText } = selection;
47
+ let startPos = value.length;
48
+ if (value.endsWith(afterText)) {
49
+ startPos = value.length - afterText.length;
50
+ }
51
+ else if (value.startsWith(beforeText)) {
52
+ startPos = beforeText.length;
53
+ }
54
+ else {
55
+ const beforeLastChar = beforeText[start - 1];
56
+ const newIndex = value.indexOf(beforeLastChar, start - 1);
57
+ if (newIndex !== -1) {
58
+ startPos = newIndex + 1;
59
+ }
60
+ }
61
+ (_a = inputEl.setSelectionRange) === null || _a === void 0 ? void 0 : _a.call(inputEl, startPos, startPos);
62
+ }
63
+ function reset() {
64
+ selectionRef.value = null;
65
+ }
66
+ (0, vue_1.watch)(inputElRef, reset);
67
+ return {
68
+ recordCursor,
69
+ restoreCursor
70
+ };
71
+ }
72
+ exports.useCursor = useCursor;
@@ -1,6 +1,6 @@
1
1
  import { PropType, CSSProperties, ExtractPropTypes } from 'vue';
2
2
  import type { ScrollbarProps } from '../../_internal';
3
- import { ExtractPublicPropTypes } from '../../_utils';
3
+ import type { ExtractPublicPropTypes } from '../../_utils';
4
4
  declare const layoutProps: {
5
5
  readonly embedded: BooleanConstructor;
6
6
  readonly position: {
@@ -319,6 +319,7 @@ export declare function createLayoutComponent(isContent: boolean): import("vue")
319
319
  } | undefined;
320
320
  };
321
321
  }>;
322
+ handleNativeElScroll: (e: Event) => void;
322
323
  cssVars: import("vue").ComputedRef<{
323
324
  '--n-bezier': string;
324
325
  '--n-color': string;
@@ -718,6 +719,7 @@ declare const _default: import("vue").DefineComponent<{
718
719
  } | undefined;
719
720
  };
720
721
  }>;
722
+ handleNativeElScroll: (e: Event) => void;
721
723
  cssVars: import("vue").ComputedRef<{
722
724
  '--n-bezier': string;
723
725
  '--n-color': string;