cbvirtua 1.0.4 → 1.0.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 (73) hide show
  1. package/package.json +1 -1
  2. package/v2/App.vue +56 -0
  3. package/v2/components/Dropdown.vue +28 -0
  4. package/v2/components/Menu.vue +9 -0
  5. package/v2/components/Popper.js +1011 -0
  6. package/v2/components/PopperContent.vue +270 -0
  7. package/v2/components/PopperMethods.js +17 -0
  8. package/v2/components/PopperWrapper.vue +101 -0
  9. package/v2/components/ResizeObserver.vue +151 -0
  10. package/v2/components/ThemeClass.js +9 -0
  11. package/v2/components/Tooltip.vue +22 -0
  12. package/v2/components/TooltipDirective.vue +171 -0
  13. package/v2/config.js +133 -0
  14. package/v2/directives/v-close-popper.js +67 -0
  15. package/v2/directives/v-tooltip.js +116 -0
  16. package/v2/floating-ui/core/computeCoordsFromPlacement.js +39 -0
  17. package/v2/floating-ui/core/computePosition.js +52 -0
  18. package/v2/floating-ui/core/detectOverflow.js +36 -0
  19. package/v2/floating-ui/core/enums.js +7 -0
  20. package/v2/floating-ui/core/index.js +11 -0
  21. package/v2/floating-ui/core/middleware/arrow.js +52 -0
  22. package/v2/floating-ui/core/middleware/autoPlacement.js +84 -0
  23. package/v2/floating-ui/core/middleware/flip.js +82 -0
  24. package/v2/floating-ui/core/middleware/hide.js +36 -0
  25. package/v2/floating-ui/core/middleware/inline.js +100 -0
  26. package/v2/floating-ui/core/middleware/offset.js +26 -0
  27. package/v2/floating-ui/core/middleware/shift.js +99 -0
  28. package/v2/floating-ui/core/middleware/size.js +58 -0
  29. package/v2/floating-ui/core/types.js +11 -0
  30. package/v2/floating-ui/core/utils/expandPaddingObject.js +3 -0
  31. package/v2/floating-ui/core/utils/getAlignment.js +3 -0
  32. package/v2/floating-ui/core/utils/getAlignmentSides.js +23 -0
  33. package/v2/floating-ui/core/utils/getBasePlacement.js +3 -0
  34. package/v2/floating-ui/core/utils/getCrossAxis.js +3 -0
  35. package/v2/floating-ui/core/utils/getExpandedPlacements.js +10 -0
  36. package/v2/floating-ui/core/utils/getLengthFromAxis.js +3 -0
  37. package/v2/floating-ui/core/utils/getMainAxisFromPlacement.js +4 -0
  38. package/v2/floating-ui/core/utils/getOppositeAlignmentPlacement.js +4 -0
  39. package/v2/floating-ui/core/utils/getOppositePlacement.js +4 -0
  40. package/v2/floating-ui/core/utils/getPaddingObject.js +6 -0
  41. package/v2/floating-ui/core/utils/math.js +2 -0
  42. package/v2/floating-ui/core/utils/rectToClientRect.js +9 -0
  43. package/v2/floating-ui/core/utils/within.js +4 -0
  44. package/v2/floating-ui/dom/index.js +5 -0
  45. package/v2/floating-ui/dom/platform.js +20 -0
  46. package/v2/floating-ui/dom/utils/contains.js +22 -0
  47. package/v2/floating-ui/dom/utils/convertOffsetParentRelativeRectToViewportRelativeRect.js +35 -0
  48. package/v2/floating-ui/dom/utils/getBoundingClientRect.js +27 -0
  49. package/v2/floating-ui/dom/utils/getClippingClientRect.js +76 -0
  50. package/v2/floating-ui/dom/utils/getComputedStyle.js +4 -0
  51. package/v2/floating-ui/dom/utils/getDimensions.js +6 -0
  52. package/v2/floating-ui/dom/utils/getDocumentElement.js +4 -0
  53. package/v2/floating-ui/dom/utils/getDocumentRect.js +21 -0
  54. package/v2/floating-ui/dom/utils/getNodeName.js +4 -0
  55. package/v2/floating-ui/dom/utils/getNodeScroll.js +13 -0
  56. package/v2/floating-ui/dom/utils/getOffsetParent.js +43 -0
  57. package/v2/floating-ui/dom/utils/getParentNode.js +16 -0
  58. package/v2/floating-ui/dom/utils/getRectRelativeToOffsetParent.js +40 -0
  59. package/v2/floating-ui/dom/utils/getScrollParent.js +13 -0
  60. package/v2/floating-ui/dom/utils/getScrollParents.js +18 -0
  61. package/v2/floating-ui/dom/utils/getViewportRect.js +25 -0
  62. package/v2/floating-ui/dom/utils/getWindowScrollBarX.js +9 -0
  63. package/v2/floating-ui/dom/utils/is.js +38 -0
  64. package/v2/floating-ui/dom/utils/math.js +3 -0
  65. package/v2/floating-ui/dom/utils/window.js +13 -0
  66. package/v2/index.js +75 -0
  67. package/v2/util/assign-deep.js +12 -0
  68. package/v2/util/env.js +18 -0
  69. package/v2/util/events.js +12 -0
  70. package/v2/util/frame.js +5 -0
  71. package/v2/util/lang.js +6 -0
  72. package/v2/util/popper.js +5 -0
  73. package/vue2/VList.js +55 -55
