@aplus-frontend/ui 0.3.10 → 0.3.12

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 (63) hide show
  1. package/es/index.mjs +231 -227
  2. package/es/src/ap-form/ap-form.vue.d.ts +13 -34
  3. package/es/src/ap-form/ap-form.vue2.mjs +143 -120
  4. package/es/src/ap-form/drawer-form/index.vue.d.ts +22 -40
  5. package/es/src/ap-form/drawer-form/index.vue.mjs +3 -3
  6. package/es/src/ap-form/index.d.ts +3 -1
  7. package/es/src/ap-form/index.mjs +26 -22
  8. package/es/src/ap-form/interface.d.ts +3 -1
  9. package/es/src/ap-form/modal-form/index.vue.d.ts +23 -41
  10. package/es/src/ap-form/modal-form/index.vue.mjs +64 -58
  11. package/es/src/ap-form/provider/context.d.ts +3 -0
  12. package/es/src/ap-form/provider/context.mjs +17 -0
  13. package/es/src/ap-form/provider/index.vue.d.ts +19 -0
  14. package/es/src/ap-form/provider/index.vue.mjs +39 -0
  15. package/es/src/ap-form/provider/index.vue2.mjs +4 -0
  16. package/es/src/ap-form/provider/interface.d.ts +22 -0
  17. package/es/src/ap-form/search-form/index.vue.d.ts +22 -40
  18. package/es/src/business/ap-select-layout/select-layout.vue2.mjs +33 -29
  19. package/es/src/business/ap-table-modal/interface.d.ts +2 -0
  20. package/es/src/business/ap-table-modal/table-modal.vue2.mjs +50 -48
  21. package/es/src/config-provider/config-provider-props.d.ts +0 -2
  22. package/es/src/config-provider/config-provider-props.mjs +2 -4
  23. package/es/src/config-provider/config-provider.d.ts +0 -6
  24. package/es/src/config-provider/config-provider.mjs +26 -25
  25. package/es/src/config-provider/constants.d.ts +2 -0
  26. package/es/src/config-provider/constants.mjs +3 -1
  27. package/es/src/config-provider/hooks/use-global-config.d.ts +0 -2
  28. package/es/src/config-provider/index.d.ts +0 -12
  29. package/es/src/config-provider/index.mjs +17 -15
  30. package/es/src/index.mjs +210 -206
  31. package/es/src/utils/slot.mjs +6 -8
  32. package/lib/index.js +1 -1
  33. package/lib/src/ap-form/ap-form.vue.d.ts +13 -34
  34. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  35. package/lib/src/ap-form/drawer-form/index.vue.d.ts +22 -40
  36. package/lib/src/ap-form/drawer-form/index.vue.js +1 -1
  37. package/lib/src/ap-form/index.d.ts +3 -1
  38. package/lib/src/ap-form/index.js +1 -1
  39. package/lib/src/ap-form/interface.d.ts +3 -1
  40. package/lib/src/ap-form/modal-form/index.vue.d.ts +23 -41
  41. package/lib/src/ap-form/modal-form/index.vue.js +1 -1
  42. package/lib/src/ap-form/provider/context.d.ts +3 -0
  43. package/lib/src/ap-form/provider/context.js +1 -0
  44. package/lib/src/ap-form/provider/index.vue.d.ts +19 -0
  45. package/lib/src/ap-form/provider/index.vue.js +1 -0
  46. package/lib/src/ap-form/provider/index.vue2.js +1 -0
  47. package/lib/src/ap-form/provider/interface.d.ts +22 -0
  48. package/lib/src/ap-form/search-form/index.vue.d.ts +22 -40
  49. package/lib/src/business/ap-select-layout/select-layout.vue2.js +1 -1
  50. package/lib/src/business/ap-table-modal/interface.d.ts +2 -0
  51. package/lib/src/business/ap-table-modal/table-modal.vue2.js +1 -1
  52. package/lib/src/config-provider/config-provider-props.d.ts +0 -2
  53. package/lib/src/config-provider/config-provider-props.js +1 -1
  54. package/lib/src/config-provider/config-provider.d.ts +0 -6
  55. package/lib/src/config-provider/config-provider.js +1 -1
  56. package/lib/src/config-provider/constants.d.ts +2 -0
  57. package/lib/src/config-provider/constants.js +1 -1
  58. package/lib/src/config-provider/hooks/use-global-config.d.ts +0 -2
  59. package/lib/src/config-provider/index.d.ts +0 -12
  60. package/lib/src/config-provider/index.js +1 -1
  61. package/lib/src/index.js +1 -1
  62. package/lib/src/utils/slot.js +1 -1
  63. package/package.json +3 -3
