@schemx/vue 1.0.0-next.0 → 1.0.0-next.2

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 (48) hide show
  1. package/README.md +172 -129
  2. package/dist/analyze.html +1 -1
  3. package/dist/components/Button/index.d.ts +3 -0
  4. package/dist/components/Button/index.d.ts.map +1 -0
  5. package/dist/components/Button/types.d.ts +21 -0
  6. package/dist/components/Button/types.d.ts.map +1 -0
  7. package/dist/components/FormItem/index.d.ts +5 -6
  8. package/dist/components/FormItem/index.d.ts.map +1 -1
  9. package/dist/components/FormItem/slot.d.ts +48 -0
  10. package/dist/components/FormItem/slot.d.ts.map +1 -0
  11. package/dist/config/appConfig.d.ts.map +1 -1
  12. package/dist/form.d.ts.map +1 -1
  13. package/dist/formBridge.d.ts +188 -0
  14. package/dist/formBridge.d.ts.map +1 -0
  15. package/dist/hocs/withRemoteOptions.d.ts.map +1 -1
  16. package/dist/hooks/index.d.ts +4 -2
  17. package/dist/hooks/index.d.ts.map +1 -1
  18. package/dist/hooks/provideFormConfigContext.d.ts +3 -4
  19. package/dist/hooks/provideFormConfigContext.d.ts.map +1 -1
  20. package/dist/hooks/provideFormContext.d.ts +7 -4
  21. package/dist/hooks/provideFormContext.d.ts.map +1 -1
  22. package/dist/hooks/useField.d.ts +4 -30
  23. package/dist/hooks/useField.d.ts.map +1 -1
  24. package/dist/hooks/useForm.d.ts +3 -2
  25. package/dist/hooks/useForm.d.ts.map +1 -1
  26. package/dist/hooks/useFormSelector.d.ts +38 -0
  27. package/dist/hooks/useFormSelector.d.ts.map +1 -0
  28. package/dist/hooks/useViewSchemas.d.ts +23 -3
  29. package/dist/hooks/useViewSchemas.d.ts.map +1 -1
  30. package/dist/hooks/useWatch.d.ts.map +1 -1
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.mjs +807 -224
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/style.css +1 -1
  38. package/dist/types/dictionary.d.ts +6 -3
  39. package/dist/types/dictionary.d.ts.map +1 -1
  40. package/dist/types/field.d.ts +1 -1
  41. package/dist/types/form.d.ts +34 -2
  42. package/dist/types/form.d.ts.map +1 -1
  43. package/dist/utils/helpers.d.ts.map +1 -1
  44. package/dist/utils/rendererProvider.d.ts +2 -1
  45. package/dist/utils/rendererProvider.d.ts.map +1 -1
  46. package/package.json +8 -6
  47. package/dist/hooks/useEffect.d.ts +0 -33
  48. package/dist/hooks/useEffect.d.ts.map +0 -1
