@oneflowui/ui 0.6.0 → 0.8.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.
Files changed (27) hide show
  1. package/dist/components/Dashboard/index.vue.d.ts +3 -1
  2. package/dist/components/Dashboard/index.vue.js +2 -2
  3. package/dist/components/Dashboard/index.vue2.js +59 -30
  4. package/dist/components/database/DatabaseView.vue.js +4 -4
  5. package/dist/components/database/DatabaseView.vue2.js +597 -442
  6. package/dist/components/detail/DetailLayout.vue.d.ts +12 -1
  7. package/dist/components/detail/DetailLayout.vue.js +2 -2
  8. package/dist/components/detail/DetailLayout.vue2.js +115 -68
  9. package/dist/components/gallery/GalleryView.vue.d.ts +3 -1
  10. package/dist/components/gallery/GalleryView.vue.js +2 -2
  11. package/dist/components/gallery/GalleryView.vue2.js +51 -27
  12. package/dist/components/overlay/Drawer.vue.d.ts +10 -0
  13. package/dist/components/overlay/Drawer.vue.js +1 -1
  14. package/dist/components/overlay/Drawer.vue2.js +74 -48
  15. package/dist/components/overlay/SidePanel.vue.d.ts +8 -0
  16. package/dist/components/overlay/SidePanel.vue.js +2 -2
  17. package/dist/components/overlay/SidePanel.vue2.js +97 -65
  18. package/dist/components/table/DataTable.vue.d.ts +32 -2
  19. package/dist/components/table/DataTable.vue.js +3 -3
  20. package/dist/components/table/DataTable.vue2.js +751 -609
  21. package/dist/components/table/FieldCell.vue.js +2 -2
  22. package/dist/components/table/FieldCell.vue2.js +26 -24
  23. package/dist/components/table/TableDataRow.vue.d.ts +19 -0
  24. package/dist/components/table/TableDataRow.vue.js +3 -3
  25. package/dist/components/table/TableDataRow.vue2.js +110 -73
  26. package/dist/style.css +1 -1
  27. package/package.json +1 -1
@@ -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 p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-c27b1b16"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-6062f0e7"]]);
5
5
  export {
6
- p as default
6
+ m as default
7
7
  };
