solely 0.2.9 → 0.4.0
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 +109 -40
- package/dist/compiler/ir/buildIR.cjs +1 -1
- package/dist/compiler/ir/buildIR.js +1 -1
- package/dist/compiler/parser/parser.cjs +1 -1
- package/dist/compiler/parser/parser.js +1 -1
- package/dist/components/commands/drawer/index.cjs +1 -0
- package/dist/components/commands/drawer/index.d.ts +10 -0
- package/dist/components/commands/drawer/index.js +1 -0
- package/dist/components/commands/drawer/style.css.cjs +1 -0
- package/dist/components/commands/drawer/style.css.js +1 -0
- package/dist/components/commands/drawer/types.d.ts +48 -0
- package/dist/components/commands/index.cjs +1 -0
- package/dist/components/commands/index.d.ts +15 -0
- package/dist/components/commands/index.js +1 -0
- package/dist/components/commands/message/index.cjs +1 -0
- package/dist/components/commands/message/index.d.ts +20 -0
- package/dist/components/commands/message/index.js +1 -0
- package/dist/components/commands/message/style.css.cjs +1 -0
- package/dist/components/commands/message/style.css.js +1 -0
- package/dist/components/commands/message/types.d.ts +39 -0
- package/dist/components/commands/modal/index.cjs +1 -0
- package/dist/components/commands/modal/index.d.ts +20 -0
- package/dist/components/commands/modal/index.js +1 -0
- package/dist/components/commands/modal/style.css.cjs +1 -0
- package/dist/components/commands/modal/style.css.js +1 -0
- package/dist/components/commands/modal/types.d.ts +68 -0
- package/dist/components/commands/popconfirm/index.cjs +1 -0
- package/dist/components/commands/popconfirm/index.d.ts +14 -0
- package/dist/components/commands/popconfirm/index.js +1 -0
- package/dist/components/commands/popconfirm/style.css.cjs +1 -0
- package/dist/components/commands/popconfirm/style.css.js +1 -0
- package/dist/components/commands/popconfirm/types.d.ts +44 -0
- package/dist/components/commands/tooltip/index.cjs +1 -0
- package/dist/components/commands/tooltip/index.d.ts +14 -0
- package/dist/components/commands/tooltip/index.js +1 -0
- package/dist/components/commands/tooltip/style.css.cjs +1 -0
- package/dist/components/commands/tooltip/style.css.js +1 -0
- package/dist/components/commands/tooltip/types.d.ts +43 -0
- package/dist/components/commands/utils.cjs +1 -0
- package/dist/components/commands/utils.d.ts +40 -0
- package/dist/components/commands/utils.js +1 -0
- package/dist/components/elements/alert/index.cjs +1 -0
- package/dist/components/elements/alert/index.d.ts +28 -0
- package/dist/components/elements/alert/index.html.cjs +1 -0
- package/dist/components/elements/alert/index.html.js +1 -0
- package/dist/components/elements/alert/index.js +1 -0
- package/dist/components/elements/alert/style.css.cjs +1 -0
- package/dist/components/elements/alert/style.css.js +1 -0
- package/dist/components/elements/alert/types.d.ts +18 -0
- package/dist/components/elements/backtop/index.cjs +1 -0
- package/dist/components/elements/backtop/index.d.ts +33 -0
- package/dist/components/elements/backtop/index.html.cjs +1 -0
- package/dist/components/elements/backtop/index.html.js +1 -0
- package/dist/components/elements/backtop/index.js +1 -0
- package/dist/components/elements/backtop/style.css.cjs +1 -0
- package/dist/components/elements/backtop/style.css.js +1 -0
- package/dist/components/elements/backtop/types.d.ts +9 -0
- package/dist/components/elements/badge/index.cjs +1 -0
- package/dist/components/elements/badge/index.d.ts +34 -0
- package/dist/components/elements/badge/index.html.cjs +1 -0
- package/dist/components/elements/badge/index.html.js +1 -0
- package/dist/components/elements/badge/index.js +1 -0
- package/dist/components/elements/badge/style.css.cjs +1 -0
- package/dist/components/elements/badge/style.css.js +1 -0
- package/dist/components/elements/badge/types.d.ts +22 -0
- package/dist/components/elements/breadcrumb/index.cjs +1 -0
- package/dist/components/elements/breadcrumb/index.d.ts +14 -0
- package/dist/components/elements/breadcrumb/index.html.cjs +1 -0
- package/dist/components/elements/breadcrumb/index.html.js +1 -0
- package/dist/components/elements/breadcrumb/index.js +1 -0
- package/dist/components/elements/breadcrumb/style.css.cjs +1 -0
- package/dist/components/elements/breadcrumb/style.css.js +1 -0
- package/dist/components/elements/breadcrumb/types.d.ts +15 -0
- package/dist/components/elements/button/index.cjs +1 -0
- package/dist/components/elements/button/index.d.ts +56 -0
- package/dist/components/elements/button/index.html.cjs +1 -0
- package/dist/components/elements/button/index.html.js +1 -0
- package/dist/components/elements/button/index.js +1 -0
- package/dist/components/elements/button/style.css.cjs +1 -0
- package/dist/components/elements/button/style.css.js +1 -0
- package/dist/components/elements/button/types.d.ts +42 -0
- package/dist/components/elements/card/index.cjs +1 -0
- package/dist/components/elements/card/index.d.ts +26 -0
- package/dist/components/elements/card/index.html.cjs +1 -0
- package/dist/components/elements/card/index.html.js +1 -0
- package/dist/components/elements/card/index.js +1 -0
- package/dist/components/elements/card/style.css.cjs +1 -0
- package/dist/components/elements/card/style.css.js +1 -0
- package/dist/components/elements/card/types.d.ts +28 -0
- package/dist/components/elements/checkbox/index.cjs +1 -0
- package/dist/components/elements/checkbox/index.d.ts +62 -0
- package/dist/components/elements/checkbox/index.html.cjs +1 -0
- package/dist/components/elements/checkbox/index.html.js +1 -0
- package/dist/components/elements/checkbox/index.js +1 -0
- package/dist/components/elements/checkbox/style.css.cjs +1 -0
- package/dist/components/elements/checkbox/style.css.js +1 -0
- package/dist/components/elements/checkbox/types.d.ts +30 -0
- package/dist/components/elements/coordinate-input/index.cjs +1 -0
- package/dist/components/elements/coordinate-input/index.d.ts +155 -0
- package/dist/components/elements/coordinate-input/index.html.cjs +1 -0
- package/dist/components/elements/coordinate-input/index.html.js +1 -0
- package/dist/components/elements/coordinate-input/index.js +1 -0
- package/dist/components/elements/coordinate-input/style.css.cjs +1 -0
- package/dist/components/elements/coordinate-input/style.css.js +1 -0
- package/dist/components/elements/coordinate-input/types.d.ts +112 -0
- package/dist/components/elements/divider/index.cjs +1 -0
- package/dist/components/elements/divider/index.d.ts +13 -0
- package/dist/components/elements/divider/index.html.cjs +1 -0
- package/dist/components/elements/divider/index.html.js +1 -0
- package/dist/components/elements/divider/index.js +1 -0
- package/dist/components/elements/divider/style.css.cjs +1 -0
- package/dist/components/elements/divider/style.css.js +1 -0
- package/dist/components/elements/divider/types.d.ts +15 -0
- package/dist/components/elements/empty/index.cjs +1 -0
- package/dist/components/elements/empty/index.d.ts +10 -0
- package/dist/components/elements/empty/index.html.cjs +1 -0
- package/dist/components/elements/empty/index.html.js +1 -0
- package/dist/components/elements/empty/index.js +1 -0
- package/dist/components/elements/empty/style.css.cjs +1 -0
- package/dist/components/elements/empty/style.css.js +1 -0
- package/dist/components/elements/empty/types.d.ts +9 -0
- package/dist/components/elements/fab/index.cjs +1 -0
- package/dist/components/elements/fab/index.d.ts +50 -0
- package/dist/components/elements/fab/index.html.cjs +1 -0
- package/dist/components/elements/fab/index.html.js +1 -0
- package/dist/components/elements/fab/index.js +1 -0
- package/dist/components/elements/fab/style.css.cjs +1 -0
- package/dist/components/elements/fab/style.css.js +1 -0
- package/dist/components/elements/fab/types.d.ts +52 -0
- package/dist/components/elements/index.cjs +1 -0
- package/dist/components/elements/index.d.ts +57 -0
- package/dist/components/elements/index.js +1 -0
- package/dist/components/elements/input/index.cjs +1 -0
- package/dist/components/elements/input/index.d.ts +100 -0
- package/dist/components/elements/input/index.html.cjs +1 -0
- package/dist/components/elements/input/index.html.js +1 -0
- package/dist/components/elements/input/index.js +1 -0
- package/dist/components/elements/input/style.css.cjs +1 -0
- package/dist/components/elements/input/style.css.js +1 -0
- package/dist/components/elements/input/types.d.ts +66 -0
- package/dist/components/elements/pagination/index.cjs +1 -0
- package/dist/components/elements/pagination/index.d.ts +80 -0
- package/dist/components/elements/pagination/index.html.cjs +1 -0
- package/dist/components/elements/pagination/index.html.js +1 -0
- package/dist/components/elements/pagination/index.js +1 -0
- package/dist/components/elements/pagination/style.css.cjs +1 -0
- package/dist/components/elements/pagination/style.css.js +1 -0
- package/dist/components/elements/pagination/types.d.ts +28 -0
- package/dist/components/elements/progress/index.cjs +1 -0
- package/dist/components/elements/progress/index.d.ts +42 -0
- package/dist/components/elements/progress/index.html.cjs +1 -0
- package/dist/components/elements/progress/index.html.js +1 -0
- package/dist/components/elements/progress/index.js +1 -0
- package/dist/components/elements/progress/style.css.cjs +1 -0
- package/dist/components/elements/progress/style.css.js +1 -0
- package/dist/components/elements/progress/types.d.ts +21 -0
- package/dist/components/elements/radio/index.cjs +1 -0
- package/dist/components/elements/radio/index.d.ts +42 -0
- package/dist/components/elements/radio/index.html.cjs +1 -0
- package/dist/components/elements/radio/index.html.js +1 -0
- package/dist/components/elements/radio/index.js +1 -0
- package/dist/components/elements/radio/style.css.cjs +1 -0
- package/dist/components/elements/radio/style.css.js +1 -0
- package/dist/components/elements/radio/types.d.ts +29 -0
- package/dist/components/elements/rate/index.cjs +1 -0
- package/dist/components/elements/rate/index.d.ts +47 -0
- package/dist/components/elements/rate/index.html.cjs +1 -0
- package/dist/components/elements/rate/index.html.js +1 -0
- package/dist/components/elements/rate/index.js +1 -0
- package/dist/components/elements/rate/style.css.cjs +1 -0
- package/dist/components/elements/rate/style.css.js +1 -0
- package/dist/components/elements/rate/types.d.ts +19 -0
- package/dist/components/elements/select/index.cjs +1 -0
- package/dist/components/elements/select/index.d.ts +68 -0
- package/dist/components/elements/select/index.html.cjs +1 -0
- package/dist/components/elements/select/index.html.js +1 -0
- package/dist/components/elements/select/index.js +1 -0
- package/dist/components/elements/select/style.css.cjs +1 -0
- package/dist/components/elements/select/style.css.js +1 -0
- package/dist/components/elements/select/types.d.ts +30 -0
- package/dist/components/elements/skeleton/index.cjs +1 -0
- package/dist/components/elements/skeleton/index.d.ts +26 -0
- package/dist/components/elements/skeleton/index.html.cjs +1 -0
- package/dist/components/elements/skeleton/index.html.js +1 -0
- package/dist/components/elements/skeleton/index.js +1 -0
- package/dist/components/elements/skeleton/style.css.cjs +1 -0
- package/dist/components/elements/skeleton/style.css.js +1 -0
- package/dist/components/elements/skeleton/types.d.ts +23 -0
- package/dist/components/elements/slider/index.cjs +1 -0
- package/dist/components/elements/slider/index.d.ts +76 -0
- package/dist/components/elements/slider/index.html.cjs +1 -0
- package/dist/components/elements/slider/index.html.js +1 -0
- package/dist/components/elements/slider/index.js +1 -0
- package/dist/components/elements/slider/style.css.cjs +1 -0
- package/dist/components/elements/slider/style.css.js +1 -0
- package/dist/components/elements/slider/types.d.ts +25 -0
- package/dist/components/elements/steps/index.cjs +1 -0
- package/dist/components/elements/steps/index.d.ts +31 -0
- package/dist/components/elements/steps/index.html.cjs +1 -0
- package/dist/components/elements/steps/index.html.js +1 -0
- package/dist/components/elements/steps/index.js +1 -0
- package/dist/components/elements/steps/style.css.cjs +1 -0
- package/dist/components/elements/steps/style.css.js +1 -0
- package/dist/components/elements/steps/types.d.ts +18 -0
- package/dist/components/elements/switch/index.cjs +1 -0
- package/dist/components/elements/switch/index.d.ts +62 -0
- package/dist/components/elements/switch/index.html.cjs +1 -0
- package/dist/components/elements/switch/index.html.js +1 -0
- package/dist/components/elements/switch/index.js +1 -0
- package/dist/components/elements/switch/style.css.cjs +1 -0
- package/dist/components/elements/switch/style.css.js +1 -0
- package/dist/components/elements/switch/types.d.ts +28 -0
- package/dist/components/elements/table/index.cjs +1 -0
- package/dist/components/elements/table/index.d.ts +46 -0
- package/dist/components/elements/table/index.html.cjs +1 -0
- package/dist/components/elements/table/index.html.js +1 -0
- package/dist/components/elements/table/index.js +1 -0
- package/dist/components/elements/table/style.css.cjs +1 -0
- package/dist/components/elements/table/style.css.js +1 -0
- package/dist/components/elements/table/types.d.ts +38 -0
- package/dist/components/elements/tabs/index.cjs +1 -0
- package/dist/components/elements/tabs/index.d.ts +54 -0
- package/dist/components/elements/tabs/index.html.cjs +1 -0
- package/dist/components/elements/tabs/index.html.js +1 -0
- package/dist/components/elements/tabs/index.js +1 -0
- package/dist/components/elements/tabs/style.css.cjs +1 -0
- package/dist/components/elements/tabs/style.css.js +1 -0
- package/dist/components/elements/tabs/types.d.ts +30 -0
- package/dist/components/elements/tag/index.cjs +1 -0
- package/dist/components/elements/tag/index.d.ts +22 -0
- package/dist/components/elements/tag/index.html.cjs +1 -0
- package/dist/components/elements/tag/index.html.js +1 -0
- package/dist/components/elements/tag/index.js +1 -0
- package/dist/components/elements/tag/style.css.cjs +1 -0
- package/dist/components/elements/tag/style.css.js +1 -0
- package/dist/components/elements/tag/types.d.ts +21 -0
- package/dist/components/elements/timeline/index.cjs +1 -0
- package/dist/components/elements/timeline/index.d.ts +25 -0
- package/dist/components/elements/timeline/index.html.cjs +1 -0
- package/dist/components/elements/timeline/index.html.js +1 -0
- package/dist/components/elements/timeline/index.js +1 -0
- package/dist/components/elements/timeline/style.css.cjs +1 -0
- package/dist/components/elements/timeline/style.css.js +1 -0
- package/dist/components/elements/timeline/types.d.ts +23 -0
- package/dist/components/elements/tree/index.cjs +1 -0
- package/dist/components/elements/tree/index.d.ts +127 -0
- package/dist/components/elements/tree/index.html.cjs +1 -0
- package/dist/components/elements/tree/index.html.js +1 -0
- package/dist/components/elements/tree/index.js +1 -0
- package/dist/components/elements/tree/style.css.cjs +1 -0
- package/dist/components/elements/tree/style.css.js +1 -0
- package/dist/components/elements/tree/types.d.ts +47 -0
- package/dist/components/elements/upload/index.cjs +1 -0
- package/dist/components/elements/upload/index.d.ts +74 -0
- package/dist/components/elements/upload/index.html.cjs +1 -0
- package/dist/components/elements/upload/index.html.js +1 -0
- package/dist/components/elements/upload/index.js +1 -0
- package/dist/components/elements/upload/style.css.cjs +1 -0
- package/dist/components/elements/upload/style.css.js +1 -0
- package/dist/components/elements/upload/types.d.ts +48 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.js +1 -0
- package/dist/components/theme/index.cjs +1 -0
- package/dist/components/theme/index.d.ts +45 -0
- package/dist/components/theme/index.js +1 -0
- package/dist/components/theme/variables.css +274 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugins/solely-vite-plugin.cjs +1 -1
- package/dist/plugins/solely-vite-plugin.js +1 -1
- package/dist/router/core.cjs +1 -1
- package/dist/router/core.js +1 -1
- package/dist/router/router-link.cjs +1 -1
- package/dist/router/router-link.js +1 -1
- package/dist/router/router-view.cjs +1 -1
- package/dist/router/router-view.js +1 -1
- package/dist/runtime/component/base-element.cjs +1 -1
- package/dist/runtime/component/base-element.d.ts +1 -1
- package/dist/runtime/component/base-element.js +1 -1
- package/dist/runtime/component/decorators.cjs +1 -1
- package/dist/runtime/component/decorators.d.ts +9 -0
- package/dist/runtime/component/decorators.js +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/reactivity/observe.cjs +1 -1
- package/dist/runtime/reactivity/observe.js +1 -1
- package/dist/runtime/renderer/html-decode.cjs +1 -1
- package/dist/runtime/renderer/html-decode.js +1 -1
- package/dist/runtime/renderer/renderIR.cjs +1 -1
- package/dist/runtime/renderer/renderIR.js +1 -1
- package/dist/shared/env.cjs +1 -1
- package/dist/shared/env.js +1 -1
- package/dist/shared/event-listeners.cjs +1 -1
- package/dist/shared/gen-function.cjs +1 -1
- package/dist/shared/gen-function.js +1 -1
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/is-object.js +1 -1
- package/dist/shared/templateError.cjs +1 -1
- package/dist/shared/templateError.js +1 -1
- package/dist/shared/url.cjs +1 -1
- package/dist/shared/url.js +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/lifecycle.cjs +1 -1
- package/package.json +43 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={width:520,mask:!0,maskClosable:!1,okText:"确定",cancelText:"取消"},a=[],l=new Set;let o=null;const c={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function s(t){var n;if(!l.has(t)){l.add(t);try{const l=a.findIndex(e=>e.id===t);if(-1===l)return;const o=a[l],c=o.element.querySelector(".modal-mask"),s=o.element.querySelector(".modal");c&&c.classList.add("is-closing"),s&&s.classList.add("is-closing"),await e.addClosingAnimation(o.element,e.ANIMATION_DURATION.NORMAL),null==(n=o.cleanup)||n.call(o);const i=a.findIndex(e=>e.id===t);-1!==i&&(a[i].element.remove(),a.splice(i,1))}finally{l.delete(t)}}}async function i(){if(0===a.length)return;const e=a[a.length-1];await s(e.id)}function d(t,n,a){const l=e.createElement("button",{className:`modal__btn modal__btn--${"default"===n?"default":n}`,textContent:t,attrs:{type:"button"}});return l.onclick=()=>e.safeAsyncCallback(a),l}function r(l){const i=e.generateId();e.injectStyle("solely-modal-styles",t.default);const r=l.type||"info",m=l.width??n.width,u=l.showCancel??"confirm"===r,p=l.maskClosable??n.maskClosable,f=e.createElement("div",{className:"modal-wrap",attrs:{tabIndex:"-1"}}),y=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),o||(o=new MutationObserver(()=>{a.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{o&&0===a.length&&(o.disconnect(),o=null)}}(f),h=[];if(!1!==l.mask){const t=e.createElement("div",{className:"modal-mask"});if(p){const e=()=>{var e;s(i),null==(e=l.onCancel)||e.call(l)};t.onclick=e,h.push({element:t,type:"click",handler:e})}f.appendChild(t)}const b=e.createElement("div",{className:"modal"+(l.className?` ${l.className}`:""),styles:{...l.style,width:"number"==typeof m?`${m}px`:m}}),C=e.createElement("div",{className:"modal__header"}),v=e.createElement("h3",{className:"modal__title",textContent:l.title||""});if(C.appendChild(v),!1!==l.closable){const t=e.createElement("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var e;s(i),null==(e=l.onClose)||e.call(l)};t.onclick=n,h.push({element:t,type:"click",handler:n}),C.appendChild(t)}b.appendChild(C);const _=e.createElement("div",{className:"modal__body"}),w=e.createElement("div",{className:"modal__content-wrapper"}),k=e.createElement("span",{className:`modal__icon modal__icon--${r}`,textContent:c[r]});w.appendChild(k);const x=e.createElement("div",{textContent:l.content||""});w.appendChild(x),_.appendChild(w),b.appendChild(_);const g=e.createElement("div",{className:"modal__footer"});if(l.buttons&&l.buttons.length>0)l.buttons.forEach(t=>{const n=d(t.text,t.type||"default",async()=>{await e.safeAsyncCallback(()=>t.onClick())});t.style&&Object.assign(n.style,t.style),g.appendChild(n)});else{if(u){const e=d(l.cancelText||n.cancelText,"default",()=>{var e;s(i),null==(e=l.onCancel)||e.call(l)});g.appendChild(e)}const t=d(l.okText||n.okText,l.okType||"primary",async()=>{l.onOk&&!1===await e.safeAsyncCallback(()=>l.onOk())||s(i)});g.appendChild(t)}b.appendChild(g),f.appendChild(b),document.body.appendChild(f),a.push({id:i,element:f,instance:null,cleanup:()=>{h.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),y()}});const N={close:()=>{var e;s(i),null==(e=l.onClose)||e.call(l)},update:e=>{if(void 0!==e.title){const t=f.querySelector(".modal__title");t&&(t.textContent=e.title)}if(void 0!==e.content){const t=f.querySelector(".modal__content");t&&(t.textContent=e.content)}if(void 0!==e.width){const t=f.querySelector(".modal");t&&(t.style.width="number"==typeof e.width?`${e.width}px`:e.width)}if(void 0!==e.className){const t=f.querySelector(".modal");t&&(t.className=`modal ${e.className}`.trim())}if(void 0!==e.style){const t=f.querySelector(".modal");t&&Object.assign(t.style,e.style)}}},E=a.find(e=>e.id===i);return E&&(E.instance=N),N}const m={open:r,confirm:function(e){return r({...e,type:"confirm",showCancel:!0})},info:function(e){return r({...e,type:"info"})},success:function(e){return r({...e,type:"success"})},error:function(e){return r({...e,type:"error"})},warning:function(e){return r({...e,type:"warning"})},config:function(e){Object.assign(n,e)},destroy:async function(){for(;a.length>0;)await i()}};exports.Modal=m;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModalOptions, ModalInstance, ModalConfig } from './types';
|
|
2
|
+
declare function open(options: ModalOptions): ModalInstance;
|
|
3
|
+
declare function confirm(options: Omit<ModalOptions, 'type'>): ModalInstance;
|
|
4
|
+
declare function info(options: Omit<ModalOptions, 'type'>): ModalInstance;
|
|
5
|
+
declare function success(options: Omit<ModalOptions, 'type'>): ModalInstance;
|
|
6
|
+
declare function error(options: Omit<ModalOptions, 'type'>): ModalInstance;
|
|
7
|
+
declare function warning(options: Omit<ModalOptions, 'type'>): ModalInstance;
|
|
8
|
+
declare function config(options: Partial<ModalConfig>): void;
|
|
9
|
+
declare function destroy(): Promise<void>;
|
|
10
|
+
export declare const Modal: {
|
|
11
|
+
open: typeof open;
|
|
12
|
+
confirm: typeof confirm;
|
|
13
|
+
info: typeof info;
|
|
14
|
+
success: typeof success;
|
|
15
|
+
error: typeof error;
|
|
16
|
+
warning: typeof warning;
|
|
17
|
+
config: typeof config;
|
|
18
|
+
destroy: typeof destroy;
|
|
19
|
+
};
|
|
20
|
+
export default Modal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createElement as t,injectStyle as e,safeAsyncCallback as n,generateId as l,addClosingAnimation as a,ANIMATION_DURATION as o}from"../utils.js";import s from"./style.css.js";const c={width:520,mask:!0,maskClosable:!1,okText:"确定",cancelText:"取消"},i=[],d=new Set;let r=null;const m={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function u(t){var e;if(!d.has(t)){d.add(t);try{const n=i.findIndex(e=>e.id===t);if(-1===n)return;const l=i[n],s=l.element.querySelector(".modal-mask"),c=l.element.querySelector(".modal");s&&s.classList.add("is-closing"),c&&c.classList.add("is-closing"),await a(l.element,o.NORMAL),null==(e=l.cleanup)||e.call(l);const d=i.findIndex(e=>e.id===t);-1!==d&&(i[d].element.remove(),i.splice(d,1))}finally{d.delete(t)}}}async function p(){if(0===i.length)return;const t=i[i.length-1];await u(t.id)}function f(e,l,a){const o=t("button",{className:`modal__btn modal__btn--${"default"===l?"default":l}`,textContent:e,attrs:{type:"button"}});return o.onclick=()=>n(a),o}function h(a){const o=l();e("solely-modal-styles",s);const d=a.type||"info",p=a.width??c.width,h=a.showCancel??"confirm"===d,y=a.maskClosable??c.maskClosable,b=t("div",{className:"modal-wrap",attrs:{tabIndex:"-1"}}),C=function(t){return(()=>{const e=document.documentElement.getAttribute("data-theme");e?t.setAttribute("data-theme",e):t.removeAttribute("data-theme")})(),r||(r=new MutationObserver(()=>{i.forEach(t=>{const e=document.documentElement.getAttribute("data-theme");e?t.element.setAttribute("data-theme",e):t.element.removeAttribute("data-theme")})}),r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{r&&0===i.length&&(r.disconnect(),r=null)}}(b),v=[];if(!1!==a.mask){const e=t("div",{className:"modal-mask"});if(y){const t=()=>{var t;u(o),null==(t=a.onCancel)||t.call(a)};e.onclick=t,v.push({element:e,type:"click",handler:t})}b.appendChild(e)}const _=t("div",{className:"modal"+(a.className?` ${a.className}`:""),styles:{...a.style,width:"number"==typeof p?`${p}px`:p}}),w=t("div",{className:"modal__header"}),x=t("h3",{className:"modal__title",textContent:a.title||""});if(w.appendChild(x),!1!==a.closable){const e=t("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var t;u(o),null==(t=a.onClose)||t.call(a)};e.onclick=n,v.push({element:e,type:"click",handler:n}),w.appendChild(e)}_.appendChild(w);const k=t("div",{className:"modal__body"}),N=t("div",{className:"modal__content-wrapper"}),g=t("span",{className:`modal__icon modal__icon--${d}`,textContent:m[d]});N.appendChild(g);const S=t("div",{textContent:a.content||""});N.appendChild(S),k.appendChild(N),_.appendChild(k);const q=t("div",{className:"modal__footer"});if(a.buttons&&a.buttons.length>0)a.buttons.forEach(t=>{const e=f(t.text,t.type||"default",async()=>{await n(()=>t.onClick())});t.style&&Object.assign(e.style,t.style),q.appendChild(e)});else{if(h){const t=f(a.cancelText||c.cancelText,"default",()=>{var t;u(o),null==(t=a.onCancel)||t.call(a)});q.appendChild(t)}const t=f(a.okText||c.okText,a.okType||"primary",async()=>{a.onOk&&!1===await n(()=>a.onOk())||u(o)});q.appendChild(t)}_.appendChild(q),b.appendChild(_),document.body.appendChild(b),i.push({id:o,element:b,instance:null,cleanup:()=>{v.forEach(({element:t,type:e,handler:n})=>{t.removeEventListener(e,n)}),C()}});const A={close:()=>{var t;u(o),null==(t=a.onClose)||t.call(a)},update:t=>{if(void 0!==t.title){const e=b.querySelector(".modal__title");e&&(e.textContent=t.title)}if(void 0!==t.content){const e=b.querySelector(".modal__content");e&&(e.textContent=t.content)}if(void 0!==t.width){const e=b.querySelector(".modal");e&&(e.style.width="number"==typeof t.width?`${t.width}px`:t.width)}if(void 0!==t.className){const e=b.querySelector(".modal");e&&(e.className=`modal ${t.className}`.trim())}if(void 0!==t.style){const e=b.querySelector(".modal");e&&Object.assign(e.style,t.style)}}},E=i.find(t=>t.id===o);return E&&(E.instance=A),A}const y={open:h,confirm:function(t){return h({...t,type:"confirm",showCancel:!0})},info:function(t){return h({...t,type:"info"})},success:function(t){return h({...t,type:"success"})},error:function(t){return h({...t,type:"error"})},warning:function(t){return h({...t,type:"warning"})},config:function(t){Object.assign(c,t)},destroy:async function(){for(;i.length>0;)await p()}};export{y as Modal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}.modal-mask{position:fixed;top:0;left:0;right:0;bottom:0;background-color:var(--solely-mask-bg);z-index:1;pointer-events:auto;animation:modal-mask-in var(--solely-transition-duration) var(--solely-transition-timing)}.modal-mask.is-closing{animation:modal-mask-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.modal-wrap{position:fixed;top:0;left:0;right:0;bottom:0;z-index:var(--solely-z-index-modal);display:flex;align-items:center;justify-content:center;overflow:auto;outline:0;pointer-events:none}.modal{position:relative;z-index:2;background-color:var(--solely-component-bg);border-radius:var(--solely-border-radius-md);box-shadow:var(--solely-shadow-lg);animation:modal-container-in var(--solely-transition-duration) var(--solely-transition-timing);max-width:calc(100vw - var(--solely-spacing-xl));margin:var(--solely-spacing-md);pointer-events:auto}.modal.is-closing{animation:modal-container-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.modal__header{padding:var(--solely-spacing-lg) var(--solely-spacing-xl);border-bottom:1px solid var(--solely-border-color-split);display:flex;align-items:center;justify-content:space-between}.modal__title{margin:0;font-size:var(--solely-font-size-lg);font-weight:500;color:var(--solely-text-primary);line-height:var(--solely-line-height-lg)}.modal__close{width:var(--solely-height-sm);height:var(--solely-height-sm);display:flex;align-items:center;justify-content:center;color:var(--solely-text-tertiary);cursor:pointer;transition:color var(--solely-transition-duration);font-size:var(--solely-font-size-lg);line-height:1;border:none;background:none;border-radius:var(--solely-border-radius-sm)}.modal__close:hover{color:var(--solely-text-secondary);background-color:var(--solely-gray-3)}.modal__close:active{color:var(--solely-text-primary)}.modal__body{padding:var(--solely-spacing-xl);font-size:var(--solely-font-size-md);line-height:var(--solely-line-height-md);color:var(--solely-text-secondary)}.modal__content-wrapper{display:flex;align-items:flex-start;gap:var(--solely-spacing-sm)}.modal__footer{padding:var(--solely-spacing-md) var(--solely-spacing-lg);border-top:1px solid var(--solely-border-color-split);display:flex;justify-content:flex-end;gap:var(--solely-spacing-sm)}.modal__icon{display:inline-flex;align-items:center;justify-content:center;width:var(--solely-height-sm);height:var(--solely-height-sm);border-radius:var(--solely-border-radius-circle);margin-right:var(--solely-spacing-sm);font-size:var(--solely-font-size-md)}.modal__icon--info{background-color:var(--solely-info-light);color:var(--solely-info)}.modal__icon--success{background-color:var(--solely-success-light);color:var(--solely-success)}.modal__icon--warning{background-color:var(--solely-warning-light);color:var(--solely-warning)}.modal__icon--error{background-color:var(--solely-error-light);color:var(--solely-error)}.modal__icon--confirm{background-color:var(--solely-warning-light);color:var(--solely-warning)}.modal__btn{display:inline-flex;align-items:center;justify-content:center;gap:var(--solely-spacing-xs);height:var(--solely-height-md);padding:0 var(--solely-spacing-md);font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);font-weight:400;line-height:var(--solely-line-height-md);white-space:nowrap;text-align:center;text-decoration:none;vertical-align:middle;background-image:none;border:1px solid transparent;border-radius:var(--solely-border-radius-md);cursor:pointer;transition:all var(--solely-transition-duration) var(--solely-transition-timing);-webkit-user-select:none;user-select:none;touch-action:manipulation;outline:none;position:relative}.modal__btn:hover:not(:disabled){opacity:.9}.modal__btn:active:not(:disabled){opacity:.8}.modal__btn:disabled{opacity:.4;cursor:not-allowed}.modal__btn--primary{color:var(--solely-white);background-color:var(--solely-primary);border-color:var(--solely-primary)}.modal__btn--default{color:var(--solely-text-primary);background-color:var(--solely-component-bg);border-color:var(--solely-border-color)}.modal__btn--danger{color:var(--solely-white);background-color:var(--solely-error);border-color:var(--solely-error)}@keyframes modal-mask-in{0%{opacity:0}to{opacity:1}}@keyframes modal-mask-out{0%{opacity:1}to{opacity:0}}@keyframes modal-container-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes modal-container-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="*,*:before,*:after{box-sizing:border-box}.modal-mask{position:fixed;top:0;left:0;right:0;bottom:0;background-color:var(--solely-mask-bg);z-index:1;pointer-events:auto;animation:modal-mask-in var(--solely-transition-duration) var(--solely-transition-timing)}.modal-mask.is-closing{animation:modal-mask-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.modal-wrap{position:fixed;top:0;left:0;right:0;bottom:0;z-index:var(--solely-z-index-modal);display:flex;align-items:center;justify-content:center;overflow:auto;outline:0;pointer-events:none}.modal{position:relative;z-index:2;background-color:var(--solely-component-bg);border-radius:var(--solely-border-radius-md);box-shadow:var(--solely-shadow-lg);animation:modal-container-in var(--solely-transition-duration) var(--solely-transition-timing);max-width:calc(100vw - var(--solely-spacing-xl));margin:var(--solely-spacing-md);pointer-events:auto}.modal.is-closing{animation:modal-container-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.modal__header{padding:var(--solely-spacing-lg) var(--solely-spacing-xl);border-bottom:1px solid var(--solely-border-color-split);display:flex;align-items:center;justify-content:space-between}.modal__title{margin:0;font-size:var(--solely-font-size-lg);font-weight:500;color:var(--solely-text-primary);line-height:var(--solely-line-height-lg)}.modal__close{width:var(--solely-height-sm);height:var(--solely-height-sm);display:flex;align-items:center;justify-content:center;color:var(--solely-text-tertiary);cursor:pointer;transition:color var(--solely-transition-duration);font-size:var(--solely-font-size-lg);line-height:1;border:none;background:none;border-radius:var(--solely-border-radius-sm)}.modal__close:hover{color:var(--solely-text-secondary);background-color:var(--solely-gray-3)}.modal__close:active{color:var(--solely-text-primary)}.modal__body{padding:var(--solely-spacing-xl);font-size:var(--solely-font-size-md);line-height:var(--solely-line-height-md);color:var(--solely-text-secondary)}.modal__content-wrapper{display:flex;align-items:flex-start;gap:var(--solely-spacing-sm)}.modal__footer{padding:var(--solely-spacing-md) var(--solely-spacing-lg);border-top:1px solid var(--solely-border-color-split);display:flex;justify-content:flex-end;gap:var(--solely-spacing-sm)}.modal__icon{display:inline-flex;align-items:center;justify-content:center;width:var(--solely-height-sm);height:var(--solely-height-sm);border-radius:var(--solely-border-radius-circle);margin-right:var(--solely-spacing-sm);font-size:var(--solely-font-size-md)}.modal__icon--info{background-color:var(--solely-info-light);color:var(--solely-info)}.modal__icon--success{background-color:var(--solely-success-light);color:var(--solely-success)}.modal__icon--warning{background-color:var(--solely-warning-light);color:var(--solely-warning)}.modal__icon--error{background-color:var(--solely-error-light);color:var(--solely-error)}.modal__icon--confirm{background-color:var(--solely-warning-light);color:var(--solely-warning)}.modal__btn{display:inline-flex;align-items:center;justify-content:center;gap:var(--solely-spacing-xs);height:var(--solely-height-md);padding:0 var(--solely-spacing-md);font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);font-weight:400;line-height:var(--solely-line-height-md);white-space:nowrap;text-align:center;text-decoration:none;vertical-align:middle;background-image:none;border:1px solid transparent;border-radius:var(--solely-border-radius-md);cursor:pointer;transition:all var(--solely-transition-duration) var(--solely-transition-timing);-webkit-user-select:none;user-select:none;touch-action:manipulation;outline:none;position:relative}.modal__btn:hover:not(:disabled){opacity:.9}.modal__btn:active:not(:disabled){opacity:.8}.modal__btn:disabled{opacity:.4;cursor:not-allowed}.modal__btn--primary{color:var(--solely-white);background-color:var(--solely-primary);border-color:var(--solely-primary)}.modal__btn--default{color:var(--solely-text-primary);background-color:var(--solely-component-bg);border-color:var(--solely-border-color)}.modal__btn--danger{color:var(--solely-white);background-color:var(--solely-error);border-color:var(--solely-error)}@keyframes modal-mask-in{0%{opacity:0}to{opacity:1}}@keyframes modal-mask-out{0%{opacity:1}to{opacity:0}}@keyframes modal-container-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes modal-container-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}";export{o as default};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal 组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
export type ModalType = 'info' | 'success' | 'warning' | 'error' | 'confirm';
|
|
5
|
+
export interface ModalButton {
|
|
6
|
+
/** 按钮文字 */
|
|
7
|
+
text: string;
|
|
8
|
+
/** 按钮类型 */
|
|
9
|
+
type?: 'primary' | 'default' | 'danger';
|
|
10
|
+
/** 按钮样式 */
|
|
11
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
12
|
+
/** 点击回调 */
|
|
13
|
+
onClick: () => void | Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface ModalOptions {
|
|
16
|
+
/** 标题 */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** 内容 */
|
|
19
|
+
content?: string;
|
|
20
|
+
/** 类型 */
|
|
21
|
+
type?: ModalType;
|
|
22
|
+
/** 宽度 */
|
|
23
|
+
width?: number | string;
|
|
24
|
+
/** 是否显示遮罩 */
|
|
25
|
+
mask?: boolean;
|
|
26
|
+
/** 是否可点击遮罩关闭 */
|
|
27
|
+
maskClosable?: boolean;
|
|
28
|
+
/** 是否显示关闭按钮 */
|
|
29
|
+
closable?: boolean;
|
|
30
|
+
/** 确定按钮文字 */
|
|
31
|
+
okText?: string;
|
|
32
|
+
/** 取消按钮文字 */
|
|
33
|
+
cancelText?: string;
|
|
34
|
+
/** 确定按钮类型 */
|
|
35
|
+
okType?: 'primary' | 'default' | 'danger';
|
|
36
|
+
/** 是否显示取消按钮 */
|
|
37
|
+
showCancel?: boolean;
|
|
38
|
+
/** 自定义按钮数组(如果提供,将忽略 okText/cancelText/showCancel) */
|
|
39
|
+
buttons?: ModalButton[];
|
|
40
|
+
/** 确定按钮回调 */
|
|
41
|
+
onOk?: () => void | Promise<void>;
|
|
42
|
+
/** 取消按钮回调 */
|
|
43
|
+
onCancel?: () => void;
|
|
44
|
+
/** 关闭后回调 */
|
|
45
|
+
onClose?: () => void;
|
|
46
|
+
/** 自定义类名 */
|
|
47
|
+
className?: string;
|
|
48
|
+
/** 自定义样式 */
|
|
49
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
50
|
+
}
|
|
51
|
+
export interface ModalInstance {
|
|
52
|
+
/** 关闭弹窗 */
|
|
53
|
+
close: () => void;
|
|
54
|
+
/** 更新内容 */
|
|
55
|
+
update: (options: Partial<ModalOptions>) => void;
|
|
56
|
+
}
|
|
57
|
+
export interface ModalConfig {
|
|
58
|
+
/** 默认宽度 */
|
|
59
|
+
width: number | string;
|
|
60
|
+
/** 默认是否显示遮罩 */
|
|
61
|
+
mask: boolean;
|
|
62
|
+
/** 默认是否可点击遮罩关闭 */
|
|
63
|
+
maskClosable: boolean;
|
|
64
|
+
/** 默认确定按钮文字 */
|
|
65
|
+
okText: string;
|
|
66
|
+
/** 默认取消按钮文字 */
|
|
67
|
+
cancelText: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={okText:"确定",cancelText:"取消",okType:"primary",showCancel:!0,placement:"top"};let o=null,a=null;const c=new WeakSet;async function s(){if(!o)return;const{element:t}=o,n=t.querySelector(".popconfirm");n&&n.classList.add("is-closing"),await e.addClosingAnimation(t,e.ANIMATION_DURATION.FAST),t.remove(),o=null}async function r(c,r){if(o&&o.target===c)return await s(),{destroy:()=>{}};await s();const l=e.generateId();e.injectStyle("solely-popconfirm-styles",t.default);const i=r.placement??n.placement,d=r.okType??n.okType,m=r.showCancel??n.showCancel,p=e.createElement("div",{className:"popconfirm-overlay"}),u=(f=p,(()=>{const e=document.documentElement.getAttribute("data-theme");e?f.setAttribute("data-theme",e):f.removeAttribute("data-theme")})(),a||(a=new MutationObserver(()=>{if(o){const e=document.documentElement.getAttribute("data-theme");e?o.element.setAttribute("data-theme",e):o.element.removeAttribute("data-theme")}}),a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{a&&!o&&(a.disconnect(),a=null)});var f;const y=e.createElement("div",{className:`popconfirm popconfirm--${i}${r.className?` ${r.className}`:""}`,styles:r.style}),v=e.createElement("div",{className:"popconfirm__content"}),b=e.createElement("span",{className:"popconfirm__icon",textContent:"⚠"});v.appendChild(b);const _=e.createElement("div",{className:"popconfirm__text"}),w=e.createElement("div",{className:"popconfirm__title",textContent:r.title});if(_.appendChild(w),r.description){const t=e.createElement("div",{className:"popconfirm__description",textContent:r.description});_.appendChild(t)}v.appendChild(_);const E=e.createElement("div",{className:"popconfirm__buttons"}),h=async()=>{var e;await s(),null==(e=r.onCancel)||e.call(r)};if(m){const t=e.createElement("button",{className:"popconfirm__btn popconfirm__btn--cancel",textContent:r.cancelText??n.cancelText,attrs:{type:"button"}});t.onclick=h,E.appendChild(t)}const C=e.createElement("button",{className:"popconfirm__btn popconfirm__btn--ok"+("danger"===d?" popconfirm__btn--danger":""),textContent:r.okText??n.okText,attrs:{type:"button"}});C.onclick=async()=>{var e;await s(),null==(e=r.onConfirm)||e.call(r)},E.appendChild(C);const k=e.createElement("div",{className:"popconfirm__arrow"});y.appendChild(k),y.appendChild(v),y.appendChild(E),p.appendChild(y),document.body.appendChild(p);const x=e.calculatePosition(c,y,i);y.style.top=`${x.top}px`,y.style.left=`${x.left}px`,void 0!==x.arrowLeft&&(k.style.left=`${x.arrowLeft}px`),void 0!==x.arrowTop&&(k.style.top=`${x.arrowTop}px`);const g=e=>{e.target===p&&h()},N=e=>{"Escape"===e.key&&(h(),document.removeEventListener("keydown",N))};p.addEventListener("click",g),document.addEventListener("keydown",N);const T=()=>{document.removeEventListener("keydown",N),p.removeEventListener("click",g),u(),s()};return o={id:l,target:c,element:p,destroy:T},{destroy:T}}const l={show:r,bind:function(e,t){if(c.has(e))return{destroy:()=>{}};c.add(e);let n=null;const a=async a=>{a.stopPropagation(),o?(await s(),n=null):n=await r(e,t)},l=async t=>{if(!o)return;const a=t.target;o.element.contains(a)||e.contains(a)||(await s(),n=null)};return e.addEventListener("click",a),document.addEventListener("mousedown",l),{destroy:()=>{c.delete(e),e.removeEventListener("click",a),document.removeEventListener("mousedown",l),null==n||n.destroy(),n=null}}},config:function(e){Object.assign(n,e)},destroy:s};exports.Popconfirm=l;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PopconfirmOptions, PopconfirmInstance, PopconfirmPlacement, PopconfirmConfig } from './types';
|
|
2
|
+
declare function destroyCurrent(): Promise<void>;
|
|
3
|
+
declare function show(target: HTMLElement, options: PopconfirmOptions): Promise<PopconfirmInstance>;
|
|
4
|
+
declare function bind(target: HTMLElement, options: Omit<PopconfirmOptions, 'placement'> & {
|
|
5
|
+
placement?: PopconfirmPlacement;
|
|
6
|
+
}): PopconfirmInstance;
|
|
7
|
+
declare function config(options: Partial<PopconfirmConfig>): void;
|
|
8
|
+
export declare const Popconfirm: {
|
|
9
|
+
show: typeof show;
|
|
10
|
+
bind: typeof bind;
|
|
11
|
+
config: typeof config;
|
|
12
|
+
destroy: typeof destroyCurrent;
|
|
13
|
+
};
|
|
14
|
+
export default Popconfirm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createElement as t,calculatePosition as e,injectStyle as n,addClosingAnimation as o,ANIMATION_DURATION as a,generateId as c}from"../utils.js";import s from"./style.css.js";const i={okText:"确定",cancelText:"取消",okType:"primary",showCancel:!0,placement:"top"};let r=null,l=null;const d=new WeakSet;async function p(){if(!r)return;const{element:t}=r,e=t.querySelector(".popconfirm");e&&e.classList.add("is-closing"),await o(t,a.FAST),t.remove(),r=null}async function m(o,a){if(r&&r.target===o)return await p(),{destroy:()=>{}};await p();const d=c();n("solely-popconfirm-styles",s);const m=a.placement??i.placement,u=a.okType??i.okType,f=a.showCancel??i.showCancel,y=t("div",{className:"popconfirm-overlay"}),v=(w=y,(()=>{const t=document.documentElement.getAttribute("data-theme");t?w.setAttribute("data-theme",t):w.removeAttribute("data-theme")})(),l||(l=new MutationObserver(()=>{if(r){const t=document.documentElement.getAttribute("data-theme");t?r.element.setAttribute("data-theme",t):r.element.removeAttribute("data-theme")}}),l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{l&&!r&&(l.disconnect(),l=null)});var w;const _=t("div",{className:`popconfirm popconfirm--${m}${a.className?` ${a.className}`:""}`,styles:a.style}),b=t("div",{className:"popconfirm__content"}),h=t("span",{className:"popconfirm__icon",textContent:"⚠"});b.appendChild(h);const C=t("div",{className:"popconfirm__text"}),k=t("div",{className:"popconfirm__title",textContent:a.title});if(C.appendChild(k),a.description){const e=t("div",{className:"popconfirm__description",textContent:a.description});C.appendChild(e)}b.appendChild(C);const x=t("div",{className:"popconfirm__buttons"}),E=async()=>{var t;await p(),null==(t=a.onCancel)||t.call(a)};if(f){const e=t("button",{className:"popconfirm__btn popconfirm__btn--cancel",textContent:a.cancelText??i.cancelText,attrs:{type:"button"}});e.onclick=E,x.appendChild(e)}const N=t("button",{className:"popconfirm__btn popconfirm__btn--ok"+("danger"===u?" popconfirm__btn--danger":""),textContent:a.okText??i.okText,attrs:{type:"button"}});N.onclick=async()=>{var t;await p(),null==(t=a.onConfirm)||t.call(a)},x.appendChild(N);const g=t("div",{className:"popconfirm__arrow"});_.appendChild(g),_.appendChild(b),_.appendChild(x),y.appendChild(_),document.body.appendChild(y);const L=e(o,_,m);_.style.top=`${L.top}px`,_.style.left=`${L.left}px`,void 0!==L.arrowLeft&&(g.style.left=`${L.arrowLeft}px`),void 0!==L.arrowTop&&(g.style.top=`${L.arrowTop}px`);const T=t=>{t.target===y&&E()},A=t=>{"Escape"===t.key&&(E(),document.removeEventListener("keydown",A))};y.addEventListener("click",T),document.addEventListener("keydown",A);const $=()=>{document.removeEventListener("keydown",A),y.removeEventListener("click",T),v(),p()};return r={id:d,target:o,element:y,destroy:$},{destroy:$}}const u={show:m,bind:function(t,e){if(d.has(t))return{destroy:()=>{}};d.add(t);let n=null;const o=async o=>{o.stopPropagation(),r?(await p(),n=null):n=await m(t,e)},a=async e=>{if(!r)return;const o=e.target;r.element.contains(o)||t.contains(o)||(await p(),n=null)};return t.addEventListener("click",o),document.addEventListener("mousedown",a),{destroy:()=>{d.delete(t),t.removeEventListener("click",o),document.removeEventListener("mousedown",a),null==n||n.destroy(),n=null}}},config:function(t){Object.assign(i,t)},destroy:p};export{u as Popconfirm};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}.popconfirm-overlay{position:absolute;top:0;left:0;width:100%;min-height:100%;z-index:var(--solely-z-index-popover)}.popconfirm{position:absolute;background-color:var(--solely-component-bg);border-radius:var(--solely-border-radius-md);box-shadow:var(--solely-shadow-lg);padding:var(--solely-spacing-lg);min-width:200px;max-width:300px;font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);z-index:var(--solely-z-index-popover);animation:popconfirm-fade-in var(--solely-transition-duration) var(--solely-transition-timing)}.popconfirm.is-closing{animation:popconfirm-fade-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.popconfirm__arrow{position:absolute;width:var(--solely-popconfirm-arrow-size, 8px);height:var(--solely-popconfirm-arrow-size, 8px);background-color:var(--solely-component-bg);transform:rotate(45deg)}.popconfirm--top .popconfirm__arrow,.popconfirm--topLeft .popconfirm__arrow,.popconfirm--topRight .popconfirm__arrow{bottom:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-bottom:1px solid var(--solely-border-color-split);border-right:1px solid var(--solely-border-color-split)}.popconfirm--bottom .popconfirm__arrow,.popconfirm--bottomLeft .popconfirm__arrow,.popconfirm--bottomRight .popconfirm__arrow{top:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-top:1px solid var(--solely-border-color-split);border-left:1px solid var(--solely-border-color-split)}.popconfirm--left .popconfirm__arrow,.popconfirm--leftTop .popconfirm__arrow,.popconfirm--leftBottom .popconfirm__arrow{right:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-top:1px solid var(--solely-border-color-split);border-right:1px solid var(--solely-border-color-split)}.popconfirm--right .popconfirm__arrow,.popconfirm--rightTop .popconfirm__arrow,.popconfirm--rightBottom .popconfirm__arrow{left:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-bottom:1px solid var(--solely-border-color-split);border-left:1px solid var(--solely-border-color-split)}.popconfirm__content{display:flex;align-items:flex-start;gap:var(--solely-spacing-sm);margin-bottom:var(--solely-spacing-md)}.popconfirm__icon{color:var(--solely-warning);font-size:var(--solely-font-size-lg);flex-shrink:0}.popconfirm__text{flex:1}.popconfirm__title{font-weight:500;color:var(--solely-text-primary);line-height:var(--solely-line-height-md)}.popconfirm__description{font-size:var(--solely-font-size-sm);color:var(--solely-text-secondary);margin-top:var(--solely-spacing-xs);line-height:var(--solely-line-height-sm)}.popconfirm__buttons{display:flex;justify-content:flex-end;gap:var(--solely-spacing-sm)}.popconfirm__btn{padding:var(--solely-spacing-xs) var(--solely-spacing-md);border-radius:var(--solely-border-radius-sm);font-size:var(--solely-font-size-sm);cursor:pointer;transition:all var(--solely-transition-duration) var(--solely-transition-timing);border:1px solid transparent;font-family:var(--solely-font-family);line-height:var(--solely-line-height-sm)}.popconfirm__btn--cancel{background-color:var(--solely-component-bg);border-color:var(--solely-border-color);color:var(--solely-text-primary)}.popconfirm__btn--cancel:hover{border-color:var(--solely-primary);color:var(--solely-primary)}.popconfirm__btn--ok{background-color:var(--solely-primary);border-color:var(--solely-primary);color:var(--solely-white)}.popconfirm__btn--ok:hover{background-color:var(--solely-primary-hover);border-color:var(--solely-primary-hover)}.popconfirm__btn--danger{background-color:var(--solely-error);border-color:var(--solely-error)}.popconfirm__btn--danger:hover{background-color:var(--solely-error-hover);border-color:var(--solely-error-hover)}@keyframes popconfirm-fade-in{0%{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}@keyframes popconfirm-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9)}}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="*,*:before,*:after{box-sizing:border-box}.popconfirm-overlay{position:absolute;top:0;left:0;width:100%;min-height:100%;z-index:var(--solely-z-index-popover)}.popconfirm{position:absolute;background-color:var(--solely-component-bg);border-radius:var(--solely-border-radius-md);box-shadow:var(--solely-shadow-lg);padding:var(--solely-spacing-lg);min-width:200px;max-width:300px;font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);z-index:var(--solely-z-index-popover);animation:popconfirm-fade-in var(--solely-transition-duration) var(--solely-transition-timing)}.popconfirm.is-closing{animation:popconfirm-fade-out var(--solely-transition-duration) var(--solely-transition-timing) forwards}.popconfirm__arrow{position:absolute;width:var(--solely-popconfirm-arrow-size, 8px);height:var(--solely-popconfirm-arrow-size, 8px);background-color:var(--solely-component-bg);transform:rotate(45deg)}.popconfirm--top .popconfirm__arrow,.popconfirm--topLeft .popconfirm__arrow,.popconfirm--topRight .popconfirm__arrow{bottom:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-bottom:1px solid var(--solely-border-color-split);border-right:1px solid var(--solely-border-color-split)}.popconfirm--bottom .popconfirm__arrow,.popconfirm--bottomLeft .popconfirm__arrow,.popconfirm--bottomRight .popconfirm__arrow{top:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-top:1px solid var(--solely-border-color-split);border-left:1px solid var(--solely-border-color-split)}.popconfirm--left .popconfirm__arrow,.popconfirm--leftTop .popconfirm__arrow,.popconfirm--leftBottom .popconfirm__arrow{right:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-top:1px solid var(--solely-border-color-split);border-right:1px solid var(--solely-border-color-split)}.popconfirm--right .popconfirm__arrow,.popconfirm--rightTop .popconfirm__arrow,.popconfirm--rightBottom .popconfirm__arrow{left:calc(var(--solely-popconfirm-arrow-size, 8px) / -2);border-bottom:1px solid var(--solely-border-color-split);border-left:1px solid var(--solely-border-color-split)}.popconfirm__content{display:flex;align-items:flex-start;gap:var(--solely-spacing-sm);margin-bottom:var(--solely-spacing-md)}.popconfirm__icon{color:var(--solely-warning);font-size:var(--solely-font-size-lg);flex-shrink:0}.popconfirm__text{flex:1}.popconfirm__title{font-weight:500;color:var(--solely-text-primary);line-height:var(--solely-line-height-md)}.popconfirm__description{font-size:var(--solely-font-size-sm);color:var(--solely-text-secondary);margin-top:var(--solely-spacing-xs);line-height:var(--solely-line-height-sm)}.popconfirm__buttons{display:flex;justify-content:flex-end;gap:var(--solely-spacing-sm)}.popconfirm__btn{padding:var(--solely-spacing-xs) var(--solely-spacing-md);border-radius:var(--solely-border-radius-sm);font-size:var(--solely-font-size-sm);cursor:pointer;transition:all var(--solely-transition-duration) var(--solely-transition-timing);border:1px solid transparent;font-family:var(--solely-font-family);line-height:var(--solely-line-height-sm)}.popconfirm__btn--cancel{background-color:var(--solely-component-bg);border-color:var(--solely-border-color);color:var(--solely-text-primary)}.popconfirm__btn--cancel:hover{border-color:var(--solely-primary);color:var(--solely-primary)}.popconfirm__btn--ok{background-color:var(--solely-primary);border-color:var(--solely-primary);color:var(--solely-white)}.popconfirm__btn--ok:hover{background-color:var(--solely-primary-hover);border-color:var(--solely-primary-hover)}.popconfirm__btn--danger{background-color:var(--solely-error);border-color:var(--solely-error)}.popconfirm__btn--danger:hover{background-color:var(--solely-error-hover);border-color:var(--solely-error-hover)}@keyframes popconfirm-fade-in{0%{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}@keyframes popconfirm-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9)}}";export{o as default};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Popconfirm 组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
export type PopconfirmPlacement = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
5
|
+
export interface PopconfirmOptions {
|
|
6
|
+
/** 确认框标题 */
|
|
7
|
+
title: string;
|
|
8
|
+
/** 确认框描述 */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** 气泡框位置 */
|
|
11
|
+
placement?: PopconfirmPlacement;
|
|
12
|
+
/** 确认按钮文字 */
|
|
13
|
+
okText?: string;
|
|
14
|
+
/** 确认按钮类型 */
|
|
15
|
+
okType?: 'primary' | 'danger' | 'default';
|
|
16
|
+
/** 取消按钮文字 */
|
|
17
|
+
cancelText?: string;
|
|
18
|
+
/** 是否显示取消按钮 */
|
|
19
|
+
showCancel?: boolean;
|
|
20
|
+
/** 确认回调 */
|
|
21
|
+
onConfirm?: () => void;
|
|
22
|
+
/** 取消回调 */
|
|
23
|
+
onCancel?: () => void;
|
|
24
|
+
/** 自定义类名 */
|
|
25
|
+
className?: string;
|
|
26
|
+
/** 自定义样式 */
|
|
27
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
28
|
+
}
|
|
29
|
+
export interface PopconfirmInstance {
|
|
30
|
+
/** 销毁确认框 */
|
|
31
|
+
destroy: () => void;
|
|
32
|
+
}
|
|
33
|
+
export interface PopconfirmConfig {
|
|
34
|
+
/** 默认确认按钮文字 */
|
|
35
|
+
okText: string;
|
|
36
|
+
/** 默认取消按钮文字 */
|
|
37
|
+
cancelText: string;
|
|
38
|
+
/** 默认确认按钮类型 */
|
|
39
|
+
okType: 'primary' | 'danger' | 'default';
|
|
40
|
+
/** 默认是否显示取消按钮 */
|
|
41
|
+
showCancel: boolean;
|
|
42
|
+
/** 默认气泡框位置 */
|
|
43
|
+
placement: PopconfirmPlacement;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={placement:"top",trigger:"hover",duration:3e3},o=[],l=new WeakSet;let s=null;async function i(t,n){const l=o.findIndex(e=>e.id===t);if(-1===l)return;const s=o[l],i=s.element.querySelector(".tooltip");i&&i.classList.add("is-closing"),await e.addClosingAnimation(s.element,e.ANIMATION_DURATION.FAST),s.element.remove(),o.splice(l,1),null==n||n()}function r(l,r){var a;const c=e.generateId();e.injectStyle("solely-tooltip-styles",t.default);const d=r.placement??n.placement,u=e.createElement("div",{className:"tooltip-overlay"}),m=(v=u,(()=>{const e=document.documentElement.getAttribute("data-theme");e?v.setAttribute("data-theme",e):v.removeAttribute("data-theme")})(),s||(s=new MutationObserver(()=>{o.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{s&&0===o.length&&(s.disconnect(),s=null)});var v;const p=e.createElement("div",{className:`tooltip tooltip--${d}${r.className?` ${r.className}`:""}`,styles:{...r.style,...r.color?{backgroundColor:r.color}:{}}}),h=e.createElement("div",{className:"tooltip__content",textContent:r.content||""});p.appendChild(h);const g=e.createElement("div",{className:"tooltip__arrow"});r.color&&(g.style.backgroundColor=r.color),p.appendChild(g),u.appendChild(p),document.body.appendChild(u);const f=e.calculatePosition(l,p,d);return p.style.top=`${f.top}px`,p.style.left=`${f.left}px`,void 0!==f.arrowLeft&&(g.style.left=`${f.arrowLeft}px`),void 0!==f.arrowTop&&(g.style.top=`${f.arrowTop}px`),o.push({id:c,element:u,target:l,destroy:()=>{m(),i(c)}}),null==(a=r.onVisibleChange)||a.call(r,!0),c}const a={bind:function(e,t){if(l.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};l.add(e);const o=t.trigger??n.trigger;let s=t.visible??t.defaultVisible??!1,a=null;const c=()=>{s||(s=!0,a=r(e,t))},d=()=>{if(!s||null===a)return;s=!1;const e=a;a=null,i(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},u=e=>{e.stopPropagation(),s?d():c()},m=t=>{s&&(e.contains(t.target)||d())};return"hover"===o?(e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",d)):"click"===o?(e.addEventListener("click",u),document.addEventListener("click",m)):"focus"===o&&(e.addEventListener("focus",c),e.addEventListener("blur",d)),s&&(a=r(e,t)),{show:c,hide:d,destroy:()=>{d(),l.delete(e),"hover"===o?(e.removeEventListener("mouseenter",c),e.removeEventListener("mouseleave",d)):"click"===o?(e.removeEventListener("click",u),document.removeEventListener("click",m)):"focus"===o&&(e.removeEventListener("focus",c),e.removeEventListener("blur",d))}}},show:function(e,t){const o=r(e,t),l=t.duration??n.duration;l>0&&setTimeout(()=>{i(o)},l)},hide:async function(t){0!==o.length?(await Promise.all(o.map(async t=>{const n=t.element.querySelector(".tooltip");n&&n.classList.add("is-closing"),await e.addClosingAnimation(t.element,e.ANIMATION_DURATION.FAST),t.element.remove()})),o.length=0,null==t||t()):null==t||t()},config:function(e){Object.assign(n,e)}};exports.Tooltip=a;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TooltipOptions, TooltipInstance, TooltipConfig } from './types';
|
|
2
|
+
declare function hideAllTooltips(callback?: () => void): Promise<void>;
|
|
3
|
+
declare function bind(target: HTMLElement, options: TooltipOptions): TooltipInstance;
|
|
4
|
+
declare function showOnce(target: HTMLElement, options: TooltipOptions & {
|
|
5
|
+
duration?: number;
|
|
6
|
+
}): void;
|
|
7
|
+
declare function config(options: Partial<TooltipConfig>): void;
|
|
8
|
+
export declare const Tooltip: {
|
|
9
|
+
bind: typeof bind;
|
|
10
|
+
show: typeof showOnce;
|
|
11
|
+
hide: typeof hideAllTooltips;
|
|
12
|
+
config: typeof config;
|
|
13
|
+
};
|
|
14
|
+
export default Tooltip;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{addClosingAnimation as e,ANIMATION_DURATION as t,generateId as n,createElement as o,calculatePosition as l,injectStyle as s}from"../utils.js";import r from"./style.css.js";const i={placement:"top",trigger:"hover",duration:3e3},a=[],c=new WeakSet;let d=null;async function u(n,o){const l=a.findIndex(e=>e.id===n);if(-1===l)return;const s=a[l],r=s.element.querySelector(".tooltip");r&&r.classList.add("is-closing"),await e(s.element,t.FAST),s.element.remove(),a.splice(l,1),null==o||o()}function m(e,t){var c;const m=n();s("solely-tooltip-styles",r);const v=t.placement??i.placement,p=o("div",{className:"tooltip-overlay"}),h=(f=p,(()=>{const e=document.documentElement.getAttribute("data-theme");e?f.setAttribute("data-theme",e):f.removeAttribute("data-theme")})(),d||(d=new MutationObserver(()=>{a.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),d.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{d&&0===a.length&&(d.disconnect(),d=null)});var f;const g=o("div",{className:`tooltip tooltip--${v}${t.className?` ${t.className}`:""}`,styles:{...t.style,...t.color?{backgroundColor:t.color}:{}}}),b=o("div",{className:"tooltip__content",textContent:t.content||""});g.appendChild(b);const y=o("div",{className:"tooltip__arrow"});t.color&&(y.style.backgroundColor=t.color),g.appendChild(y),p.appendChild(g),document.body.appendChild(p);const E=l(e,g,v);return g.style.top=`${E.top}px`,g.style.left=`${E.left}px`,void 0!==E.arrowLeft&&(y.style.left=`${E.arrowLeft}px`),void 0!==E.arrowTop&&(y.style.top=`${E.arrowTop}px`),a.push({id:m,element:p,target:e,destroy:()=>{h(),u(m)}}),null==(c=t.onVisibleChange)||c.call(t,!0),m}const v={bind:function(e,t){if(c.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};c.add(e);const n=t.trigger??i.trigger;let o=t.visible??t.defaultVisible??!1,l=null;const s=()=>{o||(o=!0,l=m(e,t))},r=()=>{if(!o||null===l)return;o=!1;const e=l;l=null,u(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},a=e=>{e.stopPropagation(),o?r():s()},d=t=>{o&&(e.contains(t.target)||r())};return"hover"===n?(e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",r)):"click"===n?(e.addEventListener("click",a),document.addEventListener("click",d)):"focus"===n&&(e.addEventListener("focus",s),e.addEventListener("blur",r)),o&&(l=m(e,t)),{show:s,hide:r,destroy:()=>{r(),c.delete(e),"hover"===n?(e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",r)):"click"===n?(e.removeEventListener("click",a),document.removeEventListener("click",d)):"focus"===n&&(e.removeEventListener("focus",s),e.removeEventListener("blur",r))}}},show:function(e,t){const n=m(e,t),o=t.duration??i.duration;o>0&&setTimeout(()=>{u(n)},o)},hide:async function(n){0!==a.length?(await Promise.all(a.map(async n=>{const o=n.element.querySelector(".tooltip");o&&o.classList.add("is-closing"),await e(n.element,t.FAST),n.element.remove()})),a.length=0,null==n||n()):null==n||n()},config:function(e){Object.assign(i,e)}};export{v as Tooltip};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}.tooltip-overlay{position:absolute;top:0;left:0;width:100%;min-height:100%;z-index:var(--solely-z-index-tooltip);pointer-events:none}.tooltip{position:absolute;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);min-width:30px;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;word-wrap:break-word;z-index:var(--solely-z-index-tooltip);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}.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)}}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="*,*:before,*:after{box-sizing:border-box}.tooltip-overlay{position:absolute;top:0;left:0;width:100%;min-height:100%;z-index:var(--solely-z-index-tooltip);pointer-events:none}.tooltip{position:absolute;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);min-width:30px;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;word-wrap:break-word;z-index:var(--solely-z-index-tooltip);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}.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,43 @@
|
|
|
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' | 'manual';
|
|
6
|
+
export interface TooltipOptions {
|
|
7
|
+
/** 提示内容 */
|
|
8
|
+
content?: string;
|
|
9
|
+
/** 气泡框位置 */
|
|
10
|
+
placement?: TooltipPlacement;
|
|
11
|
+
/** 触发方式 */
|
|
12
|
+
trigger?: TooltipTrigger;
|
|
13
|
+
/** 默认是否显隐 */
|
|
14
|
+
defaultVisible?: boolean;
|
|
15
|
+
/** 用于手动控制浮层显隐 */
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
/** 显示隐藏的回调 */
|
|
18
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
19
|
+
/** 背景颜色 */
|
|
20
|
+
color?: string;
|
|
21
|
+
/** 自定义类名 */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** 自定义样式 */
|
|
24
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
25
|
+
/** 浮层渲染节点 */
|
|
26
|
+
getPopupContainer?: () => HTMLElement;
|
|
27
|
+
}
|
|
28
|
+
export interface TooltipInstance {
|
|
29
|
+
/** 显示提示 */
|
|
30
|
+
show: () => void;
|
|
31
|
+
/** 隐藏提示 */
|
|
32
|
+
hide: () => void;
|
|
33
|
+
/** 销毁提示 */
|
|
34
|
+
destroy: () => void;
|
|
35
|
+
}
|
|
36
|
+
export interface TooltipConfig {
|
|
37
|
+
/** 默认位置 */
|
|
38
|
+
placement: TooltipPlacement;
|
|
39
|
+
/** 默认触发方式 */
|
|
40
|
+
trigger: TooltipTrigger;
|
|
41
|
+
/** 默认显示时长(show 方法使用) */
|
|
42
|
+
duration: number;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={FAST:200,NORMAL:300,SLOW:500};let e=0;exports.ANIMATION_DURATION=t,exports.Z_INDEX={TOOLTIP:9999,POPOVER:1050,MODAL:1e3,TOAST:9999},exports.addClosingAnimation=function(e,o=t.NORMAL){return new Promise(t=>{e.classList.add("is-closing"),setTimeout(()=>t(),o)})},exports.calculatePosition=function(t,e,o="top",n=8){const r=t.getBoundingClientRect(),s=(null==e?void 0:e.offsetWidth)??250,a=(null==e?void 0:e.offsetHeight)??100,i=window.pageYOffset||document.documentElement.scrollTop,l=window.pageXOffset||document.documentElement.scrollLeft;let c,m,d=0,u=0;switch(o){case"top":d=r.top+i-a-n,u=r.left+l+(r.width-s)/2,c=s/2-4;break;case"topLeft":d=r.top+i-a-n,u=r.left+l,c=16;break;case"topRight":d=r.top+i-a-n,u=r.right+l-s,c=s-24;break;case"bottom":d=r.bottom+i+n,u=r.left+l+(r.width-s)/2,c=s/2-4;break;case"bottomLeft":d=r.bottom+i+n,u=r.left+l,c=16;break;case"bottomRight":d=r.bottom+i+n,u=r.right+l-s,c=s-24;break;case"left":d=r.top+i+(r.height-a)/2,u=r.left+l-s-n,m=a/2-4;break;case"leftTop":d=r.top+i,u=r.left+l-s-n,m=16;break;case"leftBottom":d=r.bottom+i-a,u=r.left+l-s-n,m=a-24;break;case"right":d=r.top+i+(r.height-a)/2,u=r.right+l+n,m=a/2-4;break;case"rightTop":d=r.top+i,u=r.right+l+n,m=16;break;case"rightBottom":d=r.bottom+i-a,u=r.right+l+n,m=a-24}return d=Math.max(8,Math.min(d,window.innerHeight+i-a-8)),u=Math.max(8,Math.min(u,window.innerWidth+l-s-8)),{top:d,left:u,arrowLeft:c,arrowTop:m}},exports.createElement=function(t,e){const o=document.createElement(t);return(null==e?void 0:e.className)&&(o.className=e.className),void 0!==(null==e?void 0:e.textContent)&&(o.textContent=e.textContent),(null==e?void 0:e.styles)&&Object.assign(o.style,e.styles),(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(([t,e])=>{o.setAttribute(t,e)}),o},exports.generateId=function(){return e=(e+1)%Number.MAX_SAFE_INTEGER,e},exports.injectStyle=function(t,e){if(document.getElementById(t))return;const o=document.createElement("style");o.id=t,o.textContent=e,document.head.appendChild(o)},exports.removeStyle=function(t){const e=document.getElementById(t);e&&e.remove()},exports.safeAsyncCallback=async function(t,e){try{return await t()}catch(o){return console.error("[Solely Commands] Async callback error:",o),void(null==e||e())}};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solely Commands 组件共享工具函数
|
|
3
|
+
* 提供公共的样式注入、DOM 操作、位置计算等功能
|
|
4
|
+
*/
|
|
5
|
+
export declare const ANIMATION_DURATION: {
|
|
6
|
+
FAST: number;
|
|
7
|
+
NORMAL: number;
|
|
8
|
+
SLOW: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const Z_INDEX: {
|
|
11
|
+
TOOLTIP: number;
|
|
12
|
+
POPOVER: number;
|
|
13
|
+
MODAL: number;
|
|
14
|
+
TOAST: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 生成唯一 ID(带安全取模,防止无限增长)
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateId(): number;
|
|
20
|
+
export declare function injectStyle(id: string, content: string): void;
|
|
21
|
+
export declare function removeStyle(id: string): void;
|
|
22
|
+
export declare function createElement<K extends keyof HTMLElementTagNameMap>(tag: K, options?: {
|
|
23
|
+
className?: string;
|
|
24
|
+
textContent?: string;
|
|
25
|
+
styles?: Partial<CSSStyleDeclaration>;
|
|
26
|
+
attrs?: Record<string, string>;
|
|
27
|
+
}): HTMLElementTagNameMap[K];
|
|
28
|
+
export interface PositionResult {
|
|
29
|
+
top: number;
|
|
30
|
+
left: number;
|
|
31
|
+
arrowLeft?: number;
|
|
32
|
+
arrowTop?: number;
|
|
33
|
+
}
|
|
34
|
+
export type Placement = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
35
|
+
export declare function calculatePosition(target: HTMLElement, popupElement?: HTMLElement, placement?: Placement, gap?: number): PositionResult;
|
|
36
|
+
export declare function safeAsyncCallback<T>(callback: () => T | Promise<T>, fallback?: () => void): Promise<T | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* 添加关闭动画(使用 .is-closing 类)
|
|
39
|
+
*/
|
|
40
|
+
export declare function addClosingAnimation(element: HTMLElement, duration?: number): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t={FAST:200,NORMAL:300,SLOW:500},e={TOOLTIP:9999,POPOVER:1050,MODAL:1e3,TOAST:9999};let o=0;function n(){return o=(o+1)%Number.MAX_SAFE_INTEGER,o}function r(t,e){if(document.getElementById(t))return;const o=document.createElement("style");o.id=t,o.textContent=e,document.head.appendChild(o)}function a(t){const e=document.getElementById(t);e&&e.remove()}function i(t,e){const o=document.createElement(t);return(null==e?void 0:e.className)&&(o.className=e.className),void 0!==(null==e?void 0:e.textContent)&&(o.textContent=e.textContent),(null==e?void 0:e.styles)&&Object.assign(o.style,e.styles),(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(([t,e])=>{o.setAttribute(t,e)}),o}function c(t,e,o="top",n=8){const r=t.getBoundingClientRect(),a=(null==e?void 0:e.offsetWidth)??250,i=(null==e?void 0:e.offsetHeight)??100,c=window.pageYOffset||document.documentElement.scrollTop,l=window.pageXOffset||document.documentElement.scrollLeft;let s,m,d=0,u=0;switch(o){case"top":d=r.top+c-i-n,u=r.left+l+(r.width-a)/2,s=a/2-4;break;case"topLeft":d=r.top+c-i-n,u=r.left+l,s=16;break;case"topRight":d=r.top+c-i-n,u=r.right+l-a,s=a-24;break;case"bottom":d=r.bottom+c+n,u=r.left+l+(r.width-a)/2,s=a/2-4;break;case"bottomLeft":d=r.bottom+c+n,u=r.left+l,s=16;break;case"bottomRight":d=r.bottom+c+n,u=r.right+l-a,s=a-24;break;case"left":d=r.top+c+(r.height-i)/2,u=r.left+l-a-n,m=i/2-4;break;case"leftTop":d=r.top+c,u=r.left+l-a-n,m=16;break;case"leftBottom":d=r.bottom+c-i,u=r.left+l-a-n,m=i-24;break;case"right":d=r.top+c+(r.height-i)/2,u=r.right+l+n,m=i/2-4;break;case"rightTop":d=r.top+c,u=r.right+l+n,m=16;break;case"rightBottom":d=r.bottom+c-i,u=r.right+l+n,m=i-24}return d=Math.max(8,Math.min(d,window.innerHeight+c-i-8)),u=Math.max(8,Math.min(u,window.innerWidth+l-a-8)),{top:d,left:u,arrowLeft:s,arrowTop:m}}async function l(t,e){try{return await t()}catch(o){return console.error("[Solely Commands] Async callback error:",o),void(null==e||e())}}function s(e,o=t.NORMAL){return new Promise(t=>{e.classList.add("is-closing"),setTimeout(()=>t(),o)})}export{t as ANIMATION_DURATION,e as Z_INDEX,s as addClosingAnimation,c as calculatePosition,i as createElement,n as generateId,r as injectStyle,a as removeStyle,l as safeAsyncCallback};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),o=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyAlert=class extends s.default{getAlertClasses(){return{[`alert--${this.$data.type}`]:!!this.$data.type,"is-closing":this.$data.closing,"alert--block":!!this.$data.block}}getIcon(e){const t={info:"ℹ",success:"✓",warning:"⚠",error:"✕"};return t[e]||t.info}handleClose(){this.$data.closing=!0,this.emit("close"),setTimeout(()=>{this.remove()},300)}setMessage(e){this.$data.message=e}setType(e){this.$data.type=e}},exports.SolelyAlert=((e,t)=>{for(var s,o=t,a=e.length-1;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o})([o.CustomElement({tagName:"solely-alert",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"info"},{name:"message",type:"string",default:""},{name:"description",type:"string",default:""},{name:"closable",type:"boolean",default:!1},{name:"showIcon",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelyAlert);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseElement } from '../../../runtime/component';
|
|
2
|
+
import { AlertProps } from './types';
|
|
3
|
+
declare class SolelyAlert extends BaseElement<AlertProps & {
|
|
4
|
+
closing: boolean;
|
|
5
|
+
}> {
|
|
6
|
+
/**
|
|
7
|
+
* 获取 alert class 对象
|
|
8
|
+
*/
|
|
9
|
+
getAlertClasses(): Record<string, boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* 获取图标
|
|
12
|
+
*/
|
|
13
|
+
getIcon(type: AlertProps['type']): string;
|
|
14
|
+
/**
|
|
15
|
+
* 关闭事件处理
|
|
16
|
+
*/
|
|
17
|
+
handleClose(): void;
|
|
18
|
+
/**
|
|
19
|
+
* 设置消息内容
|
|
20
|
+
*/
|
|
21
|
+
setMessage(message: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* 设置类型
|
|
24
|
+
*/
|
|
25
|
+
setType(type: AlertProps['type']): void;
|
|
26
|
+
}
|
|
27
|
+
export default SolelyAlert;
|
|
28
|
+
export { SolelyAlert };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n class="alert"\n :class="this.getAlertClasses()"\n>\n <If test="$data.showIcon">\n <span class="alert__icon">{{this.getIcon($data.type)}}</span>\n </If>\n <div class="alert__content">\n <If test="$data.message">\n <div class="alert__message">{{$data.message}}</div>\n </If>\n <If test="$data.description">\n <div class="alert__description">{{$data.description}}</div>\n </If>\n <slot></slot>\n </div>\n <If test="$data.closable">\n <span\n class="alert__close"\n @click="this.handleClose()"\n >×</span>\n </If>\n</div>\n';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s='<div\n class="alert"\n :class="this.getAlertClasses()"\n>\n <If test="$data.showIcon">\n <span class="alert__icon">{{this.getIcon($data.type)}}</span>\n </If>\n <div class="alert__content">\n <If test="$data.message">\n <div class="alert__message">{{$data.message}}</div>\n </If>\n <If test="$data.description">\n <div class="alert__description">{{$data.description}}</div>\n </If>\n <slot></slot>\n </div>\n <If test="$data.closable">\n <span\n class="alert__close"\n @click="this.handleClose()"\n >×</span>\n </If>\n</div>\n';export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./style.css.js";import t from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as o}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let a=class extends s{getAlertClasses(){return{[`alert--${this.$data.type}`]:!!this.$data.type,"is-closing":this.$data.closing,"alert--block":!!this.$data.block}}getIcon(e){const t={info:"ℹ",success:"✓",warning:"⚠",error:"✕"};return t[e]||t.info}handleClose(){this.$data.closing=!0,this.emit("close"),setTimeout(()=>{this.remove()},300)}setMessage(e){this.$data.message=e}setType(e){this.$data.type=e}};a=((e,t)=>{for(var s,o=t,a=e.length-1;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o})([o({tagName:"solely-alert",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"info"},{name:"message",type:"string",default:""},{name:"description",type:"string",default:""},{name:"closable",type:"boolean",default:!1},{name:"showIcon",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],a);export{a as SolelyAlert};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}:host{display:inline-block}:host([block]){display:block;width:100%}:host([hidden]){display:none!important}.alert{display:inline-flex;align-items:flex-start;gap:var(--solely-spacing-sm);padding:var(--solely-spacing-md) var(--solely-spacing-lg);font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);line-height:var(--solely-line-height-md);border-radius:var(--solely-border-radius-md);transition:all var(--solely-transition-duration);box-sizing:border-box}.alert--info{color:var(--solely-primary);background-color:var(--solely-primary-light);border:1px solid var(--solely-primary)}.alert--success{color:var(--solely-success);background-color:var(--solely-success-light);border:1px solid var(--solely-success)}.alert--warning{color:var(--solely-warning);background-color:var(--solely-warning-light);border:1px solid var(--solely-warning)}.alert--error{color:var(--solely-error);background-color:var(--solely-error-light);border:1px solid var(--solely-error)}.alert__icon{display:inline-flex;align-items:center;justify-content:center;width:var(--solely-height-md);height:var(--solely-height-md);font-size:var(--solely-font-size-md);flex-shrink:0;margin-top:var(--solely-spacing-xs)}.alert__content{flex:1;min-width:0}.alert__message{color:var(--solely-text-primary);font-weight:500}.alert__description{color:var(--solely-text-secondary);font-size:var(--solely-font-size-sm);margin-top:var(--solely-spacing-xs);line-height:var(--solely-line-height-md)}.alert__close{display:inline-flex;align-items:center;justify-content:center;width:var(--solely-height-md);height:var(--solely-height-md);font-size:var(--solely-font-size-sm);color:var(--solely-text-tertiary);cursor:pointer;transition:color var(--solely-transition-duration);flex-shrink:0}.alert__close:hover{color:var(--solely-text-secondary)}.alert--block{display:flex;width:100%}.alert.is-closing{animation:alert-close .3s ease-in forwards}@keyframes alert-close{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-10px);height:0;padding:0;margin:0;overflow:hidden}}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l="*,*:before,*:after{box-sizing:border-box}:host{display:inline-block}:host([block]){display:block;width:100%}:host([hidden]){display:none!important}.alert{display:inline-flex;align-items:flex-start;gap:var(--solely-spacing-sm);padding:var(--solely-spacing-md) var(--solely-spacing-lg);font-family:var(--solely-font-family);font-size:var(--solely-font-size-md);line-height:var(--solely-line-height-md);border-radius:var(--solely-border-radius-md);transition:all var(--solely-transition-duration);box-sizing:border-box}.alert--info{color:var(--solely-primary);background-color:var(--solely-primary-light);border:1px solid var(--solely-primary)}.alert--success{color:var(--solely-success);background-color:var(--solely-success-light);border:1px solid var(--solely-success)}.alert--warning{color:var(--solely-warning);background-color:var(--solely-warning-light);border:1px solid var(--solely-warning)}.alert--error{color:var(--solely-error);background-color:var(--solely-error-light);border:1px solid var(--solely-error)}.alert__icon{display:inline-flex;align-items:center;justify-content:center;width:var(--solely-height-md);height:var(--solely-height-md);font-size:var(--solely-font-size-md);flex-shrink:0;margin-top:var(--solely-spacing-xs)}.alert__content{flex:1;min-width:0}.alert__message{color:var(--solely-text-primary);font-weight:500}.alert__description{color:var(--solely-text-secondary);font-size:var(--solely-font-size-sm);margin-top:var(--solely-spacing-xs);line-height:var(--solely-line-height-md)}.alert__close{display:inline-flex;align-items:center;justify-content:center;width:var(--solely-height-md);height:var(--solely-height-md);font-size:var(--solely-font-size-sm);color:var(--solely-text-tertiary);cursor:pointer;transition:color var(--solely-transition-duration);flex-shrink:0}.alert__close:hover{color:var(--solely-text-secondary)}.alert--block{display:flex;width:100%}.alert.is-closing{animation:alert-close .3s ease-in forwards}@keyframes alert-close{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-10px);height:0;padding:0;margin:0;overflow:hidden}}";export{l as default};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert 组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
export type AlertType = 'info' | 'success' | 'warning' | 'error';
|
|
5
|
+
export interface AlertProps {
|
|
6
|
+
/** 警告提示类型 */
|
|
7
|
+
type: AlertType;
|
|
8
|
+
/** 警告提示内容 */
|
|
9
|
+
message: string;
|
|
10
|
+
/** 警告提示的辅助性文字介绍 */
|
|
11
|
+
description: string;
|
|
12
|
+
/** 是否显示关闭按钮 */
|
|
13
|
+
closable: boolean;
|
|
14
|
+
/** 是否显示辅助图标 */
|
|
15
|
+
showIcon: boolean;
|
|
16
|
+
/** 是否块级显示 */
|
|
17
|
+
block: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=(t,i,s)=>((t,i,s)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s)(t,"symbol"!=typeof i?i+"":i,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyBackTop=class extends n.default{constructor(){super(...arguments),t(this,"scrollHandler"),t(this,"resizeHandler"),t(this,"container",null)}updateVisibleClass(){this.$data.visible?this.classList.add("backtop--visible"):this.classList.remove("backtop--visible")}getContainer(){let e=this.parentElement;for(;e;){const t=window.getComputedStyle(e);if("auto"===t.overflowY||"scroll"===t.overflowY)return e;e=e.parentElement}return null}mounted(){setTimeout(()=>{this.container=this.getContainer(),this.container?(this.scrollHandler=()=>{this.handleScroll()},this.container.addEventListener("scroll",this.scrollHandler),this.resizeHandler=()=>{requestAnimationFrame(()=>{this.updatePosition()})},window.addEventListener("resize",this.resizeHandler),window.addEventListener("scroll",this.resizeHandler,{passive:!0}),this.handleScroll(),this.updatePosition()):console.warn("BackTop: 未找到可滚动的父容器")},100)}unmounted(){this.scrollHandler&&this.container&&this.container.removeEventListener("scroll",this.scrollHandler),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("scroll",this.resizeHandler))}updatePosition(){if(!this.container)return;const e=this.container.getBoundingClientRect(),t=window.innerWidth-e.right+20,i=window.innerHeight-e.bottom+20;this.style.position="fixed",this.style.right=`${t}px`,this.style.bottom=`${i}px`}handleScroll(){if(!this.container)return;const e=this.container.scrollTop>=this.$data.visibilityHeight;this.$data.visible!==e&&(this.$data.visible=e,this.updateVisibleClass())}handleClick(){if(!this.container)return;const e=this.$data.duration||450,t=Date.now(),i=this.container.scrollTop,s=()=>{const n=Date.now()-t,r=Math.min(n/e,1),o=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,l=i*(1-o);this.container.scrollTop=l,r<1?requestAnimationFrame(s):this.dispatchEvent(new Event("click",{bubbles:!0,composed:!0}))};requestAnimationFrame(s)}},exports.SolelyBackTop=((e,t)=>{for(var i,s=t,n=e.length-1;n>=0;n--)(i=e[n])&&(s=i(s)||s);return s})([r.CustomElement({tagName:"solely-backtop",template:s.default,styles:i.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"visibilityHeight",type:"number",default:400},{name:"duration",type:"number",default:450}]})],exports.SolelyBackTop);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseElement } from '../../../runtime/component';
|
|
2
|
+
import { BackTopProps } from './types';
|
|
3
|
+
declare class SolelyBackTop extends BaseElement<BackTopProps & {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
}> {
|
|
6
|
+
scrollHandler?: () => void;
|
|
7
|
+
resizeHandler?: () => void;
|
|
8
|
+
container: HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* 更新显示状态
|
|
11
|
+
*/
|
|
12
|
+
updateVisibleClass(): void;
|
|
13
|
+
/**
|
|
14
|
+
* 获取滚动容器
|
|
15
|
+
*/
|
|
16
|
+
getContainer(): HTMLElement | null;
|
|
17
|
+
mounted(): void;
|
|
18
|
+
unmounted(): void;
|
|
19
|
+
/**
|
|
20
|
+
* 更新按钮位置
|
|
21
|
+
*/
|
|
22
|
+
updatePosition(): void;
|
|
23
|
+
/**
|
|
24
|
+
* 滚动事件处理
|
|
25
|
+
*/
|
|
26
|
+
handleScroll(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 点击回到顶部
|
|
29
|
+
*/
|
|
30
|
+
handleClick(): void;
|
|
31
|
+
}
|
|
32
|
+
export default SolelyBackTop;
|
|
33
|
+
export { SolelyBackTop };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n class="backtop"\n @click="this.handleClick()"\n>\n <span class="backtop__icon">↑</span>\n</div>';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n='<div\n class="backtop"\n @click="this.handleClick()"\n>\n <span class="backtop__icon">↑</span>\n</div>';export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,i,s)=>((t,i,s)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s)(t,"symbol"!=typeof i?i+"":i,s);import i from"./style.css.js";import s from"./index.html.js";import n from"../../../runtime/component/base-element.js";import{CustomElement as r}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let o=class extends n{constructor(){super(...arguments),t(this,"scrollHandler"),t(this,"resizeHandler"),t(this,"container",null)}updateVisibleClass(){this.$data.visible?this.classList.add("backtop--visible"):this.classList.remove("backtop--visible")}getContainer(){let e=this.parentElement;for(;e;){const t=window.getComputedStyle(e);if("auto"===t.overflowY||"scroll"===t.overflowY)return e;e=e.parentElement}return null}mounted(){setTimeout(()=>{this.container=this.getContainer(),this.container?(this.scrollHandler=()=>{this.handleScroll()},this.container.addEventListener("scroll",this.scrollHandler),this.resizeHandler=()=>{requestAnimationFrame(()=>{this.updatePosition()})},window.addEventListener("resize",this.resizeHandler),window.addEventListener("scroll",this.resizeHandler,{passive:!0}),this.handleScroll(),this.updatePosition()):console.warn("BackTop: 未找到可滚动的父容器")},100)}unmounted(){this.scrollHandler&&this.container&&this.container.removeEventListener("scroll",this.scrollHandler),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("scroll",this.resizeHandler))}updatePosition(){if(!this.container)return;const e=this.container.getBoundingClientRect(),t=window.innerWidth-e.right+20,i=window.innerHeight-e.bottom+20;this.style.position="fixed",this.style.right=`${t}px`,this.style.bottom=`${i}px`}handleScroll(){if(!this.container)return;const e=this.container.scrollTop>=this.$data.visibilityHeight;this.$data.visible!==e&&(this.$data.visible=e,this.updateVisibleClass())}handleClick(){if(!this.container)return;const e=this.$data.duration||450,t=Date.now(),i=this.container.scrollTop,s=()=>{const n=Date.now()-t,r=Math.min(n/e,1),o=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,l=i*(1-o);this.container.scrollTop=l,r<1?requestAnimationFrame(s):this.dispatchEvent(new Event("click",{bubbles:!0,composed:!0}))};requestAnimationFrame(s)}};o=((e,t)=>{for(var i,s=t,n=e.length-1;n>=0;n--)(i=e[n])&&(s=i(s)||s);return s})([r({tagName:"solely-backtop",template:s,styles:i,shadowDOM:{use:!0,mode:"open"},props:[{name:"visibilityHeight",type:"number",default:400},{name:"duration",type:"number",default:450}]})],o);export{o as SolelyBackTop};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}:host{display:block;position:fixed;right:20px;bottom:20px;z-index:var(--solely-z-index-fixed);opacity:0;visibility:hidden;pointer-events:none}:host(.backtop--visible){opacity:1;visibility:visible;pointer-events:auto}:host([hidden]){display:none!important}.backtop{width:var(--solely-height-lg);height:var(--solely-height-lg);display:flex;align-items:center;justify-content:center;color:var(--solely-primary);background-color:var(--solely-component-bg);border-radius:50%;box-shadow:0 2px 8px #00000026;cursor:pointer;transition:transform var(--solely-transition-duration),background-color var(--solely-transition-duration),box-shadow var(--solely-transition-duration);transform:translateY(20px)}:host(.backtop--visible) .backtop{transform:translateY(0)}.backtop:hover{background-color:var(--solely-primary);color:var(--solely-white);box-shadow:0 4px 12px #0003;transform:translateY(0)}.backtop__icon{font-size:var(--solely-font-size-lg);font-weight:700}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="*,*:before,*:after{box-sizing:border-box}:host{display:block;position:fixed;right:20px;bottom:20px;z-index:var(--solely-z-index-fixed);opacity:0;visibility:hidden;pointer-events:none}:host(.backtop--visible){opacity:1;visibility:visible;pointer-events:auto}:host([hidden]){display:none!important}.backtop{width:var(--solely-height-lg);height:var(--solely-height-lg);display:flex;align-items:center;justify-content:center;color:var(--solely-primary);background-color:var(--solely-component-bg);border-radius:50%;box-shadow:0 2px 8px #00000026;cursor:pointer;transition:transform var(--solely-transition-duration),background-color var(--solely-transition-duration),box-shadow var(--solely-transition-duration);transform:translateY(20px)}:host(.backtop--visible) .backtop{transform:translateY(0)}.backtop:hover{background-color:var(--solely-primary);color:var(--solely-white);box-shadow:0 4px 12px #0003;transform:translateY(0)}.backtop__icon{font-size:var(--solely-font-size-lg);font-weight:700}";export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),e=require("./index.html.cjs"),a=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyBadge=class extends a.default{getBadgeClasses(){return{"badge--zero":0===this.$data.count&&!this.$data.dot}}getStatusDotClasses(){const t={};return this.$data.status&&(t[`badge__status-dot--${this.$data.status}`]=!0),t}setCount(t){this.$data.count=t}increase(t=1){this.$data.count+=t}decrease(t=1){this.$data.count=Math.max(0,this.$data.count-t)}showDot(){this.$data.dot=!0}hideDot(){this.$data.dot=!1}},exports.SolelyBadge=((t,e)=>{for(var a,s=e,o=t.length-1;o>=0;o--)(a=t[o])&&(s=a(s)||s);return s})([s.CustomElement({tagName:"solely-badge",template:e.default,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"count",type:"number",default:0},{name:"dot",type:"boolean",default:!1},{name:"overflowCount",type:"number",default:99},{name:"status",type:"string",default:""},{name:"text",type:"string",default:""},{name:"title",type:"string",default:""},{name:"offset",type:"string",default:""},{name:"color",type:"string",default:""}]})],exports.SolelyBadge);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseElement } from '../../../runtime/component';
|
|
2
|
+
import { BadgeProps } from './types';
|
|
3
|
+
declare class SolelyBadge extends BaseElement<BadgeProps> {
|
|
4
|
+
/**
|
|
5
|
+
* 获取 badge class 对象
|
|
6
|
+
*/
|
|
7
|
+
getBadgeClasses(): Record<string, boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* 获取 status dot class 对象
|
|
10
|
+
*/
|
|
11
|
+
getStatusDotClasses(): Record<string, boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* 设置数字
|
|
14
|
+
*/
|
|
15
|
+
setCount(count: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* 增加数字
|
|
18
|
+
*/
|
|
19
|
+
increase(delta?: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* 减少数字
|
|
22
|
+
*/
|
|
23
|
+
decrease(delta?: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* 显示小红点
|
|
26
|
+
*/
|
|
27
|
+
showDot(): void;
|
|
28
|
+
/**
|
|
29
|
+
* 隐藏小红点
|
|
30
|
+
*/
|
|
31
|
+
hideDot(): void;
|
|
32
|
+
}
|
|
33
|
+
export default SolelyBadge;
|
|
34
|
+
export { SolelyBadge };
|