@qin-ui/element-plus-pro 1.3.5 → 1.4.1

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 (93) hide show
  1. package/AI-CONTEXT.md +27 -3
  2. package/README.md +42 -31
  3. package/api.json +69 -38
  4. package/es/components/component-provider/components/index.vue.d.ts +10 -3
  5. package/es/components/component-provider/components/index.vue.d.ts.map +1 -1
  6. package/es/components/component-provider/constants/index.d.ts +22 -4
  7. package/es/components/component-provider/constants/index.d.ts.map +1 -1
  8. package/es/components/component-provider/types/index.d.ts +15 -1
  9. package/es/components/component-provider/types/index.d.ts.map +1 -1
  10. package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
  11. package/es/components/form/components/BaseField/utils/index.d.ts +15 -0
  12. package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -1
  13. package/es/components/form/components/BaseFormItem/index.vue.d.ts +3 -1
  14. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
  15. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -1
  16. package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
  17. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -1
  18. package/es/components/form/components/index.d.ts +4 -0
  19. package/es/components/form/components/index.d.ts.map +1 -1
  20. package/es/components/form/constants/index.d.ts +8 -2
  21. package/es/components/form/constants/index.d.ts.map +1 -1
  22. package/es/components/form/hooks/useFields.d.ts.map +1 -1
  23. package/es/components/form/hooks/useForm.d.ts.map +1 -1
  24. package/es/components/form/hooks/useGroupFieldAttrs.d.ts +9 -0
  25. package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
  26. package/es/components/form/index.d.ts +2 -2
  27. package/es/components/form/index.d.ts.map +1 -1
  28. package/es/components/form/types/index.d.ts +65 -50
  29. package/es/components/form/types/index.d.ts.map +1 -1
  30. package/es/components/form/utils/fieldKey.d.ts +13 -0
  31. package/es/components/form/utils/fieldKey.d.ts.map +1 -0
  32. package/es/components/table/components/ColumnControl.vue.d.ts +1 -1
  33. package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
  34. package/es/components/table/components/ProTable.vue.d.ts +15 -1
  35. package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
  36. package/es/components/table/components/SearchForm.vue.d.ts +13 -1
  37. package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
  38. package/es/components/table/components/SizeControl.vue.d.ts +7 -2
  39. package/es/components/table/components/SizeControl.vue.d.ts.map +1 -1
  40. package/es/components/table/components/TableColumnRenderer.vue.d.ts +14 -14
  41. package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -1
  42. package/es/components/table/hooks/index.d.ts +2 -0
  43. package/es/components/table/hooks/index.d.ts.map +1 -0
  44. package/es/components/table/{useTable.d.ts → hooks/useTable.d.ts} +3 -3
  45. package/es/components/table/hooks/useTable.d.ts.map +1 -0
  46. package/es/components/table/index.d.ts +6 -2
  47. package/es/components/table/index.d.ts.map +1 -1
  48. package/es/components/table/types/index.d.ts +16 -12
  49. package/es/components/table/types/index.d.ts.map +1 -1
  50. package/es/element-plus-pro.css +14 -14
  51. package/es/index.d.ts +9 -6
  52. package/es/index.d.ts.map +1 -1
  53. package/es/index.js +307 -227
  54. package/es/index.js.map +1 -1
  55. package/es/locale/index.d.ts +2 -1
  56. package/es/locale/index.d.ts.map +1 -1
  57. package/es/shared/core/index.d.ts +1 -1
  58. package/es/shared/core/index.d.ts.map +1 -1
  59. package/es/shared/ui/index.d.ts +20 -2
  60. package/es/shared/ui/index.d.ts.map +1 -1
  61. package/package.json +5 -4
  62. package/src/components/component-provider/components/index.vue +48 -21
  63. package/src/components/component-provider/constants/index.ts +34 -6
  64. package/src/components/component-provider/types/index.ts +21 -7
  65. package/src/components/form/components/BaseField/index.vue +25 -12
  66. package/src/components/form/components/BaseField/utils/index.ts +16 -1
  67. package/src/components/form/components/BaseFormItem/index.vue +25 -32
  68. package/src/components/form/components/ContainerFragment/index.vue +3 -1
  69. package/src/components/form/components/ProForm/index.vue +41 -21
  70. package/src/components/form/components/SlotComponent/index.vue +4 -2
  71. package/src/components/form/components/index.ts +8 -1
  72. package/src/components/form/constants/index.ts +9 -2
  73. package/src/components/form/hooks/useFields.ts +5 -2
  74. package/src/components/form/hooks/useForm.ts +8 -1
  75. package/src/components/form/hooks/useGroupFieldAttrs.ts +24 -17
  76. package/src/components/form/index.ts +1 -3
  77. package/src/components/form/types/index.ts +71 -52
  78. package/src/components/form/utils/fieldKey.ts +27 -0
  79. package/src/components/table/components/ColumnControl.vue +16 -6
  80. package/src/components/table/components/ProTable.vue +183 -93
  81. package/src/components/table/components/SearchForm.vue +60 -22
  82. package/src/components/table/components/SizeControl.vue +23 -1
  83. package/src/components/table/components/TableColumnRenderer.vue +82 -63
  84. package/src/components/table/hooks/index.ts +1 -0
  85. package/src/components/table/{useTable.ts → hooks/useTable.ts} +6 -4
  86. package/src/components/table/index.ts +11 -2
  87. package/src/components/table/types/index.ts +17 -13
  88. package/src/index.ts +13 -7
  89. package/src/locale/index.ts +4 -2
  90. package/src/shared/core/index.ts +11 -0
  91. package/src/shared/ui/index.ts +29 -5
  92. package/tsconfig.json +0 -1
  93. package/es/components/table/useTable.d.ts.map +0 -1
