@piying/view-vue 1.1.1 → 1.1.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.
@@ -1,6 +1,6 @@
1
- import type { PiResolvedFormlyFieldConfig } from '../type/group';
1
+ import type { PiResolvedViewFieldConfig } from '../type/group';
2
2
  type __VLS_Props = {
3
- fields: PiResolvedFormlyFieldConfig[];
3
+ fields: PiResolvedViewFieldConfig[];
4
4
  };
5
5
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}, {}>;
6
6
  export default _default;
@@ -1,6 +1,6 @@
1
- import type { PiResolvedFormlyFieldConfig } from './type/group';
1
+ import type { PiResolvedViewFieldConfig } from './type/group';
2
2
  type __VLS_Props = {
3
- field: PiResolvedFormlyFieldConfig;
3
+ field: PiResolvedViewFieldConfig;
4
4
  };
5
5
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}, {}>;
6
6
  export default _default;
package/formly/token.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Injector } from 'static-injector';
2
2
  import type { ComputedRef, InjectionKey } from 'vue';
3
- import type { PiResolvedFormlyFieldConfig } from './type/group';
3
+ import type { PiResolvedViewFieldConfig } from './type/group';
4
4
  export declare const InjectorToken: InjectionKey<Injector>;
5
- export declare const FieldToken: InjectionKey<ComputedRef<PiResolvedFormlyFieldConfig>>;
5
+ export declare const FieldToken: InjectionKey<ComputedRef<PiResolvedViewFieldConfig>>;
@@ -2,7 +2,7 @@ import type { ConfigMergeStrategyObject, VueSchemaHandle } from '../vue-schema';
2
2
  import type { ConfigMergeStrategy, CoreResolvedComponentDefine, PiResolvedCommonViewFieldConfig } from '@piying/view-core';
3
3
  import type { SetOptional } from '@piying/view-core';
4
4
  export interface RawDirectiveOutputs {
5
- [name: string]: (event: any, field: PiResolvedFormlyFieldConfig) => void;
5
+ [name: string]: (event: any, field: PiResolvedViewFieldConfig) => void;
6
6
  }
