vue-formless 0.1.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.en.md +130 -0
- package/README.md +136 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +278 -422
- package/dist/index.js +618 -834
- package/docs/mixed-layout-code.png +0 -0
- package/docs/mixed-layout-preview.png +0 -0
- package/package.json +6 -19
package/dist/index.js
CHANGED
|
@@ -1,191 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
if (!e)
|
|
6
|
-
throw new Error("[vue-formless] useFormContext() must be used inside <FormView>.");
|
|
7
|
-
return e;
|
|
8
|
-
}
|
|
9
|
-
function ue(e) {
|
|
10
|
-
if (!e) return [];
|
|
11
|
-
const t = [];
|
|
12
|
-
let o = 0;
|
|
13
|
-
for (; o < e.length; ) {
|
|
14
|
-
if (e[o] === ".") {
|
|
15
|
-
o++;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
if (e[o] === "[") {
|
|
19
|
-
const n = e.indexOf("]", o + 1);
|
|
20
|
-
if (n === -1)
|
|
21
|
-
throw new Error(`Invalid path "${e}": unclosed bracket`);
|
|
22
|
-
const r = e.slice(o + 1, n), l = Number(r);
|
|
23
|
-
if (!Number.isInteger(l) || String(l) !== r || l < 0)
|
|
24
|
-
throw new Error(`Invalid path "${e}": index must be a non-negative integer`);
|
|
25
|
-
t.push({ type: "index", index: l }), o = n + 1;
|
|
26
|
-
} else {
|
|
27
|
-
const n = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(e.slice(o));
|
|
28
|
-
if (!n)
|
|
29
|
-
throw new Error(`Invalid path "${e}" at position ${o}`);
|
|
30
|
-
t.push({ type: "key", key: n[0] }), o += n[0].length;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
1
|
+
import { onMounted as U, toValue as h, watch as z, onBeforeUnmount as K, ref as C, defineComponent as S, inject as T, computed as f, createVNode as b, Fragment as W, mergeProps as k, provide as w, markRaw as j, nextTick as re, useAttrs as ue, isVNode as oe } from "vue";
|
|
2
|
+
const A = 24, le = 1;
|
|
3
|
+
function V(e) {
|
|
4
|
+
return Math.min(A, Math.max(1, e));
|
|
34
5
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
for (const n of t)
|
|
38
|
-
n.type === "key" ? o = o[n.key] : o = o[n.index];
|
|
39
|
-
return o;
|
|
40
|
-
}
|
|
41
|
-
function He(e, t) {
|
|
42
|
-
if (t.type === "key")
|
|
43
|
-
return e == null || typeof e != "object" || Array.isArray(e) ? void 0 : e[t.key];
|
|
44
|
-
if (Array.isArray(e))
|
|
45
|
-
return e[t.index];
|
|
46
|
-
}
|
|
47
|
-
function B(e, t) {
|
|
48
|
-
const o = ue(t);
|
|
49
|
-
if (o.length === 0) return;
|
|
50
|
-
const n = o[o.length - 1], r = ze(e, o.slice(0, -1));
|
|
51
|
-
return He(r, n);
|
|
52
|
-
}
|
|
53
|
-
function oe(e, t, o, n) {
|
|
54
|
-
const r = t[o], l = o === t.length - 1;
|
|
55
|
-
if (r.type === "key") {
|
|
56
|
-
if (Array.isArray(e))
|
|
57
|
-
throw new Error(`Cannot set "${r.key}" on an array node`);
|
|
58
|
-
const u = e != null && typeof e == "object" ? e : {};
|
|
59
|
-
return l ? { ...u, [r.key]: n } : {
|
|
60
|
-
...u,
|
|
61
|
-
[r.key]: oe(u[r.key], t, o + 1, n)
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const s = Array.isArray(e) ? [...e] : [];
|
|
65
|
-
return l ? (s[r.index] = n, s) : (s[r.index] = oe(s[r.index], t, o + 1, n), s);
|
|
66
|
-
}
|
|
67
|
-
function De(e, t, o) {
|
|
68
|
-
const n = ue(t);
|
|
69
|
-
if (n.length === 0)
|
|
70
|
-
throw new Error("Cannot set an empty prop");
|
|
71
|
-
return oe(e, n, 0, o);
|
|
72
|
-
}
|
|
73
|
-
function Ke(e) {
|
|
74
|
-
return ue(e).map((t) => t.type === "key" ? t.key : String(t.index)).join(".");
|
|
75
|
-
}
|
|
76
|
-
function Xe(e, t) {
|
|
77
|
-
let o = null;
|
|
78
|
-
function n(r, l) {
|
|
79
|
-
o || (o = [], We(() => {
|
|
80
|
-
if (!o?.length) {
|
|
81
|
-
o = null;
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
let s = e();
|
|
85
|
-
for (const u of o)
|
|
86
|
-
s = De(s, u.prop, u.value);
|
|
87
|
-
o = null, t(s);
|
|
88
|
-
})), o.push({ prop: r, value: l });
|
|
89
|
-
}
|
|
90
|
-
return { update: n };
|
|
6
|
+
function ie(e) {
|
|
7
|
+
return Math.floor(A / Y(e));
|
|
91
8
|
}
|
|
92
|
-
|
|
93
|
-
column: 1
|
|
94
|
-
};
|
|
95
|
-
function qe(e) {
|
|
9
|
+
function Y(e) {
|
|
96
10
|
const t = Math.floor(Number(e));
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
function Ze(...e) {
|
|
100
|
-
return qe(e.find((t) => t != null) ?? P.column);
|
|
101
|
-
}
|
|
102
|
-
function Je(e, t) {
|
|
103
|
-
const o = t > 0 ? t : P.column, n = Math.max(1, Math.floor(d / o));
|
|
104
|
-
if (e == null || e === "") return n;
|
|
105
|
-
if (typeof e == "number")
|
|
106
|
-
return me(e), e;
|
|
107
|
-
const r = e.trim();
|
|
108
|
-
if (r === "max") return d;
|
|
109
|
-
const l = /^(\d+)x$/.exec(r);
|
|
110
|
-
if (l) {
|
|
111
|
-
const s = Number(l[1]);
|
|
112
|
-
if (s < 1)
|
|
113
|
-
throw new Error(`[vue-formless] col:span "${e}" is invalid`);
|
|
114
|
-
return Math.min(d, s * n);
|
|
115
|
-
}
|
|
116
|
-
if (/^\d+$/.test(r)) {
|
|
117
|
-
const s = Number(r);
|
|
118
|
-
return me(s), s;
|
|
119
|
-
}
|
|
120
|
-
throw new Error(`[vue-formless] col:span "${e}" is invalid`);
|
|
11
|
+
return Number.isNaN(t) ? le : V(t);
|
|
121
12
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
13
|
+
function ae(...e) {
|
|
14
|
+
return Y([...e].reverse().find((t) => t != null));
|
|
15
|
+
}
|
|
16
|
+
function se(e, t) {
|
|
17
|
+
const n = ie(t);
|
|
18
|
+
if (typeof e != "number" && typeof e != "string" || (e = typeof e == "string" ? e.trim().toLowerCase() : e, e === "")) return n;
|
|
19
|
+
if (e === "max") return A;
|
|
20
|
+
if (typeof e == "string" && e.endsWith("x")) {
|
|
21
|
+
const r = Math.floor(Number(e.substring(0, e.length - 1)));
|
|
22
|
+
return Number.isNaN(r) ? n : V(V(r) * n);
|
|
23
|
+
}
|
|
24
|
+
return e = Math.floor(Number(e)), Number.isNaN(e) ? n : V(e);
|
|
125
25
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
if (e === "start" || e === "end") return e;
|
|
129
|
-
throw new Error(`[vue-formless] col:place "${String(e)}" is invalid`);
|
|
26
|
+
function fe(e) {
|
|
27
|
+
return e = typeof e == "string" ? e.trim().toLowerCase() : e, e === "start" || e === "end" ? e : "auto";
|
|
130
28
|
}
|
|
131
|
-
const
|
|
29
|
+
const R = Symbol(
|
|
132
30
|
"vue-formless:layout-view"
|
|
133
31
|
);
|
|
134
|
-
function
|
|
32
|
+
function ce(e) {
|
|
33
|
+
return e.reduce((t, n, r) => {
|
|
34
|
+
const u = t[r - 1], i = u ? u.$start + u.$occupied : 0, a = i % A, c = de({ cursor: a, span: n.span, place: n.place });
|
|
35
|
+
return t.push({
|
|
36
|
+
...n,
|
|
37
|
+
$start: i,
|
|
38
|
+
$occupied: c
|
|
39
|
+
}), t;
|
|
40
|
+
}, []);
|
|
41
|
+
}
|
|
42
|
+
function de({
|
|
43
|
+
cursor: e,
|
|
44
|
+
place: t,
|
|
45
|
+
span: n
|
|
46
|
+
}) {
|
|
47
|
+
const r = A - e;
|
|
48
|
+
return t === "start" ? e === 0 ? n : r + n : t === "end" ? r >= n ? r : r + A : r >= n ? n : r + n;
|
|
49
|
+
}
|
|
50
|
+
function me(e, t, n) {
|
|
51
|
+
const r = e % A, u = r + t > A ? A - r : 0, i = t - u - n;
|
|
52
|
+
return [u, i].filter((a) => a > 0);
|
|
53
|
+
}
|
|
54
|
+
function pe(e, t, n = { childList: !0 }) {
|
|
135
55
|
if (typeof MutationObserver > "u") return;
|
|
136
|
-
let
|
|
137
|
-
function
|
|
138
|
-
|
|
56
|
+
let r = null;
|
|
57
|
+
function u(a) {
|
|
58
|
+
r?.disconnect(), r = null, a && (r = new MutationObserver(t), r.observe(a, n));
|
|
139
59
|
}
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
60
|
+
U(() => u(h(e)));
|
|
61
|
+
const i = z(() => h(e), u, { flush: "post" });
|
|
62
|
+
K(() => {
|
|
63
|
+
i(), r?.disconnect(), r = null;
|
|
144
64
|
});
|
|
145
65
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
function
|
|
149
|
-
const
|
|
150
|
-
|
|
66
|
+
function ye(e, t = 0) {
|
|
67
|
+
const n = C([]);
|
|
68
|
+
function r() {
|
|
69
|
+
const u = h(e);
|
|
70
|
+
n.value = u ? Array.from(u.children) : [];
|
|
151
71
|
}
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
function nt(e, t, o) {
|
|
155
|
-
const n = [];
|
|
156
|
-
if (o === "auto")
|
|
157
|
-
return e.n + t > d && (e.n = 0), n;
|
|
158
|
-
if (o === "start")
|
|
159
|
-
return e.n > 0 && (n.push(d - e.n), e.n = 0), n;
|
|
160
|
-
e.n + t > d && e.n > 0 && (n.push(d - e.n), e.n = 0);
|
|
161
|
-
const r = d - e.n - t;
|
|
162
|
-
return r > 0 && (n.push(r), e.n += r), n;
|
|
163
|
-
}
|
|
164
|
-
function ot(e) {
|
|
165
|
-
return x(() => {
|
|
166
|
-
const t = { n: 0 }, o = /* @__PURE__ */ new Map();
|
|
167
|
-
for (const n of v(e)) {
|
|
168
|
-
const r = nt(t, n.span, n.place);
|
|
169
|
-
o.set(n.id, r), t.n += n.span;
|
|
170
|
-
}
|
|
171
|
-
return o;
|
|
172
|
-
});
|
|
72
|
+
return z(() => [h(e), h(t)], r, { immediate: !0 }), pe(e, r), n;
|
|
173
73
|
}
|
|
174
|
-
function
|
|
74
|
+
function H(e) {
|
|
175
75
|
if (e == null || typeof e != "object") return null;
|
|
176
76
|
if (typeof Element < "u" && e instanceof Element) return e;
|
|
177
|
-
const t = e;
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
function z(e) {
|
|
181
|
-
if (typeof Element < "u" && e instanceof Element) return e;
|
|
182
|
-
if (e && e.nodeType === 8) {
|
|
183
|
-
for (let t = e.nextSibling; t; t = t.nextSibling)
|
|
184
|
-
if (typeof Element < "u" && t instanceof Element) return t;
|
|
185
|
-
}
|
|
186
|
-
return null;
|
|
77
|
+
const t = e.$el;
|
|
78
|
+
return typeof Element < "u" && t instanceof Element ? t : null;
|
|
187
79
|
}
|
|
188
|
-
const
|
|
80
|
+
const q = /* @__PURE__ */ S({
|
|
189
81
|
name: "LayoutBlanks",
|
|
190
82
|
inheritAttrs: !1,
|
|
191
83
|
props: {
|
|
@@ -202,13 +94,15 @@ const rt = /* @__PURE__ */ I({
|
|
|
202
94
|
return () => {
|
|
203
95
|
if (e.spans.length === 0 || e.is == null) return null;
|
|
204
96
|
const t = e.is;
|
|
205
|
-
return
|
|
206
|
-
key:
|
|
207
|
-
span:
|
|
97
|
+
return b(W, null, [e.spans.map((n, r) => b(t, {
|
|
98
|
+
key: r,
|
|
99
|
+
span: n,
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
"data-layout-blank": ""
|
|
208
102
|
}, null))]);
|
|
209
103
|
};
|
|
210
104
|
}
|
|
211
|
-
}),
|
|
105
|
+
}), ve = /* @__PURE__ */ S({
|
|
212
106
|
name: "LayoutItem",
|
|
213
107
|
inheritAttrs: !1,
|
|
214
108
|
props: {
|
|
@@ -222,93 +116,104 @@ const rt = /* @__PURE__ */ I({
|
|
|
222
116
|
}
|
|
223
117
|
},
|
|
224
118
|
setup(e, {
|
|
225
|
-
slots: t
|
|
119
|
+
slots: t,
|
|
120
|
+
attrs: n,
|
|
121
|
+
expose: r
|
|
226
122
|
}) {
|
|
227
|
-
const
|
|
228
|
-
if (!
|
|
123
|
+
const u = T(R, null);
|
|
124
|
+
if (!u) return () => t.default?.() ?? null;
|
|
229
125
|
const {
|
|
230
|
-
span:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
Col:
|
|
234
|
-
disabled:
|
|
235
|
-
|
|
126
|
+
span: i,
|
|
127
|
+
blank: a,
|
|
128
|
+
ref: c,
|
|
129
|
+
Col: l,
|
|
130
|
+
disabled: s,
|
|
131
|
+
place: d
|
|
132
|
+
} = u(() => e.span, () => e.place), m = C(null);
|
|
133
|
+
r({
|
|
134
|
+
el: f(() => H(m.value))
|
|
135
|
+
});
|
|
136
|
+
function y(p) {
|
|
137
|
+
m.value = p, c(p);
|
|
138
|
+
}
|
|
236
139
|
return () => {
|
|
237
|
-
if (
|
|
238
|
-
const
|
|
239
|
-
return
|
|
240
|
-
is:
|
|
241
|
-
spans:
|
|
242
|
-
}, null),
|
|
243
|
-
ref:
|
|
244
|
-
span:
|
|
245
|
-
|
|
140
|
+
if (s.value) return t.default?.() ?? null;
|
|
141
|
+
const p = l;
|
|
142
|
+
return b(W, null, [b(q, {
|
|
143
|
+
is: l,
|
|
144
|
+
spans: a.value.before
|
|
145
|
+
}, null), b(p, k(n, {
|
|
146
|
+
ref: y,
|
|
147
|
+
span: i.value,
|
|
148
|
+
"data-layout-item": "",
|
|
149
|
+
"data-layout-place": d.value
|
|
150
|
+
}), {
|
|
246
151
|
default: () => [t.default?.() ?? null]
|
|
247
|
-
})
|
|
152
|
+
}), b(q, {
|
|
153
|
+
is: l,
|
|
154
|
+
spans: a.value.after
|
|
155
|
+
}, null)]);
|
|
248
156
|
};
|
|
249
157
|
}
|
|
250
|
-
}), st = /* @__PURE__ */ I({
|
|
251
|
-
name: "LayoutItemPassThrough",
|
|
252
|
-
inheritAttrs: !1,
|
|
253
|
-
setup(e, {
|
|
254
|
-
slots: t
|
|
255
|
-
}) {
|
|
256
|
-
return () => t.default?.() ?? null;
|
|
257
|
-
}
|
|
258
158
|
});
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
159
|
+
function be({
|
|
160
|
+
column: e,
|
|
161
|
+
rowRef: t
|
|
162
|
+
}) {
|
|
163
|
+
let n = 0;
|
|
164
|
+
const r = C({}), u = ye(() => H(t.value), () => Object.keys(r.value).filter((l) => r.value[l].mounted).join(",")), i = f(() => ge(r.value, u.value)), a = f(() => ce(i.value)), c = f(() => new Map(a.value.map((l) => [l.id, me(l.$start, l.$occupied, l.span)])));
|
|
265
165
|
return {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return t.value[l] = {
|
|
272
|
-
span: s,
|
|
273
|
-
place: u,
|
|
166
|
+
setup(l, s) {
|
|
167
|
+
const d = String(++n);
|
|
168
|
+
return r.value[d] = {
|
|
169
|
+
span: f(() => se(h(l), h(e))),
|
|
170
|
+
place: f(() => fe(h(s))),
|
|
274
171
|
el: null,
|
|
275
172
|
mounted: !1
|
|
276
|
-
},
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
}),
|
|
280
|
-
delete
|
|
281
|
-
}),
|
|
173
|
+
}, U(() => {
|
|
174
|
+
const m = r.value[d];
|
|
175
|
+
m && (m.mounted = !0);
|
|
176
|
+
}), K(() => {
|
|
177
|
+
delete r.value[d];
|
|
178
|
+
}), d;
|
|
179
|
+
},
|
|
180
|
+
span(l) {
|
|
181
|
+
return r.value[l]?.span ?? 0;
|
|
282
182
|
},
|
|
283
|
-
|
|
284
|
-
return
|
|
183
|
+
blank(l) {
|
|
184
|
+
return {
|
|
185
|
+
before: c.value.get(l) ?? [],
|
|
186
|
+
after: []
|
|
187
|
+
};
|
|
285
188
|
},
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
189
|
+
place(l) {
|
|
190
|
+
return r.value[l]?.place ?? "unknown";
|
|
191
|
+
},
|
|
192
|
+
ref(l, s) {
|
|
193
|
+
const d = r.value[l];
|
|
194
|
+
if (!d) return;
|
|
195
|
+
const m = H(s);
|
|
196
|
+
d.el !== m && (d.el = m);
|
|
197
|
+
},
|
|
198
|
+
placed(l) {
|
|
199
|
+
return a.value.findIndex((s) => s.id === l) > -1;
|
|
291
200
|
}
|
|
292
201
|
};
|
|
293
202
|
}
|
|
294
|
-
function
|
|
295
|
-
const
|
|
296
|
-
id:
|
|
297
|
-
span:
|
|
298
|
-
place:
|
|
203
|
+
function ge(e, t) {
|
|
204
|
+
const n = new Map(Object.entries(e).filter(([, r]) => r.el).map(([r, u]) => [u.el, {
|
|
205
|
+
id: r,
|
|
206
|
+
span: u.span,
|
|
207
|
+
place: u.place
|
|
299
208
|
}]));
|
|
300
|
-
return t.filter((
|
|
301
|
-
}
|
|
302
|
-
function ct(e, t) {
|
|
303
|
-
const o = tt(() => Ee(t.value), () => Object.keys(e.value).filter((n) => e.value[n].mounted).join(","));
|
|
304
|
-
return ot(() => at(e.value, o.value));
|
|
209
|
+
return t.filter((r) => n.has(r)).map((r) => n.get(r));
|
|
305
210
|
}
|
|
306
|
-
function
|
|
211
|
+
function Ie(e = {}) {
|
|
307
212
|
const {
|
|
308
213
|
Row: t,
|
|
309
|
-
Col:
|
|
214
|
+
Col: n
|
|
310
215
|
} = e;
|
|
311
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ S({
|
|
312
217
|
name: "LayoutView",
|
|
313
218
|
inheritAttrs: !1,
|
|
314
219
|
props: {
|
|
@@ -321,640 +226,519 @@ function Ce(e = {}) {
|
|
|
321
226
|
default: void 0
|
|
322
227
|
}
|
|
323
228
|
},
|
|
324
|
-
setup(
|
|
325
|
-
slots:
|
|
326
|
-
attrs:
|
|
229
|
+
setup(r, {
|
|
230
|
+
slots: u,
|
|
231
|
+
attrs: i
|
|
327
232
|
}) {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
233
|
+
const a = f(() => !t || !n || r.disabled), c = f(() => ae(e.column, r.column)), l = C(null), s = be({
|
|
234
|
+
column: c,
|
|
235
|
+
rowRef: l
|
|
236
|
+
});
|
|
237
|
+
return w(R, (d, m) => {
|
|
238
|
+
w(R, null);
|
|
239
|
+
const y = s.setup(d, m);
|
|
332
240
|
return {
|
|
333
|
-
span:
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
241
|
+
span: f(() => s.span(y)),
|
|
242
|
+
blank: f(() => s.blank(y)),
|
|
243
|
+
ref: (p) => s.ref(y, p),
|
|
244
|
+
place: f(() => s.place(y)),
|
|
245
|
+
placed: f(() => s.placed(y)),
|
|
246
|
+
Col: n,
|
|
247
|
+
disabled: a
|
|
338
248
|
};
|
|
339
|
-
}), () =>
|
|
340
|
-
ref:
|
|
341
|
-
},
|
|
342
|
-
|
|
249
|
+
}), () => a.value ? u.default?.() ?? null : b(t, k({
|
|
250
|
+
ref: l
|
|
251
|
+
}, i, {
|
|
252
|
+
"data-layout-row": ""
|
|
253
|
+
}), {
|
|
254
|
+
default: () => [u.default?.() ?? null]
|
|
343
255
|
});
|
|
344
256
|
}
|
|
345
257
|
});
|
|
346
258
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
259
|
+
function he(e = {}) {
|
|
260
|
+
const t = e.component ? j(e.component) : void 0;
|
|
261
|
+
return /* @__PURE__ */ S({
|
|
262
|
+
name: "FormItem",
|
|
263
|
+
inheritAttrs: !1,
|
|
264
|
+
props: {
|
|
265
|
+
fl: {
|
|
266
|
+
type: Object,
|
|
267
|
+
required: !0
|
|
268
|
+
},
|
|
269
|
+
item: {
|
|
270
|
+
type: Object,
|
|
271
|
+
required: !0
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
setup(n, {
|
|
275
|
+
slots: r
|
|
276
|
+
}) {
|
|
277
|
+
return () => {
|
|
278
|
+
if (!t || !n.fl?.item) return r.default?.() ?? null;
|
|
279
|
+
const u = t, i = typeof e.props == "function" ? e.props(n.fl) : e.props;
|
|
280
|
+
return b(u, {
|
|
281
|
+
...i,
|
|
282
|
+
...n.item
|
|
283
|
+
}, r);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
});
|
|
361
287
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
288
|
+
const $ = Symbol(
|
|
289
|
+
"vue-formless:form-view"
|
|
290
|
+
), P = Symbol(
|
|
291
|
+
"vue-formless:form-field"
|
|
292
|
+
), N = Symbol("EOF"), I = Symbol("failed"), Ae = /[a-zA-Z_$0-9]/, Fe = /[a-zA-Z0-9_$]/, Oe = /[0-9]/;
|
|
293
|
+
function G(e) {
|
|
294
|
+
if (!e) return;
|
|
295
|
+
const t = [];
|
|
296
|
+
let n = "", r = "", u = 0;
|
|
297
|
+
function i(o) {
|
|
298
|
+
if (o === "[") return s;
|
|
299
|
+
if (o !== N)
|
|
300
|
+
return typeof o == "string" && Ae.test(o) ? (n = o, l) : I;
|
|
301
|
+
}
|
|
302
|
+
function a(o) {
|
|
303
|
+
return o === "." ? c : i(o);
|
|
304
|
+
}
|
|
305
|
+
function c(o) {
|
|
306
|
+
return o === N || o === "." ? I : i(o);
|
|
307
|
+
}
|
|
308
|
+
function l(o) {
|
|
309
|
+
return typeof o == "string" && Fe.test(o) ? (n += o, l) : (t.push({ type: "key", key: n }), n = "", a(o));
|
|
310
|
+
}
|
|
311
|
+
function s(o) {
|
|
312
|
+
if (o === N) return I;
|
|
313
|
+
if (typeof o == "string" && (o === '"' || o === "'"))
|
|
314
|
+
return r = o, n = "", d;
|
|
315
|
+
if (typeof o == "string" && Oe.test(o))
|
|
316
|
+
return n += o, s;
|
|
317
|
+
if (o !== "]") return I;
|
|
318
|
+
const v = Number(n);
|
|
319
|
+
return n === "" || String(v) !== n || v < 0 ? I : (t.push({ type: "index", index: v }), n = "", a);
|
|
320
|
+
}
|
|
321
|
+
function d(o) {
|
|
322
|
+
return o === N ? I : o === "\\" ? m : o === r ? y : (n += o, d);
|
|
323
|
+
}
|
|
324
|
+
function m(o) {
|
|
325
|
+
return o === N ? I : (n += o, d);
|
|
326
|
+
}
|
|
327
|
+
function y(o) {
|
|
328
|
+
return o === N || o !== "]" ? I : (t.push({ type: "key", key: n }), n = "", a);
|
|
329
|
+
}
|
|
330
|
+
let p = i;
|
|
331
|
+
for (; u < e.length; u++) {
|
|
332
|
+
const o = p(e[u]);
|
|
333
|
+
if (o === I) return;
|
|
334
|
+
p = o;
|
|
335
|
+
}
|
|
336
|
+
if (p(N) !== I)
|
|
337
|
+
return t;
|
|
367
338
|
}
|
|
368
|
-
function
|
|
369
|
-
|
|
370
|
-
for (const [o, n] of Object.entries(e))
|
|
371
|
-
!mt.has(o) && n !== void 0 && (t[o] = n);
|
|
372
|
-
return t;
|
|
339
|
+
function Z(e) {
|
|
340
|
+
return typeof e == "object" && e !== null;
|
|
373
341
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (t == null || typeof t != "object") return {};
|
|
378
|
-
const { model: o, item: n } = t;
|
|
379
|
-
return re({ model: o, item: n });
|
|
342
|
+
const Ee = Object.prototype.hasOwnProperty;
|
|
343
|
+
function Le(e, t) {
|
|
344
|
+
return Ee.call(e, t) ? e[t] : void 0;
|
|
380
345
|
}
|
|
381
|
-
function
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
346
|
+
function X(e, t) {
|
|
347
|
+
if (Z(e)) {
|
|
348
|
+
if (t.type === "key")
|
|
349
|
+
return Array.isArray(e) ? void 0 : Le(e, t.key);
|
|
350
|
+
if (t.type === "index")
|
|
351
|
+
return Array.isArray(e) ? e[t.index] : void 0;
|
|
352
|
+
}
|
|
386
353
|
}
|
|
387
|
-
function
|
|
388
|
-
|
|
389
|
-
for (const r of t)
|
|
390
|
-
o.add(r), o.add(`onUpdate:${r}`);
|
|
391
|
-
const n = {};
|
|
392
|
-
for (const [r, l] of Object.entries(e))
|
|
393
|
-
o.has(r) || (n[r] = l);
|
|
354
|
+
function Ne(e, t) {
|
|
355
|
+
let n = e;
|
|
356
|
+
for (const r of t) n = X(n, r);
|
|
394
357
|
return n;
|
|
395
358
|
}
|
|
396
|
-
function
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
K(e.itemProps, n.fl),
|
|
413
|
-
n.itemAttrs,
|
|
414
|
-
n.itemOn
|
|
415
|
-
),
|
|
416
|
-
{
|
|
417
|
-
...n.itemSlots,
|
|
418
|
-
default: () => o
|
|
419
|
-
}
|
|
420
|
-
) : o;
|
|
421
|
-
}
|
|
422
|
-
function de(e) {
|
|
423
|
-
return typeof e == "string" ? [e] : [...e];
|
|
424
|
-
}
|
|
425
|
-
function Se(e, t = {}, o = {}) {
|
|
426
|
-
if (o.prop === "")
|
|
427
|
-
throw new Error(`[vue-formless] fl:prop cannot be an empty string (control "${e}")`);
|
|
428
|
-
if (t.prop === "")
|
|
429
|
-
throw new Error(`[vue-formless] prop cannot be an empty string (control "${e}")`);
|
|
430
|
-
const n = de(t.model ?? "modelValue"), r = de(
|
|
431
|
-
o.prop !== void 0 ? o.prop : t.prop ?? e
|
|
359
|
+
function Se(e, t) {
|
|
360
|
+
const n = G(t);
|
|
361
|
+
return n ? Ne(e, n) : void 0;
|
|
362
|
+
}
|
|
363
|
+
function Ce(e, t, n) {
|
|
364
|
+
const r = G(t);
|
|
365
|
+
return r ? J(e, r, n) : e;
|
|
366
|
+
}
|
|
367
|
+
function J(e, t, n) {
|
|
368
|
+
if (!t.length) return e;
|
|
369
|
+
if (t.length === 1) return D(e, t[0], n);
|
|
370
|
+
const [r, ...u] = t;
|
|
371
|
+
return D(
|
|
372
|
+
e,
|
|
373
|
+
r,
|
|
374
|
+
J(X(e, r), u, n)
|
|
432
375
|
);
|
|
433
|
-
if (r.length > n.length)
|
|
434
|
-
throw new Error(
|
|
435
|
-
`createFormControls: prop cannot be longer than model (control "${e}": model has ${n.length}, prop has ${r.length})`
|
|
436
|
-
);
|
|
437
|
-
if (r.some((l) => l === ""))
|
|
438
|
-
throw new Error(`[vue-formless] prop cannot be an empty string (control "${e}")`);
|
|
439
|
-
return { models: n, props: r };
|
|
440
|
-
}
|
|
441
|
-
function Mt(e, t) {
|
|
442
|
-
return e.props.length === 1 ? Ke(e.props[0]) : t;
|
|
443
|
-
}
|
|
444
|
-
function gt(e, t) {
|
|
445
|
-
const o = e.models.indexOf(t);
|
|
446
|
-
if (o === -1)
|
|
447
|
-
throw new Error(
|
|
448
|
-
`[vue-formless] useFormItem("${t}"): not a v-model port of this control`
|
|
449
|
-
);
|
|
450
|
-
const n = e.props[o];
|
|
451
|
-
if (n === void 0)
|
|
452
|
-
throw new Error(
|
|
453
|
-
`[vue-formless] useFormItem("${t}"): port is not bound to a prop`
|
|
454
|
-
);
|
|
455
|
-
return { models: [t], props: [n] };
|
|
456
|
-
}
|
|
457
|
-
function Ae(e, t, o) {
|
|
458
|
-
const n = {};
|
|
459
|
-
for (let r = 0; r < t.props.length; r++) {
|
|
460
|
-
const l = t.models[r], s = t.props[r];
|
|
461
|
-
n[l] = B(e, s), n[`onUpdate:${l}`] = (u) => {
|
|
462
|
-
o(s, u);
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
return n;
|
|
466
376
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
for (const n of Object.keys(e)) {
|
|
474
|
-
const r = e[n];
|
|
475
|
-
r && (n.startsWith($) && n.length > $.length ? t[n.slice($.length)] = r : o[n] = r);
|
|
377
|
+
function D(e, t, n) {
|
|
378
|
+
if (t.type === "key")
|
|
379
|
+
return { ...Z(e) && !Array.isArray(e) ? e : {}, [t.key]: n };
|
|
380
|
+
if (t.type === "index") {
|
|
381
|
+
const r = Array.isArray(e) ? [...e] : [];
|
|
382
|
+
return r[t.index] = n, r;
|
|
476
383
|
}
|
|
477
|
-
return
|
|
478
|
-
}
|
|
479
|
-
function Le(e) {
|
|
480
|
-
const t = {}, o = {};
|
|
481
|
-
for (const [n, r] of Object.entries(e))
|
|
482
|
-
n.startsWith(ee) && n.length > ee.length ? t[n.slice(ee.length)] = r : o[n] = r;
|
|
483
|
-
return { fl: t, rest: o };
|
|
484
|
-
}
|
|
485
|
-
function Ve(e) {
|
|
486
|
-
const t = {}, o = {}, n = {};
|
|
487
|
-
for (const [r, l] of Object.entries(e))
|
|
488
|
-
if (r.startsWith(te) && r.length > te.length) {
|
|
489
|
-
const s = r.slice(te.length);
|
|
490
|
-
ht.has(s) ? t[s] = l : pe(`[vue-formless] unknown row:${s} is ignored`);
|
|
491
|
-
} else if (r.startsWith(ne) && r.length > ne.length) {
|
|
492
|
-
const s = r.slice(ne.length);
|
|
493
|
-
vt.has(s) ? o[s] = l : pe(`[vue-formless] unknown col:${s} is ignored`);
|
|
494
|
-
} else
|
|
495
|
-
n[r] = l;
|
|
496
|
-
return { row: t, col: o, rest: n };
|
|
497
|
-
}
|
|
498
|
-
function we(e) {
|
|
499
|
-
if (e == null || e === "") return;
|
|
500
|
-
const t = typeof e == "number" ? e : Number(e);
|
|
501
|
-
if (Number.isFinite(t))
|
|
502
|
-
return t;
|
|
503
|
-
}
|
|
504
|
-
function ke(e) {
|
|
505
|
-
const t = {}, o = {}, n = {};
|
|
506
|
-
for (const [r, l] of Object.entries(e))
|
|
507
|
-
r.startsWith(Q) && r.length > Q.length ? o[bt(r.slice(Q.length))] = l : r.startsWith($) && r.length > $.length ? t[r.slice($.length)] = l : n[r] = l;
|
|
508
|
-
return { itemAttrs: t, itemOn: o, inputAttrs: n };
|
|
509
|
-
}
|
|
510
|
-
function bt(e) {
|
|
511
|
-
const t = e.indexOf(":");
|
|
512
|
-
return t === -1 ? `on${ye(e)}` : `on${ye(e.slice(0, t))}:${e.slice(t + 1)}`;
|
|
384
|
+
return e;
|
|
513
385
|
}
|
|
514
|
-
function
|
|
515
|
-
|
|
386
|
+
function _e(e) {
|
|
387
|
+
let t = null;
|
|
388
|
+
function n(u) {
|
|
389
|
+
return Se(e.value, u);
|
|
390
|
+
}
|
|
391
|
+
function r(u, i) {
|
|
392
|
+
t || (t = [], re(() => {
|
|
393
|
+
const a = t;
|
|
394
|
+
if (t = null, !a?.length) return;
|
|
395
|
+
let c = e.value;
|
|
396
|
+
for (const l of a)
|
|
397
|
+
c = Ce(c, l.path, l.value);
|
|
398
|
+
e.value = c;
|
|
399
|
+
})), t.push({ path: u, value: i });
|
|
400
|
+
}
|
|
401
|
+
return { getIn: n, setIn: r };
|
|
516
402
|
}
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
);
|
|
520
|
-
|
|
521
|
-
|
|
403
|
+
const ke = ["modelValue", "model-value"], we = ["onUpdate:modelValue", "onUpdate:model-value"];
|
|
404
|
+
function xe(e, t) {
|
|
405
|
+
const n = f(() => ke.find((i) => i in e)), r = f(() => we.find((i) => typeof e[i] == "function")), u = f(() => n.value ? "controlled" : t ? "inherit" : "local");
|
|
406
|
+
return {
|
|
407
|
+
key: n,
|
|
408
|
+
event: r,
|
|
409
|
+
source: u
|
|
410
|
+
};
|
|
522
411
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
function Re(e) {
|
|
529
|
-
return I({
|
|
530
|
-
name: e ? `FormViewItem_${e}` : "FormViewItem",
|
|
531
|
-
inheritAttrs: !1,
|
|
532
|
-
props: Et,
|
|
533
|
-
setup(t, { slots: o, attrs: n }) {
|
|
534
|
-
const r = se(), l = ut(), s = j(xe, null);
|
|
535
|
-
if (e != null && !s)
|
|
536
|
-
throw new Error(
|
|
537
|
-
"[vue-formless] useFormItem(port) must be used inside a namespaced control."
|
|
538
|
-
);
|
|
539
|
-
return () => Ft(
|
|
540
|
-
r,
|
|
541
|
-
l,
|
|
542
|
-
s,
|
|
543
|
-
e,
|
|
544
|
-
o,
|
|
545
|
-
n,
|
|
546
|
-
t
|
|
547
|
-
);
|
|
412
|
+
function je() {
|
|
413
|
+
const e = ue(), t = T($, null), { source: n, key: r, event: u } = xe(e, !!t), i = C(), a = f({
|
|
414
|
+
get: () => n.value === "controlled" ? e[r.value] : i.value,
|
|
415
|
+
set: (m) => {
|
|
416
|
+
n.value === "local" && (i.value = m), u.value && e[u.value](m);
|
|
548
417
|
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
function Ct(e) {
|
|
553
|
-
return se(), e === void 0 ? $e : Re(e);
|
|
554
|
-
}
|
|
555
|
-
function Ft(e, t, o, n, r, l, s) {
|
|
556
|
-
const { fl: u, rest: c } = Le(l), { row: i, col: m, rest: g } = Ve(c), p = { ...u, ...Fe(s) }, { itemAttrs: E, itemOn: b, inputAttrs: L } = ke(g), C = { ...E, ...L }, { itemSlots: w } = Oe(r), f = n == null && o != null, F = s["col:span"] ?? m.span, V = s["col:place"] ?? m.place, a = o?.getFrame(), k = F ?? (f ? a?.colSpan : void 0), _ = V ?? (f ? a?.colPlace : void 0), W = St(e, o, n, p), U = Ae(e.model, W.binding, e.update), J = r.default?.({ field: U }) ?? null;
|
|
557
|
-
!f && (i.column != null || i.gutter != null) && console.warn("[vue-formless] :row:* is ignored on a leaf cell");
|
|
558
|
-
let S = C, A = b, G = w;
|
|
559
|
-
f && a && (S = { ...a.itemAttrs, ...C }, A = { ...a.itemOn, ...b }, G = { ...a.itemSlots, ...w });
|
|
560
|
-
let M, Y, N = !1;
|
|
561
|
-
f && a && (M = a.wrapItem, Y = a.wrapCol, N = a.extraRow);
|
|
562
|
-
let h = J;
|
|
563
|
-
if (N && a) {
|
|
564
|
-
const T = h;
|
|
565
|
-
h = y(
|
|
566
|
-
e.LayoutView,
|
|
567
|
-
{
|
|
568
|
-
disabled: !e.isLayoutEnabled(),
|
|
569
|
-
column: a.rowColumn ?? e.factoryColumn,
|
|
570
|
-
gutter: a.rowGutter ?? e.factoryGutter
|
|
571
|
-
},
|
|
572
|
-
() => T
|
|
573
|
-
);
|
|
418
|
+
}), c = _e(a), l = f(() => n.value === "inherit" ? t.value.value : a.value);
|
|
419
|
+
function s(m) {
|
|
420
|
+
return n.value === "inherit" ? t.getIn(m) : c.getIn(m);
|
|
574
421
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
fl: W.fl,
|
|
578
|
-
itemAttrs: S,
|
|
579
|
-
itemOn: A,
|
|
580
|
-
itemSlots: G
|
|
581
|
-
}), Y !== !1) {
|
|
582
|
-
const T = h;
|
|
583
|
-
h = y(t, { span: k, place: _ }, () => T);
|
|
422
|
+
function d(m, y) {
|
|
423
|
+
return n.value === "inherit" ? t.setIn(m, y) : c.setIn(m, y);
|
|
584
424
|
}
|
|
585
|
-
return
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
controlKey: t.controlKey,
|
|
594
|
-
binding: m,
|
|
595
|
-
getValues: () => m.props.map((p) => B(e.model, p))
|
|
596
|
-
};
|
|
597
|
-
return { binding: m, fl: g };
|
|
598
|
-
}
|
|
599
|
-
const l = n.prop;
|
|
600
|
-
if (l === "")
|
|
601
|
-
throw new Error("[vue-formless] fl:prop cannot be an empty string");
|
|
602
|
-
const s = typeof l == "string" ? l : Array.isArray(l) && l[0] ? String(l[0]) : "", u = l === void 0 ? { models: ["modelValue"], props: [] } : Se(s || "field", {
|
|
603
|
-
prop: l
|
|
604
|
-
}), c = {
|
|
605
|
-
...r,
|
|
606
|
-
controlKey: s,
|
|
607
|
-
binding: u,
|
|
608
|
-
getValues: () => u.props.map((i) => B(e.model, i))
|
|
425
|
+
return w($, {
|
|
426
|
+
value: l,
|
|
427
|
+
getIn: s,
|
|
428
|
+
setIn: d
|
|
429
|
+
}), {
|
|
430
|
+
value: l,
|
|
431
|
+
getIn: s,
|
|
432
|
+
setIn: d
|
|
609
433
|
};
|
|
610
|
-
return { binding: u, fl: c };
|
|
611
434
|
}
|
|
612
|
-
function
|
|
613
|
-
|
|
614
|
-
return t.Item = $e, t;
|
|
615
|
-
}
|
|
616
|
-
const le = 0;
|
|
617
|
-
function At(e) {
|
|
618
|
-
return new Proxy(
|
|
619
|
-
{},
|
|
620
|
-
{
|
|
621
|
-
get(t, o) {
|
|
622
|
-
const n = e.value;
|
|
623
|
-
if (n == null) return;
|
|
624
|
-
const r = Reflect.get(n, o, n);
|
|
625
|
-
return typeof r == "function" ? r.bind(n) : r;
|
|
626
|
-
},
|
|
627
|
-
has(t, o) {
|
|
628
|
-
return e.value != null && o in e.value;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
);
|
|
435
|
+
function x(e) {
|
|
436
|
+
return e && e.charAt(0).toUpperCase() + e.slice(1);
|
|
632
437
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
"
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
get model() {
|
|
676
|
-
return e.getModel();
|
|
677
|
-
},
|
|
678
|
-
update: e.update,
|
|
679
|
-
wrap: t,
|
|
680
|
-
isItemEnabled: o,
|
|
681
|
-
isLayoutEnabled: e.isLayoutEnabled,
|
|
682
|
-
LayoutView: O(e.LayoutView),
|
|
683
|
-
factoryColumn: e.factoryColumn,
|
|
684
|
-
factoryGutter: e.factoryGutter
|
|
685
|
-
})
|
|
686
|
-
);
|
|
438
|
+
function Q(...e) {
|
|
439
|
+
const t = (n) => {
|
|
440
|
+
if (n !== void 0)
|
|
441
|
+
return n === "" ? !0 : !!n;
|
|
442
|
+
};
|
|
443
|
+
return e.reduce((n, r) => typeof t(r) == "boolean" ? t(r) : n, void 0);
|
|
444
|
+
}
|
|
445
|
+
function M(e) {
|
|
446
|
+
return e.replace(/-([a-z])/g, (t, n) => n.toUpperCase());
|
|
447
|
+
}
|
|
448
|
+
const Ve = ["fl", "layout-item", "layout", "item"], Te = new Map(
|
|
449
|
+
Ve.map((e) => {
|
|
450
|
+
const t = M(e);
|
|
451
|
+
return [
|
|
452
|
+
[`${e}:`, { channel: e, type: "prop" }],
|
|
453
|
+
[`${t}:`, { channel: e, type: "prop" }],
|
|
454
|
+
[`on${x(e)}:`, { channel: e, type: "listener" }],
|
|
455
|
+
[`on${x(t)}:`, { channel: e, type: "listener" }]
|
|
456
|
+
];
|
|
457
|
+
}).flat()
|
|
458
|
+
);
|
|
459
|
+
function ee(e, t, n = {}) {
|
|
460
|
+
const r = n.prefix === "keep", u = {};
|
|
461
|
+
for (const a of [...t, "default"]) u[a] = /* @__PURE__ */ Object.create(null);
|
|
462
|
+
const i = Object.entries(e).map(([a, c]) => ({ ...Me(a, t), rawKey: a, value: c }));
|
|
463
|
+
for (const { rawKey: a, key: c, value: l, channel: s, type: d } of i)
|
|
464
|
+
d !== "listener" && (u[s || "default"][r && s ? a : c] = l);
|
|
465
|
+
for (const { rawKey: a, key: c, value: l, channel: s, type: d } of i)
|
|
466
|
+
d === "listener" && (u[s || "default"][r && s ? a : c] = l);
|
|
467
|
+
return u;
|
|
468
|
+
}
|
|
469
|
+
function Me(e, t) {
|
|
470
|
+
const n = e.indexOf(":");
|
|
471
|
+
if (n === -1) return { key: e };
|
|
472
|
+
const r = e.substring(0, n + 1);
|
|
473
|
+
if (e.length === r.length) return { key: e };
|
|
474
|
+
const u = Te.get(r);
|
|
475
|
+
return !u || !t.includes(u.channel) ? { key: e } : {
|
|
476
|
+
key: u.type === "listener" ? `on${x(e.replace(r, ""))}` : e.replace(r, ""),
|
|
477
|
+
channel: u.channel,
|
|
478
|
+
type: u.type
|
|
479
|
+
};
|
|
687
480
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
if (o)
|
|
695
|
-
return {
|
|
696
|
-
getModel: () => o.model,
|
|
697
|
-
update: o.update
|
|
698
|
-
};
|
|
699
|
-
throw new Error("[vue-formless] FormView requires v-model unless nested inside another FormView.");
|
|
700
|
-
}
|
|
701
|
-
function Vt(e) {
|
|
702
|
-
if (e != null) {
|
|
703
|
-
if (e.Row == null || e.Col == null)
|
|
704
|
-
throw new Error("[vue-formless] createFormView layout requires both Row and Col.");
|
|
705
|
-
return {
|
|
706
|
-
Row: O(e.Row),
|
|
707
|
-
Col: O(e.Col),
|
|
708
|
-
column: e.column,
|
|
709
|
-
gutter: e.gutter
|
|
710
|
-
};
|
|
711
|
-
}
|
|
481
|
+
const Re = ["fl", "layout"], He = ["fl", "layout", "layout-item", "item"], $e = ["item"];
|
|
482
|
+
function te(e, t, n) {
|
|
483
|
+
const r = f(() => ee(e, t, n)), u = {};
|
|
484
|
+
for (const i of t)
|
|
485
|
+
u[M(i)] = f(() => r.value[i]);
|
|
486
|
+
return u.default = f(() => r.value.default), u;
|
|
712
487
|
}
|
|
713
|
-
function
|
|
714
|
-
|
|
715
|
-
t
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
E(At(b));
|
|
726
|
-
const L = j(Z, null) != null, { getModel: C, update: w } = Ne(
|
|
727
|
-
() => i.modelValue,
|
|
728
|
-
(f) => g("update:modelValue", f)
|
|
729
|
-
);
|
|
730
|
-
return Me({
|
|
731
|
-
getModel: C,
|
|
732
|
-
update: w,
|
|
733
|
-
Item: r,
|
|
734
|
-
itemProps: l,
|
|
735
|
-
isItemEnabled: () => i["fl:item"] !== !1,
|
|
736
|
-
isLayoutEnabled: () => X(i["fl:layout"]),
|
|
737
|
-
LayoutView: s,
|
|
738
|
-
factoryColumn: u,
|
|
739
|
-
factoryGutter: c
|
|
740
|
-
}), () => {
|
|
741
|
-
const f = m.default?.() ?? null, F = X(i["fl:layout"]), V = {
|
|
742
|
-
column: i["row:column"] ?? u,
|
|
743
|
-
gutter: i["row:gutter"] ?? c
|
|
744
|
-
}, a = y(
|
|
745
|
-
s,
|
|
746
|
-
{ disabled: !F, column: V.column, gutter: V.gutter },
|
|
747
|
-
() => f
|
|
748
|
-
), k = o ? Ot(i["fl:form"], L) : !1;
|
|
749
|
-
if (!o || !k) return a;
|
|
750
|
-
const _ = {
|
|
751
|
-
layout: F,
|
|
752
|
-
form: k,
|
|
753
|
-
item: i["fl:item"] !== !1,
|
|
754
|
-
modelValue: C()
|
|
755
|
-
};
|
|
756
|
-
return y(
|
|
757
|
-
o,
|
|
758
|
-
{
|
|
759
|
-
ref: b,
|
|
760
|
-
...ae(K(n, _), p)
|
|
761
|
-
},
|
|
762
|
-
{ default: () => a }
|
|
763
|
-
);
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
})
|
|
767
|
-
);
|
|
488
|
+
function Pe(e) {
|
|
489
|
+
return new Proxy({}, {
|
|
490
|
+
get(t, n) {
|
|
491
|
+
const r = e.value;
|
|
492
|
+
if (r == null) return;
|
|
493
|
+
const u = Reflect.get(r, n, r);
|
|
494
|
+
return typeof u == "function" ? u.bind(r) : u;
|
|
495
|
+
},
|
|
496
|
+
has(t, n) {
|
|
497
|
+
return e.value != null && n in e.value;
|
|
498
|
+
}
|
|
499
|
+
});
|
|
768
500
|
}
|
|
769
|
-
|
|
770
|
-
|
|
501
|
+
function Ke(e = {}) {
|
|
502
|
+
const {
|
|
503
|
+
Row: t,
|
|
504
|
+
Col: n
|
|
505
|
+
} = e.layout ?? {}, r = Ie({
|
|
506
|
+
Row: t,
|
|
507
|
+
Col: n
|
|
508
|
+
}), u = e.form?.component ? j(e.form.component) : void 0, i = he(e.item);
|
|
509
|
+
return /* @__PURE__ */ S({
|
|
771
510
|
name: "FormView",
|
|
772
511
|
inheritAttrs: !1,
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
);
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}),
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
512
|
+
setup(a, {
|
|
513
|
+
slots: c,
|
|
514
|
+
attrs: l,
|
|
515
|
+
expose: s
|
|
516
|
+
}) {
|
|
517
|
+
const d = C(null);
|
|
518
|
+
s(Pe(d));
|
|
519
|
+
const y = T($, null) != null, {
|
|
520
|
+
fl: p,
|
|
521
|
+
layout: o,
|
|
522
|
+
default: v
|
|
523
|
+
} = te(l, Re), E = f(() => Q(!1, p.value.layout)), F = f(() => {
|
|
524
|
+
const g = p.value.form;
|
|
525
|
+
return g === void 0 || g === "auto" ? !y : g === "" ? !0 : !!g;
|
|
526
|
+
}), {
|
|
527
|
+
getIn: O,
|
|
528
|
+
setIn: L
|
|
529
|
+
} = je();
|
|
530
|
+
return w(P, {
|
|
531
|
+
access(g) {
|
|
532
|
+
return {
|
|
533
|
+
value: f(() => O(h(g))),
|
|
534
|
+
update: (_) => L(h(g), _)
|
|
535
|
+
};
|
|
793
536
|
},
|
|
794
|
-
|
|
795
|
-
|
|
537
|
+
// 壳资源直接给出:页级 `fl:item` 默认改由 FormFieldCore 从 `fl` 桶里取
|
|
538
|
+
// (design.md §9 / §16.3),这里不再为 item 包一层。
|
|
539
|
+
FormItem: j(i),
|
|
540
|
+
LayoutView: j(r),
|
|
541
|
+
// 页级 `fl` 桶:FormFieldCore 唯一的页默认来源。`layout` / `form` 是页自己的
|
|
542
|
+
// 开关(上面已消费),FormField 只读 `item`,故契约就是 `{ item?: boolean }`。
|
|
543
|
+
fl: p
|
|
544
|
+
}), () => {
|
|
545
|
+
const _ = b(r, k({
|
|
546
|
+
...e.layout?.props,
|
|
547
|
+
...o.value
|
|
548
|
+
}, {
|
|
549
|
+
disabled: !E.value
|
|
550
|
+
}), {
|
|
551
|
+
default: c.default
|
|
552
|
+
});
|
|
553
|
+
return !u || !F.value ? _ : b(u, k({
|
|
554
|
+
ref: d
|
|
555
|
+
}, {
|
|
556
|
+
...e.form?.props,
|
|
557
|
+
...v.value
|
|
558
|
+
}), {
|
|
559
|
+
default: () => _
|
|
560
|
+
});
|
|
561
|
+
};
|
|
796
562
|
}
|
|
797
|
-
})
|
|
798
|
-
);
|
|
799
|
-
function Te(e) {
|
|
800
|
-
return e && e.charAt(0).toUpperCase() + e.slice(1);
|
|
563
|
+
});
|
|
801
564
|
}
|
|
802
|
-
function
|
|
803
|
-
return e
|
|
804
|
-
}
|
|
805
|
-
function kt(e, t) {
|
|
806
|
-
if (e === "self" && t === !1 || e === !1 && t === "self")
|
|
807
|
-
throw new Error(
|
|
808
|
-
'[vue-formless] formless.item "self" conflicts with schema item: false'
|
|
809
|
-
);
|
|
810
|
-
return e ?? t;
|
|
811
|
-
}
|
|
812
|
-
function xt(e) {
|
|
813
|
-
const t = e.internalItem === "self";
|
|
814
|
-
let o;
|
|
815
|
-
e.tagItem === !0 ? o = !0 : e.tagItem === !1 || t || e.internalItem === !1 ? o = !1 : e.internalItem === !0 ? o = !0 : o = e.pageItem;
|
|
816
|
-
let n = e.pageLayoutOn;
|
|
817
|
-
t && e.tagItem !== !0 && (o = !1, n = !1);
|
|
818
|
-
const r = t && e.tagItem === !0 && e.pageLayoutOn;
|
|
819
|
-
return { wrapItem: o, wrapCol: n, extraRow: r, self: t };
|
|
820
|
-
}
|
|
821
|
-
const Rt = {
|
|
822
|
-
"fl:prop": { type: [String, Array], default: void 0 },
|
|
823
|
-
"fl:item": { type: Boolean, default: void 0 },
|
|
824
|
-
"col:span": { type: [String, Number], default: void 0 },
|
|
825
|
-
"col:place": { type: String, default: void 0 },
|
|
826
|
-
"row:column": { type: Number, default: void 0 },
|
|
827
|
-
"row:gutter": { type: Number, default: void 0 }
|
|
828
|
-
};
|
|
829
|
-
function Wt(e, t) {
|
|
830
|
-
const o = jt(e), n = {};
|
|
831
|
-
for (const r of Object.keys(o)) {
|
|
832
|
-
const l = o[r];
|
|
833
|
-
if (!l) continue;
|
|
834
|
-
const s = Te(r);
|
|
835
|
-
n[s] = $t(
|
|
836
|
-
r,
|
|
837
|
-
l,
|
|
838
|
-
t
|
|
839
|
-
);
|
|
840
|
-
}
|
|
841
|
-
return n;
|
|
565
|
+
function qe(e) {
|
|
566
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !oe(e);
|
|
842
567
|
}
|
|
843
|
-
function
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
itemOn: _,
|
|
905
|
-
itemSlots: V
|
|
906
|
-
}, y(g, null, () => Be);
|
|
568
|
+
function B(e) {
|
|
569
|
+
if (!(typeof e > "u"))
|
|
570
|
+
return (Array.isArray(e) ? e : [e]).map((t) => {
|
|
571
|
+
if (typeof t == "string")
|
|
572
|
+
return t;
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
function De(e) {
|
|
576
|
+
if (!(typeof e > "u"))
|
|
577
|
+
return (Array.isArray(e) ? e : [e]).map((t) => {
|
|
578
|
+
if (typeof t == "string")
|
|
579
|
+
return t;
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
const Be = /* @__PURE__ */ S({
|
|
583
|
+
name: "FormFieldCore",
|
|
584
|
+
inheritAttrs: !1,
|
|
585
|
+
props: {
|
|
586
|
+
preset: {
|
|
587
|
+
type: Object
|
|
588
|
+
},
|
|
589
|
+
fl: {
|
|
590
|
+
type: Object,
|
|
591
|
+
required: !0
|
|
592
|
+
},
|
|
593
|
+
layoutItem: {
|
|
594
|
+
type: Object,
|
|
595
|
+
required: !0
|
|
596
|
+
},
|
|
597
|
+
layout: {
|
|
598
|
+
type: Object,
|
|
599
|
+
required: !0
|
|
600
|
+
},
|
|
601
|
+
item: {
|
|
602
|
+
type: Object,
|
|
603
|
+
required: !0
|
|
604
|
+
},
|
|
605
|
+
control: {
|
|
606
|
+
type: [Object, Function],
|
|
607
|
+
required: !0
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
setup(e, {
|
|
611
|
+
slots: t
|
|
612
|
+
}) {
|
|
613
|
+
const n = T(P, null), r = f(() => e.fl?.component?.formless), u = f(() => ({
|
|
614
|
+
...e.preset?.fl,
|
|
615
|
+
...e.fl
|
|
616
|
+
})), i = f(() => B(u.value?.model) || B(r.value?.model) || ["modelValue"]), a = f(() => De(u.value?.prop) || n?.getProp?.(i.value)), c = f(() => {
|
|
617
|
+
const p = {}, o = {};
|
|
618
|
+
return i.value.forEach((v, E) => {
|
|
619
|
+
if (typeof v != "string" || v.trim() === "") return;
|
|
620
|
+
const F = a.value?.[E];
|
|
621
|
+
if (typeof F != "string" || F.trim() === "") return;
|
|
622
|
+
const O = n?.access(F);
|
|
623
|
+
if (!O) return;
|
|
624
|
+
const L = M(v);
|
|
625
|
+
p[L] = O.value.value, o[`onUpdate:${L}`] = O.update;
|
|
626
|
+
}), {
|
|
627
|
+
values: p,
|
|
628
|
+
events: o
|
|
907
629
|
};
|
|
630
|
+
}), l = f(() => ({
|
|
631
|
+
...c.value.values,
|
|
632
|
+
...c.value.events
|
|
633
|
+
}));
|
|
634
|
+
w(P, {
|
|
635
|
+
...n,
|
|
636
|
+
getProp(p) {
|
|
637
|
+
return p.map((o) => {
|
|
638
|
+
if (typeof o != "string") return;
|
|
639
|
+
const v = i.value.indexOf(o);
|
|
640
|
+
return v !== -1 ? a.value?.[v] : void 0;
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
const s = f(() => {
|
|
645
|
+
const p = r.value?.field === "embed" ? "embed" : "auto", o = u.value?.field === "embed" ? "embed" : u.value?.field === "wrap-embed" ? "wrap-embed" : "auto";
|
|
646
|
+
return p === "auto" ? o === "auto" ? "wrap" : o : o === "auto" ? "embed" : o;
|
|
647
|
+
}), d = f(() => Q(!0, h(n?.fl)?.item, u.value?.item)), m = f(() => ({
|
|
648
|
+
...u.value,
|
|
649
|
+
model: i.value,
|
|
650
|
+
prop: a.value,
|
|
651
|
+
field: s.value,
|
|
652
|
+
item: d.value
|
|
653
|
+
})), y = f(() => {
|
|
654
|
+
const p = typeof e.preset?.props == "function" ? e.preset?.props(m.value) : e.preset?.props;
|
|
655
|
+
return k(c.value.events, {
|
|
656
|
+
...p,
|
|
657
|
+
...e.control
|
|
658
|
+
}, c.value.values);
|
|
659
|
+
});
|
|
660
|
+
return () => {
|
|
661
|
+
const {
|
|
662
|
+
item: p,
|
|
663
|
+
default: o
|
|
664
|
+
} = ee(t, $e), v = e.fl.component, E = v ? b(v, y.value, o) : t.default?.({
|
|
665
|
+
$bindings: l.value
|
|
666
|
+
}) ?? null;
|
|
667
|
+
if (s.value === "embed") return E;
|
|
668
|
+
const F = n?.LayoutView, O = s.value === "wrap-embed" && F ? b(F, e.layout, {
|
|
669
|
+
default: () => E
|
|
670
|
+
}) : E, L = n?.FormItem, g = L ? b(L, {
|
|
671
|
+
fl: m.value,
|
|
672
|
+
item: e.item
|
|
673
|
+
}, {
|
|
674
|
+
...p,
|
|
675
|
+
default: () => O
|
|
676
|
+
}) : O;
|
|
677
|
+
return b(ve, e.layoutItem, qe(g) ? g : {
|
|
678
|
+
default: () => [g]
|
|
679
|
+
});
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
function ne(e = {}) {
|
|
684
|
+
const {
|
|
685
|
+
name: t,
|
|
686
|
+
component: n,
|
|
687
|
+
props: r,
|
|
688
|
+
...u
|
|
689
|
+
} = e;
|
|
690
|
+
return /* @__PURE__ */ S({
|
|
691
|
+
name: t ? `FormField${x(t)}` : "FormField",
|
|
692
|
+
inheritAttrs: !1,
|
|
693
|
+
setup(i, {
|
|
694
|
+
attrs: a,
|
|
695
|
+
slots: c
|
|
696
|
+
}) {
|
|
697
|
+
const {
|
|
698
|
+
fl: l,
|
|
699
|
+
layoutItem: s,
|
|
700
|
+
layout: d,
|
|
701
|
+
item: m,
|
|
702
|
+
default: y
|
|
703
|
+
} = te(a, He);
|
|
704
|
+
return () => b(Be, {
|
|
705
|
+
preset: {
|
|
706
|
+
fl: u,
|
|
707
|
+
props: r
|
|
708
|
+
},
|
|
709
|
+
fl: {
|
|
710
|
+
...l.value,
|
|
711
|
+
// `fl.value` is the raw tag bucket (`Record<string, unknown>`); schema
|
|
712
|
+
// still wins over the tag's `fl:component` (design.md §11.2).
|
|
713
|
+
component: n ?? l.value.component
|
|
714
|
+
},
|
|
715
|
+
layoutItem: s.value,
|
|
716
|
+
layout: d.value,
|
|
717
|
+
item: m.value,
|
|
718
|
+
control: y.value
|
|
719
|
+
}, c);
|
|
908
720
|
}
|
|
909
721
|
});
|
|
910
722
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
...e
|
|
923
|
-
};
|
|
924
|
-
for (const o of Object.keys(t)) {
|
|
925
|
-
const n = t[o];
|
|
926
|
-
n && (t[o] = {
|
|
927
|
-
...n,
|
|
928
|
-
component: n.component && typeof n.component == "object" ? O(n.component) : n.component
|
|
723
|
+
const We = ne();
|
|
724
|
+
function Ye(e) {
|
|
725
|
+
const t = {};
|
|
726
|
+
for (const n of Object.keys(e)) {
|
|
727
|
+
const r = e[n];
|
|
728
|
+
if (!r) continue;
|
|
729
|
+
const u = x(M(n));
|
|
730
|
+
t[u] = ne({
|
|
731
|
+
name: u,
|
|
732
|
+
prop: n,
|
|
733
|
+
...r
|
|
929
734
|
});
|
|
930
735
|
}
|
|
931
736
|
return t;
|
|
932
737
|
}
|
|
933
738
|
export {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
gt as bindingForPort,
|
|
940
|
-
Te as camelToPascal,
|
|
941
|
-
Wt as createFormControls,
|
|
942
|
-
Nt as createFormView,
|
|
943
|
-
Ce as createLayoutView,
|
|
944
|
-
Z as formContextKey,
|
|
945
|
-
Ke as formItemProp,
|
|
946
|
-
B as getIn,
|
|
947
|
-
kt as mergeInternalItem,
|
|
948
|
-
ae as overlayProps,
|
|
949
|
-
ue as parsePath,
|
|
950
|
-
Bt as pascalToCamel,
|
|
951
|
-
Se as resolveControlBinding,
|
|
952
|
-
xt as resolveControlShell,
|
|
953
|
-
Mt as resolveFormItemProp,
|
|
954
|
-
K as resolveProps,
|
|
955
|
-
De as setIn,
|
|
956
|
-
de as toBindingList,
|
|
957
|
-
se as useFormContext,
|
|
958
|
-
Ct as useFormItem,
|
|
959
|
-
ut as useLayoutItem
|
|
739
|
+
We as FormField,
|
|
740
|
+
ve as LayoutItem,
|
|
741
|
+
Ye as createFormFields,
|
|
742
|
+
Ke as createFormView,
|
|
743
|
+
Ie as createLayoutView
|
|
960
744
|
};
|