renusify 2.5.2 → 3.0.1
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/components/app/index.vue +74 -22
- package/components/app/toast/index.vue +76 -71
- package/components/app/toast/toast.vue +62 -44
- package/components/avatar/index.vue +207 -84
- package/components/button/buttonConfirm.vue +53 -26
- package/components/button/buttonGroup.js +0 -2
- package/components/button/buttonGroup.vue +310 -62
- package/components/button/index.vue +584 -100
- package/components/calendar/index.js +0 -2
- package/components/calendar/index.vue +326 -262
- package/components/calendar/month.vue +64 -55
- package/components/calendar/year.vue +30 -25
- package/components/card/index.vue +139 -59
- package/components/codeEditor/highlightCss.vue +38 -39
- package/components/codeEditor/highlightHtml.vue +64 -64
- package/components/codeEditor/highlightJs.vue +37 -38
- package/components/codeEditor/index.vue +129 -79
- package/components/codeEditor/run.vue +225 -39
- package/components/codeEditor/useCodeFormatter.js +150 -0
- package/components/confirm/index.vue +139 -80
- package/components/container/col.vue +5 -4
- package/components/container/divider.vue +28 -19
- package/components/container/index.vue +34 -15
- package/components/container/row.vue +26 -9
- package/components/container/spacer.vue +2 -4
- package/components/container/style.scss +3 -0
- package/components/content/index.vue +49 -32
- package/components/cropper/index.vue +401 -244
- package/components/float/index.vue +542 -415
- package/components/form/addressInput/index.vue +184 -109
- package/components/form/camInput/index.vue +370 -244
- package/components/form/checkInput/index.vue +138 -71
- package/components/form/checkboxInput/index.vue +93 -49
- package/components/form/colorInput/Alpha.vue +81 -83
- package/components/form/colorInput/Hue.vue +91 -68
- package/components/form/colorInput/Preview.vue +43 -47
- package/components/form/colorInput/Saturation.vue +101 -86
- package/components/form/colorInput/index.vue +71 -39
- package/components/form/colorInput/picker.vue +111 -106
- package/components/form/colorInput/useColor.js +153 -0
- package/components/form/dateInput/index.vue +691 -356
- package/components/form/dateInput/month.vue +63 -54
- package/components/form/dateInput/year.vue +35 -25
- package/components/form/fileInput/index.js +0 -1
- package/components/form/fileInput/index.vue +263 -106
- package/components/form/fileInput/single.vue +332 -168
- package/components/form/groupInput/index.vue +199 -101
- package/components/form/index.vue +189 -83
- package/components/form/input/index.vue +416 -377
- package/components/form/jsonInput/JsonView.vue +54 -56
- package/components/form/jsonInput/index.vue +247 -165
- package/components/form/maskInput/index.vue +252 -132
- package/components/form/numberInput/index.js +0 -1
- package/components/form/numberInput/index.vue +226 -117
- package/components/form/passwordInput/index.js +2 -1
- package/components/form/passwordInput/index.vue +269 -102
- package/components/form/radioInput/index.vue +143 -72
- package/components/form/rangeInput/index.vue +280 -167
- package/components/form/ratingInput/index.vue +57 -57
- package/components/form/selectInput/index.js +1 -3
- package/components/form/selectInput/index.vue +584 -296
- package/components/form/switchInput/index.vue +73 -59
- package/components/form/telInput/index.js +0 -1
- package/components/form/telInput/index.vue +238 -135
- package/components/form/textArea/index.vue +72 -35
- package/components/form/textEditor/index.vue +739 -0
- package/components/form/{text-editor → textEditor}/style.scss +8 -16
- package/components/form/textInput/index.vue +54 -32
- package/components/form/timeInput/index.vue +82 -55
- package/components/form/timeInput/range.vue +115 -94
- package/components/form/timeInput/timepicker.vue +382 -449
- package/components/form/uniqueInput/index.vue +105 -48
- package/components/form/unitInput/index.vue +139 -84
- package/components/formCreator/index.js +0 -1
- package/components/formCreator/index.vue +314 -148
- package/components/highlight/index.vue +41 -25
- package/components/highlight/style.scss +2 -2
- package/components/highlight/{mixin.js → useHighlight.js} +181 -160
- package/components/icon/index.vue +79 -33
- package/components/img/index.vue +250 -147
- package/components/img/preview.vue +180 -198
- package/components/img/svgImg.vue +42 -39
- package/components/index.js +5 -20
- package/components/infinite/index.js +3 -3
- package/components/infinite/index.vue +290 -66
- package/components/map/index.vue +428 -261
- package/components/map/route.vue +794 -487
- package/components/map/select.vue +118 -58
- package/components/menu/index.vue +206 -94
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +382 -156
- package/components/notify/index.vue +204 -86
- package/components/notify/notification.vue +38 -55
- package/components/progress/circle.vue +189 -70
- package/components/progress/line.vue +266 -46
- package/components/searchBox/index.js +1 -3
- package/components/searchBox/index.vue +194 -101
- package/components/skeleton/index.vue +45 -20
- package/components/slider/index.vue +319 -156
- package/components/swiper/index.vue +237 -108
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +629 -399
- package/components/table/index.vue +721 -278
- package/components/timeAgo/index.vue +145 -96
- package/components/tour/index.vue +338 -235
- package/components/tree/index.vue +235 -89
- package/components/tree/tree-element.vue +106 -106
- package/directive/animate/index.js +77 -0
- package/directive/clickOutSide/index.js +98 -0
- package/directive/drag/index.js +153 -0
- package/directive/index.js +11 -13
- package/directive/intersect/index.js +263 -0
- package/directive/mask/index.js +67 -0
- package/directive/parallax/index.js +78 -0
- package/directive/ripple/index.js +14 -0
- package/directive/scroll/index.js +272 -24
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +11 -19
- package/package.json +5 -2
- package/plugins/validation/Validate.js +88 -79
- package/scripts/generate-docs.mjs +226 -0
- package/scripts/menu.mjs +240 -0
- package/scripts/parser.mjs +1086 -0
- package/style/_index.scss +7 -0
- package/style/app.scss +13 -65
- package/style/colors.scss +5 -22
- package/style/functions/index.scss +8 -0
- package/style/mixins/index.scss +17 -5
- package/style/variables/base.scss +155 -178
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +7 -2
- package/tools/root.js +71 -0
- package/components/app/style.scss +0 -41
- package/components/app/toast/style.scss +0 -20
- package/components/avatar/style.scss +0 -32
- package/components/bar/bottomNav.js +0 -1
- package/components/bar/bottomNav.vue +0 -28
- package/components/bar/bottomNavigationCircle.js +0 -2
- package/components/bar/bottomNavigationCircle.vue +0 -99
- package/components/bar/scss/bottomNav.scss +0 -67
- package/components/bar/scss/toolbar.scss +0 -174
- package/components/bar/toolbar/index.js +0 -8
- package/components/bar/toolbar/index.vue +0 -35
- package/components/bar/toolbar/laptop.vue +0 -33
- package/components/bar/toolbar/menuChilds.vue +0 -41
- package/components/bar/toolbar/menuLaptop.vue +0 -41
- package/components/bar/toolbar/menuMob.vue +0 -39
- package/components/bar/toolbar/mixin.js +0 -43
- package/components/bar/toolbar/mobile.vue +0 -34
- package/components/breadcrumb/bredcrumbItem.vue +0 -39
- package/components/breadcrumb/index.js +0 -3
- package/components/breadcrumb/index.vue +0 -71
- package/components/breadcrumb/style.scss +0 -51
- package/components/button/style.scss +0 -411
- package/components/card/style.scss +0 -86
- package/components/chart/chart.js +0 -1
- package/components/chart/chart.vue +0 -69
- package/components/chart/worldMap.js +0 -2
- package/components/chart/worldMap.vue +0 -1112
- package/components/chat/MessageList.vue +0 -163
- package/components/chat/chatInput.vue +0 -150
- package/components/chat/chatMsg.vue +0 -276
- package/components/chat/index.js +0 -11
- package/components/chat/index.vue +0 -113
- package/components/chip/index.js +0 -3
- package/components/chip/index.vue +0 -77
- package/components/chip/style.scss +0 -199
- package/components/codeEditor/mixin.js +0 -145
- package/components/countdown/index.js +0 -1
- package/components/countdown/index.vue +0 -105
- package/components/form/colorInput/mixin.js +0 -132
- package/components/form/fileInput/file.js +0 -148
- package/components/form/telInput/assets/flags.png +0 -0
- package/components/form/telInput/assets/flags@2x.png +0 -0
- package/components/form/text-editor/index.vue +0 -705
- package/components/icon/style.scss +0 -17
- package/components/infinite/div.js +0 -6
- package/components/infinite/div.vue +0 -193
- package/components/infinite/page.js +0 -3
- package/components/infinite/page.vue +0 -105
- package/components/list/index.js +0 -3
- package/components/list/index.vue +0 -122
- package/components/list/style.scss +0 -66
- package/components/message/index.js +0 -4
- package/components/message/index.vue +0 -40
- package/components/modal/style.scss +0 -146
- package/components/nestable/NestableItem.vue +0 -307
- package/components/nestable/editable.js +0 -44
- package/components/nestable/index.js +0 -1
- package/components/nestable/index.vue +0 -226
- package/components/nestable/methods.js +0 -416
- package/components/progress/style.scss +0 -229
- package/components/table/style.scss +0 -338
- package/components/tabs/index.js +0 -3
- package/components/tabs/index.vue +0 -151
- package/components/timeline/index.js +0 -6
- package/components/timeline/index.vue +0 -76
- package/directive/resize/index.js +0 -30
- package/directive/skeleton/index.js +0 -27
- package/directive/skeleton/style.scss +0 -37
- package/plugins/request/Request.js +0 -68
- package/style/animation.scss +0 -94
- package/style/style.scss +0 -8
- package/tools/rootable.js +0 -75
- /package/components/form/{text-editor → textEditor}/index.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
|
@@ -1,69 +1,83 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
2
|
+
<r-input :class="`${$r.prefix}switch`" :modelValue="lazyValue" hide>
|
|
3
|
+
<div class="switch-container" :class="{'switch-active':modelValue}">
|
|
4
|
+
<div class="switch-label me-1"
|
|
5
|
+
>{{ label }}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="switch-holder" @click.prevent="toggle()">
|
|
8
|
+
<div class="switch-line"></div>
|
|
9
|
+
<div class="switch-dot"></div>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="switch-label ms-1"
|
|
12
|
+
v-if="label2">{{ label2 }}
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</r-input>
|
|
15
16
|
</template>
|
|
16
|
-
<script>
|
|
17
|
+
<script setup>
|
|
18
|
+
import {ref, watch} from 'vue'
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
/**
|
|
22
|
+
* Primary label for the switch
|
|
23
|
+
* @type {String}
|
|
24
|
+
*/
|
|
25
|
+
label: String,
|
|
26
|
+
/**
|
|
27
|
+
* Secondary label for the switch (optional)
|
|
28
|
+
* @type {String}
|
|
29
|
+
*/
|
|
30
|
+
label2: String,
|
|
31
|
+
/**
|
|
32
|
+
* The switch's model value
|
|
33
|
+
* @type {Boolean|String}
|
|
34
|
+
*/
|
|
35
|
+
modelValue: {
|
|
36
|
+
type: [Boolean, String]
|
|
37
|
+
}
|
|
38
|
+
})
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.lazyValue = true
|
|
49
|
-
this.$emit('change', true)
|
|
50
|
-
this.$emit('update:modelValue', true)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
40
|
+
const emit = defineEmits([
|
|
41
|
+
/**
|
|
42
|
+
* Emitted when the switch value changes
|
|
43
|
+
* @param {Boolean|String} value - The updated switch value
|
|
44
|
+
*/
|
|
45
|
+
'update:modelValue',
|
|
46
|
+
/**
|
|
47
|
+
* Emitted when the switch is toggled
|
|
48
|
+
* @param {Boolean|String} value - The new switch state
|
|
49
|
+
*/
|
|
50
|
+
'change'
|
|
51
|
+
])
|
|
52
|
+
|
|
53
|
+
// Reactive data
|
|
54
|
+
const lazyValue = ref(props.modelValue || false)
|
|
56
55
|
|
|
56
|
+
// Watchers
|
|
57
|
+
watch(() => props.modelValue, (newValue) => {
|
|
58
|
+
lazyValue.value = newValue
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// Methods
|
|
62
|
+
/**
|
|
63
|
+
* Toggles the switch state and emits events
|
|
64
|
+
*/
|
|
65
|
+
const toggle = () => {
|
|
66
|
+
const newValue = !lazyValue.value
|
|
67
|
+
lazyValue.value = newValue
|
|
68
|
+
emit('change', newValue)
|
|
69
|
+
emit('update:modelValue', newValue)
|
|
70
|
+
}
|
|
57
71
|
</script>
|
|
58
72
|
<style lang="scss">
|
|
59
73
|
@use "sass:map";
|
|
60
|
-
@use "../../../style
|
|
61
|
-
@use "../../../style/mixins";
|
|
74
|
+
@use "../../../style" as *;
|
|
62
75
|
|
|
63
|
-
.#{
|
|
76
|
+
.#{$prefix}switch {
|
|
64
77
|
.switch-label {
|
|
65
78
|
color: var(--color-on-sheet);
|
|
66
79
|
}
|
|
80
|
+
|
|
67
81
|
.switch-container {
|
|
68
82
|
display: flex;
|
|
69
83
|
flex-direction: row;
|
|
@@ -94,11 +108,11 @@ emits:['update:modelValue','change'],
|
|
|
94
108
|
height: 20px;
|
|
95
109
|
border-radius: 50%;
|
|
96
110
|
background-color: #cdcbcb;
|
|
97
|
-
transition: .3s map.get(
|
|
98
|
-
@include
|
|
111
|
+
transition: .3s map.get($transition, 'fast-in-fast-out');
|
|
112
|
+
@include rtl() {
|
|
99
113
|
right: 0;
|
|
100
114
|
}
|
|
101
|
-
@include
|
|
115
|
+
@include ltr() {
|
|
102
116
|
left: 0;
|
|
103
117
|
}
|
|
104
118
|
}
|
|
@@ -111,10 +125,10 @@ emits:['update:modelValue','change'],
|
|
|
111
125
|
|
|
112
126
|
.switch-dot {
|
|
113
127
|
background-color: currentColor;
|
|
114
|
-
@include
|
|
128
|
+
@include rtl() {
|
|
115
129
|
right: 25px;
|
|
116
130
|
}
|
|
117
|
-
@include
|
|
131
|
+
@include ltr() {
|
|
118
132
|
left: 25px;
|
|
119
133
|
}
|
|
120
134
|
}
|
|
@@ -2,6 +2,5 @@ export * as rTelInput from './index.vue'
|
|
|
2
2
|
export * as l_textInput from '../textInput/index.js'
|
|
3
3
|
export * as l_modal from '../../modal/index.js'
|
|
4
4
|
export * as l_card from '../../card/index.js'
|
|
5
|
-
export * as l_list from '../../list/index.js'
|
|
6
5
|
export * as l_spacer from '../../container/spacer.js'
|
|
7
6
|
export * as l_btn from '../../button/index.js'
|
|
@@ -1,169 +1,272 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
<r-input v-model="tel.phone"
|
|
3
|
+
:active="active"
|
|
4
|
+
:class="`${$r.prefix}input-tel`"
|
|
5
|
+
:rules="required?['required','number']:['number']"
|
|
6
|
+
ltr
|
|
7
|
+
@update:model-value="emitValue"
|
|
8
|
+
@click.prevent="handleClick">
|
|
9
|
+
<div class="d-flex v-center">
|
|
10
|
+
<r-btn :disabled="!select"
|
|
11
|
+
class="btn-country mr-1" text @click.stop="toggleDropdown">
|
|
12
|
+
<div :class="activeCountry.iso2.toLowerCase()" class="iti-flag"></div>
|
|
13
|
+
<span class="country-code pa-1"> +{{ activeCountry.dialCode }} </span>
|
|
14
|
+
<span class="dropdown-arrow">{{ open ? "▲" : "▼" }}</span>
|
|
15
|
+
</r-btn>
|
|
16
|
+
<input ref="input"
|
|
17
|
+
v-model="tel.phone"
|
|
18
|
+
:autofocus="autofocus"
|
|
19
|
+
:placeholder="placeholder"
|
|
20
|
+
:type="type"
|
|
21
|
+
autocomplete="no"
|
|
22
|
+
@focusin="active=true"
|
|
23
|
+
@focusout="active=false"
|
|
24
|
+
@input="emitValue"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
17
27
|
<r-modal
|
|
28
|
+
:class="`${$r.prefix}input-tel`"
|
|
18
29
|
v-model="open"
|
|
19
30
|
>
|
|
20
|
-
<div class="
|
|
31
|
+
<div class="px-2 py-5">
|
|
21
32
|
<r-text-input
|
|
22
33
|
:label="$t('search','renusify')"
|
|
23
34
|
v-model="search"
|
|
24
35
|
></r-text-input>
|
|
25
|
-
<r-list :items="countries" :filter="search" @update:model-value="choose">
|
|
26
|
-
<template v-slot="{item}">
|
|
27
|
-
<div
|
|
28
|
-
:class="item.iso2.toLowerCase()"
|
|
29
|
-
class="iti-flag"></div>
|
|
30
|
-
<div class="list-title">{{ item.name }}</div>
|
|
31
|
-
<r-spacer></r-spacer>
|
|
32
|
-
<span class="ltr">+{{ item.dialCode }}</span>
|
|
33
|
-
</template>
|
|
34
|
-
</r-list>
|
|
35
36
|
</div>
|
|
37
|
+
<div v-for="(item,i) in genItems" :key="i" class="list-item d-flex v-center py-5 px-3 cursor-pointer"
|
|
38
|
+
@click="choose(item)">
|
|
39
|
+
<div
|
|
40
|
+
:class="item.iso2.toLowerCase()"
|
|
41
|
+
class="iti-flag"></div>
|
|
42
|
+
<div class="list-title me-1">{{ item.name }}</div>
|
|
43
|
+
<r-spacer></r-spacer>
|
|
44
|
+
<span class="ltr">+{{ item.dialCode }}</span>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
36
47
|
</r-modal>
|
|
37
|
-
</
|
|
48
|
+
</r-input>
|
|
38
49
|
</template>
|
|
39
50
|
|
|
40
|
-
<script>
|
|
41
|
-
|
|
42
|
-
export default {
|
|
43
|
-
name: 'inputTel',
|
|
44
|
-
props: {
|
|
45
|
-
label: {
|
|
46
|
-
type: String
|
|
47
|
-
},
|
|
48
|
-
modelValue: {
|
|
49
|
-
type: String
|
|
50
|
-
},
|
|
51
|
-
defaultCountry: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: 'US'
|
|
54
|
-
},
|
|
55
|
-
tile: {type: Boolean, default: undefined},
|
|
56
|
-
required: Boolean,
|
|
57
|
-
readonly: Boolean,
|
|
58
|
-
select: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
default: false
|
|
61
|
-
}
|
|
51
|
+
<script setup>
|
|
52
|
+
import {ref, nextTick, useAttrs, computed} from 'vue'
|
|
62
53
|
|
|
54
|
+
const attr = useAttrs()
|
|
55
|
+
const placeholder = attr.placeholder
|
|
56
|
+
const autofocus = attr.autofocus
|
|
57
|
+
|
|
58
|
+
const props = defineProps({
|
|
59
|
+
/**
|
|
60
|
+
* Input type attribute
|
|
61
|
+
* @type {String}
|
|
62
|
+
* @default 'text'
|
|
63
|
+
*/
|
|
64
|
+
type: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: 'text'
|
|
63
67
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The telephone input's model value (format: "country_code phone_number")
|
|
70
|
+
* @type {String|Number}
|
|
71
|
+
*
|
|
72
|
+
* Example: "1 5551234567" for US number
|
|
73
|
+
*/
|
|
74
|
+
modelValue: [String, Number],
|
|
75
|
+
/**
|
|
76
|
+
* Default country ISO code to pre-select
|
|
77
|
+
* @type {String}
|
|
78
|
+
* @default 'US'
|
|
79
|
+
*/
|
|
80
|
+
defaultCountry: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: 'US'
|
|
76
83
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Whether the input is required
|
|
86
|
+
* @type {Boolean}
|
|
87
|
+
*/
|
|
88
|
+
required: Boolean,
|
|
89
|
+
/**
|
|
90
|
+
* Whether to show country code as a selectable dropdown
|
|
91
|
+
* @type {Boolean}
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
select: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const emit = defineEmits([
|
|
101
|
+
/**
|
|
102
|
+
* Emitted when the telephone value changes
|
|
103
|
+
* @param {String} value - The updated telephone value in format "country_code phone_number"
|
|
104
|
+
*/
|
|
105
|
+
'update:modelValue'
|
|
106
|
+
])
|
|
107
|
+
|
|
108
|
+
// Reactive data
|
|
109
|
+
const open = ref(false)
|
|
110
|
+
const active = ref(false)
|
|
111
|
+
const input = ref(null)
|
|
112
|
+
const tel = ref({country_code: '', phone: ''})
|
|
113
|
+
const search = ref('')
|
|
114
|
+
const activeCountry = ref({iso2: 'US', dialCode: '1'})
|
|
115
|
+
|
|
116
|
+
// Load countries data
|
|
117
|
+
let countries = []
|
|
118
|
+
import('./assets/all-countries.js').then((d) => {
|
|
119
|
+
countries = d.default;
|
|
120
|
+
if (props.modelValue) {
|
|
121
|
+
let a = props.modelValue.split(' ')
|
|
122
|
+
tel.value.country_code = a[0]
|
|
123
|
+
tel.value.phone = a[1]
|
|
124
|
+
activeCountry.value = findCountryByCode(tel.value.country_code)
|
|
125
|
+
} else {
|
|
126
|
+
initializeCountry()
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// Methods
|
|
131
|
+
/**
|
|
132
|
+
* Focuses the telephone input field
|
|
133
|
+
*/
|
|
134
|
+
const handleClick = () => {
|
|
135
|
+
if (input.value) {
|
|
136
|
+
input.value.focus()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Emits the formatted telephone value
|
|
142
|
+
*/
|
|
143
|
+
const emitValue = () => {
|
|
144
|
+
tel.value.country_code = activeCountry.value.dialCode
|
|
145
|
+
|
|
146
|
+
nextTick(() => {
|
|
147
|
+
tel.value.phone = tel.value.phone.replaceAll(' ', '')
|
|
148
|
+
if (tel.value.phone.startsWith('0')) {
|
|
149
|
+
tel.value.phone = tel.value.phone.substring(1, tel.value.phone.length)
|
|
150
|
+
emit('update:modelValue', tel.value.country_code + ' ' + tel.value.phone)
|
|
151
|
+
} else {
|
|
152
|
+
emit('update:modelValue', tel.value.country_code + ' ' + tel.value.phone)
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Initializes the default country based on props
|
|
159
|
+
*/
|
|
160
|
+
const initializeCountry = () => {
|
|
161
|
+
if (props.defaultCountry) {
|
|
162
|
+
const defaultCountry = findCountry(props.defaultCountry)
|
|
163
|
+
if (defaultCountry) {
|
|
164
|
+
activeCountry.value = defaultCountry
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Finds a country by ISO2 code
|
|
171
|
+
* @param {String} iso - ISO2 country code (e.g., 'US', 'GB')
|
|
172
|
+
* @returns {Object|undefined} Country object if found
|
|
173
|
+
*/
|
|
174
|
+
const findCountry = (iso = '') => {
|
|
175
|
+
return countries.find(country => country.iso2 === iso)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Finds a country by dial code
|
|
180
|
+
* @param {String} code - Country dial code (e.g., '1', '44')
|
|
181
|
+
* @returns {Object|undefined} Country object if found
|
|
182
|
+
*/
|
|
183
|
+
const findCountryByCode = (code = '') => {
|
|
184
|
+
return countries.find(country => country.dialCode === code)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Selects a country and updates the telephone value
|
|
189
|
+
* @param {Object} country - Selected country object
|
|
190
|
+
*/
|
|
191
|
+
const choose = (country) => {
|
|
192
|
+
activeCountry.value = country
|
|
193
|
+
emitValue()
|
|
194
|
+
reset()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Resets the country search and closes dropdown
|
|
199
|
+
*/
|
|
200
|
+
const reset = () => {
|
|
201
|
+
search.value = ''
|
|
202
|
+
open.value = false
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Toggles the country dropdown visibility
|
|
207
|
+
*/
|
|
208
|
+
const toggleDropdown = () => {
|
|
209
|
+
open.value = !open.value
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Computed properties
|
|
213
|
+
/**
|
|
214
|
+
* Generates and filters countries list for dropdown
|
|
215
|
+
* @returns {Array} Filtered list of country objects
|
|
216
|
+
*/
|
|
217
|
+
const genItems = computed(() => {
|
|
218
|
+
const res = []
|
|
219
|
+
if (countries) {
|
|
220
|
+
const lng = countries.length
|
|
221
|
+
for (let i = 0; i < lng; i++) {
|
|
222
|
+
if (typeof countries[i] === 'object') {
|
|
223
|
+
res[i] = countries[i]
|
|
85
224
|
} else {
|
|
86
|
-
|
|
225
|
+
res[i] = {name: countries[i].toString(), value: countries[i]}
|
|
87
226
|
}
|
|
88
|
-
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (search.value) {
|
|
230
|
+
const re = new RegExp(search.value, 'gi')
|
|
89
231
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (this.tile === undefined && this.$r.inputs.tile) {
|
|
94
|
-
return this.$r.inputs.tile
|
|
232
|
+
return res.filter(function (el) {
|
|
233
|
+
if (el.name.match(re) || el.dialCode.match(re)) {
|
|
234
|
+
return el
|
|
95
235
|
}
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
methods: {
|
|
100
|
-
initializeCountry() {
|
|
101
|
-
if (this.defaultCountry) {
|
|
102
|
-
const defaultCountry = this.findCountry(this.defaultCountry)
|
|
103
|
-
if (defaultCountry) {
|
|
104
|
-
this.activeCountry = defaultCountry
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
findCountry(iso = '') {
|
|
109
|
-
return this.countries.find(country => country.iso2 === iso)
|
|
110
|
-
},
|
|
111
|
-
findCountryByCode(code = '') {
|
|
112
|
-
return this.countries.find(country => country.dialCode === code)
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
choose(country) {
|
|
116
|
-
this.activeCountry = country
|
|
117
|
-
this.emit()
|
|
118
|
-
this.reset()
|
|
119
|
-
},
|
|
120
|
-
reset() {
|
|
121
|
-
this.search = ''
|
|
122
|
-
this.open = false
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
emit(e) {
|
|
126
|
-
if (this.readonly) {
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
this.tel.country_code = this.activeCountry.dialCode
|
|
130
|
-
|
|
131
|
-
setTimeout(() => {
|
|
132
|
-
this.tel.phone = this.$helper.replacer(this.tel.phone, ' ', '')
|
|
133
|
-
if (this.tel.phone.startsWith('0')) {
|
|
134
|
-
this.tel.phone = this.tel.phone.substr(1, this.tel.phone.length)
|
|
135
|
-
this.$emit('update:modelValue', this.tel.country_code + ' ' + this.tel.phone)
|
|
136
|
-
} else {
|
|
137
|
-
this.$emit('update:modelValue', this.tel.country_code + ' ' + this.tel.phone)
|
|
138
|
-
}
|
|
139
|
-
}, 10)
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
toggleDropdown() {
|
|
143
|
-
this.open = !this.open
|
|
144
|
-
}
|
|
236
|
+
})
|
|
145
237
|
}
|
|
146
|
-
|
|
238
|
+
return res
|
|
239
|
+
})
|
|
147
240
|
</script>
|
|
148
241
|
|
|
149
242
|
<style src="./assets/sprite.css"></style>
|
|
150
243
|
<style lang="scss">
|
|
151
|
-
@use "../../../style
|
|
244
|
+
@use "../../../style" as *;
|
|
152
245
|
|
|
153
|
-
.#{
|
|
154
|
-
display: flex;
|
|
155
|
-
align-items: end;
|
|
246
|
+
.#{$prefix}input-tel {
|
|
156
247
|
direction: ltr;
|
|
157
|
-
|
|
248
|
+
|
|
158
249
|
.btn-country {
|
|
159
250
|
width: 100px;
|
|
160
|
-
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
> .input-control {
|
|
254
|
+
padding-left: 0;
|
|
255
|
+
}
|
|
161
256
|
|
|
257
|
+
.label {
|
|
258
|
+
@include ltr() {
|
|
259
|
+
left: 100px;
|
|
260
|
+
}
|
|
162
261
|
}
|
|
163
262
|
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
263
|
+
.list-item {
|
|
264
|
+
border-bottom: 1px solid var(--color-sheet-low);
|
|
265
|
+
|
|
266
|
+
&:hover {
|
|
267
|
+
background-color: var(--color-one-container);
|
|
268
|
+
color: var(--color-on-one-container);
|
|
269
|
+
}
|
|
167
270
|
}
|
|
168
271
|
}
|
|
169
272
|
</style>
|