@mythpe/quasar-ui-qui 0.0.72 → 0.0.74

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.0.72",
3
+ "version": "0.0.74",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -201,9 +201,9 @@ const getTableTitle = computed(() => {
201
201
  }
202
202
  return undefined
203
203
  })
204
- const formRef = useForm<any, any>()
205
- const formScope = reactive(formRef)
206
- const { resetForm: resetDialogForm, setValues, handleSubmit } = formRef
204
+ const useFormContext = useForm<any, any>()
205
+ // const formScope = reactive(useFormContext)
206
+ const { resetForm: resetDialogForm, setValues, handleSubmit } = useFormContext
207
207
  watch(() => props.defaultItem, (v) => {
208
208
  resetDialogForm({ values: { ...v || {} } }, { force: !0 })
209
209
  }, { immediate: !0, deep: !0 })
@@ -267,6 +267,7 @@ const dialogs = reactive<MDatatableDialogsOptions>({
267
267
  errors: dialogErrors
268
268
  })
269
269
  const resetDialogs = () => {
270
+ console.log('resetDialogs')
270
271
  dialogs.filter = !1
271
272
  dialogs.show = !1
272
273
  dialogs.form = !1
@@ -361,7 +362,9 @@ const hasShowBtn = computed<boolean>(() => {
361
362
  const hasDestroyBtn = computed<boolean>(() => !props.hideDestroyBtn)
362
363
  const hasFilterDialog = computed<boolean>(() => !!slots.filter)
363
364
  const hasMenu = computed<boolean>(() => {
364
- if (!!props.pdf || !!props.excel) {
365
+ const pdf = !!props.pdf && getRows.value.length > 0
366
+ const excel = !!props.excel && getRows.value.length > 0
367
+ if (pdf || excel) {
365
368
  return !0
366
369
  }
367
370
  return hasAddBtn.value && !!addListBtnComputed.value
@@ -767,13 +770,14 @@ const openUpdateDialog = (i: MDtItem, index: MDtItemIndex) => {
767
770
  getRows.value[index] = { ..._data } as any
768
771
  nextTick(() => setTimeout(() => (selected.value = [getRows.value[index] as any]), openDialogTimeout))
769
772
  }
770
- setTimeout(async () => {
773
+ setTimeout(() => {
771
774
  resetVeeForm(_data)
772
- nextTick()
773
- dialogs.form = !0
775
+ nextTick(() => {
776
+ dialogs.form = !0
777
+ })
774
778
  }, openDialogTimeout)
775
779
  })
776
- .catch((e) => {
780
+ .catch((e: any) => {
777
781
  const message = e?._message || e?.message
778
782
  message && alertError(message)
779
783
  })
@@ -895,7 +899,7 @@ const onSuccess: SubmissionHandler = async (form) => {
895
899
  scrollToElementFromErrors(_errors, undefined, '.m--datatable__dialog-form-container')
896
900
  _message && alertError(_message)
897
901
  if (_errors) {
898
- formRef.setErrors(_errors)
902
+ useFormContext.setErrors(_errors)
899
903
  }
900
904
  } finally {
901
905
  loading.value = !1
@@ -979,7 +983,7 @@ const deleteSelectionItem = () => {
979
983
  })
980
984
  }
981
985
  const logoutDatatable = () => {
982
- //
986
+ //
983
987
  }
984
988
  /**
985
989
  * ---
@@ -991,23 +995,22 @@ const logoutDatatable = () => {
991
995
  const contextmenu = ref(!1)
992
996
  const onRowContextmenu = (e: MouseEvent | Event, row: MDtItem, index: number | undefined) => {
993
997
  e.preventDefault?.()
994
- nextTick(() => {
995
- if (index === dialogs.index) {
996
- selected.value = []
997
- dialogs.item = undefined
998
- dialogs.index = undefined
999
- if (contextmenu.value) {
1000
- contextmenu.value = !1
1001
- }
1002
- return
1003
- }
1004
- selected.value = [row]
1005
- dialogs.item = row
1006
- dialogs.index = index
1007
- if (isGrid.value) {
1008
- contextmenu.value = !0
998
+ row = toValue(row)
999
+ if (index === dialogs.index) {
1000
+ selected.value = []
1001
+ dialogs.item = undefined
1002
+ dialogs.index = undefined
1003
+ if (contextmenu.value) {
1004
+ contextmenu.value = !1
1009
1005
  }
1010
- })
1006
+ return
1007
+ }
1008
+ selected.value = [row]
1009
+ dialogs.item = row
1010
+ dialogs.index = index
1011
+ if (isGrid.value) {
1012
+ contextmenu.value = !0
1013
+ }
1011
1014
  }
1012
1015
  const contextmenuItemsProp = computed(() => props.contextItems)
1013
1016
  const contextmenuItems = computed<any>(() => ([
@@ -1084,7 +1087,7 @@ watch(loading, v => {
1084
1087
  $q.loading.hide()
1085
1088
  }
1086
1089
  }
1087
- tableOptions.hasAction = !!v
1090
+ tableOptions.hasAction = v
1088
1091
  })
1089
1092
  watch([filterForm, () => $q.lang.nativeName], () => refreshNoUpdate(), { deep: !0 })
1090
1093
  watch(formDialogModel, (v) => {
@@ -1191,13 +1194,13 @@ defineOptions({
1191
1194
  >
1192
1195
  <!-- Context Menu -->
1193
1196
  <MModalMenu
1197
+ v-if="false"
1194
1198
  v-model="contextmenu"
1195
1199
  class="shadow-6 relative-position"
1196
1200
  context-menu
1197
1201
  position="standard"
1198
1202
  touch-position
1199
1203
  v-bind="pluginOptions.dt?.contextmenu?.menu"
1200
- @hide="resetDialogs()"
1201
1204
  >
1202
1205
  <q-list
1203
1206
  v-if="dialogs.item"
@@ -1257,7 +1260,6 @@ defineOptions({
1257
1260
  @request="fetchDatatableItems"
1258
1261
  @update:selected="onUpdateSelectedItems"
1259
1262
  @virtual-scroll="endReach ? onScroll : undefined"
1260
- @row-contextmenu="onRowContextmenu"
1261
1263
  >
1262
1264
  <template
1263
1265
  v-for="slotName in getSlots"
@@ -1266,7 +1268,7 @@ defineOptions({
1266
1268
  >
1267
1269
  <slot
1268
1270
  :dt="datatableItemsScope"
1269
- :form="formScope"
1271
+ :form="useFormContext"
1270
1272
  :index="dialogItemIndex"
1271
1273
  :item="dialogItem"
1272
1274
  :name="slotName"
@@ -1277,7 +1279,7 @@ defineOptions({
1277
1279
  <template #item="iTempProps">
1278
1280
  <slot
1279
1281
  :dt="datatableItemsScope"
1280
- :form="formScope"
1282
+ :form="useFormContext"
1281
1283
  name="item"
1282
1284
  v-bind="iTempProps"
1283
1285
  >
@@ -1400,7 +1402,7 @@ defineOptions({
1400
1402
  >
1401
1403
  <slot
1402
1404
  :dt="datatableItemsScope"
1403
- :form="formScope"
1405
+ :form="useFormContext"
1404
1406
  :index="dialogItemIndex"
1405
1407
  :item="dialogItem"
1406
1408
  name="top"
@@ -1409,7 +1411,7 @@ defineOptions({
1409
1411
  <MRow col>
1410
1412
  <slot
1411
1413
  :dt="datatableItemsScope"
1412
- :form="formScope"
1414
+ :form="useFormContext"
1413
1415
  :index="dialogItemIndex"
1414
1416
  :item="dialogItem"
1415
1417
  name="title"
@@ -1442,7 +1444,7 @@ defineOptions({
1442
1444
  </slot>
1443
1445
  <slot
1444
1446
  :dt="datatableItemsScope"
1445
- :form="formScope"
1447
+ :form="useFormContext"
1446
1448
  :index="dialogItemIndex"
1447
1449
  :item="dialogItem"
1448
1450
  name="top-search"
@@ -1541,7 +1543,7 @@ defineOptions({
1541
1543
  </MInput>
1542
1544
  <slot
1543
1545
  :dt="datatableItemsScope"
1544
- :form="formScope"
1546
+ :form="useFormContext"
1545
1547
  :index="dialogItemIndex"
1546
1548
  :item="dialogItem"
1547
1549
  name="bottom-search"
@@ -1555,8 +1557,8 @@ defineOptions({
1555
1557
  key="more-selection-btn"
1556
1558
  :disable="tableOptions.loading"
1557
1559
  icon="ion-ios-options"
1558
- tooltip="myth.datatable.hints.more"
1559
1560
  label="myth.datatable.hints.options"
1561
+ tooltip="myth.datatable.hints.more"
1560
1562
  v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.more}"
1561
1563
  >
1562
1564
  <MModalMenu
@@ -1588,8 +1590,9 @@ defineOptions({
1588
1590
  <span> {{ getFormTitle }}</span>
1589
1591
  </q-item-section>
1590
1592
  </q-item>
1593
+ <!-- Export PDF-->
1591
1594
  <q-item
1592
- v-if="pdf"
1595
+ v-if="pdf && getRows.length > 0"
1593
1596
  v-close-popup
1594
1597
  clickable
1595
1598
  v-bind="pluginOptions.dt?.buttons?.moreItem"
@@ -1615,8 +1618,9 @@ defineOptions({
1615
1618
  </span>
1616
1619
  </q-item-section>
1617
1620
  </q-item>
1621
+ <!-- Export Excel-->
1618
1622
  <q-item
1619
- v-if="excel"
1623
+ v-if="excel && getRows.length > 0"
1620
1624
  v-close-popup
1621
1625
  clickable
1622
1626
  v-bind="pluginOptions.dt?.buttons?.moreItem"
@@ -1669,8 +1673,8 @@ defineOptions({
1669
1673
  v-if="hasFilterDialog"
1670
1674
  key="filter-selection-btn"
1671
1675
  icon="o_filter_alt"
1672
- tooltip="myth.datatable.hints.filter"
1673
1676
  label="myth.datatable.hints.filter"
1677
+ tooltip="myth.datatable.hints.filter"
1674
1678
  v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.filter}"
1675
1679
  @click="openFilterDialog()"
1676
1680
  >
@@ -1704,7 +1708,7 @@ defineOptions({
1704
1708
  <slot
1705
1709
  :dt="datatableItemsScope"
1706
1710
  :filter="tableOptions.tempFilter"
1707
- :form="formScope"
1711
+ :form="useFormContext"
1708
1712
  :index="dialogItemIndex"
1709
1713
  :item="dialogItem"
1710
1714
  name="filter"
@@ -1888,7 +1892,7 @@ defineOptions({
1888
1892
  >
1889
1893
  <slot
1890
1894
  :dt="datatableItemsScope"
1891
- :form="formScope"
1895
+ :form="useFormContext"
1892
1896
  :index="dialogItemIndex"
1893
1897
  :item="dialogItem"
1894
1898
  name="selection"
@@ -1912,7 +1916,7 @@ defineOptions({
1912
1916
  >
1913
1917
  <slot
1914
1918
  :dt="datatableItemsScope"
1915
- :form="formScope"
1919
+ :form="useFormContext"
1916
1920
  :index="dialogItemIndex"
1917
1921
  :item="dialogItem"
1918
1922
  :name="`body-cell-${controlKey}`"
@@ -2006,7 +2010,7 @@ defineOptions({
2006
2010
  </q-table>
2007
2011
  <slot
2008
2012
  :dt="datatableItemsScope"
2009
- :form="formScope"
2013
+ :form="useFormContext"
2010
2014
  :index="dialogItemIndex"
2011
2015
  :item="dialogItem"
2012
2016
  name="default"
@@ -2043,7 +2047,7 @@ defineOptions({
2043
2047
  >
2044
2048
  <slot
2045
2049
  :dt="datatableItemsScope"
2046
- :form="formScope"
2050
+ :form="useFormContext"
2047
2051
  :index="dialogItemIndex"
2048
2052
  :item="dialogItem"
2049
2053
  name="show"
@@ -2080,14 +2084,14 @@ defineOptions({
2080
2084
  <q-toolbar :class="{'q-pa-none': $q.screen.lt.md}">
2081
2085
  <slot
2082
2086
  :dt="datatableItemsScope"
2083
- :form="formScope"
2087
+ :form="useFormContext"
2084
2088
  :index="dialogItemIndex"
2085
2089
  :item="dialogItem"
2086
2090
  name="form-title-left"
2087
2091
  />
2088
2092
  <slot
2089
2093
  :dt="datatableItemsScope"
2090
- :form="formScope"
2094
+ :form="useFormContext"
2091
2095
  :index="dialogItemIndex"
2092
2096
  :item="dialogItem"
2093
2097
  name="form-title"
@@ -2113,7 +2117,7 @@ defineOptions({
2113
2117
  </slot>
2114
2118
  <slot
2115
2119
  :dt="datatableItemsScope"
2116
- :form="formScope"
2120
+ :form="useFormContext"
2117
2121
  :index="dialogItemIndex"
2118
2122
  :item="dialogItem"
2119
2123
  name="form-title-right"
@@ -2150,7 +2154,7 @@ defineOptions({
2150
2154
  <slot
2151
2155
  v-else
2152
2156
  :dt="datatableItemsScope"
2153
- :form="formScope"
2157
+ :form="useFormContext"
2154
2158
  :index="dialogItemIndex"
2155
2159
  :item="dialogItem"
2156
2160
  name="form"
@@ -2163,7 +2167,7 @@ defineOptions({
2163
2167
  >
2164
2168
  <slot
2165
2169
  :dt="datatableItemsScope"
2166
- :form="formScope"
2170
+ :form="useFormContext"
2167
2171
  :index="dialogItemIndex"
2168
2172
  :item="dialogItem"
2169
2173
  name="form-actions"
@@ -15,7 +15,7 @@ import { useTemplateRef } from 'vue'
15
15
  import MInput from './MInput.vue'
16
16
  import { useMyth } from '../../composable'
17
17
 
18
- const { props: pluginOptions } = useMyth()
18
+ const { props: pluginOptions, mobileRule: mobile } = useMyth()
19
19
  const modelValue = defineModel<Props['modelValue']>({ required: !1, default: undefined })
20
20
  const input = useTemplateRef<InstanceType<typeof MInput>>('input')
21
21
  defineExpose<{ input: typeof input }>({ input })
@@ -29,8 +29,7 @@ defineOptions({
29
29
  <MInput
30
30
  ref="input"
31
31
  v-model="modelValue"
32
- type="tel"
33
- v-bind="{...pluginOptions.mobile as any,...$attrs}"
32
+ v-bind="{ type: 'tel', mobile, maxlength:mobile === !0 ? 10 : (mobile ?? 10), ...pluginOptions.mobile as any, ...$attrs }"
34
33
  >
35
34
  <template
36
35
  v-for="(_,slot) in $slots as Readonly<MInputSlots>"
@@ -108,7 +108,10 @@ const onBeforeHide = () => {
108
108
  dateRef.value = null
109
109
  }
110
110
  const saveDialog = () => {
111
- let newVal: any = dateRef.value
111
+ let newVal: any = dateRef.value ?? null
112
+ if (!newVal) {
113
+ return
114
+ }
112
115
  if (typeof newVal === 'object' && isDate.value) {
113
116
  const values: any[] = Object.values(newVal)
114
117
  for (const aKey in values) {
@@ -208,6 +211,7 @@ defineOptions({
208
211
  <q-btn
209
212
  v-if="!disable && !readonly && !viewMode"
210
213
  :icon="isDate ? 'ion-ios-calendar' : 'ion-ios-clock'"
214
+ :color="!!errorMessage ? 'negative' : undefined"
211
215
  flat
212
216
  round
213
217
  v-bind="{...pluginOptions?.pickerBtn, ...btnProps}"
@@ -318,6 +318,8 @@ defineOptions({
318
318
  #[slot]="inputSlot"
319
319
  >
320
320
  <slot
321
+ :items="getOptions"
322
+ :value="value"
321
323
  :name="slot"
322
324
  v-bind="inputSlot || {}"
323
325
  />
@@ -53,7 +53,7 @@ defineOptions({
53
53
  <template>
54
54
  <div
55
55
  :class="classes"
56
- v-bind="{...$attrs,':data-input-name': name??undefined}"
56
+ v-bind="{...$attrs,'data-input-name': name ?? undefined}"
57
57
  >
58
58
  <slot />
59
59
  </div>
@@ -64,6 +64,9 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
64
64
  if (typeof val === 'string' && val?.length > 0) {
65
65
  return val
66
66
  }
67
+ if (val === !0) {
68
+ return 'choose'
69
+ }
67
70
  return 'enter'
68
71
  })
69
72
  if (props.placeholder === undefined) {
@@ -139,7 +139,7 @@ pre
139
139
 
140
140
  .m--input__top-label__content::after
141
141
  content: ' *'
142
-
142
+ color: q.$red
143
143
 
144
144
  .m--input__color-preview
145
145
  border: 1px solid q.$primary
@@ -678,7 +678,7 @@ export interface MHiddenSlots {
678
678
  default: () => VNode[];
679
679
  }
680
680
 
681
- export type MFormScope = FormContext<Record<string, any>>;
681
+ export type MFormScope = FormContext<Record<string, any>, Record<string, any>>;
682
682
 
683
683
  export interface MFormProps {
684
684
  /**
@@ -1208,6 +1208,7 @@ declare module '@vue/runtime-core' {
1208
1208
  MForm: GlobalComponentConstructor<MFormProps, MFormSlots>;
1209
1209
  MHidden: GlobalComponentConstructor<MHiddenProps, MHiddenSlots>;
1210
1210
  MHiddenInput: GlobalComponentConstructor<MHiddenInputProps, MHiddenInputSlots>;
1211
+ MInput: GlobalComponentConstructor<MInputProps, MInputSlots>;
1211
1212
  MInputFieldControl: GlobalComponentConstructor<MInputFieldControlProps, MInputFieldControlSlots>;
1212
1213
  MInputLabel: GlobalComponentConstructor<MInputLabelProps, MInputLabelSlots>;
1213
1214
  MMobile: GlobalComponentConstructor<MInputProps, MInputSlots>;
@@ -33,4 +33,9 @@ export interface MythApi {
33
33
  * Add custom rules of vee-validate.
34
34
  */
35
35
  rules: string[];
36
+ /**
37
+ * Define mobile rule.
38
+ * Default is true. Length must be 10.
39
+ */
40
+ mobileRule?: boolean | string | number;
36
41
  }
@@ -11,21 +11,26 @@ export const createMyth = (options: InstallOptions) => {
11
11
  services: {},
12
12
  axios: {} as AxiosInstance
13
13
  },
14
- props: {},
15
- rules: [],
16
14
  theme: {
17
15
  size: 'md',
18
16
  rounded: !0,
19
17
  shadow: 2,
20
18
  fluid: !0,
21
19
  buttons: {},
22
- inputs: {},
20
+ inputs: {
21
+ hideBottomSpace: !0,
22
+ noErrorIcon: !0,
23
+ clearIcon: 'clear'
24
+ },
23
25
  buttonLoading: {
24
26
  type: 'spinner',
25
27
  color: undefined,
26
28
  size: undefined
27
29
  } as MythApi['theme']['buttonLoading']
28
- }
30
+ },
31
+ props: {},
32
+ rules: [],
33
+ mobileRule: !0
29
34
  } as MythApi
30
35
  const opts = reactive<MythApi>(extend<MythApi>(!0, { ...defaultOptions }, options))
31
36
  const functions = {