@mythpe/quasar-ui-qui 0.1.66 → 0.1.68

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -62,9 +62,21 @@ const prepare = async (fromWatch = !1) => {
62
62
  if (!props.service || loading.value) {
63
63
  return
64
64
  }
65
- const method = typeof props.service === 'string'
66
- ? (isGuest.value ? api.value.services[props.service]?.staticIndex : api.value.services[props.service]?.index)
67
- : props.service
65
+ const s = props.service
66
+ let method: any = null
67
+ if (typeof s === 'string' && s.includes('.')) {
68
+ const args = s.split('.')
69
+ do {
70
+ if (!method) {
71
+ method = api.value.services[args.shift() as any]
72
+ }
73
+ method = method[args.shift() as any]
74
+ }
75
+ while (args.length)
76
+ } else {
77
+ method = typeof s === 'function' ? s : (isGuest.value ? api.value.services[s].staticIndex : api.value.services[s].index)
78
+ }
79
+
68
80
  if (!method) {
69
81
  throw Error(`No service: ${props.service}`)
70
82
  }
@@ -13,7 +13,7 @@
13
13
 
14
14
  import { useField } from 'vee-validate'
15
15
  import type { MOptionsOptionContext, MOptionsProps as Props } from '../../types'
16
- import { reactive, toValue, useTemplateRef } from 'vue'
16
+ import { onMounted, reactive, toValue, useTemplateRef } from 'vue'
17
17
  import { QField, QOptionGroup, type QOptionGroupSlots } from 'quasar'
18
18
  import { useBindInput, useMyth } from '../../composable'
19
19
 
@@ -40,6 +40,7 @@ interface P {
40
40
  type?: Props['type'];
41
41
  keepColor?: Props['keepColor'];
42
42
  service?: Props['service'];
43
+ guest?: boolean;
43
44
  fullWidth?: Props['fullWidth'];
44
45
  fitWidth?: Props['fullWidth'];
45
46
  fieldOptions?: Props['fieldOptions'];
@@ -67,6 +68,7 @@ const props = withDefaults(defineProps<P>(), {
67
68
  color: () => 'primary',
68
69
  type: 'radio',
69
70
  keepColor: undefined,
71
+ guest: !1,
70
72
  service: undefined,
71
73
  fullWidth: () => !1,
72
74
  fitWidth: () => !1,
@@ -91,13 +93,29 @@ const listeners = {
91
93
  const input = useTemplateRef<InstanceType<typeof QField> | InstanceType<typeof QOptionGroup>>('input')
92
94
  const scopes = reactive(inputScope)
93
95
  defineExpose<typeof scopes & { input: typeof input }>({ input, ...scopes })
94
- const { alertError, __, props: pluginProps } = useMyth()
96
+ const { alertError, __, props: pluginProps, api } = useMyth()
95
97
  const fetchData = async () => {
96
98
  if (props.service) {
99
+ const s = props.service
97
100
  loading.value = !0
98
101
  try {
99
- const { _data } = await props.service()
100
- options.value = _data as any
102
+ let method: any = null
103
+ if (typeof s === 'string' && s.includes('.')) {
104
+ const args = s.split('.')
105
+ do {
106
+ if (!method) {
107
+ method = api.value.services[args.shift() as any]
108
+ }
109
+ method = method[args.shift() as any]
110
+ }
111
+ while (args.length)
112
+ } else {
113
+ method = typeof s === 'function' ? s : (props.guest ? api.value.services[s].staticIndex : api.value.services[s].index)
114
+ }
115
+ if (method != null) {
116
+ const { _data } = await method()
117
+ options.value = _data as any
118
+ }
101
119
  } catch (e: any) {
102
120
  alertError(e?._message || e?.message || 'Failed to fetch data')
103
121
  } finally {
@@ -105,7 +123,10 @@ const fetchData = async () => {
105
123
  }
106
124
  }
107
125
  }
108
- fetchData()
126
+
127
+ onMounted(() => {
128
+ fetchData()
129
+ })
109
130
  defineOptions({
110
131
  name: 'MOptions',
111
132
  inheritAttrs: !1
@@ -424,8 +424,8 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
424
424
  const resetDialogForm = useResetForm()
425
425
  const resetVeeForm = async (attrs?: Record<string, any>) => {
426
426
  const init: any = {}
427
- for (const k in props.defaultItem) {
428
- init[k] = attrs && k in attrs ? attrs[k] : props.defaultItem[k]
427
+ for (const k in defaultItem.value) {
428
+ init[k] = attrs && k in attrs ? attrs[k] : defaultItem.value[k]
429
429
  }
430
430
  resetDialogForm({ values: init || {} }, { force: !0 })
431
431
  attrs && setValues(attrs, !1)
@@ -34,15 +34,14 @@ export const useMyth = () => {
34
34
  number = parseInt(number.toString())
35
35
  route = route || $route
36
36
  const defaultValue = ''
37
- // Not is route
37
+ // Not route
38
38
  // No page title
39
39
  if (!route) {
40
40
  return defaultValue
41
41
  }
42
42
 
43
- const routePath = route?.path?.toString() || null
43
+ const routePath = route?.path?.toString()?.replace(/^\//, '').replace(/\//g, '.') || null
44
44
  const routeName = route?.name?.toString() || null
45
-
46
45
  // # Not is Route, No page title
47
46
  if (!routePath || !routeName) {
48
47
  return defaultValue
@@ -55,6 +54,7 @@ export const useMyth = () => {
55
54
  }
56
55
  const pluralize = Str.pascalCase(lodash.pluralize(lastRouteName))
57
56
  const singular = Str.pascalCase(lodash.singularize(lastRouteName))
57
+
58
58
  const keys = lodash.filter(lodash.uniq([
59
59
  `routes.${routeName}`,
60
60
  `routes.${routePath}`,
@@ -69,7 +69,7 @@ export const useMyth = () => {
69
69
  singular,
70
70
  lodash.snakeCase(singular)
71
71
  ]))
72
-
72
+ // console.log(keys)
73
73
  let str: string | null = null
74
74
  let k: string | any
75
75
 
@@ -546,10 +546,14 @@ export type MOptionsProps = Omit<QOptionGroupProps, 'name' | 'modelValue' | 'opt
546
546
  * Array of objects with value, label, and disable (optional) props. The binary components will be created according to this array; Props from QToggle & QCheckbox or QRadio can also be added as key/value pairs to control the components singularly
547
547
  */
548
548
  options?: MOptionsOptionContext[];
549
+ /**
550
+ * Uset auto static index myth api helpers.
551
+ */
552
+ guest?: boolean | undefined;
549
553
  /**
550
554
  * Get options by function. any send the current value to this function to get options.
551
555
  */
552
- service?: ((value?: any) => Promise<ApiInterface>) | undefined;
556
+ service?: ((value?: any) => Promise<ApiInterface>) | string;
553
557
  /**
554
558
  * Service loading.
555
559
  */
@@ -15,7 +15,7 @@ export const createMyth = (options: InstallOptions) => {
15
15
  size: 'md',
16
16
  rounded: !0,
17
17
  shadow: 2,
18
- fluid: !0,
18
+ fluid: !1,
19
19
  buttons: {},
20
20
  inputs: {
21
21
  hideBottomSpace: !0,