naive-ui 2.30.3 → 2.30.6

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 (279) hide show
  1. package/dist/index.js +1829 -1088
  2. package/dist/index.prod.js +2 -2
  3. package/es/_internal/scrollbar/src/Scrollbar.js +5 -18
  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 +7 -5
  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/dom/index.d.ts +1 -0
  23. package/es/_utils/dom/index.js +1 -0
  24. package/es/_utils/dom/is-document.d.ts +1 -0
  25. package/es/_utils/dom/is-document.js +3 -0
  26. package/es/_utils/event/index.d.ts +2 -0
  27. package/es/_utils/event/index.js +7 -0
  28. package/es/_utils/index.d.ts +3 -1
  29. package/es/_utils/index.js +3 -1
  30. package/es/_utils/vue/index.d.ts +3 -0
  31. package/es/_utils/vue/index.js +3 -0
  32. package/es/_utils/vue/is-node-v-show-false.d.ts +2 -0
  33. package/es/_utils/vue/is-node-v-show-false.js +6 -0
  34. package/es/_utils/vue/merge-handlers.d.ts +1 -0
  35. package/es/_utils/vue/merge-handlers.js +15 -0
  36. package/es/{_internal/scrollbar/src/Wrapper.d.ts → _utils/vue/wrapper.d.ts} +0 -0
  37. package/es/{_internal/scrollbar/src/Wrapper.js → _utils/vue/wrapper.js} +0 -0
  38. package/es/back-top/src/BackTop.d.ts +1 -1
  39. package/es/back-top/src/BackTop.js +24 -31
  40. package/es/button/src/Button.js +7 -2
  41. package/es/cascader/src/Cascader.d.ts +2 -3
  42. package/es/cascader/src/Cascader.js +26 -22
  43. package/es/cascader/src/CascaderMenu.d.ts +2 -2
  44. package/es/cascader/src/CascaderMenu.js +2 -4
  45. package/es/color-picker/src/ColorInputUnit.js +1 -1
  46. package/es/data-table/src/DataTable.d.ts +792 -2
  47. package/es/data-table/src/DataTable.js +10 -5
  48. package/es/data-table/src/HeaderButton/FilterButton.d.ts +142 -0
  49. package/es/data-table/src/HeaderButton/FilterMenu.d.ts +142 -0
  50. package/es/data-table/src/MainTable.d.ts +2 -0
  51. package/es/data-table/src/MainTable.js +5 -1
  52. package/es/data-table/src/TableParts/Body.d.ts +144 -0
  53. package/es/data-table/src/TableParts/Body.js +15 -8
  54. package/es/data-table/src/TableParts/Cell.d.ts +295 -1
  55. package/es/data-table/src/TableParts/Cell.js +19 -6
  56. package/es/data-table/src/TableParts/Header.d.ts +143 -0
  57. package/es/data-table/src/TableParts/Header.js +6 -2
  58. package/es/data-table/src/interface.d.ts +14 -7
  59. package/es/data-table/src/styles/index.cssr.js +7 -2
  60. package/es/data-table/src/use-check.js +11 -3
  61. package/es/data-table/src/use-expand.d.ts +5 -3
  62. package/es/data-table/src/use-expand.js +22 -2
  63. package/es/data-table/src/utils.d.ts +2 -2
  64. package/es/data-table/src/utils.js +10 -8
  65. package/es/data-table/styles/light.d.ts +71 -0
  66. package/es/date-picker/src/DatePicker.d.ts +2 -1
  67. package/es/date-picker/src/DatePicker.js +20 -9
  68. package/es/date-picker/src/panel/month.js +3 -2
  69. package/es/drawer/src/Drawer.d.ts +1 -1
  70. package/es/drawer/src/Drawer.js +3 -3
  71. package/es/drawer/src/DrawerBodyWrapper.d.ts +2 -2
  72. package/es/dropdown/src/Dropdown.d.ts +4 -0
  73. package/es/dynamic-tags/src/DynamicTags.js +1 -1
  74. package/es/grid/src/Grid.d.ts +3 -0
  75. package/es/grid/src/Grid.js +47 -9
  76. package/es/grid/src/GridItem.js +2 -1
  77. package/es/image/src/Image.d.ts +10 -0
  78. package/es/image/src/Image.js +42 -8
  79. package/es/image/src/utils.d.ts +11 -0
  80. package/es/image/src/utils.js +81 -0
  81. package/es/input/src/Input.d.ts +6 -3
  82. package/es/input/src/Input.js +56 -31
  83. package/es/input/src/styles/input-group-label.cssr.js +2 -0
  84. package/es/input/src/utils.d.ts +7 -1
  85. package/es/input/src/utils.js +57 -2
  86. package/es/layout/src/Layout.d.ts +3 -1
  87. package/es/layout/src/Layout.js +22 -4
  88. package/es/layout/src/LayoutContent.d.ts +1 -0
  89. package/es/layout/src/LayoutSider.d.ts +1 -0
  90. package/es/layout/src/LayoutSider.js +22 -3
  91. package/es/menu/src/Menu.d.ts +1 -1
  92. package/es/modal/src/BodyWrapper.d.ts +15 -20
  93. package/es/modal/src/BodyWrapper.js +38 -33
  94. package/es/modal/src/Modal.js +14 -9
  95. package/es/pagination/src/Pagination.d.ts +806 -20
  96. package/es/pagination/src/Pagination.js +115 -52
  97. package/es/pagination/src/interface.d.ts +2 -2
  98. package/es/pagination/src/styles/index.cssr.js +12 -10
  99. package/es/pagination/src/utils.d.ts +15 -5
  100. package/es/pagination/src/utils.js +117 -50
  101. package/es/pagination/styles/dark.js +3 -1
  102. package/es/pagination/styles/light.d.ts +71 -0
  103. package/es/pagination/styles/light.js +3 -1
  104. package/es/popconfirm/src/Popconfirm.d.ts +4 -0
  105. package/es/popover/src/Popover.d.ts +5 -0
  106. package/es/popover/src/Popover.js +1 -0
  107. package/es/popover/src/PopoverBody.d.ts +4 -0
  108. package/es/popover/src/PopoverBody.js +18 -10
  109. package/es/popselect/src/Popselect.d.ts +24 -0
  110. package/es/popselect/src/Popselect.js +12 -7
  111. package/es/popselect/src/PopselectPanel.d.ts +22 -2
  112. package/es/popselect/src/PopselectPanel.js +12 -1
  113. package/es/select/src/Select.d.ts +1 -1
  114. package/es/select/src/Select.js +5 -2
  115. package/es/slider/src/Slider.d.ts +1 -1
  116. package/es/slider/src/Slider.js +13 -5
  117. package/es/slider/src/styles/index.cssr.js +26 -31
  118. package/es/space/src/Space.d.ts +26 -0
  119. package/es/space/src/Space.js +53 -43
  120. package/es/time-picker/src/TimePicker.d.ts +2 -1
  121. package/es/time-picker/src/TimePicker.js +18 -8
  122. package/es/tooltip/index.d.ts +1 -1
  123. package/es/tooltip/src/Tooltip.d.ts +4 -0
  124. package/es/tree/src/Tree.d.ts +2 -3
  125. package/es/tree/src/Tree.js +6 -8
  126. package/es/tree/src/TreeNode.js +4 -1
  127. package/es/tree/src/interface.d.ts +0 -1
  128. package/es/tree/src/keyboard.d.ts +0 -1
  129. package/es/tree/src/keyboard.js +6 -9
  130. package/es/tree-select/src/TreeSelect.d.ts +1 -3
  131. package/es/tree-select/src/TreeSelect.js +14 -16
  132. package/es/upload/src/UploadDragger.js +2 -2
  133. package/es/upload/src/UploadFile.d.ts +2 -2
  134. package/es/upload/src/UploadFile.js +9 -4
  135. package/es/upload/src/UploadTrigger.js +4 -3
  136. package/es/upload/src/styles/index.cssr.js +2 -2
  137. package/es/upload/src/utils.js +1 -15
  138. package/es/version.d.ts +1 -1
  139. package/es/version.js +1 -1
  140. package/lib/_internal/scrollbar/src/Scrollbar.js +6 -19
  141. package/lib/_internal/select-menu/src/SelectGroupHeader.d.ts +1 -0
  142. package/lib/_internal/select-menu/src/SelectGroupHeader.js +5 -3
  143. package/lib/_internal/select-menu/src/SelectMenu.d.ts +3 -3
  144. package/lib/_internal/select-menu/src/SelectMenu.js +5 -7
  145. package/lib/_internal/select-menu/src/SelectOption.d.ts +1 -0
  146. package/lib/_internal/select-menu/src/SelectOption.js +10 -4
  147. package/lib/_internal/select-menu/src/interface.d.ts +3 -1
  148. package/lib/_internal/selection/src/Selection.d.ts +0 -2
  149. package/lib/_internal/selection/src/Selection.js +6 -4
  150. package/lib/_mixins/use-theme.js +1 -1
  151. package/lib/_utils/composable/index.d.ts +3 -5
  152. package/lib/_utils/composable/index.js +9 -116
  153. package/lib/_utils/composable/use-collection.d.ts +4 -0
  154. package/lib/_utils/composable/use-collection.js +93 -0
  155. package/lib/_utils/composable/use-deferred-true.d.ts +2 -0
  156. package/lib/_utils/composable/use-deferred-true.js +29 -0
  157. package/lib/_utils/composable/use-reactivated.d.ts +3 -0
  158. package/lib/_utils/composable/use-reactivated.js +24 -0
  159. package/lib/_utils/dom/index.d.ts +1 -0
  160. package/lib/_utils/dom/index.js +5 -0
  161. package/lib/_utils/dom/is-document.d.ts +1 -0
  162. package/lib/_utils/dom/is-document.js +7 -0
  163. package/lib/_utils/event/index.d.ts +2 -0
  164. package/lib/_utils/event/index.js +12 -0
  165. package/lib/_utils/index.d.ts +3 -1
  166. package/lib/_utils/index.js +8 -1
  167. package/lib/_utils/vue/index.d.ts +3 -0
  168. package/lib/_utils/vue/index.js +7 -1
  169. package/lib/_utils/vue/is-node-v-show-false.d.ts +2 -0
  170. package/lib/_utils/vue/is-node-v-show-false.js +10 -0
  171. package/lib/_utils/vue/merge-handlers.d.ts +1 -0
  172. package/lib/_utils/vue/merge-handlers.js +19 -0
  173. package/lib/{_internal/scrollbar/src/Wrapper.d.ts → _utils/vue/wrapper.d.ts} +0 -0
  174. package/lib/{_internal/scrollbar/src/Wrapper.js → _utils/vue/wrapper.js} +0 -0
  175. package/lib/back-top/src/BackTop.d.ts +1 -1
  176. package/lib/back-top/src/BackTop.js +23 -30
  177. package/lib/button/src/Button.js +7 -2
  178. package/lib/cascader/src/Cascader.d.ts +2 -3
  179. package/lib/cascader/src/Cascader.js +25 -21
  180. package/lib/cascader/src/CascaderMenu.d.ts +2 -2
  181. package/lib/cascader/src/CascaderMenu.js +2 -4
  182. package/lib/color-picker/src/ColorInputUnit.js +1 -1
  183. package/lib/data-table/src/DataTable.d.ts +792 -2
  184. package/lib/data-table/src/DataTable.js +10 -5
  185. package/lib/data-table/src/HeaderButton/FilterButton.d.ts +142 -0
  186. package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +142 -0
  187. package/lib/data-table/src/MainTable.d.ts +2 -0
  188. package/lib/data-table/src/MainTable.js +5 -1
  189. package/lib/data-table/src/TableParts/Body.d.ts +144 -0
  190. package/lib/data-table/src/TableParts/Body.js +15 -8
  191. package/lib/data-table/src/TableParts/Cell.d.ts +295 -1
  192. package/lib/data-table/src/TableParts/Cell.js +19 -6
  193. package/lib/data-table/src/TableParts/Header.d.ts +143 -0
  194. package/lib/data-table/src/TableParts/Header.js +6 -2
  195. package/lib/data-table/src/interface.d.ts +14 -7
  196. package/lib/data-table/src/styles/index.cssr.js +7 -2
  197. package/lib/data-table/src/use-check.js +11 -3
  198. package/lib/data-table/src/use-expand.d.ts +5 -3
  199. package/lib/data-table/src/use-expand.js +22 -2
  200. package/lib/data-table/src/utils.d.ts +2 -2
  201. package/lib/data-table/src/utils.js +11 -9
  202. package/lib/data-table/styles/light.d.ts +71 -0
  203. package/lib/date-picker/src/DatePicker.d.ts +2 -1
  204. package/lib/date-picker/src/DatePicker.js +19 -8
  205. package/lib/date-picker/src/panel/month.js +3 -2
  206. package/lib/drawer/src/Drawer.d.ts +1 -1
  207. package/lib/drawer/src/Drawer.js +2 -2
  208. package/lib/drawer/src/DrawerBodyWrapper.d.ts +2 -2
  209. package/lib/dropdown/src/Dropdown.d.ts +4 -0
  210. package/lib/dynamic-tags/src/DynamicTags.js +1 -1
  211. package/lib/grid/src/Grid.d.ts +3 -0
  212. package/lib/grid/src/Grid.js +45 -7
  213. package/lib/grid/src/GridItem.js +2 -1
  214. package/lib/image/src/Image.d.ts +10 -0
  215. package/lib/image/src/Image.js +41 -7
  216. package/lib/image/src/utils.d.ts +11 -0
  217. package/lib/image/src/utils.js +86 -0
  218. package/lib/input/src/Input.d.ts +6 -3
  219. package/lib/input/src/Input.js +55 -30
  220. package/lib/input/src/styles/input-group-label.cssr.js +2 -0
  221. package/lib/input/src/utils.d.ts +7 -1
  222. package/lib/input/src/utils.js +60 -4
  223. package/lib/layout/src/Layout.d.ts +3 -1
  224. package/lib/layout/src/Layout.js +22 -4
  225. package/lib/layout/src/LayoutContent.d.ts +1 -0
  226. package/lib/layout/src/LayoutSider.d.ts +1 -0
  227. package/lib/layout/src/LayoutSider.js +21 -2
  228. package/lib/menu/src/Menu.d.ts +1 -1
  229. package/lib/modal/src/BodyWrapper.d.ts +15 -20
  230. package/lib/modal/src/BodyWrapper.js +38 -33
  231. package/lib/modal/src/Modal.js +13 -8
  232. package/lib/pagination/src/Pagination.d.ts +806 -20
  233. package/lib/pagination/src/Pagination.js +114 -51
  234. package/lib/pagination/src/interface.d.ts +2 -2
  235. package/lib/pagination/src/styles/index.cssr.js +13 -11
  236. package/lib/pagination/src/utils.d.ts +15 -5
  237. package/lib/pagination/src/utils.js +118 -53
  238. package/lib/pagination/styles/dark.js +6 -4
  239. package/lib/pagination/styles/light.d.ts +71 -0
  240. package/lib/pagination/styles/light.js +6 -4
  241. package/lib/popconfirm/src/Popconfirm.d.ts +4 -0
  242. package/lib/popover/src/Popover.d.ts +5 -0
  243. package/lib/popover/src/Popover.js +1 -0
  244. package/lib/popover/src/PopoverBody.d.ts +4 -0
  245. package/lib/popover/src/PopoverBody.js +18 -10
  246. package/lib/popselect/src/Popselect.d.ts +24 -0
  247. package/lib/popselect/src/Popselect.js +10 -5
  248. package/lib/popselect/src/PopselectPanel.d.ts +22 -2
  249. package/lib/popselect/src/PopselectPanel.js +12 -1
  250. package/lib/select/src/Select.d.ts +1 -1
  251. package/lib/select/src/Select.js +4 -1
  252. package/lib/slider/src/Slider.d.ts +1 -1
  253. package/lib/slider/src/Slider.js +12 -4
  254. package/lib/slider/src/styles/index.cssr.js +26 -31
  255. package/lib/space/src/Space.d.ts +26 -0
  256. package/lib/space/src/Space.js +53 -43
  257. package/lib/time-picker/src/TimePicker.d.ts +2 -1
  258. package/lib/time-picker/src/TimePicker.js +17 -7
  259. package/lib/tooltip/index.d.ts +1 -1
  260. package/lib/tooltip/src/Tooltip.d.ts +4 -0
  261. package/lib/tree/src/Tree.d.ts +2 -3
  262. package/lib/tree/src/Tree.js +6 -8
  263. package/lib/tree/src/TreeNode.js +4 -1
  264. package/lib/tree/src/interface.d.ts +0 -1
  265. package/lib/tree/src/keyboard.d.ts +0 -1
  266. package/lib/tree/src/keyboard.js +6 -9
  267. package/lib/tree-select/src/TreeSelect.d.ts +1 -3
  268. package/lib/tree-select/src/TreeSelect.js +13 -15
  269. package/lib/upload/src/UploadDragger.js +2 -2
  270. package/lib/upload/src/UploadFile.d.ts +2 -2
  271. package/lib/upload/src/UploadFile.js +9 -4
  272. package/lib/upload/src/UploadTrigger.js +3 -2
  273. package/lib/upload/src/styles/index.cssr.js +2 -2
  274. package/lib/upload/src/utils.js +1 -15
  275. package/lib/version.d.ts +1 -1
  276. package/lib/version.js +1 -1
  277. package/package.json +2 -2
  278. package/volar.d.ts +0 -1
  279. package/web-types.json +73 -1
