pukaad-ui-lib 1.40.0 → 1.41.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.
Files changed (31) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/assets/json/address/Amphur.json +7346 -0
  3. package/dist/runtime/assets/json/address/Province.json +762 -0
  4. package/dist/runtime/assets/json/address/Tambon.json +64775 -0
  5. package/dist/runtime/assets/json/address/Zipcode.json +17208 -0
  6. package/dist/runtime/components/button.vue +1 -1
  7. package/dist/runtime/components/collapse/collapse.vue +1 -1
  8. package/dist/runtime/components/input/input-address.d.vue.ts +56 -1
  9. package/dist/runtime/components/input/input-address.vue +293 -74
  10. package/dist/runtime/components/input/input-address.vue.d.ts +56 -1
  11. package/dist/runtime/components/input/input-combobox.d.vue.ts +10 -2
  12. package/dist/runtime/components/input/input-combobox.vue +44 -31
  13. package/dist/runtime/components/input/input-combobox.vue.d.ts +10 -2
  14. package/dist/runtime/components/input/input-file.d.vue.ts +1 -1
  15. package/dist/runtime/components/input/input-file.vue.d.ts +1 -1
  16. package/dist/runtime/components/input/input-password.d.vue.ts +1 -1
  17. package/dist/runtime/components/input/input-password.vue.d.ts +1 -1
  18. package/dist/runtime/components/input/input-slider.d.vue.ts +1 -1
  19. package/dist/runtime/components/input/input-slider.vue.d.ts +1 -1
  20. package/dist/runtime/components/input/input-text-field.d.vue.ts +2 -0
  21. package/dist/runtime/components/input/input-text-field.vue +8 -2
  22. package/dist/runtime/components/input/input-text-field.vue.d.ts +2 -0
  23. package/dist/runtime/components/ui/native-select/NativeSelectOptGroup.d.vue.ts +2 -2
  24. package/dist/runtime/components/ui/native-select/NativeSelectOptGroup.vue.d.ts +2 -2
  25. package/dist/runtime/components/ui/native-select/NativeSelectOption.d.vue.ts +2 -2
  26. package/dist/runtime/components/ui/native-select/NativeSelectOption.vue.d.ts +2 -2
  27. package/dist/runtime/components/ui/tabs/TabsList.vue +6 -4
  28. package/dist/runtime/components/ui/tabs/TabsTrigger.vue +6 -4
  29. package/dist/runtime/composables/useThaiAddress.d.ts +45 -0
  30. package/dist/runtime/composables/useThaiAddress.js +81 -0
  31. package/package.json +1 -1
@@ -5,6 +5,7 @@
5
5
  ref="inputTextFieldRef"
6
6
  v-model="displayText"
7
7
  :name="props.name"
8
+ :label="props.label"
8
9
  :rules="computedRules"
9
10
  :required="props.required"
10
11
  :disabled-border="props.disabledBorder"
@@ -46,40 +47,42 @@
46
47
  </InputTextField>
47
48
  </ShadPopoverAnchor>
48
49
  <ShadPopoverContent @openAutoFocus.prevent>
49
- <ShadCommand>
50
- <ShadCommandInput />
51
- <ShadCommandList>
52
- <ShadCommandGroup v-if="options && options.length > 0">
53
- <slot name="options">
54
- <ShadCommandItem
55
- v-for="option in options"
56
- :key="option.value"
57
- :value="option.value"
58
- :disabled="isOptionDisabled(option.value)"
59
- :class="[
50
+ <slot name="popover-content" :close="() => popoverOpen = false">
51
+ <ShadCommand>
52
+ <ShadCommandInput />
53
+ <ShadCommandList>
54
+ <ShadCommandGroup v-if="options && options.length > 0">
55
+ <slot name="options">
56
+ <ShadCommandItem
57
+ v-for="option in options"
58
+ :key="option.value"
59
+ :value="option.value"
60
+ :disabled="isOptionDisabled(option.value)"
61
+ :class="[
60
62
  isOptionDisabled(option.value) && 'cursor-not-allowed'
61
63
  ]"
