@qin-ui/vant-pro 1.0.5 → 1.1.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 (87) hide show
  1. package/AI-CONTEXT.md +48 -33
  2. package/LICENSE +9 -0
  3. package/README.md +1 -1
  4. package/api.json +27 -22
  5. package/es/component-provider/{index-DC_k4_R3.js → index-cldbPMDQ.js} +5 -4
  6. package/es/component-provider/index-cldbPMDQ.js.map +1 -0
  7. package/es/component-provider/index.js +2 -1
  8. package/es/component-provider/index.js.map +1 -0
  9. package/es/components/component-provider/components/index.vue.d.ts +27 -0
  10. package/es/components/component-provider/components/index.vue.d.ts.map +1 -0
  11. package/es/components/component-provider/constants/index.d.ts +16 -0
  12. package/es/components/component-provider/constants/index.d.ts.map +1 -0
  13. package/es/components/component-provider/index.d.ts +4 -0
  14. package/es/components/component-provider/index.d.ts.map +1 -0
  15. package/es/components/component-provider/types/index.d.ts +16 -0
  16. package/es/components/component-provider/types/index.d.ts.map +1 -0
  17. package/es/components/form/components/BaseField/index.vue.d.ts +1323 -0
  18. package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -0
  19. package/es/components/form/components/BaseField/utils/index.d.ts +3 -0
  20. package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -0
  21. package/es/components/form/components/BaseFormItem/index.vue.d.ts +7 -0
  22. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
  23. package/es/components/form/components/ContainerFragment/index.vue.d.ts +23 -0
  24. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
  25. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +24 -0
  26. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +1 -0
  27. package/es/components/form/components/PathProvider/index.vue.d.ts +23 -0
  28. package/es/components/form/components/PathProvider/index.vue.d.ts.map +1 -0
  29. package/es/components/form/components/ProForm/index.vue.d.ts +34 -0
  30. package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -0
  31. package/es/components/form/components/SlotComponent/index.vue.d.ts +7 -0
  32. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
  33. package/es/components/form/components/index.d.ts +12 -0
  34. package/es/components/form/components/index.d.ts.map +1 -0
  35. package/es/components/form/constants/index.d.ts +62 -0
  36. package/es/components/form/constants/index.d.ts.map +1 -0
  37. package/es/components/form/hooks/index.d.ts +6 -0
  38. package/es/components/form/hooks/index.d.ts.map +1 -0
  39. package/es/components/form/hooks/useFields.d.ts +57 -0
  40. package/es/components/form/hooks/useFields.d.ts.map +1 -0
  41. package/es/components/form/hooks/useForm.d.ts +101 -0
  42. package/es/components/form/hooks/useForm.d.ts.map +1 -0
  43. package/es/components/form/hooks/useFormPopup.d.ts +57 -0
  44. package/es/components/form/hooks/useFormPopup.d.ts.map +1 -0
  45. package/es/components/form/hooks/useFormRef.d.ts +30 -0
  46. package/es/components/form/hooks/useFormRef.d.ts.map +1 -0
  47. package/es/components/form/index.d.ts +7 -0
  48. package/es/components/form/index.d.ts.map +1 -0
  49. package/es/components/form/types/index.d.ts +152 -0
  50. package/es/components/form/types/index.d.ts.map +1 -0
  51. package/es/form/index.js +11 -7
  52. package/es/form/index.js.map +1 -0
  53. package/es/index.d.ts +58 -954
  54. package/es/index.d.ts.map +1 -0
  55. package/es/index.js +10 -21
  56. package/es/index.js.map +1 -0
  57. package/es/shared/core/index.d.ts +6 -0
  58. package/es/shared/core/index.d.ts.map +1 -0
  59. package/es/shared/ui/index.d.ts +2 -0
  60. package/es/shared/ui/index.d.ts.map +1 -0
  61. package/package.json +11 -12
  62. package/src/components/component-provider/components/index.vue +67 -0
  63. package/src/components/component-provider/constants/index.ts +110 -0
  64. package/src/components/component-provider/index.ts +6 -0
  65. package/src/components/component-provider/types/index.ts +31 -0
  66. package/src/components/form/components/BaseField/index.vue +340 -0
  67. package/src/components/form/components/BaseField/utils/index.ts +14 -0
  68. package/src/components/form/components/BaseFormItem/index.vue +77 -0
  69. package/src/components/form/components/ContainerFragment/index.vue +24 -0
  70. package/src/components/form/components/GroupedFieldAttrs/index.vue +51 -0
  71. package/src/components/form/components/PathProvider/index.vue +18 -0
  72. package/src/components/form/components/ProForm/index.vue +114 -0
  73. package/src/components/form/components/SlotComponent/index.vue +26 -0
  74. package/src/components/form/components/index.ts +15 -0
  75. package/src/components/form/constants/index.ts +109 -0
  76. package/src/components/form/hooks/index.ts +6 -0
  77. package/src/components/form/hooks/useFields.ts +67 -0
  78. package/src/components/form/hooks/useForm.ts +126 -0
  79. package/src/components/form/hooks/useFormPopup.ts +111 -0
  80. package/src/components/form/hooks/useFormRef.ts +35 -0
  81. package/src/components/form/index.ts +27 -0
  82. package/src/components/form/types/index.ts +220 -0
  83. package/src/index.ts +62 -0
  84. package/src/shared/core/index.ts +37 -0
  85. package/src/shared/ui/index.ts +26 -0
  86. package/es/core/index-B5vvm4Fj.js +0 -236
  87. package/es/vendor/utils/lodash-es-DN4QDiDm.js +0 -1079
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AAEnE,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;;IAGvC;;;;;;;;;;;;;OAaG;iBACU,GAAG;;AAflB,wBAmBE"}
package/es/index.js CHANGED
@@ -1,16 +1,7 @@
1
1
  import _sfc_main from "./form/index.js";