@@ -4,7 +4,8 @@ import { default as zhCN } from './zh-CN';
4
4
  import { default as zhTW } from './zh-TW';
5
5
  import { default as enUS } from './en-US';
6
6
  export { zhCN, zhTW, enUS };
7
- export type ProLocale = typeof zhCN;
7
+ /** 内置文案类型:键集合与 zh-CN 对齐,取值允许任意文案覆盖 */
8
+ export type ProLocale = Record<keyof typeof zhCN, string>;
8
9
  /** ProComponentProvider 通过该 key 注入局部覆盖文案 */
9
10
  export declare const LOCALE_INJECT_KEY: InjectionKey<MaybeRef<Partial<ProLocale> | undefined>>;
10
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAC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,CAAC,CAClB,CAAC;AAEzB;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS;aAcJ,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,MAAM;;CAQ1E,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * 统一 re-export @qin-ui/pro-components-core,包内所有文件通过此文件引入 core 内容。
3
3
  */
4
- export { useForm, createFormProxy, useTable, useSearchFormExpand, useFields, useFormData, useFormRef, InjectionFormKey, InjectionFormSlotsKey, getObject, get, set, normalizePathKey, toPath, camelizeProperties, cloneDeep, pick, isPlainObject, isPromise, zhCN, zhTW, enUS, format, resolveLocaleName, type ProLocale, type ProLocaleName, type ProLocaleKey, type Data, type Path, type Paths, type KeyExpandString, type ExtendWithAny, type DeepPartial, type PageParam, type Fields, type Form, type Table, type UseFieldsReturn, type UseFormDataReturn, type UseFormRefReturn, } from '@qin-ui/pro-components-core';
4
+ export { type AdditionalMethods, localePacks, normalizeColumn, normalizeColumns, useForm, createFormProxy, useTable, useSearchFormExpand, useFields, resolveFieldIdentity, DEFAULT_FIELD_IDENTITY_KEYS, useFormData, useFormRef, useReactiveAttrs, InjectionFormKey, InjectionFormSlotsKey, getObject, omitBy, get, set, normalizePathKey, toPath, camelizeProperties, cloneDeep, pick, omit, isPlainObject, isObjectItem, isPromise, zhCN, zhTW, enUS, format, resolveLocaleName, type ProLocale, type ProLocaleName, type ProLocaleKey, type Data, type Path, type Paths, type KeyExpandString, type ExtendWithAny, type DeepPartial, type PageParam, type Fields, type Form, type Table, type UseFieldsReturn, type UseFormDataReturn, type UseFormRefReturn, } from '@qin-ui/pro-components-core';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,UAAU,EAEV,gBAAgB,EAChB,qBAAqB,EAErB,SAAS,EACT,GAAG,EACH,GAAG,EACH,gBAAgB,EAChB,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,aAAa,EACb,SAAS,EAET,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAEjB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,KAAK,iBAAiB,EACtB,WAAW,EACX,eAAe,EACf,gBAAgB,EAEhB,OAAO,EACP,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,2BAA2B,EAC3B,WAAW,EACX,UAAU,EACV,gBAAgB,EAEhB,gBAAgB,EAChB,qBAAqB,EAErB,SAAS,EACT,MAAM,EACN,GAAG,EACH,GAAG,EACH,gBAAgB,EAChB,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,SAAS,EAET,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAEjB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,6BAA6B,CAAC"}
@@ -1,14 +1,32 @@
1
- import { ElForm as Form, ElFormItem as FormItem, ElRow as Grid, ElCol as GridItem, ElTable as Table, ElTableColumn as TableColumn, ElSpace as Space, ElDropdown as Dropdown, ElDropdownMenu as DropdownMenu, ElDropdownItem as DropdownItem, ElCheckbox as Checkbox, ElCheckboxGroup as CheckboxGroup, ElButton as Button, ElAutocomplete as AutoComplete, ElCascader as Cascader, ElDatePicker as DatePicker, ElInput as Input, ElInputNumber as InputNumber, ElSelect as Select, ElSlider as Slider, ElSwitch as Switch, ElTransfer as Transfer, ElTreeSelect as TreeSelect, ElRadioGroup as RadioGroup, ElTimePicker as TimePicker, ElTimeSelect as TimeSelect, ElPagination as Pagination, FormItemInstance, FormInstance, FormProps, FormItemProps, TableProps as _TableProps, TableEmits, TableColumnCtx as ColumnType, PaginationProps, RowProps as GridProps, ColProps as GridItemProps } from 'element-plus';
1
+ import { ElForm as Form, ElFormItem as FormItem, ElRow as Grid, ElCol as GridItem, ElTable as Table, ElTableColumn as TableColumn, ElSpace as Space, ElDropdown as Dropdown, ElDropdownMenu as DropdownMenu, ElDropdownItem as DropdownItem, ElCheckbox as Checkbox, ElCheckboxGroup as CheckboxGroup, ElButton as Button, ElAutocomplete as AutoComplete, ElCascader as Cascader, ElDatePicker as DatePicker, ElInput as Input, ElInputNumber as InputNumber, ElSelect as Select, ElSlider as Slider, ElSwitch as Switch, ElTransfer as Transfer, ElTreeSelect as TreeSelect, ElRadioGroup as RadioGroup, ElTimePicker as TimePicker, ElTimeSelect as TimeSelect, ElPagination as Pagination, useSize, FormItemInstance, FormInstance, FormProps, FormItemProps, TableProps as _TableProps, TableEmits, TableColumnCtx as ColumnType, PaginationProps, RowProps as GridProps, ColProps as GridItemProps } from 'element-plus';
2
2
  import { MaybeRefOrGetter } from 'vue';