62
- @click="() => handleSelect(option.value)"
63
- >
64
- <ShadCheckbox
65
- v-if="props.multiple"
66
- :model-value="isSelected(option.value)"
67
- :disabled="isOptionDisabled(option.value)"
68
- class="mr-2 pointer-events-none"
69
- />
64
+ @click="() => handleSelect(option.value)"
65
+ >
66
+ <ShadCheckbox
67
+ v-if="props.multiple"
68
+ :model-value="isSelected(option.value)"
69
+ :disabled="isOptionDisabled(option.value)"
70
+ class="mr-2 pointer-events-none"
71
+ />
70
72
 
71
- {{ option.label }}
72
- <Icon
73
- v-if="!props.multiple && isSelected(option.value)"
74
- name="lucide:check"
75
- class="ml-auto h-4 w-4"
76
- />
77
- </ShadCommandItem>
78
- </slot>
79
- </ShadCommandGroup>
80
- <ShadCommandEmpty :force-show="!options || options.length === 0" />
81
- </ShadCommandList>
82
- </ShadCommand>
73
+ {{ option.label }}
74
+ <Icon
75
+ v-if="!props.multiple && isSelected(option.value)"
76
+ name="lucide:check"
77
+ class="ml-auto h-4 w-4"
78
+ />
79
+ </ShadCommandItem>
80
+ </slot>
81
+ </ShadCommandGroup>
82
+ <ShadCommandEmpty :force-show="!options || options.length === 0" />
83
+ </ShadCommandList>
84
+ </ShadCommand>
85
+ </slot>
83
86
  </ShadPopoverContent>
84
87
  </ShadPopover>
85
88
  </template>
@@ -98,6 +101,7 @@ const props = defineProps({
98
101
  options: { type: Array, required: false },
99
102
  multiple: { type: Boolean, required: false, default: false }
100
103
  });
104
+ const emits = defineEmits(["clear"]);
101
105
  const modelValue = defineModel({ type: [String, Array], ...{
102
106
  default: () => ""
103
107
  } });
@@ -105,6 +109,10 @@ const popoverOpen = ref(false);
105
109
  const inputTextFieldRef = ref();
106
110
  const displayText = ref("");
