{"version":3,"file":"table.mjs","sources":["../../../../../../../packages/components/table/src/table.ts"],"sourcesContent":["import { buildProps, definePropType, isArray } from '@m-eleplus-crud/utils'\r\nimport { useSizeProp } from '@m-eleplus-crud/hooks'\r\n\r\nimport { ColumnType, ICommonColumn } from '../../common'\r\n\r\nimport type { ExtractPropTypes, VNode } from 'vue'\r\n\r\n/**\r\n * @description 公开的table column配置\r\n */\r\nexport interface ITableCommonColumn {\r\n  /**\r\n   * @description 对齐方式\r\n   */\r\n  align?: 'left' | 'center' | 'right'\r\n  /**\r\n   * @description 超出隐藏\r\n   */\r\n  overHidden?: boolean\r\n  /**\r\n   * @description 帮助信息文本\r\n   */\r\n  help?: string\r\n  /**\r\n   * @description 格式化内容\r\n   * @param row 行数据\r\n   * @param column 列信息\r\n   * @param index 行索引\r\n   * @returns\r\n   */\r\n  formatter?: (row: any, column: ITableColumn, index: number) => VNode | string\r\n  /**\r\n   * @description 列宽度\r\n   */\r\n  width?: number\r\n  /**\r\n   * @description 二维码宽度，默认70\r\n   */\r\n  qrcodeWidth?: number\r\n  /**\r\n   * @description 二维码高度，默认70\r\n   */\r\n  qrcodeHeight?: number\r\n  /**\r\n   * 一维码宽度，默认2\r\n   */\r\n  barcodeWith?: number\r\n  /**\r\n   * 一维码高度，默认50\r\n   */\r\n  barcodeHeight?: number\r\n}\r\n\r\nexport interface ITableColumn extends ICommonColumn, ITableCommonColumn {\r\n  /**\r\n   * @description 类型\r\n   */\r\n  type?: ColumnType | 'index' | 'single' | 'selection',\r\n  /**\r\n   * @description 仅对 type=selection 的列有效，类型为 Function，Function 的返回值用来决定这一行的 CheckBox 是否可以勾选\r\n   * @param row 行数据\r\n   * @param index 索引\r\n   * @returns \r\n   */\r\n  selectable?: (row: any, index: number) => boolean\r\n  /**\r\n   * @description 对应列是否可以排序， 如果设置为 'custom'，则代表用户希望远程排序，需要监听 Table 的 sort-change 事件\r\n   */\r\n  sortable?: boolean | string\r\n}\r\n\r\n/**\r\n * @description 公开的table配置\r\n */\r\nexport interface ITableCommonOption {\r\n  /**\r\n   * @description 是否显示操作栏\r\n   */\r\n  menu?: boolean\r\n  /**\r\n   * @description 是否为斑马纹\r\n   */\r\n  stripe?: boolean\r\n  /**\r\n   * @description 是否带有纵向边框\r\n   */\r\n  border?: boolean\r\n  /**\r\n   * @description 操作栏宽度\r\n   */\r\n  menuWidth?: number\r\n  /**\r\n   * @description 操作栏列冻结列 ，true 表示固定在左侧\r\n   */\r\n  menuFixed?: true | 'left' | 'right'\r\n  /**\r\n   * @description 操作栏按钮的对齐方式\r\n   */\r\n  menuAlign?: 'left' | 'center' | 'right'\r\n  /**\r\n   * @description 操作栏标题名称\r\n   */\r\n  menuTitle?: string\r\n  /**\r\n   * @description 表格rowKey\r\n   */\r\n  rowKey?: string\r\n}\r\n\r\nexport interface ITableOption extends ITableCommonOption {\r\n  /**\r\n   * @description 列配置\r\n   */\r\n  column: ITableColumn[]\r\n}\r\n\r\nexport const tableProps = buildProps({\r\n  /**\r\n   * @description 表格尺寸\r\n   */\r\n  size: useSizeProp,\r\n  /**\r\n   * @description 表格加载状态\r\n   */\r\n  loading: {\r\n    type: Boolean,\r\n    default: false,\r\n  },\r\n  /**\r\n   * @description 表格数据\r\n   */\r\n  data: {\r\n    required: true,\r\n    type: Array,\r\n  },\r\n  /**\r\n   * @description 选择数据\r\n   */\r\n  select: {\r\n    required: false,\r\n    type: Array,\r\n  },\r\n  /**\r\n   * @description 配置信息\r\n   */\r\n  option: {\r\n    type: definePropType<ITableOption>(Object),\r\n    required: false,\r\n  },\r\n  /**\r\n   * @description 权限配置\r\n   */\r\n  permission: {\r\n    type: Object,\r\n    default: {},\r\n  },\r\n  /**\r\n   * @description 表格高度\r\n   */\r\n  height: {\r\n    type: Number,\r\n    required: false,\r\n  },\r\n  /**\r\n   * @description 表格最大高度\r\n   */\r\n  maxHeight: {\r\n    type: Number,\r\n    required: false,\r\n  },\r\n} as const)\r\n\r\nexport type TableProps = ExtractPropTypes<typeof tableProps>\r\n\r\nexport const tableEmits = {\r\n  'update:select': (arr: any[]) => isArray(arr),\r\n  /**\r\n   * 表格自定义排序模式下排序变化触发\r\n   * @param data \r\n   * @returns \r\n   */\r\n  sortChange: (data: {column: any, prop: string, order: any }) => true,\r\n  /**\r\n   * 表格选择数据触发\r\n   * @param arr 选择的数据\r\n   * @returns\r\n   */\r\n  selectionChange: (arr: any[]) => isArray(arr),\r\n}\r\nexport type TableEmits = typeof tableEmits\r\n"],"names":[],"mappings":";;;;AAoHO,MAAM,aAAa,UAAW,CAAA;AAAA,EAInC,IAAM,EAAA,WAAA;AAAA,EAIN,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,QAAU,EAAA,IAAA;AAAA,IACV,IAAM,EAAA,KAAA;AAAA,GACR;AAAA,EAIA,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA,KAAA;AAAA,IACV,IAAM,EAAA,KAAA;AAAA,GACR;AAAA,EAIA,MAAQ,EAAA;AAAA,IACN,IAAA,EAAM,eAA6B,MAAM,CAAA;AAAA,IACzC,QAAU,EAAA,KAAA;AAAA,GACZ;AAAA,EAIA,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,MAAA;AAAA,IACN,SAAS,EAAC;AAAA,GACZ;AAAA,EAIA,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,KAAA;AAAA,GACZ;AAAA,EAIA,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,KAAA;AAAA,GACZ;AACF,CAAU,EAAA;AAIH,MAAM,UAAa,GAAA;AAAA,EACxB,eAAiB,EAAA,CAAC,GAAe,KAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,EAM5C,UAAA,EAAY,CAAC,IAAmD,KAAA,IAAA;AAAA,EAMhE,eAAiB,EAAA,CAAC,GAAe,KAAA,OAAA,CAAQ,GAAG,CAAA;AAC9C;;;;"}