package/vue2/VList.js CHANGED
@@ -1,15 +1,15 @@
1
- import { SCROLL_IDLE, UPDATE_SCROLL_STATE, UPDATE_SCROLL_EVENT, UPDATE_SCROLL_END_EVENT, UPDATE_SIZE_STATE, overscanEndIndex, overscanStartIndex, createVirtualStore, ACTION_ITEMS_LENGTH_CHANGE, getScrollSize, getMinContainerSize, } from "../core/store";
2
- import { createResizer } from "../core/resizer";
3
- import { createScroller } from "../core/scroller";
4
- import { default as ListItem } from "./ListItem";
5
- import { exists } from "../core/utils";
1
+ import { SCROLL_IDLE, UPDATE_SCROLL_STATE, UPDATE_SCROLL_EVENT, UPDATE_SCROLL_END_EVENT, UPDATE_SIZE_STATE, overscanEndIndex, overscanStartIndex, createVirtualStore, ACTION_ITEMS_LENGTH_CHANGE, getScrollSize, getMinContainerSize, } from "../core/store"
2
+ import { createResizer } from "../core/resizer"
3
+ import { createScroller } from "../core/scroller"
4
+ import { default as ListItem } from "./ListItem"
5
+ import { exists } from "../core/utils"
6
6
  const props = {
7
7
  data: { type: Array, required: true },
8
8
  overscan: { type: Number, default: 4 },
9
9
  itemSize: Number,
10
10
  shift: Boolean,
11
11
  horizontal: Boolean,
12
- };
12
+ }
13
13
  export default {
14
14
  props: props,
15
15
  data() {
@@ -22,91 +22,91 @@ export default {
22
22
  },
23
23
  watch: {
24
24
  data(_data) {
25
- const count = _data.length;
26
- this.store._update(ACTION_ITEMS_LENGTH_CHANGE, [count, this.shift]);
25
+ const count = _data.length
26
+ this.store._update(ACTION_ITEMS_LENGTH_CHANGE, [count, this.shift])
27
27
  },
28
28
  JumpCount(count, prevCount) {
29
29
  this.$nextTick(() => {
30
30
  if (count === prevCount)
31
- return;
32
- const jump = this.store._flushJump();
31
+ return
32
+ const jump = this.store._flushJump()
33
33
  if (!jump)
34
- return;
35
- this.scroller._fixScrollJump(jump);
34
+ return
35
+ this.scroller._fixScrollJump(jump)
36
36
  })
37
37
  },
38
38
  range([start, end], [prevStart, prevEnd]) {
39
39
  this.$nextTick(() => {
40
40
  if (prevStart === start && prevEnd === end)
41
- return;
42
- this.$emit("rangeChange", start, end);
41
+ return
42
+ this.$emit("rangeChange", start, end)
43
43
  })
44
44
  }
45
45
 
46
46
  },
47
47
  created() {
48
- const isHorizontal = this.horizontal;
48
+ const isHorizontal = this.horizontal
49
49
  const store = this.store = createVirtualStore(
50
50
  this.data.length,
51
51
  this.itemSize ?? 40,
52
52
  undefined,
53
53
  undefined,
54
54
  !this.itemSize
55
- );
56
- const resizer = this.resizer = createResizer(store, isHorizontal);
57
- const scroller = this.scroller = createScroller(store, isHorizontal);
58
- this.scrollToIndex = scroller._scrollToIndex;
59
- this.scrollTo = scroller._scrollTo;
60
- this.scrollBy = scroller._scrollBy;
61
- const rerender = store._getStateVersion();
55
+ )
56
+ const resizer = this.resizer = createResizer(store, isHorizontal)
57
+ const scroller = this.scroller = createScroller(store, isHorizontal)
58
+ this.scrollToIndex = scroller._scrollToIndex
59
+ this.scrollTo = scroller._scrollTo
60
+ this.scrollBy = scroller._scrollBy
61
+ const rerender = store._getStateVersion()
62
62
  const unsubscribeStore = this.unsubscribeStore = store._subscribe(UPDATE_SCROLL_STATE + UPDATE_SIZE_STATE, () => {
63
- this.rerender = store._getStateVersion();
64
- this.JumpCount = store._getJumpCount();
65
- });
63
+ this.rerender = store._getStateVersion()
64
+ this.JumpCount = store._getJumpCount()
65
+ this.range = store._getRange()
66
+ })
66
67
  const unsubscribeOnScroll = this.unsubscribeOnScroll = store._subscribe(UPDATE_SCROLL_EVENT, () => {
67
- this.$emit("scroll", store._getScrollOffset());
68
- });
68
+ this.$emit("scroll", store._getScrollOffset())
69
+ })
69
70
  const unsubscribeOnScrollEnd = this.unsubscribeOnScrollEnd = store._subscribe(UPDATE_SCROLL_END_EVENT, () => {
70
- this.$emit("scrollEnd");
71
- });
71
+ this.$emit("scrollEnd")
72
+ })
72
73
  },