@@ -1,13 +1,13 @@
1
1
  import { ApFormModalFormProps } from '../interface';
2
2
  import { VNode, ComponentInternalInstance, ExtractPropTypes, PropType, HTMLAttributes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComponentOptionsMixin, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, DefineComponent, PublicProps, CSSProperties } from 'vue';
3
3
  import { InternalNamePath, NamePath, ValidateOptions, ValidateMessages, FormLabelAlign, FieldData, ValidateErrorEntity } from '@aplus-frontend/antdv/es/form/interface';
4
+ import { Recordable } from '../../type';
4
5
  import { ButtonSize, ButtonType, ButtonShape } from '@aplus-frontend/antdv/es/button';
5
6
  import { RequiredMark } from '@aplus-frontend/antdv/es/form/Form';
6
7
  import { ColSize } from '@aplus-frontend/antdv/es/grid';
7
8
  import { RuleObject } from '@aplus-frontend/antdv/es/form';
8
9
  import { Options } from '../../../node_modules/scroll-into-view-if-needed';
9
- import { Recordable } from '../../type';
10
- import { ApFormProps, WatchFunc, RegistedFieldType, ApFormInternalInstance, ApFormSubmitterConfig } from '..';
10
+ import { ApFormProps, ApFormInternalInstance, WatchFunc, ApFormSubmitterConfig } from '..';
11
11
  import { OnCleanup } from '@vue/reactivity';
12
12
  import { VueTypeValidableDef } from '../../../node_modules/vue-types';
13
13
  import { LegacyButtonType, ButtonHTMLType } from '@aplus-frontend/antdv/es/button/buttonTypes';
@@ -135,27 +135,18 @@ declare function __VLS_template(): {
135
135
  $emit: (event: string, ...args: any[]) => void;
136
136
  $el: any;
137
137
  $options: ComponentOptionsBase<Readonly< ApFormProps> & Readonly<{}>, {
138
+ setFieldsValue: (fields: Partial<any>) => void;
139
+ setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
138
140
  resetFields: () => Promise<void>;
139
- clearValidate: (name?: NamePath | NamePath[]) => void;
140
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
141
- [key: string]: any;
142
- }> | undefined;
143
- getFieldsValue: (nameList?: InternalNamePath[] | true) => {
144
- [key: string]: any;
145
- } | undefined;
146
- validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
147
- [key: string]: any;
148
- }> | undefined;
149
- scrollToField: (name: NamePath, options?: {}) => void;
150
- setFieldsValue: (values: Record<string, any>) => void;
151
- setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
141
+ clearValidate: (name?: NamePath) => void;
142
+ validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
143
+ getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
144
+ validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
145
+ scrollToField: (name: NamePath, options?: any) => void;
146
+ getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
147
+ validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
148
+ getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
152
149
  registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
153
- validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
154
- getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
155
- getInternalInstance: (mark: string) => {
156
- registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
157
- registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
158
- } | undefined;
159
150
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
160
151
  layout: string;
161
152
  colon: boolean;
