@oneflowui/ui 0.8.2 → 0.8.4

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.
@@ -18,17 +18,23 @@ type __VLS_Props = {
18
18
  field: FieldDef;
19
19
  value?: CellValue;
20
20
  readonly?: boolean;
21
+ editing?: boolean;
21
22
  };
22
23
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
23
24
  cancel: () => any;
24
25
  commit: (rowId: string, fieldId: string, value: CellValue) => any;
25
26
  tabNext: () => any;
27
+ "request-cancel": () => any;
28
+ "request-edit": (rowId: string, fieldId: string) => any;
26
29
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
27
30
  onCancel?: (() => any) | undefined;
28
31
  onCommit?: ((rowId: string, fieldId: string, value: CellValue) => any) | undefined;
29
32
  onTabNext?: (() => any) | undefined;
33
+ "onRequest-cancel"?: (() => any) | undefined;
34
+ "onRequest-edit"?: ((rowId: string, fieldId: string) => any) | undefined;
30
35
  }>, {
31
36
  value: string | number | boolean | string[] | null;
37
+ editing: boolean;
32
38
  readonly: boolean;
33
39
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
34
40
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import o from "./FieldCell.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-6062f0e7"]]);
4
+ const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-22598b04"]]);
5
5
  export {
6
- m as default
6
+ p as default
7
7
  };
@@ -1,32 +1,39 @@
1
- import { defineComponent as F, computed as a, defineAsyncComponent as e, openBlock as o, createBlock as d, resolveDynamicComponent as s, withKeys as p, withModifiers as v, normalizeClass as K, withCtx as u, Suspense as M, createElementVNode as D, createElementBlock as y, Fragment as T, unref as V, toDisplayString as $ } from "vue";
1
+ import { defineComponent as F, computed as o, defineAsyncComponent as e, openBlock as a, createBlock as c, resolveDynamicComponent as s, withKeys as p, withModifiers as v, normalizeClass as K, withCtx as m, Suspense as M, createElementVNode as D, createElementBlock as y, Fragment as T, unref as V, toDisplayString as $ } from "vue";
2
2
  import { useInlineEdit as j } from "../../composables/useInlineEdit.js";