2
2
  import { ContainerFragment, SlotComponent, useFields, useForm, useFormRef } from "./form/index.js";
3
- import { _ as _sfc_main$1 } from "./component-provider/index-DC_k4_R3.js";
4
- import { e } from "./core/index-B5vvm4Fj.js";
5
- const withInstall = (comp) => {
6
- comp.install = (app) => {
7
- app.component(comp.name, comp);
8
- };
9
- return comp;
10
- };
11
- const ProForm = withInstall(_sfc_main);
12
- const ProComponentProvider = withInstall(_sfc_main$1);
13
- const components = [ProForm, ProComponentProvider];
3
+ import { _ as _sfc_main$1 } from "./component-provider/index-cldbPMDQ.js";
4
+ import { useFormData } from "@qin-ui/pro-components-core";
14
5
  const index = {
15
6
  /**
16
7
  * @qin-ui/vant-pro 安装方法
@@ -21,27 +12,25 @@ const index = {
21
12
  * @example
22
13
  * ```ts
23
14
  * import { createApp } from 'vue'
24
- * import QinUI from '@qin-ui/vant-pro'
15
+ * import ProComponents from '@qin-ui/vant-pro'
25
16
  * const app = createApp(App)
26
- * app.use(QinUI)
17
+ * app.use(ProComponents)
27
18
  * ```
28
19
  */
29
20
  install(app) {
30
- components.forEach((component) => {
31
- if (component.name) {
32
- app.component(component.name, component);
33
- }
34
- });
21
+ app.component(_sfc_main.name, _sfc_main);
22
+ app.component(_sfc_main$1.name, _sfc_main$1);
35
23
  }
36
24
  };
