@ithinkdt/ui 4.0.0-38 → 4.0.0-400

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 (60) hide show
  1. package/auto-imports.js +1 -1
  2. package/dist/components-B_qzc9ro.js +1736 -0
  3. package/dist/components.js +5 -0
  4. package/dist/directives-qqYcWl1I.js +194 -0
  5. package/dist/directives.js +3 -0
  6. package/dist/index.js +1212 -0
  7. package/dist/page.js +519 -0
  8. package/dist/use-i18n-Dx7V4KrY.js +6 -0
  9. package/dist/use-style-DcT-1dj4.js +29 -0
  10. package/dist/use-style.js +2 -0
  11. package/{src → esm}/components.d.ts +56 -15
  12. package/esm/components.js +1 -0
  13. package/esm/directives.js +1 -0
  14. package/esm/index.js +1 -0
  15. package/{src → esm}/page.d.ts +2 -2
  16. package/esm/page.js +1 -0
  17. package/esm/use-style.js +1 -0
  18. package/package.json +29 -26
  19. package/unocss-preset.d.ts +5 -0
  20. package/unocss-preset.js +163 -0
  21. package/src/components/Checkboxes.jsx +0 -130
  22. package/src/components/DataActions.jsx +0 -105
  23. package/src/components/DataCustom.jsx +0 -187
  24. package/src/components/DataFilter.jsx +0 -119
  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 -302
  30. package/src/components/Radios.jsx +0 -134
  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 -154
  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 -92
  41. package/src/design/Menu.jsx +0 -133
  42. package/src/design/MultiTabs.jsx +0 -501
  43. package/src/design/Notification.jsx +0 -311
  44. package/src/design/Tenant.jsx +0 -88
  45. package/src/design/common.jsx +0 -21
  46. package/src/design/index.js +0 -11
  47. package/src/directives/index.js +0 -2
  48. package/src/directives/spin.js +0 -181
  49. package/src/directives/tooltip.jsx +0 -121
  50. package/src/index.js +0 -18
  51. package/src/page.jsx +0 -740
  52. package/src/use-i18n.js +0 -8
  53. package/src/use-style.js +0 -58
  54. package/src/utils.js +0 -20
  55. package/unocss.d.ts +0 -5
  56. package/unocss.js +0 -94
  57. /package/{src → esm}/design.d.ts +0 -0
  58. /package/{src → esm}/directives.d.ts +0 -0
  59. /package/{src → esm}/index.d.ts +0 -0
  60. /package/{src → esm}/use-style.d.ts +0 -0
@@ -1,121 +0,0 @@
1
- import { NButton, NIcon, NInput } from 'ithinkdt-ui'
2
- import { computed, defineComponent, ref, toRef, toValue, unref, watch } from 'vue'
3
-
4
- import { useFormModal } from '@ithinkdt/page'
5
-
6
- import { useI18n } from '../use-i18n.js'
7
-
8
- import { ILanguage } from './assets.jsx'
9
-
10
- export function useLocaleEdit(title, onSubmit, defaultRows = 1) {
11
- const { t } = useI18n()
12
-
13
- const readonly = ref(false)
14
- let supports = []
15
- const { open, reinit } = useFormModal({
16
- title,
17
- showColon: true,
18
- submitText: t('common.confirm.defaultOk'),
19
- items: ({ it }) => {
20
- return supports.map((s) => {
21
- return it(s.value, s.label, 'input', {
22
- span: 24,
23
- required: s.required,
24
- inputProps: {
25
- readonly,
26
- clearable: true,
27
- type: 'textarea',
28
- showCount: true,
29
- autosize: {
30
- minRows: unref(defaultRows),
31
- maxRows: Math.max(unref(defaultRows), 5),
32
- },
33
- },
34
- })
35
- })
36
- },
37
- onSubmit,
38
- })
39
-
40
- return {
41
- open: (data, readonly0 = false) => {
42
- readonly.value = readonly0
43
- return open(data)
44
- },
45
- setSupports: (supports0) => {
46
- supports = supports0
47
- reinit()
48
- },
49
- }
50
- }
51
-
52
- export const DataLocaleInput = /* @__PURE__ */ defineComponent({
53
- name: 'DataLocaleInput',
54
- props: {
55
- label: { type: [String, Function, Number, Boolean, Object] },
56
- modelValue: Object,
57
- supports: { type: Array, default: () => [] },
58
- disabled: { type: Boolean, default: undefined },
59
- defaultLang: { type: String, default: 'zh-CN' },
60
- showLang: { type: String, default: undefined },
61
- defaultRows: { type: Number, default: 1 },
62
- },
63
- emits: ['update:modelValue', 'updateModelValue'],
64
- setup(props, { emit }) {
65
- const onUpdateValue = (value) => {
66
- value = {
67
- ...props.modelValue,
68
- [props.showLang ?? props.defaultLang]: value,
69
- }
70
- emit('update:modelValue', value)
71
- emit('updateModelValue', value)
72
- }
73
-
74
- const { open, setSupports } = useLocaleEdit(
75
- computed(() => toValue(props.label)),
76
- (data) => {
77
- emit('update:modelValue', data)
78
- emit('updateModelValue', data)
79
- },
80
- toRef(props, 'defaultRows'),
81
- )
82
-
83
- watch(() => props.supports, setSupports, { immediate: true })
84
-
85
- const slots = {
86
- suffix: () => (
87
- <NButton
88
- quaternary
89
- onClick={() => open(props.modelValue, props.disabled)}
90
- style="--n-padding: 0 8px"
91
- >
92
- <NIcon size="20" depth="3">
93
- <ILanguage />
94
- </NIcon>
95
- </NButton>
96
- ),
97
- }
98
- const themeOverrides = {
99
- '--n-padding-right': '0',
100
- }
101
-
102
- return () => {
103
- return (
104
- <NInput
105
- value={
106
- props.modelValue?.[props.showLang ?? props.defaultLang]
107
- ?? props.modelValue?.[props.defaultLang]
108
- }
109
- onUpdateValue={onUpdateValue}
110
- disabled={props.disabled}
111
- clearable
112
- style={themeOverrides}
113
- type={props.defaultRows > 1 ? 'textarea' : 'text'}
114
- rows={props.defaultRows}
115
- >
116
- {slots}
117
- </NInput>
118
- )
119
- }
120
- },
121
- })
@@ -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,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)
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
- })