@ithinkdt/ui 4.0.0-11 → 4.0.0-110

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