pukaad-ui-lib 1.271.1 → 1.271.3

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 (24) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/card/card-review.d.vue.ts +1 -1
  3. package/dist/runtime/components/card/card-review.vue.d.ts +1 -1
  4. package/dist/runtime/components/display/display-image-place.d.vue.ts +1 -1
  5. package/dist/runtime/components/display/display-image-place.vue.d.ts +1 -1
  6. package/dist/runtime/components/input/input-autocomplete.d.vue.ts +1 -1
  7. package/dist/runtime/components/input/input-autocomplete.vue.d.ts +1 -1
  8. package/dist/runtime/components/input/input-content.d.vue.ts +1 -1
  9. package/dist/runtime/components/input/input-content.vue.d.ts +1 -1
  10. package/dist/runtime/components/input/input-file.d.vue.ts +1 -1
  11. package/dist/runtime/components/input/input-file.vue.d.ts +1 -1
  12. package/dist/runtime/components/input/input-tag.d.vue.ts +2 -2
  13. package/dist/runtime/components/input/input-tag.vue.d.ts +2 -2
  14. package/dist/runtime/components/input/input-text-field.d.vue.ts +1 -1
  15. package/dist/runtime/components/input/input-text-field.vue.d.ts +1 -1
  16. package/dist/runtime/components/input/input-textarea.d.vue.ts +1 -1
  17. package/dist/runtime/components/input/input-textarea.vue.d.ts +1 -1
  18. package/dist/runtime/components/modal/modal-review-detail.d.vue.ts +1 -1
  19. package/dist/runtime/components/modal/modal-review-detail.vue.d.ts +1 -1
  20. package/dist/runtime/components/picker/picker-option-menu/picker-option-menu-user.d.vue.ts +2 -2
  21. package/dist/runtime/components/picker/picker-option-menu/picker-option-menu-user.vue.d.ts +2 -2
  22. package/dist/runtime/composables/useApi.js +73 -3
  23. package/dist/runtime/composables/useThaiAddress.js +6 -6
  24. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.271.1",
4
+ "version": "1.271.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -13,8 +13,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
13
13
  "onSelect-image"?: ((item: CardReviewProps, index: number, liked: boolean) => any) | undefined;
