UNPKG

@jecloud/ui

Version:

JECloud UI库,基于ant-design-vue封装

1 lines 2.83 kB
var e=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var u=arguments[t],i=0,s=u.length;i<s;i++,o++)n[o]=u[i];return n};import{watch as t,reactive as r,computed as n,ref as o,getCurrentInstance as u}from"vue";import{isObject as i,pick as s,defaultsDeep as a,camelCase as v,split as l,join as f}from"@jecloud/utils";import{useField as d}from"./field";import{useConfigInfo as c}from"./config-info";import{useInjectFormItemContext as p}from"../form/src/context";export{d as useField,c as useConfigInfo};export function useModelValue(e){var r=e.props,u=e.context,i=e.key,s=void 0===i?"value":i,a=e.multiple,v=void 0!==a&&a,d=e.separator,c=void 0===d?",":d,h=e.changeEvent,x=void 0!==h&&h,g=e.changeValid,m=void 0!==g&&g,y=function(e,t){return void 0===t&&(t=!0),v?t?l(e,c):f(e,c):e},E=o(y(r[s])),M=u.emit;t((function(){return r[s]}),(function(e){var t=y(e);E.value!==t&&(E.value=t)}),{deep:!0});var k=p(),L=n({set:function(e){E.value=y(e),M("update:"+s,y(e,!1)),m&&setTimeout((function(){var e;null===(e=null==k?void 0:k.$plugin.value)||void 0===e||e.onFieldChange()}))},get:function(){return E.value}});x&&"value"===s&&((0,useListeners({props:r}).hasListener)("value-change")&&t((function(){return L.value}),(function(e,t){M("value-change",e,t)})));return L}export function useMixinsConfig(e,n){var o=Object.keys(n),u=s(e,o),v=Object.keys(u);a(u,n);var l=r(u);return v.forEach((function(r){t((function(){return e[r]}),(function(e){var t=n[r];l[r]=i(e)?a(e,t):e}))})),l}export function useExtendMethods(e){var t=e.plugin,r=e.keys,n={};return r.forEach((function(e){n[e]=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=t.value;return o&&o[e].apply(o,r)}})),n}export function useExtendEvents(t){var r=t.keys,n=t.emit,o={};return r.forEach((function(t){var r=v("on-"+t);o[r]=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n.apply(void 0,e([t],r))}})),o}export function useListeners(e){var t=e.props,r=u().vnode,n=function(e){var n,o,u=v("on-"+e);return null!==(n=t[u])&&void 0!==n?n:null===(o=r.props)||void 0===o?void 0:o[u]};return{hasListener:n,fireListener:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var o=n(e);if(o)return null==o?void 0:o.apply(void 0,t)}}}export var useOverrideMethods=function(e,t){Object.keys(t).forEach((function(r){e["_"+r]=e[r],e[r]=t[r]}))};export function useStyle4Size(e){var t=e.props,r={};return t.height&&(r.height=t.height+"px"),t.width&&(r.width=t.width+"px",r.maxWidth="100%"),r}export var Hooks={useField:d,useModelValue:useModelValue,useExtendEvents:useExtendEvents,useExtendMethods:useExtendMethods,useOverrideMethods:useOverrideMethods,useListeners:useListeners,useStyle4Size:useStyle4Size};export default Hooks;