cbvirtua 1.0.5 → 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 (76) 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/{floating → v2}/components/Popper.js +1 -1
  6. package/v2/components/PopperContent.vue +270 -0
  7. package/v2/components/PopperWrapper.vue +101 -0
  8. package/v2/components/ResizeObserver.vue +151 -0
  9. package/v2/components/Tooltip.vue +22 -0
  10. package/v2/components/TooltipDirective.vue +171 -0
  11. package/v2/floating-ui/core/computeCoordsFromPlacement.js +39 -0
  12. package/v2/floating-ui/core/computePosition.js +52 -0
  13. package/v2/floating-ui/core/detectOverflow.js +36 -0
  14. package/v2/floating-ui/core/enums.js +7 -0
  15. package/v2/floating-ui/core/index.js +11 -0
  16. package/v2/floating-ui/core/middleware/arrow.js +52 -0
  17. package/v2/floating-ui/core/middleware/autoPlacement.js +84 -0
  18. package/v2/floating-ui/core/middleware/flip.js +82 -0
  19. package/v2/floating-ui/core/middleware/hide.js +36 -0
  20. package/v2/floating-ui/core/middleware/inline.js +100 -0
  21. package/v2/floating-ui/core/middleware/offset.js +26 -0
  22. package/v2/floating-ui/core/middleware/shift.js +99 -0
  23. package/v2/floating-ui/core/middleware/size.js +58 -0
  24. package/v2/floating-ui/core/types.js +11 -0
  25. package/v2/floating-ui/core/utils/expandPaddingObject.js +3 -0
  26. package/v2/floating-ui/core/utils/getAlignment.js +3 -0
  27. package/v2/floating-ui/core/utils/getAlignmentSides.js +23 -0
  28. package/v2/floating-ui/core/utils/getBasePlacement.js +3 -0
  29. package/v2/floating-ui/core/utils/getCrossAxis.js +3 -0
  30. package/v2/floating-ui/core/utils/getExpandedPlacements.js +10 -0
  31. package/v2/floating-ui/core/utils/getLengthFromAxis.js +3 -0
  32. package/v2/floating-ui/core/utils/getMainAxisFromPlacement.js +4 -0
  33. package/v2/floating-ui/core/utils/getOppositeAlignmentPlacement.js +4 -0
  34. package/v2/floating-ui/core/utils/getOppositePlacement.js +4 -0
  35. package/v2/floating-ui/core/utils/getPaddingObject.js +6 -0
  36. package/v2/floating-ui/core/utils/math.js +2 -0
  37. package/v2/floating-ui/core/utils/rectToClientRect.js +9 -0
  38. package/v2/floating-ui/core/utils/within.js +4 -0
  39. package/v2/floating-ui/dom/index.js +5 -0
  40. package/v2/floating-ui/dom/platform.js +20 -0
  41. package/v2/floating-ui/dom/utils/contains.js +22 -0
  42. package/v2/floating-ui/dom/utils/convertOffsetParentRelativeRectToViewportRelativeRect.js +35 -0
  43. package/v2/floating-ui/dom/utils/getBoundingClientRect.js +27 -0
  44. package/v2/floating-ui/dom/utils/getClippingClientRect.js +76 -0
  45. package/v2/floating-ui/dom/utils/getComputedStyle.js +4 -0
  46. package/v2/floating-ui/dom/utils/getDimensions.js +6 -0
  47. package/v2/floating-ui/dom/utils/getDocumentElement.js +4 -0
  48. package/v2/floating-ui/dom/utils/getDocumentRect.js +21 -0
  49. package/v2/floating-ui/dom/utils/getNodeName.js +4 -0
  50. package/v2/floating-ui/dom/utils/getNodeScroll.js +13 -0
  51. package/v2/floating-ui/dom/utils/getOffsetParent.js +43 -0
  52. package/v2/floating-ui/dom/utils/getParentNode.js +16 -0
  53. package/v2/floating-ui/dom/utils/getRectRelativeToOffsetParent.js +40 -0
  54. package/v2/floating-ui/dom/utils/getScrollParent.js +13 -0
  55. package/v2/floating-ui/dom/utils/getScrollParents.js +18 -0
  56. package/v2/floating-ui/dom/utils/getViewportRect.js +25 -0
  57. package/v2/floating-ui/dom/utils/getWindowScrollBarX.js +9 -0
  58. package/v2/floating-ui/dom/utils/is.js +38 -0
  59. package/v2/floating-ui/dom/utils/math.js +3 -0
  60. package/v2/floating-ui/dom/utils/window.js +13 -0
  61. package/{floating → v2}/index.js +2 -1
  62. package/floating/demo/TestDropdown.vue +0 -22
  63. package/floating/demo/TestSubMenu.vue +0 -87
  64. package/floating/demo/TestTooltip.vue +0 -19
  65. package/floating/directives/v-tooltip.spec.js +0 -28
  66. /package/{floating → v2}/components/PopperMethods.js +0 -0
  67. /package/{floating → v2}/components/ThemeClass.js +0 -0
  68. /package/{floating → v2}/config.js +0 -0
  69. /package/{floating → v2}/directives/v-close-popper.js +0 -0
  70. /package/{floating → v2}/directives/v-tooltip.js +0 -0
  71. /package/{floating → v2}/util/assign-deep.js +0 -0
  72. /package/{floating → v2}/util/env.js +0 -0
  73. /package/{floating → v2}/util/events.js +0 -0
  74. /package/{floating → v2}/util/frame.js +0 -0
  75. /package/{floating → v2}/util/lang.js +0 -0
  76. /package/{floating → v2}/util/popper.js +0 -0
