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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.78.0",
4
+ "version": "1.79.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -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
  }
@@ -17,6 +17,7 @@ export interface InputTextFieldProps extends InputProps {
17
17
  iconAppend?: string;
18
18
  showCounter?: boolean;
19
19
  limit?: number;
20
+ maxLength?: number;
20
21
  }
21
22
  type __VLS_Props = InputTextFieldProps;
22
23
  type __VLS_ModelProps = {
@@ -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 }
@@ -17,6 +17,7 @@ export interface InputTextFieldProps extends InputProps {
17
17
  iconAppend?: string;
18
18
  showCounter?: boolean;
19
19
  limit?: number;
20
+ maxLength?: number;
20
21
  }
21
22
  type __VLS_Props = InputTextFieldProps;
22
23
  type __VLS_ModelProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.78.0",
3
+ "version": "1.79.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",