14
14
  }>, {
15
15
  item: CardReviewProps;
16
- disabledMenu: boolean;
17
16
  isProfile: boolean;
17
+ disabledMenu: boolean;
18
18
  disabledLike: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
@@ -13,8 +13,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
13
13
  "onSelect-image"?: ((item: CardReviewProps, index: number, liked: boolean) => any) | undefined;
14
14
  }>, {
15
15
  item: CardReviewProps;
16
- disabledMenu: boolean;
17
16
  isProfile: boolean;
17
+ disabledMenu: boolean;
18
18
  disabledLike: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
@@ -9,8 +9,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
9
9
  title: string;
10
10
  variant: "featured" | "album";
11
11
  photos: string[];
12
- state: "personal" | "office" | "business";
13
12
  videos: string[];
13
+ state: "personal" | "office" | "business";
14
14
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
15
  declare const _default: typeof __VLS_export;
16
16
  export default _default;
@@ -9,8 +9,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
9
9
  title: string;
10
10
  variant: "featured" | "album";
11
11
  photos: string[];
12
- state: "personal" | "office" | "business";
13
12
  videos: string[];
13
+ state: "personal" | "office" | "business";
14
14
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
15
  declare const _default: typeof __VLS_export;
16
16
  export default _default;
@@ -48,13 +48,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
48
48
  pageSize: number;
49
49
  id: string;
50
50
  name: string;
51
+ limit: number;
51
52
  options: AutocompleteOption[] | string[] | number[];
52
53
  description: string;
53
54
  placeholder: string;
54
55
  disabledErrorMessage: boolean;
55
56
  disabledBorder: boolean;
56
57
  showCounter: boolean;
57
- limit: number;
58
58
  returnObject: boolean;
59
59
  freeText: boolean;
60
60
  valueKey: string;
@@ -48,13 +48,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
48
48
  pageSize: number;
49
49
  id: string;
50
50
  name: string;
51
+ limit: number;
51
52
  options: AutocompleteOption[] | string[] | number[];
52
53
  description: string;
53
54
  placeholder: string;
54
55
  disabledErrorMessage: boolean;
55
56
  disabledBorder: boolean;
56
57
  showCounter: boolean;
57
- limit: number;
58
58
  returnObject: boolean;
59
59
  freeText: boolean;
60
60
  valueKey: string;
@@ -32,8 +32,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
32
32
  required: boolean;
33
33
  id: string;
34
34
  name: string;
35
- disableMedia: boolean;
36
35
  state: "personal" | "business";
36
+ disableMedia: boolean;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
39
39
  declare const _default: typeof __VLS_export;
@@ -32,8 +32,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
32
32
  required: boolean;
33
33
  id: string;
34
34
  name: string;
35
- disableMedia: boolean;
36
35
  state: "personal" | "business";
36
+ disableMedia: boolean;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
39
39
  declare const _default: typeof __VLS_export;
@@ -34,8 +34,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
34
34
  fullWidth: boolean;
35
35
  fullHeight: boolean;
36
36
  name: string;
37
- disabledErrorMessage: boolean;
38
37
  limit: number;
38
+ disabledErrorMessage: boolean;
39
39
  accept: string;
40
40
  labelIcon: string;
41
41
  disabledDrop: boolean;
@@ -34,8 +34,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
34
34
  fullWidth: boolean;
35
35
  fullHeight: boolean;
36
36
  name: string;
37
- disabledErrorMessage: boolean;
38
37
  limit: number;
38
+ disabledErrorMessage: boolean;
39
39
  accept: string;
40
40
  labelIcon: string;
41
41
  disabledDrop: boolean;
@@ -25,9 +25,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
25
25
  "onUpdate:modelValue"?: ((value: SelectedTag[]) => any) | undefined;
26
26
  }>, {
27
27
  name: string;
28
- placeholder: string;
29
- limit: number;
30
28
  state: "user" | "admin";
29
+ limit: number;
30
+ placeholder: string;
31
31
  ignore: string[];
32
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
33
  declare const _default: typeof __VLS_export;
@@ -25,9 +25,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
25
25
  "onUpdate:modelValue"?: ((value: SelectedTag[]) => any) | undefined;
26
26
  }>, {
27
27
  name: string;
28
- placeholder: string;
29
- limit: number;
30
28
  state: "user" | "admin";
29
+ limit: number;
30
+ placeholder: string;
31
31
  ignore: string[];
32
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
33
  declare const _default: typeof __VLS_export;
@@ -59,10 +59,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
59
59
  required: boolean;
60
60
  id: string;
61
61
  name: string;
62
+ limit: number;
62
63
  disabledErrorMessage: boolean;
63
64
  disabledBorder: boolean;
64
65
  showCounter: boolean;
65
- limit: number;
66
66
  readonly: boolean;
67
67
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
68
68
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -59,10 +59,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
59
59
  required: boolean;
60
60
  id: string;
61
61
  name: string;
62
+ limit: number;
62
63
  disabledErrorMessage: boolean;
63
64
  disabledBorder: boolean;
64
65
  showCounter: boolean;
65
- limit: number;
66
66
  readonly: boolean;
67
67
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
68
68
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -46,10 +46,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
46
46
  id: string;
47
47
  name: string;
48
48
  resize: "none" | "both" | "horizontal" | "vertical";
49
+ limit: number;
49
50
  disabledErrorMessage: boolean;
50
51
  disabledBorder: boolean;
51
52
  showCounter: boolean;
52
- limit: number;
53
53
  readonly: boolean;
54
54
  rows: number;
55
55
  heightScroll: boolean;
@@ -46,10 +46,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
46
46
  id: string;
47
47
  name: string;
48
48
  resize: "none" | "both" | "horizontal" | "vertical";
49
+ limit: number;
49
50
  disabledErrorMessage: boolean;
50
51
  disabledBorder: boolean;
51
52
  showCounter: boolean;
52
- limit: number;
53
53
  readonly: boolean;
54
54
  rows: number;
55
55
  heightScroll: boolean;
@@ -14,8 +14,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
14
14
  title: string;
15
15
  items: string[];
16
16
  selectIndex: number;
17
- isProfile: boolean;
18
17
  review: import("../../../types/components/card/card-review.js").CardReviewProps;
18
+ isProfile: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
21
21
  export default _default;
@@ -14,8 +14,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
14
14
  title: string;
15
15
  items: string[];
16
16
  selectIndex: number;
17
- isProfile: boolean;
18
17
  review: import("../../../types/components/card/card-review.js").CardReviewProps;
18
+ isProfile: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
21
21
  export default _default;
@@ -1,11 +1,11 @@
1
1
  import type { PickerOptionMenuUserProps } from "#pukaad-ui/types/components/picker/picker-option-menu/picker-option-menu-user";
2
2
  declare const __VLS_export: import("vue").DefineComponent<PickerOptionMenuUserProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "profile-name-updated": (name: string) => any;
3
4
  "blog-edit": () => any;
4
5
  "report-announce": () => any;
5
6
  "blog-unpin": () => any;
6
7
  "blog-pin": () => any;
7
8
  "blog-delete": () => any;
8
- "profile-name-updated": (name: string) => any;
9
9
  "profile-edit": () => any;
10
10
  "profile-share": () => any;
11
11
  "profile-follower-delete": () => any;
@@ -19,12 +19,12 @@ declare const __VLS_export: import("vue").DefineComponent<PickerOptionMenuUserPr
19
19
  "review-delete": () => any;
20
20
  archive: () => any;
21
21
  }, string, import("vue").PublicProps, Readonly<PickerOptionMenuUserProps> & Readonly<{
22
+ "onProfile-name-updated"?: ((name: string) => any) | undefined;
22
23
  "onBlog-edit"?: (() => any) | undefined;
23
24
  "onReport-announce"?: (() => any) | undefined;
24
25
  "onBlog-unpin"?: (() => any) | undefined;
25
26
  "onBlog-pin"?: (() => any) | undefined;
26
27
  "onBlog-delete"?: (() => any) | undefined;
27
- "onProfile-name-updated"?: ((name: string) => any) | undefined;
28
28
  "onProfile-edit"?: (() => any) | undefined;
29
29
  "onProfile-share"?: (() => any) | undefined;
30
30
  "onProfile-follower-delete"?: (() => any) | undefined;
@@ -1,11 +1,11 @@
1
1
  import type { PickerOptionMenuUserProps } from "#pukaad-ui/types/components/picker/picker-option-menu/picker-option-menu-user";
2
2
  declare const __VLS_export: import("vue").DefineComponent<PickerOptionMenuUserProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "profile-name-updated": (name: string) => any;
3
4
  "blog-edit": () => any;
4
5
  "report-announce": () => any;
5
6
  "blog-unpin": () => any;
6
7
  "blog-pin": () => any;
7
8
  "blog-delete": () => any;
8
- "profile-name-updated": (name: string) => any;
9
9
  "profile-edit": () => any;
10
10
  "profile-share": () => any;
11
11
  "profile-follower-delete": () => any;
@@ -19,12 +19,12 @@ declare const __VLS_export: import("vue").DefineComponent<PickerOptionMenuUserPr
19
19
  "review-delete": () => any;
20
20
  archive: () => any;
21
21
  }, string, import("vue").PublicProps, Readonly<PickerOptionMenuUserProps> & Readonly<{
22
+ "onProfile-name-updated"?: ((name: string) => any) | undefined;
22
23
  "onBlog-edit"?: (() => any) | undefined;
23
24
  "onReport-announce"?: (() => any) | undefined;
24
25
  "onBlog-unpin"?: (() => any) | undefined;
25
26
  "onBlog-pin"?: (() => any) | undefined;
26
27
  "onBlog-delete"?: (() => any) | undefined;
27
- "onProfile-name-updated"?: ((name: string) => any) | undefined;
28
28
  "onProfile-edit"?: (() => any) | undefined;
29
29
  "onProfile-share"?: (() => any) | undefined;
30
30
  "onProfile-follower-delete"?: (() => any) | undefined;
@@ -1,8 +1,73 @@
1
- import { useRuntimeConfig, useCookie } from "nuxt/app";
1
+ import { useRuntimeConfig, useCookie, useRequestURL, useState } from "nuxt/app";
2
2
  import { $fetch } from "ofetch";
3
+ const provinceIdByHostCache = /* @__PURE__ */ new Map();
4
+ const provinceIdByHostPromise = /* @__PURE__ */ new Map();
5
+ const normalizeDomain = (value) => {
6
+ const input = value.trim().toLowerCase();
7
+ if (!input) return "";
8
+ try {
9
+ return new URL(input.includes("://") ? input : `https://${input}`).hostname;
10
+ } catch {
11
+ return input.split("/")[0]?.split(":")[0] || "";
12
+ }
13
+ };
14
+ const getCurrentHost = () => {
15
+ if (typeof window !== "undefined") {
16
+ return normalizeDomain(window.location.hostname);
17
+ }
18
+ try {
19
+ return normalizeDomain(useRequestURL().hostname);
20
+ } catch {
21
+ return "";
22
+ }
23
+ };
24
+ const resolveProvinceIdByHost = async (host, baseURL) => {
25
+ if (!host) return null;
26
+ if (provinceIdByHostCache.has(host)) {
27
+ return provinceIdByHostCache.get(host) ?? null;
28
+ }
29
+ const activePromise = provinceIdByHostPromise.get(host);
30
+ if (activePromise) return activePromise;
31
+ const promise = (async () => {
32
+ const response = await $fetch("/master/address/provinces", {
33
+ baseURL,
34
+ query: { page_size: 100 }
35
+ });
36
+ const provinces = response.data ?? [];
37
+ const province = provinces.find((item) => {
38
+ return normalizeDomain(String(item.domain || "")) === host;
39
+ });
40
+ const provinceId = province?.id ? String(province.id) : null;
41
+ provinceIdByHostCache.set(host, provinceId);
42
+ return provinceId;
43
+ })();
44
+ provinceIdByHostPromise.set(host, promise);
45
+ try {
46
+ return await promise;
47
+ } catch {
48
+ provinceIdByHostCache.set(host, null);
49
+ return null;
50
+ } finally {
51
+ provinceIdByHostPromise.delete(host);
52
+ }
53
+ };
54
+ const resolveProvinceId = async (provinceIdState, host, baseURL, configProvinceId) => {
55
+ if (provinceIdState.value) {
56
+ return String(provinceIdState.value);
57
+ }
58
+ const provinceIdByHost = await resolveProvinceIdByHost(host, baseURL);
59
+ if (provinceIdByHost) {
60
+ provinceIdState.value = provinceIdByHost;
61
+ return provinceIdByHost;
62
+ }
63
+ return configProvinceId ? String(configProvinceId) : "";
64
+ };
3
65
  export const useApi = () => {
4
66
  const config = useRuntimeConfig();
5
67
  const baseURL = config.public.BASE_URL_API;
68
+ const provinceIdState = useState("pukaad:province-id", () => null);
69
+ const currentHost = getCurrentHost();
70
+ const configProvinceId = config.public.APP_PROVINCE_ID;
6
71
  const { APP_TYPE } = config.public;
7
72
  const secId = useCookie(
8
73
  APP_TYPE === "OFFICE" ? "OFFICE_SEC_ID" : "SEC_ID"
@@ -13,13 +78,18 @@ export const useApi = () => {
13
78
  Accept: "application/json"
14
79
  },
15
80
  // Interceptors
16
- onRequest({ request, options }) {
81
+ async onRequest({ options }) {
17
82
  const headers = new Headers(options.headers);
18
83
  const token = secId.value;
19
84
  if (token) {
20
85
  headers.set("Authorization", `Bearer ${token}`);
21
86
  }
22
- const provinceId = config.public.APP_PROVINCE_ID;
87
+ const provinceId = await resolveProvinceId(
88
+ provinceIdState,
89
+ currentHost,
90
+ baseURL,
91
+ configProvinceId
92
+ );
23
93
  if (provinceId) {
24
94
  headers.set("X-Province-ID", provinceId);
25
95
  }
@@ -11,19 +11,19 @@ const fetchList = async (path, query = {}) => {
11
11
  };
12
12
  const loadProvincesData = async () => {
13
13
  if (!provincesCache) {
14
- provincesCache = await fetchList("/api/master/address/provinces");
14
+ provincesCache = await fetchList("/master/address/provinces");
15
15
  }
16
16
  return provincesCache;
17
17
  };
18
18
  const loadAmphursByProvinceData = async (provinceId) => {
19
19
  if (amphursByProvinceCache.has(provinceId)) return amphursByProvinceCache.get(provinceId);
20
- const data = await fetchList("/api/master/address/amphurs", { province_id: provinceId });
20
+ const data = await fetchList("/master/address/amphurs", { province_id: provinceId });
21
21
  amphursByProvinceCache.set(provinceId, data);
22
22
  return data;
23
23
  };
24
24
  const loadTambonsByAmphurData = async (amphurId) => {
25
25
  if (tambonsByAmphurCache.has(amphurId)) return tambonsByAmphurCache.get(amphurId);
26
- const data = await fetchList("/api/master/address/tambons", { amphur_id: amphurId });
26
+ const data = await fetchList("/master/address/tambons", { amphur_id: amphurId });
27
27
  tambonsByAmphurCache.set(amphurId, data);
28
28
  return data;
29
29
  };
@@ -61,9 +61,9 @@ export function useThaiAddress() {
61
61
  const searchAddress = async (query) => {
62
62
  if (!query || query.length < 2) return [];
63
63
  const [provinces, amphurs, tambons] = await Promise.all([
64
- fetchList("/api/master/address/provinces", { q: query }),
65
- fetchList("/api/master/address/amphurs", { q: query }),
66
- fetchList("/api/master/address/tambons", { q: query })
64
+ fetchList("/master/address/provinces", { q: query }),
65
+ fetchList("/master/address/amphurs", { q: query }),
66
+ fetchList("/master/address/tambons", { q: query })
67
67
  ]);
68
68
  const results = [];
69
69
  const allProvinces = await loadProvincesData();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.271.1",
3
+ "version": "1.271.3",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",