@ithinkdt/ui 4.0.0-6 → 4.0.0-601
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-CDuTve1u.js +2000 -0
- package/dist/components.js +5 -0
- package/dist/directives-8VsgmCuO.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-Dx7V4KrY.js +6 -0
- package/dist/use-style-D9hLG26i.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
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h, shallowRef, ref, reactive, isVNode } from 'vue'
|
|
2
|
-
import { useEventListener } from '@vueuse/core'
|
|
3
|
-
import { NTooltip } from 'ithinkdt-ui'
|
|
4
|
-
import { debounce } from '@ithinkdt/common/fn'
|
|
5
|
-
|
|
6
|
-
const Tooltip = /* @__PURE__ */ Symbol('tooltip-dir')
|
|
7
|
-
const current = /* @__PURE__ */ shallowRef()
|
|
8
|
-
|
|
9
|
-
export const TooltipDirectiveProvider = /* @__PURE__ */ defineComponent({
|
|
10
|
-
name: 'TooltipDirectiveProvider',
|
|
11
|
-
setup() {
|
|
12
|
-
const show = ref(false)
|
|
13
|
-
const tip = shallowRef()
|
|
14
|
-
const pos = reactive({ x: 0, y: 0 })
|
|
15
|
-
const placement = ref('top')
|
|
16
|
-
|
|
17
|
-
const update = () => {
|
|
18
|
-
if (!current.value) return
|
|
19
|
-
const el = current.value
|
|
20
|
-
const tooltip = el[Tooltip]
|
|
21
|
-
const _tip = tooltip.tip
|
|
22
|
-
tip.value =
|
|
23
|
-
typeof _tip === 'function'
|
|
24
|
-
? _tip
|
|
25
|
-
: isVNode(_tip)
|
|
26
|
-
? () => _tip
|
|
27
|
-
: () =>
|
|
28
|
-
h('span', {
|
|
29
|
-
innerHTML: _tip || el.attributes.getNamedItem('title') || el.innerHTML,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
!tooltip.binding.modifiers.auto ||
|
|
34
|
-
el.offsetWidth > el.parentElement.clientWidth ||
|
|
35
|
-
el.offsetHeight > el.parentElement.clientHeight
|
|
36
|
-
) {
|
|
37
|
-
show.value = true
|
|
38
|
-
|
|
39
|
-
const rect = el.getBoundingClientRect()
|
|
40
|
-
placement.value =
|
|
41
|
-
Object.keys(tooltip.binding.modifiers).find((m) =>
|
|
42
|
-
['top', 'right', 'left', 'bottom'].find((k) => m.startsWith(k)),
|
|
43
|
-
) ?? 'top'
|
|
44
|
-
switch (placement.value.split('-')[0]) {
|
|
45
|
-
case 'top': {
|
|
46
|
-
pos.x = rect.left + rect.width / 2
|
|
47
|
-
pos.y = rect.top
|
|
48
|
-
break
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
case 'right': {
|
|
52
|
-
pos.x = rect.left + rect.width
|
|
53
|
-
pos.y = rect.top + rect.height / 2
|
|
54
|
-
break
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
case 'left': {
|
|
58
|
-
pos.x = rect.left
|
|
59
|
-
pos.y = rect.top + rect.height / 2
|
|
60
|
-
break
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
case 'bottom': {
|
|
64
|
-
pos.x = rect.left + rect.width / 2
|
|
65
|
-
pos.y = rect.bottom
|
|
66
|
-
break
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} else if (show.value) {
|
|
70
|
-
show.value = false
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const update180 = debounce(update, 180)
|
|
75
|
-
|
|
76
|
-
useEventListener(
|
|
77
|
-
'mouseover',
|
|
78
|
-
(ev) => {
|
|
79
|
-
const el = ev.target
|
|
80
|
-
const tooltip = el[Tooltip]
|
|
81
|
-
if (!tooltip) {
|
|
82
|
-
if (!current.value?.contains(el)) {
|
|
83
|
-
show.value = false
|
|
84
|
-
current.value = undefined
|
|
85
|
-
}
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
current.value = el
|
|
89
|
-
update180()
|
|
90
|
-
},
|
|
91
|
-
{ passive: true, capture: true },
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
return () => {
|
|
95
|
-
return h(
|
|
96
|
-
NTooltip,
|
|
97
|
-
{
|
|
98
|
-
trigger: 'manual',
|
|
99
|
-
show: !!current.value && show.value,
|
|
100
|
-
x: pos.x,
|
|
101
|
-
y: pos.y,
|
|
102
|
-
placement: placement.value,
|
|
103
|
-
},
|
|
104
|
-
tip.value,
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const update = (el, binding) => {
|
|
111
|
-
el[Tooltip] = {
|
|
112
|
-
binding,
|
|
113
|
-
tip: binding.value,
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export const vTooltip = {
|
|
118
|
-
mounted: update,
|
|
119
|
-
update,
|
|
120
|
-
beforeUnmount(el) {
|
|
121
|
-
if (current.value === el) {
|
|
122
|
-
current.value = undefined
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
}
|
package/src/index.d.ts
DELETED
package/src/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { computed, defineComponent, Fragment, h } from 'vue'
|
|
2
|
-
import { useStyleTag } from '@vueuse/core'
|
|
3
|
-
import { useApp } from '@ithinkdt/core'
|
|
4
|
-
import { hyphenate } from '@ithinkdt/common/string'
|
|
5
|
-
import { toRGB } from '@ithinkdt/common/color'
|
|
6
|
-
|
|
7
|
-
export { SpinDirectiveProvider, TooltipDirectiveProvider, vSpin, vTooltip } from './directives/index.js'
|
|
8
|
-
|
|
9
|
-
export * from './design/index.js'
|
|
10
|
-
|
|
11
|
-
export const GlobalCssVar = /* @__PURE__ */ defineComponent({
|
|
12
|
-
name: 'GlobalCssVar',
|
|
13
|
-
props: {
|
|
14
|
-
namespace: { type: String, default: undefined },
|
|
15
|
-
},
|
|
16
|
-
setup(props) {
|
|
17
|
-
const app = useApp()
|
|
18
|
-
|
|
19
|
-
useStyleTag(
|
|
20
|
-
computed(
|
|
21
|
-
() =>
|
|
22
|
-
`${props.namespace ? `.${props.namespace}` : ':root'} { ${Object.entries(app.vars)
|
|
23
|
-
.flatMap(([name, value]) => {
|
|
24
|
-
name = hyphenate(name)
|
|
25
|
-
return [`--${name}-rgb: ${toRGB(value).join(' ')};`, `--${name}: rgb(var(--${name}-rgb));`]
|
|
26
|
-
})
|
|
27
|
-
.join(' ')} }`,
|
|
28
|
-
),
|
|
29
|
-
{
|
|
30
|
-
id: `${props.namespace ?? 'global'}-vars`,
|
|
31
|
-
immediate: true,
|
|
32
|
-
},
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
return () => h(Fragment)
|
|
36
|
-
},
|
|
37
|
-
})
|
package/src/use-style.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import _useStyle from 'ithinkdt-ui/es/_mixins/use-style'
|
|
2
|
-
import { useMergedClsPrefix } from 'ithinkdt-ui/es/_mixins/use-config'
|
|
3
|
-
|
|
4
|
-
export default function useStyle(mountId, style, clsPrefix, styleIsolate) {
|
|
5
|
-
clsPrefix ??= useMergedClsPrefix()
|
|
6
|
-
_useStyle(mountId, style, clsPrefix, styleIsolate)
|
|
7
|
-
return clsPrefix
|
|
8
|
-
}
|
package/src/utils.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { h, withDirectives } from 'vue'
|
|
2
|
-
import { NButton, NIcon } from 'ithinkdt-ui'
|
|
3
|
-
import { vTooltip } from '../directives'
|
|
4
|
-
|
|
5
|
-
export const renderBtn = (Icon, props, tooltip) =>
|
|
6
|
-
withDirectives(
|
|
7
|
-
h(
|
|
8
|
-
NButton,
|
|
9
|
-
{
|
|
10
|
-
text: true,
|
|
11
|
-
...props,
|
|
12
|
-
},
|
|
13
|
-
() =>
|
|
14
|
-
h(NIcon, {
|
|
15
|
-
component: Icon,
|
|
16
|
-
}),
|
|
17
|
-
),
|
|
18
|
-
[[vTooltip, tooltip]],
|
|
19
|
-
)
|
package/tests/index.spec.ts
DELETED
package/tests/tsconfig.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"exclude": ["node_modules", "dist"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"noImplicitOverride": true,
|
|
6
|
-
"target": "ESNext",
|
|
7
|
-
"module": "NodeNext",
|
|
8
|
-
"moduleResolution": "NodeNext",
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"strictNullChecks": true
|
|
13
|
-
}
|
|
14
|
-
}
|
package/unocss.d.ts
DELETED
package/unocss.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
colors: Object.fromEntries(
|
|
3
|
-
['primary', 'success', 'warning', 'danger'].map((name) => [
|
|
4
|
-
name,
|
|
5
|
-
{
|
|
6
|
-
DEFAULT: `rgb(var(--color-${name}-rgb) / <alpha-value>)`,
|
|
7
|
-
...Object.fromEntries(
|
|
8
|
-
['hover', 'active'].map((level) => [
|
|
9
|
-
level,
|
|
10
|
-
`rgb(var(--color-${name}-${level}-rgb) / <alpha-value>)`,
|
|
11
|
-
]),
|
|
12
|
-
),
|
|
13
|
-
},
|
|
14
|
-
]),
|
|
15
|
-
),
|
|
16
|
-
}
|