@ug666/admin-vue 0.0.0-stage → 0.1.0-beta.2

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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +1 -0
  3. package/dist/index.ts.js +1 -0
  4. package/dist/patterns/AdminColumnSettings.js +1 -0
  5. package/dist/patterns/AdminColumnSettings.vue_vue_type_script_setup_true_lang.js +1 -0
  6. package/dist/patterns/AdminConfirmAction.js +1 -0
  7. package/dist/patterns/AdminConfirmAction.vue_vue_type_script_setup_true_lang.js +1 -0
  8. package/dist/patterns/AdminDetailPage.js +1 -0
  9. package/dist/patterns/AdminDetailPage.vue_vue_type_script_setup_true_lang.js +1 -0
  10. package/dist/patterns/AdminFormDialog.js +1 -0
  11. package/dist/patterns/AdminFormDialog.vue_vue_type_script_setup_true_lang.js +1 -0
  12. package/dist/patterns/AdminFormPage.js +1 -0
  13. package/dist/patterns/AdminFormPage.vue_vue_type_script_setup_true_lang.js +1 -0
  14. package/dist/patterns/AdminListPage.js +1 -0
  15. package/dist/patterns/AdminListPage.vue_vue_type_script_setup_true_lang.js +1 -0
  16. package/dist/patterns/AdminPage.js +1 -0
  17. package/dist/patterns/AdminPage.vue_vue_type_script_setup_true_lang.js +1 -0
  18. package/dist/patterns/AdminSearchField.js +1 -0
  19. package/dist/patterns/AdminSearchField.vue_vue_type_script_setup_true_lang.js +1 -0
  20. package/dist/patterns/AdminSearchForm.js +1 -0
  21. package/dist/patterns/AdminSearchForm.vue_vue_type_script_setup_true_lang.js +1 -0
  22. package/dist/patterns/AdminTabContextMenu.js +1 -0
  23. package/dist/patterns/AdminTabContextMenu.vue_vue_type_script_setup_true_lang.js +1 -0
  24. package/package.json +44 -4
  25. package/src/index.ts +10 -0
  26. package/src/patterns/AdminColumnSettings.vue +107 -0
  27. package/src/patterns/AdminConfirmAction.vue +30 -0
  28. package/src/patterns/AdminDetailPage.vue +35 -0
  29. package/src/patterns/AdminFormDialog.vue +47 -0
  30. package/src/patterns/AdminFormPage.vue +95 -0
  31. package/src/patterns/AdminListPage.vue +33 -0
  32. package/src/patterns/AdminPage.vue +27 -0
  33. package/src/patterns/AdminSearchField.vue +22 -0
  34. package/src/patterns/AdminSearchForm.vue +52 -0
  35. package/src/patterns/AdminTabContextMenu.vue +50 -0
  36. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 UG666
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import e from"./patterns/AdminColumnSettings.js";import t from"./patterns/AdminConfirmAction.js";import n from"./patterns/AdminDetailPage.js";import r from"./patterns/AdminFormDialog.js";import i from"./patterns/AdminFormPage.js";import a from"./patterns/AdminListPage.js";import o from"./patterns/AdminPage.js";import s from"./patterns/AdminSearchField.js";import c from"./patterns/AdminSearchForm.js";import l from"./patterns/AdminTabContextMenu.js";export{e as AdminColumnSettings,t as AdminConfirmAction,n as AdminDetailPage,r as AdminFormDialog,i as AdminFormPage,a as AdminListPage,o as AdminPage,s as AdminSearchField,c as AdminSearchForm,l as AdminTabContextMenu};
@@ -0,0 +1 @@
1
+ export * from "./index.ts/index.js";
@@ -0,0 +1 @@
1
+ import e from"./AdminColumnSettings.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{Fragment as e,computed as t,createBlock as n,createCommentVNode as r,createElementBlock as i,createElementVNode as a,createTextVNode as o,createVNode as s,defineComponent as c,isRef as l,openBlock as u,renderList as d,toDisplayString as f,unref as p,withCtx as m}from"vue";import{UGButton as h,UGCheckbox as g,UGPopover as _,UGPopoverContent as v,UGPopoverTrigger as y}from"@ug666/ui-vue";import{GripVertical as b,Pin as x,Settings2 as S}from"@lucide/vue";import{adminColumnPinLabel as C,cycleAdminColumnSide as w,moveAdminColumn as T,orderAdminColumns as E}from"@ug666/admin-core/page/column-layout";var D={class:`admin-column-settings__head`},O={class:`admin-column-settings__list`},k=[`onDrop`],A={key:0,"aria-hidden":`true`},j=c({__name:`AdminColumnSettings`,props:{columns:{},hidden:{},ariaLabel:{default:`列设置`},triggerLabel:{},layout:{}},emits:[`update:hidden`,`update:layout`],setup(c,{emit:j}){let M=c,N=j,P=t(()=>E(M.columns,M.layout?.order??[])),F,I=t(()=>M.columns.filter(e=>e.required||!M.hidden.includes(e.id)).length);function L(e,t){!t&&I.value<=1||N(`update:hidden`,t?M.hidden.filter(t=>t!==e):[...new Set([...M.hidden,e])])}function R(e,t){if(!M.layout||e===t)return;let n=T(P.value.map(e=>e.id),e,t);N(`update:layout`,{...M.layout,order:n})}function z(e,t){F=t,e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t))}function B(e,t){F&&=(e.preventDefault(),R(F,t),void 0)}function V(e,t){if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=P.value[t+(e.key===`ArrowUp`?-1:1)];n&&R(P.value[t].id,n.id)}return(t,T)=>(u(),n(p(_),null,{default:m(()=>[s(p(y),null,{default:m(()=>[s(p(h),{"aria-label":c.ariaLabel,size:c.triggerLabel?`default`:`icon`,title:c.triggerLabel?void 0:c.ariaLabel,type:`button`,variant:`outline`},{default:m(()=>[s(p(S),{size:16,"aria-hidden":`true`}),o(` `+f(c.triggerLabel),1)]),_:1},8,[`aria-label`,`size`,`title`])]),_:1}),s(p(v),{align:`end`,class:`admin-column-settings`,side:`bottom`},{default:m(()=>[a(`div`,D,[T[4]||=a(`strong`,null,`显示列`,-1),s(p(h),{size:`sm`,type:`button`,variant:`text`,onClick:T[0]||=e=>N(`update:hidden`,[])},{default:m(()=>[...T[3]||=[o(`全部显示`,-1)]]),_:1})]),a(`div`,O,[(u(!0),i(e,null,d(P.value,(e,t)=>(u(),i(`div`,{key:e.id,class:`admin-column-settings__row`,onDragover:T[2]||=e=>p(F)&&e.preventDefault(),onDrop:t=>B(t,e.id)},[c.layout?(u(),n(p(h),{key:0,"aria-label":`调整${e.header??e.id}的列顺序`,"aria-keyshortcuts":`ArrowUp ArrowDown`,class:`admin-column-settings__grip`,draggable:`true`,size:`icon-sm`,title:`拖动或按方向键调整列顺序`,type:`button`,variant:`ghost`,onDragstart:t=>z(t,e.id),onDragend:T[1]||=e=>l(F)?F.value=void 0:F=void 0,onKeydown:e=>V(e,t)},{default:m(()=>[s(p(b),{size:14,"aria-hidden":`true`})]),_:1},8,[`aria-label`,`onDragstart`,`onKeydown`])):r(`v-if`,!0),s(p(g),{"model-value":!!e.required||!c.hidden.includes(e.id),disabled:!!e.required||!c.hidden.includes(e.id)&&I.value<=1,label:e.header??e.id,"onUpdate:modelValue":t=>L(e.id,t)},null,8,[`model-value`,`disabled`,`label`,`onUpdate:modelValue`]),c.layout?(u(),n(p(h),{key:1,"aria-label":p(C)(c.layout.fixed[e.id],e.header??e.id),class:`admin-column-settings__pin`,disabled:!e.required&&c.hidden.includes(e.id),size:`sm`,title:p(C)(c.layout.fixed[e.id],e.header??e.id),tone:c.layout.fixed[e.id]?`primary`:`neutral`,type:`button`,variant:`ghost`,onClick:t=>N(`update:layout`,p(w)(c.layout,e.id))},{default:m(()=>[s(p(x),{size:14,"aria-hidden":`true`}),c.layout.fixed[e.id]?(u(),i(`span`,A,f(c.layout.fixed[e.id]===`left`?`左`:`右`),1)):r(`v-if`,!0)]),_:2},1032,[`aria-label`,`disabled`,`title`,`tone`,`onClick`])):r(`v-if`,!0)],40,k))),128))])]),_:1})]),_:1}))}});export{j as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminConfirmAction.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{createBlock as e,createCommentVNode as t,createTextVNode as n,createVNode as r,defineComponent as i,openBlock as a,toDisplayString as o,unref as s,withCtx as c}from"vue";import{UAlert as l,UAlertDescription as u}from"@ug666/ui-vue";import{UConfirmDialog as d}from"@ug666/ui-vue/patterns";var f=i({__name:`AdminConfirmAction`,props:{open:{type:Boolean},title:{},description:{},confirmText:{},loading:{type:Boolean},error:{}},emits:[`update:open`,`confirm`],setup(i,{emit:f}){let p=f;return(f,m)=>(a(),e(s(d),{open:i.open,title:i.title,description:i.description,"confirm-text":i.confirmText,loading:i.loading,"close-on-confirm":!1,variant:`destructive`,onConfirm:m[0]||=e=>p(`confirm`),"onUpdate:open":m[1]||=e=>p(`update:open`,e)},{default:c(()=>[i.error?(a(),e(s(l),{key:0,variant:`destructive`},{default:c(()=>[r(s(u),null,{default:c(()=>[n(o(i.error),1)]),_:1})]),_:1})):t(`v-if`,!0)]),_:1},8,[`open`,`title`,`description`,`confirm-text`,`loading`]))}});export{f as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminDetailPage.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminPage.js";import{Fragment as t,createBlock as n,createElementBlock as r,createElementVNode as i,createSlots as a,createTextVNode as o,createVNode as s,defineComponent as c,openBlock as l,renderList as u,renderSlot as d,toDisplayString as f,unref as p,withCtx as m}from"vue";import{UCard as h,UCardContent as g,UCardHeader as _,UCardTitle as v}from"@ug666/ui-vue";var y={class:`admin-detail-sections`},b={class:`admin-description-list`},x=c({__name:`AdminDetailPage`,props:{title:{},description:{},sections:{}},setup(c){return(x,S)=>(l(),n(e,{title:c.title,description:c.description},a({default:m(()=>[i(`div`,y,[(l(!0),r(t,null,u(c.sections,e=>(l(),n(p(h),{key:e.id},{default:m(()=>[s(p(_),null,{default:m(()=>[s(p(v),null,{default:m(()=>[o(f(e.title),1)]),_:2},1024)]),_:2},1024),s(p(g),{class:`admin-card-content`},{default:m(()=>[i(`dl`,b,[(l(!0),r(t,null,u(e.items,t=>(l(),r(`div`,{key:t.label,class:`admin-description-list__item`},[i(`dt`,null,f(t.label),1),i(`dd`,null,[d(x.$slots,`value-${e.id}-${t.label}`,{},()=>[o(f(t.value??`—`),1)])])]))),128))])]),_:2},1024)]),_:2},1024))),128))])]),_:2},[x.$slots.badge?{name:`badge`,fn:m(()=>[d(x.$slots,`badge`)]),key:`0`}:void 0,x.$slots.actions?{name:`actions`,fn:m(()=>[d(x.$slots,`actions`)]),key:`1`}:void 0]),1032,[`title`,`description`]))}});export{x as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminFormDialog.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{createBlock as e,createElementVNode as t,createTextVNode as n,createVNode as r,defineComponent as i,openBlock as a,renderSlot as o,toDisplayString as s,unref as c,useId as l,withCtx as u,withModifiers as d}from"vue";import{UGButton as f,UGModal as p}from"@ug666/ui-vue";var m=[`id`],h=i({__name:`AdminFormDialog`,props:{open:{type:Boolean},title:{},submitLabel:{},cancelLabel:{default:`取消`},loading:{type:Boolean},disabled:{type:Boolean},closeOnOverlay:{type:Boolean,default:!0},initialFocusSelector:{},size:{}},emits:[`close`,`submit`],setup(i,{emit:h}){let g=i,_=h,v=l();function y(){!g.loading&&!g.disabled&&_(`submit`)}return(l,h)=>(a(),e(c(p),{open:i.open,title:i.title,"close-on-esc":!i.loading,"close-on-overlay":i.closeOnOverlay&&!i.loading,"show-close-button":!i.loading,"initial-focus-selector":i.initialFocusSelector,size:i.size,"onUpdate:open":h[1]||=e=>{!e&&!i.loading&&_(`close`)}},{footer:u(()=>[r(c(f),{disabled:i.loading,type:`button`,variant:`text`,onClick:h[0]||=e=>_(`close`)},{default:u(()=>[n(s(i.cancelLabel),1)]),_:1},8,[`disabled`]),r(c(f),{form:c(v),disabled:i.disabled,loading:i.loading,tone:`primary`,type:`submit`,variant:`solid`},{default:u(()=>[n(s(i.submitLabel),1)]),_:1},8,[`form`,`disabled`,`loading`])]),default:u(()=>[t(`form`,{id:c(v),class:`admin-section-form`,onSubmit:d(y,[`prevent`])},[o(l.$slots,`default`)],40,m)]),_:3},8,[`open`,`title`,`close-on-esc`,`close-on-overlay`,`show-close-button`,`initial-focus-selector`,`size`]))}});export{h as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminFormPage.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminPage.js";import{createBlock as t,createCommentVNode as n,createElementVNode as r,createTextVNode as i,createVNode as a,defineComponent as o,onBeforeUnmount as s,onMounted as c,openBlock as l,ref as u,renderSlot as d,toDisplayString as f,unref as p,withCtx as m,withModifiers as h}from"vue";import{UAlert as g,UAlertDescription as _,UButton as v,UCard as y,UCardContent as b}from"@ug666/ui-vue";import{ArrowLeft as x,Save as S}from"@lucide/vue";import{t as C}from"@ug666/admin-core/i18n";import{UConfirmDialog as w}from"@ug666/ui-vue/patterns";import{onBeforeRouteLeave as T,onBeforeRouteUpdate as E}from"vue-router";var D={class:`admin-form__fields`},O={class:`admin-form__actions`},k=o({__name:`AdminFormPage`,props:{title:{},description:{default:void 0},error:{default:void 0},dirty:{type:Boolean,default:!1},submitting:{type:Boolean,default:!1},submitDisabled:{type:Boolean,default:!1},submitLabel:{default:C(`common.save`)},submitAndReturnLabel:{default:C(`common.saveAndReturn`)},showSubmitAndReturn:{type:Boolean,default:!0}},emits:[`cancel`,`submit`,`submitAndReturn`],setup(o,{emit:C}){let k=o,A=C,j=u(!1),M;function N(e){k.dirty&&(e.preventDefault(),e.returnValue=``)}c(()=>window.addEventListener(`beforeunload`,N)),s(()=>window.removeEventListener(`beforeunload`,N));function P(){return!k.dirty||(j.value=!0,new Promise(e=>{M=e}))}T(P),E((e,t)=>e.path===t.path||P());function F(e){j.value=!1,M?.(e),M=void 0}return(s,c)=>(l(),t(e,{title:o.title,description:o.description},{default:m(()=>[a(p(y),{class:`admin-form-panel`},{default:m(()=>[a(p(b),{class:`admin-card-content`},{default:m(()=>[r(`form`,{class:`admin-form`,onSubmit:c[2]||=h(e=>A(`submit`),[`prevent`])},[o.error?(l(),t(p(g),{key:0,variant:`destructive`},{default:m(()=>[a(p(_),null,{default:m(()=>[i(f(o.error),1)]),_:1})]),_:1})):n(`v-if`,!0),r(`div`,D,[d(s.$slots,`default`)]),r(`div`,O,[a(p(v),{disabled:o.submitting,type:`button`,variant:`default`,onClick:c[0]||=e=>A(`cancel`)},{default:m(()=>[a(p(x),{size:16,"aria-hidden":`true`}),c[6]||=i(`返回 `,-1)]),_:1},8,[`disabled`]),a(p(v),{loading:o.submitting,disabled:o.submitDisabled,tone:`primary`,type:`submit`,variant:`solid`},{default:m(()=>[a(p(S),{size:16,"aria-hidden":`true`}),i(f(o.submitLabel),1)]),_:1},8,[`loading`,`disabled`]),o.showSubmitAndReturn?(l(),t(p(v),{key:0,disabled:o.submitting||o.submitDisabled,type:`button`,variant:`default`,onClick:c[1]||=e=>A(`submitAndReturn`)},{default:m(()=>[i(f(o.submitAndReturnLabel),1)]),_:1},8,[`disabled`])):n(`v-if`,!0)])],32)]),_:3})]),_:3}),a(p(w),{open:j.value,title:`确认离开当前页面?`,description:`当前页面存在尚未保存的修改,离开后这些内容将丢失。`,"confirm-text":`放弃修改`,"close-on-confirm":!1,variant:`destructive`,onCancel:c[3]||=e=>F(!1),onConfirm:c[4]||=e=>F(!0),"onUpdate:open":c[5]||=e=>!e&&F(!1)},null,8,[`open`])]),_:3},8,[`title`,`description`]))}});export{k as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminListPage.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminPage.js";import{createBlock as t,createCommentVNode as n,createElementBlock as r,createElementVNode as i,defineComponent as a,openBlock as o,renderSlot as s,toDisplayString as c,withCtx as l}from"vue";var u=[`id`,`hidden`],d={class:`admin-list-search`},f={class:`admin-list-panel`},p={class:`admin-list-header`},m={class:`admin-list-header__title`},h={key:0,class:`admin-list-header__actions`},g={key:0,class:`admin-list-header__tools`},_={key:0,class:`admin-list-actions`},v={class:`admin-list-actions__start`},y={class:`admin-list-content`},b={key:1,class:`admin-list-footer`},x=a({__name:`AdminListPage`,props:{title:{},description:{},searchId:{},searchHidden:{type:Boolean}},setup(a){return(x,S)=>(o(),t(e,{title:a.title,description:a.description,"visually-hidden-header":``,class:`admin-page--list`},{default:l(()=>[x.$slots.search?(o(),r(`div`,{key:0,id:a.searchId,hidden:a.searchHidden,class:`admin-list-search-panel`},[i(`div`,d,[s(x.$slots,`search`)])],8,u)):n(`v-if`,!0),i(`div`,f,[i(`div`,p,[i(`h2`,m,c(a.title),1),x.$slots.actions||x.$slots.toolbarEnd?(o(),r(`div`,h,[s(x.$slots,`actions`),x.$slots.toolbarEnd?(o(),r(`div`,g,[s(x.$slots,`toolbarEnd`)])):n(`v-if`,!0)])):n(`v-if`,!0)]),s(x.$slots,`summary`),x.$slots.toolbarStart?(o(),r(`div`,_,[i(`div`,v,[s(x.$slots,`toolbarStart`)])])):n(`v-if`,!0),i(`div`,y,[s(x.$slots,`default`)]),x.$slots.footer?(o(),r(`div`,b,[s(x.$slots,`footer`)])):n(`v-if`,!0)])]),_:3},8,[`title`,`description`]))}});export{x as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminPage.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{createBlock as e,createElementBlock as t,createElementVNode as n,createSlots as r,defineComponent as i,openBlock as a,renderSlot as o,toDisplayString as s,unref as c,withCtx as l}from"vue";import{UPageHeader as u}from"@ug666/ui-vue/patterns";var d={class:`admin-page`},f={key:0,class:`sr-only`},p={class:`admin-page__title`},m=i({__name:`AdminPage`,props:{title:{},description:{},meta:{},visuallyHiddenHeader:{type:Boolean,default:!1}},setup(i){return(m,h)=>(a(),t(`div`,d,[i.visuallyHiddenHeader?(a(),t(`h1`,f,s(i.title),1)):(a(),e(c(u),{key:1,title:i.title,description:i.description,meta:i.meta},r({title:l(()=>[n(`span`,p,s(i.title),1)]),_:2},[m.$slots.badge?{name:`badge`,fn:l(()=>[o(m.$slots,`badge`)]),key:`0`}:void 0,m.$slots.actions?{name:`actions`,fn:l(()=>[o(m.$slots,`actions`)]),key:`1`}:void 0]),1032,[`title`,`description`,`meta`])),o(m.$slots,`default`)]))}});export{m as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminSearchField.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{createBlock as e,createTextVNode as t,createVNode as n,defineComponent as r,normalizeClass as i,normalizeStyle as a,openBlock as o,renderSlot as s,toDisplayString as c,unref as l,withCtx as u}from"vue";import{UGFormControl as d,UGFormField as f,UGFormItem as p,UGFormLabel as m}from"@ug666/ui-vue";var h=r({__name:`AdminSearchField`,props:{name:{},label:{},labelFor:{},class:{},itemClass:{},itemStyle:{}},setup(r){return(h,g)=>(o(),e(l(f),{name:r.name,class:i([`admin-search-field`,h.$props.class].filter(Boolean).join(` `))},{default:u(()=>[n(l(p),{class:i(r.itemClass),style:a(r.itemStyle)},{default:u(()=>[n(l(m),{for:r.labelFor},{default:u(()=>[t(c(r.label),1)]),_:1},8,[`for`]),n(l(d),null,{default:u(()=>[s(h.$slots,`default`)]),_:3})]),_:3},8,[`class`,`style`])]),_:3},8,[`name`,`class`]))}});export{h as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminSearchForm.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{createBlock as e,createCommentVNode as t,createElementBlock as n,createElementVNode as r,createTextVNode as i,createVNode as a,defineComponent as o,openBlock as s,ref as c,renderSlot as l,toDisplayString as u,unref as d,useId as f,withCtx as p,withModifiers as m}from"vue";import{UButton as h,UGForm as g}from"@ug666/ui-vue";import{ChevronDown as _,ChevronUp as v,RotateCcw as y,Search as b}from"@lucide/vue";var x={class:`admin-search-form__fields`},S=[`id`,`hidden`],C={class:`admin-search-form__actions`},w=o({__name:`AdminSearchForm`,props:{loading:{type:Boolean},labelWidth:{default:0},expandLabel:{default:`展开`},collapseLabel:{default:`收起`}},emits:[`reset`,`submit`],setup(o,{emit:w}){let T=w,E=c(!1),D=f();return(c,f)=>(s(),e(d(g),{class:`admin-search-form`,layout:`horizontal`,"label-position":`right`,"label-width":o.labelWidth,size:`default`,onSubmit:f[2]||=m(e=>T(`submit`),[`prevent`])},{default:p(()=>[r(`div`,x,[l(c.$slots,`default`),c.$slots.expanded?(s(),n(`div`,{key:0,id:d(D),class:`admin-search-form__expanded`,hidden:!E.value},[l(c.$slots,`expanded`)],8,S)):t(`v-if`,!0)]),r(`div`,C,[c.$slots.expanded?(s(),e(d(h),{key:0,"aria-expanded":E.value,"aria-controls":d(D),tone:`neutral`,type:`button`,variant:`text`,onClick:f[0]||=e=>E.value=!E.value},{default:p(()=>[E.value?(s(),e(d(v),{key:0,size:16,"aria-hidden":`true`})):(s(),e(d(_),{key:1,size:16,"aria-hidden":`true`})),i(` `+u(E.value?o.collapseLabel:o.expandLabel),1)]),_:1},8,[`aria-expanded`,`aria-controls`])):t(`v-if`,!0),a(d(h),{loading:o.loading,tone:`primary`,type:`submit`,variant:`outline`},{default:p(()=>[a(d(b),{size:16,"aria-hidden":`true`}),f[3]||=i(`查询 `,-1)]),_:1},8,[`loading`]),a(d(h),{tone:`neutral`,type:`button`,variant:`outline`,onClick:f[1]||=e=>T(`reset`)},{default:p(()=>[a(d(y),{size:16,"aria-hidden":`true`}),f[4]||=i(`重置 `,-1)]),_:1})])]),_:3},8,[`label-width`]))}});export{w as default};
@@ -0,0 +1 @@
1
+ import e from"./AdminTabContextMenu.vue_vue_type_script_setup_true_lang.js";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import{createBlock as e,createTextVNode as t,createVNode as n,defineComponent as r,openBlock as i,renderSlot as a,unref as o,withCtx as s,withKeys as c}from"vue";import{UGContextMenu as l,UGContextMenuContent as u,UGContextMenuItem as d,UGContextMenuTrigger as f}from"@ug666/ui-vue";var p=r({__name:`AdminTabContextMenu`,props:{tabs:{}},emits:[`close-others`],setup(r,{emit:p}){let m=r,h=p,g=null,_;function v(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-ug="app-tabs"] [data-ug-slot="item"]`),n=t?.dataset.value;!n||!m.tabs.some(e=>e.id!==n&&e.closable)?e.stopPropagation():(_=n,g=t?.querySelector(`[data-ug-slot="trigger"]`)??null)}function y(e){(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)&&v(e)}function b(){let e=g;requestAnimationFrame(()=>e?.focus({preventScroll:!0}))}function x(){_&&h(`close-others`,_),b()}return(r,p)=>(i(),e(o(l),{class:`admin-tab-menu`,onContextmenuCapture:v,onKeydownCapture:y},{default:s(()=>[n(o(f),{class:`admin-tab-menu__trigger`},{default:s(()=>[a(r.$slots,`default`)]),_:3}),n(o(u),null,{default:s(()=>[n(o(d),{onClick:x,onKeydown:c(b,[`esc`])},{default:s(()=>[...p[0]||=[t(`关闭其他页签`,-1)]]),_:1})]),_:1})]),_:3}))}});export{p as default};
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@ug666/admin-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.2",
4
+ "description": "UG Admin Vue 渲染层:AdminPage/AdminListPage/AdminFormPage/AdminDetailPage 等页面壳与组合模式",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./src/index.ts",
9
+ "import": "./dist/index.js"
10
+ },
11
+ "./patterns/*.vue": {
12
+ "types": "./src/patterns/*.vue",
13
+ "default": "./dist/patterns/*.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src"
19
+ ],
20
+ "dependencies": {
21
+ "vue-router": "^4.6.4"
22
+ },
23
+ "license": "MIT",
24
+ "main": "./dist/index.js",
25
+ "types": "./src/index.ts",
26
+ "scripts": {
27
+ "build": "bun run scripts/packages/build-packages.ts"
28
+ },
29
+ "peerDependencies": {
30
+ "@ug666/admin-core": "^0.1.0-0",
31
+ "@ug666/ui-vue": "^0.3.0-0",
32
+ "vue": "^3.5.0",
33
+ "@lucide/vue": "*"
34
+ },
35
+ "devDependencies": {
36
+ "@ug666/admin-core": "file:../admin-core",
37
+ "@ug666/ui-vue": "0.3.0-beta.3",
38
+ "vue": "3.5.45",
39
+ "@lucide/vue": "^1.27.0"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/uguang2003/ug-admin.git",
44
+ "directory": "packages/admin-vue"
45
+ }
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export { default as AdminColumnSettings } from "./patterns/AdminColumnSettings.vue";
2
+ export { default as AdminConfirmAction } from "./patterns/AdminConfirmAction.vue";
3
+ export { default as AdminDetailPage } from "./patterns/AdminDetailPage.vue";
4
+ export { default as AdminFormDialog } from "./patterns/AdminFormDialog.vue";
5
+ export { default as AdminFormPage } from "./patterns/AdminFormPage.vue";
6
+ export { default as AdminListPage } from "./patterns/AdminListPage.vue";
7
+ export { default as AdminPage } from "./patterns/AdminPage.vue";
8
+ export { default as AdminSearchField } from "./patterns/AdminSearchField.vue";
9
+ export { default as AdminSearchForm } from "./patterns/AdminSearchForm.vue";
10
+ export { default as AdminTabContextMenu } from "./patterns/AdminTabContextMenu.vue";
@@ -0,0 +1,107 @@
1
+ <script setup lang="ts">
2
+ /** @description: 控制列表列的显隐、顺序和固定方向。 */
3
+ import { GripVertical, Pin, Settings2 } from "@lucide/vue";
4
+ import {
5
+ type AdminColumnLayout,
6
+ adminColumnPinLabel,
7
+ cycleAdminColumnSide,
8
+ moveAdminColumn,
9
+ orderAdminColumns,
10
+ } from "@ug666/admin-core/page/column-layout";
11
+ import { UGButton, UGCheckbox, UGPopover, UGPopoverContent, UGPopoverTrigger } from "@ug666/ui-vue";
12
+ import { computed } from "vue";
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ columns: readonly { id: string; header?: string; required?: boolean }[];
17
+ hidden: readonly string[];
18
+ ariaLabel?: string;
19
+ triggerLabel?: string;
20
+ layout?: AdminColumnLayout;
21
+ }>(),
22
+ { ariaLabel: "列设置" },
23
+ );
24
+ const emit = defineEmits<{
25
+ "update:hidden": [hidden: string[]];
26
+ "update:layout": [layout: AdminColumnLayout];
27
+ }>();
28
+ const ordered = computed(() => orderAdminColumns(props.columns, props.layout?.order ?? []));
29
+ let dragged: string | undefined;
30
+ const visibleCount = computed(
31
+ () =>
32
+ props.columns.filter((column) => column.required || !props.hidden.includes(column.id)).length,
33
+ );
34
+
35
+ function toggle(id: string, visible: boolean) {
36
+ if (!visible && visibleCount.value <= 1) return;
37
+ emit(
38
+ "update:hidden",
39
+ visible ? props.hidden.filter((item) => item !== id) : [...new Set([...props.hidden, id])],
40
+ );
41
+ }
42
+
43
+ function move(id: string, target: string) {
44
+ if (!props.layout || id === target) return;
45
+ const order = moveAdminColumn(
46
+ ordered.value.map((column) => column.id),
47
+ id,
48
+ target,
49
+ );
50
+ emit("update:layout", { ...props.layout, order });
51
+ }
52
+
53
+ function dragStart(event: DragEvent, id: string) {
54
+ dragged = id;
55
+ if (!event.dataTransfer) return;
56
+ event.dataTransfer.effectAllowed = "move";
57
+ event.dataTransfer.setData("text/plain", id);
58
+ }
59
+
60
+ function drop(event: DragEvent, id: string) {
61
+ if (!dragged) return;
62
+ event.preventDefault();
63
+ move(dragged, id);
64
+ dragged = undefined;
65
+ }
66
+
67
+ function moveWithKey(event: KeyboardEvent, index: number) {
68
+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
69
+ event.preventDefault();
70
+ const target = ordered.value[index + (event.key === "ArrowUp" ? -1 : 1)];
71
+ if (target) move(ordered.value[index].id, target.id);
72
+ }
73
+ </script>
74
+
75
+ <template>
76
+ <UGPopover>
77
+ <UGPopoverTrigger>
78
+ <UGButton :aria-label="ariaLabel" :size="triggerLabel ? 'default' : 'icon'" :title="triggerLabel ? undefined : ariaLabel" type="button" variant="outline">
79
+ <Settings2 :size="16" aria-hidden="true" />
80
+ {{ triggerLabel }}
81
+ </UGButton>
82
+ </UGPopoverTrigger>
83
+ <UGPopoverContent align="end" class="admin-column-settings" side="bottom">
84
+ <div class="admin-column-settings__head">
85
+ <strong>显示列</strong>
86
+ <UGButton size="sm" type="button" variant="text" @click="emit('update:hidden', [])">全部显示</UGButton>
87
+ </div>
88
+ <div class="admin-column-settings__list">
89
+ <div v-for="(column, index) in ordered" :key="column.id" class="admin-column-settings__row" @dragover="dragged && $event.preventDefault()" @drop="drop($event, column.id)">
90
+ <UGButton v-if="layout" :aria-label="`调整${column.header ?? column.id}的列顺序`" aria-keyshortcuts="ArrowUp ArrowDown" class="admin-column-settings__grip" draggable="true" size="icon-sm" title="拖动或按方向键调整列顺序" type="button" variant="ghost" @dragstart="dragStart($event, column.id)" @dragend="dragged = undefined" @keydown="moveWithKey($event, index)">
91
+ <GripVertical :size="14" aria-hidden="true" />
92
+ </UGButton>
93
+ <UGCheckbox
94
+ :model-value="Boolean(column.required) || !hidden.includes(column.id)"
95
+ :disabled="Boolean(column.required) || (!hidden.includes(column.id) && visibleCount <= 1)"
96
+ :label="column.header ?? column.id"
97
+ @update:model-value="(checked) => toggle(column.id, checked)"
98
+ />
99
+ <UGButton v-if="layout" :aria-label="adminColumnPinLabel(layout.fixed[column.id], column.header ?? column.id)" class="admin-column-settings__pin" :disabled="!column.required && hidden.includes(column.id)" size="sm" :title="adminColumnPinLabel(layout.fixed[column.id], column.header ?? column.id)" :tone="layout.fixed[column.id] ? 'primary' : 'neutral'" type="button" variant="ghost" @click="emit('update:layout', cycleAdminColumnSide(layout, column.id))">
100
+ <Pin :size="14" aria-hidden="true" />
101
+ <span v-if="layout.fixed[column.id]" aria-hidden="true">{{ layout.fixed[column.id] === 'left' ? '左' : '右' }}</span>
102
+ </UGButton>
103
+ </div>
104
+ </div>
105
+ </UGPopoverContent>
106
+ </UGPopover>
107
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import { UAlert, UAlertDescription } from "@ug666/ui-vue";
3
+ import { UConfirmDialog } from "@ug666/ui-vue/patterns";
4
+
5
+ defineProps<{
6
+ open: boolean;
7
+ title: string;
8
+ description: string;
9
+ confirmText: string;
10
+ loading?: boolean;
11
+ error?: string;
12
+ }>();
13
+ const emit = defineEmits<{ "update:open": [open: boolean]; confirm: [] }>();
14
+ </script>
15
+
16
+ <template>
17
+ <UConfirmDialog
18
+ :open="open"
19
+ :title="title"
20
+ :description="description"
21
+ :confirm-text="confirmText"
22
+ :loading="loading"
23
+ :close-on-confirm="false"
24
+ variant="destructive"
25
+ @confirm="emit('confirm')"
26
+ @update:open="emit('update:open', $event)"
27
+ >
28
+ <UAlert v-if="error" variant="destructive"><UAlertDescription>{{ error }}</UAlertDescription></UAlert>
29
+ </UConfirmDialog>
30
+ </template>
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import { UCard, UCardContent, UCardHeader, UCardTitle } from "@ug666/ui-vue";
3
+ import AdminPage from "./AdminPage.vue";
4
+
5
+ export interface AdminDetailItem {
6
+ label: string;
7
+ value?: string;
8
+ }
9
+ export interface AdminDetailSection {
10
+ id: string;
11
+ title: string;
12
+ items: AdminDetailItem[];
13
+ }
14
+ defineProps<{ title: string; description?: string; sections: AdminDetailSection[] }>();
15
+ </script>
16
+
17
+ <template>
18
+ <AdminPage :title="title" :description="description">
19
+ <template v-if="$slots.badge" #badge><slot name="badge" /></template>
20
+ <template v-if="$slots.actions" #actions><slot name="actions" /></template>
21
+ <div class="admin-detail-sections">
22
+ <UCard v-for="section in sections" :key="section.id">
23
+ <UCardHeader><UCardTitle>{{ section.title }}</UCardTitle></UCardHeader>
24
+ <UCardContent class="admin-card-content">
25
+ <dl class="admin-description-list">
26
+ <div v-for="item in section.items" :key="item.label" class="admin-description-list__item">
27
+ <dt>{{ item.label }}</dt>
28
+ <dd><slot :name="`value-${section.id}-${item.label}`">{{ item.value ?? "—" }}</slot></dd>
29
+ </div>
30
+ </dl>
31
+ </UCardContent>
32
+ </UCard>
33
+ </div>
34
+ </AdminPage>
35
+ </template>
@@ -0,0 +1,47 @@
1
+ <script setup lang="ts">
2
+ /** @description: 列表页新增和编辑的表单弹窗。 */
3
+ import { UGButton, UGModal } from "@ug666/ui-vue";
4
+ import { useId } from "vue";
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ open: boolean;
9
+ title: string;
10
+ submitLabel: string;
11
+ cancelLabel?: string;
12
+ loading?: boolean;
13
+ disabled?: boolean;
14
+ closeOnOverlay?: boolean;
15
+ initialFocusSelector?: string;
16
+ size?: "sm" | "md" | "lg";
17
+ }>(),
18
+ { cancelLabel: "取消", closeOnOverlay: true },
19
+ );
20
+ const emit = defineEmits<{ close: []; submit: [] }>();
21
+ const formId = useId();
22
+
23
+ function submit() {
24
+ if (!props.loading && !props.disabled) emit("submit");
25
+ }
26
+ </script>
27
+
28
+ <template>
29
+ <UGModal
30
+ :open="open"
31
+ :title="title"
32
+ :close-on-esc="!loading"
33
+ :close-on-overlay="closeOnOverlay && !loading"
34
+ :show-close-button="!loading"
35
+ :initial-focus-selector="initialFocusSelector"
36
+ :size="size"
37
+ @update:open="(value) => { if (!value && !loading) emit('close') }"
38
+ >
39
+ <form :id="formId" class="admin-section-form" @submit.prevent="submit"><slot /></form>
40
+ <template #footer>
41
+ <UGButton :disabled="loading" type="button" variant="text" @click="emit('close')">{{ cancelLabel }}</UGButton>
42
+ <UGButton :form="formId" :disabled="disabled" :loading="loading" tone="primary" type="submit" variant="solid">
43
+ {{ submitLabel }}
44
+ </UGButton>
45
+ </template>
46
+ </UGModal>
47
+ </template>
@@ -0,0 +1,95 @@
1
+ <script setup lang="ts">
2
+ import { UAlert, UAlertDescription, UButton, UCard, UCardContent } from "@ug666/ui-vue";
3
+ import { t } from "@ug666/admin-core/i18n";
4
+ import { UConfirmDialog } from "@ug666/ui-vue/patterns";
5
+ import { ArrowLeft, Save } from "@lucide/vue";
6
+ import { onBeforeUnmount, onMounted, ref } from "vue";
7
+ import { onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
8
+ import AdminPage from "./AdminPage.vue";
9
+
10
+ const props = withDefaults(
11
+ defineProps<{
12
+ title: string;
13
+ description?: string;
14
+ error?: string;
15
+ dirty?: boolean;
16
+ submitting?: boolean;
17
+ submitDisabled?: boolean;
18
+ submitLabel?: string;
19
+ submitAndReturnLabel?: string;
20
+ showSubmitAndReturn?: boolean;
21
+ }>(),
22
+ {
23
+ description: undefined,
24
+ error: undefined,
25
+ dirty: false,
26
+ submitting: false,
27
+ submitDisabled: false,
28
+ submitLabel: t("common.save"),
29
+ submitAndReturnLabel: t("common.saveAndReturn"),
30
+ showSubmitAndReturn: true,
31
+ },
32
+ );
33
+ const emit = defineEmits<{ cancel: []; submit: []; submitAndReturn: [] }>();
34
+ const leaving = ref(false);
35
+ let resolveLeave: ((allowed: boolean) => void) | undefined;
36
+
37
+ function handleBeforeUnload(event: BeforeUnloadEvent) {
38
+ if (!props.dirty) return;
39
+ event.preventDefault();
40
+ event.returnValue = "";
41
+ }
42
+
43
+ onMounted(() => window.addEventListener("beforeunload", handleBeforeUnload));
44
+ onBeforeUnmount(() => window.removeEventListener("beforeunload", handleBeforeUnload));
45
+ function requestLeave() {
46
+ if (!props.dirty) return true;
47
+ leaving.value = true;
48
+ return new Promise<boolean>((resolve) => {
49
+ resolveLeave = resolve;
50
+ });
51
+ }
52
+ onBeforeRouteLeave(requestLeave);
53
+ onBeforeRouteUpdate((to, from) => (to.path === from.path ? true : requestLeave()));
54
+
55
+ function finishLeave(allowed: boolean) {
56
+ leaving.value = false;
57
+ resolveLeave?.(allowed);
58
+ resolveLeave = undefined;
59
+ }
60
+ </script>
61
+
62
+ <template>
63
+ <AdminPage :title="title" :description="description">
64
+ <UCard class="admin-form-panel">
65
+ <UCardContent class="admin-card-content">
66
+ <form class="admin-form" @submit.prevent="emit('submit')">
67
+ <UAlert v-if="error" variant="destructive"><UAlertDescription>{{ error }}</UAlertDescription></UAlert>
68
+ <div class="admin-form__fields"><slot /></div>
69
+ <div class="admin-form__actions">
70
+ <UButton :disabled="submitting" type="button" variant="default" @click="emit('cancel')">
71
+ <ArrowLeft :size="16" aria-hidden="true" />返回
72
+ </UButton>
73
+ <UButton :loading="submitting" :disabled="submitDisabled" tone="primary" type="submit" variant="solid">
74
+ <Save :size="16" aria-hidden="true" />{{ submitLabel }}
75
+ </UButton>
76
+ <UButton v-if="showSubmitAndReturn" :disabled="submitting || submitDisabled" type="button" variant="default" @click="emit('submitAndReturn')">
77
+ {{ submitAndReturnLabel }}
78
+ </UButton>
79
+ </div>
80
+ </form>
81
+ </UCardContent>
82
+ </UCard>
83
+ <UConfirmDialog
84
+ :open="leaving"
85
+ title="确认离开当前页面?"
86
+ description="当前页面存在尚未保存的修改,离开后这些内容将丢失。"
87
+ confirm-text="放弃修改"
88
+ :close-on-confirm="false"
89
+ variant="destructive"
90
+ @cancel="finishLeave(false)"
91
+ @confirm="finishLeave(true)"
92
+ @update:open="(open) => !open && finishLeave(false)"
93
+ />
94
+ </AdminPage>
95
+ </template>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import AdminPage from "./AdminPage.vue";
3
+
4
+ defineProps<{
5
+ title: string;
6
+ description?: string;
7
+ searchId?: string;
8
+ searchHidden?: boolean;
9
+ }>();
10
+ </script>
11
+
12
+ <template>
13
+ <AdminPage :title="title" :description="description" visually-hidden-header class="admin-page--list">
14
+ <div v-if="$slots.search" :id="searchId" :hidden="searchHidden" class="admin-list-search-panel">
15
+ <div class="admin-list-search"><slot name="search" /></div>
16
+ </div>
17
+ <div class="admin-list-panel">
18
+ <div class="admin-list-header">
19
+ <h2 class="admin-list-header__title">{{ title }}</h2>
20
+ <div v-if="$slots.actions || $slots.toolbarEnd" class="admin-list-header__actions">
21
+ <slot name="actions" />
22
+ <div v-if="$slots.toolbarEnd" class="admin-list-header__tools"><slot name="toolbarEnd" /></div>
23
+ </div>
24
+ </div>
25
+ <slot name="summary" />
26
+ <div v-if="$slots.toolbarStart" class="admin-list-actions">
27
+ <div class="admin-list-actions__start"><slot name="toolbarStart" /></div>
28
+ </div>
29
+ <div class="admin-list-content"><slot /></div>
30
+ <div v-if="$slots.footer" class="admin-list-footer"><slot name="footer" /></div>
31
+ </div>
32
+ </AdminPage>
33
+ </template>
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ import { UPageHeader } from "@ug666/ui-vue/patterns";
3
+
4
+ withDefaults(
5
+ defineProps<{
6
+ title: string;
7
+ description?: string;
8
+ meta?: string;
9
+ visuallyHiddenHeader?: boolean;
10
+ }>(),
11
+ {
12
+ visuallyHiddenHeader: false,
13
+ },
14
+ );
15
+ </script>
16
+
17
+ <template>
18
+ <div class="admin-page">
19
+ <h1 v-if="visuallyHiddenHeader" class="sr-only">{{ title }}</h1>
20
+ <UPageHeader v-else :title="title" :description="description" :meta="meta">
21
+ <template #title><span class="admin-page__title">{{ title }}</span></template>
22
+ <template v-if="$slots.badge" #badge><slot name="badge" /></template>
23
+ <template v-if="$slots.actions" #actions><slot name="actions" /></template>
24
+ </UPageHeader>
25
+ <slot />
26
+ </div>
27
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ import { UGFormControl, UGFormField, UGFormItem, UGFormLabel } from "@ug666/ui-vue";
3
+ import type { CSSProperties } from "vue";
4
+
5
+ defineProps<{
6
+ name: string;
7
+ label: string;
8
+ labelFor?: string;
9
+ class?: string;
10
+ itemClass?: string;
11
+ itemStyle?: CSSProperties;
12
+ }>();
13
+ </script>
14
+
15
+ <template>
16
+ <UGFormField :name="name" :class="['admin-search-field', $props.class].filter(Boolean).join(' ')">
17
+ <UGFormItem :class="itemClass" :style="itemStyle">
18
+ <UGFormLabel :for="labelFor">{{ label }}</UGFormLabel>
19
+ <UGFormControl><slot /></UGFormControl>
20
+ </UGFormItem>
21
+ </UGFormField>
22
+ </template>
@@ -0,0 +1,52 @@
1
+ <script setup lang="ts">
2
+ import { UButton, UGForm } from "@ug666/ui-vue";
3
+ import { ChevronDown, ChevronUp, RotateCcw, Search } from "@lucide/vue";
4
+ import { ref, useId } from "vue";
5
+
6
+ withDefaults(
7
+ defineProps<{
8
+ loading?: boolean;
9
+ labelWidth?: string | number;
10
+ expandLabel?: string;
11
+ collapseLabel?: string;
12
+ }>(),
13
+ {
14
+ labelWidth: 0,
15
+ expandLabel: "展开",
16
+ collapseLabel: "收起",
17
+ },
18
+ );
19
+ const emit = defineEmits<{ reset: []; submit: [] }>();
20
+ const expanded = ref(false);
21
+ const expandedId = useId();
22
+ </script>
23
+
24
+ <template>
25
+ <UGForm class="admin-search-form" layout="horizontal" label-position="right" :label-width="labelWidth" size="default" @submit.prevent="emit('submit')">
26
+ <div class="admin-search-form__fields">
27
+ <slot />
28
+ <div v-if="$slots.expanded" :id="expandedId" class="admin-search-form__expanded" :hidden="!expanded"><slot name="expanded" /></div>
29
+ </div>
30
+ <div class="admin-search-form__actions">
31
+ <UButton
32
+ v-if="$slots.expanded"
33
+ :aria-expanded="expanded"
34
+ :aria-controls="expandedId"
35
+ tone="neutral"
36
+ type="button"
37
+ variant="text"
38
+ @click="expanded = !expanded"
39
+ >
40
+ <ChevronUp v-if="expanded" :size="16" aria-hidden="true" />
41
+ <ChevronDown v-else :size="16" aria-hidden="true" />
42
+ {{ expanded ? collapseLabel : expandLabel }}
43
+ </UButton>
44
+ <UButton :loading="loading" tone="primary" type="submit" variant="outline">
45
+ <Search :size="16" aria-hidden="true" />查询
46
+ </UButton>
47
+ <UButton tone="neutral" type="button" variant="outline" @click="emit('reset')">
48
+ <RotateCcw :size="16" aria-hidden="true" />重置
49
+ </UButton>
50
+ </div>
51
+ </UGForm>
52
+ </template>
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ /** @description: 在 UG 页签条上提供关闭其他页签的菜单。 */
3
+ import type { AdminAppTab } from "@ug666/admin-core/routing/app-tabs";
4
+ import {
5
+ UGContextMenu,
6
+ UGContextMenuContent,
7
+ UGContextMenuItem,
8
+ UGContextMenuTrigger,
9
+ } from "@ug666/ui-vue";
10
+
11
+ const props = defineProps<{ tabs: readonly AdminAppTab[] }>();
12
+ const emit = defineEmits<{ "close-others": [tabId: string] }>();
13
+ let trigger: HTMLElement | null = null;
14
+ let tabId: string | undefined;
15
+
16
+ function prepare(event: Event) {
17
+ if (!(event.target instanceof Element)) return;
18
+ const item = event.target.closest<HTMLElement>('[data-ug="app-tabs"] [data-ug-slot="item"]');
19
+ const value = item?.dataset.value;
20
+ if (!value || !props.tabs.some((tab) => tab.id !== value && tab.closable)) {
21
+ event.stopPropagation();
22
+ return;
23
+ }
24
+ tabId = value;
25
+ trigger = item?.querySelector<HTMLElement>('[data-ug-slot="trigger"]') ?? null;
26
+ }
27
+
28
+ function prepareKeyboard(event: KeyboardEvent) {
29
+ if (event.key === "ContextMenu" || (event.shiftKey && event.key === "F10")) prepare(event);
30
+ }
31
+
32
+ function restoreFocus() {
33
+ const target = trigger;
34
+ requestAnimationFrame(() => target?.focus({ preventScroll: true }));
35
+ }
36
+
37
+ function closeOthers() {
38
+ if (tabId) emit("close-others", tabId);
39
+ restoreFocus();
40
+ }
41
+ </script>
42
+
43
+ <template>
44
+ <UGContextMenu class="admin-tab-menu" @contextmenu.capture="prepare" @keydown.capture="prepareKeyboard">
45
+ <UGContextMenuTrigger class="admin-tab-menu__trigger"><slot /></UGContextMenuTrigger>
46
+ <UGContextMenuContent>
47
+ <UGContextMenuItem @click="closeOthers" @keydown.esc="restoreFocus">关闭其他页签</UGContextMenuItem>
48
+ </UGContextMenuContent>
49
+ </UGContextMenu>
50
+ </template>
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.