pukaad-ui-lib 1.248.0 → 1.250.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.248.0",
4
+ "version": "1.250.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -4,6 +4,7 @@ export interface InputCheckboxProps {
4
4
  label?: string;
5
5
  rules?: object | string | Function;
6
6
  indeterminate?: boolean;
7
+ labelPosition?: 'left' | 'right';
7
8
  }
8
9
  type __VLS_Props = InputCheckboxProps;
9
10
  type __VLS_ModelProps = {
@@ -17,6 +18,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
17
18
  }>, {
18
19
  name: string;
19
20
  indeterminate: boolean;
21
+ labelPosition: "left" | "right";
20
22
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
23
  declare const _default: typeof __VLS_export;
22
24
  export default _default;
@@ -6,14 +6,22 @@
6
6
  >
7
7
  <ShadFormItem>
8
8
  <ShadFormControl>
9
- <div class="flex gap-2 items-center">
9
+ <div
10
+ class="flex gap-2 items-center"
11
+ :class="[
12
+ props.labelPosition === 'left' ? 'flex-row-reverse justify-between w-full' : ''
13
+ ]"
14
+ >
10
15
  <ShadCheckbox
11
16
  v-bind="componentField"
12
17
  v-model="modelValue"
13
18
  :indeterminate="props.indeterminate"
14
19
  />
15
20
  <ShadFormLabel
16
- class="font-body-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
21
+ class="font-body-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer"
22
+ :class="[
23
+ props.labelPosition === 'left' ? 'flex-1' : ''
24
+ ]"
17
25
  >
18
26
  {{ props.label }}
19
27
  </ShadFormLabel>
@@ -29,7 +37,8 @@ const props = defineProps({
29
37
  name: { type: String, required: false, default: "input-checkbox" },
30
38
  label: { type: String, required: false },
31
39
  rules: { type: [Object, String, Function], required: false },
32
- indeterminate: { type: Boolean, required: false, default: false }
40
+ indeterminate: { type: Boolean, required: false, default: false },
41
+ labelPosition: { type: String, required: false, default: "right" }
33
42
  });
34
43
  const defaultRules = () => true;
