@vuetify/nightly 3.2.0-dev-20230405.0 → 3.2.0-dev-20230407.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 (42) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/dist/json/importMap-labs.json +0 -4
  3. package/dist/json/importMap.json +52 -48
  4. package/dist/json/web-types.json +1 -1
  5. package/dist/vuetify-labs.css +10 -10
  6. package/dist/vuetify-labs.d.ts +164 -164
  7. package/dist/vuetify-labs.esm.js +180 -180
  8. package/dist/vuetify-labs.esm.js.map +1 -1
  9. package/dist/vuetify-labs.js +179 -179
  10. package/dist/vuetify-labs.min.css +2 -2
  11. package/dist/vuetify.css +10 -1
  12. package/dist/vuetify.d.ts +166 -14
  13. package/dist/vuetify.esm.js +176 -4
  14. package/dist/vuetify.esm.js.map +1 -1
  15. package/dist/vuetify.js +175 -3
  16. package/dist/vuetify.js.map +1 -1
  17. package/dist/vuetify.min.css +2 -2
  18. package/dist/vuetify.min.js +222 -206
  19. package/dist/vuetify.min.js.map +1 -1
  20. package/lib/components/VVirtualScroll/VVirtualScroll.mjs.map +1 -0
  21. package/lib/components/VVirtualScroll/VVirtualScrollItem.mjs.map +1 -0
  22. package/lib/components/VVirtualScroll/index.mjs.map +1 -0
  23. package/lib/components/index.d.ts +150 -1
  24. package/lib/components/index.mjs +2 -1
  25. package/lib/components/index.mjs.map +1 -1
  26. package/lib/entry-bundler.mjs +1 -1
  27. package/lib/framework.mjs +1 -1
  28. package/lib/index.d.ts +15 -14
  29. package/lib/labs/VDataTable/index.d.ts +15 -15
  30. package/lib/labs/components.d.ts +16 -165
  31. package/lib/labs/components.mjs +0 -1
  32. package/lib/labs/components.mjs.map +1 -1
  33. package/package.json +1 -1
  34. package/lib/labs/VVirtualScroll/VVirtualScroll.mjs.map +0 -1
  35. package/lib/labs/VVirtualScroll/VVirtualScrollItem.mjs.map +0 -1
  36. package/lib/labs/VVirtualScroll/index.mjs.map +0 -1
  37. /package/lib/{labs → components}/VVirtualScroll/VVirtualScroll.css +0 -0
  38. /package/lib/{labs → components}/VVirtualScroll/VVirtualScroll.mjs +0 -0
  39. /package/lib/{labs → components}/VVirtualScroll/VVirtualScroll.sass +0 -0
  40. /package/lib/{labs → components}/VVirtualScroll/VVirtualScrollItem.mjs +0 -0
  41. /package/lib/{labs → components}/VVirtualScroll/index.d.ts +0 -0
  42. /package/lib/{labs → components}/VVirtualScroll/index.mjs +0 -0
package/dist/vuetify.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vuetify v3.2.0-dev-20230405.0
2
+ * Vuetify v3.2.0-dev-20230407.0
3
3
  * Forged by John Leider
4
4
  * Released under the MIT License.
5
5
  */
@@ -17993,6 +17993,177 @@
17993
17993
  }
17994
17994
  });
17995
17995
 
