mediacube-ui 0.1.302 → 0.1.304
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
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.304](https://github.com/MediaCubeCo/mcui/compare/v0.1.303...v0.1.304) (2024-08-07)
|
|
6
|
+
|
|
7
|
+
### [0.1.303](https://github.com/MediaCubeCo/mcui/compare/v0.1.302...v0.1.303) (2024-08-06)
|
|
8
|
+
|
|
5
9
|
### [0.1.302](https://github.com/MediaCubeCo/mcui/compare/v0.1.301...v0.1.302) (2024-08-05)
|
|
6
10
|
|
|
7
11
|
### [0.1.301](https://github.com/MediaCubeCo/mcui/compare/v0.1.300...v0.1.301) (2024-08-01)
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="
|
|
2
|
+
<div :ref="field_key" :dir="dir" :class="classes" :style="styles">
|
|
3
3
|
<div :for="name" class="mc-field-select__header">
|
|
4
4
|
<!-- @slot Слот заголовка -->
|
|
5
5
|
<slot name="header">
|
|
@@ -335,6 +335,7 @@ export default {
|
|
|
335
335
|
return {
|
|
336
336
|
searchValue: null,
|
|
337
337
|
key: `field_select_${Date.now()}`,
|
|
338
|
+
field_key: `field-${this.name}`,
|
|
338
339
|
closest_scroll_element: null,
|
|
339
340
|
scroll_resize_observer: null,
|
|
340
341
|
local_options: [],
|
|
@@ -508,7 +509,6 @@ export default {
|
|
|
508
509
|
},
|
|
509
510
|
handleOpen() {
|
|
510
511
|
if (!this.renderAbsoluteList) return
|
|
511
|
-
this.repositionDropDown()
|
|
512
512
|
this.initScroll()
|
|
513
513
|
},
|
|
514
514
|
handleClose() {
|
|
@@ -526,25 +526,22 @@ export default {
|
|
|
526
526
|
},
|
|
527
527
|
initScroll() {
|
|
528
528
|
// looking for closest scroll elemen to track select list position dynamically
|
|
529
|
-
this.closest_scroll_element = this.findClosestScrollElement(this.$refs.
|
|
529
|
+
this.closest_scroll_element = this.findClosestScrollElement(this.$refs[this.field_key])
|
|
530
530
|
this.closest_scroll_element.addEventListener('scroll', this.repositionDropDown)
|
|
531
531
|
this.scroll_resize_observer = new ResizeObserver(this.repositionDropDown)
|
|
532
532
|
this.scroll_resize_observer.observe(this.closest_scroll_element)
|
|
533
533
|
},
|
|
534
534
|
repositionDropDown() {
|
|
535
|
-
const { top, height, width, left } = this.$el.getBoundingClientRect()
|
|
535
|
+
const { top, bottom, height, width, left } = this.$el.getBoundingClientRect()
|
|
536
536
|
const ref = this.$refs[this.key]
|
|
537
537
|
const ios_devices = ['iPhone', 'iPad']
|
|
538
538
|
// Добавляем к позиции отступ visualViewport?.offsetTop, который добавляет iOs при открытии вирутальной клавиатуры
|
|
539
539
|
const iosViewportIndent = ios_devices?.some(device => navigator?.platform?.includes(device)) ? window.visualViewport?.offsetTop || 0 : 0
|
|
540
540
|
// if field hides under scrolled element borders -> blur select to prevent overlap
|
|
541
541
|
const scrolledHeight = this.closest_scroll_element?.scrollTop
|
|
542
|
-
const fieldHeght = this.$refs.
|
|
543
|
-
const scrolledElementTop = this.closest_scroll_element?.getBoundingClientRect().top
|
|
544
|
-
|
|
545
|
-
if (scrolledHeight - fieldHeght - scrolledElementTop - top - iosViewportIndent > 0) return ref.deactivate()
|
|
546
|
-
|
|
547
|
-
if (ref) {
|
|
542
|
+
const fieldHeght = this.$refs[this.field_key]?.clientHeight || 0
|
|
543
|
+
const scrolledElementTop = this.closest_scroll_element?.getBoundingClientRect().top
|
|
544
|
+
if (ref && top >= -height && bottom <= (window.innerHeight || document.documentElement.clientHeight)) {
|
|
548
545
|
ref.$refs.list.style.width = `${width}px`
|
|
549
546
|
ref.$refs.list.style.position = 'fixed'
|
|
550
547
|
ref.$refs.list.style.left = `${left}px`
|
|
@@ -567,6 +564,10 @@ export default {
|
|
|
567
564
|
break
|
|
568
565
|
}
|
|
569
566
|
}
|
|
567
|
+
else {
|
|
568
|
+
// прячем селект, если его не видно юзеру
|
|
569
|
+
return ref.deactivate()
|
|
570
|
+
}
|
|
570
571
|
},
|
|
571
572
|
handleChange(value) {
|
|
572
573
|
/**
|
|
@@ -49,8 +49,6 @@
|
|
|
49
49
|
v-on="listeners"
|
|
50
50
|
@input="prepareHandleInput"
|
|
51
51
|
@keydown="prepareHandleKeyDown"
|
|
52
|
-
@focus="handleFocus"
|
|
53
|
-
@blur="handleBlur"
|
|
54
52
|
/>
|
|
55
53
|
</template>
|
|
56
54
|
</label>
|
|
@@ -628,14 +626,20 @@ export default {
|
|
|
628
626
|
this.setCaretPos(e.target, cursor_position + space_length, cursor_position + space_length)
|
|
629
627
|
break
|
|
630
628
|
}
|
|
631
|
-
case 'uppercase':
|
|
629
|
+
case 'uppercase': {
|
|
630
|
+
const cursor_position = this.getCaretPos(e.target)?.start
|
|
632
631
|
value = value?.toUpperCase()
|
|
633
632
|
e.target.value = value
|
|
633
|
+
this.setCaretPos(e.target, cursor_position, cursor_position)
|
|
634
634
|
break
|
|
635
|
-
|
|
635
|
+
}
|
|
636
|
+
case 'lowercase': {
|
|
637
|
+
const cursor_position = this.getCaretPos(e.target)?.start
|
|
636
638
|
value = value?.toLowerCase()
|
|
637
639
|
e.target.value = value
|
|
640
|
+
this.setCaretPos(e.target, cursor_position, cursor_position)
|
|
638
641
|
break
|
|
642
|
+
}
|
|
639
643
|
case 'password':
|
|
640
644
|
const cursor_position = this.getCaretPos(e.target)?.start
|
|
641
645
|
value = value?.replace(/ /gm, '')
|
|
@@ -644,23 +648,14 @@ export default {
|
|
|
644
648
|
break
|
|
645
649
|
case 'phone_number':
|
|
646
650
|
if (value.length === 0) value = '+'
|
|
647
|
-
|
|
651
|
+
if (value.charAt(0) !== '+') value = '+' + value
|
|
652
|
+
value = value.replace(/(?!^)\D/g, '')
|
|
648
653
|
e.target.value = value
|
|
649
654
|
break
|
|
650
655
|
}
|
|
651
656
|
|
|
652
657
|
this.handleInput(value)
|
|
653
658
|
},
|
|
654
|
-
handleFocus(e) {
|
|
655
|
-
if (this.type === 'phone_number' && e.target.value.length === 0) {
|
|
656
|
-
e.target.value = '+'
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
handleBlur(e) {
|
|
660
|
-
if (this.type === 'phone_number' && e.target.value === '+') {
|
|
661
|
-
e.target.value = ''
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
659
|
prepareHandleKeyDown(e) {
|
|
665
660
|
switch (this.type) {
|
|
666
661
|
case 'amount_format':
|