@king-one/antdv 1.0.16 → 1.0.18

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 (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cdn/index.cdn.js +18 -18
  3. package/dist/cdn/index.cdn.js.map +1 -1
  4. package/dist/cdn/index.cdn.mjs +20 -20
  5. package/dist/cdn/index.cdn.mjs.map +1 -1
  6. package/dist/cdn/index.css +1 -1
  7. package/dist/es/components/scroll-bar/index.d.ts +10 -1
  8. package/dist/es/components/scroll-bar/src/scroll-bar.d.ts +10 -1
  9. package/dist/es/components/scroll-bar/src/scroll-bar.mjs +175 -39
  10. package/dist/es/components/scroll-bar/src/scroll-bar.mjs.map +1 -1
  11. package/dist/es/components/scroll-bar/src/types.d.ts +1 -0
  12. package/dist/es/components/scroll-bar/src/types.mjs +2 -1
  13. package/dist/es/components/scroll-bar/src/types.mjs.map +1 -1
  14. package/dist/es/components/virtual-list/index.d.ts +33 -3
  15. package/dist/es/components/virtual-list/src/types.d.ts +1 -0
  16. package/dist/es/components/virtual-list/src/types.mjs +1 -0
  17. package/dist/es/components/virtual-list/src/types.mjs.map +1 -1
  18. package/dist/es/components/virtual-list/src/virtual-list.vue.d.ts +33 -3
  19. package/dist/es/components/virtual-list/src/virtual-list.vue2.mjs +35 -40
  20. package/dist/es/components/virtual-list/src/virtual-list.vue2.mjs.map +1 -1
  21. package/dist/lib/components/scroll-bar/index.d.ts +10 -1
  22. package/dist/lib/components/scroll-bar/src/scroll-bar.d.ts +10 -1
  23. package/dist/lib/components/scroll-bar/src/scroll-bar.js +175 -39
  24. package/dist/lib/components/scroll-bar/src/scroll-bar.js.map +1 -1
  25. package/dist/lib/components/scroll-bar/src/types.d.ts +1 -0
  26. package/dist/lib/components/scroll-bar/src/types.js +2 -1
  27. package/dist/lib/components/scroll-bar/src/types.js.map +1 -1
  28. package/dist/lib/components/virtual-list/index.d.ts +33 -3
  29. package/dist/lib/components/virtual-list/src/types.d.ts +1 -0
  30. package/dist/lib/components/virtual-list/src/types.js +1 -0
  31. package/dist/lib/components/virtual-list/src/types.js.map +1 -1
  32. package/dist/lib/components/virtual-list/src/virtual-list.vue.d.ts +33 -3
  33. package/dist/lib/components/virtual-list/src/virtual-list.vue2.js +35 -40
  34. package/dist/lib/components/virtual-list/src/virtual-list.vue2.js.map +1 -1
  35. package/dist/theme-chalk/index.css +1 -1
  36. package/dist/theme-chalk/scroll-bar.css +1 -1
  37. package/package.json +1 -1
@@ -20,6 +20,7 @@ const virtualListProps = {
20
20
  type: String,
21
21
  default: "key"
22
22
  },
23
+ xScrollable: Boolean,
23
24
  onScroll: Function,
24
25
  onWheel: Function,
25
26
  onResize: Function
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sources":["../../../../../components/virtual-list/src/types.ts"],"sourcesContent":["import type { VirtualListInst, VirtualListItemData } from 'vueuc'\nimport type { PropType } from 'vue'\n\nexport interface InterScrollParams {\n viewportItems: any[]\n scrollTop: number\n}\nexport const virtualListProps = {\n items: {\n type: Array as PropType<VirtualListItemData[]>,\n default: () => []\n },\n itemSize: {\n type: Number,\n required: true\n },\n itemResizable: Boolean,\n paddingTop: {\n type: [Number, String] as PropType<number | string>,\n default: 0\n },\n paddingBottom: {\n type: [Number, String] as PropType<number | string>,\n default: 0\n },\n keyField: {\n type: String,\n default: 'key'\n },\n onScroll: Function as PropType<(params: InterScrollParams) => void>,\n onWheel: Function as PropType<(event: WheelEvent) => void>,\n onResize: Function as PropType<(entry: ResizeObserverEntry) => void>\n} as const\nexport interface VirtualListRef extends VirtualListInst {\n viewportItems: any[]\n visibleItemsStyle: {\n transform: string\n }\n}\n"],"names":[],"mappings":"AAOO,MAAM,gBAAmB,GAAA;AAAA,EAC9B,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,KAAA;AAAA,IACN,OAAA,EAAS,MAAM,EAAC;AAAA,GAClB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,IAAA;AAAA,GACZ;AAAA,EACA,aAAe,EAAA,OAAA;AAAA,EACf,UAAY,EAAA;AAAA,IACV,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAS,EAAA,CAAA;AAAA,GACX;AAAA,EACA,aAAe,EAAA;AAAA,IACb,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAS,EAAA,CAAA;AAAA,GACX;AAAA,EACA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EACA,QAAU,EAAA,QAAA;AAAA,EACV,OAAS,EAAA,QAAA;AAAA,EACT,QAAU,EAAA,QAAA;AACZ;;;;"}
1
+ {"version":3,"file":"types.mjs","sources":["../../../../../components/virtual-list/src/types.ts"],"sourcesContent":["import type { VirtualListInst, VirtualListItemData } from 'vueuc'\nimport type { PropType } from 'vue'\n\nexport interface InterScrollParams {\n viewportItems: any[]\n scrollTop: number\n}\nexport const virtualListProps = {\n items: {\n type: Array as PropType<VirtualListItemData[]>,\n default: () => []\n },\n itemSize: {\n type: Number,\n required: true\n },\n itemResizable: Boolean,\n paddingTop: {\n type: [Number, String] as PropType<number | string>,\n default: 0\n },\n paddingBottom: {\n type: [Number, String] as PropType<number | string>,\n default: 0\n },\n keyField: {\n type: String,\n default: 'key'\n },\n xScrollable: Boolean,\n onScroll: Function as PropType<(params: InterScrollParams) => void>,\n onWheel: Function as PropType<(event: WheelEvent) => void>,\n onResize: Function as PropType<(entry: ResizeObserverEntry) => void>\n} as const\nexport interface VirtualListRef extends VirtualListInst {\n viewportItems: any[]\n visibleItemsStyle: {\n transform: string\n }\n}\n"],"names":[],"mappings":"AAOO,MAAM,gBAAmB,GAAA;AAAA,EAC9B,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,KAAA;AAAA,IACN,OAAA,EAAS,MAAM,EAAC;AAAA,GAClB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,IAAA;AAAA,GACZ;AAAA,EACA,aAAe,EAAA,OAAA;AAAA,EACf,UAAY,EAAA;AAAA,IACV,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAS,EAAA,CAAA;AAAA,GACX;AAAA,EACA,aAAe,EAAA;AAAA,IACb,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAS,EAAA,CAAA;AAAA,GACX;AAAA,EACA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EACA,WAAa,EAAA,OAAA;AAAA,EACb,QAAU,EAAA,QAAA;AAAA,EACV,OAAS,EAAA,QAAA;AAAA,EACT,QAAU,EAAA,QAAA;AACZ;;;;"}
@@ -20,6 +20,7 @@ declare const _default: import("vue").DefineComponent<{
20
20
  readonly type: StringConstructor;
21
21
  readonly default: "key";
22
22
  };
23
+ readonly xScrollable: BooleanConstructor;
23
24
  readonly onScroll: import("vue").PropType<(params: import("./types").InterScrollParams) => void>;
24
25
  readonly onWheel: import("vue").PropType<(event: WheelEvent) => void>;
25
26
  readonly onResize: import("vue").PropType<(entry: ResizeObserverEntry) => void>;
@@ -31,6 +32,7 @@ declare const _default: import("vue").DefineComponent<{
31
32
  readonly paddingTop: string | number;
32
33
  readonly paddingBottom: string | number;
33
34
  readonly keyField: string;
35
+ readonly xScrollable: boolean;
34
36
  readonly onScroll?: ((params: import("./types").InterScrollParams) => void) | undefined;
35
37
  readonly onWheel?: ((event: WheelEvent) => void) | undefined;
36
38
  readonly onResize?: ((entry: ResizeObserverEntry) => void) | undefined;
@@ -48,25 +50,34 @@ declare const _default: import("vue").DefineComponent<{
48
50
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
49
51
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
50
52
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
53
+ readonly xScrollable: BooleanConstructor;
51
54
  }>>, {
52
55
  sync: () => void;
53
56
  handleContentResize: () => void;
54
57
  handleContainerResize: () => void;
55
58
  contentRef: import("vue").Ref<HTMLElement | null>;
56
59
  yRailRef: import("vue").Ref<HTMLElement | null>;
60
+ xRailRef: import("vue").Ref<HTMLElement | null>;
57
61
  containerRef: import("vue").Ref<HTMLElement | null>;
58
62
  contentHeightRef: import("vue").Ref<Nullable<number>>;
59
63
  containerHeightRef: import("vue").Ref<Nullable<number>>;
60
64
  needYBarRef: import("vue").ComputedRef<boolean>;
65
+ needXBarRef: import("vue").ComputedRef<boolean>;
61
66
  yBarSizePxRef: import("vue").ComputedRef<string>;
62
67
  handleYScrollMouseDown: (e: MouseEvent) => void;
68
+ handleXScrollMouseDown: (e: MouseEvent) => void;
63
69
  yBarTopPxRef: import("vue").ComputedRef<string>;
64
70
  handleScroll: (e: Event) => void;
71
+ xBarSizePxRef: import("vue").ComputedRef<string>;
72
+ xBarLeftPxRef: import("vue").ComputedRef<string>;
65
73
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
66
74
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
67
75
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
68
76
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
69
- }>>, {}, true, {}, {}, {
77
+ readonly xScrollable: BooleanConstructor;
78
+ }>>, {
79
+ readonly xScrollable: boolean;
80
+ }, true, {}, {}, {
70
81
  P: {};
71
82
  B: {};
72
83
  D: {};
@@ -77,21 +88,29 @@ declare const _default: import("vue").DefineComponent<{
77
88
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
78
89
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
79
90
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
91
+ readonly xScrollable: BooleanConstructor;
80
92
  }>>, {
81
93
  sync: () => void;
82
94
  handleContentResize: () => void;
83
95
  handleContainerResize: () => void;
84
96
  contentRef: import("vue").Ref<HTMLElement | null>;
85
97
  yRailRef: import("vue").Ref<HTMLElement | null>;
98
+ xRailRef: import("vue").Ref<HTMLElement | null>;
86
99
  containerRef: import("vue").Ref<HTMLElement | null>;
87
100
  contentHeightRef: import("vue").Ref<Nullable<number>>;
88
101
  containerHeightRef: import("vue").Ref<Nullable<number>>;
89
102
  needYBarRef: import("vue").ComputedRef<boolean>;
103
+ needXBarRef: import("vue").ComputedRef<boolean>;
90
104
  yBarSizePxRef: import("vue").ComputedRef<string>;
91
105
  handleYScrollMouseDown: (e: MouseEvent) => void;
106
+ handleXScrollMouseDown: (e: MouseEvent) => void;
92
107
  yBarTopPxRef: import("vue").ComputedRef<string>;
93
108
  handleScroll: (e: Event) => void;
94
- }, {}, {}, {}, {}> | null>;
109
+ xBarSizePxRef: import("vue").ComputedRef<string>;
110
+ xBarLeftPxRef: import("vue").ComputedRef<string>;
111
+ }, {}, {}, {}, {
112
+ readonly xScrollable: boolean;
113
+ }> | null>;
95
114
  getScrollContainer: () => HTMLElement | null | undefined;
96
115
  getScrollContent: () => HTMLElement | null | undefined;
97
116
  syncScrollbar: () => void | undefined;
@@ -226,25 +245,34 @@ declare const _default: import("vue").DefineComponent<{
226
245
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
227
246
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
228
247
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
248
+ readonly xScrollable: BooleanConstructor;
229
249
  }, {
230
250
  sync: () => void;
231
251
  handleContentResize: () => void;
232
252
  handleContainerResize: () => void;
233
253
  contentRef: import("vue").Ref<HTMLElement | null>;
234
254
  yRailRef: import("vue").Ref<HTMLElement | null>;
255
+ xRailRef: import("vue").Ref<HTMLElement | null>;
235
256
  containerRef: import("vue").Ref<HTMLElement | null>;
236
257
  contentHeightRef: import("vue").Ref<Nullable<number>>;
237
258
  containerHeightRef: import("vue").Ref<Nullable<number>>;
238
259
  needYBarRef: import("vue").ComputedRef<boolean>;
260
+ needXBarRef: import("vue").ComputedRef<boolean>;
239
261
  yBarSizePxRef: import("vue").ComputedRef<string>;
240
262
  handleYScrollMouseDown: (e: MouseEvent) => void;
263
+ handleXScrollMouseDown: (e: MouseEvent) => void;
241
264
  yBarTopPxRef: import("vue").ComputedRef<string>;
242
265
  handleScroll: (e: Event) => void;
266
+ xBarSizePxRef: import("vue").ComputedRef<string>;
267
+ xBarLeftPxRef: import("vue").ComputedRef<string>;
243
268
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
244
269
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
245
270
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
246
271
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
247
- }>>, {}, {}>>;
272
+ readonly xScrollable: BooleanConstructor;
273
+ }>>, {
274
+ readonly xScrollable: boolean;
275
+ }, {}>>;
248
276
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
249
277
  readonly items: {
250
278
  readonly type: import("vue").PropType<import("vueuc").VVirtualListItemData[]>;
@@ -267,6 +295,7 @@ declare const _default: import("vue").DefineComponent<{
267
295
  readonly type: StringConstructor;
268
296
  readonly default: "key";
269
297
  };
298
+ readonly xScrollable: BooleanConstructor;
270
299
  readonly onScroll: import("vue").PropType<(params: import("./types").InterScrollParams) => void>;
271
300
  readonly onWheel: import("vue").PropType<(event: WheelEvent) => void>;
272
301
  readonly onResize: import("vue").PropType<(entry: ResizeObserverEntry) => void>;
@@ -276,5 +305,6 @@ declare const _default: import("vue").DefineComponent<{
276
305
  readonly paddingTop: string | number;
277
306
  readonly paddingBottom: string | number;
278
307
  readonly keyField: string;
308
+ readonly xScrollable: boolean;
279
309
  }, {}>;
280
310
  export default _default;
@@ -40,46 +40,41 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40
40
  syncScrollbar();
41
41
  }
42
42
  return (_ctx, _cache) => {
43
- return openBlock(), createBlock(
44
- unref(KScrollBar),
45
- {
46
- ref_key: "scrollbarInstRef",
47
- ref: scrollbarInstRef,
48
- style: { "max-height": "300px" },
49
- container: getScrollContainer,
50
- content: getScrollContent
51
- },
52
- {
53
- default: withCtx(() => [
54
- createVNode(unref(VVirtualList), {
55
- ref_key: "virtualListInstRef",
56
- ref: virtualListInstRef,
57
- items: _ctx.items,
58
- style: { "height": "100%" },
59
- "item-size": _ctx.itemSize,
60
- "item-resizable": _ctx.itemResizable,
61
- "show-scrollbar": false,
62
- "padding-bottom": _ctx.paddingBottom,
63
- "padding-top": _ctx.paddingTop,
64
- "on-scroll": handleScroll,
65
- "on-resize": handleResize
66
- }, {
67
- default: withCtx(({ item, index }) => [
68
- renderSlot(_ctx.$slots, "default", {
69
- item,
70
- index
71
- })
72
- ]),
73
- _: 3
74
- /* FORWARDED */
75
- }, 8, ["items", "item-size", "item-resizable", "padding-bottom", "padding-top"])
76
- ]),
77
- _: 3
78
- /* FORWARDED */
79
- },
80
- 512
81
- /* NEED_PATCH */
82
- );
43
+ return openBlock(), createBlock(unref(KScrollBar), {
44
+ ref_key: "scrollbarInstRef",
45
+ ref: scrollbarInstRef,
46
+ style: { "max-height": "300px" },
47
+ "x-scrollable": _ctx.xScrollable,
48
+ container: getScrollContainer,
49
+ content: getScrollContent
50
+ }, {
51
+ default: withCtx(() => [
52
+ createVNode(unref(VVirtualList), {
53
+ ref_key: "virtualListInstRef",
54
+ ref: virtualListInstRef,
55
+ items: _ctx.items,
56
+ style: { "height": "100%" },
57
+ "item-size": _ctx.itemSize,
58
+ "item-resizable": _ctx.itemResizable,
59
+ "show-scrollbar": false,
60
+ "padding-bottom": _ctx.paddingBottom,
61
+ "padding-top": _ctx.paddingTop,
62
+ "on-scroll": handleScroll,
63
+ "on-resize": handleResize
64
+ }, {
65
+ default: withCtx(({ item, index }) => [
66
+ renderSlot(_ctx.$slots, "default", {
67
+ item,
68
+ index
69
+ })
70
+ ]),
71
+ _: 3
72
+ /* FORWARDED */
73
+ }, 8, ["items", "item-size", "item-resizable", "padding-bottom", "padding-top"])
74
+ ]),
75
+ _: 3
76
+ /* FORWARDED */
77
+ }, 8, ["x-scrollable"]);
83
78
  };
84
79
  }