17996
+ const VVirtualScrollItem = genericComponent()({
17997
+ name: 'VVirtualScrollItem',
17998
+ props: {
17999
+ dynamicHeight: Boolean
18000
+ },
18001
+ emits: {
18002
+ 'update:height': height => true
18003
+ },
18004
+ setup(props, _ref) {
18005
+ let {
18006
+ emit,
18007
+ slots
18008
+ } = _ref;
18009
+ const {
18010
+ resizeRef,
18011
+ contentRect
18012
+ } = useResizeObserver();
18013
+ useToggleScope(() => props.dynamicHeight, () => {
18014
+ vue.watch(() => contentRect.value?.height, height => {
18015
+ if (height != null) emit('update:height', height);
18016
+ });
18017
+ });
18018
+ function updateHeight() {
18019
+ if (props.dynamicHeight && contentRect.value) {
18020
+ emit('update:height', contentRect.value.height);
18021
+ }
18022
+ }
18023
+ vue.onUpdated(updateHeight);
18024
+ useRender(() => vue.createVNode("div", {
18025
+ "ref": props.dynamicHeight ? resizeRef : undefined,
18026
+ "class": "v-virtual-scroll__item"
18027
+ }, [slots.default?.()]));
18028
+ }
18029
+ });
18030
+
18031
+ // Types
18032
+
18033
+ const UP = -1;
18034
+ const DOWN = 1;
18035
+ const VVirtualScroll = genericComponent()({
18036
+ name: 'VVirtualScroll',
18037
+ props: {
18038
+ items: {
18039
+ type: Array,
18040
+ default: () => []
18041
+ },
18042
+ itemHeight: [Number, String],
18043
+ visibleItems: [Number, String],
18044
+ ...makeDimensionProps()
18045
+ },
18046
+ setup(props, _ref) {
18047
+ let {
18048
+ slots
18049
+ } = _ref;
18050
+ const first = vue.ref(0);
18051
+ const baseItemHeight = vue.ref(props.itemHeight);
18052
+ const itemHeight = vue.computed({
18053
+ get: () => parseInt(baseItemHeight.value ?? 0, 10),
18054
+ set(val) {
18055
+ baseItemHeight.value = val;
18056
+ }
18057
+ });
18058
+ const rootEl = vue.ref();
18059
+ const {
18060
+ resizeRef,
18061
+ contentRect
18062
+ } = useResizeObserver();
18063
+ vue.watchEffect(() => {
18064
+ resizeRef.value = rootEl.value;
18065
+ });
18066
+ const display = useDisplay();
18067
+ const sizeMap = new Map();
18068
+ let sizes = createRange(props.items.length).map(() => itemHeight.value);
18069
+ const visibleItems = vue.computed(() => {
18070
+ return props.visibleItems ? parseInt(props.visibleItems, 10) : Math.max(12, Math.ceil((contentRect.value?.height ?? display.height.value) / itemHeight.value * 1.7 + 1));
18071
+ });
18072
+ function handleItemResize(index, height) {
18073
+ itemHeight.value = Math.max(itemHeight.value, height);
18074
+ sizes[index] = height;
18075
+ sizeMap.set(props.items[index], height);
18076
+ }
18077
+ function calculateOffset(index) {
18078
+ return sizes.slice(0, index).reduce((curr, value) => curr + (value || itemHeight.value), 0);
18079
+ }
18080
+ function calculateMidPointIndex(scrollTop) {
18081
+ let start = 0;
18082
+ let end = props.items.length;
18083
+ while (start <= end) {
18084
+ const middle = start + Math.floor((end - start) / 2);
18085
+ const middleOffset = calculateOffset(middle);
18086
+ if (middleOffset === scrollTop) {
18087
+ return middle;
18088
+ } else if (middleOffset < scrollTop) {
18089
+ start = middle + 1;
18090
+ } else if (middleOffset > scrollTop) {
18091
+ end = middle - 1;
18092
+ }
18093
+ }
18094
+ return start;
18095
+ }
18096
+ let lastScrollTop = 0;
18097
+ function handleScroll() {
18098
+ if (!rootEl.value || !contentRect.value) return;
18099
+ const height = contentRect.value.height;
18100
+ const scrollTop = rootEl.value.scrollTop;
18101
+ const direction = scrollTop < lastScrollTop ? UP : DOWN;
18102
+ const midPointIndex = calculateMidPointIndex(scrollTop + height / 2);
18103
+ const buffer = Math.round(visibleItems.value / 3);
18104
+ if (direction === UP && midPointIndex <= first.value + buffer * 2 - 1) {
18105
+ first.value = clamp(midPointIndex - buffer, 0, props.items.length);
18106
+ } else if (direction === DOWN && midPointIndex >= first.value + buffer * 2 - 1) {
18107
+ first.value = clamp(midPointIndex - buffer, 0, props.items.length - visibleItems.value);
18108
+ }
18109
+ lastScrollTop = rootEl.value.scrollTop;
18110
+ }
18111
+ function scrollToIndex(index) {
18112
+ if (!rootEl.value) return;
18113
+ const offset = calculateOffset(index);
18114
+ rootEl.value.scrollTop = offset;
18115
+ }
18116
+ const last = vue.computed(() => Math.min(props.items.length, first.value + visibleItems.value));
18117
+ const computedItems = vue.computed(() => props.items.slice(first.value, last.value));
18118
+ const paddingTop = vue.computed(() => calculateOffset(first.value));
18119
+ const paddingBottom = vue.computed(() => calculateOffset(props.items.length) - calculateOffset(last.value));
18120
+ const {
18121
+ dimensionStyles
18122
+ } = useDimension(props);
18123
+ vue.onMounted(() => {
18124
+ if (!itemHeight.value) {
18125
+ // If itemHeight prop is not set, then calculate an estimated height from the average of inital items
18126
+ itemHeight.value = sizes.slice(first.value, last.value).reduce((curr, height) => curr + height, 0) / visibleItems.value;
18127
+ }
18128
+ });
18129
+ vue.watch(() => props.items.length, () => {
18130
+ sizes = createRange(props.items.length).map(() => itemHeight.value);
18131
+ sizeMap.forEach((height, item) => {
18132
+ const index = props.items.indexOf(item);
18133
+ if (index === -1) {
18134
+ sizeMap.delete(item);
18135
+ } else {
18136
+ sizes[index] = height;
18137
+ }
18138
+ });
18139
+ });
18140
+ useRender(() => vue.createVNode("div", {
18141
+ "ref": rootEl,
18142
+ "class": "v-virtual-scroll",
18143
+ "onScroll": handleScroll,
18144
+ "style": dimensionStyles.value
18145
+ }, [vue.createVNode("div", {
18146
+ "class": "v-virtual-scroll__container",
18147
+ "style": {
18148
+ paddingTop: convertToUnit(paddingTop.value),
18149
+ paddingBottom: convertToUnit(paddingBottom.value)
18150
+ }
18151
+ }, [computedItems.value.map((item, index) => vue.createVNode(VVirtualScrollItem, {
18152
+ "key": index,
18153
+ "dynamicHeight": !props.itemHeight,
18154
+ "onUpdate:height": height => handleItemResize(index + first.value, height)
18155
+ }, {
18156
+ default: () => [slots.default?.({
18157
+ item,
18158
+ index: index + first.value
18159
+ })]
18160
+ }))])]));
18161
+ return {
18162
+ scrollToIndex
18163
+ };
18164
+ }
18165
+ });
18166
+
17996
18167
  var components = /*#__PURE__*/Object.freeze({
17997
18168
  __proto__: null,
17998
18169
  VAlert: VAlert,
@@ -18125,6 +18296,7 @@
18125
18296
  VToolbarTitle: VToolbarTitle,
18126
18297
  VTooltip: VTooltip,
18127
18298
  VValidation: VValidation,
18299
+ VVirtualScroll: VVirtualScroll,
18128
18300
  VWindow: VWindow,
18129
18301
  VWindowItem: VWindowItem
18130
18302
  });
@@ -18337,7 +18509,7 @@
18337
18509
  locale
18338
18510
  };
18339
18511
  }
18340
- const version$1 = "3.2.0-dev-20230405.0";
18512
+ const version$1 = "3.2.0-dev-20230407.0";
18341
18513
  createVuetify$1.version = version$1;
18342
18514
 
18343
18515
  // Vue's inject() can only be used in setup
@@ -18357,7 +18529,7 @@
18357
18529
  ...options
18358
18530
  });
18359
18531
  };
18360
- const version = "3.2.0-dev-20230405.0";
18532
+ const version = "3.2.0-dev-20230407.0";
18361
18533
  createVuetify.version = version;
18362
18534
 
18363
18535
  exports.components = components;