dydx-naive-ui-for-vue 0.1.18 → 0.1.19

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.
@@ -11,7 +11,7 @@ declare const _default: <T extends Record<string, any>>(__VLS_props: NonNullable
11
11
  slots: Partial<Record<string, (_: {
12
12
  model: T;
13
13
  schema: import('..').SlotSchema<T>;
14
- }) => any>> & Partial<Record<`field-${import('..').DeepKeys<T>}`, (_: {
14
+ }) => any>> & Partial<Record<`field-${import('../../..').DeepKeys<T>}`, (_: {
15
15
  model: T;
16
16
  schema: import('..').InputSchema<T> | import('..').SelectSchema<T> | import('..').RadioGroupSchema<T> | import('..').CheckboxGroupSchema<T> | import('..').DatePickerSchema<T> | import('..').InputNumberSchema<T> | import('..').NativeSchema<T> | import('..').CustomSchema<T>;
17
17
  value: any;
@@ -2,10 +2,8 @@ import { Component, VNode } from 'vue';
2
2
  import { FormItemRule, FormItemGiProps } from 'naive-ui';
3
3
  import { DydxUploadProps } from '../../NaiveUpload';
4
4
  import { DydxIconSelectProps } from '../../IconSelect';
5
+ import { DeepKeys } from '../../../types/utils';
5
6
  import type * as NaiveUI from 'naive-ui';
6
- export type DeepKeys<T> = T extends object ? {
7
- [K in keyof T]-?: K extends string | number ? T[K] extends object ? `${K}` | `${K}.${DeepKeys<T[K]>}` : `${K}` : never;
8
- }[keyof T] : never;
9
7
  export type NativeFieldType = 'input' | 'input-number' | 'select' | 'date-picker' | 'time-picker' | 'switch' | 'slider' | 'radio-group' | 'checkbox-group' | 'cascader' | 'tree-select' | 'upload' | 'rate' | 'color-picker' | 'auto-complete' | 'dynamic-input' | 'dynamic-tags' | 'mention' | 'image-upload' | 'file-upload' | 'icon-select';
10
8
  export interface ComponentPropsMap {
11
9
  'input': NaiveUI.InputProps;
@@ -1,6 +1,6 @@
1
1
  import { DataTableColumn, DataTableBaseColumn, DataTableSelectionColumn, DataTableExpandColumn, TagProps } from 'naive-ui';
2
2
  import { VNodeChild } from 'vue';
3
- import { DeepKeys } from '../../NaiveForm';
3
+ import { DeepKeys, StringKeys } from '../../../types/utils';
4
4
  /**
5
5
  * 列类型
6
6
  * - text: 文本(默认)
@@ -126,9 +126,14 @@ export interface ActionColumnConfig<T = any> {
126
126
  }
127
127
  /**
128
128
  * 扩展列配置 - 完全兼容 Naive UI DataTableBaseColumn
129
+ * @template T 数据类型,建议传入具体的接口类型以获得更好的类型提示
129
130
  */
130
- export interface DydxTableColumn<T = any> extends Omit<DataTableBaseColumn<T>, 'key'> {
131
- key: DeepKeys<T>;
131
+ export interface DydxTableColumn<T = Record<string, any>> extends Omit<DataTableBaseColumn<T>, 'key'> {
132
+ /**
133
+ * 列键名,支持嵌套路径(如 'user.profile.name')
134
+ * 当传入具体的 T 类型时,会提供完整的键名提示
135
+ */
136
+ key: T extends Record<string, any> ? DeepKeys<T> : StringKeys<T> | string;
132
137
  /** 是否默认显示(用于列设置功能) */
133
138
  defaultVisible?: boolean;
134
139
  /** 是否可在列设置中控制显示/隐藏 */
@@ -6,6 +6,7 @@ export { DydxUpload } from './components/NaiveUpload';
6
6
  export { DydxIconSelect } from './components/IconSelect';
7
7
  export * from './resolver';
8
8
  export { useColumns, usePagination, useTableActions, useColumnRender, } from './components/NaiveTable';
9
+ export type { DeepKeys, StringKeys, } from './types/utils';
9
10
  export type { FormSchema, DydxNaiveFormExpose, NativeFieldType, } from './components/NaiveForm';
10
11
  export type { DydxTableColumns, DydxTableColumn, ActionColumnConfig, ActionButton, ToolbarButton, TablePagination, PageChangeData, ActionEventParams, DydxNaiveTableProps, DydxNaiveTableExpose, PaginationFieldNames, } from './components/NaiveTable';
11
12
  export type { FormModalProps, FormDrawerProps, FormModalExpose, } from './components/FormModal';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 深度路径类型 - 提取对象的所有嵌套键路径
3
+ * @example
4
+ * type User = { name: string; profile: { age: number; address: { city: string } } }
5
+ * type UserKeys = DeepKeys<User> // 'name' | 'profile' | 'profile.age' | 'profile.address' | 'profile.address.city'
6
+ */
7
+ export type DeepKeys<T> = T extends object ? {
8
+ [K in keyof T]-?: K extends string | number ? T[K] extends object ? `${K}` | `${K}.${DeepKeys<T[K]>}` : `${K}` : never;
9
+ }[keyof T] : never;
10
+ /**
11
+ * 字符串键类型 - 确保键为字符串类型
12
+ */
13
+ export type StringKeys<T> = Extract<keyof T, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dydx-naive-ui-for-vue",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "web-types": "./web-types.json",
5
5
  "type": "module",
6
6
  "main": "./dist/dydx-naive-ui-for-vue.umd.cjs",