pukaad-ui-lib 1.78.0 → 1.79.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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/input/input-email.vue +1 -0
- package/dist/runtime/components/input/input-password.vue +1 -0
- package/dist/runtime/components/input/input-phone.vue +18 -2
- package/dist/runtime/components/input/input-text-field.d.vue.ts +1 -0
- package/dist/runtime/components/input/input-text-field.vue +2 -0
- package/dist/runtime/components/input/input-text-field.vue.d.ts +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -32,6 +32,7 @@ const props = defineProps({
|
|
|
32
32
|
iconAppend: { type: String, required: false },
|
|
33
33
|
showCounter: { type: Boolean, required: false },
|
|
34
34
|
limit: { type: Number, required: false },
|
|
35
|
+
maxLength: { type: Number, required: false },
|
|
35
36
|
defaultValue: { type: [String, Number], required: false },
|
|
36
37
|
modelValue: { type: [String, Number], required: false },
|
|
37
38
|
class: { type: null, required: false }
|
|
@@ -64,6 +64,7 @@ const props = defineProps({
|
|
|
64
64
|
iconAppend: { type: String, required: false },
|
|
65
65
|
showCounter: { type: Boolean, required: false },
|
|
66
66
|
limit: { type: Number, required: false },
|
|
67
|
+
maxLength: { type: Number, required: false },
|
|
67
68
|
defaultValue: { type: [String, Number], required: false },
|
|
68
69
|
modelValue: { type: [String, Number], required: false },
|
|
69
70
|
class: { type: null, required: false }
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
ref="phoneRef"
|
|
4
4
|
v-bind="$props"
|
|
5
5
|
:rules="defaultRules || props.rules"
|
|
6
|
+
:max-length="computedMaxLength"
|
|
6
7
|
v-model="phoneCode"
|
|
7
8
|
>
|
|
8
9
|
<template #append v-if="props.showIconStatus && validationState !== 'none'">
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
</template>
|
|
13
14
|
|
|
14
15
|
<script setup>
|
|
15
|
-
import { ref, watch, computed } from "vue";
|
|
16
|
+
import { ref, watch, computed, nextTick } from "vue";
|
|
16
17
|
import {
|
|
17
18
|
formatPhone,
|
|
18
19
|
reverseFormatPhone,
|
|
@@ -36,6 +37,7 @@ const props = defineProps({
|
|
|
36
37
|
iconAppend: { type: String, required: false },
|
|
37
38
|
showCounter: { type: Boolean, required: false },
|
|
38
39
|
limit: { type: Number, required: false },
|
|
40
|
+
maxLength: { type: Number, required: false },
|
|
39
41
|
defaultValue: { type: [String, Number], required: false },
|
|
40
42
|
modelValue: { type: [String, Number], required: false },
|
|
41
43
|
class: { type: null, required: false }
|
|
@@ -43,6 +45,7 @@ const props = defineProps({
|
|
|
43
45
|
const phoneRef = ref();
|
|
44
46
|
const phoneCode = ref("");
|
|
45
47
|
const validationState = ref("none");
|
|
48
|
+
const previousFormatted = ref("");
|
|
46
49
|
const modelValue = defineModel({ type: String, ...{
|
|
47
50
|
default: ""
|
|
48
51
|
} });
|
|
@@ -52,6 +55,12 @@ const validationIcon = computed(() => {
|
|
|
52
55
|
const validationIconClass = computed(() => {
|
|
53
56
|
return validationState.value === "success" ? "text-success" : "text-destructive";
|
|
54
57
|
});
|
|
58
|
+
const computedMaxLength = computed(() => {
|
|
59
|
+
if (previousFormatted.value && phoneCode.value.includes("+66")) {
|
|
60
|
+
return previousFormatted.value.length;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
});
|
|
55
64
|
const defaultRules = (v) => {
|
|
56
65
|
if (!v) return "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C";
|
|
57
66
|
if (!checkPattern(v)) return "\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
|
|
@@ -62,6 +71,7 @@ watch(
|
|
|
62
71
|
(v) => {
|
|
63
72
|
if (!v) {
|
|
64
73
|
validationState.value = "none";
|
|
74
|
+
previousFormatted.value = "";
|
|
65
75
|
return;
|
|
66
76
|
}
|
|
67
77
|
const isValidPattern = checkPattern(v);
|
|
@@ -72,11 +82,17 @@ watch(
|
|
|
72
82
|
}
|
|
73
83
|
modelValue.value = reverseFormatPhone(newNumber || v);
|
|
74
84
|
validationState.value = "success";
|
|
85
|
+
previousFormatted.value = newNumber || v;
|
|
86
|
+
nextTick(() => {
|
|
87
|
+
const inputEl = document.getElementById(props.id);
|
|
88
|
+
inputEl?.blur();
|
|
89
|
+
});
|
|
75
90
|
} else {
|
|
76
|
-
if (v.includes("+66")) {
|
|
91
|
+
if (previousFormatted.value && v.includes("+66")) {
|
|
77
92
|
phoneCode.value = "";
|
|
78
93
|
modelValue.value = "";
|
|
79
94
|
validationState.value = "none";
|
|
95
|
+
previousFormatted.value = "";
|
|
80
96
|
} else {
|
|
81
97
|
validationState.value = "error";
|
|
82
98
|
}
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
:disabled="props.disabled"
|
|
48
48
|
:placeholder="props.placeholder"
|
|
49
49
|
:type="props.type"
|
|
50
|
+
:maxlength="props.maxLength"
|
|
50
51
|
@click="emits('click', $event)"
|
|
51
52
|
@keydown="emits('keydown', $event)"
|
|
52
53
|
>
|
|
@@ -115,6 +116,7 @@ const props = defineProps({
|
|
|
115
116
|
iconAppend: { type: String, required: false },
|
|
116
117
|
showCounter: { type: Boolean, required: false, default: false },
|
|
117
118
|
limit: { type: Number, required: false, default: 0 },
|
|
119
|
+
maxLength: { type: Number, required: false },
|
|
118
120
|
defaultValue: { type: [String, Number], required: false },
|
|
119
121
|
modelValue: { type: [String, Number], required: false },
|
|
120
122
|
class: { type: null, required: false }
|