@done-coding/admin-core 0.12.1 → 0.12.2-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 (128) hide show
  1. package/README.md +1 -48
  2. package/es/bridge/index.mjs +75 -72
  3. package/es/bridge/layout.mjs +51 -0
  4. package/es/bridge/theme/index.mjs +1 -1
  5. package/es/bridge/theme/persist.mjs +1 -1
  6. package/es/components/app-layout/AppAside.vue.mjs +2 -2
  7. package/es/components/app-layout/AppAside.vue2.mjs +27 -10
  8. package/es/components/app-layout/AppCollapseToggle.vue.mjs +7 -0
  9. package/es/components/app-layout/AppCollapseToggle.vue2.mjs +54 -0
  10. package/es/components/app-layout/AppFooter.vue.mjs +1 -1
  11. package/es/components/app-layout/AppHeader.vue.mjs +3 -3
  12. package/es/components/app-layout/AppHeader.vue2.mjs +1 -1
  13. package/es/components/app-layout/AppLayout.vue.mjs +2 -2
  14. package/es/components/app-layout/AppLayout.vue2.mjs +3 -3
  15. package/es/components/app-layout/AppSidebar.vue.mjs +2 -2
  16. package/es/components/app-layout/AppSidebar.vue2.mjs +41 -61
  17. package/es/components/app-layout/AppTheme.vue.mjs +3 -3
  18. package/es/components/app-layout/viewport.mjs +3 -3
  19. package/es/components/display/TabsHeader.vue.mjs +4 -4
  20. package/es/components/form/FormItemNestForm.vue.mjs +2 -2
  21. package/es/components/form/FormItemNestFormList.vue.mjs +2 -2
  22. package/es/components/form/FormSubmitPanel.vue.mjs +1 -1
  23. package/es/components/form/FormVerifyImage.vue.mjs +1 -1
  24. package/es/components/table/TableToolbar.vue.mjs +3 -3
  25. package/es/hooks/{use-admin-theme-apply.mjs → use-theme-apply.mjs} +62 -62
  26. package/es/hooks/use-viewport-apply.mjs +39 -0
  27. package/es/index.mjs +88 -88
  28. package/es/inject/key.mjs +13 -13
  29. package/es/store/app.mjs +69 -62
  30. package/es/style.css +1 -1
  31. package/package.json +6 -8
  32. package/types/bridge/config-hook.d.ts +0 -68
  33. package/types/bridge/index.d.ts +18 -417
  34. package/types/bridge/layout.d.ts +25 -0
  35. package/types/bridge/plugin.d.ts +12 -30
  36. package/types/bridge/route.d.ts +1 -20
  37. package/types/bridge/state.d.ts +0 -14
  38. package/types/bridge/storage.d.ts +0 -9
  39. package/types/bridge/theme/index.d.ts +1 -8
  40. package/types/bridge/theme/persist.d.ts +3 -15
  41. package/types/bridge/theme/system-dark.d.ts +0 -12
  42. package/types/bridge/theme/types.d.ts +27 -265
  43. package/types/components/app-layout/AppAside.vue.d.ts +0 -1
  44. package/types/components/app-layout/AppCollapseToggle.vue.d.ts +11 -0
  45. package/types/components/app-layout/AppHeader.vue.d.ts +0 -3
  46. package/types/components/app-layout/AppLayout.vue.d.ts +0 -12
  47. package/types/components/app-layout/AppPage.vue.d.ts +0 -2
  48. package/types/components/app-layout/AppSidebar.vue.d.ts +0 -2
  49. package/types/components/app-layout/types.d.ts +2 -127
  50. package/types/components/app-layout/viewport.d.ts +2 -30
  51. package/types/components/data-view/DataListViewItem.vue.d.ts +0 -8
  52. package/types/components/data-view/index.d.ts +0 -4
  53. package/types/components/data-view/types.d.ts +0 -41
  54. package/types/components/data-view/utils.d.ts +0 -3
  55. package/types/components/display/TabsHeader.vue.d.ts +0 -2
  56. package/types/components/display/TabsMain.vue.d.ts +0 -2
  57. package/types/components/display/TabsRefineFlow.vue.d.ts +0 -1
  58. package/types/components/display/index.d.ts +1 -37
  59. package/types/components/display/types.d.ts +0 -131
  60. package/types/components/form/FormItemNestForm.vue.d.ts +0 -5
  61. package/types/components/form/FormItemNestFormList.vue.d.ts +0 -17
  62. package/types/components/form/FormVerifyCode.vue.d.ts +0 -9
  63. package/types/components/form/FormVerifyImage.vue.d.ts +0 -1
  64. package/types/components/form/form-search-utils.d.ts +0 -14
  65. package/types/components/form/nest-form-item-list.d.ts +0 -28
  66. package/types/components/form/nest-form-item.d.ts +0 -21
  67. package/types/components/form/nest-registry.d.ts +0 -14
  68. package/types/components/form/types.d.ts +8 -185
  69. package/types/components/form/use-form-submit.d.ts +0 -12
  70. package/types/components/form/use-nest-form-list.d.ts +0 -13
  71. package/types/components/form/use-nest-form.d.ts +0 -15
  72. package/types/components/form/use-nest-layout-scale.d.ts +0 -12
  73. package/types/components/form/utils.d.ts +1 -56
  74. package/types/components/list-page/ListPage.vue.d.ts +0 -6
  75. package/types/components/list-page/types.d.ts +2 -19
  76. package/types/components/misc/index.d.ts +1 -6
  77. package/types/components/misc/types.d.ts +0 -6
  78. package/types/components/modal/ConfirmModal.vue.d.ts +0 -10
  79. package/types/components/modal/modal-shelf-core.d.ts +0 -3
  80. package/types/components/modal/modal-shelf-hierarchy.d.ts +0 -4
  81. package/types/components/modal/modal-shelf-types.d.ts +0 -34
  82. package/types/components/modal/types.d.ts +1 -20
  83. package/types/components/panel/PanelItemNestForm.vue.d.ts +0 -6
  84. package/types/components/panel/PanelItemNestPanel.vue.d.ts +0 -5
  85. package/types/components/panel/nest-panel-form.d.ts +0 -21
  86. package/types/components/panel/nest-panel-item.d.ts +0 -14
  87. package/types/components/panel/types.d.ts +1 -49
  88. package/types/components/table/types.d.ts +9 -124
  89. package/types/config/list-model.d.ts +0 -29
  90. package/types/config/route.d.ts +0 -2
  91. package/types/helpers/form.d.ts +0 -5
  92. package/types/helpers/list-helper.d.ts +0 -26
  93. package/types/helpers/types.d.ts +0 -11
  94. package/types/hooks/activated.d.ts +0 -10
  95. package/types/hooks/feel-size.d.ts +0 -2
  96. package/types/hooks/index.d.ts +2 -2
  97. package/types/hooks/menus-dispatch.d.ts +0 -4
  98. package/types/hooks/timeout.d.ts +0 -4
  99. package/types/hooks/use-channel-viewport-height.d.ts +0 -14
  100. package/types/hooks/use-theme-apply.d.ts +11 -0
  101. package/types/hooks/use-viewport-apply.d.ts +8 -0
  102. package/types/inject/key.d.ts +2 -87
  103. package/types/router/guard/index.d.ts +0 -13
  104. package/types/router/guard/login.d.ts +0 -1
  105. package/types/router/guard/permission.d.ts +0 -1
  106. package/types/router/guard/types.d.ts +2 -5
  107. package/types/store/app.d.ts +10 -31
  108. package/types/store/router-permission.d.ts +2 -55
  109. package/types/store/user.d.ts +2 -26
  110. package/types/types/dot-path.d.ts +0 -8
  111. package/types/types/route.d.ts +0 -45
  112. package/types/types/utility-types.d.ts +0 -7
  113. package/types/utils/export.d.ts +1 -16
  114. package/types/utils/id.d.ts +0 -1
  115. package/types/utils/router.d.ts +0 -2
  116. package/types/utils/theme-scale.d.ts +0 -31
  117. package/types/utils/time.d.ts +0 -1
  118. package/docs/TECH_SNAPSHOT.md +0 -146
  119. package/docs/nested-config-paradigm.md +0 -80
  120. package/docs/specs/2026-05-09-055250-moderate-/345/210/227/350/241/250key/351/205/215/347/275/256/347/202/271/350/267/257/345/276/204/346/224/257/346/214/201/RETROSPECTIVE.md +0 -63
  121. package/docs/specs/2026-05-09-055250-moderate-/345/210/227/350/241/250key/351/205/215/347/275/256/347/202/271/350/267/257/345/276/204/346/224/257/346/214/201/design.md +0 -575
  122. package/docs/specs/2026-05-09-055250-moderate-/345/210/227/350/241/250key/351/205/215/347/275/256/347/202/271/350/267/257/345/276/204/346/224/257/346/214/201/landing-authorizations/2026-05-09-080900-/346/234/2371-/345/205/245/345/256/236/346/226/275/346/216/210/346/235/203.md +0 -107
  123. package/docs/specs/2026-05-09-055250-moderate-/345/210/227/350/241/250key/351/205/215/347/275/256/347/202/271/350/267/257/345/276/204/346/224/257/346/214/201/project-orchestration.md +0 -58
  124. package/docs/specs/2026-05-09-055250-moderate-/345/210/227/350/241/250key/351/205/215/347/275/256/347/202/271/350/267/257/345/276/204/346/224/257/346/214/201/requirements.md +0 -238
  125. package/docs/specs/2026-05-09-055250-moderate-/345/210/227/350/241/250key/351/205/215/347/275/256/347/202/271/350/267/257/345/276/204/346/224/257/346/214/201/tasks.md +0 -290
  126. package/es/hooks/use-admin-viewport-apply.mjs +0 -39
  127. package/types/hooks/use-admin-theme-apply.d.ts +0 -34
  128. package/types/hooks/use-admin-viewport-apply.d.ts +0 -20