@@ -8,7 +8,8 @@ const ImagePreview_1 = __importDefault(require("./ImagePreview"));
8
8
  const ImageGroup_1 = require("./ImageGroup");
9
9
  const _mixins_1 = require("../../_mixins");
10
10
  const interface_1 = require("./interface");
11
- const imageProps = Object.assign({ alt: String, height: [String, Number], imgProps: Object, objectFit: {
11
+ const utils_1 = require("./utils");
12
+ const imageProps = Object.assign({ alt: String, height: [String, Number], imgProps: Object, lazy: Boolean, intersectionObserverOptions: Object, objectFit: {
12
13
  type: String,
13
14
  default: 'fill'
14
15
  }, previewSrc: String, fallbackSrc: String, width: [String, Number], src: String, previewDisabled: Boolean, loadDescription: String, onError: Function, onLoad: Function }, interface_1.imagePreviewSharedProps);
@@ -42,18 +43,36 @@ exports.default = (0, vue_1.defineComponent)({
42
43
  previewInst.toggleShow();
43
44
  }
44
45
  };
46
+ const shouldStartLoadingRef = (0, vue_1.ref)(!props.lazy);
45
47
  (0, vue_1.onMounted)(() => {
46
48
  var _a;
47
49
  (_a = imageRef.value) === null || _a === void 0 ? void 0 : _a.setAttribute('data-group-id', (imageGroupHandle === null || imageGroupHandle === void 0 ? void 0 : imageGroupHandle.groupId) || '');
48
50
  });
51
+ (0, vue_1.onMounted)(() => {
52
+ let unobserve;
53
+ const stopWatchHandle = (0, vue_1.watchEffect)(() => {
54
+ unobserve === null || unobserve === void 0 ? void 0 : unobserve();
55
+ unobserve = undefined;
56
+ if (props.lazy) {
57
+ unobserve = (0, utils_1.observeIntersection)(imageRef.value, props.intersectionObserverOptions, shouldStartLoadingRef);
58
+ }
59
+ });
60
+ (0, vue_1.onBeforeUnmount)(() => {
61
+ stopWatchHandle();
62
+ unobserve === null || unobserve === void 0 ? void 0 : unobserve();
63
+ });
64
+ });
49
65
  (0, vue_1.watchEffect)(() => {
50
66
  var _a;
51
67
  void props.src;
52
68
  void ((_a = props.imgProps) === null || _a === void 0 ? void 0 : _a.src);
53
69
  showErrorRef.value = false;
54
70
  });
71
+ const loadedRef = (0, vue_1.ref)(false);
55
72
  return Object.assign({ mergedClsPrefix: mergedClsPrefixRef, groupId: imageGroupHandle === null || imageGroupHandle === void 0 ? void 0 : imageGroupHandle.groupId, previewInstRef,
56
- imageRef, imgProps: imgPropsRef, showError: showErrorRef, mergedOnError: (e) => {
73
+ imageRef, imgProps: imgPropsRef, showError: showErrorRef, shouldStartLoading: shouldStartLoadingRef, loaded: loadedRef, mergedOnError: (e) => {
74
+ if (!shouldStartLoadingRef.value)
75
+ return;
57
76
  showErrorRef.value = true;
58
77
  const { onError, imgProps: { onError: imgPropsOnError } = {} } = props;
59
78
  onError === null || onError === void 0 ? void 0 : onError(e);
@@ -62,18 +81,33 @@ exports.default = (0, vue_1.defineComponent)({
62
81
  const { onLoad, imgProps: { onLoad: imgPropsOnLoad } = {} } = props;
63
82
  onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
64
83
  imgPropsOnLoad === null || imgPropsOnLoad === void 0 ? void 0 : imgPropsOnLoad(e);
84
+ loadedRef.value = true;
65
85
  } }, exposedMethods);
66
86
  },
67
87
  render() {
68
- const { mergedClsPrefix, imgProps = {}, $attrs } = this;
69
- const imgNode = ((0, vue_1.h)("img", Object.assign({}, imgProps, { class: imgProps.class, ref: "imageRef", width: this.width || imgProps.width, height: this.height || imgProps.height, src: this.showError ? this.fallbackSrc : this.src || imgProps.src, alt: this.alt || imgProps.alt, "aria-label": this.alt || imgProps.alt, onClick: this.click, onError: this.mergedOnError, onLoad: this.mergedOnLoad, style: [imgProps.style || '', { objectFit: this.objectFit }], "data-error": this.showError, "data-preview-src": this.previewSrc || this.src })));
88
+ var _a, _b;
89
+ const { mergedClsPrefix, imgProps = {}, loaded, $attrs } = this;
90
+ const placeholderNode = (_b = (_a = this.$slots).placeholder) === null || _b === void 0 ? void 0 : _b.call(_a);
91
+ const imgNode = ((0, vue_1.h)("img", Object.assign({}, imgProps, { class: imgProps.class, ref: "imageRef", width: this.width || imgProps.width, height: this.height || imgProps.height, src: this.showError
92
+ ? this.fallbackSrc
93
+ : this.shouldStartLoading
94
+ ? this.src || imgProps.src
95
+ : undefined, alt: this.alt || imgProps.alt, "aria-label": this.alt || imgProps.alt, onClick: this.click, onError: this.mergedOnError, onLoad: this.mergedOnLoad, style: [
96
+ imgProps.style || '',
97
+ placeholderNode && !loaded
98
+ ? { height: '0', width: '0', visibility: 'hidden' }
99
+ : '',
100
+ { objectFit: this.objectFit }
101
+ ], "data-error": this.showError, "data-preview-src": this.previewSrc || this.src })));
70
102
  return ((0, vue_1.h)("div", Object.assign({}, $attrs, { role: "none", class: [
71
103
  $attrs.class,
72
104
  `${mergedClsPrefix}-image`,
73
105
  (this.previewDisabled || this.showError) &&
74
106
  `${mergedClsPrefix}-image--preview-disabled`
75
- ] }), this.groupId ? (imgNode) : ((0, vue_1.h)(ImagePreview_1.default, { theme: this.theme, themeOverrides: this.themeOverrides, clsPrefix: mergedClsPrefix, ref: "previewInstRef", showToolbar: this.showToolbar, showToolbarTooltip: this.showToolbarTooltip }, {
76
- default: () => imgNode
77
- }))));
107
+ ] }),
108
+ this.groupId ? (imgNode) : ((0, vue_1.h)(ImagePreview_1.default, { theme: this.theme, themeOverrides: this.themeOverrides, clsPrefix: mergedClsPrefix, ref: "previewInstRef", showToolbar: this.showToolbar, showToolbarTooltip: this.showToolbarTooltip }, {
109
+ default: () => imgNode
110
+ })),
111
+ !loaded && placeholderNode));
78
112
  }
