@done-coding/admin-core 0.1.4 → 0.2.1-alpha.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.
Files changed (42) hide show
  1. package/es/components/misc/ActionBtn.vue.mjs +117 -0
  2. package/es/components/misc/ActionBtn.vue2.mjs +4 -0
  3. package/es/components/misc/ActionConfirm.vue.mjs +7 -0
  4. package/es/components/misc/ActionConfirm.vue2.mjs +113 -0
  5. package/es/components/misc/index.mjs +11 -5
  6. package/es/components/modal/ModalPorter.vue.mjs +52 -0
  7. package/es/components/modal/ModalPorter.vue2.mjs +4 -0
  8. package/es/components/modal/ModalShelf.vue.mjs +38 -0
  9. package/es/components/modal/ModalShelf.vue2.mjs +4 -0
  10. package/es/components/modal/index.mjs +17 -11
  11. package/es/components/modal/modal-shelf-core.mjs +52 -0
  12. package/es/components/modal/modal-shelf-hierarchy.mjs +21 -0
  13. package/es/components/panel/PanelEditSwitch.vue.mjs +7 -0
  14. package/es/components/panel/PanelEditSwitch.vue2.mjs +93 -0
  15. package/es/components/panel/PanelItem.vue.mjs +54 -0
  16. package/es/components/panel/PanelItem.vue2.mjs +4 -0
  17. package/es/components/panel/PanelMain.vue.mjs +80 -0
  18. package/es/components/panel/PanelMain.vue2.mjs +4 -0
  19. package/es/components/panel/index.mjs +20 -0
  20. package/es/index.mjs +126 -109
  21. package/es/inject/key.mjs +8 -4
  22. package/es/style.css +1 -1
  23. package/package.json +2 -2
  24. package/types/components/misc/ActionBtn.vue.d.ts +26 -0
  25. package/types/components/misc/ActionConfirm.vue.d.ts +41 -0
  26. package/types/components/misc/index.d.ts +4 -1
  27. package/types/components/misc/types.d.ts +80 -0
  28. package/types/components/modal/ConfirmModal.vue.d.ts +2 -2
  29. package/types/components/modal/ModalPorter.vue.d.ts +29 -0
  30. package/types/components/modal/ModalShelf.vue.d.ts +36 -0
  31. package/types/components/modal/index.d.ts +5 -1
  32. package/types/components/modal/modal-shelf-core.d.ts +10 -0
  33. package/types/components/modal/modal-shelf-hierarchy.d.ts +7 -0
  34. package/types/components/modal/modal-shelf-types.d.ts +74 -0
  35. package/types/components/panel/PanelEditSwitch.vue.d.ts +31 -0
  36. package/types/components/panel/PanelItem.vue.d.ts +21 -0
  37. package/types/components/panel/PanelMain.vue.d.ts +17 -0
  38. package/types/components/panel/index.d.ts +9 -0
  39. package/types/components/panel/types.d.ts +62 -0
  40. package/types/components/table/TableToolbar.vue.d.ts +8 -8
  41. package/types/index.d.ts +3 -1
  42. package/types/inject/key.d.ts +8 -0
@@ -0,0 +1,36 @@
1
+ import { Component } from 'vue';
2
+ import { ModalLevel } from './modal-shelf-types';
3
+
4
+ declare function __VLS_template(): {
5
+ default?(_: {}): any;
6
+ };
7
+ declare const __VLS_component: import('vue').DefineComponent<globalThis.ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
8
+ level: ModalLevel;
9
+ }>>, {
10
+ items: Ref<import('./modal-shelf-types').ShelfItem[]>;
11
+ level: ModalLevel;
12
+ evoke: (nsKey: string, component: Component | (() => Promise<Component>), options: {
13
+ payload: Record<string, unknown>;
14
+ sameKeyStrategy?: import('./modal-shelf-types').ModalSameKeyStrategy;
15
+ }) => import('./modal-shelf-types').EvokeHandle;
16
+ remove: (nsKey: string | string[]) => void;
17
+ close: (item: import('./modal-shelf-types').ShelfItem) => void;
18
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
19
+ level: ModalLevel;
20
+ }>>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
21
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
22
+ export default _default;
23
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
24
+ type __VLS_TypePropsToRuntimeProps<T> = {
25
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
26
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
27
+ } : {
28
+ type: import('vue').PropType<T[K]>;
29
+ required: true;
30
+ };
31
+ };
32
+ type __VLS_WithTemplateSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
@@ -1,7 +1,11 @@
1
1
  import { Plugin } from 'vue';
