pukaad-ui-lib 1.45.0 → 1.47.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-phone.d.vue.ts +3 -0
- package/dist/runtime/components/input/input-phone.vue +43 -8
- package/dist/runtime/components/input/input-phone.vue.d.ts +3 -0
- package/dist/runtime/components/ui/dialog/DialogContent.d.vue.ts +2 -2
- package/dist/runtime/components/ui/dialog/DialogContent.vue.d.ts +2 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InputTextFieldProps } from "@/runtime/components/input/input-text-field.vue";
|
|
2
2
|
interface InputPhoneProps extends InputTextFieldProps {
|
|
3
|
+
showIconStatus?: boolean;
|
|
3
4
|
}
|
|
4
5
|
type __VLS_Props = InputPhoneProps;
|
|
5
6
|
type __VLS_ModelProps = {
|
|
@@ -8,6 +9,7 @@ type __VLS_ModelProps = {
|
|
|
8
9
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
10
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
10
11
|
setErrors: (errMsg: string[]) => void;
|
|
12
|
+
setSuccess: () => void;
|
|
11
13
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
14
|
"update:modelValue": (value: string) => any;
|
|
13
15
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
@@ -15,6 +17,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
15
17
|
}>, {
|
|
16
18
|
id: string;
|
|
17
19
|
name: string;
|
|
20
|
+
showIconStatus: boolean;
|
|
18
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
22
|
declare const _default: typeof __VLS_export;
|
|
20
23
|
export default _default;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<InputTextField
|
|
3
3
|
ref="phoneRef"
|
|
4
|
-
v-bind="props"
|
|
4
|
+
v-bind="$props"
|
|
5
5
|
:rules="defaultRules || props.rules"
|
|
6
6
|
v-model="phoneCode"
|
|
7
|
-
|
|
7
|
+
>
|
|
8
|
+
<template #append v-if="props.showIconStatus && validationState !== 'none'">
|
|
9
|
+
<Icon :name="validationIcon" size="20" :class="validationIconClass" />
|
|
10
|
+
</template>
|
|
11
|
+
</InputTextField>
|
|
8
12
|
</template>
|
|
9
13
|
|
|
10
14
|
<script setup>
|
|
11
|
-
import { ref, watch } from "vue";
|
|
15
|
+
import { ref, watch, computed } from "vue";
|
|
12
16
|
import {
|
|
13
17
|
formatPhone,
|
|
14
18
|
reverseFormatPhone,
|
|
15
19
|
checkPattern
|
|
16
20
|
} from "@/runtime/utils/phone";
|
|
17
21
|
const props = defineProps({
|
|
22
|
+
showIconStatus: { type: Boolean, required: false, default: false },
|
|
18
23
|
id: { type: String, required: false, default: "input-phone" },
|
|
19
24
|
name: { type: String, required: false, default: "input-phone" },
|
|
20
25
|
disabled: { type: Boolean, required: false },
|
|
@@ -37,9 +42,16 @@ const props = defineProps({
|
|
|
37
42
|
});
|
|
38
43
|
const phoneRef = ref();
|
|
39
44
|
const phoneCode = ref("");
|
|
45
|
+
const validationState = ref("none");
|
|
40
46
|
const modelValue = defineModel({ type: String, ...{
|
|
41
47
|
default: ""
|
|
42
48
|
} });
|
|
49
|
+
const validationIcon = computed(() => {
|
|
50
|
+
return validationState.value === "success" ? "lucide:check" : "lucide:x";
|
|
51
|
+
});
|
|
52
|
+
const validationIconClass = computed(() => {
|
|
53
|
+
return validationState.value === "success" ? "text-success" : "text-destructive";
|
|
54
|
+
});
|
|
43
55
|
const defaultRules = (v) => {
|
|
44
56
|
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";
|
|
45
57
|
if (!checkPattern(v)) return "\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
|
|
@@ -48,19 +60,42 @@ const defaultRules = (v) => {
|
|
|
48
60
|
watch(
|
|
49
61
|
phoneCode,
|
|
50
62
|
(v) => {
|
|
51
|
-
if (!v)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
if (!v) {
|
|
64
|
+
validationState.value = "none";
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const isValidPattern = checkPattern(v);
|
|
68
|
+
if (isValidPattern) {
|
|
69
|
+
const newNumber = formatPhone(v) || "";
|
|
70
|
+
if (newNumber && newNumber !== v) {
|
|
71
|
+
phoneCode.value = newNumber;
|
|
72
|
+
}
|
|
73
|
+
modelValue.value = reverseFormatPhone(newNumber || v);
|
|
74
|
+
validationState.value = "success";
|
|
75
|
+
} else {
|
|
76
|
+
if (v.includes("+66")) {
|
|
77
|
+
phoneCode.value = "";
|
|
78
|
+
modelValue.value = "";
|
|
79
|
+
validationState.value = "none";
|
|
80
|
+
} else {
|
|
81
|
+
validationState.value = "error";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
55
84
|
},
|
|
56
85
|
{
|
|
57
86
|
immediate: true
|
|
58
87
|
}
|
|
59
88
|
);
|
|
60
89
|
const setErrors = (errMsg) => {
|
|
90
|
+
validationState.value = errMsg.length > 0 ? "error" : "none";
|
|
61
91
|
phoneRef.value?.setErrors(errMsg);
|
|
62
92
|
};
|
|
93
|
+
const setSuccess = () => {
|
|
94
|
+
validationState.value = "success";
|
|
95
|
+
phoneRef.value?.setErrors([]);
|
|
96
|
+
};
|
|
63
97
|
defineExpose({
|
|
64
|
-
setErrors
|
|
98
|
+
setErrors,
|
|
99
|
+
setSuccess
|
|
65
100
|
});
|
|
66
101
|
</script>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InputTextFieldProps } from "@/runtime/components/input/input-text-field.vue";
|
|
2
2
|
interface InputPhoneProps extends InputTextFieldProps {
|
|
3
|
+
showIconStatus?: boolean;
|
|
3
4
|
}
|
|
4
5
|
type __VLS_Props = InputPhoneProps;
|
|
5
6
|
type __VLS_ModelProps = {
|
|
@@ -8,6 +9,7 @@ type __VLS_ModelProps = {
|
|
|
8
9
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
10
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
10
11
|
setErrors: (errMsg: string[]) => void;
|
|
12
|
+
setSuccess: () => void;
|
|
11
13
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
14
|
"update:modelValue": (value: string) => any;
|
|
13
15
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
@@ -15,6 +17,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
15
17
|
}>, {
|
|
16
18
|
id: string;
|
|
17
19
|
name: string;
|
|
20
|
+
showIconStatus: boolean;
|
|
18
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
22
|
declare const _default: typeof __VLS_export;
|
|
20
23
|
export default _default;
|
|
@@ -12,22 +12,22 @@ type __VLS_Slots = {} & {
|
|
|
12
12
|
};
|
|
13
13
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
14
|
submit: (event: Event) => any;
|
|
15
|
-
close: (event: Event) => any;
|
|
16
15
|
escapeKeyDown: (event: KeyboardEvent) => any;
|
|
17
16
|
pointerDownOutside: (event: import("reka-ui").PointerDownOutsideEvent) => any;
|
|
18
17
|
focusOutside: (event: import("reka-ui").FocusOutsideEvent) => any;
|
|
19
18
|
interactOutside: (event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => any;
|
|
20
19
|
openAutoFocus: (event: Event) => any;
|
|
21
20
|
closeAutoFocus: (event: Event) => any;
|
|
21
|
+
close: (event: Event) => any;
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
23
|
onSubmit?: ((event: Event) => any) | undefined;
|
|
24
|
-
onClose?: ((event: Event) => any) | undefined;
|
|
25
24
|
onEscapeKeyDown?: ((event: KeyboardEvent) => any) | undefined;
|
|
26
25
|
onPointerDownOutside?: ((event: import("reka-ui").PointerDownOutsideEvent) => any) | undefined;
|
|
27
26
|
onFocusOutside?: ((event: import("reka-ui").FocusOutsideEvent) => any) | undefined;
|
|
28
27
|
onInteractOutside?: ((event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => any) | undefined;
|
|
29
28
|
onOpenAutoFocus?: ((event: Event) => any) | undefined;
|
|
30
29
|
onCloseAutoFocus?: ((event: Event) => any) | undefined;
|
|
30
|
+
onClose?: ((event: Event) => any) | undefined;
|
|
31
31
|
}>, {
|
|
32
32
|
disabledCloseBtn: boolean;
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -12,22 +12,22 @@ type __VLS_Slots = {} & {
|
|
|
12
12
|
};
|
|
13
13
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
14
|
submit: (event: Event) => any;
|
|
15
|
-
close: (event: Event) => any;
|
|
16
15
|
escapeKeyDown: (event: KeyboardEvent) => any;
|
|
17
16
|
pointerDownOutside: (event: import("reka-ui").PointerDownOutsideEvent) => any;
|
|
18
17
|
focusOutside: (event: import("reka-ui").FocusOutsideEvent) => any;
|
|
19
18
|
interactOutside: (event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => any;
|
|
20
19
|
openAutoFocus: (event: Event) => any;
|
|
21
20
|
closeAutoFocus: (event: Event) => any;
|
|
21
|
+
close: (event: Event) => any;
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
23
|
onSubmit?: ((event: Event) => any) | undefined;
|
|
24
|
-
onClose?: ((event: Event) => any) | undefined;
|
|
25
24
|
onEscapeKeyDown?: ((event: KeyboardEvent) => any) | undefined;
|
|
26
25
|
onPointerDownOutside?: ((event: import("reka-ui").PointerDownOutsideEvent) => any) | undefined;
|
|
27
26
|
onFocusOutside?: ((event: import("reka-ui").FocusOutsideEvent) => any) | undefined;
|
|
28
27
|
onInteractOutside?: ((event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => any) | undefined;
|
|
29
28
|
onOpenAutoFocus?: ((event: Event) => any) | undefined;
|
|
30
29
|
onCloseAutoFocus?: ((event: Event) => any) | undefined;
|
|
30
|
+
onClose?: ((event: Event) => any) | undefined;
|
|
31
31
|
}>, {
|
|
32
32
|
disabledCloseBtn: boolean;
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|