@ram_28/kf-ai-sdk 2.0.14 → 2.0.16
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.
- package/README.md +10 -9
- package/dist/FileField-BWrSHNRq.js +296 -0
- package/dist/FileField-eDeuzln8.cjs +1 -0
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo/core/BaseBdo.d.ts +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +230 -474
- package/dist/{client-DnO2KKrw.cjs → client-D5k4SYuw.cjs} +1 -1
- package/dist/{client-iQTqFDNI.js → client-_ayziI1d.js} +33 -32
- package/dist/components/hooks/index.d.ts +9 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/{workflow/components → components/hooks}/useActivityForm/createActivityItemProxy.d.ts +9 -5
- package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts +23 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/index.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/types.d.ts +12 -8
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/useActivityForm.d.ts +2 -2
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/index.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/types.d.ts +36 -0
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/createResolver.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/index.d.ts +6 -0
- package/dist/components/hooks/useBDOForm/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/shared.d.ts +50 -0
- package/dist/components/hooks/useBDOForm/shared.d.ts.map +1 -0
- package/dist/components/hooks/{useForm → useBDOForm}/types.d.ts +6 -6
- package/dist/components/hooks/useBDOForm/types.d.ts.map +1 -0
- package/dist/components/hooks/{useForm/useForm.d.ts → useBDOForm/useBDOForm.d.ts} +4 -4
- package/dist/components/hooks/useBDOForm/useBDOForm.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/index.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/types.d.ts +24 -0
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -0
- package/dist/components/hooks/useTable/index.d.ts +2 -2
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +11 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.mjs +279 -344
- package/dist/form.types.d.ts +1 -1
- package/dist/form.types.d.ts.map +1 -1
- package/dist/{metadata-DpfI3zRN.js → metadata-Cc1mBcLS.js} +1 -1
- package/dist/{metadata-DgLSJkF5.cjs → metadata-DWXQPDav.cjs} +1 -1
- package/dist/shared-5a7UkED1.js +1180 -0
- package/dist/shared-nnmlRVs7.cjs +1 -0
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.mjs +17 -192
- package/dist/table.types.d.ts +2 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/base-fields.d.ts +4 -4
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/constants.d.ts +3 -3
- package/dist/useTable-CeRklbdT.cjs +1 -0
- package/dist/useTable-DS0-WInw.js +203 -0
- package/dist/workflow/Activity.d.ts +19 -7
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/client.d.ts +2 -2
- package/dist/workflow/client.d.ts.map +1 -1
- package/dist/workflow/createFieldFromMeta.d.ts +29 -0
- package/dist/workflow/createFieldFromMeta.d.ts.map +1 -0
- package/dist/workflow/index.d.ts +1 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +16 -12
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.d.ts +5 -2
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.mjs +687 -352
- package/dist/workflow.types.d.ts +1 -0
- package/dist/workflow.types.d.ts.map +1 -1
- package/docs/bdo.md +1 -1
- package/docs/gaps.md +360 -0
- package/docs/useActivityForm.md +393 -0
- package/docs/useActivityTable.md +418 -0
- package/docs/{useForm.md → useBDOForm.md} +24 -24
- package/docs/useBDOTable.md +284 -0
- package/docs/workflow.md +148 -297
- package/package.json +2 -2
- package/sdk/bdo/core/BaseBdo.ts +2 -2
- package/sdk/bdo/fields/UserField.ts +1 -1
- package/sdk/components/hooks/index.ts +28 -5
- package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +400 -0
- package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +87 -0
- package/sdk/{workflow/components → components/hooks}/useActivityForm/types.ts +24 -11
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +478 -0
- package/sdk/components/hooks/useActivityTable/index.ts +8 -0
- package/sdk/components/hooks/useActivityTable/types.ts +47 -0
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +40 -0
- package/sdk/components/hooks/{useForm → useBDOForm}/index.ts +4 -3
- package/sdk/components/hooks/useBDOForm/shared.ts +250 -0
- package/sdk/components/hooks/{useForm → useBDOForm}/types.ts +9 -9
- package/sdk/components/hooks/{useForm/useForm.ts → useBDOForm/useBDOForm.ts} +70 -96
- package/sdk/components/hooks/useBDOTable/index.ts +2 -0
- package/sdk/components/hooks/useBDOTable/types.ts +22 -0
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +16 -0
- package/sdk/components/hooks/useTable/index.ts +3 -3
- package/sdk/components/hooks/useTable/types.ts +16 -12
- package/sdk/components/hooks/useTable/useTable.ts +56 -49
- package/sdk/form.ts +2 -2
- package/sdk/form.types.ts +4 -4
- package/sdk/table.ts +4 -1
- package/sdk/table.types.ts +7 -4
- package/sdk/types/base-fields.ts +4 -4
- package/sdk/types/constants.ts +3 -3
- package/sdk/workflow/Activity.ts +36 -12
- package/sdk/workflow/client.ts +65 -12
- package/sdk/workflow/createFieldFromMeta.ts +110 -0
- package/sdk/workflow/index.ts +1 -6
- package/sdk/workflow/types.ts +20 -11
- package/sdk/workflow.ts +11 -2
- package/sdk/workflow.types.ts +7 -0
- package/dist/BaseField-B6da88U7.js +0 -40
- package/dist/BaseField-Drp0-OxL.cjs +0 -1
- package/dist/components/hooks/useForm/createItemProxy.d.ts.map +0 -1
- package/dist/components/hooks/useForm/createResolver.d.ts.map +0 -1
- package/dist/components/hooks/useForm/index.d.ts +0 -5
- package/dist/components/hooks/useForm/index.d.ts.map +0 -1
- package/dist/components/hooks/useForm/types.d.ts.map +0 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +0 -1
- package/dist/error-handling-CAoD0Kwb.cjs +0 -1
- package/dist/error-handling-CrhTtD88.js +0 -14
- package/dist/index.esm-Cj63v5ny.js +0 -1014
- package/dist/index.esm-DuwT11sx.cjs +0 -1
- package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts +0 -22
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/index.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/types.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/useActivityForm.d.ts.map +0 -1
- package/docs/useTable.md +0 -369
- package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +0 -130
- package/sdk/workflow/components/useActivityForm/createActivityResolver.ts +0 -61
- package/sdk/workflow/components/useActivityForm/useActivityForm.ts +0 -386
- /package/dist/{workflow/components → components/hooks}/useActivityForm/index.d.ts +0 -0
- /package/dist/components/hooks/{useForm → useBDOForm}/createItemProxy.d.ts +0 -0
- /package/dist/components/hooks/{useForm → useBDOForm}/createResolver.d.ts +0 -0
- /package/sdk/{workflow/components → components/hooks}/useActivityForm/index.ts +0 -0
- /package/sdk/components/hooks/{useForm → useBDOForm}/createItemProxy.ts +0 -0
- /package/sdk/components/hooks/{useForm → useBDOForm}/createResolver.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const W=require("react");var he=e=>e.type==="checkbox",se=e=>e instanceof Date,N=e=>e==null;const rt=e=>typeof e=="object";var T=e=>!N(e)&&!Array.isArray(e)&&rt(e)&&!se(e),mt=e=>T(e)&&e.target?he(e.target)?e.target.checked:e.target.value:e,wt=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,At=(e,r)=>e.has(wt(r)),xt=e=>{const r=e.constructor&&e.constructor.prototype;return T(r)&&r.hasOwnProperty("isPrototypeOf")},Se=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function O(e){if(e instanceof Date)return new Date(e);const r=typeof FileList<"u"&&e instanceof FileList;if(Se&&(e instanceof Blob||r))return e;const t=Array.isArray(e);if(!t&&!(T(e)&&xt(e)))return e;const n=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=O(e[o]));return n}var Fe=e=>/^\w*$/.test(e),E=e=>e===void 0,Ce=e=>Array.isArray(e)?e.filter(Boolean):[],Te=e=>Ce(e.replace(/["|']|\]/g,"").split(/\.|\[/)),h=(e,r,t)=>{if(!r||!T(e))return t;const n=(Fe(r)?[r]:Te(r)).reduce((o,a)=>N(o)?o:o[a],e);return E(n)||n===e?E(e[r])?t:e[r]:n},K=e=>typeof e=="boolean",Z=e=>typeof e=="function",k=(e,r,t)=>{let n=-1;const o=Fe(r)?[r]:Te(r),a=o.length,u=a-1;for(;++n<a;){const c=o[n];let D=t;if(n!==u){const w=e[c];D=T(w)||Array.isArray(w)?w:isNaN(+o[n+1])?{}:[]}if(c==="__proto__"||c==="constructor"||c==="prototype")return;e[c]=D,e=e[c]}};const je={BLUR:"blur",FOCUS_OUT:"focusout"},z={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},X={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dt=W.createContext(null);Dt.displayName="HookFormContext";var kt=(e,r,t,n=!0)=>{const o={defaultValues:r._defaultValues};for(const a in e)Object.defineProperty(o,a,{get:()=>{const u=a;return r._proxyFormState[u]!==z.all&&(r._proxyFormState[u]=!n||z.all),e[u]}});return o};const Et=typeof window<"u"?W.useLayoutEffect:W.useEffect;var $=e=>typeof e=="string",St=(e,r,t,n,o)=>$(e)?(n&&r.watch.add(e),h(t,e,o)):Array.isArray(e)?e.map(a=>(n&&r.watch.add(a),h(t,a))):(n&&(r.watchAll=!0),t),ke=e=>N(e)||!rt(e);function ee(e,r,t=new WeakSet){if(ke(e)||ke(r))return Object.is(e,r);if(se(e)&&se(r))return Object.is(e.getTime(),r.getTime());const n=Object.keys(e),o=Object.keys(r);if(n.length!==o.length)return!1;if(t.has(e)||t.has(r))return!0;t.add(e),t.add(r);for(const a of n){const u=e[a];if(!o.includes(a))return!1;if(a!=="ref"){const c=r[a];if(se(u)&&se(c)||T(u)&&T(c)||Array.isArray(u)&&Array.isArray(c)?!ee(u,c,t):!Object.is(u,c))return!1}}return!0}var Ct=(e,r,t,n,o)=>r?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[n]:o||!0}}:{},de=e=>Array.isArray(e)?e:[e],He=()=>{let e=[];return{get observers(){return e},next:o=>{for(const a of e)a.next&&a.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(a=>a!==o)}}),unsubscribe:()=>{e=[]}}};function st(e,r){const t={};for(const n in e)if(e.hasOwnProperty(n)){const o=e[n],a=r[n];if(o&&T(o)&&a){const u=st(o,a);T(u)&&(t[n]=u)}else e[n]&&(t[n]=a)}return t}var B=e=>T(e)&&!Object.keys(e).length,Re=e=>e.type==="file",be=e=>{if(!Se)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},it=e=>e.type==="select-multiple",Le=e=>e.type==="radio",Tt=e=>Le(e)||he(e),De=e=>be(e)&&e.isConnected;function Rt(e,r){const t=r.slice(0,-1).length;let n=0;for(;n<t;)e=E(e)?n++:e[r[n++]];return e}function Lt(e){for(const r in e)if(e.hasOwnProperty(r)&&!E(e[r]))return!1;return!0}function C(e,r){const t=Array.isArray(r)?r:Fe(r)?[r]:Te(r),n=t.length===1?e:Rt(e,t),o=t.length-1,a=t[o];return n&&delete n[a],o!==0&&(T(n)&&B(n)||Array.isArray(n)&&Lt(n))&&C(e,t.slice(0,-1)),e}var Ot=e=>{for(const r in e)if(Z(e[r]))return!0;return!1};function nt(e){return Array.isArray(e)||T(e)&&!Ot(e)}function Ee(e,r={}){for(const t in e){const n=e[t];nt(n)?(r[t]=Array.isArray(n)?[]:{},Ee(n,r[t])):E(n)||(r[t]=!0)}return r}function ae(e,r,t){t||(t=Ee(r));for(const n in e){const o=e[n];if(nt(o))E(r)||ke(t[n])?t[n]=Ee(o,Array.isArray(o)?[]:{}):ae(o,N(r)?{}:r[n],t[n]);else{const a=r[n];t[n]=!ee(o,a)}}return t}const Ze={value:!1,isValid:!1},ze={value:!0,isValid:!0};var at=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!E(e[0].attributes.value)?E(e[0].value)||e[0].value===""?ze:{value:e[0].value,isValid:!0}:ze:Ze}return Ze},lt=(e,{valueAsNumber:r,valueAsDate:t,setValueAs:n})=>E(e)?e:r?e===""?NaN:e&&+e:t&&$(e)?new Date(e):n?n(e):e;const Ke={isValid:!1,value:null};var ot=e=>Array.isArray(e)?e.reduce((r,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:r,Ke):Ke;function Ye(e){const r=e.ref;return Re(r)?r.files:Le(r)?ot(e.refs).value:it(r)?[...r.selectedOptions].map(({value:t})=>t):he(r)?at(e.refs).value:lt(E(r.value)?e.ref.value:r.value,e)}var Pt=(e,r,t,n)=>{const o={};for(const a of e){const u=h(r,a);u&&k(o,a,u._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:n}},Ve=e=>e instanceof RegExp,fe=e=>E(e)?e:Ve(e)?e.source:T(e)?Ve(e.value)?e.value.source:e.value:e,Je=e=>({isOnSubmit:!e||e===z.onSubmit,isOnBlur:e===z.onBlur,isOnChange:e===z.onChange,isOnAll:e===z.all,isOnTouch:e===z.onTouched});const Qe="AsyncFunction";var Ut=e=>!!e&&!!e.validate&&!!(Z(e.validate)&&e.validate.constructor.name===Qe||T(e.validate)&&Object.values(e.validate).find(r=>r.constructor.name===Qe)),Mt=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Xe=(e,r,t)=>!t&&(r.watchAll||r.watch.has(e)||[...r.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const ye=(e,r,t,n)=>{for(const o of t||Object.keys(e)){const a=h(e,o);if(a){const{_f:u,...c}=a;if(u){if(u.refs&&u.refs[0]&&r(u.refs[0],o)&&!n)return!0;if(u.ref&&r(u.ref,u.name)&&!n)return!0;if(ye(c,r))break}else if(T(c)&&ye(c,r))break}}};function Ge(e,r,t){const n=h(e,t);if(n||Fe(t))return{error:n,name:t};const o=t.split(".");for(;o.length;){const a=o.join("."),u=h(r,a),c=h(e,a);if(u&&!Array.isArray(u)&&t!==a)return{name:t};if(c&&c.type)return{name:a,error:c};if(c&&c.root&&c.root.type)return{name:`${a}.root`,error:c.root};o.pop()}return{name:t}}var Bt=(e,r,t,n)=>{t(e);const{name:o,...a}=e;return B(a)||Object.keys(a).length>=Object.keys(r).length||Object.keys(a).find(u=>r[u]===(!n||z.all))},It=(e,r,t)=>!e||!r||e===r||de(e).some(n=>n&&(t?n===r:n.startsWith(r)||r.startsWith(n))),Nt=(e,r,t,n,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(r||e):(t?n.isOnBlur:o.isOnBlur)?!e:(t?n.isOnChange:o.isOnChange)?e:!0,qt=(e,r)=>!Ce(h(e,r)).length&&C(e,r),Wt=(e,r,t)=>{const n=de(h(e,t));return k(n,"root",r[t]),k(e,t,n),e};function et(e,r,t="validate"){if($(e)||Array.isArray(e)&&e.every($)||K(e)&&!e)return{type:t,message:$(e)?e:"",ref:r}}var ne=e=>T(e)&&!Ve(e)?e:{value:e,message:""},tt=async(e,r,t,n,o,a)=>{const{ref:u,refs:c,required:D,maxLength:w,minLength:S,min:b,max:V,pattern:v,validate:P,name:I,valueAsNumber:Y,mount:p}=e._f,_=h(t,I);if(!p||r.has(I))return{};const J=c?c[0]:u,Q=F=>{o&&J.reportValidity&&(J.setCustomValidity(K(F)?"":F||""),J.reportValidity())},R={},le=Le(u),ge=he(u),te=le||ge,ie=(Y||Re(u))&&E(u.value)&&E(_)||be(u)&&u.value===""||_===""||Array.isArray(_)&&!_.length,j=Ct.bind(null,I,n,R),ve=(F,m,L,U=X.maxLength,H=X.minLength)=>{const q=F?m:L;R[I]={type:F?U:H,message:q,ref:u,...j(F?U:H,q)}};if(a?!Array.isArray(_)||!_.length:D&&(!te&&(ie||N(_))||K(_)&&!_||ge&&!at(c).isValid||le&&!ot(c).isValid)){const{value:F,message:m}=$(D)?{value:!!D,message:D}:ne(D);if(F&&(R[I]={type:X.required,message:m,ref:J,...j(X.required,m)},!n))return Q(m),R}if(!ie&&(!N(b)||!N(V))){let F,m;const L=ne(V),U=ne(b);if(!N(_)&&!isNaN(_)){const H=u.valueAsNumber||_&&+_;N(L.value)||(F=H>L.value),N(U.value)||(m=H<U.value)}else{const H=u.valueAsDate||new Date(_),q=ce=>new Date(new Date().toDateString()+" "+ce),oe=u.type=="time",ue=u.type=="week";$(L.value)&&_&&(F=oe?q(_)>q(L.value):ue?_>L.value:H>new Date(L.value)),$(U.value)&&_&&(m=oe?q(_)<q(U.value):ue?_<U.value:H<new Date(U.value))}if((F||m)&&(ve(!!F,L.message,U.message,X.max,X.min),!n))return Q(R[I].message),R}if((w||S)&&!ie&&($(_)||a&&Array.isArray(_))){const F=ne(w),m=ne(S),L=!N(F.value)&&_.length>+F.value,U=!N(m.value)&&_.length<+m.value;if((L||U)&&(ve(L,F.message,m.message),!n))return Q(R[I].message),R}if(v&&!ie&&$(_)){const{value:F,message:m}=ne(v);if(Ve(F)&&!_.match(F)&&(R[I]={type:X.pattern,message:m,ref:u,...j(X.pattern,m)},!n))return Q(m),R}if(P){if(Z(P)){const F=await P(_,t),m=et(F,J);if(m&&(R[I]={...m,...j(X.validate,m.message)},!n))return Q(m.message),R}else if(T(P)){let F={};for(const m in P){if(!B(F)&&!n)break;const L=et(await P[m](_,t),J,m);L&&(F={...L,...j(m,L.message)},Q(L.message),n&&(R[I]=F))}if(!B(F)&&(R[I]={ref:J,...F},!n))return R}}return Q(!0),R};const $t={mode:z.onSubmit,reValidateMode:z.onChange,shouldFocusError:!0};function pt(e={}){let r={...$t,...e},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:Z(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1},n={},o=T(r.defaultValues)||T(r.values)?O(r.defaultValues||r.values)||{}:{},a=r.shouldUnregister?{}:O(o),u={action:!1,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},D,w=0;const S={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={...S};let V={...b};const v={array:He(),state:He()},P=r.criteriaMode===z.all,I=s=>i=>{clearTimeout(w),w=setTimeout(s,i)},Y=async s=>{if(!u.keepIsValid&&!r.disabled&&(b.isValid||V.isValid||s)){let i;r.resolver?(i=B((await te()).errors),p()):i=await j(n,!0),i!==t.isValid&&v.state.next({isValid:i})}},p=(s,i)=>{!r.disabled&&(b.isValidating||b.validatingFields||V.isValidating||V.validatingFields)&&((s||Array.from(c.mount)).forEach(l=>{l&&(i?k(t.validatingFields,l,i):C(t.validatingFields,l))}),v.state.next({validatingFields:t.validatingFields,isValidating:!B(t.validatingFields)}))},_=(s,i=[],l,y,d=!0,f=!0)=>{if(y&&l&&!r.disabled){if(u.action=!0,f&&Array.isArray(h(n,s))){const g=l(h(n,s),y.argA,y.argB);d&&k(n,s,g)}if(f&&Array.isArray(h(t.errors,s))){const g=l(h(t.errors,s),y.argA,y.argB);d&&k(t.errors,s,g),qt(t.errors,s)}if((b.touchedFields||V.touchedFields)&&f&&Array.isArray(h(t.touchedFields,s))){const g=l(h(t.touchedFields,s),y.argA,y.argB);d&&k(t.touchedFields,s,g)}(b.dirtyFields||V.dirtyFields)&&(t.dirtyFields=ae(o,a)),v.state.next({name:s,isDirty:F(s,i),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else k(a,s,i)},J=(s,i)=>{k(t.errors,s,i),v.state.next({errors:t.errors})},Q=s=>{t.errors=s,v.state.next({errors:t.errors,isValid:!1})},R=(s,i,l,y)=>{const d=h(n,s);if(d){const f=h(a,s,E(l)?h(o,s):l);E(f)||y&&y.defaultChecked||i?k(a,s,i?f:Ye(d._f)):U(s,f),u.mount&&!u.action&&Y()}},le=(s,i,l,y,d)=>{let f=!1,g=!1;const A={name:s};if(!r.disabled){if(!l||y){(b.isDirty||V.isDirty)&&(g=t.isDirty,t.isDirty=A.isDirty=F(),f=g!==A.isDirty);const x=ee(h(o,s),i);g=!!h(t.dirtyFields,s),x?C(t.dirtyFields,s):k(t.dirtyFields,s,!0),A.dirtyFields=t.dirtyFields,f=f||(b.dirtyFields||V.dirtyFields)&&g!==!x}if(l){const x=h(t.touchedFields,s);x||(k(t.touchedFields,s,l),A.touchedFields=t.touchedFields,f=f||(b.touchedFields||V.touchedFields)&&x!==l)}f&&d&&v.state.next(A)}return f?A:{}},ge=(s,i,l,y)=>{const d=h(t.errors,s),f=(b.isValid||V.isValid)&&K(i)&&t.isValid!==i;if(r.delayError&&l?(D=I(()=>J(s,l)),D(r.delayError)):(clearTimeout(w),D=null,l?k(t.errors,s,l):C(t.errors,s)),(l?!ee(d,l):d)||!B(y)||f){const g={...y,...f&&K(i)?{isValid:i}:{},errors:t.errors,name:s};t={...t,...g},v.state.next(g)}},te=async s=>(p(s,!0),await r.resolver(a,r.context,Pt(s||c.mount,n,r.criteriaMode,r.shouldUseNativeValidation))),ie=async s=>{const{errors:i}=await te(s);if(p(s),s)for(const l of s){const y=h(i,l);y?k(t.errors,l,y):C(t.errors,l)}else t.errors=i;return i},j=async(s,i,l={valid:!0})=>{for(const y in s){const d=s[y];if(d){const{_f:f,...g}=d;if(f){const A=c.array.has(f.name),x=d._f&&Ut(d._f);x&&b.validatingFields&&p([f.name],!0);const M=await tt(d,c.disabled,a,P,r.shouldUseNativeValidation&&!i,A);if(x&&b.validatingFields&&p([f.name]),M[f.name]&&(l.valid=!1,i||e.shouldUseNativeValidation))break;!i&&(h(M,f.name)?A?Wt(t.errors,M,f.name):k(t.errors,f.name,M[f.name]):C(t.errors,f.name))}!B(g)&&await j(g,i,l)}}return l.valid},ve=()=>{for(const s of c.unMount){const i=h(n,s);i&&(i._f.refs?i._f.refs.every(l=>!De(l)):!De(i._f.ref))&&_e(s)}c.unMount=new Set},F=(s,i)=>!r.disabled&&(s&&i&&k(a,s,i),!ee(Oe(),o)),m=(s,i,l)=>St(s,c,{...u.mount?a:E(i)?o:$(s)?{[s]:i}:i},l,i),L=s=>Ce(h(u.mount?a:o,s,r.shouldUnregister?h(o,s,[]):[])),U=(s,i,l={})=>{const y=h(n,s);let d=i;if(y){const f=y._f;f&&(!f.disabled&&k(a,s,lt(i,f)),d=be(f.ref)&&N(i)?"":i,it(f.ref)?[...f.ref.options].forEach(g=>g.selected=d.includes(g.value)):f.refs?he(f.ref)?f.refs.forEach(g=>{(!g.defaultChecked||!g.disabled)&&(Array.isArray(d)?g.checked=!!d.find(A=>A===g.value):g.checked=d===g.value||!!d)}):f.refs.forEach(g=>g.checked=g.value===d):Re(f.ref)?f.ref.value="":(f.ref.value=d,f.ref.type||v.state.next({name:s,values:O(a)})))}(l.shouldDirty||l.shouldTouch)&&le(s,d,l.shouldTouch,l.shouldDirty,!0),l.shouldValidate&&ce(s)},H=(s,i,l)=>{for(const y in i){if(!i.hasOwnProperty(y))return;const d=i[y],f=s+"."+y,g=h(n,f);(c.array.has(s)||T(d)||g&&!g._f)&&!se(d)?H(f,d,l):U(f,d,l)}},q=(s,i,l={})=>{const y=h(n,s),d=c.array.has(s),f=O(i);k(a,s,f),d?(v.array.next({name:s,values:O(a)}),(b.isDirty||b.dirtyFields||V.isDirty||V.dirtyFields)&&l.shouldDirty&&v.state.next({name:s,dirtyFields:ae(o,a),isDirty:F(s,f)})):y&&!y._f&&!N(f)?H(s,f,l):U(s,f,l),Xe(s,c)?v.state.next({...t,name:s,values:O(a)}):v.state.next({name:u.mount?s:void 0,values:O(a)})},oe=async s=>{u.mount=!0;const i=s.target;let l=i.name,y=!0;const d=h(n,l),f=x=>{y=Number.isNaN(x)||se(x)&&isNaN(x.getTime())||ee(x,h(a,l,x))},g=Je(r.mode),A=Je(r.reValidateMode);if(d){let x,M;const re=i.type?Ye(d._f):mt(s),G=s.type===je.BLUR||s.type===je.FOCUS_OUT,Vt=!Mt(d._f)&&!r.resolver&&!h(t.errors,l)&&!d._f.deps||Nt(G,h(t.touchedFields,l),t.isSubmitted,A,g),Ae=Xe(l,c,G);k(a,l,re),G?(!i||!i.readOnly)&&(d._f.onBlur&&d._f.onBlur(s),D&&D(0)):d._f.onChange&&d._f.onChange(s);const xe=le(l,re,G),Ft=!B(xe)||Ae;if(!G&&v.state.next({name:l,type:s.type,values:O(a)}),Vt)return(b.isValid||V.isValid)&&(r.mode==="onBlur"?G&&Y():G||Y()),Ft&&v.state.next({name:l,...Ae?{}:xe});if(!G&&Ae&&v.state.next({...t}),r.resolver){const{errors:$e}=await te([l]);if(p([l]),f(re),y){const _t=Ge(t.errors,n,l),pe=Ge($e,n,_t.name||l);x=pe.error,l=pe.name,M=B($e)}}else p([l],!0),x=(await tt(d,c.disabled,a,P,r.shouldUseNativeValidation))[l],p([l]),f(re),y&&(x?M=!1:(b.isValid||V.isValid)&&(M=await j(n,!0)));y&&(d._f.deps&&(!Array.isArray(d._f.deps)||d._f.deps.length>0)&&ce(d._f.deps),ge(l,M,x,xe))}},ue=(s,i)=>{if(h(t.errors,i)&&s.focus)return s.focus(),1},ce=async(s,i={})=>{let l,y;const d=de(s);if(r.resolver){const f=await ie(E(s)?s:d);l=B(f),y=s?!d.some(g=>h(f,g)):l}else s?(y=(await Promise.all(d.map(async f=>{const g=h(n,f);return await j(g&&g._f?{[f]:g}:g)}))).every(Boolean),!(!y&&!t.isValid)&&Y()):y=l=await j(n);return v.state.next({...!$(s)||(b.isValid||V.isValid)&&l!==t.isValid?{}:{name:s},...r.resolver||!s?{isValid:l}:{},errors:t.errors}),i.shouldFocus&&!y&&ye(n,ue,s?d:c.mount),y},Oe=(s,i)=>{let l={...u.mount?a:o};return i&&(l=st(i.dirtyFields?t.dirtyFields:t.touchedFields,l)),E(s)?l:$(s)?h(l,s):s.map(y=>h(l,y))},Pe=(s,i)=>({invalid:!!h((i||t).errors,s),isDirty:!!h((i||t).dirtyFields,s),error:h((i||t).errors,s),isValidating:!!h(t.validatingFields,s),isTouched:!!h((i||t).touchedFields,s)}),ft=s=>{s&&de(s).forEach(i=>C(t.errors,i)),v.state.next({errors:s?t.errors:{}})},Ue=(s,i,l)=>{const y=(h(n,s,{_f:{}})._f||{}).ref,d=h(t.errors,s)||{},{ref:f,message:g,type:A,...x}=d;k(t.errors,s,{...x,...i,ref:y}),v.state.next({name:s,errors:t.errors,isValid:!1}),l&&l.shouldFocus&&y&&y.focus&&y.focus()},dt=(s,i)=>Z(s)?v.state.subscribe({next:l=>"values"in l&&s(m(void 0,i),l)}):m(s,i,!0),Me=s=>v.state.subscribe({next:i=>{It(s.name,i.name,s.exact)&&Bt(i,s.formState||b,bt,s.reRenderRoot)&&s.callback({values:{...a},...t,...i,defaultValues:o})}}).unsubscribe,yt=s=>(u.mount=!0,V={...V,...s.formState},Me({...s,formState:{...S,...s.formState}})),_e=(s,i={})=>{for(const l of s?de(s):c.mount)c.mount.delete(l),c.array.delete(l),i.keepValue||(C(n,l),C(a,l)),!i.keepError&&C(t.errors,l),!i.keepDirty&&C(t.dirtyFields,l),!i.keepTouched&&C(t.touchedFields,l),!i.keepIsValidating&&C(t.validatingFields,l),!r.shouldUnregister&&!i.keepDefaultValue&&C(o,l);v.state.next({values:O(a)}),v.state.next({...t,...i.keepDirty?{isDirty:F()}:{}}),!i.keepIsValid&&Y()},Be=({disabled:s,name:i})=>{(K(s)&&u.mount||s||c.disabled.has(i))&&(s?c.disabled.add(i):c.disabled.delete(i))},me=(s,i={})=>{let l=h(n,s);const y=K(i.disabled)||K(r.disabled);return k(n,s,{...l||{},_f:{...l&&l._f?l._f:{ref:{name:s}},name:s,mount:!0,...i}}),c.mount.add(s),l?Be({disabled:K(i.disabled)?i.disabled:r.disabled,name:s}):R(s,!0,i.value),{...y?{disabled:i.disabled||r.disabled}:{},...r.progressive?{required:!!i.required,min:fe(i.min),max:fe(i.max),minLength:fe(i.minLength),maxLength:fe(i.maxLength),pattern:fe(i.pattern)}:{},name:s,onChange:oe,onBlur:oe,ref:d=>{if(d){me(s,i),l=h(n,s);const f=E(d.value)&&d.querySelectorAll&&d.querySelectorAll("input,select,textarea")[0]||d,g=Tt(f),A=l._f.refs||[];if(g?A.find(x=>x===f):f===l._f.ref)return;k(n,s,{_f:{...l._f,...g?{refs:[...A.filter(De),f,...Array.isArray(h(o,s))?[{}]:[]],ref:{type:f.type,name:s}}:{ref:f}}}),R(s,!1,void 0,f)}else l=h(n,s,{}),l._f&&(l._f.mount=!1),(r.shouldUnregister||i.shouldUnregister)&&!(At(c.array,s)&&u.action)&&c.unMount.add(s)}}},we=()=>r.shouldFocusError&&ye(n,ue,c.mount),ht=s=>{K(s)&&(v.state.next({disabled:s}),ye(n,(i,l)=>{const y=h(n,l);y&&(i.disabled=y._f.disabled||s,Array.isArray(y._f.refs)&&y._f.refs.forEach(d=>{d.disabled=y._f.disabled||s}))},0,!1))},Ie=(s,i)=>async l=>{let y;l&&(l.preventDefault&&l.preventDefault(),l.persist&&l.persist());let d=O(a);if(v.state.next({isSubmitting:!0}),r.resolver){const{errors:f,values:g}=await te();p(),t.errors=f,d=O(g)}else await j(n);if(c.disabled.size)for(const f of c.disabled)C(d,f);if(C(t.errors,"root"),B(t.errors)){v.state.next({errors:{}});try{await s(d,l)}catch(f){y=f}}else i&&await i({...t.errors},l),we(),setTimeout(we);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(t.errors)&&!y,submitCount:t.submitCount+1,errors:t.errors}),y)throw y},gt=(s,i={})=>{h(n,s)&&(E(i.defaultValue)?q(s,O(h(o,s))):(q(s,i.defaultValue),k(o,s,O(i.defaultValue))),i.keepTouched||C(t.touchedFields,s),i.keepDirty||(C(t.dirtyFields,s),t.isDirty=i.defaultValue?F(s,O(h(o,s))):F()),i.keepError||(C(t.errors,s),b.isValid&&Y()),v.state.next({...t}))},Ne=(s,i={})=>{const l=s?O(s):o,y=O(l),d=B(s),f=d?o:y;if(i.keepDefaultValues||(o=l),!i.keepValues){if(i.keepDirtyValues){const g=new Set([...c.mount,...Object.keys(ae(o,a))]);for(const A of Array.from(g)){const x=h(t.dirtyFields,A),M=h(a,A),re=h(f,A);x&&!E(M)?k(f,A,M):!x&&!E(re)&&q(A,re)}}else{if(Se&&E(s))for(const g of c.mount){const A=h(n,g);if(A&&A._f){const x=Array.isArray(A._f.refs)?A._f.refs[0]:A._f.ref;if(be(x)){const M=x.closest("form");if(M){M.reset();break}}}}if(i.keepFieldsRef)for(const g of c.mount)q(g,h(f,g));else n={}}a=r.shouldUnregister?i.keepDefaultValues?O(o):{}:O(f),v.array.next({values:{...f}}),v.state.next({values:{...f}})}c={mount:i.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},u.mount=!b.isValid||!!i.keepIsValid||!!i.keepDirtyValues||!r.shouldUnregister&&!B(f),u.watch=!!r.shouldUnregister,u.keepIsValid=!!i.keepIsValid,u.action=!1,i.keepErrors||(t.errors={}),v.state.next({submitCount:i.keepSubmitCount?t.submitCount:0,isDirty:d?!1:i.keepDirty?t.isDirty:!!(i.keepDefaultValues&&!ee(s,o)),isSubmitted:i.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:d?{}:i.keepDirtyValues?i.keepDefaultValues&&a?ae(o,a):t.dirtyFields:i.keepDefaultValues&&s?ae(o,s):i.keepDirty?t.dirtyFields:{},touchedFields:i.keepTouched?t.touchedFields:{},errors:i.keepErrors?t.errors:{},isSubmitSuccessful:i.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},qe=(s,i)=>Ne(Z(s)?s(a):s,{...r.resetOptions,...i}),vt=(s,i={})=>{const l=h(n,s),y=l&&l._f;if(y){const d=y.refs?y.refs[0]:y.ref;d.focus&&setTimeout(()=>{d.focus(),i.shouldSelect&&Z(d.select)&&d.select()})}},bt=s=>{t={...t,...s}},We={control:{register:me,unregister:_e,getFieldState:Pe,handleSubmit:Ie,setError:Ue,_subscribe:Me,_runSchema:te,_updateIsValidating:p,_focusError:we,_getWatch:m,_getDirty:F,_setValid:Y,_setFieldArray:_,_setDisabledField:Be,_setErrors:Q,_getFieldArray:L,_reset:Ne,_resetDefaultValues:()=>Z(r.defaultValues)&&r.defaultValues().then(s=>{qe(s,r.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:ve,_disableForm:ht,_subjects:v,_proxyFormState:b,get _fields(){return n},get _formValues(){return a},get _state(){return u},set _state(s){u=s},get _defaultValues(){return o},get _names(){return c},set _names(s){c=s},get _formState(){return t},get _options(){return r},set _options(s){r={...r,...s}}},subscribe:yt,trigger:ce,register:me,handleSubmit:Ie,watch:dt,setValue:q,getValues:Oe,reset:qe,resetField:gt,clearErrors:ft,unregister:_e,setError:Ue,setFocus:vt,getFieldState:Pe};return{...We,formControl:We}}function jt(e={}){const r=W.useRef(void 0),t=W.useRef(void 0),[n,o]=W.useState({isDirty:!1,isValidating:!1,isLoading:Z(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Z(e.defaultValues)?void 0:e.defaultValues});if(!r.current)if(e.formControl)r.current={...e.formControl,formState:n},e.defaultValues&&!Z(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...c}=pt(e);r.current={...c,formState:n}}const a=r.current.control;return a._options=e,Et(()=>{const u=a._subscribe({formState:a._proxyFormState,callback:()=>o({...a._formState}),reRenderRoot:!0});return o(c=>({...c,isReady:!0})),a._formState.isReady=!0,u},[a]),W.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),W.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),W.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),W.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),W.useEffect(()=>{if(a._proxyFormState.isDirty){const u=a._getDirty();u!==n.isDirty&&a._subjects.state.next({isDirty:u})}},[a,n.isDirty]),W.useEffect(()=>{var u;e.values&&!ee(e.values,t.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),!((u=a._options.resetOptions)===null||u===void 0)&&u.keepIsValid||a._setValid(),t.current=e.values,o(c=>({...c}))):a._resetDefaultValues()},[a,e.values]),W.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),r.current.formState=kt(n,a),r.current}function ut(e,r){const t=[];if(e.required&&(r==null||r===""||Array.isArray(r)&&r.length===0))return t.push(`${e.label} is required`),{valid:!1,errors:t};if(r==null||r==="")return{valid:!0,errors:[]};if("length"in e&&typeof e.length=="number"&&typeof r=="string"&&r.length>e.length&&t.push(`${e.label} must be at most ${e.length} characters`),"integerPart"in e&&typeof r=="number"){const n=Math.floor(Math.abs(r)),o=e.integerPart??9;n.toString().length>o&&t.push(`${e.label} integer part must be at most ${o} digits`);const a=e.fractionPart;a!==void 0&&(r.toString().split(".")[1]??"").length>a&&t.push(`${e.label} can have at most ${a} decimal places`)}return t.length>0?{valid:!1,errors:t}:{valid:!0,errors:[]}}function Ht(e,r){return async(t,n,o)=>{var D;const a={},u=e.getFields(),c=(o==null?void 0:o.names)??Object.keys(u);for(const w of c){if(w==="_id"||(D=u[w])!=null&&D.readOnly)continue;const S=u[w];if(!S)continue;let b=t[w];if("integerPart"in S&&typeof b=="string"&&b!==""){const v=Number(b);isNaN(v)||(b=v,t[w]=v)}if(!S.required&&(b==null||b===""||Array.isArray(b)&&b.length===0))continue;const V=S.validate(b);if(!V.valid&&V.errors.length>0){a[w]={type:"validate",message:V.errors[0]||`${w} is invalid`};continue}if((r==null?void 0:r.enableConstraintValidation)!==!1){const v=ut(S,b);if(!v.valid&&v.errors.length>0){a[w]={type:"constraint",message:v.errors[0]};continue}}if(e.hasMetadata()){const v=e.validateFieldExpression(w,b,t);!v.valid&&v.errors.length>0&&(a[w]={type:"validate",message:v.errors[0]})}}return Object.keys(a).length===0?{values:t,errors:{}}:{values:{},errors:a}}}function ct(e,r){const t=e.meta.Type;if(typeof r=="string"&&t==="Number")return r===""?void 0:Number(r);if(!(typeof r=="string"&&r===""&&(t==="Date"||t==="DateTime"))){if(typeof r=="string"&&r!==""&&t==="DateTime"){let n=r;return n.endsWith("Z")&&(n=n.slice(0,-1)),((n.split("T")[1]||"").match(/:/g)||[]).length===1&&(n+=":00"),n+"Z"}return r}}function Zt(e,r){var n;const t={...r};for(const[o,a]of Object.entries(t))typeof a=="string"&&((n=e[o])==null?void 0:n.meta.Type)==="DateTime"&&a.endsWith("Z")&&(t[o]=a.slice(0,-1));return t}function zt(e){const{apiFn:r,allFields:t,readonlyFieldNames:n,rhf:o,isComputingRef:a}=e;return async u=>{if(!a.current){a.current=!0;try{if(!await o.trigger(u))return;const D=o.getValues(u),w=t[u],S=w?ct(w,D):D,b=await r(u,S);if(b===void 0)return;if(o.resetField(u,{defaultValue:D,keepTouched:!0,keepError:!0}),b&&typeof b=="object"){const V=b.Data??b;if(V&&typeof V=="object"){const v=new Set(n);for(const P of Object.keys(V))v.has(P)&&V[P]!==void 0&&o.getValues(P)!==V[P]&&o.setValue(P,V[P],{shouldDirty:!1,shouldValidate:!1})}}}catch(c){console.warn("syncField failed:",c)}finally{a.current=!1}}}}function Kt(e){const{rhf:r,allFields:t,syncField:n,syncOnBlur:o,syncOnChange:a}=e;return(u,c)=>{const D=t[u],w=D?D.readOnly:!1,S=r.register(u,{...c,...o?{onBlur:async b=>{var V;await((V=c==null?void 0:c.onBlur)==null?void 0:V.call(c,b)),await n(u)}}:{},...a?{onChange:async b=>{var V;await((V=c==null?void 0:c.onChange)==null?void 0:V.call(c,b)),await n(u)}}:{},...w?{disabled:!0}:{}});return w?{...S,disabled:!0}:S}}function Yt(e){const{control:r,syncField:t,syncOnBlur:n,syncOnChange:o}=e;return new Proxy(r,{get(a,u,c){return u==="register"?(D,w)=>{const S=a.register(D,w),b=S.onChange,V=S.onBlur;return{...S,...o?{onChange:async v=>{await b(v),await t(D)}}:{},...n?{onBlur:async v=>{await V(v),await t(D)}}:{}}}:Reflect.get(a,u,c)}})}exports.coerceFieldValue=ct;exports.coerceRecordForForm=Zt;exports.createEnhancedControl=Yt;exports.createEnhancedRegister=Kt;exports.createResolver=Ht;exports.createSyncField=zt;exports.useForm=jt;exports.validateConstraints=ut;
|
package/dist/table.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./useTable-CeRklbdT.cjs"),o=require("./client-D5k4SYuw.cjs"),e=require("./constants-QX2RX-wu.cjs");function u(a){const{bdo:t,...n}=a;return i.useTable({queryKey:["table",t.meta._id],listFn:r=>o.api(t.meta._id).list(r),countFn:r=>o.api(t.meta._id).count(r),...n})}exports.useTable=i.useTable;exports.ConditionOperator=e.ConditionOperator;exports.GroupOperator=e.GroupOperator;exports.RHSType=e.RHSType;exports.SortDirection=e.SortDirection;exports.TableDefaults=e.Defaults;exports.useBDOTable=u;
|
package/dist/table.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { useTable } from './components/hooks/useTable/useTable';
|
|
2
|
+
export { useBDOTable } from './components/hooks/useBDOTable/useBDOTable';
|
|
2
3
|
export { SortDirection, ConditionOperator, GroupOperator, RHSType, Defaults as TableDefaults, } from './types/constants';
|
|
3
4
|
//# sourceMappingURL=table.d.ts.map
|
package/dist/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../sdk/table.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGhE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,QAAQ,IAAI,aAAa,GAC1B,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../sdk/table.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAGzE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,QAAQ,IAAI,aAAa,GAC1B,MAAM,mBAAmB,CAAC"}
|
package/dist/table.mjs
CHANGED
|
@@ -1,196 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
debouncedQuery: "",
|
|
12
|
-
field: null
|
|
13
|
-
}), c = ne(null), U = 300, _ = () => {
|
|
14
|
-
var t, o;
|
|
15
|
-
const e = (t = r.initialState) == null ? void 0 : t.sort;
|
|
16
|
-
if (e && e.length > 0) {
|
|
17
|
-
const M = e[0], G = Object.keys(M)[0], b = (o = M[G]) == null ? void 0 : o.toUpperCase();
|
|
18
|
-
return { field: G, direction: b === "ASC" || b === "DESC" ? b : "ASC" };
|
|
19
|
-
}
|
|
20
|
-
return { field: null, direction: null };
|
|
21
|
-
}, [s, C] = E(_), [n, u] = E({
|
|
22
|
-
pageNo: ((P = (R = r.initialState) == null ? void 0 : R.pagination) == null ? void 0 : P.pageNo) || 1,
|
|
23
|
-
pageSize: ((w = (q = r.initialState) == null ? void 0 : q.pagination) == null ? void 0 : w.pageSize) || 10
|
|
24
|
-
}), d = ae({
|
|
25
|
-
conditions: (x = (Q = r.initialState) == null ? void 0 : Q.filter) == null ? void 0 : x.conditions,
|
|
26
|
-
operator: ((L = (H = r.initialState) == null ? void 0 : H.filter) == null ? void 0 : L.operator) || "And"
|
|
1
|
+
import { u as s } from "./useTable-DS0-WInw.js";
|
|
2
|
+
import { a } from "./client-_ayziI1d.js";
|
|
3
|
+
import { C as l, G as b, R as c, S as d, D as f } from "./constants-ConHc1oS.js";
|
|
4
|
+
function u(o) {
|
|
5
|
+
const { bdo: t, ...r } = o;
|
|
6
|
+
return s({
|
|
7
|
+
queryKey: ["table", t.meta._id],
|
|
8
|
+
listFn: (e) => a(t.meta._id).list(e),
|
|
9
|
+
countFn: (e) => a(t.meta._id).count(e),
|
|
10
|
+
...r
|
|
27
11
|
});
|
|
28
|
-
k(() => {
|
|
29
|
-
u((e) => ({ ...e, pageNo: 1 }));
|
|
30
|
-
}, [d.payload]);
|
|
31
|
-
const g = l(() => {
|
|
32
|
-
const e = {};
|
|
33
|
-
let t = d.payload;
|
|
34
|
-
if (a.debouncedQuery && a.field) {
|
|
35
|
-
const o = {
|
|
36
|
-
LHSField: a.field,
|
|
37
|
-
Operator: "Contains",
|
|
38
|
-
RHSValue: a.debouncedQuery,
|
|
39
|
-
RHSType: "Constant"
|
|
40
|
-
};
|
|
41
|
-
t ? t.Operator === "And" ? t = {
|
|
42
|
-
...t,
|
|
43
|
-
Condition: [...t.Condition || [], o]
|
|
44
|
-
} : t = {
|
|
45
|
-
Operator: "And",
|
|
46
|
-
Condition: [t, o]
|
|
47
|
-
} : t = {
|
|
48
|
-
Operator: "And",
|
|
49
|
-
Condition: [o]
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return t && (e.Filter = t), e;
|
|
53
|
-
}, [a.debouncedQuery, a.field, d.payload]), A = l(() => {
|
|
54
|
-
const e = { ...g };
|
|
55
|
-
return s.field && s.direction && (e.Sort = [
|
|
56
|
-
{
|
|
57
|
-
[String(s.field)]: s.direction
|
|
58
|
-
}
|
|
59
|
-
]), e.Page = n.pageNo, e.PageSize = n.pageSize, e;
|
|
60
|
-
}, [g, s, n]), {
|
|
61
|
-
data: f,
|
|
62
|
-
isLoading: j,
|
|
63
|
-
isFetching: B,
|
|
64
|
-
error: F,
|
|
65
|
-
refetch: z
|
|
66
|
-
} = I({
|
|
67
|
-
queryKey: ["table", r.source, A],
|
|
68
|
-
queryFn: async () => {
|
|
69
|
-
try {
|
|
70
|
-
const e = await K(r.source).list(A);
|
|
71
|
-
return r.onSuccess && r.onSuccess(e.Data), e;
|
|
72
|
-
} catch (e) {
|
|
73
|
-
throw r.onError && r.onError(h(e)), e;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
staleTime: 0,
|
|
77
|
-
gcTime: 30 * 1e3
|
|
78
|
-
}), {
|
|
79
|
-
data: S,
|
|
80
|
-
isLoading: V,
|
|
81
|
-
isFetching: J,
|
|
82
|
-
error: D,
|
|
83
|
-
refetch: O
|
|
84
|
-
} = I({
|
|
85
|
-
queryKey: ["table-count", r.source, g],
|
|
86
|
-
queryFn: async () => {
|
|
87
|
-
try {
|
|
88
|
-
return await K(r.source).count(g);
|
|
89
|
-
} catch (e) {
|
|
90
|
-
throw r.onError && r.onError(h(e)), e;
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
staleTime: 0,
|
|
94
|
-
gcTime: 30 * 1e3
|
|
95
|
-
}), W = l(() => (f == null ? void 0 : f.Data) || [], [f]), p = l(() => (S == null ? void 0 : S.Count) || 0, [S]), y = l(() => Math.ceil(p / n.pageSize), [p, n.pageSize]), X = i((e) => {
|
|
96
|
-
C((t) => {
|
|
97
|
-
if (t.field === e) {
|
|
98
|
-
if (t.direction === "ASC")
|
|
99
|
-
return { field: e, direction: "DESC" };
|
|
100
|
-
if (t.direction === "DESC")
|
|
101
|
-
return { field: null, direction: null };
|
|
102
|
-
}
|
|
103
|
-
return { field: e, direction: "ASC" };
|
|
104
|
-
});
|
|
105
|
-
}, []), Y = i(() => {
|
|
106
|
-
C({ field: null, direction: null });
|
|
107
|
-
}, []), Z = i(
|
|
108
|
-
(e, t) => {
|
|
109
|
-
C({ field: e, direction: t });
|
|
110
|
-
},
|
|
111
|
-
[]
|
|
112
|
-
), $ = i((e, t) => {
|
|
113
|
-
if (t.length > 255) {
|
|
114
|
-
console.warn("Search query exceeds maximum length of 255 characters");
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
m((o) => ({ ...o, query: t, field: e })), c.current && clearTimeout(c.current), c.current = setTimeout(() => {
|
|
118
|
-
m((o) => ({ ...o, debouncedQuery: t })), u((o) => ({ ...o, pageNo: 1 }));
|
|
119
|
-
}, U);
|
|
120
|
-
}, []), v = i(() => {
|
|
121
|
-
c.current && clearTimeout(c.current), m({ query: "", debouncedQuery: "", field: null }), u((e) => ({ ...e, pageNo: 1 }));
|
|
122
|
-
}, []);
|
|
123
|
-
k(() => () => {
|
|
124
|
-
c.current && clearTimeout(c.current);
|
|
125
|
-
}, []);
|
|
126
|
-
const N = n.pageNo < y, T = n.pageNo > 1, ee = i(() => {
|
|
127
|
-
N && u((e) => ({ ...e, pageNo: e.pageNo + 1 }));
|
|
128
|
-
}, [N]), te = i(() => {
|
|
129
|
-
T && u((e) => ({ ...e, pageNo: e.pageNo - 1 }));
|
|
130
|
-
}, [T]), re = i(
|
|
131
|
-
(e) => {
|
|
132
|
-
const t = Math.max(1, Math.min(e, y));
|
|
133
|
-
u((o) => ({ ...o, pageNo: t }));
|
|
134
|
-
},
|
|
135
|
-
[y]
|
|
136
|
-
), oe = i((e) => {
|
|
137
|
-
u((t) => ({
|
|
138
|
-
...t,
|
|
139
|
-
pageSize: e,
|
|
140
|
-
pageNo: 1
|
|
141
|
-
}));
|
|
142
|
-
}, []), ie = i(async () => {
|
|
143
|
-
const [e] = await Promise.all([z(), O()]);
|
|
144
|
-
return e.data || { Data: [] };
|
|
145
|
-
}, [z, O]);
|
|
146
|
-
return {
|
|
147
|
-
// Data
|
|
148
|
-
rows: W,
|
|
149
|
-
totalItems: p,
|
|
150
|
-
// Loading States
|
|
151
|
-
isLoading: j || V,
|
|
152
|
-
isFetching: B || J,
|
|
153
|
-
// Error Handling
|
|
154
|
-
error: F ? h(F) : D ? h(D) : null,
|
|
155
|
-
// Search (Flat Access)
|
|
156
|
-
search: {
|
|
157
|
-
query: a.query,
|
|
158
|
-
field: a.field,
|
|
159
|
-
set: $,
|
|
160
|
-
clear: v
|
|
161
|
-
},
|
|
162
|
-
// Sorting (Flat Access)
|
|
163
|
-
sort: {
|
|
164
|
-
field: s.field,
|
|
165
|
-
direction: s.direction,
|
|
166
|
-
toggle: X,
|
|
167
|
-
clear: Y,
|
|
168
|
-
set: Z
|
|
169
|
-
},
|
|
170
|
-
// Filter (Simplified chainable API)
|
|
171
|
-
filter: d,
|
|
172
|
-
// Pagination (Flat Access)
|
|
173
|
-
pagination: {
|
|
174
|
-
pageNo: n.pageNo,
|
|
175
|
-
pageSize: n.pageSize,
|
|
176
|
-
totalPages: y,
|
|
177
|
-
totalItems: p,
|
|
178
|
-
canGoNext: N,
|
|
179
|
-
canGoPrevious: T,
|
|
180
|
-
goToNext: ee,
|
|
181
|
-
goToPrevious: te,
|
|
182
|
-
goToPage: re,
|
|
183
|
-
setPageSize: oe
|
|
184
|
-
},
|
|
185
|
-
// Operations
|
|
186
|
-
refetch: ie
|
|
187
|
-
};
|
|
188
12
|
}
|
|
189
13
|
export {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
14
|
+
l as ConditionOperator,
|
|
15
|
+
b as GroupOperator,
|
|
16
|
+
c as RHSType,
|
|
17
|
+
d as SortDirection,
|
|
18
|
+
f as TableDefaults,
|
|
19
|
+
u as useBDOTable,
|
|
20
|
+
s as useTable
|
|
196
21
|
};
|
package/dist/table.types.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export type { UseTableOptionsType, UseTableReturnType,
|
|
1
|
+
export type { UseTableOptionsType, UseTableReturnType, PaginationStateType, } from './components/hooks/useTable/types';
|
|
2
|
+
export type { UseBDOTableOptionsType, UseBDOTableReturnType, } from './components/hooks/useBDOTable/types';
|
|
2
3
|
//# sourceMappingURL=table.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.types.d.ts","sourceRoot":"","sources":["../sdk/table.types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,mBAAmB,EACnB,kBAAkB,EAGlB,
|
|
1
|
+
{"version":3,"file":"table.types.d.ts","sourceRoot":"","sources":["../sdk/table.types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,mBAAmB,EACnB,kBAAkB,EAGlB,mBAAmB,GACpB,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EAEV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC"}
|
|
@@ -75,14 +75,14 @@ type Minute = number;
|
|
|
75
75
|
type Second = number;
|
|
76
76
|
/**
|
|
77
77
|
* DateTime field (date and time)
|
|
78
|
-
* API Request Format: "YYYY-MM-
|
|
78
|
+
* API Request Format: "YYYY-MM-DDTHH:MM:SSZ"
|
|
79
|
+
* API Response Format: "YYYY-MM-DDTHH:MM:SSZ" (always UTC)
|
|
79
80
|
* Use this for created_at, updated_at, event timestamps
|
|
80
81
|
*
|
|
81
82
|
* @example
|
|
82
|
-
*
|
|
83
|
-
* "2026-01-23T01:21:33"
|
|
83
|
+
* "2026-01-23T01:21:33Z"
|
|
84
84
|
*/
|
|
85
|
-
export type DateTimeFieldType = `${Year}-${Month}-${Day}T${Hour}:${Minute}:${Second}`;
|
|
85
|
+
export type DateTimeFieldType = `${Year}-${Month}-${Day}T${Hour}:${Minute}:${Second}Z`;
|
|
86
86
|
/**
|
|
87
87
|
* Reference/Lookup field for relationships to other Business Data Objects
|
|
88
88
|
*
|
|
@@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AM,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC"}
|
|
@@ -156,7 +156,7 @@ export declare const QueryType: {
|
|
|
156
156
|
* @example
|
|
157
157
|
* import { FormOperation } from "@ram_28/kf-ai-sdk/form";
|
|
158
158
|
*
|
|
159
|
-
* const { handleSubmit } =
|
|
159
|
+
* const { handleSubmit } = useBDOForm({
|
|
160
160
|
* source: "products",
|
|
161
161
|
* operation: FormOperation.Create,
|
|
162
162
|
* });
|
|
@@ -174,7 +174,7 @@ export declare const FormOperation: {
|
|
|
174
174
|
* @example
|
|
175
175
|
* import { InteractionMode } from "@ram_28/kf-ai-sdk/form";
|
|
176
176
|
*
|
|
177
|
-
* const { handleSubmit } =
|
|
177
|
+
* const { handleSubmit } = useBDOForm({
|
|
178
178
|
* source: "products",
|
|
179
179
|
* operation: "create",
|
|
180
180
|
* interactionMode: InteractionMode.Interactive,
|
|
@@ -192,7 +192,7 @@ export declare const InteractionMode: {
|
|
|
192
192
|
* @example
|
|
193
193
|
* import { ValidationMode } from "@ram_28/kf-ai-sdk/form";
|
|
194
194
|
*
|
|
195
|
-
* const { handleSubmit } =
|
|
195
|
+
* const { handleSubmit } = useBDOForm({
|
|
196
196
|
* source: "products",
|
|
197
197
|
* operation: "create",
|
|
198
198
|
* mode: ValidationMode.OnBlur,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("react"),L=require("@tanstack/react-query"),te=require("./useFilter-Bg0jvIL6.cjs");function l(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t!==null&&typeof t=="object"&&"message"in t&&typeof t.message=="string"){const i=new Error(t.message);return Object.assign(i,t),i}return new Error(String(t))}function re(t){var w,A,z,Q,M,O,P,R;const[i,C]=n.useState({query:"",debouncedQuery:"",field:null}),c=n.useRef(null),H=300,K=()=>{var r,o;const e=(r=t.initialState)==null?void 0:r.sort;if(e&&e.length>0){const D=e[0],x=Object.keys(D)[0],E=(o=D[x])==null?void 0:o.toUpperCase();return{field:x,direction:E==="ASC"||E==="DESC"?E:"ASC"}}return{field:null,direction:null}},[s,h]=n.useState(K),[a,u]=n.useState({pageNo:((A=(w=t.initialState)==null?void 0:w.pagination)==null?void 0:A.pageNo)||1,pageSize:((Q=(z=t.initialState)==null?void 0:z.pagination)==null?void 0:Q.pageSize)||10}),g=te.useFilter({conditions:(O=(M=t.initialState)==null?void 0:M.filter)==null?void 0:O.conditions,operator:((R=(P=t.initialState)==null?void 0:P.filter)==null?void 0:R.operator)||"And"});n.useEffect(()=>{u(e=>({...e,pageNo:1}))},[g.payload]);const d=n.useMemo(()=>{const e={};let r=g.payload;if(i.debouncedQuery&&i.field){const o={LHSField:i.field,Operator:"Contains",RHSValue:i.debouncedQuery,RHSType:"Constant"};r?r.Operator==="And"?r={...r,Condition:[...r.Condition||[],o]}:r={Operator:"And",Condition:[r,o]}:r={Operator:"And",Condition:[o]}}return r&&(e.Filter=r),e},[i.debouncedQuery,i.field,g.payload]),N=n.useMemo(()=>{const e={...d};return s.field&&s.direction&&(e.Sort=[{[String(s.field)]:s.direction}]),e.Page=a.pageNo,e.PageSize=a.pageSize,e},[d,s,a]),{data:f,isLoading:j,isFetching:G,error:F,refetch:T}=L.useQuery({queryKey:[...t.queryKey,N],queryFn:async()=>{try{const e=await t.listFn(N);return t.onSuccess&&t.onSuccess(e.Data),e}catch(e){throw t.onError&&t.onError(l(e)),e}},staleTime:0,gcTime:30*1e3}),{data:S,isLoading:I,isFetching:U,error:q,refetch:k}=L.useQuery({queryKey:[...t.queryKey,"count",d],queryFn:async()=>{try{return await t.countFn(d)}catch(e){throw t.onError&&t.onError(l(e)),e}},staleTime:0,gcTime:30*1e3}),_=n.useMemo(()=>(f==null?void 0:f.Data)||[],[f]),y=n.useMemo(()=>(S==null?void 0:S.Count)||0,[S]),p=n.useMemo(()=>Math.ceil(y/a.pageSize),[y,a.pageSize]),B=n.useCallback(e=>{h(r=>{if(r.field===e){if(r.direction==="ASC")return{field:e,direction:"DESC"};if(r.direction==="DESC")return{field:null,direction:null}}return{field:e,direction:"ASC"}})},[]),V=n.useCallback(()=>{h({field:null,direction:null})},[]),J=n.useCallback((e,r)=>{h({field:e,direction:r})},[]),W=n.useCallback((e,r)=>{if(r.length>255){console.warn("Search query exceeds maximum length of 255 characters");return}C(o=>({...o,query:r,field:e})),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{C(o=>({...o,debouncedQuery:r})),u(o=>({...o,pageNo:1}))},H)},[]),X=n.useCallback(()=>{c.current&&clearTimeout(c.current),C({query:"",debouncedQuery:"",field:null}),u(e=>({...e,pageNo:1}))},[]);n.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const m=a.pageNo<p,b=a.pageNo>1,Y=n.useCallback(()=>{m&&u(e=>({...e,pageNo:e.pageNo+1}))},[m]),Z=n.useCallback(()=>{b&&u(e=>({...e,pageNo:e.pageNo-1}))},[b]),$=n.useCallback(e=>{const r=Math.max(1,Math.min(e,p));u(o=>({...o,pageNo:r}))},[p]),v=n.useCallback(e=>{u(r=>({...r,pageSize:e,pageNo:1}))},[]),ee=n.useCallback(async()=>{const[e]=await Promise.all([T(),k()]);return e.data||{Data:[]}},[T,k]);return{rows:_,totalItems:y,isLoading:j||I,isFetching:G||U,error:F?l(F):q?l(q):null,search:{query:i.query,field:i.field,set:W,clear:X},sort:{field:s.field,direction:s.direction,toggle:B,clear:V,set:J},filter:g,pagination:{pageNo:a.pageNo,pageSize:a.pageSize,totalPages:p,totalItems:y,canGoNext:m,canGoPrevious:b,goToNext:Y,goToPrevious:Z,goToPage:$,setPageSize:v},refetch:ee}}exports.toError=l;exports.useTable=re;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { useState as F, useRef as oe, useEffect as j, useMemo as l, useCallback as i } from "react";
|
|
2
|
+
import { useQuery as k } from "@tanstack/react-query";
|
|
3
|
+
import { u as ie } from "./useFilter-DPNLKY3H.js";
|
|
4
|
+
function h(t) {
|
|
5
|
+
if (t instanceof Error)
|
|
6
|
+
return t;
|
|
7
|
+
if (typeof t == "string")
|
|
8
|
+
return new Error(t);
|
|
9
|
+
if (t !== null && typeof t == "object" && "message" in t && typeof t.message == "string") {
|
|
10
|
+
const o = new Error(t.message);
|
|
11
|
+
return Object.assign(o, t), o;
|
|
12
|
+
}
|
|
13
|
+
return new Error(String(t));
|
|
14
|
+
}
|
|
15
|
+
function le(t) {
|
|
16
|
+
var O, P, Q, R, D, x, L, M;
|
|
17
|
+
const [o, m] = F({
|
|
18
|
+
query: "",
|
|
19
|
+
debouncedQuery: "",
|
|
20
|
+
field: null
|
|
21
|
+
}), c = oe(null), G = 300, I = () => {
|
|
22
|
+
var n, r;
|
|
23
|
+
const e = (n = t.initialState) == null ? void 0 : n.sort;
|
|
24
|
+
if (e && e.length > 0) {
|
|
25
|
+
const H = e[0], K = Object.keys(H)[0], b = (r = H[K]) == null ? void 0 : r.toUpperCase();
|
|
26
|
+
return { field: K, direction: b === "ASC" || b === "DESC" ? b : "ASC" };
|
|
27
|
+
}
|
|
28
|
+
return { field: null, direction: null };
|
|
29
|
+
}, [s, C] = F(I), [a, u] = F({
|
|
30
|
+
pageNo: ((P = (O = t.initialState) == null ? void 0 : O.pagination) == null ? void 0 : P.pageNo) || 1,
|
|
31
|
+
pageSize: ((R = (Q = t.initialState) == null ? void 0 : Q.pagination) == null ? void 0 : R.pageSize) || 10
|
|
32
|
+
}), g = ie({
|
|
33
|
+
conditions: (x = (D = t.initialState) == null ? void 0 : D.filter) == null ? void 0 : x.conditions,
|
|
34
|
+
operator: ((M = (L = t.initialState) == null ? void 0 : L.filter) == null ? void 0 : M.operator) || "And"
|
|
35
|
+
});
|
|
36
|
+
j(() => {
|
|
37
|
+
u((e) => ({ ...e, pageNo: 1 }));
|
|
38
|
+
}, [g.payload]);
|
|
39
|
+
const d = l(() => {
|
|
40
|
+
const e = {};
|
|
41
|
+
let n = g.payload;
|
|
42
|
+
if (o.debouncedQuery && o.field) {
|
|
43
|
+
const r = {
|
|
44
|
+
LHSField: o.field,
|
|
45
|
+
Operator: "Contains",
|
|
46
|
+
RHSValue: o.debouncedQuery,
|
|
47
|
+
RHSType: "Constant"
|
|
48
|
+
};
|
|
49
|
+
n ? n.Operator === "And" ? n = {
|
|
50
|
+
...n,
|
|
51
|
+
Condition: [...n.Condition || [], r]
|
|
52
|
+
} : n = {
|
|
53
|
+
Operator: "And",
|
|
54
|
+
Condition: [n, r]
|
|
55
|
+
} : n = {
|
|
56
|
+
Operator: "And",
|
|
57
|
+
Condition: [r]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return n && (e.Filter = n), e;
|
|
61
|
+
}, [o.debouncedQuery, o.field, g.payload]), T = l(() => {
|
|
62
|
+
const e = { ...d };
|
|
63
|
+
return s.field && s.direction && (e.Sort = [
|
|
64
|
+
{
|
|
65
|
+
[String(s.field)]: s.direction
|
|
66
|
+
}
|
|
67
|
+
]), e.Page = a.pageNo, e.PageSize = a.pageSize, e;
|
|
68
|
+
}, [d, s, a]), {
|
|
69
|
+
data: f,
|
|
70
|
+
isLoading: U,
|
|
71
|
+
isFetching: _,
|
|
72
|
+
error: w,
|
|
73
|
+
refetch: A
|
|
74
|
+
} = k({
|
|
75
|
+
queryKey: [...t.queryKey, T],
|
|
76
|
+
queryFn: async () => {
|
|
77
|
+
try {
|
|
78
|
+
const e = await t.listFn(T);
|
|
79
|
+
return t.onSuccess && t.onSuccess(e.Data), e;
|
|
80
|
+
} catch (e) {
|
|
81
|
+
throw t.onError && t.onError(h(e)), e;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
staleTime: 0,
|
|
85
|
+
gcTime: 30 * 1e3
|
|
86
|
+
}), {
|
|
87
|
+
data: S,
|
|
88
|
+
isLoading: B,
|
|
89
|
+
isFetching: V,
|
|
90
|
+
error: q,
|
|
91
|
+
refetch: z
|
|
92
|
+
} = k({
|
|
93
|
+
queryKey: [...t.queryKey, "count", d],
|
|
94
|
+
queryFn: async () => {
|
|
95
|
+
try {
|
|
96
|
+
return await t.countFn(d);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
throw t.onError && t.onError(h(e)), e;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
staleTime: 0,
|
|
102
|
+
gcTime: 30 * 1e3
|
|
103
|
+
}), J = l(() => (f == null ? void 0 : f.Data) || [], [f]), p = l(() => (S == null ? void 0 : S.Count) || 0, [S]), y = l(() => Math.ceil(p / a.pageSize), [p, a.pageSize]), W = i((e) => {
|
|
104
|
+
C((n) => {
|
|
105
|
+
if (n.field === e) {
|
|
106
|
+
if (n.direction === "ASC")
|
|
107
|
+
return { field: e, direction: "DESC" };
|
|
108
|
+
if (n.direction === "DESC")
|
|
109
|
+
return { field: null, direction: null };
|
|
110
|
+
}
|
|
111
|
+
return { field: e, direction: "ASC" };
|
|
112
|
+
});
|
|
113
|
+
}, []), X = i(() => {
|
|
114
|
+
C({ field: null, direction: null });
|
|
115
|
+
}, []), Y = i(
|
|
116
|
+
(e, n) => {
|
|
117
|
+
C({ field: e, direction: n });
|
|
118
|
+
},
|
|
119
|
+
[]
|
|
120
|
+
), Z = i(
|
|
121
|
+
(e, n) => {
|
|
122
|
+
if (n.length > 255) {
|
|
123
|
+
console.warn("Search query exceeds maximum length of 255 characters");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
m((r) => ({ ...r, query: n, field: e })), c.current && clearTimeout(c.current), c.current = setTimeout(() => {
|
|
127
|
+
m((r) => ({ ...r, debouncedQuery: n })), u((r) => ({ ...r, pageNo: 1 }));
|
|
128
|
+
}, G);
|
|
129
|
+
},
|
|
130
|
+
[]
|
|
131
|
+
), $ = i(() => {
|
|
132
|
+
c.current && clearTimeout(c.current), m({ query: "", debouncedQuery: "", field: null }), u((e) => ({ ...e, pageNo: 1 }));
|
|
133
|
+
}, []);
|
|
134
|
+
j(() => () => {
|
|
135
|
+
c.current && clearTimeout(c.current);
|
|
136
|
+
}, []);
|
|
137
|
+
const N = a.pageNo < y, E = a.pageNo > 1, v = i(() => {
|
|
138
|
+
N && u((e) => ({ ...e, pageNo: e.pageNo + 1 }));
|
|
139
|
+
}, [N]), ee = i(() => {
|
|
140
|
+
E && u((e) => ({ ...e, pageNo: e.pageNo - 1 }));
|
|
141
|
+
}, [E]), te = i(
|
|
142
|
+
(e) => {
|
|
143
|
+
const n = Math.max(1, Math.min(e, y));
|
|
144
|
+
u((r) => ({ ...r, pageNo: n }));
|
|
145
|
+
},
|
|
146
|
+
[y]
|
|
147
|
+
), ne = i((e) => {
|
|
148
|
+
u((n) => ({
|
|
149
|
+
...n,
|
|
150
|
+
pageSize: e,
|
|
151
|
+
pageNo: 1
|
|
152
|
+
}));
|
|
153
|
+
}, []), re = i(async () => {
|
|
154
|
+
const [e] = await Promise.all([A(), z()]);
|
|
155
|
+
return e.data || { Data: [] };
|
|
156
|
+
}, [A, z]);
|
|
157
|
+
return {
|
|
158
|
+
// Data
|
|
159
|
+
rows: J,
|
|
160
|
+
totalItems: p,
|
|
161
|
+
// Loading States
|
|
162
|
+
isLoading: U || B,
|
|
163
|
+
isFetching: _ || V,
|
|
164
|
+
// Error Handling
|
|
165
|
+
error: w ? h(w) : q ? h(q) : null,
|
|
166
|
+
// Search (Flat Access)
|
|
167
|
+
search: {
|
|
168
|
+
query: o.query,
|
|
169
|
+
field: o.field,
|
|
170
|
+
set: Z,
|
|
171
|
+
clear: $
|
|
172
|
+
},
|
|
173
|
+
// Sorting (Flat Access)
|
|
174
|
+
sort: {
|
|
175
|
+
field: s.field,
|
|
176
|
+
direction: s.direction,
|
|
177
|
+
toggle: W,
|
|
178
|
+
clear: X,
|
|
179
|
+
set: Y
|
|
180
|
+
},
|
|
181
|
+
// Filter (Simplified chainable API)
|
|
182
|
+
filter: g,
|
|
183
|
+
// Pagination (Flat Access)
|
|
184
|
+
pagination: {
|
|
185
|
+
pageNo: a.pageNo,
|
|
186
|
+
pageSize: a.pageSize,
|
|
187
|
+
totalPages: y,
|
|
188
|
+
totalItems: p,
|
|
189
|
+
canGoNext: N,
|
|
190
|
+
canGoPrevious: E,
|
|
191
|
+
goToNext: v,
|
|
192
|
+
goToPrevious: ee,
|
|
193
|
+
goToPage: te,
|
|
194
|
+
setPageSize: ne
|
|
195
|
+
},
|
|
196
|
+
// Operations
|
|
197
|
+
refetch: re
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
h as t,
|
|
202
|
+
le as u
|
|
203
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActivityInstanceType } from "./ActivityInstance";
|
|
2
2
|
import type { ActivityInstanceFieldsType, ActivityOperations } from "./types";
|
|
3
|
-
import type { ListResponseType, MetricResponseType } from "../types/common";
|
|
3
|
+
import type { ListResponseType, ListOptionsType, MetricOptionsType, MetricResponseType } from "../types/common";
|
|
4
4
|
import { BaseField } from "../bdo/fields/BaseField";
|
|
5
5
|
/**
|
|
6
6
|
* Abstract base class for workflow activities.
|
|
@@ -59,22 +59,34 @@ export declare abstract class Activity<TEntity extends Record<string, unknown>,
|
|
|
59
59
|
private _discoverFields;
|
|
60
60
|
/**
|
|
61
61
|
* List in-progress activity instances.
|
|
62
|
-
*
|
|
62
|
+
* Accepts optional filter/sort/pagination options.
|
|
63
63
|
*/
|
|
64
|
-
getInProgressList(): Promise<ListResponseType<ActivityInstanceFieldsType & TEntity>>;
|
|
64
|
+
getInProgressList(options?: ListOptionsType): Promise<ListResponseType<ActivityInstanceFieldsType & TEntity>>;
|
|
65
65
|
/**
|
|
66
66
|
* List completed activity instances.
|
|
67
|
-
*
|
|
67
|
+
* Accepts optional filter/sort/pagination options.
|
|
68
68
|
*/
|
|
69
|
-
getCompletedList(): Promise<ListResponseType<ActivityInstanceFieldsType & TEntity>>;
|
|
69
|
+
getCompletedList(options?: ListOptionsType): Promise<ListResponseType<ActivityInstanceFieldsType & TEntity>>;
|
|
70
|
+
/**
|
|
71
|
+
* Get count of in-progress activity instances.
|
|
72
|
+
* Returns a number (same as BDO count()).
|
|
73
|
+
*/
|
|
74
|
+
inProgressCount(options?: ListOptionsType): Promise<number>;
|
|
75
|
+
/**
|
|
76
|
+
* Get count of completed activity instances.
|
|
77
|
+
* Returns a number (same as BDO count()).
|
|
78
|
+
*/
|
|
79
|
+
completedCount(options?: ListOptionsType): Promise<number>;
|
|
70
80
|
/**
|
|
71
81
|
* Get aggregated metrics for in-progress activity instances.
|
|
82
|
+
* Accepts MetricOptionsType (without Type) for custom aggregations (Sum, Avg, etc.).
|
|
72
83
|
*/
|
|
73
|
-
|
|
84
|
+
inProgressMetric(options: Omit<MetricOptionsType, 'Type'>): Promise<MetricResponseType>;
|
|
74
85
|
/**
|
|
75
86
|
* Get aggregated metrics for completed activity instances.
|
|
87
|
+
* Accepts MetricOptionsType (without Type) for custom aggregations (Sum, Avg, etc.).
|
|
76
88
|
*/
|
|
77
|
-
|
|
89
|
+
completedMetric(options: Omit<MetricOptionsType, 'Type'>): Promise<MetricResponseType>;
|
|
78
90
|
/**
|
|
79
91
|
* Get a typed ActivityInstance with field accessors and persistence methods.
|
|
80
92
|
*
|