@ithinkdt/ui 4.0.0-30 → 4.0.0-31
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 +2 -2
- package/src/components/DataTable.jsx +49 -7
- package/src/components.d.ts +2 -0
- package/src/page.d.ts +28 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ithinkdt/ui",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "iThinkDT UI",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"vite": "npm:rolldown-vite@^7.1.19",
|
|
89
89
|
"vue": "^3.5.22",
|
|
90
90
|
"vue-router": "^4.6.3",
|
|
91
|
-
"@ithinkdt/page": "^4.0.0-
|
|
91
|
+
"@ithinkdt/page": "^4.0.0-31"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
94
94
|
"release": "pnpm publish --no-git-checks"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { toReactive, unrefElement, until } from '@vueuse/core'
|
|
2
|
-
import { NButton, NDataTable, NFlex, NIcon, NPerformantEllipsis, NTooltip } from 'ithinkdt-ui'
|
|
2
|
+
import { NButton, NDataTable, NFlex, NIcon, NPerformantEllipsis, NTooltip, dataTableProps } from 'ithinkdt-ui'
|
|
3
3
|
import { Sortable } from 'sortablejs'
|
|
4
4
|
import { computed, defineComponent, inject, mergeProps, nextTick, ref, shallowRef, toValue, useTemplateRef, watch, withDirectives } from 'vue'
|
|
5
5
|
|
|
6
6
|
import { PAGE_INJECTION } from '@ithinkdt/page'
|
|
7
7
|
|
|
8
8
|
import { vTooltip } from '../directives/index.js'
|
|
9
|
-
import { useClsPrefix } from '../use-style.js'
|
|
9
|
+
import useStyle, { c, cB, cE, useClsPrefix } from '../use-style.js'
|
|
10
10
|
|
|
11
11
|
import { IHelp } from './assets.jsx'
|
|
12
12
|
|
|
@@ -124,13 +124,20 @@ export const DataTable = /* @__PURE__ */ defineComponent({
|
|
|
124
124
|
selectedKeys: {
|
|
125
125
|
type: Array,
|
|
126
126
|
},
|
|
127
|
+
highlight: {
|
|
128
|
+
type: [Boolean, String, Number, Object],
|
|
129
|
+
default: true,
|
|
130
|
+
},
|
|
131
|
+
rowClassName: dataTableProps.rowClassName,
|
|
132
|
+
rowProps: dataTableProps.rowProps,
|
|
127
133
|
},
|
|
128
|
-
emits: ['sort', 'select', 'custom'],
|
|
134
|
+
emits: ['sort', 'select', 'custom', 'highlight'],
|
|
129
135
|
setup(props, { slots, emit, expose }) {
|
|
130
136
|
const { keyField } = inject(PAGE_INJECTION)
|
|
131
137
|
|
|
132
138
|
const clsPrefix = useClsPrefix()
|
|
133
|
-
const cls = `${clsPrefix.value}-
|
|
139
|
+
const cls = `${clsPrefix.value}-datatable`
|
|
140
|
+
useStyle('-datatable', style, clsPrefix)
|
|
134
141
|
|
|
135
142
|
const tableRef = useTemplateRef('table-ref')
|
|
136
143
|
|
|
@@ -162,7 +169,7 @@ export const DataTable = /* @__PURE__ */ defineComponent({
|
|
|
162
169
|
exposed.value.scrollToView = (key) => {
|
|
163
170
|
const index = props.data.findIndex(row => rowKey.value(row) === key)
|
|
164
171
|
if (index === -1) return
|
|
165
|
-
const row = tableRef.value.$el.querySelector(`.${cls}-
|
|
172
|
+
const row = tableRef.value.$el.querySelector(`.${cls}__row-marker:nth-child(${index + 1})`)
|
|
166
173
|
tableRef.value.scrollTo({
|
|
167
174
|
top: row.offsetTop,
|
|
168
175
|
behavior: 'smooth',
|
|
@@ -181,10 +188,33 @@ export const DataTable = /* @__PURE__ */ defineComponent({
|
|
|
181
188
|
columns.value = _map(props.columns, width)
|
|
182
189
|
}, { immediate: true, deep: 1 })
|
|
183
190
|
|
|
191
|
+
const highlightKey = ref()
|
|
192
|
+
watch(() => props.highlight, (val) => {
|
|
193
|
+
highlightKey.value = typeof val === 'boolean' ? null : (val ?? null)
|
|
194
|
+
}, { immediate: true })
|
|
184
195
|
const rowClassName = computed(() => {
|
|
185
196
|
return (row, i) => {
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
return [
|
|
198
|
+
props.rowClassName?.(row, i) || '',
|
|
199
|
+
`${cls}__row-marker`,
|
|
200
|
+
(highlightKey.value != null && rowKey.value(row) === highlightKey.value) ? `${cls}__row-highlight` : '',
|
|
201
|
+
].join(' ')
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
const rowProps = computed(() => {
|
|
205
|
+
return (row, i) => {
|
|
206
|
+
const props2 = props.rowProps?.(row, i)
|
|
207
|
+
return {
|
|
208
|
+
...props2,
|
|
209
|
+
onClick: (e) => {
|
|
210
|
+
const key = rowKey.value(row)
|
|
211
|
+
if (props.highlight === true) {
|
|
212
|
+
highlightKey.value = key
|
|
213
|
+
}
|
|
214
|
+
emit('highlight', key)
|
|
215
|
+
props2?.onClick?.(e)
|
|
216
|
+
},
|
|
217
|
+
}
|
|
188
218
|
}
|
|
189
219
|
})
|
|
190
220
|
|
|
@@ -221,6 +251,7 @@ export const DataTable = /* @__PURE__ */ defineComponent({
|
|
|
221
251
|
ref="table-ref"
|
|
222
252
|
scrollX={width.value}
|
|
223
253
|
rowClassName={rowClassName.value}
|
|
254
|
+
rowProps={rowProps.value}
|
|
224
255
|
checkedRowKeys={props.selectedKeys}
|
|
225
256
|
onUpdateSorter={onUpdateSorter}
|
|
226
257
|
onUpdateCheckedRowKeys={onUpdateCheckedRowKeys}
|
|
@@ -232,6 +263,17 @@ export const DataTable = /* @__PURE__ */ defineComponent({
|
|
|
232
263
|
},
|
|
233
264
|
})
|
|
234
265
|
|
|
266
|
+
const style = /* @__PURE__ */ cB(
|
|
267
|
+
'datatable',
|
|
268
|
+
[
|
|
269
|
+
cE('row-highlight', [
|
|
270
|
+
c('& > td', {
|
|
271
|
+
backgroundColor: 'var(--n-tr-highlight-color, var(--n-merged-border-color)) !important',
|
|
272
|
+
}),
|
|
273
|
+
]),
|
|
274
|
+
],
|
|
275
|
+
)
|
|
276
|
+
|
|
235
277
|
export function useDataTableDrag(
|
|
236
278
|
tableRef,
|
|
237
279
|
{ data, onSort, ...options }) {
|
package/src/components.d.ts
CHANGED
|
@@ -149,6 +149,7 @@ export type DataTableProps<Data extends {}, KeyField extends keyof Data>
|
|
|
149
149
|
data?: Data[] | undefined
|
|
150
150
|
keyField?: KeyField | undefined
|
|
151
151
|
selectedKeys?: Data[KeyField][] | undefined
|
|
152
|
+
highlight?: boolean | Data[KeyField] | undefined
|
|
152
153
|
sorter?: SortParams<Data> | undefined
|
|
153
154
|
onSort?: MaybeArray<(param: SortParams<Data>) => void> | undefined
|
|
154
155
|
onSelect?: MaybeArray<(param: NonNullable<Data[KeyField]>[]) => void> | undefined
|
|
@@ -157,6 +158,7 @@ export type DataTableProps<Data extends {}, KeyField extends keyof Data>
|
|
|
157
158
|
export type DataTableEmits<Data extends {}, KeyField extends keyof Data> = {
|
|
158
159
|
(e: 'sort', param: SortParams<Data>): void
|
|
159
160
|
(e: 'select', param: Data[KeyField][]): void
|
|
161
|
+
(e: 'highlight', rowKey: Data[KeyField]): void
|
|
160
162
|
(e: 'custom', params: { key: string, width: number }): void
|
|
161
163
|
}
|
|
162
164
|
|
package/src/page.d.ts
CHANGED
|
@@ -7,39 +7,40 @@ import {
|
|
|
7
7
|
SelectGroupOption, SelectOption, SelectProps, SelectSlots,
|
|
8
8
|
UploadFileInfo, UploadProps,
|
|
9
9
|
} from 'ithinkdt-ui'
|
|
10
|
-
import { MaybeRef, VNode
|
|
10
|
+
import { MaybeRef, VNode } from 'vue'
|
|
11
11
|
|
|
12
|
+
import { PublicProps } from '@ithinkdt/common'
|
|
12
13
|
import { DictItem, DictTypeKey } from '@ithinkdt/common/dict'
|
|
13
14
|
import { PageOptions } from '@ithinkdt/page'
|
|
14
15
|
|
|
15
16
|
import { CheckboxesProps, RadiosProps, UserDeptProps, UserGroupOption } from './components'
|
|
16
17
|
|
|
17
|
-
type
|
|
18
|
+
type ShallowMaybeRef<T extends {}> = {
|
|
18
19
|
[Key in (keyof T)]: MaybeRef<T[Key]>
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
declare module '@ithinkdt/page' {
|
|
22
23
|
interface FormComponentPresets {
|
|
23
24
|
input: {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
inputProps?: ShallowMaybeRef<Omit<InputProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
|
|
26
|
+
inputSlots?: InputSlots
|
|
26
27
|
}
|
|
27
28
|
number: {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
numberProps?: ShallowMaybeRef<Omit<InputNumberProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
|
|
30
|
+
numberSlots?: InputNumberSlots
|
|
30
31
|
}
|
|
31
32
|
select: {
|
|
32
|
-
|
|
33
|
+
selectProps?: ShallowMaybeRef<Omit<SelectProps, 'options' | 'value' | 'onUpdate:value' | 'disabled'> & PublicProps
|
|
33
34
|
& {
|
|
34
35
|
dictType?: DictTypeKey | undefined
|
|
35
36
|
options?: DictItem[] | (SelectOption | SelectGroupOption)[] | undefined
|
|
36
37
|
}>
|
|
37
|
-
|
|
38
|
+
selectSlots?: SelectSlots
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
checkbox: {
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
checkboxProps?: ShallowMaybeRef<Omit<CheckboxProps, 'checked' | 'onUpdate:checked' | 'disabled'>> & PublicProps
|
|
43
|
+
checkboxSlots?: {
|
|
43
44
|
default?: (() => VNode[]) | undefined
|
|
44
45
|
checked?: (() => VNode[]) | undefined
|
|
45
46
|
unchecked?: (() => VNode[]) | undefined
|
|
@@ -47,59 +48,59 @@ declare module '@ithinkdt/page' {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
checkboxes: {
|
|
50
|
-
|
|
51
|
+
checkboxesProps?: ShallowMaybeRef<Omit<CheckboxesProps, 'disabled'> & PublicProps
|
|
51
52
|
& {
|
|
52
53
|
dictType?: DictTypeKey | undefined
|
|
53
54
|
options?: DictItem[] | undefined
|
|
54
55
|
}>
|
|
55
|
-
|
|
56
|
+
checkboxesSlots?: { }
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
radios: {
|
|
59
|
-
|
|
60
|
+
radiosProps?: ShallowMaybeRef<Omit<RadiosProps, 'disabled'> & PublicProps
|
|
60
61
|
& {
|
|
61
62
|
dictType?: DictTypeKey | undefined
|
|
62
63
|
options?: DictItem[] | undefined
|
|
63
64
|
}>
|
|
64
|
-
|
|
65
|
+
radiosSlots?: { }
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
datepicker: {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
datepickerProps?: ShallowMaybeRef<Omit<DatePickerProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
|
|
70
|
+
datepickerSlots?: DatePickerSlots
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
file: {
|
|
73
|
-
|
|
74
|
+
fileProps?: ShallowMaybeRef<{
|
|
74
75
|
type?: 'file' | 'image' | undefined
|
|
75
76
|
multiple?: boolean | undefined
|
|
76
77
|
max?: number | undefined
|
|
77
78
|
accept?: string | undefined
|
|
78
79
|
maxSize?: number | undefined
|
|
79
80
|
onBeforeUpload?: UploadProps['onBeforeUpload']
|
|
80
|
-
} &
|
|
81
|
-
|
|
81
|
+
} & PublicProps>
|
|
82
|
+
fileSlots?: {
|
|
82
83
|
default?: (() => VNode[]) | undefined
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
upload: {
|
|
86
|
-
|
|
87
|
+
uploadProps?: ShallowMaybeRef<{
|
|
87
88
|
type?: 'file' | 'image' | undefined
|
|
88
89
|
multiple?: boolean | undefined
|
|
89
90
|
max?: number | undefined
|
|
90
91
|
accept?: string | undefined
|
|
91
92
|
maxSize?: number | undefined
|
|
92
93
|
onBeforeUpload?: UploadProps['onBeforeUpload']
|
|
93
|
-
} &
|
|
94
|
-
|
|
94
|
+
} & PublicProps>
|
|
95
|
+
uploadSlots?: {
|
|
95
96
|
default?: (() => VNode[]) | undefined
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
user: {
|
|
100
|
-
|
|
101
|
-
| 'users' | 'groups' | 'depts' | 'getUsersByGroup' | 'getUsersByDept'>> &
|
|
102
|
-
|
|
101
|
+
uploadProps?: ShallowMaybeRef<Omit<UserDeptProps<boolean>, 'modelValue' | 'onUpdate:modelValue' | 'disabled'
|
|
102
|
+
| 'users' | 'groups' | 'depts' | 'getUsersByGroup' | 'getUsersByDept'>> & PublicProps
|
|
103
|
+
uploadSlots?: {}
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
|
|
@@ -143,9 +144,9 @@ declare module '@ithinkdt/page' {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
type ModalOptionsKey = 'type' | keyof import('@ithinkdt/page').ModalOptions
|
|
146
|
-
interface ModalDrawerOptions extends
|
|
147
|
+
interface ModalDrawerOptions extends ShallowMaybeRef<Omit<DrawerContentProps, ModalOptionsKey>>, ShallowMaybeRef<Omit<DrawerProps, ModalOptionsKey>> { }
|
|
147
148
|
|
|
148
|
-
interface ModalDialogOptions extends
|
|
149
|
+
interface ModalDialogOptions extends ShallowMaybeRef<Omit<ModalOptions, ModalOptionsKey>> {}
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
export declare function createPageFormHelper(options?: {
|