85
80
  });
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-list.vue2.mjs","sources":["../../../../../components/virtual-list/src/virtual-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, toRaw } from 'vue'\nimport { VVirtualList } from 'vueuc'\nimport { debounce } from 'lodash-es'\nimport scrollbar from '../../scroll-bar'\nimport { type VirtualListRef, virtualListProps } from './types'\n\nconst props = defineProps(virtualListProps)\nconst virtualListInstRef = ref<VirtualListRef | null>(null)\nconst scrollbarInstRef = ref<InstanceType<typeof scrollbar> | null>(null)\nfunction getScrollContainer(): HTMLElement | null | undefined {\n return virtualListInstRef.value?.listElRef\n}\nfunction getScrollContent(): HTMLElement | null | undefined {\n return virtualListInstRef.value?.itemsElRef\n}\nconst syncScrollbar = () => scrollbarInstRef.value?.sync()\nconst debouncedLogViewportItems = debounce(() => {\n if (virtualListInstRef.value) {\n const scrollTop = virtualListInstRef.value.listElRef.scrollTop\n const viewportItems = virtualListInstRef.value.viewportItems.map(item => toRaw(item))\n\n props.onScroll?.({ viewportItems, scrollTop })\n }\n}, 100)\nfunction handleScroll() {\n debouncedLogViewportItems()\n syncScrollbar()\n}\n\n// 使用防抖函数包裹 console.log\n\nfunction handleResize() {\n syncScrollbar()\n}\n</script>\n\n<template>\n <scrollbar ref=\"scrollbarInstRef\" style=\"max-height: 300px\" :container=\"getScrollContainer\" :content=\"getScrollContent\">\n <VVirtualList\n ref=\"virtualListInstRef\"\n :items=\"items\"\n style=\"height: 100%\"\n :item-size=\"itemSize\"\n :item-resizable=\"itemResizable\"\n :show-scrollbar=\"false\"\n :padding-bottom=\"paddingBottom\"\n :padding-top=\"paddingTop\"\n :on-scroll=\"handleScroll\"\n :on-resize=\"handleResize\"\n >\n <template #default=\"{ item, index }\">\n <slot :item=\"item\" :index=\"index\" />\n </template>\n </VVirtualList>\n </scrollbar>\n</template>\n\n<style></style>\n"],"names":[],"mappings":";;;;;;;;;;;AAOA,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAM,MAAA,kBAAA,GAAqB,IAA2B,IAAI,CAAA,CAAA;AAC1D,IAAM,MAAA,gBAAA,GAAmB,IAA2C,IAAI,CAAA,CAAA;AACxE,IAAA,SAAS,kBAAqD,GAAA;;AAC5D,MAAO,OAAA,CAAA,EAAA,GAAA,kBAAA,CAAmB,UAAnB,IAA0B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,SAAA,CAAA;AAAA,KACnC;AACA,IAAA,SAAS,gBAAmD,GAAA;;AAC1D,MAAO,OAAA,CAAA,EAAA,GAAA,kBAAA,CAAmB,UAAnB,IAA0B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAA,CAAA;AAAA,KACnC;AACA,IAAA,MAAM,gBAAgB,MAAG;;AAAG,MAAA,OAAA,CAAA,EAAA,GAAA,gBAAA,CAAiB,UAAjB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,EAAA,CAAA;AAAA,KAAA,CAAA;AACpD,IAAM,MAAA,yBAAA,GAA4B,SAAS,MAAM;;AAC/C,MAAA,IAAI,mBAAmB,KAAO,EAAA;AAC5B,QAAM,MAAA,SAAA,GAAY,kBAAmB,CAAA,KAAA,CAAM,SAAU,CAAA,SAAA,CAAA;AACrD,QAAM,MAAA,aAAA,GAAgB,mBAAmB,KAAM,CAAA,aAAA,CAAc,IAAI,CAAQ,IAAA,KAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAEpF,QAAA,CAAA,EAAA,GAAA,KAAA,CAAM,QAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,KAAA,EAAiB,EAAE,aAAA,EAAe,SAAU,EAAA,CAAA,CAAA;AAAA,OAC9C;AAAA,OACC,GAAG,CAAA,CAAA;AACN,IAAA,SAAS,YAAe,GAAA;AACtB,MAA0B,yBAAA,EAAA,CAAA;AAC1B,MAAc,aAAA,EAAA,CAAA;AAAA,KAChB;AAIA,IAAA,SAAS,YAAe,GAAA;AACtB,MAAc,aAAA,EAAA,CAAA;AAAA,KAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"virtual-list.vue2.mjs","sources":["../../../../../components/virtual-list/src/virtual-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, toRaw } from 'vue'\nimport { VVirtualList } from 'vueuc'\nimport { debounce } from 'lodash-es'\nimport scrollbar from '../../scroll-bar'\nimport { type VirtualListRef, virtualListProps } from './types'\n\nconst props = defineProps(virtualListProps)\nconst virtualListInstRef = ref<VirtualListRef | null>(null)\nconst scrollbarInstRef = ref<InstanceType<typeof scrollbar> | null>(null)\nfunction getScrollContainer(): HTMLElement | null | undefined {\n return virtualListInstRef.value?.listElRef\n}\nfunction getScrollContent(): HTMLElement | null | undefined {\n return virtualListInstRef.value?.itemsElRef\n}\nconst syncScrollbar = () => scrollbarInstRef.value?.sync()\nconst debouncedLogViewportItems = debounce(() => {\n if (virtualListInstRef.value) {\n const scrollTop = virtualListInstRef.value.listElRef.scrollTop\n const viewportItems = virtualListInstRef.value.viewportItems.map(item => toRaw(item))\n\n props.onScroll?.({ viewportItems, scrollTop })\n }\n}, 100)\nfunction handleScroll() {\n debouncedLogViewportItems()\n syncScrollbar()\n}\n\n// 使用防抖函数包裹 console.log\n\nfunction handleResize() {\n syncScrollbar()\n}\n</script>\n\n<template>\n <scrollbar ref=\"scrollbarInstRef\" style=\"max-height: 300px\" :x-scrollable=\"xScrollable\" :container=\"getScrollContainer\" :content=\"getScrollContent\">\n <VVirtualList\n ref=\"virtualListInstRef\"\n :items=\"items\"\n style=\"height: 100%\"\n :item-size=\"itemSize\"\n :item-resizable=\"itemResizable\"\n :show-scrollbar=\"false\"\n :padding-bottom=\"paddingBottom\"\n :padding-top=\"paddingTop\"\n :on-scroll=\"handleScroll\"\n :on-resize=\"handleResize\"\n >\n <template #default=\"{ item, index }\">\n <slot :item=\"item\" :index=\"index\" />\n </template>\n </VVirtualList>\n </scrollbar>\n</template>\n\n<style></style>\n"],"names":[],"mappings":";;;;;;;;;;;AAOA,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAM,MAAA,kBAAA,GAAqB,IAA2B,IAAI,CAAA,CAAA;AAC1D,IAAM,MAAA,gBAAA,GAAmB,IAA2C,IAAI,CAAA,CAAA;AACxE,IAAA,SAAS,kBAAqD,GAAA;;AAC5D,MAAO,OAAA,CAAA,EAAA,GAAA,kBAAA,CAAmB,UAAnB,IAA0B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,SAAA,CAAA;AAAA,KACnC;AACA,IAAA,SAAS,gBAAmD,GAAA;;AAC1D,MAAO,OAAA,CAAA,EAAA,GAAA,kBAAA,CAAmB,UAAnB,IAA0B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAA,CAAA;AAAA,KACnC;AACA,IAAA,MAAM,gBAAgB,MAAG;;AAAG,MAAA,OAAA,CAAA,EAAA,GAAA,gBAAA,CAAiB,UAAjB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,EAAA,CAAA;AAAA,KAAA,CAAA;AACpD,IAAM,MAAA,yBAAA,GAA4B,SAAS,MAAM;;AAC/C,MAAA,IAAI,mBAAmB,KAAO,EAAA;AAC5B,QAAM,MAAA,SAAA,GAAY,kBAAmB,CAAA,KAAA,CAAM,SAAU,CAAA,SAAA,CAAA;AACrD,QAAM,MAAA,aAAA,GAAgB,mBAAmB,KAAM,CAAA,aAAA,CAAc,IAAI,CAAQ,IAAA,KAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAEpF,QAAA,CAAA,EAAA,GAAA,KAAA,CAAM,QAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,KAAA,EAAiB,EAAE,aAAA,EAAe,SAAU,EAAA,CAAA,CAAA;AAAA,OAC9C;AAAA,OACC,GAAG,CAAA,CAAA;AACN,IAAA,SAAS,YAAe,GAAA;AACtB,MAA0B,yBAAA,EAAA,CAAA;AAC1B,MAAc,aAAA,EAAA,CAAA;AAAA,KAChB;AAIA,IAAA,SAAS,YAAe,GAAA;AACtB,MAAc,aAAA,EAAA,CAAA;AAAA,KAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,23 +4,32 @@ export declare const KScrollBar: import("../utils/install").SFCWithInstall<impor
4
4
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
5
5
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
6
6
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
7
+ readonly xScrollable: BooleanConstructor;
7
8
  }, {
8
9
  sync: () => void;
9
10
  handleContentResize: () => void;
10
11
  handleContainerResize: () => void;
11
12
  contentRef: import("vue").Ref<HTMLElement | null>;
12
13
  yRailRef: import("vue").Ref<HTMLElement | null>;
14
+ xRailRef: import("vue").Ref<HTMLElement | null>;
13
15
  containerRef: import("vue").Ref<HTMLElement | null>;
14
16
  contentHeightRef: import("vue").Ref<Nullable<number>>;
15
17
  containerHeightRef: import("vue").Ref<Nullable<number>>;
16
18
  needYBarRef: import("vue").ComputedRef<boolean>;
19
+ needXBarRef: import("vue").ComputedRef<boolean>;
17
20
  yBarSizePxRef: import("vue").ComputedRef<string>;
18
21
  handleYScrollMouseDown: (e: MouseEvent) => void;
22
+ handleXScrollMouseDown: (e: MouseEvent) => void;
19
23
  yBarTopPxRef: import("vue").ComputedRef<string>;
20
24
  handleScroll: (e: Event) => void;
25
+ xBarSizePxRef: import("vue").ComputedRef<string>;
26
+ xBarLeftPxRef: import("vue").ComputedRef<string>;
21
27
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
22
28
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
23
29
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
24
30
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
25
- }>>, {}, {}>>;
31
+ readonly xScrollable: BooleanConstructor;
32
+ }>>, {
33
+ readonly xScrollable: boolean;
34
+ }, {}>>;
26
35
  export default KScrollBar;
