build revisions and layout updates for toast
This commit is contained in:
parent
b341a3675e
commit
39235193e6
1116 changed files with 130517 additions and 12 deletions
2
node_modules/@hookform/resolvers/dist/index.d.ts
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from './toNestErrors';
|
||||
export * from './validateFieldsNatively';
|
||||
2
node_modules/@hookform/resolvers/dist/resolvers.js
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/resolvers.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var e=require("react-hook-form"),r=function(r,t,i){if(r&&"reportValidity"in r){var n=e.get(i,t);r.setCustomValidity(n&&n.message||""),r.reportValidity()}},t=function(e,t){var i=function(i){var n=t.fields[i];n&&n.ref&&"reportValidity"in n.ref?r(n.ref,i,e):n&&n.refs&&n.refs.forEach(function(t){return r(t,i,e)})};for(var n in t.fields)i(n)},i=function(e,r){var t=n(r);return e.some(function(e){return n(e).match("^"+t+"\\.\\d+")})};function n(e){return e.replace(/\]|\[/g,"")}exports.toNestErrors=function(r,n){n.shouldUseNativeValidation&&t(r,n);var a={};for(var o in r){var s=e.get(n.fields,o),f=Object.assign(r[o]||{},{ref:s&&s.ref});if(i(n.names||Object.keys(r),o)){var u=Object.assign({},e.get(a,o));e.set(u,"root",f),e.set(a,o,u)}else e.set(a,o,f)}return a},exports.validateFieldsNatively=t;
|
||||
//# sourceMappingURL=resolvers.js.map
|
||||
1
node_modules/@hookform/resolvers/dist/resolvers.js.map
generated
vendored
Normal file
1
node_modules/@hookform/resolvers/dist/resolvers.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"resolvers.js","sources":["../src/validateFieldsNatively.ts","../src/toNestErrors.ts"],"sourcesContent":["import {\n FieldError,\n FieldErrors,\n FieldValues,\n Ref,\n ResolverOptions,\n get,\n} from 'react-hook-form';\n\nconst setCustomValidity = (\n ref: Ref,\n fieldPath: string,\n errors: FieldErrors,\n) => {\n if (ref && 'reportValidity' in ref) {\n const error = get(errors, fieldPath) as FieldError | undefined;\n ref.setCustomValidity((error && error.message) || '');\n\n ref.reportValidity();\n }\n};\n\n// Native validation (web only)\nexport const validateFieldsNatively = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): void => {\n for (const fieldPath in options.fields) {\n const field = options.fields[fieldPath];\n if (field && field.ref && 'reportValidity' in field.ref) {\n setCustomValidity(field.ref, fieldPath, errors);\n } else if (field && field.refs) {\n field.refs.forEach((ref: HTMLInputElement) =>\n setCustomValidity(ref, fieldPath, errors),\n );\n }\n }\n};\n","import {\n Field,\n FieldErrors,\n FieldValues,\n InternalFieldName,\n ResolverOptions,\n get,\n set,\n} from 'react-hook-form';\nimport { validateFieldsNatively } from './validateFieldsNatively';\n\nexport const toNestErrors = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): FieldErrors<TFieldValues> => {\n options.shouldUseNativeValidation && validateFieldsNatively(errors, options);\n\n const fieldErrors = {} as FieldErrors<TFieldValues>;\n for (const path in errors) {\n const field = get(options.fields, path) as Field['_f'] | undefined;\n const error = Object.assign(errors[path] || {}, {\n ref: field && field.ref,\n });\n\n if (isNameInFieldArray(options.names || Object.keys(errors), path)) {\n const fieldArrayErrors = Object.assign({}, get(fieldErrors, path));\n\n set(fieldArrayErrors, 'root', error);\n set(fieldErrors, path, fieldArrayErrors);\n } else {\n set(fieldErrors, path, error);\n }\n }\n\n return fieldErrors;\n};\n\nconst isNameInFieldArray = (\n names: InternalFieldName[],\n name: InternalFieldName,\n) => {\n const path = escapeBrackets(name);\n return names.some((n) => escapeBrackets(n).match(`^${path}\\\\.\\\\d+`));\n};\n\n/**\n * Escapes special characters in a string to be used in a regex pattern.\n * it removes the brackets from the string to match the `set` method.\n *\n * @param input - The input string to escape.\n * @returns The escaped string.\n */\nfunction escapeBrackets(input: string): string {\n return input.replace(/\\]|\\[/g, '');\n}\n"],"names":["setCustomValidity","ref","fieldPath","errors","error","get","message","reportValidity","validateFieldsNatively","options","_loop","field","fields","refs","forEach","isNameInFieldArray","names","name","path","escapeBrackets","some","n","match","input","replace","shouldUseNativeValidation","fieldErrors","Object","assign","keys","fieldArrayErrors","set"],"mappings":"iCASMA,EAAoB,SACxBC,EACAC,EACAC,GAEA,GAAIF,GAAO,mBAAoBA,EAAK,CAClC,IAAMG,EAAQC,MAAIF,EAAQD,GAC1BD,EAAID,kBAAmBI,GAASA,EAAME,SAAY,IAElDL,EAAIM,gBACN,CACF,EAGaC,EAAyB,SACpCL,EACAM,GACQC,IAAAA,WAAAR,GAEN,IAAMS,EAAQF,EAAQG,OAAOV,GACzBS,GAASA,EAAMV,KAAO,mBAAoBU,EAAMV,IAClDD,EAAkBW,EAAMV,IAAKC,EAAWC,GAC/BQ,GAASA,EAAME,MACxBF,EAAME,KAAKC,QAAQ,SAACb,UAClBD,EAAkBC,EAAKC,EAAWC,EAAO,EAG/C,EATA,IAAK,IAAMD,KAAaO,EAAQG,OAAMF,EAAAR,EAUxC,ECAMa,EAAqB,SACzBC,EACAC,GAEA,IAAMC,EAAOC,EAAeF,GAC5B,OAAOD,EAAMI,KAAK,SAACC,GAAM,OAAAF,EAAeE,GAAGC,MAAK,IAAKJ,EAAI,UAAU,EACrE,EASA,SAASC,EAAeI,GACtB,OAAOA,EAAMC,QAAQ,SAAU,GACjC,sBA3C4B,SAC1BrB,EACAM,GAEAA,EAAQgB,2BAA6BjB,EAAuBL,EAAQM,GAEpE,IAAMiB,EAAc,CAA+B,EACnD,IAAK,IAAMR,KAAQf,EAAQ,CACzB,IAAMQ,EAAQN,EAAGA,IAACI,EAAQG,OAAQM,GAC5Bd,EAAQuB,OAAOC,OAAOzB,EAAOe,IAAS,GAAI,CAC9CjB,IAAKU,GAASA,EAAMV,MAGtB,GAAIc,EAAmBN,EAAQO,OAASW,OAAOE,KAAK1B,GAASe,GAAO,CAClE,IAAMY,EAAmBH,OAAOC,OAAO,CAAE,EAAEvB,EAAGA,IAACqB,EAAaR,IAE5Da,MAAID,EAAkB,OAAQ1B,GAC9B2B,MAAIL,EAAaR,EAAMY,EACzB,MACEC,EAAGA,IAACL,EAAaR,EAAMd,EAE3B,CAEA,OAAOsB,CACT"}
|
||||
2
node_modules/@hookform/resolvers/dist/resolvers.mjs
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/resolvers.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import{get as e,set as t}from"react-hook-form";const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=e(o,r);t.setCustomValidity(s&&s.message||""),t.reportValidity()}},o=(e,t)=>{for(const o in t.fields){const s=t.fields[o];s&&s.ref&&"reportValidity"in s.ref?r(s.ref,o,e):s&&s.refs&&s.refs.forEach(t=>r(t,o,e))}},s=(r,s)=>{s.shouldUseNativeValidation&&o(r,s);const n={};for(const o in r){const f=e(s.fields,o),c=Object.assign(r[o]||{},{ref:f&&f.ref});if(i(s.names||Object.keys(r),o)){const r=Object.assign({},e(n,o));t(r,"root",c),t(n,o,r)}else t(n,o,c)}return n},i=(e,t)=>{const r=n(t);return e.some(e=>n(e).match(`^${r}\\.\\d+`))};function n(e){return e.replace(/\]|\[/g,"")}export{s as toNestErrors,o as validateFieldsNatively};
|
||||
//# sourceMappingURL=resolvers.mjs.map
|
||||
1
node_modules/@hookform/resolvers/dist/resolvers.mjs.map
generated
vendored
Normal file
1
node_modules/@hookform/resolvers/dist/resolvers.mjs.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"resolvers.mjs","sources":["../src/validateFieldsNatively.ts","../src/toNestErrors.ts"],"sourcesContent":["import {\n FieldError,\n FieldErrors,\n FieldValues,\n Ref,\n ResolverOptions,\n get,\n} from 'react-hook-form';\n\nconst setCustomValidity = (\n ref: Ref,\n fieldPath: string,\n errors: FieldErrors,\n) => {\n if (ref && 'reportValidity' in ref) {\n const error = get(errors, fieldPath) as FieldError | undefined;\n ref.setCustomValidity((error && error.message) || '');\n\n ref.reportValidity();\n }\n};\n\n// Native validation (web only)\nexport const validateFieldsNatively = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): void => {\n for (const fieldPath in options.fields) {\n const field = options.fields[fieldPath];\n if (field && field.ref && 'reportValidity' in field.ref) {\n setCustomValidity(field.ref, fieldPath, errors);\n } else if (field && field.refs) {\n field.refs.forEach((ref: HTMLInputElement) =>\n setCustomValidity(ref, fieldPath, errors),\n );\n }\n }\n};\n","import {\n Field,\n FieldErrors,\n FieldValues,\n InternalFieldName,\n ResolverOptions,\n get,\n set,\n} from 'react-hook-form';\nimport { validateFieldsNatively } from './validateFieldsNatively';\n\nexport const toNestErrors = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): FieldErrors<TFieldValues> => {\n options.shouldUseNativeValidation && validateFieldsNatively(errors, options);\n\n const fieldErrors = {} as FieldErrors<TFieldValues>;\n for (const path in errors) {\n const field = get(options.fields, path) as Field['_f'] | undefined;\n const error = Object.assign(errors[path] || {}, {\n ref: field && field.ref,\n });\n\n if (isNameInFieldArray(options.names || Object.keys(errors), path)) {\n const fieldArrayErrors = Object.assign({}, get(fieldErrors, path));\n\n set(fieldArrayErrors, 'root', error);\n set(fieldErrors, path, fieldArrayErrors);\n } else {\n set(fieldErrors, path, error);\n }\n }\n\n return fieldErrors;\n};\n\nconst isNameInFieldArray = (\n names: InternalFieldName[],\n name: InternalFieldName,\n) => {\n const path = escapeBrackets(name);\n return names.some((n) => escapeBrackets(n).match(`^${path}\\\\.\\\\d+`));\n};\n\n/**\n * Escapes special characters in a string to be used in a regex pattern.\n * it removes the brackets from the string to match the `set` method.\n *\n * @param input - The input string to escape.\n * @returns The escaped string.\n */\nfunction escapeBrackets(input: string): string {\n return input.replace(/\\]|\\[/g, '');\n}\n"],"names":["setCustomValidity","ref","fieldPath","errors","error","get","message","reportValidity","validateFieldsNatively","options","fields","field","refs","forEach","toNestErrors","shouldUseNativeValidation","fieldErrors","path","Object","assign","isNameInFieldArray","names","keys","fieldArrayErrors","set","name","escapeBrackets","some","n","match","input","replace"],"mappings":"+CASA,MAAMA,EAAoBA,CACxBC,EACAC,EACAC,KAEA,GAAIF,GAAO,mBAAoBA,EAAK,CAClC,MAAMG,EAAQC,EAAIF,EAAQD,GAC1BD,EAAID,kBAAmBI,GAASA,EAAME,SAAY,IAElDL,EAAIM,gBACN,GAIWC,EAAyBA,CACpCL,EACAM,KAEA,IAAK,MAAMP,KAAaO,EAAQC,OAAQ,CACtC,MAAMC,EAAQF,EAAQC,OAAOR,GACzBS,GAASA,EAAMV,KAAO,mBAAoBU,EAAMV,IAClDD,EAAkBW,EAAMV,IAAKC,EAAWC,GAC/BQ,GAASA,EAAMC,MACxBD,EAAMC,KAAKC,QAASZ,GAClBD,EAAkBC,EAAKC,EAAWC,GAGxC,GCzBWW,EAAeA,CAC1BX,EACAM,KAEAA,EAAQM,2BAA6BP,EAAuBL,EAAQM,GAEpE,MAAMO,EAAc,GACpB,IAAK,MAAMC,KAAQd,EAAQ,CACzB,MAAMQ,EAAQN,EAAII,EAAQC,OAAQO,GAC5Bb,EAAQc,OAAOC,OAAOhB,EAAOc,IAAS,CAAA,EAAI,CAC9ChB,IAAKU,GAASA,EAAMV,MAGtB,GAAImB,EAAmBX,EAAQY,OAASH,OAAOI,KAAKnB,GAASc,GAAO,CAClE,MAAMM,EAAmBL,OAAOC,OAAO,CAAA,EAAId,EAAIW,EAAaC,IAE5DO,EAAID,EAAkB,OAAQnB,GAC9BoB,EAAIR,EAAaC,EAAMM,EACzB,MACEC,EAAIR,EAAaC,EAAMb,EAE3B,CAEA,OAAOY,GAGHI,EAAqBA,CACzBC,EACAI,KAEA,MAAMR,EAAOS,EAAeD,GAC5B,OAAOJ,EAAMM,KAAMC,GAAMF,EAAeE,GAAGC,MAAM,IAAIZ,YAAc,EAUrE,SAASS,EAAeI,GACtB,OAAOA,EAAMC,QAAQ,SAAU,GACjC"}
|
||||
2
node_modules/@hookform/resolvers/dist/resolvers.module.js
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/resolvers.module.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import{get as r,set as e}from"react-hook-form";var t=function(e,t,i){if(e&&"reportValidity"in e){var n=r(i,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},i=function(r,e){var i=function(i){var n=e.fields[i];n&&n.ref&&"reportValidity"in n.ref?t(n.ref,i,r):n&&n.refs&&n.refs.forEach(function(e){return t(e,i,r)})};for(var n in e.fields)i(n)},n=function(t,n){n.shouldUseNativeValidation&&i(t,n);var a={};for(var f in t){var s=r(n.fields,f),c=Object.assign(t[f]||{},{ref:s&&s.ref});if(o(n.names||Object.keys(t),f)){var u=Object.assign({},r(a,f));e(u,"root",c),e(a,f,u)}else e(a,f,c)}return a},o=function(r,e){var t=a(e);return r.some(function(r){return a(r).match("^"+t+"\\.\\d+")})};function a(r){return r.replace(/\]|\[/g,"")}export{n as toNestErrors,i as validateFieldsNatively};
|
||||
//# sourceMappingURL=resolvers.module.js.map
|
||||
1
node_modules/@hookform/resolvers/dist/resolvers.module.js.map
generated
vendored
Normal file
1
node_modules/@hookform/resolvers/dist/resolvers.module.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"resolvers.module.js","sources":["../src/validateFieldsNatively.ts","../src/toNestErrors.ts"],"sourcesContent":["import {\n FieldError,\n FieldErrors,\n FieldValues,\n Ref,\n ResolverOptions,\n get,\n} from 'react-hook-form';\n\nconst setCustomValidity = (\n ref: Ref,\n fieldPath: string,\n errors: FieldErrors,\n) => {\n if (ref && 'reportValidity' in ref) {\n const error = get(errors, fieldPath) as FieldError | undefined;\n ref.setCustomValidity((error && error.message) || '');\n\n ref.reportValidity();\n }\n};\n\n// Native validation (web only)\nexport const validateFieldsNatively = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): void => {\n for (const fieldPath in options.fields) {\n const field = options.fields[fieldPath];\n if (field && field.ref && 'reportValidity' in field.ref) {\n setCustomValidity(field.ref, fieldPath, errors);\n } else if (field && field.refs) {\n field.refs.forEach((ref: HTMLInputElement) =>\n setCustomValidity(ref, fieldPath, errors),\n );\n }\n }\n};\n","import {\n Field,\n FieldErrors,\n FieldValues,\n InternalFieldName,\n ResolverOptions,\n get,\n set,\n} from 'react-hook-form';\nimport { validateFieldsNatively } from './validateFieldsNatively';\n\nexport const toNestErrors = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): FieldErrors<TFieldValues> => {\n options.shouldUseNativeValidation && validateFieldsNatively(errors, options);\n\n const fieldErrors = {} as FieldErrors<TFieldValues>;\n for (const path in errors) {\n const field = get(options.fields, path) as Field['_f'] | undefined;\n const error = Object.assign(errors[path] || {}, {\n ref: field && field.ref,\n });\n\n if (isNameInFieldArray(options.names || Object.keys(errors), path)) {\n const fieldArrayErrors = Object.assign({}, get(fieldErrors, path));\n\n set(fieldArrayErrors, 'root', error);\n set(fieldErrors, path, fieldArrayErrors);\n } else {\n set(fieldErrors, path, error);\n }\n }\n\n return fieldErrors;\n};\n\nconst isNameInFieldArray = (\n names: InternalFieldName[],\n name: InternalFieldName,\n) => {\n const path = escapeBrackets(name);\n return names.some((n) => escapeBrackets(n).match(`^${path}\\\\.\\\\d+`));\n};\n\n/**\n * Escapes special characters in a string to be used in a regex pattern.\n * it removes the brackets from the string to match the `set` method.\n *\n * @param input - The input string to escape.\n * @returns The escaped string.\n */\nfunction escapeBrackets(input: string): string {\n return input.replace(/\\]|\\[/g, '');\n}\n"],"names":["setCustomValidity","ref","fieldPath","errors","error","get","message","reportValidity","validateFieldsNatively","options","_loop","field","fields","refs","forEach","toNestErrors","shouldUseNativeValidation","fieldErrors","path","Object","assign","isNameInFieldArray","names","keys","fieldArrayErrors","set","name","escapeBrackets","some","n","match","input","replace"],"mappings":"+CASA,IAAMA,EAAoB,SACxBC,EACAC,EACAC,GAEA,GAAIF,GAAO,mBAAoBA,EAAK,CAClC,IAAMG,EAAQC,EAAIF,EAAQD,GAC1BD,EAAID,kBAAmBI,GAASA,EAAME,SAAY,IAElDL,EAAIM,gBACN,CACF,EAGaC,EAAyB,SACpCL,EACAM,GACQC,IAAAA,WAAAR,GAEN,IAAMS,EAAQF,EAAQG,OAAOV,GACzBS,GAASA,EAAMV,KAAO,mBAAoBU,EAAMV,IAClDD,EAAkBW,EAAMV,IAAKC,EAAWC,GAC/BQ,GAASA,EAAME,MACxBF,EAAME,KAAKC,QAAQ,SAACb,UAClBD,EAAkBC,EAAKC,EAAWC,EAAO,EAG/C,EATA,IAAK,IAAMD,KAAaO,EAAQG,OAAMF,EAAAR,EAUxC,EC1Baa,EAAe,SAC1BZ,EACAM,GAEAA,EAAQO,2BAA6BR,EAAuBL,EAAQM,GAEpE,IAAMQ,EAAc,CAA+B,EACnD,IAAK,IAAMC,KAAQf,EAAQ,CACzB,IAAMQ,EAAQN,EAAII,EAAQG,OAAQM,GAC5Bd,EAAQe,OAAOC,OAAOjB,EAAOe,IAAS,GAAI,CAC9CjB,IAAKU,GAASA,EAAMV,MAGtB,GAAIoB,EAAmBZ,EAAQa,OAASH,OAAOI,KAAKpB,GAASe,GAAO,CAClE,IAAMM,EAAmBL,OAAOC,OAAO,CAAE,EAAEf,EAAIY,EAAaC,IAE5DO,EAAID,EAAkB,OAAQpB,GAC9BqB,EAAIR,EAAaC,EAAMM,EACzB,MACEC,EAAIR,EAAaC,EAAMd,EAE3B,CAEA,OAAOa,CACT,EAEMI,EAAqB,SACzBC,EACAI,GAEA,IAAMR,EAAOS,EAAeD,GAC5B,OAAOJ,EAAMM,KAAK,SAACC,GAAM,OAAAF,EAAeE,GAAGC,MAAK,IAAKZ,EAAI,UAAU,EACrE,EASA,SAASS,EAAeI,GACtB,OAAOA,EAAMC,QAAQ,SAAU,GACjC"}
|
||||
2
node_modules/@hookform/resolvers/dist/resolvers.umd.js
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/resolvers.umd.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","react-hook-form"],t):t((e||self).hookformResolvers={},e.ReactHookForm)}(this,function(e,t){var r=function(e,r,o){if(e&&"reportValidity"in e){var i=t.get(o,r);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},o=function(e,t){var o=function(o){var i=t.fields[o];i&&i.ref&&"reportValidity"in i.ref?r(i.ref,o,e):i&&i.refs&&i.refs.forEach(function(t){return r(t,o,e)})};for(var i in t.fields)o(i)},i=function(e,t){var r=n(t);return e.some(function(e){return n(e).match("^"+r+"\\.\\d+")})};function n(e){return e.replace(/\]|\[/g,"")}e.toNestErrors=function(e,r){r.shouldUseNativeValidation&&o(e,r);var n={};for(var f in e){var s=t.get(r.fields,f),a=Object.assign(e[f]||{},{ref:s&&s.ref});if(i(r.names||Object.keys(e),f)){var u=Object.assign({},t.get(n,f));t.set(u,"root",a),t.set(n,f,u)}else t.set(n,f,a)}return n},e.validateFieldsNatively=o});
|
||||
//# sourceMappingURL=resolvers.umd.js.map
|
||||
1
node_modules/@hookform/resolvers/dist/resolvers.umd.js.map
generated
vendored
Normal file
1
node_modules/@hookform/resolvers/dist/resolvers.umd.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"resolvers.umd.js","sources":["../src/validateFieldsNatively.ts","../src/toNestErrors.ts"],"sourcesContent":["import {\n FieldError,\n FieldErrors,\n FieldValues,\n Ref,\n ResolverOptions,\n get,\n} from 'react-hook-form';\n\nconst setCustomValidity = (\n ref: Ref,\n fieldPath: string,\n errors: FieldErrors,\n) => {\n if (ref && 'reportValidity' in ref) {\n const error = get(errors, fieldPath) as FieldError | undefined;\n ref.setCustomValidity((error && error.message) || '');\n\n ref.reportValidity();\n }\n};\n\n// Native validation (web only)\nexport const validateFieldsNatively = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): void => {\n for (const fieldPath in options.fields) {\n const field = options.fields[fieldPath];\n if (field && field.ref && 'reportValidity' in field.ref) {\n setCustomValidity(field.ref, fieldPath, errors);\n } else if (field && field.refs) {\n field.refs.forEach((ref: HTMLInputElement) =>\n setCustomValidity(ref, fieldPath, errors),\n );\n }\n }\n};\n","import {\n Field,\n FieldErrors,\n FieldValues,\n InternalFieldName,\n ResolverOptions,\n get,\n set,\n} from 'react-hook-form';\nimport { validateFieldsNatively } from './validateFieldsNatively';\n\nexport const toNestErrors = <TFieldValues extends FieldValues>(\n errors: FieldErrors,\n options: ResolverOptions<TFieldValues>,\n): FieldErrors<TFieldValues> => {\n options.shouldUseNativeValidation && validateFieldsNatively(errors, options);\n\n const fieldErrors = {} as FieldErrors<TFieldValues>;\n for (const path in errors) {\n const field = get(options.fields, path) as Field['_f'] | undefined;\n const error = Object.assign(errors[path] || {}, {\n ref: field && field.ref,\n });\n\n if (isNameInFieldArray(options.names || Object.keys(errors), path)) {\n const fieldArrayErrors = Object.assign({}, get(fieldErrors, path));\n\n set(fieldArrayErrors, 'root', error);\n set(fieldErrors, path, fieldArrayErrors);\n } else {\n set(fieldErrors, path, error);\n }\n }\n\n return fieldErrors;\n};\n\nconst isNameInFieldArray = (\n names: InternalFieldName[],\n name: InternalFieldName,\n) => {\n const path = escapeBrackets(name);\n return names.some((n) => escapeBrackets(n).match(`^${path}\\\\.\\\\d+`));\n};\n\n/**\n * Escapes special characters in a string to be used in a regex pattern.\n * it removes the brackets from the string to match the `set` method.\n *\n * @param input - The input string to escape.\n * @returns The escaped string.\n */\nfunction escapeBrackets(input: string): string {\n return input.replace(/\\]|\\[/g, '');\n}\n"],"names":["setCustomValidity","ref","fieldPath","errors","error","get","message","reportValidity","validateFieldsNatively","options","_loop","field","fields","refs","forEach","isNameInFieldArray","names","name","path","escapeBrackets","some","n","match","input","replace","shouldUseNativeValidation","fieldErrors","Object","assign","keys","fieldArrayErrors","set"],"mappings":"0SASA,IAAMA,EAAoB,SACxBC,EACAC,EACAC,GAEA,GAAIF,GAAO,mBAAoBA,EAAK,CAClC,IAAMG,EAAQC,MAAIF,EAAQD,GAC1BD,EAAID,kBAAmBI,GAASA,EAAME,SAAY,IAElDL,EAAIM,gBACN,CACF,EAGaC,EAAyB,SACpCL,EACAM,GACQC,IAAAA,WAAAR,GAEN,IAAMS,EAAQF,EAAQG,OAAOV,GACzBS,GAASA,EAAMV,KAAO,mBAAoBU,EAAMV,IAClDD,EAAkBW,EAAMV,IAAKC,EAAWC,GAC/BQ,GAASA,EAAME,MACxBF,EAAME,KAAKC,QAAQ,SAACb,UAClBD,EAAkBC,EAAKC,EAAWC,EAAO,EAG/C,EATA,IAAK,IAAMD,KAAaO,EAAQG,OAAMF,EAAAR,EAUxC,ECAMa,EAAqB,SACzBC,EACAC,GAEA,IAAMC,EAAOC,EAAeF,GAC5B,OAAOD,EAAMI,KAAK,SAACC,GAAM,OAAAF,EAAeE,GAAGC,MAAK,IAAKJ,EAAI,UAAU,EACrE,EASA,SAASC,EAAeI,GACtB,OAAOA,EAAMC,QAAQ,SAAU,GACjC,gBA3C4B,SAC1BrB,EACAM,GAEAA,EAAQgB,2BAA6BjB,EAAuBL,EAAQM,GAEpE,IAAMiB,EAAc,CAA+B,EACnD,IAAK,IAAMR,KAAQf,EAAQ,CACzB,IAAMQ,EAAQN,EAAGA,IAACI,EAAQG,OAAQM,GAC5Bd,EAAQuB,OAAOC,OAAOzB,EAAOe,IAAS,GAAI,CAC9CjB,IAAKU,GAASA,EAAMV,MAGtB,GAAIc,EAAmBN,EAAQO,OAASW,OAAOE,KAAK1B,GAASe,GAAO,CAClE,IAAMY,EAAmBH,OAAOC,OAAO,CAAE,EAAEvB,EAAGA,IAACqB,EAAaR,IAE5Da,MAAID,EAAkB,OAAQ1B,GAC9B2B,MAAIL,EAAaR,EAAMY,EACzB,MACEC,EAAGA,IAACL,EAAaR,EAAMd,EAE3B,CAEA,OAAOsB,CACT"}
|
||||
2
node_modules/@hookform/resolvers/dist/toNestErrors.d.ts
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/toNestErrors.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { FieldErrors, FieldValues, ResolverOptions } from 'react-hook-form';
|
||||
export declare const toNestErrors: <TFieldValues extends FieldValues>(errors: FieldErrors, options: ResolverOptions<TFieldValues>) => FieldErrors<TFieldValues>;
|
||||
2
node_modules/@hookform/resolvers/dist/validateFieldsNatively.d.ts
generated
vendored
Normal file
2
node_modules/@hookform/resolvers/dist/validateFieldsNatively.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { FieldErrors, FieldValues, ResolverOptions } from 'react-hook-form';
|
||||
export declare const validateFieldsNatively: <TFieldValues extends FieldValues>(errors: FieldErrors, options: ResolverOptions<TFieldValues>) => void;
|
||||
Loading…
Add table
Add a link
Reference in a new issue