3
- export { Form, FormItem, Grid, GridItem, Table, TableColumn, Space, Dropdown, DropdownMenu, DropdownItem, Checkbox, CheckboxGroup, Button, AutoComplete, Cascader, DatePicker, Input, InputNumber, Select, Slider, Switch, Transfer, TreeSelect, RadioGroup, TimePicker, TimeSelect, Pagination, type FormItemInstance, type FormInstance, type FormProps, type FormItemProps, type PaginationProps, type GridProps, type GridItemProps, type ColumnType, type TableEmits, };
3
+ export { Form, FormItem, Grid, GridItem, Table, TableColumn, Space, Dropdown, DropdownMenu, DropdownItem, Checkbox, CheckboxGroup, Button, AutoComplete, Cascader, DatePicker, Input, InputNumber, Select, Slider, Switch, Transfer, TreeSelect, RadioGroup, TimePicker, TimeSelect, Pagination, useSize, type FormItemInstance, type FormInstance, type FormProps, type FormItemProps, type PaginationProps, type GridProps, type GridItemProps, type ColumnType, type TableEmits, };
4
+ /** 宿主 Table 属性面(放宽泛型以兼容任意行数据) */
4
5
  export type TableProps = _TableProps<any>;
6
+ /** 宿主 Table 的静态 props 快照(透传键名白名单用) */
5
7
  export declare const tableProps: () => any;
8
+ /** 宿主 Pagination 的静态 props 快照(分页配置键名白名单用) */
6
9
  export declare const paginationProps: () => any;
10
+ /** 宿主 Row/Col 的静态 props 快照 */
7
11
  export declare const gridItemProps: () => any;
12
+ /** 宿主 FormItem 的静态 props 快照 */
8
13
  export declare const formItemProps: () => any;
14
+ /** 禁用上下文取值
15
+ *
16
+ * @description 字段级禁用优先,未声明时回退宿主 `el-form` 的禁用状态
17
+ * @returns {ComputedRef<boolean>} 当前生效的禁用状态
18
+ */
9
19
  export declare const useDisabledContext: () => import('vue').ComputedRef<boolean>;
20
+ /** 禁用上下文提供者
21
+ *
22
+ * @description 与父级禁用上下文合并:未声明时保持继承,声明时(含 false)覆盖
23
+ * @param {MaybeRefOrGetter<boolean | undefined>} disabled - 本层声明的禁用状态
24
+ */
10
25
  export declare const useDisabledContextProvider: (disabled: MaybeRefOrGetter<boolean | undefined>) => void;
26
+ /** {@link useDisabledContext} 的别名 */
11
27
  export declare const useInjectDisabled: () => import('vue').ComputedRef<boolean>;
28
+ /** {@link useDisabledContextProvider} 的别名 */
12
29
  export declare const useProviderDisabled: (disabled: MaybeRefOrGetter<boolean | undefined>) => void;
30
+ /** 字段路径:字符串、数字或分段数组 */
13
31
  export type NamePath = string | number | (string | number)[];
14
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,IAAI,IAAI,EACd,UAAU,IAAI,QAAQ,EACtB,KAAK,IAAI,IAAI,EACb,KAAK,IAAI,QAAQ,EACjB,OAAO,IAAI,KAAK,EAChB,aAAa,IAAI,WAAW,EAC5B,OAAO,IAAI,KAAK,EAChB,UAAU,IAAI,QAAQ,EACtB,cAAc,IAAI,YAAY,EAC9B,cAAc,IAAI,YAAY,EAC9B,UAAU,IAAI,QAAQ,EACtB,eAAe,IAAI,aAAa,EAChC,QAAQ,IAAI,MAAM,EAClB,cAAc,IAAI,YAAY,EAC9B,UAAU,IAAI,QAAQ,EACtB,YAAY,IAAI,UAAU,EAC1B,OAAO,IAAI,KAAK,EAChB,aAAa,IAAI,WAAW,EAC5B,QAAQ,IAAI,MAAM,EAClB,QAAQ,IAAI,MAAM,EAClB,QAAQ,IAAI,MAAM,EAClB,UAAU,IAAI,QAAQ,EACtB,YAAY,IAAI,UAAU,EAC1B,YAAY,IAAI,UAAU,EAC1B,YAAY,IAAI,UAAU,EAC1B,YAAY,IAAI,UAAU,EAC1B,YAAY,IAAI,UAAU,EAE1B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,UAAU,EACf,KAAK,cAAc,IAAI,UAAU,EACjC,KAAK,eAAe,EACpB,KAAK,QAAQ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R,UAAU,EACV,KAAK,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;AAO1C,sCAAsC;AACtC,eAAO,MAAM,UAAU,WAAoB,CAAC;AAC5C,6CAA6C;AAC7C,eAAO,MAAM,eAAe,WAAyB,CAAC;AACtD,8BAA8B;AAC9B,eAAO,MAAM,aAAa,WAAuB,CAAC;AAClD,+BAA+B;AAC/B,eAAO,MAAM,aAAa,WAAuB,CAAC;AAIlD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,0CAW9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAU,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,SAQhD,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,iBAAiB,0CAAqB,CAAC;AACpD,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,aAbpB,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,SAaY,CAAC;AAE9D,uBAAuB;AACvB,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/element-plus-pro",
3
- "version": "1.3.5",
3
+ "version": "1.4.1",
4
4
  "description": "基于 element-plus 的二次封装组件",
