@ithinkdt/ui 4.0.0-6 → 4.0.0-600
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.d.ts +11 -6
- package/auto-imports.js +27 -9
- package/dist/components-BMKQsJ4d.js +2000 -0
- package/dist/components.js +5 -0
- package/dist/directives-CB8tcZsk.js +203 -0
- package/dist/directives.js +3 -0
- package/dist/index.js +1212 -0
- package/dist/page.js +546 -0
- package/dist/use-i18n-D-AJ8KbA.js +6 -0
- package/dist/use-style-DrH-89qR.js +29 -0
- package/dist/use-style.js +2 -0
- package/esm/components.d.ts +523 -0
- package/esm/components.js +1 -0
- package/esm/design.d.ts +243 -0
- package/esm/directives.d.ts +42 -0
- package/esm/directives.js +1 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.js +1 -0
- package/esm/page.d.ts +189 -0
- package/esm/page.js +1 -0
- package/esm/use-style.d.ts +10 -0
- package/esm/use-style.js +1 -0
- package/locale.d.ts +78 -0
- package/package.json +64 -26
- package/unocss-preset.d.ts +5 -0
- package/unocss-preset.js +163 -0
- package/src/design/index.d.ts +0 -53
- package/src/design/index.js +0 -1
- package/src/design/layout.js +0 -113
- package/src/directives/index.d.ts +0 -37
- package/src/directives/index.js +0 -2
- package/src/directives/spin.js +0 -175
- package/src/directives/tooltip.js +0 -125
- package/src/index.d.ts +0 -5
- package/src/index.js +0 -37
- package/src/use-style.js +0 -8
- package/src/utils.js +0 -19
- package/tests/index.spec.ts +0 -9
- package/tests/tsconfig.json +0 -9
- package/tsconfig.json +0 -14
- package/unocss.d.ts +0 -3
- package/unocss.js +0 -16
- package/vitest.config.ts +0 -7
package/package.json
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ithinkdt/ui",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-600",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "iThinkDT UI",
|
|
7
7
|
"keywords": [
|
|
8
|
+
"ithinkdt",
|
|
8
9
|
"vue",
|
|
9
|
-
"
|
|
10
|
+
"ui"
|
|
10
11
|
],
|
|
11
|
-
"
|
|
12
|
-
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"esm",
|
|
15
|
+
"auto-imports.*",
|
|
16
|
+
"locale.*",
|
|
17
|
+
"unocss*"
|
|
18
|
+
],
|
|
19
|
+
"main": "./esm/index.js",
|
|
20
|
+
"module": "./esm/index.js",
|
|
21
|
+
"types": "./esm/index.d.ts",
|
|
13
22
|
"exports": {
|
|
14
23
|
".": {
|
|
15
|
-
"types": "./
|
|
16
|
-
"default": "./
|
|
24
|
+
"types": "./esm/index.d.ts",
|
|
25
|
+
"default": "./esm/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./directives": {
|
|
28
|
+
"types": "./esm/directives.d.ts",
|
|
29
|
+
"default": "./esm/directives.js"
|
|
30
|
+
},
|
|
31
|
+
"./components": {
|
|
32
|
+
"types": "./esm/components.d.ts",
|
|
33
|
+
"default": "./esm/components.js"
|
|
34
|
+
},
|
|
35
|
+
"./use-style": {
|
|
36
|
+
"types": "./esm/use-style.d.ts",
|
|
37
|
+
"default": "./esm/use-style.js"
|
|
38
|
+
},
|
|
39
|
+
"./page": {
|
|
40
|
+
"types": "./esm/page.d.ts",
|
|
41
|
+
"default": "./esm/page.js"
|
|
17
42
|
},
|
|
18
43
|
"./package.json": {
|
|
19
44
|
"default": "./package.json"
|
|
@@ -23,12 +48,8 @@
|
|
|
23
48
|
"default": "./auto-imports.js"
|
|
24
49
|
},
|
|
25
50
|
"./unocss": {
|
|
26
|
-
"types": "./unocss.d.ts",
|
|
27
|
-
"default": "./unocss.js"
|
|
28
|
-
},
|
|
29
|
-
"./design": {
|
|
30
|
-
"types": "./design/index.d.ts",
|
|
31
|
-
"default": "./design/index.js"
|
|
51
|
+
"types": "./unocss-preset.d.ts",
|
|
52
|
+
"default": "./unocss-preset.js"
|
|
32
53
|
}
|
|
33
54
|
},
|
|
34
55
|
"publishConfig": {
|
|
@@ -37,25 +58,42 @@
|
|
|
37
58
|
},
|
|
38
59
|
"sideEffects": false,
|
|
39
60
|
"dependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"
|
|
61
|
+
"@vueuse/core": "^14.1.0",
|
|
62
|
+
"date-fns": "^4.1.0",
|
|
63
|
+
"vueuc": "^0.4.65",
|
|
64
|
+
"sortablejs": "^1.15.6",
|
|
65
|
+
"@types/sortablejs": "^1.15.9",
|
|
66
|
+
"nanoid": "^5.1.6",
|
|
67
|
+
"@ithinkdt/common": "^4.0.0-600"
|
|
43
68
|
},
|
|
44
69
|
"peerDependencies": {
|
|
45
|
-
"@ithinkdt/
|
|
46
|
-
"vue": ">=3.
|
|
47
|
-
"vue-router": ">=4.
|
|
48
|
-
"ithinkdt-ui": ">=1.
|
|
70
|
+
"@ithinkdt/page": ">=4.0",
|
|
71
|
+
"vue": ">=3.5",
|
|
72
|
+
"vue-router": ">=4.5",
|
|
73
|
+
"ithinkdt-ui": ">=1.5",
|
|
74
|
+
"unocss": ">=66"
|
|
75
|
+
},
|
|
76
|
+
"peerDependenciesMeta": {
|
|
77
|
+
"@ithinkdt/page": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"unocss": {
|
|
81
|
+
"optional": true
|
|
82
|
+
}
|
|
49
83
|
},
|
|
50
84
|
"devDependencies": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
85
|
+
"@vitejs/plugin-vue-jsx": "^5.1.2",
|
|
86
|
+
"ithinkdt-ui": "^1.8.1",
|
|
87
|
+
"typescript": "~5.9.3",
|
|
88
|
+
"unocss": ">=66.5.10",
|
|
89
|
+
"vite": "npm:rolldown-vite@7.2.7",
|
|
90
|
+
"vue": "^3.5.25",
|
|
91
|
+
"vue-router": "^4.6.3",
|
|
92
|
+
"@ithinkdt/page": "^4.0.0-600"
|
|
56
93
|
},
|
|
57
94
|
"scripts": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
95
|
+
"dev": "vite build --watch",
|
|
96
|
+
"build": "vite build",
|
|
97
|
+
"release": "pnpm run build && pnpm publish --no-git-checks"
|
|
60
98
|
}
|
|
61
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 whitespace-normal',
|
|
149
|
+
'ell-3': 'line-clamp-3 whitespace-normal',
|
|
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
|
package/src/design/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
declare const AppLayout: (
|
|
2
|
-
props: import('@ithinkdt/common').PublicProps & {
|
|
3
|
-
/**
|
|
4
|
-
* 布局模式
|
|
5
|
-
* - sider-header_content_footer 左右布局,侧栏占据整个高度
|
|
6
|
-
* - header_sider-content_footer 上下布局,头部占据所有宽度
|
|
7
|
-
*/
|
|
8
|
-
layout?: 'sider-header_content_footer' | 'header_sider-content_footer'
|
|
9
|
-
},
|
|
10
|
-
context: {
|
|
11
|
-
slots: {
|
|
12
|
-
default?: () => import('vue').VNode
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
) => import('vue').VNode
|
|
16
|
-
|
|
17
|
-
declare const AppHeader: (
|
|
18
|
-
props: import('@ithinkdt/common').PublicProps & {},
|
|
19
|
-
context: {
|
|
20
|
-
slots: {
|
|
21
|
-
default?: () => import('vue').VNode
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
) => import('vue').VNode
|
|
25
|
-
|
|
26
|
-
declare const AppContent: (
|
|
27
|
-
props: import('@ithinkdt/common').PublicProps & {},
|
|
28
|
-
context: {
|
|
29
|
-
slots: {
|
|
30
|
-
default?: () => import('vue').VNode
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
) => import('vue').VNode
|
|
34
|
-
|
|
35
|
-
declare const AppSider: (
|
|
36
|
-
props: import('@ithinkdt/common').PublicProps & {},
|
|
37
|
-
context: {
|
|
38
|
-
slots: {
|
|
39
|
-
default?: () => import('vue').VNode
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
) => import('vue').VNode
|
|
43
|
-
|
|
44
|
-
declare const AppFooter: (
|
|
45
|
-
props: import('@ithinkdt/common').PublicProps & {},
|
|
46
|
-
context: {
|
|
47
|
-
slots: {
|
|
48
|
-
default?: () => import('vue').VNode
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
) => import('vue').VNode
|
|
52
|
-
|
|
53
|
-
export { AppLayout, AppHeader, AppContent, AppSider, AppFooter }
|
package/src/design/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AppLayout, AppHeader, AppContent, AppSider, AppFooter } from './layout.js'
|
package/src/design/layout.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue'
|
|
2
|
-
import { c, cB, cM } from 'ithinkdt-ui'
|
|
3
|
-
|
|
4
|
-
import useStyle from '../use-style.js'
|
|
5
|
-
|
|
6
|
-
const clsPrefix = 'app'
|
|
7
|
-
export const AppLayout = /* @__PURE__ */ defineComponent({
|
|
8
|
-
name: 'AppLayout',
|
|
9
|
-
props: {
|
|
10
|
-
layout: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: 'sider-header_content_footer',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props, { slots }) {
|
|
16
|
-
useStyle('-layout', style, ref(clsPrefix), false)
|
|
17
|
-
|
|
18
|
-
return () => {
|
|
19
|
-
const { layout } = props
|
|
20
|
-
|
|
21
|
-
return h(
|
|
22
|
-
'div',
|
|
23
|
-
{
|
|
24
|
-
class: {
|
|
25
|
-
[`${clsPrefix}-layout`]: true,
|
|
26
|
-
[`${clsPrefix}-layout--full-header`]: layout === 'header_sider-content_footer',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
slots.default?.(),
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
export const AppHeader = /* @__PURE__ */ defineComponent({
|
|
36
|
-
name: 'AppHeader',
|
|
37
|
-
props: {},
|
|
38
|
-
setup(props, { slots }) {
|
|
39
|
-
return () => h('div', { class: `${clsPrefix}-header` }, slots.default?.())
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
export const AppSider = /* @__PURE__ */ defineComponent({
|
|
43
|
-
name: 'AppSider',
|
|
44
|
-
props: {},
|
|
45
|
-
setup(props, { slots }) {
|
|
46
|
-
return () => h('div', { class: `${clsPrefix}-sider` }, slots.default?.())
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
export const AppContent = /* @__PURE__ */ defineComponent({
|
|
50
|
-
name: 'AppContent',
|
|
51
|
-
props: {},
|
|
52
|
-
setup(props, { slots }) {
|
|
53
|
-
return () => h('div', { class: `${clsPrefix}-content` }, slots.default?.())
|
|
54
|
-
},
|
|
55
|
-
})
|
|
56
|
-
export const AppFooter = /* @__PURE__ */ defineComponent({
|
|
57
|
-
name: 'AppFooter',
|
|
58
|
-
props: {},
|
|
59
|
-
setup(props, { slots }) {
|
|
60
|
-
return () => h('div', { class: `${clsPrefix}-footer` }, slots.default?.())
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const style = /* @__PURE__ */ c([
|
|
65
|
-
cB(
|
|
66
|
-
'layout',
|
|
67
|
-
{
|
|
68
|
-
display: 'grid',
|
|
69
|
-
gridTemplateAreas: `
|
|
70
|
-
'sider header'
|
|
71
|
-
'sider content'
|
|
72
|
-
'sider footer'
|
|
73
|
-
`,
|
|
74
|
-
gridTemplateRows: 'auto 1fr auto',
|
|
75
|
-
gridTemplateColumns: 'auto 1fr',
|
|
76
|
-
},
|
|
77
|
-
[
|
|
78
|
-
cM('full-header', {
|
|
79
|
-
gridTemplateAreas: `
|
|
80
|
-
'header header'
|
|
81
|
-
'sider content'
|
|
82
|
-
'sider footer'
|
|
83
|
-
`,
|
|
84
|
-
}),
|
|
85
|
-
],
|
|
86
|
-
),
|
|
87
|
-
cB('header', {
|
|
88
|
-
gridArea: 'header',
|
|
89
|
-
height: '52px',
|
|
90
|
-
boxShadow: '0 1px 4px rgb(0 21 41 / 0.08)',
|
|
91
|
-
}),
|
|
92
|
-
cB(
|
|
93
|
-
'sider',
|
|
94
|
-
{
|
|
95
|
-
gridArea: 'sider',
|
|
96
|
-
width: '210px',
|
|
97
|
-
boxShadow:
|
|
98
|
-
'1px 2px 2px -2px rgb(0 0 0 / 0.04), 3px 6px 6px 0 rgb(0 0 0 / 0.03)',
|
|
99
|
-
},
|
|
100
|
-
[
|
|
101
|
-
cM('collapsed', {
|
|
102
|
-
width: '48px',
|
|
103
|
-
}),
|
|
104
|
-
],
|
|
105
|
-
),
|
|
106
|
-
cB('content', {
|
|
107
|
-
gridArea: 'content',
|
|
108
|
-
}),
|
|
109
|
-
cB('footer', {
|
|
110
|
-
gridArea: 'footer',
|
|
111
|
-
lineHeight: '24px',
|
|
112
|
-
}),
|
|
113
|
-
])
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { VNode, Directive } from 'vue'
|
|
2
|
-
|
|
3
|
-
declare const SpinDirectiveProvider: () => VNode
|
|
4
|
-
|
|
5
|
-
type SpinDirectiveProps = void | undefined | string | boolean
|
|
6
|
-
|
|
7
|
-
type SpinDirective = Directive<
|
|
8
|
-
HTMLElement & {
|
|
9
|
-
readonly dataset: DOMStringMap & {
|
|
10
|
-
spinTip?: string
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
SpinDirectiveProps
|
|
14
|
-
>
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* directive 加载效果
|
|
18
|
-
*
|
|
19
|
-
* 将在容器最后 append 元素,如果容器的 position 是 static,将修改为 relative。如出现样式问题请注意排查
|
|
20
|
-
*/
|
|
21
|
-
declare const vSpin: SpinDirective
|
|
22
|
-
|
|
23
|
-
declare const TooltipDirectiveProvider: () => VNode
|
|
24
|
-
|
|
25
|
-
type TooltipDirectiveOptions = void | undefined | string
|
|
26
|
-
|
|
27
|
-
type TooltipDirective = Directive<HTMLElement, TooltipDirectiveOptions>
|
|
28
|
-
/**
|
|
29
|
-
* directive 弹出提示
|
|
30
|
-
*
|
|
31
|
-
* 支持的修饰符
|
|
32
|
-
* - auto 当内容溢出来容器时自动展示,否则隐藏
|
|
33
|
-
* - left-end、left、left-start、top-start、top、top-end、right-start、right、right-end、bottom-end、bottom、bottom-start 弹出内容的位置
|
|
34
|
-
*/
|
|
35
|
-
declare const vTooltip: TooltipDirective
|
|
36
|
-
|
|
37
|
-
export { SpinDirectiveProvider, SpinDirective, vSpin, TooltipDirectiveProvider, TooltipDirective, vTooltip }
|
package/src/directives/index.js
DELETED
package/src/directives/spin.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { defineComponent, ref, nextTick, h, Fragment } from 'vue'
|
|
2
|
-
import { watchDebounced } from '@vueuse/core'
|
|
3
|
-
import { useElementIntersectionRect } from '@ithinkdt/common/composables'
|
|
4
|
-
import { string2dom } from '@ithinkdt/common/dom'
|
|
5
|
-
|
|
6
|
-
import { c, cB, cE, cM } from 'ithinkdt-ui'
|
|
7
|
-
|
|
8
|
-
import useStyle from '../use-style.js'
|
|
9
|
-
|
|
10
|
-
let clsPrefix
|
|
11
|
-
|
|
12
|
-
const style = /* @__PURE__ */ c([
|
|
13
|
-
cB('spin-host', [
|
|
14
|
-
cM('relative', {
|
|
15
|
-
position: 'relative',
|
|
16
|
-
}),
|
|
17
|
-
]),
|
|
18
|
-
cB(
|
|
19
|
-
'spin-directive',
|
|
20
|
-
{
|
|
21
|
-
zIndex: '999999',
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
color: 'var(--color-primary)',
|
|
24
|
-
display: 'flex',
|
|
25
|
-
flexDirection: 'column',
|
|
26
|
-
justifyContent: 'center',
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
gap: '4px',
|
|
29
|
-
willChange: 'background-color',
|
|
30
|
-
backgroundColor: `rgb(255 255 255 / 0)`,
|
|
31
|
-
transition: 'background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
32
|
-
},
|
|
33
|
-
[
|
|
34
|
-
cE('tip', [c('&:empty', { display: 'none' })]),
|
|
35
|
-
cE('icon', {
|
|
36
|
-
willChange: 'opacity',
|
|
37
|
-
opacity: '0',
|
|
38
|
-
transition: 'opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
39
|
-
}),
|
|
40
|
-
cM(
|
|
41
|
-
'spining',
|
|
42
|
-
{
|
|
43
|
-
backgroundColor: `rgb(255 255 255 / 0.5)`,
|
|
44
|
-
},
|
|
45
|
-
[cE('icon', { opacity: '1' })],
|
|
46
|
-
),
|
|
47
|
-
],
|
|
48
|
-
),
|
|
49
|
-
])
|
|
50
|
-
|
|
51
|
-
export const SpinDirectiveProvider = /* @__PURE__ */defineComponent({
|
|
52
|
-
name: 'SpinDirectiveProvider',
|
|
53
|
-
setup() {
|
|
54
|
-
clsPrefix = useStyle('-spin-directive', style)
|
|
55
|
-
return () => h(Fragment)
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const Spin = /* @__PURE__ */ Symbol('spin-dir')
|
|
60
|
-
|
|
61
|
-
const init = (el, value) => {
|
|
62
|
-
if (el[Spin]) return
|
|
63
|
-
|
|
64
|
-
const loading = ref(!!value)
|
|
65
|
-
|
|
66
|
-
const spinEl = string2dom(`<div class="${clsPrefix.value}-spin-directive">
|
|
67
|
-
<svg class="${clsPrefix.value}-spin-directive__icon" width="32" height="32" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
68
|
-
<g>
|
|
69
|
-
<animateTransform attributeName="transform" type="rotate" values="0 100 100;270 100 100" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animateTransform>
|
|
70
|
-
<circle fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" cx="100" cy="100" r="92" stroke-dasharray="567" stroke-dashoffset="1848">
|
|
71
|
-
<animateTransform attributeName="transform" type="rotate" values="0 100 100;135 100 100;450 100 100" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animateTransform>
|
|
72
|
-
<animate attributeName="stroke-dashoffset" values="567;142;567" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animate>
|
|
73
|
-
</circle>
|
|
74
|
-
</g>
|
|
75
|
-
</svg>
|
|
76
|
-
<div class="${clsPrefix.value}-spin-directive__tip"></div>
|
|
77
|
-
</div>`)
|
|
78
|
-
|
|
79
|
-
let rect
|
|
80
|
-
const { stop: stopEl } = useElementIntersectionRect(el, (_rect) => {
|
|
81
|
-
rect = _rect
|
|
82
|
-
Object.assign(spinEl.style, {
|
|
83
|
-
left: 0,
|
|
84
|
-
top: 0,
|
|
85
|
-
width: rect.width + 'px',
|
|
86
|
-
height: rect.height + 'px',
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
let timer
|
|
91
|
-
const stopSpin = watchDebounced(
|
|
92
|
-
loading,
|
|
93
|
-
(loading) => {
|
|
94
|
-
if (loading) {
|
|
95
|
-
if (timer === undefined) {
|
|
96
|
-
clearTimeout(timer)
|
|
97
|
-
timer = undefined
|
|
98
|
-
}
|
|
99
|
-
el.append(spinEl)
|
|
100
|
-
requestAnimationFrame(() => {
|
|
101
|
-
spinEl.classList.add(`${clsPrefix.value}-spin-directive--spining`)
|
|
102
|
-
})
|
|
103
|
-
} else {
|
|
104
|
-
spinEl.classList.remove(`${clsPrefix.value}-spin-directive--spining`)
|
|
105
|
-
timer = setTimeout(() => {
|
|
106
|
-
spinEl.remove()
|
|
107
|
-
}, 300)
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{ immediate: true, debounce: 30 },
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
el[Spin] = {
|
|
114
|
-
loading,
|
|
115
|
-
spinEl,
|
|
116
|
-
updateTip: () => {
|
|
117
|
-
const tipEl = spinEl.querySelector(`.${clsPrefix.value}-spin-directive__tip`)
|
|
118
|
-
tipEl.textContent = el.dataset.spinTip
|
|
119
|
-
},
|
|
120
|
-
stop: () => {
|
|
121
|
-
stopEl()
|
|
122
|
-
stopSpin()
|
|
123
|
-
},
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const obs = async (el) => {
|
|
128
|
-
if (el[Spin].observer) return
|
|
129
|
-
// 创建 MutationObserver 对象
|
|
130
|
-
await nextTick()
|
|
131
|
-
const observer = (el[Spin].observer = new MutationObserver((mutationsList) => {
|
|
132
|
-
for (const mutation of mutationsList) {
|
|
133
|
-
if (mutation.type === 'attributes' && mutation.attributeName === 'data-spin-tip') {
|
|
134
|
-
el[Spin].updateTip()
|
|
135
|
-
return
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}))
|
|
139
|
-
|
|
140
|
-
// 开始观察目标元素
|
|
141
|
-
observer.observe(el, { attributes: true })
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const checkStyle = (el) => {
|
|
145
|
-
const style = window.getComputedStyle(el)
|
|
146
|
-
if (style.getPropertyValue('position') === 'static') {
|
|
147
|
-
el.classList.add(`${clsPrefix.value}-spin-host--relative`)
|
|
148
|
-
} else {
|
|
149
|
-
el.classList.remove(`${clsPrefix.value}-spin-host--relative`)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const vSpin = {
|
|
154
|
-
beforeMount(el, { value }) {
|
|
155
|
-
init(el, value)
|
|
156
|
-
el.classList.add(`${clsPrefix.value}-spin-host`)
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
mounted(el) {
|
|
160
|
-
el[Spin].updateTip()
|
|
161
|
-
checkStyle(el)
|
|
162
|
-
obs(el)
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
updated(el, { value }) {
|
|
166
|
-
el[Spin].loading.value = !!value
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
beforeUnmount(el) {
|
|
170
|
-
el[Spin].loading.value = false
|
|
171
|
-
el[Spin].stop()
|
|
172
|
-
el[Spin].observer?.disconnect()
|
|
173
|
-
delete el[Spin]
|
|
174
|
-
},
|
|
175
|
-
}
|