@vrojs/element-plus 0.0.11 → 0.0.12

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,97 @@
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
+ };
@@ -1,7 +1,7 @@
1
1
  import { UseAsyncTaskOptions } from '@vrojs/use';
2
2
  import { Ref } from 'vue';
3
3
  import { VroElSchemaFormInstance } from '.';
4
- import { VroElSchemaFormSchema, VroElSchemaFormSchemaBase, VroElSchemaFormSchemaFieldBase } from './types';
4
+ import { VroElSchemaFormSchema, VroElSchemaFormSchemaFieldBase } from './types';
5
5
  export interface UseVroElSchemaFormOptions extends Pick<UseAsyncTaskOptions<any>, 'throwError' | 'onError'> {
6
6
  source?: Record<string, any>;
7
7
  instanceRef?: Ref<VroElSchemaFormInstance | undefined>;
@@ -9,7 +9,7 @@ export interface UseVroElSchemaFormOptions extends Pick<UseAsyncTaskOptions<any>
9
9
  export type UseVroElSchemaFormSchema<TSchema extends VroElSchemaFormSchema> = {
10
10
  [K in keyof TSchema]: VroElSchemaFormSchemaFieldBase;
11
11
  };
12
- export declare function useVroElSchemaForm<D extends Record<string, any> = any, T extends VroElSchemaFormSchema = VroElSchemaFormSchemaBase>(rawSchema: (() => T) | T, task?: (data: D) => Promise<void>, options?: UseVroElSchemaFormOptions): {
12
+ export declare function useVroElSchemaForm<D extends Record<string, any> = any, T extends VroElSchemaFormSchema = VroElSchemaFormSchema>(rawSchema: (() => T) | T, task?: (data: D) => Promise<void>, options?: UseVroElSchemaFormOptions): {
13
13
  data: Ref<Awaited<D> | undefined, Awaited<D> | undefined>;
14
14
  error: Ref<unknown, unknown>;
15
15
  schema: import('vue').Reactive<UseVroElSchemaFormSchema<T>>;
@@ -1,11 +1,11 @@
1
- import p from "@daysnap/banana";
2
- import { isFunction as v } from "@daysnap/utils";
3
- import { useAsyncTask as d } from "@vrojs/use";
4
- import { reactive as g, ref as h } from "vue";
5
- function R(r, n, s = {}) {
6
- const { instanceRef: i, source: a, ...c } = s, e = g(
7
- v(r) ? r() : r
8
- ), t = i ?? h(), { loading: m, trigger: u, error: f, data: l } = d(async () => {
1
+ import d from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
2
+ import { isFunction as p } from "@daysnap/utils";
3
+ import { useAsyncTask as v } from "@vrojs/use";
4
+ import { reactive as g, ref as y, onBeforeMount as h } from "vue";
5
+ function V(r, n, i = {}) {
6
+ const { instanceRef: s, source: a, ...c } = i, e = g(
7
+ p(r) ? r() : r
8
+ ), t = s ?? y(), { loading: u, trigger: f, error: m, data: l } = v(async () => {
9
9
  if (!t.value)
10
10
  return;
11
11
  try {
@@ -16,15 +16,17 @@ function R(r, n, s = {}) {
16
16
  const o = await t.value.extractValues();
17
17
  return await n?.(o), o;
18
18
  }, c);
19
- return a && p.assignment(a, e), {
19
+ return h(async () => {
20
+ a && await d.assign(a, e);
21
+ }), {
20
22
  data: l,
21
- error: f,
23
+ error: m,
22
24
  schema: e,
23
25
  schemaFormRef: t,
24
- loading: m,
25
- trigger: u
26
+ loading: u,
27
+ trigger: f
26
28
  };
27
29
  }
28
30
  export {
29
- R as useVroElSchemaForm
31
+ V as useVroElSchemaForm
30
32
  };
@@ -1,5 +1,5 @@
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 f, 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 "@daysnap/banana";
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";
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";
@@ -13,11 +13,11 @@ const ve = /* @__PURE__ */ q({
13
13
  __name: "vro-el-schema-form",
14
14
  props: oe,
15
15
  emits: ["change-field", "input-field"],
16
- setup(B, { expose: D, emit: $ }) {
17
- const V = $, n = B, x = C(() => ({
16
+ setup(B, { expose: x, emit: D }) {
17
+ const w = D, n = B, $ = C(() => ({
18
18
  validateOnRuleChange: !1,
19
19
  ...n.formProps
20
- })), { locale: y } = ee(), b = F({}), w = F({}), v = F({});
20
+ })), { locale: y } = ee(), V = F({}), b = F({}), v = F({});
21
21
  z(() => {
22
22
  const { schema: e } = n;
23
23
  v.value = {};
@@ -25,7 +25,7 @@ const ve = /* @__PURE__ */ q({
25
25
  Object.entries(e).forEach(([o, t]) => {
26
26
  let { hidden: s, value: c, rules: l, is: p } = t;
27
27
  d(s) && (s = s(c, t, e)), p || (s = !0), s || (r[o] = c, v.value[o] = t), d(l) && (l = l(c, t, e)), a[o] = l;
28
- }), Object.assign(w.value, r), Object.assign(b.value, a);
28
+ }), Object.assign(b.value, r), Object.assign(V.value, a);
29
29
  });
30
30
  const R = C(() => Object.entries(v.value).reduce((e, [a, r]) => {
31
31
  let { is: o, options: t, labelKey: s, valueKey: c } = r, l = { ...r.props };
@@ -44,47 +44,47 @@ const ve = /* @__PURE__ */ q({
44
44
  }
45
45
  return e[a] = { is: o, props: l }, e;
46
46
  }, {})), K = async (e, a) => {
47
- V("change-field", { key: e, value: a }), await n.schema[e]?.onChange?.(a, n.schema[e], n.schema);
47
+ w("change-field", { key: e, value: a }), await n.schema[e]?.onChange?.(a, n.schema[e], n.schema);
48
48
  }, L = async (e, a) => {
49
- V("input-field", { key: e, value: a }), await n.schema[e]?.onInput?.(a, n.schema[e], n.schema);
50
- }, h = S("componentRefs"), i = S("formRef"), M = async () => {
49
+ w("input-field", { key: e, value: a }), await n.schema[e]?.onInput?.(a, n.schema[e], n.schema);
50
+ }, h = S("componentRefs"), f = S("formRef"), M = async () => {
51
51
  const e = h.value?.filter((a) => d(a.validate)) ?? [];
52
- await Promise.all([i.value, ...e].map((a) => a?.validate()));
52
+ await Promise.all([f.value, ...e].map((a) => a?.validate()));
53
53
  }, T = async () => {
54
54
  const e = h.value?.filter((r) => d(r.extractValues)) ?? [], a = await Promise.all(
55
55
  e.map((r) => r.extractValues())
56
56
  );
57
- return a.push(J.extract(n.schema)), a.filter(Boolean).reduce((r, o) => ({ ...r, ...o }), {});
57
+ return a.push(await J.extract(n.schema)), a.filter(Boolean).reduce((r, o) => ({ ...r, ...o }), {});
58
58
  }, U = ae(async (e) => {
59
59
  const a = h.value?.filter((r) => d(r.trigger)) ?? [];
60
60
  await Promise.all(a.map((r) => r.trigger(e)));
61
61
  });
62
- return D({
62
+ return x({
63
63
  get elForm() {
64
- return i.value;
64
+ return f.value;
65
65
  },
66
66
  validate: M,
67
- resetFields: () => i.value?.resetFields(),
67
+ resetFields: () => f.value?.resetFields(),
68
68
  trigger: U,
69
69
  extractValues: T,
70
- validateField: async (e) => i.value?.validateField(e)
71
- }), (e, a) => (g(), P(m(X), u(x.value, {
70
+ validateField: async (e) => f.value?.validateField(e)
71
+ }), (e, a) => (g(), P(m(X), u($.value, {
72
72
  ref_key: "formRef",
73
- ref: i,
73
+ ref: f,
74
74
  class: "vro-el-schema-form",
75
- model: w.value,
76
- rules: b.value
75
+ model: b.value,
76
+ rules: V.value
77
77
  }), {
78
- default: f(() => [
78
+ default: i(() => [
79
79
  I(m(Y), u({ gutter: 16 }, e.rowProps), {
80
- default: f(() => [
80
+ default: i(() => [
81
81
  (g(!0), A(G, null, _(v.value, (r, o) => (g(), P(m(Z), u({ key: o }, { ref_for: !0 }, { ...e.colProps, ...r.colProps }), {
82
- default: f(() => [
82
+ default: i(() => [
83
83
  I(m(k), u({
84
84
  label: r.label,
85
85
  prop: o
86
86
  }, { ref_for: !0 }, { ...e.formItemProps, ...r.formItemProps }), O({
87
- default: f(() => [
87
+ default: i(() => [
88
88
  (g(), P(H(R.value?.[o]?.is), u({
89
89
  modelValue: r.value,
90
90
  "onUpdate:modelValue": (t) => r.value = t
@@ -97,7 +97,7 @@ const ve = /* @__PURE__ */ q({
97
97
  }), O({ _: 2 }, [
98
98
  _(m(j)(r.slots), ({ source: t, target: s }) => ({
99
99
  name: s,
100
- fn: f((c) => [
100
+ fn: i((c) => [
101
101
  E(e.$slots, t, u({ ref_for: !0 }, c ?? {}, { item: r }))
102
102
  ])
103
103
  }))
@@ -107,7 +107,7 @@ const ve = /* @__PURE__ */ q({
107
107
  }, [
108
108
  _(m(j)(r.itemSlots), ({ source: t, target: s }) => ({
109
109
  name: s,
110
- fn: f((c) => [
110
+ fn: i((c) => [
111
111
  E(e.$slots, t, u({ ref_for: !0 }, c ?? {}, { item: r }))
112
112
  ])
113
113
  }))
@@ -1,18 +1,18 @@
1
- import l from "@daysnap/banana";
1
+ import m from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/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
- function x(o, t, a = {}) {
5
- const { onGenerate: r, onSuccess: c, instanceRef: i } = a, e = f(), m = p();
6
- return [e, async (...n) => {
7
- e.value = await o(), n[0] && l.assignment(n[0], e.value), r?.(e.value, ...n), await t(
4
+ function S(o, a, n = {}) {
5
+ const { onGenerate: r, onSuccess: i, instanceRef: c } = n, e = f(), s = p();
6
+ return [e, async (...t) => {
7
+ e.value = await o(), t[0] && await m.assign(t[0], e.value), r?.(e.value, ...t), await a(
8
8
  e.value,
9
- i?.value ?? {
10
- show: (s, u) => v(s, u ?? m?.appContext)
9
+ c?.value ?? {
10
+ show: (u, l) => v(u, l ?? s?.appContext)
11
11
  },
12
- ...n
13
- ), c?.(e.value, ...n);
12
+ ...t
13
+ ), i?.(e.value, ...t);
14
14
  }];
15
15
  }
16
16
  export {
17
- x as useVroElSchemaFormDialog
17
+ S as useVroElSchemaFormDialog
18
18
  };
@@ -1,18 +1,18 @@
1
- import l from "@daysnap/banana";
2
- import { ref as f, getCurrentInstance as p } from "vue";
3
- import { showVroElSchemaFormDrawer as v } from "./function-call.js";
4
- function x(t, a, o = {}) {
5
- const { onGenerate: r, onSuccess: c, instanceRef: i } = o, e = f(), m = p();
6
- return [e, async (...n) => {
7
- e.value = await t(), n[0] && l.assignment(n[0], e.value), r?.(e.value, ...n), await a(
1
+ import l from "../node_modules/.pnpm/@ajuanjs_banana@0.0.2/node_modules/@ajuanjs/banana/dist/index.js";
2
+ import { ref as f, getCurrentInstance as w } from "vue";
3
+ import { showVroElSchemaFormDrawer as p } from "./function-call.js";
4
+ function d(a, n, o = {}) {
5
+ const { onGenerate: r, onSuccess: c, instanceRef: i } = o, e = f(), s = w();
6
+ return [e, async (...t) => {
7
+ e.value = await a(), t[0] && await l.assign(t[0], e.value), r?.(e.value, ...t), await n(
8
8
  e.value,
9
9
  i?.value ?? {
10
- show: (s, u) => v(s, u ?? m?.appContext)
10
+ show: (u, m) => p(u, m ?? s?.appContext)
11
11
  },
12
- ...n
13
- ), c?.(e.value, ...n);
12
+ ...t
13
+ ), c?.(e.value, ...t);
14
14
  }];
15
15
  }
16
16
  export {
17
- x as useVroElSchemaFormDrawer
17
+ d as useVroElSchemaFormDrawer
18
18
  };
@@ -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>): {
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<{
20
20
  tableProps: import('vue').ComputedRef<{
21
21
  filterProps: {
22
22
  schema: import('vue').Reactive<UseVroElTableSchema<R>>;
@@ -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,34 +1,34 @@
1
- import q from "@daysnap/banana";
2
- import { isFunction as p, filterEmptyValue as z, isNumber as E } from "@daysnap/utils";
3
- import { useAsyncTask as T } from "@vrojs/use";
4
- import { reactive as a, ref as V, computed as k } from "vue";
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";
3
+ import { useAsyncTask as E } from "@vrojs/use";
4
+ import { reactive as a, ref as T, computed as V } from "vue";
5
5
  import "../vro-el-table-column-group/index.js";
6
- function Q(r, o, f, y = {}) {
7
- const { query: P, ...m } = y, i = a(
6
+ async function Q(r, i, f, y = {}) {
7
+ const { query: d, ...P } = y, o = a(
8
8
  p(r) ? r() : r
9
- ), u = a(p(o) ? o() : o), n = P ?? V(z(q.extract(i), !0)), t = a({
9
+ ), u = a(p(i) ? i() : i), n = d ?? T(x(await q.extract(o), !0)), t = a({
10
10
  currentPage: 1,
11
11
  pageSize: 10,
12
12
  total: 0
13
- }), { trigger: b, data: c, loading: s } = T(
13
+ }), { trigger: m, data: c, loading: s } = E(
14
14
  async (e) => {
15
- E(e) && (e = { currentPage: e });
15
+ z(e) && (e = { currentPage: e });
16
16
  const { currentPage: l, pageSize: g } = Object.assign({}, t, e);
17
17
  e?.query && (n.value = e?.query), t.currentPage = l, t.pageSize = g;
18
- const [d, v] = await f([l, g], n.value);
19
- return t.total = v, d || [];
18
+ const [b, v] = await f([l, g], n.value);
19
+ return t.total = v, b || [];
20
20
  },
21
21
  {
22
22
  immediate: !0,
23
23
  throwError: !0,
24
24
  initialValue: [],
25
- ...m
25
+ ...P
26
26
  }
27
27
  );
28
28
  return {
29
- tableProps: k(() => ({
29
+ tableProps: V(() => ({
30
30
  filterProps: {
31
- schema: i
31
+ schema: o
32
32
  },
33
33
  loading: s.value,
34
34
  columns: u,
@@ -36,9 +36,9 @@ function Q(r, o, f, y = {}) {
36
36
  paginationProps: t
37
37
  })),
38
38
  query: n,
39
- schema: i,
39
+ schema: o,
40
40
  columns: u,
41
- trigger: b,
41
+ trigger: m,
42
42
  data: c,
43
43
  loading: s,
44
44
  pagination: t
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrojs/element-plus",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "vrojs ui",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "vue-draggable-plus": "^0.6.1"
35
35
  },
36
36
  "peerDependencies": {
37
- "@daysnap/banana": ">=0.0.15",
37
+ "@ajuanjs/banana": ">=0.0.2",
38
38
  "@daysnap/utils": ">=0.1.34",
39
39
  "@element-plus/icons-vue": ">=2.3.2",
40
40
  "@vrojs/base": ">=0.0.6",
@@ -43,7 +43,7 @@
43
43
  "vue": ">=3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@daysnap/banana": "^0.0.15",
46
+ "@ajuanjs/banana": "^0.0.2",
47
47
  "@daysnap/utils": "^0.1.36",
48
48
  "@element-plus/icons-vue": "^2.3.2",
49
49
  "@vitejs/plugin-vue": "^6.0.1",
@@ -53,8 +53,8 @@
53
53
  "vite": "^7.1.12",
54
54
  "vite-plugin-dts": "^4.5.4",
55
55
  "vue": "^3.5.22",
56
- "@vrojs/use": "0.0.3",
57
- "@vrojs/base": "0.0.6"
56
+ "@vrojs/base": "0.0.10",
57
+ "@vrojs/use": "0.0.5"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "npm run clean && vite build",