@indielayer/ui 1.15.3 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/docs/components/menu/DocsMenu.vue +3 -0
  2. package/docs/pages/component/infiniteLoader/composable.vue +168 -0
  3. package/docs/pages/component/infiniteLoader/index.vue +36 -0
  4. package/docs/pages/component/infiniteLoader/usage.vue +161 -0
  5. package/docs/pages/component/table/usage.vue +13 -0
  6. package/docs/pages/component/virtualGrid/index.vue +29 -0
  7. package/docs/pages/component/virtualGrid/usage.vue +20 -0
  8. package/docs/pages/component/virtualList/dynamicHeight.vue +75 -0
  9. package/docs/pages/component/virtualList/index.vue +36 -0
  10. package/docs/pages/component/virtualList/usage.vue +17 -0
  11. package/docs/search/components.json +1 -1
  12. package/lib/components/select/Select.vue.js +35 -35
  13. package/lib/components/table/Table.vue.d.ts +9 -0
  14. package/lib/components/table/Table.vue.js +190 -160
  15. package/lib/components/tooltip/Tooltip.vue.js +64 -52
  16. package/lib/composables/useVirtualList.d.ts +1 -1
  17. package/lib/index.d.ts +1 -0
  18. package/lib/index.js +88 -76
  19. package/lib/index.umd.js +4 -4
  20. package/lib/install.js +15 -7
  21. package/lib/version.d.ts +1 -1
  22. package/lib/version.js +1 -1
  23. package/lib/virtual/components/infiniteLoader/InfiniteLoader.test.d.ts +1 -0
  24. package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue.d.ts +49 -0
  25. package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue.js +21 -0
  26. package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue2.js +4 -0
  27. package/lib/virtual/components/virtualGrid/VirtualGrid.vue.d.ts +185 -0
  28. package/lib/virtual/components/virtualGrid/VirtualGrid.vue.js +241 -0
  29. package/lib/virtual/components/virtualGrid/VirtualGrid.vue2.js +4 -0
  30. package/lib/virtual/components/virtualGrid/types.d.ts +138 -0
  31. package/lib/virtual/components/virtualList/VirtualList.test.d.ts +1 -0
  32. package/lib/virtual/components/virtualList/VirtualList.vue.d.ts +135 -0
  33. package/lib/virtual/components/virtualList/VirtualList.vue.js +157 -0
  34. package/lib/virtual/components/virtualList/VirtualList.vue2.js +4 -0
  35. package/lib/virtual/components/virtualList/isDynamicRowHeight.d.ts +2 -0
  36. package/lib/virtual/components/virtualList/isDynamicRowHeight.js +6 -0
  37. package/lib/virtual/components/virtualList/types.d.ts +115 -0
  38. package/lib/virtual/components/virtualList/useDynamicRowHeight.d.ts +7 -0
  39. package/lib/virtual/components/virtualList/useDynamicRowHeight.js +69 -0
  40. package/lib/virtual/components/virtualList/useDynamicRowHeight.test.d.ts +1 -0
  41. package/lib/virtual/composables/infinite-loader/scanForUnloadedIndices.d.ts +8 -0
  42. package/lib/virtual/composables/infinite-loader/scanForUnloadedIndices.js +41 -0
  43. package/lib/virtual/composables/infinite-loader/scanForUnloadedIndices.test.d.ts +1 -0
  44. package/lib/virtual/composables/infinite-loader/types.d.ts +30 -0
  45. package/lib/virtual/composables/infinite-loader/useInfiniteLoader.d.ts +6 -0
  46. package/lib/virtual/composables/infinite-loader/useInfiniteLoader.js +42 -0
  47. package/lib/virtual/composables/infinite-loader/useInfiniteLoader.test.d.ts +1 -0
  48. package/lib/virtual/core/createCachedBounds.d.ts +6 -0
  49. package/lib/virtual/core/createCachedBounds.js +55 -0
  50. package/lib/virtual/core/getEstimatedSize.d.ts +6 -0
  51. package/lib/virtual/core/getEstimatedSize.js +22 -0
  52. package/lib/virtual/core/getOffsetForIndex.d.ts +11 -0
  53. package/lib/virtual/core/getOffsetForIndex.js +40 -0
  54. package/lib/virtual/core/getStartStopIndices.d.ts +13 -0
  55. package/lib/virtual/core/getStartStopIndices.js +31 -0
  56. package/lib/virtual/core/getStartStopIndices.test.d.ts +1 -0
  57. package/lib/virtual/core/types.d.ts +11 -0
  58. package/lib/virtual/core/useCachedBounds.d.ts +7 -0
  59. package/lib/virtual/core/useCachedBounds.js +18 -0
  60. package/lib/virtual/core/useIsRtl.d.ts +2 -0
  61. package/lib/virtual/core/useIsRtl.js +15 -0
  62. package/lib/virtual/core/useItemSize.d.ts +5 -0
  63. package/lib/virtual/core/useItemSize.js +27 -0
  64. package/lib/virtual/core/useVirtualizer.d.ts +33 -0
  65. package/lib/virtual/core/useVirtualizer.js +171 -0
  66. package/lib/virtual/index.d.ts +9 -0
  67. package/lib/virtual/test-utils/mockResizeObserver.d.ts +15 -0
  68. package/lib/virtual/types.d.ts +2 -0
  69. package/lib/virtual/utils/adjustScrollOffsetForRtl.d.ts +7 -0
  70. package/lib/virtual/utils/adjustScrollOffsetForRtl.js +24 -0
  71. package/lib/virtual/utils/areArraysEqual.d.ts +1 -0
  72. package/lib/virtual/utils/assert.d.ts +1 -0
  73. package/lib/virtual/utils/assert.js +7 -0
  74. package/lib/virtual/utils/getRTLOffsetType.d.ts +2 -0
  75. package/lib/virtual/utils/getRTLOffsetType.js +13 -0
  76. package/lib/virtual/utils/getScrollbarSize.d.ts +2 -0
  77. package/lib/virtual/utils/getScrollbarSize.js +11 -0
  78. package/lib/virtual/utils/isRtl.d.ts +1 -0
  79. package/lib/virtual/utils/isRtl.js +12 -0
  80. package/lib/virtual/utils/parseNumericStyleValue.d.ts +2 -0
  81. package/lib/virtual/utils/parseNumericStyleValue.js +15 -0
  82. package/lib/virtual/utils/shallowCompare.d.ts +1 -0
  83. package/lib/virtual/utils/shallowCompare.js +14 -0
  84. package/package.json +1 -1
  85. package/src/components/select/Select.vue +3 -2
  86. package/src/components/table/Table.vue +23 -2
  87. package/src/components/tooltip/Tooltip.vue +25 -5
  88. package/src/composables/useVirtualList.ts +1 -1
  89. package/src/index.ts +1 -0
  90. package/src/install.ts +9 -3
  91. package/src/version.ts +1 -1
  92. package/src/virtual/README.md +285 -0
  93. package/src/virtual/components/infiniteLoader/InfiniteLoader.test.ts +96 -0
  94. package/src/virtual/components/infiniteLoader/InfiniteLoader.vue +18 -0
  95. package/src/virtual/components/virtualGrid/VirtualGrid.vue +322 -0
  96. package/src/virtual/components/virtualGrid/types.ts +160 -0
  97. package/src/virtual/components/virtualList/VirtualList.test.ts +47 -0
  98. package/src/virtual/components/virtualList/VirtualList.vue +233 -0
  99. package/src/virtual/components/virtualList/isDynamicRowHeight.ts +13 -0
  100. package/src/virtual/components/virtualList/types.ts +127 -0
  101. package/src/virtual/components/virtualList/useDynamicRowHeight.test.ts +183 -0
  102. package/src/virtual/components/virtualList/useDynamicRowHeight.ts +147 -0
  103. package/src/virtual/composables/infinite-loader/scanForUnloadedIndices.test.ts +141 -0
  104. package/src/virtual/composables/infinite-loader/scanForUnloadedIndices.ts +82 -0
  105. package/src/virtual/composables/infinite-loader/types.ts +36 -0
  106. package/src/virtual/composables/infinite-loader/useInfiniteLoader.test.ts +236 -0
  107. package/src/virtual/composables/infinite-loader/useInfiniteLoader.ts +88 -0
  108. package/src/virtual/core/createCachedBounds.ts +72 -0
  109. package/src/virtual/core/getEstimatedSize.ts +29 -0
  110. package/src/virtual/core/getOffsetForIndex.ts +90 -0
  111. package/src/virtual/core/getStartStopIndices.test.ts +45 -0
  112. package/src/virtual/core/getStartStopIndices.ts +71 -0
  113. package/src/virtual/core/types.ts +17 -0
  114. package/src/virtual/core/useCachedBounds.ts +21 -0
  115. package/src/virtual/core/useIsRtl.ts +25 -0
  116. package/src/virtual/core/useItemSize.ts +34 -0
  117. package/src/virtual/core/useVirtualizer.ts +294 -0
  118. package/src/virtual/index.ts +25 -0
  119. package/src/virtual/test-utils/mockResizeObserver.ts +162 -0
  120. package/src/virtual/types.ts +3 -0
  121. package/src/virtual/utils/adjustScrollOffsetForRtl.ts +37 -0
  122. package/src/virtual/utils/areArraysEqual.ts +13 -0
  123. package/src/virtual/utils/assert.ts +10 -0
  124. package/src/virtual/utils/getRTLOffsetType.ts +51 -0
  125. package/src/virtual/utils/getScrollbarSize.ts +24 -0
  126. package/src/virtual/utils/isRtl.ts +13 -0
  127. package/src/virtual/utils/parseNumericStyleValue.ts +19 -0
  128. package/src/virtual/utils/shallowCompare.ts +29 -0
  129. package/volar.d.ts +3 -0
