@piying/view-vue 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { PiResolvedViewFieldConfig } from './type/group';
1
+ import type { PiResolvedViewFieldConfig } from '../type/group';
2
2
  type __VLS_Props = {
3
3
  field: PiResolvedViewFieldConfig;
4
4
  };
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import PiyingView from './piying-view.vue';
1
+ import PiyingView from './component/piying-view.vue';
2
2
  export { PiyingView };
3
3
  export * from './util';
4
- import PiyingFieldTemplate from './field-template.vue';
4
+ import PiyingFieldTemplate from './component/field-template.vue';
5
5
  export { PiyingFieldTemplate };
6
6
  import PiyingViewGroup from './component/group.vue';
7
7
  export { PiyingViewGroup };
package/index.js CHANGED
@@ -1,99 +1,98 @@
1
- var z = Object.defineProperty;
2
- var G = (o, e, n) => e in o ? z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var x = (o, e, n) => G(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { inject as E, shallowRef as B, watchEffect as O, defineComponent as I, computed as g, createBlock as _, renderSlot as F, openBlock as d, resolveDynamicComponent as w, mergeProps as V, unref as m, toHandlers as k, withCtx as j, createVNode as K, normalizeProps as U, guardReactiveProps as J, defineAsyncComponent as M, provide as L, ref as $, watch as N, onUnmounted as Q, createElementBlock as D, createCommentVNode as T, Fragment as S, renderList as X } from "vue";
5
- import { CoreSchemaHandle as Y, FormBuilder as Z, isFieldControl as ee, createViewControlLink as te, convert as ne } from "@piying/view-core";
6
- import { effect as H, createRootInjector as oe, ChangeDetectionSchedulerImpl as re, ChangeDetectionScheduler as le, createInjector as ae, DestroyRef as se, untracked as ce } from "static-injector";
7
- import { deepEqual as ue } from "fast-equals";
8
- class ie extends Y {
1
+ var G = Object.defineProperty;
2
+ var K = (o, e, t) => e in o ? G(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var F = (o, e, t) => K(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { inject as R, shallowRef as B, watchEffect as O, defineComponent as I, computed as g, createBlock as _, renderSlot as L, openBlock as d, resolveDynamicComponent as w, mergeProps as k, unref as m, toHandlers as V, withCtx as j, createVNode as M, normalizeProps as U, guardReactiveProps as q, defineAsyncComponent as J, provide as N, ref as D, watch as z, onUnmounted as Q, createElementBlock as S, createCommentVNode as T, Fragment as P, renderList as X } from "vue";
5
+ import { CoreSchemaHandle as Y, FormBuilder as Z, isLazyMark as ee, getLazyImport as te, isFieldControl as ne, createViewControlLink as oe, convert as re, initListen as le } from "@piying/view-core";
6
+ import { effect as ae, createRootInjector as se, ChangeDetectionSchedulerImpl as ce, ChangeDetectionScheduler as ue, createInjector as ie, DestroyRef as de, untracked as pe } from "static-injector";
7
+ class fe extends Y {
9
8
  constructor() {
10
9
  super(...arguments);
11
- x(this, "contents");
10
+ F(this, "contents");
12
11
  }
13
12
  }
14
- class de extends Z {
13
+ class me extends Z {
15
14
  }
16
- const P = Symbol(), A = Symbol();
15
+ const $ = Symbol(), H = Symbol();
17
16
  function v(o) {
18
- const e = E(P), n = B(void 0);
19
- return O((r) => {
20
- n.value = o();
21
- const a = H(
17
+ const e = R($), t = B(void 0);
18
+ return O((l) => {
19
+ t.value = o();
20
+ const a = ae(
22
21
  () => {
23
- const t = o();
24
- Object.is(n.value, t) || (n.value = t);
22
+ const n = o();
23
+ Object.is(t.value, n) || (t.value = n);
25
24
  },
26
25
  { injector: e }
27
26
  );
28
- r(() => {
27
+ l(() => {
29
28
  a.destroy();
30
29
  });
31
- }), n;
30
+ }), t;
32
31
  }
33
- const W = /* @__PURE__ */ I({
32
+ const A = /* @__PURE__ */ I({
34
33
  __name: "wrapper",
35
34
  props: {
36
35
  wrappers: {}
37
36
  },
38
37
  setup(o) {
39
- const e = o, n = g(() => e.wrappers.slice(1)), r = g(() => e.wrappers[0]), a = v(() => {
40
- var l, c;
41
- return { ...(l = r.value) == null ? void 0 : l.inputs(), ...(c = r.value) == null ? void 0 : c.attributes() };
42
- }), t = g(() => {
43
- var l;
44
- return ((l = r.value) == null ? void 0 : l.outputs) ?? {};
38
+ const e = o, t = g(() => e.wrappers.slice(1)), l = g(() => e.wrappers[0]), a = v(() => {
39
+ var r, c;
40
+ return { ...(r = l.value) == null ? void 0 : r.inputs(), ...(c = l.value) == null ? void 0 : c.attributes() };
41
+ }), n = g(() => {
42
+ var r;
43
+ return ((r = l.value) == null ? void 0 : r.outputs) ?? {};
45
44
  });
46
- return (l, c) => r.value ? (d(), _(w(r.value.type), V({ key: 0 }, m(a), k(t.value)), {
45
+ return (r, c) => l.value ? (d(), _(w(l.value.type), k({ key: 0 }, m(a), V(n.value)), {
47
46
  default: j(() => [
48
- K(W, U(J({ wrappers: n.value })), {
47
+ M(A, U(q({ wrappers: t.value })), {
49
48
  default: j(() => [
50
- F(l.$slots, "default")
49
+ L(r.$slots, "default")
51
50
  ]),
52
51
  _: 3
53
52
  }, 16)
54
53
  ]),
55
54
  _: 3
56
- }, 16)) : F(l.$slots, "default", { key: 1 });
55
+ }, 16)) : L(r.$slots, "default", { key: 1 });
57
56
  }
58
- }), q = /* @__PURE__ */ I({
57
+ }), W = /* @__PURE__ */ I({
59
58
  __name: "field-template",
60
59
  props: {
61
60
  field: {}
62
61
  },
63
62
  setup(o) {
64
- const e = o, n = E(P), r = v(() => e.field.inputs()), a = v(() => e.field.outputs()), t = v(() => e.field.renderConfig()), l = v(() => e.field.attributes()), c = g(() => ({ ...l.value, ...r.value })), R = v(() => {
63
+ const e = o, t = R($), l = v(() => e.field.inputs()), a = v(() => e.field.outputs()), n = v(() => e.field.renderConfig()), r = v(() => e.field.attributes()), c = g(() => ({ ...r.value, ...l.value })), x = v(() => {
65
64
  var s, f;
66
65
  return (f = (s = e.field).children) == null ? void 0 : f.call(s);
67
66
  }), b = v(() => e.field.wrappers()), p = g(
68
67
  () => {
69
- var s, f, C;
70
- return typeof ((s = e.field.define) == null ? void 0 : s.type) == "function" ? M((f = e.field.define) == null ? void 0 : f.type) : (C = e.field.define) == null ? void 0 : C.type;
68
+ var s, f, C, E;
69
+ return typeof ((s = e.field.define) == null ? void 0 : s.type) == "function" || ee((f = e.field.define) == null ? void 0 : f.type) ? J(te((C = e.field.define) == null ? void 0 : C.type)) : (E = e.field.define) == null ? void 0 : E.type;
71
70
  }
72
71
  ), u = g(() => e.field);
73
- L(A, u);
74
- const y = $(null), h = ee(u.value.form.control);
72
+ N(H, u);
73
+ const y = D(null), h = ne(u.value.form.control);
75
74
  let i;
76
- return N(
75
+ return z(
77
76
  [y, u],
78
77
  ([s, f]) => {
79
- i == null || i(), h && s && (i = te(() => f.form.control, s.cva, n));
78
+ i == null || i(), h && s && (i = oe(() => f.form.control, s.cva, t));
80
79
  },
81
80
  { immediate: !0 }
82
81
  ), Q(() => {
83
82
  i == null || i(), i = void 0;
84
83
  }), (s, f) => {
85
84
  var C;
86
- return m(t).hidden ? T("", !0) : (d(), D(S, { key: 0 }, [
87
- (C = u.value.define) != null && C.type ? (d(), _(W, {
85
+ return m(n).hidden ? T("", !0) : (d(), S(P, { key: 0 }, [
86
+ (C = u.value.define) != null && C.type ? (d(), _(A, {
88
87
  key: 0,
89
88
  wrappers: m(b)
90
89
  }, {
91
90
  default: j(() => [
92
- m(R) ? (d(), _(w(p.value), V({ key: 0 }, c.value, k(m(a))), null, 16)) : (d(), D(S, { key: 1 }, [
93
- u.value.form.control ? (d(), _(w(p.value), V({ key: 0 }, c.value, k(m(a)), {
91
+ m(x) ? (d(), _(w(p.value), k({ key: 0 }, c.value, V(m(a))), null, 16)) : (d(), S(P, { key: 1 }, [
92
+ u.value.form.control ? (d(), _(w(p.value), k({ key: 0 }, c.value, V(m(a)), {
94
93
  ref_key: "childRef",
95
94
  ref: y
96
- }), null, 16)) : (d(), _(w(p.value), V({ key: 1 }, c.value, k(m(a))), null, 16))
95
+ }), null, 16)) : (d(), _(w(p.value), k({ key: 1 }, c.value, V(m(a))), null, 16))
97
96
  ], 64))
98
97
  ]),
99
98
  _: 1
@@ -101,18 +100,7 @@ const W = /* @__PURE__ */ I({
101
100
  ], 64));
102
101
  };
103
102
  }
104
- });
105
- function pe(o, e, n, r) {
106
- let a = !0;
107
- return H(
108
- () => {
109
- const t = e.value$$();
110
- a ? (ue(t, o) || r(t), a = !1) : r(t);
111
- },
112
- { injector: n }
113
- );
114
- }
115
- const he = /* @__PURE__ */ I({
103
+ }), ge = /* @__PURE__ */ I({
116
104
  __name: "piying-view",
117
105
  props: {
118
106
  schema: {},
@@ -121,42 +109,42 @@ const he = /* @__PURE__ */ I({
121
109
  },
122
110
  emits: ["update:modelValue"],
123
111
  setup(o, { emit: e }) {
124
- const n = o, r = e, a = oe({
112
+ const t = o, l = e, a = se({
125
113
  providers: [
126
114
  {
127
- provide: le,
128
- useClass: re
115
+ provide: ue,
116
+ useClass: ce
129
117
  }
130
118
  ]
131
119
  });
132
- L(P, a);
133
- const t = B(void 0);
134
- return N(
135
- () => [n.schema, n.options],
136
- ([l, c], R, b) => {
137
- const p = ae({ providers: [], parent: a }), u = ne(l, {
138
- handle: ie,
139
- builder: de,
120
+ N($, a);
121
+ const n = B(void 0);
122
+ return z(
123
+ () => [t.schema, t.options],
124
+ ([r, c], x, b) => {
125
+ const p = ie({ providers: [], parent: a }), u = re(r, {
126
+ handle: fe,
127
+ builder: me,
140
128
  injector: p,
141
129
  registerOnDestroy: (h) => {
142
- p.get(se).onDestroy(() => {
130
+ p.get(de).onDestroy(() => {
143
131
  h();
144
132
  });
145
133
  },
146
134
  ...c
147
135
  });
148
- t.value = u;
136
+ n.value = u;
149
137
  let y;
150
138
  if (u.form.control) {
151
- const h = n.modelValue;
152
- y = pe(
139
+ const h = t.modelValue;
140
+ y = le(
153
141
  typeof h < "u" ? h : void 0,
154
142
  u.form.control,
155
143
  p,
156
144
  (i) => {
157
- ce(() => {
145
+ pe(() => {
158
146
  var s;
159
- (s = u.form.control) != null && s.valueNoError$$() && r("update:modelValue", i);
147
+ (s = u.form.control) != null && s.valueNoError$$() && l("update:modelValue", i);
160
148
  });
161
149
  }
162
150
  );
@@ -167,62 +155,61 @@ const he = /* @__PURE__ */ I({
167
155
  },
168
156
  { immediate: !0 }
169
157
  ), O(() => {
170
- var l;
171
- (l = t.value.form.control) == null || l.updateValue(n.modelValue);
172
- }), (l, c) => (d(), _(q, {
173
- field: t.value
158
+ var r;
159
+ (r = n.value.form.control) == null || r.updateValue(t.modelValue);
160
+ }), (r, c) => (d(), _(W, {
161
+ field: n.value
174
162
  }, null, 8, ["field"]));
175
163
  }
176
164
  });
177
- function ge() {
178
- const o = $(), e = $(!1);
179
- let n, r;
165
+ function Ce() {
166
+ const o = D(), e = D(!1);
167
+ let t, l;
180
168
  return {
181
169
  cva: {
182
- writeValue(t) {
183
- o.value = t;
170
+ writeValue(n) {
171
+ o.value = n;
184
172
  },
185
- registerOnChange(t) {
186
- n = t;
173
+ registerOnChange(n) {
174
+ t = n;
187
175
  },
188
- registerOnTouched(t) {
189
- r = t;
176
+ registerOnTouched(n) {
177
+ l = n;
190
178
  },
191
- setDisabledState(t) {
192
- e.value = t;
179
+ setDisabledState(n) {
180
+ e.value = n;
193
181
  }
194
182
  },
195
183
  cvaa: {
196
184
  value: o,
197
185
  disabled: e,
198
- valueChange: (t) => {
199
- n(t), o.value = t;
186
+ valueChange: (n) => {
187
+ t(n), o.value = n;
200
188
  },
201
189
  touchedChange: () => {
202
- r();
190
+ l();
203
191
  }
204
192
  }
205
193
  };
206
194
  }
207
- const Ce = /* @__PURE__ */ I({
195
+ const we = /* @__PURE__ */ I({
208
196
  __name: "group",
209
197
  setup(o) {
210
- const e = E(A), n = v(() => e == null ? void 0 : e.value.children());
211
- return (r, a) => (d(!0), D(S, null, X(m(n), (t, l) => (d(), _(q, {
212
- key: l,
213
- field: t
198
+ const e = R(H), t = v(() => e == null ? void 0 : e.value.children());
199
+ return (l, a) => (d(!0), S(P, null, X(m(t), (n, r) => (d(), _(W, {
200
+ key: r,
201
+ field: n
214
202
  }, null, 8, ["field"]))), 128));
215
203
  }
216
204
  });
217
205
  export {
218
- P as InjectorToken,
219
- A as PI_VIEW_FIELD_TOKEN,
220
- q as PiyingFieldTemplate,
221
- he as PiyingView,
222
- Ce as PiyingViewGroup,
223
- de as VueFormBuilder,
224
- ie as VueSchemaHandle,
225
- pe as initListen,
206
+ $ as InjectorToken,
207
+ H as PI_VIEW_FIELD_TOKEN,
208
+ W as PiyingFieldTemplate,
209
+ ge as PiyingView,
210
+ we as PiyingViewGroup,
211
+ me as VueFormBuilder,
212
+ fe as VueSchemaHandle,
226
213
  v as signalToRef,
227
- ge as useControlValueAccessor
214
+ Ce as useControlValueAccessor
228
215
  };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@piying/view-vue",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Piying view For Vue;Valibot to Component",
5
5
  "type": "module",
6
6
  "homepage": "https://piying-org.github.io/website/docs/client/intro",
7
7
  "repository": {
8
- "url": "https://github.com/piying-org/piying-view",
8
+ "url": "git+https://github.com/piying-org/piying-view.git",
9
9
  "directory": "packages/vue",
10
10
  "type": "git"
11
11
  },
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "license": "MIT",
38
38
  "dependencies": {
39
- "@piying/view-core": "^1.3.2",
39
+ "@piying/view-core": "^1.4.0",
40
40
  "fast-equals": "^5.2.2",
41
41
  "rfdc": "^1.4.1",
42
42
  "static-injector": "^6.1.2"
package/util/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './init-listen';
2
1
  export * from './signal-convert';
3
2
  export * from './use-control-value-accessor';
@@ -1,3 +0,0 @@
1
- import type { Injector } from 'static-injector';
2
- import { AbstractControl } from '@piying/view-core';
3
- export declare function initListen(input: any, control: AbstractControl, injector: Injector, fn: (input: any) => void): import("static-injector").EffectRef;