@veritree/ui 0.81.0-1 → 0.81.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.
@@ -1,4 +1,12 @@
1
- import { computePosition, flip, shift, offset, size } from '@floating-ui/dom';
1
+ import {
2
+ autoUpdate,
3
+ computePosition,
4
+ flip,
5
+ shift,
6
+ offset,
7
+ size,
8
+ // update,
9
+ } from '@floating-ui/dom';
2
10
 
3
11
  export const floatingUiMixin = {
4
12
  props: {
@@ -14,6 +22,7 @@ export const floatingUiMixin = {
14
22
  componentTrigger: null,
15
23
  componentContent: null,
16
24
  active: false,
25
+ floatingUiUpdaterDisposer: null,
17
26
  };
18
27
  },
19
28
 
@@ -30,6 +39,12 @@ export const floatingUiMixin = {
30
39
  };
31
40
  },
32
41
 
42
+ beforeDestroy() {
43
+ if (this.floatingUiUpdaterDisposer) {
44
+ this.floatingUiUpdaterDisposer();
45
+ }
46
+ },
47
+
33
48
  methods: {
34
49
  setActive() {
35
50
  this.active = true;
@@ -52,54 +67,69 @@ export const floatingUiMixin = {
52
67
  const contentWidth = contentRect.width;
53
68
  const contentHeight = contentRect.height;
54
69
  const triggerWidth = trigger.getBoundingClientRect().width;
55
-
56
70
  let leftObject = this.leftPosition || {};
57
71
  let topObject = this.topPosition || {};
58
-
59
72
  let left = leftObject.value || 0;
60
73
  let top = topObject.value || 0;
61
74
 
62
75
  if (leftObject.unit === '%') {
63
76
  left = (triggerWidth * left) / 100;
64
77
  }
78
+
65
79
  if (topObject.unit === '%') {
66
80
  top = (triggerWidth * top) / 100;
67
81
  }
82
+
68
83
  if (leftObject.positionBy === 'center') {
69
84
  left = left - contentWidth / 2;
70
85
  }
86
+
71
87
  if (leftObject.positionBy === 'end') {
72
88
  left = left - contentWidth;
73
89
  }
90
+
74
91
  if (topObject.positionBy === 'top') {
75
92
  top = top + contentHeight;
76
93
  }
94
+
77
95
  if (topObject.positionBy === 'center') {
78
96
  top = top + contentHeight / 2;
79
97
  }
80
98
 
81
- computePosition(trigger, content, {
82
- placement: 'top-start',
83
- middleware: [
84
- flip(),
85
- shift({ padding: 5 }),
86
- size({
87
- apply({ rects }) {
88
- if (!minWidthLimit) return;
89
-
90
- const width = rects.reference.width;
91
- const minWidth = width < minWidthLimit ? minWidthLimit : width;
92
-
93
- Object.assign(content.style, {
94
- minWidth: `${minWidth}px`,
95
- });
96
- },
97
- }),
98
- ],
99
- }).then(({ x, y }) => {
100
- Object.assign(content.style, {
101
- left: `${x + left}px`,
102
- top: `${y + top}px`,
99
+ /**
100
+ * Initializes the auto-update functionality for positioning the floating UI element.
101
+ * This method sets up an automatic update mechanism that adjusts the position of the
102
+ * content element in relation to the trigger element based on changes in the environment,
103
+ * such as scroll or resize events.
104
+ *
105
+ * @param {Element} trigger - The DOM element that acts as the reference point for positioning.
106
+ * @param {Element} content - The DOM element representing the floating UI content that needs to be positioned.
107
+ * @param {Function} updateFunction - A callback function that executes the update logic for positioning.
108
+ */
109
+ this.floatingUiUpdaterDisposer = autoUpdate(trigger, content, () => {
110
+ computePosition(trigger, content, {
111
+ placement: 'top-start',
112
+ middleware: [
113
+ flip(),
114
+ shift({ padding: 5 }),
115
+ size({
116
+ apply({ rects }) {
117
+ if (!minWidthLimit) return;
118
+
119
+ const width = rects.reference.width;
120
+ const minWidth = width < minWidthLimit ? minWidthLimit : width;
121
+
122
+ Object.assign(content.style, {
123
+ minWidth: `${minWidth}px`,
124
+ });
125
+ },
126
+ }),
127
+ ],
128
+ }).then(({ x, y }) => {
129
+ Object.assign(content.style, {
130
+ left: `${x + left}px`,
131
+ top: `${y + top}px`,
132
+ });
103
133
  });
104
134
  });
105
135
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.81.0-1",
3
+ "version": "0.81.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -22,7 +22,6 @@
22
22
  :maximum-view="maximumView"
23
23
  :show-edge-dates="showEdgeDates"
24
24
  :disabled-dates="disabledDatesComputed"
25
- :use-utc="useUtc"
26
25
  @input="onInput"
27
26
  >
28
27
  <template #prevIntervalBtn>
@@ -37,7 +36,6 @@
37
36
  </template>
38
37
 
39
38
  <script>
40
- import utc from 'dayjs/plugin/utc';
41
39
  import {
42
40
  formControlMixin,
43
41
  formControlStyleMixin,
@@ -48,7 +46,6 @@ import VTPopoverContent from './../Popover/VTPopoverContent.vue';
48
46
  import Datepicker from '@sum.cumo/vue-datepicker';
49
47
  import { IconChevronLeft, IconChevronRight } from '@veritree/icons';
50
48
  import dayjs from 'dayjs';
51
- dayjs.extend(utc);
52
49
 
53
50
  export default {
54
51
  name: 'VTInputDate',
@@ -101,10 +98,6 @@ export default {
101
98
  type: Boolean,
102
99
  default: false,
103
100
  },
104
- useUtc: {
105
- type: Boolean,
106
- default: true,
107
- },
108
101
  },
109
102
 
110
103
  computed: {
@@ -119,7 +112,7 @@ export default {
119
112
  },
120
113
 
121
114
  valueModelFormatted() {
122
- return dayjs(this.value).utc().format(this.format);
115
+ return dayjs(this.value).format(this.format);
123
116
  },
124
117
 
125
118
  disabledDatesComputed() {