@@ -2,23 +2,32 @@ declare const _default: import("vue").DefineComponent<{
2
2
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
3
3
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
4
4
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
5
+ readonly xScrollable: BooleanConstructor;
5
6
  }, {
6
7
  sync: () => void;
7
8
  handleContentResize: () => void;
8
9
  handleContainerResize: () => void;
9
10
  contentRef: import("vue").Ref<HTMLElement | null>;
10
11
  yRailRef: import("vue").Ref<HTMLElement | null>;
12
+ xRailRef: import("vue").Ref<HTMLElement | null>;
11
13
  containerRef: import("vue").Ref<HTMLElement | null>;
12
14
  contentHeightRef: import("vue").Ref<Nullable<number>>;
13
15
  containerHeightRef: import("vue").Ref<Nullable<number>>;
14
16
  needYBarRef: import("vue").ComputedRef<boolean>;
17
+ needXBarRef: import("vue").ComputedRef<boolean>;
15
18
  yBarSizePxRef: import("vue").ComputedRef<string>;
16
19
  handleYScrollMouseDown: (e: MouseEvent) => void;
20
+ handleXScrollMouseDown: (e: MouseEvent) => void;
17
21
  yBarTopPxRef: import("vue").ComputedRef<string>;
18
22
  handleScroll: (e: Event) => void;
23
+ xBarSizePxRef: import("vue").ComputedRef<string>;
24
+ xBarLeftPxRef: import("vue").ComputedRef<string>;
19
25
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
26
  readonly container: import("vue").PropType<() => HTMLElement | null | undefined>;
21
27
  readonly content: import("vue").PropType<() => HTMLElement | null | undefined>;
22
28
  readonly onScroll: import("vue").PropType<(e: Event) => void>;
23
- }>>, {}, {}>;
29
+ readonly xScrollable: BooleanConstructor;
30
+ }>>, {
31
+ readonly xScrollable: boolean;
32
+ }, {}>;
24
33
  export default _default;