37
25
  export {
38
26
  ContainerFragment,
39
- ProComponentProvider,
40
- ProForm,
27
+ _sfc_main$1 as ProComponentProvider,
28
+ _sfc_main as ProForm,
41
29
  SlotComponent,
42
30
  index as default,
43
31
  useFields,
44
32
  useForm,
45
- e as useFormData,
33
+ useFormData,
46
34
  useFormRef
47
35
  };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { App } from 'vue';\nimport ProForm from './components/form';\nimport ProComponentProvider from './components/component-provider';\n\nexport * from './components/form';\nexport * from './components/component-provider';\n\n/**\n * Schema 驱动的表单组件,基于 vant Form 封装\n *\n * @description 通过声明式 JSON Schema 配置即可快速生成表单,\n * 提供极致的 TypeScript 类型推导与组件库插槽扩展能力。\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { ProForm, useForm } from '@qin-ui/vant-pro'\n * const form = useForm<User>({ name: '' }, [\n * { path: 'name', label: '姓名', component: 'input' }\n * ])\n * </script>\n * <template>\n * <ProForm :form=\"form\" />\n * </template>\n * ```\n *\n * 组件提供者,用于全局配置 ProForm 的默认行为\n *\n * @description 通过 `ProComponentProvider` 包裹应用根组件,\n * 可以全局覆盖组件的默认属性。\n *\n * @example\n * ```vue\n * <template>\n * <ProComponentProvider :component-props=\"customProps\">\n * <App />\n * </ProComponentProvider>\n * </template>\n * ```\n */\nexport { ProForm, ProComponentProvider };\n\nexport default {\n /**\n * @qin-ui/vant-pro 安装方法\n * @description 全局注册所有组件(ProForm、ProComponentProvider)\n *\n * @param {App} app - Vue 应用实例\n *\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import ProComponents from '@qin-ui/vant-pro'\n * const app = createApp(App)\n * app.use(ProComponents)\n * ```\n */\n install(app: App) {\n app.component(ProForm.name, ProForm);\n app.component(ProComponentProvider.name!, ProComponentProvider);\n },\n};\n"],"names":["ProForm","ProComponentProvider"],"mappings":";;;;AA0CA,MAAA,QAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeb,QAAQ,KAAU;AAChB,QAAI,UAAUA,UAAQ,MAAMA,SAAO;AACnC,QAAI,UAAUC,YAAqB,MAAOA,WAAoB;AAAA,EAChE;AACF;"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 统一 re-export @qin-ui/pro-components-core,包内所有文件通过此文件引入 core 内容,
