@ug666/admin-react 0.1.0-beta.0 → 0.1.0-beta.3
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/LICENSE +21 -0
- package/dist/AdminColumnSettings-1xerrrqm.js +2 -0
- package/dist/AdminColumnSettings-247f7yan.js +2 -0
- package/dist/AdminColumnSettings-4a6ajtjk.js +2 -0
- package/dist/AdminColumnSettings-a6913hy9.js +2 -0
- package/dist/AdminColumnSettings-aqnrn2jc.js +2 -0
- package/dist/AdminColumnSettings-fb9zzqec.js +2 -0
- package/dist/AdminColumnSettings-h570338r.js +2 -0
- package/dist/AdminColumnSettings-mj5py2kd.js +2 -0
- package/dist/AdminColumnSettings-s1mddwde.js +2 -0
- package/dist/index.js +1 -28
- package/dist/patterns/AdminColumnSettings.js +1 -0
- package/dist/patterns/AdminConfirmAction.js +1 -6
- package/dist/patterns/AdminDetailPage.js +1 -7
- package/dist/patterns/AdminFormDialog.js +1 -0
- package/dist/patterns/AdminFormPage.js +1 -7
- package/dist/patterns/AdminListPage.js +1 -7
- package/dist/patterns/AdminPage.js +1 -6
- package/dist/patterns/AdminSearchForm.js +1 -8
- package/dist/patterns/AdminTabContextMenu.js +1 -0
- package/package.json +8 -3
- package/src/index.ts +3 -0
- package/src/patterns/AdminColumnSettings.tsx +168 -0
- package/src/patterns/AdminFormDialog.tsx +96 -0
- package/src/patterns/AdminListPage.tsx +25 -14
- package/src/patterns/AdminPage.tsx +6 -2
- package/src/patterns/AdminSearchForm.tsx +3 -3
- package/src/patterns/AdminTabContextMenu.tsx +67 -0
- package/dist/index-3dcgfy6t.js +0 -131
- package/dist/index-4tstw263.js +0 -43
- package/dist/index-aqqcc4wq.js +0 -34
- package/dist/index-keve3ryw.js +0 -39
- package/dist/index-nyrhj7se.js +0 -63
- package/dist/index-zt432pkz.js +0 -125
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.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{UGPageHeader as g}from"@ug666/ui-react/patterns";import{jsx as a,jsxs as n,Fragment as f}from"react/jsx-runtime";function e({className:d,title:o,description:s,showDescription:c=!1,badge:r,meta:p,primaryAction:t,secondaryActions:i,visuallyHiddenHeader:m=!1,children:l}){let N=i||t?n(f,{children:[i,t]}):void 0;return n("div",{className:d?`admin-page ${d}`:"admin-page",children:[m?a("h1",{className:"sr-only",children:o}):a(g,{actions:N,badge:r,description:c?s:void 0,meta:p,title:a("span",{className:"admin-page__title",children:o})}),l]})}
|
|
2
|
+
export{e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e}from"./AdminColumnSettings-1xerrrqm.js";import{t as u}from"@ug666/admin-core/i18n";import{UGAlert as h,UGAlertDescription as B,UGButton as l,UGCard as E,UGCardContent as N}from"@ug666/ui-react";import{UGConfirmDialog as P}from"@ug666/ui-react/patterns";import{ArrowLeft as F,Save as L}from"lucide-react";import{useEffect as k}from"react";import{useBlocker as w}from"react-router-dom";import{jsx as n,jsxs as o}from"react/jsx-runtime";function i({title:p,description:v,children:b,error:s,isDirty:d=!1,submitting:m=!1,submitDisabled:f=!1,submitLabel:U=u("common.save"),submitAndReturnLabel:C=u("common.saveAndReturn"),onCancel:G,onSubmit:g,onSubmitAndReturn:c}){let r=w(({currentLocation:t,nextLocation:a})=>d&&t.pathname!==a.pathname);k(()=>{function t(a){if(!d)return;a.preventDefault(),a.returnValue=""}return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[d]);function A(t){t.preventDefault(),g()}return o(e,{description:v,title:p,children:[n(E,{className:"admin-form-panel",children:n(N,{className:"admin-card-content",children:o("form",{className:"admin-form",onSubmit:A,children:[s?n(h,{variant:"destructive",children:n(B,{children:s})}):null,n("div",{className:"admin-form__fields",children:b}),o("div",{className:"admin-form__actions",children:[o(l,{disabled:m,onClick:G,type:"button",variant:"default",children:[n(F,{"aria-hidden":"true",size:16}),"返回"]}),o(l,{disabled:f,loading:m,tone:"primary",type:"submit",variant:"solid",children:[n(L,{"aria-hidden":"true",size:16}),U]}),c?n(l,{disabled:m||f,onClick:c,type:"button",variant:"default",children:C}):null]})]})})}),n(P,{closeOnConfirm:!1,confirmText:"放弃修改",description:"当前页面存在尚未保存的修改,离开后这些内容将丢失。",onCancel:()=>r.reset?.(),onConfirm:()=>r.proceed?.(),onOpenChange:(t)=>{if(!t)r.reset?.()},open:r.state==="blocked",title:"确认离开当前页面?",variant:"destructive"})]})}
|
|
2
|
+
export{i};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{UGContextMenu as g,UGContextMenuContent as f,UGContextMenuItem as C,UGContextMenuTrigger as M}from"@ug666/ui-react";import{useRef as l}from"react";import{jsx as r,jsxs as b}from"react/jsx-runtime";function t({tabs:m,onCloseOthers:d,children:p}){let a=l(null),n=l(void 0);function u(e){if(!(e.target instanceof Element))return;let s=e.target.closest('[data-ug="app-tabs"] [data-ug-slot="item"]'),o=s?.dataset.value;if(!o||!m.some((c)=>c.id!==o&&c.closable)){e.stopPropagation();return}n.current=o,a.current=s?.querySelector('[data-ug-slot="trigger"]')??null}function i(){let e=a.current;requestAnimationFrame(()=>e?.focus({preventScroll:!0}))}return b(g,{className:"admin-tab-menu",children:[r(M,{className:"admin-tab-menu__trigger",onContextMenuCapture:u,onKeyDownCapture:(e)=>{if(e.key==="ContextMenu"||e.shiftKey&&e.key==="F10")u(e)},children:p}),r(f,{"aria-label":"页签操作",children:r(C,{onClick:()=>{if(n.current)d(n.current);i()},onKeyDown:(e)=>{if(e.key==="Escape")i()},children:"关闭其他页签"})})]})}
|
|
2
|
+
export{t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{adminColumnPinLabel as k,cycleAdminColumnSide as P,moveAdminColumn as S,orderAdminColumns as _,readAdminColumnLayout as N,writeAdminColumnLayout as L}from"@ug666/admin-core/page/column-layout";import{UGButton as y,UGCheckbox as z,UGPopover as x,UGPopoverContent as B,UGPopoverTrigger as q}from"@ug666/ui-react";import{GripVertical as T,Pin as R,Settings2 as E}from"lucide-react";import{useRef as K,useState as O}from"react";import{jsx as i,jsxs as u}from"react/jsx-runtime";function n(m){let[d,c]=O(()=>N(m,window.localStorage));function p(s){c(s),L(m,s,window.localStorage)}return[d,p]}function o({columns:m,hidden:d,onChange:c,ariaLabel:p="列设置",triggerLabel:s,layout:r,onLayoutChange:f}){let l=K(null),A=_(m,r?.order??[]),b=A.map((e)=>e.id),w=m.filter((e)=>e.required||!d.includes(e.id)).length;function D(e,a){if(!a&&w<=1)return;c(a?d.filter((g)=>g!==e):[...new Set([...d,e])])}function U(e,a){if(r&&e!==a)f?.({...r,order:S(b,e,a)})}return u(x,{children:[i(q,{className:"inline-flex",children:u(y,{"aria-label":p,size:s?"default":"icon",title:s?void 0:p,type:"button",variant:"outline",children:[i(E,{"aria-hidden":"true",size:16}),s]})}),u(B,{align:"end",className:"admin-column-settings",side:"bottom",children:[u("div",{className:"admin-column-settings__head",children:[i("strong",{children:"显示列"}),i(y,{onClick:()=>c([]),size:"sm",type:"button",variant:"text",children:"全部显示"})]}),i("div",{className:"admin-column-settings__list",children:A.map((e,a)=>{let g=Boolean(e.required)||!d.includes(e.id),C=typeof e.header==="string"?e.header:e.id,v=r?.fixed[e.id],h=k(v,C);return u("div",{className:"admin-column-settings__row",onDragOver:(t)=>{if(l.current)t.preventDefault()},onDrop:(t)=>{if(!l.current)return;t.preventDefault(),U(l.current,e.id),l.current=null},children:[r&&f?i(y,{"aria-label":`调整${C}的列顺序`,"aria-keyshortcuts":"ArrowUp ArrowDown",className:"admin-column-settings__grip",draggable:!0,onDragStart:(t)=>{l.current=e.id,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e.id)},onDragEnd:()=>{l.current=null},onKeyDown:(t)=>{if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let G=b[a+(t.key==="ArrowUp"?-1:1)];if(G)U(e.id,G)},size:"icon-sm",title:"拖动或按方向键调整列顺序",type:"button",variant:"ghost",children:i(T,{"aria-hidden":"true",size:14})}):null,i(z,{checked:g,disabled:e.required||g&&w<=1,label:C,onCheckedChange:(t)=>D(e.id,t)}),r&&f?u(y,{"aria-label":h,className:"admin-column-settings__pin",disabled:!g,onClick:()=>f(P(r,e.id)),size:"sm",title:h,tone:v?"primary":"neutral",type:"button",variant:"ghost",children:[i(R,{"aria-hidden":"true",size:14}),v?i("span",{"aria-hidden":"true",children:v==="left"?"左":"右"}):null]}):null]},e.id)})})]})]})}
|
|
2
|
+
export{n,o};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e}from"./AdminColumnSettings-1xerrrqm.js";import{jsx as i,jsxs as a}from"react/jsx-runtime";function r({search:d,summary:o,searchId:v,searchHidden:N=!1,toolbarStart:t,toolbarEnd:s,children:h,footer:n,...p}){let{title:l,primaryAction:m,secondaryActions:c,...P}=p,A=Boolean(m||c||s);return a(e,{...P,className:"admin-page--list",title:l,visuallyHiddenHeader:!0,children:[d?i("div",{className:"admin-list-search-panel",hidden:N,id:v,children:i("div",{className:"admin-list-search",children:d})}):null,a("div",{className:"admin-list-panel",children:[a("div",{className:"admin-list-header",children:[i("h2",{className:"admin-list-header__title",children:l}),A?a("div",{className:"admin-list-header__actions",children:[c,m,s?i("div",{className:"admin-list-header__tools",children:s}):null]}):null]}),o,t?i("div",{className:"admin-list-actions",children:i("div",{className:"admin-list-actions__start",children:t})}):null,i("div",{className:"admin-list-content",children:h}),n?i("div",{className:"admin-list-footer",children:n}):null]})]})}
|
|
2
|
+
export{r};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e}from"./AdminColumnSettings-1xerrrqm.js";import{UGCard as l,UGCardContent as o,UGCardHeader as s,UGCardTitle as c}from"@ug666/ui-react";import{jsx as i,jsxs as d}from"react/jsx-runtime";function m({sections:n,...r}){return i(e,{...r,children:i("div",{className:"admin-detail-sections",children:n.map((a)=>d(l,{children:[i(s,{children:i(c,{children:a.title})}),i(o,{className:"admin-card-content",children:i("dl",{className:"admin-description-list",children:a.items.map((t)=>d("div",{className:"admin-description-list__item",children:[i("dt",{children:t.label}),i("dd",{children:t.value??"—"})]},t.label))})})]},a.id))})})}
|
|
2
|
+
export{m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{UGButton as d,UGModal as F,UGModalBody as v,UGModalCloseButton as y,UGModalContent as B,UGModalFooter as C,UGModalHeader as O,UGModalTitle as S}from"@ug666/ui-react";import{useId as g}from"react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function a({open:m,title:l,submitLabel:s,cancelLabel:c="取消",loading:o=!1,disabled:n=!1,closeOnOverlay:u=!0,initialFocusSelector:G,size:U,onClose:i,onSubmit:b,children:f}){let r=g();function p(M){if(M.preventDefault(),!o&&!n)b()}return e(F,{ariaLabel:l,closeOnEsc:!o,closeOnOverlay:u&&!o,initialFocusSelector:G,onClose:()=>{if(!o)i()},open:m,size:U,children:t(B,{children:[t(O,{children:[e(S,{children:l}),!o?e(y,{}):null]}),e(v,{children:e("form",{className:"admin-section-form",id:r,onSubmit:p,children:f})}),t(C,{children:[e(d,{disabled:o,onClick:i,type:"button",variant:"text",children:c}),e(d,{disabled:n,form:r,loading:o,tone:"primary",type:"submit",variant:"solid",children:s})]})]})})}
|
|
2
|
+
export{a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{UGAlert as a,UGAlertDescription as p}from"@ug666/ui-react";import{UGConfirmDialog as s}from"@ug666/ui-react/patterns";import{jsx as o}from"react/jsx-runtime";function d({open:i,title:r,description:e,confirmText:t,loading:l=!1,error:n,onOpenChange:m,onConfirm:f}){return o(s,{closeOnConfirm:!1,confirmText:t,description:e,loading:l,onConfirm:f,onOpenChange:m,open:i,title:r,variant:"destructive",children:n?o(a,{variant:"destructive",children:o(p,{children:n})}):null})}
|
|
2
|
+
export{d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{UGButton as h,UGForm as v,UGFormControl as U,UGFormField as G,UGFormItem as S,UGFormLabel as g}from"@ug666/ui-react";import{ChevronDown as y,ChevronUp as N,RotateCcw as C,Search as x}from"lucide-react";import{useId as R,useState as z}from"react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function l({name:i,label:a,labelFor:o,className:r,itemClassName:m,itemStyle:d,children:c}){return e(G,{name:i,className:r?`admin-search-field ${r}`:"admin-search-field",children:t(S,{className:m,style:d,children:[e(g,{htmlFor:o,children:a}),e(U,{children:c})]})})}function s({children:i,expandedContent:a,labelWidth:o=0,expandLabel:r="展开",collapseLabel:m="收起",loading:d=!1,onReset:c,onSubmit:F}){let[n,f]=z(!1),p=R();function b(u){u.preventDefault(),F()}return t(v,{className:"admin-search-form",layout:"horizontal",labelPosition:"right",labelWidth:o,size:"default",onSubmit:b,children:[t("div",{className:"admin-search-form__fields",children:[i,a?e("div",{id:p,className:"admin-search-form__expanded",hidden:!n,children:a}):null]}),t("div",{className:"admin-search-form__actions",children:[a?t(h,{"aria-expanded":n,"aria-controls":p,onClick:()=>f((u)=>!u),tone:"neutral",type:"button",variant:"text",children:[n?e(N,{"aria-hidden":"true",size:16}):e(y,{"aria-hidden":"true",size:16}),n?m:r]}):null,t(h,{loading:d,tone:"primary",type:"submit",variant:"outline",children:[e(x,{"aria-hidden":"true",size:16}),"查询"]}),t(h,{onClick:c,tone:"neutral",type:"button",variant:"outline",children:[e(C,{"aria-hidden":"true",size:16}),"重置"]})]})]})}
|
|
2
|
+
export{l,s};
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminConfirmAction2
|
|
3
|
-
} from "./index-aqqcc4wq.js";
|
|
4
|
-
import {
|
|
5
|
-
AdminPage2
|
|
6
|
-
} from "./index-keve3ryw.js";
|
|
7
|
-
import {
|
|
8
|
-
AdminDetailPage2
|
|
9
|
-
} from "./index-4tstw263.js";
|
|
10
|
-
import {
|
|
11
|
-
AdminFormPage2
|
|
12
|
-
} from "./index-zt432pkz.js";
|
|
13
|
-
import {
|
|
14
|
-
AdminListPage2
|
|
15
|
-
} from "./index-nyrhj7se.js";
|
|
16
|
-
import {
|
|
17
|
-
AdminSearchField2,
|
|
18
|
-
AdminSearchForm2
|
|
19
|
-
} from "./index-3dcgfy6t.js";
|
|
20
|
-
export {
|
|
21
|
-
AdminConfirmAction2 as AdminConfirmAction,
|
|
22
|
-
AdminDetailPage2 as AdminDetailPage,
|
|
23
|
-
AdminFormPage2 as AdminFormPage,
|
|
24
|
-
AdminListPage2 as AdminListPage,
|
|
25
|
-
AdminPage2 as AdminPage,
|
|
26
|
-
AdminSearchField2 as AdminSearchField,
|
|
27
|
-
AdminSearchForm2 as AdminSearchForm
|
|
28
|
-
};
|
|
1
|
+
import{n,o}from"./AdminColumnSettings-a6913hy9.js";import{d}from"./AdminColumnSettings-mj5py2kd.js";import{e}from"./AdminColumnSettings-1xerrrqm.js";import{m}from"./AdminColumnSettings-fb9zzqec.js";import{a}from"./AdminColumnSettings-h570338r.js";import{i}from"./AdminColumnSettings-247f7yan.js";import{r}from"./AdminColumnSettings-aqnrn2jc.js";import{l,s}from"./AdminColumnSettings-s1mddwde.js";import{t}from"./AdminColumnSettings-4a6ajtjk.js";export{o as AdminColumnSettings,d as AdminConfirmAction,m as AdminDetailPage,a as AdminFormDialog,i as AdminFormPage,r as AdminListPage,e as AdminPage,l as AdminSearchField,s as AdminSearchForm,t as AdminTabContextMenu,n as useAdminColumnLayout};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,o}from"../AdminColumnSettings-a6913hy9.js";export{o as AdminColumnSettings,n as useAdminColumnLayout};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminDetailPage2
|
|
3
|
-
} from "../index-4tstw263.js";
|
|
4
|
-
import"../index-keve3ryw.js";
|
|
5
|
-
export {
|
|
6
|
-
AdminDetailPage2 as AdminDetailPage
|
|
7
|
-
};
|
|
1
|
+
import{m}from"../AdminColumnSettings-fb9zzqec.js";import"../AdminColumnSettings-1xerrrqm.js";export{m as AdminDetailPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../AdminColumnSettings-h570338r.js";export{a as AdminFormDialog};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminSearchField2,
|
|
3
|
-
AdminSearchForm2
|
|
4
|
-
} from "../index-3dcgfy6t.js";
|
|
5
|
-
export {
|
|
6
|
-
AdminSearchField2 as AdminSearchField,
|
|
7
|
-
AdminSearchForm2 as AdminSearchForm
|
|
8
|
-
};
|
|
1
|
+
import{l,s}from"../AdminColumnSettings-s1mddwde.js";export{l as AdminSearchField,s as AdminSearchForm};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t}from"../AdminColumnSettings-4a6ajtjk.js";export{t as AdminTabContextMenu};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ug666/admin-react",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"description": "UG Admin React 渲染层:AdminPage/AdminListPage/AdminFormPage/AdminDetailPage 等页面壳与组合模式",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"./patterns/*": {
|
|
12
12
|
"types": "./src/patterns/*.tsx",
|
|
13
|
-
"default": "./
|
|
13
|
+
"default": "./dist/patterns/*.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@types/react": "^19.0.0",
|
|
23
23
|
"@types/react-dom": "^19.0.0",
|
|
24
24
|
"@ug666/admin-core": "file:../admin-core",
|
|
25
|
-
"@ug666/ui-react": "0.3.0-beta.
|
|
25
|
+
"@ug666/ui-react": "0.3.0-beta.4",
|
|
26
26
|
"lucide-react": "^1.61.0",
|
|
27
27
|
"react": "^19.0.0",
|
|
28
28
|
"react-router-dom": "^7.18.2"
|
|
@@ -39,5 +39,10 @@
|
|
|
39
39
|
"lucide-react": "*",
|
|
40
40
|
"react": "^19.0.0",
|
|
41
41
|
"react-router-dom": "^7.0.0"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/uguang2003/ug-admin.git",
|
|
46
|
+
"directory": "packages/admin-react"
|
|
42
47
|
}
|
|
43
48
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/** @description: admin-react 公开入口;按子路径导出,构建产物与类型统一从这里收口。 */
|
|
2
2
|
|
|
3
|
+
export * from "./patterns/AdminColumnSettings";
|
|
3
4
|
export * from "./patterns/AdminConfirmAction";
|
|
4
5
|
export * from "./patterns/AdminDetailPage";
|
|
6
|
+
export * from "./patterns/AdminFormDialog";
|
|
5
7
|
export * from "./patterns/AdminFormPage";
|
|
6
8
|
export * from "./patterns/AdminListPage";
|
|
7
9
|
export * from "./patterns/AdminPage";
|
|
8
10
|
export * from "./patterns/AdminSearchForm";
|
|
11
|
+
export * from "./patterns/AdminTabContextMenu";
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AdminColumnLayout,
|
|
3
|
+
adminColumnPinLabel,
|
|
4
|
+
cycleAdminColumnSide,
|
|
5
|
+
moveAdminColumn,
|
|
6
|
+
orderAdminColumns,
|
|
7
|
+
readAdminColumnLayout,
|
|
8
|
+
writeAdminColumnLayout,
|
|
9
|
+
} from "@ug666/admin-core/page/column-layout";
|
|
10
|
+
import {
|
|
11
|
+
UGButton,
|
|
12
|
+
UGCheckbox,
|
|
13
|
+
UGPopover,
|
|
14
|
+
UGPopoverContent,
|
|
15
|
+
UGPopoverTrigger,
|
|
16
|
+
} from "@ug666/ui-react";
|
|
17
|
+
import { GripVertical, Pin, Settings2 } from "lucide-react";
|
|
18
|
+
import { type ReactNode, useRef, useState } from "react";
|
|
19
|
+
|
|
20
|
+
export interface AdminColumnSettingsProps {
|
|
21
|
+
/** 可配置的列,按当前顺序展示 */
|
|
22
|
+
columns: readonly { id: string; header?: ReactNode; required?: boolean }[];
|
|
23
|
+
ariaLabel?: string;
|
|
24
|
+
triggerLabel?: string;
|
|
25
|
+
/** 被隐藏的列 id */
|
|
26
|
+
hidden: readonly string[];
|
|
27
|
+
/** 隐藏列变化;至少保留一列 */
|
|
28
|
+
onChange: (hidden: string[]) => void;
|
|
29
|
+
layout?: AdminColumnLayout;
|
|
30
|
+
onLayoutChange?: (layout: AdminColumnLayout) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function useAdminColumnLayout(scope: string) {
|
|
34
|
+
const [layout, setLayout] = useState(() => readAdminColumnLayout(scope, window.localStorage));
|
|
35
|
+
function changeLayout(next: AdminColumnLayout) {
|
|
36
|
+
setLayout(next);
|
|
37
|
+
writeAdminColumnLayout(scope, next, window.localStorage);
|
|
38
|
+
}
|
|
39
|
+
return [layout, changeLayout] as const;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 列表页的列设置弹层:勾选可见列,并按页面配置调整顺序与固定方向。 */
|
|
43
|
+
export function AdminColumnSettings({
|
|
44
|
+
columns,
|
|
45
|
+
hidden,
|
|
46
|
+
onChange,
|
|
47
|
+
ariaLabel = "列设置",
|
|
48
|
+
triggerLabel,
|
|
49
|
+
layout,
|
|
50
|
+
onLayoutChange,
|
|
51
|
+
}: AdminColumnSettingsProps) {
|
|
52
|
+
const dragged = useRef<string | null>(null);
|
|
53
|
+
const orderedColumns = orderAdminColumns(columns, layout?.order ?? []);
|
|
54
|
+
const order = orderedColumns.map((column) => column.id);
|
|
55
|
+
const visibleCount = columns.filter(
|
|
56
|
+
(column) => column.required || !hidden.includes(column.id),
|
|
57
|
+
).length;
|
|
58
|
+
|
|
59
|
+
function toggle(id: string, visible: boolean) {
|
|
60
|
+
if (!visible && visibleCount <= 1) return;
|
|
61
|
+
onChange(visible ? hidden.filter((item) => item !== id) : [...new Set([...hidden, id])]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function move(id: string, target: string) {
|
|
65
|
+
if (layout && id !== target)
|
|
66
|
+
onLayoutChange?.({ ...layout, order: moveAdminColumn(order, id, target) });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<UGPopover>
|
|
71
|
+
<UGPopoverTrigger className="inline-flex">
|
|
72
|
+
<UGButton
|
|
73
|
+
aria-label={ariaLabel}
|
|
74
|
+
size={triggerLabel ? "default" : "icon"}
|
|
75
|
+
title={triggerLabel ? undefined : ariaLabel}
|
|
76
|
+
type="button"
|
|
77
|
+
variant="outline"
|
|
78
|
+
>
|
|
79
|
+
<Settings2 aria-hidden="true" size={16} />
|
|
80
|
+
{triggerLabel}
|
|
81
|
+
</UGButton>
|
|
82
|
+
</UGPopoverTrigger>
|
|
83
|
+
<UGPopoverContent align="end" className="admin-column-settings" side="bottom">
|
|
84
|
+
<div className="admin-column-settings__head">
|
|
85
|
+
<strong>显示列</strong>
|
|
86
|
+
<UGButton onClick={() => onChange([])} size="sm" type="button" variant="text">
|
|
87
|
+
全部显示
|
|
88
|
+
</UGButton>
|
|
89
|
+
</div>
|
|
90
|
+
<div className="admin-column-settings__list">
|
|
91
|
+
{orderedColumns.map((column, index) => {
|
|
92
|
+
const visible = Boolean(column.required) || !hidden.includes(column.id);
|
|
93
|
+
const title = typeof column.header === "string" ? column.header : column.id;
|
|
94
|
+
const side = layout?.fixed[column.id];
|
|
95
|
+
const pinLabel = adminColumnPinLabel(side, title);
|
|
96
|
+
return (
|
|
97
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: 整行接收拖放,键盘通过同一行的排序按钮操作。
|
|
98
|
+
<div
|
|
99
|
+
className="admin-column-settings__row"
|
|
100
|
+
key={column.id}
|
|
101
|
+
onDragOver={(event) => {
|
|
102
|
+
if (dragged.current) event.preventDefault();
|
|
103
|
+
}}
|
|
104
|
+
onDrop={(event) => {
|
|
105
|
+
if (!dragged.current) return;
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
move(dragged.current, column.id);
|
|
108
|
+
dragged.current = null;
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{layout && onLayoutChange ? (
|
|
112
|
+
<UGButton
|
|
113
|
+
aria-label={`调整${title}的列顺序`}
|
|
114
|
+
aria-keyshortcuts="ArrowUp ArrowDown"
|
|
115
|
+
className="admin-column-settings__grip"
|
|
116
|
+
draggable
|
|
117
|
+
onDragStart={(event) => {
|
|
118
|
+
dragged.current = column.id;
|
|
119
|
+
event.dataTransfer.effectAllowed = "move";
|
|
120
|
+
event.dataTransfer.setData("text/plain", column.id);
|
|
121
|
+
}}
|
|
122
|
+
onDragEnd={() => {
|
|
123
|
+
dragged.current = null;
|
|
124
|
+
}}
|
|
125
|
+
onKeyDown={(event) => {
|
|
126
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
const target = order[index + (event.key === "ArrowUp" ? -1 : 1)];
|
|
129
|
+
if (target) move(column.id, target);
|
|
130
|
+
}}
|
|
131
|
+
size="icon-sm"
|
|
132
|
+
title="拖动或按方向键调整列顺序"
|
|
133
|
+
type="button"
|
|
134
|
+
variant="ghost"
|
|
135
|
+
>
|
|
136
|
+
<GripVertical aria-hidden="true" size={14} />
|
|
137
|
+
</UGButton>
|
|
138
|
+
) : null}
|
|
139
|
+
<UGCheckbox
|
|
140
|
+
checked={visible}
|
|
141
|
+
disabled={column.required || (visible && visibleCount <= 1)}
|
|
142
|
+
label={title}
|
|
143
|
+
onCheckedChange={(checked) => toggle(column.id, checked)}
|
|
144
|
+
/>
|
|
145
|
+
{layout && onLayoutChange ? (
|
|
146
|
+
<UGButton
|
|
147
|
+
aria-label={pinLabel}
|
|
148
|
+
className="admin-column-settings__pin"
|
|
149
|
+
disabled={!visible}
|
|
150
|
+
onClick={() => onLayoutChange(cycleAdminColumnSide(layout, column.id))}
|
|
151
|
+
size="sm"
|
|
152
|
+
title={pinLabel}
|
|
153
|
+
tone={side ? "primary" : "neutral"}
|
|
154
|
+
type="button"
|
|
155
|
+
variant="ghost"
|
|
156
|
+
>
|
|
157
|
+
<Pin aria-hidden="true" size={14} />
|
|
158
|
+
{side ? <span aria-hidden="true">{side === "left" ? "左" : "右"}</span> : null}
|
|
159
|
+
</UGButton>
|
|
160
|
+
) : null}
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
})}
|
|
164
|
+
</div>
|
|
165
|
+
</UGPopoverContent>
|
|
166
|
+
</UGPopover>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UGButton,
|
|
3
|
+
UGModal,
|
|
4
|
+
UGModalBody,
|
|
5
|
+
UGModalCloseButton,
|
|
6
|
+
UGModalContent,
|
|
7
|
+
UGModalFooter,
|
|
8
|
+
UGModalHeader,
|
|
9
|
+
UGModalTitle,
|
|
10
|
+
} from "@ug666/ui-react";
|
|
11
|
+
import { type FormEvent, type ReactNode, useId } from "react";
|
|
12
|
+
|
|
13
|
+
export interface AdminFormDialogProps {
|
|
14
|
+
open: boolean;
|
|
15
|
+
title: string;
|
|
16
|
+
/** 提交按钮文案 */
|
|
17
|
+
submitLabel: string;
|
|
18
|
+
/** 取消按钮文案 */
|
|
19
|
+
cancelLabel?: string;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
closeOnOverlay?: boolean;
|
|
23
|
+
initialFocusSelector?: string;
|
|
24
|
+
size?: "sm" | "md" | "lg";
|
|
25
|
+
/** 关闭请求;提交中应自行忽略 */
|
|
26
|
+
onClose: () => void;
|
|
27
|
+
onSubmit: () => void;
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 列表页的“新增/编辑”弹窗:表单区单列限宽,提交与取消在页脚同一行,
|
|
33
|
+
* 不再把表单摊在列表卡片顶部。
|
|
34
|
+
*/
|
|
35
|
+
export function AdminFormDialog({
|
|
36
|
+
open,
|
|
37
|
+
title,
|
|
38
|
+
submitLabel,
|
|
39
|
+
cancelLabel = "取消",
|
|
40
|
+
loading = false,
|
|
41
|
+
disabled = false,
|
|
42
|
+
closeOnOverlay = true,
|
|
43
|
+
initialFocusSelector,
|
|
44
|
+
size,
|
|
45
|
+
onClose,
|
|
46
|
+
onSubmit,
|
|
47
|
+
children,
|
|
48
|
+
}: AdminFormDialogProps) {
|
|
49
|
+
const formId = useId();
|
|
50
|
+
|
|
51
|
+
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
if (!loading && !disabled) onSubmit();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<UGModal
|
|
58
|
+
ariaLabel={title}
|
|
59
|
+
closeOnEsc={!loading}
|
|
60
|
+
closeOnOverlay={closeOnOverlay && !loading}
|
|
61
|
+
initialFocusSelector={initialFocusSelector}
|
|
62
|
+
onClose={() => {
|
|
63
|
+
if (!loading) onClose();
|
|
64
|
+
}}
|
|
65
|
+
open={open}
|
|
66
|
+
size={size}
|
|
67
|
+
>
|
|
68
|
+
<UGModalContent>
|
|
69
|
+
<UGModalHeader>
|
|
70
|
+
<UGModalTitle>{title}</UGModalTitle>
|
|
71
|
+
{!loading ? <UGModalCloseButton /> : null}
|
|
72
|
+
</UGModalHeader>
|
|
73
|
+
<UGModalBody>
|
|
74
|
+
<form className="admin-section-form" id={formId} onSubmit={handleSubmit}>
|
|
75
|
+
{children}
|
|
76
|
+
</form>
|
|
77
|
+
</UGModalBody>
|
|
78
|
+
<UGModalFooter>
|
|
79
|
+
<UGButton disabled={loading} onClick={onClose} type="button" variant="text">
|
|
80
|
+
{cancelLabel}
|
|
81
|
+
</UGButton>
|
|
82
|
+
<UGButton
|
|
83
|
+
disabled={disabled}
|
|
84
|
+
form={formId}
|
|
85
|
+
loading={loading}
|
|
86
|
+
tone="primary"
|
|
87
|
+
type="submit"
|
|
88
|
+
variant="solid"
|
|
89
|
+
>
|
|
90
|
+
{submitLabel}
|
|
91
|
+
</UGButton>
|
|
92
|
+
</UGModalFooter>
|
|
93
|
+
</UGModalContent>
|
|
94
|
+
</UGModal>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -12,6 +12,10 @@ export interface AdminListPageProps extends Omit<AdminPageProps, "children"> {
|
|
|
12
12
|
footer?: ReactNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* 列表页模式:筛选区独立,标题与主操作在列表卡头,工具栏、表格与分页在同一卡内。
|
|
17
|
+
* 页面级标题只保留给读屏(h1),可见标题由卡片头承担,避免与面包屑、页签重复。
|
|
18
|
+
*/
|
|
15
19
|
export function AdminListPage({
|
|
16
20
|
search,
|
|
17
21
|
summary,
|
|
@@ -23,24 +27,31 @@ export function AdminListPage({
|
|
|
23
27
|
footer,
|
|
24
28
|
...pageProps
|
|
25
29
|
}: AdminListPageProps) {
|
|
26
|
-
const { primaryAction, secondaryActions, ...
|
|
30
|
+
const { title, primaryAction, secondaryActions, ...rest } = pageProps;
|
|
31
|
+
const hasActions = Boolean(primaryAction || secondaryActions || toolbarEnd);
|
|
32
|
+
|
|
27
33
|
return (
|
|
28
|
-
<AdminPage {...
|
|
34
|
+
<AdminPage {...rest} className="admin-page--list" title={title} visuallyHiddenHeader>
|
|
35
|
+
{search ? (
|
|
36
|
+
<div className="admin-list-search-panel" hidden={searchHidden} id={searchId}>
|
|
37
|
+
<div className="admin-list-search">{search}</div>
|
|
38
|
+
</div>
|
|
39
|
+
) : null}
|
|
29
40
|
<div className="admin-list-panel">
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
) : null}
|
|
35
|
-
{summary}
|
|
36
|
-
{primaryAction || secondaryActions || toolbarStart || toolbarEnd ? (
|
|
37
|
-
<div className="admin-list-actions">
|
|
38
|
-
<div className="admin-list-actions__start">
|
|
39
|
-
{primaryAction}
|
|
41
|
+
<div className="admin-list-header">
|
|
42
|
+
<h2 className="admin-list-header__title">{title}</h2>
|
|
43
|
+
{hasActions ? (
|
|
44
|
+
<div className="admin-list-header__actions">
|
|
40
45
|
{secondaryActions}
|
|
41
|
-
{
|
|
46
|
+
{primaryAction}
|
|
47
|
+
{toolbarEnd ? <div className="admin-list-header__tools">{toolbarEnd}</div> : null}
|
|
42
48
|
</div>
|
|
43
|
-
|
|
49
|
+
) : null}
|
|
50
|
+
</div>
|
|
51
|
+
{summary}
|
|
52
|
+
{toolbarStart ? (
|
|
53
|
+
<div className="admin-list-actions">
|
|
54
|
+
<div className="admin-list-actions__start">{toolbarStart}</div>
|
|
44
55
|
</div>
|
|
45
56
|
) : null}
|
|
46
57
|
<div className="admin-list-content">{children}</div>
|
|
@@ -4,7 +4,10 @@ import type { ReactNode } from "react";
|
|
|
4
4
|
export interface AdminPageProps {
|
|
5
5
|
className?: string;
|
|
6
6
|
title: ReactNode;
|
|
7
|
+
/** 页面说明文案;默认不渲染(管理台标题行只保留标题与操作),需要时显式开启 */
|
|
7
8
|
description?: ReactNode;
|
|
9
|
+
/** 是否在页头渲染 description,默认 false */
|
|
10
|
+
showDescription?: boolean;
|
|
8
11
|
badge?: ReactNode;
|
|
9
12
|
meta?: ReactNode;
|
|
10
13
|
primaryAction?: ReactNode;
|
|
@@ -17,6 +20,7 @@ export function AdminPage({
|
|
|
17
20
|
className,
|
|
18
21
|
title,
|
|
19
22
|
description,
|
|
23
|
+
showDescription = false,
|
|
20
24
|
badge,
|
|
21
25
|
meta,
|
|
22
26
|
primaryAction,
|
|
@@ -40,9 +44,9 @@ export function AdminPage({
|
|
|
40
44
|
<UGPageHeader
|
|
41
45
|
actions={actions}
|
|
42
46
|
badge={badge}
|
|
43
|
-
description={description}
|
|
47
|
+
description={showDescription ? description : undefined}
|
|
44
48
|
meta={meta}
|
|
45
|
-
title={title}
|
|
49
|
+
title={<span className="admin-page__title">{title}</span>}
|
|
46
50
|
/>
|
|
47
51
|
)}
|
|
48
52
|
{children}
|
|
@@ -60,7 +60,7 @@ export interface AdminSearchFormProps {
|
|
|
60
60
|
export function AdminSearchForm({
|
|
61
61
|
children,
|
|
62
62
|
expandedContent,
|
|
63
|
-
labelWidth =
|
|
63
|
+
labelWidth = 0,
|
|
64
64
|
expandLabel = "展开",
|
|
65
65
|
collapseLabel = "收起",
|
|
66
66
|
loading = false,
|
|
@@ -110,11 +110,11 @@ export function AdminSearchForm({
|
|
|
110
110
|
{expanded ? collapseLabel : expandLabel}
|
|
111
111
|
</UGButton>
|
|
112
112
|
) : null}
|
|
113
|
-
<UGButton loading={loading} tone="primary" type="submit" variant="
|
|
113
|
+
<UGButton loading={loading} tone="primary" type="submit" variant="outline">
|
|
114
114
|
<Search aria-hidden="true" size={16} />
|
|
115
115
|
查询
|
|
116
116
|
</UGButton>
|
|
117
|
-
<UGButton onClick={onReset} type="button" variant="
|
|
117
|
+
<UGButton onClick={onReset} tone="neutral" type="button" variant="outline">
|
|
118
118
|
<RotateCcw aria-hidden="true" size={16} />
|
|
119
119
|
重置
|
|
120
120
|
</UGButton>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** @description: 在 UG 页签条上提供关闭其他页签的菜单。 */
|
|
2
|
+
import type { AdminAppTab } from "@ug666/admin-core/routing/app-tabs";
|
|
3
|
+
import {
|
|
4
|
+
UGContextMenu,
|
|
5
|
+
UGContextMenuContent,
|
|
6
|
+
UGContextMenuItem,
|
|
7
|
+
UGContextMenuTrigger,
|
|
8
|
+
} from "@ug666/ui-react";
|
|
9
|
+
import { type ReactNode, useRef } from "react";
|
|
10
|
+
|
|
11
|
+
export function AdminTabContextMenu({
|
|
12
|
+
tabs,
|
|
13
|
+
onCloseOthers,
|
|
14
|
+
children,
|
|
15
|
+
}: {
|
|
16
|
+
tabs: readonly AdminAppTab[];
|
|
17
|
+
onCloseOthers: (tabId: string) => void;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}) {
|
|
20
|
+
const trigger = useRef<HTMLElement | null>(null);
|
|
21
|
+
const tabId = useRef<string | undefined>(undefined);
|
|
22
|
+
|
|
23
|
+
function prepare(event: React.SyntheticEvent) {
|
|
24
|
+
if (!(event.target instanceof Element)) return;
|
|
25
|
+
const item = event.target.closest<HTMLElement>('[data-ug="app-tabs"] [data-ug-slot="item"]');
|
|
26
|
+
const value = item?.dataset.value;
|
|
27
|
+
if (!value || !tabs.some((tab) => tab.id !== value && tab.closable)) {
|
|
28
|
+
event.stopPropagation();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
tabId.current = value;
|
|
32
|
+
trigger.current = item?.querySelector<HTMLElement>('[data-ug-slot="trigger"]') ?? null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function restoreFocus() {
|
|
36
|
+
const target = trigger.current;
|
|
37
|
+
requestAnimationFrame(() => target?.focus({ preventScroll: true }));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<UGContextMenu className="admin-tab-menu">
|
|
42
|
+
<UGContextMenuTrigger
|
|
43
|
+
className="admin-tab-menu__trigger"
|
|
44
|
+
onContextMenuCapture={prepare}
|
|
45
|
+
onKeyDownCapture={(event) => {
|
|
46
|
+
if (event.key === "ContextMenu" || (event.shiftKey && event.key === "F10"))
|
|
47
|
+
prepare(event);
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</UGContextMenuTrigger>
|
|
52
|
+
<UGContextMenuContent aria-label="页签操作">
|
|
53
|
+
<UGContextMenuItem
|
|
54
|
+
onClick={() => {
|
|
55
|
+
if (tabId.current) onCloseOthers(tabId.current);
|
|
56
|
+
restoreFocus();
|
|
57
|
+
}}
|
|
58
|
+
onKeyDown={(event) => {
|
|
59
|
+
if (event.key === "Escape") restoreFocus();
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
关闭其他页签
|
|
63
|
+
</UGContextMenuItem>
|
|
64
|
+
</UGContextMenuContent>
|
|
65
|
+
</UGContextMenu>
|
|
66
|
+
);
|
|
67
|
+
}
|
package/dist/index-3dcgfy6t.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// packages/admin-react/src/patterns/AdminSearchForm.tsx
|
|
2
|
-
import {
|
|
3
|
-
UGButton,
|
|
4
|
-
UGForm,
|
|
5
|
-
UGFormControl,
|
|
6
|
-
UGFormField,
|
|
7
|
-
UGFormItem,
|
|
8
|
-
UGFormLabel
|
|
9
|
-
} from "@ug666/ui-react";
|
|
10
|
-
import { ChevronDown, ChevronUp, RotateCcw, Search } from "lucide-react";
|
|
11
|
-
import {
|
|
12
|
-
useId,
|
|
13
|
-
useState
|
|
14
|
-
} from "react";
|
|
15
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
16
|
-
function AdminSearchField2({
|
|
17
|
-
name,
|
|
18
|
-
label,
|
|
19
|
-
labelFor,
|
|
20
|
-
className,
|
|
21
|
-
itemClassName,
|
|
22
|
-
itemStyle,
|
|
23
|
-
children
|
|
24
|
-
}) {
|
|
25
|
-
return /* @__PURE__ */ jsxDEV(UGFormField, {
|
|
26
|
-
name,
|
|
27
|
-
className: className ? `admin-search-field ${className}` : "admin-search-field",
|
|
28
|
-
children: /* @__PURE__ */ jsxDEV(UGFormItem, {
|
|
29
|
-
className: itemClassName,
|
|
30
|
-
style: itemStyle,
|
|
31
|
-
children: [
|
|
32
|
-
/* @__PURE__ */ jsxDEV(UGFormLabel, {
|
|
33
|
-
htmlFor: labelFor,
|
|
34
|
-
children: label
|
|
35
|
-
}, undefined, false, undefined, this),
|
|
36
|
-
/* @__PURE__ */ jsxDEV(UGFormControl, {
|
|
37
|
-
children
|
|
38
|
-
}, undefined, false, undefined, this)
|
|
39
|
-
]
|
|
40
|
-
}, undefined, true, undefined, this)
|
|
41
|
-
}, undefined, false, undefined, this);
|
|
42
|
-
}
|
|
43
|
-
function AdminSearchForm2({
|
|
44
|
-
children,
|
|
45
|
-
expandedContent,
|
|
46
|
-
labelWidth = "max-content",
|
|
47
|
-
expandLabel = "展开",
|
|
48
|
-
collapseLabel = "收起",
|
|
49
|
-
loading = false,
|
|
50
|
-
onReset,
|
|
51
|
-
onSubmit
|
|
52
|
-
}) {
|
|
53
|
-
const [expanded, setExpanded] = useState(false);
|
|
54
|
-
const expandedId = useId();
|
|
55
|
-
function handleSubmit(event) {
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
onSubmit();
|
|
58
|
-
}
|
|
59
|
-
return /* @__PURE__ */ jsxDEV(UGForm, {
|
|
60
|
-
className: "admin-search-form",
|
|
61
|
-
layout: "horizontal",
|
|
62
|
-
labelPosition: "right",
|
|
63
|
-
labelWidth,
|
|
64
|
-
size: "default",
|
|
65
|
-
onSubmit: handleSubmit,
|
|
66
|
-
children: [
|
|
67
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
68
|
-
className: "admin-search-form__fields",
|
|
69
|
-
children: [
|
|
70
|
-
children,
|
|
71
|
-
expandedContent ? /* @__PURE__ */ jsxDEV("div", {
|
|
72
|
-
id: expandedId,
|
|
73
|
-
className: "admin-search-form__expanded",
|
|
74
|
-
hidden: !expanded,
|
|
75
|
-
children: expandedContent
|
|
76
|
-
}, undefined, false, undefined, this) : null
|
|
77
|
-
]
|
|
78
|
-
}, undefined, true, undefined, this),
|
|
79
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
80
|
-
className: "admin-search-form__actions",
|
|
81
|
-
children: [
|
|
82
|
-
expandedContent ? /* @__PURE__ */ jsxDEV(UGButton, {
|
|
83
|
-
"aria-expanded": expanded,
|
|
84
|
-
"aria-controls": expandedId,
|
|
85
|
-
onClick: () => setExpanded((value) => !value),
|
|
86
|
-
tone: "neutral",
|
|
87
|
-
type: "button",
|
|
88
|
-
variant: "text",
|
|
89
|
-
children: [
|
|
90
|
-
expanded ? /* @__PURE__ */ jsxDEV(ChevronUp, {
|
|
91
|
-
"aria-hidden": "true",
|
|
92
|
-
size: 16
|
|
93
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV(ChevronDown, {
|
|
94
|
-
"aria-hidden": "true",
|
|
95
|
-
size: 16
|
|
96
|
-
}, undefined, false, undefined, this),
|
|
97
|
-
expanded ? collapseLabel : expandLabel
|
|
98
|
-
]
|
|
99
|
-
}, undefined, true, undefined, this) : null,
|
|
100
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
101
|
-
loading,
|
|
102
|
-
tone: "primary",
|
|
103
|
-
type: "submit",
|
|
104
|
-
variant: "solid",
|
|
105
|
-
children: [
|
|
106
|
-
/* @__PURE__ */ jsxDEV(Search, {
|
|
107
|
-
"aria-hidden": "true",
|
|
108
|
-
size: 16
|
|
109
|
-
}, undefined, false, undefined, this),
|
|
110
|
-
"查询"
|
|
111
|
-
]
|
|
112
|
-
}, undefined, true, undefined, this),
|
|
113
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
114
|
-
onClick: onReset,
|
|
115
|
-
type: "button",
|
|
116
|
-
variant: "default",
|
|
117
|
-
children: [
|
|
118
|
-
/* @__PURE__ */ jsxDEV(RotateCcw, {
|
|
119
|
-
"aria-hidden": "true",
|
|
120
|
-
size: 16
|
|
121
|
-
}, undefined, false, undefined, this),
|
|
122
|
-
"重置"
|
|
123
|
-
]
|
|
124
|
-
}, undefined, true, undefined, this)
|
|
125
|
-
]
|
|
126
|
-
}, undefined, true, undefined, this)
|
|
127
|
-
]
|
|
128
|
-
}, undefined, true, undefined, this);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export { AdminSearchField2, AdminSearchForm2 };
|
package/dist/index-4tstw263.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminPage2
|
|
3
|
-
} from "./index-keve3ryw.js";
|
|
4
|
-
|
|
5
|
-
// packages/admin-react/src/patterns/AdminDetailPage.tsx
|
|
6
|
-
import { UGCard, UGCardContent, UGCardHeader, UGCardTitle } from "@ug666/ui-react";
|
|
7
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
8
|
-
function AdminDetailPage2({ sections, ...pageProps }) {
|
|
9
|
-
return /* @__PURE__ */ jsxDEV(AdminPage2, {
|
|
10
|
-
...pageProps,
|
|
11
|
-
children: /* @__PURE__ */ jsxDEV("div", {
|
|
12
|
-
className: "admin-detail-sections",
|
|
13
|
-
children: sections.map((section) => /* @__PURE__ */ jsxDEV(UGCard, {
|
|
14
|
-
children: [
|
|
15
|
-
/* @__PURE__ */ jsxDEV(UGCardHeader, {
|
|
16
|
-
children: /* @__PURE__ */ jsxDEV(UGCardTitle, {
|
|
17
|
-
children: section.title
|
|
18
|
-
}, undefined, false, undefined, this)
|
|
19
|
-
}, undefined, false, undefined, this),
|
|
20
|
-
/* @__PURE__ */ jsxDEV(UGCardContent, {
|
|
21
|
-
className: "admin-card-content",
|
|
22
|
-
children: /* @__PURE__ */ jsxDEV("dl", {
|
|
23
|
-
className: "admin-description-list",
|
|
24
|
-
children: section.items.map((item) => /* @__PURE__ */ jsxDEV("div", {
|
|
25
|
-
className: "admin-description-list__item",
|
|
26
|
-
children: [
|
|
27
|
-
/* @__PURE__ */ jsxDEV("dt", {
|
|
28
|
-
children: item.label
|
|
29
|
-
}, undefined, false, undefined, this),
|
|
30
|
-
/* @__PURE__ */ jsxDEV("dd", {
|
|
31
|
-
children: item.value ?? "—"
|
|
32
|
-
}, undefined, false, undefined, this)
|
|
33
|
-
]
|
|
34
|
-
}, item.label, true, undefined, this))
|
|
35
|
-
}, undefined, false, undefined, this)
|
|
36
|
-
}, undefined, false, undefined, this)
|
|
37
|
-
]
|
|
38
|
-
}, section.id, true, undefined, this))
|
|
39
|
-
}, undefined, false, undefined, this)
|
|
40
|
-
}, undefined, false, undefined, this);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { AdminDetailPage2 };
|
package/dist/index-aqqcc4wq.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// packages/admin-react/src/patterns/AdminConfirmAction.tsx
|
|
2
|
-
import { UGAlert, UGAlertDescription } from "@ug666/ui-react";
|
|
3
|
-
import { UGConfirmDialog } from "@ug666/ui-react/patterns";
|
|
4
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
5
|
-
function AdminConfirmAction2({
|
|
6
|
-
open,
|
|
7
|
-
title,
|
|
8
|
-
description,
|
|
9
|
-
confirmText,
|
|
10
|
-
loading = false,
|
|
11
|
-
error,
|
|
12
|
-
onOpenChange,
|
|
13
|
-
onConfirm
|
|
14
|
-
}) {
|
|
15
|
-
return /* @__PURE__ */ jsxDEV(UGConfirmDialog, {
|
|
16
|
-
closeOnConfirm: false,
|
|
17
|
-
confirmText,
|
|
18
|
-
description,
|
|
19
|
-
loading,
|
|
20
|
-
onConfirm,
|
|
21
|
-
onOpenChange,
|
|
22
|
-
open,
|
|
23
|
-
title,
|
|
24
|
-
variant: "destructive",
|
|
25
|
-
children: error ? /* @__PURE__ */ jsxDEV(UGAlert, {
|
|
26
|
-
variant: "destructive",
|
|
27
|
-
children: /* @__PURE__ */ jsxDEV(UGAlertDescription, {
|
|
28
|
-
children: error
|
|
29
|
-
}, undefined, false, undefined, this)
|
|
30
|
-
}, undefined, false, undefined, this) : null
|
|
31
|
-
}, undefined, false, undefined, this);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { AdminConfirmAction2 };
|
package/dist/index-keve3ryw.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// packages/admin-react/src/patterns/AdminPage.tsx
|
|
2
|
-
import { UGPageHeader } from "@ug666/ui-react/patterns";
|
|
3
|
-
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
4
|
-
function AdminPage2({
|
|
5
|
-
className,
|
|
6
|
-
title,
|
|
7
|
-
description,
|
|
8
|
-
badge,
|
|
9
|
-
meta,
|
|
10
|
-
primaryAction,
|
|
11
|
-
secondaryActions,
|
|
12
|
-
visuallyHiddenHeader = false,
|
|
13
|
-
children
|
|
14
|
-
}) {
|
|
15
|
-
const actions = secondaryActions || primaryAction ? /* @__PURE__ */ jsxDEV(Fragment, {
|
|
16
|
-
children: [
|
|
17
|
-
secondaryActions,
|
|
18
|
-
primaryAction
|
|
19
|
-
]
|
|
20
|
-
}, undefined, true, undefined, this) : undefined;
|
|
21
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
22
|
-
className: className ? `admin-page ${className}` : "admin-page",
|
|
23
|
-
children: [
|
|
24
|
-
visuallyHiddenHeader ? /* @__PURE__ */ jsxDEV("h1", {
|
|
25
|
-
className: "sr-only",
|
|
26
|
-
children: title
|
|
27
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV(UGPageHeader, {
|
|
28
|
-
actions,
|
|
29
|
-
badge,
|
|
30
|
-
description,
|
|
31
|
-
meta,
|
|
32
|
-
title
|
|
33
|
-
}, undefined, false, undefined, this),
|
|
34
|
-
children
|
|
35
|
-
]
|
|
36
|
-
}, undefined, true, undefined, this);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { AdminPage2 };
|
package/dist/index-nyrhj7se.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminPage2
|
|
3
|
-
} from "./index-keve3ryw.js";
|
|
4
|
-
|
|
5
|
-
// packages/admin-react/src/patterns/AdminListPage.tsx
|
|
6
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
7
|
-
function AdminListPage2({
|
|
8
|
-
search,
|
|
9
|
-
summary,
|
|
10
|
-
searchId,
|
|
11
|
-
searchHidden = false,
|
|
12
|
-
toolbarStart,
|
|
13
|
-
toolbarEnd,
|
|
14
|
-
children,
|
|
15
|
-
footer,
|
|
16
|
-
...pageProps
|
|
17
|
-
}) {
|
|
18
|
-
const { primaryAction, secondaryActions, ...headerProps } = pageProps;
|
|
19
|
-
return /* @__PURE__ */ jsxDEV(AdminPage2, {
|
|
20
|
-
...headerProps,
|
|
21
|
-
visuallyHiddenHeader: true,
|
|
22
|
-
className: "admin-page--list",
|
|
23
|
-
children: /* @__PURE__ */ jsxDEV("div", {
|
|
24
|
-
className: "admin-list-panel",
|
|
25
|
-
children: [
|
|
26
|
-
search ? /* @__PURE__ */ jsxDEV("div", {
|
|
27
|
-
id: searchId,
|
|
28
|
-
className: "admin-list-search",
|
|
29
|
-
hidden: searchHidden,
|
|
30
|
-
children: search
|
|
31
|
-
}, undefined, false, undefined, this) : null,
|
|
32
|
-
summary,
|
|
33
|
-
primaryAction || secondaryActions || toolbarStart || toolbarEnd ? /* @__PURE__ */ jsxDEV("div", {
|
|
34
|
-
className: "admin-list-actions",
|
|
35
|
-
children: [
|
|
36
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
37
|
-
className: "admin-list-actions__start",
|
|
38
|
-
children: [
|
|
39
|
-
primaryAction,
|
|
40
|
-
secondaryActions,
|
|
41
|
-
toolbarStart
|
|
42
|
-
]
|
|
43
|
-
}, undefined, true, undefined, this),
|
|
44
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
45
|
-
className: "admin-list-actions__end",
|
|
46
|
-
children: toolbarEnd
|
|
47
|
-
}, undefined, false, undefined, this)
|
|
48
|
-
]
|
|
49
|
-
}, undefined, true, undefined, this) : null,
|
|
50
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
51
|
-
className: "admin-list-content",
|
|
52
|
-
children
|
|
53
|
-
}, undefined, false, undefined, this),
|
|
54
|
-
footer ? /* @__PURE__ */ jsxDEV("div", {
|
|
55
|
-
className: "admin-list-footer",
|
|
56
|
-
children: footer
|
|
57
|
-
}, undefined, false, undefined, this) : null
|
|
58
|
-
]
|
|
59
|
-
}, undefined, true, undefined, this)
|
|
60
|
-
}, undefined, false, undefined, this);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { AdminListPage2 };
|
package/dist/index-zt432pkz.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminPage2
|
|
3
|
-
} from "./index-keve3ryw.js";
|
|
4
|
-
|
|
5
|
-
// packages/admin-react/src/patterns/AdminFormPage.tsx
|
|
6
|
-
import { t } from "@ug666/admin-core/i18n";
|
|
7
|
-
import { UGAlert, UGAlertDescription, UGButton, UGCard, UGCardContent } from "@ug666/ui-react";
|
|
8
|
-
import { UGConfirmDialog } from "@ug666/ui-react/patterns";
|
|
9
|
-
import { ArrowLeft, Save } from "lucide-react";
|
|
10
|
-
import { useEffect } from "react";
|
|
11
|
-
import { useBlocker } from "react-router-dom";
|
|
12
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
13
|
-
function AdminFormPage2({
|
|
14
|
-
title,
|
|
15
|
-
description,
|
|
16
|
-
children,
|
|
17
|
-
error,
|
|
18
|
-
isDirty = false,
|
|
19
|
-
submitting = false,
|
|
20
|
-
submitDisabled = false,
|
|
21
|
-
submitLabel = t("common.save"),
|
|
22
|
-
submitAndReturnLabel = t("common.saveAndReturn"),
|
|
23
|
-
onCancel,
|
|
24
|
-
onSubmit,
|
|
25
|
-
onSubmitAndReturn
|
|
26
|
-
}) {
|
|
27
|
-
const blocker = useBlocker(({ currentLocation, nextLocation }) => isDirty && currentLocation.pathname !== nextLocation.pathname);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
function handleBeforeUnload(event) {
|
|
30
|
-
if (!isDirty)
|
|
31
|
-
return;
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
event.returnValue = "";
|
|
34
|
-
}
|
|
35
|
-
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
36
|
-
return () => window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
37
|
-
}, [isDirty]);
|
|
38
|
-
function handleSubmit(event) {
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
onSubmit();
|
|
41
|
-
}
|
|
42
|
-
return /* @__PURE__ */ jsxDEV(AdminPage2, {
|
|
43
|
-
description,
|
|
44
|
-
title,
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ jsxDEV(UGCard, {
|
|
47
|
-
className: "admin-form-panel",
|
|
48
|
-
children: /* @__PURE__ */ jsxDEV(UGCardContent, {
|
|
49
|
-
className: "admin-card-content",
|
|
50
|
-
children: /* @__PURE__ */ jsxDEV("form", {
|
|
51
|
-
className: "admin-form",
|
|
52
|
-
onSubmit: handleSubmit,
|
|
53
|
-
children: [
|
|
54
|
-
error ? /* @__PURE__ */ jsxDEV(UGAlert, {
|
|
55
|
-
variant: "destructive",
|
|
56
|
-
children: /* @__PURE__ */ jsxDEV(UGAlertDescription, {
|
|
57
|
-
children: error
|
|
58
|
-
}, undefined, false, undefined, this)
|
|
59
|
-
}, undefined, false, undefined, this) : null,
|
|
60
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
61
|
-
className: "admin-form__fields",
|
|
62
|
-
children
|
|
63
|
-
}, undefined, false, undefined, this),
|
|
64
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
65
|
-
className: "admin-form__actions",
|
|
66
|
-
children: [
|
|
67
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
68
|
-
disabled: submitting,
|
|
69
|
-
onClick: onCancel,
|
|
70
|
-
type: "button",
|
|
71
|
-
variant: "default",
|
|
72
|
-
children: [
|
|
73
|
-
/* @__PURE__ */ jsxDEV(ArrowLeft, {
|
|
74
|
-
"aria-hidden": "true",
|
|
75
|
-
size: 16
|
|
76
|
-
}, undefined, false, undefined, this),
|
|
77
|
-
"返回"
|
|
78
|
-
]
|
|
79
|
-
}, undefined, true, undefined, this),
|
|
80
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
81
|
-
disabled: submitDisabled,
|
|
82
|
-
loading: submitting,
|
|
83
|
-
tone: "primary",
|
|
84
|
-
type: "submit",
|
|
85
|
-
variant: "solid",
|
|
86
|
-
children: [
|
|
87
|
-
/* @__PURE__ */ jsxDEV(Save, {
|
|
88
|
-
"aria-hidden": "true",
|
|
89
|
-
size: 16
|
|
90
|
-
}, undefined, false, undefined, this),
|
|
91
|
-
submitLabel
|
|
92
|
-
]
|
|
93
|
-
}, undefined, true, undefined, this),
|
|
94
|
-
onSubmitAndReturn ? /* @__PURE__ */ jsxDEV(UGButton, {
|
|
95
|
-
disabled: submitting || submitDisabled,
|
|
96
|
-
onClick: onSubmitAndReturn,
|
|
97
|
-
type: "button",
|
|
98
|
-
variant: "default",
|
|
99
|
-
children: submitAndReturnLabel
|
|
100
|
-
}, undefined, false, undefined, this) : null
|
|
101
|
-
]
|
|
102
|
-
}, undefined, true, undefined, this)
|
|
103
|
-
]
|
|
104
|
-
}, undefined, true, undefined, this)
|
|
105
|
-
}, undefined, false, undefined, this)
|
|
106
|
-
}, undefined, false, undefined, this),
|
|
107
|
-
/* @__PURE__ */ jsxDEV(UGConfirmDialog, {
|
|
108
|
-
closeOnConfirm: false,
|
|
109
|
-
confirmText: "放弃修改",
|
|
110
|
-
description: "当前页面存在尚未保存的修改,离开后这些内容将丢失。",
|
|
111
|
-
onCancel: () => blocker.reset?.(),
|
|
112
|
-
onConfirm: () => blocker.proceed?.(),
|
|
113
|
-
onOpenChange: (open) => {
|
|
114
|
-
if (!open)
|
|
115
|
-
blocker.reset?.();
|
|
116
|
-
},
|
|
117
|
-
open: blocker.state === "blocked",
|
|
118
|
-
title: "确认离开当前页面?",
|
|
119
|
-
variant: "destructive"
|
|
120
|
-
}, undefined, false, undefined, this)
|
|
121
|
-
]
|
|
122
|
-
}, undefined, true, undefined, this);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { AdminFormPage2 };
|