@aplus-frontend/ui 0.2.6 → 0.2.7

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.
@@ -71,10 +71,11 @@ export type ApiFieldRadioExpose = {
71
71
  focus: () => void;
72
72
  blur: () => void;
73
73
  };
74
+ export type ApFieldSwitchConfirmConfig = Pick<PopconfirmProps, 'title' | 'okText' | 'cancelText' | 'description' | 'showCancel' | 'icon' | 'okType' | 'onCancel' | 'okButtonProps' | 'cancelButtonProps'>;
74
75
  export type ApFieldSwitchProps = BasicApFieldProps<Omit<SwitchProps, 'onClick'>> & {
75
76
  emptyText?: string;
76
77
  onAction?: (checked: string | boolean | number, e?: Event) => boolean | Promise<boolean>;
77
- confirm?: Pick<PopconfirmProps, 'title' | 'okText' | 'cancelText' | 'description' | 'showCancel' | 'icon' | 'okType' | 'onCancel'>;
78
+ confirm?: ApFieldSwitchConfirmConfig | ((checked: string | number | boolean) => ApFieldSwitchConfirmConfig);
78
79
  };
79
80
  export type ApFieldTextAreaProps = BasicApFieldProps<Omit<TextAreaProps, 'autosize'>> & {
80
81
  emptyText?: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("@aplus-frontend/antdv");require("../../hooks/index.js");const h=require("lodash-unified"),i=require("@fruits-chain/utils"),V=require("../../hooks/useControllableValue.js"),v=e.defineComponent({name:"ApFieldSwitch",__name:"index",props:{mode:{},class:{},style:{},id:{},prefixCls:{},size:{default:"default"},disabled:{type:Boolean},checkedChildren:{},unCheckedChildren:{},tabindex:{},autofocus:{type:Boolean},loading:{type:Boolean,default:void 0},checked:{},checkedValue:{default:!0},unCheckedValue:{default:!1},onChange:{},onKeydown:{},onMouseup:{},"onUpdate:checked":{},onBlur:{},onFocus:{},emptyText:{default:"--"},onAction:{},confirm:{}},emits:["update:checked"],setup(m,{emit:p}){const r=e.useSlots(),o=m,C=p,{value:l,updateValue:u}=V.useControllableValue(o,C,{valuePropName:"checked"}),a=e.ref(!1);async function k(n,d){if(!i.isDef(o.confirm)){if(!i.isDef(o.onAction)){u(n);return}a.value=!0;try{await o.onAction(n,d)&&u(n)}finally{a.value=!1}}}async function g(){const n=e.unref(l)===o.checkedValue?o.unCheckedValue:o.checkedValue;if(!i.isDef(o.onAction)){u(n);return}await o.onAction(n)&&u(n)}const y=e.computed(()=>{var c,t;const n=e.unref(l);return h.isNil(n)?e.createVNode(e.Fragment,null,[o.emptyText]):n===o.checkedValue?e.createVNode(e.Fragment,null,[o.checkedChildren||((c=r.checkedChildren)==null?void 0:c.call(r))||`${o.checkedValue}`]):e.createVNode(e.Fragment,null,[o.unCheckedChildren||((t=r.unCheckedChildren)==null?void 0:t.call(r))||`${o.unCheckedValue}`])});return(n,d)=>n.mode==="read"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y.value),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[!e.unref(i.isDef)(n.confirm)||n.disabled?(e.openBlock(),e.createBlock(e.unref(f.Switch),e.mergeProps({key:0},e.unref(h.omit)(o,"onUpdate:checked"),{checked:e.unref(l),onClick:k,loading:n.loading??a.value}),e.createSlots({_:2},[e.renderList(r,(c,t)=>({name:t,fn:e.withCtx(s=>[e.renderSlot(n.$slots,t,e.normalizeProps(e.guardReactiveProps(s||{})))])}))]),1040,["checked","loading"])):(e.openBlock(),e.createBlock(e.unref(f.Popconfirm),e.mergeProps({key:1},n.confirm||{},{onConfirm:g}),{default:e.withCtx(()=>[e.createVNode(e.unref(f.Switch),e.mergeProps(e.unref(h.omit)(o,"onUpdate:checked"),{checked:e.unref(l),onClick:k,loading:n.loading??a.value}),e.createSlots({_:2},[e.renderList(r,(c,t)=>({name:t,fn:e.withCtx(s=>[e.renderSlot(n.$slots,t,e.normalizeProps(e.guardReactiveProps(s||{})))])}))]),1040,["checked","loading"])]),_:3},16))],64))}});exports.default=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),h=require("@aplus-frontend/antdv");require("../../hooks/index.js");const s=require("lodash-unified"),l=require("@fruits-chain/utils"),V=require("../../hooks/useControllableValue.js"),B=e.defineComponent({name:"ApFieldSwitch",__name:"index",props:{mode:{},class:{},style:{},id:{},prefixCls:{},size:{default:"default"},disabled:{type:Boolean},checkedChildren:{},unCheckedChildren:{},tabindex:{},autofocus:{type:Boolean},loading:{type:Boolean,default:void 0},checked:{},checkedValue:{default:!0},unCheckedValue:{default:!1},onChange:{},onKeydown:{},onMouseup:{},"onUpdate:checked":{},onBlur:{},onFocus:{},emptyText:{default:"--"},onAction:{},confirm:{}},emits:["update:checked"],setup(m,{emit:p}){const r=e.useSlots(),n=m,C=p,{value:c,updateValue:i}=V.useControllableValue(n,C,{valuePropName:"checked"}),a=e.ref(!1);async function k(o,d){if(!l.isDef(n.confirm)){if(!l.isDef(n.onAction)){i(o);return}a.value=!0;try{await n.onAction(o,d)&&i(o)}finally{a.value=!1}}}async function g(){const o=e.unref(c)===n.checkedValue?n.unCheckedValue:n.checkedValue;if(!l.isDef(n.onAction)){i(o);return}await n.onAction(o)&&i(o)}const y=e.computed(()=>{var u,t;const o=e.unref(c);return s.isNil(o)?e.createVNode(e.Fragment,null,[n.emptyText]):o===n.checkedValue?e.createVNode(e.Fragment,null,[n.checkedChildren||((u=r.checkedChildren)==null?void 0:u.call(r))||`${n.checkedValue}`]):e.createVNode(e.Fragment,null,[n.unCheckedChildren||((t=r.unCheckedChildren)==null?void 0:t.call(r))||`${n.unCheckedValue}`])}),v=e.computed(()=>l.isDef(n.confirm)?s.isFunction(n.confirm)?n.confirm(e.unref(c)):n.confirm:{});return(o,d)=>o.mode==="read"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y.value),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[!e.unref(l.isDef)(o.confirm)||o.disabled?(e.openBlock(),e.createBlock(e.unref(h.Switch),e.mergeProps({key:0},e.unref(s.omit)(n,"onUpdate:checked"),{checked:e.unref(c),onClick:k,loading:o.loading??a.value}),e.createSlots({_:2},[e.renderList(r,(u,t)=>({name:t,fn:e.withCtx(f=>[e.renderSlot(o.$slots,t,e.normalizeProps(e.guardReactiveProps(f||{})))])}))]),1040,["checked","loading"])):(e.openBlock(),e.createBlock(e.unref(h.Popconfirm),e.mergeProps({key:1},v.value,{onConfirm:g}),{default:e.withCtx(()=>[e.createVNode(e.unref(h.Switch),e.mergeProps(e.unref(s.omit)(n,"onUpdate:checked"),{checked:e.unref(c),onClick:k,loading:o.loading??a.value}),e.createSlots({_:2},[e.renderList(r,(u,t)=>({name:t,fn:e.withCtx(f=>[e.renderSlot(o.$slots,t,e.normalizeProps(e.guardReactiveProps(f||{})))])}))]),1040,["checked","loading"])]),_:3},16))],64))}});exports.default=B;