package/lib/install.js CHANGED
@@ -1,10 +1,18 @@
1
- import * as t from "./components/index.js";
2
- import o from "./create.js";
3
- const m = o({
4
- components: Object.keys(t).map(
5
- (e) => t[e]
6
- )
1
+ import * as m from "./components/index.js";
2
+ import r from "./create.js";
3
+ import t from "./virtual/components/virtualList/VirtualList.vue.js";
4
+ import i from "./virtual/components/virtualGrid/VirtualGrid.vue.js";
5
+ import a from "./virtual/components/infiniteLoader/InfiniteLoader.vue.js";
6
+ const p = r({
7
+ components: [
8
+ ...Object.keys(m).map(
9
+ (o) => m[o]
10
+ ),
11
+ t,
12
+ i,
13
+ a
14
+ ]
7
15
  });
8
16
  export {
9
- m as default
17
+ p as default
10
18
  };
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.15.3";
1
+ declare const _default: "1.17.0";
2
2
  export default _default;
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const e = "1.15.3";
1
+ const e = "1.17.0";
2
2
  export {
3
3
  e as default
4
4
  };
@@ -0,0 +1,49 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ isRowLoaded: {
3
+ type: import("vue").PropType<(index: number) => boolean>;
4
+ required: true;
5
+ };
6
+ loadMoreRows: {
7
+ type: import("vue").PropType<(startIndex: number, stopIndex: number) => Promise<void>>;
8
+ required: true;
9
+ };
10
+ minimumBatchSize: {
11
+ type: import("vue").PropType<number>;
12
+ };
13
+ threshold: {
14
+ type: import("vue").PropType<number>;
15
+ };
16
+ rowCount: {
17
+ type: import("vue").PropType<number>;
18
+ required: true;
19
+ };
20
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ isRowLoaded: {
22
+ type: import("vue").PropType<(index: number) => boolean>;
23
+ required: true;
24
+ };
25
+ loadMoreRows: {
26
+ type: import("vue").PropType<(startIndex: number, stopIndex: number) => Promise<void>>;
27
+ required: true;
28
+ };
29
+ minimumBatchSize: {
30
+ type: import("vue").PropType<number>;
31
+ };
32
+ threshold: {
33
+ type: import("vue").PropType<number>;
34
+ };
35
+ rowCount: {
36
+ type: import("vue").PropType<number>;
37
+ required: true;
38
+ };
39
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
40
+ default?(_: {
41
+ onRowsRendered: import("../../composables/infinite-loader/types").OnRowsRendered;
42
+ }): any;
43
+ }>;
44
+ export default _default;
45
+ type __VLS_WithTemplateSlots<T, S> = T & {
46
+ new (): {
47
+ $slots: S;
48
+ };
49
+ };
@@ -0,0 +1,21 @@
1
+ import { defineComponent as r, renderSlot as s, unref as d } from "vue";
2
+ import { useInfiniteLoader as i } from "../../composables/infinite-loader/useInfiniteLoader.js";
3
+ const a = {
4
+ name: "XInfiniteLoader"
5
+ }, f = /* @__PURE__ */ r({
6
+ ...a,
7
+ props: {
8
+ isRowLoaded: { type: Function },
9
+ loadMoreRows: { type: Function },
10
+ minimumBatchSize: {},
11
+ threshold: {},
12
+ rowCount: {}
13
+ },
14
+ setup(e) {
15
+ const o = e, { onRowsRendered: n } = i(o);
16
+ return (t, u) => s(t.$slots, "default", { onRowsRendered: d(n) });
17
+ }
18
+ });
19
+ export {
20
+ f as default
21
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./InfiniteLoader.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,185 @@
1
+ import { type CSSProperties } from 'vue';
2
+ import type { Align } from '../../types';
3
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ tag: {
5
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
6
+ default: string;
7
+ };
8
+ dir: {
9
+ type: import("vue").PropType<"rtl" | "ltr" | "auto">;
10
+ };
11
+ class: {
12
+ type: import("vue").PropType<string>;
13
+ };
14
+ style: {
15
+ type: import("vue").PropType<CSSProperties>;
16
+ };
17
+ onResize: {
18
+ type: import("vue").PropType<(size: {
19
+ height: number;
20
+ width: number;
21
+ }, prevSize: {
22
+ height: number;
23
+ width: number;
24
+ }) => void>;
25
+ };
26
+ columnCount: {
27
+ type: import("vue").PropType<number>;
28
+ required: true;
29
+ };
30
+ columnWidth: {
31
+ type: import("vue").PropType<string | number | ((index: number, cellProps: Record<string, unknown>) => number)>;
32
+ required: true;
33
+ };
34
+ rowCount: {
35
+ type: import("vue").PropType<number>;
36
+ required: true;
37
+ };
38
+ overscanCount: {
39
+ type: import("vue").PropType<number>;
40
+ default: number;
41
+ };
42
+ cellProps: {
43
+ type: import("vue").PropType<{
44
+ [x: string]: unknown;
45
+ }>;
46
+ };
47
+ defaultHeight: {
48
+ type: import("vue").PropType<number>;
49
+ default: number;
50
+ };
51
+ defaultWidth: {
52
+ type: import("vue").PropType<number>;
53
+ default: number;
54
+ };
55
+ onCellsRendered: {
56
+ type: import("vue").PropType<(visibleCells: {
57
+ columnStartIndex: number;
58
+ columnStopIndex: number;
59
+ rowStartIndex: number;
60
+ rowStopIndex: number;
61
+ }, allCells: {
62
+ columnStartIndex: number;
63
+ columnStopIndex: number;
64
+ rowStartIndex: number;
65
+ rowStopIndex: number;
66
+ }) => void>;
67
+ };
68
+ rowHeight: {
69
+ type: import("vue").PropType<string | number | ((index: number, cellProps: Record<string, unknown>) => number)>;
70
+ required: true;
71
+ };
72
+ }>, {
73
+ element: HTMLDivElement | null;
74
+ scrollToCell({ behavior, columnAlign, columnIndex, rowAlign, rowIndex, }: {
75
+ behavior?: ScrollBehavior | undefined;
76
+ columnAlign?: Align | undefined;
77
+ columnIndex: number;
78
+ rowAlign?: Align | undefined;
79
+ rowIndex: number;
80
+ }): void;
81
+ scrollToColumn({ align, behavior, index, }: {
82
+ align?: Align | undefined;
83
+ behavior?: ScrollBehavior | undefined;
84
+ index: number;
85
+ }): void;
86
+ scrollToRow({ align, behavior, index, }: {
87
+ align?: Align | undefined;
88
+ behavior?: ScrollBehavior | undefined;
89
+ index: number;
90
+ }): void;
91
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
92
+ tag: {
93
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
94
+ default: string;
95
+ };
96
+ dir: {
97
+ type: import("vue").PropType<"rtl" | "ltr" | "auto">;
98
+ };
99
+ class: {
100
+ type: import("vue").PropType<string>;
101
+ };
102
+ style: {
103
+ type: import("vue").PropType<CSSProperties>;
104
+ };
105
+ onResize: {
106
+ type: import("vue").PropType<(size: {
107
+ height: number;
108
+ width: number;
109
+ }, prevSize: {
110
+ height: number;
111
+ width: number;
112
+ }) => void>;
113
+ };
114
+ columnCount: {
115
+ type: import("vue").PropType<number>;
116
+ required: true;
117
+ };
118
+ columnWidth: {
119
+ type: import("vue").PropType<string | number | ((index: number, cellProps: Record<string, unknown>) => number)>;
120
+ required: true;
121
+ };
122
+ rowCount: {
123
+ type: import("vue").PropType<number>;
124
+ required: true;
125
+ };
126
+ overscanCount: {
127
+ type: import("vue").PropType<number>;
128
+ default: number;
129
+ };
130
+ cellProps: {
131
+ type: import("vue").PropType<{
132
+ [x: string]: unknown;
133
+ }>;
134
+ };
135
+ defaultHeight: {
136
+ type: import("vue").PropType<number>;
137
+ default: number;
138
+ };
139
+ defaultWidth: {
140
+ type: import("vue").PropType<number>;
141
+ default: number;
142
+ };
143
+ onCellsRendered: {
144
+ type: import("vue").PropType<(visibleCells: {
145
+ columnStartIndex: number;
146
+ columnStopIndex: number;
147
+ rowStartIndex: number;
148
+ rowStopIndex: number;
149
+ }, allCells: {
150
+ columnStartIndex: number;
151
+ columnStopIndex: number;
152
+ rowStartIndex: number;
153
+ rowStopIndex: number;
154
+ }) => void>;
155
+ };
156
+ rowHeight: {
157
+ type: import("vue").PropType<string | number | ((index: number, cellProps: Record<string, unknown>) => number)>;
158
+ required: true;
159
+ };
160
+ }>> & Readonly<{}>, {
161
+ tag: keyof HTMLElementTagNameMap;
162
+ overscanCount: number;
163
+ defaultHeight: number;
164
+ defaultWidth: number;
165
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
166
+ cell?(_: {
167
+ columnIndex: number;
168
+ rowIndex: number;
169
+ style: CSSProperties;
170
+ ariaAttributes: {
171
+ 'aria-colindex': number;
172
+ role: 'gridcell';
173
+ };
174
+ props: {
175
+ [x: string]: unknown;
176
+ } & Record<string, unknown>;
177
+ }): any;
178
+ default?(_: {}): any;
179
+ }>;
180
+ export default _default;
181
+ type __VLS_WithTemplateSlots<T, S> = T & {
182
+ new (): {
183
+ $slots: S;
184
+ };
185
+ };
@@ -0,0 +1,241 @@
1
+ import { defineComponent as G, ref as D, computed as y, watch as F, openBlock as c, createBlock as N, resolveDynamicComponent as X, normalizeClass as j, normalizeStyle as m, withCtx as q, createElementBlock as p, Fragment as z, renderList as R, renderSlot as T, createElementVNode as J, unref as b } from "vue";
2
+ import { useIsRtl as K } from "../../core/useIsRtl.js";
3
+ import { useVirtualizer as O } from "../../core/useVirtualizer.js";
4
+ const M = ["aria-rowindex"], Q = {
5
+ name: "XVirtualGrid"
6
+ }, ee = /* @__PURE__ */ G({
7
+ ...Q,
8
+ props: {
9
+ cellProps: {},
10
+ class: {},
11
+ columnCount: {},
12
+ columnWidth: {},
13
+ defaultHeight: { default: 0 },
14
+ defaultWidth: { default: 0 },
15
+ dir: {},
16
+ onCellsRendered: {},
17
+ onResize: {},
18
+ overscanCount: { default: 3 },
19
+ rowCount: {},
20
+ rowHeight: {},
21
+ style: {},
22
+ tag: { default: "div" }
23
+ },
24
+ setup(V, { expose: k }) {
25
+ const o = V, r = D(null), f = y(() => o.cellProps || {}), u = K(r, o.dir), {
26
+ getCellBounds: B,
27
+ getEstimatedSize: $,
28
+ startIndexOverscan: x,
29
+ startIndexVisible: E,
30
+ scrollToIndex: v,
31
+ stopIndexOverscan: I,
32
+ stopIndexVisible: H
33
+ } = O({
34
+ containerElement: r,
35
+ containerStyle: o.style,
36
+ defaultContainerSize: o.defaultWidth,
37
+ direction: "horizontal",
38
+ isRtl: u.value,
39
+ itemCount: o.columnCount,
40
+ itemProps: f.value,
41
+ itemSize: o.columnWidth,
42
+ onResize: o.onResize,
43
+ overscanCount: o.overscanCount
44
+ }), {
45
+ getCellBounds: W,
46
+ getEstimatedSize: P,
47
+ startIndexOverscan: w,
48
+ startIndexVisible: _,
49
+ scrollToIndex: C,
50
+ stopIndexOverscan: h,
51
+ stopIndexVisible: A
52
+ } = O({
53
+ containerElement: r,
54
+ containerStyle: o.style,
55
+ defaultContainerSize: o.defaultHeight,
56
+ direction: "vertical",
57
+ itemCount: o.rowCount,
58
+ itemProps: f.value,
59
+ itemSize: o.rowHeight,
60
+ onResize: o.onResize,
61
+ overscanCount: o.overscanCount
62
+ });
63
+ k({
64
+ get element() {
65
+ return r.value;
66
+ },
67
+ scrollToCell({
68
+ behavior: e = "auto",
69
+ columnAlign: n = "auto",
70
+ columnIndex: s,
71
+ rowAlign: t = "auto",
72
+ rowIndex: l
73
+ }) {
74
+ var d, S, g;
75
+ const i = v({
76
+ align: n,
77
+ containerScrollOffset: ((d = r.value) == null ? void 0 : d.scrollLeft) ?? 0,
78
+ index: s
79
+ }), a = C({
80
+ align: t,
81
+ containerScrollOffset: ((S = r.value) == null ? void 0 : S.scrollTop) ?? 0,
82
+ index: l
83
+ });
84
+ typeof ((g = r.value) == null ? void 0 : g.scrollTo) == "function" && i !== void 0 && a !== void 0 && r.value.scrollTo({
85
+ behavior: e,
86
+ left: i,
87
+ top: a
88
+ });
89
+ },
90
+ scrollToColumn({
91
+ align: e = "auto",
92
+ behavior: n = "auto",
93
+ index: s
94
+ }) {
95
+ var l, i;
96
+ const t = v({
97
+ align: e,
98
+ containerScrollOffset: ((l = r.value) == null ? void 0 : l.scrollLeft) ?? 0,
99
+ index: s
100
+ });
101
+ typeof ((i = r.value) == null ? void 0 : i.scrollTo) == "function" && t !== void 0 && r.value.scrollTo({
102
+ behavior: n,
103
+ left: t
104
+ });
105
+ },
106
+ scrollToRow({
107
+ align: e = "auto",
108
+ behavior: n = "auto",
109
+ index: s
110
+ }) {
111
+ var l, i;
112
+ const t = C({
113
+ align: e,
114
+ containerScrollOffset: ((l = r.value) == null ? void 0 : l.scrollTop) ?? 0,
115
+ index: s
116
+ });
117
+ typeof ((i = r.value) == null ? void 0 : i.scrollTo) == "function" && t !== void 0 && r.value.scrollTo({
118
+ behavior: n,
119
+ top: t
120
+ });
121
+ }
122
+ }), F(
123
+ [
124
+ x,
125
+ E,
126
+ I,
127
+ H,
128
+ w,
129
+ _,
130
+ h,
131
+ A
132
+ ],
133
+ ([
134
+ e,
135
+ n,
136
+ s,
137
+ t,
138
+ l,
139
+ i,
140
+ a,
141
+ d
142
+ ]) => {
143
+ e >= 0 && s >= 0 && l >= 0 && a >= 0 && o.onCellsRendered && o.onCellsRendered(
144
+ {
145
+ columnStartIndex: n,
146
+ columnStopIndex: t,
147
+ rowStartIndex: i,
148
+ rowStopIndex: d
149
+ },
150
+ {
151
+ columnStartIndex: e,
152
+ columnStopIndex: s,
153
+ rowStartIndex: l,
154
+ rowStopIndex: a
155
+ }
156
+ );
157
+ }
158
+ );
159
+ const L = y(() => {
160
+ const e = [];
161
+ if (o.columnCount > 0 && o.rowCount > 0)
162
+ for (let n = w.value; n <= h.value; n++) {
163
+ const s = W(n), t = [];
164
+ for (let l = x.value; l <= I.value; l++) {
165
+ const i = B(l), a = {
166
+ position: "absolute",
167
+ left: u.value ? void 0 : 0,
168
+ right: u.value ? 0 : void 0,
169
+ transform: `translate(${u.value ? -i.scrollOffset : i.scrollOffset}px, ${s.scrollOffset}px)`,
170
+ height: `${s.size}px`,
171
+ width: `${i.size}px`
172
+ };
173
+ t.push({
174
+ key: l,
175
+ columnIndex: l,
176
+ rowIndex: n,
177
+ style: a,
178
+ ariaAttributes: {
179
+ "aria-colindex": l + 1,
180
+ role: "gridcell"
181
+ }
182
+ });
183
+ }
184
+ e.push({
185
+ key: n,
186
+ rowIndex: n,
187
+ columns: t,
188
+ ariaRowIndex: n + 1
189
+ });
190
+ }
191
+ return e;
192
+ });
193
+ return (e, n) => (c(), N(X(e.tag), {
194
+ ref_key: "element",
195
+ ref: r,
196
+ class: j(e.$props.class),
197
+ style: m({
198
+ position: "relative",
199
+ maxHeight: "100%",
200
+ maxWidth: "100%",
201
+ flexGrow: 1,
202
+ overflow: "auto",
203
+ ...e.style
204
+ }),
205
+ dir: e.dir,
206
+ role: "grid",
207
+ "aria-colcount": e.columnCount,
208
+ "aria-rowcount": e.rowCount
209
+ }, {
210
+ default: q(() => [
211
+ (c(!0), p(z, null, R(L.value, (s) => (c(), p("div", {
212
+ key: s.key,
213
+ role: "row",
214
+ "aria-rowindex": s.ariaRowIndex
215
+ }, [
216
+ (c(!0), p(z, null, R(s.columns, (t) => T(e.$slots, "cell", {
217
+ key: t.key,
218
+ columnIndex: t.columnIndex,
219
+ rowIndex: t.rowIndex,
220
+ style: m(t.style),
221
+ ariaAttributes: t.ariaAttributes,
222
+ props: f.value
223
+ })), 128))
224
+ ], 8, M))), 128)),
225
+ T(e.$slots, "default"),
226
+ J("div", {
227
+ "aria-hidden": "",
228
+ style: m({
229
+ height: `${b(P)}px`,
230
+ width: `${b($)}px`,
231
+ zIndex: -1
232
+ })
233
+ }, null, 4)
234
+ ]),
235
+ _: 3
236
+ }, 8, ["class", "style", "dir", "aria-colcount", "aria-rowcount"]));
237
+ }
238
+ });
239
+ export {
240
+ ee as default
241
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./VirtualGrid.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,138 @@
1
+ import type { CSSProperties } from 'vue';
2
+ import type { TagNames } from '../../types';
3
+ type ForbiddenKeys = 'ariaAttributes' | 'columnIndex' | 'rowIndex' | 'style';
4
+ type ExcludeForbiddenKeys<Type> = {
5
+ [Key in keyof Type]: Key extends ForbiddenKeys ? never : Type[Key];
6
+ };
7
+ export interface VirtualGridProps {
8
+ /**
9
+ * Additional props to be passed to the cell-rendering component via slots.
10
+ */
11
+ cellProps?: ExcludeForbiddenKeys<Record<string, unknown>>;
12
+ /**
13
+ * CSS class name.
14
+ */
15
+ class?: string;
16
+ /**
17
+ * Number of columns to be rendered in the grid.
18
+ */
19
+ columnCount: number;
20
+ /**
21
+ * Column width; the following formats are supported:
22
+ * - number of pixels (number)
23
+ * - percentage of the grid's current width (string)
24
+ * - function that returns the column width (in pixels) given an index and `cellProps`
25
+ */
26
+ columnWidth: number | string | ((index: number, cellProps: Record<string, unknown>) => number);
27
+ /**
28
+ * Default height of grid for initial render.
29
+ * This value is important for server rendering.
30
+ */
31
+ defaultHeight?: number;
32
+ /**
33
+ * Default width of grid for initial render.
34
+ * This value is important for server rendering.
35
+ */
36
+ defaultWidth?: number;
37
+ /**
38
+ * Indicates the directionality of grid cells.
39
+ */
40
+ dir?: 'ltr' | 'rtl' | 'auto';
41
+ /**
42
+ * Callback notified when the range of rendered cells changes.
43
+ */
44
+ onCellsRendered?: (visibleCells: {
45
+ columnStartIndex: number;
46
+ columnStopIndex: number;
47
+ rowStartIndex: number;
48
+ rowStopIndex: number;
49
+ }, allCells: {
50
+ columnStartIndex: number;
51
+ columnStopIndex: number;
52
+ rowStartIndex: number;
53
+ rowStopIndex: number;
54
+ }) => void;
55
+ /**
56
+ * Callback notified when the Grid's outermost HTMLElement resizes.
57
+ * This may be used to (re)scroll a cell into view.
58
+ */
59
+ onResize?: (size: {
60
+ height: number;
61
+ width: number;
62
+ }, prevSize: {
63
+ height: number;
64
+ width: number;
65
+ }) => void;
66
+ /**
67
+ * How many additional rows/columns to render outside of the visible area.
68
+ * This can reduce visual flickering near the edges of a grid when scrolling.
69
+ */
70
+ overscanCount?: number;
71
+ /**
72
+ * Number of rows to be rendered in the grid.
73
+ */
74
+ rowCount: number;
75
+ /**
76
+ * Row height; the following formats are supported:
77
+ * - number of pixels (number)
78
+ * - percentage of the grid's current height (string)
79
+ * - function that returns the row height (in pixels) given an index and `cellProps`
80
+ */
81
+ rowHeight: number | string | ((index: number, cellProps: Record<string, unknown>) => number);
82
+ /**
83
+ * Optional CSS properties.
84
+ * The grid of cells will fill the height and width defined by this style.
85
+ */
86
+ style?: CSSProperties;
87
+ /**
88
+ * Can be used to override the root HTML element rendered by the Grid component.
89
+ * The default value is "div", meaning that Grid renders an HTMLDivElement as its root.
90
+ */
91
+ tag?: TagNames;
92
+ }
93
+ export interface CellSlotProps {
94
+ ariaAttributes: {
95
+ 'aria-colindex': number;
96
+ role: 'gridcell';
97
+ };
98
+ columnIndex: number;
99
+ rowIndex: number;
100
+ style: CSSProperties;
101
+ props?: Record<string, unknown>;
102
+ }
103
+ /**
104
+ * Imperative Grid API.
105
+ */
106
+ export interface VirtualGridImperativeAPI {
107
+ /**
108
+ * Outermost HTML element for the grid if mounted and null (if not mounted.
109
+ */
110
+ readonly element: HTMLDivElement | null;
111
+ /**
112
+ * Scrolls the grid so that the specified cell is visible.
113
+ */
114
+ scrollToCell(config: {
115
+ behavior?: ScrollBehavior;
116
+ columnAlign?: 'auto' | 'center' | 'end' | 'smart' | 'start';
117
+ columnIndex: number;
118
+ rowAlign?: 'auto' | 'center' | 'end' | 'smart' | 'start';
119
+ rowIndex: number;
120
+ }): void;
121
+ /**
122
+ * Scrolls the grid so that the specified column is visible.
123
+ */
124
+ scrollToColumn(config: {
125
+ align?: 'auto' | 'center' | 'end' | 'smart' | 'start';
126
+ behavior?: ScrollBehavior;
127
+ index: number;
128
+ }): void;
129
+ /**
130
+ * Scrolls the grid so that the specified row is visible.
131
+ */
132
+ scrollToRow(config: {
133
+ align?: 'auto' | 'center' | 'end' | 'smart' | 'start';
134
+ behavior?: ScrollBehavior;
135
+ index: number;
136
+ }): void;
137
+ }
138
+ export {};