|
1 |
| -import { defineComponent as v, mergeModels as b, computed as c, useModel as V, ref as g, openBlock as u, createElementBlock as d, renderSlot as i, createVNode as m, createCommentVNode as r, createBlock as k, normalizeClass as y, createSlots as C, withCtx as $, mergeProps as B, h as w } from "vue"; |
2 |
| -import x from "./form-group.vue.mjs"; |
3 |
| -import M from "./icon-edit.vue.mjs"; |
4 |
| -const T = { class: "vue-forms-controller inline-form" }, q = /* @__PURE__ */ v({ |
| 1 | +import { defineComponent as C, mergeModels as m, computed as g, useModel as P, ref as $, openBlock as u, createElementBlock as r, renderSlot as p, createVNode as s, createCommentVNode as i, createBlock as B, normalizeClass as w, createSlots as M, withCtx as S, mergeProps as T, normalizeProps as f, guardReactiveProps as v, h as x } from "vue"; |
| 2 | +import z from "./form-group.vue.mjs"; |
| 3 | +import F from "./icon-edit.vue.mjs"; |
| 4 | +import N from "./icon-save.vue.mjs"; |
| 5 | +const h = { class: "vue-forms-controller inline-form" }, L = /* @__PURE__ */ C({ |
5 | 6 | name: "InlineForm",
|
6 | 7 | __name: "inline-form",
|
7 |
| - props: /* @__PURE__ */ b({ |
| 8 | + props: /* @__PURE__ */ m({ |
8 | 9 | name: { default: "" },
|
9 | 10 | type: { default: "text" },
|
10 | 11 | expanded: { type: Boolean },
|
| 12 | + showSave: { type: Boolean }, |
11 | 13 | labelTag: { default: "span" },
|
12 |
| - labelClass: {} |
| 14 | + labelClass: {}, |
| 15 | + iconProps: {} |
13 | 16 | }, {
|
14 | 17 | modelValue: {
|
15 | 18 | required: !0
|
16 | 19 | },
|
17 | 20 | modelModifiers: {}
|
18 | 21 | }),
|
19 |
| - emits: ["update:modelValue"], |
20 |
| - setup(s) { |
21 |
| - const t = s, p = c(() => ({ |
22 |
| - type: t.type, |
23 |
| - name: t.name, |
24 |
| - autofocus: !0 |
25 |
| - })), a = V(s, "modelValue"), e = g("label"), f = () => w(t.labelTag, { |
26 |
| - innerText: a.value, |
27 |
| - class: [t.labelClass, "inline-form-label"] |
28 |
| - }); |
29 |
| - return (l, o) => (u(), d("div", T, [ |
30 |
| - l.expanded || e.value === "label" ? i(l.$slots, "label", { |
| 22 | + emits: /* @__PURE__ */ m(["save"], ["update:modelValue"]), |
| 23 | + setup(d, { emit: c }) { |
| 24 | + const b = c, a = d, k = g(() => ({ |
| 25 | + type: a.type, |
| 26 | + name: a.name, |
| 27 | + autofocus: !a.expanded |
| 28 | + })), o = P(d, "modelValue"), l = $("label"), y = () => x(a.labelTag, { |
| 29 | + innerText: o.value, |
| 30 | + class: [a.labelClass, "inline-form-label"] |
| 31 | + }), V = () => { |
| 32 | + l.value = "label", b("save", o.value); |
| 33 | + }; |
| 34 | + return (e, n) => (u(), r("div", h, [ |
| 35 | + e.expanded || l.value === "label" ? p(e.$slots, "label", { |
31 | 36 | key: 0,
|
32 |
| - label: a.value, |
33 |
| - value: a.value |
| 37 | + label: o.value, |
| 38 | + value: o.value |
34 | 39 | }, () => [
|
35 |
| - m(f) |
36 |
| - ]) : r("", !0), |
37 |
| - l.expanded || e.value === "input" ? (u(), k(x, { |
| 40 | + s(y) |
| 41 | + ]) : i("", !0), |
| 42 | + e.expanded || l.value === "input" ? (u(), B(z, { |
38 | 43 | key: 1,
|
39 | 44 | "inline-mode": "",
|
40 |
| - field: p.value, |
41 |
| - class: y(["form-group inline-controller"]), |
42 |
| - modelValue: a.value, |
43 |
| - "onUpdate:modelValue": o[0] || (o[0] = (n) => a.value = n), |
44 |
| - onBlur: o[1] || (o[1] = (n) => e.value = "label") |
45 |
| - }, C({ _: 2 }, [ |
46 |
| - l.$slots.default ? { |
| 45 | + field: k.value, |
| 46 | + class: w(["form-group inline-controller"]), |
| 47 | + modelValue: o.value, |
| 48 | + "onUpdate:modelValue": n[0] || (n[0] = (t) => o.value = t) |
| 49 | + }, M({ _: 2 }, [ |
| 50 | + e.$slots.default ? { |
47 | 51 | name: "default",
|
48 |
| - fn: $((n) => [ |
49 |
| - i(l.$slots, "default", B(n, { |
50 |
| - toggleView: () => e.value = e.value === "input" ? "label" : "input" |
| 52 | + fn: S((t) => [ |
| 53 | + p(e.$slots, "default", T(t, { |
| 54 | + edit: () => l.value = "input" |
51 | 55 | }))
|
52 | 56 | ]),
|
53 | 57 | key: "0"
|
54 | 58 | } : void 0
|
55 |
| - ]), 1032, ["field", "modelValue"])) : r("", !0), |
56 |
| - !l.expanded && e.value !== "input" ? (u(), d("button", { |
| 59 | + ]), 1032, ["field", "modelValue"])) : i("", !0), |
| 60 | + !e.expanded && l.value !== "input" ? (u(), r("button", { |
57 | 61 | key: 2,
|
58 | 62 | class: "inline-button",
|
59 |
| - onClick: o[2] || (o[2] = (n) => e.value = "input") |
| 63 | + onClick: n[1] || (n[1] = (t) => l.value = "input") |
60 | 64 | }, [
|
61 |
| - m(M) |
62 |
| - ])) : r("", !0) |
| 65 | + s(F, f(v(e.iconProps)), null, 16) |
| 66 | + ])) : l.value === "input" ? (u(), r("button", { |
| 67 | + key: 3, |
| 68 | + class: "inline-button", |
| 69 | + onClick: V |
| 70 | + }, [ |
| 71 | + s(N, f(v(e.iconProps)), null, 16) |
| 72 | + ])) : i("", !0) |
63 | 73 | ]));
|
64 | 74 | }
|
65 | 75 | });
|
66 | 76 | export {
|
67 |
| - q as default |
| 77 | + L as default |
68 | 78 | };
|
0 commit comments