@vrojs/element-plus 0.0.13 → 0.0.15

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.
@@ -0,0 +1,106 @@
1
+ var O = (r) => Object.prototype.toString.call(r) === "[object Object]", h = (r) => typeof r == "function", g = (r) => typeof r > "u";
2
+ function A(r) {
3
+ return g(r) || r === null || r === "" || Number.isNaN(r) || Array.isArray(r) && r.length === 0 || O(r) && Object.keys(r).length === 0;
4
+ }
5
+ function d(r) {
6
+ return Array.isArray(r) ? r.map((e) => ({
7
+ field: e,
8
+ key: e.key
9
+ })) : Object.entries(r).map(([e, t]) => ({
10
+ field: t,
11
+ key: t.key ?? e
12
+ }));
13
+ }
14
+ function b(r, e) {
15
+ const t = r[e.childrenField ?? "children"];
16
+ if (Array.isArray(t) || t && typeof t == "object")
17
+ return t;
18
+ }
19
+ async function v(r, e, t, l) {
20
+ const y = d(e), { recursive: w = !1, parallel: u = !1 } = t, n = async ({ field: c, key: s }) => {
21
+ try {
22
+ let { set: o } = c;
23
+ const i = b(c, t);
24
+ if (w && i && await v(r, i, t, l), !s)
25
+ return;
26
+ const f = r[s];
27
+ h(o) ? await o(r, c, e) : g(f) || (c.value = f);
28
+ } catch (o) {
29
+ l.push({ key: s, field: c, error: o });
30
+ }
31
+ };
32
+ if (u)
33
+ await Promise.allSettled(y.map(n));
34
+ else
35
+ for (const c of y)
36
+ await n(c);
37
+ }
38
+ async function x(r, e, t = {}) {
39
+ const l = [];
40
+ if (await v(r, e, t, l), l.length > 0)
41
+ throw new AggregateError(l, "One or more fields failed to assign");
42
+ }
43
+ async function j(r, e = {}) {
44
+ const t = {}, l = d(r), { recursive: y = !1, parallel: w = !1 } = e, u = async ({ field: n, key: c }) => {
45
+ const s = {};
46
+ let { get: o, value: i, defaultValue: f, hidden: a } = n;
47
+ const p = b(n, e);
48
+ return y && p && Object.assign(s, await j(p, e)), h(a) && (a = a(i, n, r)), a && (i = h(f) ? f(i, n, r) : f), g(i) || !c || (h(o) ? (i = await o(i, n, r), O(i) ? Object.assign(s, i) : s[c] = i) : s[c] = i), s;
49
+ };
50
+ if (w) {
51
+ const n = await Promise.all(l.map(u));
52
+ Object.assign(t, ...n);
53
+ } else
54
+ for (const n of l)
55
+ Object.assign(t, await u(n));
56
+ return t;
57
+ }
58
+ async function m(r, e = {}) {
59
+ const t = d(r), { recursive: l = !1, parallel: y = !1, extract: w = !0 } = e, u = async ({ field: n, key: c }) => {
60
+ let { value: s, rules: o, hidden: i } = n;
61
+ const f = b(n, e);
62
+ if (l && f && await m(f, {
63
+ ...e,
64
+ extract: !1
65
+ }), h(i) && (i = i(s, n, r)), !(i || !o || !o.length))
66
+ try {
67
+ for (const a of o) {
68
+ if (h(a)) {
69
+ await a(s, n, r);
70
+ continue;
71
+ }
72
+ if (a.required && A(s))
73
+ throw new Error(a.message ?? "This field is required");
74
+ a.validator && await a.validator(s, n, r);
75
+ }
76
+ } catch (a) {
77
+ if (!e.onError)
78
+ throw a;
79
+ e.onError({
80
+ error: a,
81
+ field: n,
82
+ key: c,
83
+ metadata: r
84
+ });
85
+ }
86
+ };
87
+ if (y)
88
+ e.onError ? await Promise.allSettled(t.map(u)) : await Promise.all(t.map(u));
89
+ else
90
+ for (const n of t)
91
+ await u(n);
92
+ if (w)
93
+ return j(r, e);
94
+ }
95
+ var E = {
96
+ extract: j,
97
+ validate: m,
98
+ assign: x
99
+ }, F = E;
100
+ export {
101
+ x as assign,
102
+ E as banana,
103
+ F as default,
104
+ j as extract,
105
+ m as validate
106
+ };
@@ -1,4 +1,4 @@
1
- import d from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
1
+ import d from "../node_modules/.pnpm/@ajuanjs_banana@0.0.3/node_modules/@ajuanjs/banana/dist/index.js";
2
2
  import { isFunction as p } from "@daysnap/utils";
