@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
|
@@ -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
|
-
|
|
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 =
|
|
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 {
|
|
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
|
|
122
|
-
const defaultOptions
|
|
123
|
-
controlKey: 'control'
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const noSort =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
145
|
-
if (typeof elm !== 'string' && !elm?.name)
|
|
146
|
-
|
|
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
|
|
149
|
-
label: elm
|
|
150
|
-
field: elm
|
|
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
|
-
|
|
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
|
-
|
|
213
|
-
|
|
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
|
-
}
|
|
203
|
+
}
|
|
204
|
+
if (item.sortable === undefined) {
|
|
220
205
|
item.sortable = !0
|
|
221
206
|
}
|
|
222
|
-
|
|
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 (
|
|
227
|
-
if (typeof
|
|
228
|
-
res.push(
|
|
212
|
+
if (rowClass) {
|
|
213
|
+
if (typeof rowClass === 'function') {
|
|
214
|
+
res.push(rowClass(row))
|
|
229
215
|
} else {
|
|
230
|
-
res.push(
|
|
216
|
+
res.push(rowClass)
|
|
231
217
|
}
|
|
232
218
|
}
|
|
233
219
|
if (current) {
|
package/src/types/m-helpers.d.ts
CHANGED
|
@@ -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
|
|
18
|
+
controlAlign?: 'left' | 'right' | 'center' | undefined;
|
|
17
19
|
align?: 'left' | 'right' | 'center' | undefined;
|
|
18
20
|
sortable?: boolean | undefined;
|
|
19
|
-
|
|
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
|
|