35
44
  const modelValue = defineModel({ type: Boolean, ...{
@@ -4,6 +4,7 @@ export interface InputCheckboxProps {
4
4
  label?: string;
5
5
  rules?: object | string | Function;
6
6
  indeterminate?: boolean;
7
+ labelPosition?: 'left' | 'right';
7
8
  }
8
9
  type __VLS_Props = InputCheckboxProps;
9
10
  type __VLS_ModelProps = {
@@ -17,6 +18,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
17
18
  }>, {
18
19
  name: string;
19
20
  indeterminate: boolean;
21
+ labelPosition: "left" | "right";
20
22
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
23
  declare const _default: typeof __VLS_export;
22
24
  export default _default;
@@ -0,0 +1,33 @@
1
+ import type { InputTextFieldProps } from "./input-text-field.vue.js";
2
+ export interface InputProfileNameProps extends Omit<InputTextFieldProps, 'modelValue'> {
3
+ }
4
+ type __VLS_Props = InputProfileNameProps;
5
+ type __VLS_ModelProps = {
6
+ modelValue?: string;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare var __VLS_11: string, __VLS_12: any;
10
+ type __VLS_Slots = {} & {
11
+ [K in NonNullable<typeof __VLS_11>]?: (props: typeof __VLS_12) => any;
12
+ };
13
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
14
+ setErrors: (errMsg: string | string[]) => void;
15
+ validate: () => Promise<any>;
16
+ inputTextFieldRef: import("vue").Ref<any, any>;
17
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ "update:modelValue": (value: string | undefined) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
+ "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
21
+ }>, {
22
+ label: string;
23
+ id: string;
24
+ name: string;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <InputTextField
3
+ ref="inputTextFieldRef"
4
+ v-bind="props"
5
+ :rules="props.rules || defaultRules"
6
+ v-model="modelValue"
7
+ >
8
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
9
+ <slot :name="name" v-bind="slotData || {}" />
10
+ </template>
11
+ </InputTextField>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { ref } from "vue";
16
+ const props = defineProps({
17
+ id: { type: String, required: false, default: "input-profile-name" },
18
+ name: { type: String, required: false, default: "profileName" },
19
+ disabled: { type: Boolean, required: false },
20
+ label: { type: String, required: false, default: "\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C" },
21
+ rules: { type: [Object, String, Function], required: false },
22
+ readonly: { type: Boolean, required: false },
23
+ placeholder: { type: String, required: false },
24
+ type: { type: String, required: false },
25
+ description: { type: String, required: false },
26
+ disabledErrorMessage: { type: Boolean, required: false },
27
+ disabledBorder: { type: Boolean, required: false },
28
+ required: { type: Boolean, required: false },
29
+ iconPrepend: { type: String, required: false },
30
+ iconAppend: { type: String, required: false },
31
+ showCounter: { type: Boolean, required: false },
32
+ limit: { type: Number, required: false },
33
+ maxLength: { type: Number, required: false },
34
+ defaultValue: { type: [String, Number], required: false },
35
+ class: { type: null, required: false }
36
+ });
37
+ const modelValue = defineModel({ type: String });
38
+ const inputTextFieldRef = ref();
39
+ const isEmoji = (v) => {
40
+ const emojiRegex = /[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]/gu;
41
+ return emojiRegex.test(v);
42
+ };
43
+ const isMixedLanguages = (v) => {
44
+ const isLatin = /[a-zA-Z]/.test(v);
45
+ const isThai = /[\u0E00-\u0E7F]/.test(v);
46
+ const isChinese = /[\u4E00-\u9FFF]/.test(v);
47
+ const isJapanese = /[\u3040-\u309F\u30A0-\u30FF]/.test(v);
48
+ const isKorean = /[\uAC00-\uD7AF]/.test(v);
49
+ const isArabic = /[\u0600-\u06FF]/.test(v);
50
+ const isRussian = /[\u0400-\u04FF]/.test(v);
51
+ const languages = [
52
+ isLatin,
53
+ isThai,
54
+ isChinese,
55
+ isJapanese,
56
+ isKorean,
57
+ isArabic,
58
+ isRussian
59
+ ];
60
+ const activeLanguages = languages.filter(Boolean).length;
61
+ return activeLanguages > 1;
62
+ };
63
+ const isInvalidSymbols = (v) => {
64
+ const validPattern = /^[a-zA-Z\u0E00-\u0E7F\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF\u0400-\u04FF\u0600-\u06FF.\s-]+$/;
65
+ return !validPattern.test(v);
66
+ };
67
+ const defaultRules = (value) => {
68
+ if (!value) return "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
69
+ const v = value.trim();
70
+ if (!v) return "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
71
+ if (v.length < 4) return "\u0E01\u0E23\u0E2D\u0E01\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 4 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23";
72
+ if (v.length > 50) return "\u0E01\u0E23\u0E2D\u0E01\u0E44\u0E14\u0E49\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 50 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23";
73
+ if (/\d/.test(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E2A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E43\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
74
+ if (/\.{2,}/.test(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E2A\u0E48\u0E08\u0E38\u0E14 (.) \u0E15\u0E34\u0E14\u0E01\u0E31\u0E19";
75
+ if (/\s{2,}/.test(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E40\u0E27\u0E49\u0E19\u0E27\u0E23\u0E23\u0E04\u0E15\u0E34\u0E14\u0E01\u0E31\u0E19";
76
+ if (isEmoji(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E2A\u0E48 Emoji \u0E43\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
77
+ if (isMixedLanguages(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E0A\u0E49\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23 2 \u0E20\u0E32\u0E29\u0E32\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E01\u0E31\u0E19";
78
+ if (isInvalidSymbols(v)) return "\u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E40\u0E09\u0E1E\u0E32\u0E30\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23 \u0E08\u0E38\u0E14 (.) \u0E41\u0E25\u0E30\u0E02\u0E35\u0E14 (-)";
79
+ return true;
80
+ };
81
+ const setErrors = (errMsg) => {
82
+ const messages = Array.isArray(errMsg) ? errMsg : [errMsg];
83
+ inputTextFieldRef.value?.setErrors?.(messages);
84
+ };
85
+ const validate = async () => {
86
+ return await inputTextFieldRef.value?.validate?.();
87
+ };
88
+ defineExpose({
89
+ setErrors,
90
+ validate,
91
+ inputTextFieldRef
92
+ });
93
+ </script>
@@ -0,0 +1,33 @@
1
+ import type { InputTextFieldProps } from "./input-text-field.vue.js";
2
+ export interface InputProfileNameProps extends Omit<InputTextFieldProps, 'modelValue'> {
3
+ }
4
+ type __VLS_Props = InputProfileNameProps;
5
+ type __VLS_ModelProps = {
6
+ modelValue?: string;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare var __VLS_11: string, __VLS_12: any;
10
+ type __VLS_Slots = {} & {
11
+ [K in NonNullable<typeof __VLS_11>]?: (props: typeof __VLS_12) => any;
12
+ };
13
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
14
+ setErrors: (errMsg: string | string[]) => void;
15
+ validate: () => Promise<any>;
16
+ inputTextFieldRef: import("vue").Ref<any, any>;
17
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ "update:modelValue": (value: string | undefined) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
+ "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
21
+ }>, {
22
+ label: string;
23
+ id: string;
24
+ name: string;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };
@@ -49,8 +49,12 @@
49
49
  <div v-else class="flex flex-col gap-[16px]">
50
50
  <template v-if="step === 'profile-name'">
51
51
  <Form v-slot="{ meta }" class="flex flex-col gap-[16px]" @submit="saveProfileName">
52
- <InputTextField name="profileName" label="ชื่อโปรไฟล์" :placeholder="listMenu[0]?.value || '-'" full-width
53
- validate-on-input :rules="ruleProfileName" v-model="profileName" />
52
+ <InputProfileName
53
+ name="profileName"
54
+ label="ชื่อโปรไฟล์"
55
+ :placeholder="listMenu[0]?.value || '-'"
56
+ v-model="profileName"
57
+ />
54
58
  <Button type="submit" color="primary" full-width :disabled="!meta.valid || isLoading">
55
59
  <span v-if="isLoading">กำลังบันทึก...</span>
56
60
  <span v-else>บันทึก</span>
@@ -95,48 +99,6 @@ const profileName = ref();
95
99
  const profileCategory = ref();
96
100
  const profileCategoryItems = ref([]);
97
101
  const isLoading = ref(false);
98
- const isEmoji = (v) => {
99
- const emojiRegex = /[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]/gu;
100
- return emojiRegex.test(v);
101
- };
102
- const isMixedLanguages = (v) => {
103
- const isLatin = /[a-zA-Z]/.test(v);
104
- const isThai = /[\u0E00-\u0E7F]/.test(v);
105
- const isChinese = /[\u4E00-\u9FFF]/.test(v);
106
- const isJapanese = /[\u3040-\u309F\u30A0-\u30FF]/.test(v);
107
- const isKorean = /[\uAC00-\uD7AF]/.test(v);
108
- const isArabic = /[\u0600-\u06FF]/.test(v);
109
- const isRussian = /[\u0400-\u04FF]/.test(v);
110
- const languages = [
111
- isLatin,
112
- isThai,
113
- isChinese,
114
- isJapanese,
115
- isKorean,
116
- isArabic,
117
- isRussian
118
- ];
119
- const activeLanguages = languages.filter(Boolean).length;
120
- return activeLanguages > 1;
121
- };
122
- const isInvalidSymbols = (v) => {
123
- const validPattern = /^[a-zA-Z\u0E00-\u0E7F\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF\u0400-\u04FF\u0600-\u06FF.\s-]+$/;
124
- return !validPattern.test(v);
125
- };
126
- const ruleProfileName = (value) => {
127
- if (!value) return "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
128
- const v = value.trim();
129
- if (!v) return "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
130
- if (v.length < 4) return "\u0E01\u0E23\u0E2D\u0E01\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22 4 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23";
131
- if (v.length > 50) return "\u0E01\u0E23\u0E2D\u0E01\u0E44\u0E14\u0E49\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 50 \u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23";
132
- if (/\d/.test(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E2A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E43\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
133
- if (/\.{2,}/.test(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E2A\u0E48\u0E08\u0E38\u0E14 (.) \u0E15\u0E34\u0E14\u0E01\u0E31\u0E19";
134
- if (/\s{2,}/.test(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E40\u0E27\u0E49\u0E19\u0E27\u0E23\u0E23\u0E04\u0E15\u0E34\u0E14\u0E01\u0E31\u0E19";
135
- if (isEmoji(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E2A\u0E48 Emoji \u0E43\u0E19\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C";
136
- if (isMixedLanguages(v)) return "\u0E2B\u0E49\u0E32\u0E21\u0E43\u0E0A\u0E49\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23 2 \u0E20\u0E32\u0E29\u0E32\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E01\u0E31\u0E19";
137
- if (isInvalidSymbols(v)) return "\u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E40\u0E09\u0E1E\u0E32\u0E30\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23 \u0E08\u0E38\u0E14 (.) \u0E41\u0E25\u0E30\u0E02\u0E35\u0E14 (-)";
138
- return true;
139
- };
140
102
  const listMenu = ref([]);
141
103
  const isMenuClickable = (menu) => {
142
104
  if (menu.label === "\u0E40\u0E1A\u0E2A\u0E34\u0E04 ID") return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.248.0",
3
+ "version": "1.250.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",