@ug666/admin-react 0.1.0-beta.2 → 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/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 -42
- package/dist/patterns/AdminColumnSettings.js +1 -8
- package/dist/patterns/AdminConfirmAction.js +1 -6
- package/dist/patterns/AdminDetailPage.js +1 -7
- package/dist/patterns/AdminFormDialog.js +1 -6
- 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 -6
- package/package.json +2 -2
- package/dist/AdminColumnSettings-09epsf86.js +0 -80
- package/dist/AdminColumnSettings-4cv6a9m2.js +0 -125
- package/dist/AdminColumnSettings-93ajawas.js +0 -64
- package/dist/AdminColumnSettings-aqqcc4wq.js +0 -34
- package/dist/AdminColumnSettings-be5c6tmr.js +0 -43
- package/dist/AdminColumnSettings-nnrtybx5.js +0 -88
- package/dist/AdminColumnSettings-sz4q6vza.js +0 -177
- package/dist/AdminColumnSettings-t2b7bfqc.js +0 -43
- package/dist/AdminColumnSettings-tf48jqrt.js +0 -132
|
@@ -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,42 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
useAdminColumnLayout2,
|
|
3
|
-
AdminColumnSettings2
|
|
4
|
-
} from "./AdminColumnSettings-sz4q6vza.js";
|
|
5
|
-
import {
|
|
6
|
-
AdminConfirmAction2
|
|
7
|
-
} from "./AdminColumnSettings-aqqcc4wq.js";
|
|
8
|
-
import {
|
|
9
|
-
AdminPage2
|
|
10
|
-
} from "./AdminColumnSettings-be5c6tmr.js";
|
|
11
|
-
import {
|
|
12
|
-
AdminDetailPage2
|
|
13
|
-
} from "./AdminColumnSettings-t2b7bfqc.js";
|
|
14
|
-
import {
|
|
15
|
-
AdminFormDialog2
|
|
16
|
-
} from "./AdminColumnSettings-nnrtybx5.js";
|
|
17
|
-
import {
|
|
18
|
-
AdminFormPage2
|
|
19
|
-
} from "./AdminColumnSettings-4cv6a9m2.js";
|
|
20
|
-
import {
|
|
21
|
-
AdminListPage2
|
|
22
|
-
} from "./AdminColumnSettings-09epsf86.js";
|
|
23
|
-
import {
|
|
24
|
-
AdminSearchField2,
|
|
25
|
-
AdminSearchForm2
|
|
26
|
-
} from "./AdminColumnSettings-tf48jqrt.js";
|
|
27
|
-
import {
|
|
28
|
-
AdminTabContextMenu2
|
|
29
|
-
} from "./AdminColumnSettings-93ajawas.js";
|
|
30
|
-
export {
|
|
31
|
-
AdminColumnSettings2 as AdminColumnSettings,
|
|
32
|
-
AdminConfirmAction2 as AdminConfirmAction,
|
|
33
|
-
AdminDetailPage2 as AdminDetailPage,
|
|
34
|
-
AdminFormDialog2 as AdminFormDialog,
|
|
35
|
-
AdminFormPage2 as AdminFormPage,
|
|
36
|
-
AdminListPage2 as AdminListPage,
|
|
37
|
-
AdminPage2 as AdminPage,
|
|
38
|
-
AdminSearchField2 as AdminSearchField,
|
|
39
|
-
AdminSearchForm2 as AdminSearchForm,
|
|
40
|
-
AdminTabContextMenu2 as AdminTabContextMenu,
|
|
41
|
-
useAdminColumnLayout2 as useAdminColumnLayout
|
|
42
|
-
};
|
|
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};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
useAdminColumnLayout2,
|
|
3
|
-
AdminColumnSettings2
|
|
4
|
-
} from "../AdminColumnSettings-sz4q6vza.js";
|
|
5
|
-
export {
|
|
6
|
-
AdminColumnSettings2 as AdminColumnSettings,
|
|
7
|
-
useAdminColumnLayout2 as useAdminColumnLayout
|
|
8
|
-
};
|
|
1
|
+
import{n,o}from"../AdminColumnSettings-a6913hy9.js";export{o as AdminColumnSettings,n as useAdminColumnLayout};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminDetailPage2
|
|
3
|
-
} from "../AdminColumnSettings-t2b7bfqc.js";
|
|
4
|
-
import"../AdminColumnSettings-be5c6tmr.js";
|
|
5
|
-
export {
|
|
6
|
-
AdminDetailPage2 as AdminDetailPage
|
|
7
|
-
};
|
|
1
|
+
import{m}from"../AdminColumnSettings-fb9zzqec.js";import"../AdminColumnSettings-1xerrrqm.js";export{m as AdminDetailPage};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminFormPage2
|
|
3
|
-
} from "../AdminColumnSettings-4cv6a9m2.js";
|
|
4
|
-
import"../AdminColumnSettings-be5c6tmr.js";
|
|
5
|
-
export {
|
|
6
|
-
AdminFormPage2 as AdminFormPage
|
|
7
|
-
};
|
|
1
|
+
import{i}from"../AdminColumnSettings-247f7yan.js";import"../AdminColumnSettings-1xerrrqm.js";export{i as AdminFormPage};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminListPage2
|
|
3
|
-
} from "../AdminColumnSettings-09epsf86.js";
|
|
4
|
-
import"../AdminColumnSettings-be5c6tmr.js";
|
|
5
|
-
export {
|
|
6
|
-
AdminListPage2 as AdminListPage
|
|
7
|
-
};
|
|
1
|
+
import{r}from"../AdminColumnSettings-aqnrn2jc.js";import"../AdminColumnSettings-1xerrrqm.js";export{r as AdminListPage};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
AdminSearchField2,
|
|
3
|
-
AdminSearchForm2
|
|
4
|
-
} from "../AdminColumnSettings-tf48jqrt.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};
|
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": {
|
|
@@ -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"
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminPage2
|
|
3
|
-
} from "./AdminColumnSettings-be5c6tmr.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 { title, primaryAction, secondaryActions, ...rest } = pageProps;
|
|
19
|
-
const hasActions = Boolean(primaryAction || secondaryActions || toolbarEnd);
|
|
20
|
-
return /* @__PURE__ */ jsxDEV(AdminPage2, {
|
|
21
|
-
...rest,
|
|
22
|
-
className: "admin-page--list",
|
|
23
|
-
title,
|
|
24
|
-
visuallyHiddenHeader: true,
|
|
25
|
-
children: [
|
|
26
|
-
search ? /* @__PURE__ */ jsxDEV("div", {
|
|
27
|
-
className: "admin-list-search-panel",
|
|
28
|
-
hidden: searchHidden,
|
|
29
|
-
id: searchId,
|
|
30
|
-
children: /* @__PURE__ */ jsxDEV("div", {
|
|
31
|
-
className: "admin-list-search",
|
|
32
|
-
children: search
|
|
33
|
-
}, undefined, false, undefined, this)
|
|
34
|
-
}, undefined, false, undefined, this) : null,
|
|
35
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
36
|
-
className: "admin-list-panel",
|
|
37
|
-
children: [
|
|
38
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
39
|
-
className: "admin-list-header",
|
|
40
|
-
children: [
|
|
41
|
-
/* @__PURE__ */ jsxDEV("h2", {
|
|
42
|
-
className: "admin-list-header__title",
|
|
43
|
-
children: title
|
|
44
|
-
}, undefined, false, undefined, this),
|
|
45
|
-
hasActions ? /* @__PURE__ */ jsxDEV("div", {
|
|
46
|
-
className: "admin-list-header__actions",
|
|
47
|
-
children: [
|
|
48
|
-
secondaryActions,
|
|
49
|
-
primaryAction,
|
|
50
|
-
toolbarEnd ? /* @__PURE__ */ jsxDEV("div", {
|
|
51
|
-
className: "admin-list-header__tools",
|
|
52
|
-
children: toolbarEnd
|
|
53
|
-
}, undefined, false, undefined, this) : null
|
|
54
|
-
]
|
|
55
|
-
}, undefined, true, undefined, this) : null
|
|
56
|
-
]
|
|
57
|
-
}, undefined, true, undefined, this),
|
|
58
|
-
summary,
|
|
59
|
-
toolbarStart ? /* @__PURE__ */ jsxDEV("div", {
|
|
60
|
-
className: "admin-list-actions",
|
|
61
|
-
children: /* @__PURE__ */ jsxDEV("div", {
|
|
62
|
-
className: "admin-list-actions__start",
|
|
63
|
-
children: toolbarStart
|
|
64
|
-
}, undefined, false, undefined, this)
|
|
65
|
-
}, undefined, false, undefined, this) : null,
|
|
66
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
67
|
-
className: "admin-list-content",
|
|
68
|
-
children
|
|
69
|
-
}, undefined, false, undefined, this),
|
|
70
|
-
footer ? /* @__PURE__ */ jsxDEV("div", {
|
|
71
|
-
className: "admin-list-footer",
|
|
72
|
-
children: footer
|
|
73
|
-
}, undefined, false, undefined, this) : null
|
|
74
|
-
]
|
|
75
|
-
}, undefined, true, undefined, this)
|
|
76
|
-
]
|
|
77
|
-
}, undefined, true, undefined, this);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export { AdminListPage2 };
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminPage2
|
|
3
|
-
} from "./AdminColumnSettings-be5c6tmr.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 };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// packages/admin-react/src/patterns/AdminTabContextMenu.tsx
|
|
2
|
-
import {
|
|
3
|
-
UGContextMenu,
|
|
4
|
-
UGContextMenuContent,
|
|
5
|
-
UGContextMenuItem,
|
|
6
|
-
UGContextMenuTrigger
|
|
7
|
-
} from "@ug666/ui-react";
|
|
8
|
-
import { useRef } from "react";
|
|
9
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
10
|
-
function AdminTabContextMenu2({
|
|
11
|
-
tabs,
|
|
12
|
-
onCloseOthers,
|
|
13
|
-
children
|
|
14
|
-
}) {
|
|
15
|
-
const trigger = useRef(null);
|
|
16
|
-
const tabId = useRef(undefined);
|
|
17
|
-
function prepare(event) {
|
|
18
|
-
if (!(event.target instanceof Element))
|
|
19
|
-
return;
|
|
20
|
-
const item = event.target.closest('[data-ug="app-tabs"] [data-ug-slot="item"]');
|
|
21
|
-
const value = item?.dataset.value;
|
|
22
|
-
if (!value || !tabs.some((tab) => tab.id !== value && tab.closable)) {
|
|
23
|
-
event.stopPropagation();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
tabId.current = value;
|
|
27
|
-
trigger.current = item?.querySelector('[data-ug-slot="trigger"]') ?? null;
|
|
28
|
-
}
|
|
29
|
-
function restoreFocus() {
|
|
30
|
-
const target = trigger.current;
|
|
31
|
-
requestAnimationFrame(() => target?.focus({ preventScroll: true }));
|
|
32
|
-
}
|
|
33
|
-
return /* @__PURE__ */ jsxDEV(UGContextMenu, {
|
|
34
|
-
className: "admin-tab-menu",
|
|
35
|
-
children: [
|
|
36
|
-
/* @__PURE__ */ jsxDEV(UGContextMenuTrigger, {
|
|
37
|
-
className: "admin-tab-menu__trigger",
|
|
38
|
-
onContextMenuCapture: prepare,
|
|
39
|
-
onKeyDownCapture: (event) => {
|
|
40
|
-
if (event.key === "ContextMenu" || event.shiftKey && event.key === "F10")
|
|
41
|
-
prepare(event);
|
|
42
|
-
},
|
|
43
|
-
children
|
|
44
|
-
}, undefined, false, undefined, this),
|
|
45
|
-
/* @__PURE__ */ jsxDEV(UGContextMenuContent, {
|
|
46
|
-
"aria-label": "页签操作",
|
|
47
|
-
children: /* @__PURE__ */ jsxDEV(UGContextMenuItem, {
|
|
48
|
-
onClick: () => {
|
|
49
|
-
if (tabId.current)
|
|
50
|
-
onCloseOthers(tabId.current);
|
|
51
|
-
restoreFocus();
|
|
52
|
-
},
|
|
53
|
-
onKeyDown: (event) => {
|
|
54
|
-
if (event.key === "Escape")
|
|
55
|
-
restoreFocus();
|
|
56
|
-
},
|
|
57
|
-
children: "关闭其他页签"
|
|
58
|
-
}, undefined, false, undefined, this)
|
|
59
|
-
}, undefined, false, undefined, this)
|
|
60
|
-
]
|
|
61
|
-
}, undefined, true, undefined, this);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { AdminTabContextMenu2 };
|
|
@@ -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 };
|
|
@@ -1,43 +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
|
-
showDescription = false,
|
|
9
|
-
badge,
|
|
10
|
-
meta,
|
|
11
|
-
primaryAction,
|
|
12
|
-
secondaryActions,
|
|
13
|
-
visuallyHiddenHeader = false,
|
|
14
|
-
children
|
|
15
|
-
}) {
|
|
16
|
-
const actions = secondaryActions || primaryAction ? /* @__PURE__ */ jsxDEV(Fragment, {
|
|
17
|
-
children: [
|
|
18
|
-
secondaryActions,
|
|
19
|
-
primaryAction
|
|
20
|
-
]
|
|
21
|
-
}, undefined, true, undefined, this) : undefined;
|
|
22
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
23
|
-
className: className ? `admin-page ${className}` : "admin-page",
|
|
24
|
-
children: [
|
|
25
|
-
visuallyHiddenHeader ? /* @__PURE__ */ jsxDEV("h1", {
|
|
26
|
-
className: "sr-only",
|
|
27
|
-
children: title
|
|
28
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV(UGPageHeader, {
|
|
29
|
-
actions,
|
|
30
|
-
badge,
|
|
31
|
-
description: showDescription ? description : undefined,
|
|
32
|
-
meta,
|
|
33
|
-
title: /* @__PURE__ */ jsxDEV("span", {
|
|
34
|
-
className: "admin-page__title",
|
|
35
|
-
children: title
|
|
36
|
-
}, undefined, false, undefined, this)
|
|
37
|
-
}, undefined, false, undefined, this),
|
|
38
|
-
children
|
|
39
|
-
]
|
|
40
|
-
}, undefined, true, undefined, this);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { AdminPage2 };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// packages/admin-react/src/patterns/AdminFormDialog.tsx
|
|
2
|
-
import {
|
|
3
|
-
UGButton,
|
|
4
|
-
UGModal,
|
|
5
|
-
UGModalBody,
|
|
6
|
-
UGModalCloseButton,
|
|
7
|
-
UGModalContent,
|
|
8
|
-
UGModalFooter,
|
|
9
|
-
UGModalHeader,
|
|
10
|
-
UGModalTitle
|
|
11
|
-
} from "@ug666/ui-react";
|
|
12
|
-
import { useId } from "react";
|
|
13
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
14
|
-
function AdminFormDialog2({
|
|
15
|
-
open,
|
|
16
|
-
title,
|
|
17
|
-
submitLabel,
|
|
18
|
-
cancelLabel = "取消",
|
|
19
|
-
loading = false,
|
|
20
|
-
disabled = false,
|
|
21
|
-
closeOnOverlay = true,
|
|
22
|
-
initialFocusSelector,
|
|
23
|
-
size,
|
|
24
|
-
onClose,
|
|
25
|
-
onSubmit,
|
|
26
|
-
children
|
|
27
|
-
}) {
|
|
28
|
-
const formId = useId();
|
|
29
|
-
function handleSubmit(event) {
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
if (!loading && !disabled)
|
|
32
|
-
onSubmit();
|
|
33
|
-
}
|
|
34
|
-
return /* @__PURE__ */ jsxDEV(UGModal, {
|
|
35
|
-
ariaLabel: title,
|
|
36
|
-
closeOnEsc: !loading,
|
|
37
|
-
closeOnOverlay: closeOnOverlay && !loading,
|
|
38
|
-
initialFocusSelector,
|
|
39
|
-
onClose: () => {
|
|
40
|
-
if (!loading)
|
|
41
|
-
onClose();
|
|
42
|
-
},
|
|
43
|
-
open,
|
|
44
|
-
size,
|
|
45
|
-
children: /* @__PURE__ */ jsxDEV(UGModalContent, {
|
|
46
|
-
children: [
|
|
47
|
-
/* @__PURE__ */ jsxDEV(UGModalHeader, {
|
|
48
|
-
children: [
|
|
49
|
-
/* @__PURE__ */ jsxDEV(UGModalTitle, {
|
|
50
|
-
children: title
|
|
51
|
-
}, undefined, false, undefined, this),
|
|
52
|
-
!loading ? /* @__PURE__ */ jsxDEV(UGModalCloseButton, {}, undefined, false, undefined, this) : null
|
|
53
|
-
]
|
|
54
|
-
}, undefined, true, undefined, this),
|
|
55
|
-
/* @__PURE__ */ jsxDEV(UGModalBody, {
|
|
56
|
-
children: /* @__PURE__ */ jsxDEV("form", {
|
|
57
|
-
className: "admin-section-form",
|
|
58
|
-
id: formId,
|
|
59
|
-
onSubmit: handleSubmit,
|
|
60
|
-
children
|
|
61
|
-
}, undefined, false, undefined, this)
|
|
62
|
-
}, undefined, false, undefined, this),
|
|
63
|
-
/* @__PURE__ */ jsxDEV(UGModalFooter, {
|
|
64
|
-
children: [
|
|
65
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
66
|
-
disabled: loading,
|
|
67
|
-
onClick: onClose,
|
|
68
|
-
type: "button",
|
|
69
|
-
variant: "text",
|
|
70
|
-
children: cancelLabel
|
|
71
|
-
}, undefined, false, undefined, this),
|
|
72
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
73
|
-
disabled,
|
|
74
|
-
form: formId,
|
|
75
|
-
loading,
|
|
76
|
-
tone: "primary",
|
|
77
|
-
type: "submit",
|
|
78
|
-
variant: "solid",
|
|
79
|
-
children: submitLabel
|
|
80
|
-
}, undefined, false, undefined, this)
|
|
81
|
-
]
|
|
82
|
-
}, undefined, true, undefined, this)
|
|
83
|
-
]
|
|
84
|
-
}, undefined, true, undefined, this)
|
|
85
|
-
}, undefined, false, undefined, this);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export { AdminFormDialog2 };
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// packages/admin-react/src/patterns/AdminColumnSettings.tsx
|
|
2
|
-
import {
|
|
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 { useRef, useState } from "react";
|
|
19
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
20
|
-
function useAdminColumnLayout2(scope) {
|
|
21
|
-
const [layout, setLayout] = useState(() => readAdminColumnLayout(scope, window.localStorage));
|
|
22
|
-
function changeLayout(next) {
|
|
23
|
-
setLayout(next);
|
|
24
|
-
writeAdminColumnLayout(scope, next, window.localStorage);
|
|
25
|
-
}
|
|
26
|
-
return [layout, changeLayout];
|
|
27
|
-
}
|
|
28
|
-
function AdminColumnSettings2({
|
|
29
|
-
columns,
|
|
30
|
-
hidden,
|
|
31
|
-
onChange,
|
|
32
|
-
ariaLabel = "列设置",
|
|
33
|
-
triggerLabel,
|
|
34
|
-
layout,
|
|
35
|
-
onLayoutChange
|
|
36
|
-
}) {
|
|
37
|
-
const dragged = useRef(null);
|
|
38
|
-
const orderedColumns = orderAdminColumns(columns, layout?.order ?? []);
|
|
39
|
-
const order = orderedColumns.map((column) => column.id);
|
|
40
|
-
const visibleCount = columns.filter((column) => column.required || !hidden.includes(column.id)).length;
|
|
41
|
-
function toggle(id, visible) {
|
|
42
|
-
if (!visible && visibleCount <= 1)
|
|
43
|
-
return;
|
|
44
|
-
onChange(visible ? hidden.filter((item) => item !== id) : [...new Set([...hidden, id])]);
|
|
45
|
-
}
|
|
46
|
-
function move(id, target) {
|
|
47
|
-
if (layout && id !== target)
|
|
48
|
-
onLayoutChange?.({ ...layout, order: moveAdminColumn(order, id, target) });
|
|
49
|
-
}
|
|
50
|
-
return /* @__PURE__ */ jsxDEV(UGPopover, {
|
|
51
|
-
children: [
|
|
52
|
-
/* @__PURE__ */ jsxDEV(UGPopoverTrigger, {
|
|
53
|
-
className: "inline-flex",
|
|
54
|
-
children: /* @__PURE__ */ jsxDEV(UGButton, {
|
|
55
|
-
"aria-label": ariaLabel,
|
|
56
|
-
size: triggerLabel ? "default" : "icon",
|
|
57
|
-
title: triggerLabel ? undefined : ariaLabel,
|
|
58
|
-
type: "button",
|
|
59
|
-
variant: "outline",
|
|
60
|
-
children: [
|
|
61
|
-
/* @__PURE__ */ jsxDEV(Settings2, {
|
|
62
|
-
"aria-hidden": "true",
|
|
63
|
-
size: 16
|
|
64
|
-
}, undefined, false, undefined, this),
|
|
65
|
-
triggerLabel
|
|
66
|
-
]
|
|
67
|
-
}, undefined, true, undefined, this)
|
|
68
|
-
}, undefined, false, undefined, this),
|
|
69
|
-
/* @__PURE__ */ jsxDEV(UGPopoverContent, {
|
|
70
|
-
align: "end",
|
|
71
|
-
className: "admin-column-settings",
|
|
72
|
-
side: "bottom",
|
|
73
|
-
children: [
|
|
74
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
75
|
-
className: "admin-column-settings__head",
|
|
76
|
-
children: [
|
|
77
|
-
/* @__PURE__ */ jsxDEV("strong", {
|
|
78
|
-
children: "显示列"
|
|
79
|
-
}, undefined, false, undefined, this),
|
|
80
|
-
/* @__PURE__ */ jsxDEV(UGButton, {
|
|
81
|
-
onClick: () => onChange([]),
|
|
82
|
-
size: "sm",
|
|
83
|
-
type: "button",
|
|
84
|
-
variant: "text",
|
|
85
|
-
children: "全部显示"
|
|
86
|
-
}, undefined, false, undefined, this)
|
|
87
|
-
]
|
|
88
|
-
}, undefined, true, undefined, this),
|
|
89
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
90
|
-
className: "admin-column-settings__list",
|
|
91
|
-
children: 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 /* @__PURE__ */ jsxDEV("div", {
|
|
97
|
-
className: "admin-column-settings__row",
|
|
98
|
-
onDragOver: (event) => {
|
|
99
|
-
if (dragged.current)
|
|
100
|
-
event.preventDefault();
|
|
101
|
-
},
|
|
102
|
-
onDrop: (event) => {
|
|
103
|
-
if (!dragged.current)
|
|
104
|
-
return;
|
|
105
|
-
event.preventDefault();
|
|
106
|
-
move(dragged.current, column.id);
|
|
107
|
-
dragged.current = null;
|
|
108
|
-
},
|
|
109
|
-
children: [
|
|
110
|
-
layout && onLayoutChange ? /* @__PURE__ */ jsxDEV(UGButton, {
|
|
111
|
-
"aria-label": `调整${title}的列顺序`,
|
|
112
|
-
"aria-keyshortcuts": "ArrowUp ArrowDown",
|
|
113
|
-
className: "admin-column-settings__grip",
|
|
114
|
-
draggable: true,
|
|
115
|
-
onDragStart: (event) => {
|
|
116
|
-
dragged.current = column.id;
|
|
117
|
-
event.dataTransfer.effectAllowed = "move";
|
|
118
|
-
event.dataTransfer.setData("text/plain", column.id);
|
|
119
|
-
},
|
|
120
|
-
onDragEnd: () => {
|
|
121
|
-
dragged.current = null;
|
|
122
|
-
},
|
|
123
|
-
onKeyDown: (event) => {
|
|
124
|
-
if (event.key !== "ArrowUp" && event.key !== "ArrowDown")
|
|
125
|
-
return;
|
|
126
|
-
event.preventDefault();
|
|
127
|
-
const target = order[index + (event.key === "ArrowUp" ? -1 : 1)];
|
|
128
|
-
if (target)
|
|
129
|
-
move(column.id, target);
|
|
130
|
-
},
|
|
131
|
-
size: "icon-sm",
|
|
132
|
-
title: "拖动或按方向键调整列顺序",
|
|
133
|
-
type: "button",
|
|
134
|
-
variant: "ghost",
|
|
135
|
-
children: /* @__PURE__ */ jsxDEV(GripVertical, {
|
|
136
|
-
"aria-hidden": "true",
|
|
137
|
-
size: 14
|
|
138
|
-
}, undefined, false, undefined, this)
|
|
139
|
-
}, undefined, false, undefined, this) : null,
|
|
140
|
-
/* @__PURE__ */ jsxDEV(UGCheckbox, {
|
|
141
|
-
checked: visible,
|
|
142
|
-
disabled: column.required || visible && visibleCount <= 1,
|
|
143
|
-
label: title,
|
|
144
|
-
onCheckedChange: (checked) => toggle(column.id, checked)
|
|
145
|
-
}, undefined, false, undefined, this),
|
|
146
|
-
layout && onLayoutChange ? /* @__PURE__ */ jsxDEV(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
|
-
children: [
|
|
157
|
-
/* @__PURE__ */ jsxDEV(Pin, {
|
|
158
|
-
"aria-hidden": "true",
|
|
159
|
-
size: 14
|
|
160
|
-
}, undefined, false, undefined, this),
|
|
161
|
-
side ? /* @__PURE__ */ jsxDEV("span", {
|
|
162
|
-
"aria-hidden": "true",
|
|
163
|
-
children: side === "left" ? "左" : "右"
|
|
164
|
-
}, undefined, false, undefined, this) : null
|
|
165
|
-
]
|
|
166
|
-
}, undefined, true, undefined, this) : null
|
|
167
|
-
]
|
|
168
|
-
}, column.id, true, undefined, this);
|
|
169
|
-
})
|
|
170
|
-
}, undefined, false, undefined, this)
|
|
171
|
-
]
|
|
172
|
-
}, undefined, true, undefined, this)
|
|
173
|
-
]
|
|
174
|
-
}, undefined, true, undefined, this);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export { useAdminColumnLayout2, AdminColumnSettings2 };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminPage2
|
|
3
|
-
} from "./AdminColumnSettings-be5c6tmr.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 };
|
|
@@ -1,132 +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 = 0,
|
|
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: "outline",
|
|
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
|
-
tone: "neutral",
|
|
116
|
-
type: "button",
|
|
117
|
-
variant: "outline",
|
|
118
|
-
children: [
|
|
119
|
-
/* @__PURE__ */ jsxDEV(RotateCcw, {
|
|
120
|
-
"aria-hidden": "true",
|
|
121
|
-
size: 16
|
|
122
|
-
}, undefined, false, undefined, this),
|
|
123
|
-
"重置"
|
|
124
|
-
]
|
|
125
|
-
}, undefined, true, undefined, this)
|
|
126
|
-
]
|
|
127
|
-
}, undefined, true, undefined, this)
|
|
128
|
-
]
|
|
129
|
-
}, undefined, true, undefined, this);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export { AdminSearchField2, AdminSearchForm2 };
|