@unsource/ui 2.8.7 → 2.8.10

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 (62) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +24 -9
  3. package/dist/runtime/assets/main.css +1 -1
  4. package/dist/runtime/components/UnAuth.d.vue.ts +2 -2
  5. package/dist/runtime/components/UnAuth.vue +2 -2
  6. package/dist/runtime/components/UnAuth.vue.d.ts +2 -2
  7. package/dist/runtime/components/UnCard.d.vue.ts +16 -14
  8. package/dist/runtime/components/UnCard.vue +26 -2
  9. package/dist/runtime/components/UnCard.vue.d.ts +16 -14
  10. package/dist/runtime/components/UnCheckboxItem.d.vue.ts +1 -5
  11. package/dist/runtime/components/UnCheckboxItem.vue +4 -5
  12. package/dist/runtime/components/UnCheckboxItem.vue.d.ts +1 -5
  13. package/dist/runtime/components/UnCollapsible.d.vue.ts +2 -2
  14. package/dist/runtime/components/UnCollapsible.vue.d.ts +2 -2
  15. package/dist/runtime/components/UnFormItem.vue +1 -1
  16. package/dist/runtime/components/UnIRDatePicker.d.vue.ts +1 -1
  17. package/dist/runtime/components/UnIRDatePicker.vue +1 -2
  18. package/dist/runtime/components/UnIRDatePicker.vue.d.ts +1 -1
  19. package/dist/runtime/components/UnLabel.d.vue.ts +13 -13
  20. package/dist/runtime/components/UnLabel.vue +5 -5
  21. package/dist/runtime/components/UnLabel.vue.d.ts +13 -13
  22. package/dist/runtime/components/UnMap.vue +1 -1
  23. package/dist/runtime/components/UnMobileHeader.vue +0 -1
  24. package/dist/runtime/components/UnModal.vue +1 -1
  25. package/dist/runtime/components/UnMultiUploader.vue +0 -1
  26. package/dist/runtime/components/UnNavbar.vue +1 -1
  27. package/dist/runtime/components/UnNormalInput.d.vue.ts +1 -21
  28. package/dist/runtime/components/UnNormalInput.vue.d.ts +1 -21
  29. package/dist/runtime/components/UnNumberInput.vue +0 -1
  30. package/dist/runtime/components/UnNuxtIcon.d.vue.ts +0 -1
  31. package/dist/runtime/components/UnNuxtIcon.vue +1 -3
  32. package/dist/runtime/components/UnNuxtIcon.vue.d.ts +0 -1
  33. package/dist/runtime/components/UnProfile.d.vue.ts +2 -2
  34. package/dist/runtime/components/UnProfile.vue.d.ts +2 -2
  35. package/dist/runtime/components/UnRadioItem.d.vue.ts +1 -0
  36. package/dist/runtime/components/UnRadioItem.vue +8 -7
  37. package/dist/runtime/components/UnRadioItem.vue.d.ts +1 -0
  38. package/dist/runtime/components/UnSelect.d.vue.ts +0 -2
  39. package/dist/runtime/components/UnSelect.vue +2 -4
  40. package/dist/runtime/components/UnSelect.vue.d.ts +0 -2
  41. package/dist/runtime/components/UnSwiperControl.vue +0 -4
  42. package/dist/runtime/components/UnSwiperSlider.d.vue.ts +2 -2
  43. package/dist/runtime/components/UnSwiperSlider.vue.d.ts +2 -2
  44. package/dist/runtime/components/UnTransaction.vue +1 -0
  45. package/dist/runtime/components/UnUploadFile.d.vue.ts +2 -2
  46. package/dist/runtime/components/UnUploadFile.vue +1 -1
  47. package/dist/runtime/components/UnUploadFile.vue.d.ts +2 -2
  48. package/dist/runtime/components/UnWallet.vue +1 -0
  49. package/dist/runtime/composables/fetch.d.ts +38 -17
  50. package/dist/runtime/composables/fetch.js +20 -11
  51. package/dist/runtime/composables/global.d.ts +26 -24
  52. package/dist/runtime/composables/global.js +15 -33
  53. package/dist/runtime/composables/reuseable.d.ts +3 -16
  54. package/dist/runtime/composables/reuseable.js +7 -24
  55. package/dist/runtime/composables/services.js +3 -2
  56. package/dist/runtime/plugins/floating.client.d.ts +3 -0
  57. package/dist/runtime/plugins/floating.client.js +6 -0
  58. package/dist/runtime/plugins/toast.client.d.ts +14 -14
  59. package/dist/runtime/types/models.d.ts +476 -402
  60. package/package.json +8 -7
  61. package/dist/runtime/uno.config.d.ts +0 -2
  62. package/dist/runtime/uno.config.js +0 -60
