@unsource/ui 2.0.11 → 2.0.13

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": "unsource-ui",
3
3
  "configKey": "unsourceUi",
4
- "version": "2.0.11",
4
+ "version": "2.0.13",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -67,7 +67,7 @@ const module = defineNuxtModule({
67
67
  addImportsDir(resolver2.resolve("runtime/composables"));
68
68
  addPlugin(resolver2.resolve("runtime/plugins/toast.client"));
69
69
  _nuxt.options.build.transpile.push(
70
- "jallali-moment",
70
+ "jalali-moment",
71
71
  "ajv",
72
72
  "big.js",
73
73
  "handlebars"
@@ -9,7 +9,45 @@
9
9
  </template>
10
10
 
11
11
  <script setup>
12
- import { getForms, ajv, formattedAddress, setOptions, _cloneDeep, ref, useAsyncData, useNuxtApp, watch } from "#imports";
12
+ import {
13
+ getForms,
14
+ formattedAddress,
15
+ _cloneDeep,
16
+ ref,
17
+ useAsyncData,
18
+ useNuxtApp,
19
+ watch,
20
+ useGet,
21
+ _fromPairs,
22
+ _toPairs,
23
+ _get
24
+ } from "#imports";
25
+ import Handlebars from "handlebars";
26
+ import Ajv from "ajv";
27
+ const ajv = new Ajv();
28
+ const setOptions = async (f, ctx2 = {}) => {
29
+ if (f.input?.extendedInputKey) {
30
+ return {
31
+ ...f,
32
+ input: {
33
+ ...f.input,
34
+ options: f.input?.extendInput?.options ?? []
35
+ }
36
+ };
37
+ } else if (f.input?.externalOptions) {
38
+ const template = Handlebars.compile(f.input?.externalOptions);
39
+ const { result } = await useGet(template(ctx2));
40
+ return {
41
+ ...f,
42
+ input: {
43
+ ...f.input,
44
+ options: (result ?? []).map((e) => _fromPairs(_toPairs(f.input?.externalOptionsKeys).map((p) => [p[0], _get(e, p[1])])))
45
+ }
46
+ };
47
+ } else {
48
+ return f;
49
+ }
50
+ };
13
51
  const { name, ctx } = defineProps({
14
52
  name: { type: String, required: true },
15
53
  ctx: { type: Object, required: false }
@@ -1,4 +1,4 @@
1
- import type { Form, InputOption } from '../../types/models.js';
1
+ import type { Form, InputOption } from '../types/models.js';
2
2
  type __VLS_Props = {
3
3
  item: Form;
4
4
  options: InputOption[];
@@ -117,7 +117,7 @@ import { computed } from "#imports";
117
117
  import UnLocationInput from "./UnLocationInput.vue";
118
118
  const emit = defineEmits(["update:modelValue"]);
119
119
  const { item, options, required, isError } = defineProps({
120
- item: { type: null, required: true },
120
+ item: { type: Object, required: true },
121
121
  options: { type: Array, required: true },
122
122
  required: { type: Boolean, required: false },
123
123
  isError: { type: Boolean, required: false }
@@ -1,4 +1,4 @@
1
- import type { Form, InputOption } from '../../types/models.js';
1
+ import type { Form, InputOption } from '../types/models.js';
2
2
  type __VLS_Props = {
3
3
  item: Form;
4
4
  options: InputOption[];
@@ -1,4 +1,4 @@
1
- import type { Form } from '../../types/models.js';
1
+ import type { Form } from '../types/models.js';
2
2
  type __VLS_Props = {
3
3
  items: Partial<Form>[];
4
4
  errors?: string[];
@@ -10,7 +10,7 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
10
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
11
11
  schema: import("vue").ComputedRef<{
12
12
  type: string;
13
- properties: Form;
13
+ properties: Partial<Form>;
14
14
  required: string[];
15
15
  }>;
16
16
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,4 +1,4 @@
1
- import type { Form } from '../../types/models.js';
1
+ import type { Form } from '../types/models.js';
2
2
  type __VLS_Props = {
3
3
  items: Partial<Form>[];
4
4
  errors?: string[];
@@ -10,7 +10,7 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
10
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
11
11
  schema: import("vue").ComputedRef<{
12
12
  type: string;
13
- properties: Form;
13
+ properties: Partial<Form>;
14
14
  required: string[];
15
15
  }>;
16
16
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -60,7 +60,8 @@
60
60
  <script setup>
61
61
  import { vOnClickOutside } from "@vueuse/components";
62
62
  import DatePicker from "vue3-persian-datetime-picker";
63
- import { moment } from "#imports";
63
+ import moment from "jalali-moment";
64
+ import { ref } from "#imports";
64
65
  const format = {
65
66
  datetime: "YYYY-MM-DDTHH:mm:ssZ",
66
67
  time: "HH:mm",
@@ -1,16 +1,12 @@
1
- import Moment from 'jalali-moment';
2
- import Ajv from 'ajv';
3
1
  import type { CoinGateway, DiscountCode, Form, Transaction, Wallet } from '../types/models.js';
4
2
  import type { Address, MetaData, SocketJoinObject } from '../types/app.js';
5
3
  import type { RemovableRef } from '@vueuse/core';
6
4
  export declare const NESHAN_API_KEY = "service.23c2db7869bd44b986353729776b338c";
7
5
  export declare const NESHAN_WEB_KEY = "web.698da9dc73764b18a38a4c5cc4f92320";
8
6
  export declare const logger: (...args: any) => void;
9
- export declare const moment: typeof Moment;
10
7
  export declare const s2n: (string: string | number) => string;
11
8
  export declare const sleep: (ms: any) => Promise<unknown>;
12
9
  export declare const geoLink: (location: Location, isIos?: boolean) => string;
13
- export declare const ajv: Ajv;
14
10
  export declare const useComputedRoute: (route: any, key: any) => import("vue").WritableComputedRef<any, any>;
15
11
  export declare const useComputedLodash: (value: any, keys: (string | number)[] | string) => import("vue").WritableComputedRef<any, any>;
16
12
  export declare const KMapper: (num: any) => string;
@@ -20,23 +16,23 @@ export declare const copyData: (string: string) => Promise<void>;
20
16
  export declare const mapper: (data: Record<string, any>, map: Record<string, any>, keys?: string[]) => Record<string, any>;
21
17
  export declare const deg2rad: (deg: number) => number;
22
18
  export declare const getDistanceFromLatLonInKm: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
23
- export declare const isoToNormal: (time: string) => string;
24
- export declare const isoToMonth: (time: string) => string;
25
- export declare const isoToDateTime: (time: string) => string;
26
- export declare const isoToHumanDateTime: (time: string) => string;
27
- export declare const isoToTime: (time: string) => string;
28
- export declare const isoToDate: (time: string) => string;
29
- export declare const isoToStandard: (time: string) => string;
19
+ export declare const isoToNormal: (time: string) => any;
20
+ export declare const isoToMonth: (time: string) => any;
21
+ export declare const isoToDateTime: (time: string) => any;
22
+ export declare const isoToHumanDateTime: (time: string) => any;
23
+ export declare const isoToTime: (time: string) => any;
24
+ export declare const isoToDate: (time: string) => any;
25
+ export declare const isoToStandard: (time: string) => any;
30
26
  export declare const dataToRange: (data: any[] | undefined) => [string, string];
31
27
  export declare const subIsoDate: (du: string) => string;
32
- export declare const isExpire: (time: any) => boolean;
28
+ export declare const isExpire: (time: any) => any;
33
29
  export declare const remainToExpire: (timestamp: any, time: string) => string[];
34
30
  export declare const timeToDurationShort: (timeString?: string) => string;
35
31
  export declare const timeToMinutes: (timeString?: string) => number;
36
32
  export declare const minutesToTime: (m?: number) => string;
37
33
  export declare const useSocketIo: () => import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
38
34
  export declare const watchSocket: (socket: any, joinObject: SocketJoinObject, dataHandler: any, loading?: import("vue").Ref<boolean, boolean>, initHandler?: () => Promise<void>) => void;
39
- export declare const lastAct: (time: string) => string;
35
+ export declare const lastAct: (time: string) => any;
40
36
  export declare const setMeta: (data: MetaData) => void;
41
37
  export declare const encrypt: (text: any, passphrase: any) => any;
42
38
  export declare const decrypt: (ciphertext: any, passphrase: any) => any;
@@ -47,7 +43,6 @@ export declare const getDiscountInfo: (code: string, shop?: {
47
43
  } | null) => Promise<DiscountCode | null>;
48
44
  export declare const submitPayment: (amount: number, details?: Partial<Transaction>, giftCode?: undefined, redirect?: boolean) => Promise<Transaction | undefined>;
49
45
  export declare const discountedPrice: (price: any, discount?: DiscountCode) => any;
50
- export declare const submitWalletPayment: (amount: any, wallet: Wallet, details?: {}, giftCode?: undefined) => Promise<any>;
51
46
  export declare const formattedAddress: ([lng, lat]: Address) => Promise<any>;
52
47
  export declare const geoCodingAddress: (address: string, coords: Address) => Promise<unknown>;
53
48
  export declare const setOptions: (f: Form, ctx?: {}) => Promise<Form | {
@@ -14,24 +14,17 @@ import {
14
14
  useGet,
15
15
  useNuxtApp,
16
16
  usePost,
17
- usePut,
18
17
  useState
19
18
  } from "#imports";
20
- import Moment from "jalali-moment";
21
- import Ajv from "ajv";
22
19
  import { io } from "socket.io-client";
23
20
  import { digitsFaToEn, digitsArToEn } from "@persian-tools/persian-tools";
24
- import Big from "big.js";
25
- import Handlebars from "handlebars";
26
21
  import { useToken, useUserId } from "./reuseable.js";
27
22
  export const NESHAN_API_KEY = "service.23c2db7869bd44b986353729776b338c";
28
23
  export const NESHAN_WEB_KEY = "web.698da9dc73764b18a38a4c5cc4f92320";
29
24
  export const logger = (...args) => console.log("logger=>>>", ...args);
30
- export const moment = Moment;
31
25
  export const s2n = (string) => (string + "").replace(/[^\d.]|\.\./g, "");
32
26
  export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
33
27
  export const geoLink = (location2, isIos = false) => isIos ? `maps://maps.google.com/?q=${location2?.lat},${location2?.lng}` : `geo:${location2?.lat},${location2?.lng}`;
34
- export const ajv = new Ajv();
35
28
  export const useComputedRoute = (route, key) => computed({
36
29
  get() {
37
30
  return _get(route.query, [key]);
@@ -328,40 +321,6 @@ export const discountedPrice = (price, discount = null) => {
328
321
  const d = new Big(discount.percent).mul(price).div(100);
329
322
  return d > discount.maxPrice ? discount.maxPrice : d;
330
323
  };
331
- export const submitWalletPayment = async (amount, wallet, details = {}, giftCode = void 0) => {
332
- let discount;
333
- if (giftCode) {
334
- discount = await getDiscountInfo(giftCode);
335
- if (!discount) throw new Error("giftCode is missing");
336
- }
337
- const userId = useUserId();
338
- const { $toast } = useNuxtApp();
339
- const price = discountedPrice(amount, discount);
340
- if (wallet.balance < price) {
341
- return $toast.error("\u0645\u0648\u062C\u0648\u062F\u06CC \u06A9\u0627\u0641\u06CC \u0646\u06CC\u0633\u062A");
342
- } else {
343
- const { result } = await usePut(`/wallet/${wallet.id}`, {
344
- balance: {
345
- decrement: price
346
- }
347
- });
348
- if (result) {
349
- const { result: res } = await usePost("/transaction", {
350
- amount,
351
- userId: userId.value || "",
352
- discountCode: giftCode,
353
- type: "PAYMENT",
354
- status: "SUCCESS",
355
- redirectUrl: "",
356
- walletId: wallet.id,
357
- ...details
358
- });
359
- if (res) {
360
- return await verifyPayment(res.id);
361
- }
362
- }
363
- }
364
- };
365
324
  export const formattedAddress = async ([lng, lat]) => {
366
325
  const result = await $fetch(
367
326
  `https://api.neshan.org/v5/reverse?lat=${lat}&lng=${lng}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unsource/ui",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "private": false,
5
5
  "description": "nuxt ui kit for unsource env",
6
6
  "repository": "https://github.com/alisa2142/unsource-ui",