@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.
@@ -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
@@ -1,5 +0,0 @@
1
- export * from './directives/index.js'
2
-
3
- export declare const GlobalCssVar: (props: { namespace?: string | undefined }) => import('vue').VNode
4
-
5
- export * from './design/index.js'
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
- )
@@ -1,9 +0,0 @@
1
- import { describe, test } from 'vitest'
2
-
3
- // import core, { useApp, useAuth } from '../src/index'
4
-
5
- describe('plugin', () => {
6
- test('some test', ({ expect }) => {
7
- expect(1).toBe(1)
8
- })
9
- })
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "lib": ["ESNext"],
6
- "module": "NodeNext",
7
- "moduleResolution": "NodeNext"
8
- }
9
- }
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
@@ -1,3 +0,0 @@
1
- declare const unocssTheme: import('@unocss/preset-uno').Theme
2
-
3
- export default unocssTheme
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
- }
package/vitest.config.ts DELETED
@@ -1,7 +0,0 @@
1
- import { defineProject } from 'vitest/config'
2
-
3
- export default defineProject({
4
- test: {
5
- include: ['./tests/*.spec.ts'],
6
- },
7
- })