3
+ * 避免直接散列依赖 @qin-ui/pro-components-core,便于将来统一维护。
4
+ */
5
+ export { useForm, useTable, useFields, useFormData, useFormRef, InjectionFormKey, InjectionPathKey, getObject, toPath, camelizeProperties, cloneDeep, omit, pick, isPlainObject, 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';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,EAEV,gBAAgB,EAChB,gBAAgB,EAEhB,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,aAAa,EAEb,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"}
@@ -0,0 +1,2 @@
1
+ export { Form, Field, Button, Popup, Picker, DatePicker, TimePicker, Cascader, Area, Signature, Switch, Stepper, Rate, Slider, Uploader, CheckboxGroup, Checkbox, RadioGroup, Radio, Space, type FormProps, type FormInstance, type FieldInstance, type FieldProps, } from 'vant';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,MAAM,EACN,OAAO,EACP,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,UAAU,EACV,KAAK,EACL,KAAK,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qin-ui/vant-pro",
3
- "version": "1.0.5",
4
- "description": "基于 vant 和 @qin-ui/core 封装的高级表单和列表组件库",
3
+ "version": "1.1.0",
4
+ "description": "基于 vant 和 @qin-ui/pro-components-core 封装的高级表单和列表组件库",
5
5
  "bin": {
6
6
  "vant-pro": "./bin/init-ai.mjs"
7
7
  },
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "files": [
19
19
  "es",
20
+ "src",
20
21
  "bin",
21
22
  "README.md",
22
23
  "LICENSE",
@@ -28,10 +29,6 @@
28
29
  "type": "git",
29
30
  "url": "git+https://github.com/dufan3715/pro-components.git"
30
31
  },
31
- "scripts": {
32
- "prebuild": "tsx ../../scripts/generate-api-json.ts vant-pro",
33
- "build": "vue-tsc && vite build"
34
- },
35
32
  "author": "dufan3715",
36
33
  "bugs": {
37
34
  "url": "https://github.com/dufan3715/pro-components/issues"
@@ -43,12 +40,10 @@
43
40
  "vue": "^3.5.0"
44
41
  },
45
42
  "dependencies": {
46
- "vue-component-type-helpers": "^3.2.5"
43
+ "vue-component-type-helpers": "^3.2.5",
44
+ "@qin-ui/pro-components-core": "^1.0.0"
47
45
  },
48
46
  "devDependencies": {
49
- "@qin-ui/core": "workspace:^",
50
- "@types/lodash-es": "^4.17.12",
51
- "lodash-es": "^4.17.21",
52
47
  "vant": "^4.9.15"
53
48
  },
54
49
  "sideEffects": false,
@@ -67,5 +62,9 @@
67
62
  "ui",
68
63
  "form",
69
64
  "pro-form"
70
- ]
71
- }
65
+ ],
66
+ "scripts": {
67
+ "prebuild": "tsx ../../scripts/generate-api-json.ts vant-pro",
68
+ "build": "vue-tsc && vite build"
69
+ }
70
+ }
@@ -0,0 +1,67 @@
1
+ <script lang="ts" setup>
2
+ /**
3
+ * @component ProComponentProvider
4
+ * @description @qin-ui/vant-pro 全局配置提供者组件
5
+ *
6
+ * 用于在组件树的顶层配置所有子组件的全局默认属性。
7
+ *
8
+ * @param {ComponentVars} [componentVars] - 组件全局配置变量
9
+ * @param {Record<ComponentName, any>} [componentMap] - 自定义组件映射
10
+ *
11
+ * @slot default - 子组件内容
12
+ *
13
+ * @example
14
+ * ```vue
15
+ * <ProComponentProvider
16
+ * :componentVars="{ 'field': { placeholder: '请输入' } }"
17
+ * >
18
+ * <ProForm :form="form" :fields="fields" />
19
+ * </ProComponentProvider>
20
+ * ```
21
+
22
+ * @public
23
+ */
24
+ import { ComponentVars } from '../types';
25
+ import { INJECT_COMPONENTS, ensureInjectConfig } from '../constants';
26
+ import { provide } from 'vue';
27
+ import { getObject } from '../../../shared/core';
28
+ import { ComponentName } from '../../form/constants';
29
+
30
+ type ComponentMap = Partial<Record<ComponentName, any>>;
31
+
32
+ defineOptions({
33
+ name: 'ProComponentProvider',
34
+ inheritAttrs: false,
35
+ });
36
+
37
+ type Props = {
38
+ /** 组件全局配置,可配置所有内置组件的默认属性 */
39
+ componentVars?: ComponentVars;
40
+ /** 自定义组件映射,用于替换或扩展内置组件 */
41
+ componentMap?: ComponentMap;
42
+ };
43
+
44
+ const props = defineProps<Props>();
45
+
46
+ /*
47
+ * 遍历 componentVars 的每个 key,获取或创建对应的 inject 配置
48
+ * 将用户提供的值合并到默认值上,通过 provide 注入到子组件树
49
+ * 子组件通过 inject(config.injectionKey) 获取合并后的配置
50
+ */
51
+ if (props.componentVars) {
52
+ Object.entries(props.componentVars).forEach(([key, val]) => {
53
+ const config = ensureInjectConfig(key);
54
+ // 用户配置覆盖默认值
55
+ provide(config.injectionKey, { ...config.default, ...getObject(val) });
56
+ });
57
+ }
58
+
59
+ // 注入自定义组件映射,BaseField 在解析组件时会优先使用此映射
60
+ if (props.componentMap) {
61
+ provide(INJECT_COMPONENTS, props.componentMap);
62
+ }
63
+ </script>
64
+
65
+ <template>
66
+ <slot />
67
+ </template>
@@ -0,0 +1,110 @@
1
+ import { RequiredComponentVars } from '../types';
2
+ import { InjectionKey, Component } from 'vue';
3
+
4
+ export type InjectConfigEntry<T = any> = {
5
+ injectionKey: InjectionKey<T>;
6
+ default: T;
7
+ };
8
+
9
+ export const INJECT_CONFIG: {
10
+ [key in keyof RequiredComponentVars]: {
11
+ injectionKey: InjectionKey<RequiredComponentVars[key]>;
12
+ default: RequiredComponentVars[key];
13
+ };
14
+ } = {
15
+ 'pro-form': {
16
+ injectionKey: Symbol(''),
17
+ default: {
18
+ inputAlign: 'right',
19
+ errorMessageAlign: 'right',
20
+ required: 'auto',
21
+ scrollToError: true,
22
+ scrollToErrorPosition: 'nearest',
23
+ },
24
+ },
25
+ field: {
26
+ injectionKey: Symbol(''),
27
+ default: { clearable: true, placeholder: '请输入' },
28
+ },
29
+ switch: {
30
+ injectionKey: Symbol(''),
31
+ default: {},
32
+ },
33
+ stepper: {
34
+ injectionKey: Symbol(''),
35
+ default: {},
36
+ },
37
+ rate: {
38
+ injectionKey: Symbol(''),
39
+ default: {},
40
+ },
41
+ slider: {
42
+ injectionKey: Symbol(''),
43
+ default: {},
44
+ },
45
+ uploader: {
46
+ injectionKey: Symbol(''),
47
+ default: {},
48
+ },
49
+ 'checkbox-group': {
50
+ injectionKey: Symbol(''),
51
+ default: {},
52
+ },
53
+ 'radio-group': {
54
+ injectionKey: Symbol(''),
55
+ default: {},
56
+ },
57
+ picker: {
58
+ injectionKey: Symbol(''),
59
+ default: {},
60
+ },
61
+ 'date-picker': {
62
+ injectionKey: Symbol(''),
63
+ default: {},
64
+ },
65
+ 'time-picker': {
66
+ injectionKey: Symbol(''),
67
+ default: {},
68
+ },
69
+ cascader: {
70
+ injectionKey: Symbol(''),
71
+ default: {},
72
+ },
73
+ area: {
74
+ injectionKey: Symbol(''),
75
+ default: {},
76
+ },
77
+ signature: {
78
+ injectionKey: Symbol(''),
79
+ default: {},
80
+ },
81
+ button: {
82
+ injectionKey: Symbol(''),
83
+ default: {},
84
+ },
85
+ };
86
+
87
+ export const INJECT_COMPONENTS: InjectionKey<
88
+ Partial<Record<string, Component>>
89
+ > = Symbol('INJECT_COMPONENTS');
90
+
91
+ const DYNAMIC_INJECT_CONFIG: Record<string, InjectConfigEntry> =
92
+ Object.create(null);
93
+
94
+ export const getInjectConfig = (key: string): InjectConfigEntry | undefined => {
95
+ return (
96
+ (INJECT_CONFIG as Record<string, InjectConfigEntry>)[key] ||
97
+ DYNAMIC_INJECT_CONFIG[key]
98
+ );
99
+ };
100
+
101
+ export const ensureInjectConfig = (key: string): InjectConfigEntry => {
102
+ const existing = getInjectConfig(key);
103
+ if (existing) return existing;
104
+ const created: InjectConfigEntry = {
105
+ injectionKey: Symbol(`dynamic:${key}`),
106
+ default: {},
107
+ };
108
+ DYNAMIC_INJECT_CONFIG[key] = created;
109
+ return created;
110
+ };
@@ -0,0 +1,6 @@
1
+ import ComponentProvider from './components/index.vue';
2
+
3
+ // 仅导出全局属性配置类型
4
+ export { type ComponentVars } from './types';
5
+
6
+ export default ComponentProvider;
@@ -0,0 +1,31 @@
1
+ import { Base } from '../../form/types';
2
+ import { ProFormProps } from '../../form';
3
+ import { AllowedComponentProps } from 'vue';
4
+ import { GetComponentType, ComponentName } from '../../form/constants';
5
+ import type { ComponentProps } from 'vue-component-type-helpers';
6
+ import type { FormProps } from 'vant';
7
+
8
+ type PP<T extends Record<string, any>> = Partial<T & AllowedComponentProps>;
9
+
10
+ type FP<T extends Record<string, any>> = Partial<
11
+ T &
12
+ Pick<
13
+ Base,
14
+ | 'valueFormatter'
15
+ | 'displayFormatter'
16
+ | 'componentContainer'
17
+ | 'modelProp'
18
+ | 'popup'
19
+ > &
20
+ AllowedComponentProps
21
+ >;
22
+
23
+ export type RequiredComponentVars = {
24
+ 'pro-form': PP<Omit<ProFormProps & FormProps, 'form'>>;
25
+ } & {
26
+ [K in Exclude<ComponentName, 'custom'>]: FP<
27
+ ComponentProps<GetComponentType<K>>
28
+ >;
29
+ };
30
+
31
+ export type ComponentVars = Partial<RequiredComponentVars>;