@saas-ui/forms 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9d11ba5: Added StepForm and Stepper components
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [9d11ba5]
12
+ - @saas-ui/react-utils@0.1.0
13
+
3
14
  ## 0.4.0
4
15
 
5
16
  ### Minor Changes
@@ -4,4 +4,7 @@ import { FieldProps } from './field';
4
4
  export interface DisplayFieldProps extends FormControlProps, Omit<FieldProps, 'type' | 'label'> {
5
5
  }
6
6
  export declare const DisplayField: React.FC<DisplayFieldProps>;
7
+ export declare const FormValue: React.FC<{
8
+ name: string;
9
+ }>;
7
10
  //# sourceMappingURL=display-field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"display-field.d.ts","sourceRoot":"","sources":["../src/display-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAGL,gBAAgB,EAEjB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,MAAM,WAAW,iBACf,SAAQ,gBAAgB,EACtB,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CAAG;AAEzC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAcpD,CAAA"}
1
+ {"version":3,"file":"display-field.d.ts","sourceRoot":"","sources":["../src/display-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAGL,gBAAgB,EAEjB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,MAAM,WAAW,iBACf,SAAQ,gBAAgB,EACtB,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CAAG;AAEzC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAcpD,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAGhD,CAAA"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ export * from './array-field';
9
9
  export * from './use-array-field';
10
10
  export * from './object-field';
11
11
  export * from './display-if';
12
+ export * from './step-form';
13
+ export * from './use-step-form';
12
14
  export * from '@saas-ui/input-right-button';
13
15
  export type { FieldErrors } from 'react-hook-form';
14
16
  //# 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;AAE5B,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;AAE/B,cAAc,6BAA6B,CAAA;AAE3C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("react"),r=require("react-hook-form"),t=require("@chakra-ui/react"),n=require("@saas-ui/number-input"),a=require("@saas-ui/password-input"),l=require("@saas-ui/radio"),i=require("@saas-ui/pin-input"),o=require("@saas-ui/select"),u=require("yup"),s=require("@hookform/resolvers/yup"),c=require("@chakra-ui/system"),d=require("@chakra-ui/icons"),m=require("@saas-ui/button"),f=require("@chakra-ui/react-utils"),p=require("@saas-ui/input-right-button");function v(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 h=/*#__PURE__*/v(e);function b(){return b=Object.assign||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}function y(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var F=["name","label","placeholder"],E=["name","label","help","variant","hideLabel","children"],g=["name","label","help","isDisabled","isInvalid","isReadOnly","isRequired","rules","variant"],w=["name","rules"],C=["ref"],I=["name","rules"],R=["ref"],A=["label"],k=["label"],S={},O=function(e){var n=e.name,a=e.label,l=e.help,i=e.variant,o=e.hideLabel,u=e.children,s=x(e,E),c=function(e,t){return r.get(t.errors,e)}(n,r.useFormContext().formState);/*#__PURE__*/return h.createElement(t.FormControl,b({variant:i},s,{isInvalid:!!c}),a&&!o?/*#__PURE__*/h.createElement(t.FormLabel,{variant:i},a):null,/*#__PURE__*/h.createElement(t.Box,null,u,!l||null!=c&&c.message?null:/*#__PURE__*/h.createElement(t.FormHelperText,null,l),(null==c?void 0:c.message)&&/*#__PURE__*/h.createElement(t.FormErrorMessage,null,null==c?void 0:c.message)))},V=t.forwardRef(function(e,r){var t=e.type;/*#__PURE__*/return h.createElement(S[void 0===t?"text":t]||S.text,b({ref:r},e))}),L=function(e){return t.forwardRef(function(n,a){var l=n.name,i=n.rules,o=x(n,w),u=r.useFormContext();/*#__PURE__*/return h.createElement(r.Controller,{name:l,control:u.control,rules:i,render:function(r){var n=r.field,l=n.ref,i=x(n,C);/*#__PURE__*/return h.createElement(e,b({},i,o,{ref:t.useMergeRefs(a,l)}))}})})},q=function(e){return t.forwardRef(function(n,a){var l=n.name,i=n.rules,o=x(n,I),u=(0,r.useFormContext().register)(l,i),s=u.ref,c=x(u,R);/*#__PURE__*/return h.createElement(e,b({},c,o,{ref:t.useMergeRefs(a,s)}))})},j=function(e,r,n){var a=function(e,r){var n=r.displayName,a=r.hideLabel,l=r.BaseField,i=t.forwardRef(function(r,t){var n=r.name,i=r.label,o=r.help,u=r.isDisabled,s=r.isInvalid,c=r.isReadOnly,d=r.isRequired,m=r.rules,f=r.variant,p=x(r,g),v=b({required:d},m);/*#__PURE__*/return h.createElement(l,{name:n,label:i,help:o,hideLabel:a,isDisabled:u,isInvalid:s,isReadOnly:c,isRequired:d,variant:f},/*#__PURE__*/h.createElement(e,b({ref:t,name:n,label:i,rules:v},p)))});return i.displayName=n,i}(null!=n&&n.isControlled?L(r):q(r),{displayName:e.split("-").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("")+"Field",hideLabel:null==n?void 0:n.hideLabel,BaseField:(null==n?void 0:n.BaseField)||O});return S[e]=a,a},N=j("text",t.Input),P=j("number",n.NumberInput,{isControlled:!0}),B=j("password",a.PasswordInput),D=j("textarea",t.Textarea),M=j("switch",t.forwardRef(function(e,r){var n=e.label,a=x(e,A);/*#__PURE__*/return h.createElement(t.Switch,b({ref:r},a),n)}),{isControlled:!0,hideLabel:!0}),U=j("select",o.Select,{isControlled:!0}),T=j("checkbox",t.forwardRef(function(e,r){var n=e.label,a=x(e,k);/*#__PURE__*/return h.createElement(t.Checkbox,b({ref:r},a),n)}),{hideLabel:!0}),_=j("radio",l.RadioInput,{isControlled:!0}),G=j("pin",i.PinInput,{isControlled:!0}),H=j("native-select",o.NativeSelect,{isControlled:!0}),z=function(e){var r;if(null!=(r=e.spec.meta)&&r.type)return e.spec.meta.type;switch(e.type){case"array":return"array";case"object":return"object";case"number":return"number";case"date":return"date";default:return"text"}},W=function(e,r){for(var t,n=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return y(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?y(e,r):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e.tests);!(t=n()).done;){var a,l=t.value;if(null!=(a=l.OPTIONS)&&a.params[r])return l.OPTIONS.params[r]}},$=function(e){var r,t=[];for(var n in r="array"===e.type?e.innerType.fields:e.fields){var a=r[n],l={};"array"===a.type&&(l.min=W(a,"min"),l.max=W(a,"max")),t.push(b({name:n,label:a.spec.label||n,type:z(a)},l))}return t},J=["children"],K=function(e){/*#__PURE__*/return h.createElement(t.chakra.div,null,e.children)},Q=function(e){var r,n,a,l=e.children,i=x(e,J),o=b({},null!=(r=null==(n=t.useTheme().components)||null==(a=n.FormLayout)?void 0:a.defaultProps)?r:{spacing:4},i);/*#__PURE__*/return h.createElement(t.SimpleGrid,o,h.Children.map(l,function(e){return h.isValidElement(e)?/*#__PURE__*/h.createElement(K,null,e):e}))},X=function(e,r){return h.Children.map(r,function(r){return h.isValidElement(r)&&r.props.name?h.cloneElement(r,b({},r.props,{name:e+"."+r.props.name})):r})},Y=f.createContext({name:"ArrayFieldContext"}),Z=Y[0],ee=Y[1],re=f.createContext({name:"ArrayFieldRowContext"}),te=re[0],ne=re[1],ae=function(e){var t=e.name,n=e.defaultValue,a=void 0===n?{}:n,l=e.keyName,i=e.min,o=e.max,u=r.useFormContext();return b({},r.useFieldArray({control:u.control,name:t,keyName:l}),{name:t,defaultValue:a,min:i,max:o})},le=function(e){var t=e.index,n=r.useFormContext().clearErrors,a=ee(),l=a.name,i=a.remove,o=a.fields;return h.useEffect(function(){n(l)},[]),{index:t,isFirst:0===t,isLast:t===o.length-1,name:l+"."+t,remove:h.useCallback(function(){n(l),i(t)},[t])}},ie=function(){var e=ne(),r=e.isFirst,t=e.remove,n=ee(),a=n.min;return{onClick:function(){return t()},isDisabled:r&&!!(a&&n.fields.length<=a)}},oe=function(){var e=ee(),r=e.append,t=e.defaultValue,n=e.max;return{onClick:function(){return r(t,{shouldFocus:!1})},isDisabled:!!(n&&e.fields.length>=n)}},ue=["children","columns","spacing"],se=["children"],ce=["name","defaultValue","keyName","min","max","children"],de=function(e){/*#__PURE__*/return h.createElement(fe,{index:e.index},/*#__PURE__*/h.createElement(me,{columns:e.columns,spacing:e.spacing},e.children),/*#__PURE__*/h.createElement(pe,null))},me=function(e){var r=e.children,t=e.columns,n=e.spacing,a=x(e,ue),l=ne().name;/*#__PURE__*/return h.createElement(Q,b({flex:"1",columns:t,gridGap:n,mr:"2"},a),X(l,r))},fe=function(e){var r=e.children,t=le({index:e.index});/*#__PURE__*/return h.createElement(te,{value:t},/*#__PURE__*/h.createElement(c.chakra.div,{__css:{display:"flex",flexDirection:"row",alignItems:"flex-end",width:"100%",mb:4}},r))},pe=function(e){/*#__PURE__*/return h.createElement(m.IconButton,b({icon:/*#__PURE__*/h.createElement(d.MinusIcon,null),"aria-label":"Remove row"},ie(),e))},ve=function(e){/*#__PURE__*/return h.createElement(m.IconButton,b({icon:/*#__PURE__*/h.createElement(d.AddIcon,null),"aria-label":"Add row",float:"right"},oe(),e))},he=function(e){var r=e.children,t=x(e,se);/*#__PURE__*/return h.createElement(xe,t,/*#__PURE__*/h.createElement(be,null,function(e){/*#__PURE__*/return h.createElement(h.Fragment,null,e.map(function(e,t){/*#__PURE__*/return h.createElement(de,{key:e.id,index:t},r)}))}),/*#__PURE__*/h.createElement(ve,null))},be=function(e){return(0,e.children)(ee().fields)},xe=function(e){var r=e.name,t=e.defaultValue,n=e.keyName,a=e.min,l=e.max,i=e.children,o=x(e,ce),u=ae({name:r,defaultValue:t,keyName:n,min:a,max:l});/*#__PURE__*/return h.createElement(Z,{value:u},/*#__PURE__*/h.createElement(O,b({name:r},o),i))},ye=["name","label","hideLabel","children","columns","spacing"],Fe=function(e){var r=t.useStyles();/*#__PURE__*/return h.createElement(t.FormLabel,b({as:"legend",sx:r.legend},e))},Ee=function(e){var r=e.name,n=e.label,a=e.hideLabel,l=e.children,i=e.columns,o=e.spacing,u=x(e,ye);/*#__PURE__*/return h.createElement(t.FormControl,b({name:r,as:"fieldset"},u),/*#__PURE__*/h.createElement(Fe,{display:a?"none":"block"},n),/*#__PURE__*/h.createElement(Q,{columns:i,gridGap:o},X(r,l)))},ge=["name","type"],we=["schema"],Ce=["name","type","defaultValue"],Ie=function(e,r){return $(function(e,r){return u.reach(e,r)}(e,r)).map(function(e){var r=e.name,t=e.type,n=x(e,ge);/*#__PURE__*/return h.createElement(V,b({key:r,name:r,type:t},n))})},Re=function(e){var r=e.schema,t=x(e,we);/*#__PURE__*/return h.createElement(Q,t,$(r).map(function(e){var t=e.name,n=e.type,a=x(e,Ce);return"array"===n?/*#__PURE__*/h.createElement(he,b({name:t},a),Ie(r,t)):"object"===n?/*#__PURE__*/h.createElement(Ee,b({name:t},a),Ie(r,t)):/*#__PURE__*/h.createElement(V,b({key:t,name:t,type:n},a))}))},Ae=["mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","schema","defaultValues","onSubmit","onError","formRef","children"],ke=t.forwardRef(function(e,n){var a=e.mode,l=void 0===a?"all":a,i=e.resolver,o=e.reValidateMode,u=e.shouldFocusError,c=e.shouldUnregister,d=e.shouldUseNativeValidation,m=e.criteriaMode,f=e.delayError,p=e.schema,v=e.defaultValues,y=e.onSubmit,F=e.onError,E=e.formRef,g=e.children,w=x(e,Ae),C={mode:l,resolver:i,defaultValues:v,reValidateMode:o,shouldFocusError:u,shouldUnregister:c,shouldUseNativeValidation:d,criteriaMode:m,delayError:f};p&&(C.resolver=s.yupResolver(p));var I=r.useForm(C),R=I.handleSubmit;return h.useImperativeHandle(n,function(){return I},[n,I]),/*#__PURE__*/h.createElement(r.FormProvider,I,/*#__PURE__*/h.createElement(t.chakra.form,b({ref:E,onSubmit:R(y,F)},w),g))}),Se=["children","disableIfUntouched","disableIfInvalid"],Oe=c.forwardRef(function(e,t){var n=e.children,a=e.disableIfUntouched,l=e.disableIfInvalid,i=x(e,Se),o=r.useFormContext().formState;/*#__PURE__*/return h.createElement(m.Button,b({type:"submit",isLoading:o.isSubmitting,isPrimary:!0,ref:t,isDisabled:a&&!o.isDirty||l&&!o.isValid},i),n)});Oe.defaultProps={label:"Submit",disableIfUntouched:!1,disableIfInvalid:!1};var Ve=["schema","submitLabel"],Le=t.forwardRef(function(e,r){var t=e.schema,n=e.submitLabel,a=void 0===n?"Submit":n,l=x(e,Ve);/*#__PURE__*/return h.createElement(ke,b({},l,{schema:t,ref:r}),/*#__PURE__*/h.createElement(Q,null,/*#__PURE__*/h.createElement(Re,{schema:t}),a&&/*#__PURE__*/h.createElement(Oe,{label:a})))});exports.ArrayField=he,exports.ArrayFieldAddButton=ve,exports.ArrayFieldContainer=xe,exports.ArrayFieldProvider=Z,exports.ArrayFieldRemoveButton=pe,exports.ArrayFieldRow=de,exports.ArrayFieldRowContainer=fe,exports.ArrayFieldRowFields=me,exports.ArrayFieldRowProvider=te,exports.ArrayFieldRows=be,exports.AutoForm=Le,exports.BaseField=O,exports.CheckboxField=T,exports.DisplayField=function(e){var n=e.name,a=e.label,l=x(e,F),i=r.useFormContext().getValues;/*#__PURE__*/return h.createElement(t.FormControl,l,a?/*#__PURE__*/h.createElement(t.FormLabel,{htmlFor:n},a):null,/*#__PURE__*/h.createElement(t.Text,{fontSize:"md"},i(n)))},exports.DisplayIf=function(e){var t=e.children,n=e.condition;return(void 0===n?function(e){return!!e}:n)(r.useWatch({name:e.name,defaultValue:e.defaultValue,disabled:e.isDisabled,exact:e.isExact}),r.useFormContext())?t:null},exports.Field=V,exports.Fields=Re,exports.Form=ke,exports.FormLayout=Q,exports.FormLegend=Fe,exports.InputField=N,exports.NativeSelectField=H,exports.NumberInputField=P,exports.ObjectField=Ee,exports.PasswordInputFIeld=B,exports.PinField=G,exports.RadioField=_,exports.SelectField=U,exports.SubmitButton=Oe,exports.SwitchField=M,exports.TextareaField=D,exports.registerFieldType=j,exports.useArrayField=ae,exports.useArrayFieldAddButton=oe,exports.useArrayFieldContext=ee,exports.useArrayFieldRemoveButton=ie,exports.useArrayFieldRow=le,exports.useArrayFieldRowContext=ne,exports.withControlledInput=L,exports.withUncontrolledInput=q,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"),t=require("react-hook-form"),r=require("@chakra-ui/react"),n=require("@saas-ui/number-input"),a=require("@saas-ui/password-input"),o=require("@saas-ui/radio"),i=require("@saas-ui/pin-input"),l=require("@saas-ui/select"),u=require("yup"),s=require("@hookform/resolvers/yup"),c=require("@chakra-ui/system"),p=require("@chakra-ui/icons"),f=require("@saas-ui/button"),d=require("@chakra-ui/react-utils"),m=require("@saas-ui/react-utils"),v=require("@saas-ui/input-right-button");function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var y=/*#__PURE__*/h(e);function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},b.apply(this,arguments)}function _(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var g=["name","label","placeholder"],E=function(e){var r=e.name;return(0,t.useFormContext().getValues)(r)||null},S=["name","label","help","variant","hideLabel","children"],F=["name","label","help","isDisabled","isInvalid","isReadOnly","isRequired","rules","variant"],C=["name","rules"],j=["ref"],w=["name","rules"],A=["ref"],O=["label"],N=["label"],k={},I=function(e){var n=e.name,a=e.label,o=e.help,i=e.variant,l=e.hideLabel,u=e.children,s=_(e,S),c=function(e,r){return t.get(r.errors,e)}(n,t.useFormContext().formState);/*#__PURE__*/return y.createElement(r.FormControl,b({variant:i},s,{isInvalid:!!c}),a&&!l?/*#__PURE__*/y.createElement(r.FormLabel,{variant:i},a):null,/*#__PURE__*/y.createElement(r.Box,null,u,!o||null!=c&&c.message?null:/*#__PURE__*/y.createElement(r.FormHelperText,null,o),(null==c?void 0:c.message)&&/*#__PURE__*/y.createElement(r.FormErrorMessage,null,null==c?void 0:c.message)))},R=r.forwardRef(function(e,t){var r=e.type;/*#__PURE__*/return y.createElement(k[void 0===r?"text":r]||k.text,b({ref:t},e))}),P=function(e){return r.forwardRef(function(n,a){var o=n.name,i=n.rules,l=_(n,C),u=t.useFormContext();/*#__PURE__*/return y.createElement(t.Controller,{name:o,control:u.control,rules:i,render:function(t){var n=t.field,o=n.ref,i=_(n,j);/*#__PURE__*/return y.createElement(e,b({},i,l,{ref:r.useMergeRefs(a,o)}))}})})},L=function(e){return r.forwardRef(function(n,a){var o=n.name,i=n.rules,l=_(n,w),u=(0,t.useFormContext().register)(o,i),s=u.ref,c=_(u,A);/*#__PURE__*/return y.createElement(e,b({},c,l,{ref:r.useMergeRefs(a,s)}))})},V=function(e,t,n){var a=function(e,t){var n=t.displayName,a=t.hideLabel,o=t.BaseField,i=r.forwardRef(function(t,r){var n=t.name,i=t.label,l=t.help,u=t.isDisabled,s=t.isInvalid,c=t.isReadOnly,p=t.isRequired,f=t.rules,d=t.variant,m=_(t,F),v=b({required:p},f);/*#__PURE__*/return y.createElement(o,{name:n,label:i,help:l,hideLabel:a,isDisabled:u,isInvalid:s,isReadOnly:c,isRequired:p,variant:d},/*#__PURE__*/y.createElement(e,b({ref:r,name:n,label:i,rules:v},m)))});return i.displayName=n,i}(null!=n&&n.isControlled?P(t):L(t),{displayName:e.split("-").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("")+"Field",hideLabel:null==n?void 0:n.hideLabel,BaseField:(null==n?void 0:n.BaseField)||I});return k[e]=a,a},B=V("text",r.Input),z=V("number",n.NumberInput,{isControlled:!0}),D=V("password",a.PasswordInput),q=V("textarea",r.Textarea),T=V("switch",r.forwardRef(function(e,t){var n=e.label,a=_(e,O);/*#__PURE__*/return y.createElement(r.Switch,b({ref:t},a),n)}),{isControlled:!0,hideLabel:!0}),M=V("select",l.Select,{isControlled:!0}),U=V("checkbox",r.forwardRef(function(e,t){var n=e.label,a=_(e,N);/*#__PURE__*/return y.createElement(r.Checkbox,b({ref:t},a),n)}),{hideLabel:!0}),$=V("radio",o.RadioInput,{isControlled:!0}),G=V("pin",i.PinInput,{isControlled:!0}),W=V("native-select",l.NativeSelect,{isControlled:!0}),H=function(e){var t;if(null!=(t=e.spec.meta)&&t.type)return e.spec.meta.type;switch(e.type){case"array":return"array";case"object":return"object";case"number":return"number";case"date":return"date";default:return"text"}},J=function(e,t){for(var r,n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e.tests);!(r=n()).done;){var a,o=r.value;if(null!=(a=o.OPTIONS)&&a.params[t])return o.OPTIONS.params[t]}},K=function(e){var t,r=[];for(var n in t="array"===e.type?e.innerType.fields:e.fields){var a=t[n],o={};"array"===a.type&&(o.min=J(a,"min"),o.max=J(a,"max")),r.push(b({name:n,label:a.spec.label||n,type:H(a)},o))}return r},Q=["children"],X=function(e){/*#__PURE__*/return y.createElement(r.chakra.div,null,e.children)},Y=function(e){var t,n,a,o=e.children,i=_(e,Q),l=b({},null!=(t=null==(n=r.useTheme().components)||null==(a=n.FormLayout)?void 0:a.defaultProps)?t:{spacing:4},i);/*#__PURE__*/return y.createElement(r.SimpleGrid,l,y.Children.map(o,function(e){return y.isValidElement(e)?/*#__PURE__*/y.createElement(X,null,e):e}))},Z=function(e,t){return y.Children.map(t,function(t){return y.isValidElement(t)&&t.props.name?y.cloneElement(t,b({},t.props,{name:e+"."+t.props.name})):t})},ee=d.createContext({name:"ArrayFieldContext"}),te=ee[0],re=ee[1],ne=d.createContext({name:"ArrayFieldRowContext"}),ae=ne[0],oe=ne[1],ie=function(e){var r=e.name,n=e.defaultValue,a=void 0===n?{}:n,o=e.keyName,i=e.min,l=e.max,u=t.useFormContext();return b({},t.useFieldArray({control:u.control,name:r,keyName:o}),{name:r,defaultValue:a,min:i,max:l})},le=function(e){var r=e.index,n=t.useFormContext().clearErrors,a=re(),o=a.name,i=a.remove,l=a.fields;return y.useEffect(function(){n(o)},[]),{index:r,isFirst:0===r,isLast:r===l.length-1,name:o+"."+r,remove:y.useCallback(function(){n(o),i(r)},[r])}},ue=function(){var e=oe(),t=e.isFirst,r=e.remove,n=re(),a=n.min;return{onClick:function(){return r()},isDisabled:t&&!!(a&&n.fields.length<=a)}},se=function(){var e=re(),t=e.append,r=e.defaultValue,n=e.max;return{onClick:function(){return t(r,{shouldFocus:!1})},isDisabled:!!(n&&e.fields.length>=n)}},ce=["children","columns","spacing"],pe=["children"],fe=["name","defaultValue","keyName","min","max","children"],de=function(e){/*#__PURE__*/return y.createElement(ve,{index:e.index},/*#__PURE__*/y.createElement(me,{columns:e.columns,spacing:e.spacing},e.children),/*#__PURE__*/y.createElement(he,null))},me=function(e){var t=e.children,r=e.columns,n=e.spacing,a=_(e,ce),o=oe().name;/*#__PURE__*/return y.createElement(Y,b({flex:"1",columns:r,gridGap:n,mr:"2"},a),Z(o,t))},ve=function(e){var t=e.children,r=le({index:e.index});/*#__PURE__*/return y.createElement(ae,{value:r},/*#__PURE__*/y.createElement(c.chakra.div,{__css:{display:"flex",flexDirection:"row",alignItems:"flex-end",width:"100%",mb:4}},t))},he=function(e){/*#__PURE__*/return y.createElement(f.IconButton,b({icon:/*#__PURE__*/y.createElement(p.MinusIcon,null),"aria-label":"Remove row"},ue(),e))},ye=function(e){/*#__PURE__*/return y.createElement(f.IconButton,b({icon:/*#__PURE__*/y.createElement(p.AddIcon,null),"aria-label":"Add row",float:"right"},se(),e))},be=function(e){var t=e.children,r=_(e,pe);/*#__PURE__*/return y.createElement(xe,r,/*#__PURE__*/y.createElement(_e,null,function(e){/*#__PURE__*/return y.createElement(y.Fragment,null,e.map(function(e,r){/*#__PURE__*/return y.createElement(de,{key:e.id,index:r},t)}))}),/*#__PURE__*/y.createElement(ye,null))},_e=function(e){return(0,e.children)(re().fields)},xe=function(e){var t=e.name,r=e.defaultValue,n=e.keyName,a=e.min,o=e.max,i=e.children,l=_(e,fe),u=ie({name:t,defaultValue:r,keyName:n,min:a,max:o});/*#__PURE__*/return y.createElement(te,{value:u},/*#__PURE__*/y.createElement(I,b({name:t},l),i))},ge=["name","label","hideLabel","children","columns","spacing"],Ee=function(e){var t=r.useStyles();/*#__PURE__*/return y.createElement(r.FormLabel,b({as:"legend",sx:t.legend},e))},Se=function(e){var t=e.name,n=e.label,a=e.hideLabel,o=e.children,i=e.columns,l=e.spacing,u=_(e,ge);/*#__PURE__*/return y.createElement(r.FormControl,b({name:t,as:"fieldset"},u),/*#__PURE__*/y.createElement(Ee,{display:a?"none":"block"},n),/*#__PURE__*/y.createElement(Y,{columns:i,gridGap:l},Z(t,o)))},Fe=["name","type"],Ce=["schema"],je=["name","type","defaultValue"],we=function(e,t){return K(function(e,t){return u.reach(e,t)}(e,t)).map(function(e){var t=e.name,r=e.type,n=_(e,Fe);/*#__PURE__*/return y.createElement(R,b({key:t,name:t,type:r},n))})},Ae=function(e){var t=e.schema,r=_(e,Ce);/*#__PURE__*/return y.createElement(Y,r,K(t).map(function(e){var r=e.name,n=e.type,a=_(e,je);return"array"===n?/*#__PURE__*/y.createElement(be,b({name:r},a),we(t,r)):"object"===n?/*#__PURE__*/y.createElement(Se,b({name:r},a),we(t,r)):/*#__PURE__*/y.createElement(R,b({key:r,name:r,type:n},a))}))},Oe=["mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","schema","defaultValues","onSubmit","onError","formRef","children"],Ne=r.forwardRef(function(e,n){var a=e.mode,o=void 0===a?"all":a,i=e.resolver,l=e.reValidateMode,u=e.shouldFocusError,c=e.shouldUnregister,p=e.shouldUseNativeValidation,f=e.criteriaMode,d=e.delayError,m=e.schema,v=e.defaultValues,h=e.onSubmit,x=e.onError,g=e.formRef,E=e.children,S=_(e,Oe),F={mode:o,resolver:i,defaultValues:v,reValidateMode:l,shouldFocusError:u,shouldUnregister:c,shouldUseNativeValidation:p,criteriaMode:f,delayError:d};m&&(F.resolver=s.yupResolver(m));var C=t.useForm(F),j=C.handleSubmit;return y.useImperativeHandle(n,function(){return C},[n,C]),/*#__PURE__*/y.createElement(t.FormProvider,C,/*#__PURE__*/y.createElement(r.chakra.form,b({ref:g,onSubmit:j(h,x)},S),E))}),ke=["children","disableIfUntouched","disableIfInvalid"],Ie=c.forwardRef(function(e,r){var n=e.children,a=e.disableIfUntouched,o=e.disableIfInvalid,i=_(e,ke),l=t.useFormContext().formState;/*#__PURE__*/return y.createElement(f.Button,b({type:"submit",isLoading:l.isSubmitting,isPrimary:!0,ref:r,isDisabled:a&&!l.isDirty||o&&!l.isValid},i),n)});Ie.defaultProps={label:"Submit",disableIfUntouched:!1,disableIfInvalid:!1};var Re,Pe,Le=["schema","submitLabel"],Ve=r.forwardRef(function(e,t){var r=e.schema,n=e.submitLabel,a=void 0===n?"Submit":n,o=_(e,Le);/*#__PURE__*/return y.createElement(Ne,b({},o,{schema:r,ref:t}),/*#__PURE__*/y.createElement(Y,null,/*#__PURE__*/y.createElement(Ae,{schema:r}),a&&/*#__PURE__*/y.createElement(Ie,{label:a})))}),Be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ze(e){return"function"==typeof e}Re=function(e,t){var r="__lodash_hash_undefined__",n=9007199254740991,a="[object Arguments]",o="[object Function]",i="[object Object]",l=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s[a]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s[o]=s["[object Map]"]=s["[object Number]"]=s[i]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1;var c="object"==typeof Be&&Be&&Be.Object===Object&&Be,p="object"==typeof self&&self&&self.Object===Object&&self,f=c||p||Function("return this")(),d=t&&!t.nodeType&&t,m=d&&e&&!e.nodeType&&e,v=m&&m.exports===d,h=v&&c.process,y=function(){try{return m&&m.require&&m.require("util").types||h&&h.binding&&h.binding("util")}catch(e){}}(),b=y&&y.isTypedArray;function _(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var x,g,E,S=Array.prototype,F=Object.prototype,C=f["__core-js_shared__"],j=Function.prototype.toString,w=F.hasOwnProperty,A=(x=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||""))?"Symbol(src)_1."+x:"",O=F.toString,N=j.call(Object),k=RegExp("^"+j.call(w).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),I=v?f.Buffer:void 0,R=f.Symbol,P=f.Uint8Array,L=(g=Object.getPrototypeOf,E=Object,function(e){return g(E(e))}),V=Object.create,B=F.propertyIsEnumerable,z=S.splice,D=R?R.toStringTag:void 0,q=function(){try{var e=ie(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),T=I?I.isBuffer:void 0,M=Math.max,U=Date.now,$=ie(f,"Map"),G=ie(Object,"create"),W=function(){function e(){}return function(t){if(!be(t))return{};if(V)return V(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function H(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function J(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function K(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Q(e){var t=this.__data__=new J(e);this.size=t.size}function X(e,t,r){(void 0!==r&&!pe(e[t],r)||void 0===r&&!(t in e))&&ee(e,t,r)}function Y(e,t,r){var n=e[t];w.call(e,t)&&pe(n,r)&&(void 0!==r||t in e)||ee(e,t,r)}function Z(e,t){for(var r=e.length;r--;)if(pe(e[r][0],t))return r;return-1}function ee(e,t,r){"__proto__"==t&&q?q(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function te(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":D&&D in Object(e)?function(e){var t=w.call(e,D),r=e[D];try{e[D]=void 0;var n=!0}catch(e){}var a=O.call(e);return n&&(t?e[D]=r:delete e[D]),a}(e):function(e){return O.call(e)}(e)}function re(e){return _e(e)&&te(e)==a}function ne(e,t,r,n,a){e!==t&&function(e,t,r){for(var n=-1,a=Object(e),o=r(e),i=o.length;i--;){var l=o[++n];if(!1===t(a[l],l))break}}(t,function(o,l){if(a||(a=new Q),be(o))!function(e,t,r,n,a,o,l){var u=se(e,r),s=se(t,r),c=l.get(s);if(c)X(e,r,c);else{var p,f,d,m,v=o?o(u,s,r+"",e,t,l):void 0,h=void 0===v;if(h){var y=de(s),b=!y&&ve(s),_=!y&&!b&&xe(s);v=s,y||b||_?de(u)?v=u:_e(m=u)&&me(m)?v=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(u):b?(h=!1,v=s.slice()):_?(h=!1,d=new(f=(p=s).buffer).constructor(f.byteLength),new P(d).set(new P(f)),v=new p.constructor(d,p.byteOffset,p.length)):v=[]:function(e){if(!_e(e)||te(e)!=i)return!1;var t=L(e);if(null===t)return!0;var r=w.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&j.call(r)==N}(s)||fe(s)?(v=u,fe(u)?v=function(e){return function(e,t,r,n){var a=!r;r||(r={});for(var o=-1,i=t.length;++o<i;){var l=t[o],u=void 0;void 0===u&&(u=e[l]),a?ee(r,l,u):Y(r,l,u)}return r}(e,ge(e))}(u):be(u)&&!he(u)||(v=function(e){return"function"!=typeof e.constructor||ue(e)?{}:W(L(e))}(s))):h=!1}h&&(l.set(s,v),a(v,s,n,o,l),l.delete(s)),X(e,r,v)}}(e,t,l,r,ne,n,a);else{var u=n?n(se(e,l),o,l+"",e,t,a):void 0;void 0===u&&(u=o),X(e,l,u)}},ge)}H.prototype.clear=function(){this.__data__=G?G(null):{},this.size=0},H.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},H.prototype.get=function(e){var t=this.__data__;if(G){var n=t[e];return n===r?void 0:n}return w.call(t,e)?t[e]:void 0},H.prototype.has=function(e){var t=this.__data__;return G?void 0!==t[e]:w.call(t,e)},H.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=G&&void 0===t?r:t,this},J.prototype.clear=function(){this.__data__=[],this.size=0},J.prototype.delete=function(e){var t=this.__data__,r=Z(t,e);return!(r<0||(r==t.length-1?t.pop():z.call(t,r,1),--this.size,0))},J.prototype.get=function(e){var t=this.__data__,r=Z(t,e);return r<0?void 0:t[r][1]},J.prototype.has=function(e){return Z(this.__data__,e)>-1},J.prototype.set=function(e,t){var r=this.__data__,n=Z(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},K.prototype.clear=function(){this.size=0,this.__data__={hash:new H,map:new($||J),string:new H}},K.prototype.delete=function(e){var t=oe(this,e).delete(e);return this.size-=t?1:0,t},K.prototype.get=function(e){return oe(this,e).get(e)},K.prototype.has=function(e){return oe(this,e).has(e)},K.prototype.set=function(e,t){var r=oe(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Q.prototype.clear=function(){this.__data__=new J,this.size=0},Q.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Q.prototype.get=function(e){return this.__data__.get(e)},Q.prototype.has=function(e){return this.__data__.has(e)},Q.prototype.set=function(e,t){var r=this.__data__;if(r instanceof J){var n=r.__data__;if(!$||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new K(n)}return r.set(e,t),this.size=r.size,this};var ae=q?function(e,t){return q(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:Fe;function oe(e,t){var r,n,a=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?a["string"==typeof t?"string":"hash"]:a.map}function ie(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!be(e)||function(e){return!!A&&A in e}(e))&&(he(e)?k:l).test(function(e){if(null!=e){try{return j.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(r)?r:void 0}function le(e,t){var r=typeof e;return!!(t=null==t?n:t)&&("number"==r||"symbol"!=r&&u.test(e))&&e>-1&&e%1==0&&e<t}function ue(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||F)}function se(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var ce=function(e){var t=0,r=0;return function(){var n=U(),a=16-(n-r);if(r=n,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ae);function pe(e,t){return e===t||e!=e&&t!=t}var fe=re(function(){return arguments}())?re:function(e){return _e(e)&&w.call(e,"callee")&&!B.call(e,"callee")},de=Array.isArray;function me(e){return null!=e&&ye(e.length)&&!he(e)}var ve=T||function(){return!1};function he(e){if(!be(e))return!1;var t=te(e);return t==o||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}function be(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function _e(e){return null!=e&&"object"==typeof e}var xe=b?function(e){return function(t){return e(t)}}(b):function(e){return _e(e)&&ye(e.length)&&!!s[te(e)]};function ge(e){return me(e)?function(e,t){var r=de(e),n=!r&&fe(e),a=!r&&!n&&ve(e),o=!r&&!n&&!a&&xe(e),i=r||n||a||o,l=i?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],u=l.length;for(var s in e)i&&("length"==s||a&&("offset"==s||"parent"==s)||o&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||le(s,u))||l.push(s);return l}(e):function(e){if(!be(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=ue(e),r=[];for(var n in e)("constructor"!=n||!t&&w.call(e,n))&&r.push(n);return r}(e)}var Ee,Se=(Ee=function(e,t,r,n){ne(e,t,r,n)},function(e,t){return ce(function(e,t,r){return t=M(void 0===t?e.length-1:t,0),function(){for(var n=arguments,a=-1,o=M(n.length-t,0),i=Array(o);++a<o;)i[a]=n[t+a];a=-1;for(var l=Array(t+1);++a<t;)l[a]=n[a];return l[t]=r(i),_(e,this,l)}}(e,void 0,Fe),e+"")}(function(e,t){var r=-1,n=t.length,a=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(a=Ee.length>3&&"function"==typeof a?(n--,a):void 0,o&&function(e,t,r){if(!be(r))return!1;var n=typeof t;return!!("number"==n?me(r)&&le(t,r.length):"string"==n&&t in r)&&pe(r[t],e)}(t[0],t[1],o)&&(a=n<3?void 0:a,n=1),e=Object(e);++r<n;){var i=t[r];i&&Ee(e,i,r,a)}return e}));function Fe(e){return e}e.exports=Se},Re(Pe={exports:{}},Pe.exports);var De="production"!==process.env.NODE_ENV;process;var qe=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter(Boolean).join(" ")};function Te(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){t.some(function(t){return null==t||t(e),null==e?void 0:e.defaultPrevented})}}Object.freeze(["base","sm","md","lg","xl","2xl"]);var Me="production"!==process.env.NODE_ENV;process;var Ue=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter(Boolean).join(" ")};function $e(){return $e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$e.apply(this,arguments)}function Ge(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}Object.freeze(["base","sm","md","lg","xl","2xl"]);var We=d.createContext({name:"StepperContext",errorMessage:"useStepperContext: `context` is undefined. Seems you forgot to wrap stepper components in `<Stepper />`"}),He=We[0],Je=We[1];function Ke(e){var t=e.step,r=y.useState(-1),n=r[0],a=r[1],o=y.useRef([]),i=y.useState(Date.now())[1],l=y.useCallback(function(e){var t=[].concat(o.current);-1===t.indexOf(e)&&t.push(e),o.current=t,i(Date.now())},[o,i]),u=function(e){var t=o.current.indexOf(e);-1!==t&&a(t)};return y.useLayoutEffect(function(){"string"==typeof t?u(t):"number"==typeof t?a(t):-1===n&&a(0)},[t]),{stepsRef:o,activeStep:o.current[n],activeIndex:n,isFirstStep:0===n,isLastStep:n===o.current.length-1,isCompleted:n>=o.current.length,setIndex:a,setStep:u,nextStep:function(){a(n+1)},prevStep:function(){a(n-1)},registerStep:l,unregisterStep:function(e){o.current=o.current.slice(o.current.indexOf(e),1)}}}function Qe(e){var t=e.name,r=e.isActive,n=e.isCompleted,a=Je(),o=a.registerStep,i=a.unregisterStep,l=a.activeStep;return y.useEffect(function(){if(t)return o(t),function(){i(t)}},[]),{isActive:t?l===t:r,isCompleted:n}}var Xe=["children","orientation"],Ye=["children","orientation","stepComponent"],Ze=["children","isOpen"],et=["icon","isActive","isCompleted","className"],tt=["title","icon","isActive","isCompleted"],rt=["isActive"],nt=c.forwardRef(function(e,t){var r=c.useMultiStyleConfig("Stepper",e),n=c.omitThemingProps(e),a=n.children,o=n.orientation,i=Ge(n,Xe),l=Ke(e),u=$e({display:"flex",flexDirection:"column"},r.container);return y.createElement(c.StylesProvider,{value:r},/*#__PURE__*/y.createElement(He,{value:l},/*#__PURE__*/y.createElement(c.chakra.div,$e({ref:t,__css:u},i,{className:Ue("saas-stepper__container",e.className)}),/*#__PURE__*/y.createElement(at,{orientation:o},a))))});Me&&(nt.displayName="Stepper");var at=function(e){var t,r,n=e.children,a=e.orientation,o=e.stepComponent,i=Ge(e,Ye),l=c.useStyles(),u=Je().activeIndex,s=$e({display:"flex",flexDirection:"row",alignItems:"center"},l.steps),p="vertical"===a,f=o||lt,d=m.getChildrenOfType(n,f),v=d.reduce(function(e,t,r,n){return e.push(/*#__PURE__*/y.createElement(f,$e({key:r},t.props,{icon:t.props.icon||r+1,isActive:u===r,isCompleted:t.props.isCompleted||u>r}))),"vertical"===a&&e.push(/*#__PURE__*/y.createElement(ot,{isOpen:u===r},t.props.children)),r<n.length-1&&e.push(/*#__PURE__*/y.createElement(ut,{key:"separator-"+r,isActive:r<u})),e},[]),h=m.getChildOfType(n,ct),b=u>=d.length?h:p?null:null==(t=d[u])||null==(r=t.props)?void 0:r.children;return y.createElement(y.Fragment,null,/*#__PURE__*/y.createElement(c.chakra.div,$e({__css:s},i,{className:Ue("saas-stepper__steps",e.className)}),v),b&&/*#__PURE__*/y.createElement(ot,null,b))};Me&&(at.displayName="StepperSteps");var ot=function(e){var t=e.children,n=e.isOpen,a=void 0===n||n,o=Ge(e,Ze),i=c.useStyles();return y.createElement(c.chakra.div,$e({__css:i.content},o,{className:Ue("saas-stepper__content",e.className)}),/*#__PURE__*/y.createElement(r.Collapse,{in:a},t))};Me&&(ot.displayName="StepperContent");var it=function(e){var t,r=e.icon,n=e.isCompleted,a=e.className,o=Ge(e,et),i=$e({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"full",fontSize:"1em",me:2},c.useStyles().icon);return t=n?/*#__PURE__*/y.createElement(p.Icon,{as:p.CheckIcon}):r,/*#__PURE__*/y.createElement(c.chakra.div,$e({__css:i},o,{className:Ue("saas-stepper__icon",a)}),t)};Me&&(it.displayName="StepperIcon");var lt=function(e){var t=e.title,r=e.icon,n=e.isActive,a=e.isCompleted,o=Ge(e,tt),i=Qe(e),l=$e({display:"flex",alignItems:"center",flexDirection:"row"},c.useStyles().step);return y.createElement(c.chakra.div,$e({__css:l,"data-active":i.isActive,"data-completed":i.isCompleted},o,{className:Ue("saas-stepper__step",e.className)}),/*#__PURE__*/y.createElement(it,{icon:r,isActive:n,isCompleted:a}),t&&/*#__PURE__*/y.createElement(st,null,t))};Me&&(lt.displayName="StepperStep");var ut=function(e){var t=e.isActive,r=Ge(e,rt),n=$e({flex:1,borderTopWidth:"1px",mx:2},c.useStyles().separator);return y.createElement(c.chakra.div,$e({"data-active":t},r,{className:Ue("saas-stepper__separator",e.className),__css:n}))};Me&&(ut.displayName="StepperSeparator");var st=function(e){var t=c.useStyles();return y.createElement(c.chakra.p,$e({},e,{__css:t.title,className:Ue("saas-stepper__title",e.className)}))};Me&&(st.displayName="StepperStepTitle");var ct=function(e){var t=c.useStyles();return y.createElement(c.chakra.div,$e({__css:t.completed},e,{className:Ue("saas-stepper__completed",e.className)}))};Me&&(ct.displayName="StepperCompleted");var pt=d.createContext({name:"StepFormContext",errorMessage:"useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"}),ft=pt[0],dt=pt[1];function mt(e){var t=Ke(e),r=t.activeStep,n=t.isLastStep,a=t.nextStep,o=y.useState({}),i=o[0],l=o[1],u=y.useCallback(function(t){try{return n?Promise.resolve(null==e.onSubmit?void 0:e.onSubmit(t).then(function(){c(b({},i[r],{isCompleted:!0}))}).then(a)):(a(),Promise.resolve())}catch(e){return Promise.reject(e)}},[r,n]),s=y.useCallback(function(e){var t=i[r];return{onSubmit:u,schema:null==t?void 0:t.schema}},[i,u,r]),c=y.useCallback(function(e){l(function(t){var r;return b({},t,((r={})[e.name]=e,r))})},[i]);return b({getFormProps:s,updateStep:c,steps:i},t)}function vt(e){var t=e.name,r=e.schema,n=Qe({name:t}),a=dt(),o=a.steps,i=a.updateStep;return y.useEffect(function(){i({name:t,schema:r})},[t,r]),b({},n,o[t]||{})}var ht=["children","onSubmit"],yt=["getFormProps"],bt=["name","schema","children","className"],_t=["label","submitLabel"],xt=y.forwardRef(function(e,t){var r=e.children,n=_(e,ht),a=mt(e),o=a.getFormProps,i=_(a,yt),l=y.useMemo(function(){return i},[i]);/*#__PURE__*/return y.createElement(He,{value:l},/*#__PURE__*/y.createElement(ft,{value:l},/*#__PURE__*/y.createElement(Ne,b({ref:t},n,o(e)),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return ze(e)?e.apply(void 0,r):e}(r,a))))}),gt=function(e){var t=e.name,r=e.schema,n=e.children,a=e.className,o=_(e,bt);return vt({name:t,schema:r}).isActive?/*#__PURE__*/y.createElement(c.chakra.div,b({},o,{className:qe("saas-form__step",a)}),n):null};De&&(gt.displayName="FormStep");var Et=function(e){var t=Je(),r=t.prevStep;/*#__PURE__*/return y.createElement(f.Button,b({isDisabled:t.isFirstStep||t.isCompleted,label:"Back"},e,{className:qe("saas-form__prev-button",e.className),onClick:Te(e.onClick,r)}))};De&&(Et.displayName="PrevButton");var St=function(e){var t=e.label,r=void 0===t?"Next":t,n=e.submitLabel,a=void 0===n?"Complete":n,o=_(e,_t),i=Je(),l=i.isCompleted;/*#__PURE__*/return y.createElement(Ie,b({isDisabled:l,label:i.isLastStep||l?a:r},o,{className:qe("saas-form__next-button",e.className)}))};De&&(St.displayName="NextButton"),exports.ArrayField=be,exports.ArrayFieldAddButton=ye,exports.ArrayFieldContainer=xe,exports.ArrayFieldProvider=te,exports.ArrayFieldRemoveButton=he,exports.ArrayFieldRow=de,exports.ArrayFieldRowContainer=ve,exports.ArrayFieldRowFields=me,exports.ArrayFieldRowProvider=ae,exports.ArrayFieldRows=_e,exports.AutoForm=Ve,exports.BaseField=I,exports.CheckboxField=U,exports.DisplayField=function(e){var t=e.name,n=e.label,a=_(e,g);/*#__PURE__*/return y.createElement(r.FormControl,a,n?/*#__PURE__*/y.createElement(r.FormLabel,{htmlFor:t},n):null,/*#__PURE__*/y.createElement(r.Text,{fontSize:"md"},/*#__PURE__*/y.createElement(E,{name:t})))},exports.DisplayIf=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},exports.Field=R,exports.Fields=Ae,exports.Form=Ne,exports.FormLayout=Y,exports.FormLegend=Ee,exports.FormStep=gt,exports.FormStepper=function(e){var t=c.useMultiStyleConfig("Stepper",e),r=y.Children.map(e.children,function(e){if(y.isValidElement(e)&&(null==e?void 0:e.type)===gt){var t=vt(e.props);/*#__PURE__*/return y.createElement(lt,{name:e.props.name,title:e.props.title,isCompleted:t.isCompleted},e.props.children)}return e});/*#__PURE__*/return y.createElement(c.StylesProvider,{value:t},/*#__PURE__*/y.createElement(at,b({mb:"4"},e),r))},exports.FormValue=E,exports.InputField=B,exports.NativeSelectField=W,exports.NextButton=St,exports.NumberInputField=z,exports.ObjectField=Se,exports.PasswordInputFIeld=D,exports.PinField=G,exports.PrevButton=Et,exports.RadioField=$,exports.SelectField=M,exports.StepForm=xt,exports.StepFormProvider=ft,exports.SubmitButton=Ie,exports.SwitchField=T,exports.TextareaField=q,exports.registerFieldType=V,exports.useArrayField=ie,exports.useArrayFieldAddButton=se,exports.useArrayFieldContext=re,exports.useArrayFieldRemoveButton=ue,exports.useArrayFieldRow=le,exports.useArrayFieldRowContext=oe,exports.useFormStep=vt,exports.useStepForm=mt,exports.useStepFormContext=dt,exports.withControlledInput=P,exports.withUncontrolledInput=L,Object.keys(v).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return v[e]}})});
2
2
  //# sourceMappingURL=index.js.map