5
5
  "bin": {
6
6
  "element-plus-pro": "./bin/init-ai.mjs"
@@ -14,7 +14,7 @@
14
14
  "types": "./es/index.d.ts",
15
15
  "import": "./es/index.js"
16
16
  },
17
- "./element-plus-pro.css": "./es/element-plus-pro.css"
17
+ "./package.json": "./package.json"
18
18
  },
19
19
  "files": [
20
20
  "es",
@@ -35,14 +35,15 @@
35
35
  "license": "MIT",
36
36
  "private": false,
37
37
  "peerDependencies": {
38
- "element-plus": "^2.13.6",
38
+ "element-plus": "^2.14.5",
39
39
  "vue": "^3.5.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "vue-component-type-helpers": "^3.2.5",
43
- "@qin-ui/pro-components-core": "^2.0.4"
43
+ "@qin-ui/pro-components-core": "^2.1.0"
44
44
  },
45
45
  "devDependencies": {
46
+ "@types/node": "^24",
46
47
  "@vue/test-utils": "^2.4.11",
47
48
  "element-plus": "^2.14.5",
48
49
  "happy-dom": "^20.11.6",
@@ -1,36 +1,44 @@
1
1
  <script lang="ts" setup>
2
2
  /**
3
+ * 全局配置提供者组件
4
+ *
3
5
  * @component ProComponentProvider
4
- * @description @qin-ui/element-plus-pro 全局配置提供者组件
6
+ * @public
5
7
  *
6
8
  * 用于在组件树的顶层配置所有子组件的全局默认属性。
9
+ * 支持配置 ProForm、ProTable、ProFormItem 以及所有内置组件的默认属性。
7
10
  *
8
11
  * @param {ComponentVars} [componentVars] - 组件全局配置变量
9
- * @param {Record<ComponentName, any>} [componentMap] - 自定义组件映射
12
+ * @param {Record<ComponentName, any>} [componentMap] - 自定义组件映射,用于替换或扩展内置组件
10
13
  * @param {Partial<ProLocale>} [locale] - 内置文案覆盖,可覆盖任意 locale 文案(如查询/重置/序号/占位符等)
11
14
  *
12
- * @slot default - 子组件内容
15
+ * @slot default - 需要应用全局配置的子组件内容
13
16
  *
14
17
  * @example
15
18
  * ```vue
16
- * <ProComponentProvider
17
- * :componentVars="{ 'input': { placeholder: '请输入' } }"
18
- * >
19
- * <ProForm :form="form" />
20
- * </ProComponentProvider>
19
+ * <template>
20
+ * <ProComponentProvider
21
+ * :componentVars="{
22
+ * 'pro-form': { grid: { gutter: 24 } },
23
+ * 'input': { placeholder: '请输入', maxlength: 200 },
24
+ * 'select': { placeholder: '请选择' },
25
+ * }"
26
+ * >
27
+ * <ProForm :form="form" />
28
+ * </ProComponentProvider>
29
+ * </template>
21
30
  * ```
22
-
23
- * @public
24
31
  */
25
- import { ComponentVars } from '../types';
26
32
  import {
33
+ INJECT_COMPONENT_VARS,
27
34
  INJECT_COMPONENTS,
28
35
  INJECT_CONFIG,
29
36
  ensureInjectConfig,
30
37
  } from '../constants';
38
+ import type { ComponentVars } from '../types';
31
39
  import { computed, provide } from 'vue';
32
- import { getObject } from '../../../shared/core';
33
- import { ComponentName } from '../../form/constants';
40
+ import { getObject, omit } from '../../../shared/core';
41
+ import type { ComponentName } from '../../form/constants';
34
42
  import { LOCALE_INJECT_KEY, type ProLocale } from '../../../locale';
35
43
 
36
44
  type ComponentMap = Partial<Record<ComponentName, any>>;
@@ -41,13 +49,20 @@ defineOptions({
41
49
  });
42
50
 
43
51
  type Props = {
44
- /** 组件全局配置,可配置所有内置组件的默认属性 */
52
+ /**
53
+ * 组件全局配置,可配置所有内置组件和 Pro 组件的默认属性
54
+ * @example { 'input': { placeholder: '请输入' }, 'pro-form': { grid: { gutter: 24 } } }
55
+ */
45
56
  componentVars?: ComponentVars;
46
- /** 自定义组件映射,用于替换或扩展内置组件 */
57
+ /**
58
+ * 自定义组件映射:用于替换或扩展内置组件,传入的组件会覆盖默认的同名组件
59
+ * @example { 'input': MyCustomInput, 'select': MyCustomSelect }
60
+ */
47
61
  componentMap?: ComponentMap;
48
62
  /**
49
- * 内置文案覆盖,可覆盖任意 locale 文案(如查询/重置/序号/占位符等),
63
+ * 内置文案覆盖:可覆盖任意 locale 文案(如查询/重置/序号/占位符等),
50
64
  * 未覆盖的文案默认跟随宿主组件库语言自动切换
65
+ * @example { 'table.query': '搜索' }
51
66
  */
52
67
  locale?: Partial<ProLocale>;
53
68
  };
@@ -60,18 +75,24 @@ const props = withDefaults(defineProps<Props>(), {
60
75
 
61
76
  /*
62
77
  * 遍历 componentVars 的每个 key,获取或创建对应的 inject 配置
63
- * 将用户提供的值合并到默认值上,通过 provide 响应式注入到子组件树
78
+ * 将用户提供的值合并到默认值上,剔除该注入项的不可注入键后通过 provide 响应式注入到子组件树
64
79
  * 子组件通过 inject(config.injectionKey) 获取合并后的计算属性配置
65
80
  */
66
81
  (Object.keys(INJECT_CONFIG) as Array<keyof typeof INJECT_CONFIG>).forEach(
67
82
  key => {
68
83
  const config = INJECT_CONFIG[key];
84
+ const ignored = config.ignoreProps;
69
85
  provide(
70
86
  config.injectionKey as any,
71
- computed(() => ({
72
- ...config.default,
73
- ...getObject(props.componentVars?.[key as keyof ComponentVars]),
74
- }))
87
+ computed(() =>
88
+ omit(
89
+ {
90
+ ...config.default,
91
+ ...getObject(props.componentVars?.[key as keyof ComponentVars]),
92
+ },
93
+ ignored ?? []
94
+ )
95
+ )
75
96
  );
76
97
  }
77
98
  );
@@ -92,6 +113,12 @@ if (props.componentVars) {
92
113
  });
93
114
  }
94
115
 
116
+ // 全量 componentVars:自定义组件键在运行期新增后同样可被子组件读取
117
+ provide(
118
+ INJECT_COMPONENT_VARS,
119
+ computed(() => (props.componentVars as Record<string, any>) ?? {})
120
+ );
121
+
95
122
  // 注入自定义组件映射,BaseField 在解析组件时会优先使用此映射
96
123
  provide(
97
124
  INJECT_COMPONENTS,
@@ -1,19 +1,32 @@
1
- import { RequiredComponentVars } from '../types';
2
- import { InjectionKey, Component, type ComputedRef } from 'vue';
1
+ import type { RequiredComponentVars } from '../types';
2
+ import type { InjectionKey, Component } from 'vue';
3
+ import { type ComputedRef } from 'vue';
3
4
 
5
+ /** 全量 componentVars 注入通道:运行期新增的自定义组件键由此读取(按组件名取配置) */
6
+ export const INJECT_COMPONENT_VARS: InjectionKey<
7
+ ComputedRef<Record<string, any> | undefined> | Record<string, any>
8
+ > = Symbol('COMPONENT_VARS');
9
+
10
+ /** 注入项配置:注入 key、内置默认值与不可注入键清单 */
4
11
  export type InjectConfigEntry<T = any> = {
5
12
  injectionKey: InjectionKey<T>;
6
13
  default: T;
14
+ /** 不接受 Provider 注入的键,注入层静默剔除 */
15
+ ignoreProps?: readonly string[];
7
16
  };
8
17
 
18
+ /**
19
+ * 注入项配置表:键为内置组件名与 `pro-*` 组件名,值为注入 key、内置默认值与不可注入键清单
20
+ */
9
21
  export const INJECT_CONFIG: {
10
- [key in keyof RequiredComponentVars]: {
11
- injectionKey: InjectionKey<RequiredComponentVars[key]>;
12
- default: RequiredComponentVars[key];
13
- };
22
+ [key in keyof RequiredComponentVars]: InjectConfigEntry<
23
+ RequiredComponentVars[key]
24
+ >;
14
25
  } = {
15
26
  'pro-table': {
16
27
  injectionKey: Symbol(''),
28
+ // 数据取自 `:table` 实例或显式 `:data`;列与加载态非类型面成员,同样在注入层忽略
29
+ ignoreProps: ['loading', 'columns', 'data'],
17
30
  default: {
18
31
  pagination: {
19
32
  layout: 'total, sizes, prev, pager, next, jumper',
@@ -30,6 +43,8 @@ export const INJECT_CONFIG: {
30
43
  },
31
44
  'pro-form': {
32
45
  injectionKey: Symbol(''),
46
+ // 表单实例由 `:form` 显式传入;grid 仅作为启用时的参数默认值,不开启网格
47
+ ignoreProps: ['form'],
33
48
  default: { grid: { gutter: 24 } },
34
49
  },
35
50
  'pro-form-item': {
@@ -176,6 +191,7 @@ export const INJECT_CONFIG: {
176
191
  },
177
192
  };
178
193
 
194
+ /** componentMap 注入 key:BaseField 解析组件时优先取用 */
179
195
  export const INJECT_COMPONENTS: InjectionKey<
180
196
  | ComputedRef<Partial<Record<string, Component>> | undefined>
181
197
  | Partial<Record<string, Component>>
@@ -184,6 +200,12 @@ export const INJECT_COMPONENTS: InjectionKey<
184
200
  const DYNAMIC_INJECT_CONFIG: Record<string, InjectConfigEntry> =
185
201
  Object.create(null);
186
202
 
203
+ /**
204
+ * 读取注入项配置
205
+ *
206
+ * @param {string} key - 组件名或自定义注入键
207
+ * @returns {InjectConfigEntry | undefined} 内置或动态注入项配置,未注册时返回 undefined
208
+ */
187
209
  export const getInjectConfig = (key: string): InjectConfigEntry | undefined => {
188
210
  return (
189
211
  (INJECT_CONFIG as Record<string, InjectConfigEntry>)[key] ||
@@ -191,6 +213,12 @@ export const getInjectConfig = (key: string): InjectConfigEntry | undefined => {
191
213
  );
192
214
  };
193
215
 
216
+ /**
217
+ * 读取注入项配置,未注册时按组件名补建动态注入项
218
+ *
219
+ * @param {string} key - 组件名或自定义注入键
220
+ * @returns {InjectConfigEntry} 已存在或新建的注入项配置
221
+ */
194
222
  export const ensureInjectConfig = (key: string): InjectConfigEntry => {
195
223
  const existing = getInjectConfig(key);
196
224
  if (existing) return existing;
@@ -1,17 +1,17 @@
1
- import {
1
+ import type {
2
2
  GridItemProps,
3
3
  FormItemProps,
4
4
  TableProps,
5
5
  PaginationProps,
6
6
  DatePicker,
7
7
  } from '../../../shared/ui';
8
- import { ComponentName, GetComponentType } from '../../form/constants';
9
- import { Base, Grid, ContainerComponent } from '../../form/types';
10
- import { ProFormProps } from '../../form/components';
8
+ import type { ComponentName, GetComponentType } from '../../form/constants';
9
+ import type { Base, Grid, ContainerComponent } from '../../form/types';
10
+ import type { ProFormProps } from '../../form/components';
11
11
  import type { SearchFormProps } from '../../table/components/SearchForm.vue';
12
- import { AllowedComponentProps } from 'vue';
12
+ import type { AllowedComponentProps } from 'vue';
13
13
  import type { ComponentProps } from 'vue-component-type-helpers';
14
- import { ColumnControlConfig } from '../../table/types';
14
+ import type { ColumnControlConfig } from '../../table/types';
15
15
 
16
16
  type PP<T extends Record<string, any>> = Partial<T & AllowedComponentProps>;
17
17
 
@@ -30,9 +30,17 @@ type FP<T extends Record<string, any>> = Partial<
30
30
 
31
31
  type DatePickerType = NonNullable<ComponentProps<typeof DatePicker>['type']>;
32
32
 
33
+ /**
34
+ * 全局配置的完整键集合(ComponentVars 的必填形态):键为内置组件名与 `pro-*` 组件名
35
+ */
33
36
  export type RequiredComponentVars = {
37
+ /**
38
+ * ProTable 全局默认属性
39
+ *
40
+ * @description `data` 不参与全局注入:由 `:table` 实例(`useTable`)或显式 `:data` 驱动;`columns` / `loading` 非本注入项的类型面成员,传入时在注入层忽略。
41
+ */
34
42
  'pro-table': PP<
35
- TableProps & {
43
+ Omit<TableProps, 'data'> & {
36
44
  pagination?: false | Partial<PaginationProps>;
37
45
  control?:
38
46
  | boolean
@@ -49,6 +57,7 @@ export type RequiredComponentVars = {
49
57
  tableContainer?: ContainerComponent | false;
50
58
  }
51
59
  >;
60
+ /** ProForm 全局默认属性,grid 必须为 GridProps 对象而非 boolean */
52
61
  'pro-form': PP<
53
62
  Omit<ProFormProps, 'form' | 'grid'> & {
54
63
  grid?: Exclude<Grid, undefined | boolean>;
@@ -71,4 +80,9 @@ export type RequiredComponentVars = {
71
80
  >;
72
81
  };
73
82
 
83
+ /**
84
+ * 组件全局配置
85
+ * @description RequiredComponentVars 的 Partial 版本,用于 ProComponentProvider 的 props
86
+ * @public
87
+ */
74
88
  export type ComponentVars = Partial<RequiredComponentVars>;
@@ -1,7 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  /**
3
+ * 字段级渲染组件
4
+ *
3
5
  * @component BaseField
4
- * @description 字段级渲染组件,负责将 field 配置渲染为实际的输入组件
6
+ * @description 负责将 field 配置渲染为实际的输入组件
5
7
  *
6
8
  * ## 核心职责
7
9
  *
@@ -34,15 +36,19 @@ import {
34
36
  mergeProps,
35
37
  ref,
36
38
  toValue,
37
- useAttrs,
38
39
  } from 'vue';
39
- import { cloneDeep } from '../../../../shared/core';
40
+ import {
41
+ cloneDeep,
42
+ getObject,
43
+ useReactiveAttrs,
44
+ } from '../../../../shared/core';
40
45
  import { useDisabledContext } from '../../../../shared/ui';
41
46
  import type { Field } from '../../types';
42
47
  import ContainerFragment from '../ContainerFragment/index.vue';
43
48
  import SlotComponent from '../SlotComponent/index.vue';
44
49
  import { componentMap, InjectionFormSlotsKey } from '../../constants';
45
50
  import {
51
+ INJECT_COMPONENT_VARS,
46
52
  INJECT_COMPONENTS,
47
53
  getInjectConfig,
48
54
  } from '../../../component-provider/constants';
@@ -71,7 +77,7 @@ const form = useForm(false);
71
77
 
72
78
  const componentRef = ref<any>();
73
79
 
74
- const attrs: any = useAttrs();
80
+ const attrs: any = useReactiveAttrs();
75
81
 
76
82
  /**
77
83
  * 全局默认配置注入:key = 组件名 + type 修饰段,inject 须在 setup 同步期调用。
@@ -89,6 +95,8 @@ const componentInjectConfig = injectConfigKey
89
95
  const rawInjectComponentProps = componentInjectConfig
90
96
  ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default)
91
97
  : undefined;
98
+ // 全量 componentVars:运行期新增的自定义组件键由此兜底读取
99
+ const componentVars = inject(INJECT_COMPONENT_VARS, undefined);
92
100
 
93
101
  // setter: 向 formData 写入值,支持 valueFormatter / valueFormatter.set 转换
94
102
  const value = computed({
@@ -140,7 +148,10 @@ const parentDisabled = useDisabledContext();
140
148
  * 属性分为三类:绑定属性(v-model)、组件属性(传递给组件)、插槽(动态渲染)
141
149
  */
142
150
  const groupedAttrs = computed(() => {
143
- const currentInjectProps = toValue(rawInjectComponentProps) || {};
151
+ const currentInjectProps = {
152
+ ...(toValue(rawInjectComponentProps) || {}),
153
+ ...getObject(toValue(componentVars)?.[injectConfigKey]),
154
+ };
144
155
  const initProps = getInitProps(
145
156
  {
146
157
  component: props.component,
@@ -150,10 +161,14 @@ const groupedAttrs = computed(() => {
150
161
  t
151
162
  );
152
163
  const modelPropName = attrs.modelProp ?? initProps.modelProp ?? 'modelValue';
164
+ // 字段级优先;null / undefined 回退父级与 Provider,'' / 'disabled' 按宿主 Boolean 形态为 true
165
+ const normalizeDisabled = (value: unknown) =>
166
+ value === '' || value === 'disabled' ? true : Boolean(value);
153
167
  const effectiveDisabled =
154
- attrs.disabled !== undefined
155
- ? Boolean(attrs.disabled)
156
- : Boolean(parentDisabled.value || initProps.disabled);
168
+ attrs.disabled !== undefined && attrs.disabled !== null
169
+ ? normalizeDisabled(attrs.disabled)
170
+ : normalizeDisabled(parentDisabled.value) ||
171
+ normalizeDisabled(initProps.disabled);
157
172
  const mergedProps = mergeProps(
158
173
  initProps,
159
174
  attrs,
@@ -175,10 +190,8 @@ const groupedAttrs = computed(() => {
175
190
  };
176
191
  });
177
192
 
178
- // 从 ProForm 插槽注入的 slots 集合(优先级最高;shallowRef 形态,computed 内经 .value 读取建立依赖)
179
- const injectedFormSlots = inject(InjectionFormSlotsKey, undefined) as
180
- | { value: Record<string, any> | undefined }
181
- | undefined;
193
+ // 从 ProForm 插槽注入的 slots 集合(优先级最高)
194
+ const injectedFormSlots = inject(InjectionFormSlotsKey, undefined);
182
195
 
183
196
  // 从 ProComponentProvider 注入的自定义组件映射
184
197
  const customComponents = inject(INJECT_COMPONENTS, {});
@@ -1,4 +1,4 @@
1
- import { Field } from '../../../types';
1
+ import type { Field } from '../../../types';
2
2
 
3
3
  type LocaleT = (
4
4
  key: string,
@@ -59,6 +59,15 @@ const getPlaceholderProps = (
59
59
  return { placeholder: t(placeholderKey) };
60
60
  };
61
61
 
62
+ /**
63
+ * 组件初始属性:以内置默认值为底,按下发组件名补默认占位符文案
64
+ *
65
+ * @description 组件名由 `component` 与 `type` 拼接(如 `input.password`);`component` 非字符串时返回空记录。
66
+ * @param {Field} field - 字段配置
67
+ * @param {Record<string, any>} injectProps - Provider 下发的组件默认属性
68
+ * @param {LocaleT} t - 取文案的翻译函数
69
+ * @returns {Record<string, any>} 组件初始属性(键值均来自注入配置与默认文案)
70
+ */
62
71
  export const getInitProps = (
63
72
  field: Field,
64
73
  injectProps: Record<string, any> = {},
@@ -75,6 +84,12 @@ export const getInitProps = (
75
84
  /** 已告警过的未知组件名(模块级去重集合) */
76
85
  const warnedUnknownComponents = new Set<string>();
77
86
 
87
+ /**
88
+ * 未识别组件名的降级告警
89
+ *
90
+ * @description 同一组件名仅告警一次,提示注册 componentMap 或 ProComponentProvider。
91
+ * @param {string} name - 未识别的组件类型名
92
+ */
78
93
  export function warnUnknownComponent(name: string) {
79
94
  if (warnedUnknownComponents.has(name)) return;
80
95
  warnedUnknownComponents.add(name);
@@ -1,7 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  /**
3
+ * 表单字段渲染引擎
4
+ *
3
5
  * @component BaseFormItem
4
- * @description 表单字段渲染引擎
5
6
  *
6
7
  * 负责将字段配置数组渲染为实际的表单项,支持:
7
8
  * - 字段分组(嵌套 fields 递归渲染,嵌套字段 path 须为完整点分路径)
@@ -17,17 +18,23 @@
17
18
  * 3. 递归渲染 BaseFormItem(嵌套表单)或 BaseField(输入组件)
18
19
  * 4. 通过 ref 回调收集 FormItem 和 Component 实例,注入到 field 对象上
19
20
  *
20
- * @param {Fields<D>} [fields] - 字段配置数组
21
+ * @param {Fields} [fields] - 字段配置数组
21
22
  * @param {boolean | GridProps} [grid] - 是否启用网格布局
23
+ * @param {boolean} [disabled] - 是否禁用所有子字段
22
24
  *
23
25
  * @internal
24
26
  */
25
- import { getObject, normalizePathKey } from '../../../../shared/core';
27
+ import {
28
+ getObject,
29
+ isObjectItem,
30
+ normalizePathKey,
31
+ } from '../../../../shared/core';
32
+ import type { GridProps } from '../../../../shared/ui';
26
33
  import {
27
34
  FormItem,
28
35
  Grid as ElGrid,
29
36
  GridItem as ElGridItem,
30
- GridProps,
37
+ useProviderDisabled,
31
38
  } from '../../../../shared/ui';
32
39
  import { computed, inject, toRaw, toValue } from 'vue';
33
40
  import type { Fields, Grid } from '../../types';
@@ -37,46 +44,34 @@ import ContainerFragment from '../ContainerFragment/index.vue';
37
44
  import { useGroupFieldAttrs } from '../../hooks/useGroupFieldAttrs';
38
45
  import { INJECT_CONFIG } from '../../../component-provider/constants';
39
46
 
40
- /*
41
- * 无 path 字段的稳定渲染 key:以字段原始对象为 key 分配自增 id,
42
- * 字段插删/重排/过滤时保持 key 与对象绑定,不随数组位置漂移
43
- */
44
- let fieldKeySeed = 0;
45
- const fieldKeyMap = new WeakMap<object, number>();
46
- const getFieldKey = (field: unknown): number => {
47
- const raw = toRaw(field as object);
48
- let key = fieldKeyMap.get(raw);
49
- if (key === undefined) {
50
- key = ++fieldKeySeed;
51
- fieldKeyMap.set(raw, key);
52
- }
53
- return key;
54
- };
55
-
56
47
  defineOptions({ name: 'BaseFormItem', inheritAttrs: false });
57
48
 
58
49
  type Props = {
59
50
  grid?: Grid;
60
51
  fields?: Fields;
52
+ disabled?: boolean;
61
53
  };
62
54
  const props = withDefaults(defineProps<Props>(), {
63
55
  grid: undefined,
64
56
  fields: () => [],
57
+ disabled: undefined,
65
58
  });
66
59
 
60
+ // 分组字段的禁用状态向下注入,供 BaseField 经禁用上下文消费
61
+ useProviderDisabled(computed(() => props.disabled));
62
+
67
63
  const validFields = computed(() =>
68
- // hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
69
- (props.fields ?? []).filter(field => !toValue(field.hidden))
64
+ // hidden 支持 Ref / ComputedRef 响应式形态(统一使用 toValue 取值)
65
+ (props.fields ?? []).filter(
66
+ field => isObjectItem(field) && !toValue((field as any).hidden)
67
+ )
70
68
  );
71
69
 
72
70
  const config = INJECT_CONFIG['pro-form'];
73
71
  const injectFormConfig = inject(config.injectionKey, config.default);
74
72
  const injectGrid = computed(() => toValue(injectFormConfig)?.grid);
75
73
 
76
- const enableGrid = computed(() => {
77
- if (props.grid !== undefined) return !!props.grid;
78
- return !!injectGrid.value;
79
- });
74
+ const enableGrid = computed(() => !!props.grid);
80
75
 
81
76
  const computedGridProps = computed<GridProps>(() => {
82
77
  return enableGrid.value
@@ -86,7 +81,7 @@ const computedGridProps = computed<GridProps>(() => {
86
81
 
87
82
  /**
88
83
  * 以字段原始对象为 key 登记 FormItem / 控件实例,供 getFormItemRef / getComponentRef 读取;
89
- * WeakMap 不参与响应式追踪,条目随字段对象回收自动释放。
84
+ * 字段对象被回收后对应条目不再可读。
90
85
  */
91
86
  const formItemInstanceMap = new WeakMap<object, any>();
92
87
  const componentInstanceMap = new WeakMap<object, any>();
@@ -99,7 +94,7 @@ const defineFieldAccessors = (
99
94
  ) => {
100
95
  try {
101
96
  for (const [key, getter] of Object.entries(accessors)) {
102
- // 不可枚举:不进入 Object.keys / spread,不随字段配置透传
97
+ // 访问器仅用于字段对象读取,不参与属性遍历与字段配置透传
103
98
  Object.defineProperty(raw, key, {
104
99
  value: getter,
105
100
  enumerable: false,
@@ -159,10 +154,7 @@ const groupedFields = useGroupFieldAttrs(validFields);
159
154
  v-bind="computedGridProps"
160
155
  style="width: 100%"
161
156
  >
162
- <template
163
- v-for="item of groupedFields"
164
- :key="item.path || getFieldKey(item.rawField)"
165
- >
157
+ <template v-for="item of groupedFields" :key="item.renderKey">
166
158
  <ContainerFragment
167
159
  :component="enableGrid ? ElGridItem : undefined"
168
160
  v-bind="item.gridItemProps"
@@ -189,6 +181,7 @@ const groupedFields = useGroupFieldAttrs(validFields);
189
181
  <BaseFormItem
190
182
  :grid="(item.rawField as any).grid ?? props.grid"
191
183
  :fields="item.rawField.fields"
184
+ :disabled="toValue(item.rawField.disabled)"
192
185
  />
193
186
  </template>
194
187
  <template v-else>
@@ -1,7 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  /**
3
+ * 容器分片渲染组件
4
+ *
3
5
  * @component ContainerFragment
4
- * @description 容器分片渲染组件。用于动态渲染表单行或表单项的外部包裹容器(例如 Grid 行、Col 列等布局容器)。
6
+ * @description 用于动态渲染表单行或表单项的外部包裹容器(例如 Grid 行、Col 列等布局容器)
5
7
  *
6
8
  * @public
7
9
  */