73
74
  mounted() {
74
- const root = this.$refs.root;
75
+ const root = this.$refs.root
75
76
  if (!root)
76
- return;
77
- this.resizer._observeRoot(root);
78
- this.scroller._observe(root);
77
+ return
78
+ this.resizer._observeRoot(root)
79
+ this.scroller._observe(root)
79
80
 
80
81
  },
81
82
  methods: {
82
83
  scrollOffset() {
83
- return this.store._getScrollOffset();
84
+ return this.store._getScrollOffset()
84
85
  },
85
86
  scrollSize() {
86
- return this.getScrollSize(store);
87
+ return this.getScrollSize(store)
87
88
  },
88
89
  viewportSize() {
89
- return this.store._getViewportSize();
90
+ return this.store._getViewportSize()
90
91
  },
91
92
  scrollToIndex() { },
92
93
  scrollTo() { },
93
94
  scrollBy() { }
94
95
  },
95
96
  render() {
96
- this.rerender;
97
- const count = this.data.length;
98
- const store = this.store;
99
- const isHorizontal = this.horizontal;
100
- const [startIndex, endIndex] = this.store._getRange();
101
- const scrollDirection = store._getScrollDirection();
102
- const totalSize = store._getTotalSize();
103
- // https://github.com/inokawa/virtua/issues/252#issuecomment-1822861368
104
- const minSize = getMinContainerSize(store);
97
+ this.rerender
98
+ const count = this.data.length
99
+ const store = this.store
100
+ const isHorizontal = this.horizontal
101
+ const [startIndex, endIndex] = this.store._getRange()
102
+ const scrollDirection = store._getScrollDirection()
103
+ const totalSize = store._getTotalSize()
104
+ const minSize = getMinContainerSize(store)
105
105
 
106
- const items = [];
106
+ const items = []
107
107
  for (let i = overscanStartIndex(startIndex, this.overscan, scrollDirection), j = overscanEndIndex(endIndex, this.overscan, scrollDirection, count); i <= j; i++) {
108
- const e = this.$scopedSlots.default(this.data[i])[0];
109
- const key = e.key;
108
+ const e = this.$scopedSlots.default(this.data[i])[0]
109
+ const key = e.key
110
110
  items.push(
111
111
  <ListItem
112
112
  key={exists(key) ? key : "_" + i}
@@ -118,7 +118,7 @@ export default {
118
118
  children={e}
119
119
  isHorizontal={isHorizontal}
120
120
  />
121
- );
121
+ )
122
122
  }
123
123
 
124
124
  return (
@@ -149,13 +149,13 @@ export default {
149
149
  {items}
150
150
  </div>
151
151
  </div>
152
- );
152
+ )
153
153
  },
154
154
  destoryed() {
155
- this.unsubscribeStore();
156
- this.unsubscribeOnScroll();
157
- this.unsubscribeOnScrollEnd();
158
- this.resizer._dispose();
159
- this.scroller._dispose();
155
+ this.unsubscribeStore()
156
+ this.unsubscribeOnScroll()
157
+ this.unsubscribeOnScrollEnd()
158
+ this.resizer._dispose()
159
+ this.scroller._dispose()
160
160
  },
161
161
  }