@ithinkdt/ui 4.0.0-37 → 4.0.0-40

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.
Files changed (55) hide show
  1. package/dist/components-BC8oa62b.js +1612 -0
  2. package/dist/components.js +5 -0
  3. package/dist/directives-DUuJW647.js +183 -0
  4. package/dist/directives.js +3 -0
  5. package/dist/index.js +1222 -0
  6. package/dist/page.js +511 -0
  7. package/dist/use-i18n-Dx7V4KrY.js +6 -0
  8. package/dist/use-style-DcT-1dj4.js +29 -0
  9. package/dist/use-style.js +2 -0
  10. package/esm/components.js +1 -0
  11. package/esm/directives.js +1 -0
  12. package/esm/index.js +1 -0
  13. package/esm/page.js +1 -0
  14. package/esm/use-style.js +1 -0
  15. package/package.json +21 -18
  16. package/src/components/Checkboxes.jsx +0 -130
  17. package/src/components/DataActions.jsx +0 -105
  18. package/src/components/DataCustom.jsx +0 -187
  19. package/src/components/DataFilter.jsx +0 -119
  20. package/src/components/DataForm.jsx +0 -264
  21. package/src/components/DataLocaleInput.jsx +0 -121
  22. package/src/components/DataPagination.jsx +0 -62
  23. package/src/components/DataSelection.jsx +0 -57
  24. package/src/components/DataTable.jsx +0 -302
  25. package/src/components/Radios.jsx +0 -134
  26. package/src/components/UserDept.jsx +0 -643
  27. package/src/components/assets.jsx +0 -274
  28. package/src/components/index.js +0 -11
  29. package/src/design/Account.jsx +0 -154
  30. package/src/design/Appearance.jsx +0 -89
  31. package/src/design/Breadcrumb.jsx +0 -67
  32. package/src/design/Fullscreen.jsx +0 -65
  33. package/src/design/Language.jsx +0 -45
  34. package/src/design/Layout.jsx +0 -241
  35. package/src/design/Logo.jsx +0 -92
  36. package/src/design/Menu.jsx +0 -133
  37. package/src/design/MultiTabs.jsx +0 -501
  38. package/src/design/Notification.jsx +0 -311
  39. package/src/design/Tenant.jsx +0 -88
  40. package/src/design/common.jsx +0 -21
  41. package/src/design/index.js +0 -11
  42. package/src/directives/index.js +0 -2
  43. package/src/directives/spin.js +0 -181
  44. package/src/directives/tooltip.jsx +0 -121
  45. package/src/index.js +0 -18
  46. package/src/page.jsx +0 -740
  47. package/src/use-i18n.js +0 -8
  48. package/src/use-style.js +0 -58
  49. package/src/utils.js +0 -20
  50. /package/{src → esm}/components.d.ts +0 -0
  51. /package/{src → esm}/design.d.ts +0 -0
  52. /package/{src → esm}/directives.d.ts +0 -0
  53. /package/{src → esm}/index.d.ts +0 -0
  54. /package/{src → esm}/page.d.ts +0 -0
  55. /package/{src → esm}/use-style.d.ts +0 -0
