@ithinkdt/ui 4.0.0-19 → 4.0.0-200
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/auto-imports.js +1 -1
- package/dist/components-BoVUU6GJ.js +1736 -0
- package/dist/components.js +5 -0
- package/dist/directives-DUuJW647.js +183 -0
- package/dist/directives.js +3 -0
- package/dist/index.js +1224 -0
- package/dist/page.js +519 -0
- package/dist/use-i18n-Dx7V4KrY.js +6 -0
- package/dist/use-style-DcT-1dj4.js +29 -0
- package/dist/use-style.js +2 -0
- package/{src → esm}/components.d.ts +63 -17
- package/esm/components.js +1 -0
- package/{src → esm}/design.d.ts +9 -0
- package/esm/directives.js +1 -0
- package/esm/index.js +1 -0
- package/{src → esm}/page.d.ts +43 -26
- package/esm/page.js +1 -0
- package/esm/use-style.js +1 -0
- package/locale.d.ts +4 -0
- package/package.json +31 -28
- package/unocss-preset.d.ts +5 -0
- package/unocss-preset.js +163 -0
- package/src/components/Checkboxes.jsx +0 -130
- package/src/components/DataActions.jsx +0 -105
- package/src/components/DataCustom.jsx +0 -172
- package/src/components/DataFilter.jsx +0 -113
- package/src/components/DataForm.jsx +0 -264
- package/src/components/DataLocaleInput.jsx +0 -121
- package/src/components/DataPagination.jsx +0 -62
- package/src/components/DataSelection.jsx +0 -57
- package/src/components/DataTable.jsx +0 -255
- package/src/components/Radios.jsx +0 -134
- package/src/components/UserDept.jsx +0 -643
- package/src/components/assets.jsx +0 -274
- package/src/components/index.js +0 -11
- package/src/design/Account.jsx +0 -152
- package/src/design/Appearance.jsx +0 -89
- package/src/design/Breadcrumb.jsx +0 -67
- package/src/design/Fullscreen.jsx +0 -65
- package/src/design/Language.jsx +0 -45
- package/src/design/Layout.jsx +0 -241
- package/src/design/Logo.jsx +0 -92
- package/src/design/Menu.jsx +0 -133
- package/src/design/MultiTabs.jsx +0 -501
- package/src/design/Notification.jsx +0 -311
- package/src/design/common.jsx +0 -21
- package/src/design/index.js +0 -10
- package/src/directives/index.js +0 -2
- package/src/directives/spin.js +0 -181
- package/src/directives/tooltip.jsx +0 -121
- package/src/index.js +0 -18
- package/src/page.jsx +0 -628
- package/src/use-i18n.js +0 -8
- package/src/use-style.js +0 -58
- package/src/utils.js +0 -20
- package/unocss.d.ts +0 -5
- package/unocss.js +0 -95
- /package/{src → esm}/directives.d.ts +0 -0
- /package/{src → esm}/index.d.ts +0 -0
- /package/{src → esm}/use-style.d.ts +0 -0
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { toReactive, unrefElement, until } from '@vueuse/core'
|
|
2
|
-
import { NButton, NDataTable, NFlex, NIcon, NPerformantEllipsis, NTooltip } from 'ithinkdt-ui'
|
|
3
|
-
import { Sortable } from 'sortablejs'
|
|
4
|
-
import { computed, defineComponent, inject, mergeProps, nextTick, ref, shallowRef, toValue, useTemplateRef, watch, withDirectives } from 'vue'
|
|
5
|
-
|
|
6
|
-
import { PAGE_INJECTION } from '@ithinkdt/page'
|
|
7
|
-
|
|
8
|
-
import { vTooltip } from '../directives/index.js'
|
|
9
|
-
import { useClsPrefix } from '../use-style.js'
|
|
10
|
-
|
|
11
|
-
import { IHelp } from './assets.jsx'
|
|
12
|
-
|
|
13
|
-
function _map(columns, width) {
|
|
14
|
-
return (columns ?? [])
|
|
15
|
-
.map((col) => {
|
|
16
|
-
const column = {
|
|
17
|
-
csvTitle: col.exportTitle,
|
|
18
|
-
...col,
|
|
19
|
-
title: () => {
|
|
20
|
-
const title0 = toValue(col.title)
|
|
21
|
-
const title = title0
|
|
22
|
-
? withDirectives(<span>{title0}</span>, [[vTooltip, () => toValue(col.title), undefined, { auto: true }]])
|
|
23
|
-
: title0
|
|
24
|
-
if (!col.tooltip) return title
|
|
25
|
-
return (
|
|
26
|
-
<NFlex size={3} wrap={false} inline style="max-width: 100%">
|
|
27
|
-
{title}
|
|
28
|
-
|
|
29
|
-
<NTooltip>
|
|
30
|
-
{{
|
|
31
|
-
default: toValue(col.tooltip),
|
|
32
|
-
trigger: () => (
|
|
33
|
-
<NButton text style="font-size: 1.25em; opacity: 0.8">
|
|
34
|
-
<NIcon>
|
|
35
|
-
<IHelp />
|
|
36
|
-
</NIcon>
|
|
37
|
-
</NButton>
|
|
38
|
-
),
|
|
39
|
-
}}
|
|
40
|
-
</NTooltip>
|
|
41
|
-
</NFlex>
|
|
42
|
-
)
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (col.children?.length) {
|
|
47
|
-
column.children = _map(col.children, width.value)
|
|
48
|
-
} else {
|
|
49
|
-
if (col.hidden !== true) {
|
|
50
|
-
column.width ??= 100
|
|
51
|
-
width.value += Number(column.width)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const render0 = col.render ?? (v => v)
|
|
55
|
-
if (col.ellipsis !== false) {
|
|
56
|
-
column.ellipsis = false
|
|
57
|
-
column.render = (...params) => {
|
|
58
|
-
const vnode = render0(...params)
|
|
59
|
-
return (
|
|
60
|
-
<NPerformantEllipsis
|
|
61
|
-
{...mergeProps(
|
|
62
|
-
{
|
|
63
|
-
expandTrigger: 'click',
|
|
64
|
-
lineClamp: 1,
|
|
65
|
-
tooltip: {
|
|
66
|
-
style: {
|
|
67
|
-
maxWidth: '61.8vw',
|
|
68
|
-
wordBreak: 'break-all',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
typeof col.ellipsis === 'boolean' ? {} : col.ellipsis,
|
|
73
|
-
)}
|
|
74
|
-
>
|
|
75
|
-
{
|
|
76
|
-
vnode
|
|
77
|
-
}
|
|
78
|
-
</NPerformantEllipsis>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (col.ellipsisTooltip === true) {
|
|
83
|
-
column.ellipsisTooltip ??= render0
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
Object.assign(column, {
|
|
88
|
-
resizable: col.resizable !== false,
|
|
89
|
-
sorter: col.sortable,
|
|
90
|
-
type: ['selection', 'expand'].includes(col.type) ? col.type : undefined,
|
|
91
|
-
disabled: col.selectable ? model => col.selectable(model) === false : undefined,
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (column.key === '$actions') {
|
|
96
|
-
column.cellProps ??= () => {
|
|
97
|
-
return { style: { padding: '0 2px' } }
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return column
|
|
102
|
-
})
|
|
103
|
-
.filter(it => it?.hidden !== true)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const DataTable = /* @__PURE__ */ defineComponent({
|
|
107
|
-
name: 'DataTable',
|
|
108
|
-
props: {
|
|
109
|
-
data: {
|
|
110
|
-
type: Array,
|
|
111
|
-
default: () => [],
|
|
112
|
-
},
|
|
113
|
-
columns: {
|
|
114
|
-
type: Array,
|
|
115
|
-
default: () => [],
|
|
116
|
-
},
|
|
117
|
-
keyField: {
|
|
118
|
-
type: String,
|
|
119
|
-
},
|
|
120
|
-
sorter: {
|
|
121
|
-
type: Object,
|
|
122
|
-
default: () => ({}),
|
|
123
|
-
},
|
|
124
|
-
selectedKeys: {
|
|
125
|
-
type: Array,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
emits: {
|
|
129
|
-
sort: () => true,
|
|
130
|
-
select: () => true,
|
|
131
|
-
},
|
|
132
|
-
setup(props, { slots, emit, expose }) {
|
|
133
|
-
const { keyField } = inject(PAGE_INJECTION)
|
|
134
|
-
|
|
135
|
-
const clsPrefix = useClsPrefix()
|
|
136
|
-
const cls = `${clsPrefix.value}-data-table`
|
|
137
|
-
|
|
138
|
-
const tableRef = useTemplateRef('table-ref')
|
|
139
|
-
|
|
140
|
-
const handleSort = ({ sortField, sortOrder } = {}, oSort) => {
|
|
141
|
-
if (sortField == oSort?.sortField && sortOrder == oSort?.sortOrder) return
|
|
142
|
-
tableRef.value?.sort(sortField, sortOrder ? sortOrder + 'end' : false)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
watch(() => ({ ...props.sorter }), handleSort, { deep: true })
|
|
146
|
-
|
|
147
|
-
const rowKey = computed(() => {
|
|
148
|
-
const keyField0 = props.keyField || keyField || 'key'
|
|
149
|
-
return row => row[keyField0]
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
const exposed = shallowRef({
|
|
153
|
-
cache: [],
|
|
154
|
-
scrollToView(...params) {
|
|
155
|
-
this.cache.push(params)
|
|
156
|
-
},
|
|
157
|
-
})
|
|
158
|
-
until(tableRef)
|
|
159
|
-
.changed()
|
|
160
|
-
.then(() => {
|
|
161
|
-
handleSort(props.sorter)
|
|
162
|
-
|
|
163
|
-
const cache = exposed.value.cache
|
|
164
|
-
exposed.value = tableRef.value
|
|
165
|
-
exposed.value.scrollToView = (key) => {
|
|
166
|
-
const index = props.data.findIndex(row => rowKey.value(row) === key)
|
|
167
|
-
if (index === -1) return
|
|
168
|
-
const row = tableRef.value.$el.querySelector(`.${cls}-row-marker:nth-child(${index + 1})`)
|
|
169
|
-
tableRef.value.scrollTo({
|
|
170
|
-
top: row.offsetTop,
|
|
171
|
-
behavior: 'smooth',
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
for (const params of cache) exposed.value.scrollToView(...params)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
expose(toReactive(exposed))
|
|
178
|
-
|
|
179
|
-
const width = ref(0)
|
|
180
|
-
const columns = shallowRef([])
|
|
181
|
-
|
|
182
|
-
watch(() => props.columns, () => {
|
|
183
|
-
width.value = 0
|
|
184
|
-
columns.value = _map(props.columns, width)
|
|
185
|
-
}, { immediate: true, deep: 1 })
|
|
186
|
-
|
|
187
|
-
const rowClassName = computed(() => {
|
|
188
|
-
return (row, i) => {
|
|
189
|
-
const p = props.rowClassName?.(row, i) || ''
|
|
190
|
-
return p + ` ${cls}-row-marker`
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
const onUpdateSorter = (e) => {
|
|
195
|
-
if (props.sorter) {
|
|
196
|
-
const { sortField, sortOrder } = props.sorter
|
|
197
|
-
if (e?.columnKey == sortField && (e?.order ? e.order === sortOrder + 'end' : !sortOrder)) return
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
emit('sort', {
|
|
201
|
-
sortField: e?.order ? e?.columnKey : undefined,
|
|
202
|
-
sortOrder: e?.order ? e.order.replace('end', '') : undefined,
|
|
203
|
-
})
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const onUpdateCheckedRowKeys = (keys) => {
|
|
207
|
-
emit('select', keys)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return () => (
|
|
211
|
-
<NDataTable
|
|
212
|
-
class={cls}
|
|
213
|
-
data={props.data}
|
|
214
|
-
columns={columns.value}
|
|
215
|
-
rowKey={rowKey.value}
|
|
216
|
-
tableLayout="fixed"
|
|
217
|
-
ref="table-ref"
|
|
218
|
-
scrollX={width.value}
|
|
219
|
-
rowClassName={rowClassName.value}
|
|
220
|
-
checkedRowKeys={props.selectedKeys}
|
|
221
|
-
onUpdateSorter={onUpdateSorter}
|
|
222
|
-
onUpdateCheckedRowKeys={onUpdateCheckedRowKeys}
|
|
223
|
-
>
|
|
224
|
-
{slots}
|
|
225
|
-
</NDataTable>
|
|
226
|
-
)
|
|
227
|
-
},
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
export function useDataTableDrag(
|
|
231
|
-
tableRef,
|
|
232
|
-
{ data, onSort, ...options }) {
|
|
233
|
-
watch([ref(data), tableRef], async ([data, inst]) => {
|
|
234
|
-
if (data.length === 0)
|
|
235
|
-
return
|
|
236
|
-
|
|
237
|
-
await nextTick()
|
|
238
|
-
const tableEl = unrefElement(inst)
|
|
239
|
-
const tbodyEl = tableEl?.querySelector('.n-data-table-base-table-body .n-data-table-tbody')
|
|
240
|
-
|
|
241
|
-
if (!tbodyEl) return
|
|
242
|
-
|
|
243
|
-
const sortable = Sortable.create(tbodyEl, {
|
|
244
|
-
animation: 150,
|
|
245
|
-
...options,
|
|
246
|
-
onSort(evt) {
|
|
247
|
-
onSort({ from: evt.oldIndex, to: evt.newIndex })
|
|
248
|
-
},
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
return () => {
|
|
252
|
-
sortable.destroy()
|
|
253
|
-
}
|
|
254
|
-
}, { immediate: true })
|
|
255
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { NFlex, NRadio, NRadioButton, NRadioGroup, NTooltip } from 'ithinkdt-ui'
|
|
2
|
-
import { computed, defineComponent } from 'vue'
|
|
3
|
-
|
|
4
|
-
import { useI18n } from '../use-i18n.js'
|
|
5
|
-
|
|
6
|
-
export const NRadios = defineComponent({
|
|
7
|
-
name: 'Radios',
|
|
8
|
-
props: {
|
|
9
|
-
options: {
|
|
10
|
-
type: Array,
|
|
11
|
-
default: () => [],
|
|
12
|
-
},
|
|
13
|
-
vertical: {
|
|
14
|
-
type: Boolean,
|
|
15
|
-
default: false,
|
|
16
|
-
},
|
|
17
|
-
type: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: 'radio',
|
|
20
|
-
},
|
|
21
|
-
default: {
|
|
22
|
-
type: [Boolean, String, Object],
|
|
23
|
-
default: false,
|
|
24
|
-
},
|
|
25
|
-
padding: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: undefined,
|
|
28
|
-
},
|
|
29
|
-
labelField: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'label',
|
|
32
|
-
},
|
|
33
|
-
valueField: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: 'value',
|
|
36
|
-
},
|
|
37
|
-
disabledField: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: 'disabled',
|
|
40
|
-
},
|
|
41
|
-
modelValue: {
|
|
42
|
-
type: [String, Number, Boolean],
|
|
43
|
-
default: undefined,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
emits: {
|
|
47
|
-
'update:modelValue': () => true,
|
|
48
|
-
'updateModelValue': () => true,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
setup(props, { emit }) {
|
|
52
|
-
const { t } = useI18n()
|
|
53
|
-
|
|
54
|
-
const defaultLabel = computed(() => {
|
|
55
|
-
if (props.default === false) return ''
|
|
56
|
-
if (props.default === true) return t('common.all')
|
|
57
|
-
if (typeof props.default === 'string') return props.default
|
|
58
|
-
return props.default?.[props.labelField] ?? t('common.all')
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const groupStyle = computed(() => props.type === 'button-primary'
|
|
62
|
-
? {
|
|
63
|
-
'--n-button-color-active': 'var(--color-primary)',
|
|
64
|
-
'--n-button-text-color-active': 'var(--color-base)',
|
|
65
|
-
}
|
|
66
|
-
: {})
|
|
67
|
-
|
|
68
|
-
const emitValue = (v) => {
|
|
69
|
-
emit('update:modelValue', v)
|
|
70
|
-
emit('updateModelValue', v)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return () => {
|
|
74
|
-
const Comp = props.type === 'button' ? NRadioButton : NRadio
|
|
75
|
-
|
|
76
|
-
const content = (
|
|
77
|
-
<>
|
|
78
|
-
{props.default
|
|
79
|
-
? (
|
|
80
|
-
|
|
81
|
-
<Comp value={typeof props.default === 'object' ? props.default?.[props.valueField] : null}>
|
|
82
|
-
{defaultLabel.value}
|
|
83
|
-
</Comp>
|
|
84
|
-
)
|
|
85
|
-
: undefined}
|
|
86
|
-
{props.options?.map((op) => {
|
|
87
|
-
const label
|
|
88
|
-
= typeof op[props.labelField] === 'string' ? op[props.labelField] : op[props.labelField]?.()
|
|
89
|
-
return (
|
|
90
|
-
<Comp
|
|
91
|
-
value={op[props.valueField]}
|
|
92
|
-
disabled={op[props.disabledField]}
|
|
93
|
-
style={
|
|
94
|
-
props.padding
|
|
95
|
-
? {
|
|
96
|
-
paddingLeft: props.padding,
|
|
97
|
-
paddingRight: props.padding,
|
|
98
|
-
}
|
|
99
|
-
: {}
|
|
100
|
-
}
|
|
101
|
-
>
|
|
102
|
-
{op.tip
|
|
103
|
-
? (
|
|
104
|
-
<NTooltip>
|
|
105
|
-
{{
|
|
106
|
-
default: () => op.tip,
|
|
107
|
-
trigger: () => label,
|
|
108
|
-
}}
|
|
109
|
-
</NTooltip>
|
|
110
|
-
)
|
|
111
|
-
: (
|
|
112
|
-
label
|
|
113
|
-
)}
|
|
114
|
-
</Comp>
|
|
115
|
-
)
|
|
116
|
-
})}
|
|
117
|
-
</>
|
|
118
|
-
)
|
|
119
|
-
return (
|
|
120
|
-
<NRadioGroup style={props.vertical ? { ...groupStyle.value, padding: '6px 0 0' } : groupStyle.value} value={props.modelValue} onUpdateValue={emitValue}>
|
|
121
|
-
{props.type === 'radio'
|
|
122
|
-
? (
|
|
123
|
-
<NFlex size={props.vertical ? undefined : 'small'} vertical={props.vertical}>
|
|
124
|
-
{content}
|
|
125
|
-
</NFlex>
|
|
126
|
-
)
|
|
127
|
-
: (
|
|
128
|
-
content
|
|
129
|
-
)}
|
|
130
|
-
</NRadioGroup>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
})
|