@cst-ui/nano-buttons 0.1.2 → 0.2.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 +32 -2
- package/dist/NanoButton.vue_vue_type_script_setup_true_lang-D1yLWi2K.cjs +1 -0
- package/dist/NanoButton.vue_vue_type_script_setup_true_lang-DgnSKBXL.js +57 -0
- package/dist/dialog-tabs/NanoDialogTabPage.vue.d.ts +60 -0
- package/dist/dialog-tabs/context.d.ts +3 -0
- package/dist/dialog-tabs/index.cjs +1 -0
- package/dist/dialog-tabs/index.d.ts +8 -0
- package/dist/dialog-tabs/index.mjs +230 -0
- package/dist/dialog-tabs/plugin.d.ts +4 -0
- package/dist/dialog-tabs/result.d.ts +7 -0
- package/dist/dialog-tabs/types.d.ts +62 -0
- package/dist/dialog-tabs/useDialogOpen.d.ts +4 -0
- package/dist/dialog-tabs/useDialogPage.d.ts +9 -0
- package/dist/dialog-tabs/useDialogTabClose.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +106 -156
- package/package.json +58 -40
package/README.md
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Nano 项目主题按钮组件库,基于 Vue 3 和 Element Plus 封装。
|
|
4
4
|
|
|
5
|
-
这个包用于统一提供 Nano
|
|
5
|
+
这个包用于统一提供 Nano 系列按钮组件,并通过子入口提供弹窗标签页化的公共能力。模板中统一使用横线法组件名,例如 `<nano-button>`,不再保留旧命名。
|
|
6
|
+
|
|
7
|
+
## 在线文档
|
|
8
|
+
|
|
9
|
+
组件效果、安装方式、使用示例和 API 说明见在线文档:
|
|
10
|
+
|
|
11
|
+
https://nano-buttons-docs.netlify.app/
|
|
6
12
|
|
|
7
13
|
## 安装
|
|
8
14
|
|
|
@@ -68,8 +74,32 @@ app.mount('#app')
|
|
|
68
74
|
|
|
69
75
|
## 依赖说明
|
|
70
76
|
|
|
71
|
-
`vue` 和 `
|
|
77
|
+
`vue`、`element-plus` 和 `vue-router` 是 peer dependencies,需要由使用方项目提供。
|
|
78
|
+
|
|
79
|
+
## 弹窗标签页
|
|
80
|
+
|
|
81
|
+
弹窗标签页能力从子入口导入:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { createNanoDialogTabs, useDialogOpen } from '@cst-ui/nano-buttons/dialog-tabs'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
公共包只负责打开模式、上下文缓存、保存结果通知、关闭回来源页和 `NanoDialogTabPage` 页面壳。业务项目需要传入 `router`、`registry`、`tabAdapter` 和打开模式。
|
|
72
88
|
|
|
73
89
|
## 维护与发布
|
|
74
90
|
|
|
75
91
|
包维护、版本发布和权限交接说明见 [MAINTAINING.md](./MAINTAINING.md)。
|
|
92
|
+
|
|
93
|
+
文档站本地开发:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pnpm docs:dev
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
文档站构建:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pnpm docs:build
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
更新线上文档时,重新构建后将 `docs-dist/` 上传到 Netlify。若 Netlify 站点或域名发生变化,请同步修改本文档中的在线文档链接。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("vue"),u=require("element-plus"),m={...u.buttonProps,secondary:Boolean},f=o.defineComponent({name:"NanoButton",inheritAttrs:!1,__name:"NanoButton",props:m,emits:u.buttonEmits,setup(i,{emit:d}){const t=i,p=d,n=o.useAttrs(),s=o.computed(()=>{const{secondary:e,...l}=t;return l}),r=o.computed(()=>["nano-button",t.secondary?"app-button-secondary":""]),a=e=>{p("click",e)};return(e,l)=>{const c=o.resolveComponent("el-button");return e.$slots.default?(o.openBlock(),o.createBlock(c,o.mergeProps({key:0},{...s.value,...o.unref(n)},{class:r.value,onClick:a}),o.createSlots({default:o.withCtx(()=>[o.renderSlot(e.$slots,"default")]),_:2},[e.$slots.loading?{name:"loading",fn:o.withCtx(()=>[o.renderSlot(e.$slots,"loading")]),key:"0"}:void 0]),1040,["class"])):(o.openBlock(),o.createBlock(c,o.mergeProps({key:1},{...s.value,...o.unref(n)},{class:r.value,onClick:a}),o.createSlots({_:2},[e.$slots.loading?{name:"loading",fn:o.withCtx(()=>[o.renderSlot(e.$slots,"loading")]),key:"0"}:void 0]),1040,["class"]))}}});exports._sfc_main=f;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineComponent as v, useAttrs as B, computed as i, resolveComponent as _, openBlock as d, createBlock as p, mergeProps as m, unref as f, createSlots as k, withCtx as t, renderSlot as n } from "vue";
|
|
2
|
+
import { buttonProps as $, buttonEmits as C } from "element-plus";
|
|
3
|
+
const P = {
|
|
4
|
+
...$,
|
|
5
|
+
secondary: Boolean
|
|
6
|
+
}, A = /* @__PURE__ */ v({
|
|
7
|
+
name: "NanoButton",
|
|
8
|
+
inheritAttrs: !1,
|
|
9
|
+
__name: "NanoButton",
|
|
10
|
+
props: P,
|
|
11
|
+
emits: C,
|
|
12
|
+
setup(y, { emit: b }) {
|
|
13
|
+
const s = y, g = b, e = B(), a = i(() => {
|
|
14
|
+
const { secondary: o, ...c } = s;
|
|
15
|
+
return c;
|
|
16
|
+
}), r = i(() => [
|
|
17
|
+
"nano-button",
|
|
18
|
+
s.secondary ? "app-button-secondary" : ""
|
|
19
|
+
]), l = (o) => {
|
|
20
|
+
g("click", o);
|
|
21
|
+
};
|
|
22
|
+
return (o, c) => {
|
|
23
|
+
const u = _("el-button");
|
|
24
|
+
return o.$slots.default ? (d(), p(u, m({ key: 0 }, { ...a.value, ...f(e) }, {
|
|
25
|
+
class: r.value,
|
|
26
|
+
onClick: l
|
|
27
|
+
}), k({
|
|
28
|
+
default: t(() => [
|
|
29
|
+
n(o.$slots, "default")
|
|
30
|
+
]),
|
|
31
|
+
_: 2
|
|
32
|
+
}, [
|
|
33
|
+
o.$slots.loading ? {
|
|
34
|
+
name: "loading",
|
|
35
|
+
fn: t(() => [
|
|
36
|
+
n(o.$slots, "loading")
|
|
37
|
+
]),
|
|
38
|
+
key: "0"
|
|
39
|
+
} : void 0
|
|
40
|
+
]), 1040, ["class"])) : (d(), p(u, m({ key: 1 }, { ...a.value, ...f(e) }, {
|
|
41
|
+
class: r.value,
|
|
42
|
+
onClick: l
|
|
43
|
+
}), k({ _: 2 }, [
|
|
44
|
+
o.$slots.loading ? {
|
|
45
|
+
name: "loading",
|
|
46
|
+
fn: t(() => [
|
|
47
|
+
n(o.$slots, "loading")
|
|
48
|
+
]),
|
|
49
|
+
key: "0"
|
|
50
|
+
} : void 0
|
|
51
|
+
]), 1040, ["class"]));
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
export {
|
|
56
|
+
A as _
|
|
57
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
declare function __VLS_template(): {
|
|
2
|
+
slots: {
|
|
3
|
+
actions?(_: {}): any;
|
|
4
|
+
default?(_: {}): any;
|
|
5
|
+
};
|
|
6
|
+
refs: {};
|
|
7
|
+
attrs: Partial<{}>;
|
|
8
|
+
};
|
|
9
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
10
|
+
declare const __VLS_component: import("vue").DefineComponent<{
|
|
11
|
+
titleKey?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
expired?: boolean;
|
|
15
|
+
fit?: boolean;
|
|
16
|
+
bodyClass?: string;
|
|
17
|
+
outerClass?: string;
|
|
18
|
+
surfaceClass?: string;
|
|
19
|
+
expiredTextKey?: string;
|
|
20
|
+
expiredText?: string;
|
|
21
|
+
closeTextKey?: string;
|
|
22
|
+
closeText?: string;
|
|
23
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
close: () => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<{
|
|
26
|
+
titleKey?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
expired?: boolean;
|
|
30
|
+
fit?: boolean;
|
|
31
|
+
bodyClass?: string;
|
|
32
|
+
outerClass?: string;
|
|
33
|
+
surfaceClass?: string;
|
|
34
|
+
expiredTextKey?: string;
|
|
35
|
+
expiredText?: string;
|
|
36
|
+
closeTextKey?: string;
|
|
37
|
+
closeText?: string;
|
|
38
|
+
}> & Readonly<{
|
|
39
|
+
onClose?: (() => any) | undefined;
|
|
40
|
+
}>, {
|
|
41
|
+
loading: boolean;
|
|
42
|
+
title: string;
|
|
43
|
+
titleKey: string;
|
|
44
|
+
expired: boolean;
|
|
45
|
+
fit: boolean;
|
|
46
|
+
bodyClass: string;
|
|
47
|
+
outerClass: string;
|
|
48
|
+
surfaceClass: string;
|
|
49
|
+
expiredTextKey: string;
|
|
50
|
+
expiredText: string;
|
|
51
|
+
closeTextKey: string;
|
|
52
|
+
closeText: string;
|
|
53
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
54
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
55
|
+
export default _default;
|
|
56
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
57
|
+
new (): {
|
|
58
|
+
$slots: S;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),_=require("../NanoButton.vue_vue_type_script_setup_true_lang-D1yLWi2K.cjs"),D=require("vue-router"),h=Symbol("NanoDialogTabs");let v;const w=t=>{const e=()=>typeof t.mode=="function"?t.mode():t.mode,a=t.translate??(n=>n);return{...t,getMode:e,t:a}},S=t=>{const e=w(t);return v=e,e},k=t=>{const e=w(t);return{context:e,install(a){v=e,a.provide(h,e)}}},c=()=>{const t=o.hasInjectionContext()?o.inject(h,v):v;if(t==null)throw new Error("Nano dialog tabs is not configured. Call app.use(createNanoDialogTabs(...)) first.");return t},M={class:"flex shrink-0 items-center justify-between gap-app-md border-b border-app-border-light p-app-lg"},E={class:"app-section-title"},B=o.defineComponent({name:"NanoDialogTabPage",__name:"NanoDialogTabPage",props:{titleKey:{default:""},title:{default:void 0},loading:{type:Boolean,default:!1},expired:{type:Boolean,default:!1},fit:{type:Boolean,default:!1},bodyClass:{default:"overflow-x-auto"},outerClass:{default:""},surfaceClass:{default:""},expiredTextKey:{default:"dialog.contextExpired"},expiredText:{default:void 0},closeTextKey:{default:"button.close"},closeText:{default:void 0}},emits:["close"],setup(t,{emit:e}){const a=t,n=e,{t:l}=c(),r=o.computed(()=>a.title??l(a.titleKey)),u=o.computed(()=>a.expiredText??l(a.expiredTextKey)),d=o.computed(()=>a.closeText??l(a.closeTextKey)),s=o.computed(()=>[a.fit?"h-full min-h-0 overflow-hidden p-app-md":"h-full min-h-0 overflow-y-auto p-app-md",a.outerClass]),i=o.computed(()=>[a.fit?"app-surface flex h-full min-h-0 flex-col":"app-surface",a.surfaceClass]),m=o.computed(()=>[a.fit?"min-h-0 flex-1 overflow-hidden":a.bodyClass]);return(f,g)=>{const x=o.resolveComponent("el-empty"),p=o.resolveDirective("loading");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(s.value)},[o.createElementVNode("div",{class:o.normalizeClass(i.value)},[o.createElementVNode("div",M,[o.createElementVNode("span",E,o.toDisplayString(r.value),1),o.renderSlot(f.$slots,"actions")]),o.withDirectives((o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(m.value)},[t.expired?(o.openBlock(),o.createBlock(x,{key:1,description:u.value},{default:o.withCtx(()=>[o.createVNode(_._sfc_main,{icon:"Close",onClick:g[0]||(g[0]=U=>n("close"))},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(d.value),1)]),_:1})]),_:1},8,["description"])):o.renderSlot(f.$slots,"default",{key:0})],2)),[[p,t.loading]])],2)],2)}}}),T=new Map,I=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,N=(t,e)=>{const a=e??I();return T.set(a,t),a},y=t=>{if(typeof t=="string")return T.get(t)},$=t=>{typeof t=="string"&&T.delete(t)},b="nano-dialog-result",P=t=>{window.dispatchEvent(new CustomEvent(b,{detail:t}))},q=t=>{const e=a=>{t(a.detail)};return window.addEventListener(b,e),()=>{window.removeEventListener(b,e)}},C=(t,e)=>`${t.replace(/\/$/,"")}${e}`,A=(t,e)=>`dialog-${t}-${e.replace(/[^a-zA-Z0-9]+/g,"-")}`,K=t=>typeof t=="string"?t:t==null?void 0:t.path,V=(t,e,a,n)=>{const l=c(),r=typeof l.defaultRouteMeta=="function"?l.defaultRouteMeta({key:e,path:a,titleKey:n,config:t}):l.defaultRouteMeta??{};return{title:n??t.title,icon:"Setting",dialogTab:!0,...r}},z=(t,e,a)=>{const n=c(),l=n.registry[t];if(l==null)return;const r=A(t,e);n.router.hasRoute(r)||n.router.addRoute(n.parentRouteName,{path:e,name:r,component:l.component,meta:V(l,t,e,a),props:l.props})},F=(t,e)=>{const a=c();if(e.route!==void 0)return typeof e.route=="string"?e.route:{...e.route,query:e.query??e.route.query};if(e.key===void 0)return;const n=a.registry[e.key];if(n==null)return;const l=C(t,e.routeSuffix??n.suffix),r=C(t,e.routePatternSuffix??e.routeSuffix??n.suffix);return z(e.key,r,e.titleKey),{path:l,query:e.query}},j=()=>{const t=D.useRoute(),e=c();return{openDialog:async n=>{if(e.getMode()!=="tab"){n.openModal();return}const l=F(t.path,n);if(l===void 0){n.openModal();return}const r=K(l);n.context!==void 0&&r!==void 0&&r!==""&&N(n.context,r),await e.router.push(l)}}},R=()=>{const t=D.useRoute(),e=c();return{closeCurrentDialogTab:()=>{var f,g,x;const n=e.tabAdapter.getTabs(),l=n.findIndex(p=>p.fullPath===t.fullPath);if(l<=0){e.router.back();return}const r=n[l],u=typeof((f=r==null?void 0:r.meta)==null?void 0:f.dialogSourceFullPath)=="string"?r.meta.dialogSourceFullPath:void 0,d=l<n.length-1?(g=n[l+1])==null?void 0:g.fullPath:(x=n[l-1])==null?void 0:x.fullPath,s=u!==void 0&&u!==""?u:d;if(s==null||s===""){e.router.back();return}const i=l===e.tabAdapter.getCurrentIndex();e.tabAdapter.deleteTab(l);const m=e.tabAdapter.getTabs().findIndex(p=>p.fullPath===s);i&&m>=0&&e.tabAdapter.setCurrentIndex(m),e.router.replace(s)}}},O=t=>{const e=D.useRoute(),a=c(),{closeCurrentDialogTab:n}=R(),l=o.computed(()=>y(e.path)??y(e.query.dialogId)),r=o.computed(()=>typeof t=="function"&&t.length>0?t({route:e,dialogContext:l}):o.toValue(t)),u=()=>{const s=a.tabAdapter.getTabs().find(i=>i.fullPath===e.fullPath);s!=null&&(s.title=r.value)},d=(s,i)=>{P({key:s,type:"saved",payload:i}),n()};return o.watch(()=>[e.fullPath,r.value],u,{immediate:!0}),{route:e,dialogContext:l,pageTitleKey:r,closeCurrentDialogTab:n,emitSavedAndClose:d,syncTabTitle:u}};exports.NanoDialogTabPage=B;exports.configureNanoDialogTabs=S;exports.createNanoDialogTabs=k;exports.emitDialogResult=P;exports.getDialogContext=y;exports.nanoDialogTabsKey=h;exports.onDialogResult=q;exports.removeDialogContext=$;exports.setDialogContext=N;exports.useDialogOpen=j;exports.useDialogPage=O;exports.useDialogTabClose=R;exports.useNanoDialogTabs=c;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as NanoDialogTabPage } from './NanoDialogTabPage.vue';
|
|
2
|
+
export * from './context';
|
|
3
|
+
export * from './plugin';
|
|
4
|
+
export * from './result';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './useDialogOpen';
|
|
7
|
+
export * from './useDialogPage';
|
|
8
|
+
export * from './useDialogTabClose';
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { hasInjectionContext as $, inject as I, defineComponent as A, computed as c, resolveComponent as E, resolveDirective as K, openBlock as y, createElementBlock as w, normalizeClass as b, createElementVNode as h, toDisplayString as P, renderSlot as R, withDirectives as q, createBlock as B, withCtx as N, createVNode as F, createTextVNode as U, toValue as V, watch as j } from "vue";
|
|
2
|
+
import { _ as z } from "../NanoButton.vue_vue_type_script_setup_true_lang-DgnSKBXL.js";
|
|
3
|
+
import { useRoute as C } from "vue-router";
|
|
4
|
+
const k = Symbol("NanoDialogTabs");
|
|
5
|
+
let v;
|
|
6
|
+
const S = (t) => {
|
|
7
|
+
const e = () => typeof t.mode == "function" ? t.mode() : t.mode, o = t.translate ?? ((n) => n);
|
|
8
|
+
return {
|
|
9
|
+
...t,
|
|
10
|
+
getMode: e,
|
|
11
|
+
t: o
|
|
12
|
+
};
|
|
13
|
+
}, re = (t) => {
|
|
14
|
+
const e = S(t);
|
|
15
|
+
return v = e, e;
|
|
16
|
+
}, le = (t) => {
|
|
17
|
+
const e = S(t);
|
|
18
|
+
return {
|
|
19
|
+
context: e,
|
|
20
|
+
install(o) {
|
|
21
|
+
v = e, o.provide(k, e);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}, u = () => {
|
|
25
|
+
const t = $() ? I(k, v) : v;
|
|
26
|
+
if (t == null)
|
|
27
|
+
throw new Error("Nano dialog tabs is not configured. Call app.use(createNanoDialogTabs(...)) first.");
|
|
28
|
+
return t;
|
|
29
|
+
}, L = { class: "flex shrink-0 items-center justify-between gap-app-md border-b border-app-border-light p-app-lg" }, O = { class: "app-section-title" }, se = /* @__PURE__ */ A({
|
|
30
|
+
name: "NanoDialogTabPage",
|
|
31
|
+
__name: "NanoDialogTabPage",
|
|
32
|
+
props: {
|
|
33
|
+
titleKey: { default: "" },
|
|
34
|
+
title: { default: void 0 },
|
|
35
|
+
loading: { type: Boolean, default: !1 },
|
|
36
|
+
expired: { type: Boolean, default: !1 },
|
|
37
|
+
fit: { type: Boolean, default: !1 },
|
|
38
|
+
bodyClass: { default: "overflow-x-auto" },
|
|
39
|
+
outerClass: { default: "" },
|
|
40
|
+
surfaceClass: { default: "" },
|
|
41
|
+
expiredTextKey: { default: "dialog.contextExpired" },
|
|
42
|
+
expiredText: { default: void 0 },
|
|
43
|
+
closeTextKey: { default: "button.close" },
|
|
44
|
+
closeText: { default: void 0 }
|
|
45
|
+
},
|
|
46
|
+
emits: ["close"],
|
|
47
|
+
setup(t, { emit: e }) {
|
|
48
|
+
const o = t, n = e, { t: a } = u(), r = c(() => o.title ?? a(o.titleKey)), s = c(() => o.expiredText ?? a(o.expiredTextKey)), d = c(() => o.closeText ?? a(o.closeTextKey)), l = c(() => [
|
|
49
|
+
o.fit ? "h-full min-h-0 overflow-hidden p-app-md" : "h-full min-h-0 overflow-y-auto p-app-md",
|
|
50
|
+
o.outerClass
|
|
51
|
+
]), i = c(() => [
|
|
52
|
+
o.fit ? "app-surface flex h-full min-h-0 flex-col" : "app-surface",
|
|
53
|
+
o.surfaceClass
|
|
54
|
+
]), x = c(() => [
|
|
55
|
+
o.fit ? "min-h-0 flex-1 overflow-hidden" : o.bodyClass
|
|
56
|
+
]);
|
|
57
|
+
return (f, p) => {
|
|
58
|
+
const m = E("el-empty"), g = K("loading");
|
|
59
|
+
return y(), w("div", {
|
|
60
|
+
class: b(l.value)
|
|
61
|
+
}, [
|
|
62
|
+
h("div", {
|
|
63
|
+
class: b(i.value)
|
|
64
|
+
}, [
|
|
65
|
+
h("div", L, [
|
|
66
|
+
h("span", O, P(r.value), 1),
|
|
67
|
+
R(f.$slots, "actions")
|
|
68
|
+
]),
|
|
69
|
+
q((y(), w("div", {
|
|
70
|
+
class: b(x.value)
|
|
71
|
+
}, [
|
|
72
|
+
t.expired ? (y(), B(m, {
|
|
73
|
+
key: 1,
|
|
74
|
+
description: s.value
|
|
75
|
+
}, {
|
|
76
|
+
default: N(() => [
|
|
77
|
+
F(z, {
|
|
78
|
+
icon: "Close",
|
|
79
|
+
onClick: p[0] || (p[0] = (te) => n("close"))
|
|
80
|
+
}, {
|
|
81
|
+
default: N(() => [
|
|
82
|
+
U(P(d.value), 1)
|
|
83
|
+
]),
|
|
84
|
+
_: 1
|
|
85
|
+
})
|
|
86
|
+
]),
|
|
87
|
+
_: 1
|
|
88
|
+
}, 8, ["description"])) : R(f.$slots, "default", { key: 0 })
|
|
89
|
+
], 2)), [
|
|
90
|
+
[g, t.loading]
|
|
91
|
+
])
|
|
92
|
+
], 2)
|
|
93
|
+
], 2);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}), D = /* @__PURE__ */ new Map(), Z = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`, G = (t, e) => {
|
|
97
|
+
const o = e ?? Z();
|
|
98
|
+
return D.set(o, t), o;
|
|
99
|
+
}, M = (t) => {
|
|
100
|
+
if (typeof t == "string")
|
|
101
|
+
return D.get(t);
|
|
102
|
+
}, ce = (t) => {
|
|
103
|
+
typeof t == "string" && D.delete(t);
|
|
104
|
+
}, T = "nano-dialog-result", H = (t) => {
|
|
105
|
+
window.dispatchEvent(new CustomEvent(T, {
|
|
106
|
+
detail: t
|
|
107
|
+
}));
|
|
108
|
+
}, ie = (t) => {
|
|
109
|
+
const e = (o) => {
|
|
110
|
+
t(o.detail);
|
|
111
|
+
};
|
|
112
|
+
return window.addEventListener(T, e), () => {
|
|
113
|
+
window.removeEventListener(T, e);
|
|
114
|
+
};
|
|
115
|
+
}, _ = (t, e) => `${t.replace(/\/$/, "")}${e}`, J = (t, e) => `dialog-${t}-${e.replace(/[^a-zA-Z0-9]+/g, "-")}`, Q = (t) => typeof t == "string" ? t : t == null ? void 0 : t.path, W = (t, e, o, n) => {
|
|
116
|
+
const a = u(), r = typeof a.defaultRouteMeta == "function" ? a.defaultRouteMeta({ key: e, path: o, titleKey: n, config: t }) : a.defaultRouteMeta ?? {};
|
|
117
|
+
return {
|
|
118
|
+
title: n ?? t.title,
|
|
119
|
+
icon: "Setting",
|
|
120
|
+
dialogTab: !0,
|
|
121
|
+
...r
|
|
122
|
+
};
|
|
123
|
+
}, X = (t, e, o) => {
|
|
124
|
+
const n = u(), a = n.registry[t];
|
|
125
|
+
if (a == null)
|
|
126
|
+
return;
|
|
127
|
+
const r = J(t, e);
|
|
128
|
+
n.router.hasRoute(r) || n.router.addRoute(n.parentRouteName, {
|
|
129
|
+
path: e,
|
|
130
|
+
name: r,
|
|
131
|
+
component: a.component,
|
|
132
|
+
meta: W(a, t, e, o),
|
|
133
|
+
props: a.props
|
|
134
|
+
});
|
|
135
|
+
}, Y = (t, e) => {
|
|
136
|
+
const o = u();
|
|
137
|
+
if (e.route !== void 0)
|
|
138
|
+
return typeof e.route == "string" ? e.route : {
|
|
139
|
+
...e.route,
|
|
140
|
+
query: e.query ?? e.route.query
|
|
141
|
+
};
|
|
142
|
+
if (e.key === void 0)
|
|
143
|
+
return;
|
|
144
|
+
const n = o.registry[e.key];
|
|
145
|
+
if (n == null)
|
|
146
|
+
return;
|
|
147
|
+
const a = _(t, e.routeSuffix ?? n.suffix), r = _(t, e.routePatternSuffix ?? e.routeSuffix ?? n.suffix);
|
|
148
|
+
return X(e.key, r, e.titleKey), {
|
|
149
|
+
path: a,
|
|
150
|
+
query: e.query
|
|
151
|
+
};
|
|
152
|
+
}, ue = () => {
|
|
153
|
+
const t = C(), e = u();
|
|
154
|
+
return {
|
|
155
|
+
openDialog: async (n) => {
|
|
156
|
+
if (e.getMode() !== "tab") {
|
|
157
|
+
n.openModal();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const a = Y(t.path, n);
|
|
161
|
+
if (a === void 0) {
|
|
162
|
+
n.openModal();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const r = Q(a);
|
|
166
|
+
n.context !== void 0 && r !== void 0 && r !== "" && G(n.context, r), await e.router.push(a);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}, ee = () => {
|
|
170
|
+
const t = C(), e = u();
|
|
171
|
+
return {
|
|
172
|
+
closeCurrentDialogTab: () => {
|
|
173
|
+
var f, p, m;
|
|
174
|
+
const n = e.tabAdapter.getTabs(), a = n.findIndex((g) => g.fullPath === t.fullPath);
|
|
175
|
+
if (a <= 0) {
|
|
176
|
+
e.router.back();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const r = n[a], s = typeof ((f = r == null ? void 0 : r.meta) == null ? void 0 : f.dialogSourceFullPath) == "string" ? r.meta.dialogSourceFullPath : void 0, d = a < n.length - 1 ? (p = n[a + 1]) == null ? void 0 : p.fullPath : (m = n[a - 1]) == null ? void 0 : m.fullPath, l = s !== void 0 && s !== "" ? s : d;
|
|
180
|
+
if (l == null || l === "") {
|
|
181
|
+
e.router.back();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const i = a === e.tabAdapter.getCurrentIndex();
|
|
185
|
+
e.tabAdapter.deleteTab(a);
|
|
186
|
+
const x = e.tabAdapter.getTabs().findIndex((g) => g.fullPath === l);
|
|
187
|
+
i && x >= 0 && e.tabAdapter.setCurrentIndex(x), e.router.replace(l);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}, de = (t) => {
|
|
191
|
+
const e = C(), o = u(), { closeCurrentDialogTab: n } = ee(), a = c(
|
|
192
|
+
() => M(e.path) ?? M(e.query.dialogId)
|
|
193
|
+
), r = c(() => typeof t == "function" && t.length > 0 ? t({ route: e, dialogContext: a }) : V(t)), s = () => {
|
|
194
|
+
const l = o.tabAdapter.getTabs().find((i) => i.fullPath === e.fullPath);
|
|
195
|
+
l != null && (l.title = r.value);
|
|
196
|
+
}, d = (l, i) => {
|
|
197
|
+
H({
|
|
198
|
+
key: l,
|
|
199
|
+
type: "saved",
|
|
200
|
+
payload: i
|
|
201
|
+
}), n();
|
|
202
|
+
};
|
|
203
|
+
return j(
|
|
204
|
+
() => [e.fullPath, r.value],
|
|
205
|
+
s,
|
|
206
|
+
{ immediate: !0 }
|
|
207
|
+
), {
|
|
208
|
+
route: e,
|
|
209
|
+
dialogContext: a,
|
|
210
|
+
pageTitleKey: r,
|
|
211
|
+
closeCurrentDialogTab: n,
|
|
212
|
+
emitSavedAndClose: d,
|
|
213
|
+
syncTabTitle: s
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
export {
|
|
217
|
+
se as NanoDialogTabPage,
|
|
218
|
+
re as configureNanoDialogTabs,
|
|
219
|
+
le as createNanoDialogTabs,
|
|
220
|
+
H as emitDialogResult,
|
|
221
|
+
M as getDialogContext,
|
|
222
|
+
k as nanoDialogTabsKey,
|
|
223
|
+
ie as onDialogResult,
|
|
224
|
+
ce as removeDialogContext,
|
|
225
|
+
G as setDialogContext,
|
|
226
|
+
ue as useDialogOpen,
|
|
227
|
+
de as useDialogPage,
|
|
228
|
+
ee as useDialogTabClose,
|
|
229
|
+
u as useNanoDialogTabs
|
|
230
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NanoDialogTabsContext, NanoDialogTabsOptions, NanoDialogTabsPlugin } from './types';
|
|
2
|
+
export declare const configureNanoDialogTabs: <TKey extends string>(options: NanoDialogTabsOptions<TKey>) => NanoDialogTabsContext<TKey>;
|
|
3
|
+
export declare const createNanoDialogTabs: <TKey extends string>(options: NanoDialogTabsOptions<TKey>) => NanoDialogTabsPlugin<TKey>;
|
|
4
|
+
export declare const useNanoDialogTabs: () => NanoDialogTabsContext<string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface DialogResult<TPayload = unknown> {
|
|
2
|
+
key: string;
|
|
3
|
+
type: 'saved' | 'cancelled';
|
|
4
|
+
payload?: TPayload;
|
|
5
|
+
}
|
|
6
|
+
export declare const emitDialogResult: <TPayload>(result: DialogResult<TPayload>) => void;
|
|
7
|
+
export declare const onDialogResult: (listener: (result: DialogResult) => void) => () => void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { App, ComputedRef, InjectionKey, MaybeRefOrGetter, Plugin } from 'vue';
|
|
2
|
+
import type { LocationQueryRaw, RouteLocationNormalizedLoaded, RouteLocationRaw, Router } from 'vue-router';
|
|
3
|
+
export type DialogOpenMode = 'dialog' | 'tab';
|
|
4
|
+
export interface NanoDialogRouteConfig {
|
|
5
|
+
suffix: string;
|
|
6
|
+
title: string;
|
|
7
|
+
component: unknown;
|
|
8
|
+
props?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export type NanoDialogRegistry<TKey extends string = string> = Partial<Record<TKey, NanoDialogRouteConfig>>;
|
|
11
|
+
export interface NanoDialogTabData {
|
|
12
|
+
title: string;
|
|
13
|
+
name?: string | symbol | null;
|
|
14
|
+
route?: unknown;
|
|
15
|
+
fullPath: string;
|
|
16
|
+
meta?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface NanoDialogTabAdapter {
|
|
19
|
+
getTabs: () => NanoDialogTabData[];
|
|
20
|
+
getCurrentIndex: () => number;
|
|
21
|
+
setCurrentIndex: (index: number) => void;
|
|
22
|
+
deleteTab: (index: number) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface NanoDialogRouteMetaState<TKey extends string = string> {
|
|
25
|
+
key: TKey;
|
|
26
|
+
path: string;
|
|
27
|
+
titleKey?: string;
|
|
28
|
+
config: NanoDialogRouteConfig;
|
|
29
|
+
}
|
|
30
|
+
export interface NanoDialogTabsOptions<TKey extends string = string> {
|
|
31
|
+
router: Router;
|
|
32
|
+
parentRouteName: string;
|
|
33
|
+
registry: NanoDialogRegistry<TKey>;
|
|
34
|
+
mode: DialogOpenMode | (() => DialogOpenMode);
|
|
35
|
+
tabAdapter: NanoDialogTabAdapter;
|
|
36
|
+
translate?: (key: string) => string;
|
|
37
|
+
defaultRouteMeta?: Record<string, unknown> | ((state: NanoDialogRouteMetaState<TKey>) => Record<string, unknown>);
|
|
38
|
+
}
|
|
39
|
+
export interface NanoDialogTabsContext<TKey extends string = string> extends NanoDialogTabsOptions<TKey> {
|
|
40
|
+
getMode: () => DialogOpenMode;
|
|
41
|
+
t: (key: string) => string;
|
|
42
|
+
}
|
|
43
|
+
export type NanoDialogTabsPlugin<TKey extends string = string> = Plugin & {
|
|
44
|
+
install: (app: App) => void;
|
|
45
|
+
context: NanoDialogTabsContext<TKey>;
|
|
46
|
+
};
|
|
47
|
+
export interface OpenDialogOptions<TKey extends string = string> {
|
|
48
|
+
key?: TKey;
|
|
49
|
+
route?: RouteLocationRaw;
|
|
50
|
+
query?: LocationQueryRaw;
|
|
51
|
+
context?: unknown;
|
|
52
|
+
routeSuffix?: string;
|
|
53
|
+
routePatternSuffix?: string;
|
|
54
|
+
titleKey?: string;
|
|
55
|
+
openModal: () => void;
|
|
56
|
+
}
|
|
57
|
+
export interface DialogPageTitleState<TContext> {
|
|
58
|
+
route: RouteLocationNormalizedLoaded;
|
|
59
|
+
dialogContext: ComputedRef<TContext | undefined>;
|
|
60
|
+
}
|
|
61
|
+
export type DialogPageTitle<TContext> = MaybeRefOrGetter<string> | ((state: DialogPageTitleState<TContext>) => string);
|
|
62
|
+
export declare const nanoDialogTabsKey: InjectionKey<NanoDialogTabsContext>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DialogPageTitle } from './types';
|
|
2
|
+
export declare const useDialogPage: <TContext = unknown>(titleKey: DialogPageTitle<TContext>) => {
|
|
3
|
+
route: import("vue-router").RouteLocationNormalizedLoadedGeneric;
|
|
4
|
+
dialogContext: import("vue").ComputedRef<TContext | undefined>;
|
|
5
|
+
pageTitleKey: import("vue").ComputedRef<string>;
|
|
6
|
+
closeCurrentDialogTab: () => void;
|
|
7
|
+
emitSavedAndClose: <TPayload>(key: string, payload?: TPayload) => void;
|
|
8
|
+
syncTabTitle: () => void;
|
|
9
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("element-plus"),n=require("./NanoButton.vue_vue_type_script_setup_true_lang-D1yLWi2K.cjs"),a=e.defineComponent({name:"NanoAddButton",inheritAttrs:!1,__name:"NanoAddButton",props:s.buttonProps,setup(r){return(t,o)=>(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({...t.$props,...t.$attrs},{type:"primary",icon:"Plus"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[o[0]||(o[0]=e.createTextVNode("新增",-1))])]),_:3},16))}}),p=e.defineComponent({name:"NanoBackTopButton",inheritAttrs:!1,__name:"NanoBackTopButton",props:s.buttonProps,setup(r){return(t,o)=>t.$slots.default?(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:0},{...t.$props,...t.$attrs},{secondary:"",class:"app-backtop-button"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},16)):(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:1},{...t.$props,...t.$attrs},{secondary:"",class:"app-backtop-button"}),{default:e.withCtx(()=>[...o[0]||(o[0]=[e.createElementVNode("svg",{class:"app-backtop-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false"},[e.createElementVNode("path",{d:"M6 5h12"}),e.createElementVNode("path",{d:"M12 19V9"}),e.createElementVNode("path",{d:"m8 13 4-4 4 4"})],-1)])]),_:1},16))}}),l=e.defineComponent({name:"NanoCancelButton",inheritAttrs:!1,__name:"NanoCancelButton",props:s.buttonProps,setup(r){return(t,o)=>(e.openBlock(),e.createBlock(n._sfc_main,e.normalizeProps(e.guardReactiveProps({...t.$props,...t.$attrs})),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[o[0]||(o[0]=e.createTextVNode("取消",-1))])]),_:3},16))}}),u=e.defineComponent({name:"NanoDeleteButton",inheritAttrs:!1,__name:"NanoDeleteButton",props:s.buttonProps,setup(r){return(t,o)=>t.$slots.default?(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:0},{...t.$props,...t.$attrs},{type:"danger",icon:"Delete"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},16)):(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:1},{...t.$props,...t.$attrs},{type:"danger",icon:"Delete"}),null,16))}}),i=e.defineComponent({name:"NanoEditButton",inheritAttrs:!1,__name:"NanoEditButton",props:s.buttonProps,setup(r){return(t,o)=>t.$slots.default?(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:0},{...t.$props,...t.$attrs},{icon:"Edit"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},16)):(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:1},{...t.$props,...t.$attrs},{icon:"Edit"}),null,16))}}),m=e.defineComponent({name:"NanoExportButton",inheritAttrs:!1,__name:"NanoExportButton",props:s.buttonProps,setup(r){return(t,o)=>(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({...t.$props,...t.$attrs},{class:"app-button-export",icon:"Download"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[o[0]||(o[0]=e.createTextVNode("导出",-1))])]),_:3},16))}}),c=e.defineComponent({name:"NanoImportButton",inheritAttrs:!1,__name:"NanoImportButton",props:s.buttonProps,setup(r){return(t,o)=>(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({...t.$props,...t.$attrs},{class:"app-button-import",icon:"Upload"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[o[0]||(o[0]=e.createTextVNode("导入",-1))])]),_:3},16))}}),d=e.defineComponent({name:"NanoManageButton",inheritAttrs:!1,__name:"NanoManageButton",props:s.buttonProps,setup(r){return(t,o)=>t.$slots.default?(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:0},{...t.$props,...t.$attrs},{type:"primary",icon:"Setting"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},16)):(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:1},{...t.$props,...t.$attrs},{type:"primary",icon:"Setting"}),null,16))}}),f=e.defineComponent({name:"NanoMoveButton",inheritAttrs:!1,__name:"NanoMoveButton",props:s.buttonProps,setup(r){return(t,o)=>(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({...t.$props,...t.$attrs},{icon:"Rank"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[o[0]||(o[0]=e.createTextVNode("移动",-1))])]),_:3},16))}}),_=e.defineComponent({name:"NanoSubmitButton",inheritAttrs:!1,__name:"NanoSubmitButton",props:s.buttonProps,setup(r){return(t,o)=>(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({...t.$props,...t.$attrs},{type:"primary"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[o[0]||(o[0]=e.createTextVNode("保存",-1))])]),_:3},16))}}),B=e.defineComponent({name:"NanoTextAddButton",inheritAttrs:!1,__name:"NanoTextAddButton",props:s.buttonProps,setup(r){return(t,o)=>t.$slots.default?(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:0},{...t.$props,...t.$attrs},{text:"",icon:"Plus"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},16)):(e.openBlock(),e.createBlock(n._sfc_main,e.mergeProps({key:1},{...t.$props,...t.$attrs},{text:"",icon:"Plus"}),null,16))}}),k=[n._sfc_main,a,B,f,c,m,i,d,u,_,l,p],$=r=>{k.forEach(t=>{r.component(t.name||"AnonymousComponent",t)})},N={install:$};exports.NanoButton=n._sfc_main;exports.NanoAddButton=a;exports.NanoBackTopButton=p;exports.NanoCancelButton=l;exports.NanoDeleteButton=u;exports.NanoEditButton=i;exports.NanoExportButton=m;exports.NanoImportButton=c;exports.NanoManageButton=d;exports.NanoMoveButton=f;exports.NanoSubmitButton=_;exports.NanoTextAddButton=B;exports.default=N;exports.install=$;
|
package/dist/index.mjs
CHANGED
|
@@ -1,291 +1,241 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { buttonProps as i
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
secondary: Boolean
|
|
6
|
-
}, a = /* @__PURE__ */ l({
|
|
7
|
-
name: "NanoButton",
|
|
8
|
-
inheritAttrs: !1,
|
|
9
|
-
__name: "NanoButton",
|
|
10
|
-
props: M,
|
|
11
|
-
emits: C,
|
|
12
|
-
setup(p, { emit: t }) {
|
|
13
|
-
const o = p, h = t, $ = g(), B = k(() => {
|
|
14
|
-
const { secondary: d, ...N } = o;
|
|
15
|
-
return N;
|
|
16
|
-
}), _ = k(() => [
|
|
17
|
-
"nano-button",
|
|
18
|
-
o.secondary ? "app-button-secondary" : ""
|
|
19
|
-
]), c = (d) => {
|
|
20
|
-
h("click", d);
|
|
21
|
-
};
|
|
22
|
-
return (d, N) => {
|
|
23
|
-
const y = v("el-button");
|
|
24
|
-
return d.$slots.default ? (n(), s(y, e({ key: 0 }, { ...B.value, ...A($) }, {
|
|
25
|
-
class: _.value,
|
|
26
|
-
onClick: c
|
|
27
|
-
}), b({
|
|
28
|
-
default: r(() => [
|
|
29
|
-
u(d.$slots, "default")
|
|
30
|
-
]),
|
|
31
|
-
_: 2
|
|
32
|
-
}, [
|
|
33
|
-
d.$slots.loading ? {
|
|
34
|
-
name: "loading",
|
|
35
|
-
fn: r(() => [
|
|
36
|
-
u(d.$slots, "loading")
|
|
37
|
-
]),
|
|
38
|
-
key: "0"
|
|
39
|
-
} : void 0
|
|
40
|
-
]), 1040, ["class"])) : (n(), s(y, e({ key: 1 }, { ...B.value, ...A($) }, {
|
|
41
|
-
class: _.value,
|
|
42
|
-
onClick: c
|
|
43
|
-
}), b({ _: 2 }, [
|
|
44
|
-
d.$slots.loading ? {
|
|
45
|
-
name: "loading",
|
|
46
|
-
fn: r(() => [
|
|
47
|
-
u(d.$slots, "loading")
|
|
48
|
-
]),
|
|
49
|
-
key: "0"
|
|
50
|
-
} : void 0
|
|
51
|
-
]), 1040, ["class"]));
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}), S = /* @__PURE__ */ l({
|
|
1
|
+
import { defineComponent as u, openBlock as a, createBlock as e, mergeProps as s, withCtx as p, renderSlot as l, createTextVNode as d, createElementVNode as m, normalizeProps as f, guardReactiveProps as $ } from "vue";
|
|
2
|
+
import { buttonProps as i } from "element-plus";
|
|
3
|
+
import { _ as n } from "./NanoButton.vue_vue_type_script_setup_true_lang-DgnSKBXL.js";
|
|
4
|
+
const B = /* @__PURE__ */ u({
|
|
55
5
|
name: "NanoAddButton",
|
|
56
6
|
inheritAttrs: !1,
|
|
57
7
|
__name: "NanoAddButton",
|
|
58
8
|
props: i,
|
|
59
|
-
setup(
|
|
60
|
-
return (t, o) => (
|
|
9
|
+
setup(r) {
|
|
10
|
+
return (t, o) => (a(), e(n, s({ ...t.$props, ...t.$attrs }, {
|
|
61
11
|
type: "primary",
|
|
62
12
|
icon: "Plus"
|
|
63
13
|
}), {
|
|
64
|
-
default:
|
|
65
|
-
|
|
66
|
-
o[0] || (o[0] =
|
|
14
|
+
default: p(() => [
|
|
15
|
+
l(t.$slots, "default", {}, () => [
|
|
16
|
+
o[0] || (o[0] = d("新增", -1))
|
|
67
17
|
])
|
|
68
18
|
]),
|
|
69
19
|
_: 3
|
|
70
20
|
}, 16));
|
|
71
21
|
}
|
|
72
|
-
}),
|
|
22
|
+
}), _ = /* @__PURE__ */ u({
|
|
73
23
|
name: "NanoBackTopButton",
|
|
74
24
|
inheritAttrs: !1,
|
|
75
25
|
__name: "NanoBackTopButton",
|
|
76
26
|
props: i,
|
|
77
|
-
setup(
|
|
78
|
-
return (t, o) => t.$slots.default ? (
|
|
27
|
+
setup(r) {
|
|
28
|
+
return (t, o) => t.$slots.default ? (a(), e(n, s({ key: 0 }, { ...t.$props, ...t.$attrs }, {
|
|
79
29
|
secondary: "",
|
|
80
30
|
class: "app-backtop-button"
|
|
81
31
|
}), {
|
|
82
|
-
default:
|
|
83
|
-
|
|
32
|
+
default: p(() => [
|
|
33
|
+
l(t.$slots, "default")
|
|
84
34
|
]),
|
|
85
35
|
_: 3
|
|
86
|
-
}, 16)) : (
|
|
36
|
+
}, 16)) : (a(), e(n, s({ key: 1 }, { ...t.$props, ...t.$attrs }, {
|
|
87
37
|
secondary: "",
|
|
88
38
|
class: "app-backtop-button"
|
|
89
39
|
}), {
|
|
90
|
-
default:
|
|
91
|
-
|
|
40
|
+
default: p(() => [...o[0] || (o[0] = [
|
|
41
|
+
m("svg", {
|
|
92
42
|
class: "app-backtop-icon",
|
|
93
43
|
viewBox: "0 0 24 24",
|
|
94
44
|
"aria-hidden": "true",
|
|
95
45
|
focusable: "false"
|
|
96
46
|
}, [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
47
|
+
m("path", { d: "M6 5h12" }),
|
|
48
|
+
m("path", { d: "M12 19V9" }),
|
|
49
|
+
m("path", { d: "m8 13 4-4 4 4" })
|
|
100
50
|
], -1)
|
|
101
51
|
])]),
|
|
102
52
|
_: 1
|
|
103
53
|
}, 16));
|
|
104
54
|
}
|
|
105
|
-
}),
|
|
55
|
+
}), N = /* @__PURE__ */ u({
|
|
106
56
|
name: "NanoCancelButton",
|
|
107
57
|
inheritAttrs: !1,
|
|
108
58
|
__name: "NanoCancelButton",
|
|
109
59
|
props: i,
|
|
110
|
-
setup(
|
|
111
|
-
return (t, o) => (
|
|
112
|
-
default:
|
|
113
|
-
|
|
114
|
-
o[0] || (o[0] =
|
|
60
|
+
setup(r) {
|
|
61
|
+
return (t, o) => (a(), e(n, f($({ ...t.$props, ...t.$attrs })), {
|
|
62
|
+
default: p(() => [
|
|
63
|
+
l(t.$slots, "default", {}, () => [
|
|
64
|
+
o[0] || (o[0] = d("取消", -1))
|
|
115
65
|
])
|
|
116
66
|
]),
|
|
117
67
|
_: 3
|
|
118
68
|
}, 16));
|
|
119
69
|
}
|
|
120
|
-
}),
|
|
70
|
+
}), y = /* @__PURE__ */ u({
|
|
121
71
|
name: "NanoDeleteButton",
|
|
122
72
|
inheritAttrs: !1,
|
|
123
73
|
__name: "NanoDeleteButton",
|
|
124
74
|
props: i,
|
|
125
|
-
setup(
|
|
126
|
-
return (t, o) => t.$slots.default ? (
|
|
75
|
+
setup(r) {
|
|
76
|
+
return (t, o) => t.$slots.default ? (a(), e(n, s({ key: 0 }, { ...t.$props, ...t.$attrs }, {
|
|
127
77
|
type: "danger",
|
|
128
78
|
icon: "Delete"
|
|
129
79
|
}), {
|
|
130
|
-
default:
|
|
131
|
-
|
|
80
|
+
default: p(() => [
|
|
81
|
+
l(t.$slots, "default")
|
|
132
82
|
]),
|
|
133
83
|
_: 3
|
|
134
|
-
}, 16)) : (
|
|
84
|
+
}, 16)) : (a(), e(n, s({ key: 1 }, { ...t.$props, ...t.$attrs }, {
|
|
135
85
|
type: "danger",
|
|
136
86
|
icon: "Delete"
|
|
137
87
|
}), null, 16));
|
|
138
88
|
}
|
|
139
|
-
}),
|
|
89
|
+
}), c = /* @__PURE__ */ u({
|
|
140
90
|
name: "NanoEditButton",
|
|
141
91
|
inheritAttrs: !1,
|
|
142
92
|
__name: "NanoEditButton",
|
|
143
93
|
props: i,
|
|
144
|
-
setup(
|
|
145
|
-
return (t, o) => t.$slots.default ? (
|
|
146
|
-
default:
|
|
147
|
-
|
|
94
|
+
setup(r) {
|
|
95
|
+
return (t, o) => t.$slots.default ? (a(), e(n, s({ key: 0 }, { ...t.$props, ...t.$attrs }, { icon: "Edit" }), {
|
|
96
|
+
default: p(() => [
|
|
97
|
+
l(t.$slots, "default")
|
|
148
98
|
]),
|
|
149
99
|
_: 3
|
|
150
|
-
}, 16)) : (
|
|
100
|
+
}, 16)) : (a(), e(n, s({ key: 1 }, { ...t.$props, ...t.$attrs }, { icon: "Edit" }), null, 16));
|
|
151
101
|
}
|
|
152
|
-
}),
|
|
102
|
+
}), k = /* @__PURE__ */ u({
|
|
153
103
|
name: "NanoExportButton",
|
|
154
104
|
inheritAttrs: !1,
|
|
155
105
|
__name: "NanoExportButton",
|
|
156
106
|
props: i,
|
|
157
|
-
setup(
|
|
158
|
-
return (t, o) => (
|
|
107
|
+
setup(r) {
|
|
108
|
+
return (t, o) => (a(), e(n, s({ ...t.$props, ...t.$attrs }, {
|
|
159
109
|
class: "app-button-export",
|
|
160
110
|
icon: "Download"
|
|
161
111
|
}), {
|
|
162
|
-
default:
|
|
163
|
-
|
|
164
|
-
o[0] || (o[0] =
|
|
112
|
+
default: p(() => [
|
|
113
|
+
l(t.$slots, "default", {}, () => [
|
|
114
|
+
o[0] || (o[0] = d("导出", -1))
|
|
165
115
|
])
|
|
166
116
|
]),
|
|
167
117
|
_: 3
|
|
168
118
|
}, 16));
|
|
169
119
|
}
|
|
170
|
-
}),
|
|
120
|
+
}), A = /* @__PURE__ */ u({
|
|
171
121
|
name: "NanoImportButton",
|
|
172
122
|
inheritAttrs: !1,
|
|
173
123
|
__name: "NanoImportButton",
|
|
174
124
|
props: i,
|
|
175
|
-
setup(
|
|
176
|
-
return (t, o) => (
|
|
125
|
+
setup(r) {
|
|
126
|
+
return (t, o) => (a(), e(n, s({ ...t.$props, ...t.$attrs }, {
|
|
177
127
|
class: "app-button-import",
|
|
178
128
|
icon: "Upload"
|
|
179
129
|
}), {
|
|
180
|
-
default:
|
|
181
|
-
|
|
182
|
-
o[0] || (o[0] =
|
|
130
|
+
default: p(() => [
|
|
131
|
+
l(t.$slots, "default", {}, () => [
|
|
132
|
+
o[0] || (o[0] = d("导入", -1))
|
|
183
133
|
])
|
|
184
134
|
]),
|
|
185
135
|
_: 3
|
|
186
136
|
}, 16));
|
|
187
137
|
}
|
|
188
|
-
}),
|
|
138
|
+
}), h = /* @__PURE__ */ u({
|
|
189
139
|
name: "NanoManageButton",
|
|
190
140
|
inheritAttrs: !1,
|
|
191
141
|
__name: "NanoManageButton",
|
|
192
142
|
props: i,
|
|
193
|
-
setup(
|
|
194
|
-
return (t, o) => t.$slots.default ? (
|
|
143
|
+
setup(r) {
|
|
144
|
+
return (t, o) => t.$slots.default ? (a(), e(n, s({ key: 0 }, { ...t.$props, ...t.$attrs }, {
|
|
195
145
|
type: "primary",
|
|
196
146
|
icon: "Setting"
|
|
197
147
|
}), {
|
|
198
|
-
default:
|
|
199
|
-
|
|
148
|
+
default: p(() => [
|
|
149
|
+
l(t.$slots, "default")
|
|
200
150
|
]),
|
|
201
151
|
_: 3
|
|
202
|
-
}, 16)) : (
|
|
152
|
+
}, 16)) : (a(), e(n, s({ key: 1 }, { ...t.$props, ...t.$attrs }, {
|
|
203
153
|
type: "primary",
|
|
204
154
|
icon: "Setting"
|
|
205
155
|
}), null, 16));
|
|
206
156
|
}
|
|
207
|
-
}),
|
|
157
|
+
}), b = /* @__PURE__ */ u({
|
|
208
158
|
name: "NanoMoveButton",
|
|
209
159
|
inheritAttrs: !1,
|
|
210
160
|
__name: "NanoMoveButton",
|
|
211
161
|
props: i,
|
|
212
|
-
setup(
|
|
213
|
-
return (t, o) => (
|
|
214
|
-
default:
|
|
215
|
-
|
|
216
|
-
o[0] || (o[0] =
|
|
162
|
+
setup(r) {
|
|
163
|
+
return (t, o) => (a(), e(n, s({ ...t.$props, ...t.$attrs }, { icon: "Rank" }), {
|
|
164
|
+
default: p(() => [
|
|
165
|
+
l(t.$slots, "default", {}, () => [
|
|
166
|
+
o[0] || (o[0] = d("移动", -1))
|
|
217
167
|
])
|
|
218
168
|
]),
|
|
219
169
|
_: 3
|
|
220
170
|
}, 16));
|
|
221
171
|
}
|
|
222
|
-
}),
|
|
172
|
+
}), g = /* @__PURE__ */ u({
|
|
223
173
|
name: "NanoSubmitButton",
|
|
224
174
|
inheritAttrs: !1,
|
|
225
175
|
__name: "NanoSubmitButton",
|
|
226
176
|
props: i,
|
|
227
|
-
setup(
|
|
228
|
-
return (t, o) => (
|
|
229
|
-
default:
|
|
230
|
-
|
|
231
|
-
o[0] || (o[0] =
|
|
177
|
+
setup(r) {
|
|
178
|
+
return (t, o) => (a(), e(n, s({ ...t.$props, ...t.$attrs }, { type: "primary" }), {
|
|
179
|
+
default: p(() => [
|
|
180
|
+
l(t.$slots, "default", {}, () => [
|
|
181
|
+
o[0] || (o[0] = d("保存", -1))
|
|
232
182
|
])
|
|
233
183
|
]),
|
|
234
184
|
_: 3
|
|
235
185
|
}, 16));
|
|
236
186
|
}
|
|
237
|
-
}),
|
|
187
|
+
}), E = /* @__PURE__ */ u({
|
|
238
188
|
name: "NanoTextAddButton",
|
|
239
189
|
inheritAttrs: !1,
|
|
240
190
|
__name: "NanoTextAddButton",
|
|
241
191
|
props: i,
|
|
242
|
-
setup(
|
|
243
|
-
return (t, o) => t.$slots.default ? (
|
|
192
|
+
setup(r) {
|
|
193
|
+
return (t, o) => t.$slots.default ? (a(), e(n, s({ key: 0 }, { ...t.$props, ...t.$attrs }, {
|
|
244
194
|
text: "",
|
|
245
195
|
icon: "Plus"
|
|
246
196
|
}), {
|
|
247
|
-
default:
|
|
248
|
-
|
|
197
|
+
default: p(() => [
|
|
198
|
+
l(t.$slots, "default")
|
|
249
199
|
]),
|
|
250
200
|
_: 3
|
|
251
|
-
}, 16)) : (
|
|
201
|
+
}, 16)) : (a(), e(n, s({ key: 1 }, { ...t.$props, ...t.$attrs }, {
|
|
252
202
|
text: "",
|
|
253
203
|
icon: "Plus"
|
|
254
204
|
}), null, 16));
|
|
255
205
|
}
|
|
256
|
-
}),
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
],
|
|
270
|
-
|
|
271
|
-
|
|
206
|
+
}), M = [
|
|
207
|
+
n,
|
|
208
|
+
B,
|
|
209
|
+
E,
|
|
210
|
+
b,
|
|
211
|
+
A,
|
|
212
|
+
k,
|
|
213
|
+
c,
|
|
214
|
+
h,
|
|
215
|
+
y,
|
|
216
|
+
g,
|
|
217
|
+
N,
|
|
218
|
+
_
|
|
219
|
+
], P = (r) => {
|
|
220
|
+
M.forEach((t) => {
|
|
221
|
+
r.component(t.name || "AnonymousComponent", t);
|
|
272
222
|
});
|
|
273
|
-
},
|
|
274
|
-
install:
|
|
223
|
+
}, D = {
|
|
224
|
+
install: P
|
|
275
225
|
};
|
|
276
226
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
227
|
+
B as NanoAddButton,
|
|
228
|
+
_ as NanoBackTopButton,
|
|
229
|
+
n as NanoButton,
|
|
230
|
+
N as NanoCancelButton,
|
|
231
|
+
y as NanoDeleteButton,
|
|
232
|
+
c as NanoEditButton,
|
|
233
|
+
k as NanoExportButton,
|
|
234
|
+
A as NanoImportButton,
|
|
235
|
+
h as NanoManageButton,
|
|
236
|
+
b as NanoMoveButton,
|
|
237
|
+
g as NanoSubmitButton,
|
|
238
|
+
E as NanoTextAddButton,
|
|
239
|
+
D as default,
|
|
240
|
+
P as install
|
|
291
241
|
};
|
package/package.json
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name":
|
|
3
|
-
"version":
|
|
4
|
-
"description":
|
|
5
|
-
"license":
|
|
6
|
-
"type":
|
|
7
|
-
"main":
|
|
8
|
-
"module":
|
|
9
|
-
"types":
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@cst-ui/nano-buttons",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Nano themed Vue 3 button components and dialog tab helpers based on Element Plus.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
"*": {
|
|
12
|
+
"dialog-tabs": [
|
|
13
|
+
"dist/dialog-tabs/index.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"*.css"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./dialog-tabs": {
|
|
31
|
+
"types": "./dist/dialog-tabs/index.d.ts",
|
|
32
|
+
"import": "./dist/dialog-tabs/index.mjs",
|
|
33
|
+
"require": "./dist/dialog-tabs/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./style.css": "./dist/style.css"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "vite build && vue-tsc -p tsconfig.build.json --declaration --emitDeclarationOnly",
|
|
39
|
+
"docs:dev": "vite --config docs/vite.config.ts --host 0.0.0.0",
|
|
40
|
+
"docs:build": "vite build --config docs/vite.config.ts",
|
|
41
|
+
"docs:preview": "vite preview --config docs/vite.config.ts --host 0.0.0.0",
|
|
42
|
+
"typecheck": "vue-tsc -p tsconfig.build.json --noEmit"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"element-plus": "^2.8.5",
|
|
46
|
+
"vue": "^3.5.13",
|
|
47
|
+
"vue-router": "^4.4.5"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@element-plus/icons-vue": "2.3.2",
|
|
51
|
+
"@types/node": "^18.11.3",
|
|
52
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
53
|
+
"typescript": "^5.6.3",
|
|
54
|
+
"vite": "^5.4.9",
|
|
55
|
+
"vue-router": "^4.4.5",
|
|
56
|
+
"vue-tsc": "2.1.6"
|
|
57
|
+
}
|
|
58
|
+
}
|