@done-coding/admin-core 0.6.1-alpha.0 → 0.7.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 (39) hide show
  1. package/es/components/display/ActionBtnGroup.vue.mjs +1 -1
  2. package/es/components/{misc → display}/ActionConfirm.vue.mjs +2 -2
  3. package/es/components/form/FormMain.vue.mjs +47 -44
  4. package/es/components/form/FormSearch.vue.mjs +2 -2
  5. package/es/components/form/FormSearch.vue2.mjs +47 -46
  6. package/es/components/form/FormSubmitBtn.vue.mjs +66 -0
  7. package/es/components/form/FormSubmitBtn.vue2.mjs +4 -0
  8. package/es/components/form/FormSubmitPanel.vue.mjs +7 -0
  9. package/es/components/form/FormSubmitPanel.vue2.mjs +112 -0
  10. package/es/components/panel/PanelEditSwitch.vue.mjs +1 -1
  11. package/es/components/panel/PanelEditSwitch.vue2.mjs +67 -71
  12. package/es/components/panel/PanelItem.vue.mjs +72 -42
  13. package/es/components/panel/PanelMain.vue.mjs +5 -78
  14. package/es/components/panel/PanelMain.vue2.mjs +99 -2
  15. package/es/index.mjs +92 -88
  16. package/es/style.css +1 -1
  17. package/package.json +4 -2
  18. package/types/components/display/index.d.ts +12 -0
  19. package/types/components/display/types.d.ts +87 -1
  20. package/types/components/form/FormItem.vue.d.ts +2 -2
  21. package/types/components/form/FormMain.vue.d.ts +1 -1
  22. package/types/components/form/FormSearch.vue.d.ts +1 -1
  23. package/types/components/form/FormSubmitBtn.vue.d.ts +20 -0
  24. package/types/components/form/FormSubmitPanel.vue.d.ts +46 -0
  25. package/types/components/form/index.d.ts +3 -1
  26. package/types/components/form/types.d.ts +68 -3
  27. package/types/components/list-page/ListPage.vue.d.ts +1 -1
  28. package/types/components/list-page/types.d.ts +1 -1
  29. package/types/components/misc/index.d.ts +1 -3
  30. package/types/components/misc/types.d.ts +0 -88
  31. package/types/components/panel/PanelItem.vue.d.ts +18 -10
  32. package/types/components/panel/PanelMain.vue.d.ts +3 -5
  33. package/types/components/panel/types.d.ts +64 -33
  34. package/types/components/panel/PanelEditSwitch.vue.d.ts +0 -28
  35. /package/es/components/{misc → display}/ActionBtn.vue.mjs +0 -0
  36. /package/es/components/{misc → display}/ActionBtn.vue2.mjs +0 -0
  37. /package/es/components/{misc → display}/ActionConfirm.vue2.mjs +0 -0
  38. /package/types/components/{misc → display}/ActionBtn.vue.d.ts +0 -0
  39. /package/types/components/{misc → display}/ActionConfirm.vue.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { FormItemRule, ColProps, FormItemProps } from 'element-plus';
1
+ import { FormItemRule, ColProps, FormItemProps, ButtonProps, AffixProps } from 'element-plus';
2
2
  import { VNode, ComputedRef } from 'vue';
3
3
  export type OnlyOneKey<T extends Record<string, any>> = {
4
4
  [K in keyof T]: {
@@ -131,13 +131,16 @@ SV extends PK extends keyof SO ? SO[PK] : PV> {
131
131
  config: FormItemConfig<PO, SO, PK, PV, SV>;
132
132
  }
133
133
  /** FormMain expose类型 */
134
- export interface FormMainInstance {
134
+ export interface FormMainInstance<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> {
135
135
  validate: () => Promise<void>;
136
136
  resetFields: () => void;
137
137
  clearValidate: (key?: string) => void;
138
+ generate: () => PO;
139
+ parse: (stringifyData: ExtractFormStringifyFromObject<PO, SO>) => PO;
140
+ stringify: () => ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>;
138
141
  }
139
142
  /** FormSearch expose类型 */
140
- export interface FormSearchInstance extends FormMainInstance {
143
+ 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"> {
141
144
  /** 触发搜索 */
142
145
  triggerSearch: () => void;
143
146
  /** 触发重置 */
@@ -243,8 +246,70 @@ SO extends Record<string, any>> extends FormItemConfigSwiftOptionsCommon<PO, SO>
243
246
  */
244
247
  rules?: FormItemConfig["rules"];
245
248
  }
249
+ /** 表单数据信息 */
250
+ export interface FormDataInfo<PO extends Record<string, any>,
251
+ /** 需要格式化的模型 */
252
+ SO extends Record<string, any>> {
253
+ /** 表单模型数据 */
254
+ parseData: PO;
255
+ /** 表单序列化数据 */
256
+ stringifyData: ExtractFormStringifyFromObject<PO, SO>;
257
+ }
246
258
  /** 表单配置项快捷生成类型 */
247
259
  export type FormItemConfigSwiftOptions<PO extends Record<string, any>,
248
260
  /** 需要格式化的模型 */
249
261
  SO extends Record<string, any>> = FormItemConfigSwiftOptionsRequired<PO, SO> | FormItemConfigSwiftOptionsRules<PO, SO>;
262
+ /** 表单提交按钮 */
263
+ export type FormSubmitBtnProps<PO extends Record<string, any>, SO extends Record<string, any>> = Omit<ButtonProps, "loading"> & {
264
+ /** form main expose */
265
+ formMainInstance: FormMainInstance<PO, SO>;
266
+ /** 提交按钮文本 */
267
+ submitText?: string;
268
+ /** 提交方法 */
269
+ submitFn: (stringifyData: ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>) => Promise<unknown>;
270
+ };
271
+ /** 表单提交按钮扁平属性 */
272
+ export type FormSubmitPanelFlatProps = Extract<keyof FormSubmitBtnProps<Record<string, any>, Record<string, any>>, "submitText" | "submitFn">;
273
+ /**
274
+ * 表单提交面板 props——= FormMain props 透传 + 提交相关。
275
+ * 容器内编排 FormMain + FormSubmitBtn(formMainInstance 内部自动接线),对称 FormSearch。
276
+ */
277
+ export type FormSubmitPanelProps<PO extends Record<string, any>, SO extends Record<string, any>> = Omit<FormMainProps<PO, SO>, "data"> & {
278
+ /**
279
+ * 序列化的数据
280
+ * -----
281
+ * 此属性不为空 那么优先使用此字段转换为PO数据模型, 否则内部会基于表单配置化 生成初始化 PO 数据模型
282
+ */
283
+ stringifyData?: ExcludeNeverProperties<ExtractFormStringifyRawFromObject<PO, SO>>;
284
+ } & Pick<FormSubmitBtnProps<PO, SO>, FormSubmitPanelFlatProps> & {
285
+ submitBtnProps?: Omit<FormSubmitBtnProps<PO, SO>, FormSubmitPanelFlatProps | "formMainInstance">;
286
+ } & {
287
+ labelPosition?: "right" | "left" | "top";
288
+ labelWidth?: string;
289
+ /**
290
+ * 取消按钮
291
+ * -----
292
+ * 同名插槽优先级高于props,如果是props则只是取消按钮的文字 为空则不展示
293
+ * ----
294
+ * 默认的cancelBtn插槽的按钮点击后触发 cancel 事件
295
+ */
296
+ cancelBtn?: string;
297
+ /** 重置按钮
298
+ * -----
299
+ * 同名插槽优先级高于props,如果是props则只是重置按钮的文字 为空则不展示
300
+ * ----
301
+ * 默认的resetBtn插槽的按钮点击后触发 reset 事件
302
+ */
303
+ resetBtn?: string;
304
+ /** 操作区位置
305
+ * ----
306
+ * 默认值 bottom-center
307
+ */
308
+ operationPosition?: "bottom-center" | "bottom-right" | "top-right";
309
+ /** 操作区是否做图钉
310
+ * ----
311
+ * 默认值 false
312
+ */
313
+ operationAffix?: boolean | AffixProps;
314
+ };
250
315
  export {};
@@ -26,7 +26,7 @@ declare const _default: <T extends Record<string, any>, PO extends Record<string
26
26
  beforeSearch?: ((data: import('../form').ExcludeNeverProperties<import('../form').ExtractFormStringifyRawFromObject<PO, SO>>, type: FormSearchSearchType) => import('../form').ExcludeNeverProperties<import('../form').ExtractFormStringifyRawFromObject<PO, SO>>) | undefined;
27
27
  clearTableFilterOnReset?: boolean;
28
28
  }) & Partial<{}>> & import('vue').PublicProps;
29
- expose(exposed: import('vue').ShallowUnwrapRef<ListPageInstance<PO>>): void;
29
+ expose(exposed: import('vue').ShallowUnwrapRef<ListPageInstance<PO, Record<string, any>>>): void;
30
30
  attrs: any;
31
31
  slots: Readonly<{
32
32
  /** 头部插槽(无 scope) */
@@ -34,7 +34,7 @@ F extends Record<string, any>> = Partial<Pick<FormSearchProps<PO, SO, {}>, FormS
34
34
  /** 在点击搜索重置按钮时,是否同时调用清空表格表头过滤 */
35
35
  clearTableFilterOnReset?: boolean;
36
36
  };
37
- export interface ListPageInstance<PO extends Record<string, any> = Record<string, any>> extends FormSearchInstance, TableMainInstance {
37
+ export interface ListPageInstance<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> extends FormSearchInstance<PO, SO>, TableMainInstance {
38
38
  /** 更新表单数据 */
39
39
  update: (key: Extract<keyof PO, string>, value: any) => void;
40
40
  }
@@ -1,8 +1,6 @@
1
1
  import { default as TriggerAutoImport } from './TriggerAutoImport.vue';
2
2
  import { default as AutoRefresh } from './AutoRefresh.vue';
3
3
  import { default as AutoRefreshGroup } from './AutoRefreshGroup.vue';
4
- import { default as ActionBtn } from './ActionBtn.vue';
5
- import { default as ActionConfirm } from './ActionConfirm.vue';
6
4
  import { default as SelectModule } from './SelectModule.vue';
7
5
  export * from './types';
8
6
  export {
@@ -10,4 +8,4 @@ export {
10
8
  * @deprecated 全局样式引入后已无用——main.ts `import "element-plus/dist/index.css"`
11
9
  * + ElementPlusResolver `importStyle: false` 即可,无需本组件触发按需样式。下个 MAJOR 删除。
12
10
  */
13
- TriggerAutoImport, AutoRefresh, AutoRefreshGroup, ActionBtn, ActionConfirm, SelectModule, };
11
+ TriggerAutoImport, AutoRefresh, AutoRefreshGroup, SelectModule, };
@@ -1,91 +1,3 @@
1
- import { VNode } from 'vue';
2
- import { ButtonProps } from 'element-plus';
3
- /** ActionConfirm 确认交互形态:弹层气泡 / 居中模态框 */
4
- export type ActionConfirmMode = "popconfirm" | "messageConfirm";
5
- /**
6
- * ActionConfirm 文案解析器。
7
- * - string:直接渲染
8
- * - 无参函数:返回字符串或 VNode 数组(富文本);动态数据由调用方闭包捕获
9
- */
10
- export type ActionConfirmTextResolver = string | (() => string | VNode[]);
11
- /**
12
- * ActionBtn 的确认配置(嵌套对象;无此配置则为普通按钮,不触发确认)。
13
- *
14
- * ⚠️ 瞬时用户激活限制:`confirmConfig` 与 `beforeOpen` 均会异步打断点击的瞬时
15
- * 用户激活窗口(transient user activation)——confirm 后 / beforeOpen 之后的
16
- * handler 与原始点击之间隔了一次异步等待,原始激活此时已过期(注意:事件对象
17
- * `isTrusted` 仍为 true,失效的是激活窗口而非事件本身)。故 confirm 后 /
18
- * beforeOpen 之后的 handler [MUST NOT] 调用依赖瞬时用户激活的 API——
19
- * `window.open`、`navigator.clipboard.*`、`requestFullscreen` 等会被浏览器
20
- * 拦截。需要这类操作时改用无 `confirmConfig` 且无 `beforeOpen` 的 ActionBtn /
21
- * 普通按钮。此为 confirm-gate / async-prefetch 模式固有代价,组件层无法绕过。
22
- */
23
- export interface ActionBtnConfirmConfig {
24
- /** 确认标题 */
25
- title?: ActionConfirmTextResolver;
26
- /** 确认正文内容 */
27
- content?: ActionConfirmTextResolver;
28
- /** 确认按钮文案,默认"确定" */
29
- confirmText?: string;
30
- /** 取消按钮文案,默认"取消" */
31
- cancelText?: string;
32
- /** 确认按钮 type */
33
- type?: ButtonProps["type"];
34
- }
35
- /**
36
- * ActionBtn 组件 props。
37
- * 完全兼容 ElButton(继承 ButtonProps),仅一处改写 + 三个增量:
38
- * - `loading` 被 Omit:有意的 ElButton 不兼容,唯一接管项——loading 由组件内部
39
- * 独占,对接异步 confirm / beforeOpen 的进行态(innerLoading),对外不可设置。
40
- * - `disabled` 原生透传,不改写不扩展。
41
- * - 增量:`confirmMode` / `confirmConfig` / `beforeOpen`。
42
- * - 泛型 `T`:由 `beforeOpen` 返回值反推,并透传给 `confirmConfig` 函数形态的
43
- * 入参;未传 `beforeOpen` 时默认 `T = void`,函数形态的 `data = undefined`。
44
- */
45
- export type ActionBtnProps<T = void> = Omit<ButtonProps, "loading"> & {
46
- /** 确认交互形态,仅在 confirmConfig 存在时生效,默认 "popconfirm" */
47
- confirmMode?: ActionConfirmMode;
48
- /**
49
- * 确认配置;存在时点击需经确认闸门,确认后才触发 click。
50
- * - 对象形态:静态确认配置(向后兼容)。
51
- * - 函数形态:`(data: T) => ActionBtnConfirmConfig`,`data` 来自 `beforeOpen`
52
- * 返回值;无 `beforeOpen` 时 `data = undefined`(T 默认 `void`)。
53
- */
54
- confirmConfig?: ActionBtnConfirmConfig | ((data: T) => ActionBtnConfirmConfig);
55
- /**
56
- * 点击后、弹层前的异步预取钩子。
57
- * - 返回值类型 `T` 反推给 `confirmConfig` 函数形态的入参。
58
- * - 失败时静默退出(不弹层、不触发 `@click` handler);调用方 [MUST] 在内部
59
- * 自行 catch 并显示反馈(如 `ElMessage.error`),忘记 catch 会"点了没反应"。
60
- * - 期间按钮显 loading 态(`innerLoading`);同 `confirmConfig` 一样消耗
61
- * 瞬时用户激活(详见 {@link ActionBtnConfirmConfig} 顶部注释)。
62
- */
63
- beforeOpen?: () => Promise<T>;
64
- };
65
- /**
66
- * ActionConfirm 组件 props(扁平,confirm 原语;可独立于 ActionBtn 消费)。
67
- * 触发元素由默认 slot 提供;弹层可见性由 `v-model:show` 声明式驱动。
68
- */
69
- export interface ActionConfirmProps {
70
- /** 确认交互形态 */
71
- mode: ActionConfirmMode;
72
- /** 确认标题 */
73
- title?: ActionConfirmTextResolver;
74
- /** 确认正文内容 */
75
- content?: ActionConfirmTextResolver;
76
- /** 确认按钮文案,默认"确定" */
77
- confirmText?: string;
78
- /** 取消按钮文案,默认"取消" */
79
- cancelText?: string;
80
- /** 确认按钮 type */
81
- type?: ButtonProps["type"];
82
- /**
83
- * 点击确认后调用。返回 Promise 时确认按钮 loading + 弹层保持不关,
84
- * **仅成功(fulfill)才关闭弹层**;失败(reject 或同步 throw)时清 loading、
85
- * 弹层保持打开,错误由 `submitFn` 内部自行 catch 反馈。
86
- */
87
- submitFn: () => void | Promise<void>;
88
- }
89
1
  /** AutoRefresh 组件 props */
90
2
  export interface AutoRefreshProps {
91
3
  /** 刷新方法,返回 Promise。失败不影响下轮定时 */
@@ -1,12 +1,20 @@
1
1
  import { PanelItemProps } from './types';
2
- type __VLS_Props = PanelItemProps;
3
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
4
- refresh: () => any;
5
- "update:editing": (value: boolean) => any;
6
- submitFinish: (success: boolean, data: Record<string, any>) => any;
7
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & 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, false, {}, any>;
2
+ import { FormDataInfo } from '../form/types.ts';
3
+ declare const _default: <PO extends Record<string, any>, SO extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
5
+ readonly "onUpdate:editing"?: ((value: boolean) => any) | undefined;
6
+ readonly onSubmitSuccess?: ((data: FormDataInfo<PO, SO>) => any) | undefined;
7
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onSubmitSuccess" | "onUpdate:editing"> & ({
8
+ editing?: boolean;
9
+ } & PanelItemProps<PO, SO>) & Partial<{}>> & import('vue').PublicProps;
10
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
11
+ attrs: any;
12
+ slots: {};
13
+ emit: ((e: "submitSuccess", data: FormDataInfo<PO, SO>) => void) & ((evt: "update:editing", value: boolean) => void);
14
+ }>) => import('vue').VNode & {
15
+ __ctx?: Awaited<typeof __VLS_setup>;
16
+ };
12
17
  export default _default;