@@ -0,0 +1,40 @@
1
+ import { getBoundingClientRect } from './getBoundingClientRect';
2
+ import { getDocumentElement } from './getDocumentElement';
3
+ import { getNodeName } from './getNodeName';
4
+ import { getNodeScroll } from './getNodeScroll';
5
+ import getWindowScrollBarX from './getWindowScrollBarX';
6
+ import { isHTMLElement, isScrollParent } from './is';
7
+ import { round } from './math';
8
+ function isScaled(element) {
9
+ const rect = getBoundingClientRect(element);
10
+ return (round(rect.width) !== element.offsetWidth ||
11
+ round(rect.height) !== element.offsetHeight);
12
+ }
13
+ export function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
14
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
15
+ const documentElement = getDocumentElement(offsetParent);
16
+ const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent));
17
+ let scroll = { scrollLeft: 0, scrollTop: 0 };
18
+ const offsets = { x: 0, y: 0 };
19
+ if (isOffsetParentAnElement ||
20
+ (!isOffsetParentAnElement && strategy !== 'fixed')) {
21
+ if (getNodeName(offsetParent) !== 'body' ||
22
+ isScrollParent(documentElement)) {
23
+ scroll = getNodeScroll(offsetParent);
24
+ }
25
+ if (isHTMLElement(offsetParent)) {
26
+ const offsetRect = getBoundingClientRect(offsetParent, true);
27
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
28
+ offsets.y = offsetRect.y + offsetParent.clientTop;
29
+ }
30
+ else if (documentElement) {
31
+ offsets.x = getWindowScrollBarX(documentElement);
32
+ }
33
+ }
34
+ return {
35
+ x: rect.left + scroll.scrollLeft - offsets.x,
36
+ y: rect.top + scroll.scrollTop - offsets.y,
37
+ width: rect.width,
38
+ height: rect.height,
39
+ };
40
+ }
@@ -0,0 +1,13 @@
1
+ import { getParentNode } from './getParentNode';
2
+ import { getNodeName } from './getNodeName';
3
+ import { isScrollParent, isHTMLElement } from './is';
4
+ export function getScrollParent(node) {
5
+ if (['html', 'body', '#document'].includes(getNodeName(node))) {
6
+ // @ts-ignore assume body is always available
7
+ return node.ownerDocument.body;
8
+ }
9
+ if (isHTMLElement(node) && isScrollParent(node)) {
10
+ return node;
11
+ }
12
+ return getScrollParent(getParentNode(node));
13
+ }
@@ -0,0 +1,18 @@
1
+ import { getScrollParent } from './getScrollParent';
2
+ import { getParentNode } from './getParentNode';
3
+ import { getWindow } from './window';
4
+ import { isScrollParent } from './is';
5
+ export function getScrollParents(node, list = []) {
6
+ var _a;
7
+ const scrollParent = getScrollParent(node);
8
+ const isBody = scrollParent === ((_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.body);
9
+ const win = getWindow(scrollParent);
10
+ const target = isBody
11
+ ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : [])
12
+ : scrollParent;
13
+ const updatedList = list.concat(target);
14
+ return isBody
15
+ ? updatedList
16
+ : // @ts-ignore: isBody tells us target will be an HTMLElement here
17
+ updatedList.concat(getScrollParents(getParentNode(target)));
18
+ }
@@ -0,0 +1,25 @@
1
+ import { getWindow } from './window';
2
+ import { getDocumentElement } from './getDocumentElement';
3
+ export function getViewportRect(element) {
4
+ const win = getWindow(element);
5
+ const html = getDocumentElement(element);
6
+ const visualViewport = win.visualViewport;
7
+ let width = html.clientWidth;
8
+ let height = html.clientHeight;
9
+ let x = 0;
10
+ let y = 0;
11
+ if (visualViewport) {
12
+ width = visualViewport.width;
13
+ height = visualViewport.height;
14
+ // Uses Layout Viewport (like Chrome; Safari does not currently)
15
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
16
+ // errors due to floating point numbers, so we need to check precision.
17
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
18
+ if (Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
19
+ 0.01) {
20
+ x = visualViewport.offsetLeft;
21
+ y = visualViewport.offsetTop;
22
+ }
23
+ }
24
+ return { width, height, x, y };
25
+ }
@@ -0,0 +1,9 @@
1
+ import { getBoundingClientRect } from './getBoundingClientRect';
2
+ import { getDocumentElement } from './getDocumentElement';
3
+ import { getNodeScroll } from './getNodeScroll';
4
+ export default function getWindowScrollBarX(element) {
5
+ // If <html> has a CSS width greater than the viewport, then this will be
6
+ // incorrect for RTL.
7
+ return (getBoundingClientRect(getDocumentElement(element)).left +
8
+ getNodeScroll(element).scrollLeft);
9
+ }
@@ -0,0 +1,38 @@
1
+ import { getComputedStyle } from './getComputedStyle';
2
+ import { getNodeName } from './getNodeName';
3
+ import { getWindow } from './window';
4
+ export function isHTMLElement(value) {
5
+ return value instanceof getWindow(value).HTMLElement;
6
+ }
7
+ export function isElement(value) {
8
+ return value instanceof getWindow(value).Element;
9
+ }
10
+ export function isNode(value) {
11
+ return value instanceof getWindow(value).Node;
12
+ }
13
+ export function isShadowRoot(node) {
14
+ const OwnElement = getWindow(node).ShadowRoot;
15
+ return node instanceof OwnElement || node instanceof ShadowRoot;
16
+ }
17
+ export function isScrollParent(element) {
18
+ // Firefox wants us to check `-x` and `-y` variations as well
19
+ const { overflow, overflowX, overflowY } = getComputedStyle(element);
20
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
21
+ }
22
+ export function isTableElement(element) {
23
+ return ['table', 'td', 'th'].includes(getNodeName(element));
24
+ }
25
+ export function isContainingBlock(element) {
26
+ // TODO: Try and use feature detection here instead
27
+ const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
28
+ const css = getComputedStyle(element);
29
+ // This is non-exhaustive but covers the most common CSS properties that
30
+ // create a containing block.
31
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
32
+ return (css.transform !== 'none' ||
33
+ css.perspective !== 'none' ||
34
+ css.contain === 'paint' ||
35
+ ['transform', 'perspective'].includes(css.willChange) ||
36
+ (isFirefox && css.willChange === 'filter') ||
37
+ (isFirefox && (css.filter ? css.filter !== 'none' : false)));
38
+ }
@@ -0,0 +1,3 @@
1
+ export const min = Math.min;
2
+ export const max = Math.max;
3
+ export const round = Math.round;
@@ -0,0 +1,13 @@
1
+ export function isWindow(value) {
2
+ return (value === null || value === void 0 ? void 0 : value.toString()) === '[object Window]';
3
+ }
4
+ export function getWindow(node) {
5
+ if (node == null) {
6
+ return window;
7
+ }
8
+ if (!isWindow(node)) {
9
+ const ownerDocument = node.ownerDocument;
10
+ return ownerDocument ? ownerDocument.defaultView || window : window;
11
+ }
12
+ return node;
13
+ }
@@ -20,6 +20,7 @@ export const options = config;
20
20
  export const VTooltip = PrivateVTooltip;
