@saas-ui/forms 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/dist/array-field.d.ts +4 -1
- package/dist/array-field.d.ts.map +1 -1
- package/dist/auto-form.d.ts +1 -0
- package/dist/auto-form.d.ts.map +1 -1
- package/dist/display-field.d.ts.map +1 -1
- package/dist/display-if.d.ts +4 -1
- package/dist/display-if.d.ts.map +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/form.d.ts +1 -0
- package/dist/form.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/layout.d.ts +4 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/object-field.d.ts.map +1 -1
- package/dist/submit-button.d.ts.map +1 -1
- package/dist/zod/index.js +1 -1
- package/dist/zod/index.js.map +1 -1
- package/dist/zod/index.modern.js +1 -1
- package/dist/zod/index.modern.js.map +1 -1
- package/dist/zod/{index.d.ts → zod/src/index.d.ts} +0 -0
- package/dist/zod/{index.d.ts.map → zod/src/index.d.ts.map} +0 -0
- package/dist/zod/{zod-resolver.d.ts → zod/src/zod-resolver.d.ts} +0 -0
- package/dist/zod/{zod-resolver.d.ts.map → zod/src/zod-resolver.d.ts.map} +0 -0
- package/package.json +2 -1
- package/src/array-field.tsx +33 -1
- package/src/auto-form.tsx +9 -1
- package/src/display-field.tsx +9 -0
- package/src/display-if.tsx +5 -0
- package/src/field.tsx +6 -0
- package/src/fields.tsx +5 -0
- package/src/form.tsx +8 -0
- package/src/layout.tsx +13 -1
- package/src/object-field.tsx +5 -0
- package/src/submit-button.tsx +5 -0
- package/zod/package.json +1 -0
package/CHANGELOG.md
CHANGED
package/dist/array-field.d.ts
CHANGED
@@ -42,7 +42,10 @@ export declare const ArrayField: React.ForwardRefExoticComponent<ArrayFieldProps
|
|
42
42
|
export interface ArrayFieldRowsProps {
|
43
43
|
children: (fields: ArrayField[]) => React.ReactElement | null;
|
44
44
|
}
|
45
|
-
export declare const ArrayFieldRows:
|
45
|
+
export declare const ArrayFieldRows: {
|
46
|
+
({ children, }: ArrayFieldRowsProps): React.ReactElement | null;
|
47
|
+
displayName: string;
|
48
|
+
};
|
46
49
|
export declare const ArrayFieldContainer: React.ForwardRefExoticComponent<ArrayFieldProps & React.RefAttributes<UseArrayFieldReturn>>;
|
47
50
|
export {};
|
48
51
|
//# sourceMappingURL=array-field.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"array-field.d.ts","sourceRoot":"","sources":["../src/array-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAG3D,OAAO,EAAc,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAa,UAAU,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,EAKL,iBAAiB,EAKjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAE1B,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,UAAU,kBAAkB;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IAC1C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CActD,CAAA;
|
1
|
+
{"version":3,"file":"array-field.d.ts","sourceRoot":"","sources":["../src/array-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,eAAe,EAAE,MAAM,mBAAmB,CAAA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AAE,UAAU,EAAE,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CAC9D;AAED,eAAO,MAAM,cAAc;oBAExB,mBAAmB,GAAG,MAAM,YAAY,GAAG,IAAI;;CAGjD,CAAA;AAMD,eAAO,MAAM,mBAAmB,6FAgC/B,CAAA"}
|
package/dist/auto-form.d.ts
CHANGED
@@ -12,6 +12,7 @@ export interface AutoFormProps<TFieldValues extends FieldValues> extends Omit<Fo
|
|
12
12
|
export declare const AutoForm: (<TFieldValues extends FieldValues>(props: AutoFormProps<TFieldValues> & {
|
13
13
|
ref?: React.ForwardedRef<UseFormReturn<TFieldValues, object>> | undefined;
|
14
14
|
}) => React.ReactElement) & {
|
15
|
+
displayName?: string | undefined;
|
15
16
|
getFieldResolver?: ((schema: any) => FieldResolver) | undefined;
|
16
17
|
};
|
17
18
|
export {};
|
package/dist/auto-form.d.ts.map
CHANGED
@@ -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;
|
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,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAA;IACX,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;;MAoBhB,MAAM,YAAY;;iCAEO,GAAG,KAAK,aAAa;CAClD,CAAA"}
|
@@ -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;
|
1
|
+
{"version":3,"file":"display-field.d.ts","sourceRoot":"","sources":["../src/display-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,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;AAMD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAGhD,CAAA"}
|
package/dist/display-if.d.ts
CHANGED
@@ -8,5 +8,8 @@ export interface DisplayIfProps<TFieldValues> {
|
|
8
8
|
isExact?: boolean;
|
9
9
|
condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean;
|
10
10
|
}
|
11
|
-
export declare const DisplayIf:
|
11
|
+
export declare const DisplayIf: {
|
12
|
+
<TFieldValues extends FieldValues = FieldValues>({ children, name, defaultValue, isDisabled, isExact, condition, }: DisplayIfProps<TFieldValues>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
13
|
+
displayName: string;
|
14
|
+
};
|
12
15
|
//# sourceMappingURL=display-if.d.ts.map
|
package/dist/display-if.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"display-if.d.ts","sourceRoot":"","sources":["../src/display-if.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"display-if.d.ts","sourceRoot":"","sources":["../src/display-if.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAGL,WAAW,EACX,aAAa,EACd,MAAM,iBAAiB,CAAA;AAExB,MAAM,WAAW,cAAc,CAAC,YAAY;IAC1C,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,KAAK,OAAO,CAAA;CAC9E;AAED,eAAO,MAAM,SAAS;;;CAgBrB,CAAA"}
|
package/dist/field.d.ts.map
CHANGED
@@ -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,EASjB,MAAM,kBAAkB,CAAA;
|
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,EASjB,MAAM,kBAAkB,CAA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U,CAwB1C,CAAA;AAMD,eAAO,MAAM,KAAK;;;;MAkBb,MAAM,YAAY,CAAA;AA0DvB,eAAO,MAAM,mBAAmB,mBAAoB,GAAG,qFAqBtD,CAAA;AAED,eAAO,MAAM,qBAAqB,mBAAoB,GAAG,qFAgBxD,CAAA;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;CAC1B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,SACtB,MAAM,aACD,MAAM,EAAE,CAAC,GAAG,CAAC,qMAsBzB,CAAA;AAID,eAAO,MAAM,UAAU,kJAAmC,CAAA;AAC1D,eAAO,MAAM,gBAAgB,kJAE3B,CAAA;AACF,eAAO,MAAM,kBAAkB,kJAA+C,CAAA;AAC9E,eAAO,MAAM,aAAa,kJAA0C,CAAA;AACpE,eAAO,MAAM,WAAW,kJAavB,CAAA;AACD,eAAO,MAAM,WAAW,kJAEtB,CAAA;AACF,eAAO,MAAM,aAAa,kJAYzB,CAAA;AACD,eAAO,MAAM,UAAU,kJAErB,CAAA;AACF,eAAO,MAAM,QAAQ,kJAEnB,CAAA;AACF,eAAO,MAAM,iBAAiB,kJAI7B,CAAA"}
|
package/dist/fields.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,GAAG,CAAA;IACX,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;AAYD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwCxC,CAAA"}
|
package/dist/form.d.ts
CHANGED
@@ -30,6 +30,7 @@ export interface FormProps<TFieldValues extends FieldValues = FieldValues> exten
|
|
30
30
|
export declare const Form: (<TFieldValues extends FieldValues>(props: FormProps<TFieldValues> & {
|
31
31
|
ref?: React.ForwardedRef<UseFormReturn<TFieldValues, object>> | undefined;
|
32
32
|
}) => React.ReactElement) & {
|
33
|
+
displayName?: string | undefined;
|
33
34
|
getResolver?: GetResolver | undefined;
|
34
35
|
getFieldResolver: GetFieldResolver;
|
35
36
|
};
|
package/dist/form.d.ts.map
CHANGED
@@ -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;
|
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,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAuB,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AAEzD,UAAU,WAAW,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW;IAClE;;OAEG;IACH,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ;;OAEG;IACH,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAA;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAA;CAClD;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,CACvE,SAAQ,YAAY,CAAC,YAAY,CAAC,EAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC,EACrD,WAAW,CAAC,YAAY,CAAC;CAAG;AAEhC,eAAO,MAAM,IAAI;;MA8DZ,MAAM,YAAY;;;sBAGH,gBAAgB;CACnC,CAAA;AAQD,oBAAY,WAAW,GAAG,CACxB,MAAM,EAAE,GAAG,KACR,CAAC,YAAY,SAAS,WAAW,EAAE,QAAQ,EAC9C,MAAM,EAAE,iBAAiB,CAAC,YAAY,CAAC,EACvC,OAAO,EAAE,QAAQ,GAAG,SAAS,EAC7B,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,KACnC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAA;AAE1C,oBAAY,gBAAgB,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
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"),l=require("@saas-ui/radio"),i=require("@saas-ui/pin-input"),o=require("@saas-ui/select"),s=require("@chakra-ui/utils"),u=require("@chakra-ui/system"),c=require("@chakra-ui/icons"),m=require("@saas-ui/button"),d=require("@chakra-ui/react-utils"),p=require("@saas-ui/react-utils"),f=require("@saas-ui/input-right-button");function v(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 h=/*#__PURE__*/v(e);function x(){return x=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},x.apply(this,arguments)}function E(e,t){if(null==e)return{};var r,n,a={},l=Object.keys(e);for(n=0;n<l.length;n++)t.indexOf(r=l[n])>=0||(a[r]=e[r]);return a}var b=["name","label","placeholder"],y=function(e){var r=e.name;return(0,t.useFormContext().getValues)(r)||null},F=["name","label","help","variant","hideLabel","children"],S=["name","label","help","isDisabled","isInvalid","isReadOnly","isRequired","rules","variant"],_=["name","rules"],g=["ref"],C=["name","rules"],N=["ref"],k=["label"],R=["label"],w={},I=function(e){var n=e.name,a=e.label,l=e.help,i=e.variant,o=e.hideLabel,s=e.children,u=E(e,F),c=function(e,r){return t.get(r.errors,e)}(n,t.useFormContext().formState);/*#__PURE__*/return h.createElement(r.FormControl,x({variant:i},u,{isInvalid:!!c}),a&&!o?/*#__PURE__*/h.createElement(r.FormLabel,{variant:i},a):null,/*#__PURE__*/h.createElement(r.Box,null,s,!l||null!=c&&c.message?null:/*#__PURE__*/h.createElement(r.FormHelperText,null,l),(null==c?void 0:c.message)&&/*#__PURE__*/h.createElement(r.FormErrorMessage,null,null==c?void 0:c.message)))},A=r.forwardRef(function(e,t){var r=e.type;/*#__PURE__*/return h.createElement(w[void 0===r?"text":r]||w.text,x({ref:t},e))}),V=function(e){return r.forwardRef(function(n,a){var l=n.name,i=n.rules,o=E(n,_),s=t.useFormContext();/*#__PURE__*/return h.createElement(t.Controller,{name:l,control:s.control,rules:i,render:function(t){var n=t.field,l=n.ref,i=E(n,g);/*#__PURE__*/return h.createElement(e,x({},i,o,{ref:r.useMergeRefs(a,l)}))}})})},O=function(e){return r.forwardRef(function(n,a){var l=n.name,i=n.rules,o=E(n,C),s=(0,t.useFormContext().register)(l,i),u=s.ref,c=E(s,N);/*#__PURE__*/return h.createElement(e,x({},c,o,{ref:r.useMergeRefs(a,u)}))})},D=function(e,t,n){var a=function(e,t){var n=t.displayName,a=t.hideLabel,l=t.BaseField,i=r.forwardRef(function(t,r){var n=t.name,i=t.label,o=t.help,s=t.isDisabled,u=t.isInvalid,c=t.isReadOnly,m=t.isRequired,d=t.rules,p=t.variant,f=E(t,S),v=x({required:m},d);/*#__PURE__*/return h.createElement(l,{name:n,label:i,help:o,hideLabel:a,isDisabled:s,isInvalid:u,isReadOnly:c,isRequired:m,variant:p},/*#__PURE__*/h.createElement(e,x({ref:r,name:n,label:i,rules:v},f)))});return i.displayName=n,i}(null!=n&&n.isControlled?V(t):O(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 w[e]=a,a},P=D("text",r.Input),L=D("number",n.NumberInput,{isControlled:!0}),j=D("password",a.PasswordInput),q=D("textarea",r.Textarea),B=D("switch",r.forwardRef(function(e,t){var n=e.label,a=E(e,k);/*#__PURE__*/return h.createElement(r.Switch,x({ref:t},a),n)}),{isControlled:!0,hideLabel:!0}),M=D("select",o.Select,{isControlled:!0}),U=D("checkbox",r.forwardRef(function(e,t){var n=e.label,a=E(e,R);/*#__PURE__*/return h.createElement(r.Checkbox,x({ref:t},a),n)}),{hideLabel:!0}),T=D("radio",l.RadioInput,{isControlled:!0}),z=D("pin",i.PinInput,{isControlled:!0}),H=D("native-select",o.NativeSelect,{isControlled:!0}),G=function(e){return e&&Object.entries(e).map(function(e){return x({},e[1],{name:e[0]})})},W=function(e){return{getFields:function(){return G(e)},getNestedFields:function(t){var r,n=s.get(e,t);return n?"object"===(null==(r=n.items)?void 0:r.type)?G(n.items.properties):"object"===n.type?G(n.properties):[n.items]:[]}}},J=["mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","schema","defaultValues","onSubmit","onError","formRef","children"],K=r.forwardRef(function(e,n){var a=e.mode,l=void 0===a?"all":a,i=e.resolver,o=e.reValidateMode,s=e.shouldFocusError,u=e.shouldUnregister,c=e.shouldUseNativeValidation,m=e.criteriaMode,d=e.delayError,p=e.schema,f=e.defaultValues,v=e.onSubmit,b=e.onError,y=e.formRef,F=e.children,S=E(e,J),_={mode:l,resolver:i,defaultValues:f,reValidateMode:o,shouldFocusError:s,shouldUnregister:u,shouldUseNativeValidation:c,criteriaMode:m,delayError:d};p&&!i&&(_.resolver=null==K.getResolver?void 0:K.getResolver(p));var g=t.useForm(_),C=g.handleSubmit;return h.useImperativeHandle(n,function(){return g},[n,g]),/*#__PURE__*/h.createElement(t.FormProvider,g,/*#__PURE__*/h.createElement(r.chakra.form,x({ref:y,onSubmit:C(v,b)},S),F))});K.getFieldResolver=W;var Q=["children"],X=function(e){/*#__PURE__*/return h.createElement(r.chakra.div,null,e.children)},Y=function(e){var t,n,a,l=e.children,i=E(e,Q),o=x({},null!=(t=null==(n=r.useTheme().components)||null==(a=n.FormLayout)?void 0:a.defaultProps)?t:{spacing:4},i);/*#__PURE__*/return h.createElement(r.SimpleGrid,o,h.Children.map(l,function(e){return h.isValidElement(e)?/*#__PURE__*/h.createElement(X,null,e):e}))},Z=function(e,t){return h.Children.map(t,function(t){return h.isValidElement(t)&&t.props.name?h.cloneElement(t,x({},t.props,{name:e+"."+t.props.name})):t})},$=d.createContext({name:"ArrayFieldContext"}),ee=$[0],te=$[1],re=d.createContext({name:"ArrayFieldRowContext"}),ne=re[0],ae=re[1],le=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 x({},t.useFieldArray({control:s.control,name:r,keyName:l}),{name:r,defaultValue:a,min:i,max:o})},ie=function(e){var r=e.index,n=t.useFormContext().clearErrors,a=te(),l=a.name,i=a.remove,o=a.fields;return h.useEffect(function(){n(l)},[]),{index:r,isFirst:0===r,isLast:r===o.length-1,name:l+"."+r,remove:h.useCallback(function(){n(l),i(r)},[r])}},oe=function(){var e=ae(),t=e.isFirst,r=e.remove,n=te(),a=n.min;return{onClick:function(){return r()},isDisabled:t&&!!(a&&n.fields.length<=a)}},se=function(){var e=te(),t=e.append,r=e.defaultValue,n=e.max;return{onClick:function(){return t(r,{shouldFocus:!1})},isDisabled:!!(n&&e.fields.length>=n)}},ue=["children","columns","spacing"],ce=["children"],me=["name","defaultValue","keyName","min","max","children"],de=function(e){/*#__PURE__*/return h.createElement(fe,{index:e.index},/*#__PURE__*/h.createElement(pe,{columns:e.columns,spacing:e.spacing},e.children),/*#__PURE__*/h.createElement(ve,null))},pe=function(e){var t=e.children,r=e.columns,n=e.spacing,a=E(e,ue),l=ae().name;/*#__PURE__*/return h.createElement(Y,x({flex:"1",columns:r,gridGap:n,mr:"2"},a),Z(l,t))},fe=function(e){var t=e.children,r=ie({index:e.index});/*#__PURE__*/return h.createElement(ne,{value:r},/*#__PURE__*/h.createElement(u.chakra.div,{__css:{display:"flex",flexDirection:"row",alignItems:"flex-end",width:"100%",mb:4}},t))},ve=function(e){/*#__PURE__*/return h.createElement(m.IconButton,x({icon:/*#__PURE__*/h.createElement(c.MinusIcon,null),"aria-label":"Remove row"},oe(),e))},he=function(e){/*#__PURE__*/return h.createElement(m.IconButton,x({icon:/*#__PURE__*/h.createElement(c.AddIcon,null),"aria-label":"Add row",float:"right"},se(),e))},xe=h.forwardRef(function(e,t){var r=e.children,n=E(e,ce);/*#__PURE__*/return h.createElement(be,x({ref:t},n),/*#__PURE__*/h.createElement(Ee,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(he,null))}),Ee=function(e){return(0,e.children)(te().fields)},be=h.forwardRef(function(e,t){var r=e.name,n=e.defaultValue,a=e.keyName,l=e.min,i=e.max,o=e.children,s=E(e,me),u=le({name:r,defaultValue:n,keyName:a,min:l,max:i});return h.useImperativeHandle(t,function(){return u},[t,u]),/*#__PURE__*/h.createElement(ee,{value:u},/*#__PURE__*/h.createElement(I,x({name:r},s),o))}),ye=["name","label","hideLabel","children","columns","spacing"],Fe=function(e){var t=r.useStyles();/*#__PURE__*/return h.createElement(r.FormLabel,x({as:"legend",sx:t.legend},e))},Se=function(e){var t=e.name,n=e.label,a=e.hideLabel,l=e.children,i=e.columns,o=e.spacing,s=E(e,ye);/*#__PURE__*/return h.createElement(r.FormControl,x({name:t,as:"fieldset"},s),/*#__PURE__*/h.createElement(Fe,{display:a?"none":"block"},n),/*#__PURE__*/h.createElement(Y,{columns:i,gridGap:o},Z(t,l)))},_e=["name","type"],ge=["schema","fieldResolver"],Ce=["name","type","defaultValue"],Ne=function(e,t){var r;return null==(r=e.getNestedFields(t))?void 0:r.map(function(e,t){var r=e.name,n=e.type,a=E(e,_e);/*#__PURE__*/return h.createElement(A,x({key:r||t,name:r,type:n},a))})},ke=function(e){var t=e.schema,r=e.fieldResolver,n=E(e,ge),a=h.useMemo(function(){return r||K.getFieldResolver(t)},[t,r]);/*#__PURE__*/return h.createElement(Y,n,a.getFields().map(function(e){var t=e.name,r=e.type,n=E(e,Ce);return"array"===r?/*#__PURE__*/h.createElement(xe,x({key:t,name:t},n),Ne(a,t)):"object"===r?/*#__PURE__*/h.createElement(Se,x({key:t,name:t},n),Ne(a,t)):/*#__PURE__*/h.createElement(A,x({key:t,name:t,type:r},n))}))},Re=["children","disableIfUntouched","disableIfInvalid"],we=u.forwardRef(function(e,r){var n=e.children,a=e.disableIfUntouched,l=e.disableIfInvalid,i=E(e,Re),o=t.useFormContext().formState;/*#__PURE__*/return h.createElement(m.Button,x({type:"submit",isLoading:o.isSubmitting,isPrimary:!0,ref:r,isDisabled:a&&!o.isDirty||l&&!o.isValid},i),n)});we.defaultProps={label:"Submit",disableIfUntouched:!1,disableIfInvalid:!1};var Ie=["schema","submitLabel","fieldResolver"],Ae=r.forwardRef(function(e,t){var r=e.schema,n=e.submitLabel,a=void 0===n?"Submit":n,l=e.fieldResolver,i=E(e,Ie);/*#__PURE__*/return h.createElement(K,x({},i,{schema:r,ref:t}),/*#__PURE__*/h.createElement(Y,null,/*#__PURE__*/h.createElement(ke,{schema:r,fieldResolver:l}),a&&/*#__PURE__*/h.createElement(we,{label:a})))});function Ve(){return Ve=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},Ve.apply(this,arguments)}function Oe(e,t){if(null==e)return{};var r,n,a={},l=Object.keys(e);for(n=0;n<l.length;n++)t.indexOf(r=l[n])>=0||(a[r]=e[r]);return a}var De=d.createContext({name:"StepperContext",errorMessage:"useStepperContext: `context` is undefined. Seems you forgot to wrap stepper components in `<Stepper />`"}),Pe=De[0],Le=De[1];function je(e){var t=e.step,r=h.useState(-1),n=r[0],a=r[1],l=h.useRef([]),i=h.useState(Date.now())[1],o=h.useCallback(function(e){var t=[].concat(l.current);-1===t.indexOf(e)&&t.push(e),l.current=t,i(Date.now())},[l,i]),s=function(e){var t=l.current.indexOf(e);-1!==t&&a(t)};return h.useEffect(function(){"string"==typeof t?s(t):"number"==typeof t?a(t):-1===n&&a(0)},[t]),{stepsRef:l,activeStep:l.current[n],activeIndex:n,isFirstStep:0===n,isLastStep:n===l.current.length-1,isCompleted:n>=l.current.length,setIndex:a,setStep:s,nextStep:function(){a(n+1)},prevStep:function(){a(n-1)},registerStep:o,unregisterStep:function(e){l.current=l.current.slice(l.current.indexOf(e),1)}}}function qe(e){var t=e.name,r=e.isActive,n=e.isCompleted,a=Le(),l=a.registerStep,i=a.unregisterStep,o=a.activeStep;return h.useEffect(function(){if(t)return l(t),function(){i(t)}},[]),{isActive:t?o===t:r,isCompleted:n}}var Be=["children","orientation","step"],Me=["children","orientation","stepComponent"],Ue=["children","isOpen"],Te=["icon","isActive","isCompleted","className"],ze=["title","icon","isActive","isCompleted"],He=["isActive"],Ge=u.forwardRef(function(e,t){var r=e.children,n=e.orientation,a=void 0===n?"horizontal":n,l=Oe(e,Be),i=u.useMultiStyleConfig("Stepper",Ve({},l,{orientation:a})),o=u.omitThemingProps(l),c=je(e),m=Ve({display:"flex",flexDirection:"column"},i.container);return h.createElement(u.StylesProvider,{value:i},/*#__PURE__*/h.createElement(Pe,{value:c},/*#__PURE__*/h.createElement(u.chakra.div,Ve({ref:t,__css:m},o,{className:s.cx("saas-stepper",e.className)}),/*#__PURE__*/h.createElement(We,{orientation:a},r))))});s.__DEV__&&(Ge.displayName="Stepper");var We=function(e){var t,r,n=e.children,a=e.orientation,l=void 0===a?"horizontal":a,i=e.stepComponent,o=Oe(e,Me),c=u.useStyles(),m=Le().activeIndex,d=Ve({display:"flex",flexDirection:"row",alignItems:"center"},c.steps),f="vertical"===l,v=i||Qe,x=p.getChildrenOfType(n,v),E=x.reduce(function(e,t,r,n){return e.push(/*#__PURE__*/h.createElement(v,Ve({key:r},t.props,{icon:t.props.icon||r+1,isActive:m===r,isCompleted:t.props.isCompleted||m>r}))),f&&e.push(/*#__PURE__*/h.createElement(Je,{key:"content-"+r,isOpen:m===r},t.props.children)),r<n.length-1&&e.push(/*#__PURE__*/h.createElement(Xe,{key:"separator-"+r,isActive:r<m})),e},[]),b=p.getChildOfType(n,Ze),y=m>=x.length?b:f?null:/*#__PURE__*/h.createElement(Je,null,null==(t=x[m])||null==(r=t.props)?void 0:r.children);return h.createElement(h.Fragment,null,/*#__PURE__*/h.createElement(u.chakra.div,Ve({__css:d},o,{className:s.cx("saas-stepper__steps",e.className)}),E),y)};s.__DEV__&&(We.displayName="StepperSteps");var Je=function(e){var t=e.children,n=e.isOpen,a=void 0===n||n,l=Oe(e,Ue),i=u.useStyles();return h.createElement(u.chakra.div,Ve({__css:i.content},l,{className:s.cx("saas-stepper__content",e.className)}),/*#__PURE__*/h.createElement(r.Collapse,{in:a},t))};s.__DEV__&&(Je.displayName="StepperContent");var Ke=function(e){var t,r=e.icon,n=e.isCompleted,a=e.className,l=Oe(e,Te),i=Ve({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"full",fontSize:"1em"},u.useStyles().icon);return t=n?/*#__PURE__*/h.createElement(c.Icon,{as:c.CheckIcon}):r,/*#__PURE__*/h.createElement(u.chakra.div,Ve({__css:i},l,{className:s.cx("saas-stepper__icon",a)}),t)};s.__DEV__&&(Ke.displayName="StepperIcon");var Qe=function(e){var t=e.title,r=e.icon,n=e.isActive,a=e.isCompleted,l=Oe(e,ze),i=qe(e),o=Ve({display:"flex",alignItems:"center",flexDirection:"row"},u.useStyles().step);return h.createElement(u.chakra.div,Ve({},l,{__css:o,"data-active":s.dataAttr(i.isActive),"data-completed":s.dataAttr(i.isCompleted),className:s.cx("saas-stepper__step",e.className)}),/*#__PURE__*/h.createElement(Ke,{icon:r,isActive:n,isCompleted:a}),t&&/*#__PURE__*/h.createElement(Ye,null,t))};s.__DEV__&&(Qe.displayName="StepperStep");var Xe=function(e){var t=e.isActive,r=Oe(e,He),n=Ve({flex:1,mx:2},u.useStyles().separator);return h.createElement(u.chakra.div,Ve({},r,{"data-active":s.dataAttr(t),className:s.cx("saas-stepper__separator",e.className),__css:n}))};s.__DEV__&&(Xe.displayName="StepperSeparator");var Ye=function(e){var t=u.useStyles();return h.createElement(u.chakra.p,Ve({},e,{__css:t.title,className:s.cx("saas-stepper__title",e.className)}))};s.__DEV__&&(Ye.displayName="StepperStepTitle");var Ze=function(e){var t=u.useStyles();return h.createElement(u.chakra.div,Ve({__css:t.completed},e,{className:s.cx("saas-stepper__completed",e.className)}))};s.__DEV__&&(Ze.displayName="StepperCompleted");var $e=d.createContext({name:"StepFormContext",errorMessage:"useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"}),et=$e[0],tt=$e[1];function rt(e){var t=je(e),r=t.activeStep,n=t.isLastStep,a=t.nextStep,l=h.useState({}),i=l[0],o=l[1],s=h.useCallback(function(t){try{return n?Promise.resolve(null==e.onSubmit?void 0:e.onSubmit(t).then(function(){c(x({},i[r],{isCompleted:!0}))}).then(a)):(a(),Promise.resolve())}catch(e){return Promise.reject(e)}},[r,n]),u=h.useCallback(function(e){var t=i[r];return{onSubmit:s,schema:null==t?void 0:t.schema,resolver:null==t?void 0:t.resolver}},[i,s,r]),c=h.useCallback(function(e){o(function(t){var r;return x({},t,((r={})[e.name]=e,r))})},[i]);return x({getFormProps:u,updateStep:c,steps:i},t)}function nt(e){var t=e.name,r=e.schema,n=e.resolver,a=qe({name:t}),l=tt(),i=l.steps,o=l.updateStep;return h.useEffect(function(){o({name:t,schema:r,resolver:n})},[t,r]),x({},a,i[t]||{name:t,schema:r})}var at=["children","onSubmit"],lt=["getFormProps"],it=["name","schema","resolver","children","className"],ot=["label","submitLabel"],st=h.forwardRef(function(e,t){var r=e.children,n=E(e,at),a=rt(e),l=a.getFormProps,i=E(a,lt),o=h.useMemo(function(){return i},[i]);/*#__PURE__*/return h.createElement(Pe,{value:o},/*#__PURE__*/h.createElement(et,{value:o},/*#__PURE__*/h.createElement(K,x({ref:t},n,l(e)),s.runIfFn(r,a))))}),ut=function(e){var t=e.name,r=e.schema,n=e.resolver,a=e.children,l=e.className,i=E(e,it);return nt({name:t,schema:r,resolver:n}).isActive?/*#__PURE__*/h.createElement(u.chakra.div,x({},i,{className:s.cx("saas-form__step",l)}),a):null};s.__DEV__&&(ut.displayName="FormStep");var ct=function(e){var t=Le(),r=t.prevStep;/*#__PURE__*/return h.createElement(m.Button,x({isDisabled:t.isFirstStep||t.isCompleted,label:"Back"},e,{className:s.cx("saas-form__prev-button",e.className),onClick:s.callAllHandlers(e.onClick,r)}))};s.__DEV__&&(ct.displayName="PrevButton");var mt=function(e){var t=e.label,r=void 0===t?"Next":t,n=e.submitLabel,a=void 0===n?"Complete":n,l=E(e,ot),i=Le(),o=i.isCompleted;/*#__PURE__*/return h.createElement(we,x({isDisabled:o,label:i.isLastStep||o?a:r},l,{className:s.cx("saas-form__next-button",e.className)}))};s.__DEV__&&(mt.displayName="NextButton"),exports.ArrayField=xe,exports.ArrayFieldAddButton=he,exports.ArrayFieldContainer=be,exports.ArrayFieldProvider=ee,exports.ArrayFieldRemoveButton=ve,exports.ArrayFieldRow=de,exports.ArrayFieldRowContainer=fe,exports.ArrayFieldRowFields=pe,exports.ArrayFieldRowProvider=ne,exports.ArrayFieldRows=Ee,exports.AutoForm=Ae,exports.BaseField=I,exports.CheckboxField=U,exports.DisplayField=function(e){var t=e.name,n=e.label,a=E(e,b);/*#__PURE__*/return h.createElement(r.FormControl,a,n?/*#__PURE__*/h.createElement(r.FormLabel,{htmlFor:t},n):null,/*#__PURE__*/h.createElement(r.Text,{fontSize:"md"},/*#__PURE__*/h.createElement(y,{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=A,exports.Fields=ke,exports.Form=K,exports.FormLayout=Y,exports.FormLegend=Fe,exports.FormStep=ut,exports.FormStepper=function(e){var t=u.useMultiStyleConfig("Stepper",e),r=h.Children.map(e.children,function(e){if(h.isValidElement(e)&&(null==e?void 0:e.type)===ut){var t=nt(e.props);/*#__PURE__*/return h.createElement(Qe,{name:e.props.name,title:e.props.title,isCompleted:t.isCompleted},e.props.children)}return e});/*#__PURE__*/return h.createElement(u.StylesProvider,{value:t},/*#__PURE__*/h.createElement(We,x({mb:"4"},e),r))},exports.FormValue=y,exports.InputField=P,exports.NativeSelectField=H,exports.NextButton=mt,exports.NumberInputField=L,exports.ObjectField=Se,exports.PasswordInputFIeld=j,exports.PinField=z,exports.PrevButton=ct,exports.RadioField=T,exports.SelectField=M,exports.StepForm=st,exports.StepFormProvider=et,exports.SubmitButton=we,exports.SwitchField=B,exports.TextareaField=q,exports.objectFieldResolver=W,exports.registerFieldType=D,exports.useArrayField=le,exports.useArrayFieldAddButton=se,exports.useArrayFieldContext=te,exports.useArrayFieldRemoveButton=oe,exports.useArrayFieldRow=ie,exports.useArrayFieldRowContext=ae,exports.useFormStep=nt,exports.useStepForm=rt,exports.useStepFormContext=tt,exports.withControlledInput=V,exports.withUncontrolledInput=O,Object.keys(f).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return f[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"),i=require("@saas-ui/radio"),o=require("@saas-ui/pin-input"),s=require("@saas-ui/select"),u=require("@chakra-ui/system"),d=require("@chakra-ui/icons"),m=require("@saas-ui/button"),c=require("@chakra-ui/react-utils"),p=require("@saas-ui/stepper"),f=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 x=/*#__PURE__*/v(e);function h(){return h=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},h.apply(this,arguments)}function F(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 y=["name","label","placeholder"],b=function(e){var r=e.name,t=e.label,a=F(e,y);/*#__PURE__*/return x.createElement(n.FormControl,a,t?/*#__PURE__*/x.createElement(n.FormLabel,{htmlFor:r},t):null,/*#__PURE__*/x.createElement(n.Text,{fontSize:"md"},/*#__PURE__*/x.createElement(E,{name:r})))};r.__DEV__&&(b.displayName="DisplayField");var E=function(e){var r=e.name;return(0,t.useFormContext().getValues)(r)||null};r.__DEV__&&(E.displayName="FormValue");var _=["name","label","help","variant","hideLabel","children"],C=["name","label","help","isDisabled","isInvalid","isReadOnly","isRequired","rules","variant"],S=["name","rules"],g=["ref"],N=["name","rules"],R=["ref"],V=["label"],w=["label"],D={},A=function(e){var r=e.name,a=e.label,l=e.help,i=e.variant,o=e.hideLabel,s=e.children,u=F(e,_),d=function(e,r){return t.get(r.errors,e)}(r,t.useFormContext().formState);/*#__PURE__*/return x.createElement(n.FormControl,h({variant:i},u,{isInvalid:!!d}),a&&!o?/*#__PURE__*/x.createElement(n.FormLabel,{variant:i},a):null,/*#__PURE__*/x.createElement(n.Box,null,s,!l||null!=d&&d.message?null:/*#__PURE__*/x.createElement(n.FormHelperText,null,l),(null==d?void 0:d.message)&&/*#__PURE__*/x.createElement(n.FormErrorMessage,null,null==d?void 0:d.message)))};r.__DEV__&&(A.displayName="BaseField");var k=n.forwardRef(function(e,r){var t=e.type;/*#__PURE__*/return x.createElement(D[void 0===t?"text":t]||D.text,h({ref:r},e))}),I=function(e){return n.forwardRef(function(r,a){var l=r.name,i=r.rules,o=F(r,S),s=t.useFormContext();/*#__PURE__*/return x.createElement(t.Controller,{name:l,control:s.control,rules:i,render:function(r){var t=r.field,l=t.ref,i=F(t,g);/*#__PURE__*/return x.createElement(e,h({},i,o,{ref:n.useMergeRefs(a,l)}))}})})},L=function(e){return n.forwardRef(function(r,a){var l=r.name,i=r.rules,o=F(r,N),s=(0,t.useFormContext().register)(l,i),u=s.ref,d=F(s,R);/*#__PURE__*/return x.createElement(e,h({},d,o,{ref:n.useMergeRefs(a,u)}))})},P=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.name,i=r.label,o=r.help,s=r.isDisabled,u=r.isInvalid,d=r.isReadOnly,m=r.isRequired,c=r.rules,p=r.variant,f=F(r,C),v=h({required:m},c);/*#__PURE__*/return x.createElement(l,{name:n,label:i,help:o,hideLabel:a,isDisabled:s,isInvalid:u,isReadOnly:d,isRequired:m,variant:p},/*#__PURE__*/x.createElement(e,h({ref:t,name:n,label:i,rules:v},f)))});return i.displayName=t,i}(null!=t&&t.isControlled?I(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)||A});return D[e]=a,a},B=P("text",n.Input),q=P("number",a.NumberInput,{isControlled:!0}),O=P("password",l.PasswordInput),j=P("textarea",n.Textarea),M=P("switch",n.forwardRef(function(e,r){var t=e.label,a=F(e,V);/*#__PURE__*/return x.createElement(n.Switch,h({ref:r},a),t)}),{isControlled:!0,hideLabel:!0}),U=P("select",s.Select,{isControlled:!0}),T=P("checkbox",n.forwardRef(function(e,r){var t=e.label,a=F(e,w);/*#__PURE__*/return x.createElement(n.Checkbox,h({ref:r},a),t)}),{hideLabel:!0}),H=P("radio",i.RadioInput,{isControlled:!0}),G=P("pin",o.PinInput,{isControlled:!0}),z=P("native-select",s.NativeSelect,{isControlled:!0}),W=function(e){return e&&Object.entries(e).map(function(e){return h({},e[1],{name:e[0]})})},J=function(e){return{getFields:function(){return W(e)},getNestedFields:function(t){var n,a=r.get(e,t);return a?"object"===(null==(n=a.items)?void 0:n.type)?W(a.items.properties):"object"===a.type?W(a.properties):[a.items]:[]}}},K=["mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","schema","defaultValues","onSubmit","onError","formRef","children"],Q=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,m=e.shouldUseNativeValidation,c=e.criteriaMode,p=e.delayError,f=e.schema,v=e.defaultValues,y=e.onSubmit,b=e.onError,E=e.formRef,_=e.children,C=F(e,K),S={mode:i,resolver:o,defaultValues:v,reValidateMode:s,shouldFocusError:u,shouldUnregister:d,shouldUseNativeValidation:m,criteriaMode:c,delayError:p};f&&!o&&(S.resolver=null==Q.getResolver?void 0:Q.getResolver(f));var g=t.useForm(S),N=g.handleSubmit;return x.useImperativeHandle(a,function(){return g},[a,g]),/*#__PURE__*/x.createElement(t.FormProvider,g,/*#__PURE__*/x.createElement(n.chakra.form,h({ref:E,onSubmit:N(y,b)},C,{className:r.cx("saas-form",e.className)}),_))});Q.getFieldResolver=J,r.__DEV__&&(Q.displayName="Form");var X=["children"],Y=function(e){/*#__PURE__*/return x.createElement(n.chakra.div,null,e.children)};r.__DEV__&&(Y.displayName="FormLayoutItem");var Z=function(e){var t,a,l,i=e.children,o=F(e,X),s=h({},null!=(t=null==(a=n.useTheme().components)||null==(l=a.FormLayout)?void 0:l.defaultProps)?t:{spacing:4},o);/*#__PURE__*/return x.createElement(n.SimpleGrid,h({},s,{className:r.cx("saas-form__layout",o.className)}),x.Children.map(i,function(e){return x.isValidElement(e)?/*#__PURE__*/x.createElement(Y,null,e):e}))};r.__DEV__&&(Z.displayName="FormLayout");var $=function(e,r){return x.Children.map(r,function(r){return x.isValidElement(r)&&r.props.name?x.cloneElement(r,h({},r.props,{name:e+"."+r.props.name})):r})},ee=c.createContext({name:"ArrayFieldContext"}),re=ee[0],te=ee[1],ne=c.createContext({name:"ArrayFieldRowContext"}),ae=ne[0],le=ne[1],ie=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})},oe=function(e){var r=e.index,n=t.useFormContext().clearErrors,a=te(),l=a.name,i=a.remove,o=a.fields;return x.useEffect(function(){n(l)},[]),{index:r,isFirst:0===r,isLast:r===o.length-1,name:l+"."+r,remove:x.useCallback(function(){n(l),i(r)},[r])}},se=function(){var e=le(),r=e.isFirst,t=e.remove,n=te(),a=n.min;return{onClick:function(){return t()},isDisabled:r&&!!(a&&n.fields.length<=a)}},ue=function(){var e=te(),r=e.append,t=e.defaultValue,n=e.max;return{onClick:function(){return r(t,{shouldFocus:!1})},isDisabled:!!(n&&e.fields.length>=n)}},de=["children","columns","spacing"],me=["children"],ce=["name","defaultValue","keyName","min","max","children"],pe=function(e){/*#__PURE__*/return x.createElement(ve,{index:e.index},/*#__PURE__*/x.createElement(fe,{columns:e.columns,spacing:e.spacing},e.children),/*#__PURE__*/x.createElement(xe,null))};r.__DEV__&&(pe.displayName="ArrayFieldRow");var fe=function(e){var r=e.children,t=e.columns,n=e.spacing,a=F(e,de),l=le().name;/*#__PURE__*/return x.createElement(Z,h({flex:"1",columns:t,gridGap:n,mr:"2"},a),$(l,r))};r.__DEV__&&(fe.displayName="ArrayFieldRowFields");var ve=function(e){var r=e.children,t=oe({index:e.index});/*#__PURE__*/return x.createElement(ae,{value:t},/*#__PURE__*/x.createElement(u.chakra.div,{__css:{display:"flex",flexDirection:"row",alignItems:"flex-end",width:"100%",mb:4}},r))};r.__DEV__&&(ve.displayName="ArrayFieldRowContainer");var xe=function(e){/*#__PURE__*/return x.createElement(m.IconButton,h({icon:/*#__PURE__*/x.createElement(d.MinusIcon,null),"aria-label":"Remove row"},se(),e))};r.__DEV__&&(xe.displayName="ArrayFieldRemoveButton");var he=function(e){/*#__PURE__*/return x.createElement(m.IconButton,h({icon:/*#__PURE__*/x.createElement(d.AddIcon,null),"aria-label":"Add row",float:"right"},ue(),e))};r.__DEV__&&(he.displayName="ArrayFieldAddButton");var Fe=x.forwardRef(function(e,r){var t=e.children,n=F(e,me);/*#__PURE__*/return x.createElement(be,h({ref:r},n),/*#__PURE__*/x.createElement(ye,null,function(e){/*#__PURE__*/return x.createElement(x.Fragment,null,e.map(function(e,r){/*#__PURE__*/return x.createElement(pe,{key:e.id,index:r},t)}))}),/*#__PURE__*/x.createElement(he,null))});r.__DEV__&&(Fe.displayName="ArrayField");var ye=function(e){return(0,e.children)(te().fields)};r.__DEV__&&(ye.displayName="ArrayFieldRows");var be=x.forwardRef(function(e,r){var t=e.name,n=e.defaultValue,a=e.keyName,l=e.min,i=e.max,o=e.children,s=F(e,ce),u=ie({name:t,defaultValue:n,keyName:a,min:l,max:i});return x.useImperativeHandle(r,function(){return u},[r,u]),/*#__PURE__*/x.createElement(re,{value:u},/*#__PURE__*/x.createElement(A,h({name:t},s),o))});r.__DEV__&&(be.displayName="ArrayFieldContainer");var Ee=["name","label","hideLabel","children","columns","spacing"],_e=function(e){var r=n.useStyles();/*#__PURE__*/return x.createElement(n.FormLabel,h({as:"legend",sx:r.legend},e))},Ce=function(e){var r=e.name,t=e.label,a=e.hideLabel,l=e.children,i=e.columns,o=e.spacing,s=F(e,Ee);/*#__PURE__*/return x.createElement(n.FormControl,h({name:r,as:"fieldset"},s),/*#__PURE__*/x.createElement(_e,{display:a?"none":"block"},t),/*#__PURE__*/x.createElement(Z,{columns:i,gridGap:o},$(r,l)))};r.__DEV__&&(Ce.displayName="ObjectField");var Se=["name","type"],ge=["schema","fieldResolver"],Ne=["name","type","defaultValue"],Re=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=F(e,Se);/*#__PURE__*/return x.createElement(k,h({key:t||r,name:t,type:n},a))})},Ve=function(e){var r=e.schema,t=e.fieldResolver,n=F(e,ge),a=x.useMemo(function(){return t||Q.getFieldResolver(r)},[r,t]);/*#__PURE__*/return x.createElement(Z,n,a.getFields().map(function(e){var r=e.name,t=e.type,n=F(e,Ne);return"array"===t?/*#__PURE__*/x.createElement(Fe,h({key:r,name:r},n),Re(a,r)):"object"===t?/*#__PURE__*/x.createElement(Ce,h({key:r,name:r},n),Re(a,r)):/*#__PURE__*/x.createElement(k,h({key:r,name:r,type:t},n))}))};r.__DEV__&&(Ve.displayName="Fields");var we=["children","disableIfUntouched","disableIfInvalid"],De=u.forwardRef(function(e,r){var n=e.children,a=e.disableIfUntouched,l=e.disableIfInvalid,i=F(e,we),o=t.useFormContext().formState;/*#__PURE__*/return x.createElement(m.Button,h({type:"submit",isLoading:o.isSubmitting,isPrimary:!0,ref:r,isDisabled:a&&!o.isDirty||l&&!o.isValid},i),n)});De.defaultProps={label:"Submit",disableIfUntouched:!1,disableIfInvalid:!1},r.__DEV__&&(De.displayName="SubmitButton");var Ae=["schema","submitLabel","fieldResolver"],ke=n.forwardRef(function(e,r){var t=e.schema,n=e.submitLabel,a=void 0===n?"Submit":n,l=e.fieldResolver,i=F(e,Ae);/*#__PURE__*/return x.createElement(Q,h({},i,{schema:t,ref:r}),/*#__PURE__*/x.createElement(Z,null,/*#__PURE__*/x.createElement(Ve,{schema:t,fieldResolver:l}),a&&/*#__PURE__*/x.createElement(De,{label:a})))});r.__DEV__&&(ke.displayName="AutoForm");var Ie=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__&&(Ie.displayName="DisplayIf");var Le=c.createContext({name:"StepFormContext",errorMessage:"useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"}),Pe=Le[0],Be=Le[1];function qe(e){var r=p.useStepper(e),t=r.activeStep,n=r.isLastStep,a=r.nextStep,l=x.useState({}),i=l[0],o=l[1],s=x.useCallback(function(r){try{return n?Promise.resolve(null==e.onSubmit?void 0:e.onSubmit(r).then(function(){d(h({},i[t],{isCompleted:!0}))}).then(a)):(a(),Promise.resolve())}catch(e){return Promise.reject(e)}},[t,n]),u=x.useCallback(function(e){var r=i[t];return{onSubmit:s,schema:null==r?void 0:r.schema,resolver:null==r?void 0:r.resolver}},[i,s,t]),d=x.useCallback(function(e){o(function(r){var t;return h({},r,((t={})[e.name]=e,t))})},[i]);return h({getFormProps:u,updateStep:d,steps:i},r)}function Oe(e){var r=e.name,t=e.schema,n=e.resolver,a=p.useStep({name:r}),l=Be(),i=l.steps,o=l.updateStep;return x.useEffect(function(){o({name:r,schema:t,resolver:n})},[r,t]),h({},a,i[r]||{name:r,schema:t})}var je=["children","onSubmit"],Me=["getFormProps"],Ue=["name","schema","resolver","children","className"],Te=["label","submitLabel"],He=x.forwardRef(function(e,t){var n=e.children,a=F(e,je),l=qe(e),i=l.getFormProps,o=F(l,Me),s=x.useMemo(function(){return o},[o]);/*#__PURE__*/return x.createElement(p.StepperProvider,{value:s},/*#__PURE__*/x.createElement(Pe,{value:s},/*#__PURE__*/x.createElement(Q,h({ref:t},a,i(e)),r.runIfFn(n,l))))}),Ge=function(e){var t=e.name,n=e.schema,a=e.resolver,l=e.children,i=e.className,o=F(e,Ue);return Oe({name:t,schema:n,resolver:a}).isActive?/*#__PURE__*/x.createElement(u.chakra.div,h({},o,{className:r.cx("saas-form__step",i)}),l):null};r.__DEV__&&(Ge.displayName="FormStep");var ze=function(e){var t=p.useStepperContext(),n=t.prevStep;/*#__PURE__*/return x.createElement(m.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__&&(ze.displayName="PrevButton");var We=function(e){var t=e.label,n=void 0===t?"Next":t,a=e.submitLabel,l=void 0===a?"Complete":a,i=F(e,Te),o=p.useStepperContext(),s=o.isCompleted;/*#__PURE__*/return x.createElement(De,h({isDisabled:s,label:o.isLastStep||s?l:n},i,{className:r.cx("saas-form__next-button",e.className)}))};r.__DEV__&&(We.displayName="NextButton"),exports.ArrayField=Fe,exports.ArrayFieldAddButton=he,exports.ArrayFieldContainer=be,exports.ArrayFieldProvider=re,exports.ArrayFieldRemoveButton=xe,exports.ArrayFieldRow=pe,exports.ArrayFieldRowContainer=ve,exports.ArrayFieldRowFields=fe,exports.ArrayFieldRowProvider=ae,exports.ArrayFieldRows=ye,exports.AutoForm=ke,exports.BaseField=A,exports.CheckboxField=T,exports.DisplayField=b,exports.DisplayIf=Ie,exports.Field=k,exports.Fields=Ve,exports.Form=Q,exports.FormLayout=Z,exports.FormLegend=_e,exports.FormStep=Ge,exports.FormStepper=function(e){var r=u.useMultiStyleConfig("Stepper",e),t=x.Children.map(e.children,function(e){if(x.isValidElement(e)&&(null==e?void 0:e.type)===Ge){var r=Oe(e.props);/*#__PURE__*/return x.createElement(p.StepperStep,{name:e.props.name,title:e.props.title,isCompleted:r.isCompleted},e.props.children)}return e});/*#__PURE__*/return x.createElement(u.StylesProvider,{value:r},/*#__PURE__*/x.createElement(p.StepperSteps,h({mb:"4"},e),t))},exports.FormValue=E,exports.InputField=B,exports.NativeSelectField=z,exports.NextButton=We,exports.NumberInputField=q,exports.ObjectField=Ce,exports.PasswordInputFIeld=O,exports.PinField=G,exports.PrevButton=ze,exports.RadioField=H,exports.SelectField=U,exports.StepForm=He,exports.StepFormProvider=Pe,exports.SubmitButton=De,exports.SwitchField=M,exports.TextareaField=j,exports.objectFieldResolver=J,exports.registerFieldType=P,exports.useArrayField=ie,exports.useArrayFieldAddButton=ue,exports.useArrayFieldContext=te,exports.useArrayFieldRemoveButton=se,exports.useArrayFieldRow=oe,exports.useArrayFieldRowContext=le,exports.useFormStep=Oe,exports.useStepForm=qe,exports.useStepFormContext=Be,exports.withControlledInput=I,exports.withUncontrolledInput=L,Object.keys(f).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return f[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","../../saas-ui-stepper/dist/index.modern.js","../src/use-step-form.tsx","../src/step-form.tsx","../src/display-if.tsx"],"sourcesContent":["import * as React from 'react'\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\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\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} from '@chakra-ui/react'\n\nimport { NumberInput } from '@saas-ui/number-input'\nimport { PasswordInput } from '@saas-ui/password-input'\nimport { RadioInput } from '@saas-ui/radio'\nimport { PinInput } from '@saas-ui/pin-input'\nimport { Select, NativeSelect } from '@saas-ui/select'\nimport { FocusableElement } from '@chakra-ui/utils'\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 type FieldTypes =\n | 'text'\n | 'number'\n | 'password'\n | 'textarea'\n | 'select'\n | 'native-select'\n | 'checkbox'\n | 'radio'\n | 'switch'\n | 'pin'\n | string\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 * Options used for selects and radio fields\n */\n options?: Option[]\n /**\n * The field type\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 * @default 'text'\n */\n type?: FieldTypes\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<FieldTypes, 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}\nexport const Field = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> & {\n [key: string]: unknown // Make sure attributes of custom components work. Need to change this to a global typedef at some point.\n },\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 [key: string]: unknown\n } & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement\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<FieldProps, typeof FormControl>((props, ref) => {\n const {\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 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 name={name}\n label={label}\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: 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: 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 checkbox or switch field.\n */\nexport const registerFieldType = (\n type: string,\n component: React.FC<any>,\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 })\n\n inputTypes[type] = Field\n\n return Field\n}\n\n// @todo Consider not registering all fields by default to lower the package size and computations.\n// Not all types may be required in a project.\nexport const InputField = registerFieldType('text', Input)\nexport const NumberInputField = registerFieldType('number', NumberInput, {\n isControlled: true,\n})\nexport const PasswordInputFIeld = registerFieldType('password', PasswordInput)\nexport const TextareaField = registerFieldType('textarea', Textarea)\nexport const SwitchField = registerFieldType(\n 'switch',\n forwardRef(({ label, ...props }: { label?: string }, ref) => {\n return (\n <Switch ref={ref} {...props}>\n {label}\n </Switch>\n )\n }),\n {\n isControlled: true,\n hideLabel: true,\n }\n)\nexport const SelectField = registerFieldType('select', Select, {\n isControlled: true,\n})\nexport const CheckboxField = registerFieldType(\n 'checkbox',\n forwardRef(({ label, ...props }: { label?: string }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\nexport const RadioField = registerFieldType('radio', RadioInput, {\n isControlled: true,\n})\nexport const PinField = registerFieldType('pin', PinInput, {\n isControlled: true,\n})\nexport const NativeSelectField = registerFieldType(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\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) =>\n schema &&\n Object.entries(schema).map(([name, field]) => {\n return {\n ...field,\n name,\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'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n UnpackNestedValue,\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.MutableRefObject<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 >\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 getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: UnpackNestedValue<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'\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\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 {...gridProps}>\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","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 } from '@chakra-ui/system'\n\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout } 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 {\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\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n columns,\n spacing,\n index,\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields columns={columns} spacing={spacing}>\n {children}\n </ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nexport interface ArrayFieldRowFieldsProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n columns,\n spacing,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout\n flex=\"1\"\n columns={columns}\n gridGap={spacing}\n mr=\"2\"\n {...layoutProps}\n >\n {mapNestedFields(name, children)}\n </FormLayout>\n )\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\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\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\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = React.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)\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\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","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyles,\n} from '@chakra-ui/react'\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 = useStyles()\n return <FormLabel as=\"legend\" sx={styles.legend} {...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","import * as React from 'react'\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'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\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 ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n return (\n <FormLayout {...props}>\n {resolver\n .getFields()\n .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","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { forwardRef } from '@chakra-ui/system'\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 = forwardRef<SubmitButtonProps, 'button'>(\n (props, ref) => {\n const { children, disableIfUntouched, disableIfInvalid, ...rest } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid)\n\n return (\n <Button\n type=\"submit\"\n isLoading={formState.isSubmitting}\n isPrimary\n ref={ref}\n isDisabled={isDisabled}\n {...rest}\n >\n {children}\n </Button>\n )\n }\n)\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\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 submitLabel?: false | string\n schema: any\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 { schema, submitLabel = 'Submit', fieldResolver, ...rest } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton label={submitLabel} />}\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) & { getFieldResolver?: (schema: any) => FieldResolver }\n","import*as e from\"react\";import{forwardRef as t,useMultiStyleConfig as s,omitThemingProps as n,StylesProvider as r,chakra as a,useStyles as i}from\"@chakra-ui/system\";import{Icon as c,CheckIcon as l}from\"@chakra-ui/icons\";import{Collapse as p}from\"@saas-ui/collapse\";import{getChildrenOfType as o,getChildOfType as m}from\"@saas-ui/react-utils\";import{cx as u,__DEV__ as d,dataAttr as f}from\"@chakra-ui/utils\";import{createContext as S}from\"@chakra-ui/react-utils\";function v(){return v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},v.apply(this,arguments)}function _(e,t){if(null==e)return{};var s,n,r={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(s=a[n])>=0||(r[s]=e[s]);return r}const[h,N]=S({name:\"StepperContext\",errorMessage:\"useStepperContext: `context` is undefined. Seems you forgot to wrap stepper components in `<Stepper />`\"});function y(t){const{step:s}=t,[n,r]=e.useState(-1),a=e.useRef([]),[,i]=e.useState(Date.now()),c=e.useCallback(e=>{const t=[...a.current];-1===t.indexOf(e)&&t.push(e),a.current=t,i(Date.now())},[a,i]),l=e=>{const t=a.current.indexOf(e);-1!==t&&r(t)};return e.useEffect(()=>{\"string\"==typeof s?l(s):\"number\"==typeof s?r(s):-1===n&&r(0)},[s]),{stepsRef:a,activeStep:a.current[n],activeIndex:n,isFirstStep:0===n,isLastStep:n===a.current.length-1,isCompleted:n>=a.current.length,setIndex:r,setStep:l,nextStep:()=>{r(n+1)},prevStep:()=>{r(n-1)},registerStep:c,unregisterStep:e=>{a.current=a.current.slice(a.current.indexOf(e),1)}}}function x(t){const{name:s,isActive:n,isCompleted:r}=t,{registerStep:a,unregisterStep:i,activeStep:c}=N();return e.useEffect(()=>{if(s)return a(s),()=>{i(s)}},[]),{isActive:s?c===s:n,isCompleted:r}}function C({label:e=\"Back\"}={}){const{isFirstStep:t,prevStep:s}=N();return{isDisabled:t,onClick:s,label:e}}function E({label:e=\"Next\",submitLabel:t=\"Submit\"}={}){const{isLastStep:s,isCompleted:n,nextStep:r}=N();return{isDisabled:n,onClick:r,label:s?t:e}}const g=[\"children\",\"orientation\",\"step\"],b=[\"children\",\"orientation\",\"stepComponent\"],k=[\"children\",\"isOpen\"],A=[\"icon\",\"isActive\",\"isCompleted\",\"className\"],O=[\"title\",\"icon\",\"isActive\",\"isCompleted\"],D=[\"isActive\"],I=t((t,i)=>{const{children:c,orientation:l=\"horizontal\"}=t,p=_(t,g),o=s(\"Stepper\",v({},p,{orientation:l})),m=n(p),d=y(t),f=v({display:\"flex\",flexDirection:\"column\"},o.container);/*#__PURE__*/return e.createElement(r,{value:o},/*#__PURE__*/e.createElement(h,{value:d},/*#__PURE__*/e.createElement(a.div,v({ref:i,__css:f},m,{className:u(\"saas-stepper\",t.className)}),/*#__PURE__*/e.createElement(w,{orientation:l},c))))});d&&(I.displayName=\"Stepper\");const w=t=>{var s,n;const{children:r,orientation:c=\"horizontal\",stepComponent:l}=t,p=_(t,b),d=i(),{activeIndex:f}=N(),S=v({display:\"flex\",flexDirection:\"row\",alignItems:\"center\"},d.steps),h=\"vertical\"===c,y=l||F,x=o(r,y),C=x.reduce((t,s,n,r)=>(t.push(/*#__PURE__*/e.createElement(y,v({key:n},s.props,{icon:s.props.icon||n+1,isActive:f===n,isCompleted:s.props.isCompleted||f>n}))),h&&t.push(/*#__PURE__*/e.createElement(j,{key:`content-${n}`,isOpen:f===n},s.props.children)),n<r.length-1&&t.push(/*#__PURE__*/e.createElement(L,{key:`separator-${n}`,isActive:n<f})),t),[]),E=m(r,$),g=f>=x.length?E:h?null:/*#__PURE__*/e.createElement(j,null,null==(s=x[f])||null==(n=s.props)?void 0:n.children);/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(a.div,v({__css:S},p,{className:u(\"saas-stepper__steps\",t.className)}),C),g)};d&&(w.displayName=\"StepperSteps\");const j=t=>{const{children:s,isOpen:n=!0}=t,r=_(t,k),c=i();/*#__PURE__*/return e.createElement(a.div,v({__css:c.content},r,{className:u(\"saas-stepper__content\",t.className)}),/*#__PURE__*/e.createElement(p,{in:n},s))};d&&(j.displayName=\"StepperContent\");const z=t=>{const{icon:s,isCompleted:n,className:r}=t,p=_(t,A),o=v({display:\"flex\",alignItems:\"center\",justifyContent:\"center\",borderRadius:\"full\",fontSize:\"1em\"},i().icon);let m;return m=n?/*#__PURE__*/e.createElement(c,{as:l}):s,/*#__PURE__*/e.createElement(a.div,v({__css:o},p,{className:u(\"saas-stepper__icon\",r)}),m)};d&&(z.displayName=\"StepperIcon\");const F=t=>{const{title:s,icon:n,isActive:r,isCompleted:c}=t,l=_(t,O),p=x(t),o=v({display:\"flex\",alignItems:\"center\",flexDirection:\"row\"},i().step);/*#__PURE__*/return e.createElement(a.div,v({},l,{__css:o,\"data-active\":f(p.isActive),\"data-completed\":f(p.isCompleted),className:u(\"saas-stepper__step\",t.className)}),/*#__PURE__*/e.createElement(z,{icon:n,isActive:r,isCompleted:c}),s&&/*#__PURE__*/e.createElement(R,null,s))};d&&(F.displayName=\"StepperStep\");const L=t=>{const{isActive:s}=t,n=_(t,D),r=v({flex:1,mx:2},i().separator);/*#__PURE__*/return e.createElement(a.div,v({},n,{\"data-active\":f(s),className:u(\"saas-stepper__separator\",t.className),__css:r}))};d&&(L.displayName=\"StepperSeparator\");const R=t=>{const s=i();/*#__PURE__*/return e.createElement(a.p,v({},t,{__css:s.title,className:u(\"saas-stepper__title\",t.className)}))};d&&(R.displayName=\"StepperStepTitle\");const $=t=>{const s=i();/*#__PURE__*/return e.createElement(a.div,v({__css:s.completed},t,{className:u(\"saas-stepper__completed\",t.className)}))};d&&($.displayName=\"StepperCompleted\");export{I as Stepper,$ as StepperCompleted,j as StepperContent,z as StepperIcon,h as StepperProvider,L as StepperSeparator,F as StepperStep,R as StepperStepTitle,w as StepperSteps,E as useNext,C as usePrev,x as useStep,y as useStepper,N as useStepperContext};\n//# sourceMappingURL=index.modern.js.map\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler } from 'react-hook-form'\nimport { createContext } 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}\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 UseStepperProps,\n FormProps<TFieldValues> {}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n) {\n const stepper = useStepper(props)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n if (isLastStep) {\n return props\n .onSubmit?.(data)\n .then(() => {\n const step = steps[activeStep]\n updateStep({\n ...step,\n isCompleted: true,\n })\n })\n .then(nextStep) // Show completed step\n }\n\n nextStep()\n },\n [activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(\n (props) => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n },\n [steps, onSubmitStep, activeStep]\n )\n\n const updateStep = React.useCallback(\n (step) => {\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 type UseStepFormReturn = ReturnType<typeof useStepForm>\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver })\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 {\n chakra,\n HTMLChakraProps,\n useMultiStyleConfig,\n StylesProvider,\n} 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} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form, FormProps } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues>,\n FormProps<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, onSubmit, ...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(props)}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: FormProps<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 styles = useMultiStyleConfig('Stepper', props)\n\n const { children } = 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 return (\n <StylesProvider value={styles}>\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StylesProvider>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n HTMLChakraProps<'div'> {}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, ...rest } = props\n const step = useFormStep({ name, schema, resolver })\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 isDisabled={isCompleted}\n label={isLastStep || isCompleted ? submitLabel : label}\n {...rest}\n className={cx('saas-form__next-button', props.className)}\n />\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n","import * as React from 'react'\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"],"names":["FormValue","name","getValues","useFormContext","inputTypes","BaseField","props","label","help","variant","hideLabel","children","controlProps","error","formState","get","errors","getError","React","FormControl","isInvalid","FormLabel","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","withControlledInput","InputComponent","rules","inputProps","Controller","control","render","field","_ref","useMergeRefs","withUncontrolledInput","register","registerFieldType","component","options","displayName","isDisabled","isReadOnly","isRequired","inputRules","required","createField","isControlled","split","map","part","charAt","toUpperCase","slice","join","InputField","Input","NumberInputField","NumberInput","PasswordInputFIeld","PasswordInput","TextareaField","Textarea","SwitchField","Switch","SelectField","Select","CheckboxField","Checkbox","RadioField","RadioInput","PinField","PinInput","NativeSelectField","NativeSelect","mapFields","schema","Object","entries","objectFieldResolver","getFields","getNestedFields","items","properties","Form","mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","rest","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","getFieldResolver","FormLayoutItem","div","FormLayout","gridProps","useTheme","components","_theme$components","_theme$components$For2","defaultProps","spacing","SimpleGrid","Children","child","isValidElement","mapNestedFields","cloneElement","createContext","ArrayFieldProvider","useArrayFieldContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","defaultValue","keyName","min","max","useFieldArray","useArrayFieldRow","index","clearErrors","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","onClick","useArrayFieldAddButton","append","shouldFocus","ArrayFieldRow","ArrayFieldRowContainer","ArrayFieldRowFields","columns","ArrayFieldRemoveButton","layoutProps","flex","gridGap","mr","context","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","key","id","fieldProps","FormLegend","styles","useStyles","as","sx","legend","ObjectField","_resolver$getNestedFi","i","nestedFieldProps","Fields","fieldResolver","useMemo","SubmitButton","disableIfUntouched","disableIfInvalid","Button","isLoading","isSubmitting","isPrimary","isDirty","isValid","AutoForm","submitLabel","errorMessage","StepperProvider","useStepperContext","useStepper","step","useState","activeIndex","setIndex","stepsRef","useRef","onUpdate","Date","now","registerStep","newSteps","current","indexOf","push","setStep","activeStep","isFirstStep","isLastStep","isCompleted","nextStep","prevStep","unregisterStep","useStep","isActive","StepFormProvider","useStepFormContext","useStepForm","stepper","steps","updateSteps","onSubmitStep","data","then","updateStep","getFormProps","useFormStep","StepForm","ctx","runIfFn","FormStep","className","cx","__DEV__","PrevButton","callAllHandlers","NextButton","htmlFor","Text","fontSize","condition","useWatch","disabled","exact","isExact","useMultiStyleConfig","elements","StepperStep","title","StylesProvider","StepperSteps"],"mappings":"ynCAgCaA,EAAwC,gBAAGC,IAAAA,KAEtD,OAAOC,EADeC,mBAAdD,WACSD,IAAS,kPC8EtBG,EAAsC,GAmB/BC,EAAkC,SAACC,GAC9C,IAAQL,EACNK,EADML,KAAMM,EACZD,EADYC,MAAOC,EACnBF,EADmBE,KAAMC,EACzBH,EADyBG,QAASC,EAClCJ,EADkCI,UAAWC,EAC7CL,EAD6CK,SAAaC,IAC1DN,KAIIO,EAjBS,SAACZ,EAAca,GAC9B,OAAOC,MAAID,EAAUE,OAAQf,GAgBfgB,CAAShB,EAFDE,mBAAdW,wBAIR,OACEI,gBAACC,iBAAYV,QAASA,GAAaG,GAAcQ,YAAaP,IAC3DN,IAAUG,eACTQ,gBAACG,aAAUZ,QAASA,GAAUF,GAC5B,kBACJW,gBAACI,WACEX,GACAH,SAASK,GAAAA,EAAOU,QAEb,kBADFL,gBAACM,sBAAgBhB,UAElBK,SAAAA,EAAOU,uBACNL,gBAACO,8BAAkBZ,SAAAA,EAAOU,YAMvBG,EAAQC,aACnB,SACErB,EAGAsB,GAEA,MAAoCtB,EAA5BuB,kBAGR,OAAOX,gBAjDFd,aAHgB,WAGIA,EAAU,QAi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Y,gBAACC,cAAgBb,EACdC,eAAQW,gBAACG,aAAU6O,QAASjQ,GAAOM,GAAqB,kBACzDW,gBAACiP,QAAKC,SAAS,mBACblP,gBAAClB,GAAUC,KAAMA,yBeTA,gBACvBU,IAAAA,aAKA0P,UASA,kBATY,SAACjG,WAAYA,MAEXkG,WAAS,CACrBrQ,OAPFA,KAQEqI,eAPFA,aAQEiI,WAPFzN,WAQE0N,QAPFC,UASgBtQ,oBACmBQ,EAAW,0IDgDQ,SAACL,GACvD,IAAMmL,EAASiF,sBAAoB,UAAWpQ,GAIxCqQ,EAAWzP,EAAMyG,SAASrE,IAFXhD,EAAbK,SAEsC,SAACiH,GAC7C,GAAI1G,EAAM2G,eAAeD,WAAUA,SAAAA,EAAO/F,QAAS8N,GAAU,CAC3D,MAAwBJ,GAAY3H,EAAMtH,oBAC1C,OACEY,gBAAC0P,IACC3Q,KAAM2H,EAAMtH,MAAML,KAClB4Q,MAAOjJ,EAAMtH,MAAMuQ,MACnBvC,cALIA,aAOH1G,EAAMtH,MAAMK,UAInB,OAAOiH,iBAGT,OACE1G,gBAAC4P,kBAAe1G,MAAOqB,gBACrBvK,gBAAC6P,MAAarG,GAAG,KAAQpK,GACtBqQ"}
|
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} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { NumberInput } from '@saas-ui/number-input'\nimport { PasswordInput } from '@saas-ui/password-input'\nimport { RadioInput } from '@saas-ui/radio'\nimport { PinInput } from '@saas-ui/pin-input'\nimport { Select, NativeSelect } from '@saas-ui/select'\nimport { FocusableElement } from '@chakra-ui/utils'\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 type FieldTypes =\n | 'text'\n | 'number'\n | 'password'\n | 'textarea'\n | 'select'\n | 'native-select'\n | 'checkbox'\n | 'radio'\n | 'switch'\n | 'pin'\n | string\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 * Options used for selects and radio fields\n */\n options?: Option[]\n /**\n * The field type\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 * @default 'text'\n */\n type?: FieldTypes\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<FieldTypes, 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 const Field = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> & {\n [key: string]: unknown // Make sure attributes of custom components work. Need to change this to a global typedef at some point.\n },\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 [key: string]: unknown\n } & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement\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<FieldProps, typeof FormControl>((props, ref) => {\n const {\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 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 name={name}\n label={label}\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: 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: 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 checkbox or switch field.\n */\nexport const registerFieldType = (\n type: string,\n component: React.FC<any>,\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 })\n\n inputTypes[type] = Field\n\n return Field\n}\n\n// @todo Consider not registering all fields by default to lower the package size and computations.\n// Not all types may be required in a project.\nexport const InputField = registerFieldType('text', Input)\nexport const NumberInputField = registerFieldType('number', NumberInput, {\n isControlled: true,\n})\nexport const PasswordInputFIeld = registerFieldType('password', PasswordInput)\nexport const TextareaField = registerFieldType('textarea', Textarea)\nexport const SwitchField = registerFieldType(\n 'switch',\n forwardRef(({ label, ...props }: { label?: string }, ref) => {\n return (\n <Switch ref={ref} {...props}>\n {label}\n </Switch>\n )\n }),\n {\n isControlled: true,\n hideLabel: true,\n }\n)\nexport const SelectField = registerFieldType('select', Select, {\n isControlled: true,\n})\nexport const CheckboxField = registerFieldType(\n 'checkbox',\n forwardRef(({ label, ...props }: { label?: string }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\nexport const RadioField = registerFieldType('radio', RadioInput, {\n isControlled: true,\n})\nexport const PinField = registerFieldType('pin', PinInput, {\n isControlled: true,\n})\nexport const NativeSelectField = registerFieldType(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\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) =>\n schema &&\n Object.entries(schema).map(([name, field]) => {\n return {\n ...field,\n name,\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 UnpackNestedValue,\n ResolverOptions,\n ResolverResult,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\nimport { css } from '@emotion/react'\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.MutableRefObject<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: UnpackNestedValue<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 } 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 } 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 {\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\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n columns,\n spacing,\n index,\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields columns={columns} spacing={spacing}>\n {children}\n </ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n columns,\n spacing,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout\n flex=\"1\"\n columns={columns}\n gridGap={spacing}\n mr=\"2\"\n {...layoutProps}\n >\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 = React.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)\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 useStyles,\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 = useStyles()\n return <FormLabel as=\"legend\" sx={styles.legend} {...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'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\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 ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n return (\n <FormLayout {...props}>\n {resolver\n .getFields()\n .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 { forwardRef } from '@chakra-ui/system'\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 = forwardRef<SubmitButtonProps, 'button'>(\n (props, ref) => {\n const { children, disableIfUntouched, disableIfInvalid, ...rest } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid)\n\n return (\n <Button\n type=\"submit\"\n isLoading={formState.isSubmitting}\n isPrimary\n ref={ref}\n isDisabled={isDisabled}\n {...rest}\n >\n {children}\n </Button>\n )\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 submitLabel?: false | string\n schema: any\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 { schema, submitLabel = 'Submit', fieldResolver, ...rest } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton label={submitLabel} />}\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 } 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}\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 UseStepperProps,\n FormProps<TFieldValues> {}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n) {\n const stepper = useStepper(props)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n if (isLastStep) {\n return props\n .onSubmit?.(data)\n .then(() => {\n const step = steps[activeStep]\n updateStep({\n ...step,\n isCompleted: true,\n })\n })\n .then(nextStep) // Show completed step\n }\n\n nextStep()\n },\n [activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(\n (props) => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n },\n [steps, onSubmitStep, activeStep]\n )\n\n const updateStep = React.useCallback(\n (step) => {\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 type UseStepFormReturn = ReturnType<typeof useStepForm>\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver })\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 {\n chakra,\n HTMLChakraProps,\n useMultiStyleConfig,\n StylesProvider,\n} 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} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form, FormProps } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues>,\n FormProps<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, onSubmit, ...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(props)}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: FormProps<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 styles = useMultiStyleConfig('Stepper', props)\n\n const { children } = 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 return (\n <StylesProvider value={styles}>\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StylesProvider>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n HTMLChakraProps<'div'> {}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, ...rest } = props\n const step = useFormStep({ name, schema, resolver })\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 isDisabled={isCompleted}\n label={isLastStep || isCompleted ? submitLabel : label}\n {...rest}\n className={cx('saas-form__next-button', props.className)}\n />\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n"],"names":["DisplayField","name","label","props","React","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","getValues","useFormContext","inputTypes","BaseField","help","variant","hideLabel","children","controlProps","error","formState","get","errors","getError","isInvalid","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","withControlledInput","InputComponent","rules","inputProps","Controller","control","render","field","_ref","useMergeRefs","withUncontrolledInput","register","registerFieldType","component","options","isDisabled","isReadOnly","isRequired","inputRules","required","createField","isControlled","split","map","part","charAt","toUpperCase","slice","join","InputField","Input","NumberInputField","NumberInput","PasswordInputFIeld","PasswordInput","TextareaField","Textarea","SwitchField","Switch","SelectField","Select","CheckboxField","Checkbox","RadioField","RadioInput","PinField","PinInput","NativeSelectField","NativeSelect","mapFields","schema","Object","entries","objectFieldResolver","getFields","getNestedFields","items","properties","Form","mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","rest","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","className","cx","getFieldResolver","FormLayoutItem","div","FormLayout","gridProps","useTheme","components","_theme$components","_theme$components$For2","defaultProps","spacing","SimpleGrid","Children","child","isValidElement","mapNestedFields","cloneElement","createContext","ArrayFieldProvider","useArrayFieldContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","defaultValue","keyName","min","max","useFieldArray","useArrayFieldRow","index","clearErrors","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","onClick","useArrayFieldAddButton","append","shouldFocus","ArrayFieldRow","ArrayFieldRowContainer","ArrayFieldRowFields","columns","ArrayFieldRemoveButton","layoutProps","flex","gridGap","mr","context","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","key","id","fieldProps","FormLegend","styles","useStyles","as","sx","legend","ObjectField","_resolver$getNestedFi","i","nestedFieldProps","Fields","fieldResolver","useMemo","SubmitButton","disableIfUntouched","disableIfInvalid","Button","isLoading","isSubmitting","isPrimary","isDirty","isValid","AutoForm","submitLabel","DisplayIf","condition","useWatch","disabled","exact","isExact","errorMessage","StepFormProvider","useStepFormContext","useStepForm","stepper","useStepper","activeStep","isLastStep","nextStep","useState","steps","updateSteps","onSubmitStep","data","then","updateStep","isCompleted","getFormProps","step","useFormStep","useStep","StepForm","ctx","StepperProvider","runIfFn","FormStep","isActive","PrevButton","useStepperContext","prevStep","isFirstStep","callAllHandlers","NextButton","useMultiStyleConfig","elements","StepperStep","title","StylesProvider","StepperSteps"],"mappings":"qnCAiBaA,EAA4C,YACvDC,IAAAA,IAAAA,KACAC,IAAAA,MAEGC,sBAEH,OACEC,gBAACC,cAAgBF,EACdD,eAAQE,gBAACE,aAAUC,QAASN,GAAOC,GAAqB,kBACzDE,gBAACI,QAAKC,SAAS,mBACbL,gBAACM,GAAUT,KAAMA,OAMrBU,YACFX,EAAaY,YAAc,gBAGhBF,IAAAA,EAAwC,gBAAGT,IAAAA,KAEtD,OAAOY,EADeC,mBAAdD,WACSZ,IAAS,MAGxBU,YACFD,EAAUE,YAAc,6PCsEpBG,EAAsC,GAmB/BC,EAAkC,SAACb,GAC9C,IAAQF,EACNE,EADMF,KAAMC,EACZC,EADYD,MAAOe,EACnBd,EADmBc,KAAMC,EACzBf,EADyBe,QAASC,EAClChB,EADkCgB,UAAWC,EAC7CjB,EAD6CiB,SAAaC,IAC1DlB,KAIImB,EAjBS,SAACrB,EAAcsB,GAC9B,OAAOC,MAAID,EAAUE,OAAQxB,GAgBfyB,CAASzB,EAFDa,mBAAdS,wBAIR,OACEnB,gBAACC,iBAAYa,QAASA,GAAaG,GAAcM,YAAaL,IAC3DpB,IAAUiB,eACTf,gBAACE,aAAUY,QAASA,GAAUhB,GA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