@@ -3,20 +3,11 @@ declare const _default: <P extends Record<string, any>>(__VLS_props: NonNullable
3
3
  readonly "onUpdate:modelValue"?: ((value: string) => any) | undefined;
4
4
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:modelValue"> & {
5
5
  modelValue: string;
6
- /** 发送频率 */
7
6
  hz?: number;
8
7
  api: (params?: P) => Promise<void>;
9
- /** 请求参数 */
10
8
  params?: P;
11
- /** 重置标识
12
- * 内部检测变化以重新计时
13
- * @example const resetKey = ref(1);
14
- * 需要重置时 resetKey.value++;
15
- * */
16
9
  resetKey?: number;
17
- /** 是否禁用 */
18
10
  disabled?: boolean;
19
- /** 发送按钮文本 */
20
11
  btnText?: string;
21
12
  } & Partial<{}>> & import('vue').PublicProps;
22
13
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
@@ -6,7 +6,6 @@ declare const _default: <P extends Record<string, any>>(__VLS_props: NonNullable
6
6
  imgWidth?: number;
7
7
  api: (params?: P) => Promise<string>;
8
8
  params?: P;
9
- /** 是否自动销毁图片链接 */
10
9
  autoRevokeUrl?: boolean;
11
10
  } & Partial<{}>> & import('vue').PublicProps;
