@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.
- package/auto-imports.js +1 -1
- package/dist/components-B_qzc9ro.js +1736 -0
- package/dist/components.js +5 -0
- package/dist/directives-qqYcWl1I.js +194 -0
- package/dist/directives.js +3 -0
- package/dist/index.js +1212 -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 +56 -15
- package/esm/components.js +1 -0
- package/esm/directives.js +1 -0
- package/esm/index.js +1 -0
- package/{src → esm}/page.d.ts +2 -2
- package/esm/page.js +1 -0
- package/esm/use-style.js +1 -0
- package/package.json +29 -26
- 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 -187
- package/src/components/DataFilter.jsx +0 -119
- 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 -302
- 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 -154
- 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/Tenant.jsx +0 -88
- package/src/design/common.jsx +0 -21
- package/src/design/index.js +0 -11
- 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 -740
- 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 -94
- /package/{src → esm}/design.d.ts +0 -0
- /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
package/{src → esm}/page.d.ts
RENAMED
|
@@ -98,9 +98,9 @@ declare module '@ithinkdt/page' {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
user: {
|
|
101
|
-
|
|
101
|
+
userProps?: ShallowMaybeRef<Omit<UserDeptProps<boolean>, 'modelValue' | 'onUpdate:modelValue' | 'disabled'
|
|
102
102
|
| 'users' | 'groups' | 'depts' | 'getUsersByGroup' | 'getUsersByDept'>> & PublicProps
|
|
103
|
-
|
|
103
|
+
userSlots?: {}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
package/esm/page.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/page.js'
|
package/esm/use-style.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { c, cB, cE, cM, default, useClsPrefix } from '../dist/use-style.js'
|
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-400",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "iThinkDT UI",
|
|
@@ -10,34 +10,35 @@
|
|
|
10
10
|
"ui"
|
|
11
11
|
],
|
|
12
12
|
"files": [
|
|
13
|
-
"
|
|
13
|
+
"dist",
|
|
14
|
+
"esm",
|
|
14
15
|
"auto-imports.*",
|
|
15
16
|
"locale.*",
|
|
16
|
-
"unocss
|
|
17
|
+
"unocss*"
|
|
17
18
|
],
|
|
18
|
-
"main": "./
|
|
19
|
-
"module": "./
|
|
20
|
-
"types": "./
|
|
19
|
+
"main": "./esm/index.js",
|
|
20
|
+
"module": "./esm/index.js",
|
|
21
|
+
"types": "./esm/index.d.ts",
|
|
21
22
|
"exports": {
|
|
22
23
|
".": {
|
|
23
|
-
"types": "./
|
|
24
|
-
"default": "./
|
|
24
|
+
"types": "./esm/index.d.ts",
|
|
25
|
+
"default": "./esm/index.js"
|
|
25
26
|
},
|
|
26
27
|
"./directives": {
|
|
27
|
-
"types": "./
|
|
28
|
-
"default": "./
|
|
28
|
+
"types": "./esm/directives.d.ts",
|
|
29
|
+
"default": "./esm/directives.js"
|
|
29
30
|
},
|
|
30
31
|
"./components": {
|
|
31
|
-
"types": "./
|
|
32
|
-
"default": "./
|
|
32
|
+
"types": "./esm/components.d.ts",
|
|
33
|
+
"default": "./esm/components.js"
|
|
33
34
|
},
|
|
34
35
|
"./use-style": {
|
|
35
|
-
"types": "./
|
|
36
|
-
"default": "./
|
|
36
|
+
"types": "./esm/use-style.d.ts",
|
|
37
|
+
"default": "./esm/use-style.js"
|
|
37
38
|
},
|
|
38
39
|
"./page": {
|
|
39
|
-
"types": "./
|
|
40
|
-
"default": "./
|
|
40
|
+
"types": "./esm/page.d.ts",
|
|
41
|
+
"default": "./esm/page.js"
|
|
41
42
|
},
|
|
42
43
|
"./package.json": {
|
|
43
44
|
"default": "./package.json"
|
|
@@ -47,8 +48,8 @@
|
|
|
47
48
|
"default": "./auto-imports.js"
|
|
48
49
|
},
|
|
49
50
|
"./unocss": {
|
|
50
|
-
"types": "./unocss.d.ts",
|
|
51
|
-
"default": "./unocss.js"
|
|
51
|
+
"types": "./unocss-preset.d.ts",
|
|
52
|
+
"default": "./unocss-preset.js"
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
55
|
"publishConfig": {
|
|
@@ -61,9 +62,9 @@
|
|
|
61
62
|
"date-fns": "^4.1.0",
|
|
62
63
|
"vueuc": "^0.4.65",
|
|
63
64
|
"sortablejs": "^1.15.6",
|
|
64
|
-
"@types/sortablejs": "^1.15.
|
|
65
|
+
"@types/sortablejs": "^1.15.9",
|
|
65
66
|
"nanoid": "^5.1.6",
|
|
66
|
-
"@ithinkdt/common": "^4.0.0-
|
|
67
|
+
"@ithinkdt/common": "^4.0.0-400"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
70
|
"@ithinkdt/page": ">=4.0",
|
|
@@ -82,15 +83,17 @@
|
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@vitejs/plugin-vue-jsx": "^5.1.1",
|
|
85
|
-
"ithinkdt-ui": "^1.8.
|
|
86
|
+
"ithinkdt-ui": "^1.8.1",
|
|
86
87
|
"typescript": "~5.9.3",
|
|
87
|
-
"unocss": ">=66.5.
|
|
88
|
-
"vite": "npm:rolldown-vite@^7.
|
|
89
|
-
"vue": "^3.5.
|
|
88
|
+
"unocss": ">=66.5.6",
|
|
89
|
+
"vite": "npm:rolldown-vite@^7.2.5",
|
|
90
|
+
"vue": "^3.5.24",
|
|
90
91
|
"vue-router": "^4.6.3",
|
|
91
|
-
"@ithinkdt/page": "^4.0.0-
|
|
92
|
+
"@ithinkdt/page": "^4.0.0-400"
|
|
92
93
|
},
|
|
93
94
|
"scripts": {
|
|
94
|
-
"
|
|
95
|
+
"dev": "vite build --watch",
|
|
96
|
+
"build": "vite build",
|
|
97
|
+
"release": "pnpm run build && pnpm publish --no-git-checks"
|
|
95
98
|
}
|
|
96
99
|
}
|
package/unocss-preset.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { presetWind4, transformerDirectives, transformerVariantGroup } from 'unocss'
|
|
2
|
+
|
|
3
|
+
const ithinkdt = (options = {}) => {
|
|
4
|
+
const { namespace: ns } = options
|
|
5
|
+
|
|
6
|
+
let wind4, postprocess
|
|
7
|
+
if (ns) {
|
|
8
|
+
wind4 = () => {
|
|
9
|
+
const plugin = presetWind4({
|
|
10
|
+
variablePrefix: `${ns}-`,
|
|
11
|
+
preflights: {
|
|
12
|
+
reset: false,
|
|
13
|
+
property: {
|
|
14
|
+
selector: `.${ns} :where(*, ::before, ::after)`,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
...plugin,
|
|
21
|
+
preflights: plugin.preflights?.map((preflight) => {
|
|
22
|
+
if (preflight.layer === 'theme') {
|
|
23
|
+
return {
|
|
24
|
+
...preflight,
|
|
25
|
+
async getCSS(ctx) {
|
|
26
|
+
let result = await preflight.getCSS?.(ctx)
|
|
27
|
+
if (result) {
|
|
28
|
+
result = result.replace(':root, :host', `.${ns}`)
|
|
29
|
+
}
|
|
30
|
+
return result
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
} else if (preflight.layer === 'properties') {
|
|
34
|
+
return {
|
|
35
|
+
...preflight,
|
|
36
|
+
async getCSS(ctx) {
|
|
37
|
+
let result = await preflight.getCSS?.(ctx)
|
|
38
|
+
if (result) {
|
|
39
|
+
result = result
|
|
40
|
+
.replaceAll('--un-', `--${ns}-`)
|
|
41
|
+
}
|
|
42
|
+
return result
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return preflight
|
|
47
|
+
}),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
postprocess = [
|
|
51
|
+
(p) => {
|
|
52
|
+
if (p.selector.includes('--un-')) {
|
|
53
|
+
p.selector = p.selector.replaceAll('--un-', `--${ns}-`)
|
|
54
|
+
} else if (p.selector.endsWith(String.raw`.\-`)) {
|
|
55
|
+
if (p.selector.startsWith('.dark ')) {
|
|
56
|
+
p.selector = `.dark & ${p.selector.slice(6)}`
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
p.selector = p.selector.startsWith('.dark ') ? `.dark .${ns} ${p.selector.slice(6)}` : `.${ns} ${p.selector}`
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
} else { wind4 = presetWind4 }
|
|
64
|
+
|
|
65
|
+
const alphas = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
|
66
|
+
const ithinkdt = {
|
|
67
|
+
name: 'preset-ithinkdt',
|
|
68
|
+
options,
|
|
69
|
+
theme: {
|
|
70
|
+
colors: {
|
|
71
|
+
...Object.fromEntries(
|
|
72
|
+
['primary', 'success', 'warning', 'danger'].map(name => [
|
|
73
|
+
name,
|
|
74
|
+
{
|
|
75
|
+
DEFAULT: `var(--color-${name})`,
|
|
76
|
+
...Object.fromEntries(alphas.map(alpha => [`${alpha}`, `color-mix(in oklab, var(--color-${name}) ${alpha / 10}%, #fff ${(1000 - alpha) / 10}%)`])),
|
|
77
|
+
...Object.fromEntries(
|
|
78
|
+
['hover', 'active'].flatMap(level => [
|
|
79
|
+
[level, `var(--color-${name}-${level})`],
|
|
80
|
+
...alphas.map(alpha => [`${level}-${alpha}`, `color-mix(in oklab, var(--color-${name}-${level}) ${alpha / 10}%, #fff ${(1000 - alpha) / 10}%)`]),
|
|
81
|
+
]),
|
|
82
|
+
),
|
|
83
|
+
},
|
|
84
|
+
]),
|
|
85
|
+
),
|
|
86
|
+
text: {
|
|
87
|
+
DEFAULT: `var(--color-text)`,
|
|
88
|
+
...Object.fromEntries(alphas.map(alpha => [`${alpha}`, `color-mix(in oklab, var(--color-text) ${alpha / 10}%, #fff ${(1000 - alpha) / 10}%)`])),
|
|
89
|
+
},
|
|
90
|
+
base: { DEFAULT: `var(--color-base)` },
|
|
91
|
+
},
|
|
92
|
+
radius: Object.fromEntries(
|
|
93
|
+
['xs', 'sm', 'md', 'lg'].map(size => [size, `var(--rounded-${size})`]),
|
|
94
|
+
),
|
|
95
|
+
},
|
|
96
|
+
variants: [
|
|
97
|
+
// stuck:
|
|
98
|
+
(matcher) => {
|
|
99
|
+
const array = ['top', 'right', 'bottom', 'left']
|
|
100
|
+
const index = array.findIndex(it => matcher.startsWith(`stuck-${it}:`))
|
|
101
|
+
if (index === -1)
|
|
102
|
+
return matcher
|
|
103
|
+
return {
|
|
104
|
+
matcher: matcher.slice(7 + array[index].length),
|
|
105
|
+
handle: (input, next) => next({
|
|
106
|
+
...input,
|
|
107
|
+
parent: `${input.parent ? `${input.parent} $$ ` : ''} @container scroll-state(stuck: ${array[index]})`,
|
|
108
|
+
}),
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
rules: [
|
|
113
|
+
['scroll-state', { 'container-type': 'scroll-state' }],
|
|
114
|
+
[
|
|
115
|
+
/^bg-img-(.*)$/,
|
|
116
|
+
([_, r]) => {
|
|
117
|
+
return {
|
|
118
|
+
'background-image': r[0] === '[' && r.at(-1) === ']' ? r.slice(1, -1) : r,
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
/^mask-(.*)$/,
|
|
124
|
+
([_, r]) => {
|
|
125
|
+
const mask = `var(--un-icon) no-repeat`
|
|
126
|
+
return {
|
|
127
|
+
'--un-icon': r[0] === '[' && r.at(-1) === ']' ? r.slice(1, -1) : r,
|
|
128
|
+
mask,
|
|
129
|
+
'mask-size': '100% 100%',
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
],
|
|
134
|
+
shortcuts: [
|
|
135
|
+
[
|
|
136
|
+
/^card-(.*)$/,
|
|
137
|
+
([_, size]) => {
|
|
138
|
+
const i = ['none', 'sm', 'md', 'lg'].indexOf(size)
|
|
139
|
+
if (i === -1) return
|
|
140
|
+
const p = [0, 2, 4, 5][i]
|
|
141
|
+
return `rounded-${size} px-${p + 1} py-${p} bg-white dark:bg-dark ease-in-out transition-shadow
|
|
142
|
+
hover:shadow-[0_1px_2px_0_rgba(0_0_0_/_0.03),0_1px_6px_-1px_rgba(0_0_0_/_0.02),0_2px_4px_0_rgba(0_0_0_/_0.02)]`
|
|
143
|
+
},
|
|
144
|
+
{ autocomplete: ['card-none', 'card-sm', 'card-md', 'card-lg'] },
|
|
145
|
+
],
|
|
146
|
+
{
|
|
147
|
+
'ell': 'truncate',
|
|
148
|
+
'ell-2': 'line-clamp-2',
|
|
149
|
+
'ell-3': 'line-clamp-3',
|
|
150
|
+
'flex-center': 'flex justify-center items-center',
|
|
151
|
+
'card': `card-md`,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
transformers: [transformerDirectives(), transformerVariantGroup()],
|
|
155
|
+
postprocess: postprocess,
|
|
156
|
+
}
|
|
157
|
+
return [
|
|
158
|
+
wind4(),
|
|
159
|
+
ithinkdt,
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export default ithinkdt
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { NCheckbox, NCheckboxGroup, NFlex } from 'ithinkdt-ui'
|
|
2
|
-
import { computed, defineComponent, ref, watch } from 'vue'
|
|
3
|
-
|
|
4
|
-
import { useI18n } from '../use-i18n.js'
|
|
5
|
-
|
|
6
|
-
export const NCheckboxes = /* @__PURE__ */ defineComponent({
|
|
7
|
-
name: 'Checkboxes',
|
|
8
|
-
inheritAttrs: false,
|
|
9
|
-
props: {
|
|
10
|
-
options: {
|
|
11
|
-
type: Array,
|
|
12
|
-
default: () => [],
|
|
13
|
-
},
|
|
14
|
-
vertical: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: false,
|
|
17
|
-
},
|
|
18
|
-
default: {
|
|
19
|
-
type: [Boolean, String, Object],
|
|
20
|
-
default: false,
|
|
21
|
-
},
|
|
22
|
-
gap: {
|
|
23
|
-
type: [Number, String, Array],
|
|
24
|
-
default: undefined,
|
|
25
|
-
},
|
|
26
|
-
modelValue: {
|
|
27
|
-
type: Array,
|
|
28
|
-
default: undefined,
|
|
29
|
-
},
|
|
30
|
-
labelPadding: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: undefined,
|
|
33
|
-
},
|
|
34
|
-
labelField: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: 'label',
|
|
37
|
-
},
|
|
38
|
-
valueField: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: 'value',
|
|
41
|
-
},
|
|
42
|
-
disabledField: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: 'disabled',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
emits: {
|
|
48
|
-
'update:modelValue': () => true,
|
|
49
|
-
'updateModelValue': () => true,
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
setup(props, { emit, attrs }) {
|
|
53
|
-
const { t } = useI18n()
|
|
54
|
-
const defaultLabel = computed(() => {
|
|
55
|
-
if (!props.default) 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
|
-
const checked = ref([])
|
|
61
|
-
|
|
62
|
-
watch(
|
|
63
|
-
() => props.modelValue,
|
|
64
|
-
v => (checked.value = v),
|
|
65
|
-
{ immediate: true },
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
const emitValue = (v) => {
|
|
69
|
-
emit('update:modelValue', v)
|
|
70
|
-
emit('updateModelValue', v)
|
|
71
|
-
}
|
|
72
|
-
const onAll = () => {
|
|
73
|
-
emitValue(
|
|
74
|
-
checked.value?.length === props.options.length ? [] : props.options.map(it => it[props.valueField]),
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
const indeterminate = computed(() => props.options.length > checked.value?.length && checked.value?.length > 0)
|
|
78
|
-
|
|
79
|
-
const style = computed(() => {
|
|
80
|
-
return {
|
|
81
|
-
'--n-label-padding': props.labelPadding,
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
return () => {
|
|
85
|
-
const group = (
|
|
86
|
-
<NCheckboxGroup {...attrs} value={checked.value} onUpdateValue={emitValue}>
|
|
87
|
-
<NFlex
|
|
88
|
-
size={props.gap ?? (props.vertical ? undefined : 'small')}
|
|
89
|
-
vertical={props.vertical}
|
|
90
|
-
style={!props.default && props.vertical ? { padding: '6px 0 0' } : {}}
|
|
91
|
-
>
|
|
92
|
-
{props.options?.map(op => (
|
|
93
|
-
<NCheckbox
|
|
94
|
-
value={op[props.valueField]}
|
|
95
|
-
disabled={op[props.disabledField]}
|
|
96
|
-
style={style.value}
|
|
97
|
-
>
|
|
98
|
-
{op[props.labelField]}
|
|
99
|
-
</NCheckbox>
|
|
100
|
-
))}
|
|
101
|
-
</NFlex>
|
|
102
|
-
</NCheckboxGroup>
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
return props.default
|
|
106
|
-
? (
|
|
107
|
-
<NFlex
|
|
108
|
-
size={props.gap ?? (props.vertical ? undefined : 'small')}
|
|
109
|
-
vertical={props.vertical}
|
|
110
|
-
style={props.vertical ? { padding: '6px 0 0' } : {}}
|
|
111
|
-
>
|
|
112
|
-
<span>
|
|
113
|
-
<NCheckbox
|
|
114
|
-
indeterminate={indeterminate.value}
|
|
115
|
-
checked={checked.value?.length > 0}
|
|
116
|
-
onUpdateChecked={onAll}
|
|
117
|
-
style={style.value}
|
|
118
|
-
>
|
|
119
|
-
{defaultLabel.value}
|
|
120
|
-
</NCheckbox>
|
|
121
|
-
</span>
|
|
122
|
-
{group}
|
|
123
|
-
</NFlex>
|
|
124
|
-
)
|
|
125
|
-
: (
|
|
126
|
-
group
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
})
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { NButton, NDropdown } from 'ithinkdt-ui'
|
|
2
|
-
import { computed, defineComponent, ref } from 'vue'
|
|
3
|
-
import { VOverflow, VResizeObserver } from 'vueuc'
|
|
4
|
-
|
|
5
|
-
import { IMore } from './assets.jsx'
|
|
6
|
-
|
|
7
|
-
export const DataActions = /* @__PURE__ */ defineComponent({
|
|
8
|
-
name: 'DataActions',
|
|
9
|
-
props: {
|
|
10
|
-
options: {
|
|
11
|
-
type: Array,
|
|
12
|
-
default: () => [],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props) {
|
|
16
|
-
const ofRef = ref()
|
|
17
|
-
let isFirstResize = true
|
|
18
|
-
const onResize = () => {
|
|
19
|
-
if (isFirstResize) {
|
|
20
|
-
isFirstResize = false
|
|
21
|
-
} else {
|
|
22
|
-
ofRef.value?.sync({
|
|
23
|
-
showAllItemsBeforeCalculate: true,
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const counter = ref()
|
|
28
|
-
const getCounter = () => {
|
|
29
|
-
return counter.value
|
|
30
|
-
}
|
|
31
|
-
const ellipsisFromIndexRef = ref(-1)
|
|
32
|
-
const onUpdateCount = (count) => {
|
|
33
|
-
ellipsisFromIndexRef.value = props.options.length - count
|
|
34
|
-
}
|
|
35
|
-
const onUpdateOverflow = (overflow) => {
|
|
36
|
-
if (!overflow) {
|
|
37
|
-
ellipsisFromIndexRef.value = -1
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const updateCounter = () => {}
|
|
41
|
-
const moreOptions = computed(() => {
|
|
42
|
-
if (ellipsisFromIndexRef.value === -1) return []
|
|
43
|
-
return props.options.slice(ellipsisFromIndexRef.value).map((act) => {
|
|
44
|
-
return {
|
|
45
|
-
...act,
|
|
46
|
-
key: act.text,
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const renderLabel = (act) => {
|
|
52
|
-
const color = act.color === 'danger'
|
|
53
|
-
? 'error'
|
|
54
|
-
: ['default', 'tertiary', 'primary', 'info', 'success', 'warning', 'error'].includes(act.color)
|
|
55
|
-
? act.color
|
|
56
|
-
: 'primary'
|
|
57
|
-
return (
|
|
58
|
-
<NButton type={color} text>
|
|
59
|
-
{act.text}
|
|
60
|
-
</NButton>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const onSelect = (key, act) => {
|
|
65
|
-
act.onClick?.()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return () => {
|
|
69
|
-
return (
|
|
70
|
-
<VResizeObserver onResize={onResize}>
|
|
71
|
-
<VOverflow
|
|
72
|
-
ref={ofRef}
|
|
73
|
-
getCounter={getCounter}
|
|
74
|
-
onUpdateCount={onUpdateCount}
|
|
75
|
-
onUpdateOverflow={onUpdateOverflow}
|
|
76
|
-
updateCounter={updateCounter}
|
|
77
|
-
style="margin-top: 2px"
|
|
78
|
-
>
|
|
79
|
-
{ {
|
|
80
|
-
default: () => props.options.map((act) => {
|
|
81
|
-
const color = act.color === 'danger'
|
|
82
|
-
? 'error'
|
|
83
|
-
: ['default', 'tertiary', 'primary', 'info', 'success', 'warning', 'error'].includes(act.color)
|
|
84
|
-
? act.color
|
|
85
|
-
: 'primary'
|
|
86
|
-
return (
|
|
87
|
-
<NButton quaternary type={color} size="small" onClick={act.onClick}>
|
|
88
|
-
{act.text}
|
|
89
|
-
</NButton>
|
|
90
|
-
)
|
|
91
|
-
}),
|
|
92
|
-
counter: () => (
|
|
93
|
-
<span ref={counter} style="position: absolute">
|
|
94
|
-
<NDropdown options={moreOptions.value} renderLabel={renderLabel} onSelect={onSelect}>
|
|
95
|
-
<NButton quaternary size="small"><IMore style="font-size: 14px; color: #888" /></NButton>
|
|
96
|
-
</NDropdown>
|
|
97
|
-
</span>
|
|
98
|
-
),
|
|
99
|
-
}}
|
|
100
|
-
</VOverflow>
|
|
101
|
-
</VResizeObserver>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
})
|