2
2
  import { default as ConfirmModal } from './ConfirmModal.vue';
3
3
  import { default as DetailModal } from './DetailModal.vue';
4
+ import { default as ModalShelf } from './ModalShelf.vue';
5
+ import { default as ModalPorter } from './ModalPorter.vue';
4
6
 
5
7
  export * from './types';
6
- export { ConfirmModal, DetailModal };
8
+ export * from './modal-shelf-types';
9
+ export { ConfirmModal, DetailModal, ModalShelf, ModalPorter };
10
+ /** 弹窗子模块批量注册插件 */
7
11
  export declare const modalInstall: Plugin;
@@ -0,0 +1,10 @@
1
+ import { Ref } from 'vue';
2
+ import { ModalLevel, ShelfController, ShelfItem } from './modal-shelf-types';
3
+
4
+ /** ShelfController 内部扩展:额外暴露渲染用活跃实例列表 */
5
+ export interface ShelfControllerInternal extends ShelfController {
6
+ /** 渲染用:当前活跃实例列表(多例数组) */
7
+ items: Ref<ShelfItem[]>;
8
+ }
9
+ /** 创建一个架子逻辑控制器(纯逻辑,无 DOM 依赖,可单测) */
10
+ export declare function createShelfController(level: ModalLevel): ShelfControllerInternal;
@@ -0,0 +1,7 @@
1
+ import { ModalLevel } from './modal-shelf-types';
2
+
3
+ /**
4
+ * 层级合法性:app 必最顶层;page 祖先仅允许 app;custom 可嵌套任何(含 custom 套 custom)。
5
+ * 非法仅开发期 console.error,不抛、不静默。
6
+ */
7
+ export declare function assertLevelHierarchy(level: ModalLevel, ancestorLevels: ModalLevel[]): void;
@@ -0,0 +1,74 @@
1
+ import { Component } from 'vue';
2
+
3
+ /** 架子层级 */
4
+ export type ModalLevel = "app" | "page" | "custom";
5
+ /** 同 key 再 evoke 策略:recreate=关旧重建(默认);update=已开则整体替换 props 不 remount */
6
+ export type ModalSameKeyStrategy = "recreate" | "update";
7
+ /**
8
+ * 业务侧 declare merge 扩展此接口声明每个弹窗的业务 props 契约。
9
+ * 例:declare module "@done-coding/admin-core" {
10
+ * interface ModalShelfMap { detail: { id: string; onConfirm?: (r: unknown) => void } }
11
+ * }
12
+ */
13
+ export interface ModalShelfMap {
14
+ }
15
+ /** 架子注入给弹窗组件的契约(业务 payload 经单 payload 对象传入) */
16
+ export interface ModalInjectedProps<P = Record<string, unknown>> {
17
+ /** v-model:show 受控可见性 */
18
+ show: boolean;
19
+ /** 优雅关闭(隐藏→等动画→移除),=== EvokeHandle.close */
20
+ closeFn: () => void;
21
+ /** 立即移除(无动画) */
22
+ removeFn: () => void;
23
+ /** 业务 payload(ModalShelfMap[key]) */
24
+ payload: P;
25
+ }
26
+ /** evoke 返回的命令式句柄;只绑稳定 nsKey,调用时现查当前实例(不闭包 id) */
27
+ export interface EvokeHandle {
28
+ /** 优雅关闭该 nsKey 当前实例;无则 no-op */
29
+ close: () => void;
30
+ /** 对该 nsKey 当前实例受控增量合并 payload(不 remount);无则 no-op */
31
+ update: (partialPayload: Record<string, unknown>) => void;
32
+ }
33
+ /** 注册项(扁平,无 options 包裹,无 isSingle——v1 仅多例) */
34
+ export interface RegisterEntry<K extends keyof ModalShelfMap = keyof ModalShelfMap> {
35
+ /** 弹窗逻辑 key */
36
+ key: K;
37
+ /** 组件或懒工厂(() => import()) */
38
+ component: Component | (() => Promise<Component>);
39
+ /** 目标架子:app/page 名称代指,或直接持 ShelfInstance */
40
+ shelf: "app" | "page" | ShelfInstance;
41
+ /** 同 key 再 evoke 策略,缺省 "recreate" */
42
+ sameKeyStrategy?: ModalSameKeyStrategy;
43
+ }
44
+ /** 架子内部一条活跃实例 */
45
+ export interface ShelfItem {
46
+ /** 架子内部自增唯一 id,用作渲染 :key */
47
+ id: number;
48
+ /** porter 命名空间后的注册键 p{porterUid}:{key} */
49
+ nsKey: string;
50
+ /** 组件或懒工厂 */
51
+ component: Component | (() => Promise<Component>);
52
+ /** 业务 payload */
53
+ payload: Record<string, unknown>;
54
+ /** v-model:show */
55
+ show: boolean;
56
+ /** close 排定的关闭动画定时器句柄;remove 立即移除前 [MUST] clearTimeout 它 */
57
+ timer?: ReturnType<typeof setTimeout>;
58
+ }
59
+ /** ModalShelf 实例 expose === 它 provide 的 controller */
60
+ export interface ShelfController {
61
+ /** 本架子层级 */
62
+ level: ModalLevel;
63
+ /** 唤起一条;同 nsKey 先 remove(立即) 旧再新建 */
64
+ evoke: (nsKey: string, component: Component | (() => Promise<Component>), options: {
65
+ payload: Record<string, unknown>;
66
+ sameKeyStrategy?: ModalSameKeyStrategy;
67
+ }) => EvokeHandle;
68
+ /** 立即移除(不等动画),支持单个或批量 */
69
+ remove: (nsKey: string | string[]) => void;
70
+ /** 优雅关闭某条(触发隐藏 → 动画结束 → 移除) */
71
+ close: (item: ShelfItem) => void;
72
+ }
73
+ /** ModalShelf 实例引用类型别名(用于 RegisterEntry.shelf 直接持实例定位 custom 架子) */
74
+ export type ShelfInstance = ShelfController;
@@ -0,0 +1,31 @@
1
+ import { PanelEditSwitchProps } from './types';
2
+
3
+ declare function __VLS_template(): {
4
+ default?(_: {}): any;
5
+ editor?(_: {
6
+ data: Record<string, any>;
7
+ }): any;
8
+ };
9
+ declare const __VLS_component: import('vue').DefineComponent<globalThis.ExtractPropTypes<__VLS_TypePropsToRuntimeProps<PanelEditSwitchProps<Record<string, any>>>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
10
+ "update:editing": (value: boolean) => void;
11
+ submitFinish: (success: boolean, data: Record<string, any>) => void;
12
+ }, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<__VLS_TypePropsToRuntimeProps<PanelEditSwitchProps<Record<string, any>>>>> & Readonly<{
13
+ "onUpdate:editing"?: ((value: boolean) => any) | undefined;
14
+ onSubmitFinish?: ((success: boolean, data: Record<string, any>) => any) | undefined;
15
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
16
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
17
+ export default _default;
18
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
19
+ type __VLS_TypePropsToRuntimeProps<T> = {
20
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
21
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
22
+ } : {
23
+ type: import('vue').PropType<T[K]>;
24
+ required: true;
25
+ };
26
+ };
27
+ type __VLS_WithTemplateSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
@@ -0,0 +1,21 @@
1
+ import { PanelItemProps } from './types';
2
+
3
+ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropTypes<__VLS_TypePropsToRuntimeProps<PanelItemProps<Record<string, any>>>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
4
+ "update:editing": (value: boolean) => void;
5
+ submitFinish: (success: boolean, data: Record<string, any>) => void;
6
+ refresh: () => void;
7
+ }, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<__VLS_TypePropsToRuntimeProps<PanelItemProps<Record<string, any>>>>> & Readonly<{
8
+ onRefresh?: (() => any) | undefined;
9
+ "onUpdate:editing"?: ((value: boolean) => any) | undefined;
10
+ onSubmitFinish?: ((success: boolean, data: Record<string, any>) => any) | undefined;
11
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
12
+ export default _default;
13
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
14
+ type __VLS_TypePropsToRuntimeProps<T> = {
15
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
16
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
17
+ } : {
18
+ type: import('vue').PropType<T[K]>;
19
+ required: true;
20
+ };
21
+ };
@@ -0,0 +1,17 @@
1
+ import { PanelMainProps } from './types';
2
+
3
+ declare const _default: <T extends Record<string, any>>(__VLS_props: Awaited<typeof __VLS_setup>["props"], __VLS_ctx?: __VLS_Prettify<Pick<Awaited<typeof __VLS_setup>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: __VLS_Prettify<__VLS_OmitKeepDiscriminatedUnion<(Partial<{}> & Omit<{
5
+ readonly onRefresh?: ((data: T) => any) | undefined;
6
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>) & PanelMainProps<T>, keyof import('vue').VNodeProps | keyof import('vue').AllowedComponentProps>> & {} & (import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps);
7
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
8
+ attrs: any;
9
+ slots: ReturnType<() => {}>;
10
+ emit: (e: "refresh", data: T) => void;
11
+ }>) => import('vue').VNode & {
12
+ __ctx?: Awaited<typeof __VLS_setup>;
13
+ };
14
+ export default _default;
15
+ type __VLS_Prettify<T> = {
16
+ [K in keyof T]: T[K];
17
+ } & {};
@@ -0,0 +1,9 @@
1
+ import { Plugin } from 'vue';
2
+ import { default as PanelMain } from './PanelMain.vue';
3
+ import { default as PanelItem } from './PanelItem.vue';
4
+ import { default as PanelEditSwitch } from './PanelEditSwitch.vue';
5
+
6
+ export * from './types';
7
+ export { PanelMain, PanelItem, PanelEditSwitch };
8
+ /** Panel 组件族一键注册插件(app.use(panelInstall)) */
9
+ export declare const panelInstall: Plugin;
@@ -0,0 +1,62 @@
1
+ import { VNode } from 'vue';
2
+ import { ColProps } from 'element-plus';
3
+
4
+ /** Panel 只读渲染作用域(render 用) */
5
+ export interface PanelScope<T extends Record<string, any> = Record<string, any>> {
6
+ /** 原始数据(只读消费,[MUST NOT] 在 render 内修改) */
7
+ data: T;
8
+ /** data[config.key] */
9
+ value: any;
10
+ config: PanelItemConfig<T>;
11
+ /** 请求 PanelMain 向父层触发 refresh(preview 组件绕开 PanelEditSwitch 刷新用) */
12
+ refresh?: () => void;
13
+ }
14
+ /** Panel 编辑器作用域(editorRender 用,data = 深克隆副本) */
15
+ export interface PanelEditorScope<T extends Record<string, any> = Record<string, any>> {
16
+ /** PanelEditSwitch 内部深克隆副本(编辑器直接改它) */
17
+ data: T;
18
+ /** data[config.key](克隆体上的值) */
19
+ value: any;
20
+ config: PanelItemConfig<T>;
21
+ }
22
+ /** Panel 配置项 */
23
+ export interface PanelItemConfig<T extends Record<string, any> = Record<string, any>> {
24
+ /** 数据键 */
25
+ key: string;
26
+ /** 标签,非必填 */
27
+ label?: string;
28
+ /** 栅格布局,复用 resolveFormLayout 语义;缺省继承 PanelMain.layout */
29
+ layout?: Partial<ColProps>;
30
+ /** 顺序,缺省按数组序 */
31
+ order?: number;
32
+ /** 隐藏 */
33
+ hide?: boolean | ((scope: PanelScope<T>) => boolean);
34
+ /** 只读渲染;缺省=纯文本 data[key] */
35
+ render?: string | Record<string, any> | ((scope: PanelScope<T>) => VNode);
36
+ /** 是否可就地编辑 */
37
+ editable?: boolean | ((scope: PanelScope<T>) => boolean);
38
+ /** 编辑器渲染;仅 editable 时需要 */
39
+ editorRender?: string | Record<string, any> | ((scope: PanelEditorScope<T>) => VNode);
40
+ /** 单字段提交;仅 editable 时需要。draft = 深克隆副本 */
41
+ submitFn?: (draft: T) => Promise<unknown>;
42
+ }
43
+ /** Panel 配置项列表 */
44
+ export type PanelItemConfigList<T extends Record<string, any> = Record<string, any>> = PanelItemConfig<T>[];
45
+ /** PanelMain props */
46
+ export interface PanelMainProps<T extends Record<string, any> = Record<string, any>> {
47
+ data: T;
48
+ layout?: Partial<ColProps>;
49
+ list: PanelItemConfigList<T>;
50
+ }
51
+ /** PanelItem props */
52
+ export interface PanelItemProps<T extends Record<string, any> = Record<string, any>> {
53
+ data: T;
54
+ config: PanelItemConfig<T>;
55
+ editing: boolean;
56
+ }
57
+ /** PanelEditSwitch props */
58
+ export interface PanelEditSwitchProps<T extends Record<string, any> = Record<string, any>> {
59
+ data: T;
60
+ editing: boolean;
61
+ submitFn?: (draft: T) => Promise<unknown>;
62
+ }
@@ -2,14 +2,14 @@ import { ExportType, TableExportContext, TableMainInstance } from './types';
2
2
 