12
11
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
@@ -1,23 +1,9 @@
1
1
  import { ColProps } from 'element-plus';
2
2
  import { Breakpoint } from '../../hooks/use-breakpoint';
3
3
  export declare const computeItemsPerRow: (span: number) => number;
4
- /**
5
- * 计算按钮 ElCol 的 offset,使其推到当前行最右。
6
- * ElRow 共 24 格。
7
- *
8
- * @param visibleCount 可见表单项数量(不含按钮自身)
9
- * @param span 当前断点下每个表单项的 span
10
- */
11
4
  export declare const computeButtonOffset: (visibleCount: number, span: number) => number;
12
- /**
13
- * 按每个响应断点分别计算按钮的 { span, offset },
14
- * 返回可直接 v-bind 到 ElCol 的对象。
15
- */
16
5
  export declare const computeButtonColProps: (layout: Partial<ColProps> | undefined, visibleCount: number) => Record<string, {
17
6
  span: number;
18
7
  offset: number;
19
8
  }>;
20
- /**
21
- * 计算当前断点下每行能容纳的表单项数。
22
- */
23
9
  export declare const getCurrentSpan: (layout: Partial<ColProps> | undefined, breakpoint: Breakpoint) => number;
@@ -3,61 +3,33 @@ import { ColProps } from 'element-plus';
3
3
  import { FormItemConfig, FormItemConfigList } from './types';
4
4
  import { ActionBtnConfirmConfig } from '../display';
5
5
  export interface NestFormItemListOptions {
6
- /** 父 item key */
7
6
  key: string;
8
- /** 父 item label */
9
7
  label: string;
10
- /** 每行子表单配置列表 */
11
8
  list: FormItemConfigList;
12
- /** 行稳定标识字段(指向行对象内稳定 id);缺省走内部自增 rowId */
13
9
  rowKey?: string;
14
- /** 新增行工厂;缺省 generateFormData(list) */
15
10
  itemFactory?: () => Record<string, any>;
16
- /** 最少行数 */
17
11
  min?: number;
18
- /** 最多行数 */
19
12
  max?: number;
20
- /** 父 item 栅格布局 */
21
13
  layout?: Partial<ColProps>;
22
- /** 每行子表单行间距 */
23
14
  rowGutter?: number;
24
- /** 新增 / 删除按钮文案 */
25
15
  addText?: string;
26
16
  removeText?: string;
27
- /** 顶部自定义渲染(render-fn;label 由父 FormItem 渲染,本组件不出 title) */
28
17
  headerRender?: (scope: {
29
18
  count: number;
30
19
  max: number;
31
20
  }) => VNodeChild;
32
- /** 底部自定义渲染;缺省 = 内置「新增」按钮 */
33
21
  footerRender?: (scope: {
34
22
  count: number;
35
23
  max: number;
36
24
  canAdd: boolean;
37
25
  add: () => void;
38
26
  }) => VNodeChild;
39
- /** 联结组件外环 + 每行分割阴影颜色 */
40
27
  shadowColor?: string;
41
- /** 业务校验规则;与自动织入的 min/max 长度规则合并(长度规则在前) */
42
28
  rules?: FormItemConfig["rules"];
43
- /** 覆盖默认 init(缺省 = 空数组 [],[MUST NOT] 改初始值补 min;min/max 走校验) */
44
29
  init?: FormItemConfig["init"];
45
- /** 覆盖默认 stringify(缺省 = 数组逐项 `stringifyFormData(t, list)`) */
46
30
  stringify?: FormItemConfig["stringify"];
47
- /** 覆盖默认 parse(缺省 = 数组逐项 `parseFormData(t, list)`) */
48
31
  parse?: FormItemConfig["parse"];
49
- /** 是否叠本层嵌套布局 rebase(P3,缺省 true;false = 逆向逃生口,子层 layout 原样直透) */
50
32
  rebase?: boolean;
51
- /** 行删除二次确认(缺省 true=默认 popconfirm「确认删除该项?」;false=直删;对象=自定义) */
52
33
  removeConfirm?: boolean | ActionBtnConfirmConfig;
53
34
  }
54
- /**
55
- * 生成「父 item 内嵌数组子表单(N 行 FormMain)」的 FormItemConfig(C4 配套 helper)
56
- * ----
57
- * render 出口挂 FormItemNestFormList(值贯通数组 in-place + 增删 + 聚合校验穿透自动接线)。
58
- * ----
59
- * **序列化 pack(ADR-6,对齐 §34)**:自动织入 init/stringify/parse —— 父 FormMain 的
60
- * generate()/stringify()/parse() 逐项命中即对数组逐项递归(行内若再嵌 nestFormItem /
61
- * nestFormItemList → 逐层组合)。业务传 init/stringify/parse 则以业务为准。
62
- */
63
35
  export declare function nestFormItemList(options: NestFormItemListOptions): FormItemConfig;
@@ -1,36 +1,15 @@
1
1
  import { ColProps } from 'element-plus';
2
2
  import { FormItemConfig, FormItemConfigList } from './types';
3
3
  export interface NestFormItemOptions {
4
- /** 父 item key */
5
4
  key: string;
6
- /** 父 item label */
7
5
  label: string;
8
- /** 子表单配置列表 */
9
6
  list: FormItemConfigList;
10
- /** 父 item 栅格布局 */
11
7
  layout?: Partial<ColProps>;
12
- /** 子表单行间距 */
13
8
  rowGutter?: number;
14
- /** 联结组件外环阴影颜色 */
15
9
  shadowColor?: string;
16
- /** 覆盖默认 init(缺省 = `generateFormData(list)`,产子默认对象) */
17
10
  init?: FormItemConfig["init"];
18
- /** 覆盖默认 stringify(缺省 = 递归 `stringifyFormData(value, list)`) */
19
11
  stringify?: FormItemConfig["stringify"];
20
- /** 覆盖默认 parse(缺省 = 递归 `parseFormData(value, list)`) */
21
12
  parse?: FormItemConfig["parse"];
22
- /** 是否叠本层嵌套布局 rebase(P3,缺省 true;false = 逆向逃生口,子层 layout 原样直透) */
23
13
  rebase?: boolean;
24
14
  }