107
111
  const updateDisplayText = () => {
112
+ if (!props.options || props.options.length === 0) {
113
+ displayText.value = props.multiple ? modelValue.value.join(", ") : modelValue.value || "";
114
+ return;
115
+ }
108
116
  if (props.multiple) {
109
117
  const selectedValues = modelValue.value;
110
118
  if (!selectedValues || selectedValues.length === 0) {
@@ -170,6 +178,7 @@ const handleIconClick = () => {
170
178
  modelValue.value = "";
171
179
  }
172
180
  displayText.value = "";
181
+ emits("clear");
173
182
  }
174
183
  popoverOpen.value = true;
175
184
  };
@@ -209,8 +218,12 @@ const handleSelect = (value) => {
209
218
  const setErrors = (errMsg) => {
210
219
  inputTextFieldRef.value?.setErrors(errMsg);
211
220
  };
221
+ const validate = async () => {
222
+ return await inputTextFieldRef.value?.validate?.();
223
+ };
212
224
  defineExpose({
213
225
  setErrors,
226
+ validate,
214
227
  inputTextFieldRef
215
228
  });
216
229
  </script>
@@ -19,18 +19,26 @@ type __VLS_ModelProps = {
19
19
  modelValue?: string | string[];
20
20
  };
21
21
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
22
- declare var __VLS_25: {}, __VLS_67: {};
22
+ declare var __VLS_25: {}, __VLS_44: {
23
+ close: () => boolean;
24
+ }, __VLS_69: {};
23
25
  type __VLS_Slots = {} & {
24
26
  label?: (props: typeof __VLS_25) => any;
25
27
  } & {
26
- options?: (props: typeof __VLS_67) => any;
28
+ 'popover-content'?: (props: typeof __VLS_44) => any;
29
+ } & {
30
+ options?: (props: typeof __VLS_69) => any;
27
31
  };
28
32
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
29
33
  setErrors: (errMsg: string[]) => void;
34
+ validate: () => Promise<any>;
30
35
  inputTextFieldRef: import("vue").Ref<any, any>;
31
36
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
37
  "update:modelValue": (value: string | string[]) => any;
38
+ } & {
39
+ clear: () => any;
33
40
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
41
+ onClear?: (() => any) | undefined;
34
42
  "onUpdate:modelValue"?: ((value: string | string[]) => any) | undefined;
35
43
  }>, {
36
44
  name: string;
@@ -27,8 +27,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
27
27
  label: string;
28
28
  name: string;
29
29
  limit: number;
30
- disabledErrorMessage: boolean;
31
30
  accept: string;
31
+ disabledErrorMessage: boolean;
32
32
  labelIcon: string;
33
33
  disabledDrop: boolean;
34
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -27,8 +27,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
27
27
  label: string;
28
28
  name: string;
29
29
  limit: number;
30
- disabledErrorMessage: boolean;
31
30
  accept: string;
31
+ disabledErrorMessage: boolean;
32
32
  labelIcon: string;
33
33
  disabledDrop: boolean;
34
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -18,8 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
18
18
  }>, {
19
19
  id: string;
20
20
  name: string;
21
- new: boolean;
22
21
  disabledForgotPassword: boolean;
22
+ new: boolean;
23
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const _default: typeof __VLS_export;
25
25
  export default _default;
@@ -18,8 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
18
18
  }>, {
19
19
  id: string;
20
20
  name: string;
21
- new: boolean;
22
21
  disabledForgotPassword: boolean;
22
+ new: boolean;
23
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const _default: typeof __VLS_export;
25
25
  export default _default;
@@ -12,9 +12,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
12
12
  color: InputSliderColor;
13
13
  fullWidth: boolean;
14
14
  label: string;
15
+ step: number;
15
16
  max: number;
16
17
  min: number;
17
- step: number;
18
18
  lineHeight: number | string;
19
19
  appearance: boolean;
20
20
  thumbSize: number | string;
@@ -12,9 +12,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
12
12
  color: InputSliderColor;
13
13
  fullWidth: boolean;
14
14
  label: string;
15
+ step: number;
15
16
  max: number;
16
17
  min: number;
17
- step: number;
18
18
  lineHeight: number | string;
19
19
  appearance: boolean;
20
20
  thumbSize: number | string;
@@ -33,6 +33,8 @@ type __VLS_Slots = {} & {
33
33
  };
34
34
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
35
35
  setErrors: (errMsg: string[]) => void;
36
+ validate: () => Promise<any>;
37
+ fieldRef: import("vue").Ref<any, any>;
36
38
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
37
39
  "update:modelValue": (value: string) => any;
38
40
  } & {
@@ -34,7 +34,8 @@
34
34
 
35
35
  <ShadInputGroup
36
36
  :class="[
37
- props.disabledBorder && 'border-0 ring-0 focus-within:border-0 focus-within:ring-0'
37
+ 'bg-white',
38
+ props.disabledBorder && 'border-0 ring-0 focus-within:border-0 focus-within:ring-0 '
38
39
  ]"
39
40
  >
40
41
  <ShadFormControl>
@@ -129,7 +130,12 @@ const defaultRules = (v) => {
129
130
  const setErrors = (errMsg) => {
130
131
  fieldRef.value?.setErrors(errMsg);
131
132
  };
133
+ const validate = async () => {
134
+ return await fieldRef.value?.validate?.();
135
+ };
132
136
  defineExpose({
133
- setErrors
137
+ setErrors,
138
+ validate,
139
+ fieldRef
134
140
  });
135
141
  </script>
@@ -33,6 +33,8 @@ type __VLS_Slots = {} & {
33
33
  };
34
34
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
35
35
  setErrors: (errMsg: string[]) => void;
36
+ validate: () => Promise<any>;
37
+ fieldRef: import("vue").Ref<any, any>;
36
38
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
37
39
  "update:modelValue": (value: string) => any;
38
40
  } & {
@@ -59,7 +59,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
59
59
  'aria-colindex'?: (string | number) | undefined;
60
60
  'aria-colspan'?: (string | number) | undefined;
61
61
  'aria-controls'?: string | undefined | undefined;
62
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
62
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
63
63
  'aria-describedby'?: string | undefined | undefined;
64
64
  'aria-details'?: string | undefined | undefined;
65
65
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -253,7 +253,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
253
253
  'aria-colindex'?: (string | number) | undefined;
254
254
  'aria-colspan'?: (string | number) | undefined;
255
255
  'aria-controls'?: string | undefined | undefined;
256
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
256
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
257
257
  'aria-describedby'?: string | undefined | undefined;
258
258
  'aria-details'?: string | undefined | undefined;
259
259
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -59,7 +59,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
59
59
  'aria-colindex'?: (string | number) | undefined;
60
60
  'aria-colspan'?: (string | number) | undefined;
61
61
  'aria-controls'?: string | undefined | undefined;
62
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
62
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
63
63
  'aria-describedby'?: string | undefined | undefined;
64
64
  'aria-details'?: string | undefined | undefined;
65
65
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -253,7 +253,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
253
253
  'aria-colindex'?: (string | number) | undefined;
254
254
  'aria-colspan'?: (string | number) | undefined;
255
255
  'aria-controls'?: string | undefined | undefined;
256
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
256
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
257
257
  'aria-describedby'?: string | undefined | undefined;
258
258
  'aria-details'?: string | undefined | undefined;
259
259
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -61,7 +61,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
61
61
  'aria-colindex'?: (string | number) | undefined;
62
62
  'aria-colspan'?: (string | number) | undefined;
63
63
  'aria-controls'?: string | undefined | undefined;
64
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
64
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
65
65
  'aria-describedby'?: string | undefined | undefined;
66
66
  'aria-details'?: string | undefined | undefined;
67
67
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -257,7 +257,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
257
257
  'aria-colindex'?: (string | number) | undefined;
258
258
  'aria-colspan'?: (string | number) | undefined;
259
259
  'aria-controls'?: string | undefined | undefined;
260
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
260
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
261
261
  'aria-describedby'?: string | undefined | undefined;
262
262
  'aria-details'?: string | undefined | undefined;
263
263
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -61,7 +61,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
61
61
  'aria-colindex'?: (string | number) | undefined;
62
62
  'aria-colspan'?: (string | number) | undefined;
63
63
  'aria-controls'?: string | undefined | undefined;
64
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
64
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
65
65
  'aria-describedby'?: string | undefined | undefined;
66
66
  'aria-details'?: string | undefined | undefined;
67
67
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -257,7 +257,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
257
257
  'aria-colindex'?: (string | number) | undefined;
258
258
  'aria-colspan'?: (string | number) | undefined;
259
259
  'aria-controls'?: string | undefined | undefined;
260
- 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
260
+ 'aria-current'?: "time" | "page" | (boolean | "true" | "false") | "date" | "step" | "location" | undefined;
261
261
  'aria-describedby'?: string | undefined | undefined;
262
262
  'aria-details'?: string | undefined | undefined;
263
263
  'aria-disabled'?: (boolean | "true" | "false") | undefined;
@@ -15,10 +15,12 @@ const delegatedProps = reactiveOmit(props, "class");
15
15
  <TabsList
16
16
  data-slot="tabs-list"
17
17
  v-bind="delegatedProps"
18
- :class="cn(
19
- 'bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]',
20
- props.class
21
- )"
18
+ :class="
19
+ cn(
20
+ 'bg-muted text-body-medium dark:text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]',
21
+ props.class
22
+ )
23
+ "
22
24
  >
23
25
  <slot />
24
26
  </TabsList>
@@ -16,10 +16,12 @@ const forwardedProps = useForwardProps(delegatedProps);
16
16
  <template>
17
17
  <TabsTrigger
18
18
  data-slot="tabs-trigger"
19
- :class="cn(
20
- 'data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
21
- props.class
22
- )"
19
+ :class="
20
+ cn(
21
+ 'data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-body-medi dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=inactive]:text-gray [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
22
+ props.class
23
+ )
24
+ "
23
25
  v-bind="forwardedProps"
