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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/LICENSE +21 -0
  2. package/dist/AdminColumnSettings-09epsf86.js +80 -0
  3. package/dist/AdminColumnSettings-4cv6a9m2.js +125 -0
  4. package/dist/AdminColumnSettings-93ajawas.js +64 -0
  5. package/dist/AdminColumnSettings-aqqcc4wq.js +34 -0
  6. package/dist/AdminColumnSettings-be5c6tmr.js +43 -0
  7. package/dist/AdminColumnSettings-nnrtybx5.js +88 -0
  8. package/dist/AdminColumnSettings-sz4q6vza.js +177 -0
  9. package/dist/AdminColumnSettings-t2b7bfqc.js +43 -0
  10. package/dist/AdminColumnSettings-tf48jqrt.js +132 -0
  11. package/dist/index.js +42 -0
  12. package/dist/index.ts.js +1 -0
  13. package/dist/patterns/AdminColumnSettings.js +8 -0
  14. package/dist/patterns/AdminConfirmAction.js +6 -0
  15. package/dist/patterns/AdminDetailPage.js +7 -0
  16. package/dist/patterns/AdminFormDialog.js +6 -0
  17. package/dist/patterns/AdminFormPage.js +7 -0
  18. package/dist/patterns/AdminListPage.js +7 -0
  19. package/dist/patterns/AdminPage.js +6 -0
  20. package/dist/patterns/AdminSearchForm.js +8 -0
  21. package/dist/patterns/AdminTabContextMenu.js +6 -0
  22. package/package.json +46 -4
  23. package/src/index.ts +11 -0
  24. package/src/patterns/AdminColumnSettings.tsx +168 -0
  25. package/src/patterns/AdminConfirmAction.tsx +44 -0
  26. package/src/patterns/AdminDetailPage.tsx +44 -0
  27. package/src/patterns/AdminFormDialog.tsx +96 -0
  28. package/src/patterns/AdminFormPage.tsx +113 -0
  29. package/src/patterns/AdminListPage.tsx +62 -0
  30. package/src/patterns/AdminPage.tsx +55 -0
  31. package/src/patterns/AdminSearchForm.tsx +124 -0
  32. package/src/patterns/AdminTabContextMenu.tsx +67 -0
  33. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 UG666
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,80 @@
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 };
@@ -0,0 +1,125 @@
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 };
@@ -0,0 +1,64 @@
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 };
@@ -0,0 +1,34 @@
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 };
@@ -0,0 +1,43 @@
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 };
@@ -0,0 +1,88 @@
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 };
@@ -0,0 +1,177 @@
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 };
@@ -0,0 +1,43 @@
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 };