79
113
  });
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+ export declare type IntersectionObserverOptions = Omit<IntersectionObserverInit, 'root'> & {
3
+ root?: Element | Document | null | string;
4
+ };
5
+ export declare const resolveOptionsAndHash: (options?: IntersectionObserverOptions | undefined) => {
6
+ hash: string;
7
+ options: Omit<IntersectionObserverInit, "root"> & {
8
+ root: Element | Document;
9
+ };
10
+ };
11
+ export declare const observeIntersection: (el: HTMLImageElement | null, options: IntersectionObserverOptions | undefined, shouldStartLoadingRef: Ref<boolean>) => () => void;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.observeIntersection = exports.resolveOptionsAndHash = void 0;
4
+ const resolveOptionsAndHash = (options = {}) => {
5
+ var _a;
6
+ const { root = null } = options;
7
+ return {
8
+ hash: `${options.rootMargin || '0px 0px 0px 0px'}-${Array.isArray(options.threshold)
9
+ ? options.threshold.join(',')
10
+ : (_a = options.threshold) !== null && _a !== void 0 ? _a : '0'}`,
11
+ options: Object.assign(Object.assign({}, options), { root: (typeof root === 'string' ? document.querySelector(root) : root) ||
12
+ document.documentElement })
13
+ };
14
+ };
15
+ exports.resolveOptionsAndHash = resolveOptionsAndHash;
16
+ // root -> options -> [observer, elements]
17
+ const observers = new WeakMap();
18
+ const unobserveHandleMap = new WeakMap();
19
+ const shouldStartLoadingRefMap = new WeakMap();
20
+ const observeIntersection = (el, options, shouldStartLoadingRef) => {
21
+ if (!el)
22
+ return () => { };
23
+ const resolvedOptionsAndHash = (0, exports.resolveOptionsAndHash)(options);
24
+ const { root } = resolvedOptionsAndHash.options;
25
+ let rootObservers;
26
+ const _rootObservers = observers.get(root);
27
+ if (_rootObservers) {
28
+ rootObservers = _rootObservers;
29
+ }
30
+ else {
31
+ rootObservers = new Map();
32
+ observers.set(root, rootObservers);
33
+ }
34
+ let observer;
35
+ let observerAndObservedElements;
36
+ if (rootObservers.has(resolvedOptionsAndHash.hash)) {
37
+ observerAndObservedElements =
38
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
39
+ rootObservers.get(resolvedOptionsAndHash.hash);
40
+ if (!observerAndObservedElements[1].has(el)) {
41
+ observer = observerAndObservedElements[0];
42
+ observerAndObservedElements[1].add(el);
43
+ observer.observe(el);
44
+ }
45
+ }
46
+ else {
47
+ observer = new IntersectionObserver((entries) => {
48
+ entries.forEach((entry) => {
49
+ if (entry.isIntersecting) {
50
+ const _unobserve = unobserveHandleMap.get(entry.target);
51
+ const _shouldStartLoadingRef = shouldStartLoadingRefMap.get(entry.target);
52
+ if (_unobserve)
53
+ _unobserve();
54
+ if (_shouldStartLoadingRef) {
55
+ _shouldStartLoadingRef.value = true;
56
+ }
57
+ }
58
+ });
59
+ }, resolvedOptionsAndHash.options);
60
+ observer.observe(el);
61
+ observerAndObservedElements = [observer, new Set([el])];
62
+ rootObservers.set(resolvedOptionsAndHash.hash, observerAndObservedElements);
63
+ }
64
+ let unobservered = false;
65
+ const unobserve = () => {
66
+ if (unobservered)
67
+ return;
68
+ unobserveHandleMap.delete(el);
69
+ shouldStartLoadingRefMap.delete(el);
70
+ unobservered = true;
71
+ if (observerAndObservedElements[1].has(el)) {
72
+ observerAndObservedElements[0].unobserve(el);
73
+ observerAndObservedElements[1].delete(el);
74
+ }
75
+ if (observerAndObservedElements[1].size <= 0) {
76
+ rootObservers.delete(resolvedOptionsAndHash.hash);
77
+ }
78
+ if (!rootObservers.size) {
79
+ observers.delete(root);
80
+ }
81
+ };
82
+ unobserveHandleMap.set(el, unobserve);
83
+ shouldStartLoadingRefMap.set(el, shouldStartLoadingRef);
84
+ return unobserve;
85
+ };
86
+ exports.observeIntersection = observeIntersection;
@@ -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) => {
@@ -26,6 +26,8 @@ exports.default = (0, cssr_1.cB)('input-group-label', `
26
26
  font-size: var(--n-font-size);
27
27
  line-height: var(--n-height);
28
28
  height: var(--n-height);
29
+ flex-shrink: 0;
30
+ white-space: nowrap;
29
31
  transition:
30
32
  color .3s var(--n-bezier),
31
33
  background-color .3s var(--n-bezier),
@@ -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;
@@ -7,10 +7,10 @@ exports.createLayoutComponent = exports.layoutInjectionKey = void 0;
7
7
  const vue_1 = require("vue");
8
8
  const _internal_1 = require("../../_internal");
9
9
  const _mixins_1 = require("../../_mixins");
10
+ const _utils_1 = require("../../_utils");
10
11
  const styles_1 = require("../styles");
11
- const layout_cssr_1 = __importDefault(require("./styles/layout.cssr"));
12
12
  const interface_1 = require("./interface");
13
- const _utils_1 = require("../../_utils");
13
+ const layout_cssr_1 = __importDefault(require("./styles/layout.cssr"));
14
14
  const layoutProps = {
15
15
  embedded: Boolean,
16
16
  position: interface_1.positionProp,
@@ -61,6 +61,24 @@ function createLayoutComponent(isContent) {
61
61
  }
62
62
  }
63
63
  (0, vue_1.provide)(exports.layoutInjectionKey, props);
64
+ let scrollX = 0;
65
+ let scrollY = 0;
66
+ const handleNativeElScroll = (e) => {
67
+ var _a;
68
+ const target = e.target;
69
+ scrollX = target.scrollLeft;
70
+ scrollY = target.scrollTop;
71
+ (_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, e);
72
+ };
73
+ (0, _utils_1.useReactivated)(() => {
74
+ if (props.nativeScrollbar) {
75
+ const el = scrollableElRef.value;
76
+ if (el) {
77
+ el.scrollTop = scrollY;
78
+ el.scrollLeft = scrollX;
79
+ }
80
+ }
81
+ });
64
82
  const hasSiderStyle = {
65
83
  display: 'flex',
66
84
  flexWrap: 'nowrap',
@@ -83,7 +101,7 @@ function createLayoutComponent(isContent) {
83
101
  : undefined;
84
102
  return Object.assign({ mergedClsPrefix: mergedClsPrefixRef, scrollableElRef,
85
103
  scrollbarInstRef,
86
- hasSiderStyle, 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 }, exposedMethods);
104
+ hasSiderStyle, mergedTheme: themeRef, handleNativeElScroll, cssVars: inlineThemeDisabled ? undefined : cssVarsRef, themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass, onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender }, exposedMethods);
87
105
  },
88
106
  render() {
89
107
  var _a;
@@ -96,7 +114,7 @@ function createLayoutComponent(isContent) {
96
114
  `${mergedClsPrefix}-layout`,
97
115
  `${mergedClsPrefix}-layout--${this.position}-positioned`
98
116
  ];
99
- return ((0, vue_1.h)("div", { class: layoutClass, style: this.cssVars }, this.nativeScrollbar ? ((0, vue_1.h)("div", { ref: "scrollableElRef", class: `${mergedClsPrefix}-layout-scroll-container`, style: [this.contentStyle, hasSiderStyle], onScroll: this.onScroll }, this.$slots)) : ((0, vue_1.h)(_internal_1.NScrollbar, Object.assign({}, this.scrollbarProps, { onScroll: this.onScroll, ref: "scrollbarInstRef", theme: this.mergedTheme.peers.Scrollbar, themeOverrides: this.mergedTheme.peerOverrides.Scrollbar, contentStyle: [this.contentStyle, hasSiderStyle] }), this.$slots))));
117
+ return ((0, vue_1.h)("div", { class: layoutClass, style: this.cssVars }, this.nativeScrollbar ? ((0, vue_1.h)("div", { ref: "scrollableElRef", class: `${mergedClsPrefix}-layout-scroll-container`, style: [this.contentStyle, hasSiderStyle], onScroll: this.handleNativeElScroll }, this.$slots)) : ((0, vue_1.h)(_internal_1.NScrollbar, Object.assign({}, this.scrollbarProps, { onScroll: this.onScroll, ref: "scrollbarInstRef", theme: this.mergedTheme.peers.Scrollbar, themeOverrides: this.mergedTheme.peerOverrides.Scrollbar, contentStyle: [this.contentStyle, hasSiderStyle] }), this.$slots))));
100
118
  }
101
119
  });
102
120
  }
@@ -271,6 +271,7 @@ declare const _default: import("vue").DefineComponent<{
271
271
  } | undefined;
272
272
  };
273
273
  }>;
274
+ handleNativeElScroll: (e: Event) => void;
274
275
  cssVars: import("vue").ComputedRef<{
275
276
  '--n-bezier': string;
276
277
  '--n-color': string;
@@ -362,6 +362,7 @@ declare const _default: import("vue").DefineComponent<{
362
362
  mergedCollapsed: import("vue").ComputedRef<boolean>;
363
363
  scrollContainerStyle: import("vue").ComputedRef<CSSProperties>;
364
364
  siderPlacement: import("vue").ComputedRef<"left" | "right">;
365
+ handleNativeElScroll: (e: Event) => void;
365
366
  handleTransitionend: (e: TransitionEvent) => void;
366
367
  handleTriggerClick: () => void;
367
368
  inlineThemeDisabled: boolean | undefined;