25
- /**
26
- * 生成「父 item 内嵌子 FormMain」的 FormItemConfig(C1 配套 helper)
27
- * ----
28
- * 降低业务方手写 h(FormItemNestForm) 噪音:传 key/label/子 list 即得一个满足 FormItemConfig
29
- * 的配置项,渲染出口挂 FormItemNestForm(值贯通 + 校验级联自动接线)。
30
- * ----
31
- * **stringify/parse/init 自动 pack**:FormItemConfig 的 per-item `init`/`stringify`/`parse`
32
- * 钩子 + 纯 list 驱动 util(generate/stringify/parseFormData)→ 自动织入「递归进子 list」,
33
- * 父 FormMain 的 `generate()`/`stringify()`/`parse()` 逐项命中即递归序列化/回显嵌套子表单,
34
- * 多层自然组合(孙 nestFormItem 的钩子同理逐层)。业务传 init/stringify/parse 则以业务为准。
35
- */
36
15
  export declare function nestFormItem(options: NestFormItemOptions): FormItemConfig;
@@ -1,22 +1,8 @@
1
1
  import { FormMainInstance } from './types';
2
- /**
3
- * 嵌套子 FormMain 级联 expose 子集
4
- * ----
5
- * 联结组件(FormItemNestForm)把所持子 FormMain 的级联方法注册进父 FormMain 的 exposeMap,
6
- * 使父顶层 validate/clearValidate/resetFields 可级联到子。
7
- */
8
2
  export interface NestFormExpose {
9
3
  validate: FormMainInstance["validate"];
10
4
  clearValidate: FormMainInstance["clearValidate"];
11
5
  resetFields: FormMainInstance["resetFields"];
12
6
  }
13
- /**
14
- * 嵌套子表单 exposeMap
15
- * ----
16
- * key = 联结组件所属父 item 的 key(天然唯一,供父 FormMain 对齐 hideKeyList:隐藏 item 不级联 validate)。
17
- * 用 `shallowReactive`:顶层 key 增删响应式(注册/摘除可被响应式消费),value(expose 对象)保持 raw
18
- * 不深代理——既规避 expose 引用循环,又留响应式消费口。每个 FormMain 经工厂在闭包内 new 一份,零模块级单例。
19
- */
20
7
  export type NestFormExposeMap = Record<string, NestFormExpose>;
21
- /** 创建一个嵌套子表单 exposeMap(shallowReactive) */
22
8
  export declare function createNestFormExposeMap(): NestFormExposeMap;
@@ -5,132 +5,61 @@ export type OnlyOneKey<T extends Record<string, any>> = {
5
5
  [P in K]?: T[P];
6
6
  } & Partial<Record<Exclude<keyof T, K>, never>>;
7
7
  }[keyof T];
8
- /** 额外扩展表单配置项 */
9
8
  export type FormItemConfigExtra = OnlyOneKey<{
10
- /** 是输入类型 */
11
9
  isInput: boolean;
12
- /** 是选择类型 */
13
10
  isSelect: boolean;
14
11
  }> & {
15
- /** 回车提交 */
16
12
  enterSubmit?: boolean;
17
- /** 失去焦点提交[isInput默认为true] */
18
13
  blurSubmit?: boolean;
19
- /** 变化提交 [isSelect默认为true] */
20
14
  changeSubmit?: boolean;
21
15
  };
22
16
  interface WrapProps extends FormItemProps {
23
17
  [key: string]: any;
24
18
  }
25
- /** formItem联动配置 */
26
19
  interface FormItemLinkConfig<K extends string, BV, OV> {
27
- /** 关联(该宿主配置)表单项的key */
28
20
  key: K;
29
- /**
30
- * 获取该项的值
31
- * @param hostValue 宿主/依赖项的值
32
- * @param ownValue 该(寄生/收集依赖)项的值
33
- * @param attachInfo 附加信息,可用于表单渲染为自定义组件时触发事件triggerChangeLink, 此场景 寄生项的值内部会去拿
34
- * @example emit('triggerChangeLink', hostValue, attachInfo)
35
- */
36
21
  getValue: (hostValue: BV, ownValue: OV, attachInfo?: any) => void;
37
22
  }
