@aplus-frontend/ui 0.4.35 → 0.4.36

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.
@@ -2,5 +2,8 @@ import { NamePath } from '@aplus-frontend/antdv/es/form/interface';
2
2
  import { ApFormExpose } from '../interface';
3
3
  import { Ref } from 'vue';
4
4
  type ApFormIns<T> = ApFormExpose<T>;
5
- declare const useWatch: <ValueType = any, StoreType = any>(name: NamePath | Ref<NamePath>, form?: Ref<ApFormIns<StoreType> | undefined>) => Ref<ValueType | undefined, ValueType | undefined>;
5
+ type WatchOptions<ValueType> = {
6
+ initialValue: ValueType;
7
+ };
8
+ export declare function useWatch<ValueType = any, StoreType = any>(name: NamePath | Ref<NamePath>, formOrOptions?: Ref<ApFormIns<StoreType> | undefined> | WatchOptions<ValueType>, options?: WatchOptions<ValueType>): Ref<ValueType | undefined, ValueType | undefined>;
6
9
  export default useWatch;
@@ -1,40 +1,42 @@
1
- import { useInjectForm as V } from "../context.mjs";
2
- import { ref as N, watchEffect as A, unref as l, watch as M } from "vue";
3
- import { isArray as R } from "lodash-unified";
4
- import { INTERNAL_FORM_INSTANCE_MARK as y } from "../constant.mjs";
5
- function w(t, e) {
6
- return R(e) ? e.reduce((n, u) => n == null ? void 0 : n[u], t) : t == null ? void 0 : t[e];
1
+ import { useInjectForm as M } from "../context.mjs";
2
+ import { ref as R, watchEffect as d, unref as s, watch as y } from "vue";
3
+ import { isArray as E } from "lodash-unified";
4
+ import { INTERNAL_FORM_INSTANCE_MARK as _ } from "../constant.mjs";
5
+ function N(e, t) {
6
+ return E(t) ? t.reduce((n, l) => n == null ? void 0 : n[l], e) : e == null ? void 0 : e[t];
7
7
  }
8
- function I(t) {
8
+ function V(e) {
9
9
  try {
10
- return JSON.stringify(t);
10
+ return JSON.stringify(e);
11
11
  } catch {
12
12
  return Math.random();
13
13
  }
14
14
  }
15
- const F = (t, e) => {
16
- const { internalInstance: n, model: u } = V(), i = N();
17
- let a = "", o = !0;
18
- return A((s) => {
19
- var f;
20
- const r = ((f = e == null ? void 0 : e.value) == null ? void 0 : f.getInternalInstance(y)) || n;
21
- if (!r) {
22
- o = !1;
15
+ function W(e, t, n) {
16
+ const { internalInstance: l, model: v } = M(), g = (n == null ? void 0 : n.initialValue) || (t == null ? void 0 : t.initialValue) || void 0, r = R(g);
17
+ let u = V(g), h = !0;
18
+ const i = t && "value" in t ? t : void 0;
19
+ return d((f) => {
20
+ var w;
21
+ const a = ((w = i == null ? void 0 : i.value) == null ? void 0 : w.getInternalInstance(_)) || l;
22
+ if (!a) {
23
+ h = !1;
23
24
  return;
24
25
  }
25
- const c = r.registerWatch((S) => {
26
- const g = w(S, l(t)), h = I(g);
27
- h !== a && (i.value = g, a = h);
28
- }, o);
29
- s(c);
30
- }), M(
31
- () => l(t),
32
- (s) => {
33
- const r = w(l(u), s), c = I(r);
34
- c !== a && (i.value = r, a = c);
26
+ const c = a.registerWatch((A) => {
27
+ const I = N(A, s(e)), S = V(I);
28
+ S !== u && (r.value = I, u = S);
29
+ }, h);
30
+ f(c);
31
+ }), y(
32
+ () => s(e),
33
+ (f) => {
34
+ const a = N(s(v), f), c = V(a);
35
+ c !== u && (r.value = a, u = c);
35
36
  }
36
- ), i;
37
- };
37
+ ), r;
38
+ }
38
39
  export {
39
- F as default
40
+ W as default,
41
+ W as useWatch
40
42
  };
@@ -4,7 +4,7 @@ import "./item-group/index.vue2.mjs";
4
4
  import "./list/index.vue2.mjs";
5
5
  import "./search-form/index.vue2.mjs";
6
6
  import "./modal-form/index.vue2.mjs";
7
- import m from "./hooks/use-watch.mjs";
7
+ import { useWatch as m } from "./hooks/use-watch.mjs";
8
8
  import "./dependency/index.vue2.mjs";
9
9
  import "./set/index.vue2.mjs";
10
10
  import "./drawer-form/index.vue2.mjs";
@@ -1,4 +1,4 @@
1
- import { defineComponent as _, ref as h, createBlock as a, openBlock as s, unref as u, withCtx as d, createElementBlock as v, Fragment as t, renderList as y, mergeProps as k, createElementVNode as w, withDirectives as g, createVNode as C, vShow as b, resolveDynamicComponent as L, h as M } from "vue";
1
+ import { defineComponent as _, ref as v, createBlock as a, openBlock as s, unref as u, withCtx as d, createElementBlock as h, Fragment as t, renderList as y, mergeProps as k, createElementVNode as w, withDirectives as g, createVNode as C, vShow as b, resolveDynamicComponent as L, h as M } from "vue";
2
2
  import { LoadingOutlined as B } from "@ant-design/icons-vue";
3
3
  import { Menu as R, MenuItem as x } from "@aplus-frontend/antdv";
4
4
  const D = { style: { display: "flex", "align-items": "center" } }, P = /* @__PURE__ */ _({
@@ -9,31 +9,31 @@ const D = { style: { display: "flex", "align-items": "center" } }, P = /* @__PUR
9
9
  menuList: {}
10
10
  },
11
11
  setup(f) {
12
- const o = f, r = h({});
13
- async function p(e, c) {
14
- var l;
15
- const n = (e == null ? void 0 : e.id) || c;
12
+ const l = f, r = v({});
13
+ async function p(o, c) {
14
+ var e;
15
+ const n = (o == null ? void 0 : o.id) || c;
16
16
  r.value[n] = !0;
17
17
  try {
18
- await ((l = e == null ? void 0 : e.onClick) == null ? void 0 : l.call(e, { selectedRows: o == null ? void 0 : o.selectedRows }));
18
+ await ((e = o == null ? void 0 : o.onClick) == null ? void 0 : e.call(o, { selectedRows: l == null ? void 0 : l.selectedRows }));
19
19
  } finally {
20
- r.value[n] = !1;
20
+ r.value[n] = void 0;
21
21
  }
22
22
  }
23
- return (e, c) => (s(), a(u(R), null, {
23
+ return (o, c) => (s(), a(u(R), null, {
24
24
  default: d(() => [
25
- (s(!0), v(t, null, y(o.menuList, (n, l) => (s(), a(u(x), k({
26
- key: (n == null ? void 0 : n.id) || l,
25
+ (s(!0), h(t, null, y(l.menuList, (n, e) => (s(), a(u(x), k({
26
+ key: (n == null ? void 0 : n.id) || e,
27
27
  ref_for: !0
28
28
  }, {
29
29
  ...n,
30
- onClick: () => p(n, l),
31
- disabled: r.value[(n == null ? void 0 : n.id) || l] ?? (n == null ? void 0 : n.disabled) ?? !1
30
+ onClick: () => p(n, e),
31
+ disabled: r.value[(n == null ? void 0 : n.id) || e] ?? (n == null ? void 0 : n.disabled) ?? !1
32
32
  }), {
33
33
  default: d(() => [
34
34
  w("div", D, [
35
35
  g(C(u(B), { style: { "margin-right": "10px" } }, null, 512), [
36
- [b, r.value[(n == null ? void 0 : n.id) || l]]
36
+ [b, r.value[(n == null ? void 0 : n.id) || e]]
37
37
  ]),
38
38
  (s(), a(L(M(t, [n == null ? void 0 : n.content]))))
39
39
  ])
@@ -2,5 +2,8 @@ import { NamePath } from '@aplus-frontend/antdv/es/form/interface';
2
2
  import { ApFormExpose } from '../interface';
3
3
  import { Ref } from 'vue';
4
4
  type ApFormIns<T> = ApFormExpose<T>;
5
- declare const useWatch: <ValueType = any, StoreType = any>(name: NamePath | Ref<NamePath>, form?: Ref<ApFormIns<StoreType> | undefined>) => Ref<ValueType | undefined, ValueType | undefined>;
5
+ type WatchOptions<ValueType> = {
6
+ initialValue: ValueType;
7
+ };
8
+ export declare function useWatch<ValueType = any, StoreType = any>(name: NamePath | Ref<NamePath>, formOrOptions?: Ref<ApFormIns<StoreType> | undefined> | WatchOptions<ValueType>, options?: WatchOptions<ValueType>): Ref<ValueType | undefined, ValueType | undefined>;
6
9
  export default useWatch;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("../context.js"),n=require("vue"),M=require("lodash-unified"),V=require("../constant.js");function h(e,t){return M.isArray(t)?t.reduce((r,s)=>r==null?void 0:r[s],e):e==null?void 0:e[t]}function d(e){try{return JSON.stringify(e)}catch{return Math.random()}}const N=(e,t)=>{const{internalInstance:r,model:s}=I.useInjectForm(),i=n.ref();let c="",o=!0;return n.watchEffect(l=>{var f;const u=((f=t==null?void 0:t.value)==null?void 0:f.getInternalInstance(V.INTERNAL_FORM_INSTANCE_MARK))||r;if(!u){o=!1;return}const a=u.registerWatch(w=>{const g=h(w,n.unref(e)),S=d(g);S!==c&&(i.value=g,c=S)},o);l(a)}),n.watch(()=>n.unref(e),l=>{const u=h(n.unref(s),l),a=d(u);a!==c&&(i.value=u,c=a)}),i};exports.default=N;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("../context.js"),u=require("vue"),o=require("lodash-unified"),q=require("../constant.js");function w(t,e){return o.isArray(e)?e.reduce((n,r)=>n==null?void 0:n[r],t):t==null?void 0:t[e]}function g(t){try{return JSON.stringify(t)}catch{return Math.random()}}function I(t,e,n){const{internalInstance:r,model:M}=_.useInjectForm(),V=(n==null?void 0:n.initialValue)||(e==null?void 0:e.initialValue)||void 0,i=u.ref(V);let c=g(V),d=!0;const s=e&&"value"in e?e:void 0;return u.watchEffect(f=>{var h;const a=((h=s==null?void 0:s.value)==null?void 0:h.getInternalInstance(q.INTERNAL_FORM_INSTANCE_MARK))||r;if(!a){d=!1;return}const l=a.registerWatch(N=>{const S=w(N,u.unref(t)),v=g(S);v!==c&&(i.value=S,c=v)},d);f(l)}),u.watch(()=>u.unref(t),f=>{const a=w(u.unref(M),f),l=g(a);l!==c&&(i.value=a,c=l)}),i}exports.default=I;exports.useWatch=I;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./ap-form.vue.js");require("./item/index.vue2.js");require("./item-group/index.vue2.js");require("./list/index.vue2.js");require("./search-form/index.vue2.js");require("./modal-form/index.vue2.js");const s=require("./hooks/use-watch.js");require("./dependency/index.vue2.js");require("./set/index.vue2.js");require("./drawer-form/index.vue2.js");require("./render/control.vue2.js");require("./render/item.vue2.js");require("./provider/index.vue2.js");require("./items/index.js");require("./interface.js");const c=require("./ap-form.vue2.js"),r=require("./item/index.vue.js"),t=require("./item-group/index.vue.js"),u=require("./list/index.vue.js"),_=require("./search-form/index.vue.js"),i=require("./modal-form/index.vue.js"),p=require("./dependency/index.vue.js"),o=require("./set/index.vue.js"),n=require("./drawer-form/index.vue.js"),a=require("./render/control.vue.js"),d=require("./render/item.vue.js"),l=require("./provider/index.vue.js"),e=c.default;e.FormItem=r.default;e.FormItemGroup=t.default;e.FormList=u.default;e.SearchForm=_.default;e.ModalForm=i.default;e.useWatch=s.default;e.Dependency=p.default;e.Set=o.default;e.DrawerForm=n.default;e.ControlRender=a.default;e.ItemRender=d.default;e.Provider=l.default;exports.ApFormItem=r.default;exports.ApFormItemGroup=t.default;exports.ApFormList=u.default;exports.ApFormSearchForm=_.default;exports.ApFormModalForm=i.default;exports.ApFormDependency=p.default;exports.ApFormSet=o.default;exports.ApFormDrawerForm=n.default;exports.ApFormControlRender=a.default;exports.ApFormItemRender=d.default;exports.ApFormProvider=l.default;exports.ApForm=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./ap-form.vue.js");require("./item/index.vue2.js");require("./item-group/index.vue2.js");require("./list/index.vue2.js");require("./search-form/index.vue2.js");require("./modal-form/index.vue2.js");const l=require("./hooks/use-watch.js");require("./dependency/index.vue2.js");require("./set/index.vue2.js");require("./drawer-form/index.vue2.js");require("./render/control.vue2.js");require("./render/item.vue2.js");require("./provider/index.vue2.js");require("./items/index.js");require("./interface.js");const c=require("./ap-form.vue2.js"),r=require("./item/index.vue.js"),t=require("./item-group/index.vue.js"),u=require("./list/index.vue.js"),_=require("./search-form/index.vue.js"),i=require("./modal-form/index.vue.js"),p=require("./dependency/index.vue.js"),o=require("./set/index.vue.js"),n=require("./drawer-form/index.vue.js"),a=require("./render/control.vue.js"),s=require("./render/item.vue.js"),d=require("./provider/index.vue.js"),e=c.default;e.FormItem=r.default;e.FormItemGroup=t.default;e.FormList=u.default;e.SearchForm=_.default;e.ModalForm=i.default;e.useWatch=l.useWatch;e.Dependency=p.default;e.Set=o.default;e.DrawerForm=n.default;e.ControlRender=a.default;e.ItemRender=s.default;e.Provider=d.default;exports.ApFormItem=r.default;exports.ApFormItemGroup=t.default;exports.ApFormList=u.default;exports.ApFormSearchForm=_.default;exports.ApFormModalForm=i.default;exports.ApFormDependency=p.default;exports.ApFormSet=o.default;exports.ApFormDrawerForm=n.default;exports.ApFormControlRender=a.default;exports.ApFormItemRender=s.default;exports.ApFormProvider=d.default;exports.ApForm=e;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("@ant-design/icons-vue"),s=require("@aplus-frontend/antdv"),f={style:{display:"flex","align-items":"center"}},p=e.defineComponent({__name:"MenuItemGroup",props:{selectedRows:{},buttonProps:{},menuList:{}},setup(a){const r=a,c=e.ref({});async function t(l,u){var o;const n=(l==null?void 0:l.id)||u;c.value[n]=!0;try{await((o=l==null?void 0:l.onClick)==null?void 0:o.call(l,{selectedRows:r==null?void 0:r.selectedRows}))}finally{c.value[n]=!1}}return(l,u)=>(e.openBlock(),e.createBlock(e.unref(s.Menu),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.menuList,(n,o)=>(e.openBlock(),e.createBlock(e.unref(s.MenuItem),e.mergeProps({key:(n==null?void 0:n.id)||o,ref_for:!0},{...n,onClick:()=>t(n,o),disabled:c.value[(n==null?void 0:n.id)||o]??(n==null?void 0:n.disabled)??!1}),{default:e.withCtx(()=>[e.createElementVNode("div",f,[e.withDirectives(e.createVNode(e.unref(d.LoadingOutlined),{style:{"margin-right":"10px"}},null,512),[[e.vShow,c.value[(n==null?void 0:n.id)||o]]]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.h(e.Fragment,[n==null?void 0:n.content]))))])]),_:2},1040))),128))]),_:1}))}});exports.default=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("@ant-design/icons-vue"),s=require("@aplus-frontend/antdv"),f={style:{display:"flex","align-items":"center"}},p=e.defineComponent({__name:"MenuItemGroup",props:{selectedRows:{},buttonProps:{},menuList:{}},setup(a){const r=a,c=e.ref({});async function t(o,u){var l;const n=(o==null?void 0:o.id)||u;c.value[n]=!0;try{await((l=o==null?void 0:o.onClick)==null?void 0:l.call(o,{selectedRows:r==null?void 0:r.selectedRows}))}finally{c.value[n]=void 0}}return(o,u)=>(e.openBlock(),e.createBlock(e.unref(s.Menu),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.menuList,(n,l)=>(e.openBlock(),e.createBlock(e.unref(s.MenuItem),e.mergeProps({key:(n==null?void 0:n.id)||l,ref_for:!0},{...n,onClick:()=>t(n,l),disabled:c.value[(n==null?void 0:n.id)||l]??(n==null?void 0:n.disabled)??!1}),{default:e.withCtx(()=>[e.createElementVNode("div",f,[e.withDirectives(e.createVNode(e.unref(d.LoadingOutlined),{style:{"margin-right":"10px"}},null,512),[[e.vShow,c.value[(n==null?void 0:n.id)||l]]]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.h(e.Fragment,[n==null?void 0:n.content]))))])]),_:2},1040))),128))]),_:1}))}});exports.default=p;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aplus-frontend/ui",
3
- "version": "0.4.35",
3
+ "version": "0.4.36",
4
4
  "main": "./lib/index.js",
5
5
  "type": "module",
6
6
  "files": [
@@ -65,8 +65,8 @@
65
65
  "sortablejs": "^1.15.2",
66
66
  "vue-virtual-scroller": "2.0.0-beta.8",
67
67
  "vuedraggable": "^4.1.0",
68
- "@aplus-frontend/hooks": "1.0.7",
69
- "@aplus-frontend/utils": "1.0.52"
68
+ "@aplus-frontend/utils": "1.0.52",
69
+ "@aplus-frontend/hooks": "1.0.7"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@aplus-frontend/antdv": "^1.0.13",