@@ -1,9 +1,9 @@
1
- import { defineComponent as S, computed as r, defineAsyncComponent as e, openBlock as n, createBlock as d, resolveDynamicComponent as s, withKeys as p, withModifiers as y, normalizeClass as F, withCtx as u, Suspense as K, createElementVNode as M, createElementBlock as v, Fragment as D, unref as T, toDisplayString as V } from "vue";
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";
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
- }, $ = /* @__PURE__ */ S({
6
+ }, q = /* @__PURE__ */ F({
7
7
  __name: "FieldCell",
8
8
  props: {
9
9
  rowId: {},
@@ -13,14 +13,14 @@ const z = {
13
13
  },
14
14
  emits: ["commit", "cancel", "tabNext"],
15
15
  setup(i, { emit: b }) {
16
- const t = i, c = b, { isEditing: h, activate: k, commit: w, cancel: x } = j(), o = r(() => h(t.rowId, t.field.id)), a = r(() => t.readonly || t.field.readonly);
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
17
  function m() {
18
- a.value || k(t.rowId, t.field.id);
18
+ n.value || k(t.rowId, t.field.id);
19
19
  }
20
- function C(l) {
20
+ function g(l) {
21
21
  w(t.rowId, t.field.id, l), c("commit", t.rowId, t.field.id, l);
22
22
  }
23
- function g() {
23
+ function A() {
24
24
  x(), c("cancel");
25
25
  }
26
26
  function E() {
@@ -47,50 +47,52 @@ const z = {
47
47
  phone: e(() => import("../field/FieldPhone.vue.js"))
48
48
  }, N = e(
49
49
  () => import("../field/FieldMarkdownPreview.vue.js")
50
- ), A = r(() => I[t.field.type]), B = r(() => {
50
+ ), B = a(() => I[t.field.type]), S = a(() => {
51
51
  const l = t.value;
52
52
  return l == null || l === "" ? "—" : Array.isArray(l) ? l.join(", ") : typeof l == "boolean" ? l ? "✓" : "—" : String(l);
53
53
  });
54
- return (l, f) => (n(), d(s(a.value || o.value ? "div" : "button"), {
55
- class: F(["of-field-cell", {
56
- "of-field-cell--editing": o.value,
57
- "of-field-cell--readonly": a.value
54
+ return (l, f) => (o(), d(s(n.value || r.value ? "div" : "button"), {
55
+ class: K(["of-field-cell", {
56
+ "of-field-cell--editing": r.value,
57
+ "of-field-cell--readonly": n.value,
58
+ "of-field-cell--actionable": C.value
58
59
  }]),
59
- type: a.value || o.value ? void 0 : "button",
60
+ type: n.value || r.value ? void 0 : "button",
60
61
  "aria-label": `${i.field.label}字段`,
62
+ title: n.value ? void 0 : `点击编辑 ${i.field.label}`,
61
63
  onClick: m,
62
64
  onKeydown: [
63
- p(y(m, ["prevent"]), ["enter"]),
64
- p(y(m, ["prevent"]), ["space"])
65
+ p(v(m, ["prevent"]), ["enter"]),
66
+ p(v(m, ["prevent"]), ["space"])
65
67
  ]
66
68
  }, {
67
69
  default: u(() => [
68
- o.value ? (n(), d(K, { key: 0 }, {
70
+ r.value ? (o(), d(M, { key: 0 }, {
69
71
  fallback: u(() => [...f[0] || (f[0] = [
70
- M("span", { class: "of-field-cell__loading" }, "...", -1)
72
+ D("span", { class: "of-field-cell__loading" }, "...", -1)
71
73
  ])]),
72
74
  default: u(() => [
73
- (n(), d(s(A.value), {
75
+ (o(), d(s(B.value), {
74
76
  value: i.value,
75
77
  field: i.field,
76
- onCommit: C,
77
- onCancel: g,
78
+ onCommit: g,
79
+ onCancel: A,
78
80
  onTabNext: E
79
81
  }, null, 40, ["value", "field"]))
80
82
  ]),
81
83
  _: 1
82
- })) : (n(), v(D, { key: 1 }, [
83
- i.field.type === "richtext" && typeof i.value == "string" && i.value ? (n(), d(T(N), {
84
+ })) : (o(), y(T, { key: 1 }, [
85
+ i.field.type === "richtext" && typeof i.value == "string" && i.value ? (o(), d(V(N), {
84
86
  key: 0,
85
87
  content: i.value,
86
88
  "max-lines": 2
87
- }, null, 8, ["content"])) : (n(), v("span", z, V(B.value), 1))
89
+ }, null, 8, ["content"])) : (o(), y("span", z, $(S.value), 1))
88
90
  ], 64))
89
91
  ]),
90
92
  _: 1
91
- }, 40, ["class", "type", "aria-label", "onKeydown"]));
93
+ }, 40, ["class", "type", "aria-label", "title", "onKeydown"]));
92
94
  }
93
95
  });
94
96
  export {
95
- $ as default
97
+ q as default
96
98
  };
@@ -1,7 +1,16 @@
1
+ import { Component } from 'vue';
1
2
  import { TableColumn, ColorMap, Density } from '../../types';
2
3
  type TableRow = Record<string, unknown> & {
3
4
  id: string;
4
5
  };
6
+ export interface RowActionItem {
7
+ key: string;
8
+ label: string;
9
+ onClick: () => void;
10
+ variant?: "default" | "danger";
11
+ icon?: string | Component;
12
+ disabled?: boolean;
13
+ }
5
14
  type __VLS_Props = {
6
15
  row: TableRow;
7
16
  rowKey?: string;
@@ -17,6 +26,8 @@ type __VLS_Props = {
17
26
  * 状态颜色映射,与内置默认映射合并(传入优先)
18
27
  */
19
28
  statusColorMap?: ColorMap;
29
+ showRowActions?: boolean;
30
+ rowActionItems?: RowActionItem[];
20
31
  };
21
32
  declare function __VLS_template(): {
22
33
  attrs: Partial<{}>;
@@ -25,6 +36,12 @@ declare function __VLS_template(): {
25
36
  row: TableRow;
26
37
  col: TableColumn;
27
38
  }): any;
39
+ 'row-actions'?(_: {
40
+ row: TableRow;
41
+ rowId: string;
42
+ items: RowActionItem[];
43
+ openDetail: () => void;
44
+ }): any;
28
45
  };
29
46
  refs: {};
30
47
  rootEl: HTMLDivElement;
@@ -43,6 +60,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
43
60
  selected: boolean;
44
61
  priorityColorMap: ColorMap;
45
62
  statusColorMap: ColorMap;
63
+ showRowActions: boolean;
64
+ rowActionItems: RowActionItem[];
46
65
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
47
66
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
48
67
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import o from "./TableDataRow.vue2.js";
2
2
  /* empty css */
3
- import t from "../../_virtual/_plugin-vue_export-helper.js";
4
- const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-2e39c1f1"]]);
3
+ import a from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const m = /* @__PURE__ */ a(o, [["__scopeId", "data-v-c81e54a5"]]);
5
5
  export {
6
- f as default
6
+ m as default
7
7
  };
@@ -1,24 +1,24 @@
1
- import { defineComponent as B, computed as d, openBlock as o, createElementBlock as n, normalizeStyle as c, normalizeClass as Y, withModifiers as E, createElementVNode as g, createCommentVNode as R, Fragment as b, renderList as W, renderSlot as _, toDisplayString as r } from "vue";
2
- import { mergeColorMap as v, DEFAULT_PRIORITY_MAP as H, DEFAULT_STATUS_MAP as N, resolveBadge as x } from "../../composables/useBadge.js";
3
- const I = ["aria-selected"], K = ["for"], L = ["id", "checked"], U = {
1
+ import { defineComponent as N, computed as c, openBlock as l, createElementBlock as n, normalizeStyle as u, normalizeClass as M, withModifiers as g, createElementVNode as k, createCommentVNode as b, Fragment as m, renderList as A, renderSlot as P, toDisplayString as r, createBlock as L, resolveDynamicComponent as U } from "vue";
2
+ import { mergeColorMap as $, DEFAULT_PRIORITY_MAP as V, DEFAULT_STATUS_MAP as X, resolveBadge as D } from "../../composables/useBadge.js";
3
+ const F = ["aria-selected"], z = ["for"], O = ["id", "checked"], G = {
4
4
  key: 0,
5
5
  class: "of-badge of-badge--role"
6
- }, V = {
6
+ }, _ = {
7
7
  key: 1,
8
8
  class: "of-td-empty"
9
- }, X = {
9
+ }, j = {
10
10
  key: 3,
11
11
  class: "of-td-text"
12
- }, F = {
12
+ }, q = {
13
13
  key: 4,
14
14
  class: "of-td-id"
15
- }, z = {
15
+ }, J = {
16
16
  key: 5,
17
17
  class: "of-td-title"
18
- }, O = {
18
+ }, Q = {
19
19
  key: 6,
20
20
  class: "of-td-text"
21
- }, q = /* @__PURE__ */ B({
21
+ }, Z = ["disabled", "onClick", "onKeydown"], oe = /* @__PURE__ */ N({
22
22
  __name: "TableDataRow",
23
23
  props: {
24
24
  row: {},
@@ -28,11 +28,13 @@ const I = ["aria-selected"], K = ["for"], L = ["id", "checked"], U = {
28
28
  columns: {},
29
29
  density: { default: "standard" },
30
30
  priorityColorMap: { default: void 0 },
31
- statusColorMap: { default: void 0 }
31
+ statusColorMap: { default: void 0 },
32
+ showRowActions: { type: Boolean, default: !0 },
33
+ rowActionItems: { default: () => [] }
32
34
  },
33
35
  emits: ["select", "click"],
34
- setup(i, { emit: M }) {
35
- const s = i, y = M, C = {
36
+ setup(i, { emit: S }) {
37
+ const a = i, f = S, T = {
36
38
  compact: {
37
39
  rowHeight: 36,
38
40
  cellPaddingX: 10,
@@ -51,108 +53,143 @@ const I = ["aria-selected"], K = ["for"], L = ["id", "checked"], U = {
51
53
  cellPaddingY: 10,
52
54
  fillMinWidth: 240
53
55
  }
54
- }, u = d(() => C[s.density]), P = d(() => ({
55
- minHeight: `${u.value.rowHeight}px`
56
- })), k = d(() => ({
57
- padding: `${u.value.cellPaddingY}px ${u.value.cellPaddingX}px`
56
+ }, y = c(() => T[a.density]), B = c(() => ({
57
+ minHeight: `${y.value.rowHeight}px`
58
+ })), p = c(() => ({
59
+ padding: `${y.value.cellPaddingY}px ${y.value.cellPaddingX}px`
58
60
  }));
59
- function S(e) {
60
- const l = k.value;
61
+ function I(e) {
62
+ const o = p.value;
61
63
  if (e.width === "fill") {
62
- const t = `${e.minWidth ?? u.value.fillMinWidth}px`;
63
- return { ...l, flex: `1 1 ${t}`, minWidth: t };
64
+ const t = `${e.minWidth ?? y.value.fillMinWidth}px`;
65
+ return { ...o, flex: `1 1 ${t}`, minWidth: t };
64
66
  }
65
- return { ...l, width: `${e.width}px`, flexShrink: "0", flexGrow: "0" };
67
+ return { ...o, width: `${e.width}px`, flexShrink: "0", flexGrow: "0" };
66
68
  }
67
- const $ = d(
68
- () => v(H, s.priorityColorMap)
69
- ), D = d(() => v(N, s.statusColorMap));
70
- function p(e) {
71
- return x(e, $.value);
69
+ const R = c(
70
+ () => $(V, a.priorityColorMap)
71
+ ), E = c(() => $(X, a.statusColorMap));
72
+ function h(e) {
73
+ return D(e, R.value);
72
74
  }
73
- function m(e) {
74
- return x(e, D.value);
75
+ function C(e) {
76
+ return D(e, E.value);
75
77
  }
76
- function T(e) {
78
+ function K(e) {
77
79
  if (!e) return "-";
78
- const l = new Date(e);
79
- return isNaN(l.getTime()) ? e : `${l.getMonth() + 1}/${l.getDate()}`;
80
+ const o = new Date(e);
81
+ return isNaN(o.getTime()) ? e : `${o.getMonth() + 1}/${o.getDate()}`;
80
82
  }
81
- function w(e) {
82
- return s.row[e.key];
83
+ function v(e) {
84
+ return a.row[e.key];
83
85
  }
84
- function h(e) {
85
- const l = w(e);
86
- return l != null ? String(l) : "-";
86
+ function x(e) {
87
+ const o = v(e);
88
+ return o != null ? String(o) : "-";
87
89
  }
88
- function a(e) {
89
- const l = w(e);
90
- return typeof l == "string" ? l : "";
90
+ function s(e) {
91
+ const o = v(e);
92
+ return typeof o == "string" ? o : "";
91
93
  }
92
- function f() {
93
- const e = s.row[s.rowKey];
94
+ function d() {
95
+ const e = a.row[a.rowKey];
94
96
  return e != null ? String(e) : "";
95
97
  }
96
- function A(e) {
97
- e.target === e.currentTarget && (e.key !== "Enter" && e.key !== " " || (e.preventDefault(), y("click", s.row)));
98
+ function Y(e) {
99
+ e.target === e.currentTarget && (e.key !== "Enter" && e.key !== " " || (e.preventDefault(), f("click", a.row)));
100
+ }
101
+ function W(e, o) {
102
+ o.stopPropagation(), !e.disabled && e.onClick();
98
103
  }
99
- return (e, l) => (o(), n("div", {
100
- class: Y(["of-table-row", { "of-table-row--selected": i.selected }]),
104
+ function H(e, o) {
105
+ o.stopPropagation(), !e.disabled && (o.key !== "Enter" && o.key !== " " || (o.preventDefault(), e.onClick()));
106
+ }
107
+ return (e, o) => (l(), n("div", {
108
+ class: M(["of-table-row", { "of-table-row--selected": i.selected }]),
101
109
  role: "row",
102
110
  tabindex: "0",
103
111
  "aria-selected": i.selected || void 0,
104
- style: c(P.value),
105
- onClick: l[2] || (l[2] = (t) => y("click", i.row)),
106
- onKeydown: A
112
+ style: u(B.value),
113
+ onClick: o[3] || (o[3] = (t) => f("click", i.row)),
114
+ onKeydown: Y
107
115
  }, [
108
- i.selectable ? (o(), n("div", {
116
+ i.selectable ? (l(), n("div", {
109
117
  key: 0,
110
118
  class: "of-td of-td-checkbox",
111
119
  role: "gridcell",
112
- style: c(k.value),
113
- onClick: l[1] || (l[1] = E(() => {
120
+ style: u(p.value),
121
+ onClick: o[1] || (o[1] = g(() => {
114
122
  }, ["stop"]))
115
123
  }, [
116
- g("label", {
124
+ k("label", {
117
125
  class: "of-checkbox-label",
118
- for: `of-table-row-checkbox-${f()}`
126
+ for: `of-table-row-checkbox-${d()}`
119
127
  }, [
120
- g("input", {
121
- id: `of-table-row-checkbox-${f()}`,
128
+ k("input", {
129
+ id: `of-table-row-checkbox-${d()}`,
122
130
  type: "checkbox",
123
131
  class: "of-checkbox",
124
132
  checked: i.selected,
125
- onChange: l[0] || (l[0] = (t) => y("select", f()))
126
- }, null, 40, L),
127
- l[3] || (l[3] = g("span", { class: "of-sr-only" }, "选择当前行", -1))
128
- ], 8, K)
129
- ], 4)) : R("", !0),
130
- (o(!0), n(b, null, W(i.columns, (t) => (o(), n("div", {
133
+ onChange: o[0] || (o[0] = (t) => f("select", d()))
134
+ }, null, 40, O),
135
+ o[4] || (o[4] = k("span", { class: "of-sr-only" }, "选择当前行", -1))
136
+ ], 8, z)
137
+ ], 4)) : b("", !0),
138
+ (l(!0), n(m, null, A(i.columns, (t) => (l(), n("div", {
131
139
  key: t.key,
132
140
  class: "of-td",
133
141
  role: "gridcell",
134
- style: c(S(t))
142
+ style: u(I(t))
135
143
  }, [
136
- _(e.$slots, "cell", {
144
+ P(e.$slots, "cell", {
137
145
  row: i.row,
138
146
  col: t
139
147
  }, () => [
140
- t.key === "status" ? (o(), n("span", {
148
+ t.key === "status" ? (l(), n("span", {
141
149
  key: 0,
142
150
  class: "of-badge",
143
- style: c(m(a(t)).style)
144
- }, r(m(a(t)).label), 5)) : t.key === "priority" ? (o(), n("span", {
151
+ style: u(C(s(t)).style)
152
+ }, r(C(s(t)).label), 5)) : t.key === "priority" ? (l(), n("span", {
145
153
  key: 1,
146
154
  class: "of-badge",
147
- style: c(p(a(t)).style)
148
- }, r(p(a(t)).label), 5)) : t.key === "role" ? (o(), n(b, { key: 2 }, [
149
- a(t) ? (o(), n("span", U, r(a(t)), 1)) : (o(), n("span", V, "-"))
150
- ], 64)) : t.key === "updatedAt" ? (o(), n("span", X, r(T(a(t))), 1)) : t.key === "id" ? (o(), n("span", F, r(f()), 1)) : t.key === "title" ? (o(), n("span", z, r(h(t)), 1)) : (o(), n("span", O, r(h(t)), 1))
155
+ style: u(h(s(t)).style)
156
+ }, r(h(s(t)).label), 5)) : t.key === "role" ? (l(), n(m, { key: 2 }, [
157
+ s(t) ? (l(), n("span", G, r(s(t)), 1)) : (l(), n("span", _, "-"))
158
+ ], 64)) : t.key === "updatedAt" ? (l(), n("span", j, r(K(s(t))), 1)) : t.key === "id" ? (l(), n("span", q, r(d()), 1)) : t.key === "title" ? (l(), n("span", J, r(x(t)), 1)) : (l(), n("span", Q, r(x(t)), 1))
159
+ ], !0)
160
+ ], 4))), 128)),
161
+ i.showRowActions && i.rowActionItems.length ? (l(), n("div", {
162
+ key: 1,
163
+ class: "of-table-row__actions",
164
+ "aria-label": "行快捷操作",
165
+ onClick: o[2] || (o[2] = g(() => {
166
+ }, ["stop"]))
167
+ }, [
168
+ P(e.$slots, "row-actions", {
169
+ row: i.row,
170
+ rowId: d(),
171
+ items: i.rowActionItems,
172
+ openDetail: () => f("click", i.row)
173
+ }, () => [
174
+ (l(!0), n(m, null, A(i.rowActionItems, (t) => (l(), n("button", {
175
+ key: t.key,
176
+ type: "button",
177
+ class: M(["of-table-row__action-btn", { "of-table-row__action-btn--danger": t.variant === "danger" }]),
178
+ disabled: t.disabled,
179
+ onClick: g((w) => W(t, w), ["stop"]),
180
+ onKeydown: (w) => H(t, w)
181
+ }, [
182
+ t.icon ? (l(), L(U(t.icon), {
183
+ key: 0,
184
+ class: "of-table-row__action-icon"
185
+ })) : b("", !0),
186
+ k("span", null, r(t.label), 1)
187
+ ], 42, Z))), 128))
151
188
  ], !0)
152
- ], 4))), 128))
153
- ], 46, I));
189
+ ])) : b("", !0)
190
+ ], 46, F));
154
191
  }
155
192
  });
156
193
  export {
157
- q as default
194
+ oe as default
158
195
  };