@saas-ui/forms 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ interface AutoFormOptions {
10
10
  submitLabel?: React.ReactNode;
11
11
  /**
12
12
  * The schema.
13
- * Supports object schema, Yup or Zod.
13
+ * Supports object schema, Zod, Yup or Ajv (JSON Schema).
14
14
  * @see https://www.saas-ui.dev/docs/forms/auto-form
15
15
  */
16
16
  schema: any;
@@ -19,7 +19,8 @@ interface AutoFormOptions {
19
19
  */
20
20
  fieldResolver?: any;
21
21
  }
22
- export interface AutoFormProps<TFieldValues extends FieldValues> extends Omit<FormProps<TFieldValues>, 'schema'>, AutoFormOptions {
22
+ export interface AutoFormProps<TFieldValues extends FieldValues> extends Omit<FormProps<TFieldValues>, 'schema' | 'children'>, AutoFormOptions {
23
+ children?: React.ReactNode;
23
24
  }
24
25
  export declare const AutoForm: (<TFieldValues extends FieldValues>(props: AutoFormProps<TFieldValues> & {
25
26
  ref?: React.ForwardedRef<UseFormReturn<TFieldValues, any>> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../src/auto-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI5D,OAAO,EAAQ,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIxC,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAA;AAEjC,UAAU,eAAe;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAA;IACX;;OAEG;IACH,aAAa,CAAC,EAAE,GAAG,CAAA;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,YAAY,SAAS,WAAW,CAC7D,SAAQ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,EAC7C,eAAe;CAAG;AAEtB,eAAO,MAAM,QAAQ;;MA2BhB,MAAM,YAAY;;iCAEO,GAAG,KAAK,aAAa;CAClD,CAAA"}
1
+ {"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../src/auto-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI5D,OAAO,EAAQ,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIxC,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAA;AAEjC,UAAU,eAAe;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAA;IACX;;OAEG;IACH,aAAa,CAAC,EAAE,GAAG,CAAA;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,YAAY,SAAS,WAAW,CAC7D,SAAQ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,EAC1D,eAAe;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,eAAO,MAAM,QAAQ;;MA2BhB,MAAM,YAAY;;iCAEO,GAAG,KAAK,aAAa;CAClD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAKL,eAAe,EACf,WAAW,EACX,SAAS,EACV,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAIL,gBAAgB,EAUhB,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EAIb,gBAAgB,EAChB,WAAW,EACZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAW,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,OAAO,E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,UAAU,6DAMtB,CAAA;AAED,eAAO,MAAM,iBAAiB,+DAI7B,CAAA;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAA;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;CAChC;AAED,eAAO,MAAM,QAAQ,2DAqBpB,CAAA;AAED,QAAA,MAAM,UAAU;;;;;;;;;;;;;;CAcf,CAAA;AAED,aAAK,UAAU,GAAG,OAAO,UAAU,CAAA;AAEnC,aAAK,SAAS,CAAC,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;AAEtD,aAAK,SAAS,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,GAAG;IAC3E,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAED,aAAK,cAAc,GACf;KACG,QAAQ,IAAI,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC1E,CAAC,MAAM,UAAU,CAAC,GACnB;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
package/dist/form.d.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import { HTMLChakraProps } from '@chakra-ui/react';
3
- import { UseFormProps, UseFormReturn, FieldValues, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult } from 'react-hook-form';
3
+ import { UseFormProps, UseFormReturn, FieldValues, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, WatchObserver } from 'react-hook-form';
4
4
  import { FieldResolver } from './field-resolver';
5
+ import { MaybeRenderProp } from '@chakra-ui/react-utils';
5
6
  export type { UseFormReturn, FieldValues, SubmitHandler };
6
7
  interface FormOptions<TFieldValues extends FieldValues = FieldValues> {
7
8
  /**
8
9
  * The form schema, currently supports Yup schema only.
9
10
  */
10
11
  schema?: any;
12
+ /**
13
+ * Triggers when any of the field change.
14
+ */
15
+ onChange?: WatchObserver<TFieldValues>;
11
16
  /**
12
17
  * The submit handler.
13
18
  */
@@ -20,12 +25,12 @@ interface FormOptions<TFieldValues extends FieldValues = FieldValues> {
20
25
  * Ref on the HTMLFormElement.
21
26
  */
22
27
  formRef?: React.RefObject<HTMLFormElement>;
28
+ /**
29
+ * The form children, can be a render prop or a ReactNode.
30
+ */
31
+ children?: MaybeRenderProp<UseFormReturn<TFieldValues>>;
23
32
  }
24
- /**
25
- * @todo Figure out how to pass down FieldValues to all Field components,
26
- * if at all possible.
27
- */
28
- export interface FormProps<TFieldValues extends FieldValues = FieldValues> extends UseFormProps<TFieldValues>, Omit<HTMLChakraProps<'form'>, 'onSubmit' | 'onError'>, FormOptions<TFieldValues> {
33
+ export interface FormProps<TFieldValues extends FieldValues = FieldValues> extends UseFormProps<TFieldValues>, Omit<HTMLChakraProps<'form'>, 'children' | 'onChange' | 'onSubmit' | 'onError'>, FormOptions<TFieldValues> {
29
34
  }
30
35
  export declare const Form: (<TFieldValues extends FieldValues>(props: FormProps<TFieldValues> & {
31
36
  ref?: React.ForwardedRef<UseFormReturn<TFieldValues, any>> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,eAAe,EAAc,MAAM,kBAAkB,CAAA;AAGtE,OAAO,EAGL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAuB,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aA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G,CAAC,MAAM,EAAE,GAAG,KAAK,aAAa,CAAA"}
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export * from './display-if';
12
12
  export * from './step-form';
13
13
  export * from './use-step-form';
14
14
  export * from './field-resolver';
15
+ export * from './watch-field';
15
16
  export * from '@saas-ui/input-right-button';
16
- export type { FieldErrors } from 'react-hook-form';
17
+ export type { BatchFieldArrayUpdate, ChangeHandler, Control, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, Field as FieldDef, FieldArray, FieldArrayMethodProps, FieldArrayWithId, FieldElement, FieldError, FieldErrors, FieldName, FieldNamesMarkedBoolean, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UnpackNestedValue, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormProps, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormReturn, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, } from 'react-hook-form';
18
+ export { appendErrors, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch, Controller, FormProvider, } from 'react-hook-form';
17
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,6BAA6B,CAAA;AAE3C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAE3C,YAAY,EACV,qBAAqB,EACrB,aAAa,EACb,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,WAAW,EACX,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,KAAK,IAAI,QAAQ,EACjB,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,mBAAmB,EACnB,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,aAAa,EACb,GAAG,EACH,WAAW,EACX,eAAe,EACf,QAAQ,EACR,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,OAAO,EACP,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,YAAY,GACb,MAAM,iBAAiB,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("react"),r=require("@chakra-ui/utils"),t=require("react-hook-form"),n=require("@chakra-ui/react"),a=require("@saas-ui/number-input"),l=require("@saas-ui/password-input"),i=require("@saas-ui/radio"),o=require("@saas-ui/select"),s=require("@chakra-ui/system"),u=require("@chakra-ui/icons"),d=require("@saas-ui/button"),c=require("@chakra-ui/react-utils"),m=require("@saas-ui/stepper"),p=require("@saas-ui/input-right-button");function f(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var v=/*#__PURE__*/f(e);function h(){return h=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},h.apply(this,arguments)}function x(e,r){if(null==e)return{};var t,n,a={},l=Object.keys(e);for(n=0;n<l.length;n++)r.indexOf(t=l[n])>=0||(a[t]=e[t]);return a}var F=["name","label","placeholder"],b=function(e){var r=e.name,t=e.label,a=x(e,F);/*#__PURE__*/return v.createElement(n.FormControl,a,t?/*#__PURE__*/v.createElement(n.FormLabel,{htmlFor:r},t):null,/*#__PURE__*/v.createElement(n.Text,{fontSize:"md"},/*#__PURE__*/v.createElement(y,{name:r})))};r.__DEV__&&(b.displayName="DisplayField");var y=function(e){var r=e.name;return(0,t.useFormContext().getValues)(r)||null};r.__DEV__&&(y.displayName="FormValue");var E=["name","label","help","variant","hideLabel","children"],_=["id","name","label","help","isDisabled","isInvalid","isReadOnly","isRequired","rules","variant"],g=["name","rules"],C=["ref"],S=["name","rules"],N=["ref"],R=["type","leftAddon","rightAddon","size"],V=["type"],w=["label","type"],A=["pinLength","pinType","spacing"],D={},k=function(e){var r=e.name,a=e.label,l=e.help,i=e.variant,o=e.hideLabel,s=e.children,u=x(e,E),d=function(e,r){return t.get(r.errors,e)}(r,t.useFormContext().formState);/*#__PURE__*/return v.createElement(n.FormControl,h({variant:i},u,{isInvalid:!!d}),a&&!o?/*#__PURE__*/v.createElement(n.FormLabel,{variant:i},a):null,/*#__PURE__*/v.createElement(n.Box,null,s,!l||null!=d&&d.message?null:/*#__PURE__*/v.createElement(n.FormHelperText,null,l),(null==d?void 0:d.message)&&/*#__PURE__*/v.createElement(n.FormErrorMessage,null,null==d?void 0:d.message)))};r.__DEV__&&(k.displayName="BaseField");var I=v.forwardRef(function(e,r){var t=e.type;/*#__PURE__*/return v.createElement(D[void 0===t?"text":t]||D.text,h({ref:r},e))}),L=function(e){return n.forwardRef(function(r,a){var l=r.name,i=r.rules,o=x(r,g),s=t.useFormContext();/*#__PURE__*/return v.createElement(t.Controller,{name:l,control:s.control,rules:i,render:function(r){var t=r.field,l=t.ref,i=x(t,C);/*#__PURE__*/return v.createElement(e,h({},i,o,{ref:n.useMergeRefs(a,l)}))}})})},P=function(e){return n.forwardRef(function(r,a){var l=r.name,i=r.rules,o=x(r,S),s=(0,t.useFormContext().register)(l,i),u=s.ref,d=x(s,N);/*#__PURE__*/return v.createElement(e,h({},d,o,{ref:n.useMergeRefs(a,u)}))})},B=function(e,r,t){var a=function(e,r){var t=r.displayName,a=r.hideLabel,l=r.BaseField,i=n.forwardRef(function(r,t){var n=r.id,i=r.name,o=r.label,s=r.help,u=r.isDisabled,d=r.isInvalid,c=r.isReadOnly,m=r.isRequired,p=r.rules,f=r.variant,F=x(r,_),b=h({required:m},p);/*#__PURE__*/return v.createElement(l,{id:n,name:i,label:o,help:s,hideLabel:a,isDisabled:u,isInvalid:d,isReadOnly:c,isRequired:m,variant:f},/*#__PURE__*/v.createElement(e,h({ref:t,id:n,name:i,label:a?o:void 0,rules:b},F)))});return i.displayName=t,i}(null!=t&&t.isControlled?L(r):P(r),{displayName:e.split("-").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("")+"Field",hideLabel:null==t?void 0:t.hideLabel,BaseField:(null==t?void 0:t.BaseField)||k});return D[e]=a,a},O=B("text",n.forwardRef(function(e,r){var t=e.type,a=void 0===t?"text":t,l=e.leftAddon,i=e.rightAddon,o=e.size,s=x(e,R),u=/*#__PURE__*/v.createElement(n.Input,h({type:a,size:o},s,{ref:r}));return l||i?/*#__PURE__*/v.createElement(n.InputGroup,{size:o},l,u,i):u})),j=B("number",a.NumberInput,{isControlled:!0}),q=B("password",n.forwardRef(function(e,r){/*#__PURE__*/return v.createElement(l.PasswordInput,h({ref:r},e))})),M=B("textarea",n.Textarea),U=B("switch",n.forwardRef(function(e,r){var t=x(e,V);/*#__PURE__*/return v.createElement(n.Switch,h({},t,{ref:r}))}),{isControlled:!0}),T=B("select",o.Select,{isControlled:!0}),z=B("checkbox",n.forwardRef(function(e,r){var t=e.label,a=x(e,w);/*#__PURE__*/return v.createElement(n.Checkbox,h({ref:r},a),t)}),{hideLabel:!0}),H=B("radio",i.RadioInput,{isControlled:!0}),G=B("native-select",o.NativeSelect,{isControlled:!0}),W=B("pin",n.forwardRef(function(e,r){for(var t=e.pinLength,a=void 0===t?4:t,l=e.pinType,i=e.spacing,o=x(e,A),s=[],u=0;u<a;u++)s.push(/*#__PURE__*/v.createElement(n.PinInputField,{key:u,ref:r}));/*#__PURE__*/return v.createElement(n.HStack,{spacing:i},/*#__PURE__*/v.createElement(n.PinInput,h({},o,{type:l}),s))}),{isControlled:!0}),J=["items","label","title"],K=function(e){return e&&Object.entries(e).map(function(e){var r=e[0],t=e[1],n=t.label,a=t.title;return h({},x(t,J),{name:r,label:n||a})})},Q=function(e){return{getFields:function(){return K(e)},getNestedFields:function(t){var n,a=r.get(e,t);return a?"object"===(null==(n=a.items)?void 0:n.type)?K(a.items.properties):"object"===a.type?K(a.properties):[a.items]:[]}}},X=["mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","schema","defaultValues","onSubmit","onError","formRef","children"],Y=n.forwardRef(function(e,a){var l=e.mode,i=void 0===l?"all":l,o=e.resolver,s=e.reValidateMode,u=e.shouldFocusError,d=e.shouldUnregister,c=e.shouldUseNativeValidation,m=e.criteriaMode,p=e.delayError,f=e.schema,F=e.defaultValues,b=e.onSubmit,y=e.onError,E=e.formRef,_=e.children,g=x(e,X),C={mode:i,resolver:o,defaultValues:F,reValidateMode:s,shouldFocusError:u,shouldUnregister:d,shouldUseNativeValidation:c,criteriaMode:m,delayError:p};f&&!o&&(C.resolver=null==Y.getResolver?void 0:Y.getResolver(f));var S=t.useForm(C),N=S.handleSubmit;return v.useImperativeHandle(a,function(){return S},[a,S]),/*#__PURE__*/v.createElement(t.FormProvider,S,/*#__PURE__*/v.createElement(n.chakra.form,h({ref:E,onSubmit:N(b,y)},g,{className:r.cx("saas-form",e.className)}),_))});Y.getFieldResolver=Q,r.__DEV__&&(Y.displayName="Form");var Z=["children"],$=function(e){/*#__PURE__*/return v.createElement(n.chakra.div,null,e.children)};r.__DEV__&&($.displayName="FormLayoutItem");var ee=function(e){var t,a,l,i=e.children,o=x(e,Z),s=h({},null!=(t=null==(a=n.useTheme().components)||null==(l=a.FormLayout)?void 0:l.defaultProps)?t:{spacing:4},o);/*#__PURE__*/return v.createElement(n.SimpleGrid,h({},s,{className:r.cx("saas-form__layout",o.className)}),v.Children.map(i,function(e){return v.isValidElement(e)?/*#__PURE__*/v.createElement($,null,e):e}))};r.__DEV__&&(ee.displayName="FormLayout");var re=function(e,r){return v.Children.map(r,function(r){return v.isValidElement(r)&&r.props.name?v.cloneElement(r,h({},r.props,{name:e+"."+r.props.name})):r})},te=c.createContext({name:"ArrayFieldContext"}),ne=te[0],ae=te[1],le=c.createContext({name:"ArrayFieldRowContext"}),ie=le[0],oe=le[1],se=function(e){var r=e.name,n=e.defaultValue,a=void 0===n?{}:n,l=e.keyName,i=e.min,o=e.max,s=t.useFormContext();return h({},t.useFieldArray({control:s.control,name:r,keyName:l}),{name:r,defaultValue:a,min:i,max:o})},ue=function(e){var r=e.index,n=t.useFormContext().clearErrors,a=ae(),l=a.name,i=a.remove,o=a.fields;return v.useEffect(function(){n(l)},[]),{index:r,isFirst:0===r,isLast:r===o.length-1,name:l+"."+r,remove:v.useCallback(function(){n(l),i(r)},[r])}},de=function(){var e=oe(),r=e.isFirst,t=e.remove,n=ae(),a=n.min;return{onClick:function(){return t()},isDisabled:r&&!!(a&&n.fields.length<=a)}},ce=function(){var e=ae(),r=e.append,t=e.defaultValue,n=e.max;return{onClick:function(){return r(t,{shouldFocus:!1})},isDisabled:!!(n&&e.fields.length>=n)}},me=["children","index"],pe=["children"],fe=["children"],ve=["name","defaultValue","keyName","min","max","children"],he=function(e){var r=e.children,t=e.index,n=x(e,me);/*#__PURE__*/return v.createElement(Fe,{index:t},/*#__PURE__*/v.createElement(xe,n,r),/*#__PURE__*/v.createElement(be,null))};r.__DEV__&&(he.displayName="ArrayFieldRow");var xe=function(e){var r=e.children,t=x(e,pe),n=oe().name;/*#__PURE__*/return v.createElement(ee,h({flex:"1",mr:"2"},t),re(n,r))};r.__DEV__&&(xe.displayName="ArrayFieldRowFields");var Fe=function(e){var r=e.children,t=ue({index:e.index});/*#__PURE__*/return v.createElement(ie,{value:t},/*#__PURE__*/v.createElement(s.chakra.div,{__css:{display:"flex",flexDirection:"row",alignItems:"flex-end",width:"100%",mb:4}},r))};r.__DEV__&&(Fe.displayName="ArrayFieldRowContainer");var be=function(e){/*#__PURE__*/return v.createElement(d.IconButton,h({icon:/*#__PURE__*/v.createElement(u.MinusIcon,null),"aria-label":"Remove row"},de(),e))};r.__DEV__&&(be.displayName="ArrayFieldRemoveButton");var ye=function(e){/*#__PURE__*/return v.createElement(d.IconButton,h({icon:/*#__PURE__*/v.createElement(u.AddIcon,null),"aria-label":"Add row",float:"right"},ce(),e))};r.__DEV__&&(ye.displayName="ArrayFieldAddButton");var Ee=s.forwardRef(function(e,r){var t=e.children,n=x(e,fe);/*#__PURE__*/return v.createElement(ge,h({ref:r},n),/*#__PURE__*/v.createElement(_e,null,function(e){/*#__PURE__*/return v.createElement(v.Fragment,null,e.map(function(e,r){/*#__PURE__*/return v.createElement(he,{key:e.id,index:r},t)}))}),/*#__PURE__*/v.createElement(ye,null))});r.__DEV__&&(Ee.displayName="ArrayField");var _e=function(e){return(0,e.children)(ae().fields)};r.__DEV__&&(_e.displayName="ArrayFieldRows");var ge=v.forwardRef(function(e,r){var t=e.name,n=e.defaultValue,a=e.keyName,l=e.min,i=e.max,o=e.children,s=x(e,ve),u=se({name:t,defaultValue:n,keyName:a,min:l,max:i});return v.useImperativeHandle(r,function(){return u},[r,u]),/*#__PURE__*/v.createElement(ne,{value:u},/*#__PURE__*/v.createElement(k,h({name:t},s),o))});r.__DEV__&&(ge.displayName="ArrayFieldContainer");var Ce=["name","label","hideLabel","children","columns","spacing"],Se=function(e){var r=n.useStyleConfig("FormLegend");/*#__PURE__*/return v.createElement(n.FormLabel,h({as:"legend",sx:r},e))},Ne=function(e){var r=e.name,t=e.label,a=e.hideLabel,l=e.children,i=e.columns,o=e.spacing,s=x(e,Ce);/*#__PURE__*/return v.createElement(n.FormControl,h({name:r,as:"fieldset"},s),/*#__PURE__*/v.createElement(Se,{display:a?"none":"block"},t),/*#__PURE__*/v.createElement(ee,{columns:i,gridGap:o},re(r,l)))};r.__DEV__&&(Ne.displayName="ObjectField");var Re=["name","type"],Ve=["schema","fieldResolver","focusFirstField"],we=["name","type","defaultValue"],Ae=function(e,r){var t;return null==(t=e.getNestedFields(r))?void 0:t.map(function(e,r){var t=e.name,n=e.type,a=x(e,Re);/*#__PURE__*/return v.createElement(I,h({key:t||r,name:t,type:n},a))})},De=function(e){var r=e.schema,n=e.fieldResolver,a=e.focusFirstField,l=x(e,Ve),i=v.useMemo(function(){return n||Y.getFieldResolver(r)},[r,n]),o=v.useMemo(function(){return i.getFields()},[i]),s=t.useFormContext();return v.useEffect(function(){var e;a&&null!=(e=o[0])&&e.name&&s.setFocus(o[0].name)},[r,n,a]),/*#__PURE__*/v.createElement(ee,l,o.map(function(e){var r=e.name,t=e.type,n=x(e,we);return"array"===t?/*#__PURE__*/v.createElement(Ee,h({key:r,name:r},n),Ae(i,r)):"object"===t?/*#__PURE__*/v.createElement(Ne,h({key:r,name:r},n),Ae(i,r)):/*#__PURE__*/v.createElement(I,h({key:r,name:r,type:t},n))}))};r.__DEV__&&(De.displayName="Fields");var ke=["children","disableIfUntouched","disableIfInvalid","isDisabled","isLoading"],Ie=v.forwardRef(function(e,r){var n=e.children,a=e.disableIfUntouched,l=e.disableIfInvalid,i=e.isDisabled,o=e.isLoading,s=x(e,ke),u=t.useFormContext().formState;/*#__PURE__*/return v.createElement(d.Button,h({},s,{ref:r,variant:"primary",type:"submit",isLoading:u.isSubmitting||o,isDisabled:a&&!u.isDirty||l&&!u.isValid||i}),n)});Ie.defaultProps={label:"Submit",disableIfUntouched:!1,disableIfInvalid:!1},r.__DEV__&&(Ie.displayName="SubmitButton");var Le=["schema","submitLabel","fieldResolver","children"],Pe=n.forwardRef(function(e,r){var t=e.schema,n=e.submitLabel,a=void 0===n?"Submit":n,l=e.fieldResolver,i=e.children,o=x(e,Le);/*#__PURE__*/return v.createElement(Y,h({},o,{schema:t,ref:r}),/*#__PURE__*/v.createElement(ee,null,/*#__PURE__*/v.createElement(De,{schema:t,fieldResolver:l}),a&&/*#__PURE__*/v.createElement(Ie,null,a),i))});r.__DEV__&&(Pe.displayName="AutoForm");var Be=function(e){var r=e.children,n=e.condition;return(void 0===n?function(e){return!!e}:n)(t.useWatch({name:e.name,defaultValue:e.defaultValue,disabled:e.isDisabled,exact:e.isExact}),t.useFormContext())?r:null};r.__DEV__&&(Be.displayName="DisplayIf");var Oe=["onChange"],je=c.createContext({name:"StepFormContext",errorMessage:"useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"}),qe=je[0],Me=je[1];function Ue(e){var r=x(e,Oe),t=m.useStepper(r),n=t.activeStep,a=t.isLastStep,l=t.nextStep,i=v.useState({}),o=i[0],s=i[1],u=v.useCallback(function(r){var i;return Promise.resolve(function(s,u){try{var d=function(){function s(e){return i?e:Promise.resolve(null==u.onSubmit?void 0:u.onSubmit(r,t)).then(function(){l()})}var u=o[n],d=function(){if(a)return Promise.resolve(null==e.onSubmit?void 0:e.onSubmit(r)).then(function(){c(h({},u,{isCompleted:!0})),l(),i=1})}();return d&&d.then?d.then(s):s(d)}()}catch(e){return}return d&&d.then?d.then(void 0,function(){}):d}())},[o,n,a]),d=v.useCallback(function(){var e=o[n];return{onSubmit:u,schema:null==e?void 0:e.schema,resolver:null==e?void 0:e.resolver}},[o,u,n]),c=v.useCallback(function(e){s(function(r){var t;return h({},r,((t={})[e.name]=e,t))})},[o]);return h({getFormProps:d,updateStep:c,steps:o},t)}function Te(e){var r=e.name,t=e.schema,n=e.resolver,a=e.onSubmit,l=m.useStep({name:r}),i=Me(),o=i.steps,s=i.updateStep;return v.useEffect(function(){s({name:r,schema:t,resolver:n,onSubmit:a})},[r,t]),h({},l,o[r]||{name:r,schema:t})}var ze=["children"],He=["getFormProps"],Ge=["name","schema","resolver","children","className","onSubmit"],We=["label","submitLabel"],Je=v.forwardRef(function(e,t){var n=e.children,a=x(e,ze),l=Ue(e),i=l.getFormProps,o=x(l,He),s=v.useMemo(function(){return o},[o]);/*#__PURE__*/return v.createElement(m.StepperProvider,{value:s},/*#__PURE__*/v.createElement(qe,{value:s},/*#__PURE__*/v.createElement(Y,h({ref:t},a,i()),r.runIfFn(n,l))))}),Ke=function(e){var t=e.name,n=e.schema,a=e.resolver,l=e.children,i=e.className,o=e.onSubmit,u=x(e,Ge);return Te({name:t,schema:n,resolver:a,onSubmit:o}).isActive?/*#__PURE__*/v.createElement(s.chakra.div,h({},u,{className:r.cx("saas-form__step",i)}),l):null};r.__DEV__&&(Ke.displayName="FormStep");var Qe=function(e){var t=m.useStepperContext(),n=t.prevStep;/*#__PURE__*/return v.createElement(d.Button,h({isDisabled:t.isFirstStep||t.isCompleted,label:"Back"},e,{className:r.cx("saas-form__prev-button",e.className),onClick:r.callAllHandlers(e.onClick,n)}))};r.__DEV__&&(Qe.displayName="PrevButton");var Xe=function(e){var t=e.label,n=void 0===t?"Next":t,a=e.submitLabel,l=void 0===a?"Complete":a,i=x(e,We),o=m.useStepperContext(),s=o.isLastStep,u=o.isCompleted;/*#__PURE__*/return v.createElement(Ie,h({},i,{isDisabled:u,className:r.cx("saas-form__next-button",e.className)}),s||u?l:n)};r.__DEV__&&(Xe.displayName="NextButton"),exports.ArrayField=Ee,exports.ArrayFieldAddButton=ye,exports.ArrayFieldContainer=ge,exports.ArrayFieldProvider=ne,exports.ArrayFieldRemoveButton=be,exports.ArrayFieldRow=he,exports.ArrayFieldRowContainer=Fe,exports.ArrayFieldRowFields=xe,exports.ArrayFieldRowProvider=ie,exports.ArrayFieldRows=_e,exports.AutoForm=Pe,exports.BaseField=k,exports.CheckboxField=z,exports.DisplayField=b,exports.DisplayIf=Be,exports.Field=I,exports.Fields=De,exports.Form=Y,exports.FormLayout=ee,exports.FormLegend=Se,exports.FormStep=Ke,exports.FormStepper=function(e){var r=m.useStepperContext(),t=r.activeIndex,n=r.setIndex,a=e.orientation,l=v.Children.map(e.children,function(e){if(v.isValidElement(e)&&(null==e?void 0:e.type)===Ke){var r=Te(e.props);/*#__PURE__*/return v.createElement(m.StepperStep,{name:e.props.name,title:e.props.title,isCompleted:r.isCompleted},e.props.children)}return e}),i=v.useCallback(function(e){n(e)},[]);/*#__PURE__*/return v.createElement(m.StepperContainer,{orientation:a,step:t,onChange:i},/*#__PURE__*/v.createElement(m.StepperSteps,h({mb:"4"},e),l))},exports.FormValue=y,exports.InputField=O,exports.NativeSelectField=G,exports.NextButton=Xe,exports.NumberInputField=j,exports.ObjectField=Ne,exports.PasswordInputField=q,exports.PinField=W,exports.PrevButton=Qe,exports.RadioField=H,exports.SelectField=T,exports.StepForm=Je,exports.StepFormProvider=qe,exports.SubmitButton=Ie,exports.SwitchField=U,exports.TextareaField=M,exports.objectFieldResolver=Q,exports.registerFieldType=B,exports.useArrayField=se,exports.useArrayFieldAddButton=ce,exports.useArrayFieldContext=ae,exports.useArrayFieldRemoveButton=de,exports.useArrayFieldRow=ue,exports.useArrayFieldRowContext=oe,exports.useFormStep=Te,exports.useStepForm=Ue,exports.useStepFormContext=Me,exports.withControlledInput=L,exports.withUncontrolledInput=P,Object.keys(p).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return p[e]}})});
1
+ var e=require("react"),r=require("@chakra-ui/utils"),t=require("react-hook-form"),n=require("@chakra-ui/react"),a=require("@saas-ui/number-input"),l=require("@saas-ui/password-input"),o=require("@saas-ui/radio"),i=require("@saas-ui/select"),u=require("@chakra-ui/system"),s=require("@chakra-ui/icons"),d=require("@saas-ui/button"),c=require("@chakra-ui/react-utils"),m=require("@saas-ui/stepper"),p=require("@saas-ui/input-right-button");function f(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var v=/*#__PURE__*/f(e);function b(){return b=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},b.apply(this,arguments)}function x(e,r){if(null==e)return{};var t,n,a={},l=Object.keys(e);for(n=0;n<l.length;n++)r.indexOf(t=l[n])>=0||(a[t]=e[t]);return a}var h=["name","label","placeholder"],F=function(e){var r=e.name,t=e.label,a=x(e,h);/*#__PURE__*/return v.createElement(n.FormControl,a,t?/*#__PURE__*/v.createElement(n.FormLabel,{htmlFor:r},t):null,/*#__PURE__*/v.createElement(n.Text,{fontSize:"md"},/*#__PURE__*/v.createElement(y,{name:r})))};r.__DEV__&&(F.displayName="DisplayField");var y=function(e){var r=e.name;return(0,t.useFormContext().getValues)(r)||null};r.__DEV__&&(y.displayName="FormValue");var E=["name","label","help","hideLabel","children"],_=["id","name","label","help","isDisabled","isInvalid","isReadOnly","isRequired","rules"],g=["name","rules"],C=["ref"],S=["name","rules"],N=["ref"],R=["type","leftAddon","rightAddon","size"],V=["type"],w=["label","type"],A=["pinLength","pinType","spacing"],D={},k=function(e){var r=e.name,a=e.label,l=e.help,o=e.hideLabel,i=e.children,u=x(e,E),s=function(e,r){return t.get(r.errors,e)}(r,t.useFormContext().formState);/*#__PURE__*/return v.createElement(n.FormControl,b({},u,{isInvalid:!!s}),a&&!o?/*#__PURE__*/v.createElement(n.FormLabel,null,a):null,/*#__PURE__*/v.createElement(n.Box,null,i,!l||null!=s&&s.message?null:/*#__PURE__*/v.createElement(n.FormHelperText,null,l),(null==s?void 0:s.message)&&/*#__PURE__*/v.createElement(n.FormErrorMessage,null,null==s?void 0:s.message)))};r.__DEV__&&(k.displayName="BaseField");var I=v.forwardRef(function(e,r){var t=e.type;/*#__PURE__*/return v.createElement(D[void 0===t?"text":t]||D.text,b({ref:r},e))}),P=function(e){return n.forwardRef(function(r,a){var l=r.name,o=r.rules,i=x(r,g),u=t.useFormContext();/*#__PURE__*/return v.createElement(t.Controller,{name:l,control:u.control,rules:o,render:function(r){var t=r.field,l=t.ref,o=x(t,C);/*#__PURE__*/return v.createElement(e,b({},o,i,{ref:n.useMergeRefs(a,l)}))}})})},L=function(e){return n.forwardRef(function(r,a){var l=r.name,o=r.rules,i=x(r,S),u=(0,t.useFormContext().register)(l,o),s=u.ref,d=x(u,N);/*#__PURE__*/return v.createElement(e,b({},d,i,{ref:n.useMergeRefs(a,s)}))})},O=function(e,r,t){var a=function(e,r){var t=r.displayName,a=r.hideLabel,l=r.BaseField,o=n.forwardRef(function(r,t){var n=r.id,o=r.name,i=r.label,u=r.help,s=r.isDisabled,d=r.isInvalid,c=r.isReadOnly,m=r.isRequired,p=r.rules,f=x(r,_),h=b({required:m},p);/*#__PURE__*/return v.createElement(l,{id:n,name:o,label:i,help:u,hideLabel:a,isDisabled:s,isInvalid:d,isReadOnly:c,isRequired:m},/*#__PURE__*/v.createElement(e,b({ref:t,id:n,name:o,label:a?i:void 0,rules:h},f)))});return o.displayName=t,o}(null!=t&&t.isControlled?P(r):L(r),{displayName:e.split("-").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("")+"Field",hideLabel:null==t?void 0:t.hideLabel,BaseField:(null==t?void 0:t.BaseField)||k});return D[e]=a,a},j=O("text",n.forwardRef(function(e,r){var t=e.type,a=void 0===t?"text":t,l=e.leftAddon,o=e.rightAddon,i=e.size,u=x(e,R),s=/*#__PURE__*/v.createElement(n.Input,b({type:a,size:i},u,{ref:r}));return l||o?/*#__PURE__*/v.createElement(n.InputGroup,{size:i},l,s,o):s})),B=O("number",a.NumberInput,{isControlled:!0}),q=O("password",n.forwardRef(function(e,r){/*#__PURE__*/return v.createElement(l.PasswordInput,b({ref:r},e))})),M=O("textarea",n.Textarea),U=O("switch",n.forwardRef(function(e,r){var t=x(e,V);/*#__PURE__*/return v.createElement(n.Switch,b({},t,{ref:r}))}),{isControlled:!0}),T=O("select",i.Select,{isControlled:!0}),z=O("checkbox",n.forwardRef(function(e,r){var t=e.label,a=x(e,w);/*#__PURE__*/return v.createElement(n.Checkbox,b({ref:r},a),t)}),{hideLabel:!0}),H=O("radio",o.RadioInput,{isControlled:!0}),W=O("native-select",i.NativeSelect,{isControlled:!0}),G=O("pin",n.forwardRef(function(e,r){for(var t=e.pinLength,a=void 0===t?4:t,l=e.pinType,o=e.spacing,i=x(e,A),u=[],s=0;s<a;s++)u.push(/*#__PURE__*/v.createElement(n.PinInputField,{key:s,ref:r}));/*#__PURE__*/return v.createElement(n.HStack,{spacing:o},/*#__PURE__*/v.createElement(n.PinInput,b({},i,{type:l}),u))}),{isControlled:!0}),J=["items","label","title"],K=function(e){return e&&Object.entries(e).map(function(e){var r=e[0],t=e[1],n=t.label,a=t.title;return b({},x(t,J),{name:r,label:n||a})})},Q=function(e){return{getFields:function(){return K(e)},getNestedFields:function(t){var n,a=r.get(e,t);return a?"object"===(null==(n=a.items)?void 0:n.type)?K(a.items.properties):"object"===a.type?K(a.properties):[a.items]:[]}}},X=["mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","schema","defaultValues","onChange","onSubmit","onError","formRef","children"],Y=n.forwardRef(function(e,a){var l=e.mode,o=void 0===l?"all":l,i=e.resolver,u=e.reValidateMode,s=e.shouldFocusError,d=e.shouldUnregister,c=e.shouldUseNativeValidation,m=e.criteriaMode,p=e.delayError,f=e.schema,h=e.defaultValues,F=e.onChange,y=e.onSubmit,E=e.onError,_=e.formRef,g=e.children,C=x(e,X),S={mode:o,resolver:i,defaultValues:h,reValidateMode:u,shouldFocusError:s,shouldUnregister:d,shouldUseNativeValidation:c,criteriaMode:m,delayError:p};f&&!i&&(S.resolver=null==Y.getResolver?void 0:Y.getResolver(f));var N=t.useForm(S),R=N.handleSubmit;return v.useImperativeHandle(a,function(){return N},[a,N]),v.useEffect(function(){var e;return F&&(e=N.watch(F)),function(){var r;return null==(r=e)?void 0:r.unsubscribe()}},[N,F]),/*#__PURE__*/v.createElement(t.FormProvider,N,/*#__PURE__*/v.createElement(n.chakra.form,b({ref:_,onSubmit:R(y,E)},C,{className:r.cx("saas-form",e.className)}),r.runIfFn(g,N)))});Y.getFieldResolver=Q,r.__DEV__&&(Y.displayName="Form");var Z=["children"],$=function(e){/*#__PURE__*/return v.createElement(n.chakra.div,null,e.children)};r.__DEV__&&($.displayName="FormLayoutItem");var ee=function(e){var t,a,l,o=e.children,i=x(e,Z),u=b({},null!=(t=null==(a=n.useTheme().components)||null==(l=a.FormLayout)?void 0:l.defaultProps)?t:{spacing:4},i);/*#__PURE__*/return v.createElement(n.SimpleGrid,b({},u,{className:r.cx("saas-form__layout",i.className)}),v.Children.map(o,function(e){return v.isValidElement(e)?/*#__PURE__*/v.createElement($,null,e):e}))};r.__DEV__&&(ee.displayName="FormLayout");var re=function(e,r){return v.Children.map(r,function(r){return v.isValidElement(r)&&r.props.name?v.cloneElement(r,b({},r.props,{name:e+"."+r.props.name})):r})},te=c.createContext({name:"ArrayFieldContext"}),ne=te[0],ae=te[1],le=c.createContext({name:"ArrayFieldRowContext"}),oe=le[0],ie=le[1],ue=function(e){var r=e.name,n=e.defaultValue,a=void 0===n?{}:n,l=e.keyName,o=e.min,i=e.max,u=t.useFormContext();return b({},t.useFieldArray({control:u.control,name:r,keyName:l}),{name:r,defaultValue:a,min:o,max:i})},se=function(e){var r=e.index,n=t.useFormContext().clearErrors,a=ae(),l=a.name,o=a.remove,i=a.fields;return v.useEffect(function(){n(l)},[]),{index:r,isFirst:0===r,isLast:r===i.length-1,name:l+"."+r,remove:v.useCallback(function(){n(l),o(r)},[r])}},de=function(){var e=ie(),r=e.isFirst,t=e.remove,n=ae(),a=n.min;return{onClick:function(){return t()},isDisabled:r&&!!(a&&n.fields.length<=a)}},ce=function(){var e=ae(),r=e.append,t=e.defaultValue,n=e.max;return{onClick:function(){return r(t,{shouldFocus:!1})},isDisabled:!!(n&&e.fields.length>=n)}},me=["children","index"],pe=["children"],fe=["children"],ve=["name","defaultValue","keyName","min","max","children"],be=function(e){var r=e.children,t=e.index,n=x(e,me);/*#__PURE__*/return v.createElement(he,{index:t},/*#__PURE__*/v.createElement(xe,n,r),/*#__PURE__*/v.createElement(Fe,null))};r.__DEV__&&(be.displayName="ArrayFieldRow");var xe=function(e){var r=e.children,t=x(e,pe),n=ie().name;/*#__PURE__*/return v.createElement(ee,b({flex:"1",mr:"2"},t),re(n,r))};r.__DEV__&&(xe.displayName="ArrayFieldRowFields");var he=function(e){var r=e.children,t=se({index:e.index});/*#__PURE__*/return v.createElement(oe,{value:t},/*#__PURE__*/v.createElement(u.chakra.div,{__css:{display:"flex",flexDirection:"row",alignItems:"flex-end",width:"100%",mb:4}},r))};r.__DEV__&&(he.displayName="ArrayFieldRowContainer");var Fe=function(e){/*#__PURE__*/return v.createElement(d.IconButton,b({icon:/*#__PURE__*/v.createElement(s.MinusIcon,null),"aria-label":"Remove row"},de(),e))};r.__DEV__&&(Fe.displayName="ArrayFieldRemoveButton");var ye=function(e){/*#__PURE__*/return v.createElement(d.IconButton,b({icon:/*#__PURE__*/v.createElement(s.AddIcon,null),"aria-label":"Add row",float:"right"},ce(),e))};r.__DEV__&&(ye.displayName="ArrayFieldAddButton");var Ee=u.forwardRef(function(e,r){var t=e.children,n=x(e,fe);/*#__PURE__*/return v.createElement(ge,b({ref:r},n),/*#__PURE__*/v.createElement(_e,null,function(e){/*#__PURE__*/return v.createElement(v.Fragment,null,e.map(function(e,r){/*#__PURE__*/return v.createElement(be,{key:e.id,index:r},t)}))}),/*#__PURE__*/v.createElement(ye,null))});r.__DEV__&&(Ee.displayName="ArrayField");var _e=function(e){return(0,e.children)(ae().fields)};r.__DEV__&&(_e.displayName="ArrayFieldRows");var ge=v.forwardRef(function(e,r){var t=e.name,n=e.defaultValue,a=e.keyName,l=e.min,o=e.max,i=e.children,u=x(e,ve),s=ue({name:t,defaultValue:n,keyName:a,min:l,max:o});return v.useImperativeHandle(r,function(){return s},[r,s]),/*#__PURE__*/v.createElement(ne,{value:s},/*#__PURE__*/v.createElement(k,b({name:t},u),i))});r.__DEV__&&(ge.displayName="ArrayFieldContainer");var Ce=["name","label","hideLabel","children","columns","spacing"],Se=function(e){var r=n.useStyleConfig("FormLegend");/*#__PURE__*/return v.createElement(n.FormLabel,b({as:"legend",sx:r},e))},Ne=function(e){var r=e.name,t=e.label,a=e.hideLabel,l=e.children,o=e.columns,i=e.spacing,u=x(e,Ce);/*#__PURE__*/return v.createElement(n.FormControl,b({name:r,as:"fieldset"},u),/*#__PURE__*/v.createElement(Se,{display:a?"none":"block"},t),/*#__PURE__*/v.createElement(ee,{columns:o,gridGap:i},re(r,l)))};r.__DEV__&&(Ne.displayName="ObjectField");var Re=["name","type"],Ve=["schema","fieldResolver","focusFirstField"],we=["name","type","defaultValue"],Ae=function(e,r){var t;return null==(t=e.getNestedFields(r))?void 0:t.map(function(e,r){var t=e.name,n=e.type,a=x(e,Re);/*#__PURE__*/return v.createElement(I,b({key:t||r,name:t,type:n},a))})},De=function(e){var r=e.schema,n=e.fieldResolver,a=e.focusFirstField,l=x(e,Ve),o=v.useMemo(function(){return n||Y.getFieldResolver(r)},[r,n]),i=v.useMemo(function(){return o.getFields()},[o]),u=t.useFormContext();return v.useEffect(function(){var e;a&&null!=(e=i[0])&&e.name&&u.setFocus(i[0].name)},[r,n,a]),/*#__PURE__*/v.createElement(ee,l,i.map(function(e){var r=e.name,t=e.type,n=x(e,we);return"array"===t?/*#__PURE__*/v.createElement(Ee,b({key:r,name:r},n),Ae(o,r)):"object"===t?/*#__PURE__*/v.createElement(Ne,b({key:r,name:r},n),Ae(o,r)):/*#__PURE__*/v.createElement(I,b({key:r,name:r,type:t},n))}))};r.__DEV__&&(De.displayName="Fields");var ke=["children","disableIfUntouched","disableIfInvalid","isDisabled","isLoading"],Ie=v.forwardRef(function(e,r){var n=e.children,a=e.disableIfUntouched,l=e.disableIfInvalid,o=e.isDisabled,i=e.isLoading,u=x(e,ke),s=t.useFormContext().formState;/*#__PURE__*/return v.createElement(d.Button,b({},u,{ref:r,variant:"primary",type:"submit",isLoading:s.isSubmitting||i,isDisabled:a&&!s.isDirty||l&&!s.isValid||o}),n)});Ie.defaultProps={label:"Submit",disableIfUntouched:!1,disableIfInvalid:!1},r.__DEV__&&(Ie.displayName="SubmitButton");var Pe=["schema","submitLabel","fieldResolver","children"],Le=n.forwardRef(function(e,r){var t=e.schema,n=e.submitLabel,a=void 0===n?"Submit":n,l=e.fieldResolver,o=e.children,i=x(e,Pe);/*#__PURE__*/return v.createElement(Y,b({},i,{schema:t,ref:r}),/*#__PURE__*/v.createElement(ee,null,/*#__PURE__*/v.createElement(De,{schema:t,fieldResolver:l}),a&&/*#__PURE__*/v.createElement(Ie,null,a),o))});r.__DEV__&&(Le.displayName="AutoForm");var Oe=function(e){var r=e.children,n=e.condition;return(void 0===n?function(e){return!!e}:n)(t.useWatch({name:e.name,defaultValue:e.defaultValue,disabled:e.isDisabled,exact:e.isExact}),t.useFormContext())?r:null};r.__DEV__&&(Oe.displayName="DisplayIf");var je=["onChange"],Be=c.createContext({name:"StepFormContext",errorMessage:"useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"}),qe=Be[0],Me=Be[1];function Ue(e){var r=x(e,je),t=m.useStepper(r),n=t.activeStep,a=t.isLastStep,l=t.nextStep,o=v.useState({}),i=o[0],u=o[1],s=v.useCallback(function(r){var o;return Promise.resolve(function(u,s){try{var d=function(){function u(e){return o?e:Promise.resolve(null==s.onSubmit?void 0:s.onSubmit(r,t)).then(function(){l()})}var s=i[n],d=function(){if(a)return Promise.resolve(null==e.onSubmit?void 0:e.onSubmit(r)).then(function(){c(b({},s,{isCompleted:!0})),l(),o=1})}();return d&&d.then?d.then(u):u(d)}()}catch(e){return}return d&&d.then?d.then(void 0,function(){}):d}())},[i,n,a]),d=v.useCallback(function(){var e=i[n];return{onSubmit:s,schema:null==e?void 0:e.schema,resolver:null==e?void 0:e.resolver}},[i,s,n]),c=v.useCallback(function(e){u(function(r){var t;return b({},r,((t={})[e.name]=e,t))})},[i]);return b({getFormProps:d,updateStep:c,steps:i},t)}function Te(e){var r=e.name,t=e.schema,n=e.resolver,a=e.onSubmit,l=m.useStep({name:r}),o=Me(),i=o.steps,u=o.updateStep;return v.useEffect(function(){u({name:r,schema:t,resolver:n,onSubmit:a})},[r,t]),b({},l,i[r]||{name:r,schema:t})}var ze=["children"],He=["getFormProps"],We=["name","schema","resolver","children","className","onSubmit"],Ge=["label","submitLabel"],Je=v.forwardRef(function(e,t){var n=e.children,a=x(e,ze),l=Ue(e),o=l.getFormProps,i=x(l,He),u=v.useMemo(function(){return i},[i]);/*#__PURE__*/return v.createElement(m.StepperProvider,{value:u},/*#__PURE__*/v.createElement(qe,{value:u},/*#__PURE__*/v.createElement(Y,b({ref:t},a,o()),r.runIfFn(n,l))))}),Ke=function(e){var t=e.name,n=e.schema,a=e.resolver,l=e.children,o=e.className,i=e.onSubmit,s=x(e,We);return Te({name:t,schema:n,resolver:a,onSubmit:i}).isActive?/*#__PURE__*/v.createElement(u.chakra.div,b({},s,{className:r.cx("saas-form__step",o)}),l):null};r.__DEV__&&(Ke.displayName="FormStep");var Qe=function(e){var t=m.useStepperContext(),n=t.prevStep;/*#__PURE__*/return v.createElement(d.Button,b({isDisabled:t.isFirstStep||t.isCompleted,label:"Back"},e,{className:r.cx("saas-form__prev-button",e.className),onClick:r.callAllHandlers(e.onClick,n)}))};r.__DEV__&&(Qe.displayName="PrevButton");var Xe=function(e){var t=e.label,n=void 0===t?"Next":t,a=e.submitLabel,l=void 0===a?"Complete":a,o=x(e,Ge),i=m.useStepperContext(),u=i.isLastStep,s=i.isCompleted;/*#__PURE__*/return v.createElement(Ie,b({},o,{isDisabled:s,className:r.cx("saas-form__next-button",e.className)}),u||s?l:n)};r.__DEV__&&(Xe.displayName="NextButton"),Object.defineProperty(exports,"Controller",{enumerable:!0,get:function(){return t.Controller}}),Object.defineProperty(exports,"FormProvider",{enumerable:!0,get:function(){return t.FormProvider}}),Object.defineProperty(exports,"appendErrors",{enumerable:!0,get:function(){return t.appendErrors}}),Object.defineProperty(exports,"useController",{enumerable:!0,get:function(){return t.useController}}),Object.defineProperty(exports,"useFieldArray",{enumerable:!0,get:function(){return t.useFieldArray}}),Object.defineProperty(exports,"useForm",{enumerable:!0,get:function(){return t.useForm}}),Object.defineProperty(exports,"useFormContext",{enumerable:!0,get:function(){return t.useFormContext}}),Object.defineProperty(exports,"useFormState",{enumerable:!0,get:function(){return t.useFormState}}),Object.defineProperty(exports,"useWatch",{enumerable:!0,get:function(){return t.useWatch}}),exports.ArrayField=Ee,exports.ArrayFieldAddButton=ye,exports.ArrayFieldContainer=ge,exports.ArrayFieldProvider=ne,exports.ArrayFieldRemoveButton=Fe,exports.ArrayFieldRow=be,exports.ArrayFieldRowContainer=he,exports.ArrayFieldRowFields=xe,exports.ArrayFieldRowProvider=oe,exports.ArrayFieldRows=_e,exports.AutoForm=Le,exports.BaseField=k,exports.CheckboxField=z,exports.DisplayField=F,exports.DisplayIf=Oe,exports.Field=I,exports.Fields=De,exports.Form=Y,exports.FormLayout=ee,exports.FormLegend=Se,exports.FormStep=Ke,exports.FormStepper=function(e){var r=m.useStepperContext(),t=r.activeIndex,n=r.setIndex,a=e.orientation,l=v.Children.map(e.children,function(e){if(v.isValidElement(e)&&(null==e?void 0:e.type)===Ke){var r=Te(e.props);/*#__PURE__*/return v.createElement(m.StepperStep,{name:e.props.name,title:e.props.title,isCompleted:r.isCompleted},e.props.children)}return e}),o=v.useCallback(function(e){n(e)},[]);/*#__PURE__*/return v.createElement(m.StepperContainer,{orientation:a,step:t,onChange:o},/*#__PURE__*/v.createElement(m.StepperSteps,b({mb:"4"},e),l))},exports.FormValue=y,exports.InputField=j,exports.NativeSelectField=W,exports.NextButton=Xe,exports.NumberInputField=B,exports.ObjectField=Ne,exports.PasswordInputField=q,exports.PinField=G,exports.PrevButton=Qe,exports.RadioField=H,exports.SelectField=T,exports.StepForm=Je,exports.StepFormProvider=qe,exports.SubmitButton=Ie,exports.SwitchField=U,exports.TextareaField=M,exports.WatchField=function(e){var r=e.name,n=e.defaultValue,a=e.isDisabled,l=e.isExact,o=t.useFormContext(),i=t.useWatch({name:r,defaultValue:n,disabled:a,exact:l});return e.children(i,o)||null},exports.objectFieldResolver=Q,exports.registerFieldType=O,exports.useArrayField=ue,exports.useArrayFieldAddButton=ce,exports.useArrayFieldContext=ae,exports.useArrayFieldRemoveButton=de,exports.useArrayFieldRow=se,exports.useArrayFieldRowContext=ie,exports.useFormStep=Te,exports.useStepForm=Ue,exports.useStepFormContext=Me,exports.withControlledInput=P,exports.withUncontrolledInput=L,Object.keys(p).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return p[e]}})});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/display-field.tsx","../src/field.tsx","../src/field-resolver.ts","../src/form.tsx","../src/layout.tsx","../src/utils.ts","../src/use-array-field.tsx","../src/array-field.tsx","../src/object-field.tsx","../src/fields.tsx","../src/submit-button.tsx","../src/auto-form.tsx","../src/display-if.tsx","../src/use-step-form.tsx","../src/step-form.tsx"],"sourcesContent":["import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { useFormContext } from 'react-hook-form'\n\nimport {\n Text,\n FormControl,\n FormControlProps,\n FormLabel,\n} from '@chakra-ui/react'\n\nimport { FieldProps } from './field'\n\nexport interface DisplayFieldProps\n extends FormControlProps,\n Omit<FieldProps, 'type' | 'label'> {}\n\nexport const DisplayField: React.FC<DisplayFieldProps> = ({\n name,\n label,\n placeholder,\n ...props\n}) => {\n return (\n <FormControl {...props}>\n {label ? <FormLabel htmlFor={name}>{label}</FormLabel> : null}\n <Text fontSize=\"md\">\n <FormValue name={name} />\n </Text>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n DisplayField.displayName = 'DisplayField'\n}\n\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\n}\n\nif (__DEV__) {\n FormValue.displayName = 'FormValue'\n}\n","import * as React from 'react'\nimport {\n useFormContext,\n FormState,\n Controller,\n get,\n RegisterOptions,\n FieldValues,\n FieldPath,\n} from 'react-hook-form'\n\nimport {\n forwardRef,\n Box,\n FormControl,\n FormControlProps,\n FormLabel,\n FormHelperText,\n FormErrorMessage,\n Input,\n Textarea,\n Checkbox,\n Switch,\n useMergeRefs,\n InputGroup,\n InputProps,\n TextareaProps,\n SwitchProps,\n CheckboxProps,\n PinInputField,\n HStack,\n PinInput,\n UsePinInputProps,\n SystemProps,\n} from '@chakra-ui/react'\nimport { __DEV__, FocusableElement } from '@chakra-ui/utils'\n\nimport { NumberInput, NumberInputProps } from '@saas-ui/number-input'\nimport { PasswordInput, PasswordInputProps } from '@saas-ui/password-input'\nimport { RadioInput, RadioInputProps } from '@saas-ui/radio'\n\nimport {\n Select,\n SelectProps,\n NativeSelect,\n NativeSelectProps,\n} from '@saas-ui/select'\n\nexport interface Option {\n value: string\n label?: string\n [key: string]: unknown\n}\n\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength' | 'pattern'\n>\n\nexport interface FieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<FormControlProps, 'label' | 'type'> {\n /**\n * The field name\n */\n name: TName\n /**\n * The field label\n */\n label?: string\n /**\n * Hide the field label\n */\n hideLabel?: boolean\n /**\n * Field help text\n */\n help?: string\n /**\n * React hook form rules\n */\n rules?: Omit<\n RegisterOptions<TFieldValues, TName>,\n 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'\n >\n /**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\n type?: string\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<string, React.FC<any>> = {}\n\nconst defaultInputType = 'text'\n\nconst getInput = (type: string) => {\n return inputTypes[type] || inputTypes[defaultInputType]\n}\n\nconst getError = (name: string, formState: FormState<{ [x: string]: any }>) => {\n return get(formState.errors, name)\n}\n\nconst isTouched = (\n name: string,\n formState: FormState<{ [x: string]: any }>\n) => {\n return get(formState.touchedFields, name)\n}\n\nexport const BaseField: React.FC<FieldProps> = (props) => {\n const { name, label, help, variant, hideLabel, children, ...controlProps } =\n props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl variant={variant} {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? (\n <FormLabel variant={variant}>{label}</FormLabel>\n ) : null}\n <Box>\n {children}\n {help && !error?.message ? (\n <FormHelperText>{help}</FormHelperText>\n ) : null}\n {error?.message && (\n <FormErrorMessage>{error?.message}</FormErrorMessage>\n )}\n </Box>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n BaseField.displayName = 'BaseField'\n}\n\nexport type As<Props = any> = React.ElementType<Props>\n\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n type?: FieldTypes\n}\n\n/**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\nexport const Field = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> | FieldTypeProps,\n ref: React.ForwardedRef<FocusableElement>\n ) => {\n const { type = defaultInputType } = props\n const InputComponent = getInput(type)\n\n return <InputComponent ref={ref} {...props} />\n }\n) as (<TFieldValues extends FieldValues>(\n props: FieldProps<TFieldValues> &\n FieldTypeProps & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n}\n\ninterface CreateFieldProps {\n displayName: string\n hideLabel?: boolean\n BaseField: React.FC<any>\n}\n\nconst createField = (\n InputComponent: React.FC<any>,\n { displayName, hideLabel, BaseField }: CreateFieldProps\n) => {\n const Field = forwardRef((props, ref) => {\n const {\n id,\n name,\n label,\n help,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n rules,\n variant,\n ...inputProps\n } = props\n\n const inputRules = {\n required: isRequired,\n ...rules,\n }\n\n return (\n <BaseField\n id={id}\n name={name}\n label={label}\n help={help}\n hideLabel={hideLabel}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n variant={variant}\n >\n <InputComponent\n ref={ref}\n id={id}\n name={name}\n label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { control } = useFormContext()\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { ref: _ref, ...field } }) => (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )}\n />\n )\n }\n )\n}\n\nexport const withUncontrolledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { register } = useFormContext()\n\n const { ref: _ref, ...field } = register(name, rules)\n\n return (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )\n }\n )\n}\n\nexport interface RegisterFieldTypeOptions {\n isControlled?: boolean\n hideLabel?: boolean\n BaseField?: React.FC<any>\n}\n\n/**\n * Register a new field type\n * @param type The name for this field in kebab-case, eg `email` or `array-field`\n * @param component The React component\n * @param options\n * @param options.isControlled Set this to true if this is a controlled field.\n * @param options.hideLabel Hide the field label, for example for the checkbox field.\n */\nexport const registerFieldType = <T extends object>(\n type: string,\n component: React.FC<T>,\n options?: RegisterFieldTypeOptions\n) => {\n let InputComponent\n if (options?.isControlled) {\n InputComponent = withControlledInput(component)\n } else {\n InputComponent = withUncontrolledInput(component)\n }\n\n const Field = createField(InputComponent, {\n displayName: `${type\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')}Field`,\n hideLabel: options?.hideLabel,\n BaseField: options?.BaseField || BaseField,\n }) as React.FC<T & FieldProps>\n\n inputTypes[type] = Field\n\n return Field\n}\n\nexport interface InputFieldProps extends InputProps {\n type?: string\n leftAddon?: React.ReactNode\n rightAddon?: React.ReactNode\n}\n\nexport const InputField = registerFieldType<InputFieldProps>(\n 'text',\n forwardRef(({ type = 'text', leftAddon, rightAddon, size, ...rest }, ref) => {\n const input = <Input type={type} size={size} {...rest} ref={ref} />\n if (leftAddon || rightAddon) {\n return (\n <InputGroup size={size}>\n {leftAddon}\n {input}\n {rightAddon}\n </InputGroup>\n )\n }\n return input\n })\n)\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n type: 'number'\n}\n\nexport const NumberInputField = registerFieldType<NumberInputFieldProps>(\n 'number',\n NumberInput,\n {\n isControlled: true,\n }\n)\n\nexport const PasswordInputField = registerFieldType<PasswordInputProps>(\n 'password',\n forwardRef((props, ref) => <PasswordInput ref={ref} {...props} />)\n)\n\nexport const TextareaField = registerFieldType<TextareaProps>(\n 'textarea',\n Textarea\n)\n\nexport const SwitchField = registerFieldType<SwitchProps>(\n 'switch',\n forwardRef(({ type, ...rest }, ref) => {\n return <Switch {...rest} ref={ref} />\n }),\n {\n isControlled: true,\n }\n)\n\nexport const SelectField = registerFieldType<SelectProps>('select', Select, {\n isControlled: true,\n})\n\nexport const CheckboxField = registerFieldType<CheckboxProps>(\n 'checkbox',\n forwardRef(({ label, type, ...props }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\n\nexport const RadioField = registerFieldType<RadioInputProps>(\n 'radio',\n RadioInput,\n {\n isControlled: true,\n }\n)\n\nexport const NativeSelectField = registerFieldType<NativeSelectProps>(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\n\nexport interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {\n pinLength?: number\n pinType?: 'alphanumeric' | 'number'\n spacing?: SystemProps['margin']\n}\n\nexport const PinField = registerFieldType<PinFieldProps>(\n 'pin',\n forwardRef((props, ref) => {\n const { pinLength = 4, pinType, spacing, ...inputProps } = props\n\n const inputs: React.ReactNode[] = []\n for (let i = 0; i < pinLength; i++) {\n inputs.push(<PinInputField key={i} ref={ref} />)\n }\n\n return (\n <HStack spacing={spacing}>\n <PinInput {...inputProps} type={pinType}>\n {inputs}\n </PinInput>\n </HStack>\n )\n }),\n {\n isControlled: true,\n }\n)\n\nconst fieldTypes = {\n text: InputField,\n email: InputField,\n url: InputField,\n phone: InputField,\n number: NumberInputField,\n password: PasswordInputField,\n textarea: TextareaField,\n switch: SwitchField,\n checkbox: CheckboxField,\n radio: RadioField,\n pin: PinField,\n select: SelectField,\n 'native-select': NativeSelectField,\n}\n\ntype FieldTypes = typeof fieldTypes\n\ntype FieldType<Props = any> = React.ElementType<Props>\n\ntype TypeProps<P extends FieldType, T> = React.ComponentPropsWithoutRef<P> & {\n type: T\n}\n\ntype FieldTypeProps =\n | {\n [Property in keyof FieldTypes]: TypeProps<FieldTypes[Property], Property>\n }[keyof FieldTypes]\n | { type?: string }\n","import { FieldProps } from './field'\n\nimport { get } from '@chakra-ui/utils'\n\nexport type FieldResolver = {\n getFields(): FieldProps[]\n getNestedFields(name: string): FieldProps[]\n}\n\ninterface SchemaField extends FieldProps {\n items?: SchemaField[]\n properties?: Record<string, SchemaField>\n}\n\nexport type ObjectSchema = Record<string, SchemaField>\n\nconst mapFields = (schema: ObjectSchema): FieldProps[] =>\n schema &&\n Object.entries(schema).map(([name, { items, label, title, ...field }]) => {\n return {\n ...field,\n name,\n label: label || title, // json schema compatibility\n }\n })\n\nexport const objectFieldResolver = (schema: ObjectSchema): FieldResolver => {\n const getFields = () => {\n return mapFields(schema)\n }\n const getNestedFields = (name: string) => {\n const field = get(schema, name)\n\n if (!field) return []\n\n if (field.items?.type === 'object') {\n return mapFields(field.items.properties)\n } else if (field.type === 'object') {\n return mapFields(field.properties)\n }\n return [field.items]\n }\n\n return { getFields, getNestedFields }\n}\n","import * as React from 'react'\n\nimport { chakra, HTMLChakraProps, forwardRef } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n ResolverOptions,\n ResolverResult,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\n\nexport type { UseFormReturn, FieldValues, SubmitHandler }\n\ninterface FormOptions<TFieldValues extends FieldValues = FieldValues> {\n /**\n * The form schema, currently supports Yup schema only.\n */\n schema?: any\n /**\n * The submit handler.\n */\n onSubmit: SubmitHandler<TFieldValues>\n /**\n * Triggers when there are validation errors.\n */\n onError?: SubmitErrorHandler<TFieldValues>\n /**\n * Ref on the HTMLFormElement.\n */\n formRef?: React.RefObject<HTMLFormElement>\n}\n\n/**\n * @todo Figure out how to pass down FieldValues to all Field components,\n * if at all possible.\n */\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<HTMLChakraProps<'form'>, 'onSubmit' | 'onError'>,\n FormOptions<TFieldValues> {}\n\nexport const Form = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n mode = 'all',\n resolver,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n schema,\n defaultValues,\n onSubmit,\n onError,\n formRef,\n children,\n ...rest\n } = props\n\n const form = {\n mode,\n resolver,\n defaultValues,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n }\n\n if (schema && !resolver) {\n form.resolver = Form.getResolver?.(schema)\n }\n\n const methods = useForm<TFieldValues>(form)\n const { handleSubmit } = methods\n\n // This exposes the useForm api through the forwarded ref\n React.useImperativeHandle(ref, () => methods, [ref, methods])\n\n return (\n <FormProvider {...methods}>\n <chakra.form\n ref={formRef}\n onSubmit={handleSubmit(onSubmit, onError)}\n {...rest}\n className={cx('saas-form', props.className)}\n >\n {children}\n </chakra.form>\n </FormProvider>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: FormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nif (__DEV__) {\n Form.displayName = 'Form'\n}\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: TFieldValues,\n context: TContext | undefined,\n options: ResolverOptions<TFieldValues>\n) => Promise<ResolverResult<TFieldValues>>\n\nexport type GetFieldResolver = (schema: any) => FieldResolver\n","import * as React from 'react'\n\nimport { chakra, SimpleGrid, SimpleGridProps, useTheme } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nexport type FormLayoutProps = SimpleGridProps\n\ninterface FormLayoutItemProps {\n children: React.ReactNode\n}\n\nconst FormLayoutItem: React.FC<FormLayoutItemProps> = ({ children }) => {\n return <chakra.div>{children}</chakra.div>\n}\n\nif (__DEV__) {\n FormLayoutItem.displayName = 'FormLayoutItem'\n}\n\n/**\n * FormLayout\n *\n * Renders form items in a `SimpleGrid`\n * @see https://chakra-ui.com/docs/layout/simple-grid\n */\nexport const FormLayout = ({ children, ...props }: FormLayoutProps) => {\n const theme = useTheme()\n\n const defaultProps = theme.components?.FormLayout?.defaultProps ?? {\n spacing: 4,\n }\n\n const gridProps = {\n ...defaultProps,\n ...props,\n }\n\n return (\n <SimpleGrid\n {...gridProps}\n className={cx('saas-form__layout', props.className)}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return <FormLayoutItem>{child}</FormLayoutItem>\n }\n return child\n })}\n </SimpleGrid>\n )\n}\n\nif (__DEV__) {\n FormLayout.displayName = 'FormLayout'\n}\n","import * as React from 'react'\n\nexport const mapNestedFields = (name: string, children: React.ReactNode) => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.props.name) {\n return React.cloneElement(child, {\n ...child.props,\n name: `${name}.${child.props.name}`,\n })\n }\n return child\n })\n}\n","import * as React from 'react'\nimport {\n useFieldArray,\n useFormContext,\n UseFieldArrayReturn,\n} from 'react-hook-form'\n\nimport { createContext } from '@chakra-ui/react-utils'\n\nexport interface UseArrayFieldReturn extends UseFieldArrayReturn {\n /**\n * The array field name\n */\n name: string\n /**\n * The default value for new items\n */\n defaultValue: Record<string, any>\n /**\n * Min amount of items\n */\n min?: number\n /**\n * Max amount of items\n */\n max?: number\n}\n\nexport const [ArrayFieldProvider, useArrayFieldContext] =\n createContext<UseArrayFieldReturn>({\n name: 'ArrayFieldContext',\n })\n\nexport interface UseArrayFieldRowReturn {\n /**\n * Name of the array field including the index, eg 'field.0'\n */\n name: string\n /**\n * The field index\n */\n index: number\n /**\n * Remove this array item\n */\n remove: () => void\n /**\n * True if this is the first item\n */\n isFirst: boolean\n /**\n * True if this is the last item\n */\n isLast: boolean\n}\n\nexport const [ArrayFieldRowProvider, useArrayFieldRowContext] =\n createContext<UseArrayFieldRowReturn>({\n name: 'ArrayFieldRowContext',\n })\n\nexport interface ArrayFieldOptions {\n /**\n * The field name\n */\n name: string\n /**\n * Default value for new values in the array\n */\n defaultValue?: Record<string, any>\n /**\n * Default key name for rows, change this if your data uses a different 'id' field\n * @default \"id\"\n */\n keyName?: string\n min?: number\n max?: number\n}\n\nexport const useArrayField = ({\n name,\n defaultValue = {},\n keyName,\n min,\n max,\n}: ArrayFieldOptions) => {\n const { control } = useFormContext()\n const context = useFieldArray({\n control,\n name,\n keyName,\n })\n\n return {\n ...context,\n name,\n defaultValue,\n min,\n max,\n }\n}\n\nexport interface UseArrayFieldRowProps {\n index: number\n}\n\nexport const useArrayFieldRow = ({ index }: UseArrayFieldRowProps) => {\n const { clearErrors } = useFormContext()\n const { name, remove, fields } = useArrayFieldContext()\n\n React.useEffect(() => {\n // reset errors, to make sure min/max errors reset correctly\n clearErrors(name)\n }, [])\n\n return {\n index,\n isFirst: index === 0,\n isLast: index === fields.length - 1,\n name: `${name}.${index}`,\n remove: React.useCallback(() => {\n clearErrors(name)\n remove(index)\n }, [index]),\n }\n}\n\nexport const useArrayFieldRemoveButton = () => {\n const { isFirst, remove } = useArrayFieldRowContext()\n const { min, fields } = useArrayFieldContext()\n\n const isDisabled = isFirst && !!(min && fields.length <= min)\n\n return {\n onClick: () => remove(),\n isDisabled,\n }\n}\n\nexport const useArrayFieldAddButton = () => {\n const { append, defaultValue, max, fields } = useArrayFieldContext()\n\n const isDisabled = !!(max && fields.length >= max)\n\n return {\n onClick: () =>\n append(defaultValue, {\n shouldFocus: false,\n }),\n isDisabled,\n }\n}\n","import * as React from 'react'\n\nimport { chakra, ResponsiveValue, forwardRef } from '@chakra-ui/system'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout, FormLayoutProps } from './layout'\nimport { BaseField, FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nimport {\n useArrayField,\n useArrayFieldRow,\n useArrayFieldContext,\n ArrayFieldProvider,\n ArrayFieldOptions,\n ArrayFieldRowProvider,\n useArrayFieldRowContext,\n useArrayFieldRemoveButton,\n useArrayFieldAddButton,\n UseArrayFieldReturn,\n} from './use-array-field'\n\ninterface ArrayField {\n id: string\n [key: string]: unknown\n}\n\ninterface ArrayFieldRowProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The array index\n */\n index: number\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n ...rowFieldsProps\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields {...rowFieldsProps}>{children}</ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout flex=\"1\" mr=\"2\" {...layoutProps}>\n {mapNestedFields(name, children)}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowFields.displayName = 'ArrayFieldRowFields'\n}\n\nexport const ArrayFieldRowContainer: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n}) => {\n const context = useArrayFieldRow({ index })\n\n const styles = {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'flex-end',\n width: '100%',\n mb: 4,\n }\n\n return (\n <ArrayFieldRowProvider value={context}>\n <chakra.div __css={styles}>{children}</chakra.div>\n </ArrayFieldRowProvider>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowContainer.displayName = 'ArrayFieldRowContainer'\n}\n\nexport const ArrayFieldRemoveButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<MinusIcon />}\n aria-label=\"Remove row\"\n {...useArrayFieldRemoveButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldRemoveButton.displayName = 'ArrayFieldRemoveButton'\n}\n\nexport const ArrayFieldAddButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<AddIcon />}\n aria-label=\"Add row\"\n float=\"right\"\n {...useArrayFieldAddButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldAddButton.displayName = 'ArrayFieldAddButton'\n}\n\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = forwardRef(\n (props: ArrayFieldProps, ref: React.ForwardedRef<UseArrayFieldReturn>) => {\n const { children, ...containerProps } = props\n\n return (\n <ArrayFieldContainer ref={ref} {...containerProps}>\n <ArrayFieldRows>\n {(fields: ArrayField[]) => (\n <>\n {fields.map(({ id }, index: number) => (\n <ArrayFieldRow key={id} index={index}>\n {children}\n </ArrayFieldRow>\n ))}\n </>\n )}\n </ArrayFieldRows>\n <ArrayFieldAddButton />\n </ArrayFieldContainer>\n )\n }\n) as ((\n props: ArrayFieldProps & {\n ref?: React.ForwardedRef<UseArrayFieldReturn>\n }\n) => React.ReactElement) & {\n displayName: string\n}\n\nif (__DEV__) {\n ArrayField.displayName = 'ArrayField'\n}\n\nexport interface ArrayFieldRowsProps {\n children: (fields: ArrayField[]) => React.ReactElement | null\n}\n\nexport const ArrayFieldRows = ({\n children,\n}: ArrayFieldRowsProps): React.ReactElement | null => {\n const { fields } = useArrayFieldContext()\n return children(fields)\n}\n\nif (__DEV__) {\n ArrayFieldRows.displayName = 'ArrayFieldRows'\n}\n\nexport const ArrayFieldContainer = React.forwardRef(\n (\n {\n name,\n defaultValue,\n keyName,\n min,\n max,\n children,\n ...fieldProps\n }: ArrayFieldProps,\n ref: React.ForwardedRef<UseArrayFieldReturn>\n ) => {\n const context = useArrayField({\n name,\n defaultValue,\n keyName,\n min,\n max,\n })\n\n // This exposes the useArrayField api through the forwarded ref\n React.useImperativeHandle(ref, () => context, [ref, context])\n\n return (\n <ArrayFieldProvider value={context}>\n <BaseField name={name} {...fieldProps}>\n {children}\n </BaseField>\n </ArrayFieldProvider>\n )\n }\n)\n\nif (__DEV__) {\n ArrayFieldContainer.displayName = 'ArrayFieldContainer'\n}\n","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyleConfig,\n} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { FormLayout } from './layout'\nimport { FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nexport interface ObjectFieldProps extends FieldProps {\n name: string\n children: React.ReactNode\n columns?: ResponsiveValue<number>\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const FormLegend = (props: FormLabelProps) => {\n const styles = useStyleConfig('FormLegend')\n return <FormLabel as=\"legend\" sx={styles} {...props} />\n}\n\nexport const ObjectField: React.FC<ObjectFieldProps> = (props) => {\n const { name, label, hideLabel, children, columns, spacing, ...fieldProps } =\n props\n\n return (\n <FormControl name={name} as=\"fieldset\" {...fieldProps}>\n <FormLegend display={hideLabel ? 'none' : 'block'}>{label}</FormLegend>\n <FormLayout columns={columns} gridGap={spacing}>\n {mapNestedFields(name, children)}\n </FormLayout>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n ObjectField.displayName = 'ObjectField'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form } from './form'\nimport { FormLayout } from './layout'\nimport { Field, FieldProps } from './field'\n\nimport { ArrayField } from './array-field'\nimport { ObjectField } from './object-field'\nimport { FieldResolver } from './field-resolver'\nimport { useFormContext } from 'react-hook-form'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\n focusFirstField?: boolean\n}\n\nconst mapNestedFields = (resolver: FieldResolver, name: string) => {\n return resolver\n .getNestedFields(name)\n ?.map(\n ({ name, type, ...nestedFieldProps }: FieldProps, i): React.ReactNode => (\n <Field key={name || i} name={name} type={type} {...nestedFieldProps} />\n )\n )\n}\n\nexport const Fields: React.FC<FieldsProps> = ({\n schema,\n fieldResolver,\n focusFirstField,\n ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n const fields = React.useMemo(() => resolver.getFields(), [resolver])\n\n const form = useFormContext()\n\n React.useEffect(() => {\n if (focusFirstField && fields[0]?.name) {\n form.setFocus(fields[0].name)\n }\n }, [schema, fieldResolver, focusFirstField])\n\n return (\n <FormLayout {...props}>\n {fields.map(\n ({\n name,\n type,\n defaultValue,\n ...fieldProps\n }: FieldProps): React.ReactNode => {\n if (type === 'array') {\n return (\n <ArrayField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ArrayField>\n )\n } else if (type === 'object') {\n return (\n <ObjectField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ObjectField>\n )\n }\n\n return <Field key={name} name={name} type={type} {...fieldProps} />\n }\n )}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n Fields.displayName = 'Fields'\n}\n","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { __DEV__ } from '@chakra-ui/utils'\n\nexport interface SubmitButtonProps extends ButtonProps {\n /**\n * Disable the submit button if the form is untouched.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfUntouched`\n */\n disableIfUntouched?: boolean\n /**\n * Disable the submit button if the form is invalid.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfInvalid`\n */\n disableIfInvalid?: boolean\n}\n\nexport const SubmitButton = React.forwardRef<\n HTMLButtonElement,\n SubmitButtonProps\n>((props, ref) => {\n const {\n children,\n disableIfUntouched,\n disableIfInvalid,\n isDisabled: isDisabledProp,\n isLoading,\n ...rest\n } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid) ||\n isDisabledProp\n\n return (\n <Button\n {...rest}\n ref={ref}\n variant=\"primary\"\n type=\"submit\"\n isLoading={formState.isSubmitting || isLoading}\n isDisabled={isDisabled}\n >\n {children}\n </Button>\n )\n})\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n\nif (__DEV__) {\n SubmitButton.displayName = 'SubmitButton'\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form, FormProps } from './form'\nimport { FormLayout } from './layout'\nimport { Fields } from './fields'\nimport { SubmitButton } from './submit-button'\nimport { FieldResolver } from '.'\n\ninterface AutoFormOptions {\n /**\n * The submit button label.\n * Pass `null` to render no submit button.\n */\n submitLabel?: React.ReactNode\n /**\n * The schema.\n * Supports object schema, Yup or Zod.\n * @see https://www.saas-ui.dev/docs/forms/auto-form\n */\n schema: any\n /**\n * The field resolver.\n */\n fieldResolver?: any\n}\n\nexport interface AutoFormProps<TFieldValues extends FieldValues>\n extends Omit<FormProps<TFieldValues>, 'schema'>,\n AutoFormOptions {}\n\nexport const AutoForm = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: AutoFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n schema,\n submitLabel = 'Submit',\n fieldResolver,\n children,\n ...rest\n } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton>{submitLabel}</SubmitButton>}\n {children}\n </FormLayout>\n </Form>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: AutoFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getFieldResolver?: (schema: any) => FieldResolver\n}\n\nif (__DEV__) {\n AutoForm.displayName = 'AutoForm'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport {\n useFormContext,\n useWatch,\n FieldValues,\n UseFormReturn,\n} from 'react-hook-form'\n\nexport interface DisplayIfProps<TFieldValues> {\n children: React.ReactElement\n name: string\n defaultValue?: unknown\n isDisabled?: boolean\n isExact?: boolean\n condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean\n}\n\nexport const DisplayIf = <TFieldValues extends FieldValues = FieldValues>({\n children,\n name,\n defaultValue,\n isDisabled,\n isExact,\n condition = (value) => !!value,\n}: DisplayIfProps<TFieldValues>) => {\n const value = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n const context = useFormContext<TFieldValues>()\n return condition(value, context) ? children : null\n}\n\nif (__DEV__) {\n DisplayIf.displayName = 'DisplayIf'\n}\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler } from 'react-hook-form'\nimport { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'\nimport {\n useStepper,\n useStep,\n UseStepperProps,\n UseStepperReturn,\n} from '@saas-ui/stepper'\n\nexport interface StepState {\n name: string\n schema?: any\n resolver?: any\n isActive?: boolean\n isCompleted?: boolean\n onSubmit?: FormStepSubmitHandler\n}\n\nexport type FormStepSubmitHandler<\n TFieldValues extends FieldValues = FieldValues\n> = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>\n\nexport interface StepFormContext extends UseStepperReturn {\n updateStep(state: StepState): void\n steps: Record<string, StepState>\n}\n\nexport const [StepFormProvider, useStepFormContext] =\n createContext<StepFormContext>({\n name: 'StepFormContext',\n errorMessage:\n 'useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`',\n })\n\nimport { FormProps } from './form'\n\nexport interface UseStepFormProps<\n TFieldValues extends FieldValues = FieldValues\n> extends Omit<UseStepperProps, 'onChange'>,\n Omit<FormProps<TFieldValues>, 'children'> {\n children: MaybeRenderProp<UseStepFormReturn<TFieldValues>>\n}\n\nexport interface UseStepFormReturn<\n TFieldValues extends FieldValues = FieldValues\n> extends UseStepperReturn {\n getFormProps(): {\n onSubmit: SubmitHandler<TFieldValues>\n schema?: any\n resolver?: any\n }\n updateStep(step: any): void\n steps: Record<string, any>\n}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n): UseStepFormReturn<TFieldValues> {\n const { onChange, ...rest } = props\n const stepper = useStepper(rest)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState<Record<string, StepState>>({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n try {\n const step = steps[activeStep]\n\n if (isLastStep) {\n await props.onSubmit?.(data)\n\n updateStep({\n ...step,\n isCompleted: true,\n })\n\n nextStep() // show completed step\n return\n }\n\n await step.onSubmit?.(data, stepper)\n\n nextStep()\n } catch (e) {\n // Step submission failed.\n }\n },\n [steps, activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(() => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n }, [steps, onSubmitStep, activeStep])\n\n const updateStep = React.useCallback(\n (step: StepState) => {\n updateSteps((steps) => {\n return {\n ...steps,\n [step.name]: step,\n }\n })\n },\n [steps]\n )\n\n return {\n getFormProps,\n updateStep,\n steps,\n ...stepper,\n }\n}\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n onSubmit?: FormStepSubmitHandler\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver, onSubmit } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver, onSubmit })\n }, [name, schema])\n\n return {\n ...step,\n ...(steps[name] || { name, schema }),\n }\n}\n","import * as React from 'react'\n\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\n\nimport { chakra, HTMLChakraProps } from '@chakra-ui/system'\n\nimport { callAllHandlers, runIfFn, cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n StepperProvider,\n StepperSteps,\n StepperStepsProps,\n StepperStep,\n useStepperContext,\n StepperContainer,\n} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n FormStepSubmitHandler,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues> {}\n\nexport const StepForm = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: StepFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const { children, ...rest } = props\n\n const stepper = useStepForm<TFieldValues>(props)\n\n const { getFormProps, ...ctx } = stepper\n\n const context = React.useMemo(() => ctx, [ctx])\n\n return (\n <StepperProvider value={context}>\n <StepFormProvider value={context}>\n <Form ref={ref} {...rest} {...getFormProps()}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: StepFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement\n\nexport interface FormStepOptions {\n /**\n * The step name\n */\n name: string\n /**\n * Schema\n */\n schema?: any\n /**\n * Hook Form Resolver\n */\n resolver?: any\n}\n\nexport const FormStepper: React.FC<StepperStepsProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation } = props\n\n const elements = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child?.type === FormStep) {\n const { isCompleted } = useFormStep(child.props) // Register this step\n return (\n <StepperStep\n name={child.props.name}\n title={child.props.title}\n isCompleted={isCompleted}\n >\n {child.props.children}\n </StepperStep>\n )\n }\n return child\n })\n\n const onChange = React.useCallback((i: number) => {\n setIndex(i)\n }, [])\n\n return (\n <StepperContainer\n orientation={orientation}\n step={activeIndex}\n onChange={onChange}\n >\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StepperContainer>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n Omit<HTMLChakraProps<'div'>, 'onSubmit'> {\n onSubmit?: FormStepSubmitHandler\n}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, onSubmit, ...rest } =\n props\n const step = useFormStep({ name, schema, resolver, onSubmit })\n\n const { isActive } = step\n\n return isActive ? (\n <chakra.div {...rest} className={cx('saas-form__step', className)}>\n {children}\n </chakra.div>\n ) : null\n}\n\nif (__DEV__) {\n FormStep.displayName = 'FormStep'\n}\n\nexport const PrevButton: React.FC<ButtonProps> = (props) => {\n const { isFirstStep, isCompleted, prevStep } = useStepperContext()\n\n return (\n <Button\n isDisabled={isFirstStep || isCompleted}\n label=\"Back\"\n {...props}\n className={cx('saas-form__prev-button', props.className)}\n onClick={callAllHandlers(props.onClick, prevStep)}\n />\n )\n}\n\nif (__DEV__) {\n PrevButton.displayName = 'PrevButton'\n}\n\nexport interface NextButtonProps extends ButtonProps {\n submitLabel?: string\n}\n\nexport const NextButton: React.FC<NextButtonProps> = (props) => {\n const { label = 'Next', submitLabel = 'Complete', ...rest } = props\n const { isLastStep, isCompleted } = useStepperContext()\n\n return (\n <SubmitButton\n {...rest}\n isDisabled={isCompleted}\n className={cx('saas-form__next-button', props.className)}\n >\n {isLastStep || isCompleted ? submitLabel : label}\n </SubmitButton>\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n"],"names":["_excluded","DisplayField","_ref","name","label","props","React","createElement","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","_ref2","getValues","useFormContext","_excluded2","_excluded3","_excluded4","_excluded5","_excluded6","_excluded7","_excluded8","_excluded9","_excluded10","inputTypes","help","variant","hideLabel","children","controlProps","formState","get","errors","getError","_extends","isInvalid","error","Box","message","FormHelperText","FormErrorMessage","BaseField","Field","forwardRef","ref","_props$type","type","defaultInputType","withControlledInput","InputComponent","rules","_ref3","inputProps","_objectWithoutPropertiesLoose","_useFormContext2","Controller","control","render","field","_ref4$field","useMergeRefs","withUncontrolledInput","_ref5","_register","register","component","options","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","isControlled","split","map","part","charAt","toUpperCase","slice","join","registerFieldType","_ref6","_ref6$type","leftAddon","rightAddon","size","rest","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInputField","PasswordInput","Textarea","SwitchField","_ref7","Switch","SelectField","Select","CheckboxField","_ref8","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","pinLength","_props$pinLength","pinType","spacing","inputs","i","push","PinInputField","key","HStack","PinInput","schema","Object","entries","title","_ref$","objectFieldResolver","getFields","getNestedFields","_field$items","items","mapFields","properties","Form","mode","_props$mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","className","cx","getFieldResolver","FormLayoutItem","div","FormLayout","_theme$components$For","_theme$components","_theme$components$For2","gridProps","theme","useTheme","components","defaultProps","SimpleGrid","Children","child","isValidElement","mapNestedFields","cloneElement","createContext","ArrayFieldProvider","useArrayFieldContext","_createContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","_ref$defaultValue","defaultValue","keyName","min","max","context","useFieldArray","useArrayFieldRow","index","clearErrors","_useArrayFieldContext","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","_useArrayFieldRowCont","_useArrayFieldContext2","onClick","append","_useArrayFieldContext3","shouldFocus","ArrayFieldRow","rowFieldsProps","ArrayFieldRowContainer","ArrayFieldRowFields","ArrayFieldRemoveButton","layoutProps","flex","mr","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","useArrayFieldAddButton","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","Fragment","_ref4","fieldProps","FormLegend","styles","useStyleConfig","as","sx","columns","gridGap","ObjectField","_resolver$getNestedFi","nestedFieldProps","Fields","fieldResolver","focusFirstField","useMemo","_fields$","setFocus","SubmitButton","disableIfUntouched","disableIfInvalid","isDisabledProp","isLoading","Button","isSubmitting","isDirty","isValid","AutoForm","submitLabel","_props$submitLabel","DisplayIf","condition","_ref$condition","useWatch","disabled","exact","isExact","errorMessage","StepFormProvider","useStepFormContext","useStepForm","onChange","stepper","useStepper","activeStep","isLastStep","nextStep","_React$useState","useState","steps","updateSteps","onSubmitStep","data","step","_temp","then","updateStep","isCompleted","_exit","_temp2","getFormProps","_extends2","useStep","ctx","StepperProvider","runIfFn","FormStep","useFormStep","isActive","PrevButton","_useStepperContext2","useStepperContext","prevStep","isFirstStep","callAllHandlers","NextButton","_props$label","_useStepperContext3","_useStepperContext","activeIndex","setIndex","orientation","elements","StepperStep","StepperContainer","StepperSteps"],"mappings":"okCAAA,IAAAA,EAAA,CAAA,OAAA,QAAA,eAiByBC,EAAgC,SAAAC,GACvDC,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,MAEGC,sBAEH,OACEC,EAAAC,cAACC,EAADA,YAAiBH,EACdD,eAAQE,EAACC,cAAAE,EAADA,UAAW,CAAAC,QAASP,GAAOC,GAAqB,kBACzDE,EAAAC,cAACI,EAADA,KAAA,CAAMC,SAAS,mBACbN,EAACC,cAAAM,EAAU,CAAAV,KAAMA,KAIxB,EAEGW,EAAAA,UACFb,EAAac,YAAc,gBAGhBF,MAAwC,SAAAG,GAAGb,IAAAA,EAAAA,EAAAA,KAEtD,OAAOc,EADeC,EAAcA,iBAA5BD,WACSd,IAAS,IAC3B,EAEGW,EAAAA,UACFD,EAAUE,YAAc,aC3C1B,IAAAf,EAAA,CAAA,OAAA,QAAA,OAAA,UAAA,YAAA,YAAAmB,EAAA,CAAA,KAAA,OAAA,QAAA,OAAA,aAAA,YAAA,aAAA,aAAA,QAAA,WAAAC,EAAA,CAAA,OAAA,SAAAC,EAAA,CAAA,OAAAC,EAAA,CAAA,OAAA,SAAAC,EAAA,CAAA,OAAAC,EAAA,CAAA,OAAA,YAAA,aAAA,QAAAC,EAAA,CAAA,QAAAC,EAAA,CAAA,QAAA,QAAAC,EAAA,CAAA,YAAA,UAAA,WA4GMC,EAA4C,CAAA,IAmBH,SAACvB,GAC9C,MACEA,EADMF,KAAMC,EACZC,EADYD,MAAOyB,EACnBxB,EADmBwB,KAAMC,EACzBzB,EADyByB,QAASC,EAClC1B,EADkC0B,UAAWC,EAC7C3B,EAD6C2B,SAAaC,EAC1D5B,EAAAA,OAba,SAACF,EAAc+B,GAC9B,OAAUC,EAAAA,IAACD,EAAUE,OAAQjC,EAC9B,CAeekC,CAASlC,EAFDe,EAAcA,iBAA5BgB,wBAIR,OACE5B,gBAACE,EAAAA,YAAD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../src/display-field.tsx","../src/field.tsx","../src/field-resolver.ts","../src/form.tsx","../src/layout.tsx","../src/utils.ts","../src/use-array-field.tsx","../src/array-field.tsx","../src/object-field.tsx","../src/fields.tsx","../src/submit-button.tsx","../src/auto-form.tsx","../src/display-if.tsx","../src/use-step-form.tsx","../src/step-form.tsx","../src/watch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { useFormContext } from 'react-hook-form'\n\nimport {\n Text,\n FormControl,\n FormControlProps,\n FormLabel,\n} from '@chakra-ui/react'\n\nimport { FieldProps } from './field'\n\nexport interface DisplayFieldProps\n extends FormControlProps,\n Omit<FieldProps, 'type' | 'label'> {}\n\nexport const DisplayField: React.FC<DisplayFieldProps> = ({\n name,\n label,\n placeholder,\n ...props\n}) => {\n return (\n <FormControl {...props}>\n {label ? <FormLabel htmlFor={name}>{label}</FormLabel> : null}\n <Text fontSize=\"md\">\n <FormValue name={name} />\n </Text>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n DisplayField.displayName = 'DisplayField'\n}\n\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\n}\n\nif (__DEV__) {\n FormValue.displayName = 'FormValue'\n}\n","import * as React from 'react'\nimport {\n useFormContext,\n FormState,\n Controller,\n get,\n RegisterOptions,\n FieldValues,\n FieldPath,\n} from 'react-hook-form'\n\nimport {\n forwardRef,\n Box,\n FormControl,\n FormControlProps,\n FormLabel,\n FormHelperText,\n FormErrorMessage,\n Input,\n Textarea,\n Checkbox,\n Switch,\n useMergeRefs,\n InputGroup,\n InputProps,\n TextareaProps,\n SwitchProps,\n CheckboxProps,\n PinInputField,\n HStack,\n PinInput,\n UsePinInputProps,\n SystemProps,\n} from '@chakra-ui/react'\nimport { __DEV__, FocusableElement } from '@chakra-ui/utils'\n\nimport { NumberInput, NumberInputProps } from '@saas-ui/number-input'\nimport { PasswordInput, PasswordInputProps } from '@saas-ui/password-input'\nimport { RadioInput, RadioInputProps } from '@saas-ui/radio'\n\nimport {\n Select,\n SelectProps,\n NativeSelect,\n NativeSelectProps,\n} from '@saas-ui/select'\n\nexport interface Option {\n value: string\n label?: string\n [key: string]: unknown\n}\n\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength' | 'pattern'\n>\n\nexport interface FieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<FormControlProps, 'label' | 'type'> {\n /**\n * The field name\n */\n name: TName\n /**\n * The field label\n */\n label?: string\n /**\n * Hide the field label\n */\n hideLabel?: boolean\n /**\n * Field help text\n */\n help?: string\n /**\n * React hook form rules\n */\n rules?: Omit<\n RegisterOptions<TFieldValues, TName>,\n 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'\n >\n /**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\n type?: string\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<string, React.FC<any>> = {}\n\nconst defaultInputType = 'text'\n\nconst getInput = (type: string) => {\n return inputTypes[type] || inputTypes[defaultInputType]\n}\n\nconst getError = (name: string, formState: FormState<{ [x: string]: any }>) => {\n return get(formState.errors, name)\n}\n\nconst isTouched = (\n name: string,\n formState: FormState<{ [x: string]: any }>\n) => {\n return get(formState.touchedFields, name)\n}\n\nexport const BaseField: React.FC<FieldProps> = (props) => {\n const { name, label, help, hideLabel, children, ...controlProps } = props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? <FormLabel>{label}</FormLabel> : null}\n <Box>\n {children}\n {help && !error?.message ? (\n <FormHelperText>{help}</FormHelperText>\n ) : null}\n {error?.message && (\n <FormErrorMessage>{error?.message}</FormErrorMessage>\n )}\n </Box>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n BaseField.displayName = 'BaseField'\n}\n\nexport type As<Props = any> = React.ElementType<Props>\n\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n type?: FieldTypes\n}\n\n/**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\nexport const Field = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> | FieldTypeProps,\n ref: React.ForwardedRef<FocusableElement>\n ) => {\n const { type = defaultInputType } = props\n const InputComponent = getInput(type)\n\n return <InputComponent ref={ref} {...props} />\n }\n) as (<TFieldValues extends FieldValues>(\n props: FieldProps<TFieldValues> &\n FieldTypeProps & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n}\n\ninterface CreateFieldProps {\n displayName: string\n hideLabel?: boolean\n BaseField: React.FC<any>\n}\n\nconst createField = (\n InputComponent: React.FC<any>,\n { displayName, hideLabel, BaseField }: CreateFieldProps\n) => {\n const Field = forwardRef((props, ref) => {\n const {\n id,\n name,\n label,\n help,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n rules,\n ...inputProps\n } = props\n\n const inputRules = {\n required: isRequired,\n ...rules,\n }\n\n return (\n <BaseField\n id={id}\n name={name}\n label={label}\n help={help}\n hideLabel={hideLabel}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n >\n <InputComponent\n ref={ref}\n id={id}\n name={name}\n label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { control } = useFormContext()\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { ref: _ref, ...field } }) => (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )}\n />\n )\n }\n )\n}\n\nexport const withUncontrolledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { register } = useFormContext()\n\n const { ref: _ref, ...field } = register(name, rules)\n\n return (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )\n }\n )\n}\n\nexport interface RegisterFieldTypeOptions {\n isControlled?: boolean\n hideLabel?: boolean\n BaseField?: React.FC<any>\n}\n\n/**\n * Register a new field type\n * @param type The name for this field in kebab-case, eg `email` or `array-field`\n * @param component The React component\n * @param options\n * @param options.isControlled Set this to true if this is a controlled field.\n * @param options.hideLabel Hide the field label, for example for the checkbox field.\n */\nexport const registerFieldType = <T extends object>(\n type: string,\n component: React.FC<T>,\n options?: RegisterFieldTypeOptions\n) => {\n let InputComponent\n if (options?.isControlled) {\n InputComponent = withControlledInput(component)\n } else {\n InputComponent = withUncontrolledInput(component)\n }\n\n const Field = createField(InputComponent, {\n displayName: `${type\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')}Field`,\n hideLabel: options?.hideLabel,\n BaseField: options?.BaseField || BaseField,\n }) as React.FC<T & FieldProps>\n\n inputTypes[type] = Field\n\n return Field\n}\n\nexport interface InputFieldProps extends InputProps {\n type?: string\n leftAddon?: React.ReactNode\n rightAddon?: React.ReactNode\n}\n\nexport const InputField = registerFieldType<InputFieldProps>(\n 'text',\n forwardRef(({ type = 'text', leftAddon, rightAddon, size, ...rest }, ref) => {\n const input = <Input type={type} size={size} {...rest} ref={ref} />\n if (leftAddon || rightAddon) {\n return (\n <InputGroup size={size}>\n {leftAddon}\n {input}\n {rightAddon}\n </InputGroup>\n )\n }\n return input\n })\n)\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n type: 'number'\n}\n\nexport const NumberInputField = registerFieldType<NumberInputFieldProps>(\n 'number',\n NumberInput,\n {\n isControlled: true,\n }\n)\n\nexport const PasswordInputField = registerFieldType<PasswordInputProps>(\n 'password',\n forwardRef((props, ref) => <PasswordInput ref={ref} {...props} />)\n)\n\nexport const TextareaField = registerFieldType<TextareaProps>(\n 'textarea',\n Textarea\n)\n\nexport const SwitchField = registerFieldType<SwitchProps>(\n 'switch',\n forwardRef(({ type, ...rest }, ref) => {\n return <Switch {...rest} ref={ref} />\n }),\n {\n isControlled: true,\n }\n)\n\nexport const SelectField = registerFieldType<SelectProps>('select', Select, {\n isControlled: true,\n})\n\nexport const CheckboxField = registerFieldType<CheckboxProps>(\n 'checkbox',\n forwardRef(({ label, type, ...props }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\n\nexport const RadioField = registerFieldType<RadioInputProps>(\n 'radio',\n RadioInput,\n {\n isControlled: true,\n }\n)\n\nexport const NativeSelectField = registerFieldType<NativeSelectProps>(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\n\nexport interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {\n pinLength?: number\n pinType?: 'alphanumeric' | 'number'\n spacing?: SystemProps['margin']\n}\n\nexport const PinField = registerFieldType<PinFieldProps>(\n 'pin',\n forwardRef((props, ref) => {\n const { pinLength = 4, pinType, spacing, ...inputProps } = props\n\n const inputs: React.ReactNode[] = []\n for (let i = 0; i < pinLength; i++) {\n inputs.push(<PinInputField key={i} ref={ref} />)\n }\n\n return (\n <HStack spacing={spacing}>\n <PinInput {...inputProps} type={pinType}>\n {inputs}\n </PinInput>\n </HStack>\n )\n }),\n {\n isControlled: true,\n }\n)\n\nconst fieldTypes = {\n text: InputField,\n email: InputField,\n url: InputField,\n phone: InputField,\n number: NumberInputField,\n password: PasswordInputField,\n textarea: TextareaField,\n switch: SwitchField,\n checkbox: CheckboxField,\n radio: RadioField,\n pin: PinField,\n select: SelectField,\n 'native-select': NativeSelectField,\n}\n\ntype FieldTypes = typeof fieldTypes\n\ntype FieldType<Props = any> = React.ElementType<Props>\n\ntype TypeProps<P extends FieldType, T> = React.ComponentPropsWithoutRef<P> & {\n type: T\n}\n\ntype FieldTypeProps =\n | {\n [Property in keyof FieldTypes]: TypeProps<FieldTypes[Property], Property>\n }[keyof FieldTypes]\n | { type?: string }\n","import { FieldProps } from './field'\n\nimport { get } from '@chakra-ui/utils'\n\nexport type FieldResolver = {\n getFields(): FieldProps[]\n getNestedFields(name: string): FieldProps[]\n}\n\ninterface SchemaField extends FieldProps {\n items?: SchemaField[]\n properties?: Record<string, SchemaField>\n}\n\nexport type ObjectSchema = Record<string, SchemaField>\n\nconst mapFields = (schema: ObjectSchema): FieldProps[] =>\n schema &&\n Object.entries(schema).map(([name, { items, label, title, ...field }]) => {\n return {\n ...field,\n name,\n label: label || title, // json schema compatibility\n }\n })\n\nexport const objectFieldResolver = (schema: ObjectSchema): FieldResolver => {\n const getFields = () => {\n return mapFields(schema)\n }\n const getNestedFields = (name: string) => {\n const field = get(schema, name)\n\n if (!field) return []\n\n if (field.items?.type === 'object') {\n return mapFields(field.items.properties)\n } else if (field.type === 'object') {\n return mapFields(field.properties)\n }\n return [field.items]\n }\n\n return { getFields, getNestedFields }\n}\n","import * as React from 'react'\n\nimport { chakra, HTMLChakraProps, forwardRef } from '@chakra-ui/react'\nimport { cx, MaybeFunction, runIfFn, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n ResolverOptions,\n ResolverResult,\n ChangeHandler,\n WatchObserver,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\nimport { MaybeRenderProp } from '@chakra-ui/react-utils'\n\nexport type { UseFormReturn, FieldValues, SubmitHandler }\n\ninterface FormOptions<TFieldValues extends FieldValues = FieldValues> {\n /**\n * The form schema, currently supports Yup schema only.\n */\n schema?: any\n /**\n * Triggers when any of the field change.\n */\n onChange?: WatchObserver<TFieldValues>\n /**\n * The submit handler.\n */\n onSubmit: SubmitHandler<TFieldValues>\n /**\n * Triggers when there are validation errors.\n */\n onError?: SubmitErrorHandler<TFieldValues>\n /**\n * Ref on the HTMLFormElement.\n */\n formRef?: React.RefObject<HTMLFormElement>\n /**\n * The form children, can be a render prop or a ReactNode.\n */\n children?: MaybeRenderProp<UseFormReturn<TFieldValues>>\n}\n\n// @todo Figure out how to pass down FieldValues to all Field components, if at all possible.\n\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<\n HTMLChakraProps<'form'>,\n 'children' | 'onChange' | 'onSubmit' | 'onError'\n >,\n FormOptions<TFieldValues> {}\n\nexport const Form = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n mode = 'all',\n resolver,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n schema,\n defaultValues,\n onChange,\n onSubmit,\n onError,\n formRef,\n children,\n ...rest\n } = props\n\n const form = {\n mode,\n resolver,\n defaultValues,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n }\n\n if (schema && !resolver) {\n form.resolver = Form.getResolver?.(schema)\n }\n\n const methods = useForm<TFieldValues>(form)\n const { handleSubmit } = methods\n\n // This exposes the useForm api through the forwarded ref\n React.useImperativeHandle(ref, () => methods, [ref, methods])\n\n React.useEffect(() => {\n let subscription: any\n if (onChange) {\n subscription = methods.watch(onChange)\n }\n return () => subscription?.unsubscribe()\n }, [methods, onChange])\n\n return (\n <FormProvider {...methods}>\n <chakra.form\n ref={formRef}\n onSubmit={handleSubmit(onSubmit, onError)}\n {...rest}\n className={cx('saas-form', props.className)}\n >\n {runIfFn(children, methods)}\n </chakra.form>\n </FormProvider>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: FormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nif (__DEV__) {\n Form.displayName = 'Form'\n}\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: TFieldValues,\n context: TContext | undefined,\n options: ResolverOptions<TFieldValues>\n) => Promise<ResolverResult<TFieldValues>>\n\nexport type GetFieldResolver = (schema: any) => FieldResolver\n","import * as React from 'react'\n\nimport { chakra, SimpleGrid, SimpleGridProps, useTheme } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nexport type FormLayoutProps = SimpleGridProps\n\ninterface FormLayoutItemProps {\n children: React.ReactNode\n}\n\nconst FormLayoutItem: React.FC<FormLayoutItemProps> = ({ children }) => {\n return <chakra.div>{children}</chakra.div>\n}\n\nif (__DEV__) {\n FormLayoutItem.displayName = 'FormLayoutItem'\n}\n\n/**\n * FormLayout\n *\n * Renders form items in a `SimpleGrid`\n * @see https://chakra-ui.com/docs/layout/simple-grid\n */\nexport const FormLayout = ({ children, ...props }: FormLayoutProps) => {\n const theme = useTheme()\n\n const defaultProps = theme.components?.FormLayout?.defaultProps ?? {\n spacing: 4,\n }\n\n const gridProps = {\n ...defaultProps,\n ...props,\n }\n\n return (\n <SimpleGrid\n {...gridProps}\n className={cx('saas-form__layout', props.className)}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return <FormLayoutItem>{child}</FormLayoutItem>\n }\n return child\n })}\n </SimpleGrid>\n )\n}\n\nif (__DEV__) {\n FormLayout.displayName = 'FormLayout'\n}\n","import * as React from 'react'\n\nexport const mapNestedFields = (name: string, children: React.ReactNode) => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.props.name) {\n return React.cloneElement(child, {\n ...child.props,\n name: `${name}.${child.props.name}`,\n })\n }\n return child\n })\n}\n","import * as React from 'react'\nimport {\n useFieldArray,\n useFormContext,\n UseFieldArrayReturn,\n} from 'react-hook-form'\n\nimport { createContext } from '@chakra-ui/react-utils'\n\nexport interface UseArrayFieldReturn extends UseFieldArrayReturn {\n /**\n * The array field name\n */\n name: string\n /**\n * The default value for new items\n */\n defaultValue: Record<string, any>\n /**\n * Min amount of items\n */\n min?: number\n /**\n * Max amount of items\n */\n max?: number\n}\n\nexport const [ArrayFieldProvider, useArrayFieldContext] =\n createContext<UseArrayFieldReturn>({\n name: 'ArrayFieldContext',\n })\n\nexport interface UseArrayFieldRowReturn {\n /**\n * Name of the array field including the index, eg 'field.0'\n */\n name: string\n /**\n * The field index\n */\n index: number\n /**\n * Remove this array item\n */\n remove: () => void\n /**\n * True if this is the first item\n */\n isFirst: boolean\n /**\n * True if this is the last item\n */\n isLast: boolean\n}\n\nexport const [ArrayFieldRowProvider, useArrayFieldRowContext] =\n createContext<UseArrayFieldRowReturn>({\n name: 'ArrayFieldRowContext',\n })\n\nexport interface ArrayFieldOptions {\n /**\n * The field name\n */\n name: string\n /**\n * Default value for new values in the array\n */\n defaultValue?: Record<string, any>\n /**\n * Default key name for rows, change this if your data uses a different 'id' field\n * @default \"id\"\n */\n keyName?: string\n min?: number\n max?: number\n}\n\nexport const useArrayField = ({\n name,\n defaultValue = {},\n keyName,\n min,\n max,\n}: ArrayFieldOptions) => {\n const { control } = useFormContext()\n const context = useFieldArray({\n control,\n name,\n keyName,\n })\n\n return {\n ...context,\n name,\n defaultValue,\n min,\n max,\n }\n}\n\nexport interface UseArrayFieldRowProps {\n index: number\n}\n\nexport const useArrayFieldRow = ({ index }: UseArrayFieldRowProps) => {\n const { clearErrors } = useFormContext()\n const { name, remove, fields } = useArrayFieldContext()\n\n React.useEffect(() => {\n // reset errors, to make sure min/max errors reset correctly\n clearErrors(name)\n }, [])\n\n return {\n index,\n isFirst: index === 0,\n isLast: index === fields.length - 1,\n name: `${name}.${index}`,\n remove: React.useCallback(() => {\n clearErrors(name)\n remove(index)\n }, [index]),\n }\n}\n\nexport const useArrayFieldRemoveButton = () => {\n const { isFirst, remove } = useArrayFieldRowContext()\n const { min, fields } = useArrayFieldContext()\n\n const isDisabled = isFirst && !!(min && fields.length <= min)\n\n return {\n onClick: () => remove(),\n isDisabled,\n }\n}\n\nexport const useArrayFieldAddButton = () => {\n const { append, defaultValue, max, fields } = useArrayFieldContext()\n\n const isDisabled = !!(max && fields.length >= max)\n\n return {\n onClick: () =>\n append(defaultValue, {\n shouldFocus: false,\n }),\n isDisabled,\n }\n}\n","import * as React from 'react'\n\nimport { chakra, ResponsiveValue, forwardRef } from '@chakra-ui/system'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout, FormLayoutProps } from './layout'\nimport { BaseField, FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nimport {\n useArrayField,\n useArrayFieldRow,\n useArrayFieldContext,\n ArrayFieldProvider,\n ArrayFieldOptions,\n ArrayFieldRowProvider,\n useArrayFieldRowContext,\n useArrayFieldRemoveButton,\n useArrayFieldAddButton,\n UseArrayFieldReturn,\n} from './use-array-field'\n\ninterface ArrayField {\n id: string\n [key: string]: unknown\n}\n\ninterface ArrayFieldRowProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The array index\n */\n index: number\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n ...rowFieldsProps\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields {...rowFieldsProps}>{children}</ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout flex=\"1\" mr=\"2\" {...layoutProps}>\n {mapNestedFields(name, children)}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowFields.displayName = 'ArrayFieldRowFields'\n}\n\nexport const ArrayFieldRowContainer: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n}) => {\n const context = useArrayFieldRow({ index })\n\n const styles = {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'flex-end',\n width: '100%',\n mb: 4,\n }\n\n return (\n <ArrayFieldRowProvider value={context}>\n <chakra.div __css={styles}>{children}</chakra.div>\n </ArrayFieldRowProvider>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowContainer.displayName = 'ArrayFieldRowContainer'\n}\n\nexport const ArrayFieldRemoveButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<MinusIcon />}\n aria-label=\"Remove row\"\n {...useArrayFieldRemoveButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldRemoveButton.displayName = 'ArrayFieldRemoveButton'\n}\n\nexport const ArrayFieldAddButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<AddIcon />}\n aria-label=\"Add row\"\n float=\"right\"\n {...useArrayFieldAddButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldAddButton.displayName = 'ArrayFieldAddButton'\n}\n\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = forwardRef(\n (props: ArrayFieldProps, ref: React.ForwardedRef<UseArrayFieldReturn>) => {\n const { children, ...containerProps } = props\n\n return (\n <ArrayFieldContainer ref={ref} {...containerProps}>\n <ArrayFieldRows>\n {(fields: ArrayField[]) => (\n <>\n {fields.map(({ id }, index: number) => (\n <ArrayFieldRow key={id} index={index}>\n {children}\n </ArrayFieldRow>\n ))}\n </>\n )}\n </ArrayFieldRows>\n <ArrayFieldAddButton />\n </ArrayFieldContainer>\n )\n }\n) as ((\n props: ArrayFieldProps & {\n ref?: React.ForwardedRef<UseArrayFieldReturn>\n }\n) => React.ReactElement) & {\n displayName: string\n}\n\nif (__DEV__) {\n ArrayField.displayName = 'ArrayField'\n}\n\nexport interface ArrayFieldRowsProps {\n children: (fields: ArrayField[]) => React.ReactElement | null\n}\n\nexport const ArrayFieldRows = ({\n children,\n}: ArrayFieldRowsProps): React.ReactElement | null => {\n const { fields } = useArrayFieldContext()\n return children(fields)\n}\n\nif (__DEV__) {\n ArrayFieldRows.displayName = 'ArrayFieldRows'\n}\n\nexport const ArrayFieldContainer = React.forwardRef(\n (\n {\n name,\n defaultValue,\n keyName,\n min,\n max,\n children,\n ...fieldProps\n }: ArrayFieldProps,\n ref: React.ForwardedRef<UseArrayFieldReturn>\n ) => {\n const context = useArrayField({\n name,\n defaultValue,\n keyName,\n min,\n max,\n })\n\n // This exposes the useArrayField api through the forwarded ref\n React.useImperativeHandle(ref, () => context, [ref, context])\n\n return (\n <ArrayFieldProvider value={context}>\n <BaseField name={name} {...fieldProps}>\n {children}\n </BaseField>\n </ArrayFieldProvider>\n )\n }\n)\n\nif (__DEV__) {\n ArrayFieldContainer.displayName = 'ArrayFieldContainer'\n}\n","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyleConfig,\n} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { FormLayout } from './layout'\nimport { FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nexport interface ObjectFieldProps extends FieldProps {\n name: string\n children: React.ReactNode\n columns?: ResponsiveValue<number>\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const FormLegend = (props: FormLabelProps) => {\n const styles = useStyleConfig('FormLegend')\n return <FormLabel as=\"legend\" sx={styles} {...props} />\n}\n\nexport const ObjectField: React.FC<ObjectFieldProps> = (props) => {\n const { name, label, hideLabel, children, columns, spacing, ...fieldProps } =\n props\n\n return (\n <FormControl name={name} as=\"fieldset\" {...fieldProps}>\n <FormLegend display={hideLabel ? 'none' : 'block'}>{label}</FormLegend>\n <FormLayout columns={columns} gridGap={spacing}>\n {mapNestedFields(name, children)}\n </FormLayout>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n ObjectField.displayName = 'ObjectField'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form } from './form'\nimport { FormLayout } from './layout'\nimport { Field, FieldProps } from './field'\n\nimport { ArrayField } from './array-field'\nimport { ObjectField } from './object-field'\nimport { FieldResolver } from './field-resolver'\nimport { useFormContext } from 'react-hook-form'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\n focusFirstField?: boolean\n}\n\nconst mapNestedFields = (resolver: FieldResolver, name: string) => {\n return resolver\n .getNestedFields(name)\n ?.map(\n ({ name, type, ...nestedFieldProps }: FieldProps, i): React.ReactNode => (\n <Field key={name || i} name={name} type={type} {...nestedFieldProps} />\n )\n )\n}\n\nexport const Fields: React.FC<FieldsProps> = ({\n schema,\n fieldResolver,\n focusFirstField,\n ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n const fields = React.useMemo(() => resolver.getFields(), [resolver])\n\n const form = useFormContext()\n\n React.useEffect(() => {\n if (focusFirstField && fields[0]?.name) {\n form.setFocus(fields[0].name)\n }\n }, [schema, fieldResolver, focusFirstField])\n\n return (\n <FormLayout {...props}>\n {fields.map(\n ({\n name,\n type,\n defaultValue,\n ...fieldProps\n }: FieldProps): React.ReactNode => {\n if (type === 'array') {\n return (\n <ArrayField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ArrayField>\n )\n } else if (type === 'object') {\n return (\n <ObjectField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ObjectField>\n )\n }\n\n return <Field key={name} name={name} type={type} {...fieldProps} />\n }\n )}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n Fields.displayName = 'Fields'\n}\n","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { __DEV__ } from '@chakra-ui/utils'\n\nexport interface SubmitButtonProps extends ButtonProps {\n /**\n * Disable the submit button if the form is untouched.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfUntouched`\n */\n disableIfUntouched?: boolean\n /**\n * Disable the submit button if the form is invalid.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfInvalid`\n */\n disableIfInvalid?: boolean\n}\n\nexport const SubmitButton = React.forwardRef<\n HTMLButtonElement,\n SubmitButtonProps\n>((props, ref) => {\n const {\n children,\n disableIfUntouched,\n disableIfInvalid,\n isDisabled: isDisabledProp,\n isLoading,\n ...rest\n } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid) ||\n isDisabledProp\n\n return (\n <Button\n {...rest}\n ref={ref}\n variant=\"primary\"\n type=\"submit\"\n isLoading={formState.isSubmitting || isLoading}\n isDisabled={isDisabled}\n >\n {children}\n </Button>\n )\n})\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n\nif (__DEV__) {\n SubmitButton.displayName = 'SubmitButton'\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form, FormProps } from './form'\nimport { FormLayout } from './layout'\nimport { Fields } from './fields'\nimport { SubmitButton } from './submit-button'\nimport { FieldResolver } from '.'\n\ninterface AutoFormOptions {\n /**\n * The submit button label.\n * Pass `null` to render no submit button.\n */\n submitLabel?: React.ReactNode\n /**\n * The schema.\n * Supports object schema, Zod, Yup or Ajv (JSON Schema).\n * @see https://www.saas-ui.dev/docs/forms/auto-form\n */\n schema: any\n /**\n * The field resolver.\n */\n fieldResolver?: any\n}\n\nexport interface AutoFormProps<TFieldValues extends FieldValues>\n extends Omit<FormProps<TFieldValues>, 'schema' | 'children'>,\n AutoFormOptions {\n children?: React.ReactNode\n}\n\nexport const AutoForm = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: AutoFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n schema,\n submitLabel = 'Submit',\n fieldResolver,\n children,\n ...rest\n } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton>{submitLabel}</SubmitButton>}\n {children}\n </FormLayout>\n </Form>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: AutoFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getFieldResolver?: (schema: any) => FieldResolver\n}\n\nif (__DEV__) {\n AutoForm.displayName = 'AutoForm'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport {\n useFormContext,\n useWatch,\n FieldValues,\n UseFormReturn,\n} from 'react-hook-form'\n\nexport interface DisplayIfProps<TFieldValues> {\n children: React.ReactElement\n name: string\n defaultValue?: unknown\n isDisabled?: boolean\n isExact?: boolean\n condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean\n}\n\nexport const DisplayIf = <TFieldValues extends FieldValues = FieldValues>({\n children,\n name,\n defaultValue,\n isDisabled,\n isExact,\n condition = (value) => !!value,\n}: DisplayIfProps<TFieldValues>) => {\n const value = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n const context = useFormContext<TFieldValues>()\n return condition(value, context) ? children : null\n}\n\nif (__DEV__) {\n DisplayIf.displayName = 'DisplayIf'\n}\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler } from 'react-hook-form'\nimport { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'\nimport {\n useStepper,\n useStep,\n UseStepperProps,\n UseStepperReturn,\n} from '@saas-ui/stepper'\n\nexport interface StepState {\n name: string\n schema?: any\n resolver?: any\n isActive?: boolean\n isCompleted?: boolean\n onSubmit?: FormStepSubmitHandler\n}\n\nexport type FormStepSubmitHandler<\n TFieldValues extends FieldValues = FieldValues\n> = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>\n\nexport interface StepFormContext extends UseStepperReturn {\n updateStep(state: StepState): void\n steps: Record<string, StepState>\n}\n\nexport const [StepFormProvider, useStepFormContext] =\n createContext<StepFormContext>({\n name: 'StepFormContext',\n errorMessage:\n 'useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`',\n })\n\nimport { FormProps } from './form'\n\nexport interface UseStepFormProps<\n TFieldValues extends FieldValues = FieldValues\n> extends Omit<UseStepperProps, 'onChange'>,\n Omit<FormProps<TFieldValues>, 'children'> {\n children: MaybeRenderProp<UseStepFormReturn<TFieldValues>>\n}\n\nexport interface UseStepFormReturn<\n TFieldValues extends FieldValues = FieldValues\n> extends UseStepperReturn {\n getFormProps(): {\n onSubmit: SubmitHandler<TFieldValues>\n schema?: any\n resolver?: any\n }\n updateStep(step: any): void\n steps: Record<string, any>\n}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n): UseStepFormReturn<TFieldValues> {\n const { onChange, ...rest } = props\n const stepper = useStepper(rest)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState<Record<string, StepState>>({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n try {\n const step = steps[activeStep]\n\n if (isLastStep) {\n await props.onSubmit?.(data)\n\n updateStep({\n ...step,\n isCompleted: true,\n })\n\n nextStep() // show completed step\n return\n }\n\n await step.onSubmit?.(data, stepper)\n\n nextStep()\n } catch (e) {\n // Step submission failed.\n }\n },\n [steps, activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(() => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n }, [steps, onSubmitStep, activeStep])\n\n const updateStep = React.useCallback(\n (step: StepState) => {\n updateSteps((steps) => {\n return {\n ...steps,\n [step.name]: step,\n }\n })\n },\n [steps]\n )\n\n return {\n getFormProps,\n updateStep,\n steps,\n ...stepper,\n }\n}\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n onSubmit?: FormStepSubmitHandler\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver, onSubmit } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver, onSubmit })\n }, [name, schema])\n\n return {\n ...step,\n ...(steps[name] || { name, schema }),\n }\n}\n","import * as React from 'react'\n\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\n\nimport { chakra, HTMLChakraProps } from '@chakra-ui/system'\n\nimport { callAllHandlers, runIfFn, cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n StepperProvider,\n StepperSteps,\n StepperStepsProps,\n StepperStep,\n useStepperContext,\n StepperContainer,\n} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n FormStepSubmitHandler,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues> {}\n\nexport const StepForm = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: StepFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const { children, ...rest } = props\n\n const stepper = useStepForm<TFieldValues>(props)\n\n const { getFormProps, ...ctx } = stepper\n\n const context = React.useMemo(() => ctx, [ctx])\n\n return (\n <StepperProvider value={context}>\n <StepFormProvider value={context}>\n <Form ref={ref} {...rest} {...getFormProps()}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: StepFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement\n\nexport interface FormStepOptions {\n /**\n * The step name\n */\n name: string\n /**\n * Schema\n */\n schema?: any\n /**\n * Hook Form Resolver\n */\n resolver?: any\n}\n\nexport const FormStepper: React.FC<StepperStepsProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation } = props\n\n const elements = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child?.type === FormStep) {\n const { isCompleted } = useFormStep(child.props) // Register this step\n return (\n <StepperStep\n name={child.props.name}\n title={child.props.title}\n isCompleted={isCompleted}\n >\n {child.props.children}\n </StepperStep>\n )\n }\n return child\n })\n\n const onChange = React.useCallback((i: number) => {\n setIndex(i)\n }, [])\n\n return (\n <StepperContainer\n orientation={orientation}\n step={activeIndex}\n onChange={onChange}\n >\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StepperContainer>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n Omit<HTMLChakraProps<'div'>, 'onSubmit'> {\n onSubmit?: FormStepSubmitHandler\n}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, onSubmit, ...rest } =\n props\n const step = useFormStep({ name, schema, resolver, onSubmit })\n\n const { isActive } = step\n\n return isActive ? (\n <chakra.div {...rest} className={cx('saas-form__step', className)}>\n {children}\n </chakra.div>\n ) : null\n}\n\nif (__DEV__) {\n FormStep.displayName = 'FormStep'\n}\n\nexport const PrevButton: React.FC<ButtonProps> = (props) => {\n const { isFirstStep, isCompleted, prevStep } = useStepperContext()\n\n return (\n <Button\n isDisabled={isFirstStep || isCompleted}\n label=\"Back\"\n {...props}\n className={cx('saas-form__prev-button', props.className)}\n onClick={callAllHandlers(props.onClick, prevStep)}\n />\n )\n}\n\nif (__DEV__) {\n PrevButton.displayName = 'PrevButton'\n}\n\nexport interface NextButtonProps extends ButtonProps {\n submitLabel?: string\n}\n\nexport const NextButton: React.FC<NextButtonProps> = (props) => {\n const { label = 'Next', submitLabel = 'Complete', ...rest } = props\n const { isLastStep, isCompleted } = useStepperContext()\n\n return (\n <SubmitButton\n {...rest}\n isDisabled={isCompleted}\n className={cx('saas-form__next-button', props.className)}\n >\n {isLastStep || isCompleted ? submitLabel : label}\n </SubmitButton>\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n","import {\n FieldValues,\n useFormContext,\n UseFormReturn,\n useWatch,\n} from 'react-hook-form'\n\nexport interface WatchFieldProps<\n Value = unknown,\n TFieldValues extends FieldValues = FieldValues\n> {\n name: string\n defaultValue?: Value\n isDisabled?: boolean\n isExact?: boolean\n children: (\n value: Value,\n form: UseFormReturn<TFieldValues>\n ) => React.ReactElement | void\n}\n\nexport const WatchField = <\n Value = unknown,\n TFieldValues extends FieldValues = FieldValues\n>(\n props: WatchFieldProps<Value, TFieldValues>\n) => {\n const { name, defaultValue, isDisabled, isExact } = props\n const form = useFormContext<TFieldValues>()\n\n const field = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n\n return props.children(field, form) || null\n}\n"],"names":["_excluded","DisplayField","_ref","name","label","props","React","createElement","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","_ref2","getValues","useFormContext","_excluded2","_excluded3","_excluded4","_excluded5","_excluded6","_excluded7","_excluded8","_excluded9","_excluded10","inputTypes","BaseField","help","hideLabel","children","controlProps","error","formState","get","errors","getError","isInvalid","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","_props$type","_extends","withControlledInput","InputComponent","rules","inputProps","_objectWithoutPropertiesLoose","_ref3","Controller","control","render","_ref4","_ref4$field","field","useMergeRefs","withUncontrolledInput","_ref5","register","_register","component","options","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","isControlled","split","map","part","charAt","toUpperCase","slice","join","InputField","registerFieldType","_ref6$type","leftAddon","_ref6","rightAddon","size","rest","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInput","TextareaField","Textarea","_ref7","Switch","SelectField","Select","CheckboxField","_ref8","Checkbox","RadioField","RadioInput","NativeSelect","PinField","_props$pinLength","pinLength","pinType","spacing","inputs","i","push","PinInputField","key","HStack","PinInput","schema","Object","entries","title","_ref$","objectFieldResolver","getFields","getNestedFields","_field$items","items","mapFields","properties","Form","mode","_props$mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onChange","onSubmit","onError","formRef","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","useEffect","subscription","watch","_subscription","unsubscribe","FormProvider","chakra","className","cx","runIfFn","getFieldResolver","FormLayoutItem","div","FormLayout","_theme$components$For","_theme$components","_theme$components$For2","gridProps","theme","useTheme","components","defaultProps","SimpleGrid","Children","child","isValidElement","mapNestedFields","cloneElement","createContext","ArrayFieldProvider","useArrayFieldContext","_createContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","_ref$defaultValue","defaultValue","keyName","min","max","context","useFieldArray","useArrayFieldRow","index","clearErrors","_useArrayFieldContext","remove","fields","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","_useArrayFieldRowCont","_useArrayFieldContext2","onClick","append","_useArrayFieldContext3","shouldFocus","ArrayFieldRow","rowFieldsProps","ArrayFieldRowContainer","ArrayFieldRowFields","ArrayFieldRemoveButton","layoutProps","flex","mr","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","useArrayFieldAddButton","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","Fragment","fieldProps","FormLegend","styles","useStyleConfig","as","sx","columns","gridGap","ObjectField","_resolver$getNestedFi","nestedFieldProps","Fields","fieldResolver","focusFirstField","useMemo","_fields$","setFocus","SubmitButton","disableIfUntouched","disableIfInvalid","isDisabledProp","isLoading","Button","variant","isSubmitting","isDirty","isValid","AutoForm","submitLabel","_props$submitLabel","DisplayIf","condition","_ref$condition","useWatch","disabled","exact","isExact","errorMessage","StepFormProvider","useStepFormContext","useStepForm","stepper","useStepper","activeStep","isLastStep","nextStep","_React$useState","useState","steps","updateSteps","onSubmitStep","data","step","_temp","then","updateStep","isCompleted","_exit","_temp2","getFormProps","_extends2","useStep","ctx","StepperProvider","FormStep","useFormStep","isActive","PrevButton","_useStepperContext2","useStepperContext","prevStep","isFirstStep","callAllHandlers","NextButton","_props$label","_useStepperContext3","_useStepperContext","activeIndex","setIndex","orientation","elements","StepperStep","StepperContainer","StepperSteps"],"mappings":"okCAAA,IAAAA,EAAA,CAAA,OAAA,QAAA,eAiByBC,EAAgC,SAAAC,GACvDC,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,MAEGC,sBAEH,OACEC,EAAAC,cAACC,EAADA,YAAiBH,EACdD,eAAQE,EAACC,cAAAE,EAADA,UAAW,CAAAC,QAASP,GAAOC,GAAqB,kBACzDE,EAAAC,cAACI,EAADA,KAAA,CAAMC,SAAS,mBACbN,EAACC,cAAAM,EAAU,CAAAV,KAAMA,KAIxB,E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