@@ -0,0 +1,188 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { FieldExternalStore, FormExternalStore } from '@schemx/core/adapter';
3
+ import { FieldValue, NamePath, SchemxInstance, Values } from '@schemx/core';
4
+ /**
5
+ * 可在 Vue effect 中直接读取 Form 方法的结构兼容实例类型。
6
+ *
7
+ * Facade 与 Core Form 不同一引用,但保留完整的 `SchemxInstance` API。
8
+ */
9
+ export type VueSchemxInstance<TValues extends Values = Values> = SchemxInstance<TValues>;
10
+ /**
11
+ * External Store 中 pending 字段的只读聚合快照。
12
+ */
13
+ type PendingFieldsSnapshot<TValues extends Values> = readonly ReturnType<SchemxInstance<TValues>["getPendingFields"]>[number][];
14
+ /**
15
+ * Vue 中单个字段状态的 Ref 投影。
16
+ */
17
+ export interface VueFieldBridge<TValues extends Values = Values, TName extends NamePath<TValues> = NamePath<TValues>> {
18
+ /**
19
+ * 对应的 Core 字段 External Store。
20
+ */
21
+ readonly store: FieldExternalStore<TValues, TName>;
22
+ /**
23
+ * 当前字段值。
24
+ */
25
+ readonly value: ShallowRef<FieldValue<TValues, TName> | undefined>;
26
+ /**
27
+ * 当前字段错误消息。
28
+ */
29
+ readonly errors: ShallowRef<readonly string[]>;
30
+ /**
31
+ * 当前字段 touched 状态。
32
+ */
33
+ readonly touched: ShallowRef<boolean>;
34
+ /**
35
+ * 当前字段 pending 状态。
36
+ */
37
+ readonly pending: ShallowRef<boolean>;
38
+ }
39
+ /**
40
+ * 包含唯一 Vue Facade 的共享 Form Bridge。
41
+ */
42
+ export interface VueFormBridge<TValues extends Values = Values> {
43
+ /**
44
+ * 原始 Core Form。
45
+ */
46
+ readonly form: SchemxInstance<TValues>;
47
+ /**
48
+ * 该 Form 的 Core External Store owner。
49
+ */
50
+ readonly externalStore: FormExternalStore<TValues>;
51
+ /**
52
+ * 全表值 Ref。
53
+ */
54
+ readonly values: ShallowRef<TValues>;
55
+ /**
56
+ * 已 touched 字段 Ref。
57
+ */
58
+ readonly touchedFields: ShallowRef<readonly NamePath<TValues>[]>;
59
+ /**
60
+ * pending 字段 Ref。
61
+ */
62
+ readonly pendingFields: ShallowRef<PendingFieldsSnapshot<TValues>>;
63
+ /**
64
+ * 当前表单提交状态的 Vue Ref 投影。
65
+ */
66
+ readonly loading: ShallowRef<boolean>;
67
+ /**
68
+ * 按 Field External Store 身份缓存的字段 Ref 投影。
69
+ */
70
+ readonly fieldBridges: Map<object, ManagedVueFieldBridge<TValues>>;
71
+ /**
72
+ * 正在使用当前 Bridge 的 Vue owner 数量。
73
+ */
74
+ refCount: number;
75
+ /**
76
+ * Bridge 是否已被手动或自动释放。
77
+ */
78
+ destroyed: boolean;
79
+ /**
80
+ * 取消 Form 级 External Store 订阅。
81
+ */
82
+ readonly unsubscribe: () => void;
83
+ /**
84
+ * 与原始 Core Form 对应的唯一 Vue Facade。
85
+ */
86
+ readonly facade: VueSchemxInstance<TValues>;
87
+ }
88
+ /**
89
+ * 内部使用的、可停止订阅的字段 Ref 投影。
90
+ */
91
+ interface ManagedVueFieldBridge<TValues extends Values> extends VueFieldBridge<TValues> {
92
+ dispose(): void;
93
+ }
94
+ /**
95
+ * 返回原始 Core Form;普通 Core Form 输入时保持引用不变。
96
+ *
97
+ * @param form - Core Form 或 Vue Facade。
98
+ * @returns 原始 Core Form。
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const coreForm = getCoreForm(form)
103
+ * const snapshot = coreForm.getFieldsSnapshot()
104
+ * ```
105
+ */
106
+ export declare function getCoreForm<TValues extends Values = Values>(form: SchemxInstance<TValues> | VueSchemxInstance<TValues>): SchemxInstance<TValues>;
107
+ /**
108
+ * 获取指定 Form 的共享 Vue Bridge。
109
+ *
110
+ * @param form - Core Form 或 Vue Facade。
111
+ * @returns 对应的共享 Bridge。
112
+ *
113
+ * @remarks
114
+ * 首次调用会创建 External Store 订阅;调用方应使用
115
+ * `retainVueFormBridge()` 持有 Bridge,并在 owner 销毁时释放。
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const bridge = getVueFormBridge(form)
120
+ * const release = retainVueFormBridge(bridge)
121
+ * onScopeDispose(release)
122
+ * ```
123
+ */
124
+ export declare function getVueFormBridge<TValues extends Values = Values>(form: SchemxInstance<TValues> | VueSchemxInstance<TValues>): VueFormBridge<TValues>;
125
+ /**
126
+ * 获取指定 Form 的唯一 Vue Facade。
127
+ *
128
+ * @param form - Core Form 或已有 Vue Facade。
129
+ * @returns 可被 Vue effect 追踪的 Facade。
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const reactiveForm = getVueFormFacade(form)
134
+ * watchEffect(() => {
135
+ * console.log(reactiveForm.getFieldsValue())
136
+ * })
137
+ * ```
138
+ */
139
+ export declare function getVueFormFacade<TValues extends Values = Values>(form: SchemxInstance<TValues> | VueSchemxInstance<TValues>): VueSchemxInstance<TValues>;
140
+ /**
141
+ * 为一个 Vue owner 保留 Bridge,并返回对应的幂等释放函数。
142
+ *
143
+ * @param bridge - 要保留的共享 Bridge。
144
+ * @returns 释放当前 owner 的函数。
145
+ *
146
+ * @remarks
147
+ * 返回的释放函数可安全重复调用;最后一个 owner 释放后,Bridge 会自动销毁。
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * const bridge = getVueFormBridge(form)
152
+ * const release = retainVueFormBridge(bridge)
153
+ * onScopeDispose(release)
154
+ * ```
155
+ */
156
+ export declare function retainVueFormBridge<TValues extends Values>(bridge: VueFormBridge<TValues>): () => void;
157
+ /**
158
+ * 获取一个字段的共享 Vue Ref 投影。
159
+ *
160
+ * @param bridge - 所属 Form Bridge。
161
+ * @param name - 字段路径。
162
+ * @returns 对应字段的共享 Vue Bridge。
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * const bridge = getVueFormBridge(form)
167
+ * const field = getVueFieldBridge(bridge, "email")
168
+ * watchEffect(() => console.log(field.value.value))
169
+ * ```
170
+ */
171
+ export declare function getVueFieldBridge<TValues extends Values = Values, TName extends NamePath<TValues> = NamePath<TValues>>(bridge: VueFormBridge<TValues>, name: TName): VueFieldBridge<TValues, TName>;
172
+ /**
173
+ * 销毁共享 Bridge、全部字段订阅与 Core External Store。
174
+ *
175
+ * @param bridge - 要销毁的共享 Form Bridge。
176
+ *
177
+ * @remarks
178
+ * 销毁后 Bridge、字段 Ref 投影和 External Store 均不可继续使用;通常由
179
+ * `retainVueFormBridge()` 返回的最后一个释放函数自动触发。
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * disposeVueFormBridge(bridge)
184
+ * ```
185
+ */
186
+ export declare function disposeVueFormBridge<TValues extends Values>(bridge: VueFormBridge<TValues>): void;
187
+ export {};
188
+ //# sourceMappingURL=formBridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formBridge.d.ts","sourceRoot":"","sources":["../src/formBridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAIrC,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEhF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;AAExF;;GAEG;AACH,KAAK,qBAAqB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AC7B,MAAM,IAAI,CAoBZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,KAAK,SAAS,QAAQ,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EACnD,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAqD7E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,MAAM,EACzD,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,IAAI,CAgBN"}
@@ -1 +1 @@
1
- {"version":3,"file":"withRemoteOptions.d.ts","sourceRoot":"","sources":["../../src/hocs/withRemoteOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAwD,MAAM,KAAK,CAAA;AASrF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,cAAc;IACd,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,WAAW;IACX,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAkCxE;AAED,eAAe,iBAAiB,CAAA"}
1
+ {"version":3,"file":"withRemoteOptions.d.ts","sourceRoot":"","sources":["../../src/hocs/withRemoteOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAwD,MAAM,KAAK,CAAA;AAQrF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,cAAc;IACd,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,WAAW;IACX,OAAO,EAAE,OAAO,CAAA;CACjB;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAiCxE;AAED,eAAe,iBAAiB,CAAA"}
@@ -5,6 +5,8 @@
5
5
  */
6
6
  /** useForm - 表单状态管理 */
7
7
  export { useForm } from './useForm';
8
+ /** Vue Form Facade - 在 Vue effect 中可追踪的 Form 实例。 */
9
+ export { getCoreForm, type VueSchemxInstance } from '../formBridge';
8
10
  /** createFormContext - 表单上下文注入与消费 */
9
11
  export { createFormContext, useFormContext } from './provideFormContext';
10
12
  /** useField - 单字段控制 */
@@ -13,8 +15,6 @@ export { useField } from './useField';
13
15
  export { createFieldContext, useFieldContext } from './provideFieldContext';
14
16
  /** useWatch - 字段变化监听 */
15
17
  export { useWatch, useWatchField, useWatchFields, useWatchAll } from './useWatch';
16
- /** useEffect - 通用 Signal effect */
17
- export { useEffect } from './useEffect';
18
18
  /** useDictionary - 字典选项加载 */
19
19
  export { useDictionary, type UseDictionaryReturn } from './useDictionary';
20
20
  /** useFormConfigContext - 表单上下文注入与消费 */
@@ -23,4 +23,6 @@ export { createFormConfigContext, useFormConfigContext, type FormContextProps, }
23
23
  export { useStableRef } from './useStableRef';
24
24
  /** useViewSchemas - ViewSchemas Vue 桥接 */
25
25
  export { useViewSchemas } from './useViewSchemas';
26
+ /** useFormSelector - 表单值 Selector Vue 桥接 */
27
+ export { useFormSelector, type UseFormSelectorOptions, } from './useFormSelector';
26
28
  //# sourceMappingURL=index.d.ts.map
@@ -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,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,sCAAs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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;AAEjD,4CAA4C;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { InjectionKey } from 'vue';
2
- import { SchemxSchemaConfig, Values } from '@schemx/core';
2
+ import { SchemxSchemaConfig } from '@schemx/core';
3
3
  /** 表单级展示配置在 Vue provide/inject 中使用的注入 key。 */
4
4
  export declare const SCHEMX_FORM_CONFIG_KEY: InjectionKey<FormContextProps>;
5
5
  /**
@@ -18,7 +18,6 @@ export interface FormContextProps {
18
18
  * 应在 `SchemxForm` 或自定义 Provider 的 setup() 同步阶段调用,
19
19
  * 使后代字段组件能够读取 readonly、disabled、labelAlign 等默认配置。
20
20
  *
21
- * @typeParam TValues - 表单值类型
22
21
  * @param props - 要提供给后代组件的 Schema 配置
23
22
  *
24
23
  * @remarks
@@ -29,7 +28,7 @@ export interface FormContextProps {
29
28
  * createFormConfigContext({ schemaConfig: { readonly: true, labelAlign: "right" } })
30
29
  * ```
31
30
  */
32
- export declare const createFormConfigContext: <TValues extends Values = Values>(props: FormContextProps) => void;
31
+ export declare const createFormConfigContext: (props: FormContextProps) => void;
33
32
  /**
34
33
  * `createFormConfigContext` 的兼容别名。
35
34
  *
@@ -40,7 +39,7 @@ export declare const createFormConfigContext: <TValues extends Values = Values>(
40
39
  * createContext({ schemaConfig: { disabled: true } })
41
40
  * ```
42
41
  */
43
- export declare const createContext: <TValues extends Values = Values>(props: FormContextProps) => void;
42
+ export declare const createContext: (props: FormContextProps) => void;
44
43
  /**
45
44
  * 获取最近祖先组件提供的表单级配置。
46
45
  *
@@ -1 +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,kBAAkB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE9D,8CAA8C;AAC9C,eAAO,MAAM,sBAAsB,EAE9B,YAAY,CAAC,gBAAgB,CAAC,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC1C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACrE,OAAO,gBAAgB,KACtB,IAEF,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAhBc,OAAO,SAAS,MAAM,kBACrD,gBAAgB,KACtB,IAciD,CAAA;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAWvD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,6BAAuB,CAAA"}
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,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,8CAA8C;AAC9C,eAAO,MAAM,sBAAsB,EAE9B,YAAY,CAAC,gBAAgB,CAAC,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,gBAAgB,KAAG,IAEjE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,UAdqB,gBAAgB,KAAG,IAcd,CAAA;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAWvD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,6BAAuB,CAAA"}
@@ -1,18 +1,20 @@
1
1
  import { InjectionKey } from 'vue';
2
+ import { VueSchemxInstance } from '../formBridge';
2
3
  import { SchemxInstance, Values } from '@schemx/core';
4
+ type FormContextInstance = VueSchemxInstance<any>;
3
5
  /**
4
6
  * SchemxInstance 在 Vue provide/inject 中使用的注入 key。
5
7
  *
6
8
  * 该 key 只应与同一份包代码导出的 createFormContext() 和 useFormContext()
7
9
  * 配套使用;重复安装不兼容版本的包不会共享此上下文。
8
10
  */
9
- export declare const SCHEMX_FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
11
+ export declare const SCHEMX_FORM_INSTANCE_KEY: InjectionKey<FormContextInstance>;
10
12
  /**
11
13
  * 旧版表单实例注入 key。
12
14
  *
13
15
  * @deprecated 请使用 SCHEMX_FORM_INSTANCE_KEY。该别名仅用于兼容旧测试和旧适配代码。
14
16
  */
15
- export declare const FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
17
+ export declare const FORM_INSTANCE_KEY: InjectionKey<FormContextInstance>;
16
18
  /**
17
19
  * 向当前组件的后代组件提供表单实例。
18
20
  *
@@ -33,7 +35,7 @@ export declare const FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
33
35
  * createFormContext(form)
34
36
  * ```
35
37
  */
36
- export declare function createFormContext<TValues extends Values = Values>(instance: SchemxInstance<TValues>): void;
38
+ export declare function createFormContext<TValues extends Values = Values>(instance: SchemxInstance<TValues>): VueSchemxInstance<TValues>;
37
39
  /**
38
40
  * 获取最近祖先组件提供的表单实例。
39
41
  *
@@ -52,5 +54,6 @@ export declare function createFormContext<TValues extends Values = Values>(insta
52
54
  * form.setFieldValue("name", "Schemx")
53
55
  * ```
54
56
  */
55
- export declare function useFormContext<TValues extends Values = Values>(): SchemxInstance<TValues>;
57
+ export declare function useFormContext<TValues extends Values = Values>(): VueSchemxInstance<TValues>;
58
+ export {};
56
59
  //# sourceMappingURL=provideFormContext.d.ts.map
@@ -1 +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
+ {"version":3,"file":"provideFormContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFormContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAA0B,KAAK,YAAY,EAAW,MAAM,KAAK,CAAA;AAExE,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAK1D,KAAK,mBAAmB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAgC,YAAY,CAC/E,mBAAmB,CACpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,mCAA2B,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/D,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,GAChC,iBAAiB,CAAC,OAAO,CAAC,CAQ5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,SAAS,MAAM,GAAG,MAAM,KAC5B,iBAAiB,CAAC,OAAO,CAAC,CAW9B"}
@@ -1,36 +1,10 @@
1
- import { FieldInstance } from '../types/field';
2
1
  import { NamePath, Values } from '@schemx/core';
2
+ import { FieldInstance } from '../types/field';
3
3
  /**
4
- * 获取单个字段的控制能力
5
- *
6
- * 通过 core 层 createField 提供字段操作方法,
7
- * 通过 subscribe 回调桥接 Signal 变化到 Vue shallowRef。
8
- *
9
- * @param name - 字段名(支持嵌套路径,如 'user.address.city')
10
- * @returns 字段状态和操作方法
11
- *
12
- * @example
13
- * ```typescript
14
- * const field = useField('username')
15
- *
16
- * // 响应式值(在 computed/watchEffect/template 中自动追踪)
17
- * field.getValue()
18
- *
19
- * // 响应式错误
20
- * field.errors.value // readonly string[]
21
- *
22
- * // 响应式脏状态
23
- * field.dirty.value // boolean
24
- *
25
- * // 响应式操作中状态
26
- * field.pending.value // boolean
27
- *
28
- * // 写入值
29
- * field.setValue('new value')
4
+ * 获取单个字段的控制能力。
30
5
  *
31
- * // 校验
32
- * const result = await field.validate()
33
- * ```
6
+ * @param name - 字段路径(支持嵌套字段)。
7
+ * @returns 包含 Vue Ref 状态和 Core 字段操作的控制器。
34
8
  */
35
9
  export declare const useField: <TValues extends Values = Values>(name: NamePath<TValues>) => FieldInstance<TValues>;
36
10
  export default useField;
@@ -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;AAuEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
1
+ {"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/hooks/useField.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAwCnD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACtD,MAAM,QAAQ,CAAC,OAAO,CAAC,KACtB,aAAa,CAAC,OAAO,CAOvB,CAAA;AAED,eAAe,QAAQ,CAAA"}
@@ -1,4 +1,5 @@
1
- import { CreateFormOptions, NamePath, SchemxInstance, Values } from '@schemx/core';
1
+ import { VueSchemxInstance } from '../formBridge';
2
+ import { CreateFormOptions, NamePath, Values } from '@schemx/core';
2
3
  /**
3
4
  * useForm 配置选项。
4
5
  *
@@ -52,5 +53,5 @@ export interface UseFormOptions<TValues extends Values> extends CreateFormOption
52
53
  * createFormContext(form)
53
54
  * ```
54
55
  */
55
- export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): SchemxInstance<TValues>;
56
+ export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): VueSchemxInstance<TValues>;
56
57
  //# sourceMappingURL=useForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAiBA,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,CA0BzB"}
