@veritree/ui 0.77.0 → 0.77.2

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.
@@ -3,7 +3,7 @@ import { computePosition, flip, shift, offset, size } from '@floating-ui/dom';
3
3
  export const floatingUiMixin = {
4
4
  props: {
5
5
  offset: {
6
- type: [Number, String, Object],
6
+ type: [Number, String],
7
7
  default: 5,
8
8
  },
9
9
  },
@@ -39,79 +39,11 @@ export const floatingUiMixin = {
39
39
  this.active = null;
40
40
  },
41
41
 
42
- positionContentToTriggerByTopAndLeft(trigger, content, minWidthLimit) {
43
- /*
44
- TODO: Try to replace this with the offset object from floating-ui, using mainAxis, crossAxis, and alignmentAxis.
45
- The problem is that the floating-ui offset values are px values, not percentages, which is the use case I am trying to solve.
46
- I tried to calculate the percentage based off of the width and height of the trigger element,
47
- but depending on the placement prop, mainAxis could be x OR y and crossAxis could be x OR y,
48
- so to calculate the offset based on the width/height of the trigger element
49
- we would have to calculate it differently for each individual placement preset.
50
- */
51
- const contentRect = content.getBoundingClientRect();
52
- const contentWidth = contentRect.width;
53
- const contentHeight = contentRect.height;
54
- const triggerWidth = trigger.getBoundingClientRect().width;
55
-
56
- let left = this.left?.value || 0;
57
- let top = this.top?.value || 0;
58
-
59
- if (this.left?.unit === '%') {
60
- left = (triggerWidth * left) / 100;
61
- }
62
- if (this.top?.unit === '%') {
63
- top = (triggerWidth * top) / 100;
64
- }
65
- if (this.left?.positionBy === 'center') {
66
- left = left - contentWidth / 2;
67
- }
68
- if (this.left?.positionBy === 'end') {
69
- left = left - contentWidth;
70
- }
71
- if (this.top?.positionBy === 'top') {
72
- top = top + contentHeight;
73
- }
74
- if (this.top?.positionBy === 'center') {
75
- top = top + contentHeight / 2;
76
- }
77
-
78
- computePosition(trigger, content, {
79
- placement: 'top-start',
80
- middleware: [
81
- flip(),
82
- shift({ padding: 5 }),
83
- size({
84
- apply({ rects }) {
85
- if (!minWidthLimit) return;
86
-
87
- const width = rects.reference.width;
88
- const minWidth = width < minWidthLimit ? minWidthLimit : width;
89
-
90
- Object.assign(content.style, {
91
- minWidth: `${minWidth}px`,
92
- });
93
- },
94
- }),
95
- ]
96
- }).then(({ x, y }) => {
97
- Object.assign(content.style, {
98
- left: `${x + left}px`,
99
- top: `${y + top}px`,
100
- });
101
- });
102
- },
103
-
104
42
  positionContentToTrigger() {
105
43
  const trigger = document.getElementById(this.componentTrigger.id);
106
44
  const content = document.getElementById(this.componentContent.id);
107
45
  const minWidthLimit = Number(this.floatingUiMinWidth);
108
46
 
109
- if (this.top !== null || this.top !== undefined || this.left !== null || this.left !== undefined) {
110
- this.positionContentToTriggerByTopAndLeft(trigger, content, minWidthLimit);
111
- return;
112
- }
113
-
114
-
115
47
  computePosition(trigger, content, {
116
48
  placement: this.placement,
117
49
  middleware: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.77.0",
3
+ "version": "0.77.2",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -31,34 +31,8 @@ export default {
31
31
  default: false,
32
32
  },
33
33
  /**
34
- * The position of the tooltip from the top of the trigger. This overrides the placement prop.
35
- *
36
- * @type {Object}
37
- * @property {string} unit - The unit of the top position (% or px).
38
- * @property {string} positionBy - Whether to position the top, center, or bottom of the tooltip at it's top value. Defaults to bottom.
39
- * @property {number} value - The value of the top position.
40
- * @default null
41
- */
42
- top: {
43
- type: Object,
44
- default: null,
45
- },
46
- /**
47
- * The position of the tooltip from the start (left) of the trigger. This overrides the placement prop.
48
- *
49
- * @type {Object}
50
- * @property {string} unit - The unit of the top position (& or px).
51
- * @property {string} positionBy - Whether to position the start, center, or end of the tooltip at it's left value. Defaults to start.
52
- * @property {number} value - The value of the top position.
53
- * @default null
54
- */
55
- left: {
56
- type: Object,
57
- default: null,
58
- },
59
- /**
60
- * The placement of the component relative to its trigger element. If top or bottom are supplied, this value will be ignored.
61
- * @type {string|number}
34
+ * The placement of the component relative to its trigger element.
35
+ * @type {string}
62
36
  * @values 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'
63
37
  * @default 'bottom-start'
64
38
  */