@@ -29,11 +29,13 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
29
29
  const contentRef = vue.ref(null);
30
30
  const containerRef = vue.ref(null);
31
31
  const yRailRef = vue.ref(null);
32
+ const xRailRef = vue.ref(null);
32
33
  const contentHeightRef = vue.ref(null);
33
34
  const contentWidthRef = vue.ref(null);
34
35
  const containerHeightRef = vue.ref(null);
35
36
  const containerWidthRef = vue.ref(null);
36
37
  const yRailSizeRef = vue.ref(null);
38
+ const xRailSizeRef = vue.ref(null);
37
39
  const mergedContentRef = vue.computed(() => {
38
40
  var _a;
39
41
  return ((_a = props.content) == null ? void 0 : _a.call(props)) || contentRef.value;
@@ -43,6 +45,16 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
43
45
  return ((_a = props.container) == null ? void 0 : _a.call(props)) || containerRef.value;
44
46
  });
45
47
  const containerScrollTopRef = vue.ref(0);
48
+ const containerScrollLeftRef = vue.ref(0);
49
+ const needYBarRef = vue.computed(() => {
50
+ const {
51
+ value: containerHeight
52
+ } = containerHeightRef;
53
+ const {
54
+ value: contentHeight
55
+ } = contentHeightRef;
56
+ return containerHeight !== null && contentHeight !== null && contentHeight > containerHeight;
57
+ });
46
58
  const yBarSizeRef = vue.computed(() => {
47
59
  const {
48
60
  value: containerHeight
@@ -59,6 +71,9 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
59
71
  return Math.min(containerHeight, yRailSize * containerHeight / contentHeight + 5 * 1.5);
60
72
  }
61
73
  });
