@schemx/vue 0.2.0 → 0.2.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.
- package/README.md +37 -14
- package/dist/analyze.html +1 -1
- package/dist/components/FormItem/index.d.ts +12 -5
- package/dist/components/FormItem/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +8 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/provideFieldContext.d.ts +41 -0
- package/dist/hooks/provideFieldContext.d.ts.map +1 -0
- package/dist/hooks/provideFormConfigContext.d.ts +59 -0
- package/dist/hooks/provideFormConfigContext.d.ts.map +1 -0
- package/dist/hooks/provideFormContext.d.ts +57 -0
- package/dist/hooks/provideFormContext.d.ts.map +1 -0
- package/dist/hooks/useDictionary.d.ts.map +1 -1
- package/dist/hooks/useField.d.ts +0 -31
- package/dist/hooks/useField.d.ts.map +1 -1
- package/dist/hooks/useForm.d.ts +29 -31
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +188 -148
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -8
- package/dist/hooks/useContext.d.ts +0 -52
- package/dist/hooks/useContext.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
## 安装
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
pnpm add @schemx/vue vue
|
|
18
|
+
pnpm add @schemx/vue @schemx/core vue
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
`@schemx/core` 是 `@schemx/vue` 的 peer dependency,业务项目需要显式安装。
|
|
22
|
+
|
|
21
23
|
## 快速开始
|
|
22
24
|
|
|
23
25
|
`@schemx/vue` 默认不提供具体输入控件。使用前需要注册 renderer:
|
|
@@ -66,7 +68,7 @@ rendererRegistry.register("input", markRaw(InputRenderer))
|
|
|
66
68
|
</template>
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
`@schemx/vue`
|
|
71
|
+
`@schemx/vue` 的 ESM 入口会自动加载基础样式,常规 Vite / Vue 项目不需要手动引入。直接使用 CommonJS 入口或构建工具未处理入口 CSS import 时,请显式引入 `@schemx/vue/style.css`。
|
|
70
72
|
|
|
71
73
|
## 自定义 Renderer
|
|
72
74
|
|
|
@@ -117,18 +119,39 @@ rendererRegistry.register("input", InputRenderer)
|
|
|
117
119
|
|
|
118
120
|
## Composition API
|
|
119
121
|
|
|
120
|
-
| API
|
|
121
|
-
|
|
|
122
|
-
| `useForm()`
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
122
|
+
| API | 说明 |
|
|
123
|
+
| --------------------------- | -------------------------------------------------------------------------- |
|
|
124
|
+
| `useForm()` | 创建由当前 Vue effect scope 管理生命周期的表单实例;不会自动执行 `provide` |
|
|
125
|
+
| `createFormContext()` | 向后代组件提供表单实例 |
|
|
126
|
+
| `useFormContext()` | 获取上层提供的表单实例 |
|
|
127
|
+
| `useField()` | 创建字段级读写、校验和状态控制器 |
|
|
128
|
+
| `createFieldContext()` | 向后代组件提供字段控制器 |
|
|
129
|
+
| `useFieldContext()` | 获取当前字段控制器 |
|
|
130
|
+
| `createFormConfigContext()` | 向后代组件提供表单展示配置 |
|
|
131
|
+
| `useFormConfigContext()` | 获取上层提供的表单展示配置 |
|
|
132
|
+
| `useWatch()` | 按单字段、多字段或全表签名监听变化 |
|
|
133
|
+
| `useWatchField()` | 监听单个字段 |
|
|
134
|
+
| `useWatchFields()` | 监听多个字段 |
|
|
135
|
+
| `useWatchAll()` | 监听整张表单 |
|
|
136
|
+
| `useDictionary()` | 管理依赖字段的远程或本地选项 |
|
|
137
|
+
| `useEffect()` | 创建字段依赖追踪 effect,并在 scope 销毁时清理 |
|
|
138
|
+
| `useStableRef()` | 创建引用保持稳定的 `shallowRef` |
|
|
139
|
+
| `useViewSchemas()` | 把 `subscribeViewSchemas()` 桥接为 Vue `shallowRef` |
|
|
140
|
+
|
|
141
|
+
## 根入口导出
|
|
142
|
+
|
|
143
|
+
以下内容均可直接从 `@schemx/vue` 引入:
|
|
144
|
+
|
|
145
|
+
| 分类 | API |
|
|
146
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| 表单组件 | 默认导出的表单组件、命名导出的 `schemxForm`、`FormItem`、`FormGroup` |
|
|
148
|
+
| 全局注册表 | `rendererRegistry`、`validatorRegistry` |
|
|
149
|
+
| Composition API | 上表中的全部 context、field、watch、dictionary、effect 和 ViewSchemas API |
|
|
150
|
+
| 高阶组件 | `WithRemoteOptions` |
|
|
151
|
+
| 类型 | `SchemxInstallOptions`、`SchemxDictionary`、`SchemxWithDictionary`、`UseDictionaryReturn`、`FormContextProps` |
|
|
152
|
+
| Core API | `@schemx/core` 根入口的全部公开 API 与类型 |
|
|
153
|
+
|
|
154
|
+
`schemxForm` 与默认导出指向同一个可安装组件。`@schemx/vue` 不额外导出命名为 `SchemxForm` 的组件;需要该命名时,可以在业务代码中自行给默认导入命名。
|
|
132
155
|
|
|
133
156
|
## Adapter 边界
|
|
134
157
|
|
package/dist/analyze.html
CHANGED
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.cjs","children":[{"name":"src","children":[{"name":"styles/index.css","uid":"5a50e0ba-1"},{"name":"utils","children":[{"uid":"5a50e0ba-3","name":"rendererProvider.ts"},{"uid":"5a50e0ba-5","name":"rulesProvider.ts"},{"uid":"5a50e0ba-19","name":"equal.ts"},{"uid":"5a50e0ba-25","name":"validation.ts"},{"uid":"5a50e0ba-27","name":"slot.ts"},{"uid":"5a50e0ba-33","name":"helpers.ts"}]},{"name":"hooks","children":[{"uid":"5a50e0ba-7","name":"useForm.ts"},{"uid":"5a50e0ba-9","name":"useField.ts"},{"uid":"5a50e0ba-11","name":"useWatch.ts"},{"uid":"5a50e0ba-13","name":"useEffect.ts"},{"uid":"5a50e0ba-15","name":"useDictionary.ts"},{"uid":"5a50e0ba-17","name":"useContext.ts"},{"uid":"5a50e0ba-21","name":"useStableRef.ts"},{"uid":"5a50e0ba-23","name":"useViewSchemas.ts"}]},{"name":"components","children":[{"name":"FormGroup/index.tsx","uid":"5a50e0ba-29"},{"name":"FormItem/index.tsx","uid":"5a50e0ba-31"}]},{"uid":"5a50e0ba-35","name":"form.vue?vue&type=script&setup=true&lang.ts"},{"uid":"5a50e0ba-37","name":"form.ts"},{"name":"hocs/withRemoteOptions.ts","uid":"5a50e0ba-39"},{"uid":"5a50e0ba-41","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"5a50e0ba-1":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"5a50e0ba-0"},"5a50e0ba-3":{"renderedLength":62,"gzipLength":69,"brotliLength":49,"metaUid":"5a50e0ba-2"},"5a50e0ba-5":{"renderedLength":58,"gzipLength":65,"brotliLength":49,"metaUid":"5a50e0ba-4"},"5a50e0ba-7":{"renderedLength":724,"gzipLength":334,"brotliLength":282,"metaUid":"5a50e0ba-6"},"5a50e0ba-9":{"renderedLength":1914,"gzipLength":688,"brotliLength":607,"metaUid":"5a50e0ba-8"},"5a50e0ba-11":{"renderedLength":551,"gzipLength":219,"brotliLength":186,"metaUid":"5a50e0ba-10"},"5a50e0ba-13":{"renderedLength":125,"gzipLength":112,"brotliLength":90,"metaUid":"5a50e0ba-12"},"5a50e0ba-15":{"renderedLength":2696,"gzipLength":879,"brotliLength":753,"metaUid":"5a50e0ba-14"},"5a50e0ba-17":{"renderedLength":319,"gzipLength":215,"brotliLength":167,"metaUid":"5a50e0ba-16"},"5a50e0ba-19":{"renderedLength":202,"gzipLength":154,"brotliLength":120,"metaUid":"5a50e0ba-18"},"5a50e0ba-21":{"renderedLength":240,"gzipLength":168,"brotliLength":143,"metaUid":"5a50e0ba-20"},"5a50e0ba-23":{"renderedLength":261,"gzipLength":162,"brotliLength":143,"metaUid":"5a50e0ba-22"},"5a50e0ba-25":{"renderedLength":768,"gzipLength":322,"brotliLength":262,"metaUid":"5a50e0ba-24"},"5a50e0ba-27":{"renderedLength":1262,"gzipLength":486,"brotliLength":401,"metaUid":"5a50e0ba-26"},"5a50e0ba-29":{"renderedLength":1849,"gzipLength":800,"brotliLength":674,"metaUid":"5a50e0ba-28"},"5a50e0ba-31":{"renderedLength":6476,"gzipLength":2312,"brotliLength":1891,"metaUid":"5a50e0ba-30"},"5a50e0ba-33":{"renderedLength":976,"gzipLength":385,"brotliLength":326,"metaUid":"5a50e0ba-32"},"5a50e0ba-35":{"renderedLength":3730,"gzipLength":1190,"brotliLength":1046,"metaUid":"5a50e0ba-34"},"5a50e0ba-37":{"renderedLength":281,"gzipLength":228,"brotliLength":174,"metaUid":"5a50e0ba-36"},"5a50e0ba-39":{"renderedLength":838,"gzipLength":382,"brotliLength":319,"metaUid":"5a50e0ba-38"},"5a50e0ba-41":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"5a50e0ba-40"}},"nodeMetas":{"5a50e0ba-0":{"id":"/src/styles/index.css","moduleParts":{"index.cjs":"5a50e0ba-1"},"imported":[],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-34"}]},"5a50e0ba-2":{"id":"/src/utils/rendererProvider.ts","moduleParts":{"index.cjs":"5a50e0ba-3"},"imported":[{"uid":"5a50e0ba-44"}],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-6"}]},"5a50e0ba-4":{"id":"/src/utils/rulesProvider.ts","moduleParts":{"index.cjs":"5a50e0ba-5"},"imported":[{"uid":"5a50e0ba-44"}],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-6"}]},"5a50e0ba-6":{"id":"/src/hooks/useForm.ts","moduleParts":{"index.cjs":"5a50e0ba-7"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-44"},{"uid":"5a50e0ba-2"},{"uid":"5a50e0ba-4"}],"importedBy":[{"uid":"5a50e0ba-42"},{"uid":"5a50e0ba-8"},{"uid":"5a50e0ba-10"},{"uid":"5a50e0ba-14"}]},"5a50e0ba-8":{"id":"/src/hooks/useField.ts","moduleParts":{"index.cjs":"5a50e0ba-9"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-44"},{"uid":"5a50e0ba-6"}],"importedBy":[{"uid":"5a50e0ba-42"}]},"5a50e0ba-10":{"id":"/src/hooks/useWatch.ts","moduleParts":{"index.cjs":"5a50e0ba-11"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-44"},{"uid":"5a50e0ba-6"}],"importedBy":[{"uid":"5a50e0ba-42"},{"uid":"5a50e0ba-14"}]},"5a50e0ba-12":{"id":"/src/hooks/useEffect.ts","moduleParts":{"index.cjs":"5a50e0ba-13"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-44"}],"importedBy":[{"uid":"5a50e0ba-42"}]},"5a50e0ba-14":{"id":"/src/hooks/useDictionary.ts","moduleParts":{"index.cjs":"5a50e0ba-15"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-6"},{"uid":"5a50e0ba-10"}],"importedBy":[{"uid":"5a50e0ba-42"},{"uid":"5a50e0ba-38"}]},"5a50e0ba-16":{"id":"/src/hooks/useContext.ts","moduleParts":{"index.cjs":"5a50e0ba-17"},"imported":[{"uid":"5a50e0ba-46"}],"importedBy":[{"uid":"5a50e0ba-42"}]},"5a50e0ba-18":{"id":"/src/utils/equal.ts","moduleParts":{"index.cjs":"5a50e0ba-19"},"imported":[],"importedBy":[{"uid":"5a50e0ba-20"}]},"5a50e0ba-20":{"id":"/src/hooks/useStableRef.ts","moduleParts":{"index.cjs":"5a50e0ba-21"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-18"}],"importedBy":[{"uid":"5a50e0ba-42"}]},"5a50e0ba-22":{"id":"/src/hooks/useViewSchemas.ts","moduleParts":{"index.cjs":"5a50e0ba-23"},"imported":[{"uid":"5a50e0ba-46"}],"importedBy":[{"uid":"5a50e0ba-42"}]},"5a50e0ba-24":{"id":"/src/utils/validation.ts","moduleParts":{"index.cjs":"5a50e0ba-25"},"imported":[],"importedBy":[{"uid":"5a50e0ba-48"}]},"5a50e0ba-26":{"id":"/src/utils/slot.ts","moduleParts":{"index.cjs":"5a50e0ba-27"},"imported":[],"importedBy":[{"uid":"5a50e0ba-48"}]},"5a50e0ba-28":{"id":"/src/components/FormGroup/index.tsx","moduleParts":{"index.cjs":"5a50e0ba-29"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-47"},{"uid":"5a50e0ba-30"}],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-30"}]},"5a50e0ba-30":{"id":"/src/components/FormItem/index.tsx","moduleParts":{"index.cjs":"5a50e0ba-31"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-47"},{"uid":"5a50e0ba-42"},{"uid":"5a50e0ba-48"},{"uid":"5a50e0ba-28"}],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-36"},{"uid":"5a50e0ba-28"},{"uid":"5a50e0ba-34"}]},"5a50e0ba-32":{"id":"/src/utils/helpers.ts","moduleParts":{"index.cjs":"5a50e0ba-33"},"imported":[],"importedBy":[{"uid":"5a50e0ba-34"}]},"5a50e0ba-34":{"id":"/src/form.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"index.cjs":"5a50e0ba-35"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-52"},{"uid":"5a50e0ba-30"},{"uid":"5a50e0ba-42"},{"uid":"5a50e0ba-32"},{"uid":"5a50e0ba-0"}],"importedBy":[{"uid":"5a50e0ba-49"}]},"5a50e0ba-36":{"id":"/src/form.ts","moduleParts":{"index.cjs":"5a50e0ba-37"},"imported":[{"uid":"5a50e0ba-30"},{"uid":"5a50e0ba-45"}],"importedBy":[{"uid":"5a50e0ba-40"}]},"5a50e0ba-38":{"id":"/src/hocs/withRemoteOptions.ts","moduleParts":{"index.cjs":"5a50e0ba-39"},"imported":[{"uid":"5a50e0ba-46"},{"uid":"5a50e0ba-14"}],"importedBy":[{"uid":"5a50e0ba-43"}]},"5a50e0ba-40":{"id":"/src/index.ts","moduleParts":{"index.cjs":"5a50e0ba-41"},"imported":[{"uid":"5a50e0ba-0"},{"uid":"5a50e0ba-36"},{"uid":"5a50e0ba-2"},{"uid":"5a50e0ba-4"},{"uid":"5a50e0ba-42"},{"uid":"5a50e0ba-43"},{"uid":"5a50e0ba-30"},{"uid":"5a50e0ba-28"},{"uid":"5a50e0ba-44"}],"importedBy":[],"isEntry":true},"5a50e0ba-42":{"id":"/src/hooks/index.ts","moduleParts":{},"imported":[{"uid":"5a50e0ba-6"},{"uid":"5a50e0ba-8"},{"uid":"5a50e0ba-10"},{"uid":"5a50e0ba-12"},{"uid":"5a50e0ba-14"},{"uid":"5a50e0ba-16"},{"uid":"5a50e0ba-20"},{"uid":"5a50e0ba-22"}],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-30"},{"uid":"5a50e0ba-34"}]},"5a50e0ba-43":{"id":"/src/hocs/index.ts","moduleParts":{},"imported":[{"uid":"5a50e0ba-38"}],"importedBy":[{"uid":"5a50e0ba-40"}]},"5a50e0ba-44":{"id":"@schemx/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"5a50e0ba-40"},{"uid":"5a50e0ba-2"},{"uid":"5a50e0ba-4"},{"uid":"5a50e0ba-6"},{"uid":"5a50e0ba-8"},{"uid":"5a50e0ba-10"},{"uid":"5a50e0ba-12"}],"isExternal":true},"5a50e0ba-45":{"id":"/src/formRuntime.js","moduleParts":{},"imported":[{"uid":"5a50e0ba-49"}],"importedBy":[{"uid":"5a50e0ba-36"}]},"5a50e0ba-46":{"id":"vue","moduleParts":{},"imported":[],"importedBy":[{"uid":"5a50e0ba-30"},{"uid":"5a50e0ba-28"},{"uid":"5a50e0ba-6"},{"uid":"5a50e0ba-8"},{"uid":"5a50e0ba-10"},{"uid":"5a50e0ba-12"},{"uid":"5a50e0ba-14"},{"uid":"5a50e0ba-16"},{"uid":"5a50e0ba-20"},{"uid":"5a50e0ba-22"},{"uid":"5a50e0ba-38"},{"uid":"5a50e0ba-34"}],"isExternal":true},"5a50e0ba-47":{"id":"classnames","moduleParts":{},"imported":[],"importedBy":[{"uid":"5a50e0ba-30"},{"uid":"5a50e0ba-28"}],"isExternal":true},"5a50e0ba-48":{"id":"/src/utils/index.ts","moduleParts":{},"imported":[{"uid":"5a50e0ba-50"},{"uid":"5a50e0ba-24"},{"uid":"5a50e0ba-26"},{"uid":"5a50e0ba-51"}],"importedBy":[{"uid":"5a50e0ba-30"}]},"5a50e0ba-49":{"id":"/src/form.vue","moduleParts":{},"imported":[{"uid":"5a50e0ba-34"}],"importedBy":[{"uid":"5a50e0ba-45"}]},"5a50e0ba-50":{"id":"/src/utils/dynamic.ts","moduleParts":{},"imported":[{"uid":"5a50e0ba-52"}],"importedBy":[{"uid":"5a50e0ba-48"}]},"5a50e0ba-51":{"id":"/src/utils/diff.ts","moduleParts":{},"imported":[{"uid":"5a50e0ba-53"}],"importedBy":[{"uid":"5a50e0ba-48"}]},"5a50e0ba-52":{"id":"es-toolkit","moduleParts":{},"imported":[],"importedBy":[{"uid":"5a50e0ba-50"},{"uid":"5a50e0ba-34"}],"isExternal":true},"5a50e0ba-53":{"id":"es-toolkit/compat","moduleParts":{},"imported":[],"importedBy":[{"uid":"5a50e0ba-51"}],"isExternal":true}},"env":{"rollup":"4.62.2"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.cjs","children":[{"name":"src","children":[{"name":"styles/index.css","uid":"35805a52-1"},{"name":"utils","children":[{"uid":"35805a52-3","name":"rendererProvider.ts"},{"uid":"35805a52-5","name":"rulesProvider.ts"},{"uid":"35805a52-23","name":"equal.ts"},{"uid":"35805a52-29","name":"validation.ts"},{"uid":"35805a52-31","name":"slot.ts"},{"uid":"35805a52-37","name":"helpers.ts"}]},{"name":"hooks","children":[{"uid":"35805a52-7","name":"useForm.ts"},{"uid":"35805a52-9","name":"provideFormContext.ts"},{"uid":"35805a52-11","name":"useField.ts"},{"uid":"35805a52-13","name":"provideFieldContext.ts"},{"uid":"35805a52-15","name":"useWatch.ts"},{"uid":"35805a52-17","name":"useEffect.ts"},{"uid":"35805a52-19","name":"useDictionary.ts"},{"uid":"35805a52-21","name":"provideFormConfigContext.ts"},{"uid":"35805a52-25","name":"useStableRef.ts"},{"uid":"35805a52-27","name":"useViewSchemas.ts"}]},{"name":"components","children":[{"name":"FormGroup/index.tsx","uid":"35805a52-33"},{"name":"FormItem/index.tsx","uid":"35805a52-35"}]},{"uid":"35805a52-39","name":"form.vue?vue&type=script&setup=true&lang.ts"},{"uid":"35805a52-41","name":"form.ts"},{"name":"hocs/withRemoteOptions.ts","uid":"35805a52-43"},{"uid":"35805a52-45","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"35805a52-1":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"35805a52-0"},"35805a52-3":{"renderedLength":62,"gzipLength":69,"brotliLength":49,"metaUid":"35805a52-2"},"35805a52-5":{"renderedLength":58,"gzipLength":65,"brotliLength":49,"metaUid":"35805a52-4"},"35805a52-7":{"renderedLength":348,"gzipLength":194,"brotliLength":159,"metaUid":"35805a52-6"},"35805a52-9":{"renderedLength":468,"gzipLength":280,"brotliLength":223,"metaUid":"35805a52-8"},"35805a52-11":{"renderedLength":1583,"gzipLength":557,"brotliLength":486,"metaUid":"35805a52-10"},"35805a52-13":{"renderedLength":410,"gzipLength":249,"brotliLength":198,"metaUid":"35805a52-12"},"35805a52-15":{"renderedLength":551,"gzipLength":219,"brotliLength":186,"metaUid":"35805a52-14"},"35805a52-17":{"renderedLength":125,"gzipLength":112,"brotliLength":90,"metaUid":"35805a52-16"},"35805a52-19":{"renderedLength":2696,"gzipLength":879,"brotliLength":753,"metaUid":"35805a52-18"},"35805a52-21":{"renderedLength":479,"gzipLength":282,"brotliLength":237,"metaUid":"35805a52-20"},"35805a52-23":{"renderedLength":202,"gzipLength":154,"brotliLength":120,"metaUid":"35805a52-22"},"35805a52-25":{"renderedLength":240,"gzipLength":168,"brotliLength":143,"metaUid":"35805a52-24"},"35805a52-27":{"renderedLength":261,"gzipLength":162,"brotliLength":143,"metaUid":"35805a52-26"},"35805a52-29":{"renderedLength":768,"gzipLength":322,"brotliLength":262,"metaUid":"35805a52-28"},"35805a52-31":{"renderedLength":1262,"gzipLength":486,"brotliLength":401,"metaUid":"35805a52-30"},"35805a52-33":{"renderedLength":1849,"gzipLength":800,"brotliLength":674,"metaUid":"35805a52-32"},"35805a52-35":{"renderedLength":7348,"gzipLength":2417,"brotliLength":1981,"metaUid":"35805a52-34"},"35805a52-37":{"renderedLength":976,"gzipLength":385,"brotliLength":326,"metaUid":"35805a52-36"},"35805a52-39":{"renderedLength":3763,"gzipLength":1198,"brotliLength":1057,"metaUid":"35805a52-38"},"35805a52-41":{"renderedLength":281,"gzipLength":228,"brotliLength":174,"metaUid":"35805a52-40"},"35805a52-43":{"renderedLength":838,"gzipLength":382,"brotliLength":319,"metaUid":"35805a52-42"},"35805a52-45":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"35805a52-44"}},"nodeMetas":{"35805a52-0":{"id":"/src/styles/index.css","moduleParts":{"index.cjs":"35805a52-1"},"imported":[],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-38"}]},"35805a52-2":{"id":"/src/utils/rendererProvider.ts","moduleParts":{"index.cjs":"35805a52-3"},"imported":[{"uid":"35805a52-48"}],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-6"}]},"35805a52-4":{"id":"/src/utils/rulesProvider.ts","moduleParts":{"index.cjs":"35805a52-5"},"imported":[{"uid":"35805a52-48"}],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-6"}]},"35805a52-6":{"id":"/src/hooks/useForm.ts","moduleParts":{"index.cjs":"35805a52-7"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-48"},{"uid":"35805a52-2"},{"uid":"35805a52-4"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-8":{"id":"/src/hooks/provideFormContext.ts","moduleParts":{"index.cjs":"35805a52-9"},"imported":[{"uid":"35805a52-50"}],"importedBy":[{"uid":"35805a52-46"},{"uid":"35805a52-10"},{"uid":"35805a52-14"},{"uid":"35805a52-18"},{"uid":"35805a52-38"}]},"35805a52-10":{"id":"/src/hooks/useField.ts","moduleParts":{"index.cjs":"35805a52-11"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-48"},{"uid":"35805a52-8"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-12":{"id":"/src/hooks/provideFieldContext.ts","moduleParts":{"index.cjs":"35805a52-13"},"imported":[{"uid":"35805a52-50"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-14":{"id":"/src/hooks/useWatch.ts","moduleParts":{"index.cjs":"35805a52-15"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-48"},{"uid":"35805a52-8"}],"importedBy":[{"uid":"35805a52-46"},{"uid":"35805a52-18"}]},"35805a52-16":{"id":"/src/hooks/useEffect.ts","moduleParts":{"index.cjs":"35805a52-17"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-48"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-18":{"id":"/src/hooks/useDictionary.ts","moduleParts":{"index.cjs":"35805a52-19"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-8"},{"uid":"35805a52-14"}],"importedBy":[{"uid":"35805a52-46"},{"uid":"35805a52-42"}]},"35805a52-20":{"id":"/src/hooks/provideFormConfigContext.ts","moduleParts":{"index.cjs":"35805a52-21"},"imported":[{"uid":"35805a52-50"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-22":{"id":"/src/utils/equal.ts","moduleParts":{"index.cjs":"35805a52-23"},"imported":[],"importedBy":[{"uid":"35805a52-24"}]},"35805a52-24":{"id":"/src/hooks/useStableRef.ts","moduleParts":{"index.cjs":"35805a52-25"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-22"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-26":{"id":"/src/hooks/useViewSchemas.ts","moduleParts":{"index.cjs":"35805a52-27"},"imported":[{"uid":"35805a52-50"}],"importedBy":[{"uid":"35805a52-46"}]},"35805a52-28":{"id":"/src/utils/validation.ts","moduleParts":{"index.cjs":"35805a52-29"},"imported":[],"importedBy":[{"uid":"35805a52-52"}]},"35805a52-30":{"id":"/src/utils/slot.ts","moduleParts":{"index.cjs":"35805a52-31"},"imported":[],"importedBy":[{"uid":"35805a52-52"}]},"35805a52-32":{"id":"/src/components/FormGroup/index.tsx","moduleParts":{"index.cjs":"35805a52-33"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-51"},{"uid":"35805a52-34"}],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-34"}]},"35805a52-34":{"id":"/src/components/FormItem/index.tsx","moduleParts":{"index.cjs":"35805a52-35"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-51"},{"uid":"35805a52-46"},{"uid":"35805a52-52"},{"uid":"35805a52-32"}],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-40"},{"uid":"35805a52-32"},{"uid":"35805a52-38"}]},"35805a52-36":{"id":"/src/utils/helpers.ts","moduleParts":{"index.cjs":"35805a52-37"},"imported":[],"importedBy":[{"uid":"35805a52-38"}]},"35805a52-38":{"id":"/src/form.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"index.cjs":"35805a52-39"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-56"},{"uid":"35805a52-34"},{"uid":"35805a52-46"},{"uid":"35805a52-36"},{"uid":"35805a52-0"},{"uid":"35805a52-8"}],"importedBy":[{"uid":"35805a52-53"}]},"35805a52-40":{"id":"/src/form.ts","moduleParts":{"index.cjs":"35805a52-41"},"imported":[{"uid":"35805a52-34"},{"uid":"35805a52-49"}],"importedBy":[{"uid":"35805a52-44"}]},"35805a52-42":{"id":"/src/hocs/withRemoteOptions.ts","moduleParts":{"index.cjs":"35805a52-43"},"imported":[{"uid":"35805a52-50"},{"uid":"35805a52-18"}],"importedBy":[{"uid":"35805a52-47"}]},"35805a52-44":{"id":"/src/index.ts","moduleParts":{"index.cjs":"35805a52-45"},"imported":[{"uid":"35805a52-0"},{"uid":"35805a52-40"},{"uid":"35805a52-2"},{"uid":"35805a52-4"},{"uid":"35805a52-46"},{"uid":"35805a52-47"},{"uid":"35805a52-34"},{"uid":"35805a52-32"},{"uid":"35805a52-48"}],"importedBy":[],"isEntry":true},"35805a52-46":{"id":"/src/hooks/index.ts","moduleParts":{},"imported":[{"uid":"35805a52-6"},{"uid":"35805a52-8"},{"uid":"35805a52-10"},{"uid":"35805a52-12"},{"uid":"35805a52-14"},{"uid":"35805a52-16"},{"uid":"35805a52-18"},{"uid":"35805a52-20"},{"uid":"35805a52-24"},{"uid":"35805a52-26"}],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-34"},{"uid":"35805a52-38"}]},"35805a52-47":{"id":"/src/hocs/index.ts","moduleParts":{},"imported":[{"uid":"35805a52-42"}],"importedBy":[{"uid":"35805a52-44"}]},"35805a52-48":{"id":"@schemx/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"35805a52-44"},{"uid":"35805a52-2"},{"uid":"35805a52-4"},{"uid":"35805a52-6"},{"uid":"35805a52-10"},{"uid":"35805a52-14"},{"uid":"35805a52-16"}],"isExternal":true},"35805a52-49":{"id":"/src/formRuntime.js","moduleParts":{},"imported":[{"uid":"35805a52-53"}],"importedBy":[{"uid":"35805a52-40"}]},"35805a52-50":{"id":"vue","moduleParts":{},"imported":[],"importedBy":[{"uid":"35805a52-34"},{"uid":"35805a52-32"},{"uid":"35805a52-6"},{"uid":"35805a52-8"},{"uid":"35805a52-10"},{"uid":"35805a52-12"},{"uid":"35805a52-14"},{"uid":"35805a52-16"},{"uid":"35805a52-18"},{"uid":"35805a52-20"},{"uid":"35805a52-24"},{"uid":"35805a52-26"},{"uid":"35805a52-42"},{"uid":"35805a52-38"}],"isExternal":true},"35805a52-51":{"id":"classnames","moduleParts":{},"imported":[],"importedBy":[{"uid":"35805a52-34"},{"uid":"35805a52-32"}],"isExternal":true},"35805a52-52":{"id":"/src/utils/index.ts","moduleParts":{},"imported":[{"uid":"35805a52-54"},{"uid":"35805a52-28"},{"uid":"35805a52-30"},{"uid":"35805a52-55"}],"importedBy":[{"uid":"35805a52-34"}]},"35805a52-53":{"id":"/src/form.vue","moduleParts":{},"imported":[{"uid":"35805a52-38"}],"importedBy":[{"uid":"35805a52-49"}]},"35805a52-54":{"id":"/src/utils/dynamic.ts","moduleParts":{},"imported":[{"uid":"35805a52-56"}],"importedBy":[{"uid":"35805a52-52"}]},"35805a52-55":{"id":"/src/utils/diff.ts","moduleParts":{},"imported":[{"uid":"35805a52-57"}],"importedBy":[{"uid":"35805a52-52"}]},"35805a52-56":{"id":"es-toolkit","moduleParts":{},"imported":[],"importedBy":[{"uid":"35805a52-54"},{"uid":"35805a52-38"}],"isExternal":true},"35805a52-57":{"id":"es-toolkit/compat","moduleParts":{},"imported":[],"importedBy":[{"uid":"35805a52-55"}],"isExternal":true}},"env":{"rollup":"4.62.2"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PropType, VNodeChild } from 'vue';
|
|
1
2
|
import { SchemxViewSchema, Values } from '@schemx/core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -8,10 +9,16 @@ import { SchemxViewSchema, Values } from '@schemx/core';
|
|
|
8
9
|
export interface SchemxItemProps<T extends Values = Values> {
|
|
9
10
|
schema: SchemxViewSchema<T>;
|
|
10
11
|
}
|
|
11
|
-
declare const FormItem: import('vue').
|
|
12
|
-
schema:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
12
|
+
declare const FormItem: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
13
|
+
schema: {
|
|
14
|
+
type: PropType<SchemxViewSchema>;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
}>, () => VNodeChild, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
18
|
+
schema: {
|
|
19
|
+
type: PropType<SchemxViewSchema>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
16
23
|
export default FormItem;
|
|
17
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormItem/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormItem/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAgC,QAAQ,EAAS,MAAM,KAAK,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAqBrC,OAAO,KAAK,EAMV,gBAAgB,EAChB,MAAM,EACP,MAAM,cAAc,CAAA;AAErB;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;CAC5B;AAED,QAAA,MAAM,QAAQ;;cAKQ,QAAQ,CAAC,gBAAgB,CAAC;;;UAMjC,UAAU;;cANH,QAAQ,CAAC,gBAAgB,CAAC;;;iGAgB9C,CAAA;AAoOF,eAAe,QAAQ,CAAA"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* @module hooks
|
|
5
5
|
*/
|
|
6
6
|
/** useForm - 表单状态管理 */
|
|
7
|
-
export { useForm
|
|
7
|
+
export { useForm } from './useForm';
|
|
8
|
+
/** createFormContext - 表单上下文注入与消费 */
|
|
9
|
+
export { createFormContext, useFormContext } from './provideFormContext';
|
|
8
10
|
/** useField - 单字段控制 */
|
|
9
|
-
export { useField
|
|
11
|
+
export { useField } from './useField';
|
|
12
|
+
/** createFieldContext - 表单上下文注入与消费 */
|
|
13
|
+
export { createFieldContext, useFieldContext } from './provideFieldContext';
|
|
10
14
|
/** useWatch - 字段变化监听 */
|
|
11
15
|
export { useWatch, useWatchField, useWatchFields, useWatchAll } from './useWatch';
|
|
12
16
|
/** useEffect - 通用 Signal effect */
|
|
13
17
|
export { useEffect } from './useEffect';
|
|
14
18
|
/** useDictionary - 字典选项加载 */
|
|
15
19
|
export { useDictionary, type SchemxDictionary, type SchemxWithDictionary, type UseDictionaryReturn, } from './useDictionary';
|
|
16
|
-
/**
|
|
17
|
-
export {
|
|
20
|
+
/** useFormConfigContext - 表单上下文注入与消费 */
|
|
21
|
+
export { createFormConfigContext, useFormConfigContext, type FormContextProps, } from './provideFormConfigContext';
|
|
18
22
|
/** useStableRef - 引用稳定化的 shallowRef */
|
|
19
23
|
export { useStableRef } from './useStableRef';
|
|
20
24
|
/** useViewSchemas - ViewSchemas Vue 桥接 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uBAAuB;AACvB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uBAAuB;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,qCAAqC;AACrC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAExE,uBAAuB;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE3E,wBAAwB;AACxB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEjF,mCAAmC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,6BAA6B;AAC7B,OAAO,EACL,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAA;AAExB,wCAAwC;AACxC,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,4BAA4B,CAAA;AAEnC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,0CAA0C;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FieldInstance } from '../types/field';
|
|
2
|
+
import { Values } from '@schemx/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 向后代组件提供当前字段实例。
|
|
6
|
+
*
|
|
7
|
+
* 应在创建字段实例的组件 setup() 同步阶段调用,通常由 FormItem
|
|
8
|
+
* 在调用 useField() 后使用,使字段插槽或自定义子组件能够读取同一实例。
|
|
9
|
+
*
|
|
10
|
+
* @param field - useField() 返回的字段实例
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* 该函数只注册字段上下文,不创建字段实例,也不负责字段实例的生命周期。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // FormItem 中
|
|
18
|
+
* const field = useField('date')
|
|
19
|
+
* createFieldContext(field)
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createFieldContext<TValues extends Values = Values>(field: FieldInstance<TValues>): void;
|
|
24
|
+
/**
|
|
25
|
+
* 获取最近祖先组件提供的当前字段实例。
|
|
26
|
+
*
|
|
27
|
+
* 必须在已调用 createFieldContext() 的组件子树内调用,否则抛出错误。
|
|
28
|
+
*
|
|
29
|
+
* @returns useField() 返回的字段实例
|
|
30
|
+
*
|
|
31
|
+
* @throws Error 当前组件不在字段上下文的后代组件树中时抛出
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const field = useFieldContext()
|
|
36
|
+
* field.error.value // string[] | undefined
|
|
37
|
+
* field.getValue() // 当前字段值
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useFieldContext(): FieldInstance<Values>;
|
|
41
|
+
//# sourceMappingURL=provideFieldContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideFieldContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFieldContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAO1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAChE,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAC5B,IAAI,CAEN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,IAAI,aAAa,CAAC,MAAM,CAAC,CAWvD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { SchemxFormProps } from '../types';
|
|
3
|
+
import { Values } from '@schemx/core';
|
|
4
|
+
|
|
5
|
+
/** 表单级展示配置在 Vue provide/inject 中使用的注入 key。 */
|
|
6
|
+
export declare const SCHEMX_FORM_CONFIG_KEY: InjectionKey<FormContextProps<Values>>;
|
|
7
|
+
/**
|
|
8
|
+
* 表单级默认配置。
|
|
9
|
+
*
|
|
10
|
+
* 该类型描述由 SchemxForm 提供给字段组件的配置上下文,排除表单实例、
|
|
11
|
+
* 表单数据和回调等运行时处理属性,供字段组件读取默认展示行为。
|
|
12
|
+
*
|
|
13
|
+
* @typeParam TValues - 表单值类型
|
|
14
|
+
*/
|
|
15
|
+
export interface FormContextProps<TValues extends Values = Values> extends Omit<SchemxFormProps<TValues>, "form" | "modelValue" | "rendererRegistry" | "defaultRendererTValuesype" | "rulesRegistery" | "onFinish" | "onFinishFailed" | "onValuesChange" | "onFieldsChange"> {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 创建并注入表单级配置上下文。
|
|
19
|
+
*
|
|
20
|
+
* 应在 `SchemxForm` 或自定义 Provider 的 setup() 同步阶段调用,
|
|
21
|
+
* 使后代字段组件能够读取 readonly、disabled、labelAlign 等默认配置。
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TValues - 表单值类型
|
|
24
|
+
* @param props - 要提供给后代组件的表单级默认配置
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* 该函数只注册上下文,不创建或销毁表单实例,也不改变传入配置的所有权。
|
|
28
|
+
*/
|
|
29
|
+
export declare const createFormConfigContext: <TValues extends Values = Values>(props: FormContextProps<TValues>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* `createFormConfigContext` 的兼容别名。
|
|
32
|
+
*
|
|
33
|
+
* @deprecated 请使用 createFormConfigContext。
|
|
34
|
+
*/
|
|
35
|
+
export declare const createContext: <TValues extends Values = Values>(props: FormContextProps<TValues>) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取最近祖先组件提供的表单级配置。
|
|
38
|
+
*
|
|
39
|
+
* 只能读取祖先组件通过 createFormConfigContext() 注册的配置,
|
|
40
|
+
* 不能读取当前组件或后代组件提供的值。
|
|
41
|
+
*
|
|
42
|
+
* @returns 当前表单树中的表单级默认配置
|
|
43
|
+
*
|
|
44
|
+
* @throws Error 当前组件不在已注册表单配置上下文的后代组件树中时抛出
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const context = useFormConfigContext()
|
|
49
|
+
* console.log(context.readonly, context.disabled)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function useFormConfigContext(): FormContextProps;
|
|
53
|
+
/**
|
|
54
|
+
* `useFormConfigContext` 的兼容别名。
|
|
55
|
+
*
|
|
56
|
+
* @deprecated 请使用 useFormConfigContext。
|
|
57
|
+
*/
|
|
58
|
+
export declare const useContext: typeof useFormConfigContext;
|
|
59
|
+
//# sourceMappingURL=provideFormConfigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideFormConfigContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFormConfigContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAU,KAAK,YAAY,EAAW,MAAM,KAAK,CAAA;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,8CAA8C;AAC9C,eAAO,MAAM,sBAAsB,EAAmC,YAAY,CAChF,gBAAgB,CAAC,MAAM,CAAC,CACzB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CAC7E,eAAe,CAAC,OAAO,CAAC,EACtB,MAAM,GACN,YAAY,GACZ,kBAAkB,GAClB,2BAA2B,GAC3B,gBAAgB,GAChB,UAAU,GACV,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,CACnB;CAAG;AAEJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACrE,OAAO,gBAAgB,CAAC,OAAO,CAAC,KAC/B,IAEF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAXc,OAAO,SAAS,MAAM,kBACrD,gBAAgB,CAAC,OAAO,CAAC,KAC/B,IASiD,CAAA;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAWvD;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,6BAAuB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { SchemxInstance, Values } from '@schemx/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SchemxInstance 在 Vue provide/inject 中使用的注入 key。
|
|
6
|
+
*
|
|
7
|
+
* 该 key 只应与同一份包代码导出的 createFormContext() 和 useFormContext()
|
|
8
|
+
* 配套使用;重复安装不兼容版本的包不会共享此上下文。
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCHEMX_FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
|
|
11
|
+
/**
|
|
12
|
+
* 旧版表单实例注入 key。
|
|
13
|
+
*
|
|
14
|
+
* @deprecated 请使用 SCHEMX_FORM_INSTANCE_KEY。该别名仅用于兼容旧测试和旧适配代码。
|
|
15
|
+
*/
|
|
16
|
+
export declare const FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
|
|
17
|
+
/**
|
|
18
|
+
* 向当前组件的后代组件提供表单实例。
|
|
19
|
+
*
|
|
20
|
+
* 必须在组件 setup() 的同步执行阶段调用;不要放入 onMounted、nextTick、
|
|
21
|
+
* Promise 或其他异步回调中,否则 Vue 无法把上下文关联到当前组件实例。
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TValues - 表单值类型
|
|
24
|
+
* @param instance - 要提供给后代组件的表单实例
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* 该函数不接管实例所有权,也不会在组件卸载时销毁实例。
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const form = props.form ?? useForm(options)
|
|
32
|
+
*
|
|
33
|
+
* // 无论 form 来自外部还是内部,都统一注册上下文。
|
|
34
|
+
* createFormContext(form)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function createFormContext<TValues extends Values = Values>(instance: SchemxInstance<TValues>): void;
|
|
38
|
+
/**
|
|
39
|
+
* 获取最近祖先组件提供的表单实例。
|
|
40
|
+
*
|
|
41
|
+
* 该函数只能读取祖先组件注册的上下文,不能读取当前组件自身或后代组件
|
|
42
|
+
* 调用 createFormContext() 提供的值。通常由 useField()、useWatch() 等其他
|
|
43
|
+
* 表单 hook 间接调用。
|
|
44
|
+
*
|
|
45
|
+
* @typeParam TValues - 表单值类型
|
|
46
|
+
* @returns 当前组件所属表单树中的 SchemxInstance
|
|
47
|
+
*
|
|
48
|
+
* @throws Error 当前组件不在已注册表单实例上下文的后代组件树中时抛出
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const form = useFormContext<FormValues>()
|
|
53
|
+
* form.setFieldValue("name", "Schemx")
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function useFormContext<TValues extends Values = Values>(): SchemxInstance<TValues>;
|
|
57
|
+
//# sourceMappingURL=provideFormContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideFormContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFormContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAU,KAAK,YAAY,EAAW,MAAM,KAAK,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAgC,YAAY,CAC/E,cAAc,CAAC,MAAM,CAAC,CACvB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,sCAA2B,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/D,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,GAChC,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,SAAS,MAAM,GAAG,MAAM,KAC5B,cAAc,CAAC,OAAO,CAAC,CAW3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../src/hooks/useDictionary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAa,GAAG,EAAO,MAAM,KAAK,CAAA;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../src/hooks/useDictionary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAa,GAAG,EAAO,MAAM,KAAK,CAAA;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEpD,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEhF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uBAAuB;IACvB,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;IAChB,kBAAkB;IAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,kBAAkB;IAClB,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAA;IAC7B,eAAe;IACf,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,qBAAqB;IACrB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,8BAA8B;IAC9B,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,CAAA;AAEtD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAIlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,KAAK,SAAS,QAAQ,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EAEnD,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAClC,YAAY,KAAK,KAChB,mBAmIF,CAAA;AAED,eAAe,aAAa,CAAA"}
|
package/dist/hooks/useField.d.ts
CHANGED
|
@@ -34,36 +34,5 @@ import { NamePath, Values } from '@schemx/core';
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
export declare const useField: <TValues extends Values = Values>(name: NamePath<TValues>) => FieldInstance<TValues>;
|
|
37
|
-
/**
|
|
38
|
-
* 向子组件树注入当前字段上下文。
|
|
39
|
-
*
|
|
40
|
-
* 应在 FormItem(或任何创建了 useField 的组件)的 setup 中调用。
|
|
41
|
-
*
|
|
42
|
-
* @param field - useField 返回的字段实例
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* // FormItem 中
|
|
47
|
-
* const field = useField('date')
|
|
48
|
-
* createFieldContext(field)
|
|
49
|
-
*
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function createFieldContext<TValues extends Values = Values>(field: FieldInstance<TValues>): void;
|
|
53
|
-
/**
|
|
54
|
-
* 从最近的 FormItem 获取当前字段上下文。
|
|
55
|
-
*
|
|
56
|
-
* 必须在 FormItem 的组件子树内调用,否则抛出错误。
|
|
57
|
-
*
|
|
58
|
-
* @returns useField 返回的字段实例
|
|
59
|
-
*
|
|
60
|
-
* @throws 当不在 FormItem 子树内时抛出
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const field = useFieldContext()
|
|
64
|
-
* field.error.value // string[] | undefined
|
|
65
|
-
* field.getValue() // 当前字段值(Vue 响应式)
|
|
66
|
-
*/
|
|
67
|
-
export declare function useFieldContext(): ReturnType<typeof useField>;
|
|
68
37
|
export default useField;
|
|
69
38
|
//# sourceMappingURL=useField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/hooks/useField.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAI9C,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/hooks/useField.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAI9C,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,EAAE,MAAM,cAAc,CAAA;AAoEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACtD,MAAM,QAAQ,CAAC,OAAO,CAAC,KACtB,aAAa,CAAC,OAAO,CAuCvB,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
package/dist/hooks/useForm.d.ts
CHANGED
|
@@ -1,59 +1,57 @@
|
|
|
1
1
|
import { CreateFormOptions, NamePath, SchemxInstance, Values } from '@schemx/core';
|
|
2
2
|
|
|
3
|
-
/** SchemxInstance 在 Vue provide/inject 中的注入 key */
|
|
4
|
-
export declare const SCHEMX_INSTANCE_KEY: unique symbol;
|
|
5
|
-
/** @deprecated 请使用 SCHEMX_INSTANCE_KEY。保留给旧测试和旧适配代码兼容。 */
|
|
6
|
-
export declare const FORM_INSTANCE_KEY: symbol;
|
|
7
3
|
/**
|
|
8
|
-
* useForm
|
|
4
|
+
* useForm 配置选项。
|
|
9
5
|
*
|
|
10
|
-
*
|
|
6
|
+
* 当前与 core 层 CreateFormOptions 保持一致,并在 Vue 层自动补充默认的
|
|
7
|
+
* rendererRegistry 和 validatorRegistry。保留独立类型用于后续扩展
|
|
8
|
+
* Vue 专属配置,而不污染 core 层接口。
|
|
11
9
|
*
|
|
12
10
|
* @typeParam TValues - 表单值类型
|
|
13
11
|
*/
|
|
14
12
|
export interface UseFormOptions<TValues extends Values> extends CreateFormOptions<TValues, NamePath<TValues>> {
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
15
|
+
* 创建由当前 Vue effect scope 持有的表单实例。
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* useForm 只负责以下职责:
|
|
18
|
+
* 1. 合并 Vue 层默认注册表;
|
|
19
|
+
* 2. 同步创建 SchemxInstance;
|
|
20
|
+
* 3. 在当前 effect scope 销毁时调用 instance.destroy()。
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* useForm 不再自动调用 provide()。需要向后代组件暴露实例时,应由
|
|
23
|
+
* <SchemxForm> 或其他 Provider 组件显式调用 createFormContext(form)。
|
|
24
|
+
* 这样无论实例是内部创建还是通过 props.form 外部传入,都能走同一条
|
|
25
|
+
* 上下文注册路径,并保持清晰的实例所有权:谁创建,谁销毁。
|
|
26
|
+
*
|
|
27
|
+
* 该函数应在组件 setup() 或其他有效的 Vue effect scope 中同步调用。
|
|
28
|
+
* 非 Vue 生命周期场景请直接使用 @schemx/core 的 createForm(),并自行销毁实例。
|
|
23
29
|
*
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
30
|
+
* @typeParam TValues - 表单值类型
|
|
31
|
+
* @param options - 表单创建配置
|
|
32
|
+
* @returns 当前 scope 持有的 SchemxInstance
|
|
26
33
|
*
|
|
27
34
|
* @example
|
|
28
|
-
* ```
|
|
29
|
-
* // 在 setup 中使用
|
|
35
|
+
* ```ts
|
|
30
36
|
* const form = useForm({
|
|
31
|
-
* initialValues: {
|
|
37
|
+
* initialValues: {
|
|
38
|
+
* name: "",
|
|
39
|
+
* email: "",
|
|
40
|
+
* },
|
|
32
41
|
* onFinish: async (values) => {
|
|
33
42
|
* await api.submit(values)
|
|
34
43
|
* },
|
|
35
44
|
* })
|
|
36
45
|
*
|
|
37
|
-
* form.setFieldValue(
|
|
46
|
+
* form.setFieldValue("name", "Schemx")
|
|
38
47
|
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): SchemxInstance<TValues>;
|
|
41
|
-
/**
|
|
42
|
-
* 获取表单实例
|
|
43
|
-
*
|
|
44
|
-
* 在子组件中获取 useForm 创建的 SchemxInstance,
|
|
45
|
-
* 可用于读写字段值、校验、订阅等操作。
|
|
46
|
-
*
|
|
47
|
-
* @typeParam TValues - 表单值类型
|
|
48
|
-
* @returns 表单实例
|
|
49
|
-
*
|
|
50
|
-
* @throws Error 如果不在 schemx 提供的上下文中调用
|
|
51
48
|
*
|
|
52
49
|
* @example
|
|
53
50
|
* ```ts
|
|
54
|
-
*
|
|
55
|
-
* form.
|
|
51
|
+
* // Provider 组件中统一注册上下文。
|
|
52
|
+
* const form = props.form ?? useForm(options)
|
|
53
|
+
* createFormContext(form)
|
|
56
54
|
* ```
|
|
57
55
|
*/
|
|
58
|
-
export declare function
|
|
56
|
+
export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): SchemxInstance<TValues>;
|
|
59
57
|
//# sourceMappingURL=useForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEvF;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,MAAM,CAAE,SAAQ,iBAAiB,CAC/E,OAAO,EACP,QAAQ,CAAC,OAAO,CAAC,CAClB;CAAG;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,OAAO,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACrD,OAAO,GAAE,cAAc,CAAC,OAAO,CAAM,GACpC,cAAc,CAAC,OAAO,CAAC,CAgBzB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("classnames"),r=require("@schemx/core"),n=require("es-toolkit"),o=r.createRendererRegistry("input"),s=r.createValidatorsRegistry(),a=Symbol("SCHEMX_INSTANCE");function l(t={}){const{...n}=t,l={...n,rendererRegistry:n.rendererRegistry??o,validatorRegistry:n.validatorRegistry??s},i=e.computed(()=>r.createForm(l));return e.provide(a,i.value),e.onUnmounted(()=>{i.value.destroy()}),i.value}function i(){const t=e.inject(a);if(!t)throw new Error("useFormContext must be used within a Form");return t}const u=Symbol("schemx:field"),c=new WeakMap;const d=t=>{const n=i(),o=t;let s=c.get(n);s||(s=new Map,c.set(n,s));const a=s.get(o);let l;if(a)a.refCount++,l=a;else{const{result:a,dispose:i}=function(t,n){const o=r.createField(t,n),s=e.shallowRef(o.getValue()),a=e.shallowRef(o.getError()),l=e.shallowRef(o.isPending()),i=o.effect(()=>{s.value=o.getValue(),a.value=o.getError(),l.value=o.isPending()}),u=e.computed(()=>a.value),c=e.computed(()=>(s.value,o.isTouched())),d=e.computed(()=>l.value);return{result:{value:s,error:u,dirty:c,pending:d,...o,getValue:()=>s.value},dispose:i}}(n,t);l={refCount:1,result:a,dispose:i},s.set(o,l)}return e.onUnmounted(()=>{--l.refCount<=0&&(l.dispose(),s.delete(o))}),l.result};function m(t,n,o){const s=i(),a=r.createWatch(s,t,n,o);return e.onUnmounted(a),a}function p(e,t,r){return m(e,t,r)}function f(e){return e instanceof Error?e:new Error(String(e))}const h=(t,r)=>{var n;const o=i(),s=e.ref([]),a=e.ref(!1),l=e.ref(void 0);let u=0;const c=async()=>{try{const e=o.getFieldsValue();if("function"==typeof t.shouldFetch&&!t.shouldFetch(e))return s.value=[],void(a.value=!1);a.value=!0,l.value=void 0;const r=++u,n=await(async e=>{const r=t.retryCount??0,n=t.retryInterval??1e3;let s=new Error("Unknown error");for(let l=0;l<=r;l++)try{return await t.api(e,o)}catch(a){s=f(a),l<r&&await new Promise(e=>setTimeout(e,n))}throw s})(e);if(r!==u)return;const i=await(async e=>"function"==typeof(null==t?void 0:t.formatter)?await t.formatter(e,o):e)(n);if(r!==u)return;s.value=i,l.value=void 0,"function"==typeof t.onSuccess&&t.onSuccess(i,o),a.value=!1}catch(e){const r=f(e);l.value=r,s.value=[],a.value=!1,"function"==typeof t.onError&&t.onError(r,o)}};(null==(n=t.dependsOn)?void 0:n.length)&&p(t.dependsOn,(e,n)=>{"function"==typeof t.onDepsChange&&t.onDepsChange(n,o),t.resetOnDepsChange&&r&&o.setFieldValue(r,void 0),c()});const d=t.immediate??!0;return e.onMounted(()=>{d&&c()}),{list:s,loading:a,error:l,loadDict:c,refresh:()=>c(),mutate:e=>{s.value=e}}},v=Symbol("FormContext");function y(){const t=e.inject(v);if(!t)throw new Error("useConfigContext must be used within a Form");return t}function g(t){const r=e.shallowRef({});return e.watchEffect(()=>{const e=t();((e,t)=>{const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every(r=>e[r]===t[r])})(r.value,e)||(r.value=e)}),r}function b(e){return void 0!==e&&(!Array.isArray(e)||0!==e.length)}function x(e,t){if(!t)return!1;return(Array.isArray(t)?t:[t]).some(t=>function(e){return{onBlur:"blur",onChange:"change",onSubmit:"submit",blur:"blur",change:"change",submit:"submit"}[e]??"submit"}(t)===e)}const F=e=>/[A-Z]/.test(e),w=e=>e.includes("-"),C=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),V=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),_=(e,t)=>{if(e[t])return e[t];const r=F(t)?C(t):w(t)?V(t):void 0;return r&&e[r]?e[r]:void 0},R=(e,t)=>{const r={},n=(o=String(e),(w(o)?V(o):o)+":");var o;const s=(e=>F(e)?C(e):e)(String(e))+":";for(const[a,l]of Object.entries(t))a.startsWith(n)?r[a.slice(n.length)]=l:a.startsWith(s)&&s!==n&&(r[a.slice(s.length)]=l);return r},S=e.defineComponent((r,{slots:n})=>{const o=e.ref(Boolean(r.schema.defaultCollapsed)),s=()=>{r.schema.collapsible&&(o.value=!o.value)};return()=>{const a=r.schema,l=Boolean(a.collapsible);return e.createVNode("div",{class:t("schemx-group",{"schemx-group--collapsed":o.value},a.class),"data-key":a.key},[a.label&&e.createVNode("div",{role:l?"button":void 0,tabindex:l?0:void 0,class:t("schemx-group__header",{"schemx-group__header--clickable":l}),onClick:s,onKeydown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())}},[e.createVNode("span",{class:"schemx-group__title"},[a.label]),l&&e.createVNode("span",{class:t("schemx-group__arrow",{"schemx-group__arrow--down":!o.value})},null)]),!o.value&&e.createVNode("div",{class:"schemx-group__body"},[a.children.map(t=>e.createVNode(k,{key:t.key,schema:t},n))])])}},{name:"SchemxGroup",props:{schema:{type:Object,required:!0}}}),k=e.defineComponent((r,{slots:n})=>{const o=e.toRef(r,"schema");if(E(o.value))return()=>e.h(S,{schema:o.value},n);const s=i(),a=y(),l=()=>o.value,c=d(l().name);!function(t){e.provide(u,t)}(c);const m=e.computed(()=>{return e=l().validationTrigger,t=a.validationTrigger,r="onChange",b(e)?e:b(t)?t:r;var e,t,r}),p=e.computed(()=>{const e=l().visible&&!l().readonly&&!l().disabled,t=l().rules,r=Array.isArray(t)?(null==t?void 0:t.length)>0:!!l().rules;return e&&r}),f=e=>{var t,r;c.setValue(e),null==(r=null==(t=l().componentProps)?void 0:t.onChange)||r.call(t,e),p.value&&x("change",m.value)&&c.validate()},h=()=>{p.value&&x("blur",m.value)&&c.validate()},v=g(()=>({...l().componentProps,value:c.getValue(),onChange:f,onBlur:h,"onUpdate:value":e=>c.setValue(e)})),F=()=>{const t=_(n,`${l().name}Label`);if(t)return t(l());const r=l().labelAlign||a.labelAlign,o=l().labelWidth||a.labelWidth,s=l().colon??a.colon;return e.createVNode("label",{class:"schemx-item__label",style:{width:o,textAlign:r}},[!l().required||l().disabled||l().readonly?null:e.createVNode("span",{class:"schemx-item__required"},[e.createTextVNode("*")]),e.createVNode("span",{class:"schemx-item__label-text"},[l().label,s?":":""])])},w=()=>{const t=s.getRenderer(l().componentType);if(!t)throw new Error(`[schemx] Can not find component renderer of "${l().componentType}".`);const r=R(A(l().name),n),o=e.h(t,v.value,r),a=_(n,`${l().name}Content`);return a?a({...l(),columnElement:o}):e.createVNode("div",{class:"schemx-item__control"},[o])},C=()=>{const t=_(n,`${l().name}Error`);return t?t({...l(),errors:c.error.value}):Array.isArray(c.error.value)&&0!==c.error.value.length?e.createVNode("div",{class:"schemx-item__error"},[c.error.value[0]]):null};return()=>{if(!l().visible)return null;const r=_(n,A(l().name));if(r)return r(l());const o=l().labelPosition||a.labelPosition;return e.createVNode("div",{class:t("schemx-item-wrapper")},[e.createVNode("div",{class:t("schemx-item",`schemx-item--label-${o}`,l().class,{"is-readonly":l().readonly,"is-disabled":l().disabled}),style:{...l().style??{}}},[F(),e.createVNode("div",{class:"schemx-item__content"},[w(),C()])])])}},{name:"SchemxItem",props:{schema:{type:Object,required:!0}}}),E=e=>"group"===e.componentType,A=e=>Array.isArray(e)?e.map(e=>String(e)).join("."):String(e);function N(e){return!(!e||"group"===e.componentType||"visible"in e&&!1===e.visible)}function O(e,t,r){for(let n=t+r;n>=0&&n<e.length;n+=r)if(N(e[n]))return e[n]}const T=e.defineComponent({name:"SchemxForm",__name:"form",props:{class:{default:""},style:{default:()=>({})},required:{type:Boolean},readonly:{type:Boolean},disabled:{type:Boolean},visible:{type:Boolean},labelIcon:{},labelAlign:{},labelPosition:{},labelWidth:{},contentAlign:{},validationTrigger:{},colon:{type:Boolean},modelValue:{default:()=>({})},initialValues:{default:()=>({})},schemas:{default:()=>[]},form:{default:void 0},rendererRegistry:{default:void 0},defaultRendererType:{},validatorRegistry:{default:void 0},onFinish:{type:Function,default:void 0},onFinishFailed:{type:Function,default:void 0},onValuesChange:{type:Function,default:void 0},onFieldsChange:{type:Function,default:void 0}},emits:["update:modelValue"],setup(t,{expose:r,emit:o}){const s=t,a=o;(t=>{e.provide(v,t)})(n.omit(s,["form","modelValue","rendererRegistry","defaultRendererType","validatorRegistry","onFinish","onFinishFailed","onValuesChange","onFieldsChange"]));const i=s.form?s.form:l({schemas:s.schemas,initialValues:s.initialValues,rendererRegistry:s.rendererRegistry,defaultRendererType:s.defaultRendererType,validatorRegistry:s.validatorRegistry,readonly:s.readonly,disabled:s.disabled,onFinish:async e=>{var t;null==(t=s.onFinish)||t.call(s,e)},onFinishFailed:async e=>{var t;null==(t=s.onFinishFailed)||t.call(s,e)},onValuesChange:(e,t)=>{var r;a("update:modelValue",t),null==(r=s.onValuesChange)||r.call(s,e,t)},onFieldsChange:(e,t)=>{var r;null==(r=s.onFieldsChange)||r.call(s,e,t)}});e.watch(()=>s.schemas,e=>{i.setSchemas(e)},{deep:!1,immediate:!!s.form});const u=function(t){const r=e.shallowRef(t.getViewSchemas()),n=t.subscribeViewSchemas(e=>{r.value=e});return e.onScopeDispose(n),r}(i),c=e=>{const{isFirst:t,isLast:r}=function(e,t){const r=e.findIndex(e=>e.key===t);return-1===r?{found:!1,isFirst:!1,isLast:!1}:N(e[r])?{found:!0,isFirst:!O(e,r,-1),isLast:!O(e,r,1)}:{found:!0,isFirst:!1,isLast:!1}}(u.value,e.key);return{"schemx-item-wrapper--first":t,"schemx-item-wrapper--last":r}};return e.watchEffect(()=>{i.updateDefaultProps(s)}),r({...i}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["schemx",s.class])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(u),r=>(e.openBlock(),e.createBlock(e.unref(k),{key:r.key,schema:r,class:e.normalizeClass(c(r))},e.createSlots({_:2},[e.renderList(t.$slots,(r,n)=>({name:n,fn:e.withCtx(r=>[e.renderSlot(t.$slots,n,e.mergeProps({ref_for:!0},r??{}))])}))]),1032,["schema","class"]))),128))],2))}});const j=(B=T,P={install(e,t){e.component("SchemxForm",T)},FormItem:k},Object.assign(B,P));var B,P;exports.FormGroup=S,exports.FormItem=k,exports.WithRemoteOptions=function(t){return e.defineComponent({name:`WithRemoteOptions(${t.name||"Anonymous"})`,inheritAttrs:!1,props:{dict:{type:Object,default:void 0},fieldName:{type:[String,Array],default:void 0}},setup(r,{attrs:n,slots:o}){const s=r.dict?h(r.dict,r.fieldName):null,a=e.computed(()=>({...n,dict:r.dict,options:r.dict?null==s?void 0:s.list.value:n.options,loading:r.dict?null==s?void 0:s.loading.value:n.loading}));return()=>e.h(t,a.value,o)}})},exports.default=j,exports.rendererRegistry=o,exports.schemxForm=j,exports.useConfigContext=y,exports.useDictionary=h,exports.useEffect=function(t){const n=r.createEffect(t);return e.onUnmounted(n),n},exports.useField=d,exports.useFieldContext=function(){const t=e.inject(u);if(!t)throw new Error("[schemx] useFieldContext() must be used inside a FormItem tree");return t},exports.useForm=l,exports.useFormContext=i,exports.useWatch=m,exports.useWatchAll=function(e,t){return m(e,t)},exports.useWatchField=function(e,t,r){return m(e,t,r)},exports.useWatchFields=p,exports.validatorRegistry=s,Object.keys(r).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("classnames"),r=require("@schemx/core"),n=require("es-toolkit"),o=r.createRendererRegistry("input"),s=r.createValidatorsRegistry();function a(t={}){const n={...t,rendererRegistry:t.rendererRegistry??o,validatorRegistry:t.validatorRegistry??s},a=r.createForm(n);return e.onScopeDispose(()=>{a.destroy()}),a}const l=Symbol("schemx:instance");function i(t){e.provide(l,t)}function c(){const t=e.inject(l,null);if(!t)throw new Error("[schemx] useFormContext() must be called inside a <SchemxForm> descendant. Ensure createFormContext(form) is called synchronously during setup().");return t}const u=new WeakMap;const d=t=>{const n=c(),o=t;let s=u.get(n);s||(s=new Map,u.set(n,s));const a=s.get(o);let l;if(a)a.refCount++,l=a;else{const{result:a,dispose:i}=function(t,n){const o=r.createField(t,n),s=e.shallowRef(o.getValue()),a=e.shallowRef(o.getError()),l=e.shallowRef(o.isPending()),i=o.effect(()=>{s.value=o.getValue(),a.value=o.getError(),l.value=o.isPending()}),c=e.computed(()=>a.value),u=e.computed(()=>(s.value,o.isTouched())),d=e.computed(()=>l.value);return{result:{value:s,error:c,dirty:u,pending:d,...o,getValue:()=>s.value},dispose:i}}(n,t);l={refCount:1,result:a,dispose:i},s.set(o,l)}return e.onUnmounted(()=>{--l.refCount<=0&&(l.dispose(),s.delete(o))}),l.result},m=Symbol("schemx:field");function p(t){e.provide(m,t)}function h(t,n,o){const s=c(),a=r.createWatch(s,t,n,o);return e.onUnmounted(a),a}function f(e,t,r){return h(e,t,r)}function v(e){return e instanceof Error?e:new Error(String(e))}const y=(t,r)=>{var n;const o=c(),s=e.ref([]),a=e.ref(!1),l=e.ref(void 0);let i=0;const u=async()=>{try{const e=o.getFieldsValue();if("function"==typeof t.shouldFetch&&!t.shouldFetch(e))return s.value=[],void(a.value=!1);a.value=!0,l.value=void 0;const r=++i,n=await(async e=>{const r=t.retryCount??0,n=t.retryInterval??1e3;let s=new Error("Unknown error");for(let l=0;l<=r;l++)try{return await t.api(e,o)}catch(a){s=v(a),l<r&&await new Promise(e=>setTimeout(e,n))}throw s})(e);if(r!==i)return;const c=await(async e=>"function"==typeof(null==t?void 0:t.formatter)?await t.formatter(e,o):e)(n);if(r!==i)return;s.value=c,l.value=void 0,"function"==typeof t.onSuccess&&t.onSuccess(c,o),a.value=!1}catch(e){const r=v(e);l.value=r,s.value=[],a.value=!1,"function"==typeof t.onError&&t.onError(r,o)}};(null==(n=t.dependsOn)?void 0:n.length)&&f(t.dependsOn,(e,n)=>{"function"==typeof t.onDepsChange&&t.onDepsChange(n,o),t.resetOnDepsChange&&r&&o.setFieldValue(r,void 0),u()});const d=t.immediate??!0;return e.onMounted(()=>{d&&u()}),{list:s,loading:a,error:l,loadDict:u,refresh:()=>u(),mutate:e=>{s.value=e}}},g=Symbol("schemx:form-config"),x=t=>{e.provide(g,t)};function b(){const t=e.inject(g);if(!t)throw new Error("[schemx] useFormConfigContext() must be called inside a <SchemxForm> descendant. Ensure createFormConfigContext(props) is called synchronously during setup().");return t}function F(t){const r=e.shallowRef({});return e.watchEffect(()=>{const e=t();((e,t)=>{const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every(r=>e[r]===t[r])})(r.value,e)||(r.value=e)}),r}function C(t){const r=e.shallowRef(t.getViewSchemas()),n=t.subscribeViewSchemas(e=>{r.value=e});return e.onScopeDispose(n),r}function w(e){return void 0!==e&&(!Array.isArray(e)||0!==e.length)}function V(e,t){if(!t)return!1;return(Array.isArray(t)?t:[t]).some(t=>function(e){return{onBlur:"blur",onChange:"change",onSubmit:"submit",blur:"blur",change:"change",submit:"submit"}[e]??"submit"}(t)===e)}const R=e=>/[A-Z]/.test(e),S=e=>e.includes("-"),_=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),k=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),E=(e,t)=>{if(e[t])return e[t];const r=R(t)?_(t):S(t)?k(t):void 0;return r&&e[r]?e[r]:void 0},A=(e,t)=>{const r={},n=(o=String(e),(S(o)?k(o):o)+":");var o;const s=(e=>R(e)?_(e):e)(String(e))+":";for(const[a,l]of Object.entries(t))a.startsWith(n)?r[a.slice(n.length)]=l:a.startsWith(s)&&s!==n&&(r[a.slice(s.length)]=l);return r},O=e.defineComponent((r,{slots:n})=>{const o=e.ref(Boolean(r.schema.defaultCollapsed)),s=()=>{r.schema.collapsible&&(o.value=!o.value)};return()=>{const a=r.schema,l=Boolean(a.collapsible);return e.createVNode("div",{class:t("schemx-group",{"schemx-group--collapsed":o.value},a.class),"data-key":a.key},[a.label&&e.createVNode("div",{role:l?"button":void 0,tabindex:l?0:void 0,class:t("schemx-group__header",{"schemx-group__header--clickable":l}),onClick:s,onKeydown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())}},[e.createVNode("span",{class:"schemx-group__title"},[a.label]),l&&e.createVNode("span",{class:t("schemx-group__arrow",{"schemx-group__arrow--down":!o.value})},null)]),!o.value&&e.createVNode("div",{class:"schemx-group__body"},[a.children.map(t=>e.createVNode(N,{key:t.key,schema:t},n))])])}},{name:"SchemxGroup",props:{schema:{type:Object,required:!0}}}),N=e.defineComponent({name:"SchemxItem",props:{schema:{type:Object,required:!0}},setup:(t,{slots:r})=>()=>{const n=t.schema;return B(n)?e.h(O,{schema:n},r):e.h(j,{schema:n},r)}}),j=e.defineComponent({name:"SchemxFieldItem",props:{schema:{type:Object,required:!0}},setup(r,{slots:n}){const o=e.toRef(r,"schema"),s=c(),a=b(),l=()=>o.value,i=d(l().name);p(i);const u=e.computed(()=>{return e=l().validationTrigger,t=a.validationTrigger,r="onChange",w(e)?e:w(t)?t:r;var e,t,r}),m=e.computed(()=>{const e=l().visible&&!l().readonly&&!l().disabled,t=l().rules,r=Array.isArray(t)?(null==t?void 0:t.length)>0:!!l().rules;return e&&r}),h=e=>{var t,r;i.setValue(e),null==(r=null==(t=l().componentProps)?void 0:t.onChange)||r.call(t,e),m.value&&V("change",u.value)&&i.validate()},f=()=>{m.value&&V("blur",u.value)&&i.validate()},v=F(()=>{const e=l();return{...e.componentProps,readonly:e.readonly,disabled:e.disabled,placeholder:e.placeholder,formItemProps:e,value:i.getValue(),onChange:h,onBlur:f,"onUpdate:value":e=>i.setValue(e)}}),y=()=>{const t=E(n,`${l().name}Label`);if(t)return t(l());const r=l().labelAlign||a.labelAlign,o=l().labelWidth||a.labelWidth,s=l().colon??a.colon;return e.createVNode("label",{class:"schemx-item__label",style:{width:o,textAlign:r}},[!l().required||l().disabled||l().readonly?null:e.createVNode("span",{class:"schemx-item__required"},[e.createTextVNode("*")]),e.createVNode("span",{class:"schemx-item__label-text"},[l().label,s?":":""])])},g=()=>{const t=s.getRenderer(l().componentType);if(!t)throw new Error(`[schemx] Can not find component renderer of "${l().componentType}".`);const r=A(T(l().name),n),o=e.h(t,v.value,r),a=E(n,`${l().name}Content`);return a?a({...l(),columnElement:o}):e.createVNode("div",{class:"schemx-item__control"},[o])},x=()=>{const t=E(n,`${l().name}Error`);return t?t({...l(),errors:i.error.value}):Array.isArray(i.error.value)&&0!==i.error.value.length?e.createVNode("div",{class:"schemx-item__error"},[i.error.value[0]]):null};return()=>{if(!l().visible)return null;const r=E(n,T(l().name));if(r)return r(l());const o=l().labelPosition||a.labelPosition;return e.createVNode("div",{class:t("schemx-item-wrapper")},[e.createVNode("div",{class:t("schemx-item",`schemx-item--label-${o}`,l().class,{"is-readonly":l().readonly,"is-disabled":l().disabled}),style:{...l().style??{}}},[y(),e.createVNode("div",{class:"schemx-item__content"},[g(),x()])])])}}}),B=e=>"group"===e.componentType,T=e=>Array.isArray(e)?e.map(e=>String(e)).join("."):String(e);function P(e){return!(!e||"group"===e.componentType||"visible"in e&&!1===e.visible)}function W(e,t,r){for(let n=t+r;n>=0&&n<e.length;n+=r)if(P(e[n]))return e[n]}const q=e.defineComponent({name:"SchemxForm",__name:"form",props:{class:{default:""},style:{default:()=>({})},required:{type:Boolean},readonly:{type:Boolean},disabled:{type:Boolean},visible:{type:Boolean},labelIcon:{},labelAlign:{},labelPosition:{},labelWidth:{},contentAlign:{},validationTrigger:{},colon:{type:Boolean},modelValue:{default:()=>({})},initialValues:{default:()=>({})},schemas:{default:()=>[]},form:{default:void 0},rendererRegistry:{default:void 0},defaultRendererType:{},validatorRegistry:{default:void 0},onFinish:{type:Function,default:void 0},onFinishFailed:{type:Function,default:void 0},onValuesChange:{type:Function,default:void 0},onFieldsChange:{type:Function,default:void 0}},emits:["update:modelValue"],setup(t,{expose:r,emit:o}){const s=t,l=o;x(n.omit(s,["form","modelValue","rendererRegistry","defaultRendererType","validatorRegistry","onFinish","onFinishFailed","onValuesChange","onFieldsChange"]));const c=s.form?s.form:a({schemas:s.schemas,initialValues:s.initialValues,rendererRegistry:s.rendererRegistry,defaultRendererType:s.defaultRendererType,validatorRegistry:s.validatorRegistry,readonly:s.readonly,disabled:s.disabled,onFinish:async e=>{var t;null==(t=s.onFinish)||t.call(s,e)},onFinishFailed:async e=>{var t;null==(t=s.onFinishFailed)||t.call(s,e)},onValuesChange:(e,t)=>{var r;l("update:modelValue",t),null==(r=s.onValuesChange)||r.call(s,e,t)},onFieldsChange:(e,t)=>{var r;null==(r=s.onFieldsChange)||r.call(s,e,t)}});i(c),e.watch(()=>s.schemas,e=>{c.setSchemas(e)},{deep:!1,immediate:!!s.form});const u=C(c),d=e=>{const{isFirst:t,isLast:r}=function(e,t){const r=e.findIndex(e=>e.key===t);return-1===r?{found:!1,isFirst:!1,isLast:!1}:P(e[r])?{found:!0,isFirst:!W(e,r,-1),isLast:!W(e,r,1)}:{found:!0,isFirst:!1,isLast:!1}}(u.value,e.key);return{"schemx-item-wrapper--first":t,"schemx-item-wrapper--last":r}};return e.watchEffect(()=>{c.updateDefaultProps(s)}),r({...c}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["schemx",s.class])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(u),r=>(e.openBlock(),e.createBlock(e.unref(N),{key:r.key,schema:r,class:e.normalizeClass(d(r))},e.createSlots({_:2},[e.renderList(t.$slots,(r,n)=>({name:n,fn:e.withCtx(r=>[e.renderSlot(t.$slots,n,e.mergeProps({ref_for:!0},r??{}))])}))]),1032,["schema","class"]))),128))],2))}});const D=($=q,I={install(e,t){e.component("SchemxForm",q)},FormItem:N},Object.assign($,I));var $,I;exports.FormGroup=O,exports.FormItem=N,exports.WithRemoteOptions=function(t){return e.defineComponent({name:`WithRemoteOptions(${t.name||"Anonymous"})`,inheritAttrs:!1,props:{dict:{type:Object,default:void 0},fieldName:{type:[String,Array],default:void 0}},setup(r,{attrs:n,slots:o}){const s=r.dict?y(r.dict,r.fieldName):null,a=e.computed(()=>({...n,dict:r.dict,options:r.dict?null==s?void 0:s.list.value:n.options,loading:r.dict?null==s?void 0:s.loading.value:n.loading}));return()=>e.h(t,a.value,o)}})},exports.createFieldContext=p,exports.createFormConfigContext=x,exports.createFormContext=i,exports.default=D,exports.rendererRegistry=o,exports.schemxForm=D,exports.useDictionary=y,exports.useEffect=function(t){const n=r.createEffect(t);return e.onUnmounted(n),n},exports.useField=d,exports.useFieldContext=function(){const t=e.inject(m);if(!t)throw new Error("[schemx] useFieldContext() must be called inside a component tree where createFieldContext(field) has been called.");return t},exports.useForm=a,exports.useFormConfigContext=b,exports.useFormContext=c,exports.useStableRef=F,exports.useViewSchemas=C,exports.useWatch=h,exports.useWatchAll=function(e,t){return h(e,t)},exports.useWatchField=function(e,t,r){return h(e,t,r)},exports.useWatchFields=f,exports.validatorRegistry=s,Object.keys(r).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|