@@ -192,28 +183,19 @@ declare function __VLS_template(): {
192
183
  hideRequiredMark: boolean;
193
184
  validateOnRuleChange: boolean;
194
185
  syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
195
- }> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
186
+ }> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl") | "setFieldsValue" | "getInternalInstance" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed"> & ShallowUnwrapRef<{
187
+ setFieldsValue: (fields: Partial<any>) => void;
188
+ setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
196
189
  resetFields: () => Promise<void>;
197
- clearValidate: (name?: NamePath | NamePath[]) => void;
198
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
199
- [key: string]: any;
200
- }> | undefined;
201
- getFieldsValue: (nameList?: InternalNamePath[] | true) => {
202
- [key: string]: any;
203
- } | undefined;
204
- validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
205
- [key: string]: any;
206
- }> | undefined;
207
- scrollToField: (name: NamePath, options?: {}) => void;
208
- setFieldsValue: (values: Record<string, any>) => void;
209
- setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
190
+ clearValidate: (name?: NamePath) => void;
191
+ validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
192
+ getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
193
+ validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
194
+ scrollToField: (name: NamePath, options?: any) => void;
195
+ getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
196
+ validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
197
+ getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
210
198
  registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
211
- validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
212
- getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
213
- getInternalInstance: (mark: string) => {
214
- registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
215
- registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
216
- } | undefined;
217
199
  }> & {} & ComponentCustomProperties & {} & {
218
200
  $slots: {
219
201
  default?(_: {}): any;
@@ -1,20 +1,21 @@
1
- import { isVNode as q, defineComponent as D, useSlots as L, ref as g, watch as A, cloneVNode as G, computed as I, createVNode as u, mergeProps as p, unref as n, openBlock as F, createElementBlock as W, Fragment as H, withCtx as h, renderSlot as w, createTextVNode as J, toDisplayString as K, createElementVNode as Q, normalizeClass as X, createBlock as P, resolveDynamicComponent as x, createCommentVNode as Y } from "vue";
1
+ import { isVNode as q, defineComponent as D, useSlots as L, ref as g, watch as A, cloneVNode as G, computed as I, createVNode as u, mergeProps as p, unref as n, openBlock as F, createElementBlock as W, Fragment as H, withCtx as b, renderSlot as P, createTextVNode as J, toDisplayString as K, createElementVNode as Q, normalizeClass as X, createBlock as w, resolveDynamicComponent as x, createCommentVNode as Y } from "vue";
2
2
  import { Button as V, Flex as Z, Space as ee, Modal as te } from "@aplus-frontend/antdv";
3
3
  import "../ap-form.vue.mjs";
4
4
  import "../../hooks/index.mjs";
5
5
  import { getSingleVNode as le } from "../../utils/slot.mjs";
6
6
  import "../../config-provider/index.mjs";
7
7
  import { omit as oe } from "lodash-unified";
8
- import { convertReactiveToRaw as ae } from "../../utils/index.mjs";
9
- import { useControllableValue as ie } from "../../hooks/useControllableValue.mjs";
8
+ import "../item/index.vue2.mjs";
9
+ import { useControllableValue as ae } from "../../hooks/useControllableValue.mjs";
10
10
  import { useLocale as ne } from "../../config-provider/hooks/use-locale.mjs";
11
- import { useGlobalConfig as se } from "../../config-provider/hooks/use-global-config.mjs";
12
- import { useNamespace as re } from "../../config-provider/hooks/use-namespace.mjs";
13
- import ue from "../ap-form.vue2.mjs";
14
- function N(d) {
15
- return typeof d == "function" || Object.prototype.toString.call(d) === "[object Object]" && !q(d);
11
+ import { useGlobalConfig as ie } from "../../config-provider/hooks/use-global-config.mjs";
12
+ import { useNamespace as se } from "../../config-provider/hooks/use-namespace.mjs";
13
+ import re from "../ap-form.vue2.mjs";
14
+ import ue from "../item/index.vue.mjs";
15
+ function N(m) {
16
+ return typeof m == "function" || Object.prototype.toString.call(m) === "[object Object]" && !q(m);
16
17
  }
17
- const Me = /* @__PURE__ */ D({
18
+ const Re = /* @__PURE__ */ D({
18
19
  __name: "index",
19
20
  props: {
20
21
  layout: {
@@ -91,32 +92,32 @@ const Me = /* @__PURE__ */ D({
91
92
  submitTimeout: {}
92
93
  },
93
94
  emits: ["update:open"],
94
- setup(d, {
95
- expose: S,
96
- emit: R
95
+ setup(m, {
96
+ expose: _,
97
+ emit: S
97
98
  }) {
98
- const o = d, b = L(), _ = R, a = g(), c = g(), s = g(!1), {
99
- value: M,
100
- updateValue: m
101
- } = ie(o, _, {
99
+ const o = m, v = L(), M = S, a = g(), c = g(), s = g(!1), {
100
+ value: R,
101
+ updateValue: f
102
+ } = ae(o, M, {
102
103
  valuePropName: "open",
103
104
  defaultValue: !1
104
105
  }), {
105
- t: v
106
- } = ne(), y = se("uiMode", "aplus"), {
106
+ t: y
107
+ } = ne(), h = ie("uiMode", "aplus"), {
107
108
  b: j,
108
109
  e: C
109
- } = re("ap-form-modal-form");
110
+ } = se("ap-form-modal-form");
110
111
  A(() => a.value, (e) => {
111
112
  var t;
112
113
  e && c.value && ((t = e.setFieldsValue) == null || t.call(e, c.value), c.value = void 0);
113
114
  });
114
- const B = le(b.trigger), T = B ? G(B, {
115
+ const T = le(v.trigger), B = T ? G(T, {
115
116
  onClick: () => {
116
- m(!0);
117
+ f(!0);
117
118
  }
118
119
  }) : null, O = I(() => {
119
- var t, l, r, f;
120
+ var t, l, r, d;
120
121
  const e = [];
121
122
  if (o.submitter === !1)
122
123
  return null;
@@ -125,35 +126,36 @@ const Me = /* @__PURE__ */ D({
125
126
  e.push(u(V, {
126
127
  onClick: k,
127
128
  disabled: s.value
128
- }, N(i = v("ap.common.cancelText")) ? i : {
129
+ }, N(i = y("ap.common.cancelText")) ? i : {
129
130
  default: () => [i]
130
131
  }));
131
132
  }
132
133
  return ((t = o.submitter) == null ? void 0 : t.resetButtonProps) !== !1 && e.push(u(V, p(((l = o.submitter) == null ? void 0 : l.resetButtonProps) || {}, {
133
- key: "submit",
134
+ key: "reset",
134
135
  disabled: s.value,
135
- onClick: U
136
+ onClick: U,
137
+ htmlType: "reset"
136
138
  }), {
137
139
  default: () => {
138
140
  var i;
139
- return [((i = o.submitter) == null ? void 0 : i.resetText) || v("ap.common.resetText")];
141
+ return [((i = o.submitter) == null ? void 0 : i.resetText) || y("ap.common.resetText")];
140
142
  }
141
143
  })), ((r = o.submitter) == null ? void 0 : r.submitButtonProps) !== !1 && e.push(u(V, p({
142
144
  type: "primary",
143
- key: "submit"
144
- }, ((f = o.submitter) == null ? void 0 : f.submitButtonProps) || {}, {
145
- loading: s.value,
146
- onClick: z
145
+ key: "submit",
146
+ htmlType: "submit"
147
+ }, ((d = o.submitter) == null ? void 0 : d.submitButtonProps) || {}, {
148
+ loading: s.value
147
149
  }), {
148
150
  default: () => {
149
151
  var i;
150
- return [((i = o.submitter) == null ? void 0 : i.submitText) || v("ap.common.okText")];
152
+ return [((i = o.submitter) == null ? void 0 : i.submitText) || y("ap.common.okText")];
151
153
  }
152
154
  })), u(Z, {
153
155
  justify: "flex-end",
154
- class: C(n(y) === "admin" ? "footer-admin" : "footer")
156
+ class: C(n(h) === "admin" ? "footer-admin" : "footer")
155
157
  }, {
156
- default: () => [b.submitter ? b.submitter(e) : u(ee, null, N(e) ? e : {
158
+ default: () => [v.submitter ? v.submitter(e) : u(ee, null, N(e) ? e : {
157
159
  default: () => [e]
158
160
  })]
159
161
  });
@@ -162,31 +164,30 @@ const Me = /* @__PURE__ */ D({
162
164
  var e, t, l;
163
165
  o.submitter !== !1 && ((e = a.value) == null || e.resetFields(), (l = (t = o.submitter) == null ? void 0 : t.onReset) == null || l.call(t));
164
166
  }
165
- async function z() {
166
- var e, t, l, r;
167
+ async function $(e) {
168
+ var t, l, r;
167
169
  if (o.submitter !== !1)
168
170
  try {
169
- const f = await ((e = a.value) == null ? void 0 : e.validateFields());
170
171
  (l = (t = o.submitter) == null ? void 0 : t.onSubmit) == null || l.call(t), s.value = !0;
171
- const i = (r = o.onFinish) == null ? void 0 : r.call(o, ae(f));
172
- if (o.submitTimeout && i instanceof Promise) {
173
- const $ = setTimeout(() => s.value = !1, o.submitTimeout);
174
- i.finally(() => {
175
- clearTimeout($), s.value = !1;
172
+ const d = (r = o.onFinish) == null ? void 0 : r.call(o, e);
173
+ if (o.submitTimeout && d instanceof Promise) {
174
+ const E = setTimeout(() => s.value = !1, o.submitTimeout);
175
+ d.finally(() => {
176
+ clearTimeout(E), s.value = !1;
176
177
  });
177
178
  }
178
- await i && m(!1);
179
+ await d && f(!1);
179
180
  } finally {
180
181
  s.value = !1;
181
182
  }
182
183
  }
183
184
  function k() {
184
- n(s) || m(!1);
185
+ n(s) || f(!1);
185
186
  }
186
- function E(e) {
187
- !e && n(s) || m(e);
187
+ function z(e) {
188
+ !e && n(s) || f(e);
188
189
  }
189
- return S({
190
+ return _({
190
191
  resetFields: () => {
191
192
  var e;
192
193
  (e = a.value) == null || e.resetFields();
@@ -230,36 +231,41 @@ const Me = /* @__PURE__ */ D({
230
231
  }), (e, t) => {
231
232
  var l;
232
233
  return F(), W(H, null, [u(n(te), p(e.modalProps, {
233
- open: n(M),
234
+ open: n(R),
234
235
  footer: null,
235
236
  width: e.width,
236
237
  class: n(j)(),
237
238
  "body-style": {
238
239
  ...((l = e.modalProps) == null ? void 0 : l.bodyStyle) || {},
239
- padding: n(y) === "admin" ? "0px !important" : "20px !important"
240
+ padding: n(h) === "admin" ? "0px !important" : "20px !important"
240
241
  // 这里使用内联样式目的是为了使用最高优先级覆盖设置的全局样式
241
242
  // 使用ModalForm你可能无法再自定义body的样式
242
243
  },
243
- "onUpdate:open": E,
244
+ "onUpdate:open": z,
244
245
  onCancel: k
245
246
  }), {
246
- title: h(() => [w(e.$slots, "title", {}, () => [J(K(o.title), 1)])]),
247
- default: h(() => [Q("div", {
248
- class: X(n(C)(n(y) === "admin" ? "content-admin" : "content"))
249
- }, [u(ue, p({
247
+ title: b(() => [P(e.$slots, "title", {}, () => [J(K(o.title), 1)])]),
248
+ default: b(() => [u(re, p({
250
249
  ref_key: "formRef",
251
250
  ref: a
252
- }, n(oe)(o, ["modalProps", "open", "onUpdate:open", "title", "width", "onFinish", "submitter"])), {
253
- default: h(() => [w(e.$slots, "default")]),
251
+ }, n(oe)(o, ["modalProps", "open", "onUpdate:open", "title", "width", "onFinish", "submitter"]), {
252
+ onFinish: $
253
+ }), {
254
+ default: b(() => [Q("div", {
255
+ class: X(n(C)(n(h) === "admin" ? "content-admin" : "content"))
256
+ }, [P(e.$slots, "default")], 2), u(ue, null, {
257
+ default: b(() => [(F(), w(x(O.value)))]),
258
+ _: 1
259
+ })]),
254
260
  _: 3
255
- }, 16)], 2), (F(), P(x(O.value)))]),
261
+ }, 16)]),
256
262
  _: 3
257
- }, 16, ["open", "width", "class", "body-style"]), n(T) ? (F(), P(x(n(T)), {
263
+ }, 16, ["open", "width", "class", "body-style"]), n(B) ? (F(), w(x(n(B)), {
258
264
  key: 0
259
265
  })) : Y("", !0)], 64);
260
266
  };
261
267
  }
262
268
  });
263
269
  export {
264
- Me as default
270
+ Re as default
265
271
  };
@@ -0,0 +1,3 @@
1
+ import { InternalFormProviderContext } from './interface';
2
+ export declare const useProvideFormProvider: (config: InternalFormProviderContext) => void;
3
+ export declare const useInjectFormProvider: () => InternalFormProviderContext;
@@ -0,0 +1,17 @@
1
+ import { provide as e, inject as t } from "vue";
2
+ const r = Symbol("InternalContextProps"), m = (o) => {
3
+ e(r, o);
4
+ }, n = {
5
+ triggerFormChange: () => {
6
+ },
7
+ triggerFormFinish: () => {
8
+ },
9
+ registerForm: () => {
10
+ },
11
+ unregisterForm: () => {
12
+ }
13
+ }, s = () => t(r, n);
14
+ export {
15
+ s as useInjectFormProvider,
16
+ m as useProvideFormProvider
17
+ };
@@ -0,0 +1,19 @@
1
+ import { ApFormProviderProps } from './interface';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ declare function __VLS_template(): {
4
+ attrs: Partial<{}>;
5
+ slots: {
6
+ default?(_: {}): any;
7
+ };
8
+ refs: {};
9
+ rootEl: any;
10
+ };
11
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
12
+ declare const __VLS_component: DefineComponent<ApFormProviderProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApFormProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
14
+ export default _default;
15
+ type __VLS_WithTemplateSlots<T, S> = T & {
16
+ new (): {
17
+ $slots: S;
18
+ };
19
+ };
@@ -0,0 +1,39 @@
1
+ import { defineComponent as s, ref as g, renderSlot as t } from "vue";
2
+ import { useInjectFormProvider as u, useProvideFormProvider as m } from "./context.mjs";
3
+ const h = /* @__PURE__ */ s({
4
+ __name: "index",
5
+ props: {
6
+ onFormChange: { type: Function },
7
+ onFormFinish: { type: Function }
8
+ },
9
+ setup(F) {
10
+ const o = F, n = g({}), e = u();
11
+ return m({
12
+ triggerFormChange(r, i) {
13
+ o != null && o.onFormChange && o.onFormChange(r, {
14
+ changedFields: i,
15
+ forms: n.value
16
+ }), e == null || e.triggerFormChange(r, i);
17
+ },
18
+ triggerFormFinish: (r, i) => {
19
+ o != null && o.onFormFinish && o.onFormFinish(r, {
20
+ values: i,
21
+ forms: n.value
22
+ }), e == null || e.triggerFormFinish(r, i);
23
+ },
24
+ registerForm: (r, i) => {
25
+ r && (n.value = {
26
+ ...n.value,
27
+ [r]: i
28
+ }), e == null || e.registerForm(r, i);
29
+ },
30
+ unregisterForm: (r) => {
31
+ const i = { ...n.value };
32
+ delete i[r], n.value = i, e == null || e.unregisterForm(r);
33
+ }
34
+ }), (r, i) => t(r.$slots, "default");
35
+ }
36
+ });
37
+ export {
38
+ h as default
39
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index.vue.mjs";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,22 @@
1
+ import { Store } from '@aplus-frontend/antdv/es/form/interface';
2
+ import { ApFormExpose } from '../interface';
3
+ export type ApFormInstance = ApFormExpose;
4
+ export type Forms = Record<string, ApFormInstance>;
5
+ export interface ApFormChangeInfo {
6
+ changedFields: any;
7
+ forms: Forms;
8
+ }
9
+ export interface ApFormFinishInfo {
10
+ values: Store;
11
+ forms: Forms;
12
+ }
13
+ export type ApFormProviderProps = {
14
+ onFormChange?: (name: string, info: ApFormChangeInfo) => void;
15
+ onFormFinish?: (name: string, info: ApFormFinishInfo) => void;
16
+ };
17
+ export interface InternalFormProviderContext {
18
+ triggerFormChange: (name: string, changedFields: any) => void;
19
+ triggerFormFinish: (name: string, values: Store) => void;
20
+ registerForm: (name: string, form: ApFormInstance) => void;
21
+ unregisterForm: (name: string) => void;
22
+ }
@@ -7,7 +7,7 @@ import { ColSize } from '@aplus-frontend/antdv/es/grid';
7
7
  import { RuleObject } from '@aplus-frontend/antdv/es/form';
8
8
  import { Options } from '../../../node_modules/scroll-into-view-if-needed';
9
9
  import { Recordable } from '../../type';
10
- import { ApFormProps, WatchFunc, RegistedFieldType } from '..';
10
+ import { ApFormProps, ApFormInternalInstance, WatchFunc } from '..';
11
11
  import { OnCleanup } from '@vue/reactivity';
12
12
  declare function __VLS_template(): {
13
13
  attrs: Partial<{}>;
@@ -131,27 +131,18 @@ declare function __VLS_template(): {
131
131
  $emit: (event: string, ...args: any[]) => void;
132
132
  $el: any;
133
133
  $options: ComponentOptionsBase<Readonly< ApFormProps> & Readonly<{}>, {
134
+ setFieldsValue: (fields: Partial<any>) => void;
135
+ setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
134
136
  resetFields: () => Promise<void>;
135
- clearValidate: (name?: NamePath | NamePath[]) => void;
136
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
137
- [key: string]: any;
138
- }> | undefined;
139
- getFieldsValue: (nameList?: InternalNamePath[] | true) => {
140
- [key: string]: any;
141
- } | undefined;
142
- validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
143
- [key: string]: any;
144
- }> | undefined;
145
- scrollToField: (name: NamePath, options?: {}) => void;
146
- setFieldsValue: (values: Record<string, any>) => void;
147
- setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
137
+ clearValidate: (name?: NamePath) => void;
138
+ validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
139
+ getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
140
+ validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
141
+ scrollToField: (name: NamePath, options?: any) => void;
142
+ getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
143
+ validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
144
+ getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
148
145
  registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
149
- validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
150
- getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
151
- getInternalInstance: (mark: string) => {
152
- registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
153
- registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
154
- } | undefined;
155
146
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
156
147
  layout: string;
157
148
  colon: boolean;
@@ -188,28 +179,19 @@ declare function __VLS_template(): {
188
179
  hideRequiredMark: boolean;
189
180
  validateOnRuleChange: boolean;
190
181
  syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
191
- }> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
182
+ }> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl") | "setFieldsValue" | "getInternalInstance" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed"> & ShallowUnwrapRef<{
183
+ setFieldsValue: (fields: Partial<any>) => void;
184
+ setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
192
185
  resetFields: () => Promise<void>;
193
- clearValidate: (name?: NamePath | NamePath[]) => void;
194
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
195
- [key: string]: any;
196
- }> | undefined;
197
- getFieldsValue: (nameList?: InternalNamePath[] | true) => {
198
- [key: string]: any;
199
- } | undefined;
200
- validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
201
- [key: string]: any;
202
- }> | undefined;
203
- scrollToField: (name: NamePath, options?: {}) => void;
204
- setFieldsValue: (values: Record<string, any>) => void;
205
- setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
186
+ clearValidate: (name?: NamePath) => void;
187
+ validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
188
+ getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
189
+ validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
190
+ scrollToField: (name: NamePath, options?: any) => void;
191
+ getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
192
+ validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
193
+ getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
206
194
  registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
207
- validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
208
- getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
209
- getInternalInstance: (mark: string) => {
210
- registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
211
- registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
212
- } | undefined;
213
195
  }> & {} & ComponentCustomProperties & {} & {
214
196
  $slots: {
215
197
  default?(_: {}): any;