21
21
  export { createTooltip, destroyTooltip } from './directives/v-tooltip';
22
22
  export const VClosePopper = PrivateVClosePopper;
23
+ console.log(PrivateVClosePopper)
23
24
  // Components
24
25
  export const Dropdown = PrivateDropdown;
25
26
  export const Menu = PrivateMenu;
@@ -56,7 +57,7 @@ export function install(app, options = {}) {
56
57
  }
57
58
  const plugin = {
58
59
  // eslint-disable-next-line no-undef
59
- version: VERSION,
60
+ //version: VERSION,
60
61
  install,
61
62
  options: config,
62
63
  };
@@ -1,22 +0,0 @@
1
- <template>
2
- <div class="meow">
3
- <VDropdown
4
- :triggers="['hover']"
5
- :popper-triggers="['hover']"
6
- >
7
- <button>Meow</button>
8
-
9
- <template #popper>
10
- Menu
11
- </template>
12
- </VDropdown>
13
- </div>
14
- </template>
15
-
16
- <style scoped>
17
- .meow {
18
- display: flex;
19
- align-items: center;
20
- justify-content: center;
21
- }
22
- </style>
@@ -1,87 +0,0 @@
1
- <template>
2
- <div class="example flex justify-center items-center gap-6">
3
- <VMenu placement="bottom-start">
4
- <button class="border border-gray-300 rounded px-4 py-2">
5
- Hover me
6
- </button>
7
-
8
- <template #popper>
9
- <div class="px-4 py-1">
10
- Sub menus:
11
- </div>
12
-
13
- <VMenu
14
- v-for="n in 5"
15
- :key="n"
16
- placement="right-start"
17
- instant-move
18
- >
19
- <button class="rounded hover:bg-green-100 px-4 py-2">
20
- Sub menu >
21
- </button>
22
-
23
- <template #popper>
24
- <VMenu
25
- v-for="n in 5"
26
- :key="n"
27
- placement="right-start"
28
- instant-move
29
- >
30
- <button class="rounded hover:bg-green-100 px-4 py-2">
31
- Option {{ n }} >
32
- </button>
33
-
34
- <template #popper>
35
- <div class="px-6 py-2">
36
- Hello
37
- </div>
38
- </template>
39
- </VMenu>
40
- </template>
41
- </VMenu>
42
- </template>
43
- </VMenu>
44
-
45
- <VDropdown placement="bottom-start">
46
- <button class="border border-gray-300 rounded px-4 py-2">
47
- Click me
48
- </button>
49
-
50
- <template #popper>
51
- <div class="px-4 py-1">
52
- Sub menus:
53
- </div>
54
-
55
- <VDropdown
56
- v-for="n in 5"
57
- :key="n"
58
- placement="right-start"
59
- instant-move
60
- >
61
- <button class="rounded hover:bg-green-100 px-4 py-2">
62
- Sub menu >
63
- </button>
64
-
65
- <template #popper>
66
- <VDropdown
67
- v-for="n in 5"
68
- :key="n"
69
- placement="right-start"
70
- instant-move
71
- >
72
- <button class="rounded hover:bg-green-100 px-4 py-2">
73
- Option {{ n }} >
74
- </button>
75
-
76
- <template #popper>
77
- <div class="px-6 py-2">
78
- Hello
79
- </div>
80
- </template>
81
- </VDropdown>
82
- </template>
83
- </VDropdown>
84
- </template>
85
- </VDropdown>
86
- </div>
87
- </template>
@@ -1,19 +0,0 @@
1
- <template>
2
- <div class="meow">
3
- <button
4
- v-tooltip="{
5
- content: 'Tooltip',
6
- triggers: ['hover'],
7
- popperTriggers: ['hover'],
8
- }"
9
- >Meow</button>
10
- </div>
11
- </template>
12
-
13
- <style scoped>
14
- .meow {
15
- display: flex;
16
- align-items: center;
17
- justify-content: center;
18
- }
19
- </style>
@@ -1,28 +0,0 @@
1
- import { describe, test, expect } from '@peeky/test';
2
- import * as VTooltip from './v-tooltip';
3
- describe('getPlacement', () => {
4
- test('object notation', () => {
5
- const value = {
6
- placement: 'bottom',
7
- };
8
- const modifiers = {};
9
- const result = VTooltip.getPlacement(value, modifiers);
10
- expect(result).toBe('bottom');
11
- });
12
- test('modifier', () => {
13
- const value = {};
14
- const modifiers = {
15
- 'top-end': true,
16
- };
17
- const result = VTooltip.getPlacement(value, modifiers);
18
- expect(result).toBe('top-end');
19
- });
20
- test('invalid modifier', () => {
21
- const value = {};
22
- const modifiers = {
23
- 'left-middle': true,
24
- };
25
- const result = VTooltip.getPlacement(value, modifiers);
26
- expect(result).toBe('top');
27
- });
28
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes