@aspire-ui/element-component-pro 1.0.25 → 1.0.27

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 (37) hide show
  1. package/dist/ProTableForm/CellEditor.vue.d.ts +33 -0
  2. package/dist/ProTableForm/ProTableForm.vue.d.ts +122 -102
  3. package/dist/ProTableForm/index.d.ts +4 -2
  4. package/dist/ProTableForm/types.d.ts +1 -69
  5. package/dist/ProTableForm/useProTableForm.d.ts +55 -0
  6. package/dist/element-component-pro.es.js +1433 -1255
  7. package/dist/element-component-pro.es.js.map +1 -1
  8. package/dist/element-component-pro.umd.js +2 -2
  9. package/dist/element-component-pro.umd.js.map +1 -1
  10. package/dist/index.d.ts +445 -282
  11. package/dist/style.css +1 -1
  12. package/dist/types/index.d.ts +227 -0
  13. package/docs/CollapseContainer.md +100 -0
  14. package/docs/ComponentSetting.md +113 -0
  15. package/docs/ProDescriptions.md +215 -0
  16. package/docs/ProForm.md +879 -0
  17. package/docs/ProTable-Redesign.md +214 -0
  18. package/docs/ProTable.md +556 -0
  19. package/docs/ProTableForm.md +207 -0
  20. package/docs/image.png +0 -0
  21. package/package.json +3 -2
  22. package/src/CollapseContainer/CollapseContainer.vue +1 -1
  23. package/src/ProDescriptions/ProDescriptions.vue +1 -1
  24. package/src/ProForm/FormActions.vue +1 -1
  25. package/src/ProForm/ProForm.vue +1 -1
  26. package/src/ProForm/ProFormItem.vue +1 -1
  27. package/src/ProForm/TreeSelect.vue +1 -1
  28. package/src/ProTable/ProTable.vue +1 -2
  29. package/src/ProTable/TableAction.vue +1 -1
  30. package/src/ProTableForm/CellEditor.vue +192 -0
  31. package/src/ProTableForm/ProTableForm.vue +350 -453
  32. package/src/ProTableForm/TableFormCell.vue +46 -0
  33. package/src/ProTableForm/index.ts +6 -7
  34. package/src/ProTableForm/types.ts +12 -72
  35. package/src/ProTableForm/useProTableForm.ts +442 -0
  36. package/src/index.ts +6 -4
  37. package/src/types/index.ts +241 -0
@@ -285,3 +285,244 @@ export interface DescriptionActionType {
285
285
  setData: (data: Record<string, unknown>) => Promise<void>
286
286
  getData: () => Record<string, unknown>
287
287
  }