1
+ {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAcA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEvE;;;;;;;;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,iBAAiB,CAAC,OAAO,CAAC,CA8B5B"}
@@ -0,0 +1,38 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { SchemxInstance, Values } from '@schemx/core';
3
+ /**
4
+ * `useFormSelector` 的选中结果比较配置。
5
+ */
6
+ export interface UseFormSelectorOptions<TSelected> {
7
+ /**
8
+ * 判断两次 selector 结果是否等价;返回 true 时保持当前 Ref 值。
9
+ * 默认使用 `Object.is`。
10
+ */
11
+ equals?: (previous: TSelected, next: TSelected) => boolean;
12
+ }
13
+ /**
14
+ * 将 Core 表单值按 selector 映射为 Vue 只读浅引用。
15
+ *
16
+ * selector 只应读取快照,不应通过快照修改表单值或调用表单写入方法。
17
+ * `Readonly<TValues>` 仅表达顶层只读,嵌套字段应按不可变值使用;字段值需通过
18
+ * `setFieldValue()` 或 `setFieldsValue()` 更新,才能触发后续计算。
19
+ *
20
+ * @typeParam TValues - 表单值类型。
21
+ * @typeParam TSelected - selector 返回值类型。
22
+ * @param form - 要订阅的表单实例。
23
+ * @param selector - 从当前表单值快照派生结果的纯函数。
24
+ * @param options - 选中结果的比较配置。
25
+ * @returns selector 当前结果的 Vue 只读浅引用。
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const selectedName = useFormSelector(form, (values) => values.name)
30
+ *
31
+ * watchEffect(() => {
32
+ * console.log(selectedName.value)
33
+ * })
34
+ * ```
35
+ */
36
+ export declare function useFormSelector<TValues extends Values = Values, TSelected = unknown>(form: SchemxInstance<TValues>, selector: (values: Readonly<TValues>) => TSelected, options?: UseFormSelectorOptions<TSelected>): Readonly<ShallowRef<TSelected>>;
37
+ export default useFormSelector;
38
+ //# sourceMappingURL=useFormSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormSelector.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormSelector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAIrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1D;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,SAAS;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAA;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,SAAS,GAAG,OAAO,EAEnB,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,EAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,SAAS,EAClD,OAAO,GAAE,sBAAsB,CAAC,SAAS,CAAM,GAC9C,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CA6BjC;AAED,eAAe,eAAe,CAAA"}
@@ -1,11 +1,13 @@
1
- import { ShallowRef } from 'vue';
1
+ import { ComputedRef, ShallowRef } from 'vue';
2
2
  import { SchemxInstance, SchemxViewSchema, Values } from '@schemx/core';
3
3
  /**
4
- * 将表单 ViewSchema 映射为 Vue 响应式引用,并在当前作用域销毁时自动取消订阅。
4
+ * 将表单 ViewSchema 映射为共享的 Vue 响应式引用。
5
+ *
6
+ * 当前作用域释放一个桥接使用者;所有使用者都释放后才取消 Core 订阅。
5
7
  *
6
8
  * @typeParam TValues - 表单值类型。
7
9
  * @param form - 要订阅的表单实例。
8
- * @returns 当前 ViewSchema 列表的只读浅引用。
10
+ * @returns 当前 ViewSchema 列表的共享响应式浅引用;调用方不应直接改写其值。
9
11
  *
10
12
  * @example
11
13
  * ```ts
@@ -16,5 +18,23 @@ import { SchemxInstance, SchemxViewSchema, Values } from '@schemx/core';
16
18
  * ```
17
19
  */
18
20
  export declare function useViewSchemas<TValues extends Values = Values>(form: SchemxInstance<TValues>): ShallowRef<readonly SchemxViewSchema<TValues>[]>;
21
+ /**
22
+ * 获取指定 key 的响应式 ViewSchema,并复用当前表单的共享订阅。
23
+ *
24
+ * @typeParam TValues - 表单值类型。
25
+ * @param form - 要读取的表单实例。
26
+ * @param getKey - 返回当前 schema key 的响应式 getter。
27
+ * @returns 对应的最新 ViewSchema;不存在时返回 undefined。
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const schema = useViewSchema(form, () => fieldKey)
32
+ *
33
+ * watchEffect(() => {
34
+ * console.log(schema.value?.label)
35
+ * })
36
+ * ```
37
+ */
38
+ export declare function useViewSchema<TValues extends Values = Values>(form: SchemxInstance<TValues>, getKey: () => string): ComputedRef<SchemxViewSchema<TValues> | undefined>;
19
39
  export default useViewSchemas;
20
40
  //# sourceMappingURL=useViewSchemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useViewSchemas.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewSchemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE5E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC5D,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,GAC5B,UAAU,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAYlD;AAED,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"useViewSchemas.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewSchemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAElD,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACZ,MAAM,cAAc,CAAA;AA+BrB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC5D,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,GAC5B,UAAU,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC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,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,EACvB,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACrC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,IAAI,CAAA;AACb;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,OAAO,SAAS,MAAM,EAC7C,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAC1B,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC,EACtC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,IAAI,CAAA;AA2Bb;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC3D,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,EACvB,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACrC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,IAAI,CAEZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,EACnD,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAC1B,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC,EACtC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,IAAI,CAEZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACzD,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,EACnC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,IAAI,CAEZ;AAED,eAAe,QAAQ,CAAA"}
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=Symbol("schemx:app-config"),a=Object.freeze({schemaConfig:Object.freeze({}),validatorAdapters:Object.freeze([])});function s(e,t={}){const r=function(e){const t=Object.freeze({...e.schemaConfig??{}}),r=Object.freeze([...e.validatorAdapters??[]]);return Object.freeze({schemaConfig:t,validatorAdapters:r,defaultRendererType:e.defaultRendererType,rendererRegistry:e.rendererRegistry,validationRuleRegistry:e.validationRuleRegistry})}(t);e.provide(o,r)}const l=r.createRendererRegistry("input"),i=r.createValidationRuleRegistry();function c(t={}){const n=r.mergeSchemxConfig(function(e){const{schemaConfig:t={},validatorAdapters:r=[],defaultRendererType:n,rendererRegistry:o,validationRuleRegistry:a,...s}=e;return{schemaConfig:t,defaultRendererType:n,rendererRegistry:o,validationRuleRegistry:a,validatorAdapters:r}}(t),null===e.getCurrentInstance()?a:e.inject(o,a),{rendererRegistry:l,validationRuleRegistry:i}),s={...t,...n},c=r.createForm(s);return e.onScopeDispose(()=>{c.destroy()}),c}const d=Symbol("schemx:instance");function u(t){e.provide(d,t)}function m(){const t=e.inject(d,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 p=new WeakMap;const h=t=>{const n=m(),o=t;let a=p.get(n);a||(a=new Map,p.set(n,a));const s=a.get(o);let l;if(s)s.refCount++,l=s;else{const{result:s,dispose:i}=function(t,n){const o=r.createField(t,n),a=e.shallowRef(o.getValue()),s=e.shallowRef(o.getErrors()),l=e.shallowRef(o.isPending()),i=o.effect(()=>{a.value=o.getValue(),s.value=o.getErrors(),l.value=o.isPending()}),c=e.computed(()=>s.value),d=e.computed(()=>(a.value,o.isTouched())),u=e.computed(()=>l.value);return{result:{name:n,value:a,errors:c,dirty:d,pending:u,...o,getValue:()=>a.value},dispose:i}}(n,t);l={refCount:1,result:s,dispose:i},a.set(o,l)}return e.onUnmounted(()=>{--l.refCount<=0&&(l.dispose(),a.delete(o))}),l.result},f=Symbol("schemx:field");function v(t){e.provide(f,t)}function y(){const t=e.inject(f);if(!t)throw new Error("[schemx] useFieldContext() must be called inside a component tree where createFieldContext(field) has been called.");return t}function g(t,n,o){const a=m(),s=r.createWatch(a,t,n,o);return e.onUnmounted(s),s}function b(e,t,r){return g(e,t,r)}function x(e){return e instanceof Error?e:new Error(String(e))}const C=(t,r)=>{var n;const o=m(),a=e.shallowRef([]),s=e.ref(!1),l=e.ref(void 0);let i=0;const c=async()=>{try{const e=o.getFieldsValue();if("function"==typeof t.shouldFetch&&!t.shouldFetch(e))return a.value=[],void(s.value=!1);s.value=!0,l.value=void 0;const r=++i,n=await(async e=>{const r=t.retryCount??0,n=t.retryInterval??1e3;let a=new Error("Unknown error");for(let l=0;l<=r;l++)try{return await t.api(e,o)}catch(s){a=x(s),l<r&&await new Promise(e=>setTimeout(e,n))}throw a})(e);if(r!==i)return;const c=await(async e=>{if("function"==typeof(null==t?void 0:t.formatter))return await t.formatter(e,o);if(!Array.isArray(e))throw new Error("[schemx] Dictionary api must return an array when formatter is not provided.");return e})(n);if(r!==i)return;a.value=c,l.value=void 0,"function"==typeof t.onSuccess&&t.onSuccess(c,o),s.value=!1}catch(e){const r=x(e);l.value=r,a.value=[],s.value=!1,"function"==typeof t.onError&&t.onError(r,o)}};(null==(n=t.dependsOn)?void 0:n.length)&&b(t.dependsOn,(e,n)=>{"function"==typeof t.onDepsChange&&t.onDepsChange(e,o),t.resetOnDepsChange&&r&&o.setFieldValue(r,void 0),c()});const d=t.immediate??!0;return e.onMounted(()=>{d&&c()}),{list:a,loading:s,error:l,loadDict:c,refresh:()=>c(),mutate:e=>{a.value=e}}},F=Symbol("schemx:form-config"),R=t=>{e.provide(F,t)};function w(){const t=e.inject(F);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 V(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 S(t){const r=e.shallowRef(t.getViewSchemas()),n=t.subscribeViewSchemas(e=>{r.value=e});return e.onScopeDispose(n),r}function A(e){return void 0!==e&&(!Array.isArray(e)||0!==e.length)}function _(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 k=e=>/[A-Z]/.test(e),O=e=>e.includes("-"),j=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),E=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),B=(e,t)=>{if(e[t])return e[t];const r=k(t)?j(t):O(t)?E(t):void 0;return r&&e[r]?e[r]:void 0},N=(e,t)=>{const r={},n=(o=String(e),(O(o)?E(o):o)+":");var o;const a=(e=>k(e)?j(e):e)(String(e))+":";for(const[s,l]of Object.entries(t))s.startsWith(n)?r[s.slice(n.length)]=l:s.startsWith(a)&&a!==n&&(r[s.slice(a.length)]=l);return r},T=e.defineComponent((r,{slots:n})=>{var o;const a=e.ref(Boolean(r.schema.defaultCollapsed)),s=e.computed(()=>r.schema.collapsed??a.value),l=(null==(o=e.getCurrentInstance())?void 0:o.uid)??0;e.watch(()=>r.schema.collapsed,(e,t)=>{void 0!==e?a.value=e:void 0!==t&&(a.value=t)});const i=()=>{var e,t;if(!r.schema.collapsible||r.schema.disabled)return;const n=!s.value;void 0===r.schema.collapsed&&(a.value=n),null==(t=(e=r.schema).onCollapsedChange)||t.call(e,n)};return()=>{var o;const a=r.schema;if(!1===a.visible)return null;const c=Boolean(a.collapsible),d=s.value,u=a.destroyOnCollapse??!0,m=`schemx-group-${(null==(o=a.debug)?void 0:o.runtimeNodeId)??`local-${l}`}-${P(a.key)}`,p=`${m}-header`,h=`${m}-body`,f=e.createVNode("div",{id:h,role:"group","aria-labelledby":a.label?p:void 0,"aria-hidden":d||void 0,class:"schemx-group__body",style:!u&&d?{display:"none"}:void 0},[a.children.map(t=>e.createVNode(W,{key:t.key,schema:t},n))]);return e.createVNode("div",{class:t("schemx-group",{"schemx-group--collapsed":d,"is-readonly":a.readonly,"is-disabled":a.disabled},a.class),style:a.style,"data-key":a.key,"aria-disabled":a.disabled||void 0},[a.label&&e.createVNode("div",{id:p,role:c?"button":void 0,tabindex:c?a.disabled?-1:0:void 0,"aria-expanded":c?!d:void 0,"aria-controls":c?h:void 0,"aria-disabled":c&&a.disabled||void 0,class:t("schemx-group__header",{"schemx-group__header--clickable":c&&!a.disabled}),onClick:i,onKeydown:e=>{a.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())}},[e.createVNode("span",{class:"schemx-group__title"},[a.label]),c&&e.createVNode("span",{class:t("schemx-group__arrow",{"schemx-group__arrow--down":!d})},null)]),u?!d&&f:f])}},{name:"SchemxGroup",props:{schema:{type:Object,required:!0}}}),P=e=>String(e).replace(/[^a-zA-Z0-9_-]/g,"-"),W=e.defineComponent({name:"SchemxItem",props:{schema:{type:Object,required:!0}},setup:(t,{slots:r})=>()=>{const n=t.schema;return q(n)?e.h(T,{schema:n},r):e.h($,{schema:n},r)}}),$=e.defineComponent({name:"SchemxFieldItem",props:{schema:{type:Object,required:!0}},setup(r,{slots:n}){const o=e.toRef(r,"schema"),a=m(),s=w(),l=()=>o.value,i=h(l().name);v(i);const c=e.computed(()=>{return e=l().validationTrigger,t=s.schemaConfig.validationTrigger,r="onChange",A(e)?e:A(t)?t:r;var e,t,r}),d=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&&(Boolean(l().required)||r)}),u=e=>{var t,r;i.setValue(e),null==(r=null==(t=l().componentProps)?void 0:t.onChange)||r.call(t,e),d.value&&_("change",c.value)&&i.validate()},p=e=>{var t,r;null==(r=null==(t=l().componentProps)?void 0:t.onBlur)||r.call(t,e),d.value&&_("blur",c.value)&&i.validate()},f=V(()=>{const e=l();return{...e.componentProps,readonly:e.readonly,disabled:e.disabled,placeholder:e.placeholder,formItemProps:e,value:i.getValue(),onChange:u,onBlur:p,"onUpdate:value":e=>i.setValue(e)}}),y=()=>{const t=B(n,`${l().name}Label`);if(t)return t(l());const r=l().labelAlign||s.schemaConfig.labelAlign,o=l().labelWidth||s.schemaConfig.labelWidth,a=l().colon??s.schemaConfig.colon;return e.createVNode("label",{class:"schemx-item__label",style:{width:o,textAlign:r}},[!(l().showRequiredMark??Boolean(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,a?":":""])])},g=()=>{const t=a.getRenderer(l().componentType);if(!t)throw new Error(`[schemx] Can not find component renderer of "${l().componentType}".`);const r=N(z(l().name),n),o=e.h(t,f.value,r),s=B(n,`${l().name}Content`);return s?s({...l(),columnElement:o}):e.createVNode("div",{class:"schemx-item__control"},[o])},b=()=>{const t=B(n,`${l().name}Error`);return t?t({...l(),errors:i.errors.value}):0===i.errors.value.length?null:e.createVNode("div",{class:"schemx-item__error"},[i.errors.value[0]])};return()=>{if(!l().visible)return null;const r=B(n,z(l().name));if(r)return r(l());const o=l().labelPosition||s.schemaConfig.labelPosition;return e.createVNode("div",{class:t("schemx-item-wrapper"),style:l().style},[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(),b()])])])}}}),q=e=>"children"in e,z=e=>Array.isArray(e)?e.map(e=>String(e)).join("."):String(e);function I(e){return!!e&&"children"in e}function D(e){return!!e&&!I(e)&&!1!==e.visible}function L(e,t,r){for(let n=t+r;n>=0&&n<e.length;n+=r){const t=e[n];if(!1!==t.visible){if(I(t))return!1;if(D(t))return!0}}return!1}const M=e.defineComponent({name:"SchemxForm",__name:"form",props:{schemas:{default:()=>[]},initialValues:{default:()=>({})},modelValue:{default:()=>({})},form:{default:void 0},class:{default:""},style:{type:[Boolean,null,String,Object,Array],default:()=>({})},validatorAdapters:{},defaultRendererType:{},rendererRegistry:{default:void 0},validationRuleRegistry:{default:void 0},onRuleError:{},onFinish:{type:Function,default:void 0},onFinishFailed:{type:Function,default:void 0},onValuesChange:{type:Function,default:void 0},onFieldsChange:{type:Function,default:void 0},lifecycleHooks:{},required:{type:[Boolean,Object]},readonly:{type:Boolean},disabled:{type:Boolean},visible:{type:Boolean,default:!0},labelIcon:{},labelAlign:{},labelPosition:{},labelWidth:{},contentAlign:{},validationTrigger:{},colon:{type:Boolean},showRequiredMark:{type:Boolean}},emits:["update:modelValue"],setup(t,{expose:o,emit:a}){const s=t,l=a,i=()=>n.pick(s,r.defaultSchemxConfigKeys),d=e.reactive(i());R({schemaConfig:d});const m=s.form?s.form:c({schemas:s.schemas,schemaConfig:i(),initialValues:Object.keys(s.modelValue).length>0?s.modelValue:s.initialValues,rendererRegistry:s.rendererRegistry,defaultRendererType:s.defaultRendererType,validationRuleRegistry:s.validationRuleRegistry,validatorAdapters:s.validatorAdapters,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;null==(r=s.onValuesChange)||r.call(s,e,t)},onFieldsChange:(e,t)=>{var r;null==(r=s.onFieldsChange)||r.call(s,e,t)}});u(m);let p=!1;e.watch(()=>s.modelValue,e=>{p=!0,m.setFieldsValue(e),p=!1});const h=r.createWatch(m,e=>{p||l("update:modelValue",e)});e.onUnmounted(h),e.watch(()=>s.schemas,e=>{r.isSchemxSchemas(e)||m.setSchemas(e)},{deep:!1,immediate:!!s.form});const f=S(m),v=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}:D(e[r])?{found:!0,isFirst:!L(e,r,-1),isLast:!L(e,r,1)}:{found:!0,isFirst:!1,isLast:!1}}(f.value,e.key);return{"schemx-item-wrapper--first":t,"schemx-item-wrapper--last":r}};return e.watchEffect(()=>{const e=i();Object.assign(d,e),m.updateSchemaConfig(e)}),o({...m}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["schemx",s.class]),style:e.normalizeStyle(s.style)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f),r=>(e.openBlock(),e.createBlock(e.unref(W),{key:r.key,schema:r,class:e.normalizeClass(v(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))],6))}});const U=(Z=M,G={install(e,t={}){s(e,t),e.component("SchemxForm",M)},FormItem:W},Object.assign(Z,G));var Z,G;exports.FormGroup=T,exports.FormItem=W,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 a=r.fieldName??(r.dict?y().name:void 0),s=r.dict?C(r.dict,a):null,l=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,l.value,o)}})},exports.createFieldContext=v,exports.createFormConfigContext=R,exports.createFormContext=u,exports.default=U,exports.rendererRegistry=l,exports.schemxForm=U,exports.useDictionary=C,exports.useEffect=function(t){const n=r.createEffect(t);return e.onUnmounted(n),n},exports.useField=h,exports.useFieldContext=y,exports.useForm=c,exports.useFormConfigContext=w,exports.useFormContext=m,exports.useStableRef=V,exports.useViewSchemas=S,exports.useWatch=g,exports.useWatchAll=function(e,t){return g(e,t)},exports.useWatchField=function(e,t,r){return g(e,t,r)},exports.useWatchFields=b,exports.validationRuleRegistry=i,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("@schemx/core"),r=require("classnames"),o=require("@schemx/core/adapter"),n=require("es-toolkit"),a=Symbol("schemx:app-config"),l=Object.freeze({schemaConfig:Object.freeze({}),validatorAdapters:Object.freeze([])});function s(e){if(void 0===e)return;const t=Object.entries(e).map(([e,t])=>[e,void 0===t?void 0:Object.freeze({...t})]);return Object.freeze(Object.fromEntries(t))}function i(e,t={}){const r=function(e){const t=Object.freeze({...e.schemaConfig??{}}),r=Object.freeze([...e.validatorAdapters??[]]);return Object.freeze({schemaConfig:t,rendererProps:s(e.rendererProps),validatorAdapters:r,defaultRendererType:e.defaultRendererType,rendererRegistry:e.rendererRegistry,validationRuleRegistry:e.validationRuleRegistry})}(t);e.provide(a,r)}const u=new WeakMap,d=new WeakMap,c=new WeakMap;function m(t){return e.shallowRef(t)}function p(e){return c.get(e)??e}function v(e){const t=p(e),r=u.get(t);if(r)return r;const n=function(e){const t=o.createFormExternalStore(e),r=m(t.values.getSnapshot()),n=m(t.touchedFields.getSnapshot()),a=m(t.pendingFields.getSnapshot()),l=m(t.loading.getSnapshot()),s=new Map,i=()=>{r.value=t.values.getSnapshot()},u=()=>{n.value=t.touchedFields.getSnapshot()},d=()=>{a.value=t.pendingFields.getSnapshot()},c=()=>{l.value=t.loading.getSnapshot()},p=t.values.subscribe(i),v=t.touchedFields.subscribe(u),h=t.pendingFields.subscribe(d),g=t.loading.subscribe(c),y=()=>{p(),v(),h(),g()},b=f(e),x={form:e,externalStore:t,values:r,touchedFields:n,pendingFields:a,loading:l,fieldBridges:s,refCount:0,destroyed:!1,unsubscribe:y,facade:b};return x}(t);return u.set(t,n),n}function f(e){const t=p(e),r=d.get(t);if(r)return r;const o=function(e){let t=!1;const r=r=>{if(!t){g(v(e),r).value.value}return e.getFieldValue(r)},o=r=>{if(!t){g(v(e),r).errors.value}return e.getFieldErrors(r)},n=r=>{if(!t){g(v(e),r).touched.value}return e.isFieldTouched(r)},a=r=>{if(!t){g(v(e),r).pending.value}return e.isFieldPending(r)},l=r=>{if(!t){const t=v(e);if(void 0===r)t.values.value;else for(const e of r)g(t,e).value.value}return e.getFieldsValue(r)},s=()=>{if(!t){v(e).touchedFields.value}return e.getTouchedFields()},i=()=>{if(!t){v(e).pendingFields.value}return e.getPendingFields()},d=()=>{if(!t){v(e).loading.value}return e.isLoading()},c=()=>{if(t)return;t=!0;const r=u.get(e);r&&y(r),e.destroy()};return{...e,getFieldValue:r,getFieldErrors:o,isFieldTouched:n,isFieldPending:a,getFieldsValue:l,getTouchedFields:s,getPendingFields:i,isLoading:d,destroy:c}}(t);return d.set(t,o),c.set(o,t),o}function h(e){if(e.destroyed)return()=>{};e.refCount++;let t=!1;return()=>{t||e.destroyed||(t=!0,e.refCount--,0===e.refCount&&y(e))}}function g(e,t){const r=e.externalStore.field(t),o=e.fieldBridges.get(r);if(o)return o;const n=r.getSnapshot(),a=m(n.value),l=m(n.errors),s=m(n.touched),i=m(n.pending),u=r.subscribe(()=>{const e=r.getSnapshot();var t,o;Object.is(a.value,e.value)||(a.value=e.value),t=l.value,o=e.errors,t.length===o.length&&t.every((e,t)=>e===o[t])||(l.value=e.errors),s.value!==e.touched&&(s.value=e.touched),i.value!==e.pending&&(i.value=e.pending)}),d={store:r,value:a,errors:l,touched:s,pending:i,dispose:()=>{u()}};return e.fieldBridges.set(r,d),d}function y(e){if(!e.destroyed){e.destroyed=!0,e.refCount=0,e.unsubscribe();for(const t of e.fieldBridges.values())t.dispose();e.fieldBridges.clear(),e.externalStore.dispose(),u.delete(e.form)}}const b=o.createRendererRegistry("input"),x=t.createValidationRuleRegistry();function C(r={}){const o=t.mergeSchemxConfig(function(e){const{schemaConfig:t={},rendererProps:r,validatorAdapters:o=[],defaultRendererType:n,rendererRegistry:a,validationRuleRegistry:l}=e;return{schemaConfig:t,rendererProps:r,defaultRendererType:n,rendererRegistry:a,validationRuleRegistry:l,validatorAdapters:o}}(r),null===e.getCurrentInstance()?l:e.inject(a,l),{rendererRegistry:b,validationRuleRegistry:x}),n={...r,...o},s=t.createForm(n),i=f(s),u=h(v(s));return e.onScopeDispose(()=>{u(),i.destroy()}),i}const F=Symbol("schemx:instance");function S(t){const r=f(t),o=h(v(r));return e.provide(F,r),e.onScopeDispose(o),r}function w(){const t=e.inject(F,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 k=r=>{const o=w();return function(r,o,n){const a=p(r),l=t.createField(a,o),s=e.computed(()=>n.errors.value),i=e.computed(()=>n.touched.value),u=e.computed(()=>n.pending.value);return{...l,name:o,value:n.value,errors:s,dirty:i,pending:u,getValue:()=>n.value.value,getErrors:()=>n.errors.value,isTouched:()=>n.touched.value,isPending:()=>n.pending.value,getValues:()=>r.getFieldsValue()}}(o,r,g(v(p(o)),r))},V=Symbol("schemx:field");function B(t){e.provide(V,t)}function R(){const t=e.inject(V);if(!t)throw new Error("[schemx] useFieldContext() must be called inside a component tree where createFieldContext(field) has been called.");return t}function O(r,o,n){const a=w(),l=t.createWatch(p(a),r,o,n);return e.onUnmounted(l),l}function _(e,t,r){return O(e,t,r)}function j(e){return e instanceof Error?e:new Error(String(e))}const A=(t,r)=>{var o;const n=w(),a=e.shallowRef([]),l=e.ref(!1),s=e.ref(void 0);let i=0;const u=async()=>{try{const e=n.getFieldsValue();if("function"==typeof t.shouldFetch&&!t.shouldFetch(e))return a.value=[],void(l.value=!1);l.value=!0,s.value=void 0;const r=++i,o=await(async e=>{const r=t.retryCount??0,o=t.retryInterval??1e3;let a=new Error("Unknown error");for(let s=0;s<=r;s++)try{return await t.api(e,n)}catch(l){a=j(l),s<r&&await new Promise(e=>setTimeout(e,o))}throw a})(e);if(r!==i)return;const u=await(async e=>{if("function"==typeof(null==t?void 0:t.formatter))return await t.formatter(e,n);if(!Array.isArray(e))throw new Error("[schemx] Dictionary api must return an array when formatter is not provided.");return e})(o);if(r!==i)return;a.value=u,s.value=void 0,"function"==typeof t.onSuccess&&t.onSuccess(u,n),l.value=!1}catch(e){const r=j(e);s.value=r,a.value=[],l.value=!1,"function"==typeof t.onError&&t.onError(r,n)}};(null==(o=t.dependsOn)?void 0:o.length)&&_(t.dependsOn,(e,o)=>{"function"==typeof t.onDepsChange&&t.onDepsChange(e,n),t.resetOnDepsChange&&r&&n.setFieldValue(r,void 0),u()});const d=t.immediate??!0;return e.onMounted(()=>{d&&u()}),{list:a,loading:l,error:s,loadDict:u,refresh:()=>u(),mutate:e=>{a.value=e}}},E=Symbol("schemx:form-config"),P=t=>{e.provide(E,t)};function N(){const t=e.inject(E);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 T(t){const r=e.shallowRef({});return e.watchEffect(()=>{const e=t();((e,t)=>{const r=Object.keys(e),o=Object.keys(t);return r.length===o.length&&r.every(r=>e[r]===t[r])})(r.value,e)||(r.value=e)}),r}const $=new WeakMap;function L(e){return q(p(e)).viewSchemas}function W(r){const o=e.shallowRef(r.getViewSchemas()),n=e.computed(()=>function(e){const r=new Map,o=e=>{for(const n of e)r.set(n.key,n),t.isViewGroupSchema(n)&&o(n.children)};return o(e),r}(o.value));return{refCount:0,schemasByKey:n,unsubscribe:r.subscribeViewSchemas(e=>{o.value=e}),viewSchemas:o}}function q(t){const r=$.get(t),o=r??W(t);return r||$.set(t,o),o.refCount++,e.onScopeDispose(()=>{o.refCount--,o.refCount>0||(o.unsubscribe(),$.delete(t))}),o}function z(t,r,o={}){const n=v(p(t)),a=h(n),l=e.shallowRef(r(n.values.value)),s=o.equals??Object.is,i=e.watch(n.values,e=>{const t=r(e);s(l.value,t)||(l.value=t)},{flush:"sync"});return e.onScopeDispose(()=>{i(),a()}),e.readonly(l)}function M(e){return void 0!==e&&(!Array.isArray(e)||0!==e.length)}function D(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 I=e=>/[A-Z]/.test(e),G=e=>e.includes("-"),K=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),U=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),Z=(e,t)=>{if(e[t])return e[t];const r=I(t)?K(t):G(t)?U(t):void 0;return r&&e[r]?e[r]:void 0},H=(e,t)=>{const r={},o=(n=String(e),(G(n)?U(n):n)+":");var n;const a=(e=>I(e)?K(e):e)(String(e))+":";for(const[l,s]of Object.entries(t))l.startsWith(o)?r[l.slice(o.length)]=s:l.startsWith(a)&&a!==o&&(r[l.slice(a.length)]=s);return r},J=e.defineComponent((t,{slots:o})=>{var n;const a=e.ref(Boolean(t.schema.defaultCollapsed)),l=e.computed(()=>t.schema.collapsed??a.value),s=(null==(n=e.getCurrentInstance())?void 0:n.uid)??0;e.watch(()=>t.schema.collapsed,(e,t)=>{void 0!==e?a.value=e:void 0!==t&&(a.value=t)});const i=()=>{var e,r;if(!t.schema.collapsible||t.schema.disabled)return;const o=!l.value;void 0===t.schema.collapsed&&(a.value=o),null==(r=(e=t.schema).onCollapsedChange)||r.call(e,o)};return()=>{var n;const a=t.schema;if(!1===a.visible)return null;const u=Boolean(a.collapsible),d=l.value,c=a.destroyOnCollapse??!0,m=`schemx-group-${(null==(n=a.debug)?void 0:n.runtimeNodeId)??`local-${s}`}-${Q(a.key)}`,p=`${m}-header`,v=`${m}-body`,f=e.createVNode("div",{id:v,role:"group","aria-labelledby":a.label?p:void 0,"aria-hidden":d||void 0,class:"schemx-group__body",style:!c&&d?{display:"none"}:void 0},[a.children.map(t=>e.createVNode(te,{key:t.key,schema:t},o))]);return e.createVNode("div",{class:r("schemx-group",{"schemx-group--collapsed":d,"is-readonly":a.readonly,"is-disabled":a.disabled},a.class),style:a.style,"data-key":a.key,"aria-disabled":a.disabled||void 0},[a.label&&e.createVNode("div",{id:p,role:u?"button":void 0,tabindex:u?a.disabled?-1:0:void 0,"aria-expanded":u?!d:void 0,"aria-controls":u?v:void 0,"aria-disabled":u&&a.disabled||void 0,class:r("schemx-group__header",{"schemx-group__header--clickable":u&&!a.disabled}),onClick:i,onKeydown:e=>{a.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())}},[e.createVNode("span",{class:"schemx-group__title"},[a.label]),u&&e.createVNode("span",{class:r("schemx-group__arrow",{"schemx-group__arrow--down":!d})},null)]),c?!d&&f:f])}},{name:"SchemxGroup",props:{schema:{type:Object,required:!0}}}),Q=e=>String(e).replace(/[^a-zA-Z0-9_-]/g,"-");function X(e){return Array.isArray(e)?e.map(e=>String(e)).join("."):String(e)}const Y=e.defineComponent({name:"SchemxItem",props:{schema:{type:Object,required:!0}},setup:(r,{slots:o})=>()=>{const n=r.schema;return t.isViewGroupSchema(n)?e.h(J,{schema:n},o):e.h(ee,{schema:n},o)}}),ee=e.defineComponent({name:"SchemxFieldItem",inheritAttrs:!1,props:{schema:{type:Object,required:!0}},setup(o,{attrs:n,slots:a}){const l=w(),s=e.computed(()=>o.schema),i=function(t,r){const o=q(p(t));return e.computed(()=>o.schemasByKey.value.get(r()))}(l,()=>s.value.key),u=e.computed(()=>i.value&&t.isSchemxViewFieldSchema(i.value)?i.value:s.value),d=N(),c=k(u.value.name);B(c);const m=e.computed(()=>{return e=u.value.validationTrigger,t=d.schemaConfig.validationTrigger,r="onChange",M(e)?e:M(t)?t:r;var e,t,r}),v=e.computed(()=>{const e=u.value.visible&&!u.value.readonly&&!u.value.disabled,t=u.value.rules,r=Array.isArray(t)?(null==t?void 0:t.length)>0:!!u.value.rules;return e&&(Boolean(u.value.required)||r)}),f=e=>{var t,r;c.setValue(e),null==(r=null==(t=u.value.componentProps)?void 0:t.onChange)||r.call(t,e),v.value&&D("change",m.value)&&c.validate()},h=e=>{var t,r;null==(r=null==(t=u.value.componentProps)?void 0:t.onBlur)||r.call(t,e),v.value&&D("blur",m.value)&&c.validate()},g=e=>{c.setValue(e)},y=T(()=>({...u.value.componentProps??{},value:c.value.value,onChange:f,onBlur:h,"onUpdate:value":g})),{createSlotProps:b,renderAfter:x,renderBefore:C,renderContent:F,renderError:S,renderLabel:V}=function(t){const{schemaRef:r,field:o,form:n,formContext:a,componentProps:l,slots:s}=t,i=(e={})=>({...l.value,value:o.value.value,...e}),u=e=>{const t=Z(s,`${r.value.name}${e}`);return(null==t?void 0:t(i()))??null};return{createSlotProps:i,renderAfter:()=>u("After"),renderBefore:()=>u("Before"),renderContent:()=>{const t=n.getRenderer(r.value.componentType);if(!t)throw new Error(`[schemx] Can not find component renderer of "${r.value.componentType}".`);const o=H(X(r.value.name),s),a=e.h(t,l.value,o),u=Z(s,`${r.value.name}Content`);return u?u(i({columnElement:a})):e.createVNode("div",{class:"schemx-item__control"},[a])},renderError:()=>{const t=Z(s,`${r.value.name}Error`);return t?t(i({errors:o.errors.value})):0===o.errors.value.length?null:e.createVNode("div",{class:"schemx-item__error"},[o.errors.value[0]])},renderLabel:()=>{const t=Z(s,`${r.value.name}Label`);if(t)return t(r.value);const o=r.value.labelAlign||a.schemaConfig.labelAlign,n=r.value.labelWidth||a.schemaConfig.labelWidth,l=r.value.colon??a.schemaConfig.colon;return e.createVNode("label",{class:"schemx-item__label",style:{width:n,textAlign:o}},[!(r.value.showRequiredMark??Boolean(r.value.required))||r.value.disabled||r.value.readonly?null:e.createVNode("span",{class:"schemx-item__required"},[e.createTextVNode("*")]),e.createVNode("span",{class:"schemx-item__label-text"},[r.value.label,l?":":""])])}}}({schemaRef:u,field:c,form:l,formContext:d,componentProps:y,slots:a});return()=>{if(!u.value.visible)return null;const t=Z(a,X(u.value.name));if(t)return t(b());const o=u.value.labelPosition||d.schemaConfig.labelPosition;return e.createVNode("div",e.mergeProps(n,{class:r("schemx-item-wrapper",n.class),style:[n.style,u.value.style]}),[e.createVNode("div",{class:r("schemx-item",`schemx-item--label-${o}`,u.value.class,{"is-readonly":u.value.readonly,"is-disabled":u.value.disabled}),style:{...u.value.style??{}}},[V(),e.createVNode("div",{class:"schemx-item__content"},[C(),F(),x(),S()])])])}}}),te=Y,re=["aria-busy","data-loading","disabled"],oe={key:0,class:"schemx-button__prefix"},ne={key:1,class:"schemx-button__loading",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},ae={key:4,class:"schemx-button__suffix"},le=e.defineComponent({name:"SchemxButton",inheritAttrs:!1,__name:"index",props:{loading:{type:Boolean,default:!1},loadingText:{default:void 0},disabled:{type:Boolean,default:!1},size:{default:"medium"}},setup(t){const r=t,o=e.useAttrs(),n=e.computed(()=>r.disabled||r.loading),a=e.computed(()=>["schemx-button",`schemx-button--${r.size}`]);return(t,l)=>(e.openBlock(),e.createElementBlock("button",e.mergeProps(e.unref(o),{class:a.value,"aria-busy":r.loading||void 0,"data-loading":r.loading||void 0,disabled:n.value}),[t.$slots.prefix?(e.openBlock(),e.createElementBlock("span",oe,[e.renderSlot(t.$slots,"prefix")])):e.createCommentVNode("",!0),r.loading?(e.openBlock(),e.createElementBlock("svg",ne,[...l[0]||(l[0]=[e.createStaticVNode('<path d="M12 2v4"></path><path d="m16.2 7.8 2.9-2.9"></path><path d="M18 12h4"></path><path d="m16.2 16.2 2.9 2.9"></path><path d="M12 18v4"></path><path d="m4.9 19.1 2.9-2.9"></path><path d="M2 12h4"></path><path d="m4.9 4.9 2.9 2.9"></path>',8)])])):e.createCommentVNode("",!0),r.loading&&r.loadingText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(r.loadingText),1)],64)):e.renderSlot(t.$slots,"default",{},void 0,void 0,3),t.$slots.suffix?(e.openBlock(),e.createElementBlock("span",ae,[e.renderSlot(t.$slots,"suffix")])):e.createCommentVNode("",!0)],16,re))}});function se(e){return!!e&&!t.isViewGroupSchema(e)&&!1!==e.visible}function ie(e,r,o){for(let n=r+o;n>=0&&n<e.length;n+=o){const r=e[n];if(!1!==r.visible){if(t.isViewGroupSchema(r))return!1;if(se(r))return!0}}return!1}const ue={key:0,class:"schemx-actions"},de=e.defineComponent({name:"SchemxForm",__name:"form",props:{schemas:{default:()=>[]},initialValues:{default:()=>({})},modelValue:{default:()=>({})},form:{default:void 0},loading:{type:Boolean,default:void 0},submitter:{type:[Boolean,Object],default:!0},resetter:{type:[Boolean,Object],default:!0},class:{default:""},style:{type:[Boolean,null,String,Object,Array],default:()=>({})},rendererProps:{default:void 0},validatorAdapters:{},defaultRendererType:{},rendererRegistry:{default:void 0},validationRuleRegistry:{default:void 0},onRuleError:{},onFinish:{type:Function,default:void 0},onFinishFailed:{type:Function,default:void 0},onReset:{type:Function,default:void 0},onLoadingChange:{type:Function,default:void 0},onValuesChange:{type:Function,default:void 0},onFieldsChange:{type:Function,default:void 0},lifecycleHooks:{},required:{type:[Boolean,Object]},readonly:{type:Boolean},disabled:{type:Boolean},visible:{type:Boolean,default:!0},labelIcon:{},labelAlign:{},labelPosition:{},labelWidth:{},contentAlign:{},validationTrigger:{},colon:{type:Boolean},showRequiredMark:{type:Boolean}},emits:["update:modelValue"],setup(r,{expose:o,emit:a}){const l=r,s=a,i=e.useSlots(),u=()=>n.pick(l,t.defaultSchemxConfigKeys),d=e.reactive(u());P({schemaConfig:d});const c=l.form?l.form:C({schemas:l.schemas,schemaConfig:u(),initialValues:Object.keys(l.modelValue).length>0?l.modelValue:l.initialValues,rendererProps:l.rendererProps,rendererRegistry:l.rendererRegistry,defaultRendererType:l.defaultRendererType,validationRuleRegistry:l.validationRuleRegistry,validatorAdapters:l.validatorAdapters,onFinish:e=>{var t;return null==(t=l.onFinish)?void 0:t.call(l,e)},onFinishFailed:e=>{var t;return null==(t=l.onFinishFailed)?void 0:t.call(l,e)},onReset:()=>{var e;null==(e=l.onReset)||e.call(l)},onLoadingChange:e=>{var t;null==(t=l.onLoadingChange)||t.call(l,e)},onValuesChange:(e,t)=>{var r;null==(r=l.onValuesChange)||r.call(l,e,t)},onFieldsChange:(e,t)=>{var r;null==(r=l.onFieldsChange)||r.call(l,e,t)}}),m=void 0!==l.form,p=S(c),v=e.computed(()=>l.loading??p.isLoading()),f=e=>!0===e?{}:e||{},h=e.computed(()=>f(l.submitter)),g=e.computed(()=>f(l.resetter)),y=e=>Object.fromEntries(Object.entries(e.buttonProps??{}).filter(([e])=>"type"!==e&&"onClick"!==e)),b=e.computed(()=>y(h.value)),x=e.computed(()=>y(g.value)),F=e.computed(()=>!1!==l.submitter&&(void 0!==l.submitter||i.submitter)),w=e.computed(()=>!1!==l.resetter&&(void 0!==l.resetter||i.resetter)),k=e.computed(()=>F.value||w.value),V=e.computed(()=>Object.fromEntries(Object.entries(i).filter(([e])=>"submitter"!==e&&"resetter"!==e))),B=e.computed(()=>v.value||Boolean(b.value.disabled)),R=e.computed(()=>v.value||Boolean(x.value.disabled));let O=!1;e.watch(()=>l.modelValue,e=>{O=!0,p.setFieldsValue(e),O=!1},{deep:!0});const _=()=>p.submit(),j=()=>{p.reset()},A=z(p,e=>e);e.watch(A,e=>{O||s("update:modelValue",e)},{flush:"sync"}),e.watch(()=>l.schemas,e=>{t.isSchemxSchemas(e)||p.setSchemas(e)},{deep:!1,immediate:!!l.form});const E=L(p),N=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}:se(e[r])?{found:!0,isFirst:!ie(e,r,-1),isLast:!ie(e,r,1)}:{found:!0,isFirst:!1,isLast:!1}}(E.value,e.key);return{"schemx-item-wrapper--first":t,"schemx-item-wrapper--last":r}};return e.watch(u,e=>{Object.assign(d,e),p.updateSchemaConfig(e)},{deep:!1,immediate:m}),o({...p,submit:_,reset:j}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["schemx",l.class]),style:e.normalizeStyle(l.style)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),r=>(e.openBlock(),e.createBlock(e.unref(te),{key:r.key,schema:r,class:e.normalizeClass(N(r))},e.createSlots({_:2},[e.renderList(V.value,(r,o)=>({name:o,fn:e.withCtx(r=>[e.renderSlot(t.$slots,o,e.mergeProps({ref_for:!0},r??{}))])}))]),1032,["schema","class"]))),128)),k.value?(e.openBlock(),e.createElementBlock("div",ue,[w.value&&e.unref(i).resetter?e.renderSlot(t.$slots,"resetter",{form:e.unref(p),loading:v.value,disabled:R.value,reset:j},void 0,void 0,0):w.value?(e.openBlock(),e.createBlock(e.unref(le),e.mergeProps({key:1},x.value,{class:"schemx-actions-button schemx-actions-button--reset",type:"button",disabled:R.value,onClick:j}),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.value.text??"重置"),1)]),_:1},16,["disabled"])):e.createCommentVNode("",!0),F.value&&e.unref(i).submitter?e.renderSlot(t.$slots,"submitter",{form:e.unref(p),loading:v.value,disabled:B.value,submit:_},void 0,void 0,2):F.value?(e.openBlock(),e.createBlock(e.unref(le),e.mergeProps({key:3},b.value,{class:"schemx-actions-button schemx-actions-button--submit",type:"button",loading:v.value,disabled:B.value,onClick:_}),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.value.text??"提交"),1)]),_:1},16,["loading","disabled"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],6))}});var ce,me;const pe=(ce=de,me={install(e,t={}){i(e,t),e.component("SchemxForm",de)},FormItem:te},Object.assign(ce,me));exports.Button=le,exports.FormGroup=J,exports.FormItem=te,exports.WithRemoteOptions=function(t){return e.defineComponent({name:`WithRemoteOptions(${t.name||"Anonymous"})`,inheritAttrs:!1,props:{dict:{type:[Object,Function],default:void 0}},setup(r,{attrs:o,slots:n}){const a=function(e){return"function"==typeof e?{api:e}:e}(r.dict),l=a?o.fieldName??R().name:void 0,s=a?A(a,l):null,i=e.computed(()=>({...o,dict:a,options:a?null==s?void 0:s.list.value:o.options,loading:a?null==s?void 0:s.loading.value:o.loading}));return()=>e.h(t,i.value,n)}})},exports.createFieldContext=B,exports.createFormConfigContext=P,exports.createFormContext=S,exports.default=pe,exports.getCoreForm=p,exports.rendererRegistry=b,exports.schemxForm=pe,exports.useDictionary=A,exports.useField=k,exports.useFieldContext=R,exports.useForm=C,exports.useFormConfigContext=N,exports.useFormContext=w,exports.useFormSelector=z,exports.useStableRef=T,exports.useViewSchemas=L,exports.useWatch=O,exports.useWatchAll=function(e,t){return O(e,t)},exports.useWatchField=function(e,t,r){return O(e,t,r)},exports.useWatchFields=_,exports.validationRuleRegistry=x,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
2
2
  //# sourceMappingURL=index.cjs.map