74
+ const yBarSizePxRef = vue.computed(() => {
75
+ return `${yBarSizeRef.value}px`;
76
+ });
62
77
  const yBarTopRef = vue.computed(() => {
63
78
  const {
64
79
  value: containerHeight
@@ -83,46 +98,16 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
83
98
  const yBarTopPxRef = vue.computed(() => {
84
99
  return `${yBarTopRef.value}px`;
85
100
  });
86
- const needYBarRef = vue.computed(() => {
87
- const {
88
- value: containerHeight
89
- } = containerHeightRef;
90
- const {
91
- value: contentHeight
92
- } = contentHeightRef;
93
- return containerHeight !== null && contentHeight !== null && contentHeight > containerHeight;
94
- });
95
- const yBarSizePxRef = vue.computed(() => {
96
- return `${yBarSizeRef.value}px`;
97
- });
98
- const syncPositionState = () => {
99
- const {
100
- value: content
101
- } = mergedContentRef;
102
- if (content) {
103
- contentHeightRef.value = content.offsetHeight;
104
- contentWidthRef.value = content.offsetWidth;
105
- }
106
- const {
107
- value: container
108
- } = mergedContainerRef;
109
- if (container) {
110
- containerHeightRef.value = container.offsetHeight;
111
- containerWidthRef.value = container.offsetWidth;
112
- }
113
- const {
114
- value: yRailEl
115
- } = yRailRef;
116
- if (yRailEl) {
117
- yRailSizeRef.value = yRailEl.offsetHeight;
118
- }
119
- };
120
101
  let yBarPressed = false;
121
102
  let memoYTop = 0;
122
103
  let memoMouseY = 0;
123
104
  let yBarVanishTimerId;
105
+ let xBarVanishTimerId;
124
106
  const handleYScrollMouseMove = (e) => {
125
107
  if (!yBarPressed) return;
108
+ if (xBarVanishTimerId !== void 0) {
109
+ window.clearTimeout(xBarVanishTimerId);
110
+ }
126
111
  if (yBarVanishTimerId !== void 0) {
127
112
  window.clearTimeout(yBarVanishTimerId);
128
113
  }
@@ -173,14 +158,146 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
173
158
  if (onScroll) onScroll(e);
174
159
  syncScrollState();
175
160
  }
161
+ const needXBarRef = vue.computed(() => {
162
+ const {
163
+ value: containerWidth
164
+ } = containerWidthRef;
165
+ const {
166
+ value: contentWidth
167
+ } = contentWidthRef;
168
+ return containerWidth !== null && contentWidth !== null && contentWidth > containerWidth;
169
+ });
170
+ const xBarSizeRef = vue.computed(() => {
171
+ const {
172
+ value: containerWidth
173
+ } = containerWidthRef;
174
+ const {
175
+ value: contentWidth
176
+ } = contentWidthRef;
177
+ const {
178
+ value: xRailSize
179
+ } = xRailSizeRef;
180
+ if (containerWidth === null || contentWidth === null || xRailSize === null) {
181
+ return 0;
182
+ } else {
183
+ return xRailSize * containerWidth / contentWidth + 5 * 1.5;
184
+ }
185
+ });
186
+ const xBarSizePxRef = vue.computed(() => {
187
+ return `${xBarSizeRef.value}px`;
188
+ });
189
+ const xBarLeftRef = vue.computed(() => {
190
+ const {
191
+ value: containerWidth
192
+ } = containerWidthRef;
193
+ const {
194
+ value: containerScrollLeft
195
+ } = containerScrollLeftRef;
196
+ const {
197
+ value: contentWidth
198
+ } = contentWidthRef;
199
+ const {
200
+ value: xRailSize
201
+ } = xRailSizeRef;
202
+ if (containerWidth === null || contentWidth === null || xRailSize === null) {
203
+ return 0;
204
+ } else {
205
+ const widthDiff = contentWidth - containerWidth;
206
+ if (!widthDiff) return 0;
207
+ return containerScrollLeft / widthDiff * (xRailSize - xBarSizeRef.value);
208
+ }
209
+ });
210
+ const xBarLeftPxRef = vue.computed(() => {
211
+ return `${xBarLeftRef.value}px`;
212
+ });
213
+ let xBarPressed = false;
214
+ let memoXLeft = 0;
215
+ let memoMouseX = 0;
216
+ const handleXScrollMouseMove = (e) => {
217
+ if (!xBarPressed) return;
218
+ if (xBarVanishTimerId !== void 0) {
219
+ window.clearTimeout(xBarVanishTimerId);
220
+ }
221
+ if (yBarVanishTimerId !== void 0) {
222
+ window.clearTimeout(yBarVanishTimerId);
223
+ }
224
+ const {
225
+ value: containerWidth
226
+ } = containerWidthRef;
227
+ const {
228
+ value: contentWidth
229
+ } = contentWidthRef;
230
+ const {
231
+ value: xBarSize
232
+ } = xBarSizeRef;
233
+ if (containerWidth === null || contentWidth === null) return;
234
+ const dX = e.clientX - memoMouseX;
235
+ const dScrollLeft = dX * (contentWidth - containerWidth) / (containerWidth - xBarSize);
236
+ const toScrollLeftUpperBound = contentWidth - containerWidth;
237
+ let toScrollLeft = memoXLeft + dScrollLeft;
238
+ toScrollLeft = Math.min(toScrollLeftUpperBound, toScrollLeft);
239
+ toScrollLeft = Math.max(toScrollLeft, 0);
240
+ const {
241
+ value: container
242
+ } = mergedContainerRef;
243
+ if (container) {
244
+ container.scrollLeft = toScrollLeft;
245
+ }
246
+ };
247
+ const handleXScrollMouseUp = (e) => {
248
+ e.preventDefault();
249
+ e.stopPropagation();
250
+ evtd.off("mousemove", window, handleXScrollMouseMove, true);
251
+ evtd.off("mouseup", window, handleXScrollMouseUp, true);
252
+ xBarPressed = false;
253
+ sync();
254
+ };
255
+ function handleXScrollMouseDown(e) {
256
+ e.preventDefault();
257
+ e.stopPropagation();
258
+ xBarPressed = true;
259
+ evtd.on("mousemove", window, handleXScrollMouseMove, true);
260
+ evtd.on("mouseup", window, handleXScrollMouseUp, true);
261
+ memoXLeft = containerScrollLeftRef.value;
262
+ memoMouseX = e.clientX;
263
+ }
176
264
  function syncScrollState() {
177
265
  const {
178
266
  value: container
179
267
  } = mergedContainerRef;
180
268
  if (container) {
181
269
  containerScrollTopRef.value = container.scrollTop;
270
+ containerScrollLeftRef.value = container.scrollLeft;
182
271
  }
183
272
  }
273
+ const syncPositionState = () => {
274
+ const {
275
+ value: content
276
+ } = mergedContentRef;
277
+ if (content) {
278
+ contentHeightRef.value = content.offsetHeight;
279
+ contentWidthRef.value = content.offsetWidth;
280
+ }
281
+ const {
282
+ value: container
283
+ } = mergedContainerRef;
284
+ if (container) {
285
+ containerHeightRef.value = container.offsetHeight;
286
+ containerWidthRef.value = container.offsetWidth;
287
+ }
288
+ const {
289
+ value: yRailEl
290
+ } = yRailRef;
291
+ if (yRailEl) {
292
+ yRailSizeRef.value = yRailEl.offsetHeight;
293
+ }
294
+ const {
295
+ value: xRailEl
296
+ } = xRailRef;
297
+ if (xRailEl) {
298
+ xRailSizeRef.value = xRailEl.offsetWidth;
299
+ }
300
+ };
184
301
  function sync() {
185
302
  syncPositionState();
186
303
  syncScrollState();
@@ -191,27 +308,46 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
191
308
  handleContainerResize,
192
309
  contentRef,
193
310
  yRailRef,
311
+ xRailRef,
194
312
  containerRef,
195
313
  contentHeightRef,
196
314
  containerHeightRef,
197
315
  needYBarRef,
316
+ needXBarRef,
198
317
  yBarSizePxRef,
199
318
  handleYScrollMouseDown,
319
+ handleXScrollMouseDown,
200
320
  yBarTopPxRef,
201
- handleScroll
321
+ handleScroll,
322
+ xBarSizePxRef,
323
+ xBarLeftPxRef
202
324
  };
203
325
  },
204
326
  render() {
205
327
  let _slot;
206
328
  const {
207
- $slots
329
+ $slots,
330
+ xScrollable
208
331
  } = this;
332
+ const createXBar = () => {
333
+ return vue.createVNode("div", {
334
+ "class": `${index.defaultNamespace}-scrollbar-rail ${index.defaultNamespace}-scrollbar-rail--horizontal`,
335
+ "ref": "xRailRef"
336
+ }, [this.needXBarRef && vue.createVNode("div", {
337
+ "class": `${index.defaultNamespace}-scrollbar-rail__scrollbar--horizontal`,
338
+ "style": {
339
+ width: this.xBarSizePxRef,
340
+ left: this.xBarLeftPxRef
341
+ },
342
+ "onMousedown": this.handleXScrollMouseDown
343
+ }, null)]);
344
+ };
209
345
  const createYBar = () => {
210
346
  return vue.createVNode("div", {
211
- "class": `${index.defaultNamespace}-scrollbar-rail`,
347
+ "class": `${index.defaultNamespace}-scrollbar-rail ${index.defaultNamespace}-scrollbar-rail--vertical`,
212
348
  "ref": "yRailRef"
213
349
  }, [this.needYBarRef && vue.createVNode("div", {
214
- "class": `${index.defaultNamespace}-scrollbar-rail__scrollbar`,
350
+ "class": `${index.defaultNamespace}-scrollbar-rail__scrollbar--vertical`,
215
351
  "style": {
216
352
  height: this.yBarSizePxRef,
217
353
  top: this.yBarTopPxRef
@@ -237,7 +373,7 @@ var ScrollBar = /* @__PURE__ */ vue.defineComponent({
237
373
  "class": `${index.defaultNamespace}-scrollbar-content`
238
374
  }, [(_a2 = $slots.default) == null ? void 0 : _a2.call($slots)])];
239
375
  }
240
- })]), createYBar()]);
376
+ })]), createYBar(), xScrollable && createXBar()]);
241
377
  };
242
378
  const createBarNode = this.container ? createChildren() : vue.createVNode(vueuc.VResizeObserver, {
243
379
  "onResize": this.handleContainerResize