@harnessio/forms 0.7.0 → 0.9.0
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/dist/core/components/InputComponentRenderer.d.ts +1 -1
- package/dist/core/components/InputErrorBoundary.d.ts +2 -2
- package/dist/core/context/RootFormContext.d.ts +1 -0
- package/dist/core/utils/request-idle-callback.d.ts +23 -0
- package/dist/form/RenderInputs/RenderInputs.d.ts +3 -0
- package/dist/hook-form.d.ts +2 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +415 -387
- package/dist/index.js.map +1 -1
- package/dist/setupTests.d.ts +0 -0
- package/dist/tests/RootForm.simple.test.d.ts +1 -0
- package/dist/tests/RootForm.test.d.ts +0 -0
- package/dist/tests/components/TestFormComponent.d.ts +19 -0
- package/dist/tests/conditional-rendering.test.d.ts +0 -0
- package/dist/tests/factory/factory.d.ts +3 -0
- package/dist/tests/form-submission.test.d.ts +0 -0
- package/dist/tests/inputs/group-form-input/group-form-input-types.d.ts +7 -0
- package/dist/tests/inputs/group-form-input/group-form-input.d.ts +7 -0
- package/dist/tests/inputs/text-form-input/text-form-input-types.d.ts +7 -0
- package/dist/tests/inputs/text-form-input/text-form-input.d.ts +7 -0
- package/dist/tests/validation-workflows.test.d.ts +0 -0
- package/dist/tests/zod-validation.test.d.ts +1 -0
- package/dist/types/types.d.ts +4 -0
- package/dist/utils/utils.d.ts +1 -1
- package/package.json +10 -3
- /package/dist/{core/factory → tests}/InputFactory.spec.d.ts +0 -0
|
@@ -5,4 +5,4 @@ export interface InputComponentRendererProps<TConfig, TValue> extends Omit<Input
|
|
|
5
5
|
withoutWrapper?: boolean;
|
|
6
6
|
input: IInputDefinition<TConfig, TValue>;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
8
|
+
export declare const InputComponentRenderer: import('react').MemoExoticComponent<(<TValue, TConfig = unknown>({ path, factory, onUpdate, onChange, initialValues, input, withoutWrapper }: InputComponentRendererProps<TConfig, TValue>) => JSX.Element | null)>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
1
|
+
import { Component, ErrorInfo } from 'react';
|
|
2
2
|
interface InputErrorBoundaryProps {
|
|
3
3
|
path: string;
|
|
4
4
|
inputType: string;
|
|
@@ -13,7 +13,7 @@ export declare class InputErrorBoundary extends Component<InputErrorBoundaryProp
|
|
|
13
13
|
static getDerivedStateFromError(): {
|
|
14
14
|
hasError: boolean;
|
|
15
15
|
};
|
|
16
|
-
componentDidCatch(): void;
|
|
16
|
+
componentDidCatch(err: Error, errorInfo: ErrorInfo): void;
|
|
17
17
|
render(): import('react').ReactNode;
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface RootFormContextProps<T> {
|
|
2
2
|
metadata?: T;
|
|
3
3
|
readonly?: boolean;
|
|
4
|
+
inputErrorHandler?: (error: Error) => void;
|
|
4
5
|
}
|
|
5
6
|
export declare const RootFormContext: import('react').Context<RootFormContextProps<unknown>>;
|
|
6
7
|
export interface RootFormProviderProps<T> {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polyfill for requestIdleCallback and cancelIdleCallback
|
|
3
|
+
* Returns polyfilled functions that use native implementation when available,
|
|
4
|
+
* otherwise falls back to setTimeout
|
|
5
|
+
*/
|
|
6
|
+
export interface IdleDeadline {
|
|
7
|
+
readonly didTimeout: boolean;
|
|
8
|
+
timeRemaining(): number;
|
|
9
|
+
}
|
|
10
|
+
export interface IdleRequestOptions {
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
export type IdleCallback = (deadline: IdleDeadline) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a requestIdleCallback function that uses native implementation when available,
|
|
16
|
+
* otherwise falls back to setTimeout
|
|
17
|
+
*/
|
|
18
|
+
export declare function requestIdleCallbackPolyfill(): ((callback: IdleRequestCallback, options?: globalThis.IdleRequestOptions) => number) & typeof requestIdleCallback;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a cancelIdleCallback function that uses native implementation when available,
|
|
21
|
+
* otherwise falls back to clearTimeout
|
|
22
|
+
*/
|
|
23
|
+
export declare function cancelIdleCallbackPolyfill(): ((handle: number) => void) & typeof cancelIdleCallback;
|
package/dist/hook-form.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FieldPath, FieldValues, UseControllerProps, UseControllerReturn } from 'react-hook-form';
|
|
2
|
-
export * from 'react-hook-form';
|
|
3
2
|
/**
|
|
4
3
|
* !!!
|
|
5
4
|
* Since useController from react-hook-form has an onBlur handler that triggers updates in useForm,
|
|
@@ -9,3 +8,5 @@ export * from 'react-hook-form';
|
|
|
9
8
|
* This code solves the issue by deferring the onBlur call to the next frame.
|
|
10
9
|
*/
|
|
11
10
|
export declare function useController<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>(props: UseControllerProps<TFieldValues, TName>): UseControllerReturn<TFieldValues, TName>;
|
|
11
|
+
export type { SubmitHandler, SubmitErrorHandler, Mode, DefaultValues, FieldValues } from 'react-hook-form';
|
|
12
|
+
export { useForm, Controller, FormProvider, Form, useWatch, useFormState, get, set, useFieldArray, useFormContext } from 'react-hook-form';
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Re=Object.defineProperty;var je=(r,e,t)=>e in r?Re(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var q=(r,e,t)=>je(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("lodash-es"),h=require("react"),b=require("react-hook-form"),Se=require("zod"),_e=require("@hookform/resolvers");function Ie(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const d=Ie(Se);class ie extends Error{constructor(e){super(`Input component '${e}' is already registered.`)}}class B{constructor(e){q(this,"componentBank");q(this,"allowOverride");this.allowOverride=(e==null?void 0:e.allowOverride)??!1,this.componentBank=new Map}registerComponent(e){if(!this.allowOverride&&this.getComponent(e.internalType))throw new ie(e.internalType);this.componentBank.set(e.internalType,e)}getComponent(e){if(e&&!c.isEmpty(e))return this.componentBank.get(e)}listRegisteredComponents(){return Array.from(this.componentBank.keys())}clone(){const e=new B({allowOverride:this.allowOverride});return this.listRegisteredComponents().forEach(t=>{e.registerComponent(this.componentBank.get(t))}),e}}var N={exports:{}},_={};/*
|
|
2
2
|
object-assign
|
|
3
3
|
(c) Sindre Sorhus
|
|
4
4
|
@license MIT
|
|
5
|
-
*/var
|
|
5
|
+
*/var M,re;function Ce(){if(re)return M;re=1;var r=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable;function n(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function a(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var o={},u=0;u<10;u++)o["_"+String.fromCharCode(u)]=u;var i=Object.getOwnPropertyNames(o).map(function(f){return o[f]});if(i.join("")!=="0123456789")return!1;var l={};return"abcdefghijklmnopqrst".split("").forEach(function(f){l[f]=f}),Object.keys(Object.assign({},l)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return M=a()?Object.assign:function(s,o){for(var u,i=n(s),l,f=1;f<arguments.length;f++){u=Object(arguments[f]);for(var p in u)e.call(u,p)&&(i[p]=u[p]);if(r){l=r(u);for(var m=0;m<l.length;m++)t.call(u,l[m])&&(i[l[m]]=u[l[m]])}}return i},M}/** @license React v17.0.2
|
|
6
6
|
* react-jsx-runtime.production.min.js
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/var z;function Ee(){if(z)return S;z=1,ve();var r=g,e=60103;if(S.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var n=Symbol.for;e=n("react.element"),S.Fragment=n("react.fragment")}var t=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,s={key:!0,ref:!0,__self:!0,__source:!0};function c(o,i,f){var l,p={},m=null,h=null;f!==void 0&&(m=""+f),i.key!==void 0&&(m=""+i.key),i.ref!==void 0&&(h=i.ref);for(l in i)a.call(i,l)&&!s.hasOwnProperty(l)&&(p[l]=i[l]);if(o&&o.defaultProps)for(l in i=o.defaultProps,i)p[l]===void 0&&(p[l]=i[l]);return{$$typeof:e,type:o,key:m,ref:h,props:p,_owner:t.current}}return S.jsx=c,S.jsxs=c,S}var G;function Te(){return G||(G=1,q.exports=Ee()),q.exports}var y=Te();const Y=g.createContext({});function Oe({children:r,metadata:e,inputErrorHandler:n,readonly:t}){return y.jsx(Y.Provider,{value:{metadata:e,readonly:t,inputErrorHandler:n},children:r})}function ee(){const r=g.useContext(Y);return r||console.warn("useRootFormContext must be used within RootFormProvider"),r}class Re extends g.Component{constructor(){super(...arguments);V(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){const n=new Error(`Form input [${this.props.inputType}] has failed at path [${this.props.path}].`);this.props.inputErrorHandler?this.props.inputErrorHandler(n):console.error(n)}render(){return this.state.hasError?y.jsx(y.Fragment,{}):this.props.children}}const K=({children:r,withoutWrapper:e=!1})=>e||!r?r:y.jsx("div",{children:r});function re({path:r,factory:e,onUpdate:n,onChange:t,initialValues:a,input:s,withoutWrapper:c=!1}){var U;const{formState:o,watch:i}=j.useFormContext(),{fixedValues:f={}}={},{metadata:l,readonly:p,inputErrorHandler:m}=ee(),h=e==null?void 0:e.getComponent(s.inputType),v=i(),b=u.cloneDeep(v);f&&Object.keys(f).forEach(C=>{const P=f[C];u.set(b,C,P)});const T=!s.isVisible||s.isVisible(b,l);let O,_;T&&(O=p||s.readonly,_=typeof s.disabled=="function"?s.disabled(b,l):s.disabled);const R=(U=s.warning)==null?void 0:U.schema,E=g.useMemo(()=>{var J,L;if(!T||typeof R>"u")return;const C=j.get(v,s.path),P=typeof R=="function"?R(b):R,{success:me,error:x}=P.safeParse(C),H=(L=(J=x==null?void 0:x.errors)==null?void 0:J[0])==null?void 0:L.message;return!me&&H?H:void 0},[s.path,v,R,T]),$=g.useMemo(()=>({path:r,key:r,initialValues:a,onUpdate:n,onChange:t,factory:e,readonly:O,input:s,disabled:_,warning:E}),[e,a,s,t,n,r,O,o.errors,_,E]),de=g.useMemo(()=>T?y.jsxs(y.Fragment,{children:[s.before?s.before:null,y.jsx(Re,{path:r,inputType:s.inputType,inputErrorHandler:m,children:h==null?void 0:h.renderComponent($)}),s.after?s.after:null]}):null,[T,s.before,s.inputType,s.after,r,h,$,o.errors]);return h?y.jsx(K,{withoutWrapper:c,children:de}):y.jsx(K,{withoutWrapper:c,children:y.jsxs("p",{children:["Input component not found (internal type: ",s.inputType,")"]})})}class je{getType(){return this.internalType}}function _e(r){const{mode:e="onSubmit",resolver:n,defaultValues:t,shouldFocusError:a,onValuesChange:s,onValidationChange:c,onSubmit:o,onInputRenderError:i,metadata:f,children:l,autoFocusPath:p,readonly:m}=r,h=j.useForm({mode:e??"onSubmit",reValidateMode:"onChange",defaultValues:t,shouldFocusError:a,resolver:n}),v=g.useRef(!1);g.useEffect(()=>{h.reset(t,{})},[h.reset,t]),g.useEffect(()=>{const E=requestIdleCallback(()=>{h.reset({},{keepErrors:!0,keepDirty:!0,keepDirtyValues:!0,keepValues:!0,keepDefaultValues:!1,keepIsSubmitted:!0,keepTouched:!0,keepIsValid:!0,keepSubmitCount:!0})});return()=>cancelIdleCallback(E)},[]);const{getValues:b,handleSubmit:T}=h,O=b(),_=g.useRef(!0);g.useEffect(()=>{if(_.current){_.current=!1;return}s==null||s({...O}),v.current===!0&&h.trigger()},[JSON.stringify(O)]);const R=g.useRef(!0);return g.useEffect(()=>{if(R.current){R.current=!1;return}c==null||c({isValid:h.formState.isValid,isSubmitted:h.formState.isSubmitted})},[h.formState.isValid,h.formState.isSubmitted]),g.useEffect(()=>{if(p)if("requestIdleCallback"in window){const E=requestIdleCallback(()=>{h.setFocus(p)});return()=>cancelIdleCallback(E)}else{const E=setTimeout(()=>{h.setFocus(p)},100);return()=>clearTimeout(E)}},[h]),y.jsx(Oe,{metadata:f,readonly:m,inputErrorHandler:i,children:y.jsx(j.FormProvider,{...h,children:typeof l=="function"?l({...h,submitForm:async()=>{o&&(v.current=!0,T(E=>{o(E)})())}}):l})})}const Se=r=>{const e={},n=t=>{t.forEach(a=>{const{path:s,default:c,inputType:o,inputs:i}=a;(o==="group"||o==="accordion")&&Array.isArray(i)?n(i):u.get(e,s)===void 0&&u.set(e,s,c)})};return Array.isArray(r.inputs)&&n(r.inputs),e};function Ie(r,e){const n=r.inputs.map(t=>{const a=Ce(e,t.path);return a||t});return{...r,inputs:n}}function Ce(r,e){return r.inputs.find(n=>n.path===e)}const te="__temp_",Ve=r=>te+r.split(".").join("__");function ne(r){const e={...r};return u.forOwn(e,(n,t)=>{t.startsWith(te)&&delete e[t]}),e}const we="Required field";function I(r){const e=typeof r=="string"?JSON.parse(r):r;if(typeof e=="string")return e;if(u.isArray(e))return I(e[0]);const n=e;return u.isObject(n)&&(n!=null&&n.message)?e==null?void 0:e.message:"Unknown error"}function se(r,e,n){let t={};if(F(t,r.inputs,e,n),n!=null&&n.prefix){const s=n==null?void 0:n.prefix.replace(/.$/,"");t=u.set({},s,t)}return d.object(w(t,e,n))}function w(r,e,n){const t={};return Object.keys(r).forEach(a=>{const{_requiredOnly:s,_schemaObj:c,_input:o,_isList:i,_isArrayItem:f,_schema:l}=r[a];if(i&&c&&o){const p=d.array(d.object(w(c,e,n))).optional(),m=Q(l,o,e,n,p);t[a]=m}else if(f&&o){const p=c!=null&&c.___array?w({___array:c.___array},e,n):{___array:d.any()},m=Fe(p,o,n),h=Q(l,o,e,n,m);t[a]=h}else if(l&&o){const p=Pe(l,o,e,n);t[a]=p}else s&&o?t[a]=M(o,n):t[a]=d.object(w(r[a],e,n)).optional()}),t}function Fe(r,e,n){return d.union([d.array(r.___array).optional(),d.string().superRefine((t,a)=>{var s;if((s=n==null?void 0:n.validationConfig)!=null&&s.globalValidation){const c=n.validationConfig.globalValidation(t,e,n.metadata);if(c.error)return a.addIssue({code:d.ZodIssueCode.custom,message:c.error}),!1;if(!c.continue)return!0}return!0})])}function Pe(r,e,n,t){return d.any().optional().superRefine(async(a,s)=>{var o,i;if(e.required&&!(await M(e,t).safeParseAsync(a)).success)return s.addIssue({code:d.ZodIssueCode.custom,message:k(e,t)}),d.NEVER;if((o=t==null?void 0:t.validationConfig)!=null&&o.globalValidation){const f=(i=t==null?void 0:t.validationConfig)==null?void 0:i.globalValidation(a,e,t.metadata);if(f.error)return s.addIssue({code:d.ZodIssueCode.custom,message:f.error}),d.NEVER;if(!f.continue)return!0}const c=ae(r,n);if(c){const f=await c.safeParseAsync(a);if(!f.success){const l=I(f==null?void 0:f.error.message),p=l==="Required"?k(e,t):l;s.addIssue({code:d.ZodIssueCode.custom,message:p})}}})}function Q(r,e,n,t,a){return d.any().optional().superRefine(async(s,c)=>{var l,p;const i=await M(e,t).safeParseAsync(s);if(e.required&&!i.success){const m=I(i.error.message);return c.addIssue({code:d.ZodIssueCode.custom,message:m,fatal:!0}),d.NEVER}if(!e.required&&!i.success)return d.NEVER;if((l=t==null?void 0:t.validationConfig)!=null&&l.globalValidation){const m=(p=t==null?void 0:t.validationConfig)==null?void 0:p.globalValidation(s,e,t.metadata);if(m.error)return c.addIssue({code:d.ZodIssueCode.custom,message:I(m.error)}),d.NEVER;if(!m.continue)return d.NEVER}if(!u.isArray(s))return c.addIssue({code:d.ZodIssueCode.custom,message:"'Value is not array'"}),d.NEVER;const f=ae(r,n);if(f){const m=await f.safeParseAsync(s);if(!m.success)return c.addIssue({code:d.ZodIssueCode.custom,message:I(m.error.message)}),d.NEVER}}).pipe(a??d.any())}function F(r,e,n,t,a){e.forEach(s=>{var o,i,f,l,p,m,h;const c=n;if(!s.isVisible||(o=s.isVisible)!=null&&o.call(s,c,t==null?void 0:t.metadata)){const v=u.get(r,s.path);if((i=s.validation)!=null&&i.schema?u.set(r,s.path,u.merge(v,{_schema:(f=s.validation)==null?void 0:f.schema,_input:s})):s.required&&u.set(r,s.path,u.merge(v,{_requiredOnly:!0,_input:s})),s.inputs&&F(r,s.inputs,n,t),s.inputType==="list"){const b={};F(b,(p=(l=s.inputConfig)==null?void 0:l.inputs)==null?void 0:p.map(O=>({...O,path:O.relativePath})),n,t);const T=u.get(r,s.path);u.set(r,s.path,u.merge(T,{_schemaObj:b,_isList:!0,_input:s}))}if(!((m=s.validation)!=null&&m.schema)&&s.inputType==="array"){const b={};F(b,[{...s.inputConfig.input,path:"___array"}],n,t),u.set(r,s.path,u.merge(v,{_schemaObj:b,_schema:(h=s.validation)==null?void 0:h.schema,_isArrayItem:!0,_input:s}))}}})}function k(r,e){var n,t,a;return((t=(n=e==null?void 0:e.validationConfig)==null?void 0:n.requiredMessagePerInput)==null?void 0:t[r.inputType])??((a=e==null?void 0:e.validationConfig)==null?void 0:a.requiredMessage)??we}function M(r,e){var t,a,s,c,o,i;if((a=(t=e==null?void 0:e.validationConfig)==null?void 0:t.requiredSchemaPerInput)!=null&&a[r.inputType])return(c=(s=e==null?void 0:e.validationConfig)==null?void 0:s.requiredSchemaPerInput)==null?void 0:c[r.inputType];if((o=e==null?void 0:e.validationConfig)!=null&&o.requiredSchema)return(i=e==null?void 0:e.validationConfig)==null?void 0:i.requiredSchema;const n=k(r,e);return d.any().optional().superRefine((f,l)=>{typeof f=="object"&&u.isEmpty(f)&&l.addIssue({code:d.ZodIssueCode.custom,message:n}),(u.isUndefined(f)||f==="")&&l.addIssue({code:d.ZodIssueCode.custom,message:n})})}function ae(r,e){if(r instanceof d.ZodType)return r;if(typeof r=="function")return r(e)}const xe=r=>Array.isArray(r==null?void 0:r.errors),qe=(r,e)=>{const n={};for(;r.length;){const t=r[0],{code:a,message:s,path:c}=t,o=c.join(".");if(!n[o])if("unionErrors"in t){const i=t.unionErrors[0].errors[0];n[o]={message:i.message,type:i.code}}else n[o]={message:s,type:a};"unionErrors"in t&&t.unionErrors.forEach(i=>i.errors.forEach(f=>r.push(f)));{const i=n[o].types,f=i&&i[t.code];n[o]=j.appendErrors(o,e,n,a,f?[].concat(f,t.message):t.message)}r.shift()}return n};function Ae(r,e){return g.useCallback(async(n,t,a)=>{try{return await se(r,n,e).parseAsync(n),{values:n,errors:{}}}catch(s){if(xe(s))return{values:{},errors:ge.toNestErrors(qe(s.errors,!0),a)};throw s}},[r])}function oe(r,e){const n=u.cloneDeep(r);return e.forEach(t=>{t.inputTransform&&(u.isArray(t.inputTransform)?t.inputTransform:[t.inputTransform]).forEach(s=>{const c=u.get(n,t.path),o=s(c,n);o&&u.set(n,o.path??t.path,o.value)})}),n}function ue(r,e){const n=[],t=u.cloneDeep(r);return e.forEach(a=>{a.outputTransform&&(u.isArray(a.outputTransform)?a.outputTransform:[a.outputTransform]).forEach(c=>{const o=u.get(t,a.path),i=c(o,t);i&&(i.path?(u.set(t,i.path,i.value),i.unset&&n.push(a.path)):u.set(t,a.path,i.value))})}),n.forEach(a=>{u.unset(t,a)}),t}function Z(r){return r.reduce((n,t)=>(t.inputType==="group"||t.inputType==="accordion")&&t.inputs?[...n,t,...Z(t.inputs)]:[...n,t],[])}function B(r){const n=Z(r.inputs).reduce((t,a)=>{const s=a.inputType==="text"||a.inputType==="boolean"||a.inputType==="number"||a.inputType==="textarea"||a.inputType==="select";return(a.inputTransform||a.outputTransform)&&t.push({...u.pick(a,"path","inputTransform","outputTransform"),level:a.path.split(".").length,isPrimitive:s}),t},[]);return n.sort((t,a)=>t.level===a.level?t.isPrimitive?1:-1:t.level>a.level?-1:1),n}function ie(r,e,n,t={}){const{preserve:a}=t,s=Z(r.inputs),c=u.cloneDeep(e);return s.forEach(o=>{a&&a.includes(o.path)||o.isVisible&&!o.isVisible(e,n)&&u.unset(c,o.path)}),c}function ke(r,e){const n=B(e);return oe(r,n)}function Ne(r,e,n,t={}){const a=B(e);let s=ie(e,r,n,t);return s=ue(s,a),s=ne(s),s}function De(r){const e={},n=t=>{t.forEach(a=>{const{default:s,path:c,inputType:o,inputs:i}=a;(o==="group"||o==="accordion")&&Array.isArray(i)?n(i):s!==void 0&&u.set(e,c,s)})};return Array.isArray(r.inputs)&&n(r.inputs),e}function Me(){return function(r,e){if(!(typeof r>"u"))return r?{value:Object.getOwnPropertyNames(r).map(n=>({key:n,value:r[n]}))}:{value:r}}}function Ze(r){return function(e,n){if(typeof e>"u")return;if(!e)return{value:e};const t={value:e.reduce((a,s)=>({...a,[s.key]:r!=null&&r.assignKeyToValue?s.key:s.value??(r==null?void 0:r.fallbackValue)}),{})};return r!=null&&r.unsetIfEmpty&&Object.getOwnPropertyNames(t.value).length===0?{value:void 0}:t}}function Be(){return function(r,e){if(!(typeof r>"u"))return u.isArray(r)&&u.isEmpty(r)?{value:void 0}:{value:r}}}function $e(r){return function(e,n){const t=r?u.get(n,r):e;if(!(typeof t>"u")){if(u.isNull(t))return{value:void 0,path:r};if(u.isObject(t)){const a=u.omitBy(t,u.isNil);if(u.isEmpty(a))return{value:void 0,path:r}}return{value:t,path:r}}}}function Ue(){return function(r,e){if(!(typeof r>"u"))return u.isString(r)&&u.isEmpty(r)?{value:void 0}:{value:r}}}function He(r){return function(e,n){const t=u.get(n,r);return typeof t=="string"?{value:t}:{value:e}}}function Je(r){return function(e,n){if(typeof e>"u")return;if(!e)return{value:e};const t=u.get(n,r);if(typeof t=="object"){const a=ze(t);if(Object.getOwnPropertyNames(a).length===1)return{value:e,path:r}}return{value:e}}}function Le(r){return function(e,n){if(typeof e>"u")return;const t=u.get(n,r);return typeof t=="string"?{value:[t]}:{value:e}}}function We(r,e){return function(n,t){if(typeof n>"u")return;if(!n)return{value:n};const a=u.get(t,r);if(u.isArray(a)){if(a.length===1)return{value:a[0],path:r};if(a.length===0&&e!=null&&e.unsetIfEmpty)return{value:void 0,path:r}}return{value:n}}}function ce(r){return typeof r=="object"?!Object.getOwnPropertyNames(r).some(e=>!ce(r[e])):u.isUndefined(r)}function ze(r){return u.omitBy(r,e=>typeof e=="object"?ce(e):u.isUndefined(e))}function N(r){const{items:e,...n}=r;return y.jsx(y.Fragment,{children:e.map(t=>y.jsx(re,{input:t,path:t.path,...n},`${t.inputType}_${t.path}_${t.label}`))})}const fe=g.forwardRef((r,e)=>{const{inputs:n,className:t,factory:a,withoutWrapper:s}=r;return s?y.jsxs(g.Fragment,{children:[n.hero,y.jsx(N,{items:n.inputs,factory:a,withoutWrapper:s})]}):y.jsxs("div",{className:t,ref:e,children:[n.hero,y.jsx(N,{items:n.inputs,factory:a,withoutWrapper:s})]})});fe.displayName="RenderForm";function Ge(r){let e=!0;return u.forOwn(r,n=>{e=e&&(n===""||u.isNull(n)||u.isUndefined(n))}),e}const Ke=(r="")=>u.capitalize(r.split("_").join(" ")),le=(r,e=2)=>{let n=!1;const t=()=>{requestAnimationFrame(()=>{n||(e-=1,e<=0?r():t())})};return t(),()=>{n=!0}};function Qe(r){const{field:{onBlur:e,...n},...t}=j.useController(r);return{...t,field:{...n,onBlur:le(e)}}}exports.InputComponent=je;exports.InputComponentRenderer=re;exports.InputFactory=D;exports.InputOverrideError=X;exports.RenderForm=fe;exports.RenderInputs=N;exports.RootForm=_e;exports.afterFrames=le;exports.arrayToObjectOutputTransformer=Ze;exports.collectDefaultValues=De;exports.convertDataToFormModel=ke;exports.convertFormModelToData=Ne;exports.generateReadableLabel=Ke;exports.getDefaultValuesFromFormDefinition=Se;exports.getTemporaryPath=Ve;exports.getTransformers=B;exports.getValidationSchema=se;exports.inputTransformValues=oe;exports.isChildrenEmpty=Ge;exports.objectToArrayInputTransformer=Me;exports.outputTransformValues=ue;exports.overrideFormDefinition=Ie;exports.processValidationParseResponse=I;exports.removeTemporaryFieldsValue=ne;exports.shorthandArrayInputTransformer=Le;exports.shorthandArrayOutputTransformer=We;exports.shorthandObjectInputTransformer=He;exports.shorthandObjectOutputTransformer=Je;exports.unsetEmptyArrayOutputTransformer=Be;exports.unsetEmptyObjectOutputTransformer=$e;exports.unsetEmptyStringOutputTransformer=Ue;exports.unsetHiddenInputsValues=ie;exports.useController=Qe;exports.useRootFormContext=ee;exports.useZodValidationResolver=Ae;Object.keys(j).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>j[r]})});
|
|
12
|
+
*/var te;function we(){if(te)return _;te=1,Ce();var r=h,e=60103;if(_.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var t=Symbol.for;e=t("react.element"),_.Fragment=t("react.fragment")}var n=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,s={key:!0,ref:!0,__self:!0,__source:!0};function o(u,i,l){var f,p={},m=null,y=null;l!==void 0&&(m=""+l),i.key!==void 0&&(m=""+i.key),i.ref!==void 0&&(y=i.ref);for(f in i)a.call(i,f)&&!s.hasOwnProperty(f)&&(p[f]=i[f]);if(u&&u.defaultProps)for(f in i=u.defaultProps,i)p[f]===void 0&&(p[f]=i[f]);return{$$typeof:e,type:u,key:m,ref:y,props:p,_owner:n.current}}return _.jsx=o,_.jsxs=o,_}var ne;function Ve(){return ne||(ne=1,N.exports=we()),N.exports}var g=Ve();const ce=h.createContext({});function Fe({children:r,metadata:e,inputErrorHandler:t,readonly:n}){return g.jsx(ce.Provider,{value:{metadata:e,readonly:n,inputErrorHandler:t},children:r})}function fe(){const r=h.useContext(ce);return r||console.warn("useRootFormContext must be used within RootFormProvider"),r}class Pe extends h.Component{constructor(){super(...arguments);q(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){var s,o;console.error(t,n);const a=new Error(`Form input [${this.props.inputType}] has failed at path [${this.props.path}]. Error: ${t}, Error info: ${n}`);(o=(s=this.props).inputErrorHandler)==null||o.call(s,a)}render(){return this.state.hasError?g.jsx(g.Fragment,{}):this.props.children}}const se=({children:r,withoutWrapper:e=!1})=>e||!r?r:g.jsx("div",{children:r}),le=h.memo(function({path:e,factory:t,onUpdate:n,onChange:a,initialValues:s,input:o,withoutWrapper:u=!1}){var H,z,G,K,Q;const i=b.useFormContext(),{formState:l}=i,{fixedValues:f={}}={},{metadata:p,readonly:m,inputErrorHandler:y}=fe(),v=t==null?void 0:t.getComponent(o.inputType),O=!!(o.isVisible||typeof o.disabled=="function"||typeof((H=o.validation)==null?void 0:H.schema)=="function"||typeof((z=o.warning)==null?void 0:z.schema)=="function"),C=!!((G=o.warning)!=null&&G.schema||(K=o.validation)!=null&&K.schema),T=O?i.watch():{},w=C?O?b.get(T,o.path):i.watch(o.path):void 0,R=h.useMemo(()=>{if(!O)return{};let F=T;return f&&Object.keys(f).forEach(x=>{const P=f[x];F=c.set(F,x,P)}),F},[O,T,f]),E=!o.isVisible||o.isVisible(R,p),j=m||o.readonly,S=typeof o.disabled=="function"?o.disabled(R,p):o.disabled,V=(Q=o.warning)==null?void 0:Q.schema,J=h.useMemo(()=>{var Y,ee;if(!E||typeof V>"u")return;const F=typeof V=="function"?V(R):V,{success:x,error:P}=F.safeParse(w),X=(ee=(Y=P==null?void 0:P.errors)==null?void 0:Y[0])==null?void 0:ee.message;return!x&&X?X:void 0},[o.path,w,V,E]),L=h.useMemo(()=>({path:e,key:e,initialValues:s,onUpdate:n,onChange:a,factory:t,readonly:j,input:o,disabled:S,warning:J}),[t,s,o,a,n,e,j,l.errors,S,J]),Te=h.useMemo(()=>E?g.jsxs(g.Fragment,{children:[o.before?o.before:null,g.jsx(Pe,{path:e,inputType:o.inputType,inputErrorHandler:y,children:v==null?void 0:v.renderComponent(L)}),o.after?o.after:null]}):null,[E,o.before,o.inputType,o.after,e,v,L,l.errors]);return v?g.jsx(se,{withoutWrapper:u,children:Te}):g.jsx(se,{withoutWrapper:u,children:g.jsxs("p",{children:["Input component not found (internal type: ",o.inputType,")"]})})});class xe{getType(){return this.internalType}}function ae(){return typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback:function(r,e){const t=Date.now(),n=(e==null?void 0:e.timeout)||1;return setTimeout(function(){r({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},n)}}function oe(){return typeof window<"u"&&"cancelIdleCallback"in window?window.cancelIdleCallback:clearTimeout}function qe(r){const{mode:e="onSubmit",resolver:t,defaultValues:n,shouldFocusError:a,onValuesChange:s,onValidationChange:o,onSubmit:u,onInputRenderError:i,metadata:l,children:f,autoFocusPath:p,readonly:m}=r,y=b.useForm({mode:e??"onSubmit",reValidateMode:"onChange",defaultValues:n,shouldFocusError:a,resolver:t}),v=h.useRef(!1);h.useEffect(()=>{y.reset(n,{})},[y.reset,n]),h.useEffect(()=>{const E=ae(),j=oe(),S=E(()=>{y.reset({},{keepErrors:!0,keepDirty:!0,keepDirtyValues:!0,keepValues:!0,keepDefaultValues:!1,keepIsSubmitted:!0,keepTouched:!0,keepIsValid:!0,keepSubmitCount:!0})});return()=>j(S)},[]);const{getValues:O,handleSubmit:C}=y,T=O(),w=h.useRef(!0);h.useEffect(()=>{if(w.current){w.current=!1;return}s==null||s({...T}),v.current===!0&&y.trigger()},[JSON.stringify(T)]);const R=h.useRef(!0);return h.useEffect(()=>{if(R.current){R.current=!1;return}o==null||o({isValid:y.formState.isValid,isSubmitted:y.formState.isSubmitted})},[y.formState.isValid,y.formState.isSubmitted]),h.useEffect(()=>{if(p){const E=ae(),j=oe(),S=E(()=>{y.setFocus(p)});return()=>j(S)}},[y]),g.jsx(Fe,{metadata:l,readonly:m,inputErrorHandler:i,children:g.jsx(b.FormProvider,{...y,children:typeof f=="function"?f({...y,submitForm:async()=>{u&&(v.current=!0,C(E=>{u(E)})())}}):f})})}const Ae=r=>{const e={},t=n=>{n.forEach(a=>{const{path:s,default:o,inputType:u,inputs:i}=a;(u==="group"||u==="accordion")&&Array.isArray(i)?t(i):c.get(e,s)===void 0&&c.set(e,s,o)})};return Array.isArray(r.inputs)&&t(r.inputs),e};function ke(r,e){const t=r.inputs.map(n=>{const a=De(e,n.path);return a||n});return{...r,inputs:t}}function De(r,e){return r.inputs.find(t=>t.path===e)}const de="__temp_",Ne=r=>de+r.split(".").join("__");function me(r){const e={...r};return c.forOwn(e,(t,n)=>{n.startsWith(de)&&delete e[n]}),e}const Me="Required field";function I(r){let e;if(typeof r=="string")try{e=JSON.parse(r)}catch{e=r}else e=r;if(typeof e=="string")return e;if(c.isArray(e))return I(e[0]);const t=e;return c.isObject(t)&&(t!=null&&t.message)?e==null?void 0:e.message:"Unknown error"}function pe(r,e,t){let n={};if(k(n,r.inputs,e,t),t!=null&&t.prefix){const s=t==null?void 0:t.prefix.replace(/.$/,"");n=c.set({},s,n)}return d.object(A(n,e,t))}function A(r,e,t){const n={};return Object.keys(r).forEach(a=>{const{_requiredOnly:s,_schemaObj:o,_input:u,_isList:i,_isArrayItem:l,_schema:f}=r[a];if(i&&o&&u){const p=d.array(d.object(A(o,e,t))).optional(),m=ue(f,u,e,t,p);n[a]=m}else if(l&&u){const p=o!=null&&o.___array?A({___array:o.___array},e,t):{___array:d.any()},m=Ze(p,u,t),y=ue(f,u,e,t,m);n[a]=y}else if(f&&u){const p=Be(f,u,e,t);n[a]=p}else s&&u?n[a]=$(u,t):n[a]=d.object(A(r[a],e,t)).optional()}),n}function Ze(r,e,t){return d.union([d.array(r.___array).optional(),d.string().superRefine((n,a)=>{var s;if((s=t==null?void 0:t.validationConfig)!=null&&s.globalValidation){const o=t.validationConfig.globalValidation(n,e,t.metadata);if(o.error)return a.addIssue({code:d.ZodIssueCode.custom,message:o.error}),!1;if(!o.continue)return!0}return!0})])}function Be(r,e,t,n){return d.any().optional().superRefine(async(a,s)=>{var u,i;if(e.required&&!(await $(e,n).safeParseAsync(a)).success)return s.addIssue({code:d.ZodIssueCode.custom,message:Z(e,n)}),d.NEVER;if((u=n==null?void 0:n.validationConfig)!=null&&u.globalValidation){const l=(i=n==null?void 0:n.validationConfig)==null?void 0:i.globalValidation(a,e,n.metadata);if(l.error)return s.addIssue({code:d.ZodIssueCode.custom,message:l.error}),d.NEVER;if(!l.continue)return!0}const o=ye(r,t);if(o){const l=await o.safeParseAsync(a);if(!l.success){const f=I(l==null?void 0:l.error.message),p=f==="Required"?Z(e,n):f;s.addIssue({code:d.ZodIssueCode.custom,message:p})}}})}function ue(r,e,t,n,a){return d.any().optional().superRefine(async(s,o)=>{var f,p;const i=await $(e,n).safeParseAsync(s);if(e.required&&!i.success){const m=I(i.error.message);return o.addIssue({code:d.ZodIssueCode.custom,message:m,fatal:!0}),d.NEVER}if(!e.required&&!i.success)return d.NEVER;if((f=n==null?void 0:n.validationConfig)!=null&&f.globalValidation){const m=(p=n==null?void 0:n.validationConfig)==null?void 0:p.globalValidation(s,e,n.metadata);if(m.error)return o.addIssue({code:d.ZodIssueCode.custom,message:I(m.error)}),d.NEVER;if(!m.continue)return d.NEVER}if(!c.isArray(s))return o.addIssue({code:d.ZodIssueCode.custom,message:"'Value is not array'"}),d.NEVER;const l=ye(r,t);if(l){const m=await l.safeParseAsync(s);if(!m.success)return o.addIssue({code:d.ZodIssueCode.custom,message:I(m.error.message)}),d.NEVER}}).pipe(a??d.any())}function k(r,e,t,n,a){e.forEach(s=>{var u,i,l,f,p,m,y;const o=t;if(!s.isVisible||(u=s.isVisible)!=null&&u.call(s,o,n==null?void 0:n.metadata)){const v=c.get(r,s.path);if((i=s.validation)!=null&&i.schema?c.set(r,s.path,c.merge(v,{_schema:(l=s.validation)==null?void 0:l.schema,_input:s})):s.required&&c.set(r,s.path,c.merge(v,{_requiredOnly:!0,_input:s})),s.inputs&&k(r,s.inputs,t,n),s.inputType==="list"){const O={};k(O,(p=(f=s.inputConfig)==null?void 0:f.inputs)==null?void 0:p.map(T=>({...T,path:T.relativePath})),t,n);const C=c.get(r,s.path);c.set(r,s.path,c.merge(C,{_schemaObj:O,_isList:!0,_input:s}))}if(!((m=s.validation)!=null&&m.schema)&&s.inputType==="array"){const O={};k(O,[{...s.inputConfig.input,path:"___array"}],t,n),c.set(r,s.path,c.merge(v,{_schemaObj:O,_schema:(y=s.validation)==null?void 0:y.schema,_isArrayItem:!0,_input:s}))}}})}function Z(r,e){var t,n,a;return((n=(t=e==null?void 0:e.validationConfig)==null?void 0:t.requiredMessagePerInput)==null?void 0:n[r.inputType])??((a=e==null?void 0:e.validationConfig)==null?void 0:a.requiredMessage)??Me}function $(r,e){var n,a,s,o,u,i;if((a=(n=e==null?void 0:e.validationConfig)==null?void 0:n.requiredSchemaPerInput)!=null&&a[r.inputType])return(o=(s=e==null?void 0:e.validationConfig)==null?void 0:s.requiredSchemaPerInput)==null?void 0:o[r.inputType];if((u=e==null?void 0:e.validationConfig)!=null&&u.requiredSchema)return(i=e==null?void 0:e.validationConfig)==null?void 0:i.requiredSchema;const t=Z(r,e);return d.any().optional().superRefine((l,f)=>{typeof l=="object"&&c.isEmpty(l)&&f.addIssue({code:d.ZodIssueCode.custom,message:t}),(c.isUndefined(l)||l==="")&&f.addIssue({code:d.ZodIssueCode.custom,message:t})})}function ye(r,e){if(r instanceof d.ZodType)return r;if(typeof r=="function")return r(e)}const $e=r=>Array.isArray(r==null?void 0:r.errors),Ue=(r,e)=>{const t={};for(;r.length;){const n=r[0],{code:a,message:s,path:o}=n,u=o.join(".");if(!t[u])if("unionErrors"in n){const i=n.unionErrors[0].errors[0];t[u]={message:i.message,type:i.code}}else t[u]={message:s,type:a};"unionErrors"in n&&n.unionErrors.forEach(i=>i.errors.forEach(l=>r.push(l)));{const i=t[u].types,l=i&&i[n.code];t[u]=b.appendErrors(u,e,t,a,l?[].concat(l,n.message):n.message)}r.shift()}return t};function We(r,e){return h.useCallback(async(t,n,a)=>{try{return await pe(r,t,e).parseAsync(t),{values:t,errors:{}}}catch(s){if($e(s))return{values:{},errors:_e.toNestErrors(Ue(s.errors,!0),a)};throw s}},[r,e])}function he(r,e){const t=c.cloneDeep(r);return e.forEach(n=>{n.inputTransform&&(c.isArray(n.inputTransform)?n.inputTransform:[n.inputTransform]).forEach(s=>{const o=c.get(t,n.path),u=s(o,t);u&&c.set(t,u.path??n.path,u.value)})}),t}function ge(r,e){const t=[],n=c.cloneDeep(r);return e.forEach(a=>{a.outputTransform&&(c.isArray(a.outputTransform)?a.outputTransform:[a.outputTransform]).forEach(o=>{const u=c.get(n,a.path),i=o(u,n);i&&(i.path?(c.set(n,i.path,i.value),i.unset&&t.push(a.path)):c.set(n,a.path,i.value))})}),t.forEach(a=>{c.unset(n,a)}),n}function U(r){return r.reduce((t,n)=>(n.inputType==="group"||n.inputType==="accordion")&&n.inputs?[...t,n,...U(n.inputs)]:[...t,n],[])}function W(r){const t=U(r.inputs).reduce((n,a)=>{const s=a.inputType==="text"||a.inputType==="boolean"||a.inputType==="number"||a.inputType==="textarea"||a.inputType==="select";return(a.inputTransform||a.outputTransform)&&n.push({...c.pick(a,"path","inputTransform","outputTransform"),level:a.path.split(".").length,isPrimitive:s}),n},[]);return t.sort((n,a)=>n.level===a.level?n.isPrimitive?1:-1:n.level>a.level?-1:1),t}function be(r,e,t,n={}){const{preserve:a}=n,s=U(r.inputs),o=c.cloneDeep(e);return s.forEach(u=>{a&&a.includes(u.path)||u.isVisible&&!u.isVisible(e,t)&&c.unset(o,u.path)}),o}function Je(r,e){const t=W(e);return he(r,t)}function Le(r,e,t,n={}){const a=W(e);let s=be(e,r,t,n);return s=ge(s,a),s=me(s),s}function He(r){const e={},t=n=>{n.forEach(a=>{const{default:s,path:o,inputType:u,inputs:i}=a;(u==="group"||u==="accordion")&&Array.isArray(i)?t(i):s!==void 0&&c.set(e,o,s)})};return Array.isArray(r.inputs)&&t(r.inputs),e}function ze(){return function(r,e){if(!(typeof r>"u"))return r?{value:Object.getOwnPropertyNames(r).map(t=>({key:t,value:r[t]}))}:{value:r}}}function Ge(r){return function(e,t){if(typeof e>"u")return;if(!e)return{value:e};const n={value:e.reduce((a,s)=>({...a,[s.key]:r!=null&&r.assignKeyToValue?s.key:s.value??(r==null?void 0:r.fallbackValue)}),{})};return r!=null&&r.unsetIfEmpty&&Object.getOwnPropertyNames(n.value).length===0?{value:void 0}:n}}function Ke(){return function(r,e){if(!(typeof r>"u"))return c.isArray(r)&&c.isEmpty(r)?{value:void 0}:{value:r}}}function Qe(r){return function(e,t){const n=r?c.get(t,r):e;if(!(typeof n>"u")){if(c.isNull(n))return{value:void 0,path:r};if(c.isObject(n)){const a=c.omitBy(n,c.isNil);if(c.isEmpty(a))return{value:void 0,path:r}}return{value:n,path:r}}}}function Xe(){return function(r,e){if(!(typeof r>"u"))return c.isString(r)&&c.isEmpty(r)?{value:void 0}:{value:r}}}function Ye(r){return function(e,t){const n=c.get(t,r);return typeof n=="string"?{value:n}:{value:e}}}function er(r){return function(e,t){if(typeof e>"u")return;if(!e)return{value:e};const n=c.get(t,r);if(typeof n=="object"){const a=nr(n);if(Object.getOwnPropertyNames(a).length===1)return{value:e,path:r}}return{value:e}}}function rr(r){return function(e,t){if(typeof e>"u")return;const n=c.get(t,r);return typeof n=="string"?{value:[n]}:{value:e}}}function tr(r,e){return function(t,n){if(typeof t>"u")return;if(!t)return{value:t};const a=c.get(n,r);if(c.isArray(a)){if(a.length===1)return{value:a[0],path:r};if(a.length===0&&e!=null&&e.unsetIfEmpty)return{value:void 0,path:r}}return{value:t}}}function ve(r){return typeof r=="object"?!Object.getOwnPropertyNames(r).some(e=>!ve(r[e])):c.isUndefined(r)}function nr(r){return c.omitBy(r,e=>typeof e=="object"?ve(e):c.isUndefined(e))}function D(r){const{items:e,...t}=r;return g.jsx(g.Fragment,{children:e.map(n=>g.jsx(le,{input:n,path:n.path,...t},`${n.inputType}_${n.path}`))})}D.displayName="RenderInputs";const Oe=h.forwardRef((r,e)=>{const{inputs:t,className:n,factory:a,withoutWrapper:s}=r;return s?g.jsxs(h.Fragment,{children:[t.hero,g.jsx(D,{items:t.inputs,factory:a,withoutWrapper:s})]}):g.jsxs("div",{className:n,ref:e,children:[t.hero,g.jsx(D,{items:t.inputs,factory:a,withoutWrapper:s})]})});Oe.displayName="RenderForm";function sr(r){let e=!0;return c.forOwn(r,t=>{e=e&&(t===""||c.isNull(t)||c.isUndefined(t))}),e}const ar=(r="")=>c.capitalize(r.split("_").join(" ")),Ee=(r,e=2,t,n=1e3)=>{let a=!1;const s=()=>{requestAnimationFrame(()=>{a||(e-=1,e<=0?r():s())})};return t&&Date.now()-t<=n?(r(),()=>{}):(s(),()=>{a=!0})};function or(r){const{field:{onBlur:e,...t},...n}=b.useController(r),a=h.useRef(Date.now());return{...n,field:{...t,onBlur:Ee(e,2,a.current)}}}Object.defineProperty(exports,"Controller",{enumerable:!0,get:()=>b.Controller});Object.defineProperty(exports,"Form",{enumerable:!0,get:()=>b.Form});Object.defineProperty(exports,"FormProvider",{enumerable:!0,get:()=>b.FormProvider});Object.defineProperty(exports,"get",{enumerable:!0,get:()=>b.get});Object.defineProperty(exports,"set",{enumerable:!0,get:()=>b.set});Object.defineProperty(exports,"useFieldArray",{enumerable:!0,get:()=>b.useFieldArray});Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>b.useForm});Object.defineProperty(exports,"useFormContext",{enumerable:!0,get:()=>b.useFormContext});Object.defineProperty(exports,"useFormState",{enumerable:!0,get:()=>b.useFormState});Object.defineProperty(exports,"useWatch",{enumerable:!0,get:()=>b.useWatch});exports.InputComponent=xe;exports.InputComponentRenderer=le;exports.InputFactory=B;exports.InputOverrideError=ie;exports.RenderForm=Oe;exports.RenderInputs=D;exports.RootForm=qe;exports.afterFrames=Ee;exports.arrayToObjectOutputTransformer=Ge;exports.collectDefaultValues=He;exports.convertDataToFormModel=Je;exports.convertFormModelToData=Le;exports.generateReadableLabel=ar;exports.getDefaultValuesFromFormDefinition=Ae;exports.getTemporaryPath=Ne;exports.getTransformers=W;exports.getValidationSchema=pe;exports.inputTransformValues=he;exports.isChildrenEmpty=sr;exports.objectToArrayInputTransformer=ze;exports.outputTransformValues=ge;exports.overrideFormDefinition=ke;exports.processValidationParseResponse=I;exports.removeTemporaryFieldsValue=me;exports.shorthandArrayInputTransformer=rr;exports.shorthandArrayOutputTransformer=tr;exports.shorthandObjectInputTransformer=Ye;exports.shorthandObjectOutputTransformer=er;exports.unsetEmptyArrayOutputTransformer=Ke;exports.unsetEmptyObjectOutputTransformer=Qe;exports.unsetEmptyStringOutputTransformer=Xe;exports.unsetHiddenInputsValues=be;exports.useController=or;exports.useRootFormContext=fe;exports.useZodValidationResolver=We;
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|