24
26
  >
25
27
  <slot />
@@ -0,0 +1,45 @@
1
+ export interface Province {
2
+ id: number;
3
+ name_th: string;
4
+ name_en: string;
5
+ [key: string]: any;
6
+ }
7
+ export interface Amphur {
8
+ id: number;
9
+ name_th: string;
10
+ name_en: string;
11
+ province_id: number;
12
+ [key: string]: any;
13
+ }
14
+ export interface Tambon {
15
+ id: number;
16
+ name_th: string;
17
+ name_en: string;
18
+ amphur_id: number;
19
+ zipcode_code: number;
20
+ [key: string]: any;
21
+ }
22
+ export interface Zipcode {
23
+ code: number;
24
+ amphur_ids: number[];
25
+ tambon_ids: number[];
26
+ [key: string]: any;
27
+ }
28
+ export interface SearchResult {
29
+ type: 'province' | 'amphur' | 'tambon';
30
+ id: number;
31
+ name_th: string;
32
+ name_en: string;
33
+ parentId?: number;
34
+ label: string;
35
+ }
36
+ export declare function useThaiAddress(): {
37
+ getProvinces: () => Province[];
38
+ getProvinceById: (id: number) => Province | undefined;
39
+ getAmphursByProvinceId: (provinceId: number) => Amphur[];
40
+ getAmphurById: (id: number) => Amphur | undefined;
41
+ getTambonsByAmphurId: (amphurId: number) => Tambon[];
42
+ getTambonById: (id: number) => Tambon | undefined;
43
+ getZipcodeByTambonId: (tambonId: number) => string | undefined;
44
+ searchAddress: (query: string) => SearchResult[];
45
+ };
@@ -0,0 +1,81 @@
1
+ import provincesData from "@/runtime/assets/json/address/Province.json";
2
+ import amphursData from "@/runtime/assets/json/address/Amphur.json";
3
+ import tambonsData from "@/runtime/assets/json/address/Tambon.json";
4
+ export function useThaiAddress() {
5
+ const getProvinces = () => {
6
+ return provincesData;
7
+ };
8
+ const getProvinceById = (id) => {
9
+ return provincesData.find((p) => p.id === id);
10
+ };
11
+ const getAmphursByProvinceId = (provinceId) => {
12
+ return amphursData.filter((a) => a.province_id === provinceId);
13
+ };
14
+ const getAmphurById = (id) => {
15
+ return amphursData.find((a) => a.id === id);
16
+ };
17
+ const getTambonsByAmphurId = (amphurId) => {
18
+ return tambonsData.filter((t) => t.amphur_id === amphurId);
19
+ };
20
+ const getTambonById = (id) => {
21
+ return tambonsData.find((t) => t.id === id);
22
+ };
23
+ const getZipcodeByTambonId = (tambonId) => {
24
+ const tambon = getTambonById(tambonId);
25
+ return tambon?.zipcode_code?.toString();
26
+ };
27
+ const searchAddress = (query) => {
28
+ if (!query || query.length < 2) return [];
29
+ const lowerQuery = query.toLowerCase();
30
+ const results = [];
31
+ provincesData.forEach((p) => {
32
+ if (p.name_th.includes(query) || p.name_en.toLowerCase().includes(lowerQuery)) {
33
+ results.push({
34
+ type: "province",
35
+ id: p.id,
36
+ name_th: p.name_th,
37
+ name_en: p.name_en,
38
+ label: `\u0E08\u0E31\u0E07\u0E2B\u0E27\u0E31\u0E14${p.name_th} (${p.name_en})`
39
+ });
40
+ }
41
+ });
42
+ amphursData.forEach((a) => {
43
+ if (a.name_th.includes(query) || a.name_en.toLowerCase().includes(lowerQuery)) {
44
+ const province = getProvinceById(a.province_id);
45
+ results.push({
46
+ type: "amphur",
47
+ id: a.id,
48
+ name_th: a.name_th,
49
+ name_en: a.name_en,
50
+ parentId: a.province_id,
51
+ label: `\u0E2D\u0E33\u0E40\u0E20\u0E2D${a.name_th} (${a.name_en}) - ${province?.name_th}`
52
+ });
53
+ }
54
+ });
55
+ tambonsData.forEach((t) => {
56
+ if (t.name_th.includes(query) || t.name_en.toLowerCase().includes(lowerQuery)) {
57
+ const amphur = getAmphurById(t.amphur_id);
58
+ const province = amphur ? getProvinceById(amphur.province_id) : null;
59
+ results.push({
60
+ type: "tambon",
61
+ id: t.id,
62
+ name_th: t.name_th,
63
+ name_en: t.name_en,
64
+ parentId: t.amphur_id,
65
+ label: `\u0E15\u0E33\u0E1A\u0E25${t.name_th} (${t.name_en}) - ${amphur?.name_th} - ${province?.name_th}`
66
+ });
67
+ }
68
+ });
69
+ return results;
70
+ };
71
+ return {
72
+ getProvinces,
73
+ getProvinceById,
74
+ getAmphursByProvinceId,
75
+ getAmphurById,
76
+ getTambonsByAmphurId,
77
+ getTambonById,
78
+ getZipcodeByTambonId,
79
+ searchAddress
80
+ };
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",