7
7
  export type RawWrapperDefine = {
8
8
  inputs?: Record<string, any>;
@@ -20,21 +20,21 @@ export interface ComponentFieldConfig {
20
20
  contents?: any[];
21
21
  }
22
22
  export type ResolvedComponentFieldConfig = Omit<ComponentFieldConfig, 'inputs' | 'outputs' | 'directives' | 'wrappers'>;
23
- export type PiDefaultRawFormlyFieldConfig = Pick<VueSchemaHandle, 'inputs' | 'outputs' | 'wrappers' | 'formConfig' | 'renderConfig' | 'props'>;
24
- export type PiResolvedFormlyFieldConfig = PiResolvedCommonViewFieldConfig<() => PiResolvedFormlyFieldConfig, CoreResolvedComponentDefine> & ResolvedComponentFieldConfig & {
23
+ export type PiDefaultRawViewFieldConfig = Pick<VueSchemaHandle, 'inputs' | 'outputs' | 'wrappers' | 'formConfig' | 'renderConfig' | 'props'>;
24
+ export type PiResolvedViewFieldConfig = PiResolvedCommonViewFieldConfig<() => PiResolvedViewFieldConfig, CoreResolvedComponentDefine> & ResolvedComponentFieldConfig & {
25
25
  /** 除了无component的控件,其他情况下都应该有define,group/array会赋值默认 */
26
26
  define?: RawComponentDefine;
27
27
  };
28
28
  export type PiComponentDefaultConfig = {
29
29
  type: any | (() => Promise<any>);
30
- } & Omit<SetOptional<PiDefaultRawFormlyFieldConfig, 'formConfig'>, 'type'>;
31
- export interface PiFormlyConfig {
30
+ } & Omit<SetOptional<PiDefaultRawViewFieldConfig, 'formConfig'>, 'type'>;
31
+ export interface PiViewConfig {
32
32
  types?: Record<string, PiComponentDefaultConfig>;
33
33
  wrappers?: Record<string, {
34
34
  type: any | (() => Promise<any>);
35
35
  inputs?: Record<string, any>;
36
36
  }>;
37
- defaultConfig?: PiDefaultRawFormlyFieldConfig;
37
+ defaultConfig?: PiDefaultRawViewFieldConfig;
38
38
  /** merge 数组/对象会合并 replace 优先自身/组件/全局 */
39
39
  defaultConfigMergeStrategy?: ConfigMergeStrategy | ConfigMergeStrategyObject;
40
40
  }
@@ -1,6 +1,6 @@
1
1
  import { CoreSchemaHandle, type ConfigMergeStrategy } from '@piying/view-core';
2
- import type { PiResolvedFormlyFieldConfig } from './type/group';
3
- export declare class VueSchemaHandle extends CoreSchemaHandle<VueSchemaHandle, () => PiResolvedFormlyFieldConfig> {
2
+ import type { PiResolvedViewFieldConfig } from './type/group';
3
+ export declare class VueSchemaHandle extends CoreSchemaHandle<VueSchemaHandle, () => PiResolvedViewFieldConfig> {
4
4
  type?: any;
5
5
  contents?: any[];
6
6
  }
package/index.d.ts CHANGED
@@ -2,3 +2,8 @@ import PiyingView from './formly/piying-view.vue';
2
2
  export { PiyingView };
3
3
  export * from '@piying/view-core';
4
4
  export * from './formly/util';
5
+ import PiyingFieldTemplate from './formly/field-template.vue';
6
+ export { PiyingFieldTemplate };
7
+ import PiyingViewGroup from './formly/component/group.vue';
8
+ export { PiyingViewGroup };
9
+ export * from './formly/type';
package/index.js CHANGED
@@ -1,25 +1,25 @@
1
- var W = Object.defineProperty;
2
- var J = (n, e, o) => e in n ? W(n, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[e] = o;
3
- var R = (n, e, o) => J(n, typeof e != "symbol" ? e + "" : e, o);
4
- import { inject as P, shallowRef as T, watchEffect as G, defineComponent as D, computed as v, createBlock as _, renderSlot as A, openBlock as d, resolveDynamicComponent as V, mergeProps as b, unref as i, toHandlers as j, withCtx as S, createVNode as K, normalizeProps as M, guardReactiveProps as Q, defineAsyncComponent as X, provide as H, ref as $, watch as N, onUnmounted as Y, createElementBlock as B, createCommentVNode as F, Fragment as O } from "vue";
5
- import { CoreSchemaHandle as Z, FormBuilder as L, isFieldControl as ee, createViewControlLink as te, convert as oe } from "@piying/view-core";
1
+ var J = Object.defineProperty;
2
+ var K = (n, e, o) => e in n ? J(n, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[e] = o;
3
+ var R = (n, e, o) => K(n, typeof e != "symbol" ? e + "" : e, o);
4
+ import { inject as T, shallowRef as G, watchEffect as O, defineComponent as j, computed as v, createBlock as y, renderSlot as A, openBlock as c, resolveDynamicComponent as V, mergeProps as I, unref as d, toHandlers as b, withCtx as S, createVNode as L, normalizeProps as M, guardReactiveProps as Q, defineAsyncComponent as X, provide as H, ref as x, watch as N, onUnmounted as Y, createElementBlock as D, createCommentVNode as B, Fragment as E, renderList as Z } from "vue";
5
+ import { CoreSchemaHandle as ee, FormBuilder as te, isFieldControl as oe, createViewControlLink as ne, convert as re } from "@piying/view-core";
6
6
  export * from "@piying/view-core";
7
- import { effect as q, createRootInjector as ne, ChangeDetectionSchedulerImpl as re, ChangeDetectionScheduler as le, createInjector as ae, DestroyRef as ue, untracked as se } from "static-injector";
8
- import { deepEqual as ce } from "fast-equals";
9
- class ie extends Z {
7
+ import { effect as q, createRootInjector as le, ChangeDetectionSchedulerImpl as ae, ChangeDetectionScheduler as ue, createInjector as se, DestroyRef as ce, untracked as ie } from "static-injector";
8
+ import { deepEqual as de } from "fast-equals";
9
+ class pe extends ee {
10
10
  constructor() {
11
11
  super(...arguments);
12
12
  R(this, "contents");
13
13
  }
14
14
  }
15
- class de extends L {
15
+ class fe extends te {
16
16
  }
17
- const x = Symbol(), fe = Symbol();
17
+ const F = Symbol(), me = Symbol();
18
18
  function m(n) {
19
- const e = P(x), o = T(void 0);
20
- return G((r) => {
19
+ const e = T(F), o = G(void 0);
20
+ return O((r) => {
21
21
  o.value = n();
22
- const a = q(
22
+ const l = q(
23
23
  () => {
24
24
  const t = n();
25
25
  Object.is(o.value, t) || (o.value = t);
@@ -27,100 +27,100 @@ function m(n) {
27
27
  { injector: e }
28
28
  );
29
29
  r(() => {
30
- a.destroy();
30
+ l.destroy();
31
31
  });
32
32
  }), o;
33
33
  }
34
- const z = /* @__PURE__ */ D({
34
+ const z = /* @__PURE__ */ j({
35
35
  __name: "wrapper",
36
36
  props: {
37
37
  wrappers: {}
38
38
  },
39
39
  setup(n) {
40
- const e = n, o = v(() => e.wrappers.slice(1)), r = v(() => e.wrappers[0]), a = m(() => {
41
- var l, f;
42
- return { ...(l = r.value) == null ? void 0 : l.inputs(), ...(f = r.value) == null ? void 0 : f.attributes() };
40
+ const e = n, o = v(() => e.wrappers.slice(1)), r = v(() => e.wrappers[0]), l = m(() => {
41
+ var a, p;
42
+ return { ...(a = r.value) == null ? void 0 : a.inputs(), ...(p = r.value) == null ? void 0 : p.attributes() };
43
43
  }), t = v(() => {
44
- var l;
45
- return ((l = r.value) == null ? void 0 : l.outputs) ?? {};
44
+ var a;
45
+ return ((a = r.value) == null ? void 0 : a.outputs) ?? {};
46
46
  });
47
- return (l, f) => r.value ? (d(), _(V(r.value.type), b({ key: 0 }, i(a), j(t.value)), {
47
+ return (a, p) => r.value ? (c(), y(V(r.value.type), I({ key: 0 }, d(l), b(t.value)), {
48
48
  default: S(() => [
49
- K(z, M(Q({ wrappers: o.value })), {
49
+ L(z, M(Q({ wrappers: o.value })), {
50
50
  default: S(() => [
51
- A(l.$slots, "default")
51
+ A(a.$slots, "default")
52
52
  ]),
53
53
  _: 3
54
54
  }, 16)
55
55
  ]),
56
56
  _: 3
57
- }, 16)) : A(l.$slots, "default", { key: 1 });
57
+ }, 16)) : A(a.$slots, "default", { key: 1 });
58
58
  }
59
- }), pe = /* @__PURE__ */ D({
59
+ }), U = /* @__PURE__ */ j({
60
60
  __name: "field-template",
61
61
  props: {
62
62
  field: {}
63
63
  },
64
64
  setup(n) {
65
- const e = n, o = P(x), r = m(() => e.field.inputs()), a = m(() => e.field.outputs()), t = m(() => e.field.renderConfig()), l = m(() => e.field.attributes()), f = v(() => ({ ...r.value, fields: e.field.fieldGroup() })), E = v(() => ({ ...r.value, fields: e.field.fieldArray() })), I = m(() => e.field.wrappers()), C = m(() => {
65
+ const e = n, o = T(F), r = m(() => e.field.inputs()), l = m(() => e.field.outputs()), t = m(() => e.field.renderConfig()), a = m(() => e.field.attributes()), p = v(() => ({ ...r.value, fields: e.field.fieldGroup() })), P = v(() => ({ ...r.value, fields: e.field.fieldArray() })), $ = m(() => e.field.wrappers()), g = m(() => {
66
66
  var u, s;
67
67
  return (s = (u = e.field).fieldGroup) == null ? void 0 : s.call(u);
68
- }), g = m(() => {
68
+ }), w = m(() => {
69
69
  var u, s;
70
70
  return (s = (u = e.field).fieldArray) == null ? void 0 : s.call(u);
71
- }), y = v(() => ({ ...l.value, ...r.value })), c = v(
71
+ }), h = v(() => ({ ...a.value, ...r.value })), i = v(
72
72
  () => {
73
73
  var u, s, k;
74
74
  return typeof ((u = e.field.define) == null ? void 0 : u.type) == "function" ? X((s = e.field.define) == null ? void 0 : s.type) : (k = e.field.define) == null ? void 0 : k.type;
75
75
  }
76
- ), h = v(() => e.field);
77
- H(fe, h);
78
- const w = $(null), U = ee(h.value.form.control);
79
- let p;
76
+ ), _ = v(() => e.field);
77
+ H(me, _);
78
+ const C = x(null), W = oe(_.value.form.control);
79
+ let f;
80
80
  return N(
81
- w,
81
+ C,
82
82
  (u) => {
83
- p == null || p.forEach((s) => s()), U && u && (p = te(
84
- () => h.value.form.control,
83
+ f == null || f.forEach((s) => s()), W && u && (f = ne(
84
+ () => _.value.form.control,
85
85
  u.cva,
86
86
  o
87
87
  ));
88
88
  },
89
89
  { immediate: !0 }
90
90
  ), Y(() => {
91
- p == null || p.forEach((u) => u()), p = [];
91
+ f == null || f.forEach((u) => u()), f = [];
92
92
  }), (u, s) => {
93
93
  var k;
94
- return i(t).hidden ? F("", !0) : (d(), B(O, { key: 0 }, [
95
- (k = h.value.define) != null && k.type ? (d(), _(z, {
94
+ return d(t).hidden ? B("", !0) : (c(), D(E, { key: 0 }, [
95
+ (k = _.value.define) != null && k.type ? (c(), y(z, {
96
96
  key: 0,
97
- wrappers: i(I)
97
+ wrappers: d($)
98
98
  }, {
99
99
  default: S(() => [
100
- i(C) ? (d(), _(V(c.value), b({ key: 0 }, f.value, j(i(a))), null, 16)) : i(g) ? (d(), _(V(c.value), b({ key: 1 }, E.value, j(i(a))), null, 16)) : (d(), B(O, { key: 2 }, [
101
- h.value.form.control ? (d(), _(V(c.value), b({ key: 0 }, y.value, j(i(a)), {
100
+ d(g) ? (c(), y(V(i.value), I({ key: 0 }, p.value, b(d(l))), null, 16)) : d(w) ? (c(), y(V(i.value), I({ key: 1 }, P.value, b(d(l))), null, 16)) : (c(), D(E, { key: 2 }, [
101
+ _.value.form.control ? (c(), y(V(i.value), I({ key: 0 }, h.value, b(d(l)), {
102
102
  ref_key: "childRef",
103
- ref: w
104
- }), null, 16)) : (d(), _(V(c.value), b({ key: 1 }, y.value, j(i(a))), null, 16))
103
+ ref: C
104
+ }), null, 16)) : (c(), y(V(i.value), I({ key: 1 }, h.value, b(d(l))), null, 16))
105
105
  ], 64))
106
106
  ]),
107
107
  _: 1
108
- }, 8, ["wrappers"])) : F("", !0)
108
+ }, 8, ["wrappers"])) : B("", !0)
109
109
  ], 64));
110
110
  };
111
111
  }
112
112
  });
113
- function me(n, e, o, r) {
114
- let a = !0;
113
+ function ve(n, e, o, r) {
114
+ let l = !0;
115
115
  return q(
116
116
  () => {
117
117
  const t = e.value$$();
118
- a ? (ce(t, n) || r(t), a = !1) : r(t);
118
+ l ? (de(t, n) || r(t), l = !1) : r(t);
119
119
  },
120
120
  { injector: o }
121
121
  );
122
122
  }
123
- const ge = /* @__PURE__ */ D({
123
+ const Ce = /* @__PURE__ */ j({
124
124
  __name: "piying-view",
125
125
  props: {
126
126
  schema: {},
@@ -129,61 +129,61 @@ const ge = /* @__PURE__ */ D({
129
129
  },
130
130
  emits: ["update:modelValue"],
131
131
  setup(n, { emit: e }) {
132
- const o = n, r = e, a = ne({
132
+ const o = n, r = e, l = le({
133
133
  providers: [
134
134
  {
135
- provide: le,
136
- useClass: re
135
+ provide: ue,
136
+ useClass: ae
137
137
  }
138
138
  ]
139
139
  });
140
- H(x, a);
141
- const t = T(void 0);
140
+ H(F, l);
141
+ const t = G(void 0);
142
142
  return N(
143
143
  () => [o.schema, o.options],
144
- ([l, f], E, I) => {
145
- const C = ae({ providers: [], parent: a }), g = oe(l, {
146
- handle: ie,
147
- builder: de,
148
- injector: C,
149
- registerOnDestroy: (c) => {
150
- C.get(ue).onDestroy(() => {
151
- c();
144
+ ([a, p], P, $) => {
145
+ const g = se({ providers: [], parent: l }), w = re(a, {
146
+ handle: pe,
147
+ builder: fe,
148
+ injector: g,
149
+ registerOnDestroy: (i) => {
150
+ g.get(ce).onDestroy(() => {
151
+ i();
152
152
  });
153
153
  },
154
- ...f
154
+ ...p
155
155
  });
156
- t.value = g;
157
- let y;
158
- if (g.form.control) {
159
- const c = o.modelValue;
160
- y = me(
161
- typeof c < "u" ? c : void 0,
162
- g.form.control,
163
- C,
164
- (h) => {
165
- se(() => {
166
- var w;
167
- (w = g.form.control) != null && w.valueNoError$$() && r("update:modelValue", h);
156
+ t.value = w;
157
+ let h;
158
+ if (w.form.control) {
159
+ const i = o.modelValue;
160
+ h = ve(
161
+ typeof i < "u" ? i : void 0,
162
+ w.form.control,
163
+ g,
164
+ (_) => {
165
+ ie(() => {
166
+ var C;
167
+ (C = w.form.control) != null && C.valueNoError$$() && r("update:modelValue", _);
168
168
  });
169
169
  }
170
170
  );
171
171
  }
172
- I(() => {
173
- C.destroy(), y == null || y.destroy();
172
+ $(() => {
173
+ g.destroy(), h == null || h.destroy();
174
174
  });
175
175
  },
176
176
  { immediate: !0 }
177
- ), G(() => {
178
- var l;
179
- (l = t.value.form.control) == null || l.updateValue(o.modelValue);
180
- }), (l, f) => (d(), _(pe, {
177
+ ), O(() => {
178
+ var a;
179
+ (a = t.value.form.control) == null || a.updateValue(o.modelValue);
180
+ }), (a, p) => (c(), y(U, {
181
181
  field: t.value
182
182
  }, null, 8, ["field"]));
183
183
  }
184
184
  });
185
- function we() {
186
- const n = $(), e = $(!1);
185
+ function ke() {
186
+ const n = x(), e = x(!1);
187
187
  let o, r;
188
188
  return {
189
189
  cva: {
@@ -210,9 +210,24 @@ function we() {
210
210
  }
211
211
  };
212
212
  }
213
+ const Ve = /* @__PURE__ */ j({
214
+ __name: "group",
215
+ props: {
216
+ fields: {}
217
+ },
218
+ setup(n) {
219
+ const e = n;
220
+ return (o, r) => (c(!0), D(E, null, Z(e.fields, (l, t) => (c(), y(U, {
221
+ key: t,
222
+ field: l
223
+ }, null, 8, ["field"]))), 128));
224
+ }
225
+ });
213
226
  export {
214
- ge as PiyingView,
215
- me as initListen,
216
- we as useControlValueAccessor,
227
+ U as PiyingFieldTemplate,
228
+ Ce as PiyingView,
229
+ Ve as PiyingViewGroup,
230
+ ve as initListen,
231
+ ke as useControlValueAccessor,
217
232
  m as watchChange
218
233
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piying/view-vue",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@piying/view-core": "^0.6.22",