3
3
  import { useAsyncTask as v } from "@vrojs/use";
4
4
  import { reactive as g, ref as y, onBeforeMount as h } from "vue";
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as q, computed as C, ref as F, watchEffect as z, useTemplateRef as S, createBlock as P, openBlock as g, unref as m, mergeProps as u, withCtx as i, createVNode as I, createElementBlock as A, renderSlot as E, Fragment as G, renderList as _, createSlots as O, resolveDynamicComponent as H } from "vue";
2
- import J from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
2
+ import J from "../node_modules/.pnpm/@ajuanjs_banana@0.0.3/node_modules/@ajuanjs/banana/dist/index.js";
3
3
  import { isFunction as d, isString as Q, filterEmptyValue as W } from "@daysnap/utils";
4
4
  import { getSlotEntries as j } from "@vrojs/base";
5
5
  import { ElForm as X, ElRow as Y, ElCol as Z, ElFormItem as k } from "element-plus";
@@ -1,4 +1,4 @@
1
- import m from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
1
+ import m from "../node_modules/.pnpm/@ajuanjs_banana@0.0.3/node_modules/@ajuanjs/banana/dist/index.js";
2
2
  import { ref as f, getCurrentInstance as p } from "vue";
3
3
  import { showVroElSchemaFormDialog as v } from "./function-call.js";