@@ -25,12 +25,10 @@
25
25
 
26
26
  <script setup>
27
27
  import { ref } from "#imports";
28
- const props = defineProps({
28
+ defineProps({
29
29
  name: { type: [String, null], required: false },
30
- iconType: { type: String, required: false },
31
30
  filled: { type: Boolean, required: false },
32
31
  alt: { type: String, required: false }
33
32
  });
34
- const iconType = props.iconType || "icon";
35
33
  const loaded = ref(true);
36
34
  </script>
@@ -1,6 +1,5 @@
1
1
  type __VLS_Props = {
2
2
  name?: string | null;
3
- iconType?: string;
4
3
  filled?: boolean;
5
4
  alt?: string;
6
5
  };
@@ -26,9 +26,9 @@ type __VLS_Props = {
26
26
  owner?: string;
27
27
  customClass?: ProfileCustomClass;
28
28
  };
29
- declare var __VLS_15: {};
29
+ declare var __VLS_16: {};
30
30
  type __VLS_Slots = {} & {
31
- default?: (props: typeof __VLS_15) => any;
31
+ default?: (props: typeof __VLS_16) => any;
32
32
  };
33
33
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -26,9 +26,9 @@ type __VLS_Props = {
26
26
  owner?: string;
27
27
  customClass?: ProfileCustomClass;
28
28
  };
29
- declare var __VLS_15: {};
29
+ declare var __VLS_16: {};
30
30
  type __VLS_Slots = {} & {
31
- default?: (props: typeof __VLS_15) => any;
31
+ default?: (props: typeof __VLS_16) => any;
32
32
  };
33
33
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -12,6 +12,7 @@ type __VLS_Props = {
12
12
  selected?: boolean;
13
13
  customClass?: RadioCustomClass;
14
14
  disabled?: boolean;
15
+ infoIcon?: string;
15
16
  };
16
17
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
18
  declare const _default: typeof __VLS_export;
@@ -1,38 +1,39 @@
1
1
  <template>
2
2
  <div
3
- class="select-none group px-4 py-3 flex flex-row items-center gap-3 transition duration-300 hover:bg-primary-500/10 border-0 min-w-fit"
3
+ class="relative select-none group px-4 py-3 flex flex-row items-center gap-3 transition duration-300 hover:bg-primary-500/10 border-0 min-w-fit"
4
4
  :class="{ 'opacity-50 grayscale': disabled, 'disable': disabled, 'selected': selected }"
5
5
  @click.prevent.stop="toggle"
6
6
  >
7
7
  <div
8
8
  name="radio"
9
- :class="[customClass.radio, customClass[selected ? 'selected' : 'notSelected']?.radio]"
9
+ :class="customClass.radio"
10
10
  class="group-[.disable]:border-secondary border-(1 solid primary) rounded-1/2 w-4 h-4 flex justify-center items-center"
11
11
  >
12
12
  <div
13
13
  name="radioInside"
14
14
  class="bg-primary-500 rounded-1/2 h-10px w-10px transition-opacity duration-200"
15
- :class="[customClass.radioInside, customClass[selected ? 'selected' : 'notSelected']?.radioInside, selected ? 'opacity-full' : 'opacity-0']"
15
+ :class="[customClass.radioInside, selected ? 'opacity-full' : 'opacity-0']"
16
16
  />
17
17
  </div>
18
18
  <UnCard
19
19
  :item="item"
20
20
  class="!bg-transparent grow-1"
21
- :class="[customClass.card, customClass[selected ? 'selected' : 'notSelected']?.card]"
22
- :custom-class="_mergeWith(customClass.item, customClass[selected ? 'selected' : 'notSelected']?.item, merge)"
21
+ :class="customClass.card"
22
+ :custom-class="customClass.item"
23
+ :info-icon="infoIcon"
23
24
  />
24
25
  </div>
25
26
  </template>
26
27
 
27
28
  <script setup>
28
- import { _mergeWith, merge } from "#imports";
29
29
  const emit = defineEmits(["input"]);
30
30
  const { customClass = {}, disabled } = defineProps({
31
31
  value: { type: null, required: true },
32
32
  item: { type: Object, required: true },
33
33
  selected: { type: Boolean, required: false },
34
34
  customClass: { type: Object, required: false },
35
- disabled: { type: Boolean, required: false }
35
+ disabled: { type: Boolean, required: false },
36
+ infoIcon: { type: String, required: false }
36
37
  });
37
38
  const toggle = () => {
38
39
  if (disabled) return;
@@ -12,6 +12,7 @@ type __VLS_Props = {
12
12
  selected?: boolean;
13
13
  customClass?: RadioCustomClass;
14
14
  disabled?: boolean;
15
+ infoIcon?: string;
15
16
  };
16
17
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
18
  declare const _default: typeof __VLS_export;
@@ -16,8 +16,6 @@ type __VLS_Props = {
16
16
  customClass?: Partial<Record<'header' | 'icon' | 'label' | 'arrowIcon' | 'wrapper' | 'innerWrapper' | 'search' | 'list' | 'radio' | 'checkbox' | 'checkboxButton', unknown>> & {
17
17
  radioItem?: RadioCustomClass;
18
18
  checkboxItem?: CheckboxCustomClass;
19
- selected: Partial<Record<'radio' | 'checkbox', string>>;
20
- notSelected: Partial<Record<'radio' | 'checkbox', string>>;
21
19
  };
22
20
  };
23
21
  type __VLS_ModelProps = {
@@ -73,7 +73,7 @@
73
73
  :key="Value(option)"
74
74
  :value="Value(option)"
75
75
  :item="Label(option)"
76
- :class="[customClass.checkbox, customClass[value?.includes?.(Value(option)) ? 'selected' : 'notSelected']?.checkbox]"
76
+ :class="customClass.checkbox"
77
77
  :custom-class="customClass.checkboxItem"
78
78
  :selected="value?.includes?.(Value(option))"
79
79
  :disabled="option.disable"
@@ -94,7 +94,7 @@
94
94
  :key="Value(option)"
95
95
  :value="Value(option)"
96
96
  :item="Label(option)"
97
- :class="[customClass.radio, customClass[isEqual(Value(option), value) ? 'selected' : 'notSelected']?.radio]"
97
+ :class="customClass.radio"
98
98
  :custom-class="customClass.radioItem"
99
99
  :selected="isEqual(Value(option), value)"
100
100
  :disabled="option.disable"
@@ -138,12 +138,10 @@ const close = (e = {}) => {
138
138
  const name = e?.target?.id;
139
139
  const pname = e?.target?.parentElement?.id;
140
140
  const ppname = e?.target?.parentElement?.parentElement?.id;
141
- console.log(e);
142
141
  if ([name, pname, ppname].includes(id)) return;
143
142
  show.value = false;
144
143
  };
145
144
  const toggle = () => {
146
- console.log("aaa");
147
145
  show.value = !show.value;
148
146
  };
149
147
  const dropdownStyles = ref({});
@@ -16,8 +16,6 @@ type __VLS_Props = {
16
16
  customClass?: Partial<Record<'header' | 'icon' | 'label' | 'arrowIcon' | 'wrapper' | 'innerWrapper' | 'search' | 'list' | 'radio' | 'checkbox' | 'checkboxButton', unknown>> & {
17
17
  radioItem?: RadioCustomClass;
18
18
  checkboxItem?: CheckboxCustomClass;
19
- selected: Partial<Record<'radio' | 'checkbox', string>>;
20
- notSelected: Partial<Record<'radio' | 'checkbox', string>>;
21
19
  };
22
20
  };
23
21
  type __VLS_ModelProps = {
@@ -1,7 +1,3 @@
1
- <template>
2
-
3
- </template>
4
-
5
1
  <script setup>
6
2
  const props = defineProps({
7
3
  name: { type: String, required: false }
@@ -9,11 +9,11 @@ type __VLS_Props = {
9
9
  pagination?: boolean;
10
10
  initialSlide?: number;
11
11
  };
12
- declare var __VLS_11: {
12
+ declare var __VLS_13: {
13
13
  item: any;
14
14
  };
15
15
  type __VLS_Slots = {} & {
16
- default?: (props: typeof __VLS_11) => any;
16
+ default?: (props: typeof __VLS_13) => any;
17
17
  };
18
18
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -9,11 +9,11 @@ type __VLS_Props = {
9
9
  pagination?: boolean;
10
10
  initialSlide?: number;
11
11
  };
12
- declare var __VLS_11: {
12
+ declare var __VLS_13: {
13
13
  item: any;
14
14
  };
15
15
  type __VLS_Slots = {} & {
16
- default?: (props: typeof __VLS_11) => any;
16
+ default?: (props: typeof __VLS_13) => any;
17
17
  };
18
18
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -77,6 +77,7 @@ const Title = computed(() => {
77
77
  if (transaction.type === "TRANSFER" && transaction.toWallet?.userId !== userId.value) {
78
78
  return `\u0627\u0631\u0633\u0627\u0644 \u0634\u0627\u0631\u0698 ${transaction.wallet?.coin?.name} \u0628\u0647 ${transaction.toWallet?.user?.profile?.firstName || ""} ${transaction.toWallet?.user?.profile?.lastName || ""}`;
79
79
  }
80
+ return "";
80
81
  });
81
82
  const statusVariant = computed(() => ["REJECTED", "FAILED"].includes(transaction.status) ? "text-danger" : transaction.type === "DEPOSIT" || transaction.type === "TRANSFER" && transaction.toWallet?.userId === userId.value ? "text-success" : "text-danger");
82
83
  const statusIcon = computed(() => ["REJECTED", "FAILED"].includes(transaction.status) ? "solar:danger-circle-bold-duotone" : transaction.type === "DEPOSIT" || transaction.type === "TRANSFER" && transaction.toWallet?.userId === userId.value ? "solar:import-bold-duotone" : "solar:export-bold-duotone");
@@ -5,7 +5,7 @@ type __VLS_WithSlots<T, S> = T & (new () => {
5
5
  $slots: S;
6
6
  });
7
7
  declare const __VLS_base: import("vue").DefineComponent<{}, {
8
- $props: Partial<typeof props>;
8
+ $props: Partial<typeof __VLS_props>;
9
9
  icon: string;
10
10
  label: string;
11
11
  disabled: boolean;
@@ -15,7 +15,7 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
15
15
  type __VLS_Slots = {
16
16
  icon?: ((props: {}) => any) | undefined;
17
17
  };
18
- declare const props: {
18
+ declare const __VLS_props: {
19
19
  readonly icon: string;
20
20
  readonly label: string;
21
21
  readonly disabled: boolean;
@@ -51,7 +51,7 @@
51
51
  </template>
52
52
 
53
53
  <script setup>
54
- const props = defineProps({
54
+ defineProps({
55
55
  edit: {
56
56
  type: Boolean,
57
57
  default: true
@@ -5,7 +5,7 @@ type __VLS_WithSlots<T, S> = T & (new () => {
5
5
  $slots: S;
6
6
  });
7
7
  declare const __VLS_base: import("vue").DefineComponent<{}, {
8
- $props: Partial<typeof props>;
8
+ $props: Partial<typeof __VLS_props>;
9
9
  icon: string;
10
10
  label: string;
11
11
  disabled: boolean;
@@ -15,7 +15,7 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
15
15
  type __VLS_Slots = {
16
16
  icon?: ((props: {}) => any) | undefined;
17
17
  };
18
- declare const props: {
18
+ declare const __VLS_props: {
19
19
  readonly icon: string;
20
20
  readonly label: string;
21
21
  readonly disabled: boolean;
@@ -124,6 +124,7 @@ const mappedWallet = computed(() => wallets.value.map((e) => ({
124
124
  icon: e.coin?.icon,
125
125
  title: e.coin?.name,
126
126
  unit: e.coin?.unit,
127
+ info: e.coin?.info,
127
128
  description: ["\u0645\u0627\u0646\u062F\u0647:", _ceil(e.balance || 0, e.coin?.precision || 0)?.toLocaleString("en"), e.coin?.isFiat ? "\u062A\u0648\u0645\u0627\u0646" : e.coin?.unit].join(" "),
128
129
  type: "wallet"
129
130
  })));
@@ -1,30 +1,51 @@
1
1
  import type { NitroFetchOptions, NitroFetchRequest } from 'nitropack';
2
- export declare const fetch: <T>({ body, config, controller, URL, method }: {
3
- body?: undefined;
4
- config?: {} | undefined;
5
- controller?: undefined;
6
- URL?: string | undefined;
7
- method?: string | undefined;
2
+ declare global {
3
+ interface Window {
4
+ BASE_URL?: string;
5
+ APP_CODE?: string;
6
+ NESHAN_API_KEY?: string;
7
+ NESHAN_WEB_KEY?: string;
8
+ urlPrefix?: string;
9
+ }
10
+ }
11
+ type Config = NitroFetchOptions<NitroFetchRequest, 'get' | 'post' | 'put' | 'delete'> & {
12
+ headers?: Record<string, unknown>;
13
+ };
14
+ export declare const fetch: <T>({ body, config, controller, URL, method, }: {
15
+ body?: Record<string, unknown>;
16
+ config?: Config;
17
+ controller?: AbortController;
18
+ URL?: string;
19
+ method?: "GET" | "POST" | "PUT" | "DELETE";
8
20
  }) => Promise<{
9
- error: never;
21
+ result: undefined;
22
+ error: Record<string, Record<string, unknown>>;
10
23
  } | {
11
- result: import("nitropack").TypedInternalResponse<NitroFetchRequest, T, NitroFetchOptions<NitroFetchRequest, "get" | "head" | "patch" | "post" | "put" | "delete" | "connect" | "options" | "trace"> extends NitroFetchOptions<R, import("nitropack").AvailableRouterMethod<R>> ? "get" : Lowercase<Exclude<import("nitropack").AvailableRouterMethod<R>, undefined>> | Lowercase<Exclude<Uppercase<import("nitropack").AvailableRouterMethod<R>>, undefined>> extends "get" | "head" | "patch" | "post" | "put" | "delete" | "connect" | "options" | "trace" ? Lowercase<Exclude<import("nitropack").AvailableRouterMethod<R>, undefined>> | Lowercase<Exclude<Uppercase<import("nitropack").AvailableRouterMethod<R>>, undefined>> : "get">;
24
+ result: T;
25
+ error: undefined;
12
26
  }>;
13
- export declare const useGet: <T>(URL: string, config?: NitroFetchOptions<NitroFetchRequest, "get"> | {
14
- headers?: Record<string, never>;
27
+ export declare const useGet: <T>(URL: string, config?: NitroFetchOptions<NitroFetchRequest, "get"> & {
28
+ headers?: Record<string, unknown>;
15
29
  }, controller?: AbortController | undefined) => Promise<{
16
30
  result?: T;
17
- error?: never;
31
+ error?: unknown;
18
32
  }>;
19
- export declare const useDelete: <T>(URL: string, config?: NitroFetchOptions<NitroFetchRequest, "delete">, controller?: AbortController | undefined) => Promise<{
33
+ export declare const useDelete: <T>(URL: string, config?: NitroFetchOptions<NitroFetchRequest, "delete"> & {
34
+ headers?: Record<string, unknown>;
35
+ }, controller?: AbortController | undefined) => Promise<{
20
36
  result?: T;
21
- error?: never;
37
+ error?: unknown;
22
38
  }>;
23
- export declare const usePost: <T, R = T>(URL: string, data: R, config?: NitroFetchOptions<NitroFetchRequest, "post">, controller?: AbortController | undefined) => Promise<{
39
+ export declare const usePost: <T, R = T>(URL: string, data: R, config?: NitroFetchOptions<NitroFetchRequest, "post"> & {
40
+ headers?: Record<string, unknown>;
41
+ }, controller?: AbortController | undefined) => Promise<{
24
42
  result?: T;
25
- error?: never;
43
+ error?: unknown;
26
44
  }>;
27
- export declare const usePut: <T, R = T>(URL: string, data: Partial<R>, config?: NitroFetchOptions<NitroFetchRequest, "put">, controller?: AbortController | undefined) => Promise<{
45
+ export declare const usePut: <T, R = T>(URL: string, data: Partial<R>, config?: NitroFetchOptions<NitroFetchRequest, "put"> & {
46
+ headers?: Record<string, unknown>;
47
+ }, controller?: AbortController | undefined) => Promise<{
28
48
  result?: T;
29
- error?: never;
49
+ error?: unknown;
30
50
  }>;
51
+ export {};
@@ -1,7 +1,5 @@
1
1
  import { useModuleConfig, useToken } from "./reuseable.js";
2
- import { _get, _set, useNuxtApp, _takeRight } from "#imports";
3
- const domain = location.hostname.split(".");
4
- const tld = _takeRight(domain, 2).join(".");
2
+ import { _get, _set, useNuxtApp, isArray } from "#imports";
5
3
  const setHeaders = (config) => {
6
4
  const token = useToken();
7
5
  _set(config, ["headers", "Authorization"], _get(config, ["headers", "Authorization"], token.value || ""));
@@ -9,18 +7,29 @@ const setHeaders = (config) => {
9
7
  return config;
10
8
  };
11
9
  const errorHandler = (error, config) => {
12
- const msg = error?.data?.errors?.map((e) => e.field + ":" + e.message).join(" , ");
13
- if (!config?.headers?.["no-error"]) {
14
- const { $toast } = useNuxtApp();
15
- $toast?.error(msg || JSON.stringify(error?.data));
10
+ if ("data" in error) {
11
+ let msg = "";
12
+ if ("errors" in error.data && isArray(error.data.errors)) {
13
+ msg = error?.data?.errors?.map?.((e) => e.field + ":" + e.message).join(" , ");
14
+ }
15
+ if (!config?.headers?.["no-error"]) {
16
+ const { $toast } = useNuxtApp();
17
+ $toast?.error(msg || JSON.stringify(error?.data));
18
+ }
16
19
  }
17
- return { error };
20
+ return { result: void 0, error };
18
21
  };
19
- export const fetch = async ({ body = void 0, config = {}, controller = void 0, URL = "", method = "GET" }) => {
22
+ export const fetch = async ({
23
+ body = void 0,
24
+ config = {},
25
+ controller = void 0,
26
+ URL = "",
27
+ method = "GET"
28
+ }) => {
20
29
  const moduleConfig = useModuleConfig();
21
30
  controller = new AbortController();
22
31
  const signal = controller.signal;
23
- config = setHeaders(config);
32
+ config = setHeaders(config || {});
24
33
  try {
25
34
  const result = await $fetch(URL, {
26
35
  baseURL: window.BASE_URL || moduleConfig?.BASE_URL,
@@ -29,7 +38,7 @@ export const fetch = async ({ body = void 0, config = {}, controller = void 0, U
29
38
  body,
30
39
  ...config
31
40
  });
32
- return { result };
41
+ return { result, error: void 0 };
33
42
  } catch (error) {
34
43
  return errorHandler(error, config);
35
44
  }
@@ -1,21 +1,25 @@
1
+ import type { Socket } from 'socket.io-client';
1
2
  import type { CoinGateway, DiscountCode, Form, Transaction, Wallet } from '../types/models.js';
2
3
  import type { Address, MetaData, SocketJoinObject } from '../types/app.js';
3
4
  import type { RemovableRef } from '@vueuse/core';
4
5
  import Moment from 'jalali-moment';
5
6
  import Ajv from 'ajv';
7
+ import type { Ref } from '@vue/reactivity';
8
+ import type { DefaultEventsMap } from '@socket.io/component-emitter';
6
9
  export declare const moment: typeof Moment;
7
10
  export declare const ajv: Ajv;
8
11
  export declare const logger: (...args: any) => void;
9
12
  export declare const s2n: (string: string | number) => string;
10
- export declare const sleep: (ms: any) => Promise<unknown>;
13
+ export declare const sleep: (ms: number) => Promise<unknown>;
11
14
  export declare const geoLink: (location: Location, isIos?: boolean) => string;
12
- export declare const useComputedRoute: (route: any, key: any) => import("vue").WritableComputedRef<any, any>;
13
- export declare const useComputedLodash: (value: any, keys: (string | number)[] | string) => import("vue").WritableComputedRef<any, any>;
14
- export declare const KMapper: (num: any) => string;
15
+ export declare const useComputedRoute: (route: {
16
+ query: Record<string, any>;
17
+ }, key: string) => import("vue").WritableComputedRef<any, any>;
18
+ export declare const useComputedLodash: (value: Ref, keys: (string | number)[] | string) => import("vue").WritableComputedRef<any, any>;
19
+ export declare const KMapper: (num: number) => string;
15
20
  export declare const p2e: (string: string | number) => string;
16
21
  export declare const toLocal: (number: number | string, decimal?: number) => string | number;
17
22
  export declare const copyData: (string: string) => Promise<void>;
18
- export declare const mapper: (data: Record<string, any>, map: Record<string, any>, keys?: string[]) => Record<string, any>;
19
23
  export declare const deg2rad: (deg: number) => number;
20
24
  export declare const getDistanceFromLatLonInKm: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
21
25
  export declare const isoToNormal: (time: string) => string;
@@ -27,25 +31,23 @@ export declare const isoToDate: (time: string) => string;
27
31
  export declare const isoToStandard: (time: string) => string;
28
32
  export declare const dataToRange: (data: any[] | undefined) => [string, string];
29
33
  export declare const subIsoDate: (du: string) => string;
30
- export declare const isExpire: (time: any) => boolean;
31
- export declare const remainToExpire: (timestamp: any, time: string) => string[];
34
+ export declare const isExpire: (time: string) => boolean;
35
+ export declare const remainToExpire: (timestamp: number, time: string) => string[];
32
36
  export declare const timeToDurationShort: (timeString?: string) => string;
33
37
  export declare const timeToMinutes: (timeString?: string) => number;
34
38
  export declare const minutesToTime: (m?: number) => string;
35
- export declare const useSocketIo: () => import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
36
- export declare const watchSocket: (socket: any, joinObject: SocketJoinObject, dataHandler: any, loading?: import("vue").Ref<boolean, boolean>, initHandler?: () => Promise<void>) => void;
39
+ export declare const useSocketIo: () => Socket<DefaultEventsMap, DefaultEventsMap>;
40
+ export declare const watchSocket: (socket: Socket<DefaultEventsMap, DefaultEventsMap>, joinObject: SocketJoinObject, dataHandler: (...args: any[]) => void, loading?: Ref<boolean, boolean>, initHandler?: () => Promise<void>) => void;
37
41
  export declare const lastAct: (time: string) => string;
38
42
  export declare const setMeta: (data: MetaData) => void;
39
- export declare const encrypt: (text: any, passphrase: any) => any;
40
- export declare const decrypt: (ciphertext: any, passphrase: any) => any;
41
- export declare const useWallets: (isActive?: boolean | undefined, id?: string) => Promise<RemovableRef<Wallet[]>>;
43
+ export declare const useWallets: (isActive?: boolean | undefined, id?: string | undefined) => Promise<RemovableRef<Wallet[]>>;
42
44
  export declare const useGateways: (isActive?: boolean | undefined) => Promise<CoinGateway[]>;
43
45
  export declare const getDiscountInfo: (code: string, shop?: {
44
46
  categoryKey: string;
45
47
  } | null) => Promise<DiscountCode | null>;
46
48
  export declare const submitPayment: (amount: number, details?: Partial<Transaction>, giftCode?: undefined, redirect?: boolean) => Promise<Transaction | undefined>;
47
- export declare const discountedPrice: (price: any, discount?: DiscountCode) => any;
48
- export declare const formattedAddress: ([lng, lat]: Address) => Promise<any>;
49
+ export declare const discountedPrice: (price: number, discount?: DiscountCode | null) => number | object | null | undefined;
50
+ export declare const formattedAddress: ([lng, lat]: Address) => Promise<string>;
49
51
  export declare const geoCodingAddress: (address: string, coords: Address) => Promise<unknown>;
50
52
  export declare const setOptions: (f: Form, ctx?: {}) => Promise<Form | {
51
53
  input: {
@@ -64,26 +66,26 @@ export declare const setOptions: (f: Form, ctx?: {}) => Promise<Form | {
64
66
  externalOptionsKeys?: import("../types/models.js").ExternalOptionsKeys | null;
65
67
  multiSelect?: boolean | null;
66
68
  keyboadType?: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url" | null;
67
- min?: number | {} | null;
68
- max?: number | {} | null;
69
+ min?: number | object | null;
70
+ max?: number | object | null;
69
71
  extendedInputKey?: string | null;
70
72
  createdAt?: string | null;
71
73
  updatedAt?: string | null;
72
- forms?: Form[];
73
- requiredForms?: Form[];
74
- activatedForms?: Form[];
75
- filterOptions?: import("../types/models.js").InputOption[];
76
- extendedInputs?: import("../types/models.js").Input[];
74
+ forms?: Form[] | object;
75
+ requiredForms?: Form[] | object;
76
+ activatedForms?: Form[] | object;
77
+ filterOptions?: import("../types/models.js").InputOption[] | object;
78
+ extendedInputs?: import("../types/models.js").Input[] | object;
77
79
  };
78
80
  id?: string;
79
81
  name: string;
80
- priority?: number | {} | null;
82
+ priority?: number | object | null;
81
83
  required?: boolean;
82
84
  requiredby?: string | null;
83
85
  activatedByInput?: import("../types/models.js").Input | null;
84
- activatedByValues?: string[];
86
+ activatedByValues?: string[] | object;
85
87
  requiredByInput?: import("../types/models.js").Input | null;
86
- requiredByValues?: string[];
88
+ requiredByValues?: string[] | object;
87
89
  createdAt?: string | null;
88
90
  updatedAt?: string | null;
89
91
  activatedBy?: string | null;
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  _fromPairs,
3
3
  _get,
4
- _has,
5
4
  _mergeWith,
6
5
  _set,
7
6
  _toPairs,
@@ -23,6 +22,7 @@ import { useModuleConfig, useToken, useUserId } from "./reuseable.js";
23
22
  import Moment from "jalali-moment";
24
23
  import Handlebars from "handlebars";
25
24
  import Ajv from "ajv";
25
+ import Big from "big.js";
26
26
  export const moment = Moment;
27
27
  export const ajv = new Ajv();
28
28
  export const logger = (...args) => console.log("logger=>>>", ...args);
@@ -83,21 +83,9 @@ export const toLocal = (number, decimal = 8) => {
83
83
  };
84
84
  export const copyData = async (string) => {
85
85
  const { $toast } = useNuxtApp();
86
+ const { t } = useI18n();
86
87
  await navigator.clipboard.writeText(string);
87
- $toast.success("Copied :)");
88
- };
89
- export const mapper = (data, map, keys = _keys(map)) => {
90
- const value = {};
91
- const mapKeys = Object.keys(map);
92
- for (const key of keys) {
93
- const v = _get(data, key);
94
- _set(value, key, v);
95
- }
96
- for (const key of mapKeys) {
97
- const v = _has(data, key) && _get(map, [key, "handler"])?.(data[key]) || _get(data, key);
98
- _set(value, map[key]?.label || key, v);
99
- }
100
- return value;
88
+ $toast.success(t("Copied :)"));
101
89
  };
102
90
  export const deg2rad = (deg) => {
103
91
  return deg * (Math.PI / 180);
@@ -153,7 +141,7 @@ export const timeToMinutes = (timeString = "") => {
153
141
  export const minutesToTime = (m = 0) => {
154
142
  const hour = Math.floor(m / 60) + "";
155
143
  const minute = Math.round(m % 60) + "";
156
- return `${hour.padStart(2, 0)}:${minute.padStart(2, 0)}`;
144
+ return `${hour.padStart(2, "0")}:${minute.padStart(2, "0")}`;
157
145
  };
158
146
  export const useSocketIo = () => {
159
147
  const moduleConfig = useModuleConfig();
@@ -199,46 +187,36 @@ export const setMeta = (data) => {
199
187
  const metaData = useState("meta-data");
200
188
  metaData.value = data;
201
189
  };
202
- export const encrypt = (text, passphrase) => {
203
- return AES.encrypt(text, passphrase).toString();
204
- };
205
- export const decrypt = (ciphertext, passphrase) => {
206
- const bytes = AES.decrypt(ciphertext, passphrase);
207
- try {
208
- return bytes.toString(enc);
209
- } catch (e) {
210
- return "";
211
- }
212
- };
213
190
  export const useWallets = async (isActive = void 0, id = void 0) => {
214
191
  const userId = id ? { value: id } : useUserId();
215
192
  const wallet = id ? ref([]) : useState("wallet", () => []);
193
+ const moduleConfig = useModuleConfig();
216
194
  const { result: currentWallets } = await useGet("/wallet", {
217
195
  params: {
218
196
  "$w.userId": userId.value,
219
197
  // '$w.isActive': isActive,
220
198
  "$i.coin.$i.gateways.$w.active": isActive,
221
- "$i.coin.$i.gateways.$i.gateway": isActive
199
+ "$i.coin.$i.gateways.$i.gateway": true
222
200
  }
223
201
  });
224
202
  const { result: coins } = await useGet("/coin", { params: { "$w.walletable": true } });
225
- wallet.value = currentWallets || [];
203
+ wallet.value = currentWallets?.filter((e) => !e.coin?.platforms?.length || e.coin?.platforms?.includes(window.APP_CODE || moduleConfig?.APP_CODE)) || [];
226
204
  const wallets = coins?.map((e) => ({
227
205
  balance: 0,
228
206
  coinId: e.id,
229
207
  userId: userId.value
230
- })).filter((c) => !wallet.value?.find((w) => w.coinId === c.coinId));
208
+ })).filter((c) => !currentWallets?.find((w) => w.coinId === c.coinId));
231
209
  if (wallets?.length) {
232
210
  await usePost("/wallet", wallets);
233
211
  const { result: w } = await useGet("/wallet", {
234
212
  params: {
235
213
  "$w.userId": userId.value,
236
214
  "$i.coin.$i.gateways.$w.active": isActive,
237
- "$i.coin.$i.gateways.$i.gateway": isActive
215
+ "$i.coin.$i.gateways.$i.gateway": true
238
216
  // '$w.isActive': isActive,
239
217
  }
240
218
  });
241
- wallet.value = w || [];
219
+ wallet.value = w?.filter((e) => !e.coin?.platforms?.length || e.coin?.platforms?.includes(window.APP_CODE || moduleConfig?.APP_CODE)) || [];
242
220
  }
243
221
  return wallet;
244
222
  };
@@ -259,6 +237,7 @@ export const getDiscountInfo = async (code, shop = null) => {
259
237
  params: {
260
238
  "$i.transactions": true
261
239
  },
240
+ // @ts-ignore
262
241
  headers: {
263
242
  "no-error": true
264
243
  }
@@ -331,13 +310,14 @@ export const discountedPrice = (price, discount = null) => {
331
310
  return price;
332
311
  }
333
312
  const d = new Big(discount.percent).mul(price).div(100);
334
- return d > discount.maxPrice ? discount.maxPrice : d;
313
+ return d > (discount.maxPrice || Infinity) ? discount.maxPrice : d;
335
314
  };
336
315
  export const formattedAddress = async ([lng, lat]) => {
337
316
  const result = await $fetch(
338
317
  `https://api.neshan.org/v5/reverse?lat=${lat}&lng=${lng}`,
339
318
  {
340
319
  method: "GET",
320
+ // @ts-ignore
341
321
  headers: {
342
322
  "Api-Key": window.NESHAN_API_KEY
343
323
  }
@@ -350,6 +330,7 @@ export const geoCodingAddress = async (address, coords) => {
350
330
  `https://api.neshan.org/v1/search?term=${address}&lat=${coords[1]}&lng=${coords[0]}`,
351
331
  {
352
332
  method: "GET",
333
+ // @ts-ignore
353
334
  headers: {
354
335
  "Api-Key": window.NESHAN_API_KEY
355
336
  }
@@ -372,6 +353,7 @@ export const setOptions = async (f, ctx = {}) => {
372
353
  ...f,
373
354
  input: {
374
355
  ...f.input,
356
+ // @ts-ignore
375
357
  options: (result ?? []).map((e) => _fromPairs(_toPairs(f.input?.externalOptionsKeys).map((p) => [p[0], _get(e, p[1])])))
376
358
  }
377
359
  };