solely 0.4.10 → 0.4.11
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/README.md +35 -0
- package/dist/components/commands/tooltip/index.cjs +1 -1
- package/dist/components/commands/tooltip/index.js +1 -1
- package/dist/components/commands/tooltip/style.css.cjs +1 -1
- package/dist/components/commands/tooltip/style.css.js +1 -1
- package/dist/components/commands/tooltip/types.d.ts +2 -0
- package/dist/components/elements/tooltip/index.d.ts +59 -0
- package/dist/components/elements/tooltip/types.d.ts +23 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
**一个轻量级、现代化的 Web 组件开发框架**
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/solely)
|
|
10
|
+
[](https://codecov.io/gh/solelyjs/solely)
|
|
11
|
+
[](https://marketplace.visualstudio.com/items?itemName=solely.solely-vscode)
|
|
10
12
|
[](LICENSE)
|
|
11
13
|
[](https://www.typescriptlang.org/)
|
|
12
14
|
|
|
@@ -29,6 +31,7 @@
|
|
|
29
31
|
- [快速开始指南](./docs/guide.md) - 从零开始学习 Solely
|
|
30
32
|
- [API 文档](./docs/api.md) - 完整的 API 参考
|
|
31
33
|
- [示例项目](./examples/) - 实际应用示例
|
|
34
|
+
- [VS Code 扩展](./vscode-extension/) - 语法高亮、智能跳转、错误诊断
|
|
32
35
|
- [插件系统](#插件系统) - 了解 Vite 插件的使用方法
|
|
33
36
|
- [安全机制说明](#安全机制) - 了解框架的 XSS 防护机制
|
|
34
37
|
- [安全演示](./examples/security-demo/) - 查看 XSS 防护实际效果
|
|
@@ -46,6 +49,38 @@ yarn add solely
|
|
|
46
49
|
pnpm add solely
|
|
47
50
|
```
|
|
48
51
|
|
|
52
|
+
## 🛠️ VS Code 扩展
|
|
53
|
+
|
|
54
|
+
Solely 提供了官方 VS Code 扩展,为 `.html` 模板文件提供语法高亮、智能跳转、悬停提示和错误诊断。
|
|
55
|
+
|
|
56
|
+
### 安装
|
|
57
|
+
|
|
58
|
+
**方式一:通过 VS Code 扩展面板安装(推荐)**
|
|
59
|
+
|
|
60
|
+
按 `Ctrl+Shift+X` 打开扩展面板,搜索 **"Solely Framework Support"** 即可安装。
|
|
61
|
+
|
|
62
|
+
**方式二:通过命令行安装**
|
|
63
|
+
|
|
64
|
+
需确保 `code` 命令已在系统 PATH 中(可通过 `Shell Command: Install 'code' command in PATH` 命令添加):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
code --install-extension solely.solely-vscode
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 功能
|
|
71
|
+
|
|
72
|
+
| 功能 | 说明 |
|
|
73
|
+
| ------------ | --------------------------------------------------------------------------------- |
|
|
74
|
+
| **语法高亮** | `$data.xxx`、`this.xxx()`、`<If>`/`<For>`、`@click`、`ref="xxx"` 等均有独立配色 |
|
|
75
|
+
| **定义跳转** | Ctrl+点击模板中的方法名/属性名/引用,跳转到 TS 文件中对应定义 |
|
|
76
|
+
| **悬停提示** | 鼠标悬停显示方法签名、属性信息和跳转提示 |
|
|
77
|
+
| **错误诊断** | `<If>`/`<ElseIf>`/`<Else>`/`<For>` 标签配对检查和嵌套错误提示 |
|
|
78
|
+
| **模板关联** | 自动识别 `import template from './xxx.html?raw'` / `?solely`,正确关联 HTML 与 TS |
|
|
79
|
+
|
|
80
|
+
### 版本要求
|
|
81
|
+
|
|
82
|
+
- VS Code `>= 1.85.0`
|
|
83
|
+
|
|
49
84
|
## 🎯 快速开始
|
|
50
85
|
|
|
51
86
|
### 1. 创建一个简单的组件
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),o={placement:"top",trigger:"hover",duration:3e3,singleton:!0},n=[],r=new WeakSet;let l=null;function s(e,t,o,n=8){const r=e.getBoundingClientRect(),l=t.offsetWidth||250,s=t.offsetHeight||100;let i,a,c=0,d=0;switch(o){case"top":c=r.top-s-n,d=r.left+(r.width-l)/2,i=l/2-4;break;case"topLeft":c=r.top-s-n,d=r.left,i=16;break;case"topRight":c=r.top-s-n,d=r.right-l,i=l-24;break;case"bottom":c=r.bottom+n,d=r.left+(r.width-l)/2,i=l/2-4;break;case"bottomLeft":c=r.bottom+n,d=r.left,i=16;break;case"bottomRight":c=r.bottom+n,d=r.right-l,i=l-24;break;case"left":c=r.top+(r.height-s)/2,d=r.left-l-n,a=s/2-4;break;case"leftTop":c=r.top,d=r.left-l-n,a=16;break;case"leftBottom":c=r.bottom-s,d=r.left-l-n,a=s-24;break;case"right":c=r.top+(r.height-s)/2,d=r.right+n,a=s/2-4;break;case"rightTop":c=r.top,d=r.right+n,a=16;break;case"rightBottom":c=r.bottom-s,d=r.right+n,a=s-24}return c=Math.max(8,Math.min(c,window.innerHeight-s-8)),d=Math.max(8,Math.min(d,window.innerWidth-l-8)),{top:c,left:d,arrowLeft:i,arrowTop:a}}let i=null,a=!1;function c(){i||(i=requestAnimationFrame(()=>{i=null,n.forEach(e=>{const t=e.element;if(!t||!e.target)return;const o=t.querySelector(".tooltip__arrow"),n=s(e.target,t,e.placement);t.style.top=`${n.top}px`,t.style.left=`${n.left}px`,o&&(void 0!==n.arrowLeft&&(o.style.left=`${n.arrowLeft}px`,o.style.top=""),void 0!==n.arrowTop&&(o.style.top=`${n.arrowTop}px`,o.style.left=""))})}))}function d(){a&&(a=!1,window.removeEventListener("resize",c),i&&(cancelAnimationFrame(i),i=null))}async function m(e,t){const o=n.findIndex(t=>t.id===e);if(-1===o)return;const r=n[o];r.element.classList.add("is-closing"),r.element.remove(),r.scrollParents.forEach(e=>e.removeEventListener("scroll",c)),n.splice(o,1),0===n.length&&d(),null==t||t()}function u(){if(0===n.length)return;const e=new Set;n.forEach(t=>{t.scrollParents.forEach(t=>e.add(t)),t.element.classList.add("is-closing"),t.element.remove()}),e.forEach(e=>e.removeEventListener("scroll",c)),n.length=0,d()}function f(r,i){var d;const m=e.generateId();e.injectStyle("solely-tooltip-styles",t.default);const f=i.placement??o.placement,p=n.findIndex(e=>e.target===r);if(-1!==p){const e=n[p];e.element.remove(),e.scrollParents.forEach(e=>e.removeEventListener("scroll",c)),n.splice(p,1)}o.singleton&&n.length>0&&u();const h=e.createElement("div",{className:`tooltip tooltip--${f}${i.className?` ${i.className}`:""}`,styles:{...i.style,...i.color?{backgroundColor:i.color}:{}}});var v;v=h,(()=>{const e=document.documentElement.getAttribute("data-theme");e?v.setAttribute("data-theme",e):v.removeAttribute("data-theme")})(),l||(l=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");n.forEach(t=>{e?t.element.setAttribute("data-theme",e):t.element.removeAttribute("data-theme")})}),l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}));const g=e.createElement("div",{className:"tooltip__content"});i.content&&("string"==typeof i.content?g.textContent=i.content:i.content instanceof HTMLElement&&g.appendChild(i.content.cloneNode(!0))),h.appendChild(g);const b=e.createElement("div",{className:"tooltip__arrow"});i.color&&(b.style.backgroundColor=i.color),h.appendChild(b),document.body.appendChild(h),requestAnimationFrame(()=>{const e=s(r,h,f);h.style.top=`${e.top}px`,h.style.left=`${e.left}px`,void 0!==e.arrowLeft&&(b.style.left=`${e.arrowLeft}px`),void 0!==e.arrowTop&&(b.style.top=`${e.arrowTop}px`)});const E=function(e){const t=[];let o=e.parentElement;for(;o&&o!==document.body;){const e=getComputedStyle(o);"auto"!==e.overflow&&"scroll"!==e.overflow&&"auto"!==e.overflowY&&"scroll"!==e.overflowY||t.push(o),o=o.parentElement}return t}(r);return E.forEach(e=>e.addEventListener("scroll",c)),a||0===n.length||(a=!0,window.addEventListener("resize",c)),n.push({id:m,element:h,target:r,placement:f,scrollParents:E}),null==(d=i.onVisibleChange)||d.call(i,!0),m}const p={bind:function(e,t){if(r.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};r.add(e);const n=t.trigger??o.trigger;let l=t.visible??t.defaultVisible??!1,s=null;const i=()=>{l||(l=!0,s=f(e,t))},a=()=>{if(!l||null===s)return;l=!1;const e=s;s=null,m(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},c=e=>{e.stopPropagation(),l?a():i()},d=t=>{l&&(e.contains(t.target)||a())};return"hover"===n?(e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",a)):"click"===n?(e.addEventListener("click",c),document.addEventListener("click",d)):"focus"===n&&(e.addEventListener("focus",i),e.addEventListener("blur",a)),l&&(s=f(e,t)),{show:i,hide:a,destroy:()=>{a(),r.delete(e),"hover"===n?(e.removeEventListener("mouseenter",i),e.removeEventListener("mouseleave",a)):"click"===n?(e.removeEventListener("click",c),document.removeEventListener("click",d)):"focus"===n&&(e.removeEventListener("focus",i),e.removeEventListener("blur",a))}}},show:function(e,t){const n=f(e,t),r=t.duration??o.duration;r>0&&setTimeout(()=>m(n),r)},hide:async function(e){u(),null==e||e()},config:function(e){Object.assign(o,e)}};exports.Tooltip=p;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{generateId as e,createElement as t,injectStyle as o}from"../utils.js";import n from"./style.css.js";const r={placement:"top",trigger:"hover",duration:3e3,singleton:!0},l=[],s=new WeakSet;let i=null;function a(e,t,o,n=8){const r=e.getBoundingClientRect(),l=t.offsetWidth||250,s=t.offsetHeight||100;let i,a,c=0,d=0;switch(o){case"top":c=r.top-s-n,d=r.left+(r.width-l)/2,i=l/2-4;break;case"topLeft":c=r.top-s-n,d=r.left,i=16;break;case"topRight":c=r.top-s-n,d=r.right-l,i=l-24;break;case"bottom":c=r.bottom+n,d=r.left+(r.width-l)/2,i=l/2-4;break;case"bottomLeft":c=r.bottom+n,d=r.left,i=16;break;case"bottomRight":c=r.bottom+n,d=r.right-l,i=l-24;break;case"left":c=r.top+(r.height-s)/2,d=r.left-l-n,a=s/2-4;break;case"leftTop":c=r.top,d=r.left-l-n,a=16;break;case"leftBottom":c=r.bottom-s,d=r.left-l-n,a=s-24;break;case"right":c=r.top+(r.height-s)/2,d=r.right+n,a=s/2-4;break;case"rightTop":c=r.top,d=r.right+n,a=16;break;case"rightBottom":c=r.bottom-s,d=r.right+n,a=s-24}return c=Math.max(8,Math.min(c,window.innerHeight-s-8)),d=Math.max(8,Math.min(d,window.innerWidth-l-8)),{top:c,left:d,arrowLeft:i,arrowTop:a}}let c=null,d=!1;function m(){c||(c=requestAnimationFrame(()=>{c=null,l.forEach(e=>{const t=e.element;if(!t||!e.target)return;const o=t.querySelector(".tooltip__arrow"),n=a(e.target,t,e.placement);t.style.top=`${n.top}px`,t.style.left=`${n.left}px`,o&&(void 0!==n.arrowLeft&&(o.style.left=`${n.arrowLeft}px`,o.style.top=""),void 0!==n.arrowTop&&(o.style.top=`${n.arrowTop}px`,o.style.left=""))})}))}function u(){d&&(d=!1,window.removeEventListener("resize",m),c&&(cancelAnimationFrame(c),c=null))}async function f(e,t){const o=l.findIndex(t=>t.id===e);if(-1===o)return;const n=l[o];n.element.classList.add("is-closing"),n.element.remove(),n.scrollParents.forEach(e=>e.removeEventListener("scroll",m)),l.splice(o,1),0===l.length&&u(),null==t||t()}function p(){if(0===l.length)return;const e=new Set;l.forEach(t=>{t.scrollParents.forEach(t=>e.add(t)),t.element.classList.add("is-closing"),t.element.remove()}),e.forEach(e=>e.removeEventListener("scroll",m)),l.length=0,u()}function h(s,c){var u;const f=e();o("solely-tooltip-styles",n);const h=c.placement??r.placement,v=l.findIndex(e=>e.target===s);if(-1!==v){const e=l[v];e.element.remove(),e.scrollParents.forEach(e=>e.removeEventListener("scroll",m)),l.splice(v,1)}r.singleton&&l.length>0&&p();const g=t("div",{className:`tooltip tooltip--${h}${c.className?` ${c.className}`:""}`,styles:{...c.style,...c.color?{backgroundColor:c.color}:{}}});var b;b=g,(()=>{const e=document.documentElement.getAttribute("data-theme");e?b.setAttribute("data-theme",e):b.removeAttribute("data-theme")})(),i||(i=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");l.forEach(t=>{e?t.element.setAttribute("data-theme",e):t.element.removeAttribute("data-theme")})}),i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}));const w=t("div",{className:"tooltip__content"});c.content&&("string"==typeof c.content?w.textContent=c.content:c.content instanceof HTMLElement&&w.appendChild(c.content.cloneNode(!0))),g.appendChild(w);const E=t("div",{className:"tooltip__arrow"});c.color&&(E.style.backgroundColor=c.color),g.appendChild(E),document.body.appendChild(g),requestAnimationFrame(()=>{const e=a(s,g,h);g.style.top=`${e.top}px`,g.style.left=`${e.left}px`,void 0!==e.arrowLeft&&(E.style.left=`${e.arrowLeft}px`),void 0!==e.arrowTop&&(E.style.top=`${e.arrowTop}px`)});const L=function(e){const t=[];let o=e.parentElement;for(;o&&o!==document.body;){const e=getComputedStyle(o);"auto"!==e.overflow&&"scroll"!==e.overflow&&"auto"!==e.overflowY&&"scroll"!==e.overflowY||t.push(o),o=o.parentElement}return t}(s);return L.forEach(e=>e.addEventListener("scroll",m)),d||0===l.length||(d=!0,window.addEventListener("resize",m)),l.push({id:f,element:g,target:s,placement:h,scrollParents:L}),null==(u=c.onVisibleChange)||u.call(c,!0),f}const v={bind:function(e,t){if(s.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};s.add(e);const o=t.trigger??r.trigger;let n=t.visible??t.defaultVisible??!1,l=null;const i=()=>{n||(n=!0,l=h(e,t))},a=()=>{if(!n||null===l)return;n=!1;const e=l;l=null,f(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},c=e=>{e.stopPropagation(),n?a():i()},d=t=>{n&&(e.contains(t.target)||a())};return"hover"===o?(e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",a)):"click"===o?(e.addEventListener("click",c),document.addEventListener("click",d)):"focus"===o&&(e.addEventListener("focus",i),e.addEventListener("blur",a)),n&&(l=h(e,t)),{show:i,hide:a,destroy:()=>{a(),s.delete(e),"hover"===o?(e.removeEventListener("mouseenter",i),e.removeEventListener("mouseleave",a)):"click"===o?(e.removeEventListener("click",c),document.removeEventListener("click",d)):"focus"===o&&(e.removeEventListener("focus",i),e.removeEventListener("blur",a))}}},show:function(e,t){const o=h(e,t),n=t.duration??r.duration;n>0&&setTimeout(()=>f(o),n)},hide:async function(e){p(),null==e||e()},config:function(e){Object.assign(r,e)}};export{v as Tooltip};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default=".tooltip{position:fixed;background-color:var(--solely-inverted-bg);border-radius:var(--solely-border-radius-md);box-shadow:var(--solely-shadow-md);padding:var(--solely-spacing-sm) var(--solely-spacing-md);width:max-content;max-width:250px;font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);font-weight:400;line-height:var(--solely-line-height-md);color:var(--solely-inverted-text);text-align:left;text-decoration:none;z-index:var(--solely-z-index-tooltip);pointer-events:auto;animation:tooltip-fade-in var(--solely-transition-duration) var(--solely-transition-timing)}.tooltip.is-closing{animation:tooltip-fade-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.tooltip__content{position:relative;z-index:1;word-wrap:break-word;overflow-wrap:break-word}.tooltip__arrow{position:absolute;width:var(--solely-tooltip-arrow-size, 8px);height:var(--solely-tooltip-arrow-size, 8px);background-color:var(--solely-inverted-bg);transform:rotate(45deg);z-index:0}.tooltip--top .tooltip__arrow,.tooltip--topLeft .tooltip__arrow,.tooltip--topRight .tooltip__arrow{bottom:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}.tooltip--bottom .tooltip__arrow,.tooltip--bottomLeft .tooltip__arrow,.tooltip--bottomRight .tooltip__arrow{top:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}.tooltip--left .tooltip__arrow,.tooltip--leftTop .tooltip__arrow,.tooltip--leftBottom .tooltip__arrow{right:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}.tooltip--right .tooltip__arrow,.tooltip--rightTop .tooltip__arrow,.tooltip--rightBottom .tooltip__arrow{left:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}@keyframes tooltip-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes tooltip-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="
|
|
1
|
+
const o=".tooltip{position:fixed;background-color:var(--solely-inverted-bg);border-radius:var(--solely-border-radius-md);box-shadow:var(--solely-shadow-md);padding:var(--solely-spacing-sm) var(--solely-spacing-md);width:max-content;max-width:250px;font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);font-weight:400;line-height:var(--solely-line-height-md);color:var(--solely-inverted-text);text-align:left;text-decoration:none;z-index:var(--solely-z-index-tooltip);pointer-events:auto;animation:tooltip-fade-in var(--solely-transition-duration) var(--solely-transition-timing)}.tooltip.is-closing{animation:tooltip-fade-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.tooltip__content{position:relative;z-index:1;word-wrap:break-word;overflow-wrap:break-word}.tooltip__arrow{position:absolute;width:var(--solely-tooltip-arrow-size, 8px);height:var(--solely-tooltip-arrow-size, 8px);background-color:var(--solely-inverted-bg);transform:rotate(45deg);z-index:0}.tooltip--top .tooltip__arrow,.tooltip--topLeft .tooltip__arrow,.tooltip--topRight .tooltip__arrow{bottom:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}.tooltip--bottom .tooltip__arrow,.tooltip--bottomLeft .tooltip__arrow,.tooltip--bottomRight .tooltip__arrow{top:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}.tooltip--left .tooltip__arrow,.tooltip--leftTop .tooltip__arrow,.tooltip--leftBottom .tooltip__arrow{right:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}.tooltip--right .tooltip__arrow,.tooltip--rightTop .tooltip__arrow,.tooltip--rightBottom .tooltip__arrow{left:calc(var(--solely-tooltip-arrow-size, 8px) / -2)}@keyframes tooltip-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes tooltip-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}";export{o as default};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseElement } from '../../../runtime/component';
|
|
2
|
+
import { TooltipProps } from './types';
|
|
3
|
+
declare class SolelyTooltip extends BaseElement<TooltipProps> {
|
|
4
|
+
private _clickOutsideHandler?;
|
|
5
|
+
/**
|
|
6
|
+
* 获取 tooltip class 对象
|
|
7
|
+
*/
|
|
8
|
+
getTooltipClasses(): Record<string, boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* 显示 tooltip
|
|
11
|
+
*/
|
|
12
|
+
show(): void;
|
|
13
|
+
/**
|
|
14
|
+
* 隐藏 tooltip
|
|
15
|
+
*/
|
|
16
|
+
hide(): void;
|
|
17
|
+
/**
|
|
18
|
+
* 鼠标移入处理
|
|
19
|
+
*/
|
|
20
|
+
handleMouseEnter(event: Event): void;
|
|
21
|
+
/**
|
|
22
|
+
* 鼠标移出处理
|
|
23
|
+
*/
|
|
24
|
+
handleMouseLeave(event: Event): void;
|
|
25
|
+
/**
|
|
26
|
+
* 聚焦处理
|
|
27
|
+
*/
|
|
28
|
+
handleFocus(event: Event): void;
|
|
29
|
+
/**
|
|
30
|
+
* 失焦处理
|
|
31
|
+
*/
|
|
32
|
+
handleBlur(event: Event): void;
|
|
33
|
+
/**
|
|
34
|
+
* 绑定事件到 slot 内容元素
|
|
35
|
+
*/
|
|
36
|
+
private bindSlotEvents;
|
|
37
|
+
/**
|
|
38
|
+
* 点击处理
|
|
39
|
+
*/
|
|
40
|
+
handleClick(event: Event): void;
|
|
41
|
+
/**
|
|
42
|
+
* 绑定点击外部关闭
|
|
43
|
+
*/
|
|
44
|
+
private bindClickOutside;
|
|
45
|
+
/**
|
|
46
|
+
* 解绑点击外部关闭
|
|
47
|
+
*/
|
|
48
|
+
private unbindClickOutside;
|
|
49
|
+
/**
|
|
50
|
+
* 组件挂载后初始化
|
|
51
|
+
*/
|
|
52
|
+
mounted(): void;
|
|
53
|
+
/**
|
|
54
|
+
* 组件销毁时清理
|
|
55
|
+
*/
|
|
56
|
+
unmounted(): void;
|
|
57
|
+
}
|
|
58
|
+
export default SolelyTooltip;
|
|
59
|
+
export { SolelyTooltip };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tooltip 组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
export type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
5
|
+
export type TooltipTrigger = 'hover' | 'click' | 'focus';
|
|
6
|
+
export interface TooltipProps {
|
|
7
|
+
/** 提示内容 */
|
|
8
|
+
content: string;
|
|
9
|
+
/** 气泡框位置 */
|
|
10
|
+
placement: TooltipPlacement;
|
|
11
|
+
/** 触发方式 */
|
|
12
|
+
trigger: TooltipTrigger;
|
|
13
|
+
/** 是否显示 */
|
|
14
|
+
visible: boolean;
|
|
15
|
+
/** 背景颜色 */
|
|
16
|
+
color: string;
|
|
17
|
+
/** 最大宽度 */
|
|
18
|
+
maxWidth: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TooltipRefs extends Record<string, Element> {
|
|
21
|
+
tooltipRef: HTMLElement;
|
|
22
|
+
arrowRef: HTMLElement;
|
|
23
|
+
}
|
package/package.json
CHANGED