18
+ type __VLS_PrettifyLocal<T> = {
19
+ [K in keyof T]: T[K];
20
+ } & {};
@@ -1,12 +1,10 @@
1
1
  import { PanelMainProps } from './types';
2
- declare const _default: <T extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
- readonly onRefresh?: ((data: T) => any) | undefined;
5
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onRefresh"> & PanelMainProps<T> & Partial<{}>> & import('vue').PublicProps;
2
+ declare const _default: <PO extends Record<string, any>, SO extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & PanelMainProps<PO, SO> & Partial<{}>> & import('vue').PublicProps;
6
4
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
5
  attrs: any;
8
6
  slots: {};
9
- emit: (e: "refresh", data: T) => void;
7
+ emit: {};
10
8
  }>) => import('vue').VNode & {
11
9
  __ctx?: Awaited<typeof __VLS_setup>;
12
10
  };
@@ -1,25 +1,34 @@
1
1
  import { VNode } from 'vue';
2
- import { ColProps } from 'element-plus';
3
- /** Panel 只读渲染作用域(render 用) */
4
- export interface PanelScope<T extends Record<string, any> = Record<string, any>> {
2
+ import { ColProps, CardProps } from 'element-plus';
3
+ import { ExtractFormStringifyFromObject, FormDataInfo, FormItemConfig, FormSubmitPanelProps } from '../form';
4
+ /**
5
+ * 通用作用于
6
+ * -----
7
+ * 用于 render 、editorRender 及 判断
8
+ */
9
+ export interface PanelScopeBase<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> {
5
10
  /** 原始数据(只读消费,[MUST NOT] 在 render 内修改) */
6
- data: T;
11
+ data: ExtractFormStringifyFromObject<PO, SO>;
7
12
  /** data[config.key] */
8
13
  value: any;
9
- config: PanelItemConfig<T>;
10
- /** 请求 PanelMain 向父层触发 refresh(preview 组件绕开 PanelEditSwitch 刷新用) */
11
- refresh?: () => void;
14
+ /** 配置项 */
15
+ config: PanelItemConfig<PO, SO>;
12
16
  }
13
- /** Panel 编辑器作用域(editorRender 用,data = 深克隆副本) */
14
- export interface PanelEditorScope<T extends Record<string, any> = Record<string, any>> {
15
- /** PanelEditSwitch 内部深克隆副本(编辑器直接改它) */
16
- data: T;
17
- /** data[config.key](克隆体上的值) */
18
- value: any;
19
- config: PanelItemConfig<T>;
17
+ /**
18
+ * Panel render 作用域
19
+ * -----
20
+ * 应用于 render \ editorRender
21
+ */
22
+ export interface PanelRenderScope<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> extends PanelScopeBase<PO, SO> {
23
+ /** 是否编辑态 */
24
+ editing: boolean;
25
+ /** 请求 PanelMain 向父层触发 refresh(preview 组件绕开 PanelEditSwitch 刷新用) */
26
+ refresh?: () => Promise<unknown> | void;
27
+ /** 结束编辑态 */
28
+ closeEdit?: () => void;
20
29
  }
21
30
  /** Panel 配置项 */
22
- export interface PanelItemConfig<T extends Record<string, any> = Record<string, any>> {
31
+ export interface PanelItemConfig<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> {
23
32
  /** 数据键 */
24
33
  key: string;
25
34
  /** 标签,非必填 */
@@ -29,33 +38,55 @@ export interface PanelItemConfig<T extends Record<string, any> = Record<string,
29
38
  /** 顺序,缺省按数组序 */
30
39
  order?: number;
31
40
  /** 隐藏 */
32
- hide?: boolean | ((scope: PanelScope<T>) => boolean);
41
+ hide?: boolean | ((scope: PanelScopeBase<PO, SO>) => boolean);
33
42
  /** 只读渲染;缺省=纯文本 data[key] */
34
- render?: string | Record<string, any> | ((scope: PanelScope<T>) => VNode);
43
+ render?: string | Record<string, any> | ((scope: PanelRenderScope<PO, SO>) => VNode[]);
35
44
  /** 是否可就地编辑 */
36
- editable?: boolean | ((scope: PanelScope<T>) => boolean);
37
- /** 编辑器渲染;仅 editable 时需要 */
38
- editorRender?: string | Record<string, any> | ((scope: PanelEditorScope<T>) => VNode);
45
+ editable?: boolean | ((scope: PanelScopeBase<PO, SO>) => boolean);
46
+ /** 编辑器渲染;仅 editable 时需要
47
+ * ----
48
+ * 使用优先级高于 editorConfig
49
+ */
50
+ editorRender?: string | Record<string, any> | ((scope: PanelRenderScope<PO, SO>) => VNode[]);
51
+ /** 编辑器表单配置;仅 editable 时需要
52
+ * ----
53
+ * 使用优先级次于 editorRender
54
+ * 但是优先级高于 render 即编辑态时使用render
55
+ */
56
+ editorConfig?: Omit<FormItemConfig<PO, SO>, "key" | "label" | "labelHide" | "layout">;
39
57
  /** 单字段提交;仅 editable 时需要。draft = 深克隆副本 */
40
- submitFn?: (draft: T) => Promise<unknown>;
58
+ submitFn?: FormSubmitPanelProps<PO, SO>["submitFn"];
41
59
  }
42
60
  /** Panel 配置项列表 */
43
- export type PanelItemConfigList<T extends Record<string, any> = Record<string, any>> = PanelItemConfig<T>[];
61
+ export type PanelItemConfigList<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> = PanelItemConfig<PO, SO>[];
44
62
  /** PanelMain props */
45
- export interface PanelMainProps<T extends Record<string, any> = Record<string, any>> {
46
- data: T;
63
+ export interface PanelMainProps<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> {
64
+ data: ExtractFormStringifyFromObject<PO, SO>;
65
+ /** 行水平间距 */
66
+ rowGutter?: number;
47
67
  layout?: Partial<ColProps>;
48
- list: PanelItemConfigList<T>;
68
+ list: PanelItemConfigList<PO, SO>;
69
+ /** item是否包括Card */
70
+ itemCard?: boolean | Partial<CardProps & {
71
+ /** 最后一个 margin bottom */
72
+ lastMarginBottom?: string;
73
+ }>;
74
+ refreshFn?: (stringifyData: any, parseData: any) => Promise<unknown> | void;
49
75
  }
50
76
  /** PanelItem props */
51
- export interface PanelItemProps<T extends Record<string, any> = Record<string, any>> {
52
- data: T;
53
- config: PanelItemConfig<T>;
54
- editing: boolean;
77
+ export interface PanelItemProps<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> {
78
+ data: ExtractFormStringifyFromObject<PO, SO>;
79
+ config: PanelItemConfig<PO, SO>;
80
+ refreshFn?: (info: FormDataInfo<PO, SO>) => Promise<unknown> | void;
55
81
  }
56
82
  /** PanelEditSwitch props */
57
- export interface PanelEditSwitchProps<T extends Record<string, any> = Record<string, any>> {
58
- data: T;
59
- editing: boolean;
60
- submitFn?: (draft: T) => Promise<unknown>;
83
+ export interface PanelEditSwitchProps<PO extends Record<string, any> = Record<string, any>, SO extends Record<string, any> = Record<string, any>> extends Partial<Pick<FormSubmitPanelProps<PO, SO>, "submitFn">> {
84
+ data: ExtractFormStringifyFromObject<PO, SO>;
85
+ /** panel 配置项 */
86
+ config: Omit<PanelItemConfig<PO, SO>, "editorConfig"> & {
87
+ /** 缺失的key label 由 PanelItem补齐 */
88
+ editorConfig?: FormItemConfig<PO, SO>;
89
+ };
90
+ /** 是否可编辑 */
91
+ editable?: boolean;
61
92
  }
@@ -1,28 +0,0 @@
1
- import { PanelEditSwitchProps } from './types';
2
- type __VLS_Props = PanelEditSwitchProps;
3
- declare function __VLS_template(): {
4
- attrs: Partial<{}>;
5
- slots: {
6
- default?(_: {}): any;
7
- editor?(_: {
8
- data: Record<string, any>;
9
- }): any;
10
- };
11
- refs: {};
12
- rootEl: HTMLDivElement;
13
- };
14
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
- declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
16
- "update:editing": (value: boolean) => any;
17
- submitFinish: (success: boolean, data: Record<string, any>) => any;
18
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
19
- "onUpdate:editing"?: ((value: boolean) => any) | undefined;
20
- onSubmitFinish?: ((success: boolean, data: Record<string, any>) => any) | undefined;
21
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
22
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
23
- export default _default;
24
- type __VLS_WithTemplateSlots<T, S> = T & {
25
- new (): {
26
- $slots: S;
27
- };
28
- };