3
3
  declare const _default: import('vue').DefineComponent<globalThis.ExtractPropTypes<{
4
4
  isAutoRefresh: import('vue').PropType<boolean>;
5
- pageSize: {
6
- type: globalThis.PropType<number>;
7
- required: true;
8
- };
9
5
  loading: {
10
6
  type: globalThis.PropType<boolean>;
11
7
  required: true;
12
8
  };
9
+ pageSize: {
10
+ type: globalThis.PropType<number>;
11
+ required: true;
12
+ };
13
13
  showRefresh: {
14
14
  type: globalThis.PropType<boolean>;
15
15
  default: boolean;
@@ -52,14 +52,14 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
52
52
  };
53
53
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
54
54
  isAutoRefresh: import('vue').PropType<boolean>;
55
- pageSize: {
56
- type: globalThis.PropType<number>;
57
- required: true;
58
- };
59
55
  loading: {
60
56
  type: globalThis.PropType<boolean>;
61
57
  required: true;
62
58
  };
59
+ pageSize: {
60
+ type: globalThis.PropType<number>;
61
+ required: true;
62
+ };
63
63
  showRefresh: {
64
64
  type: globalThis.PropType<boolean>;
65
65
  default: boolean;
package/types/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { miscInstall } from './components/misc';
6
6
  import { modalInstall } from './components/modal';
7
7
  import { tableInstall } from './components/table';
8
8
  import { listPageInstall } from './components/list-page';
9
+ import { panelInstall } from './components/panel';
9
10
 
10
11
  export * from './components/form';
11
12
  export * from './components/menu';
@@ -14,6 +15,7 @@ export * from './components/misc';
14
15
  export * from './components/modal';
15
16
  export * from './components/table';
16
17
  export * from './components/list-page';
18
+ export * from './components/panel';
17
19
  export * from './utils';
18
20
  export * from './hooks';
19
21
  export * from './types';
@@ -22,5 +24,5 @@ export * from './inject';
22
24
  export * from './helpers';
23
25
  export * from './bridge';
24
26
  export * from './store';
25
- export { formInstall, menuInstall, displayInstall, miscInstall, modalInstall, tableInstall, listPageInstall, };
27
+ export { formInstall, menuInstall, displayInstall, miscInstall, modalInstall, tableInstall, listPageInstall, panelInstall, };
26
28
  export declare const installComponents: Plugin;
@@ -1,3 +1,6 @@
1
+ import { InjectionKey } from 'vue';
2
+ import { ModalLevel, ShelfController } from '../components/modal';
3
+
1
4
  /**
2
5
  * body 视口高度
3
6
  * ---
@@ -20,3 +23,8 @@ export declare const BODY_CONTENT_VIEWPORT_HEIGHT: unique symbol;
20
23
  * 导致 provide/inject 失配 → 预算链断裂)。
21
24
  */
22
25
  export declare const FULLSCREEN_HEIGHT_CHANNEL: unique symbol;
26
+ /**
27
+ * 弹窗架子 inject key 工厂——按 level 参数化。
28
+ * Symbol.for 全局注册表保证跨包/跨 chunk/跨 ESM 实例唯一(同 BODY_CONTENT_VIEWPORT_HEIGHT)。
29
+ */
30
+ export declare function getModalShelfInjectionKey(level: ModalLevel): InjectionKey<ShelfController>;