4
4
  function S(o, a, n = {}) {
@@ -1,4 +1,4 @@
1
- import l from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
1
+ import l from "../node_modules/.pnpm/@ajuanjs_banana@0.0.3/node_modules/@ajuanjs/banana/dist/index.js";
2
2
  import { ref as f, getCurrentInstance as w } from "vue";
3
3
  import { showVroElSchemaFormDrawer as p } from "./function-call.js";
4
4
  function d(a, n, o = {}) {
@@ -4,4 +4,7 @@ import { UseVroElTableOptions, UseVroElTableRawColumns, useVroElTable } from './
4
4
  export interface CreateUseVroElTable<Row extends Record<string, any> = any> {
5
5
  <R extends VroElSchemaFormSchema>(rowSchema: (() => R) | R, rawColumns: UseVroElTableRawColumns<Row>, request: VroElTableRequest<Row>, options?: UseVroElTableOptions<Row>): ReturnType<typeof useVroElTable<Row, R>>;
6
6
  }
7
+ /**
8
+ * 类型辅助器,现在 typescript 升级了之后,应该用不到了
9
+ */
7
10
  export declare function createUseVroElTable<Row extends Record<string, any> = any>(): CreateUseVroElTable<Row>;
@@ -16,7 +16,7 @@ export type UseVroElTableRawColumns<T extends Record<string, any> = any> = (() =
16
16
  export type UseVroElTableSchema<T extends VroElSchemaFormSchema> = {
17
17
  [P in keyof T]: VroElSchemaFormSchemaFieldBase;
18
18
  };
19
- export declare function useVroElTable<Row extends Record<string, any> = any, R extends VroElSchemaFormSchema = VroElSchemaFormSchema>(rowSchema: (() => R) | R, rawColumns: UseVroElTableRawColumns<Row>, request: VroElTableRequest<Row>, options?: UseVroElTableOptions<Row>): Promise<{
19
+ export declare function useVroElTable<Row extends Record<string, any> = any, R extends VroElSchemaFormSchema = VroElSchemaFormSchema>(rowSchema: (() => R) | R, rawColumns: UseVroElTableRawColumns<Row>, request: VroElTableRequest<Row>, options?: UseVroElTableOptions<Row>): {
20
20
  tableProps: import('vue').ComputedRef<{
21
21
  filterProps: {
22
22
  schema: import('vue').Reactive<UseVroElTableSchema<R>>;
@@ -30,7 +30,7 @@ export declare function useVroElTable<Row extends Record<string, any> = any, R e
30
30
  total: number;
31
31
  };
32
32
  }>;
33
- query: Ref<Record<string, any>, Record<string, any>>;
33
+ query: Ref<Record<string, any> | undefined, Record<string, any> | undefined>;
34
34
  schema: import('vue').Reactive<UseVroElTableSchema<R>>;
35
35
  columns: import('vue').Reactive<VroElTableColumnGroupColumns<Row>>;
36
36
  trigger: (params?: UseVroElTableAsyncTaskParams) => Promise<Row[]>;
@@ -41,4 +41,4 @@ export declare function useVroElTable<Row extends Record<string, any> = any, R e
41
41
  pageSize: number;
42
42
  total: number;
43
43
  };
44
- }>;
44
+ };
@@ -1,22 +1,22 @@
1
- import q from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
2
- import { isFunction as p, filterEmptyValue as x, isNumber as z } from "@daysnap/utils";
1
+ import q from "../node_modules/.pnpm/@ajuanjs_banana@0.0.3/node_modules/@ajuanjs/banana/dist/index.js";
2
+ import { isFunction as p, isNumber as x, filterEmptyValue as z } from "@daysnap/utils";
3
3
  import { useAsyncTask as E } from "@vrojs/use";
4
- import { reactive as a, ref as T, computed as V } from "vue";
4
+ import { reactive as n, ref as T, computed as V } from "vue";
5
5
  import "../vro-el-table-column-group/index.js";
6
- async function Q(r, i, f, y = {}) {
7
- const { query: d, ...P } = y, o = a(
8
- p(r) ? r() : r
9
- ), u = a(p(i) ? i() : i), n = d ?? T(x(await q.extract(o), !0)), t = a({
6
+ function Q(i, o, f, y = {}) {
7
+ const { query: d, ...P } = y, a = n(
8
+ p(i) ? i() : i
9
+ ), u = n(p(o) ? o() : o), r = d ?? T(), t = n({
10
10
  currentPage: 1,
11
11
  pageSize: 10,
12
12
  total: 0
13
- }), { trigger: m, data: c, loading: s } = E(
13
+ }), { trigger: m, data: c, loading: l } = E(
14
14
  async (e) => {
15
- z(e) && (e = { currentPage: e });
16
- const { currentPage: l, pageSize: g } = Object.assign({}, t, e);
17
- e?.query && (n.value = e?.query), t.currentPage = l, t.pageSize = g;
18
- const [b, v] = await f([l, g], n.value);
19
- return t.total = v, b || [];
15
+ x(e) && (e = { currentPage: e });
16
+ const { currentPage: s, pageSize: g } = Object.assign({}, t, e);
17
+ e?.query && (r.value = e?.query), r.value || (r.value = z(await q.extract(a), !0)), t.currentPage = s, t.pageSize = g;
18
+ const [v, b] = await f([s, g], r.value);
19
+ return t.total = b, v || [];
20
20
  },
21
21
  {
22
22
  immediate: !0,
@@ -28,19 +28,19 @@ async function Q(r, i, f, y = {}) {
28
28
  return {
29
29
  tableProps: V(() => ({
30
30
  filterProps: {
31
- schema: o
31
+ schema: a
32
32
  },
33
- loading: s.value,
33
+ loading: l.value,
34
34
  columns: u,
35
35
  data: c.value,
36
36
  paginationProps: t
37
37
  })),
38
- query: n,
39
- schema: o,
38
+ query: r,
39
+ schema: a,
40
40
  columns: u,
41
41
  trigger: m,
42
42
  data: c,
43
- loading: s,
43
+ loading: l,
44
44
  pagination: t
45
45
  };
46
46
  }
@@ -1,57 +1,57 @@
1
- import { defineComponent as y, useTemplateRef as k, computed as P, resolveDirective as T, createElementBlock as i, openBlock as l, createBlock as n, createCommentVNode as a, createElementVNode as d, unref as r, mergeProps as u, withDirectives as $, renderSlot as s, withCtx as p, createTextVNode as V, toDisplayString as q, createVNode as C } from "vue";
2
- import { isEmptyObject as S } from "@daysnap/utils";
3
- import { RefreshRight as w } from "@element-plus/icons-vue";
4
- import { ElButton as z, ElTable as B, ElPagination as N } from "element-plus";
5
- import { useLocale as R } from "../locale/useLocale.js";
1
+ import { defineComponent as $, useTemplateRef as y, computed as k, resolveDirective as P, createElementBlock as i, openBlock as l, createBlock as a, createCommentVNode as s, createElementVNode as d, unref as r, mergeProps as u, withDirectives as T, renderSlot as n, withCtx as p, createTextVNode as V, toDisplayString as q, createVNode as w } from "vue";
2
+ import { isEmptyObject as C } from "@daysnap/utils";
3
+ import { RefreshRight as S } from "@element-plus/icons-vue";
4
+ import { ElButton as z, ElTable as B, ElPagination as R } from "element-plus";
5
+ import { useLocale as N } from "../locale/useLocale.js";
6
6
  import { VroElSchemaFilter as D } from "../vro-el-schema-filter/index.js";
7
7
  import { VroElTableColumnGroup as j } from "../vro-el-table-column-group/index.js";
8
8
  import { vroElTableProps as U } from "./types.js";
9
9
  const F = { class: "vro-el-table" }, G = { class: "vro-el-table-inner" }, H = {
10
10
  key: 0,
11
11
  class: "vro-el-table-header"
12
- }, L = { class: "vro-el-table-actions" }, O = { class: "vro-el-table-content" }, Y = /* @__PURE__ */ y({
12
+ }, L = { class: "vro-el-table-actions" }, O = { class: "vro-el-table-content" }, Y = /* @__PURE__ */ $({
13
13
  name: "VroElTable",
14
14
  __name: "vro-el-table",
15
15
  props: U,
16
16
  emits: ["request", "selection-change"],
17
17
  setup(f, { expose: g }) {
18
- const b = f, { t: c } = R(), v = B, m = k("refElTable"), E = P(() => {
18
+ const b = f, { t: v } = N(), c = B, m = y("refElTable"), h = k(() => {
19
19
  const { filterable: e, filterProps: o } = b;
20
- return !!(e && o?.schema && !S(o.schema));
20
+ return !!(e && o?.schema && !C(o.schema));
21
21
  });
22
22
  return g({
23
23
  get elTable() {
24
24
  return m.value;
25
25
  }
26
26
  }), (e, o) => {
27
- const h = T("loading");
27
+ const E = P("loading");
28
28
  return l(), i("div", F, [
29
- E.value ? (l(), n(r(D), u({ key: 0 }, e.filterProps, {
29
+ h.value ? (l(), a(r(D), u({ key: 0 }, e.filterProps, {
30
30
  loading: e.loading,
31
31
  class: "vro-el-table-filter",
32
32
  onQuery: o[0] || (o[0] = (t) => e.$emit("request", { query: t, currentPage: 1 }))
33
- }), null, 16, ["loading"])) : a("", !0),
33
+ }), null, 16, ["loading"])) : s("", !0),
34
34
  d("div", G, [
35
- e.showHeader ? (l(), i("div", H, [
36
- s(e.$slots, "title"),
35
+ e.showHeader && (e.$slots.title || e.$slots.actions || e.showRefresh) ? (l(), i("div", H, [
36
+ n(e.$slots, "title"),
37
37
  d("div", L, [
38
- e.showRefresh ? (l(), n(r(z), {
38
+ e.showRefresh ? (l(), a(r(z), {
39
39
  key: 0,
40
40
  plain: "",
41
- icon: r(w),
41
+ icon: r(S),
42
42
  loading: e.loading,
43
43
  onClick: o[1] || (o[1] = (t) => e.$emit("request"))
44
44
  }, {
45
45
  default: p(() => [
46
- V(q(r(c)("table.refresh")), 1)
46
+ V(q(r(v)("table.refresh")), 1)
47
47
  ]),
48
48
  _: 1
49
- }, 8, ["icon", "loading"])) : a("", !0),
50
- s(e.$slots, "actions")
49
+ }, 8, ["icon", "loading"])) : s("", !0),
50
+ n(e.$slots, "actions")
51
51
  ])
52
- ])) : a("", !0),
53
- $((l(), i("div", O, [
54
- C(r(v), u({
52
+ ])) : s("", !0),
53
+ T((l(), i("div", O, [
54
+ w(r(c), u({
55
55
  ref_key: "refElTable",
56
56
  ref: m,
57
57
  width: "100%",
@@ -61,19 +61,19 @@ const F = { class: "vro-el-table" }, G = { class: "vro-el-table-inner" }, H = {
61
61
  onSelectionChange: o[2] || (o[2] = (t) => e.$emit("selection-change", t))
62
62
  }), {
63
63
  default: p(() => [
64
- s(e.$slots, "content-prefix"),
65
- e.columns.length ? (l(), n(r(j), {
64
+ n(e.$slots, "content-prefix"),
65
+ e.columns.length ? (l(), a(r(j), {
66
66
  key: 0,
67
67
  columns: e.columns
68
- }, null, 8, ["columns"])) : a("", !0),
69
- s(e.$slots, "default")
68
+ }, null, 8, ["columns"])) : s("", !0),
69
+ n(e.$slots, "default")
70
70
  ]),
71
71
  _: 3
72
72
  }, 16, ["data"])
73
73
  ])), [
74
- [h, e.loading]
74
+ [E, e.loading]
75
75
  ]),
76
- e.pageable ? (l(), n(r(N), u({
76
+ e.pageable ? (l(), a(r(R), u({
77
77
  key: 1,
78
78
  class: "vro-el-table-pagination",
79
79
  layout: "total, prev, pager, next, sizes, jumper",
@@ -83,7 +83,7 @@ const F = { class: "vro-el-table" }, G = { class: "vro-el-table-inner" }, H = {
83
83
  }, e.paginationProps, {
84
84
  "onUpdate:currentPage": o[3] || (o[3] = (t) => e.$emit("request", { currentPage: t })),
85
85
  "onUpdate:pageSize": o[4] || (o[4] = (t) => e.$emit("request", { pageSize: t, currentPage: 1 }))
86
- }), null, 16)) : a("", !0)
86
+ }), null, 16)) : s("", !0)
87
87
  ])
88
88
  ]);
89
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrojs/element-plus",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "vrojs ui",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "vue": ">=3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@ajuanjs/banana": "^0.0.2",
46
+ "@ajuanjs/banana": "^0.0.3",
47
47
  "@daysnap/utils": "^0.1.36",
48
48
  "@element-plus/icons-vue": "^2.3.2",
49
49
  "@vitejs/plugin-vue": "^6.0.1",
@@ -1,97 +0,0 @@
1
- var v = (r) => Object.prototype.toString.call(r) === "[object Object]", y = (r) => typeof r == "function", b = (r) => typeof r > "u";
2
- function A(r) {
3
- return b(r) || r === null || r === "" || Number.isNaN(r) || Array.isArray(r) && r.length === 0 || v(r) && Object.keys(r).length === 0;
4
- }
5
- function g(r) {
6
- return Array.isArray(r) ? r.map((t) => ({
7
- field: t,
8
- key: t.key
9
- })) : Object.entries(r).map(([t, n]) => ({
10
- field: n,
11
- key: n.key ?? t
12
- }));
13
- }
14
- function d(r, t) {
15
- const n = r[t.childrenField ?? "children"];
16
- if (Array.isArray(n) || n && typeof n == "object")
17
- return n;
18
- }
19
- async function O(r, t, n = {}) {
20
- const f = g(t), { recursive: h = !1, parallel: w = !1 } = n, l = async ({ field: e, key: o }) => {
21
- let { set: s } = e;
22
- const a = d(e, n);
23
- if (h && a && await O(r, a, n), !o)
24
- return;
25
- const i = r[o];
26
- y(s) ? await s(r, e, t) : b(i) || (e.value = i);
27
- };
28
- if (w)
29
- await Promise.all(f.map(l));
30
- else
31
- for (const e of f)
32
- await l(e);
33
- }
34
- async function j(r, t = {}) {
35
- const n = {}, f = g(r), { recursive: h = !1, parallel: w = !1 } = t, l = async ({ field: e, key: o }) => {
36
- const s = {};
37
- let { get: a, value: i, defaultValue: u, hidden: c } = e;
38
- const p = d(e, t);
39
- return h && p && Object.assign(s, await j(p, t)), y(c) && (c = c(i, e, r)), c && (i = y(u) ? u(i, e, r) : u), b(i) || !o || (y(a) ? (i = await a(i, e, r), v(i) ? Object.assign(s, i) : s[o] = i) : s[o] = i), s;
40
- };
41
- if (w) {
42
- const e = await Promise.all(f.map(l));
43
- Object.assign(n, ...e);
44
- } else
45
- for (const e of f)
46
- Object.assign(n, await l(e));
47
- return n;
48
- }
49
- async function x(r, t = {}) {
50
- const n = g(r), { recursive: f = !1, parallel: h = !1, extract: w = !0 } = t, l = async ({ field: e, key: o }) => {
51
- let { value: s, rules: a, hidden: i } = e;
52
- const u = d(e, t);
53
- if (f && u && await x(u, {
54
- ...t,
55
- extract: !1
56
- }), y(i) && (i = i(s, e, r)), !(i || !a || !a.length))
57
- try {
58
- for (const c of a) {
59
- if (y(c)) {
60
- await c(s, e, r);
61
- continue;
62
- }
63
- if (c.required && A(s))
64
- throw new Error(c.message ?? "This field is required");
65
- c.validator && await c.validator(s, e, r);
66
- }
67
- } catch (c) {
68
- if (!t.onError)
69
- throw c;
70
- t.onError({
71
- error: c,
72
- field: e,
73
- key: o,
74
- metadata: r
75
- });
76
- }
77
- };
78
- if (h)
79
- await Promise.all(n.map(l));
80
- else
81
- for (const e of n)
82
- await l(e);
83
- if (w)
84
- return j(r, t);
85
- }
86
- var F = {
87
- extract: j,
88
- validate: x,
89
- assign: O
90
- }, m = F;
91
- export {
92
- O as assign,
93
- F as banana,
94
- m as default,
95
- j as extract,
96
- x as validate
97
- };