288
+
289
+ // ---------------------------------------------------------------------------
290
+ // ProTableForm
291
+ // ---------------------------------------------------------------------------
292
+
293
+ /** el-form 实例 */
294
+ export interface FormInstance {
295
+ validate?(cb?: (valid: boolean) => void): Promise<unknown> | void
296
+ clearValidate?(props?: string | string[]): void
297
+ resetFields?(): void
298
+ scrollToField?(name: string): void
299
+ }
300
+
301
+ /** 指标列单元格渲染方式 */
302
+ export type ProTableFormBuiltInComponent =
303
+ | 'input'
304
+ | 'input-number'
305
+ | 'formatted-number'
306
+ | 'select'
307
+ | 'api-select'
308
+ | 'tree-select'
309
+ | 'date-picker'
310
+ | 'date-range'
311
+ | 'switch'
312
+ | 'cascader'
313
+ | 'checkbox'
314
+ | 'radio'
315
+ | 'slot'
316
+
317
+ /** 自定义渲染函数,返回文本或 VNode;参数为 { row, value, column } */
318
+ export type ProTableFormColumnRender = (params: {
319
+ row: Record<string, unknown>
320
+ value: unknown
321
+ column: ProTableFormColumn | ProTableFormColumnChild
322
+ }) => string | VNode
323
+
324
+ /** 指标列(或含友商名称等任意 key) */
325
+ export interface ProTableFormColumn {
326
+ /** 对应 model 中对象字段名 */
327
+ key: string
328
+ title: string
329
+ required?: boolean
330
+ /** 单元格渲染方式:input / formatted-number / slot */
331
+ component?: ProTableFormBuiltInComponent
332
+ /** component 为 slot 时必填,对应插槽名为 `cell-{slotName}` */
333
+ slotName?: string
334
+ /**
335
+ * 自定义渲染,返回 string(文本)或 VNode(组件)。
336
+ * 若返回 string 且不为纯数字,单元格自动包裹 `el-form-item` 做校验;
337
+ * 若返回 VNode 则直接渲染,不包裹 form-item(适合纯展示列)。
338
+ */
339
+ render?: ProTableFormColumnRender
340
+ placeholder?: string
341
+ /** 列宽(优先级低于 minWidth) */
342
+ width?: number
343
+ /** 列最小宽度 */
344
+ minWidth?: number
345
+ /**
346
+ * 透传给单元格组件。`component === 'formatted-number'` 时在此传入
347
+ * `integerDigits`、`decimalPlaces`、`rounding`、`inputLimit` 等(与 FormattedNumberInput 一致)。
348
+ * 支持函数形式,参数为 { row, value, column },返回要合并到组件上的属性。
349
+ */
350
+ /**
351
+ * 透传给单元格组件。`component === 'formatted-number'` 时在此传入
352
+ * `integerDigits`、`decimalPlaces`、`rounding`、`inputLimit` 等。
353
+ * 支持函数形式,参数为 { row, value, column, action },返回要合并到组件上的属性。
354
+ */
355
+ componentProps?: Record<string, unknown> | ((params: CellComponentPropsParams) => Record<string, unknown>)
356
+ /** 动态校验规则 */
357
+ dynamicRules?: unknown[] | ((params: {
358
+ row: Record<string, unknown>
359
+ value: unknown
360
+ column: ProTableFormColumn
361
+ }) => unknown[])
362
+ /** 列级校验规则(会与 dynamicRules/required 合并) */
363
+ rules?: unknown[]
364
+ /**
365
+ * 多级表头子列。
366
+ * 配置后本列作为分组标题行,不渲染数据单元格,子列渲染数据。
367
+ */
368
+ children?: ProTableFormColumnChild[]
369
+ /**
370
+ * 本列是否渲染单元格(默认 true)。children 存在时自动为 false。
371
+ */
372
+ hideInTable?: boolean
373
+ /** 单元格对齐方式 */
374
+ align?: 'left' | 'center' | 'right'
375
+ /** 表头对齐方式 */
376
+ headerAlign?: 'left' | 'center' | 'right'
377
+ /** 是否固定列 */
378
+ fixed?: boolean | 'left' | 'right'
379
+ /** 单元格样式 */
380
+ cellStyle?: Record<string, string | number>
381
+ /** 表头单元格样式 */
382
+ headerCellStyle?: Record<string, string | number>
383
+ /** 单元格 className */
384
+ cellClassName?: string
385
+ /** 表头单元格 className */
386
+ headerCellClassName?: string
387
+ /** 是否可排序 */
388
+ sortable?: boolean
389
+ /** 是否可拖拽调整宽度 */
390
+ resizable?: boolean
391
+ }
392
+
393
+ /** 多级表头子列 */
394
+ export interface ProTableFormColumnChild {
395
+ key: string
396
+ title: string
397
+ required?: boolean
398
+ component?: ProTableFormBuiltInComponent
399
+ slotName?: string
400
+ /** 自定义渲染,返回 string(文本)或 VNode(组件) */
401
+ render?: ProTableFormColumnRender
402
+ placeholder?: string
403
+ /** 列宽(优先级低于 minWidth) */
404
+ width?: number
405
+ /** 列最小宽度 */
406
+ minWidth?: number
407
+ /**
408
+ * 透传给单元格组件。`component === 'formatted-number'` 时在此传入
409
+ * `integerDigits`、`decimalPlaces`、`rounding`、`inputLimit` 等。
410
+ * 支持函数形式,参数为 { row, value, column, action },返回要合并到组件上的属性。
411
+ */
412
+ componentProps?: Record<string, unknown> | ((params: CellComponentPropsParams) => Record<string, unknown>)
413
+ rules?: unknown[]
414
+ /** 动态校验规则 */
415
+ dynamicRules?: unknown[] | ((params: {
416
+ row: Record<string, unknown>
417
+ value: unknown
418
+ column: ProTableFormColumnChild
419
+ }) => unknown[])
420
+ hideInTable?: boolean
421
+ /** 单元格对齐方式 */
422
+ align?: 'left' | 'center' | 'right'
423
+ /** 表头对齐方式 */
424
+ headerAlign?: 'left' | 'center' | 'right'
425
+ /** 是否固定列 */
426
+ fixed?: boolean | 'left' | 'right'
427
+ /** 单元格样式 */
428
+ cellStyle?: Record<string, string | number>
429
+ /** 表头单元格样式 */
430
+ headerCellStyle?: Record<string, string | number>
431
+ /** 单元格 className */
432
+ cellClassName?: string
433
+ /** 表头单元格 className */
434
+ headerCellClassName?: string
435
+ /** 是否可排序 */
436
+ sortable?: boolean
437
+ /** 是否可拖拽调整宽度 */
438
+ resizable?: boolean
439
+ }
440
+
441
+ /** ProTableForm Props */
442
+ export interface ProTableFormProps {
443
+ modelValue?: Record<string, unknown>[]
444
+ columns: ProTableFormColumn[]
445
+ metricPlaceholder?: string
446
+ minRows?: number
447
+ rules?: Record<string, unknown>
448
+ labelWidth?: string
449
+ bordered?: boolean
450
+ /**
451
+ * 表格合并单元格函数,参数同 Element UI el-table span-method。
452
+ * column.property 格式:叶子列 `{colKey}` 或 `{colKey}.{childKey}`;分组列 `{colKey}`。
453
+ */
454
+ spanMethod?: (params: {
455
+ row: Record<string, unknown>
456
+ column: { property: string; label: string }
457
+ rowIndex: number
458
+ columnIndex: number
459
+ }) => [number, number] | { rowspan: number; colspan: number } | void
460
+ // ─── el-form 原生配置 ───────────────────────────────────────────────────────
461
+ /** 表单尺寸 */
462
+ formSize?: 'medium' | 'small' | 'large'
463
+ /** 标签位置 */
464
+ labelPosition?: 'left' | 'right' | 'top'
465
+ /** 表单禁用态 */
466
+ disabled?: boolean
467
+ // ─── el-table 原生配置 ───────────────────────────────────────────────────────
468
+ /** 斑马纹 */
469
+ stripe?: boolean
470
+ /** 表格尺寸 */
471
+ size?: 'medium' | 'small' | 'large'
472
+ /** 表格最大高度 */
473
+ maxHeight?: number | string
474
+ /** 表格固定高度 */
475
+ height?: number | string
476
+ /** 行 ClassName */
477
+ rowClassName?: string | ((params: { row: Record<string, unknown>; rowIndex: number }) => string)
478
+ /** 展开行 Keys(树形数据) */
479
+ expandRowKeys?: (string | number)[]
480
+ /** 默认展开所有行 */
481
+ defaultExpandAll?: boolean
482
+ /** 行点击事件 */
483
+ onRowClick?: (row: Record<string, unknown>, event: Event) => void
484
+ /** 行双击事件 */
485
+ onRowDblclick?: (row: Record<string, unknown>, event: Event) => void
486
+ /** 排序变化事件 */
487
+ onSortChange?: (sortInfo: { prop: string; order: string }) => void
488
+ /** 展开变化事件 */
489
+ onExpandChange?: (row: Record<string, unknown>, expanded: boolean) => void
490
+ /** 透传给 el-table 的额外属性(所有上面未覆盖的 el-table 属性均可通过此传入) */
491
+ tableProps?: Record<string, unknown>
492
+ /** 透传给 el-form 的额外属性 */
493
+ formProps?: Record<string, unknown>
494
+ }
495
+
496
+ /** ProTableForm 操作实例类型 */
497
+ export interface ProTableFormActionType {
498
+ /** 表单校验 */
499
+ validate: () => Promise<boolean>
500
+ /** 清除校验 */
501
+ clearValidate: (props?: string | string[]) => void
502
+ /** 新增行 */
503
+ addRow: () => void
504
+ /** 删除行 */
505
+ removeRow: (index: number) => void
506
+ /** 获取行列表 */
507
+ getRows: () => Record<string, unknown>[]
508
+ /** 获取 el-table 实例 */
509
+ getTable: () => { clearSelection: () => void } | null
510
+ /** 获取当前行数 */
511
+ getRowCount: () => number
512
+ /** 获取整个 modelValue */
513
+ getModelValue: () => Record<string, unknown>[]
514
+ /** 设置整个 modelValue(触发 update:modelValue) */
515
+ setModelValue: (val: Record<string, unknown>[]) => void
516
+ /** 获取 el-form 实例(可用于滚动、聚焦等高级操作) */
517
+ getFormRef: () => FormInstance | null
518
+ }
519
+
520
+ /** componentProps 函数的参数类型 */
521
+ export interface CellComponentPropsParams {
522
+ row: Record<string, unknown>
523
+ value: unknown
524
+ column: ProTableFormColumn | ProTableFormColumnChild
525
+ /** ProTableForm 操作实例,可调用 validate、addRow、removeRow 等 */
526
+ action: ProTableFormActionType
527
+ }
528
+