@jdfed/hooks
Advanced tools
Comparing version 0.8.0-alpha.7 to 0.8.0-alpha.8
@@ -162,2 +162,3 @@ /// <reference types="react" /> | ||
type DeltItem = (order: number) => void; | ||
type ArrayMove = (oldIndex: number, newIndex: number) => void; | ||
declare const useArray: ({ fieldKey, dispatch, fieldData }: { | ||
@@ -170,2 +171,3 @@ fieldKey: string; | ||
deltItem: DeltItem; | ||
arrayMove: ArrayMove; | ||
}; | ||
@@ -172,0 +174,0 @@ declare const useContainer: ({ fieldKey, dispatch }: { |
@@ -1,2 +0,2 @@ | ||
import e from"@babel/runtime/helpers/esm/slicedToArray";import{useState as t,useCallback as r,useRef as n,useEffect as a,createContext as c,useContext as i,useMemo as o}from"react";import u from"@babel/runtime/helpers/esm/toConsumableArray";import s from"ahooks/es/useDebounceFn";import l from"@babel/runtime/helpers/esm/defineProperty";import f from"@babel/runtime/helpers/esm/typeof";import p from"moment";import d,{produce as m}from"immer";import{isEmpty as y,typeCheck as h,generateReg as v}from"@jdfed/utils";import b from"@babel/runtime/helpers/esm/asyncToGenerator";import g from"@babel/runtime/regenerator";var O=function(n){var a=t(n),c=e(a,2),i=c[0],o=c[1];return[i,r((function(){o(!0)}),[]),r((function(){o(!1)}),[])]},S=function(e){var t=n(null);return a((function(){t.current=e})),t},j=function(e){var t=n();return a((function(){t.current=e})),t.current},D=function(e,t){var c=n((function(){throw new Error("Cannot call an event handler while rendering.")}));return a((function(){c.current=e}),[e].concat(u(t))),r((function(){var e=c.current;return e.apply(void 0,arguments)}),[c])},w=function(){var e=n(!0),t=r((function(){e.current=!1}),[]),a=r((function(){e.current=!0}),[]);return[e.current,t,a]},K=function(e){return s((function(t){var r=t.dataSchema,n=t.formData,a=t.dispatch,c=t.visibleFieldKey,i=t.ajv,o=e({schema:r,formData:n,ajv:i,visibleFieldKey:c}),u=o.errorsMap,s=o.formData;a({type:"setAjvErr",action:{errors:u}}),a({type:"setData",action:{formData:s}}),a({type:"setChecking",checking:!1}),a({type:"setDefaultSuccess",action:{hasDefault:!0}})}),{wait:500}).run},P=c("default"),k=function(){return i(P)};function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var x={isMoment:function(e){var t=e.value,r=e.format;return t?Array.isArray(t)?[t[0].format(r),t[1].format(r)]:p(t).format(r):t},isColor:function(e){var t,r,n,a,c=e.value;if("object"===f(c))switch(c.source){case"rgb":return"rgba(".concat((null==c||null===(t=c.rgb)||void 0===t?void 0:t.r)||0,",").concat((null==c||null===(r=c.rgb)||void 0===r?void 0:r.g)||0,",").concat((null==c||null===(n=c.rgb)||void 0===n?void 0:n.b)||0,",").concat((null==c||null===(a=c.rgb)||void 0===a?void 0:a.a)||1,")");default:return(null==c?void 0:c.hex)||"#ffffff"}return c},isWithPid:function(e){var t=e.value,r=e.options,n=e.withPidDelimiter,a=function e(t){return t.reduce((function(t,r){if(r.children){var n=e(r.children);return t.concat(n).concat(r)}return t.concat(r)}),[])}(r);return t.map((function(e){return function e(t,r){var c=a.findIndex((function(e){return e.value===t}));if(-1!=c){var i=a[c].parentValue;return e(i,r="".concat(i).concat(n).concat(r||t))}return r}(e)}))},isFormat:function(e){var t=e.value,r=e.disabled_input;if(r){var n=r.join("|"),a=new RegExp(n,"g");if(a.test(t))return t.replace(a,"")}return t},isSelectText:function(e){var t=e.value,r=e.subFieldKey,n=e.prevFieldData;return Object.assign({select:[],text:""},"Object"===h(n)?n:{},l({},r,t))}},E=function(e,t){var r=e.fieldKey,n=e.onChange,a=e.options,c=void 0===a?{}:a,i=e.asyncValidate,o=e.prevFieldData,u=e.fieldData,f=e.getKey,p=k(),d=s((function(e,t){if(n)try{if("function"==typeof n)n({val:e,dispatch:t,fieldKey:r,prevFieldData:o,fieldData:u,getKey:f});else{var a=new Function("props",n);a&&a({val:e,dispatch:t,fieldKey:r,prevFieldData:o,fieldData:u,getKey:f})}}catch(e){console.error("onChange函数体错误"),console.error(e)}if(i&&"change"===i.type){var c=i.fn(e);null!=c&&c.then?c.then((function(e){t(e?{type:"setErr",action:{set:l({},r,e)}}:{type:"setErr",action:{deleteKeys:r}})})):t(c?{type:"setErr",action:{set:l({},r,c)}}:{type:"setErr",action:{deleteKeys:r}})}}),{wait:300}).run;return D((function(e){var n,a=y(u)?null!=e&&e.target?null==e||null===(n=e.target)||void 0===n?void 0:n.value:e:u;c.draft&&(a=m(a,(function(e){return e})));var i=Object.keys(x),o=Object.keys(c).filter((function(e){return!0===c[e]&&i.includes(e)}));1===o.length&&x[o[0]]&&(a=x[o[0]](function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({value:a},c))),(c.isDelete||y(a))&&"items"!==f(r,"dataSchema").split(".").pop()?(t("default"===p?{type:"setData",action:{deleteKeys:r}}:{type:"setData",action:{set:l({},r,a)}}),t({type:"setValidate",action:{deleteKeys:"".concat(f(r,"dataSchema"),".default")}})):t({type:"setData",action:{set:l({},r,a)}}),t({type:"setChecking",checking:!0}),d(a,t)}),[t,n,r])},A=function(e,t){var n=e.options,a=e.queryFunc,c=e.requestCache,i=void 0===c||c,o=e.fieldKey,u=e.getKey;return r(b(g.mark((function e(){var r,c=arguments;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==n.length&&i||!a){e.next=5;break}return e.next=3,a.apply(void 0,c);case 3:r=e.sent,t({type:"setUi",action:{set:l({},"".concat(u(o,"uiSchema"),".options"),r)}});case 5:case"end":return e.stop()}}),e)}))),[t,o,u,n.length,a,i])},T=function(e){var t=e.fieldKey,n=e.dispatch,a=e.fieldData;return{addItem:r((function(e,r){n({type:"setArrayKey",action:{fieldKey:t,order:e}}),n({type:"setData",action:{set:l({},t,d(a||[],(function(t){t.splice(e,0,r)})))}})}),[n,a,t]),deltItem:r((function(e){n({type:"setArrayKey",action:{fieldKey:t,order:e,isDelete:!0}}),n({type:"setErr",action:{deleteKeys:"".concat(t,".").concat(e)}}),n({type:"setData",action:{deleteKeys:"".concat(t,".").concat(e)}})}),[n,t])}},C=function(e){var t=e.fieldKey,r=e.dispatch;a((function(){return r({type:"setVisibleKey",action:{fieldKey:t}}),function(){r({type:"setVisibleKey",action:{deleteKeys:t}})}}),[r,t])},V=function(e){var t=r((function(t){var r=Object.keys(e).find((function(e){return v(t.split(".")).test(e)}));if(!r)throw"无法在typeMap中找到与".concat(t,"对应的key");return r}),[e]),n=r((function(r,n){return"data"===n?r:"unitedSchema"===n?e[t(r)].unitedSchemaKey:t(r).split(".").reduce((function(t,r,a,c){switch(0===a?"object":e[c.slice(0,a).join(".")].type){case"array":return"$container"===r?"uiSchema"===n?"".concat(t?"".concat(t,"."):"","properties.").concat(r):"".concat(t?"".concat(t,"."):"","items"):"uiSchema"===n?"".concat(t?"".concat(t,"."):"","properties.").concat(r):"".concat(t?"".concat(t,"."):"","items.").concat(r);case"object":default:return"".concat(t?"".concat(t,"."):"","properties.").concat(r)}}),"")}),[t,e]);return{getTypeKey:t,getKey:n}};function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var I=function(e){var t=e.uiSchema,n=e.dataSchema,a=e.typeMap,c=e.formData,i=e.dispatch,o=V(a),u=o.getTypeKey,s=o.getKey,f=r((function(e){if(e){var r=e.split(".");return u(e).split(".").reduce((function(e,t,n,c){return""===t?e:0===n||"object"===a[c.slice(0,n).join(".")].type?{uiSchema:e.uiSchema.properties[t],dataSchema:e.dataSchema.properties[t],data:e.data?e.data[t]:void 0}:"array"===a[c.slice(0,n).join(".")].type?"$container"===t?{uiSchema:e.uiSchema.properties.$container,dataSchema:e.dataSchema[0===n?"properties":"items"],data:e.data?e.data[r[n]]:void 0}:{uiSchema:e.uiSchema.properties[t],dataSchema:e.dataSchema[0===n?"properties":"items"][t],data:e.data?e.data[t]:void 0}:{uiSchema:e.uiSchema,dataSchema:e.dataSchema,data:e.data}}),{data:c,uiSchema:t,dataSchema:n})}return{uiSchema:t,dataSchema:n,data:c}}),[n,c,u,a,t]),p=r((function(e,r,a){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"set",u={data:c,uiSchema:t,dataSchema:n};if(""===e)i=u[a];else{var l=s(e,a);i=l.split(".").reduce((function(e,t){return e[t]}),u[a])}switch(h(r)){case"Function":return d(i,r);case"Object":if("set"===o)return r;var f=function e(t,r){return d(t,(function(t){for(var n in r)"Object"===h(r[n])&&t[n]?t[n]=e(t[n],r[n]):t[n]=r[n]}))};return f(i,r);default:return r}}),[n,c,s,t]),m=r((function(e,t,r){switch(t){case"data":i({type:"setData",action:M(M({},""===e&&{formData:p(e,r,"data")}),""!==e&&{set:l({},e,p(e,r,"data"))})});break;case"uiSchema":i({type:"setUi",action:M(M({},""===e&&{uiSchema:p(e,r,"uiSchema")}),""!==e&&{set:l({},s(e,"uiSchema"),p(e,r,"uiSchema"))})});break;case"dataSchema":i({type:"setValidate",action:M(M({},""===e&&{dataSchema:p(e,r,"dataSchema")}),""!==e&&{set:l({},s(e,"dataSchema"),p(e,r,"dataSchema"))})})}}),[i,s,p]),y=r((function(e,t,r){switch(t){case"data":i({type:"setData",action:M(M({},""===e&&{formData:p(e,r,"data","merge")}),""!==e&&{set:l({},e,p(e,r,"data","merge"))})});break;case"uiSchema":i({type:"setUi",action:M(M({},""===e&&{uiSchema:p(e,r,"uiSchema","merge")}),""!==e&&{set:l({},s(e,"uiSchema"),p(e,r,"uiSchema","merge"))})});break;case"dataSchema":i({type:"setValidate",action:M(M({},""===e&&{dataSchema:p(e,r,"dataSchema","merge")}),""!==e&&{set:l({},s(e,"dataSchema"),p(e,r,"dataSchema","merge"))})})}}),[i,s,p]),v=r((function(e,t){i({type:"deleteField",action:{fieldKey:e,get:f,getKey:s,getTypeKey:u}}),t&&t()}),[i,f,s,u]),b=r((function(e){var t=e.fieldKey,r=e.closestEdge,n=e.unitedSchema,a=e.overFieldKey,c=e.cb,o=e.shouldDelete;i({type:"addField",action:{fieldKey:t,closestEdge:r,unitedSchema:n,overFieldKey:a,get:f,getKey:s,getTypeKey:u,shouldDelete:o}}),c&&c()}),[i,f,s,u]);return{get:f,set:m,deleteField:v,addField:b,merge:y}};function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var $={top:["0","0","5px","0"],right:["0","0","0","10px"],bottom:["5px","0","0","0"],left:["0","10px","0","0"]},q=["marginTop","marginRight","marginBottom","marginLeft"];function B(e,t){var r=$[t||"left"];if(Object.hasOwnProperty.call(e,"margin")){var n,a=(null==e||null===(n=e.margin)||void 0===n?void 0:n.split(" "))||[];r=1===(a=a.filter((function(e){return!!e}))).length?r.map((function(){return a[0]})):2===a.length?r.map((function(e,t){return t%2==0?a[0]:a[1]})):3===a.length?r.map((function(e,t){return 3===t?a[1]:a[t]})):a}return{style:(r=r.map((function(t,r){var n=q[r],a=Object.hasOwnProperty.call(e,n)&&null!==e&&Object.hasOwnProperty.call(e,n)&&void 0!==e[n]?e[n]:t;return Number.isNaN(Number(a))?"".concat(a):"".concat(a,"px")}))).join(" "),stringArr:r}}var L=function(r,n){var c=t((function(){return B(r,null==r?void 0:r.placement)})),i=e(c,2),u=i[0],s=i[1];a((function(){s(B(r,null==r?void 0:r.placement))}),[r]);var l=o((function(){return"object"===n?"100%":"Number"===h((null==r?void 0:r.width)||82)?"".concat((null==r?void 0:r.width)||82,"px"):(null==r?void 0:r.width)||"82px"}),[null==r?void 0:r.width,n]);return U(U({},r),{},{margin:u.style,width:l,marginTop:u.stringArr[0],marginRight:u.stringArr[1],marginBottom:u.stringArr[2],marginLeft:u.stringArr[3]})};export{P as RequiredModeContext,T as useArray,w as useClickOne,C as useContainer,D as useEventCallback,E as useField,V as useGetKey,O as useModal,j as usePrevious,A as useQuery,S as useRefProp,k as useRequiredModeContext,I as useSchema,L as useTitle,K as useValidate}; | ||
import e from"@babel/runtime/helpers/esm/slicedToArray";import{useState as t,useCallback as r,useRef as n,useEffect as a,createContext as c,useContext as i,useMemo as o}from"react";import u from"@babel/runtime/helpers/esm/toConsumableArray";import s from"ahooks/es/useDebounceFn";import l from"@babel/runtime/helpers/esm/defineProperty";import f from"@babel/runtime/helpers/esm/typeof";import p from"moment";import d,{produce as m}from"immer";import{isEmpty as y,typeCheck as h,generateReg as v}from"@jdfed/utils";import b from"@babel/runtime/helpers/esm/asyncToGenerator";import g from"@babel/runtime/regenerator";var O=function(n){var a=t(n),c=e(a,2),i=c[0],o=c[1];return[i,r((function(){o(!0)}),[]),r((function(){o(!1)}),[])]},S=function(e){var t=n(null);return a((function(){t.current=e})),t},j=function(e){var t=n();return a((function(){t.current=e})),t.current},D=function(e,t){var c=n((function(){throw new Error("Cannot call an event handler while rendering.")}));return a((function(){c.current=e}),[e].concat(u(t))),r((function(){var e=c.current;return e.apply(void 0,arguments)}),[c])},K=function(){var e=n(!0),t=r((function(){e.current=!1}),[]),a=r((function(){e.current=!0}),[]);return[e.current,t,a]},w=function(e){return s((function(t){var r=t.dataSchema,n=t.formData,a=t.dispatch,c=t.visibleFieldKey,i=t.ajv,o=e({schema:r,formData:n,ajv:i,visibleFieldKey:c}),u=o.errorsMap,s=o.formData;a({type:"setAjvErr",action:{errors:u}}),a({type:"setData",action:{formData:s}}),a({type:"setChecking",checking:!1}),a({type:"setDefaultSuccess",action:{hasDefault:!0}})}),{wait:500}).run},P=c("default"),k=function(){return i(P)};function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var x={isMoment:function(e){var t=e.value,r=e.format;return t?Array.isArray(t)?[t[0].format(r),t[1].format(r)]:p(t).format(r):t},isColor:function(e){var t,r,n,a,c=e.value;if("object"===f(c))switch(c.source){case"rgb":return"rgba(".concat((null==c||null===(t=c.rgb)||void 0===t?void 0:t.r)||0,",").concat((null==c||null===(r=c.rgb)||void 0===r?void 0:r.g)||0,",").concat((null==c||null===(n=c.rgb)||void 0===n?void 0:n.b)||0,",").concat((null==c||null===(a=c.rgb)||void 0===a?void 0:a.a)||1,")");default:return(null==c?void 0:c.hex)||"#ffffff"}return c},isWithPid:function(e){var t=e.value,r=e.options,n=e.withPidDelimiter,a=function e(t){return t.reduce((function(t,r){if(r.children){var n=e(r.children);return t.concat(n).concat(r)}return t.concat(r)}),[])}(r);return t.map((function(e){return function e(t,r){var c=a.findIndex((function(e){return e.value===t}));if(-1!=c){var i=a[c].parentValue;return e(i,r="".concat(i).concat(n).concat(r||t))}return r}(e)}))},isFormat:function(e){var t=e.value,r=e.disabled_input;if(r){var n=r.join("|"),a=new RegExp(n,"g");if(a.test(t))return t.replace(a,"")}return t},isSelectText:function(e){var t=e.value,r=e.subFieldKey,n=e.prevFieldData;return Object.assign({select:[],text:""},"Object"===h(n)?n:{},l({},r,t))}},E=function(e,t){var r=e.fieldKey,n=e.onChange,a=e.options,c=void 0===a?{}:a,i=e.asyncValidate,o=e.prevFieldData,u=e.fieldData,f=e.getKey,p=k(),d=s((function(e,t){if(n)try{if("function"==typeof n)n({val:e,dispatch:t,fieldKey:r,prevFieldData:o,fieldData:u,getKey:f});else{var a=new Function("props",n);a&&a({val:e,dispatch:t,fieldKey:r,prevFieldData:o,fieldData:u,getKey:f})}}catch(e){console.error("onChange函数体错误"),console.error(e)}if(i&&"change"===i.type){var c=i.fn(e);null!=c&&c.then?c.then((function(e){t(e?{type:"setErr",action:{set:l({},r,e)}}:{type:"setErr",action:{deleteKeys:r}})})):t(c?{type:"setErr",action:{set:l({},r,c)}}:{type:"setErr",action:{deleteKeys:r}})}}),{wait:300}).run;return D((function(e){var n,a=y(u)?null!=e&&e.target?null==e||null===(n=e.target)||void 0===n?void 0:n.value:e:u;c.draft&&(a=m(a,(function(e){return e})));var i=Object.keys(x),o=Object.keys(c).filter((function(e){return!0===c[e]&&i.includes(e)}));1===o.length&&x[o[0]]&&(a=x[o[0]](function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({value:a},c))),(c.isDelete||y(a))&&"items"!==f(r,"dataSchema").split(".").pop()?(t("default"===p?{type:"setData",action:{deleteKeys:r}}:{type:"setData",action:{set:l({},r,a)}}),t({type:"setValidate",action:{deleteKeys:"".concat(f(r,"dataSchema"),".default")}})):t({type:"setData",action:{set:l({},r,a)}}),t({type:"setChecking",checking:!0}),d(a,t)}),[t,n,r])},A=function(e,t){var n=e.options,a=e.queryFunc,c=e.requestCache,i=void 0===c||c,o=e.fieldKey,u=e.getKey;return r(b(g.mark((function e(){var r,c=arguments;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==n.length&&i||!a){e.next=5;break}return e.next=3,a.apply(void 0,c);case 3:r=e.sent,t({type:"setUi",action:{set:l({},"".concat(u(o,"uiSchema"),".options"),r)}});case 5:case"end":return e.stop()}}),e)}))),[t,o,u,n.length,a,i])},T=function(e){var t=e.fieldKey,n=e.dispatch,a=e.fieldData;return{addItem:r((function(e,r){n({type:"setArrayKey",action:{fieldKey:t,order:e}}),n({type:"setData",action:{set:l({},t,d(a||[],(function(t){t.splice(e,0,r)})))}})}),[n,a,t]),deltItem:r((function(e){n({type:"setArrayKey",action:{fieldKey:t,order:e,isDelete:!0}}),n({type:"setErr",action:{deleteKeys:"".concat(t,".").concat(e)}}),n({type:"setData",action:{deleteKeys:"".concat(t,".").concat(e)}})}),[n,t]),arrayMove:r((function(e,r){n({type:"setData",action:{set:l({},t,d(a||[],(function(t){t.splice(r,0,t.splice(e,1)[0])})))}}),n({type:"setArrayKey",action:{fieldKey:t,move:[e,r]}})}),[n,a,t])}},C=function(e){var t=e.fieldKey,r=e.dispatch;a((function(){return r({type:"setVisibleKey",action:{fieldKey:t}}),function(){r({type:"setVisibleKey",action:{deleteKeys:t}})}}),[r,t])},V=function(e){var t=r((function(t){var r=Object.keys(e).find((function(e){return v(t.split(".")).test(e)}));if(!r)throw"无法在typeMap中找到与".concat(t,"对应的key");return r}),[e]),n=r((function(r,n){return"data"===n?r:"unitedSchema"===n?e[t(r)].unitedSchemaKey:t(r).split(".").reduce((function(t,r,a,c){switch(0===a?"object":e[c.slice(0,a).join(".")].type){case"array":return"$container"===r?"uiSchema"===n?"".concat(t?"".concat(t,"."):"","properties.").concat(r):"".concat(t?"".concat(t,"."):"","items"):"uiSchema"===n?"".concat(t?"".concat(t,"."):"","properties.").concat(r):"".concat(t?"".concat(t,"."):"","items.").concat(r);case"object":default:return"".concat(t?"".concat(t,"."):"","properties.").concat(r)}}),"")}),[t,e]);return{getTypeKey:t,getKey:n}};function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var I=function(e){var t=e.uiSchema,n=e.dataSchema,a=e.typeMap,c=e.formData,i=e.dispatch,o=V(a),u=o.getTypeKey,s=o.getKey,f=r((function(e){if(e){var r=e.split(".");return u(e).split(".").reduce((function(e,t,n,c){return""===t?e:0===n||"object"===a[c.slice(0,n).join(".")].type?{uiSchema:e.uiSchema.properties[t],dataSchema:e.dataSchema.properties[t],data:e.data?e.data[t]:void 0}:"array"===a[c.slice(0,n).join(".")].type?"$container"===t?{uiSchema:e.uiSchema.properties.$container,dataSchema:e.dataSchema[0===n?"properties":"items"],data:e.data?e.data[r[n]]:void 0}:{uiSchema:e.uiSchema.properties[t],dataSchema:e.dataSchema[0===n?"properties":"items"][t],data:e.data?e.data[t]:void 0}:{uiSchema:e.uiSchema,dataSchema:e.dataSchema,data:e.data}}),{data:c,uiSchema:t,dataSchema:n})}return{uiSchema:t,dataSchema:n,data:c}}),[n,c,u,a,t]),p=r((function(e,r,a){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"set",u={data:c,uiSchema:t,dataSchema:n};if(""===e)i=u[a];else{var l=s(e,a);i=l.split(".").reduce((function(e,t){return e[t]}),u[a])}switch(h(r)){case"Function":return d(i,r);case"Object":if("set"===o)return r;var f=function e(t,r){return d(t,(function(t){for(var n in r)"Object"===h(r[n])&&t[n]?t[n]=e(t[n],r[n]):t[n]=r[n]}))};return f(i,r);default:return r}}),[n,c,s,t]),m=r((function(e,t,r){switch(t){case"data":i({type:"setData",action:N(N({},""===e&&{formData:p(e,r,"data")}),""!==e&&{set:l({},e,p(e,r,"data"))})});break;case"uiSchema":i({type:"setUi",action:N(N({},""===e&&{uiSchema:p(e,r,"uiSchema")}),""!==e&&{set:l({},s(e,"uiSchema"),p(e,r,"uiSchema"))})});break;case"dataSchema":i({type:"setValidate",action:N(N({},""===e&&{dataSchema:p(e,r,"dataSchema")}),""!==e&&{set:l({},s(e,"dataSchema"),p(e,r,"dataSchema"))})})}}),[i,s,p]),y=r((function(e,t,r){switch(t){case"data":i({type:"setData",action:N(N({},""===e&&{formData:p(e,r,"data","merge")}),""!==e&&{set:l({},e,p(e,r,"data","merge"))})});break;case"uiSchema":i({type:"setUi",action:N(N({},""===e&&{uiSchema:p(e,r,"uiSchema","merge")}),""!==e&&{set:l({},s(e,"uiSchema"),p(e,r,"uiSchema","merge"))})});break;case"dataSchema":i({type:"setValidate",action:N(N({},""===e&&{dataSchema:p(e,r,"dataSchema","merge")}),""!==e&&{set:l({},s(e,"dataSchema"),p(e,r,"dataSchema","merge"))})})}}),[i,s,p]),v=r((function(e,t){i({type:"deleteField",action:{fieldKey:e,get:f,getKey:s,getTypeKey:u}}),t&&t()}),[i,f,s,u]),b=r((function(e){var t=e.fieldKey,r=e.closestEdge,n=e.unitedSchema,a=e.overFieldKey,c=e.cb,o=e.shouldDelete;i({type:"addField",action:{fieldKey:t,closestEdge:r,unitedSchema:n,overFieldKey:a,get:f,getKey:s,getTypeKey:u,shouldDelete:o}}),c&&c()}),[i,f,s,u]);return{get:f,set:m,deleteField:v,addField:b,merge:y}};function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var $={top:["0","0","5px","0"],right:["0","0","0","10px"],bottom:["5px","0","0","0"],left:["0","10px","0","0"]},q=["marginTop","marginRight","marginBottom","marginLeft"];function B(e,t){var r=$[t||"left"];if(Object.hasOwnProperty.call(e,"margin")){var n,a=(null==e||null===(n=e.margin)||void 0===n?void 0:n.split(" "))||[];r=1===(a=a.filter((function(e){return!!e}))).length?r.map((function(){return a[0]})):2===a.length?r.map((function(e,t){return t%2==0?a[0]:a[1]})):3===a.length?r.map((function(e,t){return 3===t?a[1]:a[t]})):a}return{style:(r=r.map((function(t,r){var n=q[r],a=Object.hasOwnProperty.call(e,n)&&null!==e&&Object.hasOwnProperty.call(e,n)&&void 0!==e[n]?e[n]:t;return Number.isNaN(Number(a))?"".concat(a):"".concat(a,"px")}))).join(" "),stringArr:r}}var L=function(r,n){var c=t((function(){return B(r,null==r?void 0:r.placement)})),i=e(c,2),u=i[0],s=i[1];a((function(){s(B(r,null==r?void 0:r.placement))}),[r]);var l=o((function(){return"object"===n?"100%":"Number"===h((null==r?void 0:r.width)||82)?"".concat((null==r?void 0:r.width)||82,"px"):(null==r?void 0:r.width)||"82px"}),[null==r?void 0:r.width,n]);return U(U({},r),{},{margin:u.style,width:l,marginTop:u.stringArr[0],marginRight:u.stringArr[1],marginBottom:u.stringArr[2],marginLeft:u.stringArr[3]})};export{P as RequiredModeContext,T as useArray,K as useClickOne,C as useContainer,D as useEventCallback,E as useField,V as useGetKey,O as useModal,j as usePrevious,A as useQuery,S as useRefProp,k as useRequiredModeContext,I as useSchema,L as useTitle,w as useValidate}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@jdfed/hooks", | ||
"version": "0.8.0-alpha.7", | ||
"version": "0.8.0-alpha.8", | ||
"description": "drip-form通用hooks", | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
"@babel/runtime": "^7.10.2", | ||
"@jdfed/utils": "^0.8.0-alpha.7", | ||
"@jdfed/utils": "^0.8.0-alpha.8", | ||
"ahooks": "^2.10.12", | ||
@@ -45,3 +45,3 @@ "ajv": "^8.8.2", | ||
}, | ||
"gitHead": "ea5007c3090a5581c1359db9171a4149ed8c1085" | ||
"gitHead": "7bb993b3e8ab256b388c567d30dfa9ac5890ee89" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227382
253
Updated@jdfed/utils@^0.8.0-alpha.8