3
3
  const z = {
4
4
  key: 1,
5
5
  class: "of-field-cell__display"
6
- }, q = /* @__PURE__ */ F({
6
+ }, G = /* @__PURE__ */ F({
7
7
  __name: "FieldCell",
8
8
  props: {
9
9
  rowId: {},
10
10
  field: {},
11
11
  value: { type: [String, Number, Boolean, Array, null], default: void 0 },
12
- readonly: { type: Boolean, default: !1 }
12
+ readonly: { type: Boolean, default: !1 },
13
+ editing: { type: Boolean, default: void 0 }
13
14
  },
14
- emits: ["commit", "cancel", "tabNext"],
15
- setup(i, { emit: b }) {
16
- const t = i, c = b, { isEditing: h, activate: k, commit: w, cancel: x } = j(), r = a(() => h(t.rowId, t.field.id)), n = a(() => t.readonly || t.field.readonly), C = a(() => !n.value);
17
- function m() {
18
- n.value || k(t.rowId, t.field.id);
15
+ emits: ["commit", "cancel", "request-cancel", "tabNext", "request-edit"],
16
+ setup(l, { emit: b }) {
17
+ const t = l, r = b, { isEditing: g, activate: w, commit: h, cancel: k } = j(), x = o(() => g(t.rowId, t.field.id)), d = o(() => t.editing ?? x.value), n = o(() => t.readonly || t.field.readonly), C = o(() => !n.value);
18
+ function u() {
19
+ if (!n.value) {
20
+ if (t.editing !== void 0) {
21
+ r("request-edit", t.rowId, t.field.id);
22
+ return;
23
+ }
24
+ w(t.rowId, t.field.id);
25
+ }
19
26
  }
20
- function g(l) {
21
- w(t.rowId, t.field.id, l), c("commit", t.rowId, t.field.id, l);
27
+ function E(i) {
28
+ h(t.rowId, t.field.id, i), r("commit", t.rowId, t.field.id, i);
22
29
  }
23
- function A() {
24
- x(), c("cancel");
30
+ function I() {
31
+ t.editing === void 0 && k(), r("request-cancel"), r("cancel");
25
32
  }
26
- function E() {
27
- c("tabNext");
33
+ function A() {
34
+ r("tabNext");
28
35
  }
29
- const I = {
36
+ const B = {
30
37
  text: e(() => import("../field/FieldText.vue.js")),
31
38
  number: e(() => import("../field/FieldNumber.vue.js")),
32
39
  checkbox: e(() => import("../field/FieldCheckbox.vue.js")),
@@ -47,46 +54,46 @@ const z = {
47
54
  phone: e(() => import("../field/FieldPhone.vue.js"))
48
55
  }, N = e(
49
56
  () => import("../field/FieldMarkdownPreview.vue.js")
50
- ), B = a(() => I[t.field.type]), S = a(() => {
51
- const l = t.value;
52
- return l == null || l === "" ? "—" : Array.isArray(l) ? l.join(", ") : typeof l == "boolean" ? l ? "✓" : "—" : String(l);
57
+ ), q = o(() => B[t.field.type]), S = o(() => {
58
+ const i = t.value;
59
+ return i == null || i === "" ? "—" : Array.isArray(i) ? i.join(", ") : typeof i == "boolean" ? i ? "✓" : "—" : String(i);
53
60
  });
54
- return (l, f) => (o(), d(s(n.value || r.value ? "div" : "button"), {
61
+ return (i, f) => (a(), c(s(n.value || d.value ? "div" : "button"), {
55
62
  class: K(["of-field-cell", {
56
- "of-field-cell--editing": r.value,
63
+ "of-field-cell--editing": d.value,
57
64
  "of-field-cell--readonly": n.value,
58
65
  "of-field-cell--actionable": C.value
59
66
  }]),
60
- type: n.value || r.value ? void 0 : "button",
61
- "aria-label": `${i.field.label}字段`,
62
- title: n.value ? void 0 : `点击编辑 ${i.field.label}`,
63
- onClick: m,
67
+ type: n.value || d.value ? void 0 : "button",
68
+ "aria-label": `${l.field.label}字段`,
69
+ title: n.value ? void 0 : `点击编辑 ${l.field.label}`,
70
+ onClick: u,
64
71
  onKeydown: [
65
- p(v(m, ["prevent"]), ["enter"]),
66
- p(v(m, ["prevent"]), ["space"])
72
+ p(v(u, ["prevent"]), ["enter"]),
73
+ p(v(u, ["prevent"]), ["space"])
67
74
  ]
68
75
  }, {
69
- default: u(() => [
70
- r.value ? (o(), d(M, { key: 0 }, {
71
- fallback: u(() => [...f[0] || (f[0] = [
76
+ default: m(() => [
77
+ d.value ? (a(), c(M, { key: 0 }, {
78
+ fallback: m(() => [...f[0] || (f[0] = [
72
79
  D("span", { class: "of-field-cell__loading" }, "...", -1)
73
80
  ])]),
74
- default: u(() => [
75
- (o(), d(s(B.value), {
76
- value: i.value,
77
- field: i.field,
78
- onCommit: g,
79
- onCancel: A,
80
- onTabNext: E
81
+ default: m(() => [
82
+ (a(), c(s(q.value), {
83
+ value: l.value,
84
+ field: l.field,
85
+ onCommit: E,
86
+ onCancel: I,
87
+ onTabNext: A
81
88
  }, null, 40, ["value", "field"]))
82
89
  ]),
83
90
  _: 1
84
- })) : (o(), y(T, { key: 1 }, [
85
- i.field.type === "richtext" && typeof i.value == "string" && i.value ? (o(), d(V(N), {
91
+ })) : (a(), y(T, { key: 1 }, [
92
+ l.field.type === "richtext" && typeof l.value == "string" && l.value ? (a(), c(V(N), {
86
93
  key: 0,
87
- content: i.value,
94
+ content: l.value,
88
95
  "max-lines": 2
89
- }, null, 8, ["content"])) : (o(), y("span", z, $(S.value), 1))
96
+ }, null, 8, ["content"])) : (a(), y("span", z, $(S.value), 1))
90
97
  ], 64))
91
98
  ]),
92
99
  _: 1
@@ -94,5 +101,5 @@ const z = {
94
101
  }
95
102
  });
96
103
  export {
97
- q as default
104
+ G as default
98
105
  };