@mythpe/quasar-ui-qui 0.4.34 → 0.4.37

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.4.34",
3
+ "version": "0.4.37",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -130,7 +130,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>, emit?:
130
130
  controlKey: controlProps.value.name,
131
131
  controlStyle: controlProps.value.style,
132
132
  align: getProp.value('align'),
133
- classes: props.rowClass
133
+ rowClass: props.rowClass
134
134
  } as any
135
135
  const h = parseHeaders(props.headers as MDtHeadersParameter, opt) || []
136
136
  if (!activeContextItems.value.length) {
@@ -421,7 +421,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>, emit?:
421
421
  const ex = async () => {
422
422
  loading.value = !0
423
423
  const toBLob = exportToBlob.value === !0 || exportToBlob.value === type
424
- const headerItems = getHeaders.value.filter(e => e?.field !== controlKey.value && visibleHeaders.value.indexOf(e.name) !== -1)
424
+ const headerItems = getSortedHeaders.value.filter(e => e?.name !== controlKey.value && visibleHeaders.value.indexOf(e.name) !== -1)
425
425
  const data = getDatatableParams({
426
426
  pagination: pagination.value,
427
427
  filter: search.value
@@ -13,7 +13,8 @@ import type { QDialogOptions, QDialogProps, QNotifyCreateOptions } from 'quasar'
13
13
  import { colors, copyToClipboard, extend, useQuasar } from 'quasar'
14
14
  import { Helpers, MythKey, type MythType, Str, veeRules } from '../utils'
15
15
  import type { MDtColumn, MDtHeadersParameter, ParseHeaderOptions, Vue3MAlertMessage, Vue3MAlertMessageOptions, Vue3MConfirmMessage } from '../types'
16
- import { computed, inject } from 'vue'
16
+ import type { MaybeRefOrGetter } from 'vue'
17
+ import { computed, inject, toValue } from 'vue'
17
18
 
18
19
  export const useMyth = () => {
19
20
  const plugin = inject(MythKey) as MythType
@@ -118,41 +119,40 @@ export const useMyth = () => {
118
119
  * @param headers
119
120
  * @param options
120
121
  */
121
- const parseHeaders = (headers: MDtHeadersParameter, options: ParseHeaderOptions = {}): MDtColumn[] => {
122
- const defaultOptions: Partial<ParseHeaderOptions> = {
123
- controlKey: 'control'
124
- // controlStyle: 'max-width: 150 px',
125
- // align: 'center'
126
- // sortable: !0
122
+ const parseHeaders = (headers: MaybeRefOrGetter<MDtHeadersParameter>, options: MaybeRefOrGetter<ParseHeaderOptions> = {}): MDtColumn[] => {
123
+ const defaultOptions = {
124
+ controlKey: 'control',
125
+ controlStyle: 'max-width: 150px',
126
+ controlAlign: 'right',
127
+ align: 'left',
128
+ sortable: !0
127
129
  }
128
- const opts = extend<ParseHeaderOptions>(!0, {}, defaultOptions, options)
129
- // console.log(opts)
130
- const control: string | undefined = opts.controlKey || defaultOptions.controlKey
131
- const controlStyle: string | undefined = opts.controlStyle || defaultOptions.controlStyle
132
- const noSort = options.noSort || []
133
- // delete opts.noSort
134
- // if (opts.controlKey) {
135
- // control = opts.controlKey
136
- // delete opts.controlKey
137
- // }
138
- // if (opts.controlStyle) {
139
- // controlStyle = opts.controlStyle
140
- // delete opts.controlStyle
141
- // }
130
+ const opts = extend<ParseHeaderOptions>(!0, {}, defaultOptions, toValue(options))
131
+ const control: string = opts.controlKey || defaultOptions.controlKey
132
+ const controlStyle: string | undefined = opts.controlStyle
133
+ const controlAlign: string | undefined = opts.controlAlign
134
+ const noSort = opts.noSort || []
135
+ const rowClass = opts.rowClass
136
+ delete opts.controlKey
137
+ delete opts.controlStyle
138
+ delete opts.controlAlign
139
+ delete opts.rowClass
142
140
  const result: MDtColumn[] = []
143
-
144
- headers.forEach((elm: string | MDtColumn | undefined) => {
145
- if (typeof elm !== 'string' && !elm?.name) return elm
146
- // Todo: will do this
141
+ const h = toValue(headers)
142
+ h.forEach((elm: string | MDtColumn | undefined) => {
143
+ if (typeof elm !== 'string' && !elm?.name) {
144
+ return elm
145
+ }
147
146
  let item: MDtColumn = typeof elm === 'string' ? {
148
- name: elm as string,
149
- label: elm as string,
150
- field: elm as string
147
+ name: elm,
148
+ label: elm,
149
+ field: elm
151
150
  } : { ...elm }
152
151
  item.name = item.name ?? ''
153
152
  item.label = (item.label === undefined || item.label === null) ? item.name : item.label
154
153
  item.field = (item.field === undefined || item.field === null) ? item.name : item.field
155
154
  item = {
155
+ ...opts,
156
156
  ...item,
157
157
  name: Str.strBefore(Str.strBefore(item.name), 'ToString'),
158
158
  label: (item.label !== undefined && item.label !== null) ? Str.strBefore(Str.strBefore(item.label), 'ToString') : item.label
@@ -194,40 +194,26 @@ export const useMyth = () => {
194
194
  item.headerClasses = (item.headerClasses ? item.headerClasses : '') + ' m-control-header'
195
195
  item.headerClasses = item.headerClasses.trim()
196
196
  item.sortable = !1
197
- if (opts.controlAlign) {
198
- item.align = opts.controlAlign
199
- } else if (!item.align) {
200
- // console.log(item)
201
- item.align = 'right'
202
- }
203
- // opts.classes = opts.classes || ''
204
- if (typeof opts.classes === 'function') {
205
- const callback = opts.classes
206
- opts.classes = (item) => (callback(item) || '') + ' m-control-cell'
207
- } else if (typeof opts.classes === 'string') {
208
- opts.classes += ' m-control-cell'
209
- opts.classes = opts.classes.trim()
210
- }
197
+ item.align = controlAlign ?? item.align ?? defaultOptions.controlAlign
211
198
  }
212
- if (!item.align) {
213
- item.align = 'left'
214
- }
215
- // item = { ...opts, ...item }
216
-
199
+ item.align = item.align ?? defaultOptions.align
200
+ // console.log(item)
217
201
  if (item.sortable === undefined && noSort.length > 0 && noSort.includes(item.name)) {
218
202
  item.sortable = !1
219
- } else if (item.sortable === undefined) {
203
+ }
204
+ if (item.sortable === undefined) {
220
205
  item.sortable = !0
221
206
  }
222
- if ((item.classes || opts.classes) && name !== control) {
207
+
208
+ if ((item.classes || rowClass) && name !== control) {
223
209
  const current = item.classes
224
210
  item.classes = (row: any) => {
225
211
  const res: string[] = []
226
- if (opts.classes) {
227
- if (typeof opts.classes === 'function') {
228
- res.push(opts.classes(row))
212
+ if (rowClass) {
213
+ if (typeof rowClass === 'function') {
214
+ res.push(rowClass(row))
229
215
  } else {
230
- res.push(opts.classes)
216
+ res.push(rowClass)
231
217
  }
232
218
  }
233
219
  if (current) {
@@ -10,17 +10,18 @@ import type { AxiosError, AxiosResponse } from 'axios'
10
10
  import type { DialogChainObject, QNotifyCreateOptions, QNotifyUpdateOptions, QTableProps } from 'quasar'
11
11
  import type { MDatatableProps } from './m-datatable'
12
12
 
13
+ export type MDtColumn = QTableProps['columns'][number]
14
+
13
15
  export type ParseHeaderOptions = {
14
16
  controlKey?: 'control' | string;
15
17
  controlStyle?: 'max-width: 150px' | string;
16
- controlAlign?: 'left' | 'right' | 'center' | undefined | null;
18
+ controlAlign?: 'left' | 'right' | 'center' | undefined;
17
19
  align?: 'left' | 'right' | 'center' | undefined;
18
20
  sortable?: boolean | undefined;
19
- classes?: string | (() => string) | (<T>(item: T) => string);
21
+ rowClass?: string | (() => string) | (<T>(item: T) => string);
20
22
  noSort?: string[];
21
- }
22
-
23
- export type MDtColumn = QTableProps['columns'][number]
23
+ // [k: string]: any;
24
+ } & MDtColumn
24
25
 
25
26
  export type MDtHeadersParameter = MDtColumn[] | (keyof MDatatableProps['defaultItem'])[]
26
27