@weni/unnnic-system 2.0.24 → 2.0.25
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.
- package/CHANGELOG.md +6 -0
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +33 -8
- package/dist/unnnic.umd.js +16 -16
- package/package.json +2 -2
- package/src/components/Modal/Modal.vue +5 -2
- package/src/components/Slider/Slider.vue +36 -8
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
/>
|
|
29
29
|
</div>
|
|
30
30
|
<div
|
|
31
|
-
v-if="
|
|
31
|
+
v-if="hasIcon"
|
|
32
32
|
class="unnnic-modal-container-background-body__icon-slot"
|
|
33
33
|
>
|
|
34
34
|
<slot name="icon"></slot>
|
|
@@ -126,7 +126,10 @@ export default {
|
|
|
126
126
|
return !(this.alertMessage === null || this.alertMessage.length === 0);
|
|
127
127
|
},
|
|
128
128
|
hasButton() {
|
|
129
|
-
return !!this.$slots.options;
|
|
129
|
+
return !!this.$slots.options?.().length;
|
|
130
|
+
},
|
|
131
|
+
hasIcon() {
|
|
132
|
+
return !!this.$slots.icon?.().length;
|
|
130
133
|
},
|
|
131
134
|
},
|
|
132
135
|
mounted() {
|
|
@@ -161,11 +161,8 @@ export default {
|
|
|
161
161
|
window.removeEventListener('resize', this.handleResize);
|
|
162
162
|
},
|
|
163
163
|
mounted() {
|
|
164
|
-
|
|
165
|
-
this.
|
|
166
|
-
this.labelWidth =
|
|
167
|
-
this.$refs.tooltip.$refs.label.clientWidth || fallbackLabelWidth;
|
|
168
|
-
this.tooltipOffset = this.getNewTooltipPosition();
|
|
164
|
+
this.checkInputWidth();
|
|
165
|
+
this.checkTooltipLabelWidth();
|
|
169
166
|
},
|
|
170
167
|
methods: {
|
|
171
168
|
configureTooltip() {
|
|
@@ -185,9 +182,40 @@ export default {
|
|
|
185
182
|
|
|
186
183
|
this.handleValueChange();
|
|
187
184
|
},
|
|
185
|
+
checkInputWidth() {
|
|
186
|
+
const intervalId = setInterval(() => {
|
|
187
|
+
const inputElement = this.$refs.input;
|
|
188
|
+
if (inputElement) {
|
|
189
|
+
const { offsetWidth } = inputElement;
|
|
190
|
+
if (offsetWidth > 0) {
|
|
191
|
+
this.sliderWidth = offsetWidth;
|
|
192
|
+
this.configureTooltip();
|
|
193
|
+
clearInterval(intervalId);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}, 100);
|
|
197
|
+
},
|
|
198
|
+
checkTooltipLabelWidth() {
|
|
199
|
+
const intervalId = setInterval(() => {
|
|
200
|
+
const tooltipLabel = this.$refs.tooltip?.$refs.label;
|
|
201
|
+
if (!tooltipLabel) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const { clientWidth } = tooltipLabel;
|
|
206
|
+
if (clientWidth > 0) {
|
|
207
|
+
this.labelWidth = clientWidth;
|
|
208
|
+
this.configureTooltip();
|
|
209
|
+
clearInterval(intervalId);
|
|
210
|
+
}
|
|
211
|
+
}, 100);
|
|
212
|
+
},
|
|
188
213
|
getNewTooltipPosition() {
|
|
189
|
-
|
|
190
|
-
|
|
214
|
+
if (this.sliderWidth === 0 || this.labelWidth === 0) {
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
const halfThumbWidth = 12 / 2;
|
|
218
|
+
const halfLabelWidth = this.labelWidth / 2 || 16;
|
|
191
219
|
const centerPosition = this.sliderWidth / 2;
|
|
192
220
|
|
|
193
221
|
let percentOfRange =
|
|
@@ -199,7 +227,7 @@ export default {
|
|
|
199
227
|
const valuePXPosition = percentOfRange * this.sliderWidth;
|
|
200
228
|
const distFromCenter = valuePXPosition - centerPosition;
|
|
201
229
|
const percentDistFromCenter = distFromCenter / centerPosition;
|
|
202
|
-
const offset = percentDistFromCenter *
|
|
230
|
+
const offset = percentDistFromCenter * halfThumbWidth;
|
|
203
231
|
|
|
204
232
|
const finalLabelPosition = valuePXPosition - halfLabelWidth - offset;
|
|
205
233
|
return finalLabelPosition;
|