@@ -1,302 +0,0 @@
1
- import { toReactive, unrefElement, until } from '@vueuse/core'
2
- import { NButton, NDataTable, NFlex, NIcon, NPerformantEllipsis, NTooltip, dataTableProps } 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 useStyle, { c, cB, cE, 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
- highlight: {
128
- type: [Boolean, String, Number, Object],
129
- default: true,
130
- },
131
- rowClassName: dataTableProps.rowClassName,
132
- rowProps: dataTableProps.rowProps,
133
- },
134
- emits: ['sort', 'select', 'custom', 'highlight'],
135
- setup(props, { slots, emit, expose }) {
136
- const { keyField } = inject(PAGE_INJECTION)
137
-
138
- const clsPrefix = useClsPrefix()
139
- const cls = `${clsPrefix.value}-datatable`
140
- useStyle('-datatable', style, clsPrefix)
141
-
142
- const tableRef = useTemplateRef('table-ref')
143
-
144
- const handleSort = ({ sortField, sortOrder } = {}, oSort) => {
145
- if (sortField == oSort?.sortField && sortOrder == oSort?.sortOrder) return
146
- tableRef.value?.sort(sortField, sortOrder ? sortOrder + 'end' : false)
147
- }
148
-
149
- watch(() => ({ ...props.sorter }), handleSort, { deep: true })
150
-
151
- const rowKey = computed(() => {
152
- const keyField0 = props.keyField || keyField || 'key'
153
- return row => row[keyField0]
154
- })
155
-
156
- const exposed = shallowRef({
157
- cache: [],
158
- scrollToView(...params) {
159
- this.cache.push(params)
160
- },
161
- })
162
- until(tableRef)
163
- .changed()
164
- .then(() => {
165
- handleSort(props.sorter)
166
-
167
- const cache = exposed.value.cache
168
- exposed.value = tableRef.value
169
- exposed.value.scrollToView = (key) => {
170
- const index = props.data.findIndex(row => rowKey.value(row) === key)
171
- if (index === -1) return
172
- const row = tableRef.value.$el.querySelector(`.${cls}__row-marker:nth-child(${index + 1})`)
173
- tableRef.value.scrollTo({
174
- top: row.offsetTop,
175
- behavior: 'smooth',
176
- })
177
- }
178
- for (const params of cache) exposed.value.scrollToView(...params)
179
- })
180
-
181
- expose(toReactive(exposed))
182
-
183
- const width = ref(0)
184
- const columns = shallowRef([])
185
-
186
- watch(() => props.columns, () => {
187
- width.value = 0
188
- columns.value = _map(props.columns, width)
189
- }, { immediate: true, deep: 1 })
190
-
191
- const highlightKey = ref()
192
- watch(() => props.highlight, (val) => {
193
- highlightKey.value = typeof val === 'boolean' ? null : (val ?? null)
194
- }, { immediate: true })
195
- const rowClassName = computed(() => {
196
- return (row, i) => {
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
- }
218
- }
219
- })
220
-
221
- const onUpdateSorter = (e) => {
222
- if (props.sorter) {
223
- const { sortField, sortOrder } = props.sorter
224
- if (e?.columnKey == sortField && (e?.order ? e.order === sortOrder + 'end' : !sortOrder)) return
225
- }
226
-
227
- emit('sort', {
228
- sortField: e?.order ? e?.columnKey : undefined,
229
- sortOrder: e?.order ? e.order.replace('end', '') : undefined,
230
- })
231
- }
232
-
233
- const onUpdateCheckedRowKeys = (keys) => {
234
- emit('select', keys)
235
- }
236
-
237
- const onColumnResize = (resizedWidth, limitedWidth, column) => {
238
- emit('custom', {
239
- key: column.key,
240
- width: resizedWidth,
241
- })
242
- }
243
-
244
- return () => (
245
- <NDataTable
246
- class={cls}
247
- data={props.data}
248
- columns={columns.value}
249
- rowKey={rowKey.value}
250
- tableLayout="fixed"
251
- ref="table-ref"
252
- scrollX={width.value}
253
- rowClassName={rowClassName.value}
254
- rowProps={rowProps.value}
255
- checkedRowKeys={props.selectedKeys}
256
- onUpdateSorter={onUpdateSorter}
257
- onUpdateCheckedRowKeys={onUpdateCheckedRowKeys}
258
- onUnstableColumnResize={onColumnResize}
259
- >
260
- {slots}
261
- </NDataTable>
262
- )
263
- },
264
- })
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
-
277
- export function useDataTableDrag(
278
- tableRef,
279
- { data, onSort, ...options }) {
280
- watch([ref(data), tableRef], async ([data, inst]) => {
281
- if (data.length === 0)
282
- return
283
-
284
- await nextTick()
285
- const tableEl = unrefElement(inst)
286
- const tbodyEl = tableEl?.querySelector('.n-data-table-base-table-body .n-data-table-tbody')
287
-
288
- if (!tbodyEl) return
289
-
290
- const sortable = Sortable.create(tbodyEl, {
291
- animation: 150,
292
- ...options,
293
- onSort(evt) {
294
- onSort({ from: evt.oldIndex, to: evt.newIndex })
295
- },
296
- })
297
-
298
- return () => {
299
- sortable.destroy()
300
- }
301
- }, { immediate: true })
302
- }
@@ -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
- })