38
- /** formItem配置 */
39
- export interface FormItemConfig<PO extends Record<string, any> = Record<string, any>,
40
- /** 需要格式化的模型 */
41
- SO extends Record<string, any> = Record<string, any>,
42
- /** 解析的模型的key */
43
- PK extends Extract<keyof PO, string> = Extract<keyof PO, string>,
44
- /** 解析的模型的值 */
45
- PV extends PO[PK] = PO[PK],
46
- /** 需要格式化的模型的值 */
47
- SV extends PK extends keyof SO ? SO[PK] : PV = PK extends keyof SO ? SO[PK] : PV> {
48
- /** 表单项key __大写视为忽略 等价于 ignore = true */
23
+ export interface FormItemConfig<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>, PK extends Extract<keyof PO, string> = Extract<keyof PO, string>, PV extends PO[PK] = PO[PK], SV extends PK extends keyof SO ? SO[PK] : PV = PK extends keyof SO ? SO[PK] : PV> {
49
24
  key: PK;
50
- /** 表单项label */
51
25
  label: string;
52
- /**
53
- * 隐藏 label 且不占位(label-wrap 整体 display:none,表单元素顶满整行)。
54
- * 仅当 label 有值时生效——无 label 时 element-plus 会给 content 加 margin-left 留白,需改用 labelWidth:0。
55
- */
56
26
  labelHide?: boolean;
57
- /** 提示信息 */
58
27
  tip?: string | (() => VNode);
59
- /** 表单布局 优先级高于FormMain同名属性 */
60
28
  layout?: Partial<ColProps>;
61
- /** 表单外FormItem属性 */
62
29
  wrapProps?: Partial<WrapProps> | ((scope: FormScope<PO, SO, PK, PV, SV>) => Partial<WrapProps>);
63
- /** 表单主体属性 */
64
30
  props?: Record<string, any> | ((scope: FormScope<PO, SO, PK, PV, SV>) => Record<string, any>);
65
- /** 表单渲染函数/渲染标签/组件 */
66
31
  render?: string | Record<string, any> | ((props: {
67
32
  modelValue: PV;
68
33
  ["onUpdate:modelValue"]: (value: PV) => void;
69
34
  placeholder?: string;
70
35
  ["onTriggerChangeLink"]?: (value: SV, attachInfo?: any) => void;
71
36
  } & Record<string, any>) => VNode);
72
- /** 表单校验规则 */
73
37
  rules?: FormItemRule[] | ((scope: FormScope<PO, SO, PK, PV, SV>) => FormItemRule[]);
74
- /** 表单初始值 */
75
38
  init?: (() => PV) | PV;
76
- /** 表单回显解析处理 */
77
39
  parse?: (value: any, parseData: Partial<PO>, originData: ExtractFormStringifyFromObject<PO, SO>) => PV | void;
78
- /** 表单序列化处理 */
79
40
  stringify?: (value: any, stringifyData: Partial<ExtractFormStringifyFromObject<PO, SO>>, originData: PO) => SV | void;
80
- /**
81
- * 是否在初始化数据、解析数据、序列化数据时忽略处理
82
- */
83
41
  ignore?: boolean;
84
- /**
85
- * 是否在表单中隐藏
86
- */
87
42
  hide?: boolean | ((scope: FormScope<PO, SO, PK, PV, SV> & {
88
43
  getInitValue: () => PV;
89
44
  }) => boolean);
90
- /**
91
- * 被关联配置
92
- * 1. 不要配置当前表单项的key
93
- * 2. 最好不要循环关联
94
- * 3. 必须循环关联时,避免循环引用
95
- */
96
45
  beLink?: FormItemLinkConfig<PK, PV, any> | FormItemLinkConfig<PK, PV, any>[];
97
- /**
98
- * 额外一些配置
99
- */
100
46
  extra?: FormItemConfigExtra;
101
47
  }
102
- /** form配置 */
103
48
  export type FormItemConfigList<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> = FormItemConfig<PO, SO>[];
104
- /** 表单数据 */ export type FormModel<L> = L extends FormItemConfigList<infer PO, any> ? PO : Record<string, any>;
105
- /** 提取格式化原始对象 */
49
+ export type FormModel<L> = L extends FormItemConfigList<infer PO, any> ? PO : Record<string, any>;
106
50
  export type ExtractFormStringifyRawFromObject<PO extends Record<string, any>, SO extends Record<string, any>> = {
107
51
  [K in keyof PO | keyof SO]: K extends keyof SO ? SO[K] extends never ? never : SO[K] extends undefined ? K extends keyof PO ? PO[K] : never : SO[K] : K extends keyof PO ? PO[K] : never;
108
52
  };
109
- /** 表单序列化数据原始 */
110
53
  export type ExtractFormStringifyRawFromList<L> = L extends FormItemConfigList<infer PO, infer SO> ? PO extends Record<string, any> ? SO extends Record<string, any> ? ExtractFormStringifyFromObject<PO, SO> : Record<string, any> : Record<string, any> : Record<string, any>;
111
- /** 提取除never以外的属性值 */
112
54
  export type ExcludeNeverProperties<T> = {
113
55
  [K in keyof T as T[K] extends never ? never : K]: T[K];
114
56
  };
115
57
  export type ExtractFormStringifyFromObject<PO extends Record<string, any>, SO extends Record<string, any>> = ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>;
116
- /** 表单序列化数据 */
117
58
  export type ExtractFormStringifyFromList<L> = ExcludeNeverProperties<ExtractFormStringifyRawFromList<L>>;
118
- /** form作用域数据 */
119
- export interface FormScope<
120
- /** 解析的模型 */
121
- PO extends Record<string, any>,
122
- /** 需要格式化的模型 */
123
- SO extends Record<string, any>,
124
- /** 解析的模型的key */
125
- PK extends Extract<keyof PO, string>,
126
- /** 解析的模型的值 */
127
- PV extends PO[PK],
128
- /** 需要格式化的模型的值 */
129
- SV extends PK extends keyof SO ? SO[PK] : PV> {
59
+ export interface FormScope<PO extends Record<string, any>, SO extends Record<string, any>, PK extends Extract<keyof PO, string>, PV extends PO[PK], SV extends PK extends keyof SO ? SO[PK] : PV> {
130
60
  data: PO;
131
61
  config: FormItemConfig<PO, SO, PK, PV, SV>;
132
62
  }
133
- /** FormMain expose类型 */
134
63
  export interface FormMainInstance<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> {
135
64
  validate: () => Promise<void>;
136
65
  resetFields: () => void;
@@ -139,59 +68,44 @@ export interface FormMainInstance<PO extends Record<string, any> = Record<string
139
68
  parse: (stringifyData: ExtractFormStringifyFromObject<PO, SO>) => PO;
140
69
  stringify: () => ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>;
141
70
  }
142
- /** FormSearch expose类型 */
143
71
  export interface FormSearchInstance<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> extends Omit<FormMainInstance<PO, SO>, "generate" | "parse" | "stringify"> {
144
- /** 触发搜索 */
145
72
  triggerSearch: () => void;
146
- /** 触发重置 */
147
73
  triggerReset: () => void;
148
- /** 切换折叠状态 */
149
74
  toggleCollapse: (nextValue?: boolean) => void;
150
- /** 当前折叠状态 */
151
75
  isCollapsed: ComputedRef<boolean>;
152
76
  }
153
- /** FormItem props */
154
77
  export interface FormMainItemProps {
155
78
  config: FormItemConfig<Record<string, any>, Record<string, any>>;
156
79
  data: Record<string, any>;
157
80
  }
158
- /** FormMain props */
159
81
  export interface FormMainProps<PO extends Record<string, any>, SO extends Record<string, any>> {
160
82
  list: FormItemConfigList<PO, SO>;
161
83
  data: PO;
162
84
  layout?: Partial<ColProps>;
163
85
  rowGutter?: number;
164
- /** P3 嵌套 rebase 累乘因子(缺省 1 = 顶级行为不变,向后兼容)。由联结薄壳算出后传子 FormMain */
165
86
  layoutScale?: number;
166
87
  }
167
- /** FormSearch props */
168
88
  export interface FormSearchProps<PO extends Record<string, any>, SO extends Record<string, any>, SQ extends Record<string, any>> extends FormMainProps<PO, SO> {
169
89
  labelPosition?: "right" | "left" | "top";
170
90
  labelWidth?: string;
171
- /** 静态参数(非表单 非分页参数) */
172
91
  staticQuery?: SQ;
173
- /** 最多展示行数,超出折叠。0 = 不折叠。默认 2 */
174
92
  maxRows?: number;
175
93
  }
176
- /** form item loading 信息 */
177
94
  export interface FormItemLoadingInfo {
178
95
  key: string;
179
96
  label: string;
180
97
  message: string;
181
98
  }
182
- /** form item 加载状态信息 */
183
99
  export type FormItemLoadingChangeFunc = (data: {
184
100
  key: string;
185
101
  message?: string;
186
102
  }) => void;
187
- /** 选项类型 */
188
103
  export interface OptionItem extends Record<string, any> {
189
104
  label: string | number;
190
105
  value: string | number;
191
106
  disabled?: boolean;
192
107
  [key: string]: any;
193
108
  }
194
- /** form tree 单项类型 */
195
109
  export interface FormTreeItem {
196
110
  id: string | number;
197
111
  label: string;
@@ -199,136 +113,45 @@ export interface FormTreeItem {
199
113
  disabled?: boolean;
200
114
  [key: string]: any;
201
115
  }
202
- /** form单项表单提交类型 */
203
116
  export type FormItemSubmitType = "blur" | "change" | "enter";
204
- /** 表单搜索搜索类型 */
205
117
  export type FormSearchSearchType = "search" | "reset" | FormItemSubmitType;
206
- /**
207
- * ElDatePicker 原生 `shortcuts` 项(时间段快捷)。
208
- * 直接传给 `<ElDatePicker :shortcuts="...">`,由 ElDatePicker 自身的
209
- * pick 管线按其 value-format 归一化输出,无需额外格式化依赖。
210
- */
211
118
  export interface DatePickerShortcut {
212
119
  text: string;
213
120
  value: () => [Date, Date];
214
121
  }
215
- export type FormItemConfigSwiftOptionsCommon<PO extends Record<string, any>,
216
- /** 需要格式化的模型 */
217
- SO extends Record<string, any>> = Omit<FormItemConfig<PO, SO>, "rules"> & {
218
- /** label */
219
- /**
220
- * 表单类型
221
- * ----
222
- * input: 会补齐 extra.isInput = true 最终表现在组件会默认设置placeholder `请输入${label}`,同时如果设置了required 会自动添加一条校验规则 提示信息同 placeholder;
223
- *
224
- * select: 会补齐 extra.isSelect = true 最终表现在组件会默认设置placeholder `请选择${label}`,同时如果设置了required 会自动添加一条校验规则 提示信息同 placeholder;
225
- * 如果不设置此项 不会补齐 extra
226
- */
122
+ export type FormItemConfigSwiftOptionsCommon<PO extends Record<string, any>, SO extends Record<string, any>> = Omit<FormItemConfig<PO, SO>, "rules"> & {
227
123
  type?: "input" | "select";
228
124
  };
229
- /** 表单配置项快捷生成类型 - 设置required */
230
- export interface FormItemConfigSwiftOptionsRequired<PO extends Record<string, any>,
231
- /** 需要格式化的模型 */
232
- SO extends Record<string, any>> extends FormItemConfigSwiftOptionsCommon<PO, SO> {
233
- /**
234
- * 是否必填
235
- * -----
236
- * 设置了此项 不能设置 rules, 如果校验规则只是验证必填 使用此选项更方便
237
- */
125
+ export interface FormItemConfigSwiftOptionsRequired<PO extends Record<string, any>, SO extends Record<string, any>> extends FormItemConfigSwiftOptionsCommon<PO, SO> {
238
126
  required?: true;
239
127
  }
240
- /** 表单配置项快捷生成类型 - 设置rules */
241
- export interface FormItemConfigSwiftOptionsRules<PO extends Record<string, any>,
242
- /** 需要格式化的模型 */
243
- SO extends Record<string, any>> extends FormItemConfigSwiftOptionsCommon<PO, SO> {
244
- /**
245
- * 校验规则
246
- * ---
247
- * 设置了此项 不能直接设置 required, 如果校验规则特殊 或者 要基于数据值动态校验 请使用 rules
248
- */
128
+ export interface FormItemConfigSwiftOptionsRules<PO extends Record<string, any>, SO extends Record<string, any>> extends FormItemConfigSwiftOptionsCommon<PO, SO> {
249
129
  rules?: FormItemConfig["rules"];
250
130
  }
251
- /** 表单数据信息 */
252
- export interface FormDataInfo<PO extends Record<string, any>,
253
- /** 需要格式化的模型 */
254
- SO extends Record<string, any>> {
255
- /** 表单模型数据 */
131
+ export interface FormDataInfo<PO extends Record<string, any>, SO extends Record<string, any>> {
256
132
  parseData: PO;
257
- /** 表单序列化数据 */
258
133
  stringifyData: ExtractFormStringifyFromObject<PO, SO>;
259
134
  }
260
- /** 表单配置项快捷生成类型 */
261
- export type FormItemConfigSwiftOptions<PO extends Record<string, any>,
262
- /** 需要格式化的模型 */
263
- SO extends Record<string, any>> = FormItemConfigSwiftOptionsRequired<PO, SO> | FormItemConfigSwiftOptionsRules<PO, SO>;
264
- /** 表单提交按钮 */
135
+ export type FormItemConfigSwiftOptions<PO extends Record<string, any>, SO extends Record<string, any>> = FormItemConfigSwiftOptionsRequired<PO, SO> | FormItemConfigSwiftOptionsRules<PO, SO>;
265
136
  export type FormSubmitBtnProps<PO extends Record<string, any>, SO extends Record<string, any>> = Omit<ButtonProps, "loading"> & {
266
- /** form main expose */
267
137
  formMainInstance: FormMainInstance<PO, SO>;
268
- /** 提交按钮文本 */
269
138
  submitText?: string;
270
- /** 提交方法 */
271
139
  submitFn: (stringifyData: ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>) => Promise<unknown>;
272
140
  };
273
- /** 表单提交按钮扁平属性 */
274
141
  export type FormSubmitPanelFlatProps = Extract<keyof FormSubmitBtnProps<Record<string, any>, Record<string, any>>, "submitText" | "submitFn">;
275
- /**
276
- * 表单提交面板 props——= FormMain props 透传 + 提交相关。
277
- * 容器内编排 FormMain + FormSubmitBtn(formMainInstance 内部自动接线),对称 FormSearch。
278
- */
279
142
  export type FormSubmitPanelProps<PO extends Record<string, any>, SO extends Record<string, any>> = Omit<FormMainProps<PO, SO>, "data"> & {
280
- /**
281
- * 序列化的数据
282
- * -----
283
- * 此属性不为空 那么优先使用此字段转换为PO数据模型, 否则内部会基于表单配置化 生成初始化 PO 数据模型
284
- */
285
143
  stringifyData?: ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>;
286
144
  } & Pick<FormSubmitBtnProps<PO, SO>, FormSubmitPanelFlatProps> & {
287
145
  submitBtnProps?: Omit<FormSubmitBtnProps<PO, SO>, FormSubmitPanelFlatProps | "formMainInstance">;
288
146
  } & {
289
147
  labelPosition?: "right" | "left" | "top";
290
148
  labelWidth?: string;
291
- /**
292
- * 取消按钮
293
- * -----
294
- * 同名插槽优先级高于props,如果是props则只是取消按钮的文字 为空则不展示
295
- * ----
296
- * 默认的cancelBtn插槽的按钮点击后触发 cancel 事件
297
- */
298
149
  cancelBtn?: string;
299
- /** 重置按钮
300
- * -----
301
- * 同名插槽优先级高于props,如果是props则只是重置按钮的文字 为空则不展示
302
- * ----
303
- * 默认的resetBtn插槽的按钮点击后重置内部 parseData,并通过 parseDataChange 通知外部
304
- */
305
150
  resetBtn?: string;
306
- /** 操作区位置
307
- * ----
308
- * 默认值 bottom-center
309
- */
310
151
  operationPosition?: "bottom-center" | "bottom-right" | "top-right";
311
- /** 操作区是否做图钉
312
- * ----
313
- * 默认值 false
314
- */
315
152
  operationAffix?: boolean | AffixProps;
316
- /** 操作区分隔线(含外侧圆角)
317
- * ----
318
- * 默认值 true;置 false 去掉分隔线 + 圆角(极简 / 单按钮场景)
319
- */
320
153
  divider?: boolean;
321
- /** 操作区无内边距(bare)
322
- * ----
323
- * 默认 false;置 true 去掉操作区 padding(嵌入 / 极简场景)。
324
- * 与 divider 正交:divider 管边框+圆角,bare 管 padding,可叠加全 flush。
325
- */
326
154
  bare?: boolean;
327
- /** 根面板自定义 class(显式根出口)
328
- * ----
329
- * inheritAttrs:false 下消费方 `class` 经 v-bind 转发内层 FormMain(对标 FormSearch),
330
- * 根面板 `.form-submit-panel` 拿不到。需给根面板加类时用本 prop。
331
- */
332
155
  rootClass?: string | string[] | Record<string, boolean>;
333
156
  };
334
157
  export {};
@@ -1,25 +1,13 @@
1
1
  import { Ref } from 'vue';
2
2
  import { FormMainInstance, FormSubmitBtnProps, FormDataInfo } from './types';
3
- /** useFormSubmit 入参——提交管线的 4 个外部接线点 */
4
3
  export interface UseFormSubmitOptions<PO extends Record<string, any>, SO extends Record<string, any>> {
5
- /** 惰性取 FormMain 实例(首渲染 undefined 容忍,click 时才用) */
6
4
  getFormMainInstance: () => FormMainInstance<PO, SO>;
7
- /** 提交方法(每次调用时读取,保留响应式) */
8
5
  submitFn: FormSubmitBtnProps<PO, SO>["submitFn"];
9
- /** 成功回调(载荷 = stringifyData) */
10
6
  onSuccess?: (data: FormDataInfo<PO, SO>["stringifyData"]) => void;
11
- /** 失败回调(校验未过 / submitFn reject) */
12
7
  onFail?: (error: unknown) => void;
13
8
  }
14
- /** useFormSubmit 返回——loading 态 + 提交触发器 */
15
9
  export interface UseFormSubmitReturn {
16
- /** 提交中 loading 态 */
17
10
  submitting: Ref<boolean>;
18
- /** 触发提交:validate → stringify → submitFn → onSuccess / onFail */
19
11
  submit: () => Promise<void>;
20
12
  }
21
- /**
22
- * 表单提交管线 composable——validate→stringify→submitFn 全程接管 loading。
23
- * FormSubmitBtn 与 FormSubmitPanel(#submitBtn slot) 共用,单一事实源。
24
- */
25
13
  export declare function useFormSubmit<PO extends Record<string, any>, SO extends Record<string, any>>(options: UseFormSubmitOptions<PO, SO>): UseFormSubmitReturn;
@@ -1,20 +1,7 @@
1
1
  import { MaybeRefOrGetter } from 'vue';
2
2
  import { FormMainInstance } from './types';
3
3
  export interface UseNestFormListOptions {
4
- /** 当前存活行子 FormMain 实例(getter,每次取最新存活集合) */
5
4
  rowInstances: () => FormMainInstance[];
6
- /**
7
- * 父 item key——注册到父 FormMain exposeMap 的索引(C4 必传);
8
- * 无父 FormMain registry(脱离嵌套上下文)时 inject 返回 null → 跳过注册。
9
- */
10
5
  key?: MaybeRefOrGetter<string | undefined>;
11
6
  }
12
- /**
13
- * 数组子表单聚合注册 composable(C4 配套,ADR-1/2)
14
- * ----
15
- * 向最近祖先 FormMain registry 注册【1 个聚合 expose】(key = 本 item key),方法体
16
- * fan-out 遍历当前存活 N 行子 FormMain:validate=Promise.all、clearValidate/resetFields=forEach。
17
- * → 父 registry 仍「1 item 1 entry」,父 validate 的 hideKeyList 过滤按 item key 命中(守 ADR-8)。
18
- * 职责收窄:仅聚合注册 + 摘除,[MUST NOT] 碰值贯通 / 增删(组件自管)。
19
- */
20
7
  export declare function useNestFormList(options: UseNestFormListOptions): void;
@@ -1,24 +1,9 @@
1
1
  import { MaybeRefOrGetter, Ref } from 'vue';
2
2
  import { FormMainInstance } from './types';
3
3
  export interface UseNestFormOptions {
4
- /** 子 FormMain 实例 ref(联结组件内 FormMain 的 defineExpose) */
5
4
  childRef: Ref<FormMainInstance | undefined>;
6
- /**
7
- * 所属父 item key——注册到父 FormMain exposeMap 时必传(C1 form 族,作 map 索引);
8
- * panel 上下文(C3)无父 FormMain exposeMap,可省(inject 返回 null → 跳过注册)。
9
- * 接受 ref/getter,挂载/摘除时经 toValue 取值(避免 setup 根作用域读 props 失响应式)。
10
- */
11
5
  key?: MaybeRefOrGetter<string | undefined>;
12
6
  }
13
- /**
14
- * 嵌套联结组件子表单接线 composable
15
- * ----
16
- * 职责(ADR-7,刻意收窄):
17
- * 1. 代理子 FormMain 的 validate / clearValidate / resetFields;
18
- * 2. context 自适应注册——inject 到最近祖先 FormMain 的 exposeMap 则按 key 写入(onMounted)+
19
- * 删除(onBeforeUnmount);无(panel 上下文)则跳过。
20
- * [MUST NOT] 在此处理值贯通——值语义 form/panel 两族不同(ADR-5),由各联结组件自管。
21
- */
22
7
  export declare function useNestForm(options: UseNestFormOptions): {
23
8
  validateChild: () => Promise<void>;
24
9
  clearChild: (k?: string) => void;
@@ -1,17 +1,5 @@
1
1
  import { MaybeRefOrGetter, ComputedRef } from 'vue';
2
- /**
3
- * 联结薄壳计算子 Form/PanelMain 的嵌套布局 rebase 因子(P3,4 薄壳共用)。
4
- * ----
5
- * `childScale = parentScale × (24 / parentSpan)`:
6
- * - parentScale 经 inject 从最近祖先 Form/PanelMain 取(顶级 / 未嵌套 → 缺省 1);
7
- * - parentSpan = 父 item 实际分配的代表 span(薄壳由 helper 经 props 传入,缺省 24 = 本层不缩);
8
- * - `rebase === false`(逆向逃生口)→ 不叠本层因子(= parentScale),layout 原样直透子层。
9
- * ----
10
- * 返回 ComputedRef,薄壳作 `layoutScale` 传子 FormMain/PanelMain(其再 resolveFormLayout 取整到档集)。
11
- */
12
2
  export declare function useNestLayoutScale(options: {
13
- /** 父 item 代表 span(来自 helper 的 resolveLayoutSpan(layout)) */
14
3
  parentSpan: MaybeRefOrGetter<number | undefined>;
15
- /** 是否叠本层 rebase 因子(缺省 true;false = 逆向逃生口) */
16
4
  rebase: MaybeRefOrGetter<boolean | undefined>;
17
5
  }): ComputedRef<number>;