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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import"./patterns/AdminConfirmAction.js";import"./patterns/AdminDetailPage.js";import"./patterns/AdminFormPage.js";import"./patterns/AdminListPage.js";import"./patterns/AdminPage.js";import"./patterns/AdminSearchField.js";import"./patterns/AdminSearchForm.js";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminConfirmAction.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminDetailPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminFormPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminListPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminSearchField.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminSearchForm.vue?vue&type=script&setup=true&lang.ts";
@@ -0,0 +1 @@
1
+ export * from "./index.ts/index.js";
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminConfirmAction.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminConfirmAction.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminDetailPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminDetailPage.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminFormPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminFormPage.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminListPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminListPage.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminPage.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminPage.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminSearchField.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminSearchField.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminSearchForm.vue?vue&type=script&setup=true&lang.ts";export*from"D:/CodeProjects/UGProject/ug-admin/packages/admin-vue/src/patterns/AdminSearchForm.vue?vue&type=script&setup=true&lang.ts";var t=e;export{t as default};
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@ug666/admin-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.0",
4
+ "description": "UG Admin Vue 渲染层:AdminPage/AdminListPage/AdminFormPage/AdminDetailPage 等页面壳与组合模式",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./src/index.ts",
9
+ "import": "./dist/index.js"
10
+ },
11
+ "./patterns/*.vue": {
12
+ "types": "./src/patterns/*.vue",
13
+ "default": "./src/patterns/*.vue"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src"
19
+ ],
20
+ "dependencies": {
21
+ "vue-router": "^4.6.4"
22
+ },
23
+ "license": "MIT",
24
+ "main": "./dist/index.js",
25
+ "types": "./src/index.ts",
26
+ "scripts": {
27
+ "build": "bun run scripts/packages/build-packages.ts"
28
+ },
29
+ "peerDependencies": {
30
+ "@ug666/admin-core": "^0.1.0-0",
31
+ "@ug666/ui-vue": "^0.3.0-0",
32
+ "vue": "^3.5.0",
33
+ "@lucide/vue": "*"
34
+ },
35
+ "devDependencies": {
36
+ "@ug666/admin-core": "file:../admin-core",
37
+ "@ug666/ui-vue": "0.3.0-beta.3",
38
+ "vue": "3.5.45",
39
+ "@lucide/vue": "^1.27.0"
40
+ }
41
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./patterns/AdminConfirmAction.vue";
2
+ export * from "./patterns/AdminDetailPage.vue";
3
+ export * from "./patterns/AdminFormPage.vue";
4
+ export * from "./patterns/AdminListPage.vue";
5
+ export * from "./patterns/AdminPage.vue";
6
+ export * from "./patterns/AdminSearchField.vue";
7
+ export * from "./patterns/AdminSearchForm.vue";
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import { UAlert, UAlertDescription } from "@ug666/ui-vue";
3
+ import { UConfirmDialog } from "@ug666/ui-vue/patterns";
4
+
5
+ defineProps<{
6
+ open: boolean;
7
+ title: string;
8
+ description: string;
9
+ confirmText: string;
10
+ loading?: boolean;
11
+ error?: string;
12
+ }>();
13
+ const emit = defineEmits<{ "update:open": [open: boolean]; confirm: [] }>();
14
+ </script>
15
+
16
+ <template>
17
+ <UConfirmDialog
18
+ :open="open"
19
+ :title="title"
20
+ :description="description"
21
+ :confirm-text="confirmText"
22
+ :loading="loading"
23
+ :close-on-confirm="false"
24
+ variant="destructive"
25
+ @confirm="emit('confirm')"
26
+ @update:open="emit('update:open', $event)"
27
+ >
28
+ <UAlert v-if="error" variant="destructive"><UAlertDescription>{{ error }}</UAlertDescription></UAlert>
29
+ </UConfirmDialog>
30
+ </template>
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import { UCard, UCardContent, UCardHeader, UCardTitle } from "@ug666/ui-vue";
3
+ import AdminPage from "./AdminPage.vue";
4
+
5
+ export interface AdminDetailItem {
6
+ label: string;
7
+ value?: string;
8
+ }
9
+ export interface AdminDetailSection {
10
+ id: string;
11
+ title: string;
12
+ items: AdminDetailItem[];
13
+ }
14
+ defineProps<{ title: string; description?: string; sections: AdminDetailSection[] }>();
15
+ </script>
16
+
17
+ <template>
18
+ <AdminPage :title="title" :description="description">
19
+ <template v-if="$slots.badge" #badge><slot name="badge" /></template>
20
+ <template v-if="$slots.actions" #actions><slot name="actions" /></template>
21
+ <div class="admin-detail-sections">
22
+ <UCard v-for="section in sections" :key="section.id">
23
+ <UCardHeader><UCardTitle>{{ section.title }}</UCardTitle></UCardHeader>
24
+ <UCardContent class="admin-card-content">
25
+ <dl class="admin-description-list">
26
+ <div v-for="item in section.items" :key="item.label" class="admin-description-list__item">
27
+ <dt>{{ item.label }}</dt>
28
+ <dd><slot :name="`value-${section.id}-${item.label}`">{{ item.value ?? "—" }}</slot></dd>
29
+ </div>
30
+ </dl>
31
+ </UCardContent>
32
+ </UCard>
33
+ </div>
34
+ </AdminPage>
35
+ </template>
@@ -0,0 +1,95 @@
1
+ <script setup lang="ts">
2
+ import { UAlert, UAlertDescription, UButton, UCard, UCardContent } from "@ug666/ui-vue";
3
+ import { t } from "@ug666/admin-core/i18n";
4
+ import { UConfirmDialog } from "@ug666/ui-vue/patterns";
5
+ import { ArrowLeft, Save } from "@lucide/vue";
6
+ import { onBeforeUnmount, onMounted, ref } from "vue";
7
+ import { onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
8
+ import AdminPage from "./AdminPage.vue";
9
+
10
+ const props = withDefaults(
11
+ defineProps<{
12
+ title: string;
13
+ description?: string;
14
+ error?: string;
15
+ dirty?: boolean;
16
+ submitting?: boolean;
17
+ submitDisabled?: boolean;
18
+ submitLabel?: string;
19
+ submitAndReturnLabel?: string;
20
+ showSubmitAndReturn?: boolean;
21
+ }>(),
22
+ {
23
+ description: undefined,
24
+ error: undefined,
25
+ dirty: false,
26
+ submitting: false,
27
+ submitDisabled: false,
28
+ submitLabel: t("common.save"),
29
+ submitAndReturnLabel: t("common.saveAndReturn"),
30
+ showSubmitAndReturn: true,
31
+ },
32
+ );
33
+ const emit = defineEmits<{ cancel: []; submit: []; submitAndReturn: [] }>();
34
+ const leaving = ref(false);
35
+ let resolveLeave: ((allowed: boolean) => void) | undefined;
36
+
37
+ function handleBeforeUnload(event: BeforeUnloadEvent) {
38
+ if (!props.dirty) return;
39
+ event.preventDefault();
40
+ event.returnValue = "";
41
+ }
42
+
43
+ onMounted(() => window.addEventListener("beforeunload", handleBeforeUnload));
44
+ onBeforeUnmount(() => window.removeEventListener("beforeunload", handleBeforeUnload));
45
+ function requestLeave() {
46
+ if (!props.dirty) return true;
47
+ leaving.value = true;
48
+ return new Promise<boolean>((resolve) => {
49
+ resolveLeave = resolve;
50
+ });
51
+ }
52
+ onBeforeRouteLeave(requestLeave);
53
+ onBeforeRouteUpdate((to, from) => (to.path === from.path ? true : requestLeave()));
54
+
55
+ function finishLeave(allowed: boolean) {
56
+ leaving.value = false;
57
+ resolveLeave?.(allowed);
58
+ resolveLeave = undefined;
59
+ }
60
+ </script>
61
+
62
+ <template>
63
+ <AdminPage :title="title" :description="description">
64
+ <UCard class="admin-form-panel">
65
+ <UCardContent class="admin-card-content">
66
+ <form class="admin-form" @submit.prevent="emit('submit')">
67
+ <UAlert v-if="error" variant="destructive"><UAlertDescription>{{ error }}</UAlertDescription></UAlert>
68
+ <div class="admin-form__fields"><slot /></div>
69
+ <div class="admin-form__actions">
70
+ <UButton :disabled="submitting" type="button" variant="default" @click="emit('cancel')">
71
+ <ArrowLeft :size="16" aria-hidden="true" />返回
72
+ </UButton>
73
+ <UButton :loading="submitting" :disabled="submitDisabled" tone="primary" type="submit" variant="solid">
74
+ <Save :size="16" aria-hidden="true" />{{ submitLabel }}
75
+ </UButton>
76
+ <UButton v-if="showSubmitAndReturn" :disabled="submitting || submitDisabled" type="button" variant="default" @click="emit('submitAndReturn')">
77
+ {{ submitAndReturnLabel }}
78
+ </UButton>
79
+ </div>
80
+ </form>
81
+ </UCardContent>
82
+ </UCard>
83
+ <UConfirmDialog
84
+ :open="leaving"
85
+ title="确认离开当前页面?"
86
+ description="当前页面存在尚未保存的修改,离开后这些内容将丢失。"
87
+ confirm-text="放弃修改"
88
+ :close-on-confirm="false"
89
+ variant="destructive"
90
+ @cancel="finishLeave(false)"
91
+ @confirm="finishLeave(true)"
92
+ @update:open="(open) => !open && finishLeave(false)"
93
+ />
94
+ </AdminPage>
95
+ </template>
@@ -0,0 +1,25 @@
1
+ <script setup lang="ts">
2
+ import AdminPage from "./AdminPage.vue";
3
+
4
+ defineProps<{
5
+ title: string;
6
+ description?: string;
7
+ searchId?: string;
8
+ searchHidden?: boolean;
9
+ }>();
10
+ </script>
11
+
12
+ <template>
13
+ <AdminPage :title="title" :description="description" visually-hidden-header class="admin-page--list">
14
+ <div class="admin-list-panel">
15
+ <div v-if="$slots.search" :id="searchId" class="admin-list-search" :hidden="searchHidden"><slot name="search" /></div>
16
+ <slot name="summary" />
17
+ <div v-if="$slots.actions || $slots.toolbarStart || $slots.toolbarEnd" class="admin-list-actions">
18
+ <div class="admin-list-actions__start"><slot name="actions" /><slot name="toolbarStart" /></div>
19
+ <div class="admin-list-actions__end"><slot name="toolbarEnd" /></div>
20
+ </div>
21
+ <div class="admin-list-content"><slot /></div>
22
+ <div v-if="$slots.footer" class="admin-list-footer"><slot name="footer" /></div>
23
+ </div>
24
+ </AdminPage>
25
+ </template>
@@ -0,0 +1,26 @@
1
+ <script setup lang="ts">
2
+ import { UPageHeader } from "@ug666/ui-vue/patterns";
3
+
4
+ withDefaults(
5
+ defineProps<{
6
+ title: string;
7
+ description?: string;
8
+ meta?: string;
9
+ visuallyHiddenHeader?: boolean;
10
+ }>(),
11
+ {
12
+ visuallyHiddenHeader: false,
13
+ },
14
+ );
15
+ </script>
16
+
17
+ <template>
18
+ <div class="admin-page">
19
+ <h1 v-if="visuallyHiddenHeader" class="sr-only">{{ title }}</h1>
20
+ <UPageHeader v-else :title="title" :description="description" :meta="meta">
21
+ <template v-if="$slots.badge" #badge><slot name="badge" /></template>
22
+ <template v-if="$slots.actions" #actions><slot name="actions" /></template>
23
+ </UPageHeader>
24
+ <slot />
25
+ </div>
26
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ import { UGFormControl, UGFormField, UGFormItem, UGFormLabel } from "@ug666/ui-vue";
3
+ import type { CSSProperties } from "vue";
4
+
5
+ defineProps<{
6
+ name: string;
7
+ label: string;
8
+ labelFor?: string;
9
+ class?: string;
10
+ itemClass?: string;
11
+ itemStyle?: CSSProperties;
12
+ }>();
13
+ </script>
14
+
15
+ <template>
16
+ <UGFormField :name="name" :class="['admin-search-field', $props.class].filter(Boolean).join(' ')">
17
+ <UGFormItem :class="itemClass" :style="itemStyle">
18
+ <UGFormLabel :for="labelFor">{{ label }}</UGFormLabel>
19
+ <UGFormControl><slot /></UGFormControl>
20
+ </UGFormItem>
21
+ </UGFormField>
22
+ </template>
@@ -0,0 +1,52 @@
1
+ <script setup lang="ts">
2
+ import { UButton, UGForm } from "@ug666/ui-vue";
3
+ import { ChevronDown, ChevronUp, RotateCcw, Search } from "@lucide/vue";
4
+ import { ref, useId } from "vue";
5
+
6
+ withDefaults(
7
+ defineProps<{
8
+ loading?: boolean;
9
+ labelWidth?: string | number;
10
+ expandLabel?: string;
11
+ collapseLabel?: string;
12
+ }>(),
13
+ {
14
+ labelWidth: "max-content",
15
+ expandLabel: "展开",
16
+ collapseLabel: "收起",
17
+ },
18
+ );
19
+ const emit = defineEmits<{ reset: []; submit: [] }>();
20
+ const expanded = ref(false);
21
+ const expandedId = useId();
22
+ </script>
23
+
24
+ <template>
25
+ <UGForm class="admin-search-form" layout="horizontal" label-position="right" :label-width="labelWidth" size="default" @submit.prevent="emit('submit')">
26
+ <div class="admin-search-form__fields">
27
+ <slot />
28
+ <div v-if="$slots.expanded" :id="expandedId" class="admin-search-form__expanded" :hidden="!expanded"><slot name="expanded" /></div>
29
+ </div>
30
+ <div class="admin-search-form__actions">
31
+ <UButton
32
+ v-if="$slots.expanded"
33
+ :aria-expanded="expanded"
34
+ :aria-controls="expandedId"
35
+ tone="neutral"
36
+ type="button"
37
+ variant="text"
38
+ @click="expanded = !expanded"
39
+ >
40
+ <ChevronUp v-if="expanded" :size="16" aria-hidden="true" />
41
+ <ChevronDown v-else :size="16" aria-hidden="true" />
42
+ {{ expanded ? collapseLabel : expandLabel }}
43
+ </UButton>
44
+ <UButton :loading="loading" tone="primary" type="submit" variant="solid">
45
+ <Search :size="16" aria-hidden="true" />查询
46
+ </UButton>
47
+ <UButton type="button" variant="default" @click="emit('reset')">
48
+ <RotateCcw :size="16" aria-hidden="true" />重置
49
+ </UButton>
50
+ </div>
51
+ </UGForm>
52
+ </template>
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.