diff --git a/node_modules/@hookform/resolvers/typebox/dist/typebox.modern.mjs.map b/node_modules/@hookform/resolvers/typebox/dist/typebox.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..c8af1b43fd58d577a8a6b36327e66fabb3073b2a --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/dist/typebox.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"typebox.modern.mjs","sources":["../src/typebox.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Static, StaticDecode, TObject } from '@sinclair/typebox';\nimport { TypeCheck } from '@sinclair/typebox/compiler';\nimport { Value, type ValueError } from '@sinclair/typebox/value';\nimport { FieldError, Resolver, appendErrors } from 'react-hook-form';\n\nfunction parseErrorSchema(\n _errors: ValueError[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (; _errors.length; ) {\n const error = _errors[0];\n const { type, message, path } = error;\n const _path = path.substring(1).replace(/\\//g, '.');\n\n if (!errors[_path]) {\n errors[_path] = { message, type: '' + type };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types['' + type];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '' + type,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n _errors.shift();\n }\n\n return errors;\n}\n\n/**\n * Creates a resolver for react-hook-form using Typebox schema validation\n * @param {Schema | TypeCheck} schema - The Typebox schema to validate against\n * @param {Object} options - Additional resolver configuration\n * @param {string} [options.mode='async'] - Validation mode\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Type.Object({\n * name: Type.String(),\n * age: Type.Number()\n * });\n *\n * useForm({\n * resolver: typeboxResolver(schema)\n * });\n *\n * // Schemas using a custom/third-party `Kind` (e.g. ElysiaJS's `t.Files()`) must have\n * // that kind registered with TypeBox's own `TypeRegistry` before validating, since\n * // this resolver validates via `@sinclair/typebox`'s `Value.Errors`/`Value.Check`:\n * // TypeRegistry.Set('Files', (schema, value) => Array.isArray(value));\n */\nexport function typeboxResolver(\n schema: Schema | TypeCheck,\n): Resolver, Context, StaticDecode> {\n return async (values: Static, _, options) => {\n const errors = Array.from(\n schema instanceof TypeCheck\n ? schema.Errors(values)\n : Value.Errors(schema, values),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n if (!errors.length) {\n return {\n errors: {},\n values,\n };\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n errors,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n };\n}\n"],"names":["parseErrorSchema","_errors","validateAllFieldCriteria","errors","Object","create","length","error","type","message","path","_path","substring","replace","types","messages","appendErrors","concat","shift","typeboxResolver","schema","async","values","_","options","Array","from","TypeCheck","Errors","Value","shouldUseNativeValidation","validateFieldsNatively","toNestErrors","criteriaMode"],"mappings":"qOAMA,SAASA,EACPC,EACAC,GAGA,MAAMC,EAAqCC,OAAOC,OAAO,MACzD,KAAOJ,EAAQK,QAAU,CACvB,MAAMC,EAAQN,EAAQ,IAChBO,KAAEA,EAAIC,QAAEA,EAAOC,KAAEA,GAASH,EAC1BI,EAAQD,EAAKE,UAAU,GAAGC,QAAQ,MAAO,KAM/C,GAJKV,EAAOQ,KACVR,EAAOQ,GAAS,CAAEF,UAASD,KAAM,GAAKA,IAGpCN,EAA0B,CAC5B,MAAMY,EAAQX,EAAOQ,GAAOG,MACtBC,EAAWD,GAASA,EAAM,GAAKN,GAErCL,EAAOQ,GAASK,EACdL,EACAT,EACAC,EACA,GAAKK,EACLO,EACK,GAAgBE,OAAOF,EAAsBR,EAAME,SACpDF,EAAME,QAEd,CAEAR,EAAQiB,OACV,CAEA,OAAOf,CACT,CAuBgB,SAAAgB,EACdC,GAEA,OAAOC,MAAOC,EAAwBC,EAAGC,KACvC,MAAMrB,EAASsB,MAAMC,KACnBN,aAAkBO,EACdP,EAAOQ,OAAON,GACdO,EAAMD,OAAOR,EAAQE,IAK3B,OAFAE,EAAQM,2BAA6BC,EAAuB,CAAA,EAAIP,GAE3DrB,EAAOG,OAOL,CACLgB,OAAQ,CAAE,EACVnB,OAAQ6B,EACNhC,EACEG,GACCqB,EAAQM,2BAAsD,QAAzBN,EAAQS,cAEhDT,IAbK,CACLrB,OAAQ,CAAA,EACRmB,SAaH,CAEL"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typebox/dist/typebox.module.js b/node_modules/@hookform/resolvers/typebox/dist/typebox.module.js new file mode 100644 index 0000000000000000000000000000000000000000..8179dd6561f834a7aa62c2bbf4276db2bc2da53e --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/dist/typebox.module.js @@ -0,0 +1,2 @@ +import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{TypeCheck as o}from"@sinclair/typebox/compiler";import{Value as t}from"@sinclair/typebox/value";import{appendErrors as s}from"react-hook-form";function a(r,e){for(var o=Object.create(null);r.length;){var t=r[0],a=t.type,i=t.message,n=t.path.substring(1).replace(/\//g,".");if(o[n]||(o[n]={message:i,type:""+a}),e){var l=o[n].types,m=l&&l[""+a];o[n]=s(n,e,o,""+a,m?[].concat(m,t.message):t.message)}r.shift()}return o}function i(s){return function(i,n,l){try{var m=Array.from(s instanceof o?s.Errors(i):t.Errors(s,i));return l.shouldUseNativeValidation&&r({},l),Promise.resolve(m.length?{values:{},errors:e(a(m,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)}:{errors:{},values:i})}catch(r){return Promise.reject(r)}}}export{i as typeboxResolver}; +//# sourceMappingURL=typebox.module.js.map diff --git a/node_modules/@hookform/resolvers/typebox/dist/typebox.module.js.map b/node_modules/@hookform/resolvers/typebox/dist/typebox.module.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f9fd8c2613337d1ae540f209d781a83402ff9c80 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/dist/typebox.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typebox.module.js","sources":["../src/typebox.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Static, StaticDecode, TObject } from '@sinclair/typebox';\nimport { TypeCheck } from '@sinclair/typebox/compiler';\nimport { Value, type ValueError } from '@sinclair/typebox/value';\nimport { FieldError, Resolver, appendErrors } from 'react-hook-form';\n\nfunction parseErrorSchema(\n _errors: ValueError[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (; _errors.length; ) {\n const error = _errors[0];\n const { type, message, path } = error;\n const _path = path.substring(1).replace(/\\//g, '.');\n\n if (!errors[_path]) {\n errors[_path] = { message, type: '' + type };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types['' + type];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '' + type,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n _errors.shift();\n }\n\n return errors;\n}\n\n/**\n * Creates a resolver for react-hook-form using Typebox schema validation\n * @param {Schema | TypeCheck} schema - The Typebox schema to validate against\n * @param {Object} options - Additional resolver configuration\n * @param {string} [options.mode='async'] - Validation mode\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Type.Object({\n * name: Type.String(),\n * age: Type.Number()\n * });\n *\n * useForm({\n * resolver: typeboxResolver(schema)\n * });\n *\n * // Schemas using a custom/third-party `Kind` (e.g. ElysiaJS's `t.Files()`) must have\n * // that kind registered with TypeBox's own `TypeRegistry` before validating, since\n * // this resolver validates via `@sinclair/typebox`'s `Value.Errors`/`Value.Check`:\n * // TypeRegistry.Set('Files', (schema, value) => Array.isArray(value));\n */\nexport function typeboxResolver(\n schema: Schema | TypeCheck,\n): Resolver, Context, StaticDecode> {\n return async (values: Static, _, options) => {\n const errors = Array.from(\n schema instanceof TypeCheck\n ? schema.Errors(values)\n : Value.Errors(schema, values),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n if (!errors.length) {\n return {\n errors: {},\n values,\n };\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n errors,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n };\n}\n"],"names":["parseErrorSchema","_errors","validateAllFieldCriteria","errors","Object","create","length","error","type","message","_path","path","substring","replace","types","messages","appendErrors","concat","shift","typeboxResolver","schema","values","_","options","Array","from","TypeCheck","Errors","Value","shouldUseNativeValidation","validateFieldsNatively","Promise","resolve","toNestErrors","criteriaMode","e","reject"],"mappings":"qOAMA,SAASA,EACPC,EACAC,GAIA,IADA,IAAMC,EAAqCC,OAAOC,OAAO,MAClDJ,EAAQK,QAAU,CACvB,IAAMC,EAAQN,EAAQ,GACdO,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,UAAU,GAAGC,QAAQ,MAAO,KAM/C,GAJKV,EAAOO,KACVP,EAAOO,GAAS,CAAED,QAAAA,EAASD,KAAM,GAAKA,IAGpCN,EAA0B,CAC5B,IAAMY,EAAQX,EAAOO,GAAOI,MACtBC,EAAWD,GAASA,EAAM,GAAKN,GAErCL,EAAOO,GAASM,EACdN,EACAR,EACAC,EACA,GAAKK,EACLO,EACK,GAAgBE,OAAOF,EAAsBR,EAAME,SACpDF,EAAME,QAEd,CAEAR,EAAQiB,OACV,CAEA,OAAOf,CACT,CAuBM,SAAUgB,EACdC,GAEA,OAAcC,SAAAA,EAAwBC,EAAGC,GAAO,IAC9C,IAAMpB,EAASqB,MAAMC,KACnBL,aAAkBM,EACdN,EAAOO,OAAON,GACdO,EAAMD,OAAOP,EAAQC,IAK3B,OAFAE,EAAQM,2BAA6BC,EAAuB,CAAE,EAAEP,GAShEQ,QAAAC,QAPK7B,EAAOG,OAOL,CACLe,OAAQ,CAAE,EACVlB,OAAQ8B,EACNjC,EACEG,GACCoB,EAAQM,2BAAsD,QAAzBN,EAAQW,cAEhDX,IAbK,CACLpB,OAAQ,GACRkB,OAAAA,GAcN,CAAC,MAAAc,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typebox/dist/typebox.umd.js b/node_modules/@hookform/resolvers/typebox/dist/typebox.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..f0e18a0432d04c08c50afdcbae5585bc86a00788 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/dist/typebox.umd.js @@ -0,0 +1,2 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("@sinclair/typebox/compiler"),require("@sinclair/typebox/value"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","@sinclair/typebox/compiler","@sinclair/typebox/value","react-hook-form"],r):r((e||self).hookformResolversTypebox={},e.hookformResolvers,e.compiler,e.value,e.ReactHookForm)}(this,function(e,r,o,t,s){function i(e,r){for(var o=Object.create(null);e.length;){var t=e[0],i=t.type,a=t.message,l=t.path.substring(1).replace(/\//g,".");if(o[l]||(o[l]={message:a,type:""+i}),r){var n=o[l].types,c=n&&n[""+i];o[l]=s.appendErrors(l,r,o,""+i,c?[].concat(c,t.message):t.message)}e.shift()}return o}e.typeboxResolver=function(e){return function(s,a,l){try{var n=Array.from(e instanceof o.TypeCheck?e.Errors(s):t.Value.Errors(e,s));return l.shouldUseNativeValidation&&r.validateFieldsNatively({},l),Promise.resolve(n.length?{values:{},errors:r.toNestErrors(i(n,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)}:{errors:{},values:s})}catch(e){return Promise.reject(e)}}}}); +//# sourceMappingURL=typebox.umd.js.map diff --git a/node_modules/@hookform/resolvers/typebox/dist/typebox.umd.js.map b/node_modules/@hookform/resolvers/typebox/dist/typebox.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1faa2cd59e3aafd3d0bb15bb582c6a290db983d2 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/dist/typebox.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typebox.umd.js","sources":["../src/typebox.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Static, StaticDecode, TObject } from '@sinclair/typebox';\nimport { TypeCheck } from '@sinclair/typebox/compiler';\nimport { Value, type ValueError } from '@sinclair/typebox/value';\nimport { FieldError, Resolver, appendErrors } from 'react-hook-form';\n\nfunction parseErrorSchema(\n _errors: ValueError[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (; _errors.length; ) {\n const error = _errors[0];\n const { type, message, path } = error;\n const _path = path.substring(1).replace(/\\//g, '.');\n\n if (!errors[_path]) {\n errors[_path] = { message, type: '' + type };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types['' + type];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '' + type,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n _errors.shift();\n }\n\n return errors;\n}\n\n/**\n * Creates a resolver for react-hook-form using Typebox schema validation\n * @param {Schema | TypeCheck} schema - The Typebox schema to validate against\n * @param {Object} options - Additional resolver configuration\n * @param {string} [options.mode='async'] - Validation mode\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Type.Object({\n * name: Type.String(),\n * age: Type.Number()\n * });\n *\n * useForm({\n * resolver: typeboxResolver(schema)\n * });\n *\n * // Schemas using a custom/third-party `Kind` (e.g. ElysiaJS's `t.Files()`) must have\n * // that kind registered with TypeBox's own `TypeRegistry` before validating, since\n * // this resolver validates via `@sinclair/typebox`'s `Value.Errors`/`Value.Check`:\n * // TypeRegistry.Set('Files', (schema, value) => Array.isArray(value));\n */\nexport function typeboxResolver(\n schema: Schema | TypeCheck,\n): Resolver, Context, StaticDecode> {\n return async (values: Static, _, options) => {\n const errors = Array.from(\n schema instanceof TypeCheck\n ? schema.Errors(values)\n : Value.Errors(schema, values),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n if (!errors.length) {\n return {\n errors: {},\n values,\n };\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n errors,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n };\n}\n"],"names":["parseErrorSchema","_errors","validateAllFieldCriteria","errors","Object","create","length","error","type","message","_path","path","substring","replace","types","messages","appendErrors","concat","shift","schema","values","_","options","Array","from","TypeCheck","Errors","Value","shouldUseNativeValidation","validateFieldsNatively","Promise","resolve","toNestErrors","criteriaMode","e","reject"],"mappings":"mhBAMA,SAASA,EACPC,EACAC,GAIA,IADA,IAAMC,EAAqCC,OAAOC,OAAO,MAClDJ,EAAQK,QAAU,CACvB,IAAMC,EAAQN,EAAQ,GACdO,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,UAAU,GAAGC,QAAQ,MAAO,KAM/C,GAJKV,EAAOO,KACVP,EAAOO,GAAS,CAAED,QAAAA,EAASD,KAAM,GAAKA,IAGpCN,EAA0B,CAC5B,IAAMY,EAAQX,EAAOO,GAAOI,MACtBC,EAAWD,GAASA,EAAM,GAAKN,GAErCL,EAAOO,GAASM,EAAAA,aACdN,EACAR,EACAC,EACA,GAAKK,EACLO,EACK,GAAgBE,OAAOF,EAAsBR,EAAME,SACpDF,EAAME,QAEd,CAEAR,EAAQiB,OACV,CAEA,OAAOf,CACT,mBAuBM,SACJgB,GAEA,OAAcC,SAAAA,EAAwBC,EAAGC,GAAO,IAC9C,IAAMnB,EAASoB,MAAMC,KACnBL,aAAkBM,EAASA,UACvBN,EAAOO,OAAON,GACdO,EAAKA,MAACD,OAAOP,EAAQC,IAK3B,OAFAE,EAAQM,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEP,GAShEQ,QAAAC,QAPK5B,EAAOG,OAOL,CACLc,OAAQ,CAAE,EACVjB,OAAQ6B,EAAAA,aACNhC,EACEG,GACCmB,EAAQM,2BAAsD,QAAzBN,EAAQW,cAEhDX,IAbK,CACLnB,OAAQ,GACRiB,OAAAA,GAcN,CAAC,MAAAc,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typebox/package.json b/node_modules/@hookform/resolvers/typebox/package.json new file mode 100644 index 0000000000000000000000000000000000000000..adfbb61bf5a46ce3ee964ba5aad0517c83b77948 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/package.json @@ -0,0 +1,18 @@ +{ + "name": "@hookform/resolvers/typebox", + "amdName": "hookformResolversTypebox", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: typebox", + "main": "dist/typebox.js", + "module": "dist/typebox.module.js", + "umd:main": "dist/typebox.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.55.0", + "@hookform/resolvers": "^2.0.0", + "@sinclair/typebox": "^0.25.24" + } +} diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-compiler.tsx b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-compiler.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ef3ca70a665f688a0e9e4e352ce0092c5b4ff7e5 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-compiler.tsx @@ -0,0 +1,53 @@ +import { Static, Type } from '@sinclair/typebox'; +import { TypeCompiler } from '@sinclair/typebox/compiler'; +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { typeboxResolver } from '..'; + +const schema = Type.Object({ + username: Type.String({ minLength: 1 }), + password: Type.String({ minLength: 1 }), +}); + +const typecheck = TypeCompiler.Compile(schema); + +function TestComponent({ + onSubmit, +}: { onSubmit: (data: Static) => void }) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: typeboxResolver(typecheck), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Typebox (with compiler) and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect( + screen.getAllByText(/Expected string length greater or equal to 1/i), + ).toHaveLength(2); + + expect(handleSubmit).not.toHaveBeenCalled(); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-native-validation-compiler.tsx b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-native-validation-compiler.tsx new file mode 100644 index 0000000000000000000000000000000000000000..98ff06baf6d7eb150e40d3fad1de4275695f8c3f --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-native-validation-compiler.tsx @@ -0,0 +1,86 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { typeboxResolver } from '..'; + +import { Static, Type } from '@sinclair/typebox'; +import { TypeCompiler } from '@sinclair/typebox/compiler'; + +const schema = Type.Object({ + username: Type.String({ minLength: 1 }), + password: Type.String({ minLength: 1 }), +}); + +const typecheck = TypeCompiler.Compile(schema); + +type FormData = Static; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: typeboxResolver(typecheck), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Typebox (with compiler)", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe( + 'Expected string length greater or equal to 1', + ); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe( + 'Expected string length greater or equal to 1', + ); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..b0d4de6d7875fbedde277c90570cfb98c8a47c17 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,83 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { typeboxResolver } from '..'; + +import { Static, Type } from '@sinclair/typebox'; + +const schema = Type.Object({ + username: Type.String({ minLength: 1 }), + password: Type.String({ minLength: 1 }), +}); + +type FormData = Static; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: typeboxResolver(schema), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Typebox", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe( + 'Expected string length greater or equal to 1', + ); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe( + 'Expected string length greater or equal to 1', + ); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..aa871532ad768a3df3a3bb4126a43f95ce448b41 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/Form.tsx @@ -0,0 +1,52 @@ +import { Static, Type } from '@sinclair/typebox'; +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { typeboxResolver } from '..'; + +const schema = Type.Object({ + username: Type.String({ minLength: 1 }), + password: Type.String({ minLength: 1 }), +}); + +function TestComponent({ + onSubmit, +}: { + onSubmit: (data: Static) => void; +}) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: typeboxResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Typebox and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect( + screen.getAllByText(/Expected string length greater or equal to 1/i), + ).toHaveLength(2); + + expect(handleSubmit).not.toHaveBeenCalled(); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/__fixtures__/data.ts b/node_modules/@hookform/resolvers/typebox/src/__tests__/__fixtures__/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..55f2054cd5e8f4f35c73d7a0b78f15ec7412e0cc --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/__fixtures__/data.ts @@ -0,0 +1,83 @@ +import { StaticDecode, Type } from '@sinclair/typebox'; +import { Field, InternalFieldName } from 'react-hook-form'; + +export const schema = Type.Object({ + username: Type.String({ + minLength: 3, + maxLength: 30, + pattern: '^[a-zA-Z0-9]+$', + }), + password: Type.String({ + minLength: 8, + pattern: '^(.*[A-Za-z\\d].*)$', + }), + repeatPassword: Type.String(), + accessToken: Type.Union([Type.String(), Type.Number()]), + birthYear: Type.Optional( + Type.Number({ + minimum: 1900, + maximum: 2013, + }), + ), + email: Type.Optional( + Type.RegExp( + /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, + ), + ), + tags: Type.Array(Type.String()), + enabled: Type.Boolean(), + like: Type.Optional( + Type.Array( + Type.Object({ + id: Type.Number(), + name: Type.String({ minLength: 4, maxLength: 4 }), + }), + ), + ), + dateStr: Type.Date(), +}); + +export const validData: StaticDecode = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'google@gmail.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + like: [ + { + id: 1, + name: 'name', + }, + ], + dateStr: new Date(), +}; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], + url: 'abc', +} as unknown as StaticDecode; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap b/node_modules/@hookform/resolvers/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..f5c378e9a397161c935c587e9150856e4f2ab771 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap @@ -0,0 +1,188 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`typeboxResolver (with compiler) > should return a single error from typeboxResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "birthYear": { + "message": "Expected number", + "ref": undefined, + "type": "41", + }, + "dateStr": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "email": { + "message": "Expected string to match regular expression", + "ref": { + "name": "email", + }, + "type": "48", + }, + "enabled": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "like": [ + { + "id": { + "message": "Expected number", + "ref": undefined, + "type": "41", + }, + "name": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + }, + ], + "password": { + "message": "Expected string length greater or equal to 8", + "ref": { + "name": "password", + }, + "type": "52", + }, + "repeatPassword": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "tags": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "username": { + "message": "Expected required property", + "ref": { + "name": "username", + }, + "type": "45", + }, + }, + "values": {}, +} +`; + +exports[`typeboxResolver (with compiler) > should return all the errors from typeboxResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "62": "Expected union value", + }, + }, + "birthYear": { + "message": "Expected number", + "ref": undefined, + "type": "41", + "types": { + "41": "Expected number", + }, + }, + "dateStr": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "20": "Expected Date", + "45": "Expected required property", + }, + }, + "email": { + "message": "Expected string to match regular expression", + "ref": { + "name": "email", + }, + "type": "48", + "types": { + "48": "Expected string to match regular expression", + }, + }, + "enabled": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "14": "Expected boolean", + "45": "Expected required property", + }, + }, + "like": [ + { + "id": { + "message": "Expected number", + "ref": undefined, + "type": "41", + "types": { + "41": "Expected number", + }, + }, + "name": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "54": "Expected string", + }, + }, + }, + ], + "password": { + "message": "Expected string length greater or equal to 8", + "ref": { + "name": "password", + }, + "type": "52", + "types": { + "52": "Expected string length greater or equal to 8", + "53": "Expected string to match '^(.*[A-Za-z\\d].*)$'", + }, + }, + "repeatPassword": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "54": "Expected string", + }, + }, + "tags": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "6": "Expected array", + }, + }, + "username": { + "message": "Expected required property", + "ref": { + "name": "username", + }, + "type": "45", + "types": { + "45": "Expected required property", + "54": "Expected string", + }, + }, + }, + "values": {}, +} +`; diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/__snapshots__/typebox.ts.snap b/node_modules/@hookform/resolvers/typebox/src/__tests__/__snapshots__/typebox.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..bb1507829c08e6505a4dd86beae4ff803edb1e54 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/__snapshots__/typebox.ts.snap @@ -0,0 +1,188 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`typeboxResolver > should return a single error from typeboxResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "birthYear": { + "message": "Expected number", + "ref": undefined, + "type": "41", + }, + "dateStr": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "email": { + "message": "Expected string to match regular expression", + "ref": { + "name": "email", + }, + "type": "48", + }, + "enabled": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "like": [ + { + "id": { + "message": "Expected number", + "ref": undefined, + "type": "41", + }, + "name": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + }, + ], + "password": { + "message": "Expected string length greater or equal to 8", + "ref": { + "name": "password", + }, + "type": "52", + }, + "repeatPassword": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "tags": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + }, + "username": { + "message": "Expected required property", + "ref": { + "name": "username", + }, + "type": "45", + }, + }, + "values": {}, +} +`; + +exports[`typeboxResolver > should return all the errors from typeboxResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "62": "Expected union value", + }, + }, + "birthYear": { + "message": "Expected number", + "ref": undefined, + "type": "41", + "types": { + "41": "Expected number", + }, + }, + "dateStr": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "20": "Expected Date", + "45": "Expected required property", + }, + }, + "email": { + "message": "Expected string to match regular expression", + "ref": { + "name": "email", + }, + "type": "48", + "types": { + "48": "Expected string to match regular expression", + }, + }, + "enabled": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "14": "Expected boolean", + "45": "Expected required property", + }, + }, + "like": [ + { + "id": { + "message": "Expected number", + "ref": undefined, + "type": "41", + "types": { + "41": "Expected number", + }, + }, + "name": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "54": "Expected string", + }, + }, + }, + ], + "password": { + "message": "Expected string length greater or equal to 8", + "ref": { + "name": "password", + }, + "type": "52", + "types": { + "52": "Expected string length greater or equal to 8", + "53": "Expected string to match '^(.*[A-Za-z\\d].*)$'", + }, + }, + "repeatPassword": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "54": "Expected string", + }, + }, + "tags": { + "message": "Expected required property", + "ref": undefined, + "type": "45", + "types": { + "45": "Expected required property", + "6": "Expected array", + }, + }, + "username": { + "message": "Expected required property", + "ref": { + "name": "username", + }, + "type": "45", + "types": { + "45": "Expected required property", + "54": "Expected string", + }, + }, + }, + "values": {}, +} +`; diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/typebox/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..79082fa0855853595c646ff29856a9d711384974 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/special-path-names.ts @@ -0,0 +1,21 @@ +import { Type } from '@sinclair/typebox'; +import { typeboxResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe('typeboxResolver special path names', () => { + it.each(['hasOwnProperty', 'toString'])( + 'reports a validation error for a field named "%s"', + async (name) => { + const schema = Type.Object({ [name]: Type.String({ minLength: 1 }) }); + + const result = await typeboxResolver(schema as any)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors[name]).toBeDefined(); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/typebox-compiler.ts b/node_modules/@hookform/resolvers/typebox/src/__tests__/typebox-compiler.ts new file mode 100644 index 0000000000000000000000000000000000000000..fce2c1b4d5923497bdd7abddbdd72b84bf9e42de --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/typebox-compiler.ts @@ -0,0 +1,37 @@ +import { TypeCompiler } from '@sinclair/typebox/compiler'; +import { typeboxResolver } from '..'; +import { fields, invalidData, schema, validData } from './__fixtures__/data'; + +const shouldUseNativeValidation = false; + +describe('typeboxResolver (with compiler)', () => { + const typecheck = TypeCompiler.Compile(schema); + + it('should return a single error from typeboxResolver when validation fails', async () => { + const result = await typeboxResolver(typecheck)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from typeboxResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await typeboxResolver(typecheck)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should validate with success', async () => { + const result = await typeboxResolver(typecheck)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toEqual({ errors: {}, values: validData }); + }); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/__tests__/typebox.ts b/node_modules/@hookform/resolvers/typebox/src/__tests__/typebox.ts new file mode 100644 index 0000000000000000000000000000000000000000..05229ccc196f00dc4bddfd3553d96340262f4ba4 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/__tests__/typebox.ts @@ -0,0 +1,145 @@ +import { Type } from '@sinclair/typebox'; +import { TypeCompiler } from '@sinclair/typebox/compiler'; +import { renderHook } from '@testing-library/react'; +import { Resolver, SubmitHandler, useForm } from 'react-hook-form'; +import { typeboxResolver } from '..'; +import { fields, invalidData, schema, validData } from './__fixtures__/data'; + +const shouldUseNativeValidation = false; + +describe('typeboxResolver', () => { + it('should return a single error from typeboxResolver when validation fails', async () => { + const result = await typeboxResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from typeboxResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await typeboxResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should validate with success', async () => { + const result = await typeboxResolver(schema)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toEqual({ errors: {}, values: validData }); + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a typebox schema', () => { + const resolver = typeboxResolver(Type.Object({ id: Type.Number() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a typebox schema with TypeCompiler', () => { + const typecheck = TypeCompiler.Compile(Type.Object({ id: Type.Number() })); + const resolver = typeboxResolver(typecheck); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a typebox schema using a transform', () => { + const resolver = typeboxResolver( + Type.Object({ + id: Type.Transform(Type.Number()) + .Decode((v) => String(v)) + .Encode((v) => Number.parseInt(v)), + }), + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a typebox schema for the handleSubmit function in useForm', () => { + const schema = Type.Object({ id: Type.Number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: typeboxResolver(schema), + defaultValues: { + id: 3, + }, + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a typebox schema with TypeCompiler for the handleSubmit function in useForm', () => { + const typecheck = TypeCompiler.Compile(Type.Object({ id: Type.Number() })); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: typeboxResolver(typecheck), + defaultValues: { + id: 3, + }, + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a typebox schema with a transform for the handleSubmit function in useForm', () => { + const schema = Type.Object({ + id: Type.Transform(Type.Number()) + .Decode((v) => String(v)) + .Encode((v) => Number.parseInt(v)), + }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: typeboxResolver(schema), + defaultValues: { + id: 3, + }, + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/typebox/src/index.ts b/node_modules/@hookform/resolvers/typebox/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f7dfd5006e0c1a6db861c5ac42baf793245d70e2 --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/index.ts @@ -0,0 +1 @@ +export * from './typebox'; diff --git a/node_modules/@hookform/resolvers/typebox/src/typebox.ts b/node_modules/@hookform/resolvers/typebox/src/typebox.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d3c575103abd61a931465728f160dcfb90c285b --- /dev/null +++ b/node_modules/@hookform/resolvers/typebox/src/typebox.ts @@ -0,0 +1,94 @@ +import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; +import { Static, StaticDecode, TObject } from '@sinclair/typebox'; +import { TypeCheck } from '@sinclair/typebox/compiler'; +import { Value, type ValueError } from '@sinclair/typebox/value'; +import { FieldError, Resolver, appendErrors } from 'react-hook-form'; + +function parseErrorSchema( + _errors: ValueError[], + validateAllFieldCriteria: boolean, +) { + // See the matching comment in the zod resolver's `parseZod3Issues`. + const errors: Record = Object.create(null); + for (; _errors.length; ) { + const error = _errors[0]; + const { type, message, path } = error; + const _path = path.substring(1).replace(/\//g, '.'); + + if (!errors[_path]) { + errors[_path] = { message, type: '' + type }; + } + + if (validateAllFieldCriteria) { + const types = errors[_path].types; + const messages = types && types['' + type]; + + errors[_path] = appendErrors( + _path, + validateAllFieldCriteria, + errors, + '' + type, + messages + ? ([] as string[]).concat(messages as string[], error.message) + : error.message, + ) as FieldError; + } + + _errors.shift(); + } + + return errors; +} + +/** + * Creates a resolver for react-hook-form using Typebox schema validation + * @param {Schema | TypeCheck} schema - The Typebox schema to validate against + * @param {Object} options - Additional resolver configuration + * @param {string} [options.mode='async'] - Validation mode + * @returns {Resolver>} A resolver function compatible with react-hook-form + * @example + * const schema = Type.Object({ + * name: Type.String(), + * age: Type.Number() + * }); + * + * useForm({ + * resolver: typeboxResolver(schema) + * }); + * + * // Schemas using a custom/third-party `Kind` (e.g. ElysiaJS's `t.Files()`) must have + * // that kind registered with TypeBox's own `TypeRegistry` before validating, since + * // this resolver validates via `@sinclair/typebox`'s `Value.Errors`/`Value.Check`: + * // TypeRegistry.Set('Files', (schema, value) => Array.isArray(value)); + */ +export function typeboxResolver( + schema: Schema | TypeCheck, +): Resolver, Context, StaticDecode> { + return async (values: Static, _, options) => { + const errors = Array.from( + schema instanceof TypeCheck + ? schema.Errors(values) + : Value.Errors(schema, values), + ); + + options.shouldUseNativeValidation && validateFieldsNatively({}, options); + + if (!errors.length) { + return { + errors: {}, + values, + }; + } + + return { + values: {}, + errors: toNestErrors( + parseErrorSchema( + errors, + !options.shouldUseNativeValidation && options.criteriaMode === 'all', + ), + options, + ), + }; + }; +} diff --git a/node_modules/@hookform/resolvers/typeschema/dist/index.d.ts b/node_modules/@hookform/resolvers/typeschema/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0dc28b8acf035899b888404c1bc14ecf7f45cebe --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/index.d.ts @@ -0,0 +1 @@ +export * from './typeschema'; diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.d.ts b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c399a0aac2a69a3158984611744ed74932ccc111 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.d.ts @@ -0,0 +1,8 @@ +import { StandardSchemaV1 } from '@standard-schema/spec'; +import { FieldValues, Resolver } from 'react-hook-form'; +export declare function typeschemaResolver(schema: StandardSchemaV1, _schemaOptions?: never, resolverOptions?: { + raw?: false; +}): Resolver; +export declare function typeschemaResolver(schema: StandardSchemaV1, _schemaOptions: never | undefined, resolverOptions: { + raw: true; +}): Resolver; diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.js b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.js new file mode 100644 index 0000000000000000000000000000000000000000..0dd02cba26aeac8c68aaa3414aff94da150a8d03 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.js @@ -0,0 +1,2 @@ +var e=require("@hookform/resolvers"),r=require("react-hook-form");function t(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(o);!(a=s()).done;){var u=a.value;if(u.path){var l=u.path.join(".");if(i[l]||(i[l]={message:u.message,type:""}),n){var c=i[l].types,v=c&&c[""];i[l]=r.appendErrors(l,n,i,"",v?[].concat(v,u.message):u.message)}}}return i}(l.issues,!s.shouldUseNativeValidation&&"all"===s.criteriaMode);return{values:{},errors:e.toNestErrors(n,s)}}return s.shouldUseNativeValidation&&e.validateFieldsNatively({},s),{values:o.raw?Object.assign({},a):l.value,errors:{}}},l=n["~standard"].validate(a),c=function(){if(l instanceof Promise)return Promise.resolve(l).then(function(e){l=e})}();return Promise.resolve(c&&c.then?c.then(u):u())}catch(e){return Promise.reject(e)}}}; +//# sourceMappingURL=typeschema.js.map diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.js.map b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.js.map new file mode 100644 index 0000000000000000000000000000000000000000..794e75c7bab371e678638680f672bb57586e0e38 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeschema.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n // Need to pass generics so that the array isn't typed as \"never[]\"\n const schemaErrors = Object.assign(\n [] as typeof typeschemaErrors,\n typeschemaErrors,\n );\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n\n for (const error of schemaErrors) {\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n }\n\n return errors;\n};\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver;\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["schema","_schemaOptions","resolverOptions","values","_","options","_temp2","result","issues","errors","typeschemaErrors","validateAllFieldCriteria","_step","schemaErrors","Object","assign","create","_iterator","_createForOfIteratorHelperLoose","done","error","value","path","_path","join","message","type","types","messages","appendErrors","concat","parseErrorSchema","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","validate","_temp","Promise","resolve","then","_result","e","reject"],"mappings":"4MAqFEA,EACAC,EACAC,GAIA,gBAJAA,IAAAA,EAEI,CAAA,YAEUC,EAAQC,EAAGC,GAAW,IAAA,IAAAC,EAAAA,WAMlC,GAAIC,EAAOC,OAAQ,CACjB,IAAMC,EAxFa,SACvBC,EACAC,GAUA,IAPA,IAOgCC,EAP1BC,EAAeC,OAAOC,OAC1B,GACAL,GAGID,EAAqCK,OAAOE,OAAO,MAEzDC,2pBAAAC,CAAoBL,KAAYD,EAAAK,KAAAE,MAAE,CAAA,IAAvBC,EAAKR,EAAAS,MACd,GAAKD,EAAME,KAAX,CAGA,IAAMC,EAAQH,EAAME,KAAKE,KAAK,KAM9B,GAJKf,EAAOc,KACVd,EAAOc,GAAS,CAAEE,QAASL,EAAMK,QAASC,KAAM,KAG9Cf,EAA0B,CAC5B,IAAMgB,EAAQlB,EAAOc,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhClB,EAAOc,GAASM,EAAYA,aAC1BN,EACAZ,EACAF,EACA,GACAmB,EACK,GAAgBE,OAAOF,EAAsBR,EAAMK,SACpDL,EAAMK,QAEd,CApBA,CAqBF,CAEA,OAAOhB,CACT,CAiDqBsB,CACbxB,EAAOC,QACNH,EAAQ2B,2BAAsD,QAAzB3B,EAAQ4B,cAGhD,MAAO,CACL9B,OAAQ,CAAA,EACRM,OAAQyB,eAAazB,EAAQJ,GAEjC,CAIA,OAFAA,EAAQ2B,2BAA6BG,EAAsBA,uBAAC,GAAI9B,GAEzD,CACLF,OAAQD,EAAgBkC,IAAMtB,OAAOC,OAAO,CAAA,EAAIZ,GAAUI,EAAOc,MACjEZ,OAAQ,GACR,EAtBEF,EAASP,EAAO,aAAaqC,SAASlC,GAAQmC,EAC9C/B,WAAAA,GAAAA,aAAkBgC,QAAOA,OAAAA,QAAAC,QACZjC,GAAMkC,cAAAC,GAArBnC,EAAMmC,CAAgB,EAAAH,CADpBhC,GACoBgC,OAAAA,QAAAC,QAAAF,GAAAA,EAAAG,KAAAH,EAAAG,KAAAnC,GAAAA,IAqB1B,CAAC,MAAAqC,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.mjs b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.mjs new file mode 100644 index 0000000000000000000000000000000000000000..be5b218c1de228dbceaec8bb7fc3e71ccff9e29a --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.mjs @@ -0,0 +1,2 @@ +import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{appendErrors as t}from"react-hook-form";function n(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t=r.length?{done:!0}:{done:!1,value:r[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(a);!(o=s()).done;){var u=o.value;if(u.path){var l=u.path.join(".");if(i[l]||(i[l]={message:u.message,type:""}),e){var c=i[l].types,f=c&&c[""];i[l]=t(l,e,i,"",f?[].concat(f,u.message):u.message)}}}return i}(c.issues,!u.shouldUseNativeValidation&&"all"===u.criteriaMode);return{values:{},errors:r(o,u)}}return u.shouldUseNativeValidation&&e({},u),{values:i.raw?Object.assign({},a):c.value,errors:{}}},c=o["~standard"].validate(a),f=function(){if(c instanceof Promise)return Promise.resolve(c).then(function(r){c=r})}();return Promise.resolve(f&&f.then?f.then(l):l())}catch(r){return Promise.reject(r)}}}export{o as typeschemaResolver}; +//# sourceMappingURL=typeschema.module.js.map diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.modern.mjs b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.modern.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7d57ada46cf847e249c5f26dd8daa43dd2d73ad1 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.modern.mjs @@ -0,0 +1,2 @@ +import{toNestErrors as e,validateFieldsNatively as s}from"@hookform/resolvers";import{appendErrors as t}from"react-hook-form";function o(o,a,r={}){return async(a,i,n)=>{let c=o["~standard"].validate(a);if(c instanceof Promise&&(c=await c),c.issues){const s=((e,s)=>{const o=Object.assign([],e),a=Object.create(null);for(const e of o){if(!e.path)continue;const o=e.path.join(".");if(a[o]||(a[o]={message:e.message,type:""}),s){const r=a[o].types,i=r&&r[""];a[o]=t(o,s,a,"",i?[].concat(i,e.message):e.message)}}return a})(c.issues,!n.shouldUseNativeValidation&&"all"===n.criteriaMode);return{values:{},errors:e(s,n)}}return n.shouldUseNativeValidation&&s({},n),{values:r.raw?Object.assign({},a):c.value,errors:{}}}}export{o as typeschemaResolver}; +//# sourceMappingURL=typeschema.modern.mjs.map diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.modern.mjs.map b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..12dded6369e70ee8d699dd9a2b91e2e5d30955f7 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"typeschema.modern.mjs","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n // Need to pass generics so that the array isn't typed as \"never[]\"\n const schemaErrors = Object.assign(\n [] as typeof typeschemaErrors,\n typeschemaErrors,\n );\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n\n for (const error of schemaErrors) {\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n }\n\n return errors;\n};\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver;\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["typeschemaResolver","schema","_schemaOptions","resolverOptions","values","_","options","result","validate","Promise","issues","errors","parseErrorSchema","typeschemaErrors","validateAllFieldCriteria","schemaErrors","Object","assign","create","error","path","_path","join","message","type","types","messages","appendErrors","concat","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","value"],"mappings":"uIAoFgBA,EACdC,EACAC,EACAC,EAEI,CAAE,GAEN,aAAcC,EAAQC,EAAGC,KACvB,IAAIC,EAASN,EAAO,aAAaO,SAASJ,GAK1C,GAJIG,aAAkBE,UACpBF,QAAeA,GAGbA,EAAOG,OAAQ,CACjB,MAAMC,EAxFaC,EACvBC,EACAC,KAGA,MAAMC,EAAeC,OAAOC,OAC1B,GACAJ,GAGIF,EAAqCK,OAAOE,OAAO,MAEzD,IAAK,MAAMC,KAASJ,EAAc,CAChC,IAAKI,EAAMC,KACT,SAEF,MAAMC,EAAQF,EAAMC,KAAKE,KAAK,KAM9B,GAJKX,EAAOU,KACVV,EAAOU,GAAS,CAAEE,QAASJ,EAAMI,QAASC,KAAM,KAG9CV,EAA0B,CAC5B,MAAMW,EAAQd,EAAOU,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhCd,EAAOU,GAASM,EACdN,EACAP,EACAH,EACA,GACAe,EACK,GAAgBE,OAAOF,EAAsBP,EAAMI,SACpDJ,EAAMI,QAEd,CACF,CAEA,OAAOZ,CAAM,EAkDMC,CACbL,EAAOG,QACNJ,EAAQuB,2BAAsD,QAAzBvB,EAAQwB,cAGhD,MAAO,CACL1B,OAAQ,CAAE,EACVO,OAAQoB,EAAapB,EAAQL,GAEjC,CAIA,OAFAA,EAAQuB,2BAA6BG,EAAuB,CAAA,EAAI1B,GAEzD,CACLF,OAAQD,EAAgB8B,IAAMjB,OAAOC,OAAO,CAAA,EAAIb,GAAUG,EAAO2B,MACjEvB,OAAQ,CAAA,EACT,CAEL"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.module.js b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.module.js new file mode 100644 index 0000000000000000000000000000000000000000..be5b218c1de228dbceaec8bb7fc3e71ccff9e29a --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.module.js @@ -0,0 +1,2 @@ +import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{appendErrors as t}from"react-hook-form";function n(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t=r.length?{done:!0}:{done:!1,value:r[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(a);!(o=s()).done;){var u=o.value;if(u.path){var l=u.path.join(".");if(i[l]||(i[l]={message:u.message,type:""}),e){var c=i[l].types,f=c&&c[""];i[l]=t(l,e,i,"",f?[].concat(f,u.message):u.message)}}}return i}(c.issues,!u.shouldUseNativeValidation&&"all"===u.criteriaMode);return{values:{},errors:r(o,u)}}return u.shouldUseNativeValidation&&e({},u),{values:i.raw?Object.assign({},a):c.value,errors:{}}},c=o["~standard"].validate(a),f=function(){if(c instanceof Promise)return Promise.resolve(c).then(function(r){c=r})}();return Promise.resolve(f&&f.then?f.then(l):l())}catch(r){return Promise.reject(r)}}}export{o as typeschemaResolver}; +//# sourceMappingURL=typeschema.module.js.map diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.module.js.map b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.module.js.map new file mode 100644 index 0000000000000000000000000000000000000000..03268cb4a9f7d6381eb2ea0123fafefabf936dc0 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeschema.module.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n // Need to pass generics so that the array isn't typed as \"never[]\"\n const schemaErrors = Object.assign(\n [] as typeof typeschemaErrors,\n typeschemaErrors,\n );\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n\n for (const error of schemaErrors) {\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n }\n\n return errors;\n};\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver;\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["typeschemaResolver","schema","_schemaOptions","resolverOptions","values","_","options","_temp2","result","issues","errors","typeschemaErrors","validateAllFieldCriteria","_step","schemaErrors","Object","assign","create","_iterator","_createForOfIteratorHelperLoose","done","error","value","path","_path","join","message","type","types","messages","appendErrors","concat","parseErrorSchema","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","validate","_temp","Promise","resolve","then","_result","e","reject"],"mappings":"6OAoFgBA,EACdC,EACAC,EACAC,GAIA,gBAJAA,IAAAA,EAEI,CAAA,YAEUC,EAAQC,EAAGC,GAAW,IAAA,IAAAC,EAAAA,WAMlC,GAAIC,EAAOC,OAAQ,CACjB,IAAMC,EAxFa,SACvBC,EACAC,GAUA,IAPA,IAOgCC,EAP1BC,EAAeC,OAAOC,OAC1B,GACAL,GAGID,EAAqCK,OAAOE,OAAO,MAEzDC,2pBAAAC,CAAoBL,KAAYD,EAAAK,KAAAE,MAAE,CAAA,IAAvBC,EAAKR,EAAAS,MACd,GAAKD,EAAME,KAAX,CAGA,IAAMC,EAAQH,EAAME,KAAKE,KAAK,KAM9B,GAJKf,EAAOc,KACVd,EAAOc,GAAS,CAAEE,QAASL,EAAMK,QAASC,KAAM,KAG9Cf,EAA0B,CAC5B,IAAMgB,EAAQlB,EAAOc,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhClB,EAAOc,GAASM,EACdN,EACAZ,EACAF,EACA,GACAmB,EACK,GAAgBE,OAAOF,EAAsBR,EAAMK,SACpDL,EAAMK,QAEd,CApBA,CAqBF,CAEA,OAAOhB,CACT,CAiDqBsB,CACbxB,EAAOC,QACNH,EAAQ2B,2BAAsD,QAAzB3B,EAAQ4B,cAGhD,MAAO,CACL9B,OAAQ,CAAA,EACRM,OAAQyB,EAAazB,EAAQJ,GAEjC,CAIA,OAFAA,EAAQ2B,2BAA6BG,EAAuB,GAAI9B,GAEzD,CACLF,OAAQD,EAAgBkC,IAAMtB,OAAOC,OAAO,CAAA,EAAIZ,GAAUI,EAAOc,MACjEZ,OAAQ,GACR,EAtBEF,EAASP,EAAO,aAAaqC,SAASlC,GAAQmC,EAC9C/B,WAAAA,GAAAA,aAAkBgC,QAAOA,OAAAA,QAAAC,QACZjC,GAAMkC,cAAAC,GAArBnC,EAAMmC,CAAgB,EAAAH,CADpBhC,GACoBgC,OAAAA,QAAAC,QAAAF,GAAAA,EAAAG,KAAAH,EAAAG,KAAAnC,GAAAA,IAqB1B,CAAC,MAAAqC,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.umd.js b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..0a2dec14bad77ce050f0bbe9c6655ab9794ecbb5 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.umd.js @@ -0,0 +1,2 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form"],r):r((e||self).hookformResolversTypeschema={},e.hookformResolvers,e.ReactHookForm)}(this,function(e,r,t){function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(a);!(n=s()).done;){var l=n.value;if(l.path){var u=l.path.join(".");if(i[u]||(i[u]={message:l.message,type:""}),r){var f=i[u].types,c=f&&f[""];i[u]=t.appendErrors(u,r,i,"",c?[].concat(c,l.message):l.message)}}}return i}(u.issues,!s.shouldUseNativeValidation&&"all"===s.criteriaMode);return{values:{},errors:r.toNestErrors(e,s)}}return s.shouldUseNativeValidation&&r.validateFieldsNatively({},s),{values:a.raw?Object.assign({},n):u.value,errors:{}}},u=e["~standard"].validate(n),f=function(){if(u instanceof Promise)return Promise.resolve(u).then(function(e){u=e})}();return Promise.resolve(f&&f.then?f.then(l):l())}catch(e){return Promise.reject(e)}}}}); +//# sourceMappingURL=typeschema.umd.js.map diff --git a/node_modules/@hookform/resolvers/typeschema/dist/typeschema.umd.js.map b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e45db6ded2becaea55a47f723b3ff6f1e4a5e687 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/dist/typeschema.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeschema.umd.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n // Need to pass generics so that the array isn't typed as \"never[]\"\n const schemaErrors = Object.assign(\n [] as typeof typeschemaErrors,\n typeschemaErrors,\n );\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n\n for (const error of schemaErrors) {\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n }\n\n return errors;\n};\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver;\n\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver(\n schema: StandardSchemaV1,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["schema","_schemaOptions","resolverOptions","values","_","options","_temp2","result","issues","errors","typeschemaErrors","validateAllFieldCriteria","_step","schemaErrors","Object","assign","create","_iterator","_createForOfIteratorHelperLoose","done","error","value","path","_path","join","message","type","types","messages","appendErrors","concat","parseErrorSchema","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","validate","_temp","Promise","resolve","then","_result","e","reject"],"mappings":"mgBAqFEA,EACAC,EACAC,GAIA,gBAJAA,IAAAA,EAEI,CAAA,YAEUC,EAAQC,EAAGC,GAAW,IAAA,IAAAC,EAAAA,WAMlC,GAAIC,EAAOC,OAAQ,CACjB,IAAMC,EAxFa,SACvBC,EACAC,GAUA,IAPA,IAOgCC,EAP1BC,EAAeC,OAAOC,OAC1B,GACAL,GAGID,EAAqCK,OAAOE,OAAO,MAEzDC,2pBAAAC,CAAoBL,KAAYD,EAAAK,KAAAE,MAAE,CAAA,IAAvBC,EAAKR,EAAAS,MACd,GAAKD,EAAME,KAAX,CAGA,IAAMC,EAAQH,EAAME,KAAKE,KAAK,KAM9B,GAJKf,EAAOc,KACVd,EAAOc,GAAS,CAAEE,QAASL,EAAMK,QAASC,KAAM,KAG9Cf,EAA0B,CAC5B,IAAMgB,EAAQlB,EAAOc,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhClB,EAAOc,GAASM,EAAYA,aAC1BN,EACAZ,EACAF,EACA,GACAmB,EACK,GAAgBE,OAAOF,EAAsBR,EAAMK,SACpDL,EAAMK,QAEd,CApBA,CAqBF,CAEA,OAAOhB,CACT,CAiDqBsB,CACbxB,EAAOC,QACNH,EAAQ2B,2BAAsD,QAAzB3B,EAAQ4B,cAGhD,MAAO,CACL9B,OAAQ,CAAA,EACRM,OAAQyB,eAAazB,EAAQJ,GAEjC,CAIA,OAFAA,EAAQ2B,2BAA6BG,EAAsBA,uBAAC,GAAI9B,GAEzD,CACLF,OAAQD,EAAgBkC,IAAMtB,OAAOC,OAAO,CAAA,EAAIZ,GAAUI,EAAOc,MACjEZ,OAAQ,GACR,EAtBEF,EAASP,EAAO,aAAaqC,SAASlC,GAAQmC,EAC9C/B,WAAAA,GAAAA,aAAkBgC,QAAOA,OAAAA,QAAAC,QACZjC,GAAMkC,cAAAC,GAArBnC,EAAMmC,CAAgB,EAAAH,CADpBhC,GACoBgC,OAAAA,QAAAC,QAAAF,GAAAA,EAAAG,KAAAH,EAAAG,KAAAnC,GAAAA,IAqB1B,CAAC,MAAAqC,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/typeschema/package.json b/node_modules/@hookform/resolvers/typeschema/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ae7cd1dbad84905fac466a06d3b473fe5d7baeb1 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/package.json @@ -0,0 +1,18 @@ +{ + "name": "@hookform/resolvers/typeschema", + "amdName": "hookformResolversTypeschema", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: typeschema", + "main": "dist/typeschema.js", + "module": "dist/typeschema.module.js", + "umd:main": "dist/typeschema.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.55.0", + "@hookform/resolvers": "^2.0.0", + "@typeschema/main": "^0.13.7" + } +} diff --git a/node_modules/@hookform/resolvers/typeschema/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/typeschema/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..5e39ff21c2845c4836d61abf14dd84c62aff8915 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,81 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod/v3'; +import { typeschemaResolver } from '..'; + +const USERNAME_REQUIRED_MESSAGE = 'username field is required'; +const PASSWORD_REQUIRED_MESSAGE = 'password field is required'; + +const schema = z.object({ + username: z.string().min(1, { message: USERNAME_REQUIRED_MESSAGE }), + password: z.string().min(1, { message: PASSWORD_REQUIRED_MESSAGE }), +}); + +type FormData = z.infer; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: typeschemaResolver(schema), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with TypeSchema", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe(PASSWORD_REQUIRED_MESSAGE); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/typeschema/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/typeschema/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a544df84334d46166fdf3819f05933a17962d06b --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/__tests__/Form.tsx @@ -0,0 +1,50 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod/v3'; +import { typeschemaResolver } from '..'; + +const schema = z.object({ + username: z.string().min(1, { message: 'username field is required' }), + password: z.string().min(1, { message: 'password field is required' }), +}); + +interface Props { + onSubmit: (data: z.infer) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: typeschemaResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with TypeSchema and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect(screen.getByText(/username field is required/i)).toBeInTheDocument(); + expect(screen.getByText(/password field is required/i)).toBeInTheDocument(); + expect(handleSubmit).not.toHaveBeenCalled(); +}); diff --git a/node_modules/@hookform/resolvers/typeschema/src/__tests__/__fixtures__/data.ts b/node_modules/@hookform/resolvers/typeschema/src/__tests__/__fixtures__/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..d206eee7fcb2f0fe1262a7073faf26d4c41d1e8f --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/__tests__/__fixtures__/data.ts @@ -0,0 +1,88 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import { z } from 'zod/v3'; + +export const schema = z + .object({ + username: z.string().regex(/^\w+$/).min(3).max(30), + password: z + .string() + .regex(new RegExp('.*[A-Z].*'), 'One uppercase character') + .regex(new RegExp('.*[a-z].*'), 'One lowercase character') + .regex(new RegExp('.*\\d.*'), 'One number') + .regex( + new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), + 'One special character', + ) + .min(8, 'Must be at least 8 characters in length'), + repeatPassword: z.string(), + accessToken: z.union([z.string(), z.number()]), + birthYear: z.number().min(1900).max(2013).optional(), + email: z.string().email().optional(), + tags: z.array(z.string()), + enabled: z.boolean(), + url: z.string().url('Custom error url').or(z.literal('')), + like: z + .array( + z.object({ + id: z.number(), + name: z.string().length(4), + }), + ) + .optional(), + dateStr: z + .string() + .transform((value) => new Date(value)) + .refine((value) => !isNaN(value.getTime()), { + message: 'Invalid date', + }), + }) + .refine((obj) => obj.password === obj.repeatPassword, { + message: 'Passwords do not match', + path: ['confirm'], + }); + +export const validData: z.input = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + url: 'https://react-hook-form.com/', + like: [ + { + id: 1, + name: 'name', + }, + ], + dateStr: '2020-01-01', +}; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], + url: 'abc', +} as unknown as z.input; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/typeschema/src/__tests__/__snapshots__/typeschema.ts.snap b/node_modules/@hookform/resolvers/typeschema/src/__tests__/__snapshots__/typeschema.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..143a3fcd04e86b984560ec63b995473464b8226f --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/__tests__/__snapshots__/typeschema.ts.snap @@ -0,0 +1,225 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`typeschemaResolver > should return a single error from typeschemaResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input", + "ref": undefined, + "type": "", + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "", + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "", + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "", + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "", + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "", + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "", + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "", + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "", + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "", + }, + }, + "values": {}, +} +`; + +exports[`typeschemaResolver > should return all the errors from typeschemaResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input", + "ref": undefined, + "type": "", + "types": { + "": "Invalid input", + }, + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "", + "types": { + "": "Expected number, received string", + }, + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "", + "types": { + "": "Required", + }, + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "", + "types": { + "": "Invalid email", + }, + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "", + "types": { + "": "Required", + }, + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "", + "types": { + "": "Expected number, received string", + }, + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "", + "types": { + "": "Required", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "", + "types": { + "": [ + "One uppercase character", + "One lowercase character", + "One number", + "Must be at least 8 characters in length", + ], + }, + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "", + "types": { + "": "Required", + }, + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "", + "types": { + "": "Required", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "", + "types": { + "": "Custom error url", + }, + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "", + "types": { + "": "Required", + }, + }, + }, + "values": {}, +} +`; + +exports[`typeschemaResolver > should return parsed values from typeschemaResolver when validation pass 1`] = ` +{ + "errors": {}, + "values": { + "accessToken": "accessToken", + "birthYear": 2000, + "dateStr": 2020-01-01T00:00:00.000Z, + "email": "john@doe.com", + "enabled": true, + "like": [ + { + "id": 1, + "name": "name", + }, + ], + "password": "Password123_", + "repeatPassword": "Password123_", + "tags": [ + "tag1", + "tag2", + ], + "url": "https://react-hook-form.com/", + "username": "Doe", + }, +} +`; diff --git a/node_modules/@hookform/resolvers/typeschema/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/typeschema/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd5a193bcbf0e667256ff408086f3323071b01eb --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/__tests__/special-path-names.ts @@ -0,0 +1,21 @@ +import { z } from 'zod/v3'; +import { typeschemaResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe('typeschemaResolver special path names', () => { + it.each(['hasOwnProperty', 'toString'])( + 'reports a validation error for a field named "%s"', + async (name) => { + const schema = z.object({ [name]: z.string().min(1) }); + + const result = await typeschemaResolver(schema as any)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors[name]).toBeDefined(); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/typeschema/src/__tests__/typeschema.ts b/node_modules/@hookform/resolvers/typeschema/src/__tests__/typeschema.ts new file mode 100644 index 0000000000000000000000000000000000000000..979057dcbe7e1647e992836c8e65420cd42c5191 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/__tests__/typeschema.ts @@ -0,0 +1,155 @@ +import { renderHook } from '@testing-library/react'; +import { Resolver, SubmitHandler, useForm } from 'react-hook-form'; +import { z } from 'zod/v3'; +import { typeschemaResolver } from '..'; +import { fields, invalidData, schema, validData } from './__fixtures__/data'; + +const shouldUseNativeValidation = false; + +vi.mock('@typeschema/main', async (importOriginal) => { + const module: object = await importOriginal(); + return { ...module }; +}); + +describe('typeschemaResolver', () => { + it('should return values from typeschemaResolver when validation pass & raw=true', async () => { + const validateSpy = vi.spyOn(schema['~standard'], 'validate'); + + const result = await typeschemaResolver(schema, undefined, { raw: true })( + validData, + undefined, + { fields, shouldUseNativeValidation }, + ); + + expect(validateSpy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return parsed values from typeschemaResolver when validation pass', async () => { + const validateSpy = vi.spyOn(schema['~standard'], 'validate'); + + const result = await typeschemaResolver(schema)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(validateSpy).toHaveBeenCalledTimes(1); + expect(result.errors).toEqual({}); + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from typeschemaResolver when validation fails', async () => { + const result = await typeschemaResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from typeschemaResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await typeschemaResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should throw any error unrelated to TypeSchema', async () => { + const schemaWithCustomError = schema.refine(() => { + throw Error('custom error'); + }); + const promise = typeschemaResolver(schemaWithCustomError)( + validData, + undefined, + { fields, shouldUseNativeValidation }, + ); + + await expect(promise).rejects.toThrow('custom error'); + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a typeschema schema', () => { + const resolver = typeschemaResolver(z.object({ id: z.number() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a typeschema schema using a transform', () => { + const resolver = typeschemaResolver( + z.object({ id: z.number().transform((val) => String(val)) }), + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a typeschema schema when a different input type is specified', () => { + const schema = z.object({ id: z.number() }).transform(({ id }) => { + return { id: String(id) }; + }); + + const resolver = typeschemaResolver< + { id: number }, + any, + z.output + >(schema); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, any, { id: string }> + >(); + }); + + it('should correctly infer the output type from a typeschema schema for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: typeschemaResolver(schema), + defaultValues: { + id: 3, + }, + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a typeschema schema with a transform for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number().transform((val) => String(val)) }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: typeschemaResolver(schema), + defaultValues: { + id: 3, + }, + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/typeschema/src/index.ts b/node_modules/@hookform/resolvers/typeschema/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0dc28b8acf035899b888404c1bc14ecf7f45cebe --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/index.ts @@ -0,0 +1 @@ +export * from './typeschema'; diff --git a/node_modules/@hookform/resolvers/typeschema/src/typeschema.ts b/node_modules/@hookform/resolvers/typeschema/src/typeschema.ts new file mode 100644 index 0000000000000000000000000000000000000000..35121741da0eb34bbd68d5c7da142e44e6106247 --- /dev/null +++ b/node_modules/@hookform/resolvers/typeschema/src/typeschema.ts @@ -0,0 +1,117 @@ +import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; +import { StandardSchemaV1 } from '@standard-schema/spec'; +import { + FieldError, + FieldErrors, + FieldValues, + Resolver, + appendErrors, +} from 'react-hook-form'; + +const parseErrorSchema = ( + typeschemaErrors: readonly StandardSchemaV1.Issue[], + validateAllFieldCriteria: boolean, +): FieldErrors => { + // Need to pass generics so that the array isn't typed as "never[]" + const schemaErrors = Object.assign( + [] as typeof typeschemaErrors, + typeschemaErrors, + ); + // See the matching comment in the zod resolver's `parseZod3Issues`. + const errors: Record = Object.create(null); + + for (const error of schemaErrors) { + if (!error.path) { + continue; + } + const _path = error.path.join('.'); + + if (!errors[_path]) { + errors[_path] = { message: error.message, type: '' }; + } + + if (validateAllFieldCriteria) { + const types = errors[_path].types; + const messages = types && types['']; + + errors[_path] = appendErrors( + _path, + validateAllFieldCriteria, + errors, + '', + messages + ? ([] as string[]).concat(messages as string[], error.message) + : error.message, + ) as FieldError; + } + } + + return errors; +}; + +export function typeschemaResolver( + schema: StandardSchemaV1, + _schemaOptions?: never, + resolverOptions?: { + raw?: false; + }, +): Resolver; + +export function typeschemaResolver( + schema: StandardSchemaV1, + _schemaOptions: never | undefined, + resolverOptions: { + raw: true; + }, +): Resolver; + +/** + * Creates a resolver for react-hook-form using TypeSchema validation + * @param {any} schema - The TypeSchema to validate against + * @param {any} _ - Unused parameter + * @param {Object} resolverOptions - Additional resolver configuration + * @param {string} [resolverOptions.mode='async'] - Validation mode + * @returns {Resolver} A resolver function compatible with react-hook-form + * @example + * const schema = z.object({ + * name: z.string().required(), + * age: z.number().required(), + * }); + * + * useForm({ + * resolver: typeschemaResolver(schema) + * }); + */ +export function typeschemaResolver( + schema: StandardSchemaV1, + _schemaOptions?: never, + resolverOptions: { + raw?: boolean; + } = {}, +): Resolver { + return async (values, _, options) => { + let result = schema['~standard'].validate(values); + if (result instanceof Promise) { + result = await result; + } + + if (result.issues) { + const errors = parseErrorSchema( + result.issues, + !options.shouldUseNativeValidation && options.criteriaMode === 'all', + ); + + return { + values: {}, + errors: toNestErrors(errors, options), + }; + } + + options.shouldUseNativeValidation && validateFieldsNatively({}, options); + + return { + values: resolverOptions.raw ? Object.assign({}, values) : result.value, + errors: {}, + }; + }; +} diff --git a/node_modules/@hookform/resolvers/valibot/dist/index.d.ts b/node_modules/@hookform/resolvers/valibot/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..097f317f8f5f37a2ee4e21cc7f977652c3e4bf3c --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/index.d.ts @@ -0,0 +1 @@ +export * from './valibot'; diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.d.ts b/node_modules/@hookform/resolvers/valibot/dist/valibot.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b01c643dfdcc56702425096ed76dfd077bf406f9 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.d.ts @@ -0,0 +1,10 @@ +import { FieldValues, Resolver } from 'react-hook-form'; +import { BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot'; +export declare function valibotResolver(schema: BaseSchema | BaseSchemaAsync, schemaOptions?: Partial>, 'abortPipeEarly' | 'skipPipe'>>, resolverOptions?: { + mode?: 'async' | 'sync'; + raw?: false; +}): Resolver; +export declare function valibotResolver(schema: BaseSchema | BaseSchemaAsync, schemaOptions: Partial>, 'abortPipeEarly' | 'skipPipe'>> | undefined, resolverOptions: { + mode?: 'async' | 'sync'; + raw: true; +}): Resolver; diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.js b/node_modules/@hookform/resolvers/valibot/dist/valibot.js new file mode 100644 index 0000000000000000000000000000000000000000..05dcdb2c5c226653f48eb6e19959d1e1275d9d4c --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.js @@ -0,0 +1,2 @@ +var e=require("@hookform/resolvers"),r=require("react-hook-form"),s=require("valibot");exports.valibotResolver=function(t,a,o){return void 0===o&&(o={}),function(i,u,n){try{var c=!n.shouldUseNativeValidation&&"all"===n.criteriaMode;return Promise.resolve(s.safeParseAsync(t,i,Object.assign({},a,{abortPipeEarly:!c}))).then(function(t){if(t.issues){for(var a=Object.create(null);t.issues.length;){var u=t.issues[0],l=s.getDotPath(u);if(l&&(a[l]||(a[l]={message:u.message,type:u.type}),c)){var v=a[l].types,f=v&&v[u.type];a[l]=r.appendErrors(l,c,a,u.type,f?[].concat(f,u.message):u.message)}t.issues.shift()}return{values:{},errors:e.toNestErrors(a,n)}}return{values:o.raw?Object.assign({},i):t.output,errors:{}}})}catch(e){return Promise.reject(e)}}}; +//# sourceMappingURL=valibot.js.map diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.js.map b/node_modules/@hookform/resolvers/valibot/dist/valibot.js.map new file mode 100644 index 0000000000000000000000000000000000000000..46369b53b7a74faec88e4b3c8fa45c7acd560005 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.js.map @@ -0,0 +1 @@ +{"version":3,"file":"valibot.js","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport { BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot';\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions:\n | Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >\n | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using Valibot schema validation\n * @param {BaseSchema | BaseSchemaAsync} schema - The Valibot schema to validate against\n * @param {Partial>, 'abortPipeEarly' | 'skipPipe'>>} [schemaOptions] - Optional Valibot validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('sync' | 'async')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values rather than validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = valibot.object({\n * name: valibot.string().minLength(2),\n * age: valibot.number().min(18)\n * });\n *\n * useForm({\n * resolver: valibotResolver(schema)\n * });\n */\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'sync' | 'async';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values: Input, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object. A null-prototype object avoids false-positive\n // hits from inherited members (e.g. `toString`, `constructor`) when a\n // field is named after one of them — a plain `{}` would make\n // `!errors[path]` truthy-skip those paths and silently drop their\n // errors.\n const errors: Record = Object.create(null);\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.output,\n errors: {},\n };\n };\n}\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","Promise","resolve","safeParseAsync","Object","assign","abortPipeEarly","then","result","issues","errors","create","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output","e","reject"],"mappings":"+GAoDM,SACJA,EACAC,EAGAC,GAYA,gBAZAA,IAAAA,EAUI,CAAE,GAEQC,SAAAA,EAAeC,EAAGC,OAE9B,IAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAAuB,OAAAC,QAAAC,QAGlDC,EAAcA,eACjCX,EACAG,EACAS,OAAOC,OAAO,CAAA,EAAIZ,EAAe,CAC/Ba,gBAAiBR,MAEpBS,KAAA,SANKC,GASN,GAAIA,EAAOC,OAAQ,CASjB,IAHA,IAAMC,EAAqCN,OAAOO,OAAO,MAGlDH,EAAOC,OAAOG,QAAU,CAC7B,IAAMC,EAAQL,EAAOC,OAAO,GAEtBK,EAAOC,EAAUA,WAACF,GAExB,GAAIC,IAEGJ,EAAOI,KACVJ,EAAOI,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDnB,GAA0B,CAC5B,IAAMoB,EAAQR,EAAOI,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCP,EAAOI,GAAQM,EAAYA,aACzBN,EACAhB,EACAY,EACAG,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFR,EAAOC,OAAOa,OAChB,CAGA,MAAO,CACL3B,OAAQ,GACRe,OAAQa,EAAAA,aAAab,EAAQb,GAEjC,CAGA,MAAO,CACLF,OAAQD,EAAgB8B,IAAMpB,OAAOC,OAAO,CAAE,EAAEV,GAAUa,EAAOiB,OACjEf,OAAQ,GACR,EACJ,CAAC,MAAAgB,UAAAzB,QAAA0B,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.mjs b/node_modules/@hookform/resolvers/valibot/dist/valibot.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c12180ed0626d9d2eba54c5ac1477cb9d7b05747 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.mjs @@ -0,0 +1,2 @@ +import{toNestErrors as e}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";import{safeParseAsync as s,getDotPath as t}from"valibot";function o(o,a,i){return void 0===i&&(i={}),function(n,u,c){try{var m=!c.shouldUseNativeValidation&&"all"===c.criteriaMode;return Promise.resolve(s(o,n,Object.assign({},a,{abortPipeEarly:!m}))).then(function(s){if(s.issues){for(var o=Object.create(null);s.issues.length;){var a=s.issues[0],u=t(a);if(u&&(o[u]||(o[u]={message:a.message,type:a.type}),m)){var l=o[u].types,f=l&&l[a.type];o[u]=r(u,m,o,a.type,f?[].concat(f,a.message):a.message)}s.issues.shift()}return{values:{},errors:e(o,c)}}return{values:i.raw?Object.assign({},n):s.output,errors:{}}})}catch(e){return Promise.reject(e)}}}export{o as valibotResolver}; +//# sourceMappingURL=valibot.module.js.map diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs b/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0ff9a00b578661f874adf331255a591f85a61606 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs @@ -0,0 +1,2 @@ +import{toNestErrors as e}from"@hookform/resolvers";import{appendErrors as s}from"react-hook-form";import{safeParseAsync as t,getDotPath as r}from"valibot";function o(o,a,i={}){return async(n,c,u)=>{const l=!u.shouldUseNativeValidation&&"all"===u.criteriaMode,m=await t(o,n,Object.assign({},a,{abortPipeEarly:!l}));if(m.issues){const t=Object.create(null);for(;m.issues.length;){const e=m.issues[0],o=r(e);if(o&&(t[o]||(t[o]={message:e.message,type:e.type}),l)){const r=t[o].types,a=r&&r[e.type];t[o]=s(o,l,t,e.type,a?[].concat(a,e.message):e.message)}m.issues.shift()}return{values:{},errors:e(t,u)}}return{values:i.raw?Object.assign({},n):m.output,errors:{}}}}export{o as valibotResolver}; +//# sourceMappingURL=valibot.modern.mjs.map diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs.map b/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..89b6a4a0eda3335bc4f89bccf775a8d40c282c3e --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"valibot.modern.mjs","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport { BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot';\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions:\n | Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >\n | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using Valibot schema validation\n * @param {BaseSchema | BaseSchemaAsync} schema - The Valibot schema to validate against\n * @param {Partial>, 'abortPipeEarly' | 'skipPipe'>>} [schemaOptions] - Optional Valibot validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('sync' | 'async')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values rather than validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = valibot.object({\n * name: valibot.string().minLength(2),\n * age: valibot.number().min(18)\n * });\n *\n * useForm({\n * resolver: valibotResolver(schema)\n * });\n */\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'sync' | 'async';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values: Input, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object. A null-prototype object avoids false-positive\n // hits from inherited members (e.g. `toString`, `constructor`) when a\n // field is named after one of them — a plain `{}` would make\n // `!errors[path]` truthy-skip those paths and silently drop their\n // errors.\n const errors: Record = Object.create(null);\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.output,\n errors: {},\n };\n };\n}\n"],"names":["valibotResolver","schema","schemaOptions","resolverOptions","async","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","result","safeParseAsync","Object","assign","abortPipeEarly","issues","errors","create","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output"],"mappings":"2JAoDgB,SAAAA,EACdC,EACAC,EAGAC,EAUI,CAAA,GAEJ,OAAOC,MAAOC,EAAeC,EAAGC,KAE9B,MAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAG1CC,QAAeC,EACnBX,EACAI,EACAQ,OAAOC,OAAO,CAAA,EAAIZ,EAAe,CAC/Ba,gBAAiBP,KAKrB,GAAIG,EAAOK,OAAQ,CAMjB,MAAMC,EAAqCJ,OAAOK,OAAO,MAGzD,KAAOP,EAAOK,OAAOG,QAAU,CAC7B,MAAMC,EAAQT,EAAOK,OAAO,GAEtBK,EAAOC,EAAWF,GAExB,GAAIC,IAEGJ,EAAOI,KACVJ,EAAOI,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDhB,GAA0B,CAC5B,MAAMiB,EAAQR,EAAOI,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCP,EAAOI,GAAQM,EACbN,EACAb,EACAS,EACAG,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFZ,EAAOK,OAAOa,OAChB,CAGA,MAAO,CACLxB,OAAQ,CAAE,EACVY,OAAQa,EAAab,EAAQV,GAEjC,CAGA,MAAO,CACLF,OAAQF,EAAgB4B,IAAMlB,OAAOC,OAAO,CAAA,EAAIT,GAAUM,EAAOqB,OACjEf,OAAQ,GACT,CAEL"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js b/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js new file mode 100644 index 0000000000000000000000000000000000000000..c12180ed0626d9d2eba54c5ac1477cb9d7b05747 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js @@ -0,0 +1,2 @@ +import{toNestErrors as e}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";import{safeParseAsync as s,getDotPath as t}from"valibot";function o(o,a,i){return void 0===i&&(i={}),function(n,u,c){try{var m=!c.shouldUseNativeValidation&&"all"===c.criteriaMode;return Promise.resolve(s(o,n,Object.assign({},a,{abortPipeEarly:!m}))).then(function(s){if(s.issues){for(var o=Object.create(null);s.issues.length;){var a=s.issues[0],u=t(a);if(u&&(o[u]||(o[u]={message:a.message,type:a.type}),m)){var l=o[u].types,f=l&&l[a.type];o[u]=r(u,m,o,a.type,f?[].concat(f,a.message):a.message)}s.issues.shift()}return{values:{},errors:e(o,c)}}return{values:i.raw?Object.assign({},n):s.output,errors:{}}})}catch(e){return Promise.reject(e)}}}export{o as valibotResolver}; +//# sourceMappingURL=valibot.module.js.map diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js.map b/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a4c457d2ec3090e99aaba6cb49a4c1e2161098e4 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"valibot.module.js","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport { BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot';\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions:\n | Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >\n | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using Valibot schema validation\n * @param {BaseSchema | BaseSchemaAsync} schema - The Valibot schema to validate against\n * @param {Partial>, 'abortPipeEarly' | 'skipPipe'>>} [schemaOptions] - Optional Valibot validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('sync' | 'async')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values rather than validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = valibot.object({\n * name: valibot.string().minLength(2),\n * age: valibot.number().min(18)\n * });\n *\n * useForm({\n * resolver: valibotResolver(schema)\n * });\n */\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'sync' | 'async';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values: Input, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object. A null-prototype object avoids false-positive\n // hits from inherited members (e.g. `toString`, `constructor`) when a\n // field is named after one of them — a plain `{}` would make\n // `!errors[path]` truthy-skip those paths and silently drop their\n // errors.\n const errors: Record = Object.create(null);\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.output,\n errors: {},\n };\n };\n}\n"],"names":["valibotResolver","schema","schemaOptions","resolverOptions","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","Promise","resolve","safeParseAsync","Object","assign","abortPipeEarly","then","result","issues","errors","create","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output","e","reject"],"mappings":"2JAoDM,SAAUA,EACdC,EACAC,EAGAC,GAYA,gBAZAA,IAAAA,EAUI,CAAE,GAEQC,SAAAA,EAAeC,EAAGC,OAE9B,IAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAAuB,OAAAC,QAAAC,QAGlDC,EACnBX,EACAG,EACAS,OAAOC,OAAO,CAAA,EAAIZ,EAAe,CAC/Ba,gBAAiBR,MAEpBS,KAAA,SANKC,GASN,GAAIA,EAAOC,OAAQ,CASjB,IAHA,IAAMC,EAAqCN,OAAOO,OAAO,MAGlDH,EAAOC,OAAOG,QAAU,CAC7B,IAAMC,EAAQL,EAAOC,OAAO,GAEtBK,EAAOC,EAAWF,GAExB,GAAIC,IAEGJ,EAAOI,KACVJ,EAAOI,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDnB,GAA0B,CAC5B,IAAMoB,EAAQR,EAAOI,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCP,EAAOI,GAAQM,EACbN,EACAhB,EACAY,EACAG,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFR,EAAOC,OAAOa,OAChB,CAGA,MAAO,CACL3B,OAAQ,GACRe,OAAQa,EAAab,EAAQb,GAEjC,CAGA,MAAO,CACLF,OAAQD,EAAgB8B,IAAMpB,OAAOC,OAAO,CAAE,EAAEV,GAAUa,EAAOiB,OACjEf,OAAQ,GACR,EACJ,CAAC,MAAAgB,UAAAzB,QAAA0B,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js b/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..ea94e19e153396e25dc3467ca3fcf4c9f742dd27 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js @@ -0,0 +1,2 @@ +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@hookform/resolvers"),require("react-hook-form"),require("valibot")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form","valibot"],o):o((e||self).hookformResolversValibot={},e.hookformResolvers,e.ReactHookForm,e.valibot)}(this,function(e,o,r,s){e.valibotResolver=function(e,t,i){return void 0===i&&(i={}),function(a,n,f){try{var l=!f.shouldUseNativeValidation&&"all"===f.criteriaMode;return Promise.resolve(s.safeParseAsync(e,a,Object.assign({},t,{abortPipeEarly:!l}))).then(function(e){if(e.issues){for(var t=Object.create(null);e.issues.length;){var n=e.issues[0],u=s.getDotPath(n);if(u&&(t[u]||(t[u]={message:n.message,type:n.type}),l)){var c=t[u].types,v=c&&c[n.type];t[u]=r.appendErrors(u,l,t,n.type,v?[].concat(v,n.message):n.message)}e.issues.shift()}return{values:{},errors:o.toNestErrors(t,f)}}return{values:i.raw?Object.assign({},a):e.output,errors:{}}})}catch(e){return Promise.reject(e)}}}}); +//# sourceMappingURL=valibot.umd.js.map diff --git a/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js.map b/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..104c90d491ce9cc4c618547bc542bad2e6953b6d --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"valibot.umd.js","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport { BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot';\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions:\n | Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >\n | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using Valibot schema validation\n * @param {BaseSchema | BaseSchemaAsync} schema - The Valibot schema to validate against\n * @param {Partial>, 'abortPipeEarly' | 'skipPipe'>>} [schemaOptions] - Optional Valibot validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('sync' | 'async')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values rather than validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = valibot.object({\n * name: valibot.string().minLength(2),\n * age: valibot.number().min(18)\n * });\n *\n * useForm({\n * resolver: valibotResolver(schema)\n * });\n */\nexport function valibotResolver(\n schema: BaseSchema | BaseSchemaAsync,\n schemaOptions?: Partial<\n Omit>, 'abortPipeEarly' | 'skipPipe'>\n >,\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'sync' | 'async';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver {\n return async (values: Input, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object. A null-prototype object avoids false-positive\n // hits from inherited members (e.g. `toString`, `constructor`) when a\n // field is named after one of them — a plain `{}` would make\n // `!errors[path]` truthy-skip those paths and silently drop their\n // errors.\n const errors: Record = Object.create(null);\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.output,\n errors: {},\n };\n };\n}\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","Promise","resolve","safeParseAsync","Object","assign","abortPipeEarly","then","result","issues","errors","create","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output","e","reject"],"mappings":"ubAoDM,SACJA,EACAC,EAGAC,GAYA,gBAZAA,IAAAA,EAUI,CAAE,GAEQC,SAAAA,EAAeC,EAAGC,OAE9B,IAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAAuB,OAAAC,QAAAC,QAGlDC,EAAcA,eACjCX,EACAG,EACAS,OAAOC,OAAO,CAAA,EAAIZ,EAAe,CAC/Ba,gBAAiBR,MAEpBS,KAAA,SANKC,GASN,GAAIA,EAAOC,OAAQ,CASjB,IAHA,IAAMC,EAAqCN,OAAOO,OAAO,MAGlDH,EAAOC,OAAOG,QAAU,CAC7B,IAAMC,EAAQL,EAAOC,OAAO,GAEtBK,EAAOC,EAAUA,WAACF,GAExB,GAAIC,IAEGJ,EAAOI,KACVJ,EAAOI,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDnB,GAA0B,CAC5B,IAAMoB,EAAQR,EAAOI,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCP,EAAOI,GAAQM,EAAYA,aACzBN,EACAhB,EACAY,EACAG,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFR,EAAOC,OAAOa,OAChB,CAGA,MAAO,CACL3B,OAAQ,GACRe,OAAQa,EAAAA,aAAab,EAAQb,GAEjC,CAGA,MAAO,CACLF,OAAQD,EAAgB8B,IAAMpB,OAAOC,OAAO,CAAE,EAAEV,GAAUa,EAAOiB,OACjEf,OAAQ,GACR,EACJ,CAAC,MAAAgB,UAAAzB,QAAA0B,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/valibot/package.json b/node_modules/@hookform/resolvers/valibot/package.json new file mode 100644 index 0000000000000000000000000000000000000000..fe3f50220643ab6dc518bf9a1cbcdb430caf1825 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/package.json @@ -0,0 +1,18 @@ +{ + "name": "@hookform/resolvers/valibot", + "amdName": "hookformResolversValibot", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: valibot", + "main": "dist/valibot.js", + "module": "dist/valibot.module.js", + "umd:main": "dist/valibot.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "@hookform/resolvers": "^2.0.0", + "react-hook-form": "^7.55.0", + "valibot": ">=0.31.0 || ^1.0.0-beta.4 || ^1.0.0-rc" + } +} diff --git a/node_modules/@hookform/resolvers/valibot/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/valibot/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..cabf71e5e328477fab1088615ce6f88c33301d32 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,81 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import * as v from 'valibot'; +import { valibotResolver } from '..'; + +const USERNAME_REQUIRED_MESSAGE = 'username field is v.required'; +const PASSWORD_REQUIRED_MESSAGE = 'password field is v.required'; + +const schema = v.object({ + username: v.pipe( + v.string(USERNAME_REQUIRED_MESSAGE), + v.minLength(2, USERNAME_REQUIRED_MESSAGE), + ), + password: v.pipe( + v.string(PASSWORD_REQUIRED_MESSAGE), + v.minLength(2, PASSWORD_REQUIRED_MESSAGE), + ), +}); + +type FormData = { username: string; password: string }; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: valibotResolver(schema), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Valibot", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe(PASSWORD_REQUIRED_MESSAGE); + + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/valibot/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/valibot/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..44bc9bbe682c7020675cf9f0058a7438d13c2484 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/__tests__/Form.tsx @@ -0,0 +1,87 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import * as v from 'valibot'; +import { valibotResolver } from '..'; + +const USERNAME_REQUIRED_MESSAGE = 'username field is required'; +const PASSWORD_REQUIRED_MESSAGE = 'password field is required'; + +const schema = v.object({ + username: v.pipe( + v.string(USERNAME_REQUIRED_MESSAGE), + v.minLength(2, USERNAME_REQUIRED_MESSAGE), + ), + password: v.pipe( + v.string(PASSWORD_REQUIRED_MESSAGE), + v.minLength(2, PASSWORD_REQUIRED_MESSAGE), + ), +}); + +type FormData = { username: string; password: string }; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: valibotResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Valibot and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect(screen.getByText(/username field is required/i)).toBeInTheDocument(); + expect(screen.getByText(/password field is required/i)).toBeInTheDocument(); + expect(handleSubmit).not.toHaveBeenCalled(); +}); + +export function TestComponentManualType({ + onSubmit, +}: { + onSubmit: (data: FormData) => void; +}) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm, undefined, FormData>({ + resolver: valibotResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} diff --git a/node_modules/@hookform/resolvers/valibot/src/__tests__/__fixtures__/data.ts b/node_modules/@hookform/resolvers/valibot/src/__tests__/__fixtures__/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..21691c708d1e53412d5a8ff40874ac255cf62ecc --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/__tests__/__fixtures__/data.ts @@ -0,0 +1,99 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import * as v from 'valibot'; + +export const schema = v.object({ + username: v.pipe( + v.string(), + v.minLength(2), + v.maxLength(30), + v.regex(/^\w+$/), + ), + password: v.pipe( + v.string('New Password is required'), + v.regex(new RegExp('.*[A-Z].*'), 'One uppercase character'), + v.regex(new RegExp('.*[a-z].*'), 'One lowercase character'), + v.regex(new RegExp('.*\\d.*'), 'One number'), + v.regex( + new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), + 'One special character', + ), + v.minLength(8, 'Must be at least 8 characters in length'), + ), + repeatPassword: v.string('Repeat Password is required'), + accessToken: v.union( + [ + v.string('Access token should be a string'), + v.number('Access token should be a number'), + ], + 'access token is required', + ), + birthYear: v.pipe( + v.number('Please enter your birth year'), + v.minValue(1900), + v.maxValue(2013), + ), + email: v.pipe(v.string(), v.email('Invalid email address')), + tags: v.array(v.string('Tags should be strings')), + enabled: v.boolean(), + like: v.object({ + id: v.number('Like id is required'), + name: v.pipe( + v.string('Like name is required'), + v.minLength(4, 'Too short'), + ), + }), +}); + +export const schemaError = v.variant('type', [ + v.object({ type: v.literal('a') }), + v.object({ type: v.literal('b') }), +]); + +export const validSchemaErrorData = { type: 'a' } as v.InferOutput< + typeof schemaError +>; +export const invalidSchemaErrorData = { type: 'c' } as any as v.InferOutput< + typeof schemaError +>; + +export const validData = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + like: { + id: 1, + name: 'name', + }, +}; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: { id: 'z' }, + tags: [1, 2, 3], +} as any as v.InferOutput; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/valibot/src/__tests__/__snapshots__/valibot.ts.snap b/node_modules/@hookform/resolvers/valibot/src/__tests__/__snapshots__/valibot.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..2de4b784cecc27d9470508435778966158a8ea4e --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/__tests__/__snapshots__/valibot.ts.snap @@ -0,0 +1,418 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`valibotResolver > should return a single error from valibotResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "access token is required", + "ref": undefined, + "type": "union", + }, + "birthYear": { + "message": "Please enter your birth year", + "ref": undefined, + "type": "number", + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "email", + }, + "enabled": { + "message": "Invalid type: Expected boolean but received undefined", + "ref": undefined, + "type": "boolean", + }, + "like": { + "id": { + "message": "Like id is required", + "ref": undefined, + "type": "number", + }, + "name": { + "message": "Like name is required", + "ref": undefined, + "type": "string", + }, + }, + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "regex", + }, + "repeatPassword": { + "message": "Repeat Password is required", + "ref": undefined, + "type": "string", + }, + "tags": [ + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + }, + ], + "username": { + "message": "Invalid type: Expected string but received undefined", + "ref": { + "name": "username", + }, + "type": "string", + }, + }, + "values": {}, +} +`; + +exports[`valibotResolver > should return a single error from valibotResolver with \`mode: sync\` when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "access token is required", + "ref": undefined, + "type": "union", + }, + "birthYear": { + "message": "Please enter your birth year", + "ref": undefined, + "type": "number", + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "email", + }, + "enabled": { + "message": "Invalid type: Expected boolean but received undefined", + "ref": undefined, + "type": "boolean", + }, + "like": { + "id": { + "message": "Like id is required", + "ref": undefined, + "type": "number", + }, + "name": { + "message": "Like name is required", + "ref": undefined, + "type": "string", + }, + }, + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "regex", + }, + "repeatPassword": { + "message": "Repeat Password is required", + "ref": undefined, + "type": "string", + }, + "tags": [ + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + }, + ], + "username": { + "message": "Invalid type: Expected string but received undefined", + "ref": { + "name": "username", + }, + "type": "string", + }, + }, + "values": {}, +} +`; + +exports[`valibotResolver > should return all the errors from valibotResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "access token is required", + "ref": undefined, + "type": "union", + "types": { + "union": "access token is required", + }, + }, + "birthYear": { + "message": "Please enter your birth year", + "ref": undefined, + "type": "number", + "types": { + "number": "Please enter your birth year", + }, + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "email", + "types": { + "email": "Invalid email address", + }, + }, + "enabled": { + "message": "Invalid type: Expected boolean but received undefined", + "ref": undefined, + "type": "boolean", + "types": { + "boolean": "Invalid type: Expected boolean but received undefined", + }, + }, + "like": { + "id": { + "message": "Like id is required", + "ref": undefined, + "type": "number", + "types": { + "number": "Like id is required", + }, + }, + "name": { + "message": "Like name is required", + "ref": undefined, + "type": "string", + "types": { + "string": "Like name is required", + }, + }, + }, + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "regex", + "types": { + "min_length": "Must be at least 8 characters in length", + "regex": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + }, + }, + "repeatPassword": { + "message": "Repeat Password is required", + "ref": undefined, + "type": "string", + "types": { + "string": "Repeat Password is required", + }, + }, + "tags": [ + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + "types": { + "string": "Tags should be strings", + }, + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + "types": { + "string": "Tags should be strings", + }, + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + "types": { + "string": "Tags should be strings", + }, + }, + ], + "username": { + "message": "Invalid type: Expected string but received undefined", + "ref": { + "name": "username", + }, + "type": "string", + "types": { + "string": "Invalid type: Expected string but received undefined", + }, + }, + }, + "values": {}, +} +`; + +exports[`valibotResolver > should return all the errors from valibotResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "accessToken": { + "message": "access token is required", + "ref": undefined, + "type": "union", + "types": { + "union": "access token is required", + }, + }, + "birthYear": { + "message": "Please enter your birth year", + "ref": undefined, + "type": "number", + "types": { + "number": "Please enter your birth year", + }, + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "email", + "types": { + "email": "Invalid email address", + }, + }, + "enabled": { + "message": "Invalid type: Expected boolean but received undefined", + "ref": undefined, + "type": "boolean", + "types": { + "boolean": "Invalid type: Expected boolean but received undefined", + }, + }, + "like": { + "id": { + "message": "Like id is required", + "ref": undefined, + "type": "number", + "types": { + "number": "Like id is required", + }, + }, + "name": { + "message": "Like name is required", + "ref": undefined, + "type": "string", + "types": { + "string": "Like name is required", + }, + }, + }, + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "regex", + "types": { + "min_length": "Must be at least 8 characters in length", + "regex": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + }, + }, + "repeatPassword": { + "message": "Repeat Password is required", + "ref": undefined, + "type": "string", + "types": { + "string": "Repeat Password is required", + }, + }, + "tags": [ + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + "types": { + "string": "Tags should be strings", + }, + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + "types": { + "string": "Tags should be strings", + }, + }, + { + "message": "Tags should be strings", + "ref": undefined, + "type": "string", + "types": { + "string": "Tags should be strings", + }, + }, + ], + "username": { + "message": "Invalid type: Expected string but received undefined", + "ref": { + "name": "username", + }, + "type": "string", + "types": { + "string": "Invalid type: Expected string but received undefined", + }, + }, + }, + "values": {}, +} +`; + +exports[`valibotResolver > should return parsed values from valibotResolver with \`mode: sync\` when validation pass 1`] = ` +{ + "errors": {}, + "values": { + "accessToken": "accessToken", + "birthYear": 2000, + "email": "john@doe.com", + "enabled": true, + "like": { + "id": 1, + "name": "name", + }, + "password": "Password123_", + "repeatPassword": "Password123_", + "tags": [ + "tag1", + "tag2", + ], + "username": "Doe", + }, +} +`; diff --git a/node_modules/@hookform/resolvers/valibot/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/valibot/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..407decdf624219fd7d88541f834d38846f907724 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/__tests__/special-path-names.ts @@ -0,0 +1,21 @@ +import * as v from 'valibot'; +import { valibotResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe('valibotResolver special path names', () => { + it.each(['hasOwnProperty', 'toString'])( + 'reports a validation error for a field named "%s"', + async (name) => { + const schema = v.object({ [name]: v.pipe(v.string(), v.minLength(1)) }); + + const result = await valibotResolver(schema as any)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors[name]).toBeDefined(); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/valibot/src/__tests__/valibot.ts b/node_modules/@hookform/resolvers/valibot/src/__tests__/valibot.ts new file mode 100644 index 0000000000000000000000000000000000000000..3def1123b0ad4eb050b32e008b928af701bb66d6 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/__tests__/valibot.ts @@ -0,0 +1,244 @@ +import { renderHook } from '@testing-library/react'; +import { SubmitHandler } from 'react-hook-form'; +import { useForm } from 'react-hook-form'; +import { Resolver } from 'react-hook-form'; +import * as v from 'valibot'; +/* eslint-disable no-console, @typescript-eslint/ban-ts-comment */ +import { valibotResolver } from '..'; +import { + fields, + invalidData, + invalidSchemaErrorData, + schema, + schemaError, + validData, + validSchemaErrorData, +} from './__fixtures__/data'; + +const shouldUseNativeValidation = false; +describe('valibotResolver', () => { + it('should return parsed values from valibotResolver with `mode: sync` when validation pass', async () => { + vi.mock('valibot', async () => { + const a = await vi.importActual('valibot'); + return { + __esModule: true, + ...a, + }; + }); + const funcSpy = vi.spyOn(v, 'safeParseAsync'); + + const result = await valibotResolver(schema, undefined, { + mode: 'sync', + })(validData, undefined, { fields, shouldUseNativeValidation }); + + expect(funcSpy).toHaveBeenCalledTimes(1); + expect(result.errors).toEqual({}); + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from valibotResolver with `mode: sync` when validation fails', async () => { + vi.mock('valibot', async () => { + const a = await vi.importActual('valibot'); + return { + __esModule: true, + ...a, + }; + }); + const funcSpy = vi.spyOn(v, 'safeParseAsync'); + + const result = await valibotResolver(schema, undefined, { + mode: 'sync', + })(invalidData, undefined, { fields, shouldUseNativeValidation }); + + expect(funcSpy).toHaveBeenCalledTimes(1); + expect(result).toMatchSnapshot(); + }); + + it('should return values from valibotResolver when validation pass', async () => { + const result = await valibotResolver(schema)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return a single error from valibotResolver when validation fails', async () => { + const result = await valibotResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return values from valibotResolver when validation pass & raw=true', async () => { + const result = await valibotResolver(schema, undefined, { + raw: true, + })(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return all the errors from valibotResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await valibotResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from valibotResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => { + const result = await valibotResolver(schema, undefined, { mode: 'sync' })( + invalidData, + undefined, + { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }, + ); + + expect(result).toMatchSnapshot(); + }); + + it('should be able to validate variants without errors', async () => { + const result = await valibotResolver(schemaError, undefined, { + mode: 'sync', + })(validSchemaErrorData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toEqual({ + errors: {}, + values: { + type: 'a', + }, + }); + }); + + it('should be able to validate variants with errors', async () => { + const result = await valibotResolver(schemaError, undefined, { + mode: 'sync', + })(invalidSchemaErrorData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toEqual({ + errors: { + type: { + message: 'Invalid type: Expected ("a" | "b") but received "c"', + ref: undefined, + type: 'variant', + }, + }, + values: {}, + }); + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a valibot schema', () => { + const resolver = valibotResolver(v.object({ id: v.number() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a valibot schema using a transform', () => { + const resolver = valibotResolver( + v.object({ + id: v.pipe( + v.number(), + v.transform((val) => String(val)), + ), + }), + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a valibot schema for the handleSubmit function in useForm', () => { + const schema = v.object({ id: v.number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: valibotResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a valibot schema with a transform for the handleSubmit function in useForm', () => { + const schema = v.object({ + id: v.pipe( + v.number(), + v.transform((val) => String(val)), + ), + }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: valibotResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); + + it('keeps handleSubmit typed to the transformed output when useForm is given all three generics (#773)', () => { + const schema = v.object({ + name: v.string(), + number: v.pipe(v.string(), v.transform(Number)), + }); + + const { + result: { current: form }, + } = renderHook(() => + useForm< + v.InferInput, + unknown, + v.InferOutput + >({ + resolver: valibotResolver(schema), + }), + ); + + expectTypeOf(form.watch('number')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + name: string; + number: number; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/valibot/src/index.ts b/node_modules/@hookform/resolvers/valibot/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..097f317f8f5f37a2ee4e21cc7f977652c3e4bf3c --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/index.ts @@ -0,0 +1 @@ +export * from './valibot'; diff --git a/node_modules/@hookform/resolvers/valibot/src/valibot.ts b/node_modules/@hookform/resolvers/valibot/src/valibot.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a501667a1dcd8cf2b8263e47ab3357c05144e39 --- /dev/null +++ b/node_modules/@hookform/resolvers/valibot/src/valibot.ts @@ -0,0 +1,140 @@ +import { toNestErrors } from '@hookform/resolvers'; +import { + FieldError, + FieldValues, + Resolver, + appendErrors, +} from 'react-hook-form'; +import { getDotPath, safeParseAsync } from 'valibot'; +import { BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot'; + +export function valibotResolver( + schema: BaseSchema | BaseSchemaAsync, + schemaOptions?: Partial< + Omit>, 'abortPipeEarly' | 'skipPipe'> + >, + resolverOptions?: { + mode?: 'async' | 'sync'; + raw?: false; + }, +): Resolver; + +export function valibotResolver( + schema: BaseSchema | BaseSchemaAsync, + schemaOptions: + | Partial< + Omit>, 'abortPipeEarly' | 'skipPipe'> + > + | undefined, + resolverOptions: { + mode?: 'async' | 'sync'; + raw: true; + }, +): Resolver; + +/** + * Creates a resolver for react-hook-form using Valibot schema validation + * @param {BaseSchema | BaseSchemaAsync} schema - The Valibot schema to validate against + * @param {Partial>, 'abortPipeEarly' | 'skipPipe'>>} [schemaOptions] - Optional Valibot validation options + * @param {Object} resolverOptions - Additional resolver configuration + * @param {('sync' | 'async')} [resolverOptions.mode] - Validation mode + * @param {boolean} [resolverOptions.raw] - If true, returns raw values rather than validated results + * @returns {Resolver>} A resolver function compatible with react-hook-form + * @example + * const schema = valibot.object({ + * name: valibot.string().minLength(2), + * age: valibot.number().min(18) + * }); + * + * useForm({ + * resolver: valibotResolver(schema) + * }); + */ +export function valibotResolver( + schema: BaseSchema | BaseSchemaAsync, + schemaOptions?: Partial< + Omit>, 'abortPipeEarly' | 'skipPipe'> + >, + resolverOptions: { + /** + * @default async + */ + mode?: 'sync' | 'async'; + /** + * Return the raw input values rather than the parsed values. + * @default false + */ + raw?: boolean; + } = {}, +): Resolver { + return async (values: Input, _, options) => { + // Check if we should validate all field criteria + const validateAllFieldCriteria = + !options.shouldUseNativeValidation && options.criteriaMode === 'all'; + + // Parse values with Valibot schema + const result = await safeParseAsync( + schema, + values, + Object.assign({}, schemaOptions, { + abortPipeEarly: !validateAllFieldCriteria, + }), + ); + + // If there are issues, return them as errors + if (result.issues) { + // Create errors object. A null-prototype object avoids false-positive + // hits from inherited members (e.g. `toString`, `constructor`) when a + // field is named after one of them — a plain `{}` would make + // `!errors[path]` truthy-skip those paths and silently drop their + // errors. + const errors: Record = Object.create(null); + + // Iterate over issues to add them to errors object + for (; result.issues.length; ) { + const issue = result.issues[0]; + // Create dot path from issue + const path = getDotPath(issue); + + if (path) { + // Add first error of path to errors object + if (!errors[path]) { + errors[path] = { message: issue.message, type: issue.type }; + } + + // If configured, add all errors of path to errors object + if (validateAllFieldCriteria) { + const types = errors[path].types; + const messages = types && types[issue.type]; + errors[path] = appendErrors( + path, + validateAllFieldCriteria, + errors, + issue.type, + messages + ? ([] as string[]).concat( + messages as string | string[], + issue.message, + ) + : issue.message, + ) as FieldError; + } + } + + result.issues.shift(); + } + + // Return resolver result with errors + return { + values: {}, + errors: toNestErrors(errors, options), + } as const; + } + + // Otherwise, return resolver result with values + return { + values: resolverOptions.raw ? Object.assign({}, values) : result.output, + errors: {}, + }; + }; +} diff --git a/node_modules/@hookform/resolvers/vest/dist/index.d.ts b/node_modules/@hookform/resolvers/vest/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b98329cb6ad76ea2db3c34ea28fcfa5a7f52525 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/index.d.ts @@ -0,0 +1,2 @@ +export * from './vest'; +export * from './types'; diff --git a/node_modules/@hookform/resolvers/vest/dist/types.d.ts b/node_modules/@hookform/resolvers/vest/dist/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17f5244a367b1086b45c19b6ddcf04eb09c2c6dc --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/types.d.ts @@ -0,0 +1,8 @@ +import { FieldName, FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form'; +import type { Suite } from 'vest'; +export type ICreateResult = Suite[], context?: TContext) => void>; +export type Resolver = (schema: ICreateResult, schemaOptions?: never, factoryOptions?: { + mode?: 'async' | 'sync'; + rawValues?: boolean; +}) => (values: TValues, context: TContext | undefined, options: ResolverOptions) => Promise>; +export type VestErrors = Record; diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.d.ts b/node_modules/@hookform/resolvers/vest/dist/vest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..64efa3e4df6a239ae00b7d2edb539e6c19eb5a18 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.d.ts @@ -0,0 +1,20 @@ +import type { Resolver } from './types'; +/** + * Creates a resolver for react-hook-form using Vest validation + * @param {Function} schema - The Vest validation schema + * @param {Object} _ - Unused parameter + * @param {Object} resolverOptions - Additional resolver configuration + * @param {string} [resolverOptions.mode='async'] - Validation mode + * @returns {Resolver} A resolver function compatible with react-hook-form + * @example + * const schema = vest.create((data) => { + * if (!data.name) { + * return 'Name is required'; + * } + * }); + * + * useForm({ + * resolver: vestResolver(schema) + * }); + */ +export declare const vestResolver: Resolver; diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.js b/node_modules/@hookform/resolvers/vest/dist/vest.js new file mode 100644 index 0000000000000000000000000000000000000000..20ec4921c3fa0a47b4c24781b2e35cb03c0f28a0 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.js @@ -0,0 +1,2 @@ +var r=require("@hookform/resolvers"),e=function(r,e){var t=Object.create(null);for(var o in r)t[o]||(t[o]={message:r[o][0],type:""}),e&&(t[o].types=r[o].reduce(function(r,e,t){return(r[t]=e)&&r},{}));return t};exports.vestResolver=function(t,o,s){return void 0===s&&(s={}),function(o,n,a){try{var i=function(t){return t.hasErrors()?{values:{},errors:r.toNestErrors(e(t.getErrors(),!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&r.validateFieldsNatively({},a),{values:o,errors:{}})};return Promise.resolve("sync"===s.mode?i(t.run(o,a.names,n)):Promise.resolve(t.run(o,a.names,n)).then(i))}catch(r){return Promise.reject(r)}}}; +//# sourceMappingURL=vest.js.map diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.js.map b/node_modules/@hookform/resolvers/vest/dist/vest.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9308becd128c134416fa4912db5a3390a1981ff8 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vest.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","run","names","then","e","reject"],"mappings":"qCAIMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAA,IAIN,OAAOR,CACT,uBAqBE,SAACU,EAAQC,EAAGC,GAAoB,YAAL,IAAfA,IAAAA,EAAkB,CAAE,GAAA,SACzBC,EAAQC,EAASC,GAAO,IAAIC,IAAAA,EAAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAE,EACVb,OAAQmB,eACNtB,EACEoB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAER,GAEzD,CAAEF,OAAAA,EAAQb,OAAQ,IAAK,EApBG,OAAAwB,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQU,QAAAC,QACpCf,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQe,KAAAb,GAmBxD,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.mjs b/node_modules/@hookform/resolvers/vest/dist/vest.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c1b9bdf9bd88609859a79549314c5fcedf34a8a5 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.mjs @@ -0,0 +1,2 @@ +import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";var o=function(r,e){var o=Object.create(null);for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},t=function(t,n,s){return void 0===s&&(s={}),function(n,a,i){try{var u=function(t){return t.hasErrors()?{values:{},errors:r(o(t.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e({},i),{values:n,errors:{}})};return Promise.resolve("sync"===s.mode?u(t.run(n,i.names,a)):Promise.resolve(t.run(n,i.names,a)).then(u))}catch(r){return Promise.reject(r)}}};export{t as vestResolver}; +//# sourceMappingURL=vest.module.js.map diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.modern.mjs b/node_modules/@hookform/resolvers/vest/dist/vest.modern.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bdd32d8d3651d975bea7dcb61368cea2aa68b3ea --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.modern.mjs @@ -0,0 +1,2 @@ +import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";const s=(r,e)=>{const s=Object.create(null);for(const o in r)s[o]||(s[o]={message:r[o][0],type:""}),e&&(s[o].types=r[o].reduce((r,e,s)=>(r[s]=e)&&r,{}));return s},o=(o,t,a={})=>async(t,n,i)=>{const l="sync"===a.mode?o.run(t,i.names,n):await o.run(t,i.names,n);return l.hasErrors()?{values:{},errors:r(s(l.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e({},i),{values:t,errors:{}})};export{o as vestResolver}; +//# sourceMappingURL=vest.modern.mjs.map diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.modern.mjs.map b/node_modules/@hookform/resolvers/vest/dist/vest.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..5f02e8e4af3994c095277a34946b6ba8c674c93d --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"vest.modern.mjs","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","async","values","context","options","result","mode","run","names","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively"],"mappings":"+EAIA,MAAMA,EAAmBA,CACvBC,EACAC,KAGA,MAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,MAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,CAACC,EAAKJ,EAASK,KAAWD,EAAIC,GAASL,IAAYI,EACnD,CAAE,IAIR,OAAOR,CAAM,EAqBFU,EACXA,CAACC,EAAQC,EAAGC,EAAkB,CAAA,IAC9BC,MAAOC,EAAQC,EAASC,KACtB,MAAMC,EACqB,SAAzBL,EAAgBM,KACZR,EAAOS,IAAIL,EAAQE,EAAQI,MAAOL,SAC5BL,EAAOS,IAAIL,EAAQE,EAAQI,MAAOL,GAE9C,OAAIE,EAAOI,YACF,CACLP,OAAQ,CAAE,EACVf,OAAQuB,EACN1B,EACEqB,EAAOM,aACNP,EAAQQ,2BACkB,QAAzBR,EAAQS,cAEZT,KAKNA,EAAQQ,2BAA6BE,EAAuB,CAAA,EAAIV,GAEzD,CAAEF,SAAQf,OAAQ,IAAI"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.module.js b/node_modules/@hookform/resolvers/vest/dist/vest.module.js new file mode 100644 index 0000000000000000000000000000000000000000..c1b9bdf9bd88609859a79549314c5fcedf34a8a5 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.module.js @@ -0,0 +1,2 @@ +import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";var o=function(r,e){var o=Object.create(null);for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},t=function(t,n,s){return void 0===s&&(s={}),function(n,a,i){try{var u=function(t){return t.hasErrors()?{values:{},errors:r(o(t.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e({},i),{values:n,errors:{}})};return Promise.resolve("sync"===s.mode?u(t.run(n,i.names,a)):Promise.resolve(t.run(n,i.names,a)).then(u))}catch(r){return Promise.reject(r)}}};export{t as vestResolver}; +//# sourceMappingURL=vest.module.js.map diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.module.js.map b/node_modules/@hookform/resolvers/vest/dist/vest.module.js.map new file mode 100644 index 0000000000000000000000000000000000000000..dc7f7dc993153df422103f0ac4d080a5fecd2444 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vest.module.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","run","names","then","e","reject"],"mappings":"+EAIA,IAAMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAA,IAIN,OAAOR,CACT,EAoBaU,EACX,SAACC,EAAQC,EAAGC,GAAoB,YAAL,IAAfA,IAAAA,EAAkB,CAAE,GAAA,SACzBC,EAAQC,EAASC,GAAO,IAAIC,IAAAA,EAAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAE,EACVd,OAAQoB,EACNvB,EACEqB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAuB,CAAE,EAAER,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAAK,EApBG,OAAAyB,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQU,QAAAC,QACpCf,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQe,KAAAb,GAmBxD,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.umd.js b/node_modules/@hookform/resolvers/vest/dist/vest.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..960665aef692ac4f887d6b8e28e05b2ff05d62d0 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.umd.js @@ -0,0 +1,2 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers"],r):r((e||self).hookformResolversVest={},e.hookformResolvers)}(this,function(e,r){var o=function(e,r){var o=Object.create(null);for(var s in e)o[s]||(o[s]={message:e[s][0],type:""}),r&&(o[s].types=e[s].reduce(function(e,r,o){return(e[o]=r)&&e},{}));return o};e.vestResolver=function(e,s,t){return void 0===t&&(t={}),function(s,n,i){try{var a=function(e){return e.hasErrors()?{values:{},errors:r.toNestErrors(o(e.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&r.validateFieldsNatively({},i),{values:s,errors:{}})};return Promise.resolve("sync"===t.mode?a(e.run(s,i.names,n)):Promise.resolve(e.run(s,i.names,n)).then(a))}catch(e){return Promise.reject(e)}}}}); +//# sourceMappingURL=vest.umd.js.map diff --git a/node_modules/@hookform/resolvers/vest/dist/vest.umd.js.map b/node_modules/@hookform/resolvers/vest/dist/vest.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b0fb85012b8c60286f9805409d8ccaa211b66cff --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/dist/vest.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vest.umd.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","run","names","then","e","reject"],"mappings":"0TAIA,IAAMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAA,IAIN,OAAOR,CACT,iBAqBE,SAACU,EAAQC,EAAGC,GAAoB,YAAL,IAAfA,IAAAA,EAAkB,CAAE,GAAA,SACzBC,EAAQC,EAASC,GAAO,IAAIC,IAAAA,EAAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAE,EACVb,OAAQmB,eACNtB,EACEoB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAER,GAEzD,CAAEF,OAAAA,EAAQb,OAAQ,IAAK,EApBG,OAAAwB,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQU,QAAAC,QACpCf,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQe,KAAAb,GAmBxD,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vest/package.json b/node_modules/@hookform/resolvers/vest/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ec0593d2d6e945ae7e710b737e1bfe1cb50173d2 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/package.json @@ -0,0 +1,18 @@ +{ + "name": "@hookform/resolvers/vest", + "amdName": "hookformResolversVest", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: vest", + "main": "dist/vest.js", + "module": "dist/vest.module.js", + "umd:main": "dist/vest.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.55.0", + "@hookform/resolvers": "^2.0.0", + "vest": ">=3.0.0" + } +} diff --git a/node_modules/@hookform/resolvers/vest/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/vest/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..c38c7bb95b71d27d0ed083669ed5eeaf99ff59f4 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,89 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import * as vest from 'vest'; +import { vestResolver } from '..'; + +const USERNAME_REQUIRED_MESSAGE = 'username field is required'; +const PASSWORD_SYMBOL_MESSAGE = 'password must contain a symbol'; + +interface FormData { + username: string; + password: string; +} + +const validationSuite = vest.create((data: FormData) => { + vest.test('username', USERNAME_REQUIRED_MESSAGE, () => { + vest.enforce(data.username).isNotEmpty(); + }); + + vest.test('password', PASSWORD_SYMBOL_MESSAGE, () => { + vest.enforce(data.password).isNotEmpty(); + }); +}); + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: vestResolver(validationSuite), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Vest", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe(PASSWORD_SYMBOL_MESSAGE); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/vest/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/vest/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..8d4b93b1a2b7823d9f3b5ea1e6fe4ceccb7383bc --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/__tests__/Form.tsx @@ -0,0 +1,60 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import * as vest from 'vest'; +import { vestResolver } from '..'; + +interface FormData { + username: string; + password: string; +} + +const validationSuite = vest.create((data: FormData) => { + vest.test('username', 'Username is required', () => { + vest.enforce(data.username).isNotEmpty(); + }); + + vest.test('password', 'Password must contain a symbol', () => { + vest.enforce(data.password).matches(/[^A-Za-z0-9]/); + }); +}); + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { + register, + formState: { errors }, + handleSubmit, + } = useForm({ + resolver: vestResolver(validationSuite), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Vest and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect(screen.getByText(/Username is required/i)).toBeVisible(); + expect(screen.getByText(/Password must contain a symbol/i)).toBeVisible(); + expect(handleSubmit).not.toHaveBeenCalled(); +}); diff --git a/node_modules/@hookform/resolvers/vest/src/__tests__/__fixtures__/data.ts b/node_modules/@hookform/resolvers/vest/src/__tests__/__fixtures__/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..99208eda26a54e9ef84b400010256f803dc0096e --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/__tests__/__fixtures__/data.ts @@ -0,0 +1,67 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import * as vest from 'vest'; + +export const validationSuite = vest.create((data: any = {}) => { + vest.test('username', 'Username is required', () => { + vest.enforce(data.username).isNotEmpty(); + }); + + vest.test('username', 'Must be longer than 3 chars', () => { + vest.enforce(data.username).longerThan(3); + }); + + vest.test('deepObject.data', 'deepObject.data is required', () => { + vest.enforce(data.deepObject.data).isNotEmpty(); + }); + + vest.test('password', 'Password is required', () => { + vest.enforce(data.password).isNotEmpty(); + }); + + vest.test('password', 'Password must be at least 5 chars', () => { + vest.enforce(data.password).longerThanOrEquals(5); + }); + + vest.test('password', 'Password must contain a digit', () => { + vest.enforce(data.password).matches(/[0-9]/); + }); + + vest.test('password', 'Password must contain a symbol', () => { + vest.enforce(data.password).matches(/[^A-Za-z0-9]/); + }); +}); + +export const validData = { + username: 'asdda', + password: 'asddfg123!', + deepObject: { + data: 'test', + }, +}; + +export const invalidData = { + username: '', + password: 'a', + deepObject: { + data: '', + }, +}; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/vest/src/__tests__/__snapshots__/vest.ts.snap b/node_modules/@hookform/resolvers/vest/src/__tests__/__snapshots__/vest.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..110992ffb7896a30d25cd2e21f7000428f9cbc56 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/__tests__/__snapshots__/vest.ts.snap @@ -0,0 +1,135 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`vestResolver > should return all the error messages from vestResolver when validation fails and validateAllFieldCriteria set to true 1`] = ` +{ + "errors": { + "deepObject": { + "data": { + "message": "deepObject.data is required", + "ref": undefined, + "type": "", + "types": { + "0": "deepObject.data is required", + }, + }, + }, + "password": { + "message": "Password must be at least 5 chars", + "ref": { + "name": "password", + }, + "type": "", + "types": { + "0": "Password must be at least 5 chars", + }, + }, + "username": { + "message": "Username is required", + "ref": { + "name": "username", + }, + "type": "", + "types": { + "0": "Username is required", + }, + }, + }, + "values": {}, +} +`; + +exports[`vestResolver > should return all the error messages from vestResolver when validation fails and validateAllFieldCriteria set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "deepObject": { + "data": { + "message": "deepObject.data is required", + "ref": undefined, + "type": "", + "types": { + "0": "deepObject.data is required", + }, + }, + }, + "password": { + "message": "Password must be at least 5 chars", + "ref": { + "name": "password", + }, + "type": "", + "types": { + "0": "Password must be at least 5 chars", + }, + }, + "username": { + "message": "Username is required", + "ref": { + "name": "username", + }, + "type": "", + "types": { + "0": "Username is required", + }, + }, + }, + "values": {}, +} +`; + +exports[`vestResolver > should return single error message from vestResolver when validation fails and validateAllFieldCriteria set to false 1`] = ` +{ + "errors": { + "deepObject": { + "data": { + "message": "deepObject.data is required", + "ref": undefined, + "type": "", + }, + }, + "password": { + "message": "Password must be at least 5 chars", + "ref": { + "name": "password", + }, + "type": "", + }, + "username": { + "message": "Username is required", + "ref": { + "name": "username", + }, + "type": "", + }, + }, + "values": {}, +} +`; + +exports[`vestResolver > should return single error message from vestResolver when validation fails and validateAllFieldCriteria set to false and \`mode: sync\` 1`] = ` +{ + "errors": { + "deepObject": { + "data": { + "message": "deepObject.data is required", + "ref": undefined, + "type": "", + }, + }, + "password": { + "message": "Password must be at least 5 chars", + "ref": { + "name": "password", + }, + "type": "", + }, + "username": { + "message": "Username is required", + "ref": { + "name": "username", + }, + "type": "", + }, + }, + "values": {}, +} +`; diff --git a/node_modules/@hookform/resolvers/vest/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/vest/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a86dc8f57bf3296538baa2eb68cd49e2a5868ff --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/__tests__/special-path-names.ts @@ -0,0 +1,32 @@ +import { vestResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe('vestResolver special path names', () => { + it.each(['hasOwnProperty', 'toString'])( + 'reports a validation error for a field named "%s"', + async (name) => { + // The `vest` package itself throws when a field is named after an + // Object.prototype member (`agg.failures.errors[fieldName].push is + // not a function`) — a separate, pre-existing bug in that package, + // unreachable through this resolver's public API regardless of this + // fix. A fake schema function isolates the resolver's own + // path-tracking logic instead. + const schema = { + run: () => ({ + hasErrors: () => true, + getErrors: () => ({ [name]: [`${name} is required`] }), + }), + }; + + const result = await vestResolver(schema as any, undefined, { + mode: 'sync', + })({ [name]: '' } as any, undefined, { + fields: {}, + shouldUseNativeValidation, + } as any); + + expect(result.errors[name]).toBeDefined(); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/vest/src/__tests__/vest.ts b/node_modules/@hookform/resolvers/vest/src/__tests__/vest.ts new file mode 100644 index 0000000000000000000000000000000000000000..45c71abdcad5a5d3f77f241f8c38e1f4c8b2b599 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/__tests__/vest.ts @@ -0,0 +1,90 @@ +import { vestResolver } from '..'; +import { + fields, + invalidData, + validData, + validationSuite, +} from './__fixtures__/data'; + +const shouldUseNativeValidation = false; + +describe('vestResolver', () => { + it('should return values from vestResolver when validation pass', async () => { + expect( + await vestResolver(validationSuite)(validData, undefined, { + fields, + shouldUseNativeValidation, + }), + ).toEqual({ + values: validData, + errors: {}, + }); + }); + + it('should return values from vestResolver with `mode: sync` when validation pass', async () => { + expect( + await vestResolver(validationSuite, undefined, { + mode: 'sync', + })(validData, undefined, { fields, shouldUseNativeValidation }), + ).toEqual({ + values: validData, + errors: {}, + }); + }); + + it('should return single error message from vestResolver when validation fails and validateAllFieldCriteria set to false', async () => { + expect( + await vestResolver(validationSuite)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }), + ).toMatchSnapshot(); + }); + + it('should return single error message from vestResolver when validation fails and validateAllFieldCriteria set to false and `mode: sync`', async () => { + expect( + await vestResolver(validationSuite, undefined, { + mode: 'sync', + })(invalidData, undefined, { fields, shouldUseNativeValidation }), + ).toMatchSnapshot(); + }); + + it('should return all the error messages from vestResolver when validation fails and validateAllFieldCriteria set to true', async () => { + expect( + await vestResolver(validationSuite)( + invalidData, + {}, + { fields, criteriaMode: 'all', shouldUseNativeValidation }, + ), + ).toMatchSnapshot(); + }); + + it('should return all the error messages from vestResolver when validation fails and validateAllFieldCriteria set to true and `mode: sync`', async () => { + expect( + await vestResolver(validationSuite, undefined, { mode: 'sync' })( + invalidData, + {}, + { fields, criteriaMode: 'all', shouldUseNativeValidation }, + ), + ).toMatchSnapshot(); + }); + + it('should call a suite with values, validated field names and a context as arguments', async () => { + const run = vi.spyOn(validationSuite, 'run'); + + await vestResolver(validationSuite)( + validData, + { some: 'context' }, + { + fields: { username: fields.username }, + names: ['username'], + shouldUseNativeValidation, + }, + ); + + expect(run).toHaveBeenCalledTimes(1); + expect(run).toHaveBeenCalledWith(validData, ['username'], { + some: 'context', + }); + }); +}); diff --git a/node_modules/@hookform/resolvers/vest/src/index.ts b/node_modules/@hookform/resolvers/vest/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b98329cb6ad76ea2db3c34ea28fcfa5a7f52525 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/index.ts @@ -0,0 +1,2 @@ +export * from './vest'; +export * from './types'; diff --git a/node_modules/@hookform/resolvers/vest/src/types.ts b/node_modules/@hookform/resolvers/vest/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..f426a98f891792cce694c963f0408cf5d59a2f4c --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/types.ts @@ -0,0 +1,28 @@ +import { + FieldName, + FieldValues, + ResolverOptions, + ResolverResult, +} from 'react-hook-form'; +import type { Suite } from 'vest'; + +export type ICreateResult< + TValues extends FieldValues = FieldValues, + TContext = any, +> = Suite< + any, + any, + (values: TValues, names?: FieldName[], context?: TContext) => void +>; + +export type Resolver = ( + schema: ICreateResult, + schemaOptions?: never, + factoryOptions?: { mode?: 'async' | 'sync'; rawValues?: boolean }, +) => ( + values: TValues, + context: TContext | undefined, + options: ResolverOptions, +) => Promise>; + +export type VestErrors = Record; diff --git a/node_modules/@hookform/resolvers/vest/src/vest.ts b/node_modules/@hookform/resolvers/vest/src/vest.ts new file mode 100644 index 0000000000000000000000000000000000000000..f829dd2acf95d6bcdbb1206a3d721cb395595738 --- /dev/null +++ b/node_modules/@hookform/resolvers/vest/src/vest.ts @@ -0,0 +1,69 @@ +import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; +import { FieldError } from 'react-hook-form'; +import type { Resolver, VestErrors } from './types'; + +const parseErrorSchema = ( + vestError: VestErrors, + validateAllFieldCriteria: boolean, +) => { + // See the matching comment in the zod resolver's `parseZod3Issues`. + const errors: Record = Object.create(null); + for (const path in vestError) { + if (!errors[path]) { + errors[path] = { message: vestError[path][0], type: '' }; + } + + if (validateAllFieldCriteria) { + errors[path].types = vestError[path].reduce>( + (acc, message, index) => (acc[index] = message) && acc, + {}, + ); + } + } + return errors; +}; + +/** + * Creates a resolver for react-hook-form using Vest validation + * @param {Function} schema - The Vest validation schema + * @param {Object} _ - Unused parameter + * @param {Object} resolverOptions - Additional resolver configuration + * @param {string} [resolverOptions.mode='async'] - Validation mode + * @returns {Resolver} A resolver function compatible with react-hook-form + * @example + * const schema = vest.create((data) => { + * if (!data.name) { + * return 'Name is required'; + * } + * }); + * + * useForm({ + * resolver: vestResolver(schema) + * }); + */ +export const vestResolver: Resolver = + (schema, _, resolverOptions = {}) => + async (values, context, options) => { + const result = + resolverOptions.mode === 'sync' + ? schema.run(values, options.names, context) + : await schema.run(values, options.names, context); + + if (result.hasErrors()) { + return { + values: {}, + errors: toNestErrors( + parseErrorSchema( + result.getErrors(), + !options.shouldUseNativeValidation && + options.criteriaMode === 'all', + ), + options, + ), + }; + } + + options.shouldUseNativeValidation && validateFieldsNatively({}, options); + + return { values, errors: {} }; + }; diff --git a/node_modules/@hookform/resolvers/vine/dist/index.d.ts b/node_modules/@hookform/resolvers/vine/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ddc3de183aa82d0d27ba106f79341fb95ab3fa5d --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/index.d.ts @@ -0,0 +1 @@ +export * from './vine'; diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.d.ts b/node_modules/@hookform/resolvers/vine/dist/vine.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..790016761da3391e1df4a76428e815d5e7ec3578 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.d.ts @@ -0,0 +1,11 @@ +import { VineValidator } from '@vinejs/vine'; +import { ConstructableSchema, ValidationOptions } from '@vinejs/vine/build/src/types'; +import { FieldValues, Resolver } from 'react-hook-form'; +export declare function vineResolver(schema: VineValidator, any>, schemaOptions?: ValidationOptions, resolverOptions?: { + mode?: 'async' | 'sync'; + raw?: false; +}): Resolver; +export declare function vineResolver(schema: VineValidator, any>, schemaOptions: ValidationOptions | undefined, resolverOptions: { + mode?: 'async' | 'sync'; + raw: true; +}): Resolver; diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.js b/node_modules/@hookform/resolvers/vine/dist/vine.js new file mode 100644 index 0000000000000000000000000000000000000000..037473a84482ad749ba68bb9fdae20d8f3b191d9 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.js @@ -0,0 +1,2 @@ +var e=require("@hookform/resolvers"),r=require("@vinejs/vine"),t=require("react-hook-form");function s(e,r){for(var s=Object.create(null);e.length;){var o=e[0],i=o.field;if(i in s||(s[i]={message:o.message,type:o.rule}),r){var n=s[i].types,a=n&&n[o.rule];s[i]=t.appendErrors(i,r,s,o.rule,a?[].concat(a,[o.message]):o.message)}e.shift()}return s}exports.vineResolver=function(t,o,i){return void 0===i&&(i={}),function(n,a,u){try{return Promise.resolve(function(r,s){try{var a=Promise.resolve(t.validate(n,o)).then(function(r){return u.shouldUseNativeValidation&&e.validateFieldsNatively({},u),{errors:{},values:i.raw?Object.assign({},n):r}})}catch(e){return s(e)}return a&&a.then?a.then(void 0,s):a}(0,function(t){if(t instanceof r.errors.E_VALIDATION_ERROR)return{values:{},errors:e.toNestErrors(s(t.messages,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw t}))}catch(e){return Promise.reject(e)}}}; +//# sourceMappingURL=vine.js.map diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.js.map b/node_modules/@hookform/resolvers/vine/dist/vine.js.map new file mode 100644 index 0000000000000000000000000000000000000000..eed83aa10fd5f8ae863f1023bd746ec6bc85ad54 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vine.js","sources":["../src/vine.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { SimpleErrorReporter, VineValidator, errors } from '@vinejs/vine';\nimport {\n ConstructableSchema,\n ValidationOptions,\n} from '@vinejs/vine/build/src/types';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nfunction parseErrorSchema(\n vineErrors: SimpleErrorReporter['errors'],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `path in schemaErrors` true for\n // those paths and silently drop their errors.\n const schemaErrors: Record = Object.create(null);\n\n for (; vineErrors.length; ) {\n const error = vineErrors[0];\n const path = error.field;\n\n if (!(path in schemaErrors)) {\n schemaErrors[path] = { message: error.message, type: error.rule };\n }\n\n if (validateAllFieldCriteria) {\n const { types } = schemaErrors[path];\n const messages = types && types[error.rule];\n\n schemaErrors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n schemaErrors,\n error.rule,\n messages ? [...(messages as string[]), error.message] : error.message,\n ) as FieldError;\n }\n\n vineErrors.shift();\n }\n\n return schemaErrors;\n}\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions: ValidationOptions | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using VineJS schema validation\n * @param {T} schema - The VineJS schema to validate against\n * @param {ValidationOptions} [schemaOptions] - Optional VineJS validation options\n * @param {Object} [resolverOptions] - Optional resolver configuration\n * @param {boolean} [resolverOptions.raw=false] - If true, returns raw values instead of validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = vine.create({\n * name: vine.string().minLength(2),\n * age: vine.number().min(18)\n * });\n *\n * useForm({\n * resolver: vineResolver(schema)\n * });\n */\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions: { raw?: boolean } = {},\n): Resolver {\n return async (values, _, options) => {\n try {\n const data = await schema.validate(values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n };\n } catch (error: any) {\n if (error instanceof errors.E_VALIDATION_ERROR) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.messages,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["parseErrorSchema","vineErrors","validateAllFieldCriteria","schemaErrors","Object","create","length","error","path","field","message","type","rule","types","messages","appendErrors","concat","shift","schema","schemaOptions","resolverOptions","values","_","options","Promise","resolve","validate","then","data","shouldUseNativeValidation","validateFieldsNatively","errors","raw","assign","_catch","E_VALIDATION_ERROR","toNestErrors","criteriaMode","e","reject"],"mappings":"4FAaA,SAASA,EACPC,EACAC,GAQA,IAFA,IAAMC,EAA2CC,OAAOC,OAAO,MAExDJ,EAAWK,QAAU,CAC1B,IAAMC,EAAQN,EAAW,GACnBO,EAAOD,EAAME,MAMnB,GAJMD,KAAQL,IACZA,EAAaK,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMK,OAGzDV,EAA0B,CAC5B,IAAQW,EAAUV,EAAaK,GAAvBK,MACFC,EAAWD,GAASA,EAAMN,EAAMK,MAEtCT,EAAaK,GAAQO,EAAAA,aACnBP,EACAN,EACAC,EACAI,EAAMK,KACNE,KAAQE,OAAQF,EAAuBP,CAAAA,EAAMG,UAAWH,EAAMG,QAElE,CAEAT,EAAWgB,OACb,CAEA,OAAOd,CACT,sBAqCM,SACJe,EACAC,EACAC,GAEA,gBAFAA,IAAAA,EAAqC,CAAA,YAEvBC,EAAQC,EAAGC,OAAWC,OAAAA,QAAAC,gCAC9BD,QAAAC,QACiBP,EAAOQ,SAASL,EAAQF,IAAcQ,KAAA,SAAnDC,GAIN,OAFAL,EAAQM,2BAA6BC,EAAsBA,uBAAC,GAAIP,GAEzD,CACLQ,OAAQ,CAAE,EACVV,OAAQD,EAAgBY,IAAM5B,OAAO6B,OAAO,CAAA,EAAIZ,GAAUO,EAC1D,4DAT8BM,CAC9B,EASK3B,SAAAA,GACP,GAAIA,aAAiBwB,EAAMA,OAACI,mBAC1B,MAAO,CACLd,OAAQ,CAAE,EACVU,OAAQK,EAAAA,aACNpC,EACEO,EAAMO,UACLS,EAAQM,2BACkB,QAAzBN,EAAQc,cAEZd,IAKN,MAAMhB,CACR,GACF,CAAC,MAAA+B,GAAAd,OAAAA,QAAAe,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.mjs b/node_modules/@hookform/resolvers/vine/dist/vine.mjs new file mode 100644 index 0000000000000000000000000000000000000000..885e885314b70ad8b3a401316d401ea0d6bac4bd --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.mjs @@ -0,0 +1,2 @@ +import{validateFieldsNatively as e,toNestErrors as r}from"@hookform/resolvers";import{errors as t}from"@vinejs/vine";import{appendErrors as o}from"react-hook-form";function n(e,r){for(var t=Object.create(null);e.length;){var n=e[0],i=n.field;if(i in t||(t[i]={message:n.message,type:n.rule}),r){var s=t[i].types,a=s&&s[n.rule];t[i]=o(i,r,t,n.rule,a?[].concat(a,[n.message]):n.message)}e.shift()}return t}function i(o,i,s){return void 0===s&&(s={}),function(a,u,c){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(o.validate(a,i)).then(function(r){return c.shouldUseNativeValidation&&e({},c),{errors:{},values:s.raw?Object.assign({},a):r}})}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(0,function(e){if(e instanceof t.E_VALIDATION_ERROR)return{values:{},errors:r(n(e.messages,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw e}))}catch(e){return Promise.reject(e)}}}export{i as vineResolver}; +//# sourceMappingURL=vine.module.js.map diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.modern.mjs b/node_modules/@hookform/resolvers/vine/dist/vine.modern.mjs new file mode 100644 index 0000000000000000000000000000000000000000..eed75cca9f21bcb8fa892abc1b39bbf26befe8e2 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.modern.mjs @@ -0,0 +1,2 @@ +import{validateFieldsNatively as e,toNestErrors as r}from"@hookform/resolvers";import{errors as t}from"@vinejs/vine";import{appendErrors as s}from"react-hook-form";function o(e,r){const t=Object.create(null);for(;e.length;){const o=e[0],a=o.field;if(a in t||(t[a]={message:o.message,type:o.rule}),r){const{types:e}=t[a],i=e&&e[o.rule];t[a]=s(a,r,t,o.rule,i?[...i,o.message]:o.message)}e.shift()}return t}function a(s,a,i={}){return async(n,l,c)=>{try{const r=await s.validate(n,a);return c.shouldUseNativeValidation&&e({},c),{errors:{},values:i.raw?Object.assign({},n):r}}catch(e){if(e instanceof t.E_VALIDATION_ERROR)return{values:{},errors:r(o(e.messages,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw e}}}export{a as vineResolver}; +//# sourceMappingURL=vine.modern.mjs.map diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.modern.mjs.map b/node_modules/@hookform/resolvers/vine/dist/vine.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..44e643fec01a46fb62e3b6eac4364db8f950650e --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"vine.modern.mjs","sources":["../src/vine.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { SimpleErrorReporter, VineValidator, errors } from '@vinejs/vine';\nimport {\n ConstructableSchema,\n ValidationOptions,\n} from '@vinejs/vine/build/src/types';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nfunction parseErrorSchema(\n vineErrors: SimpleErrorReporter['errors'],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `path in schemaErrors` true for\n // those paths and silently drop their errors.\n const schemaErrors: Record = Object.create(null);\n\n for (; vineErrors.length; ) {\n const error = vineErrors[0];\n const path = error.field;\n\n if (!(path in schemaErrors)) {\n schemaErrors[path] = { message: error.message, type: error.rule };\n }\n\n if (validateAllFieldCriteria) {\n const { types } = schemaErrors[path];\n const messages = types && types[error.rule];\n\n schemaErrors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n schemaErrors,\n error.rule,\n messages ? [...(messages as string[]), error.message] : error.message,\n ) as FieldError;\n }\n\n vineErrors.shift();\n }\n\n return schemaErrors;\n}\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions: ValidationOptions | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using VineJS schema validation\n * @param {T} schema - The VineJS schema to validate against\n * @param {ValidationOptions} [schemaOptions] - Optional VineJS validation options\n * @param {Object} [resolverOptions] - Optional resolver configuration\n * @param {boolean} [resolverOptions.raw=false] - If true, returns raw values instead of validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = vine.create({\n * name: vine.string().minLength(2),\n * age: vine.number().min(18)\n * });\n *\n * useForm({\n * resolver: vineResolver(schema)\n * });\n */\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions: { raw?: boolean } = {},\n): Resolver {\n return async (values, _, options) => {\n try {\n const data = await schema.validate(values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n };\n } catch (error: any) {\n if (error instanceof errors.E_VALIDATION_ERROR) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.messages,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["parseErrorSchema","vineErrors","validateAllFieldCriteria","schemaErrors","Object","create","length","error","path","field","message","type","rule","types","messages","appendErrors","shift","vineResolver","schema","schemaOptions","resolverOptions","values","_","options","data","validate","shouldUseNativeValidation","validateFieldsNatively","errors","raw","assign","E_VALIDATION_ERROR","toNestErrors","criteriaMode"],"mappings":"oKAaA,SAASA,EACPC,EACAC,GAMA,MAAMC,EAA2CC,OAAOC,OAAO,MAE/D,KAAOJ,EAAWK,QAAU,CAC1B,MAAMC,EAAQN,EAAW,GACnBO,EAAOD,EAAME,MAMnB,GAJMD,KAAQL,IACZA,EAAaK,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMK,OAGzDV,EAA0B,CAC5B,MAAMW,MAAEA,GAAUV,EAAaK,GACzBM,EAAWD,GAASA,EAAMN,EAAMK,MAEtCT,EAAaK,GAAQO,EACnBP,EACAN,EACAC,EACAI,EAAMK,KACNE,EAAW,IAAKA,EAAuBP,EAAMG,SAAWH,EAAMG,QAElE,CAEAT,EAAWe,OACb,CAEA,OAAOb,CACT,UAqCgBc,EACdC,EACAC,EACAC,EAAqC,CAAE,GAEvC,OAAcC,MAAAA,EAAQC,EAAGC,KACvB,IACE,MAAMC,QAAaN,EAAOO,SAASJ,EAAQF,GAI3C,OAFAI,EAAQG,2BAA6BC,EAAuB,CAAA,EAAIJ,GAEzD,CACLK,OAAQ,CAAE,EACVP,OAAQD,EAAgBS,IAAMzB,OAAO0B,OAAO,CAAA,EAAIT,GAAUG,EAE9D,CAAE,MAAOjB,GACP,GAAIA,aAAiBqB,EAAOG,mBAC1B,MAAO,CACLV,OAAQ,GACRO,OAAQI,EACNhC,EACEO,EAAMO,UACLS,EAAQG,2BACkB,QAAzBH,EAAQU,cAEZV,IAKN,MAAMhB,CACR,EAEJ"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.module.js b/node_modules/@hookform/resolvers/vine/dist/vine.module.js new file mode 100644 index 0000000000000000000000000000000000000000..885e885314b70ad8b3a401316d401ea0d6bac4bd --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.module.js @@ -0,0 +1,2 @@ +import{validateFieldsNatively as e,toNestErrors as r}from"@hookform/resolvers";import{errors as t}from"@vinejs/vine";import{appendErrors as o}from"react-hook-form";function n(e,r){for(var t=Object.create(null);e.length;){var n=e[0],i=n.field;if(i in t||(t[i]={message:n.message,type:n.rule}),r){var s=t[i].types,a=s&&s[n.rule];t[i]=o(i,r,t,n.rule,a?[].concat(a,[n.message]):n.message)}e.shift()}return t}function i(o,i,s){return void 0===s&&(s={}),function(a,u,c){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(o.validate(a,i)).then(function(r){return c.shouldUseNativeValidation&&e({},c),{errors:{},values:s.raw?Object.assign({},a):r}})}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(0,function(e){if(e instanceof t.E_VALIDATION_ERROR)return{values:{},errors:r(n(e.messages,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw e}))}catch(e){return Promise.reject(e)}}}export{i as vineResolver}; +//# sourceMappingURL=vine.module.js.map diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.module.js.map b/node_modules/@hookform/resolvers/vine/dist/vine.module.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8c04df61949424fe9a5f4fc99d9d2b9ecf0d7077 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vine.module.js","sources":["../src/vine.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { SimpleErrorReporter, VineValidator, errors } from '@vinejs/vine';\nimport {\n ConstructableSchema,\n ValidationOptions,\n} from '@vinejs/vine/build/src/types';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nfunction parseErrorSchema(\n vineErrors: SimpleErrorReporter['errors'],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `path in schemaErrors` true for\n // those paths and silently drop their errors.\n const schemaErrors: Record = Object.create(null);\n\n for (; vineErrors.length; ) {\n const error = vineErrors[0];\n const path = error.field;\n\n if (!(path in schemaErrors)) {\n schemaErrors[path] = { message: error.message, type: error.rule };\n }\n\n if (validateAllFieldCriteria) {\n const { types } = schemaErrors[path];\n const messages = types && types[error.rule];\n\n schemaErrors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n schemaErrors,\n error.rule,\n messages ? [...(messages as string[]), error.message] : error.message,\n ) as FieldError;\n }\n\n vineErrors.shift();\n }\n\n return schemaErrors;\n}\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions: ValidationOptions | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using VineJS schema validation\n * @param {T} schema - The VineJS schema to validate against\n * @param {ValidationOptions} [schemaOptions] - Optional VineJS validation options\n * @param {Object} [resolverOptions] - Optional resolver configuration\n * @param {boolean} [resolverOptions.raw=false] - If true, returns raw values instead of validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = vine.create({\n * name: vine.string().minLength(2),\n * age: vine.number().min(18)\n * });\n *\n * useForm({\n * resolver: vineResolver(schema)\n * });\n */\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions: { raw?: boolean } = {},\n): Resolver {\n return async (values, _, options) => {\n try {\n const data = await schema.validate(values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n };\n } catch (error: any) {\n if (error instanceof errors.E_VALIDATION_ERROR) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.messages,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["parseErrorSchema","vineErrors","validateAllFieldCriteria","schemaErrors","Object","create","length","error","path","field","message","type","rule","types","messages","appendErrors","concat","shift","vineResolver","schema","schemaOptions","resolverOptions","values","_","options","Promise","resolve","validate","then","data","shouldUseNativeValidation","validateFieldsNatively","errors","raw","assign","_catch","E_VALIDATION_ERROR","toNestErrors","criteriaMode","e","reject"],"mappings":"oKAaA,SAASA,EACPC,EACAC,GAQA,IAFA,IAAMC,EAA2CC,OAAOC,OAAO,MAExDJ,EAAWK,QAAU,CAC1B,IAAMC,EAAQN,EAAW,GACnBO,EAAOD,EAAME,MAMnB,GAJMD,KAAQL,IACZA,EAAaK,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMK,OAGzDV,EAA0B,CAC5B,IAAQW,EAAUV,EAAaK,GAAvBK,MACFC,EAAWD,GAASA,EAAMN,EAAMK,MAEtCT,EAAaK,GAAQO,EACnBP,EACAN,EACAC,EACAI,EAAMK,KACNE,KAAQE,OAAQF,EAAuBP,CAAAA,EAAMG,UAAWH,EAAMG,QAElE,CAEAT,EAAWgB,OACb,CAEA,OAAOd,CACT,CAqCM,SAAUe,EACdC,EACAC,EACAC,GAEA,gBAFAA,IAAAA,EAAqC,CAAA,YAEvBC,EAAQC,EAAGC,OAAWC,OAAAA,QAAAC,gCAC9BD,QAAAC,QACiBP,EAAOQ,SAASL,EAAQF,IAAcQ,KAAA,SAAnDC,GAIN,OAFAL,EAAQM,2BAA6BC,EAAuB,GAAIP,GAEzD,CACLQ,OAAQ,CAAE,EACVV,OAAQD,EAAgBY,IAAM7B,OAAO8B,OAAO,CAAA,EAAIZ,GAAUO,EAC1D,4DAT8BM,CAC9B,EASK5B,SAAAA,GACP,GAAIA,aAAiByB,EAAOI,mBAC1B,MAAO,CACLd,OAAQ,CAAE,EACVU,OAAQK,EACNrC,EACEO,EAAMO,UACLU,EAAQM,2BACkB,QAAzBN,EAAQc,cAEZd,IAKN,MAAMjB,CACR,GACF,CAAC,MAAAgC,GAAAd,OAAAA,QAAAe,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.umd.js b/node_modules/@hookform/resolvers/vine/dist/vine.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..1354abae53223d5cbdb3460a564679f2aea5be22 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.umd.js @@ -0,0 +1,2 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("@vinejs/vine"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","@vinejs/vine","react-hook-form"],r):r((e||self).hookformResolversVine={},e.hookformResolvers,e.vine,e.ReactHookForm)}(this,function(e,r,o,t){function n(e,r){for(var o=Object.create(null);e.length;){var n=e[0],s=n.field;if(s in o||(o[s]={message:n.message,type:n.rule}),r){var i=o[s].types,a=i&&i[n.rule];o[s]=t.appendErrors(s,r,o,n.rule,a?[].concat(a,[n.message]):n.message)}e.shift()}return o}e.vineResolver=function(e,t,s){return void 0===s&&(s={}),function(i,a,l){try{return Promise.resolve(function(o,n){try{var a=Promise.resolve(e.validate(i,t)).then(function(e){return l.shouldUseNativeValidation&&r.validateFieldsNatively({},l),{errors:{},values:s.raw?Object.assign({},i):e}})}catch(e){return n(e)}return a&&a.then?a.then(void 0,n):a}(0,function(e){if(e instanceof o.errors.E_VALIDATION_ERROR)return{values:{},errors:r.toNestErrors(n(e.messages,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)};throw e}))}catch(e){return Promise.reject(e)}}}}); +//# sourceMappingURL=vine.umd.js.map diff --git a/node_modules/@hookform/resolvers/vine/dist/vine.umd.js.map b/node_modules/@hookform/resolvers/vine/dist/vine.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c6041ec5c39876fb1a427a7ae238a31026daa89c --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/dist/vine.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vine.umd.js","sources":["../src/vine.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { SimpleErrorReporter, VineValidator, errors } from '@vinejs/vine';\nimport {\n ConstructableSchema,\n ValidationOptions,\n} from '@vinejs/vine/build/src/types';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nfunction parseErrorSchema(\n vineErrors: SimpleErrorReporter['errors'],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `path in schemaErrors` true for\n // those paths and silently drop their errors.\n const schemaErrors: Record = Object.create(null);\n\n for (; vineErrors.length; ) {\n const error = vineErrors[0];\n const path = error.field;\n\n if (!(path in schemaErrors)) {\n schemaErrors[path] = { message: error.message, type: error.rule };\n }\n\n if (validateAllFieldCriteria) {\n const { types } = schemaErrors[path];\n const messages = types && types[error.rule];\n\n schemaErrors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n schemaErrors,\n error.rule,\n messages ? [...(messages as string[]), error.message] : error.message,\n ) as FieldError;\n }\n\n vineErrors.shift();\n }\n\n return schemaErrors;\n}\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver;\n\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions: ValidationOptions | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver;\n\n/**\n * Creates a resolver for react-hook-form using VineJS schema validation\n * @param {T} schema - The VineJS schema to validate against\n * @param {ValidationOptions} [schemaOptions] - Optional VineJS validation options\n * @param {Object} [resolverOptions] - Optional resolver configuration\n * @param {boolean} [resolverOptions.raw=false] - If true, returns raw values instead of validated results\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @example\n * const schema = vine.create({\n * name: vine.string().minLength(2),\n * age: vine.number().min(18)\n * });\n *\n * useForm({\n * resolver: vineResolver(schema)\n * });\n */\nexport function vineResolver(\n schema: VineValidator, any>,\n schemaOptions?: ValidationOptions,\n resolverOptions: { raw?: boolean } = {},\n): Resolver {\n return async (values, _, options) => {\n try {\n const data = await schema.validate(values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n };\n } catch (error: any) {\n if (error instanceof errors.E_VALIDATION_ERROR) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.messages,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["parseErrorSchema","vineErrors","validateAllFieldCriteria","schemaErrors","Object","create","length","error","path","field","message","type","rule","types","messages","appendErrors","concat","shift","schema","schemaOptions","resolverOptions","values","_","options","Promise","resolve","validate","then","data","shouldUseNativeValidation","validateFieldsNatively","errors","raw","assign","_catch","E_VALIDATION_ERROR","toNestErrors","criteriaMode","e","reject"],"mappings":"yaAaA,SAASA,EACPC,EACAC,GAQA,IAFA,IAAMC,EAA2CC,OAAOC,OAAO,MAExDJ,EAAWK,QAAU,CAC1B,IAAMC,EAAQN,EAAW,GACnBO,EAAOD,EAAME,MAMnB,GAJMD,KAAQL,IACZA,EAAaK,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMK,OAGzDV,EAA0B,CAC5B,IAAQW,EAAUV,EAAaK,GAAvBK,MACFC,EAAWD,GAASA,EAAMN,EAAMK,MAEtCT,EAAaK,GAAQO,EAAAA,aACnBP,EACAN,EACAC,EACAI,EAAMK,KACNE,KAAQE,OAAQF,EAAuBP,CAAAA,EAAMG,UAAWH,EAAMG,QAElE,CAEAT,EAAWgB,OACb,CAEA,OAAOd,CACT,gBAqCM,SACJe,EACAC,EACAC,GAEA,gBAFAA,IAAAA,EAAqC,CAAA,YAEvBC,EAAQC,EAAGC,OAAWC,OAAAA,QAAAC,gCAC9BD,QAAAC,QACiBP,EAAOQ,SAASL,EAAQF,IAAcQ,KAAA,SAAnDC,GAIN,OAFAL,EAAQM,2BAA6BC,EAAsBA,uBAAC,GAAIP,GAEzD,CACLQ,OAAQ,CAAE,EACVV,OAAQD,EAAgBY,IAAM5B,OAAO6B,OAAO,CAAA,EAAIZ,GAAUO,EAC1D,4DAT8BM,CAC9B,EASK3B,SAAAA,GACP,GAAIA,aAAiBwB,EAAMA,OAACI,mBAC1B,MAAO,CACLd,OAAQ,CAAE,EACVU,OAAQK,EAAAA,aACNpC,EACEO,EAAMO,UACLS,EAAQM,2BACkB,QAAzBN,EAAQc,cAEZd,IAKN,MAAMhB,CACR,GACF,CAAC,MAAA+B,GAAAd,OAAAA,QAAAe,OAAAD,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/vine/package.json b/node_modules/@hookform/resolvers/vine/package.json new file mode 100644 index 0000000000000000000000000000000000000000..cf911504ee039bb9100591071175c15561efef48 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/package.json @@ -0,0 +1,18 @@ +{ + "name": "@hookform/resolvers/vine", + "amdName": "hookformResolversVine", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: vine", + "main": "dist/vine.js", + "module": "dist/vine.module.js", + "umd:main": "dist/vine.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.55.0", + "@hookform/resolvers": "^2.0.0", + "@vinejs/vine": "^2.0.0 || ^3.0.0 || ^4.0.0" + } +} diff --git a/node_modules/@hookform/resolvers/vine/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/vine/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..8b1097870197e6bc40cae8880d723b4e74552a13 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,81 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import vine from '@vinejs/vine'; +import { Infer } from '@vinejs/vine/build/src/types'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { vineResolver } from '..'; + +const schema = vine.create({ + username: vine.string().minLength(1), + password: vine.string().minLength(1), +}); + +interface Props { + onSubmit: (data: Infer) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: vineResolver(schema), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Zod", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe( + 'The username field must have at least 1 characters', + ); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe( + 'The password field must have at least 1 characters', + ); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/vine/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/vine/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ab794419d32a5ac71b095eb441acdb74488e2ae8 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/__tests__/Form.tsx @@ -0,0 +1,53 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import vine from '@vinejs/vine'; +import { Infer } from '@vinejs/vine/build/src/types'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { vineResolver } from '..'; + +const schema = vine.create({ + username: vine.string().minLength(1), + password: vine.string().minLength(1), +}); + +function TestComponent({ + onSubmit, +}: { onSubmit: (data: Infer) => void }) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: vineResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Vine and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect( + screen.getByText(/The username field must have at least 1 characters/i), + ).toBeInTheDocument(); + expect( + screen.getByText(/The password field must have at least 1 characters/i), + ).toBeInTheDocument(); + expect(handleSubmit).not.toHaveBeenCalled(); +}); diff --git a/node_modules/@hookform/resolvers/vine/src/__tests__/__fixtures__/data.ts b/node_modules/@hookform/resolvers/vine/src/__tests__/__fixtures__/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b6732aed808e0120b4152eddcd1f3710da1718f --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/__tests__/__fixtures__/data.ts @@ -0,0 +1,74 @@ +import vine from '@vinejs/vine'; +import { InferInput } from '@vinejs/vine/build/src/types'; +import { Field, InternalFieldName } from 'react-hook-form'; + +export const schema = vine.create({ + username: vine.string().regex(/^\w+$/).minLength(3).maxLength(30), + password: vine + .string() + .regex(new RegExp('.*[A-Z].*')) + .regex(new RegExp('.*[a-z].*')) + .regex(new RegExp('.*\\d.*')) + .regex(new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*')) + .minLength(8) + .confirmed({ as: 'repeatPassword' }), + repeatPassword: vine.string().sameAs('password'), + accessToken: vine.unionOfTypes([vine.string(), vine.number()]), + birthYear: vine.number().min(1900).max(2013), + email: vine.string().email().optional(), + tags: vine.array(vine.string()), + enabled: vine.boolean(), + like: vine.array( + vine.object({ + id: vine.number(), + name: vine.string().fixedLength(4), + }), + ), + dateStr: vine + .string() + .transform((value: string) => new Date(value).toISOString()), +}); + +export const validData = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + like: [ + { + id: 1, + name: 'name', + }, + ], + dateStr: '2020-01-01T00:00:00.000Z', +} satisfies InferInput; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], +} as unknown as InferInput; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/vine/src/__tests__/__snapshots__/vine.ts.snap b/node_modules/@hookform/resolvers/vine/src/__tests__/__snapshots__/vine.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..b139736b1c1eebfe161397c6073b5b989fcf6b62 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/__tests__/__snapshots__/vine.ts.snap @@ -0,0 +1,180 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`vineResolver > should return a single error from vineResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid value provided for accessToken field", + "ref": undefined, + "type": "unionOfTypes", + }, + "birthYear": { + "message": "The birthYear field must be a number", + "ref": undefined, + "type": "number", + }, + "dateStr": { + "message": "The dateStr field must be defined", + "ref": undefined, + "type": "required", + }, + "email": { + "message": "The email field must be a valid email address", + "ref": { + "name": "email", + }, + "type": "email", + }, + "enabled": { + "message": "The enabled field must be defined", + "ref": undefined, + "type": "required", + }, + "like": [ + { + "id": { + "message": "The id field must be a number", + "ref": undefined, + "type": "number", + }, + "name": { + "message": "The name field must be defined", + "ref": undefined, + "type": "required", + }, + }, + ], + "password": { + "message": "The password field format is invalid", + "ref": { + "name": "password", + }, + "type": "regex", + }, + "repeatPassword": { + "message": "The repeatPassword field must be defined", + "ref": undefined, + "type": "required", + }, + "tags": { + "message": "The tags field must be defined", + "ref": undefined, + "type": "required", + }, + "username": { + "message": "The username field must be defined", + "ref": { + "name": "username", + }, + "type": "required", + }, + }, + "values": {}, +} +`; + +exports[`vineResolver > should return all the errors from vineResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid value provided for accessToken field", + "ref": undefined, + "type": "unionOfTypes", + "types": { + "unionOfTypes": "Invalid value provided for accessToken field", + }, + }, + "birthYear": { + "message": "The birthYear field must be a number", + "ref": undefined, + "type": "number", + "types": { + "number": "The birthYear field must be a number", + }, + }, + "dateStr": { + "message": "The dateStr field must be defined", + "ref": undefined, + "type": "required", + "types": { + "required": "The dateStr field must be defined", + }, + }, + "email": { + "message": "The email field must be a valid email address", + "ref": { + "name": "email", + }, + "type": "email", + "types": { + "email": "The email field must be a valid email address", + }, + }, + "enabled": { + "message": "The enabled field must be defined", + "ref": undefined, + "type": "required", + "types": { + "required": "The enabled field must be defined", + }, + }, + "like": [ + { + "id": { + "message": "The id field must be a number", + "ref": undefined, + "type": "number", + "types": { + "number": "The id field must be a number", + }, + }, + "name": { + "message": "The name field must be defined", + "ref": undefined, + "type": "required", + "types": { + "required": "The name field must be defined", + }, + }, + }, + ], + "password": { + "message": "The password field format is invalid", + "ref": { + "name": "password", + }, + "type": "regex", + "types": { + "regex": "The password field format is invalid", + }, + }, + "repeatPassword": { + "message": "The repeatPassword field must be defined", + "ref": undefined, + "type": "required", + "types": { + "required": "The repeatPassword field must be defined", + }, + }, + "tags": { + "message": "The tags field must be defined", + "ref": undefined, + "type": "required", + "types": { + "required": "The tags field must be defined", + }, + }, + "username": { + "message": "The username field must be defined", + "ref": { + "name": "username", + }, + "type": "required", + "types": { + "required": "The username field must be defined", + }, + }, + }, + "values": {}, +} +`; diff --git a/node_modules/@hookform/resolvers/vine/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/vine/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..171d69135fc418b9623cd6ea882d54b7959043ce --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/__tests__/special-path-names.ts @@ -0,0 +1,23 @@ +import vine from '@vinejs/vine'; +import { vineResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe('vineResolver special path names', () => { + it.each(['hasOwnProperty', 'toString'])( + 'reports a validation error for a field named "%s"', + async (name) => { + const schema = vine.compile( + vine.object({ [name]: vine.string().minLength(1) } as any), + ); + + const result = await vineResolver(schema as any)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors[name]).toBeDefined(); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/vine/src/__tests__/vine.ts b/node_modules/@hookform/resolvers/vine/src/__tests__/vine.ts new file mode 100644 index 0000000000000000000000000000000000000000..35cfceaab169ffa573095cd48eebce6d97e23701 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/__tests__/vine.ts @@ -0,0 +1,125 @@ +import { renderHook } from '@testing-library/react'; +import vine from '@vinejs/vine'; +import { Resolver, useForm } from 'react-hook-form'; +import { SubmitHandler } from 'react-hook-form'; +import { vineResolver } from '..'; +import { fields, invalidData, schema, validData } from './__fixtures__/data'; + +const shouldUseNativeValidation = false; + +describe('vineResolver', () => { + it('should return values from vineResolver when validation pass', async () => { + const schemaSpy = vi.spyOn(schema, 'validate'); + + const result = await vineResolver(schema)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(schemaSpy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return a single error from vineResolver when validation fails', async () => { + const result = await vineResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from vineResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await vineResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return values from vineResolver when validation pass & raw=true', async () => { + const schemaSpy = vi.spyOn(schema, 'validate'); + + const result = await vineResolver(schema, undefined, { raw: true })( + validData, + undefined, + { + fields, + shouldUseNativeValidation, + }, + ); + + expect(schemaSpy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a vine schema', () => { + const schema = vine.create({ id: vine.number() }); + const resolver = vineResolver(schema); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number | string }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a vine schema using a transform', () => { + const schema = vine.create({ + id: vine + .number() + .decimal([2, 4]) + .transform((val: unknown) => String(val)), + }); + const resolver = vineResolver(schema); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number | string }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a vine schema for the handleSubmit function in useForm', () => { + const schema = vine.create({ id: vine.number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: vineResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a vine schema with a transform for the handleSubmit function in useForm', () => { + const schema = vine.create({ + id: vine.number().transform((val: unknown) => String(val)), + }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: vineResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/vine/src/index.ts b/node_modules/@hookform/resolvers/vine/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ddc3de183aa82d0d27ba106f79341fb95ab3fa5d --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/index.ts @@ -0,0 +1 @@ +export * from './vine'; diff --git a/node_modules/@hookform/resolvers/vine/src/vine.ts b/node_modules/@hookform/resolvers/vine/src/vine.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6ad7a34b7e0df782371d03d96acd99f2a898373 --- /dev/null +++ b/node_modules/@hookform/resolvers/vine/src/vine.ts @@ -0,0 +1,119 @@ +import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; +import { SimpleErrorReporter, VineValidator, errors } from '@vinejs/vine'; +import { + ConstructableSchema, + ValidationOptions, +} from '@vinejs/vine/build/src/types'; +import { + FieldError, + FieldValues, + Resolver, + appendErrors, +} from 'react-hook-form'; + +function parseErrorSchema( + vineErrors: SimpleErrorReporter['errors'], + validateAllFieldCriteria: boolean, +) { + // A null-prototype object avoids false-positive hits from inherited + // members (e.g. `toString`, `constructor`) when a field is named after + // one of them — a plain `{}` would make `path in schemaErrors` true for + // those paths and silently drop their errors. + const schemaErrors: Record = Object.create(null); + + for (; vineErrors.length; ) { + const error = vineErrors[0]; + const path = error.field; + + if (!(path in schemaErrors)) { + schemaErrors[path] = { message: error.message, type: error.rule }; + } + + if (validateAllFieldCriteria) { + const { types } = schemaErrors[path]; + const messages = types && types[error.rule]; + + schemaErrors[path] = appendErrors( + path, + validateAllFieldCriteria, + schemaErrors, + error.rule, + messages ? [...(messages as string[]), error.message] : error.message, + ) as FieldError; + } + + vineErrors.shift(); + } + + return schemaErrors; +} + +export function vineResolver( + schema: VineValidator, any>, + schemaOptions?: ValidationOptions, + resolverOptions?: { + mode?: 'async' | 'sync'; + raw?: false; + }, +): Resolver; + +export function vineResolver( + schema: VineValidator, any>, + schemaOptions: ValidationOptions | undefined, + resolverOptions: { + mode?: 'async' | 'sync'; + raw: true; + }, +): Resolver; + +/** + * Creates a resolver for react-hook-form using VineJS schema validation + * @param {T} schema - The VineJS schema to validate against + * @param {ValidationOptions} [schemaOptions] - Optional VineJS validation options + * @param {Object} [resolverOptions] - Optional resolver configuration + * @param {boolean} [resolverOptions.raw=false] - If true, returns raw values instead of validated results + * @returns {Resolver>} A resolver function compatible with react-hook-form + * @example + * const schema = vine.create({ + * name: vine.string().minLength(2), + * age: vine.number().min(18) + * }); + * + * useForm({ + * resolver: vineResolver(schema) + * }); + */ +export function vineResolver( + schema: VineValidator, any>, + schemaOptions?: ValidationOptions, + resolverOptions: { raw?: boolean } = {}, +): Resolver { + return async (values, _, options) => { + try { + const data = await schema.validate(values, schemaOptions); + + options.shouldUseNativeValidation && validateFieldsNatively({}, options); + + return { + errors: {}, + values: resolverOptions.raw ? Object.assign({}, values) : data, + }; + } catch (error: any) { + if (error instanceof errors.E_VALIDATION_ERROR) { + return { + values: {}, + errors: toNestErrors( + parseErrorSchema( + error.messages, + !options.shouldUseNativeValidation && + options.criteriaMode === 'all', + ), + options, + ), + }; + } + + throw error; + } + }; +} diff --git a/node_modules/@hookform/resolvers/yup/dist/index.d.ts b/node_modules/@hookform/resolvers/yup/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13c89e6eb059648677c90cb9e787079bb2038828 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/index.d.ts @@ -0,0 +1 @@ +export * from './yup'; diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.d.ts b/node_modules/@hookform/resolvers/yup/dist/yup.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..11c9be4550dfcb91b6eaf6fc0003e0978e764c6d --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.d.ts @@ -0,0 +1,10 @@ +import { FieldValues, Resolver } from 'react-hook-form'; +import * as Yup from 'yup'; +export declare function yupResolver(schema: Yup.ObjectSchema | ReturnType>>, schemaOptions?: Parameters<(typeof schema)['validate']>[1], resolverOptions?: { + mode?: 'async' | 'sync'; + raw?: false; +}): Resolver, Context, Yup.InferType>; +export declare function yupResolver(schema: Yup.ObjectSchema | ReturnType>>, schemaOptions: Parameters<(typeof schema)['validate']>[1] | undefined, resolverOptions: { + mode?: 'async' | 'sync'; + raw: true; +}): Resolver, Context, Yup.InferType>; diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.js b/node_modules/@hookform/resolvers/yup/dist/yup.js new file mode 100644 index 0000000000000000000000000000000000000000..58cdf2885a13e41aa1cc6a82cbc325aa5359f8c9 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.js @@ -0,0 +1,2 @@ +var e=require("@hookform/resolvers"),t=require("react-hook-form");exports.yupResolver=function(r,o,n){return void 0===n&&(n={}),function(s,a,i){try{return Promise.resolve(function(t,u){try{var c=(null!=o&&o.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(r["sync"===n.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},o,{context:a}))).then(function(t){return i.shouldUseNativeValidation&&e.validateFieldsNatively({},i),{values:n.raw?Object.assign({},s):t,errors:{}}}))}catch(e){return u(e)}return c&&c.then?c.then(void 0,u):c}(0,function(r){if(!r.inner)throw r;return{values:{},errors:e.toNestErrors((o=r,n=!i.shouldUseNativeValidation&&"all"===i.criteriaMode,(o.inner||[]).reduce(function(e,r){if(e[r.path]||(e[r.path]={message:r.message,type:r.type}),n){var o=e[r.path].types,s=o&&o[r.type];e[r.path]=t.appendErrors(r.path,n,e,r.type,s?[].concat(s,r.message):r.message)}return e},Object.create(null))),i)};var o,n}))}catch(e){return Promise.reject(e)}}}; +//# sourceMappingURL=yup.js.map diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.js.map b/node_modules/@hookform/resolvers/yup/dist/yup.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5912a31238d021e7831602b5eaa2453a4017f609 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.js.map @@ -0,0 +1 @@ +{"version":3,"file":"yup.js","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nfunction parseErrorSchema(\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype accumulator avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `!previous[error.path!]`\n // truthy-skip those paths and silently drop their errors.\n return (error.inner || []).reduce>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n Object.create(null),\n );\n}\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\n/**\n * Creates a resolver for react-hook-form using Yup schema validation\n * @param {Yup.ObjectSchema | ReturnType>>} schema - Yup validation schema\n * @param {Parameters<(typeof schema)['validate']>[1]} schemaOptions - Options to pass to Yup's validate/validateSync\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('async' | 'sync')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values instead of validated results\n * @returns {Resolver | Input>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Yup.object({\n * name: Yup.string().required(),\n * age: Yup.number().required(),\n * });\n *\n * useForm({\n * resolver: yupResolver(schema)\n * });\n */\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver | Input> {\n return async (values: Input, context, options) => {\n try {\n if (schemaOptions?.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["schema","schemaOptions","resolverOptions","values","context","options","Promise","resolve","process","env","NODE_ENV","console","warn","mode","Object","assign","abortEarly","then","result","shouldUseNativeValidation","validateFieldsNatively","raw","errors","_catch","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","create","reject"],"mappings":"+FAiGEA,EAGAC,EACAC,GAKA,gBALAA,IAAAA,EAGI,IAEJ,SAAcC,EAAeC,EAASC,GAAO,WAAIC,QAAAC,uCAEzCN,GAAAA,EAAeG,SAAoC,gBAAzBI,QAAQC,IAAIC,UAExCC,QAAQC,KACN,iGAEHN,QAAAC,QAEoBP,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDV,EACAW,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEG,QAAAA,MACvDa,KALKC,SAAAA,GASN,OAFAb,EAAQc,2BAA6BC,yBAAuB,CAAA,EAAIf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAMP,OAAOC,OAAO,CAAA,EAAIZ,GAAUe,EAC1DI,OAAQ,GACR,6DArB2CC,CAAA,EAsB9C,SAAQC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLrB,OAAQ,GACRmB,OAAQI,EAAYA,cAzH1BC,EA2HUH,EA1HVI,GA2HWvB,EAAQc,2BACkB,QAAzBd,EAAQwB,cAtHZF,EAAMF,OAAS,IAAIK,OACzB,SAACC,EAAUJ,GAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,IAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EAAYA,aAClCV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CACT,EACAjB,OAAOyB,OAAO,QAiGRlC,IAhIV,IACEsB,EACAC,CAiIE,GACF,CAAC,MAAAJ,GAAA,OAAAlB,QAAAkC,OAAAhB,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.mjs b/node_modules/@hookform/resolvers/yup/dist/yup.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1963f4c084de42526836450e1970450038c1e3dd --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.mjs @@ -0,0 +1,2 @@ +import{validateFieldsNatively as e,toNestErrors as t}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";function o(o,n,a){return void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(null!=n&&n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===a.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&e({},c),{values:a.raw?Object.assign({},s):t,errors:{}}}))}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return{values:{},errors:t((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,a=o&&o[t.type];e[t.path]=r(t.path,n,e,t.type,a?[].concat(a,t.message):t.message)}return e},Object.create(null))),c)};var o,n}))}catch(e){return Promise.reject(e)}}}export{o as yupResolver}; +//# sourceMappingURL=yup.module.js.map diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs b/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bed94f82749d9631f21b75744d40c65700bcd09a --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs @@ -0,0 +1,2 @@ +import{validateFieldsNatively as e,toNestErrors as t}from"@hookform/resolvers";import{appendErrors as o}from"react-hook-form";function a(a,r,s={}){return async(n,c,i)=>{try{null!=r&&r.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");const t=await a["sync"===s.mode?"validateSync":"validate"](n,Object.assign({abortEarly:!1},r,{context:c}));return i.shouldUseNativeValidation&&e({},i),{values:s.raw?Object.assign({},n):t,errors:{}}}catch(e){if(!e.inner)throw e;return{values:{},errors:t((l=e,u=!i.shouldUseNativeValidation&&"all"===i.criteriaMode,(l.inner||[]).reduce((e,t)=>{if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),u){const a=e[t.path].types,r=a&&a[t.type];e[t.path]=o(t.path,u,e,t.type,r?[].concat(r,t.message):t.message)}return e},Object.create(null))),i)}}var l,u}}export{a as yupResolver}; +//# sourceMappingURL=yup.modern.mjs.map diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs.map b/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..d6c39fc49011a6aec36eb5da46f853925a0d9f64 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"yup.modern.mjs","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nfunction parseErrorSchema(\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype accumulator avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `!previous[error.path!]`\n // truthy-skip those paths and silently drop their errors.\n return (error.inner || []).reduce>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n Object.create(null),\n );\n}\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\n/**\n * Creates a resolver for react-hook-form using Yup schema validation\n * @param {Yup.ObjectSchema | ReturnType>>} schema - Yup validation schema\n * @param {Parameters<(typeof schema)['validate']>[1]} schemaOptions - Options to pass to Yup's validate/validateSync\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('async' | 'sync')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values instead of validated results\n * @returns {Resolver | Input>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Yup.object({\n * name: Yup.string().required(),\n * age: Yup.number().required(),\n * });\n *\n * useForm({\n * resolver: yupResolver(schema)\n * });\n */\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver | Input> {\n return async (values: Input, context, options) => {\n try {\n if (schemaOptions?.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["yupResolver","schema","schemaOptions","resolverOptions","async","values","context","options","process","env","NODE_ENV","console","warn","result","mode","Object","assign","abortEarly","shouldUseNativeValidation","validateFieldsNatively","raw","errors","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","create"],"mappings":"8HAgGgB,SAAAA,EACdC,EAGAC,EACAC,EAGI,CAAE,GAEN,OAAOC,MAAOC,EAAeC,EAASC,KACpC,IACmB,MAAbL,GAAAA,EAAeI,SAAoC,gBAAzBE,QAAQC,IAAIC,UAExCC,QAAQC,KACN,iGAIJ,MAAMC,QAAeZ,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDT,EACAU,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEI,aAKxD,OAFAC,EAAQW,2BAA6BC,EAAuB,CAAA,EAAIZ,GAEzD,CACLF,OAAQF,EAAgBiB,IAAML,OAAOC,OAAO,GAAIX,GAAUQ,EAC1DQ,OAAQ,CAAA,EAEZ,CAAE,MAAOC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLjB,OAAQ,CAAE,EACVgB,OAAQG,GAzHdC,EA2HUH,EA1HVI,GA2HWnB,EAAQW,2BACkB,QAAzBX,EAAQoB,cAtHZF,EAAMF,OAAS,IAAIK,OACzB,CAACC,EAAUJ,KAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,MAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EACtBV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CAAQ,EAEjBd,OAAOsB,OAAO,QAiGR9B,GAGN,CAnIJ,IACEkB,EACAC,CAiIE,CAEJ"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.module.js b/node_modules/@hookform/resolvers/yup/dist/yup.module.js new file mode 100644 index 0000000000000000000000000000000000000000..1963f4c084de42526836450e1970450038c1e3dd --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.module.js @@ -0,0 +1,2 @@ +import{validateFieldsNatively as e,toNestErrors as t}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";function o(o,n,a){return void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(null!=n&&n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===a.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&e({},c),{values:a.raw?Object.assign({},s):t,errors:{}}}))}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return{values:{},errors:t((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,a=o&&o[t.type];e[t.path]=r(t.path,n,e,t.type,a?[].concat(a,t.message):t.message)}return e},Object.create(null))),c)};var o,n}))}catch(e){return Promise.reject(e)}}}export{o as yupResolver}; +//# sourceMappingURL=yup.module.js.map diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.module.js.map b/node_modules/@hookform/resolvers/yup/dist/yup.module.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e34bf58a69990bf004325307d032a646d168de77 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"yup.module.js","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nfunction parseErrorSchema(\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype accumulator avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `!previous[error.path!]`\n // truthy-skip those paths and silently drop their errors.\n return (error.inner || []).reduce>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n Object.create(null),\n );\n}\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\n/**\n * Creates a resolver for react-hook-form using Yup schema validation\n * @param {Yup.ObjectSchema | ReturnType>>} schema - Yup validation schema\n * @param {Parameters<(typeof schema)['validate']>[1]} schemaOptions - Options to pass to Yup's validate/validateSync\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('async' | 'sync')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values instead of validated results\n * @returns {Resolver | Input>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Yup.object({\n * name: Yup.string().required(),\n * age: Yup.number().required(),\n * });\n *\n * useForm({\n * resolver: yupResolver(schema)\n * });\n */\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver | Input> {\n return async (values: Input, context, options) => {\n try {\n if (schemaOptions?.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["yupResolver","schema","schemaOptions","resolverOptions","values","context","options","Promise","resolve","process","env","NODE_ENV","console","warn","mode","Object","assign","abortEarly","then","result","shouldUseNativeValidation","validateFieldsNatively","raw","errors","_catch","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","create","reject"],"mappings":"uIAgGgBA,EACdC,EAGAC,EACAC,GAKA,gBALAA,IAAAA,EAGI,IAEJ,SAAcC,EAAeC,EAASC,GAAO,WAAIC,QAAAC,uCAEzCN,GAAAA,EAAeG,SAAoC,gBAAzBI,QAAQC,IAAIC,UAExCC,QAAQC,KACN,iGAEHN,QAAAC,QAEoBP,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDV,EACAW,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEG,QAAAA,MACvDa,KALKC,SAAAA,GASN,OAFAb,EAAQc,2BAA6BC,EAAuB,CAAA,EAAIf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAMP,OAAOC,OAAO,CAAA,EAAIZ,GAAUe,EAC1DI,OAAQ,GACR,6DArB2CC,CAAA,EAsB9C,SAAQC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLrB,OAAQ,GACRmB,OAAQI,GAzHdC,EA2HUH,EA1HVI,GA2HWvB,EAAQc,2BACkB,QAAzBd,EAAQwB,cAtHZF,EAAMF,OAAS,IAAIK,OACzB,SAACC,EAAUJ,GAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,IAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EACtBV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CACT,EACAjB,OAAOyB,OAAO,QAiGRlC,IAhIV,IACEsB,EACAC,CAiIE,GACF,CAAC,MAAAJ,GAAA,OAAAlB,QAAAkC,OAAAhB,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.umd.js b/node_modules/@hookform/resolvers/yup/dist/yup.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..d0a28bf0297d141edaf464c3270a687e3f14a308 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.umd.js @@ -0,0 +1,2 @@ +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@hookform/resolvers"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form"],o):o((e||self).hookformResolversYup={},e.hookformResolvers,e.ReactHookForm)}(this,function(e,o,t){e.yupResolver=function(e,r,n){return void 0===n&&(n={}),function(s,a,i){try{return Promise.resolve(function(t,u){try{var c=(null!=r&&r.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e["sync"===n.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},r,{context:a}))).then(function(e){return i.shouldUseNativeValidation&&o.validateFieldsNatively({},i),{values:n.raw?Object.assign({},s):e,errors:{}}}))}catch(e){return u(e)}return c&&c.then?c.then(void 0,u):c}(0,function(e){if(!e.inner)throw e;return{values:{},errors:o.toNestErrors((r=e,n=!i.shouldUseNativeValidation&&"all"===i.criteriaMode,(r.inner||[]).reduce(function(e,o){if(e[o.path]||(e[o.path]={message:o.message,type:o.type}),n){var r=e[o.path].types,s=r&&r[o.type];e[o.path]=t.appendErrors(o.path,n,e,o.type,s?[].concat(s,o.message):o.message)}return e},Object.create(null))),i)};var r,n}))}catch(e){return Promise.reject(e)}}}}); +//# sourceMappingURL=yup.umd.js.map diff --git a/node_modules/@hookform/resolvers/yup/dist/yup.umd.js.map b/node_modules/@hookform/resolvers/yup/dist/yup.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..03eb772b90addf16306ad39507234e377133780b --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/dist/yup.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"yup.umd.js","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nfunction parseErrorSchema(\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype accumulator avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`) when a field is named after\n // one of them — a plain `{}` would make `!previous[error.path!]`\n // truthy-skip those paths and silently drop their errors.\n return (error.inner || []).reduce>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n Object.create(null),\n );\n}\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions?: {\n mode?: 'async' | 'sync';\n raw?: false;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] | undefined,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw: true;\n },\n): Resolver<\n Yup.InferType,\n Context,\n Yup.InferType\n>;\n\n/**\n * Creates a resolver for react-hook-form using Yup schema validation\n * @param {Yup.ObjectSchema | ReturnType>>} schema - Yup validation schema\n * @param {Parameters<(typeof schema)['validate']>[1]} schemaOptions - Options to pass to Yup's validate/validateSync\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {('async' | 'sync')} [resolverOptions.mode] - Validation mode\n * @param {boolean} [resolverOptions.raw] - If true, returns raw values instead of validated results\n * @returns {Resolver | Input>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Yup.object({\n * name: Yup.string().required(),\n * age: Yup.number().required(),\n * });\n *\n * useForm({\n * resolver: yupResolver(schema)\n * });\n */\nexport function yupResolver(\n schema:\n | Yup.ObjectSchema\n | ReturnType>>,\n schemaOptions?: Parameters<(typeof schema)['validate']>[1],\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver | Input> {\n return async (values: Input, context, options) => {\n try {\n if (schemaOptions?.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["schema","schemaOptions","resolverOptions","values","context","options","Promise","resolve","process","env","NODE_ENV","console","warn","mode","Object","assign","abortEarly","then","result","shouldUseNativeValidation","validateFieldsNatively","raw","errors","_catch","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","create","reject"],"mappings":"+YAiGEA,EAGAC,EACAC,GAKA,gBALAA,IAAAA,EAGI,IAEJ,SAAcC,EAAeC,EAASC,GAAO,WAAIC,QAAAC,uCAEzCN,GAAAA,EAAeG,SAAoC,gBAAzBI,QAAQC,IAAIC,UAExCC,QAAQC,KACN,iGAEHN,QAAAC,QAEoBP,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDV,EACAW,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEG,QAAAA,MACvDa,KALKC,SAAAA,GASN,OAFAb,EAAQc,2BAA6BC,yBAAuB,CAAA,EAAIf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAMP,OAAOC,OAAO,CAAA,EAAIZ,GAAUe,EAC1DI,OAAQ,GACR,6DArB2CC,CAAA,EAsB9C,SAAQC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLrB,OAAQ,GACRmB,OAAQI,EAAYA,cAzH1BC,EA2HUH,EA1HVI,GA2HWvB,EAAQc,2BACkB,QAAzBd,EAAQwB,cAtHZF,EAAMF,OAAS,IAAIK,OACzB,SAACC,EAAUJ,GAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,IAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EAAYA,aAClCV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CACT,EACAjB,OAAOyB,OAAO,QAiGRlC,IAhIV,IACEsB,EACAC,CAiIE,GACF,CAAC,MAAAJ,GAAA,OAAAlB,QAAAkC,OAAAhB,EACH,CAAA,CAAA"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/yup/package.json b/node_modules/@hookform/resolvers/yup/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9aa0671bf958f466bbfe36e94266578b812a1234 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/package.json @@ -0,0 +1,17 @@ +{ + "name": "@hookform/resolvers/yup", + "amdName": "hookformResolversYup", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: yup", + "main": "dist/yup.js", + "module": "dist/yup.module.js", + "umd:main": "dist/yup.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.55.0", + "@hookform/resolvers": "^2.0.0" + } +} diff --git a/node_modules/@hookform/resolvers/yup/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/yup/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a479e9b6d560f9ff05d4601fc9f6c4e7c256a741 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,81 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import * as Yup from 'yup'; +import { yupResolver } from '..'; + +const USERNAME_REQUIRED_MESSAGE = 'username field is required'; +const PASSWORD_REQUIRED_MESSAGE = 'password field is required'; + +const schema = Yup.object({ + username: Yup.string().required(USERNAME_REQUIRED_MESSAGE), + password: Yup.string().required(PASSWORD_REQUIRED_MESSAGE), +}); + +type FormData = Yup.InferType; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: yupResolver(schema), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Yup", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe(PASSWORD_REQUIRED_MESSAGE); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/yup/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/yup/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..5b6c9802320d672d27290f5be329dd53ed13d2e8 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/__tests__/Form.tsx @@ -0,0 +1,78 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { SubmitHandler, useForm } from 'react-hook-form'; +import * as Yup from 'yup'; +import { yupResolver } from '..'; + +const schema = Yup.object({ + username: Yup.string().required(), + password: Yup.string().required(), +}); + +type FormData = Yup.InferType; + +interface Props { + onSubmit: SubmitHandler; +} + +function TestComponent({ onSubmit }: Props) { + const { + register, + formState: { errors }, + handleSubmit, + } = useForm({ + resolver: yupResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Yup and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect(screen.getByText(/username is a required field/i)).toBeInTheDocument(); + expect(screen.getByText(/password is a required field/i)).toBeInTheDocument(); + expect(handleSubmit).not.toHaveBeenCalled(); +}); + +const checkboxSchema = Yup.object({ + isTosAccepted: Yup.boolean().oneOf([true], 'must accept tos').required(), +}); + +test('errors..ref is the checkbox input element, not validation metadata (#630)', async () => { + let latestErrors: ReturnType['formState']['errors'] = {}; + function Wrapper() { + const methods = useForm({ resolver: yupResolver(checkboxSchema) }); + latestErrors = methods.formState.errors; + + return ( +
{})}> + + +
+ ); + } + + render(); + + const checkbox = screen.getByRole('checkbox'); + await user.click(screen.getByText(/submit/i)); + + expect(latestErrors.isTosAccepted?.ref).toBe(checkbox); +}); diff --git a/node_modules/@hookform/resolvers/yup/src/__tests__/__fixtures__/data.ts b/node_modules/@hookform/resolvers/yup/src/__tests__/__fixtures__/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..90348fecd237c73aeb3928f0ae6fd54a0bc2d866 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/__tests__/__fixtures__/data.ts @@ -0,0 +1,80 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import * as yup from 'yup'; + +export const schema = yup.object({ + username: yup.string().matches(/^\w+$/).min(3).max(30).required(), + password: yup + .string() + .matches(new RegExp('.*[A-Z].*'), 'One uppercase character') + .matches(new RegExp('.*[a-z].*'), 'One lowercase character') + .matches(new RegExp('.*\\d.*'), 'One number') + .matches( + new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), + 'One special character', + ) + .min(8, 'Must be at least 8 characters in length') + .required('New Password is required'), + repeatPassword: yup.ref('password'), + accessToken: yup.string(), + birthYear: yup.number().min(1900).max(2013), + email: yup.string().email(), + tags: yup.array(yup.string()), + enabled: yup.boolean(), + like: yup.array().of( + yup.object({ + id: yup.number().required(), + name: yup.string().length(4).required(), + }), + ), +}); + +export const schemaWithWhen = yup.object({ + name: yup.string().required(), + value: yup.string().when('name', ([name], schema) => { + return name === 'test' ? yup.number().required() : schema; + }), +}); + +export const validData = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + like: [ + { + id: 1, + name: 'name', + }, + ], +} satisfies yup.InferType; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], + // Must be set to "unknown", otherwise typescript knows that it is invalid +} as unknown as Required>; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/yup/src/__tests__/__snapshots__/yup.ts.snap b/node_modules/@hookform/resolvers/yup/src/__tests__/__snapshots__/yup.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..076491d31a4e03a9380f62a41ba5d508681c33e6 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/__tests__/__snapshots__/yup.ts.snap @@ -0,0 +1,244 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`yupResolver > should return a single error from yupResolver when validation fails 1`] = ` +{ + "errors": { + "birthYear": { + "message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).", + "ref": undefined, + "type": "typeError", + }, + "like": [ + { + "id": { + "message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).", + "ref": undefined, + "type": "typeError", + }, + "name": { + "message": "like[0].name is a required field", + "ref": undefined, + "type": "optionality", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "matches", + }, + "username": { + "message": "username is a required field", + "ref": { + "name": "username", + }, + "type": "optionality", + }, + }, + "values": {}, +} +`; + +exports[`yupResolver > should return a single error from yupResolver with \`mode: sync\` when validation fails 1`] = ` +{ + "errors": { + "birthYear": { + "message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).", + "ref": undefined, + "type": "typeError", + }, + "like": [ + { + "id": { + "message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).", + "ref": undefined, + "type": "typeError", + }, + "name": { + "message": "like[0].name is a required field", + "ref": undefined, + "type": "optionality", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "matches", + }, + "username": { + "message": "username is a required field", + "ref": { + "name": "username", + }, + "type": "optionality", + }, + }, + "values": {}, +} +`; + +exports[`yupResolver > should return all the errors from yupResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "birthYear": { + "message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).", + "ref": undefined, + "type": "typeError", + "types": { + "typeError": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).", + }, + }, + "like": [ + { + "id": { + "message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).", + "ref": undefined, + "type": "typeError", + "types": { + "typeError": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).", + }, + }, + "name": { + "message": "like[0].name is a required field", + "ref": undefined, + "type": "optionality", + "types": { + "optionality": "like[0].name is a required field", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "matches", + "types": { + "matches": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "min": "Must be at least 8 characters in length", + }, + }, + "username": { + "message": "username is a required field", + "ref": { + "name": "username", + }, + "type": "optionality", + "types": { + "optionality": "username is a required field", + }, + }, + }, + "values": {}, +} +`; + +exports[`yupResolver > should return all the errors from yupResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "birthYear": { + "message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).", + "ref": undefined, + "type": "typeError", + "types": { + "typeError": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).", + }, + }, + "like": [ + { + "id": { + "message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).", + "ref": undefined, + "type": "typeError", + "types": { + "typeError": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).", + }, + }, + "name": { + "message": "like[0].name is a required field", + "ref": undefined, + "type": "optionality", + "types": { + "optionality": "like[0].name is a required field", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "matches", + "types": { + "matches": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "min": "Must be at least 8 characters in length", + }, + }, + "username": { + "message": "username is a required field", + "ref": { + "name": "username", + }, + "type": "optionality", + "types": { + "optionality": "username is a required field", + }, + }, + }, + "values": {}, +} +`; + +exports[`yupResolver > should return an error from yupResolver when validation fails and pass down the yup context 1`] = ` +{ + "errors": { + "name": { + "message": "name must be at least 6 characters", + "ref": undefined, + "type": "min", + }, + }, + "values": {}, +} +`; + +exports[`yupResolver > should return correct error message with using yup.test 1`] = ` +{ + "errors": { + "": { + "message": "Email or name are required", + "ref": undefined, + "type": "name", + }, + }, + "values": {}, +} +`; + +exports[`yupResolver > should throw an error without inner property 1`] = ` +{ + "errors": { + "value": { + "message": "value must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`""\`).", + "ref": undefined, + "type": "typeError", + }, + }, + "values": {}, +} +`; diff --git a/node_modules/@hookform/resolvers/yup/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/yup/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..73fd6bc56ba897e18097843106773d505ba8650b --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/__tests__/special-path-names.ts @@ -0,0 +1,21 @@ +import * as yup from 'yup'; +import { yupResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe('yupResolver special path names', () => { + it.each(['hasOwnProperty', 'toString'])( + 'reports a validation error for a field named "%s"', + async (name) => { + const schema = yup.object({ [name]: yup.string().min(1).required() }); + + const result = await yupResolver(schema as any)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors[name]).toBeDefined(); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/yup/src/__tests__/yup.ts b/node_modules/@hookform/resolvers/yup/src/__tests__/yup.ts new file mode 100644 index 0000000000000000000000000000000000000000..246793edbcbd9b8a39142e0d58a0bfc860570344 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/__tests__/yup.ts @@ -0,0 +1,294 @@ +import { renderHook } from '@testing-library/react'; +import { type Resolver, type SubmitHandler, useForm } from 'react-hook-form'; +/* eslint-disable no-console, @typescript-eslint/ban-ts-comment */ +import * as yup from 'yup'; +import { yupResolver } from '..'; +import { + fields, + invalidData, + schema, + schemaWithWhen, + validData, +} from './__fixtures__/data'; + +const shouldUseNativeValidation = false; + +describe('yupResolver', () => { + it('should return values from yupResolver when validation pass', async () => { + const schemaSpy = vi.spyOn(schema, 'validate'); + const schemaSyncSpy = vi.spyOn(schema, 'validateSync'); + + const result = await yupResolver(schema)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(schemaSpy).toHaveBeenCalledTimes(1); + expect(schemaSyncSpy).not.toHaveBeenCalled(); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return values from yupResolver with `mode: sync` when validation pass', async () => { + const validateSyncSpy = vi.spyOn(schema, 'validateSync'); + const validateSpy = vi.spyOn(schema, 'validate'); + + const result = await yupResolver(schema, undefined, { + mode: 'sync', + })(validData, undefined, { fields, shouldUseNativeValidation }); + + expect(validateSyncSpy).toHaveBeenCalledTimes(1); + expect(validateSpy).not.toHaveBeenCalled(); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return a single error from yupResolver when validation fails', async () => { + const result = await yupResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from yupResolver with `mode: sync` when validation fails', async () => { + const validateSyncSpy = vi.spyOn(schema, 'validateSync'); + const validateSpy = vi.spyOn(schema, 'validate'); + + const result = await yupResolver(schema, undefined, { + mode: 'sync', + })(invalidData, undefined, { fields, shouldUseNativeValidation }); + + expect(validateSyncSpy).toHaveBeenCalledTimes(1); + expect(validateSpy).not.toHaveBeenCalled(); + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from yupResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await yupResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from yupResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => { + const result = await yupResolver(schema, undefined, { mode: 'sync' })( + invalidData, + undefined, + { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }, + ); + + expect(result).toMatchSnapshot(); + }); + + it('should return an error from yupResolver when validation fails and pass down the yup context', async () => { + const data = { name: 'eric' }; + const context = { min: true }; + const schemaWithContext = yup.object({ + name: yup + .string() + .required() + .when('$min', ([min], schema) => { + return min ? schema.min(6) : schema; + }), + }); + + const validateSpy = vi.spyOn(schemaWithContext, 'validate'); + + const result = await yupResolver(schemaWithContext)(data, context, { + fields, + shouldUseNativeValidation, + }); + expect(validateSpy).toHaveBeenCalledTimes(1); + expect(validateSpy).toHaveBeenCalledWith( + data, + expect.objectContaining({ + abortEarly: false, + context, + }), + ); + expect(result).toMatchSnapshot(); + }); + + it('should return correct error message with using yup.test', async () => { + const result = await yupResolver( + yup + .object({ + name: yup.string(), + email: yup.string(), + }) + .test( + 'name', + 'Email or name are required', + (value) => !!(value && (value.name || value.email)), + ), + )({ name: '', email: '' }, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it("should merge default yup resolver options with yup's options", async () => { + const validateSpy = vi.spyOn(schema, 'validate'); + + await yupResolver(schema, { stripUnknown: true })(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(validateSpy.mock.calls[0][1]).toEqual( + expect.objectContaining({ stripUnknown: true, abortEarly: false }), + ); + }); + + it('should throw an error without inner property', async () => { + const result = await yupResolver(schemaWithWhen)( + { name: 'test', value: '' }, + undefined, + { + fields, + shouldUseNativeValidation, + }, + ); + + expect(result).toMatchSnapshot(); + }); + + it('should throw any error unrelated to Yup', async () => { + const schemaWithCustomError = schema.transform(() => { + throw Error('custom error'); + }); + const promise = yupResolver(schemaWithCustomError)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + await expect(promise).rejects.toThrow('custom error'); + }); + + it('should return values from yupResolver when validation pass & raw=true', async () => { + const schemaSpy = vi.spyOn(schema, 'validate'); + const schemaSyncSpy = vi.spyOn(schema, 'validateSync'); + + const result = await yupResolver(schema, undefined, { raw: true })( + validData, + undefined, + { + fields, + shouldUseNativeValidation, + }, + ); + + expect(schemaSpy).toHaveBeenCalledTimes(1); + expect(schemaSyncSpy).not.toHaveBeenCalled(); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('shoud validate a lazy schema with success', async () => { + const lazySchema = yup.lazy(() => + yup.object().shape({ firstName: yup.string().optional() }), + ); + + const schemaSpy = vi.spyOn(lazySchema, 'validate'); + const schemaSyncSpy = vi.spyOn(lazySchema, 'validateSync'); + + const result = await yupResolver(lazySchema, undefined)( + { firstName: 'resolver' }, + undefined, + { + fields: { + firstName: { + ref: { name: 'firstName' }, + name: 'firstName', + }, + }, + shouldUseNativeValidation, + }, + ); + + expect(schemaSpy).toHaveBeenCalledTimes(1); + expect(schemaSyncSpy).not.toHaveBeenCalled(); + expect(result).toEqual({ errors: {}, values: { firstName: 'resolver' } }); + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a yup schema', () => { + const resolver = yupResolver(yup.object({ id: yup.number().required() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a yup schema using a transform', () => { + const resolver = yupResolver( + yup.object({ + id: yup + .number() + .required() + .transform((val) => String(val)), + }), + ); + + // Because Yup is not able to infer the output type from the schema with a transform, the output type remains unchanged + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a yup schema for the handleSubmit function in useForm', () => { + const schema = yup.object({ id: yup.number().required() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: yupResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a yup schema with a transform for the handleSubmit function in useForm', () => { + const schema = yup.object({ + id: yup + .number() + .required() + .transform((val) => String(val)), + }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: yupResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + // Because Yup is not able to infer the output type from the schema with a transform, the output type remains unchanged + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/yup/src/index.ts b/node_modules/@hookform/resolvers/yup/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..13c89e6eb059648677c90cb9e787079bb2038828 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/index.ts @@ -0,0 +1 @@ +export * from './yup'; diff --git a/node_modules/@hookform/resolvers/yup/src/yup.ts b/node_modules/@hookform/resolvers/yup/src/yup.ts new file mode 100644 index 0000000000000000000000000000000000000000..16099c14fb6c8988b28ffcd63bddd752f7461061 --- /dev/null +++ b/node_modules/@hookform/resolvers/yup/src/yup.ts @@ -0,0 +1,147 @@ +import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; +import { + FieldError, + FieldValues, + Resolver, + appendErrors, +} from 'react-hook-form'; +import * as Yup from 'yup'; + +/** + * Why `path!` ? because it could be `undefined` in some case + * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string + */ +function parseErrorSchema( + error: Yup.ValidationError, + validateAllFieldCriteria: boolean, +) { + // A null-prototype accumulator avoids false-positive hits from inherited + // members (e.g. `toString`, `constructor`) when a field is named after + // one of them — a plain `{}` would make `!previous[error.path!]` + // truthy-skip those paths and silently drop their errors. + return (error.inner || []).reduce>( + (previous, error) => { + if (!previous[error.path!]) { + previous[error.path!] = { message: error.message, type: error.type! }; + } + + if (validateAllFieldCriteria) { + const types = previous[error.path!].types; + const messages = types && types[error.type!]; + + previous[error.path!] = appendErrors( + error.path!, + validateAllFieldCriteria, + previous, + error.type!, + messages + ? ([] as string[]).concat(messages as string[], error.message) + : error.message, + ) as FieldError; + } + + return previous; + }, + Object.create(null), + ); +} + +export function yupResolver( + schema: + | Yup.ObjectSchema + | ReturnType>>, + schemaOptions?: Parameters<(typeof schema)['validate']>[1], + resolverOptions?: { + mode?: 'async' | 'sync'; + raw?: false; + }, +): Resolver< + Yup.InferType, + Context, + Yup.InferType +>; + +export function yupResolver( + schema: + | Yup.ObjectSchema + | ReturnType>>, + schemaOptions: Parameters<(typeof schema)['validate']>[1] | undefined, + resolverOptions: { + mode?: 'async' | 'sync'; + raw: true; + }, +): Resolver< + Yup.InferType, + Context, + Yup.InferType +>; + +/** + * Creates a resolver for react-hook-form using Yup schema validation + * @param {Yup.ObjectSchema | ReturnType>>} schema - Yup validation schema + * @param {Parameters<(typeof schema)['validate']>[1]} schemaOptions - Options to pass to Yup's validate/validateSync + * @param {Object} resolverOptions - Additional resolver configuration + * @param {('async' | 'sync')} [resolverOptions.mode] - Validation mode + * @param {boolean} [resolverOptions.raw] - If true, returns raw values instead of validated results + * @returns {Resolver | Input>} A resolver function compatible with react-hook-form + * @example + * const schema = Yup.object({ + * name: Yup.string().required(), + * age: Yup.number().required(), + * }); + * + * useForm({ + * resolver: yupResolver(schema) + * }); + */ +export function yupResolver( + schema: + | Yup.ObjectSchema + | ReturnType>>, + schemaOptions?: Parameters<(typeof schema)['validate']>[1], + resolverOptions: { + mode?: 'async' | 'sync'; + raw?: boolean; + } = {}, +): Resolver | Input> { + return async (values: Input, context, options) => { + try { + if (schemaOptions?.context && process.env.NODE_ENV === 'development') { + // eslint-disable-next-line no-console + console.warn( + "You should not used the yup options context. Please, use the 'useForm' context object instead", + ); + } + + const result = await schema[ + resolverOptions.mode === 'sync' ? 'validateSync' : 'validate' + ]( + values, + Object.assign({ abortEarly: false }, schemaOptions, { context }), + ); + + options.shouldUseNativeValidation && validateFieldsNatively({}, options); + + return { + values: resolverOptions.raw ? Object.assign({}, values) : result, + errors: {}, + }; + } catch (e: any) { + if (!e.inner) { + throw e; + } + + return { + values: {}, + errors: toNestErrors( + parseErrorSchema( + e, + !options.shouldUseNativeValidation && + options.criteriaMode === 'all', + ), + options, + ), + }; + } + }; +} diff --git a/node_modules/@hookform/resolvers/zod/dist/index.d.ts b/node_modules/@hookform/resolvers/zod/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6748f26c1284c2247415dc6d8cf2f817beef811c --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/index.d.ts @@ -0,0 +1 @@ +export * from './zod'; diff --git a/node_modules/@hookform/resolvers/zod/dist/zod.d.ts b/node_modules/@hookform/resolvers/zod/dist/zod.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..40ca2a4c54a2117d0aa4b0bcf1c8c83f223eb177 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/zod.d.ts @@ -0,0 +1,53 @@ +import { FieldValues, Resolver } from 'react-hook-form'; +import type * as z3 from 'zod/v3'; +import type * as z4 from 'zod/v4/core'; +type RawResolverOptions = { + mode?: 'async' | 'sync'; + raw: true; +}; +type NonRawResolverOptions = { + mode?: 'async' | 'sync'; + raw?: false; +}; +interface Zod3Type { + _output: O; + _input: I; + _def: object; +} +interface Zod4Type { + _zod: { + output: Output; + input: Input; + }; +} +type IsUnresolved = PropertyKey extends keyof T ? true : false; +type UnresolvedFallback = IsUnresolved extends true ? Fallback : T; +type FallbackIssue = { + code: string; + message: string; + path: (string | number)[]; +}; +type Zod3ParseParams = UnresolvedFallback { + message: string; + }; + async?: boolean; +}>; +type Zod4ParseParams = UnresolvedFallback, { + readonly error?: (iss: FallbackIssue) => null | undefined | string | { + message: string; + }; + readonly reportInput?: boolean; + readonly jitless?: boolean; +}>; +export declare function zodResolver(schema: Zod3Type, schemaOptions?: Zod3ParseParams, resolverOptions?: NonRawResolverOptions): Resolver; +export declare function zodResolver(schema: Zod3Type, schemaOptions: Zod3ParseParams | undefined, resolverOptions: RawResolverOptions): Resolver; +export declare function zodResolver = Zod4Type>(schema: T, schemaOptions?: Zod4ParseParams, // already partial +resolverOptions?: NonRawResolverOptions): Resolver, Context, z4.output>; +export declare function zodResolver = Zod4Type>(schema: Zod4Type, schemaOptions: Zod4ParseParams | undefined, // already partial +resolverOptions: RawResolverOptions): Resolver, Context, z4.input>; +export {}; diff --git a/node_modules/@hookform/resolvers/zod/dist/zod.js b/node_modules/@hookform/resolvers/zod/dist/zod.js new file mode 100644 index 0000000000000000000000000000000000000000..4fc8f6abbc579e1756a1433ba7f02fd08c816edb --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/zod.js @@ -0,0 +1,2 @@ +var r=require("@hookform/resolvers"),e=require("react-hook-form");function n(){return n=Object.assign?Object.assign.bind():function(r){for(var e=1;e0){var l,c,f=s.errors.reduce(function(r,e){return e.length {\n return Array.isArray(error?.issues);\n};\nconst isZod3Schema = (schema: any): schema is z3.ZodSchema => {\n // Deliberately doesn't require `typeName` in `_def` — dynamically selected\n // schemas typed via the generic `z.ZodType` annotation (rather than\n // a concrete subclass like `ZodObject`) don't statically expose `typeName`,\n // even though they're genuine Zod 3 schema instances at runtime.\n return '_def' in schema && typeof schema._def === 'object';\n};\nconst isZod4Error = (error: any): error is z4.$ZodError => {\n // Replicates zod4's own `$ZodError`/`Symbol.hasInstance` check\n // (`inst?._zod?.traits?.has(name)`, see zod's `$constructor` in\n // `v4/core/core.ts`) by hand rather than importing `$ZodError` as a value,\n // since that import only exists in zod@3.25.0+ (see the `import type` note\n // above).\n return !!error?._zod?.traits?.has('$ZodError');\n};\nconst isZod4Schema = (schema: any): schema is z4.$ZodType => {\n return '_zod' in schema && typeof schema._zod === 'object';\n};\n\nfunction parseZod3Issues(\n zodErrors: z3.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`, `__proto__`) when a field is\n // named after one of them — a plain `{}` would make `!errors[_path]`\n // truthy-skip those paths and silently drop their errors.\n const errors: Record = Object.create(null);\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestUnionError = error.unionErrors.reduce(\n (closest, current) =>\n current.errors.length < closest.errors.length ? current : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // member somehow has no issues of its own (shouldn't happen, but\n // avoids ever throwing on an unexpected/malformed union shape).\n const unionError = closestUnionError.errors[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\nfunction parseZod4Issues(\n zodErrors: z4.$ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in `parseZod3Issues` above.\n const errors: Record = Object.create(null);\n // const _zodErrors = zodErrors as z4.$ZodISsue; //\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if (error.code === 'invalid_union' && error.errors.length > 0) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestBranch = error.errors.reduce((closest, branch) =>\n branch.length < closest.length ? branch : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // branch somehow has no issues of its own (shouldn't happen — a\n // 0-issue branch means that branch matched — but this guarantees we\n // never throw on an unexpected/malformed union shape, e.g. a \"no\n // matching discriminator\" issue nested in a way we haven't seen).\n const unionError = closestBranch[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if (error.code === 'invalid_union') {\n error.errors.forEach((unionError) =>\n unionError.forEach((e) =>\n zodErrors.push({ ...e, path: [...error.path, ...e.path] }),\n ),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\ntype RawResolverOptions = {\n mode?: 'async' | 'sync';\n raw: true;\n};\ntype NonRawResolverOptions = {\n mode?: 'async' | 'sync';\n raw?: false;\n};\n\n// minimal interfaces to avoid asssignability issues between versions\ninterface Zod3Type {\n _output: O;\n _input: I;\n _def: object;\n}\n\n// minimal interface to avoid assignability issues between zod v4 patch/minor\n// releases, which brand the full `$ZodType` shape with an exact version literal\n// (e.g. `_zod.version.minor`)\ninterface Zod4Type {\n _zod: {\n output: Output;\n input: Input;\n };\n}\n\n// some type magic to make versions pre-3.25.0 still work\ntype IsUnresolved = PropertyKey extends keyof T ? true : false;\ntype UnresolvedFallback = IsUnresolved extends true\n ? Fallback\n : T;\ntype FallbackIssue = {\n code: string;\n message: string;\n path: (string | number)[];\n};\ntype Zod3ParseParams = UnresolvedFallback<\n z3.ParseParams,\n // fallback if user is on <3.25.0\n {\n path?: (string | number)[];\n errorMap?: (\n iss: FallbackIssue,\n ctx: {\n defaultError: string;\n data: any;\n },\n ) => { message: string };\n async?: boolean;\n }\n>;\ntype Zod4ParseParams = UnresolvedFallback<\n z4.ParseContext,\n // fallback if user is on <3.25.0\n {\n readonly error?: (\n iss: FallbackIssue,\n ) => null | undefined | string | { message: string };\n readonly reportInput?: boolean;\n readonly jitless?: boolean;\n }\n>;\n\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions?: Zod3ParseParams,\n resolverOptions?: NonRawResolverOptions,\n): Resolver;\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions: Zod3ParseParams | undefined,\n resolverOptions: RawResolverOptions,\n): Resolver;\n// the Zod 4 overloads need to be generic for complicated reasons\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: T,\n schemaOptions?: Zod4ParseParams, // already partial\n resolverOptions?: NonRawResolverOptions,\n): Resolver, Context, z4.output>;\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: Zod4Type,\n schemaOptions: Zod4ParseParams | undefined, // already partial\n resolverOptions: RawResolverOptions,\n): Resolver, Context, z4.input>;\n/**\n * Creates a resolver function for react-hook-form that validates form data using a Zod schema\n * @param {z3.ZodSchema} schema - The Zod schema used to validate the form data\n * @param {Partial} [schemaOptions] - Optional configuration options for Zod parsing\n * @param {Object} [resolverOptions] - Optional resolver-specific configuration\n * @param {('async'|'sync')} [resolverOptions.mode='async'] - Validation mode. Use 'sync' for synchronous validation\n * @param {boolean} [resolverOptions.raw=false] - If true, returns the raw form values instead of the parsed data\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @throws {Error} Throws if validation fails with a non-Zod error\n * @example\n * const schema = z3.object({\n * name: z3.string().min(2),\n * age: z3.number().min(18)\n * });\n *\n * useForm({\n * resolver: zodResolver(schema)\n * });\n */\nexport function zodResolver(\n schema: object,\n schemaOptions?: object,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver {\n // Zod 4 is checked first: its `_zod` marker is unambiguous, whereas the\n // Zod 3 check below only requires an object-shaped `_def` (to support\n // dynamically-selected schemas typed via the generic `z.ZodType`\n // annotation, see `isZod3Schema`) — and Zod 4 schemas also have an\n // object-shaped `_def`, so they'd otherwise be misdetected as Zod 3.\n if (isZod4Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n // Call the schema's own bound `parse`/`parseAsync` method rather\n // than the standalone `z4.parse`/`z4.parseAsync` functions. Those\n // standalone functions read from this module's own imported\n // `zod/v4/core`, which — under bundlers that can resolve `zod` and\n // `zod/v4/core` to two distinct module instances (e.g. Metro with\n // package-exports resolution enabled) — may not be the same zod\n // instance the schema was created with, silently dropping any\n // global config (`z.config()`) or locale the app configured on its\n // own zod instance. The schema's own method is always bound to\n // whichever zod instance actually created it.\n const classicSchema = schema as unknown as {\n parse: (values: unknown, schemaOptions: unknown) => unknown;\n parseAsync: (\n values: unknown,\n schemaOptions: unknown,\n ) => Promise;\n };\n const data: any =\n resolverOptions.mode === 'sync'\n ? classicSchema.parse(values, schemaOptions)\n : await classicSchema.parseAsync(values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod4Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod4Issues(\n error.issues,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n if (isZod3Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod3Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod3Issues(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n throw new Error('Invalid input: not a Zod schema');\n}\n"],"names":["parseZod3Issues","zodErrors","validateAllFieldCriteria","errors","Object","create","length","error","code","message","_path","path","join","_unionError$message","_unionError$code","unionError","unionErrors","reduce","closest","current","type","forEach","e","push","types","messages","appendErrors","concat","shift","parseZod4Issues","_loop","_unionError$message2","_unionError$code2","branch","_extends","schema","schemaOptions","resolverOptions","_zod","isZod4Schema","values","_","options","Promise","resolve","_catch","_temp2","data","shouldUseNativeValidation","validateFieldsNatively","raw","assign","classicSchema","_temp","mode","parse","parseAsync","then","_error$_zod","traits","has","isZod4Error","toNestErrors","issues","criteriaMode","reject","_def","isZod3Schema","Array","isArray","isZod3Error","Error"],"mappings":"iXAuCA,SAASA,EACPC,EACAC,GAOA,IADA,IAAMC,EAAqCC,OAAOC,OAAO,MAClDJ,EAAUK,QAAU,CACzB,IAAMC,EAAQN,EAAU,GAChBO,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,KAAK,KAExB,IAAKT,EAAOO,GACV,GAAI,gBAAiBH,EAAO,CAAAM,IAAAA,EAAAC,EAWpBC,EAPoBR,EAAMS,YAAYC,OAC1C,SAACC,EAASC,GACR,OAAAA,EAAQhB,OAAOG,OAASY,EAAQf,OAAOG,OAASa,EAAUD,CAAO,GAKhCf,OAAO,GAE5CA,EAAOO,GAAS,CACdD,QAA4BI,OAArBA,EAAY,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A,aACNjC,EACEtB,EAAMwD,QACLrB,EAAQM,2BACkB,QAAzBN,EAAQsB,cAEZtB,IAKN,MAAMnC,CACR,GACF,CAAC,MAAAe,GAAA,OAAAqB,QAAAsB,OAAA3C,EACH,CAAA,EAEA,GAtUmB,SAACa,GAKpB,MAAO,SAAUA,GAAiC,iBAAhBA,EAAO+B,IAC3C,CAgUMC,CAAahC,GACf,OAAcK,SAAAA,EAAeC,EAAGC,GAAO,IAAIC,OAAAA,QAAAC,QAAAC,aACrCF,OAAAA,QAAAC,QACiBT,EACQ,SAAzBE,EAAgBiB,KAAkB,QAAU,cAC5Cd,EAAQJ,IAAcqB,KAFlBV,SAAAA,GAON,OAHAL,EAAQM,2BACNC,EAAsBA,uBAAC,GAAIP,GAEtB,CACLvC,OAAQ,CAAA,EACRqC,OAAQH,EAAgBa,IAAM9C,OAAO+C,OAAO,CAAA,EAAIX,GAAUO,EAChB,EAC9C,EAASxC,SAAAA,GACP,GAxVY,SAACA,GACnB,OAAO6D,MAAMC,QAAa,MAAL9D,OAAK,EAALA,EAAOwD,OAC9B,CAsVYO,CAAY/D,GACd,MAAO,CACLiC,OAAQ,CAAE,EACVrC,OAAQ2D,EAAYA,aAClB9D,EACEO,EAAMJ,QACLuC,EAAQM,2BACkB,QAAzBN,EAAQsB,cAEZtB,IAKN,MAAMnC,CACR,GACF,CAAC,MAAAe,GAAAqB,OAAAA,QAAAsB,OAAA3C,EAAA,CAAA,EAGH,UAAUiD,MAAM,kCAClB"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/zod/dist/zod.mjs b/node_modules/@hookform/resolvers/zod/dist/zod.mjs new file mode 100644 index 0000000000000000000000000000000000000000..744a5dfa91e581e34dac9d632ecdd8b2e12836f1 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/zod.mjs @@ -0,0 +1,2 @@ +import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{appendErrors as n}from"react-hook-form";function o(){return o=Object.assign?Object.assign.bind():function(r){for(var e=1;e0){var c,l,f=s.errors.reduce(function(r,e){return e.lengthe.errors.lengthe.errors.forEach(e=>r.push(e))),e){const r=s[u].types,n=r&&r[a.code];s[u]=o(u,e,s,i,n?[].concat(n,a.message):a.message)}r.shift()}return s}function t(r,e){const n=Object.create(null);for(;r.length;){const i=r[0],{code:l,message:c,path:u}=i,d=u.join(".");if(!n[d])if("invalid_union"===i.code&&i.errors.length>0){var t,a;const r=i.errors.reduce((r,e)=>e.lengthe.forEach(e=>r.push(s({},e,{path:[...i.path,...e.path]})))),e){const r=n[d].types,s=r&&r[i.code];n[d]=o(d,e,n,l,s?[].concat(s,i.message):i.message)}r.shift()}return n}function a(o,s,a={}){if((r=>"_zod"in r&&"object"==typeof r._zod)(o))return async(n,i,l)=>{try{const e=o,t="sync"===a.mode?e.parse(n,s):await e.parseAsync(n,s);return l.shouldUseNativeValidation&&r({},l),{errors:{},values:a.raw?Object.assign({},n):t}}catch(r){if((r=>{var e;return!(null==r||null==(e=r._zod)||null==(e=e.traits)||!e.has("$ZodError"))})(r))return{values:{},errors:e(t(r.issues,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)};throw r}};if((r=>"_def"in r&&"object"==typeof r._def)(o))return async(t,i,l)=>{try{const e=await o["sync"===a.mode?"parse":"parseAsync"](t,s);return l.shouldUseNativeValidation&&r({},l),{errors:{},values:a.raw?Object.assign({},t):e}}catch(r){if((r=>Array.isArray(null==r?void 0:r.issues))(r))return{values:{},errors:e(n(r.errors,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)};throw r}};throw new Error("Invalid input: not a Zod schema")}export{a as zodResolver}; +//# sourceMappingURL=zod.modern.mjs.map diff --git a/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs.map b/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..03088e74c6cab7261b0cdd73c717254851714a58 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"zod.modern.mjs","sources":["../src/zod.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n ResolverError,\n ResolverSuccess,\n appendErrors,\n} from 'react-hook-form';\n// Type-only: these subpaths don't exist before zod@3.25.0, so importing them\n// as values would break resolution for anyone on an older zod 3.x. `import\n// type` is fully erased at build time, so the compiled output never\n// references these subpaths at runtime — see `isZod4Error` below for how the\n// one runtime check that used to need `z4.$ZodError` avoids that now.\nimport type * as z3 from 'zod/v3';\nimport type * as z4 from 'zod/v4/core';\n\nconst isZod3Error = (error: any): error is z3.ZodError => {\n return Array.isArray(error?.issues);\n};\nconst isZod3Schema = (schema: any): schema is z3.ZodSchema => {\n // Deliberately doesn't require `typeName` in `_def` — dynamically selected\n // schemas typed via the generic `z.ZodType` annotation (rather than\n // a concrete subclass like `ZodObject`) don't statically expose `typeName`,\n // even though they're genuine Zod 3 schema instances at runtime.\n return '_def' in schema && typeof schema._def === 'object';\n};\nconst isZod4Error = (error: any): error is z4.$ZodError => {\n // Replicates zod4's own `$ZodError`/`Symbol.hasInstance` check\n // (`inst?._zod?.traits?.has(name)`, see zod's `$constructor` in\n // `v4/core/core.ts`) by hand rather than importing `$ZodError` as a value,\n // since that import only exists in zod@3.25.0+ (see the `import type` note\n // above).\n return !!error?._zod?.traits?.has('$ZodError');\n};\nconst isZod4Schema = (schema: any): schema is z4.$ZodType => {\n return '_zod' in schema && typeof schema._zod === 'object';\n};\n\nfunction parseZod3Issues(\n zodErrors: z3.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`, `__proto__`) when a field is\n // named after one of them — a plain `{}` would make `!errors[_path]`\n // truthy-skip those paths and silently drop their errors.\n const errors: Record = Object.create(null);\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestUnionError = error.unionErrors.reduce(\n (closest, current) =>\n current.errors.length < closest.errors.length ? current : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // member somehow has no issues of its own (shouldn't happen, but\n // avoids ever throwing on an unexpected/malformed union shape).\n const unionError = closestUnionError.errors[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\nfunction parseZod4Issues(\n zodErrors: z4.$ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in `parseZod3Issues` above.\n const errors: Record = Object.create(null);\n // const _zodErrors = zodErrors as z4.$ZodISsue; //\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if (error.code === 'invalid_union' && error.errors.length > 0) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestBranch = error.errors.reduce((closest, branch) =>\n branch.length < closest.length ? branch : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // branch somehow has no issues of its own (shouldn't happen — a\n // 0-issue branch means that branch matched — but this guarantees we\n // never throw on an unexpected/malformed union shape, e.g. a \"no\n // matching discriminator\" issue nested in a way we haven't seen).\n const unionError = closestBranch[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if (error.code === 'invalid_union') {\n error.errors.forEach((unionError) =>\n unionError.forEach((e) =>\n zodErrors.push({ ...e, path: [...error.path, ...e.path] }),\n ),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\ntype RawResolverOptions = {\n mode?: 'async' | 'sync';\n raw: true;\n};\ntype NonRawResolverOptions = {\n mode?: 'async' | 'sync';\n raw?: false;\n};\n\n// minimal interfaces to avoid asssignability issues between versions\ninterface Zod3Type {\n _output: O;\n _input: I;\n _def: object;\n}\n\n// minimal interface to avoid assignability issues between zod v4 patch/minor\n// releases, which brand the full `$ZodType` shape with an exact version literal\n// (e.g. `_zod.version.minor`)\ninterface Zod4Type {\n _zod: {\n output: Output;\n input: Input;\n };\n}\n\n// some type magic to make versions pre-3.25.0 still work\ntype IsUnresolved = PropertyKey extends keyof T ? true : false;\ntype UnresolvedFallback = IsUnresolved extends true\n ? Fallback\n : T;\ntype FallbackIssue = {\n code: string;\n message: string;\n path: (string | number)[];\n};\ntype Zod3ParseParams = UnresolvedFallback<\n z3.ParseParams,\n // fallback if user is on <3.25.0\n {\n path?: (string | number)[];\n errorMap?: (\n iss: FallbackIssue,\n ctx: {\n defaultError: string;\n data: any;\n },\n ) => { message: string };\n async?: boolean;\n }\n>;\ntype Zod4ParseParams = UnresolvedFallback<\n z4.ParseContext,\n // fallback if user is on <3.25.0\n {\n readonly error?: (\n iss: FallbackIssue,\n ) => null | undefined | string | { message: string };\n readonly reportInput?: boolean;\n readonly jitless?: boolean;\n }\n>;\n\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions?: Zod3ParseParams,\n resolverOptions?: NonRawResolverOptions,\n): Resolver;\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions: Zod3ParseParams | undefined,\n resolverOptions: RawResolverOptions,\n): Resolver;\n// the Zod 4 overloads need to be generic for complicated reasons\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: T,\n schemaOptions?: Zod4ParseParams, // already partial\n resolverOptions?: NonRawResolverOptions,\n): Resolver, Context, z4.output>;\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: Zod4Type,\n schemaOptions: Zod4ParseParams | undefined, // already partial\n resolverOptions: RawResolverOptions,\n): Resolver, Context, z4.input>;\n/**\n * Creates a resolver function for react-hook-form that validates form data using a Zod schema\n * @param {z3.ZodSchema} schema - The Zod schema used to validate the form data\n * @param {Partial} [schemaOptions] - Optional configuration options for Zod parsing\n * @param {Object} [resolverOptions] - Optional resolver-specific configuration\n * @param {('async'|'sync')} [resolverOptions.mode='async'] - Validation mode. Use 'sync' for synchronous validation\n * @param {boolean} [resolverOptions.raw=false] - If true, returns the raw form values instead of the parsed data\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @throws {Error} Throws if validation fails with a non-Zod error\n * @example\n * const schema = z3.object({\n * name: z3.string().min(2),\n * age: z3.number().min(18)\n * });\n *\n * useForm({\n * resolver: zodResolver(schema)\n * });\n */\nexport function zodResolver(\n schema: object,\n schemaOptions?: object,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver {\n // Zod 4 is checked first: its `_zod` marker is unambiguous, whereas the\n // Zod 3 check below only requires an object-shaped `_def` (to support\n // dynamically-selected schemas typed via the generic `z.ZodType`\n // annotation, see `isZod3Schema`) — and Zod 4 schemas also have an\n // object-shaped `_def`, so they'd otherwise be misdetected as Zod 3.\n if (isZod4Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n // Call the schema's own bound `parse`/`parseAsync` method rather\n // than the standalone `z4.parse`/`z4.parseAsync` functions. Those\n // standalone functions read from this module's own imported\n // `zod/v4/core`, which — under bundlers that can resolve `zod` and\n // `zod/v4/core` to two distinct module instances (e.g. Metro with\n // package-exports resolution enabled) — may not be the same zod\n // instance the schema was created with, silently dropping any\n // global config (`z.config()`) or locale the app configured on its\n // own zod instance. The schema's own method is always bound to\n // whichever zod instance actually created it.\n const classicSchema = schema as unknown as {\n parse: (values: unknown, schemaOptions: unknown) => unknown;\n parseAsync: (\n values: unknown,\n schemaOptions: unknown,\n ) => Promise;\n };\n const data: any =\n resolverOptions.mode === 'sync'\n ? classicSchema.parse(values, schemaOptions)\n : await classicSchema.parseAsync(values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod4Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod4Issues(\n error.issues,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n if (isZod3Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod3Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod3Issues(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n throw new Error('Invalid input: not a Zod schema');\n}\n"],"names":["parseZod3Issues","zodErrors","validateAllFieldCriteria","errors","Object","create","length","error","code","message","path","_path","join","_unionError$message","_unionError$code","unionError","unionErrors","reduce","closest","current","type","forEach","e","push","types","messages","appendErrors","concat","shift","parseZod4Issues","_unionError$message2","_unionError$code2","branch","_extends","zodResolver","schema","schemaOptions","resolverOptions","_zod","isZod4Schema","async","values","_","options","classicSchema","data","mode","parse","parseAsync","shouldUseNativeValidation","validateFieldsNatively","raw","assign","_error$_zod","traits","has","isZod4Error","toNestErrors","issues","criteriaMode","_def","isZod3Schema","Array","isArray","isZod3Error","Error"],"mappings":"sVAuCA,SAASA,EACPC,EACAC,GAMA,MAAMC,EAAqCC,OAAOC,OAAO,MACzD,KAAOJ,EAAUK,QAAU,CACzB,MAAMC,EAAQN,EAAU,IAClBO,KAAEA,EAAIC,QAAEA,EAAOC,KAAEA,GAASH,EAC1BI,EAAQD,EAAKE,KAAK,KAExB,IAAKT,EAAOQ,GACV,GAAI,gBAAiBJ,EAAO,CAAAM,IAAAA,EAAAC,EAI1B,MAOMC,EAPoBR,EAAMS,YAAYC,OAC1C,CAACC,EAASC,IACRA,EAAQhB,OAAOG,OAASY,EAAQf,OAAOG,OAASa,EAAUD,GAKzBf,OAAO,GAE5CA,EAAOQ,GAAS,CACdF,QAA4BI,OAArBA,EAAY,MAAVE,OAAU,EAAVA,EAAYN,SAAOI,EAAIJ,EAChCW,KAAsBN,OAAlBA,EAAEC,MAAAA,OAAAA,EAAAA,EAAYP,MAAIM,EAAIN,EAE9B,MACEL,EAAOQ,GAAS,CAAEF,UAASW,KAAMZ,GAUrC,GANI,gBAAiBD,GACnBA,EAAMS,YAAYK,QAASN,GACzBA,EAAWZ,OAAOkB,QAASC,GAAMrB,EAAUsB,KAAKD,KAIhDpB,EAA0B,CAC5B,MAAMsB,EAAQrB,EAAOQ,GAAOa,MACtBC,EAAWD,GAASA,EAAMjB,EAAMC,MAEtCL,EAAOQ,GAASe,EACdf,EACAT,EACAC,EACAK,EACAiB,EACK,GAAgBE,OAAOF,EAAsBlB,EAAME,SACpDF,EAAME,QAEd,CAEAR,EAAU2B,O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hookform/resolvers/zod/dist/zod.module.js new file mode 100644 index 0000000000000000000000000000000000000000..744a5dfa91e581e34dac9d632ecdd8b2e12836f1 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/zod.module.js @@ -0,0 +1,2 @@ +import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{appendErrors as n}from"react-hook-form";function o(){return o=Object.assign?Object.assign.bind():function(r){for(var e=1;e0){var c,l,f=s.errors.reduce(function(r,e){return e.length {\n return Array.isArray(error?.issues);\n};\nconst isZod3Schema = (schema: any): schema is z3.ZodSchema => {\n // Deliberately doesn't require `typeName` in `_def` — dynamically selected\n // schemas typed via the generic `z.ZodType` annotation (rather than\n // a concrete subclass like `ZodObject`) don't statically expose `typeName`,\n // even though they're genuine Zod 3 schema instances at runtime.\n return '_def' in schema && typeof schema._def === 'object';\n};\nconst isZod4Error = (error: any): error is z4.$ZodError => {\n // Replicates zod4's own `$ZodError`/`Symbol.hasInstance` check\n // (`inst?._zod?.traits?.has(name)`, see zod's `$constructor` in\n // `v4/core/core.ts`) by hand rather than importing `$ZodError` as a value,\n // since that import only exists in zod@3.25.0+ (see the `import type` note\n // above).\n return !!error?._zod?.traits?.has('$ZodError');\n};\nconst isZod4Schema = (schema: any): schema is z4.$ZodType => {\n return '_zod' in schema && typeof schema._zod === 'object';\n};\n\nfunction parseZod3Issues(\n zodErrors: z3.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`, `__proto__`) when a field is\n // named after one of them — a plain `{}` would make `!errors[_path]`\n // truthy-skip those paths and silently drop their errors.\n const errors: Record = Object.create(null);\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestUnionError = error.unionErrors.reduce(\n (closest, current) =>\n current.errors.length < closest.errors.length ? current : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // member somehow has no issues of its own (shouldn't happen, but\n // avoids ever throwing on an unexpected/malformed union shape).\n const unionError = closestUnionError.errors[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\nfunction parseZod4Issues(\n zodErrors: z4.$ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in `parseZod3Issues` above.\n const errors: Record = Object.create(null);\n // const _zodErrors = zodErrors as z4.$ZodISsue; //\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if (error.code === 'invalid_union' && error.errors.length > 0) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestBranch = error.errors.reduce((closest, branch) =>\n branch.length < closest.length ? branch : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // branch somehow has no issues of its own (shouldn't happen — a\n // 0-issue branch means that branch matched — but this guarantees we\n // never throw on an unexpected/malformed union shape, e.g. a \"no\n // matching discriminator\" issue nested in a way we haven't seen).\n const unionError = closestBranch[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if (error.code === 'invalid_union') {\n error.errors.forEach((unionError) =>\n unionError.forEach((e) =>\n zodErrors.push({ ...e, path: [...error.path, ...e.path] }),\n ),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\ntype RawResolverOptions = {\n mode?: 'async' | 'sync';\n raw: true;\n};\ntype NonRawResolverOptions = {\n mode?: 'async' | 'sync';\n raw?: false;\n};\n\n// minimal interfaces to avoid asssignability issues between versions\ninterface Zod3Type {\n _output: O;\n _input: I;\n _def: object;\n}\n\n// minimal interface to avoid assignability issues between zod v4 patch/minor\n// releases, which brand the full `$ZodType` shape with an exact version literal\n// (e.g. `_zod.version.minor`)\ninterface Zod4Type {\n _zod: {\n output: Output;\n input: Input;\n };\n}\n\n// some type magic to make versions pre-3.25.0 still work\ntype IsUnresolved = PropertyKey extends keyof T ? true : false;\ntype UnresolvedFallback = IsUnresolved extends true\n ? Fallback\n : T;\ntype FallbackIssue = {\n code: string;\n message: string;\n path: (string | number)[];\n};\ntype Zod3ParseParams = UnresolvedFallback<\n z3.ParseParams,\n // fallback if user is on <3.25.0\n {\n path?: (string | number)[];\n errorMap?: (\n iss: FallbackIssue,\n ctx: {\n defaultError: string;\n data: any;\n },\n ) => { message: string };\n async?: boolean;\n }\n>;\ntype Zod4ParseParams = UnresolvedFallback<\n z4.ParseContext,\n // fallback if user is on <3.25.0\n {\n readonly error?: (\n iss: FallbackIssue,\n ) => null | undefined | string | { message: string };\n readonly reportInput?: boolean;\n readonly jitless?: boolean;\n }\n>;\n\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions?: Zod3ParseParams,\n resolverOptions?: NonRawResolverOptions,\n): Resolver;\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions: Zod3ParseParams | undefined,\n resolverOptions: RawResolverOptions,\n): Resolver;\n// the Zod 4 overloads need to be generic for complicated reasons\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: T,\n schemaOptions?: Zod4ParseParams, // already partial\n resolverOptions?: NonRawResolverOptions,\n): Resolver, Context, z4.output>;\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: Zod4Type,\n schemaOptions: Zod4ParseParams | undefined, // already partial\n resolverOptions: RawResolverOptions,\n): Resolver, Context, z4.input>;\n/**\n * Creates a resolver function for react-hook-form that validates form data using a Zod schema\n * @param {z3.ZodSchema} schema - The Zod schema used to validate the form data\n * @param {Partial} [schemaOptions] - Optional configuration options for Zod parsing\n * @param {Object} [resolverOptions] - Optional resolver-specific configuration\n * @param {('async'|'sync')} [resolverOptions.mode='async'] - Validation mode. Use 'sync' for synchronous validation\n * @param {boolean} [resolverOptions.raw=false] - If true, returns the raw form values instead of the parsed data\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @throws {Error} Throws if validation fails with a non-Zod error\n * @example\n * const schema = z3.object({\n * name: z3.string().min(2),\n * age: z3.number().min(18)\n * });\n *\n * useForm({\n * resolver: zodResolver(schema)\n * });\n */\nexport function zodResolver(\n schema: object,\n schemaOptions?: object,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver {\n // Zod 4 is checked first: its `_zod` marker is unambiguous, whereas the\n // Zod 3 check below only requires an object-shaped `_def` (to support\n // dynamically-selected schemas typed via the generic `z.ZodType`\n // annotation, see `isZod3Schema`) — and Zod 4 schemas also have an\n // object-shaped `_def`, so they'd otherwise be misdetected as Zod 3.\n if (isZod4Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n // Call the schema's own bound `parse`/`parseAsync` method rather\n // than the standalone `z4.parse`/`z4.parseAsync` functions. Those\n // standalone functions read from this module's own imported\n // `zod/v4/core`, which — under bundlers that can resolve `zod` and\n // `zod/v4/core` to two distinct module instances (e.g. Metro with\n // package-exports resolution enabled) — may not be the same zod\n // instance the schema was created with, silently dropping any\n // global config (`z.config()`) or locale the app configured on its\n // own zod instance. The schema's own method is always bound to\n // whichever zod instance actually created it.\n const classicSchema = schema as unknown as {\n parse: (values: unknown, schemaOptions: unknown) => unknown;\n parseAsync: (\n values: unknown,\n schemaOptions: unknown,\n ) => Promise;\n };\n const data: any =\n resolverOptions.mode === 'sync'\n ? classicSchema.parse(values, schemaOptions)\n : await classicSchema.parseAsync(values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod4Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod4Issues(\n error.issues,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n if (isZod3Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod3Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod3Issues(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n throw new Error('Invalid input: not a Zod schema');\n}\n"],"names":["parseZod3Issues","zodErrors","validateAllFieldCriteria","errors","Object","create","length","error","code","message","_path","path","join","_unionError$message","_unionError$code","unionError","unionErrors","reduce","closest","current","type","forEach","e","push","types","messages","appendErrors","concat","shift","parseZod4Issues","_loop","_unionError$message2","_unionError$code2","branch","_extends","zodResolver","schema","schemaOptions","resolverOptions","_zod","isZod4Schema","values","_","options","Promise","resolve","_catch","_temp2","data","shouldUseNativeValidation","validateFieldsNatively","raw","assign","classicSchema","_temp","mode","parse","parseAsync","then","_error$_zod","traits","has","isZod4Error","toNestErrors","issues","criteriaMode","reject","_def","isZod3Schema","Array","isArray","isZod3Error","Error"],"mappings":"6aAuCA,SAASA,EACPC,EACAC,GAOA,IADA,IAAMC,EAAqCC,OAAOC,OAAO,MAClDJ,EAAUK,QAAU,CACzB,IAAMC,EAAQN,EAAU,GAChBO,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,KAAK,KAExB,IAAKT,EAAOO,GACV,GAAI,gBAAiBH,EAAO,CAAAM,IAAAA,EAAAC,EAWpBC,EAPoBR,EAAMS,YAAYC,OAC1C,SAACC,EAASC,GACR,OAAAA,EAAQhB,OAAOG,OAASY,EAAQf,OAAOG,OAASa,EAAUD,CAAO,GAKhCf,OAAO,GAE5CA,EAAOO,GAAS,CACdD,QAA4BI,OAArBA,EAAY,MAAVE,OAAU,EAAVA,EAAYN,SAAOI,EAAIJ,EAChCW,KAAsB,OAAlBN,EAAY,MAAVC,OAAU,EAAVA,EAAYP,MAAIM,EAAIN,EAE9B,MACEL,EAAOO,GAAS,CAAED,QAAAA,EAASW,KAAMZ,GAUrC,GANI,gBAAiBD,GACnBA,EAAMS,YAAYK,QAAQ,SAACN,GAAU,OACnCA,EAAWZ,OAAOkB,QAAQ,SAACC,GAAM,OAAArB,EAAUsB,KAAKD,EAAE,EAAC,GAInDpB,EAA0B,CAC5B,IAAMsB,EAAQrB,EAAOO,GAAOc,MACtBC,EAAWD,GAASA,EAAMjB,EAAMC,MAEtCL,EAAOO,GAASgB,EACdhB,EACAR,EACAC,EACAK,EACAiB,EACK,GAAgBE,OAAOF,EAAsBlB,EAAME,SACpDF,EAAME,QAEd,CAEAR,EAAU2B,OACZ,CAEA,OAAOzB,CACT,CAEA,SAAS0B,EACP5B,EACAC,GAKA,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OAAO8D,MAAMC,QAAa,MAAL/D,OAAK,EAALA,EAAOyD,OAC9B,CAsVYO,CAAYhE,GACd,MAAO,CACLkC,OAAQ,CAAE,EACVtC,OAAQ4D,EACN/D,EACEO,EAAMJ,QACLwC,EAAQM,2BACkB,QAAzBN,EAAQsB,cAEZtB,IAKN,MAAMpC,CACR,GACF,CAAC,MAAAe,GAAAsB,OAAAA,QAAAsB,OAAA5C,EAAA,CAAA,EAGH,UAAUkD,MAAM,kCAClB"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/zod/dist/zod.umd.js b/node_modules/@hookform/resolvers/zod/dist/zod.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..51a863fec841f1af665cc3882a6a439bdca21bba --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/dist/zod.umd.js @@ -0,0 +1,2 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form"],r):r((e||self).hookformResolversZod={},e.hookformResolvers,e.ReactHookForm)}(this,function(e,r,n){function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r0){var l,c,f=s.errors.reduce(function(e,r){return r.length {\n return Array.isArray(error?.issues);\n};\nconst isZod3Schema = (schema: any): schema is z3.ZodSchema => {\n // Deliberately doesn't require `typeName` in `_def` — dynamically selected\n // schemas typed via the generic `z.ZodType` annotation (rather than\n // a concrete subclass like `ZodObject`) don't statically expose `typeName`,\n // even though they're genuine Zod 3 schema instances at runtime.\n return '_def' in schema && typeof schema._def === 'object';\n};\nconst isZod4Error = (error: any): error is z4.$ZodError => {\n // Replicates zod4's own `$ZodError`/`Symbol.hasInstance` check\n // (`inst?._zod?.traits?.has(name)`, see zod's `$constructor` in\n // `v4/core/core.ts`) by hand rather than importing `$ZodError` as a value,\n // since that import only exists in zod@3.25.0+ (see the `import type` note\n // above).\n return !!error?._zod?.traits?.has('$ZodError');\n};\nconst isZod4Schema = (schema: any): schema is z4.$ZodType => {\n return '_zod' in schema && typeof schema._zod === 'object';\n};\n\nfunction parseZod3Issues(\n zodErrors: z3.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // A null-prototype object avoids false-positive hits from inherited\n // members (e.g. `toString`, `constructor`, `__proto__`) when a field is\n // named after one of them — a plain `{}` would make `!errors[_path]`\n // truthy-skip those paths and silently drop their errors.\n const errors: Record = Object.create(null);\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestUnionError = error.unionErrors.reduce(\n (closest, current) =>\n current.errors.length < closest.errors.length ? current : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // member somehow has no issues of its own (shouldn't happen, but\n // avoids ever throwing on an unexpected/malformed union shape).\n const unionError = closestUnionError.errors[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\nfunction parseZod4Issues(\n zodErrors: z4.$ZodIssue[],\n validateAllFieldCriteria: boolean,\n) {\n // See the matching comment in `parseZod3Issues` above.\n const errors: Record = Object.create(null);\n // const _zodErrors = zodErrors as z4.$ZodISsue; //\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if (error.code === 'invalid_union' && error.errors.length > 0) {\n // Surface the error from whichever union member came closest to\n // matching (fewest issues), rather than always the first member —\n // the first member isn't necessarily the one the input was meant for.\n const closestBranch = error.errors.reduce((closest, branch) =>\n branch.length < closest.length ? branch : closest,\n );\n // Fall back to the union issue's own message/code if the closest\n // branch somehow has no issues of its own (shouldn't happen — a\n // 0-issue branch means that branch matched — but this guarantees we\n // never throw on an unexpected/malformed union shape, e.g. a \"no\n // matching discriminator\" issue nested in a way we haven't seen).\n const unionError = closestBranch[0];\n\n errors[_path] = {\n message: unionError?.message ?? message,\n type: unionError?.code ?? code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if (error.code === 'invalid_union') {\n error.errors.forEach((unionError) =>\n unionError.forEach((e) =>\n zodErrors.push({ ...e, path: [...error.path, ...e.path] }),\n ),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n}\n\ntype RawResolverOptions = {\n mode?: 'async' | 'sync';\n raw: true;\n};\ntype NonRawResolverOptions = {\n mode?: 'async' | 'sync';\n raw?: false;\n};\n\n// minimal interfaces to avoid asssignability issues between versions\ninterface Zod3Type {\n _output: O;\n _input: I;\n _def: object;\n}\n\n// minimal interface to avoid assignability issues between zod v4 patch/minor\n// releases, which brand the full `$ZodType` shape with an exact version literal\n// (e.g. `_zod.version.minor`)\ninterface Zod4Type {\n _zod: {\n output: Output;\n input: Input;\n };\n}\n\n// some type magic to make versions pre-3.25.0 still work\ntype IsUnresolved = PropertyKey extends keyof T ? true : false;\ntype UnresolvedFallback = IsUnresolved extends true\n ? Fallback\n : T;\ntype FallbackIssue = {\n code: string;\n message: string;\n path: (string | number)[];\n};\ntype Zod3ParseParams = UnresolvedFallback<\n z3.ParseParams,\n // fallback if user is on <3.25.0\n {\n path?: (string | number)[];\n errorMap?: (\n iss: FallbackIssue,\n ctx: {\n defaultError: string;\n data: any;\n },\n ) => { message: string };\n async?: boolean;\n }\n>;\ntype Zod4ParseParams = UnresolvedFallback<\n z4.ParseContext,\n // fallback if user is on <3.25.0\n {\n readonly error?: (\n iss: FallbackIssue,\n ) => null | undefined | string | { message: string };\n readonly reportInput?: boolean;\n readonly jitless?: boolean;\n }\n>;\n\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions?: Zod3ParseParams,\n resolverOptions?: NonRawResolverOptions,\n): Resolver;\nexport function zodResolver(\n schema: Zod3Type,\n schemaOptions: Zod3ParseParams | undefined,\n resolverOptions: RawResolverOptions,\n): Resolver;\n// the Zod 4 overloads need to be generic for complicated reasons\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: T,\n schemaOptions?: Zod4ParseParams, // already partial\n resolverOptions?: NonRawResolverOptions,\n): Resolver, Context, z4.output>;\nexport function zodResolver<\n Input extends FieldValues,\n Context,\n Output,\n T extends Zod4Type = Zod4Type,\n>(\n schema: Zod4Type,\n schemaOptions: Zod4ParseParams | undefined, // already partial\n resolverOptions: RawResolverOptions,\n): Resolver, Context, z4.input>;\n/**\n * Creates a resolver function for react-hook-form that validates form data using a Zod schema\n * @param {z3.ZodSchema} schema - The Zod schema used to validate the form data\n * @param {Partial} [schemaOptions] - Optional configuration options for Zod parsing\n * @param {Object} [resolverOptions] - Optional resolver-specific configuration\n * @param {('async'|'sync')} [resolverOptions.mode='async'] - Validation mode. Use 'sync' for synchronous validation\n * @param {boolean} [resolverOptions.raw=false] - If true, returns the raw form values instead of the parsed data\n * @returns {Resolver>} A resolver function compatible with react-hook-form\n * @throws {Error} Throws if validation fails with a non-Zod error\n * @example\n * const schema = z3.object({\n * name: z3.string().min(2),\n * age: z3.number().min(18)\n * });\n *\n * useForm({\n * resolver: zodResolver(schema)\n * });\n */\nexport function zodResolver(\n schema: object,\n schemaOptions?: object,\n resolverOptions: {\n mode?: 'async' | 'sync';\n raw?: boolean;\n } = {},\n): Resolver {\n // Zod 4 is checked first: its `_zod` marker is unambiguous, whereas the\n // Zod 3 check below only requires an object-shaped `_def` (to support\n // dynamically-selected schemas typed via the generic `z.ZodType`\n // annotation, see `isZod3Schema`) — and Zod 4 schemas also have an\n // object-shaped `_def`, so they'd otherwise be misdetected as Zod 3.\n if (isZod4Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n // Call the schema's own bound `parse`/`parseAsync` method rather\n // than the standalone `z4.parse`/`z4.parseAsync` functions. Those\n // standalone functions read from this module's own imported\n // `zod/v4/core`, which — under bundlers that can resolve `zod` and\n // `zod/v4/core` to two distinct module instances (e.g. Metro with\n // package-exports resolution enabled) — may not be the same zod\n // instance the schema was created with, silently dropping any\n // global config (`z.config()`) or locale the app configured on its\n // own zod instance. The schema's own method is always bound to\n // whichever zod instance actually created it.\n const classicSchema = schema as unknown as {\n parse: (values: unknown, schemaOptions: unknown) => unknown;\n parseAsync: (\n values: unknown,\n schemaOptions: unknown,\n ) => Promise;\n };\n const data: any =\n resolverOptions.mode === 'sync'\n ? classicSchema.parse(values, schemaOptions)\n : await classicSchema.parseAsync(values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod4Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod4Issues(\n error.issues,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n if (isZod3Schema(schema)) {\n return async (values: Input, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n } satisfies ResolverSuccess;\n } catch (error) {\n if (isZod3Error(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseZod3Issues(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n } satisfies ResolverError;\n }\n\n throw error;\n }\n };\n }\n\n throw new Error('Invalid input: not a Zod schema');\n}\n"],"names":["parseZod3Issues","zodErrors","validateAllFieldCriteria","errors","Object","create","length","error","code","message","_path","path","join","_unionError$message","_unionError$code","unionError","unionErrors","reduce","closest","current","type","forEach","e","push","types","messages","appendErrors","concat","shift","parseZod4Issues","_loop","_unionError$message2","_unionError$code2","branch","_extends","schema","schemaOptions","resolverOptions","_zod","isZod4Schema","values","_","options","Promise","resolve","_catch","_temp2","data","shouldUseNativeValidation","validateFieldsNatively","raw","assign","classicSchema","_temp","mode","parse","parseAsync","then","_error$_zod","traits","has","isZod4Error","toNestErrors","issues","criteriaMode","reject","_def","isZod3Schema","Array","isArray","isZod3Error","Error"],"mappings":"uqBAuCA,SAASA,EACPC,EACAC,GAOA,IADA,IAAMC,EAAqCC,OAAOC,OAAO,MAClDJ,EAAUK,QAAU,CACzB,IAAMC,EAAQN,EAAU,GAChBO,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,KAAK,KAExB,IAAKT,EAAOO,GACV,GAAI,gBAAiBH,EAAO,CAAAM,IAAAA,EAAAC,EAWpBC,EAPoBR,EAAMS,YAAYC,OAC1C,SAACC,EAASC,GACR,OAAAA,EAAQhB,OAAOG,OAASY,EAAQf,OAAOG,OAASa,EAAUD,CAAO,GAKhCf,OAAO,GAE5CA,EAAOO,GAAS,CACdD,QAA4BI,OAArBA,EAAY,MAAVE,OAAU,EAAVA,EAAYN,SAAOI,EAAIJ,EAChCW,KAAsB,OAAlBN,EAAY,MAAVC,OAAU,EAAVA,EAAYP,MAAIM,EAAIN,EAE9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qB,QAAAsB,OAAA3C,EACH,CAAA,EAEA,GAtUmB,SAACa,GAKpB,MAAO,SAAUA,GAAiC,iBAAhBA,EAAO+B,IAC3C,CAgUMC,CAAahC,GACf,OAAcK,SAAAA,EAAeC,EAAGC,GAAO,IAAIC,OAAAA,QAAAC,QAAAC,aACrCF,OAAAA,QAAAC,QACiBT,EACQ,SAAzBE,EAAgBiB,KAAkB,QAAU,cAC5Cd,EAAQJ,IAAcqB,KAFlBV,SAAAA,GAON,OAHAL,EAAQM,2BACNC,EAAsBA,uBAAC,GAAIP,GAEtB,CACLvC,OAAQ,CAAA,EACRqC,OAAQH,EAAgBa,IAAM9C,OAAO+C,OAAO,CAAA,EAAIX,GAAUO,EAChB,EAC9C,EAASxC,SAAAA,GACP,GAxVY,SAACA,GACnB,OAAO6D,MAAMC,QAAa,MAAL9D,OAAK,EAALA,EAAOwD,OAC9B,CAsVYO,CAAY/D,GACd,MAAO,CACLiC,OAAQ,CAAE,EACVrC,OAAQ2D,EAAYA,aAClB9D,EACEO,EAAMJ,QACLuC,EAAQM,2BACkB,QAAzBN,EAAQsB,cAEZtB,IAKN,MAAMnC,CACR,GACF,CAAC,MAAAe,GAAAqB,OAAAA,QAAAsB,OAAA3C,EAAA,CAAA,EAGH,UAAUiD,MAAM,kCAClB"} \ No newline at end of file diff --git a/node_modules/@hookform/resolvers/zod/package.json b/node_modules/@hookform/resolvers/zod/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f415f3c28e2286ac3a443478fcd7cde29e0844f9 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/package.json @@ -0,0 +1,18 @@ +{ + "name": "@hookform/resolvers/zod", + "amdName": "hookformResolversZod", + "version": "1.0.0", + "private": true, + "description": "React Hook Form validation resolver: zod", + "main": "dist/zod.js", + "module": "dist/zod.module.js", + "umd:main": "dist/zod.umd.js", + "source": "src/index.ts", + "types": "dist/index.d.ts", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.55.0", + "@hookform/resolvers": "^2.0.0", + "zod": "^3.25.0 || ^4.0.0" + } +} diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/Form-native-validation.tsx b/node_modules/@hookform/resolvers/zod/src/__tests__/Form-native-validation.tsx new file mode 100644 index 0000000000000000000000000000000000000000..68957de077c316394d85fdb4f3ab9f9a693000cd --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/Form-native-validation.tsx @@ -0,0 +1,81 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod/v3'; +import { zodResolver } from '..'; + +const USERNAME_REQUIRED_MESSAGE = 'username field is required'; +const PASSWORD_REQUIRED_MESSAGE = 'password field is required'; + +const schema = z.object({ + username: z.string().nonempty({ message: USERNAME_REQUIRED_MESSAGE }), + password: z.string().nonempty({ message: PASSWORD_REQUIRED_MESSAGE }), +}); + +type FormData = z.infer; + +interface Props { + onSubmit: (data: FormData) => void; +} + +function TestComponent({ onSubmit }: Props) { + const { register, handleSubmit } = useForm({ + resolver: zodResolver(schema), + shouldUseNativeValidation: true, + }); + + return ( +
+ + + + + +
+ ); +} + +test("form's native validation with Zod", async () => { + const handleSubmit = vi.fn(); + render(); + + // username + let usernameField = screen.getByPlaceholderText( + /username/i, + ) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + let passwordField = screen.getByPlaceholderText( + /password/i, + ) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); + + await user.click(screen.getByText(/submit/i)); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(false); + expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(false); + expect(passwordField.validationMessage).toBe(PASSWORD_REQUIRED_MESSAGE); + + await user.type(screen.getByPlaceholderText(/username/i), 'joe'); + await user.type(screen.getByPlaceholderText(/password/i), 'password'); + + // username + usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement; + expect(usernameField.validity.valid).toBe(true); + expect(usernameField.validationMessage).toBe(''); + + // password + passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement; + expect(passwordField.validity.valid).toBe(true); + expect(passwordField.validationMessage).toBe(''); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/Form.tsx b/node_modules/@hookform/resolvers/zod/src/__tests__/Form.tsx new file mode 100644 index 0000000000000000000000000000000000000000..d766924c10d3c0d65433e3df14df37ae494d28a2 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/Form.tsx @@ -0,0 +1,48 @@ +import { render, screen } from '@testing-library/react'; +import user from '@testing-library/user-event'; +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod/v3'; +import { zodResolver } from '..'; + +const schema = z.object({ + username: z.string().nonempty({ message: 'username field is required' }), + password: z.string().nonempty({ message: 'password field is required' }), +}); + +function TestComponent({ + onSubmit, +}: { onSubmit: (data: z.infer) => void }) { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: zodResolver(schema), // Useful to check TypeScript regressions + }); + + return ( +
+ + {errors.username && {errors.username.message}} + + + {errors.password && {errors.password.message}} + + +
+ ); +} + +test("form's validation with Zod and TypeScript's integration", async () => { + const handleSubmit = vi.fn(); + render(); + + expect(screen.queryAllByRole('alert')).toHaveLength(0); + + await user.click(screen.getByText(/submit/i)); + + expect(screen.getByText(/username field is required/i)).toBeInTheDocument(); + expect(screen.getByText(/password field is required/i)).toBeInTheDocument(); + expect(handleSubmit).not.toHaveBeenCalled(); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v3.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..4904ce2c054daa20ebeb7246de264a0673704eda --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v3.ts @@ -0,0 +1,88 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import { z } from 'zod/v3'; + +export const schema = z + .object({ + username: z.string().regex(/^\w+$/).min(3).max(30), + password: z + .string() + .regex(new RegExp('.*[A-Z].*'), 'One uppercase character') + .regex(new RegExp('.*[a-z].*'), 'One lowercase character') + .regex(new RegExp('.*\\d.*'), 'One number') + .regex( + new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), + 'One special character', + ) + .min(8, 'Must be at least 8 characters in length'), + repeatPassword: z.string(), + accessToken: z.union([z.string(), z.number()]), + birthYear: z.number().min(1900).max(2013).optional(), + email: z.string().email().optional(), + tags: z.array(z.string()), + enabled: z.boolean(), + url: z.string().url('Custom error url').or(z.literal('')), + like: z + .array( + z.object({ + id: z.number(), + name: z.string().length(4), + }), + ) + .optional(), + dateStr: z + .string() + .transform((value) => new Date(value)) + .refine((value) => !isNaN(value.getTime()), { + message: 'Invalid date', + }), + }) + .refine((obj) => obj.password === obj.repeatPassword, { + message: 'Passwords do not match', + path: ['confirm'], + }); + +export const validData = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + url: 'https://react-hook-form.com/', + like: [ + { + id: 1, + name: 'name', + }, + ], + dateStr: '2020-01-01', +} satisfies z.input; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], + url: 'abc', +} as unknown as z.input; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v4-mini.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v4-mini.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6ebb23e8cede8dc535c9a67c25cc780ad58a21d --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v4-mini.ts @@ -0,0 +1,112 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import { z } from 'zod/v4-mini'; + +export const schema = z + .object({ + username: z + .string() + .check(z.regex(/^\w+$/), z.minLength(3), z.maxLength(30)), + password: z + .string() + .check( + z.regex(new RegExp('.*[A-Z].*'), 'One uppercase character'), + z.regex(new RegExp('.*[a-z].*'), 'One lowercase character'), + z.regex(new RegExp('.*\\d.*'), 'One number'), + z.regex( + new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), + 'One special character', + ), + z.minLength(8, 'Must be at least 8 characters in length'), + ), + repeatPassword: z.string(), + accessToken: z.union([z.string(), z.number()]), + birthYear: z.optional(z.number().check(z.minimum(1900), z.maximum(2013))), + email: z.optional(z.email()), + tags: z.array(z.string()), + enabled: z.boolean(), + url: z.union([z.url('Custom error url'), z.literal('')]), + like: z.optional( + z.array( + z.object({ + id: z.number(), + name: z.string().check(z.length(4)), + }), + ), + ), + dateStr: z + .pipe( + z.string(), + z.transform((value) => new Date(value)), + ) + .check( + z.refine((value) => !isNaN(value.getTime()), { + message: 'Invalid date', + }), + ), + auth: z.discriminatedUnion('type', [ + z.object({ + type: z.literal('registered'), + passwordHash: z.string(), + }), + z.object({ + type: z.literal('guest'), + }), + ]), + }) + .check( + z.refine((obj) => obj.password === obj.repeatPassword, { + message: 'Passwords do not match', + path: ['confirm'], + }), + ); + +export const validData = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + url: 'https://react-hook-form.com/', + like: [ + { + id: 1, + name: 'name', + }, + ], + dateStr: '2020-01-01', + auth: { + type: 'registered', + passwordHash: 'hash', + }, +} satisfies z.input; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], + url: 'abc', + auth: { type: 'invalid' }, +} as unknown as z.input; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v4.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v4.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c6f55f01dc053e51dd18e7e85107f4f814e8656 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data-v4.ts @@ -0,0 +1,89 @@ +import { Field, InternalFieldName } from 'react-hook-form'; +import { z } from 'zod/v4'; + +export const schema = z + .object({ + username: z.string().regex(/^\w+$/).min(3).max(30), + password: z + .string() + .regex(new RegExp('.*[A-Z].*'), 'One uppercase character') + .regex(new RegExp('.*[a-z].*'), 'One lowercase character') + .regex(new RegExp('.*\\d.*'), 'One number') + .regex( + new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), + 'One special character', + ) + .min(8, 'Must be at least 8 characters in length'), + repeatPassword: z.string(), + accessToken: z.union([z.string(), z.number()]), + birthYear: z.number().min(1900).max(2013).optional(), + email: z.string().email().optional(), + tags: z.array(z.string()), + + enabled: z.boolean(), + url: z.string().url('Custom error url').or(z.literal('')), + like: z + .array( + z.object({ + id: z.number(), + name: z.string().length(4), + }), + ) + .optional(), + dateStr: z + .string() + .transform((value) => new Date(value)) + .refine((value) => !isNaN(value.getTime()), { + message: 'Invalid date', + }), + }) + .refine((obj) => obj.password === obj.repeatPassword, { + message: 'Passwords do not match', + path: ['confirm'], + }); + +export const validData = { + username: 'Doe', + password: 'Password123_', + repeatPassword: 'Password123_', + birthYear: 2000, + email: 'john@doe.com', + tags: ['tag1', 'tag2'], + enabled: true, + accessToken: 'accessToken', + url: 'https://react-hook-form.com/', + like: [ + { + id: 1, + name: 'name', + }, + ], + dateStr: '2020-01-01', +} satisfies z.input; + +export const invalidData = { + password: '___', + email: '', + birthYear: 'birthYear', + like: [{ id: 'z' }], + url: 'abc', +} as unknown as z.input; + +export const fields: Record = { + username: { + ref: { name: 'username' }, + name: 'username', + }, + password: { + ref: { name: 'password' }, + name: 'password', + }, + email: { + ref: { name: 'email' }, + name: 'email', + }, + birthday: { + ref: { name: 'birthday' }, + name: 'birthday', + }, +}; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v3.ts.snap b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v3.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..169a9bfebb0a58e90666b6b0b251fbbca36765df --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v3.ts.snap @@ -0,0 +1,430 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`zodResolver > should return a single error from zodResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return a single error from zodResolver with \`mode: sync\` when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Required", + "Required", + ], + "invalid_union": "Invalid input", + }, + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + "types": { + "invalid_string": "Invalid email", + }, + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + "types": { + "invalid_string": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + "types": { + "invalid_string": "Custom error url", + }, + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Required", + "Required", + ], + "invalid_union": "Invalid input", + }, + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + "types": { + "invalid_string": "Invalid email", + }, + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + "types": { + "invalid_string": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + "types": { + "invalid_string": "Custom error url", + }, + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return parsed values from zodResolver with \`mode: sync\` when validation pass 1`] = ` +{ + "errors": {}, + "values": { + "accessToken": "accessToken", + "birthYear": 2000, + "dateStr": 2020-01-01T00:00:00.000Z, + "email": "john@doe.com", + "enabled": true, + "like": [ + { + "id": 1, + "name": "name", + }, + ], + "password": "Password123_", + "repeatPassword": "Password123_", + "tags": [ + "tag1", + "tag2", + ], + "url": "https://react-hook-form.com/", + "username": "Doe", + }, +} +`; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v4-mini.ts.snap b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v4-mini.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..4788e7a36d63702d465bf8d22c059ff60caf31b3 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v4-mini.ts.snap @@ -0,0 +1,472 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`zodResolver > should return a single error from zodResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "auth": { + "type": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_union", + }, + }, + "birthYear": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid input", + "ref": { + "name": "email", + }, + "type": "invalid_format", + }, + "enabled": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + }, + "repeatPassword": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + }, + "username": { + "message": "Invalid input", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return a single error from zodResolver with \`mode: sync\` when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "auth": { + "type": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_union", + }, + }, + "birthYear": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid input", + "ref": { + "name": "email", + }, + "type": "invalid_format", + }, + "enabled": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + }, + "repeatPassword": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + }, + "username": { + "message": "Invalid input", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Invalid input", + "Invalid input", + ], + "invalid_union": "Invalid input", + }, + }, + "auth": { + "type": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_union", + "types": { + "invalid_union": "Invalid input", + }, + }, + }, + "birthYear": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "dateStr": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "email": { + "message": "Invalid input", + "ref": { + "name": "email", + }, + "type": "invalid_format", + "types": { + "invalid_format": "Invalid input", + }, + }, + "enabled": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "like": [ + { + "id": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "name": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + "types": { + "invalid_format": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "tags": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + "types": { + "invalid_format": "Custom error url", + "invalid_union": "Invalid input", + "invalid_value": "Invalid input", + }, + }, + "username": { + "message": "Invalid input", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Invalid input", + "Invalid input", + ], + "invalid_union": "Invalid input", + }, + }, + "auth": { + "type": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_union", + "types": { + "invalid_union": "Invalid input", + }, + }, + }, + "birthYear": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "dateStr": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "email": { + "message": "Invalid input", + "ref": { + "name": "email", + }, + "type": "invalid_format", + "types": { + "invalid_format": "Invalid input", + }, + }, + "enabled": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "like": [ + { + "id": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "name": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + "types": { + "invalid_format": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "tags": { + "message": "Invalid input", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + "types": { + "invalid_format": "Custom error url", + "invalid_union": "Invalid input", + "invalid_value": "Invalid input", + }, + }, + "username": { + "message": "Invalid input", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return parsed values from zodResolver with \`mode: sync\` when validation pass 1`] = ` +{ + "errors": {}, + "values": { + "accessToken": "accessToken", + "auth": { + "passwordHash": "hash", + "type": "registered", + }, + "birthYear": 2000, + "dateStr": 2020-01-01T00:00:00.000Z, + "email": "john@doe.com", + "enabled": true, + "like": [ + { + "id": 1, + "name": "name", + }, + ], + "password": "Password123_", + "repeatPassword": "Password123_", + "tags": [ + "tag1", + "tag2", + ], + "url": "https://react-hook-form.com/", + "username": "Doe", + }, +} +`; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v4.ts.snap b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v4.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..c2c74e71802ad19b7465170ee268e4501d6b25dd --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod-v4.ts.snap @@ -0,0 +1,434 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`zodResolver > should return a single error from zodResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "birthYear": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "invalid_format", + }, + "enabled": { + "message": "Invalid input: expected boolean, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + }, + "repeatPassword": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Invalid input: expected array, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + }, + "username": { + "message": "Invalid input: expected string, received undefined", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return a single error from zodResolver with \`mode: sync\` when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "birthYear": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "invalid_format", + }, + "enabled": { + "message": "Invalid input: expected boolean, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + }, + "repeatPassword": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Invalid input: expected array, received undefined", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + }, + "username": { + "message": "Invalid input: expected string, received undefined", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Invalid input: expected string, received undefined", + "Invalid input: expected number, received undefined", + ], + "invalid_union": "Invalid input", + }, + }, + "birthYear": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected number, received string", + }, + }, + "dateStr": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "invalid_format", + "types": { + "invalid_format": "Invalid email address", + }, + }, + "enabled": { + "message": "Invalid input: expected boolean, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected boolean, received undefined", + }, + }, + "like": [ + { + "id": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected number, received string", + }, + }, + "name": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + "types": { + "invalid_format": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + "tags": { + "message": "Invalid input: expected array, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected array, received undefined", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + "types": { + "invalid_format": "Custom error url", + "invalid_union": "Invalid input", + "invalid_value": "Invalid input: expected """, + }, + }, + "username": { + "message": "Invalid input: expected string, received undefined", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Invalid input: expected string, received undefined", + "Invalid input: expected number, received undefined", + ], + "invalid_union": "Invalid input", + }, + }, + "birthYear": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected number, received string", + }, + }, + "dateStr": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + "email": { + "message": "Invalid email address", + "ref": { + "name": "email", + }, + "type": "invalid_format", + "types": { + "invalid_format": "Invalid email address", + }, + }, + "enabled": { + "message": "Invalid input: expected boolean, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected boolean, received undefined", + }, + }, + "like": [ + { + "id": { + "message": "Invalid input: expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected number, received string", + }, + }, + "name": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_format", + "types": { + "invalid_format": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Invalid input: expected string, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + "tags": { + "message": "Invalid input: expected array, received undefined", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected array, received undefined", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_format", + "types": { + "invalid_format": "Custom error url", + "invalid_union": "Invalid input", + "invalid_value": "Invalid input: expected """, + }, + }, + "username": { + "message": "Invalid input: expected string, received undefined", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Invalid input: expected string, received undefined", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return parsed values from zodResolver with \`mode: sync\` when validation pass 1`] = ` +{ + "errors": {}, + "values": { + "accessToken": "accessToken", + "birthYear": 2000, + "dateStr": 2020-01-01T00:00:00.000Z, + "email": "john@doe.com", + "enabled": true, + "like": [ + { + "id": 1, + "name": "name", + }, + ], + "password": "Password123_", + "repeatPassword": "Password123_", + "tags": [ + "tag1", + "tag2", + ], + "url": "https://react-hook-form.com/", + "username": "Doe", + }, +} +`; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod.ts.snap b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..169a9bfebb0a58e90666b6b0b251fbbca36765df --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod.ts.snap @@ -0,0 +1,430 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`zodResolver > should return a single error from zodResolver when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return a single error from zodResolver with \`mode: sync\` when validation fails 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Required", + "Required", + ], + "invalid_union": "Invalid input", + }, + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + "types": { + "invalid_string": "Invalid email", + }, + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + "types": { + "invalid_string": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + "types": { + "invalid_string": "Custom error url", + }, + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = ` +{ + "errors": { + "accessToken": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": [ + "Required", + "Required", + ], + "invalid_union": "Invalid input", + }, + }, + "birthYear": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "dateStr": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "email": { + "message": "Invalid email", + "ref": { + "name": "email", + }, + "type": "invalid_string", + "types": { + "invalid_string": "Invalid email", + }, + }, + "enabled": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "like": [ + { + "id": { + "message": "Expected number, received string", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Expected number, received string", + }, + }, + "name": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + ], + "password": { + "message": "One uppercase character", + "ref": { + "name": "password", + }, + "type": "invalid_string", + "types": { + "invalid_string": [ + "One uppercase character", + "One lowercase character", + "One number", + ], + "too_small": "Must be at least 8 characters in length", + }, + }, + "repeatPassword": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "tags": { + "message": "Required", + "ref": undefined, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + "url": { + "message": "Custom error url", + "ref": undefined, + "type": "invalid_string", + "types": { + "invalid_string": "Custom error url", + }, + }, + "username": { + "message": "Required", + "ref": { + "name": "username", + }, + "type": "invalid_type", + "types": { + "invalid_type": "Required", + }, + }, + }, + "values": {}, +} +`; + +exports[`zodResolver > should return parsed values from zodResolver with \`mode: sync\` when validation pass 1`] = ` +{ + "errors": {}, + "values": { + "accessToken": "accessToken", + "birthYear": 2000, + "dateStr": 2020-01-01T00:00:00.000Z, + "email": "john@doe.com", + "enabled": true, + "like": [ + { + "id": 1, + "name": "name", + }, + ], + "password": "Password123_", + "repeatPassword": "Password123_", + "tags": [ + "tag1", + "tag2", + ], + "url": "https://react-hook-form.com/", + "username": "Doe", + }, +} +`; diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/special-path-names.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/special-path-names.ts new file mode 100644 index 0000000000000000000000000000000000000000..db5b9607255061f379a9303c115fae6568f000e7 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/special-path-names.ts @@ -0,0 +1,55 @@ +import { z as z3 } from 'zod/v3'; +import { z as z4 } from 'zod/v4'; +import { zodResolver } from '..'; + +const shouldUseNativeValidation = false; + +describe.each([ + { version: 'v3', z: z3 as unknown as typeof z4 }, + { version: 'v4', z: z4 }, +])('zodResolver special path names ($version)', ({ z }) => { + // These names are inherited (truthy) members of `Object.prototype`, so a + // resolver that tracks seen paths via a plain `{}` map and `!errors[path]` + // would treat them as "already recorded" and drop the real error. + it.each(['toString', 'hasOwnProperty'])( + 'reports a validation error for a field named "%s"', + async (name) => { + const schema = z.object({ [name]: z.string().min(1) }); + + const direct = schema.safeParse({ [name]: '' }); + expect(direct.success).toBe(false); + + const result = await zodResolver(schema)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors[name]).toMatchObject({ type: 'too_small' }); + }, + ); + + // `__proto__`, `constructor`, and `prototype` are also inherited/special + // members, but even once the resolver stops mis-tracking them internally, + // react-hook-form's own `set`/`get` helpers refuse to write those path + // segments at all (they hard-code them as a protected-path list to guard + // against prototype pollution). So these remain dropped end-to-end — that + // part of the behavior lives in react-hook-form, not in this resolver. + it.each(['__proto__', 'constructor', 'prototype'])( + 'still drops a field named "%s" (react-hook-form protected path)', + async (name) => { + const schema = z.object({ [name]: z.string().min(1) }); + + const direct = schema.safeParse({ [name]: '' }); + expect(direct.success).toBe(false); + + const result = await zodResolver(schema)( + { [name]: '' } as any, + undefined, + { fields: {}, shouldUseNativeValidation } as any, + ); + + expect(result.errors).toEqual({}); + }, + ); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/subpath-imports.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/subpath-imports.ts new file mode 100644 index 0000000000000000000000000000000000000000..6fd4060732a1b605ffc2c2d77ac1979ba1067b12 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/subpath-imports.ts @@ -0,0 +1,16 @@ +import { readFileSync } from 'fs'; +import { join } from 'path'; + +// `zod/v3` and `zod/v4/core` don't exist before zod@3.25.0. Importing either +// as a value (rather than `import type`) makes the compiled output reference +// that subpath at runtime, which breaks module resolution for anyone on an +// older zod 3.x — even if they never touch the zod4 code path (#811). +test('zod/v3 and zod/v4/core are only ever imported as types', () => { + const source = readFileSync(join(__dirname, '..', 'zod.ts'), 'utf8'); + + const v3Import = source.match(/^import .*'zod\/v3';$/m)?.[0]; + const v4Import = source.match(/^import .*'zod\/v4\/core';$/m)?.[0]; + + expect(v3Import).toMatch(/^import type /); + expect(v4Import).toMatch(/^import type /); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v3.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..8419a3e9859427dcc3a8f50e971d4d46d457f3ab --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v3.ts @@ -0,0 +1,240 @@ +import { renderHook } from '@testing-library/react'; +import { Resolver, SubmitHandler, useForm } from 'react-hook-form'; +import { z } from 'zod/v3'; +import { zodResolver } from '..'; +import { fields, invalidData, schema, validData } from './__fixtures__/data-v3'; + +const shouldUseNativeValidation = false; + +describe('zodResolver', () => { + it('should return values from zodResolver when validation pass & raw=true', async () => { + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + raw: true, + })(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(parseAsyncSpy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return parsed values from zodResolver with `mode: sync` when validation pass', async () => { + const parseSpy = vi.spyOn(schema, 'parse'); + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + mode: 'sync', + })(validData, undefined, { fields, shouldUseNativeValidation }); + + expect(parseSpy).toHaveBeenCalledTimes(1); + expect(parseAsyncSpy).not.toHaveBeenCalled(); + expect(result.errors).toEqual({}); + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from zodResolver when validation fails', async () => { + const result = await zodResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from zodResolver with `mode: sync` when validation fails', async () => { + const parseSpy = vi.spyOn(schema, 'parse'); + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + mode: 'sync', + })(invalidData, undefined, { fields, shouldUseNativeValidation }); + + expect(parseSpy).toHaveBeenCalledTimes(1); + expect(parseAsyncSpy).not.toHaveBeenCalled(); + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await zodResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => { + const result = await zodResolver(schema, undefined, { mode: 'sync' })( + invalidData, + undefined, + { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }, + ); + + expect(result).toMatchSnapshot(); + }); + + it('should surface the error from the union member closest to matching, not just the first member', async () => { + const branchWithMoreIssues = z.object({ + id: z.number({ invalid_type_error: 'id wrong (branch B)' }), + name: z.number({ invalid_type_error: 'name wrong (branch B)' }), + }); + const branchWithFewerIssues = z.object({ + id: z.string(), + name: z.number({ + invalid_type_error: 'name wrong (branch A, closer match)', + }), + }); + // branchWithMoreIssues is listed first, but only branchWithFewerIssues + // actually comes close to matching the input (it only fails on `name`). + const unionSchema = z.object({ + target: z.union([branchWithMoreIssues, branchWithFewerIssues]), + }); + + const result = await zodResolver(unionSchema)( + { target: { id: 'abc', name: 'xyz' } } as unknown as z.input< + typeof unionSchema + >, + undefined, + { fields: {}, shouldUseNativeValidation }, + ); + + expect(result.errors).toMatchObject({ + target: { message: 'name wrong (branch A, closer match)' }, + }); + }); + + it('should throw any error unrelated to Zod', async () => { + const schemaWithCustomError = schema.refine(() => { + throw Error('custom error'); + }); + const promise = zodResolver(schemaWithCustomError)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + await expect(promise).rejects.toThrow('custom error'); + }); + + it('should enforce parse params type signature', async () => { + const resolver = zodResolver(schema, { + async: true, + path: ['asdf', 1234], + errorMap(iss, ctx) { + iss.path; + iss.code; + iss.path; + ctx.data; + ctx.defaultError; + return { message: 'asdf' }; + }, + }); + + resolver; + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a zod schema', () => { + const resolver = zodResolver(z.object({ id: z.number() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a zod schema using a transform', () => { + const resolver = zodResolver( + z.object({ id: z.number().transform((val) => String(val)) }), + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a zod schema when a different input type is specified', () => { + const schema = z.object({ id: z.number() }).transform(({ id }) => { + return { id: String(id) }; + }); + + const resolver = zodResolver<{ id: number }, any, z.output>( + schema, + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, any, { id: string }> + >(); + }); + + it('should correctly infer the output type from a Zod schema for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: zodResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a Zod schema with a transform for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number().transform((val) => String(val)) }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: zodResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); + + it('should accept a dynamically selected schema typed via the generic z.ZodType annotation', async () => { + // https://github.com/react-hook-form/resolvers/issues/782 — schemas + // chosen conditionally between two shapes and annotated with the base + // `z.ZodType` (rather than a concrete subclass like `ZodObject`) + // don't statically expose `_def.typeName`, even though they're genuine + // Zod 3 schema instances at runtime. + const updateSchema = z.object({ id: z.string(), name: z.string() }); + const createSchema = z.object({ name: z.string() }); + const useUpdateSchema = true; + const dynamicSchema = ( + useUpdateSchema ? updateSchema : createSchema + ) as z.ZodType<{ name: string }>; + + const resolver = zodResolver(dynamicSchema); + + const result = await resolver({ id: '1', name: 'John' } as any, undefined, { + fields: {}, + shouldUseNativeValidation, + }); + + expect(result.errors).toEqual({}); + }); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v4-mini.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v4-mini.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a0446b6f1641da423625833ba5e1a1b473b92d4 --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v4-mini.ts @@ -0,0 +1,191 @@ +import { renderHook } from '@testing-library/react'; +import { Resolver, SubmitHandler, useForm } from 'react-hook-form'; +import { z } from 'zod/v4-mini'; +import { zodResolver } from '..'; +import { + fields, + invalidData, + schema, + validData, +} from './__fixtures__/data-v4-mini'; + +const shouldUseNativeValidation = false; + +describe('zodResolver', () => { + it('should return values from zodResolver when validation pass & raw=true', async () => { + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + raw: true, + })(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + result; + + expect(parseAsyncSpy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ errors: {}, values: validData }); + expectTypeOf(result.values); + }); + + it('should return parsed values from zodResolver with `mode: sync` when validation pass', async () => { + const parseSpy = vi.spyOn(schema, 'parse'); + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + mode: 'sync', + })(validData, undefined, { fields, shouldUseNativeValidation }); + expect(parseSpy).toHaveBeenCalledTimes(1); + expect(parseAsyncSpy).not.toHaveBeenCalled(); + expect(result.errors).toEqual({}); + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from zodResolver when validation fails', async () => { + const result = await zodResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from zodResolver with `mode: sync` when validation fails', async () => { + const parseSpy = vi.spyOn(schema, 'parse'); + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + mode: 'sync', + })(invalidData, undefined, { fields, shouldUseNativeValidation }); + + expect(parseSpy).toHaveBeenCalledTimes(1); + expect(parseAsyncSpy).not.toHaveBeenCalled(); + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await zodResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => { + const result = await zodResolver(schema, undefined, { mode: 'sync' })( + invalidData, + undefined, + { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }, + ); + + expect(result).toMatchSnapshot(); + }); + + it('should throw any error unrelated to Zod', async () => { + const schemaWithCustomError = schema.check( + z.refine(() => { + throw Error('custom error'); + }), + ); + const promise = zodResolver(schemaWithCustomError)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + await expect(promise).rejects.toThrow('custom error'); + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a zod schema', () => { + const resolver = zodResolver(z.object({ id: z.number() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a zod schema using a transform', () => { + const resolver = zodResolver( + z.object({ + id: z.pipe( + z.number(), + z.transform((val) => String(val)), + ), + }), + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a zod schema when a different input type is specified', () => { + const schema = z.pipe( + z.object({ id: z.number() }), + z.transform(({ id }) => { + return { id: String(id) }; + }), + ); + + const resolver = zodResolver<{ id: number }, any, z.output>( + schema, + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, any, { id: string }> + >(); + }); + + it('should correctly infer the output type from a Zod schema for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: zodResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a Zod schema with a transform for the handleSubmit function in useForm', () => { + const schema = z.object({ + id: z.pipe( + z.number(), + z.transform((val) => String(val)), + ), + }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: zodResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v4.ts b/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v4.ts new file mode 100644 index 0000000000000000000000000000000000000000..df4e6786d4d672466369c0a2062294bd228016cb --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/__tests__/zod-v4.ts @@ -0,0 +1,336 @@ +import { renderHook } from '@testing-library/react'; +import { Resolver, SubmitHandler, useForm } from 'react-hook-form'; +import { z } from 'zod/v4'; +import { zodResolver } from '..'; +import { fields, invalidData, schema, validData } from './__fixtures__/data-v4'; + +const shouldUseNativeValidation = false; + +describe('zodResolver', () => { + it('should return values from zodResolver when validation pass & raw=true', async () => { + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + raw: true, + })(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(parseAsyncSpy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ errors: {}, values: validData }); + }); + + it('should return parsed values from zodResolver with `mode: sync` when validation pass', async () => { + const parseSpy = vi.spyOn(schema, 'parse'); + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + mode: 'sync', + })(validData, undefined, { fields, shouldUseNativeValidation }); + + expect(parseSpy).toHaveBeenCalledTimes(1); + expect(parseAsyncSpy).not.toHaveBeenCalled(); + expect(result.errors).toEqual({}); + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from zodResolver when validation fails', async () => { + const result = await zodResolver(schema)(invalidData, undefined, { + fields, + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return a single error from zodResolver with `mode: sync` when validation fails', async () => { + const parseSpy = vi.spyOn(schema, 'parse'); + const parseAsyncSpy = vi.spyOn(schema, 'parseAsync'); + + const result = await zodResolver(schema, undefined, { + mode: 'sync', + })(invalidData, undefined, { fields, shouldUseNativeValidation }); + + expect(parseSpy).toHaveBeenCalledTimes(1); + expect(parseAsyncSpy).not.toHaveBeenCalled(); + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true', async () => { + const result = await zodResolver(schema)(invalidData, undefined, { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }); + + expect(result).toMatchSnapshot(); + }); + + it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => { + const result = await zodResolver(schema, undefined, { mode: 'sync' })( + invalidData, + undefined, + { + fields, + criteriaMode: 'all', + shouldUseNativeValidation, + }, + ); + + expect(result).toMatchSnapshot(); + }); + + it('should surface the error from the union member closest to matching, not just the first member', async () => { + const branchWithMoreIssues = z.object({ + id: z.string().refine(() => false, { error: 'id wrong (branch B)' }), + name: z.string().refine(() => false, { error: 'name wrong (branch B)' }), + }); + const branchWithFewerIssues = z.object({ + id: z.string(), + name: z + .string() + .refine((v) => v.length >= 5, { error: 'name too short' }), + }); + // branchWithMoreIssues is listed first, but only branchWithFewerIssues + // actually comes close to matching the input (it only fails on `name`). + const unionSchema = z.union([branchWithMoreIssues, branchWithFewerIssues]); + + const result = await zodResolver(unionSchema)( + { id: 'abc', name: 'yo' }, + undefined, + { fields: {}, shouldUseNativeValidation }, + ); + + expect(result.errors).toMatchObject({ + '': { message: 'name too short' }, + }); + }); + + it('should not throw when a discriminated union is submitted without its discriminator set', async () => { + // https://github.com/react-hook-form/resolvers/issues/ (zod4 + // discriminatedUnion with no matching discriminator used to throw + // "t.errors[0] is undefined" / "Cannot read properties of undefined + // (reading '0')" instead of reporting a validation error). + const unionSchema = z.discriminatedUnion('type', [ + z.object({ type: z.literal('foo') }), + z.object({ type: z.literal('bar') }), + ]); + + const result = await zodResolver(unionSchema)( + {} as unknown as z.input, + undefined, + { fields: {}, shouldUseNativeValidation }, + ); + + expect(result.errors).toMatchObject({ + type: { type: 'invalid_union' }, + }); + }); + + it('should not throw when a discriminated union member is itself a discriminated union whose discriminator is missing', async () => { + // https://github.com/react-hook-form/resolvers/issues/... (nested + // discriminatedUnion whose own discriminator is absent used to throw + // "Cannot read properties of undefined (reading '0')" instead of + // reporting a validation error). + const baseNested = { + type: z.literal('b'), + name: z.string().nonempty(), + nested_type: z.enum(['nested_1', 'nested_2']), + }; + + const nestedUnionSchema = z.object({ + my_array: z.array( + z.discriminatedUnion('type', [ + z.object({ + type: z.literal('a'), + name: z.string().nonempty(), + }), + z.discriminatedUnion('nested_type', [ + z.object({ + ...baseNested, + nested_type: z.literal('nested_1'), + role_other: z.string().nonempty(), + }), + z.object({ + ...baseNested, + nested_type: z.literal('nested_2'), + }), + ]), + ]), + ), + }); + + const result = await zodResolver(nestedUnionSchema)( + // `type: 'b'` matches the second (nested) union, but its own + // `nested_type` discriminator is missing. + { my_array: [{ type: 'b' }] } as unknown as z.input< + typeof nestedUnionSchema + >, + undefined, + { fields: {}, shouldUseNativeValidation }, + ); + + expect(result.errors).toMatchObject({ + my_array: [{ nested_type: { type: 'invalid_union' } }], + }); + }); + + it("should use the schema's own bound parse/parseAsync method rather than a standalone zod/v4/core import", async () => { + // Bundlers that can resolve `zod` and `zod/v4/core` to two distinct + // module instances (e.g. Metro with package-exports resolution enabled) + // would silently drop any `z.config()`/locale the app configured on its + // own zod instance if this resolver called a standalone parse function + // from its own `zod/v4/core` import instead of the schema's own method. + // Proven here by making the schema's own `parseAsync` throw a distinct + // error and asserting the resolver actually surfaces it, rather than + // independently re-validating via some other zod reference. + const testSchema = z.object({ name: z.string() }); + const customIssue: z.core.$ZodIssue = { + code: 'custom', + message: 'error from the schema instance, not a separate zod import', + path: ['name'], + input: undefined, + }; + vi.spyOn(testSchema, 'parseAsync').mockRejectedValueOnce( + new z.core.$ZodError([customIssue]), + ); + + const result = await zodResolver(testSchema)({ name: '' }, undefined, { + fields: {}, + shouldUseNativeValidation, + }); + + expect(result.errors).toMatchObject({ + name: { + message: 'error from the schema instance, not a separate zod import', + }, + }); + }); + + it('should not misdetect a zod4 schema as zod3 (both have an object-shaped `_def`)', async () => { + // The zod3 detection was loosened to only require an object-shaped + // `_def` (see issue #782 — dynamically selected schemas typed via the + // generic `z.ZodType` annotation don't statically expose + // `_def.typeName`). Zod 4 schemas also have an object-shaped `_def` + // (just without `typeName`), so zod4 must be detected first via its + // unambiguous `_zod` marker — otherwise this would incorrectly take the + // zod3 code path and mishandle zod4's error shape. + const testSchema = z.object({ name: z.string() }); + + const result = await zodResolver(testSchema)( + { name: 123 as any }, + undefined, + { + fields: {}, + shouldUseNativeValidation, + }, + ); + + expect(result.errors).toMatchObject({ + name: { type: 'invalid_type' }, + }); + }); + + it('should throw any error unrelated to Zod', async () => { + const schemaWithCustomError = schema.refine(() => { + throw Error('custom error'); + }); + const promise = zodResolver(schemaWithCustomError)(validData, undefined, { + fields, + shouldUseNativeValidation, + }); + + await expect(promise).rejects.toThrow('custom error'); + }); + + it('should enforce parse params type signature', async () => { + const resolver = zodResolver(schema, { + jitless: true, + reportInput: true, + error(iss) { + iss.path; + iss.code; + iss.path; + return { message: 'asdf' }; + }, + }); + + resolver; + }); + + /** + * Type inference tests + */ + it('should correctly infer the output type from a zod schema', () => { + const resolver = zodResolver(z.object({ id: z.number() })); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: number }> + >(); + }); + + it('should correctly infer the output type from a zod schema using a transform', () => { + const resolver = zodResolver( + z.object({ id: z.number().transform((val) => String(val)) }), + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, unknown, { id: string }> + >(); + }); + + it('should correctly infer the output type from a zod schema when a different input type is specified', () => { + const schema = z.object({ id: z.number() }).transform(({ id }) => { + return { id: String(id) }; + }); + + const resolver = zodResolver<{ id: number }, any, z.output>( + schema, + ); + + expectTypeOf(resolver).toEqualTypeOf< + Resolver<{ id: number }, any, { id: string }> + >(); + }); + + it('should correctly infer the output type from a Zod schema for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number() }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: zodResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: number; + }> + >(); + }); + + it('should correctly infer the output type from a Zod schema with a transform for the handleSubmit function in useForm', () => { + const schema = z.object({ id: z.number().transform((val) => String(val)) }); + + const { + result: { current: form }, + } = renderHook(() => + useForm({ + resolver: zodResolver(schema), + }), + ); + + expectTypeOf(form.watch('id')).toEqualTypeOf(); + + expectTypeOf(form.handleSubmit).parameter(0).toEqualTypeOf< + SubmitHandler<{ + id: string; + }> + >(); + }); +}); diff --git a/node_modules/@hookform/resolvers/zod/src/index.ts b/node_modules/@hookform/resolvers/zod/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..6748f26c1284c2247415dc6d8cf2f817beef811c --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/index.ts @@ -0,0 +1 @@ +export * from './zod'; diff --git a/node_modules/@hookform/resolvers/zod/src/zod.ts b/node_modules/@hookform/resolvers/zod/src/zod.ts new file mode 100644 index 0000000000000000000000000000000000000000..f33986bf0b53e4b20d81c5cc48224463cfd5457f --- /dev/null +++ b/node_modules/@hookform/resolvers/zod/src/zod.ts @@ -0,0 +1,382 @@ +import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; +import { + FieldError, + FieldValues, + Resolver, + ResolverError, + ResolverSuccess, + appendErrors, +} from 'react-hook-form'; +// Type-only: these subpaths don't exist before zod@3.25.0, so importing them +// as values would break resolution for anyone on an older zod 3.x. `import +// type` is fully erased at build time, so the compiled output never +// references these subpaths at runtime — see `isZod4Error` below for how the +// one runtime check that used to need `z4.$ZodError` avoids that now. +import type * as z3 from 'zod/v3'; +import type * as z4 from 'zod/v4/core'; + +const isZod3Error = (error: any): error is z3.ZodError => { + return Array.isArray(error?.issues); +}; +const isZod3Schema = (schema: any): schema is z3.ZodSchema => { + // Deliberately doesn't require `typeName` in `_def` — dynamically selected + // schemas typed via the generic `z.ZodType` annotation (rather than + // a concrete subclass like `ZodObject`) don't statically expose `typeName`, + // even though they're genuine Zod 3 schema instances at runtime. + return '_def' in schema && typeof schema._def === 'object'; +}; +const isZod4Error = (error: any): error is z4.$ZodError => { + // Replicates zod4's own `$ZodError`/`Symbol.hasInstance` check + // (`inst?._zod?.traits?.has(name)`, see zod's `$constructor` in + // `v4/core/core.ts`) by hand rather than importing `$ZodError` as a value, + // since that import only exists in zod@3.25.0+ (see the `import type` note + // above). + return !!error?._zod?.traits?.has('$ZodError'); +}; +const isZod4Schema = (schema: any): schema is z4.$ZodType => { + return '_zod' in schema && typeof schema._zod === 'object'; +}; + +function parseZod3Issues( + zodErrors: z3.ZodIssue[], + validateAllFieldCriteria: boolean, +) { + // A null-prototype object avoids false-positive hits from inherited + // members (e.g. `toString`, `constructor`, `__proto__`) when a field is + // named after one of them — a plain `{}` would make `!errors[_path]` + // truthy-skip those paths and silently drop their errors. + const errors: Record = Object.create(null); + for (; zodErrors.length; ) { + const error = zodErrors[0]; + const { code, message, path } = error; + const _path = path.join('.'); + + if (!errors[_path]) { + if ('unionErrors' in error) { + // Surface the error from whichever union member came closest to + // matching (fewest issues), rather than always the first member — + // the first member isn't necessarily the one the input was meant for. + const closestUnionError = error.unionErrors.reduce( + (closest, current) => + current.errors.length < closest.errors.length ? current : closest, + ); + // Fall back to the union issue's own message/code if the closest + // member somehow has no issues of its own (shouldn't happen, but + // avoids ever throwing on an unexpected/malformed union shape). + const unionError = closestUnionError.errors[0]; + + errors[_path] = { + message: unionError?.message ?? message, + type: unionError?.code ?? code, + }; + } else { + errors[_path] = { message, type: code }; + } + } + + if ('unionErrors' in error) { + error.unionErrors.forEach((unionError) => + unionError.errors.forEach((e) => zodErrors.push(e)), + ); + } + + if (validateAllFieldCriteria) { + const types = errors[_path].types; + const messages = types && types[error.code]; + + errors[_path] = appendErrors( + _path, + validateAllFieldCriteria, + errors, + code, + messages + ? ([] as string[]).concat(messages as string[], error.message) + : error.message, + ) as FieldError; + } + + zodErrors.shift(); + } + + return errors; +} + +function parseZod4Issues( + zodErrors: z4.$ZodIssue[], + validateAllFieldCriteria: boolean, +) { + // See the matching comment in `parseZod3Issues` above. + const errors: Record = Object.create(null); + // const _zodErrors = zodErrors as z4.$ZodISsue; // + for (; zodErrors.length; ) { + const error = zodErrors[0]; + const { code, message, path } = error; + const _path = path.join('.'); + + if (!errors[_path]) { + if (error.code === 'invalid_union' && error.errors.length > 0) { + // Surface the error from whichever union member came closest to + // matching (fewest issues), rather than always the first member — + // the first member isn't necessarily the one the input was meant for. + const closestBranch = error.errors.reduce((closest, branch) => + branch.length < closest.length ? branch : closest, + ); + // Fall back to the union issue's own message/code if the closest + // branch somehow has no issues of its own (shouldn't happen — a + // 0-issue branch means that branch matched — but this guarantees we + // never throw on an unexpected/malformed union shape, e.g. a "no + // matching discriminator" issue nested in a way we haven't seen). + const unionError = closestBranch[0]; + + errors[_path] = { + message: unionError?.message ?? message, + type: unionError?.code ?? code, + }; + } else { + errors[_path] = { message, type: code }; + } + } + + if (error.code === 'invalid_union') { + error.errors.forEach((unionError) => + unionError.forEach((e) => + zodErrors.push({ ...e, path: [...error.path, ...e.path] }), + ), + ); + } + + if (validateAllFieldCriteria) { + const types = errors[_path].types; + const messages = types && types[error.code]; + + errors[_path] = appendErrors( + _path, + validateAllFieldCriteria, + errors, + code, + messages + ? ([] as string[]).concat(messages as string[], error.message) + : error.message, + ) as FieldError; + } + + zodErrors.shift(); + } + + return errors; +} + +type RawResolverOptions = { + mode?: 'async' | 'sync'; + raw: true; +}; +type NonRawResolverOptions = { + mode?: 'async' | 'sync'; + raw?: false; +}; + +// minimal interfaces to avoid asssignability issues between versions +interface Zod3Type { + _output: O; + _input: I; + _def: object; +} + +// minimal interface to avoid assignability issues between zod v4 patch/minor +// releases, which brand the full `$ZodType` shape with an exact version literal +// (e.g. `_zod.version.minor`) +interface Zod4Type { + _zod: { + output: Output; + input: Input; + }; +} + +// some type magic to make versions pre-3.25.0 still work +type IsUnresolved = PropertyKey extends keyof T ? true : false; +type UnresolvedFallback = IsUnresolved extends true + ? Fallback + : T; +type FallbackIssue = { + code: string; + message: string; + path: (string | number)[]; +}; +type Zod3ParseParams = UnresolvedFallback< + z3.ParseParams, + // fallback if user is on <3.25.0 + { + path?: (string | number)[]; + errorMap?: ( + iss: FallbackIssue, + ctx: { + defaultError: string; + data: any; + }, + ) => { message: string }; + async?: boolean; + } +>; +type Zod4ParseParams = UnresolvedFallback< + z4.ParseContext, + // fallback if user is on <3.25.0 + { + readonly error?: ( + iss: FallbackIssue, + ) => null | undefined | string | { message: string }; + readonly reportInput?: boolean; + readonly jitless?: boolean; + } +>; + +export function zodResolver( + schema: Zod3Type, + schemaOptions?: Zod3ParseParams, + resolverOptions?: NonRawResolverOptions, +): Resolver; +export function zodResolver( + schema: Zod3Type, + schemaOptions: Zod3ParseParams | undefined, + resolverOptions: RawResolverOptions, +): Resolver; +// the Zod 4 overloads need to be generic for complicated reasons +export function zodResolver< + Input extends FieldValues, + Context, + Output, + T extends Zod4Type = Zod4Type, +>( + schema: T, + schemaOptions?: Zod4ParseParams, // already partial + resolverOptions?: NonRawResolverOptions, +): Resolver, Context, z4.output>; +export function zodResolver< + Input extends FieldValues, + Context, + Output, + T extends Zod4Type = Zod4Type, +>( + schema: Zod4Type, + schemaOptions: Zod4ParseParams | undefined, // already partial + resolverOptions: RawResolverOptions, +): Resolver, Context, z4.input>; +/** + * Creates a resolver function for react-hook-form that validates form data using a Zod schema + * @param {z3.ZodSchema} schema - The Zod schema used to validate the form data + * @param {Partial} [schemaOptions] - Optional configuration options for Zod parsing + * @param {Object} [resolverOptions] - Optional resolver-specific configuration + * @param {('async'|'sync')} [resolverOptions.mode='async'] - Validation mode. Use 'sync' for synchronous validation + * @param {boolean} [resolverOptions.raw=false] - If true, returns the raw form values instead of the parsed data + * @returns {Resolver>} A resolver function compatible with react-hook-form + * @throws {Error} Throws if validation fails with a non-Zod error + * @example + * const schema = z3.object({ + * name: z3.string().min(2), + * age: z3.number().min(18) + * }); + * + * useForm({ + * resolver: zodResolver(schema) + * }); + */ +export function zodResolver( + schema: object, + schemaOptions?: object, + resolverOptions: { + mode?: 'async' | 'sync'; + raw?: boolean; + } = {}, +): Resolver { + // Zod 4 is checked first: its `_zod` marker is unambiguous, whereas the + // Zod 3 check below only requires an object-shaped `_def` (to support + // dynamically-selected schemas typed via the generic `z.ZodType` + // annotation, see `isZod3Schema`) — and Zod 4 schemas also have an + // object-shaped `_def`, so they'd otherwise be misdetected as Zod 3. + if (isZod4Schema(schema)) { + return async (values: Input, _, options) => { + try { + // Call the schema's own bound `parse`/`parseAsync` method rather + // than the standalone `z4.parse`/`z4.parseAsync` functions. Those + // standalone functions read from this module's own imported + // `zod/v4/core`, which — under bundlers that can resolve `zod` and + // `zod/v4/core` to two distinct module instances (e.g. Metro with + // package-exports resolution enabled) — may not be the same zod + // instance the schema was created with, silently dropping any + // global config (`z.config()`) or locale the app configured on its + // own zod instance. The schema's own method is always bound to + // whichever zod instance actually created it. + const classicSchema = schema as unknown as { + parse: (values: unknown, schemaOptions: unknown) => unknown; + parseAsync: ( + values: unknown, + schemaOptions: unknown, + ) => Promise; + }; + const data: any = + resolverOptions.mode === 'sync' + ? classicSchema.parse(values, schemaOptions) + : await classicSchema.parseAsync(values, schemaOptions); + + options.shouldUseNativeValidation && + validateFieldsNatively({}, options); + + return { + errors: {}, + values: resolverOptions.raw ? Object.assign({}, values) : data, + } satisfies ResolverSuccess; + } catch (error) { + if (isZod4Error(error)) { + return { + values: {}, + errors: toNestErrors( + parseZod4Issues( + error.issues, + !options.shouldUseNativeValidation && + options.criteriaMode === 'all', + ), + options, + ), + } satisfies ResolverError; + } + + throw error; + } + }; + } + + if (isZod3Schema(schema)) { + return async (values: Input, _, options) => { + try { + const data = await schema[ + resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync' + ](values, schemaOptions); + + options.shouldUseNativeValidation && + validateFieldsNatively({}, options); + + return { + errors: {}, + values: resolverOptions.raw ? Object.assign({}, values) : data, + } satisfies ResolverSuccess; + } catch (error) { + if (isZod3Error(error)) { + return { + values: {}, + errors: toNestErrors( + parseZod3Issues( + error.errors, + !options.shouldUseNativeValidation && + options.criteriaMode === 'all', + ), + options, + ), + } satisfies ResolverError; + } + + throw error; + } + }; + } + + throw new Error('Invalid input: not a Zod schema'); +} diff --git a/node_modules/@internationalized/date/LICENSE b/node_modules/@internationalized/date/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..e3af6041dce3ff35457db0cfded595ec7421300e --- /dev/null +++ b/node_modules/@internationalized/date/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2019 Adobe + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node_modules/@internationalized/date/README.md b/node_modules/@internationalized/date/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bbb05ac4f6f08c6946a3893dc799a8d9a6899322 --- /dev/null +++ b/node_modules/@internationalized/date/README.md @@ -0,0 +1,44 @@ +# @internationalized/date + +The `@internationalized/date` package provides objects and functions for representing and manipulating dates and times in a locale-aware manner. + +## Features + +* **Typed objects** – Includes immutable objects to represent dates, times, calendars, and more. +* **International calendars** – Support for 13 calendar systems used around the world, including Gregorian, Buddhist, Islamic, Persian, and more. +* **Manipulation** – Add and subtract durations, set and cycle fields, and more. +* **Conversion** – Convert between calendar systems, time zones, string representations, and object types. +* **Queries** – Compare dates and times for ordering or full/partial equality. Determine locale-specific metadata such as day of week, weekend/weekday, etc. +* **Time zone aware** – The [ZonedDateTime](https://react-spectrum.adobe.com/internationalized/date/ZonedDateTime.html) object supports time zone aware date and time manipulation. +* **Predictable** – The API is designed to resolve ambiguity in all operations explicitly, including time zone conversions, arithmetic involving daylight saving time, locale-specific queries, and more. +* **Small bundle size** – The entire library including all calendars and functions is 8 kB minified and compressed with Brotli. +* **Tree shakeable** – Only include the functions and calendar systems you need. For example, if you only use the Gregorian calendar and builtin `CalendarDate` methods, it's just 2.8 kB. + +## Introduction + +Dates and times are represented in many different ways by cultures around the world. This includes differences in calendar systems, time zones, daylight saving time rules, date and time formatting, weekday and weekend rules, and much more. When building applications that support users around the world, it is important to handle these aspects correctly for each locale. The `@internationalized/date` package provides a library of objects and functions to perform date and time related manipulation, queries, and conversions that work across locales and calendars. + +By default, JavaScript represents dates and times using the [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object. However, `Date` has _many_ problems, including a very difficult to use API, lack of all internationalization support, and more. The [Temporal](https://tc39.es/proposal-temporal/docs/index.html) proposal will eventually address this in the language, and `@internationalized/date` is heavily inspired by it. We hope to back the objects in this package with it once it is implemented in browsers. + +## Package structure + +The `@internationalized/date` package includes the following object types: + +* [Calendar](https://react-spectrum.adobe.com/internationalized/date/Calendar.html) – An interface which provides calendar conversion and metadata like number of days in month, and number of months in year. Many implementations are provided to support the most commonly used calendar systems. +* [CalendarDate](https://react-spectrum.adobe.com/internationalized/date/CalendarDate.html) – An immutable object that stores a date associated with a specific calendar system, without any time components. +* [CalendarDateTime](https://react-spectrum.adobe.com/internationalized/date/CalendarDateTime.html) – An immutable object that represents a date and time without a time zone, in a specific calendar system. +* [ZonedDateTime](https://react-spectrum.adobe.com/internationalized/date/ZonedDateTime.html) – An immutable object that represents a date and time in a specific time zone and calendar system. +* [Time](https://react-spectrum.adobe.com/internationalized/date/Time.html) – An immutable object that stores a clock time without any date components. + +Each object includes methods to allow basic manipulation and conversion functionality, such as adding and subtracting durations, and formatting as an ISO 8601 string. Additional less commonly used functions can be imported from the `@internationalized/date` package, and passed a date object as a parameter. This includes functions to parse ISO 8601 strings, query properties such as day of week, convert between time zones and much more. See the documentation for each of the objects to learn more about the supported methods and functions. + +This example constructs a `CalendarDate` object, manipulates it to get the start of the next week, and converts it to a string representation. + +```tsx +import {CalendarDate, startOfWeek} from '@internationalized/date'; + +let date = new CalendarDate(2022, 2, 3); +date = date.add({weeks: 1}); +date = startOfWeek(date, 'en-US'); +date.toString(); // 2022-02-06 +``` diff --git a/node_modules/@internationalized/date/dist/index.cjs b/node_modules/@internationalized/date/dist/index.cjs new file mode 100644 index 0000000000000000000000000000000000000000..995819aae9d849c4582a3f20e6712d9e9966e57a --- /dev/null +++ b/node_modules/@internationalized/date/dist/index.cjs @@ -0,0 +1,113 @@ +var $c51b7e0106f45dea$exports = require("./private/CalendarDate.cjs"); +var $05031860ba2f881f$exports = require("./private/calendars/GregorianCalendar.cjs"); +var $a90e2192fa9a0f41$exports = require("./private/calendars/JapaneseCalendar.cjs"); +var $0ce473f03e925476$exports = require("./private/calendars/BuddhistCalendar.cjs"); +var $2dab1d4ea1fc722b$exports = require("./private/calendars/TaiwanCalendar.cjs"); +var $4100faec94dc031c$exports = require("./private/calendars/PersianCalendar.cjs"); +var $9dc8610ad30fbfe5$exports = require("./private/calendars/IndianCalendar.cjs"); +var $fbcc6aba7cd7f47c$exports = require("./private/calendars/IslamicCalendar.cjs"); +var $1aa25867248bd474$exports = require("./private/calendars/HebrewCalendar.cjs"); +var $b6b43214f5cff964$exports = require("./private/calendars/EthiopicCalendar.cjs"); +var $9d3159c6111892aa$exports = require("./private/createCalendar.cjs"); +var $e13115b3b86b9007$exports = require("./private/conversion.cjs"); +var $84a63d30beb0af0f$exports = require("./private/queries.cjs"); +var $1b358053f79e3a77$exports = require("./private/string.cjs"); +var $10afcf45c4831ff7$exports = require("./private/DateFormatter.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "CalendarDate", function () { return $c51b7e0106f45dea$exports.CalendarDate; }); +$parcel$export(module.exports, "CalendarDateTime", function () { return $c51b7e0106f45dea$exports.CalendarDateTime; }); +$parcel$export(module.exports, "Time", function () { return $c51b7e0106f45dea$exports.Time; }); +$parcel$export(module.exports, "ZonedDateTime", function () { return $c51b7e0106f45dea$exports.ZonedDateTime; }); +$parcel$export(module.exports, "GregorianCalendar", function () { return $05031860ba2f881f$exports.GregorianCalendar; }); +$parcel$export(module.exports, "JapaneseCalendar", function () { return $a90e2192fa9a0f41$exports.JapaneseCalendar; }); +$parcel$export(module.exports, "BuddhistCalendar", function () { return $0ce473f03e925476$exports.BuddhistCalendar; }); +$parcel$export(module.exports, "TaiwanCalendar", function () { return $2dab1d4ea1fc722b$exports.TaiwanCalendar; }); +$parcel$export(module.exports, "PersianCalendar", function () { return $4100faec94dc031c$exports.PersianCalendar; }); +$parcel$export(module.exports, "IndianCalendar", function () { return $9dc8610ad30fbfe5$exports.IndianCalendar; }); +$parcel$export(module.exports, "IslamicCivilCalendar", function () { return $fbcc6aba7cd7f47c$exports.IslamicCivilCalendar; }); +$parcel$export(module.exports, "IslamicTabularCalendar", function () { return $fbcc6aba7cd7f47c$exports.IslamicTabularCalendar; }); +$parcel$export(module.exports, "IslamicUmalquraCalendar", function () { return $fbcc6aba7cd7f47c$exports.IslamicUmalquraCalendar; }); +$parcel$export(module.exports, "HebrewCalendar", function () { return $1aa25867248bd474$exports.HebrewCalendar; }); +$parcel$export(module.exports, "EthiopicCalendar", function () { return $b6b43214f5cff964$exports.EthiopicCalendar; }); +$parcel$export(module.exports, "EthiopicAmeteAlemCalendar", function () { return $b6b43214f5cff964$exports.EthiopicAmeteAlemCalendar; }); +$parcel$export(module.exports, "CopticCalendar", function () { return $b6b43214f5cff964$exports.CopticCalendar; }); +$parcel$export(module.exports, "createCalendar", function () { return $9d3159c6111892aa$exports.createCalendar; }); +$parcel$export(module.exports, "toCalendarDate", function () { return $e13115b3b86b9007$exports.toCalendarDate; }); +$parcel$export(module.exports, "toCalendarDateTime", function () { return $e13115b3b86b9007$exports.toCalendarDateTime; }); +$parcel$export(module.exports, "toTime", function () { return $e13115b3b86b9007$exports.toTime; }); +$parcel$export(module.exports, "toCalendar", function () { return $e13115b3b86b9007$exports.toCalendar; }); +$parcel$export(module.exports, "toZoned", function () { return $e13115b3b86b9007$exports.toZoned; }); +$parcel$export(module.exports, "toTimeZone", function () { return $e13115b3b86b9007$exports.toTimeZone; }); +$parcel$export(module.exports, "toLocalTimeZone", function () { return $e13115b3b86b9007$exports.toLocalTimeZone; }); +$parcel$export(module.exports, "fromDate", function () { return $e13115b3b86b9007$exports.fromDate; }); +$parcel$export(module.exports, "fromDateToLocal", function () { return $e13115b3b86b9007$exports.fromDateToLocal; }); +$parcel$export(module.exports, "fromAbsolute", function () { return $e13115b3b86b9007$exports.fromAbsolute; }); +$parcel$export(module.exports, "isSameDay", function () { return $84a63d30beb0af0f$exports.isSameDay; }); +$parcel$export(module.exports, "isSameMonth", function () { return $84a63d30beb0af0f$exports.isSameMonth; }); +$parcel$export(module.exports, "isSameYear", function () { return $84a63d30beb0af0f$exports.isSameYear; }); +$parcel$export(module.exports, "isEqualDay", function () { return $84a63d30beb0af0f$exports.isEqualDay; }); +$parcel$export(module.exports, "isEqualMonth", function () { return $84a63d30beb0af0f$exports.isEqualMonth; }); +$parcel$export(module.exports, "isEqualYear", function () { return $84a63d30beb0af0f$exports.isEqualYear; }); +$parcel$export(module.exports, "isToday", function () { return $84a63d30beb0af0f$exports.isToday; }); +$parcel$export(module.exports, "getDayOfWeek", function () { return $84a63d30beb0af0f$exports.getDayOfWeek; }); +$parcel$export(module.exports, "now", function () { return $84a63d30beb0af0f$exports.now; }); +$parcel$export(module.exports, "today", function () { return $84a63d30beb0af0f$exports.today; }); +$parcel$export(module.exports, "getHoursInDay", function () { return $84a63d30beb0af0f$exports.getHoursInDay; }); +$parcel$export(module.exports, "getLocalTimeZone", function () { return $84a63d30beb0af0f$exports.getLocalTimeZone; }); +$parcel$export(module.exports, "setLocalTimeZone", function () { return $84a63d30beb0af0f$exports.setLocalTimeZone; }); +$parcel$export(module.exports, "resetLocalTimeZone", function () { return $84a63d30beb0af0f$exports.resetLocalTimeZone; }); +$parcel$export(module.exports, "startOfMonth", function () { return $84a63d30beb0af0f$exports.startOfMonth; }); +$parcel$export(module.exports, "startOfWeek", function () { return $84a63d30beb0af0f$exports.startOfWeek; }); +$parcel$export(module.exports, "startOfYear", function () { return $84a63d30beb0af0f$exports.startOfYear; }); +$parcel$export(module.exports, "endOfMonth", function () { return $84a63d30beb0af0f$exports.endOfMonth; }); +$parcel$export(module.exports, "endOfWeek", function () { return $84a63d30beb0af0f$exports.endOfWeek; }); +$parcel$export(module.exports, "endOfYear", function () { return $84a63d30beb0af0f$exports.endOfYear; }); +$parcel$export(module.exports, "getMinimumMonthInYear", function () { return $84a63d30beb0af0f$exports.getMinimumMonthInYear; }); +$parcel$export(module.exports, "getMinimumDayInMonth", function () { return $84a63d30beb0af0f$exports.getMinimumDayInMonth; }); +$parcel$export(module.exports, "getWeeksInMonth", function () { return $84a63d30beb0af0f$exports.getWeeksInMonth; }); +$parcel$export(module.exports, "minDate", function () { return $84a63d30beb0af0f$exports.minDate; }); +$parcel$export(module.exports, "maxDate", function () { return $84a63d30beb0af0f$exports.maxDate; }); +$parcel$export(module.exports, "isWeekend", function () { return $84a63d30beb0af0f$exports.isWeekend; }); +$parcel$export(module.exports, "isWeekday", function () { return $84a63d30beb0af0f$exports.isWeekday; }); +$parcel$export(module.exports, "isEqualCalendar", function () { return $84a63d30beb0af0f$exports.isEqualCalendar; }); +$parcel$export(module.exports, "parseDate", function () { return $1b358053f79e3a77$exports.parseDate; }); +$parcel$export(module.exports, "parseDateTime", function () { return $1b358053f79e3a77$exports.parseDateTime; }); +$parcel$export(module.exports, "parseTime", function () { return $1b358053f79e3a77$exports.parseTime; }); +$parcel$export(module.exports, "parseAbsolute", function () { return $1b358053f79e3a77$exports.parseAbsolute; }); +$parcel$export(module.exports, "parseAbsoluteToLocal", function () { return $1b358053f79e3a77$exports.parseAbsoluteToLocal; }); +$parcel$export(module.exports, "parseZonedDateTime", function () { return $1b358053f79e3a77$exports.parseZonedDateTime; }); +$parcel$export(module.exports, "parseDuration", function () { return $1b358053f79e3a77$exports.parseDuration; }); +$parcel$export(module.exports, "DateFormatter", function () { return $10afcf45c4831ff7$exports.DateFormatter; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + + + + + + + + + + + + +//# sourceMappingURL=index.cjs.map diff --git a/node_modules/@internationalized/date/dist/index.cjs.map b/node_modules/@internationalized/date/dist/index.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..d32386cad775102762929dd410928ef64dc5d2b4 --- /dev/null +++ b/node_modules/@internationalized/date/dist/index.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/date/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {\n AnyCalendarDate,\n AnyTime,\n AnyDateTime,\n Calendar,\n CalendarIdentifier,\n DateDuration,\n TimeDuration,\n DateTimeDuration,\n DateFields,\n TimeFields,\n DateField,\n TimeField,\n Disambiguation,\n CycleOptions,\n CycleTimeOptions\n} from './types';\nexport type {DateValue} from './CalendarDate';\nexport type {DayOfWeek} from './queries';\n\nexport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nexport {GregorianCalendar} from './calendars/GregorianCalendar';\nexport {JapaneseCalendar} from './calendars/JapaneseCalendar';\nexport {BuddhistCalendar} from './calendars/BuddhistCalendar';\nexport {TaiwanCalendar} from './calendars/TaiwanCalendar';\nexport {PersianCalendar} from './calendars/PersianCalendar';\nexport {IndianCalendar} from './calendars/IndianCalendar';\nexport {\n IslamicCivilCalendar,\n IslamicTabularCalendar,\n IslamicUmalquraCalendar\n} from './calendars/IslamicCalendar';\nexport {HebrewCalendar} from './calendars/HebrewCalendar';\nexport {\n EthiopicCalendar,\n EthiopicAmeteAlemCalendar,\n CopticCalendar\n} from './calendars/EthiopicCalendar';\nexport {createCalendar} from './createCalendar';\nexport {\n toCalendarDate,\n toCalendarDateTime,\n toTime,\n toCalendar,\n toZoned,\n toTimeZone,\n toLocalTimeZone,\n fromDate,\n fromDateToLocal,\n fromAbsolute\n} from './conversion';\nexport {\n isSameDay,\n isSameMonth,\n isSameYear,\n isEqualDay,\n isEqualMonth,\n isEqualYear,\n isToday,\n getDayOfWeek,\n now,\n today,\n getHoursInDay,\n getLocalTimeZone,\n setLocalTimeZone,\n resetLocalTimeZone,\n startOfMonth,\n startOfWeek,\n startOfYear,\n endOfMonth,\n endOfWeek,\n endOfYear,\n getMinimumMonthInYear,\n getMinimumDayInMonth,\n getWeeksInMonth,\n minDate,\n maxDate,\n isWeekend,\n isWeekday,\n isEqualCalendar\n} from './queries';\nexport {\n parseDate,\n parseDateTime,\n parseTime,\n parseAbsolute,\n parseAbsoluteToLocal,\n parseZonedDateTime,\n parseDuration\n} from './string';\nexport {DateFormatter} from './DateFormatter';\n"],"names":[],"version":3,"file":"index.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/index.js b/node_modules/@internationalized/date/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7be2b7980277f3363a182400da1c80d7ea809981 --- /dev/null +++ b/node_modules/@internationalized/date/dist/index.js @@ -0,0 +1,45 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f, CalendarDateTime as $9a4e222e1bd2b190$export$ca871e8dbb80966f, Time as $9a4e222e1bd2b190$export$680ea196effce5f, ZonedDateTime as $9a4e222e1bd2b190$export$d3b7288e7994edea} from "./private/CalendarDate.js"; +import {GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./private/calendars/GregorianCalendar.js"; +import {JapaneseCalendar as $97f08bcb2befa667$export$b746ab2b60cdffbf} from "./private/calendars/JapaneseCalendar.js"; +import {BuddhistCalendar as $6f54c4fe66fc5ed5$export$42d20a78301dee44} from "./private/calendars/BuddhistCalendar.js"; +import {TaiwanCalendar as $0e7b6ab888014459$export$65e01080afcb0799} from "./private/calendars/TaiwanCalendar.js"; +import {PersianCalendar as $3e485caf6e85028a$export$37fccdbfd14c5939} from "./private/calendars/PersianCalendar.js"; +import {IndianCalendar as $a07127433beb6bf1$export$39f31c639fa15726} from "./private/calendars/IndianCalendar.js"; +import {IslamicCivilCalendar as $a938ddf4fc940323$export$2066795aadd37bfc, IslamicTabularCalendar as $a938ddf4fc940323$export$37f0887f2f9d22f7, IslamicUmalquraCalendar as $a938ddf4fc940323$export$5baab4758c231076} from "./private/calendars/IslamicCalendar.js"; +import {HebrewCalendar as $f6eb69e87cd1adc1$export$ca405048b8fb5af} from "./private/calendars/HebrewCalendar.js"; +import {CopticCalendar as $ca8f5bca40aaf2d4$export$fe6243cbe1a4b7c1, EthiopicAmeteAlemCalendar as $ca8f5bca40aaf2d4$export$d72e0c37005a4914, EthiopicCalendar as $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d} from "./private/calendars/EthiopicCalendar.js"; +import {createCalendar as $d36eda2e2bc2be5a$export$dd0bbc9b26defe37} from "./private/createCalendar.js"; +import {fromAbsolute as $e83297bd1a9e3ddc$export$1b96692a1ba042ac, fromDate as $e83297bd1a9e3ddc$export$e57ff100d91bd4b9, fromDateToLocal as $e83297bd1a9e3ddc$export$d7f92bcd3596b086, toCalendar as $e83297bd1a9e3ddc$export$b4a036af3fc0b032, toCalendarDate as $e83297bd1a9e3ddc$export$93522d1a439f3617, toCalendarDateTime as $e83297bd1a9e3ddc$export$b21e0b124e224484, toLocalTimeZone as $e83297bd1a9e3ddc$export$d9b67bc93c097491, toTime as $e83297bd1a9e3ddc$export$d33f79e3ffc3dc83, toTimeZone as $e83297bd1a9e3ddc$export$538b00033cc11c75, toZoned as $e83297bd1a9e3ddc$export$84c95a83c799e074} from "./private/conversion.js"; +import {endOfMonth as $8daeb11568269f24$export$a2258d9c4118825c, endOfWeek as $8daeb11568269f24$export$ef8b6d9133084f4e, endOfYear as $8daeb11568269f24$export$8b7aa55c66d5569e, getDayOfWeek as $8daeb11568269f24$export$2061056d06d7cdf7, getHoursInDay as $8daeb11568269f24$export$126c91c941de7e, getLocalTimeZone as $8daeb11568269f24$export$aa8b41735afcabd2, getMinimumDayInMonth as $8daeb11568269f24$export$b2f4953d301981d5, getMinimumMonthInYear as $8daeb11568269f24$export$5412ac11713b72ad, getWeeksInMonth as $8daeb11568269f24$export$ccc1b2479e7dd654, isEqualCalendar as $8daeb11568269f24$export$dbc69fd56b53d5e, isEqualDay as $8daeb11568269f24$export$91b62ebf2ba703ee, isEqualMonth as $8daeb11568269f24$export$5a8da0c44a3afdf2, isEqualYear as $8daeb11568269f24$export$ea840f5a6dda8147, isSameDay as $8daeb11568269f24$export$ea39ec197993aef0, isSameMonth as $8daeb11568269f24$export$a18c89cbd24170ff, isSameYear as $8daeb11568269f24$export$5841f9eb9773f25f, isToday as $8daeb11568269f24$export$629b0a497aa65267, isWeekday as $8daeb11568269f24$export$ee9d87258e1d19ed, isWeekend as $8daeb11568269f24$export$618d60ea299da42, maxDate as $8daeb11568269f24$export$a75f2bff57811055, minDate as $8daeb11568269f24$export$5c333a116e949cdd, now as $8daeb11568269f24$export$461939dd4422153, resetLocalTimeZone as $8daeb11568269f24$export$55753838ffe79333, setLocalTimeZone as $8daeb11568269f24$export$61a9d83ceb59a3dd, startOfMonth as $8daeb11568269f24$export$a5a3b454ada2268e, startOfWeek as $8daeb11568269f24$export$42c81a444fbfb5d4, startOfYear as $8daeb11568269f24$export$f91e89d3d0406102, today as $8daeb11568269f24$export$d0bdf45af03a6ea3} from "./private/queries.js"; +import {parseAbsolute as $7dccf15509582627$export$5adfdab05168c219, parseAbsoluteToLocal as $7dccf15509582627$export$8e384432362ed0f0, parseDate as $7dccf15509582627$export$6b862160d295c8e, parseDateTime as $7dccf15509582627$export$588937bcd60ade55, parseDuration as $7dccf15509582627$export$ecae829bb3747ea6, parseTime as $7dccf15509582627$export$c9698ec7f05a07e1, parseZonedDateTime as $7dccf15509582627$export$fd7893f06e92a6a4} from "./private/string.js"; +import {DateFormatter as $f48a4033af8eadca$export$ad991b66133851cf} from "./private/DateFormatter.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + + + + + + + + + + + + +export {$9a4e222e1bd2b190$export$99faa760c7908e4f as CalendarDate, $9a4e222e1bd2b190$export$ca871e8dbb80966f as CalendarDateTime, $9a4e222e1bd2b190$export$680ea196effce5f as Time, $9a4e222e1bd2b190$export$d3b7288e7994edea as ZonedDateTime, $f25df78da1f6b40f$export$80ee6245ec4f29ec as GregorianCalendar, $97f08bcb2befa667$export$b746ab2b60cdffbf as JapaneseCalendar, $6f54c4fe66fc5ed5$export$42d20a78301dee44 as BuddhistCalendar, $0e7b6ab888014459$export$65e01080afcb0799 as TaiwanCalendar, $3e485caf6e85028a$export$37fccdbfd14c5939 as PersianCalendar, $a07127433beb6bf1$export$39f31c639fa15726 as IndianCalendar, $a938ddf4fc940323$export$2066795aadd37bfc as IslamicCivilCalendar, $a938ddf4fc940323$export$37f0887f2f9d22f7 as IslamicTabularCalendar, $a938ddf4fc940323$export$5baab4758c231076 as IslamicUmalquraCalendar, $f6eb69e87cd1adc1$export$ca405048b8fb5af as HebrewCalendar, $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d as EthiopicCalendar, $ca8f5bca40aaf2d4$export$d72e0c37005a4914 as EthiopicAmeteAlemCalendar, $ca8f5bca40aaf2d4$export$fe6243cbe1a4b7c1 as CopticCalendar, $d36eda2e2bc2be5a$export$dd0bbc9b26defe37 as createCalendar, $e83297bd1a9e3ddc$export$93522d1a439f3617 as toCalendarDate, $e83297bd1a9e3ddc$export$b21e0b124e224484 as toCalendarDateTime, $e83297bd1a9e3ddc$export$d33f79e3ffc3dc83 as toTime, $e83297bd1a9e3ddc$export$b4a036af3fc0b032 as toCalendar, $e83297bd1a9e3ddc$export$84c95a83c799e074 as toZoned, $e83297bd1a9e3ddc$export$538b00033cc11c75 as toTimeZone, $e83297bd1a9e3ddc$export$d9b67bc93c097491 as toLocalTimeZone, $e83297bd1a9e3ddc$export$e57ff100d91bd4b9 as fromDate, $e83297bd1a9e3ddc$export$d7f92bcd3596b086 as fromDateToLocal, $e83297bd1a9e3ddc$export$1b96692a1ba042ac as fromAbsolute, $8daeb11568269f24$export$ea39ec197993aef0 as isSameDay, $8daeb11568269f24$export$a18c89cbd24170ff as isSameMonth, $8daeb11568269f24$export$5841f9eb9773f25f as isSameYear, $8daeb11568269f24$export$91b62ebf2ba703ee as isEqualDay, $8daeb11568269f24$export$5a8da0c44a3afdf2 as isEqualMonth, $8daeb11568269f24$export$ea840f5a6dda8147 as isEqualYear, $8daeb11568269f24$export$629b0a497aa65267 as isToday, $8daeb11568269f24$export$2061056d06d7cdf7 as getDayOfWeek, $8daeb11568269f24$export$461939dd4422153 as now, $8daeb11568269f24$export$d0bdf45af03a6ea3 as today, $8daeb11568269f24$export$126c91c941de7e as getHoursInDay, $8daeb11568269f24$export$aa8b41735afcabd2 as getLocalTimeZone, $8daeb11568269f24$export$61a9d83ceb59a3dd as setLocalTimeZone, $8daeb11568269f24$export$55753838ffe79333 as resetLocalTimeZone, $8daeb11568269f24$export$a5a3b454ada2268e as startOfMonth, $8daeb11568269f24$export$42c81a444fbfb5d4 as startOfWeek, $8daeb11568269f24$export$f91e89d3d0406102 as startOfYear, $8daeb11568269f24$export$a2258d9c4118825c as endOfMonth, $8daeb11568269f24$export$ef8b6d9133084f4e as endOfWeek, $8daeb11568269f24$export$8b7aa55c66d5569e as endOfYear, $8daeb11568269f24$export$5412ac11713b72ad as getMinimumMonthInYear, $8daeb11568269f24$export$b2f4953d301981d5 as getMinimumDayInMonth, $8daeb11568269f24$export$ccc1b2479e7dd654 as getWeeksInMonth, $8daeb11568269f24$export$5c333a116e949cdd as minDate, $8daeb11568269f24$export$a75f2bff57811055 as maxDate, $8daeb11568269f24$export$618d60ea299da42 as isWeekend, $8daeb11568269f24$export$ee9d87258e1d19ed as isWeekday, $8daeb11568269f24$export$dbc69fd56b53d5e as isEqualCalendar, $7dccf15509582627$export$6b862160d295c8e as parseDate, $7dccf15509582627$export$588937bcd60ade55 as parseDateTime, $7dccf15509582627$export$c9698ec7f05a07e1 as parseTime, $7dccf15509582627$export$5adfdab05168c219 as parseAbsolute, $7dccf15509582627$export$8e384432362ed0f0 as parseAbsoluteToLocal, $7dccf15509582627$export$fd7893f06e92a6a4 as parseZonedDateTime, $7dccf15509582627$export$ecae829bb3747ea6 as parseDuration, $f48a4033af8eadca$export$ad991b66133851cf as DateFormatter}; +//# sourceMappingURL=index.js.map diff --git a/node_modules/@internationalized/date/dist/index.js.map b/node_modules/@internationalized/date/dist/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b96dd961fe7480d31d7fed97fcfe8189a8791f75 --- /dev/null +++ b/node_modules/@internationalized/date/dist/index.js.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/date/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {\n AnyCalendarDate,\n AnyTime,\n AnyDateTime,\n Calendar,\n CalendarIdentifier,\n DateDuration,\n TimeDuration,\n DateTimeDuration,\n DateFields,\n TimeFields,\n DateField,\n TimeField,\n Disambiguation,\n CycleOptions,\n CycleTimeOptions\n} from './types';\nexport type {DateValue} from './CalendarDate';\nexport type {DayOfWeek} from './queries';\n\nexport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nexport {GregorianCalendar} from './calendars/GregorianCalendar';\nexport {JapaneseCalendar} from './calendars/JapaneseCalendar';\nexport {BuddhistCalendar} from './calendars/BuddhistCalendar';\nexport {TaiwanCalendar} from './calendars/TaiwanCalendar';\nexport {PersianCalendar} from './calendars/PersianCalendar';\nexport {IndianCalendar} from './calendars/IndianCalendar';\nexport {\n IslamicCivilCalendar,\n IslamicTabularCalendar,\n IslamicUmalquraCalendar\n} from './calendars/IslamicCalendar';\nexport {HebrewCalendar} from './calendars/HebrewCalendar';\nexport {\n EthiopicCalendar,\n EthiopicAmeteAlemCalendar,\n CopticCalendar\n} from './calendars/EthiopicCalendar';\nexport {createCalendar} from './createCalendar';\nexport {\n toCalendarDate,\n toCalendarDateTime,\n toTime,\n toCalendar,\n toZoned,\n toTimeZone,\n toLocalTimeZone,\n fromDate,\n fromDateToLocal,\n fromAbsolute\n} from './conversion';\nexport {\n isSameDay,\n isSameMonth,\n isSameYear,\n isEqualDay,\n isEqualMonth,\n isEqualYear,\n isToday,\n getDayOfWeek,\n now,\n today,\n getHoursInDay,\n getLocalTimeZone,\n setLocalTimeZone,\n resetLocalTimeZone,\n startOfMonth,\n startOfWeek,\n startOfYear,\n endOfMonth,\n endOfWeek,\n endOfYear,\n getMinimumMonthInYear,\n getMinimumDayInMonth,\n getWeeksInMonth,\n minDate,\n maxDate,\n isWeekend,\n isWeekday,\n isEqualCalendar\n} from './queries';\nexport {\n parseDate,\n parseDateTime,\n parseTime,\n parseAbsolute,\n parseAbsoluteToLocal,\n parseZonedDateTime,\n parseDuration\n} from './string';\nexport {DateFormatter} from './DateFormatter';\n"],"names":[],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/index.mjs b/node_modules/@internationalized/date/dist/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..dcd2f359ed3dd9849076981bf96c152a245a41c7 --- /dev/null +++ b/node_modules/@internationalized/date/dist/index.mjs @@ -0,0 +1,45 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f, CalendarDateTime as $2aaf608024c21ca1$export$ca871e8dbb80966f, Time as $2aaf608024c21ca1$export$680ea196effce5f, ZonedDateTime as $2aaf608024c21ca1$export$d3b7288e7994edea} from "./private/CalendarDate.mjs"; +import {GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./private/calendars/GregorianCalendar.mjs"; +import {JapaneseCalendar as $34b940b49ba042df$export$b746ab2b60cdffbf} from "./private/calendars/JapaneseCalendar.mjs"; +import {BuddhistCalendar as $63d4eafd4d826996$export$42d20a78301dee44} from "./private/calendars/BuddhistCalendar.mjs"; +import {TaiwanCalendar as $c009cc5f64923054$export$65e01080afcb0799} from "./private/calendars/TaiwanCalendar.mjs"; +import {PersianCalendar as $a0cc0739a536c3b1$export$37fccdbfd14c5939} from "./private/calendars/PersianCalendar.mjs"; +import {IndianCalendar as $11fa67a177e45470$export$39f31c639fa15726} from "./private/calendars/IndianCalendar.mjs"; +import {IslamicCivilCalendar as $fd4f9bc1ba0e49a8$export$2066795aadd37bfc, IslamicTabularCalendar as $fd4f9bc1ba0e49a8$export$37f0887f2f9d22f7, IslamicUmalquraCalendar as $fd4f9bc1ba0e49a8$export$5baab4758c231076} from "./private/calendars/IslamicCalendar.mjs"; +import {HebrewCalendar as $f39495b96f9dbac6$export$ca405048b8fb5af} from "./private/calendars/HebrewCalendar.mjs"; +import {CopticCalendar as $97cfca9efd59523d$export$fe6243cbe1a4b7c1, EthiopicAmeteAlemCalendar as $97cfca9efd59523d$export$d72e0c37005a4914, EthiopicCalendar as $97cfca9efd59523d$export$26ba6eab5e20cd7d} from "./private/calendars/EthiopicCalendar.mjs"; +import {createCalendar as $84102b64e5ca022f$export$dd0bbc9b26defe37} from "./private/createCalendar.mjs"; +import {fromAbsolute as $d07e34cce18680fd$export$1b96692a1ba042ac, fromDate as $d07e34cce18680fd$export$e57ff100d91bd4b9, fromDateToLocal as $d07e34cce18680fd$export$d7f92bcd3596b086, toCalendar as $d07e34cce18680fd$export$b4a036af3fc0b032, toCalendarDate as $d07e34cce18680fd$export$93522d1a439f3617, toCalendarDateTime as $d07e34cce18680fd$export$b21e0b124e224484, toLocalTimeZone as $d07e34cce18680fd$export$d9b67bc93c097491, toTime as $d07e34cce18680fd$export$d33f79e3ffc3dc83, toTimeZone as $d07e34cce18680fd$export$538b00033cc11c75, toZoned as $d07e34cce18680fd$export$84c95a83c799e074} from "./private/conversion.mjs"; +import {endOfMonth as $ad063034c8620db8$export$a2258d9c4118825c, endOfWeek as $ad063034c8620db8$export$ef8b6d9133084f4e, endOfYear as $ad063034c8620db8$export$8b7aa55c66d5569e, getDayOfWeek as $ad063034c8620db8$export$2061056d06d7cdf7, getHoursInDay as $ad063034c8620db8$export$126c91c941de7e, getLocalTimeZone as $ad063034c8620db8$export$aa8b41735afcabd2, getMinimumDayInMonth as $ad063034c8620db8$export$b2f4953d301981d5, getMinimumMonthInYear as $ad063034c8620db8$export$5412ac11713b72ad, getWeeksInMonth as $ad063034c8620db8$export$ccc1b2479e7dd654, isEqualCalendar as $ad063034c8620db8$export$dbc69fd56b53d5e, isEqualDay as $ad063034c8620db8$export$91b62ebf2ba703ee, isEqualMonth as $ad063034c8620db8$export$5a8da0c44a3afdf2, isEqualYear as $ad063034c8620db8$export$ea840f5a6dda8147, isSameDay as $ad063034c8620db8$export$ea39ec197993aef0, isSameMonth as $ad063034c8620db8$export$a18c89cbd24170ff, isSameYear as $ad063034c8620db8$export$5841f9eb9773f25f, isToday as $ad063034c8620db8$export$629b0a497aa65267, isWeekday as $ad063034c8620db8$export$ee9d87258e1d19ed, isWeekend as $ad063034c8620db8$export$618d60ea299da42, maxDate as $ad063034c8620db8$export$a75f2bff57811055, minDate as $ad063034c8620db8$export$5c333a116e949cdd, now as $ad063034c8620db8$export$461939dd4422153, resetLocalTimeZone as $ad063034c8620db8$export$55753838ffe79333, setLocalTimeZone as $ad063034c8620db8$export$61a9d83ceb59a3dd, startOfMonth as $ad063034c8620db8$export$a5a3b454ada2268e, startOfWeek as $ad063034c8620db8$export$42c81a444fbfb5d4, startOfYear as $ad063034c8620db8$export$f91e89d3d0406102, today as $ad063034c8620db8$export$d0bdf45af03a6ea3} from "./private/queries.mjs"; +import {parseAbsolute as $58246871e4652552$export$5adfdab05168c219, parseAbsoluteToLocal as $58246871e4652552$export$8e384432362ed0f0, parseDate as $58246871e4652552$export$6b862160d295c8e, parseDateTime as $58246871e4652552$export$588937bcd60ade55, parseDuration as $58246871e4652552$export$ecae829bb3747ea6, parseTime as $58246871e4652552$export$c9698ec7f05a07e1, parseZonedDateTime as $58246871e4652552$export$fd7893f06e92a6a4} from "./private/string.mjs"; +import {DateFormatter as $12a3c853105e5a70$export$ad991b66133851cf} from "./private/DateFormatter.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + + + + + + + + + + + + +export {$2aaf608024c21ca1$export$99faa760c7908e4f as CalendarDate, $2aaf608024c21ca1$export$ca871e8dbb80966f as CalendarDateTime, $2aaf608024c21ca1$export$680ea196effce5f as Time, $2aaf608024c21ca1$export$d3b7288e7994edea as ZonedDateTime, $93635573935797de$export$80ee6245ec4f29ec as GregorianCalendar, $34b940b49ba042df$export$b746ab2b60cdffbf as JapaneseCalendar, $63d4eafd4d826996$export$42d20a78301dee44 as BuddhistCalendar, $c009cc5f64923054$export$65e01080afcb0799 as TaiwanCalendar, $a0cc0739a536c3b1$export$37fccdbfd14c5939 as PersianCalendar, $11fa67a177e45470$export$39f31c639fa15726 as IndianCalendar, $fd4f9bc1ba0e49a8$export$2066795aadd37bfc as IslamicCivilCalendar, $fd4f9bc1ba0e49a8$export$37f0887f2f9d22f7 as IslamicTabularCalendar, $fd4f9bc1ba0e49a8$export$5baab4758c231076 as IslamicUmalquraCalendar, $f39495b96f9dbac6$export$ca405048b8fb5af as HebrewCalendar, $97cfca9efd59523d$export$26ba6eab5e20cd7d as EthiopicCalendar, $97cfca9efd59523d$export$d72e0c37005a4914 as EthiopicAmeteAlemCalendar, $97cfca9efd59523d$export$fe6243cbe1a4b7c1 as CopticCalendar, $84102b64e5ca022f$export$dd0bbc9b26defe37 as createCalendar, $d07e34cce18680fd$export$93522d1a439f3617 as toCalendarDate, $d07e34cce18680fd$export$b21e0b124e224484 as toCalendarDateTime, $d07e34cce18680fd$export$d33f79e3ffc3dc83 as toTime, $d07e34cce18680fd$export$b4a036af3fc0b032 as toCalendar, $d07e34cce18680fd$export$84c95a83c799e074 as toZoned, $d07e34cce18680fd$export$538b00033cc11c75 as toTimeZone, $d07e34cce18680fd$export$d9b67bc93c097491 as toLocalTimeZone, $d07e34cce18680fd$export$e57ff100d91bd4b9 as fromDate, $d07e34cce18680fd$export$d7f92bcd3596b086 as fromDateToLocal, $d07e34cce18680fd$export$1b96692a1ba042ac as fromAbsolute, $ad063034c8620db8$export$ea39ec197993aef0 as isSameDay, $ad063034c8620db8$export$a18c89cbd24170ff as isSameMonth, $ad063034c8620db8$export$5841f9eb9773f25f as isSameYear, $ad063034c8620db8$export$91b62ebf2ba703ee as isEqualDay, $ad063034c8620db8$export$5a8da0c44a3afdf2 as isEqualMonth, $ad063034c8620db8$export$ea840f5a6dda8147 as isEqualYear, $ad063034c8620db8$export$629b0a497aa65267 as isToday, $ad063034c8620db8$export$2061056d06d7cdf7 as getDayOfWeek, $ad063034c8620db8$export$461939dd4422153 as now, $ad063034c8620db8$export$d0bdf45af03a6ea3 as today, $ad063034c8620db8$export$126c91c941de7e as getHoursInDay, $ad063034c8620db8$export$aa8b41735afcabd2 as getLocalTimeZone, $ad063034c8620db8$export$61a9d83ceb59a3dd as setLocalTimeZone, $ad063034c8620db8$export$55753838ffe79333 as resetLocalTimeZone, $ad063034c8620db8$export$a5a3b454ada2268e as startOfMonth, $ad063034c8620db8$export$42c81a444fbfb5d4 as startOfWeek, $ad063034c8620db8$export$f91e89d3d0406102 as startOfYear, $ad063034c8620db8$export$a2258d9c4118825c as endOfMonth, $ad063034c8620db8$export$ef8b6d9133084f4e as endOfWeek, $ad063034c8620db8$export$8b7aa55c66d5569e as endOfYear, $ad063034c8620db8$export$5412ac11713b72ad as getMinimumMonthInYear, $ad063034c8620db8$export$b2f4953d301981d5 as getMinimumDayInMonth, $ad063034c8620db8$export$ccc1b2479e7dd654 as getWeeksInMonth, $ad063034c8620db8$export$5c333a116e949cdd as minDate, $ad063034c8620db8$export$a75f2bff57811055 as maxDate, $ad063034c8620db8$export$618d60ea299da42 as isWeekend, $ad063034c8620db8$export$ee9d87258e1d19ed as isWeekday, $ad063034c8620db8$export$dbc69fd56b53d5e as isEqualCalendar, $58246871e4652552$export$6b862160d295c8e as parseDate, $58246871e4652552$export$588937bcd60ade55 as parseDateTime, $58246871e4652552$export$c9698ec7f05a07e1 as parseTime, $58246871e4652552$export$5adfdab05168c219 as parseAbsolute, $58246871e4652552$export$8e384432362ed0f0 as parseAbsoluteToLocal, $58246871e4652552$export$fd7893f06e92a6a4 as parseZonedDateTime, $58246871e4652552$export$ecae829bb3747ea6 as parseDuration, $12a3c853105e5a70$export$ad991b66133851cf as DateFormatter}; +//# sourceMappingURL=index.mjs.map diff --git a/node_modules/@internationalized/date/dist/index.mjs.map b/node_modules/@internationalized/date/dist/index.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..a44e40944aa0bf0f4dc42ee88abfc0a46fe88b56 --- /dev/null +++ b/node_modules/@internationalized/date/dist/index.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/date/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {\n AnyCalendarDate,\n AnyTime,\n AnyDateTime,\n Calendar,\n CalendarIdentifier,\n DateDuration,\n TimeDuration,\n DateTimeDuration,\n DateFields,\n TimeFields,\n DateField,\n TimeField,\n Disambiguation,\n CycleOptions,\n CycleTimeOptions\n} from './types';\nexport type {DateValue} from './CalendarDate';\nexport type {DayOfWeek} from './queries';\n\nexport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nexport {GregorianCalendar} from './calendars/GregorianCalendar';\nexport {JapaneseCalendar} from './calendars/JapaneseCalendar';\nexport {BuddhistCalendar} from './calendars/BuddhistCalendar';\nexport {TaiwanCalendar} from './calendars/TaiwanCalendar';\nexport {PersianCalendar} from './calendars/PersianCalendar';\nexport {IndianCalendar} from './calendars/IndianCalendar';\nexport {\n IslamicCivilCalendar,\n IslamicTabularCalendar,\n IslamicUmalquraCalendar\n} from './calendars/IslamicCalendar';\nexport {HebrewCalendar} from './calendars/HebrewCalendar';\nexport {\n EthiopicCalendar,\n EthiopicAmeteAlemCalendar,\n CopticCalendar\n} from './calendars/EthiopicCalendar';\nexport {createCalendar} from './createCalendar';\nexport {\n toCalendarDate,\n toCalendarDateTime,\n toTime,\n toCalendar,\n toZoned,\n toTimeZone,\n toLocalTimeZone,\n fromDate,\n fromDateToLocal,\n fromAbsolute\n} from './conversion';\nexport {\n isSameDay,\n isSameMonth,\n isSameYear,\n isEqualDay,\n isEqualMonth,\n isEqualYear,\n isToday,\n getDayOfWeek,\n now,\n today,\n getHoursInDay,\n getLocalTimeZone,\n setLocalTimeZone,\n resetLocalTimeZone,\n startOfMonth,\n startOfWeek,\n startOfYear,\n endOfMonth,\n endOfWeek,\n endOfYear,\n getMinimumMonthInYear,\n getMinimumDayInMonth,\n getWeeksInMonth,\n minDate,\n maxDate,\n isWeekend,\n isWeekday,\n isEqualCalendar\n} from './queries';\nexport {\n parseDate,\n parseDateTime,\n parseTime,\n parseAbsolute,\n parseAbsoluteToLocal,\n parseZonedDateTime,\n parseDuration\n} from './string';\nexport {DateFormatter} from './DateFormatter';\n"],"names":[],"version":3,"file":"index.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/CalendarDate.cjs b/node_modules/@internationalized/date/dist/private/CalendarDate.cjs new file mode 100644 index 0000000000000000000000000000000000000000..9e5c390cd78be1beeb9607a579b4a4733ede0f68 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/CalendarDate.cjs @@ -0,0 +1,272 @@ +var $19485913bea41f19$exports = require("./manipulation.cjs"); +var $84a63d30beb0af0f$exports = require("./queries.cjs"); +var $1b358053f79e3a77$exports = require("./string.cjs"); +var $05031860ba2f881f$exports = require("./calendars/GregorianCalendar.cjs"); +var $e13115b3b86b9007$exports = require("./conversion.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "CalendarDate", function () { return $c51b7e0106f45dea$export$99faa760c7908e4f; }); +$parcel$export(module.exports, "Time", function () { return $c51b7e0106f45dea$export$680ea196effce5f; }); +$parcel$export(module.exports, "CalendarDateTime", function () { return $c51b7e0106f45dea$export$ca871e8dbb80966f; }); +$parcel$export(module.exports, "ZonedDateTime", function () { return $c51b7e0106f45dea$export$d3b7288e7994edea; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + +function $c51b7e0106f45dea$var$shiftArgs(args) { + let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $05031860ba2f881f$exports.GregorianCalendar)(); + let era; + if (typeof args[0] === 'string') era = args.shift(); + else { + let eras = calendar.getEras(); + era = eras[eras.length - 1]; + } + let year = args.shift(); + let month = args.shift(); + let day = args.shift(); + return [ + calendar, + era, + year, + month, + day + ]; +} +class $c51b7e0106f45dea$export$99faa760c7908e4f { + // This prevents TypeScript from allowing other types with the same fields to match. + // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate. + // If that behavior is desired, use the AnyCalendarDate interface instead. + // @ts-ignore + #type; + constructor(...args){ + let [calendar, era, year, month, day] = $c51b7e0106f45dea$var$shiftArgs(args); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + (0, $19485913bea41f19$exports.constrain)(this); + } + /** Returns a copy of this date. */ copy() { + if (this.era) return new $c51b7e0106f45dea$export$99faa760c7908e4f(this.calendar, this.era, this.year, this.month, this.day); + else return new $c51b7e0106f45dea$export$99faa760c7908e4f(this.calendar, this.year, this.month, this.day); + } + /** Returns a new `CalendarDate` with the given duration added to it. */ add(duration) { + return (0, $19485913bea41f19$exports.add)(this, duration); + } + /** Returns a new `CalendarDate` with the given duration subtracted from it. */ subtract(duration) { + return (0, $19485913bea41f19$exports.subtract)(this, duration); + } + /** + * Returns a new `CalendarDate` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields) { + return (0, $19485913bea41f19$exports.set)(this, fields); + } + /** + * Returns a new `CalendarDate` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $19485913bea41f19$exports.cycleDate)(this, field, amount, options); + } + /** + * Converts the date to a native JavaScript Date object, with the time set to midnight in the + * given time zone. + */ toDate(timeZone) { + return (0, $e13115b3b86b9007$exports.toDate)(this, timeZone); + } + /** Converts the date to an ISO 8601 formatted string. */ toString() { + return (0, $1b358053f79e3a77$exports.dateToString)(this); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + return (0, $84a63d30beb0af0f$exports.compareDate)(this, b); + } +} +class $c51b7e0106f45dea$export$680ea196effce5f { + // This prevents TypeScript from allowing other types with the same fields to match. + // @ts-ignore + #type; + constructor(hour = 0, minute = 0, second = 0, millisecond = 0){ + this.hour = hour; + this.minute = minute; + this.second = second; + this.millisecond = millisecond; + (0, $19485913bea41f19$exports.constrainTime)(this); + } + /** Returns a copy of this time. */ copy() { + return new $c51b7e0106f45dea$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `Time` with the given duration added to it. */ add(duration) { + return (0, $19485913bea41f19$exports.addTime)(this, duration); + } + /** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) { + return (0, $19485913bea41f19$exports.subtractTime)(this, duration); + } + /** + * Returns a new `Time` with the given fields set to the provided values. Other fields will be + * constrained accordingly. + */ set(fields) { + return (0, $19485913bea41f19$exports.setTime)(this, fields); + } + /** + * Returns a new `Time` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $19485913bea41f19$exports.cycleTime)(this, field, amount, options); + } + /** Converts the time to an ISO 8601 formatted string. */ toString() { + return (0, $1b358053f79e3a77$exports.timeToString)(this); + } + /** + * Compares this time with another. A negative result indicates that this time is before the given + * one, and a positive time indicates that it is after. + */ compare(b) { + return (0, $84a63d30beb0af0f$exports.compareTime)(this, b); + } +} +class $c51b7e0106f45dea$export$ca871e8dbb80966f { + // This prevents TypeScript from allowing other types with the same fields to match. + // @ts-ignore + #type; + constructor(...args){ + let [calendar, era, year, month, day] = $c51b7e0106f45dea$var$shiftArgs(args); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + this.hour = args.shift() || 0; + this.minute = args.shift() || 0; + this.second = args.shift() || 0; + this.millisecond = args.shift() || 0; + (0, $19485913bea41f19$exports.constrain)(this); + } + /** Returns a copy of this date. */ copy() { + if (this.era) return new $c51b7e0106f45dea$export$ca871e8dbb80966f(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + else return new $c51b7e0106f45dea$export$ca871e8dbb80966f(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `CalendarDateTime` with the given duration added to it. */ add(duration) { + return (0, $19485913bea41f19$exports.add)(this, duration); + } + /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */ subtract(duration) { + return (0, $19485913bea41f19$exports.subtract)(this, duration); + } + /** + * Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields) { + return (0, $19485913bea41f19$exports.set)((0, $19485913bea41f19$exports.setTime)(this, fields), fields); + } + /** + * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + switch(field){ + case 'era': + case 'year': + case 'month': + case 'day': + return (0, $19485913bea41f19$exports.cycleDate)(this, field, amount, options); + default: + return (0, $19485913bea41f19$exports.cycleTime)(this, field, amount, options); + } + } + /** Converts the date to a native JavaScript Date object in the given time zone. */ toDate(timeZone, disambiguation) { + return (0, $e13115b3b86b9007$exports.toDate)(this, timeZone, disambiguation); + } + /** Converts the date to an ISO 8601 formatted string. */ toString() { + return (0, $1b358053f79e3a77$exports.dateTimeToString)(this); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + let res = (0, $84a63d30beb0af0f$exports.compareDate)(this, b); + if (res === 0) return (0, $84a63d30beb0af0f$exports.compareTime)(this, (0, $e13115b3b86b9007$exports.toCalendarDateTime)(b)); + return res; + } +} +class $c51b7e0106f45dea$export$d3b7288e7994edea { + // This prevents TypeScript from allowing other types with the same fields to match. + // @ts-ignore + #type; + constructor(...args){ + let [calendar, era, year, month, day] = $c51b7e0106f45dea$var$shiftArgs(args); + let timeZone = args.shift(); + let offset = args.shift(); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + this.timeZone = timeZone; + this.offset = offset; + this.hour = args.shift() || 0; + this.minute = args.shift() || 0; + this.second = args.shift() || 0; + this.millisecond = args.shift() || 0; + (0, $19485913bea41f19$exports.constrain)(this); + } + /** Returns a copy of this date. */ copy() { + if (this.era) return new $c51b7e0106f45dea$export$d3b7288e7994edea(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond); + else return new $c51b7e0106f45dea$export$d3b7288e7994edea(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `ZonedDateTime` with the given duration added to it. */ add(duration) { + return (0, $19485913bea41f19$exports.addZoned)(this, duration); + } + /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */ subtract(duration) { + return (0, $19485913bea41f19$exports.subtractZoned)(this, duration); + } + /** + * Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields, disambiguation) { + return (0, $19485913bea41f19$exports.setZoned)(this, fields, disambiguation); + } + /** + * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $19485913bea41f19$exports.cycleZoned)(this, field, amount, options); + } + /** Converts the date to a native JavaScript Date object. */ toDate() { + return (0, $e13115b3b86b9007$exports.zonedToDate)(this); + } + /** + * Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone + * identifier. + */ toString() { + return (0, $1b358053f79e3a77$exports.zonedDateTimeToString)(this); + } + /** Converts the date to an ISO 8601 formatted string in UTC. */ toAbsoluteString() { + return this.toDate().toISOString(); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + // TODO: Is this a bad idea?? + return this.toDate().getTime() - (0, $e13115b3b86b9007$exports.toZoned)(b, this.timeZone).toDate().getTime(); + } +} + + +//# sourceMappingURL=CalendarDate.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/CalendarDate.cjs.map b/node_modules/@internationalized/date/dist/private/CalendarDate.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..2327c84632e09cb1733344be43e373504fe75519 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/CalendarDate.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAwCD,SAAS,gCAAU,IAAW;IAC5B,IAAI,WAAqB,OAAO,IAAI,CAAC,EAAE,KAAK,WAAW,KAAK,KAAK,KAAK,IAAI,CAAA,GAAA,2CAAgB;IAE1F,IAAI;IACJ,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,UACrB,MAAM,KAAK,KAAK;SACX;QACL,IAAI,OAAO,SAAS,OAAO;QAC3B,MAAM,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE;IAC7B;IAEA,IAAI,OAAO,KAAK,KAAK;IACrB,IAAI,QAAQ,KAAK,KAAK;IACtB,IAAI,MAAM,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EAAE,MAAc,EAAE,OAA0B,EAAiB;QAC7F,OAAO,CAAA,GAAA,oCAAS,EAAE,IAAI,EAAE,OAAO,QAAQ;IACzC;IAEA,0DAA0D,GAC1D,SAAe;QACb,OAAO,CAAA,GAAA,qCAAU,EAAE,IAAI;IACzB;IAEA;;;GAGC,GACD,WAAmB;QACjB,OAAO,CAAA,GAAA,+CAAoB,EAAE,IAAI;IACnC;IAEA,8DAA8D,GAC9D,mBAA2B;QACzB,OAAO,IAAI,CAAC,MAAM,GAAG,WAAW;IAClC;IAEA;;;GAGC,GACD,QAAQ,CAAkD,EAAU;QAClE,6BAA6B;QAC7B,OAAO,IAAI,CAAC,MAAM,GAAG,OAAO,KAAK,CAAA,GAAA,iCAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAC7E;AACF","sources":["packages/@internationalized/date/src/CalendarDate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n add,\n addTime,\n addZoned,\n constrain,\n constrainTime,\n cycleDate,\n cycleTime,\n cycleZoned,\n set,\n setTime,\n setZoned,\n subtract,\n subtractTime,\n subtractZoned\n} from './manipulation';\nimport {\n AnyCalendarDate,\n AnyTime,\n Calendar,\n CycleOptions,\n CycleTimeOptions,\n DateDuration,\n DateField,\n DateFields,\n DateTimeDuration,\n Disambiguation,\n TimeDuration,\n TimeField,\n TimeFields\n} from './types';\nimport {compareDate, compareTime} from './queries';\nimport {dateTimeToString, dateToString, timeToString, zonedDateTimeToString} from './string';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {toCalendarDateTime, toDate, toZoned, zonedToDate} from './conversion';\n\nexport type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;\n\nfunction shiftArgs(args: any[]) {\n let calendar: Calendar = typeof args[0] === 'object' ? args.shift() : new GregorianCalendar();\n\n let era: string;\n if (typeof args[0] === 'string') {\n era = args.shift();\n } else {\n let eras = calendar.getEras();\n era = eras[eras.length - 1];\n }\n\n let year = args.shift();\n let month = args.shift();\n let day = args.shift();\n\n return [calendar, era, year, month, day];\n}\n\n/** A CalendarDate represents a date without any time components in a specific calendar system. */\nexport class CalendarDate {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.\n // If that behavior is desired, use the AnyCalendarDate interface instead.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n\n constructor(year: number, month: number, day: number);\n constructor(era: string, year: number, month: number, day: number);\n constructor(calendar: Calendar, year: number, month: number, day: number);\n constructor(calendar: Calendar, era: string, year: number, month: number, day: number);\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDate {\n if (this.era) {\n return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);\n } else {\n return new CalendarDate(this.calendar, this.year, this.month, this.day);\n }\n }\n\n /** Returns a new `CalendarDate` with the given duration added to it. */\n add(duration: DateDuration): CalendarDate {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDate` with the given duration subtracted from it. */\n subtract(duration: DateDuration): CalendarDate {\n return subtract(this, duration);\n }\n\n /**\n * Returns a new `CalendarDate` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields): CalendarDate {\n return set(this, fields);\n }\n\n /**\n * Returns a new `CalendarDate` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField, amount: number, options?: CycleOptions): CalendarDate {\n return cycleDate(this, field, amount, options);\n }\n\n /**\n * Converts the date to a native JavaScript Date object, with the time set to midnight in the\n * given time zone.\n */\n toDate(timeZone: string): Date {\n return toDate(this, timeZone);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateToString(this);\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: AnyCalendarDate): number {\n return compareDate(this, b);\n }\n}\n\n/** A Time represents a clock time without any date components. */\nexport class Time {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The hour, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(hour: number = 0, minute: number = 0, second: number = 0, millisecond: number = 0) {\n this.hour = hour;\n this.minute = minute;\n this.second = second;\n this.millisecond = millisecond;\n constrainTime(this);\n }\n\n /** Returns a copy of this time. */\n copy(): Time {\n return new Time(this.hour, this.minute, this.second, this.millisecond);\n }\n\n /** Returns a new `Time` with the given duration added to it. */\n add(duration: TimeDuration): Time {\n return addTime(this, duration);\n }\n\n /** Returns a new `Time` with the given duration subtracted from it. */\n subtract(duration: TimeDuration): Time {\n return subtractTime(this, duration);\n }\n\n /**\n * Returns a new `Time` with the given fields set to the provided values. Other fields will be\n * constrained accordingly.\n */\n set(fields: TimeFields): Time {\n return setTime(this, fields);\n }\n\n /**\n * Returns a new `Time` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: TimeField, amount: number, options?: CycleTimeOptions): Time {\n return cycleTime(this, field, amount, options);\n }\n\n /** Converts the time to an ISO 8601 formatted string. */\n toString(): string {\n return timeToString(this);\n }\n\n /**\n * Compares this time with another. A negative result indicates that this time is before the given\n * one, and a positive time indicates that it is after.\n */\n compare(b: AnyTime): number {\n return compareTime(this, b);\n }\n}\n\n/** A CalendarDateTime represents a date and time without a time zone, in a specific calendar system. */\nexport class CalendarDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n era: string,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n era: string,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDateTime {\n if (this.era) {\n return new CalendarDateTime(\n this.calendar,\n this.era,\n this.year,\n this.month,\n this.day,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n } else {\n return new CalendarDateTime(\n this.calendar,\n this.year,\n this.month,\n this.day,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n }\n }\n\n /** Returns a new `CalendarDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): CalendarDateTime {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): CalendarDateTime {\n return subtract(this, duration);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields & TimeFields): CalendarDateTime {\n return set(setTime(this, fields), fields);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(\n field: DateField | TimeField,\n amount: number,\n options?: CycleTimeOptions\n ): CalendarDateTime {\n switch (field) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return cycleDate(this, field, amount, options);\n default:\n return cycleTime(this, field, amount, options);\n }\n }\n\n /** Converts the date to a native JavaScript Date object in the given time zone. */\n toDate(timeZone: string, disambiguation?: Disambiguation): Date {\n return toDate(this, timeZone, disambiguation);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateTimeToString(this);\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n let res = compareDate(this, b);\n if (res === 0) {\n return compareTime(this, toCalendarDateTime(b));\n }\n\n return res;\n }\n}\n\n/** A ZonedDateTime represents a date and time in a specific time zone and calendar system. */\nexport class ZonedDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n /** The IANA time zone identifier that this date and time is represented in. */\n public readonly timeZone: string;\n /** The UTC offset for this time, in milliseconds. */\n public readonly offset: number;\n\n constructor(\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n era: string,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n era: string,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n let timeZone = args.shift();\n let offset = args.shift();\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.timeZone = timeZone;\n this.offset = offset;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): ZonedDateTime {\n if (this.era) {\n return new ZonedDateTime(\n this.calendar,\n this.era,\n this.year,\n this.month,\n this.day,\n this.timeZone,\n this.offset,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n } else {\n return new ZonedDateTime(\n this.calendar,\n this.year,\n this.month,\n this.day,\n this.timeZone,\n this.offset,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n }\n }\n\n /** Returns a new `ZonedDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): ZonedDateTime {\n return addZoned(this, duration);\n }\n\n /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): ZonedDateTime {\n return subtractZoned(this, duration);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields & TimeFields, disambiguation?: Disambiguation): ZonedDateTime {\n return setZoned(this, fields, disambiguation);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions): ZonedDateTime {\n return cycleZoned(this, field, amount, options);\n }\n\n /** Converts the date to a native JavaScript Date object. */\n toDate(): Date {\n return zonedToDate(this);\n }\n\n /**\n * Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone\n * identifier.\n */\n toString(): string {\n return zonedDateTimeToString(this);\n }\n\n /** Converts the date to an ISO 8601 formatted string in UTC. */\n toAbsoluteString(): string {\n return this.toDate().toISOString();\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n // TODO: Is this a bad idea??\n return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();\n }\n}\n"],"names":[],"version":3,"file":"CalendarDate.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/CalendarDate.js b/node_modules/@internationalized/date/dist/private/CalendarDate.js new file mode 100644 index 0000000000000000000000000000000000000000..f5009220d98977974fc9117c6b75d00bdfb75f27 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/CalendarDate.js @@ -0,0 +1,282 @@ +import {add as $13bd2ffe0df4e09c$export$e16d8520af44a096, addTime as $13bd2ffe0df4e09c$export$7ed87b6bc2506470, addZoned as $13bd2ffe0df4e09c$export$96b1d28349274637, constrain as $13bd2ffe0df4e09c$export$c4e2ecac49351ef2, constrainTime as $13bd2ffe0df4e09c$export$7555de1e070510cb, cycleDate as $13bd2ffe0df4e09c$export$d52ced6badfb9a4c, cycleTime as $13bd2ffe0df4e09c$export$dd02b3e0007dfe28, cycleZoned as $13bd2ffe0df4e09c$export$9a297d111fc86b79, set as $13bd2ffe0df4e09c$export$adaa4cf7ef1b65be, setTime as $13bd2ffe0df4e09c$export$e5d5e1c1822b6e56, setZoned as $13bd2ffe0df4e09c$export$31b5430eb18be4f8, subtract as $13bd2ffe0df4e09c$export$4e2d2ead65e5f7e3, subtractTime as $13bd2ffe0df4e09c$export$fe34d3a381cd7501, subtractZoned as $13bd2ffe0df4e09c$export$6814caac34ca03c7} from "./manipulation.js"; +import {compareDate as $8daeb11568269f24$export$68781ddf31c0090f, compareTime as $8daeb11568269f24$export$c19a80a9721b80f6} from "./queries.js"; +import {dateTimeToString as $7dccf15509582627$export$4223de14708adc63, dateToString as $7dccf15509582627$export$60dfd74aa96791bd, timeToString as $7dccf15509582627$export$f59dee82248f5ad4, zonedDateTimeToString as $7dccf15509582627$export$bf79f1ebf4b18792} from "./string.js"; +import {GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.js"; +import {toCalendarDateTime as $e83297bd1a9e3ddc$export$b21e0b124e224484, toDate as $e83297bd1a9e3ddc$export$e67a095c620b86fe, toZoned as $e83297bd1a9e3ddc$export$84c95a83c799e074, zonedToDate as $e83297bd1a9e3ddc$export$83aac07b4c37b25} from "./conversion.js"; +import {_ as $iHuWX$_} from "@swc/helpers/_/_class_private_field_init"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + +function $9a4e222e1bd2b190$var$shiftArgs(args) { + let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec)(); + let era; + if (typeof args[0] === 'string') era = args.shift(); + else { + let eras = calendar.getEras(); + era = eras[eras.length - 1]; + } + let year = args.shift(); + let month = args.shift(); + let day = args.shift(); + return [ + calendar, + era, + year, + month, + day + ]; +} +var // This prevents TypeScript from allowing other types with the same fields to match. +// i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate. +// If that behavior is desired, use the AnyCalendarDate interface instead. +// @ts-ignore +$9a4e222e1bd2b190$var$_type = /*#__PURE__*/ new WeakMap(); +class $9a4e222e1bd2b190$export$99faa760c7908e4f { + /** Returns a copy of this date. */ copy() { + if (this.era) return new $9a4e222e1bd2b190$export$99faa760c7908e4f(this.calendar, this.era, this.year, this.month, this.day); + else return new $9a4e222e1bd2b190$export$99faa760c7908e4f(this.calendar, this.year, this.month, this.day); + } + /** Returns a new `CalendarDate` with the given duration added to it. */ add(duration) { + return (0, $13bd2ffe0df4e09c$export$e16d8520af44a096)(this, duration); + } + /** Returns a new `CalendarDate` with the given duration subtracted from it. */ subtract(duration) { + return (0, $13bd2ffe0df4e09c$export$4e2d2ead65e5f7e3)(this, duration); + } + /** + * Returns a new `CalendarDate` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields) { + return (0, $13bd2ffe0df4e09c$export$adaa4cf7ef1b65be)(this, fields); + } + /** + * Returns a new `CalendarDate` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $13bd2ffe0df4e09c$export$d52ced6badfb9a4c)(this, field, amount, options); + } + /** + * Converts the date to a native JavaScript Date object, with the time set to midnight in the + * given time zone. + */ toDate(timeZone) { + return (0, $e83297bd1a9e3ddc$export$e67a095c620b86fe)(this, timeZone); + } + /** Converts the date to an ISO 8601 formatted string. */ toString() { + return (0, $7dccf15509582627$export$60dfd74aa96791bd)(this); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + return (0, $8daeb11568269f24$export$68781ddf31c0090f)(this, b); + } + constructor(...args){ + (0, $iHuWX$_)(this, $9a4e222e1bd2b190$var$_type, { + writable: true, + value: void 0 + }); + let [calendar, era, year, month, day] = $9a4e222e1bd2b190$var$shiftArgs(args); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + (0, $13bd2ffe0df4e09c$export$c4e2ecac49351ef2)(this); + } +} +var // This prevents TypeScript from allowing other types with the same fields to match. +// @ts-ignore +$9a4e222e1bd2b190$var$_type1 = /*#__PURE__*/ new WeakMap(); +class $9a4e222e1bd2b190$export$680ea196effce5f { + /** Returns a copy of this time. */ copy() { + return new $9a4e222e1bd2b190$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `Time` with the given duration added to it. */ add(duration) { + return (0, $13bd2ffe0df4e09c$export$7ed87b6bc2506470)(this, duration); + } + /** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) { + return (0, $13bd2ffe0df4e09c$export$fe34d3a381cd7501)(this, duration); + } + /** + * Returns a new `Time` with the given fields set to the provided values. Other fields will be + * constrained accordingly. + */ set(fields) { + return (0, $13bd2ffe0df4e09c$export$e5d5e1c1822b6e56)(this, fields); + } + /** + * Returns a new `Time` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $13bd2ffe0df4e09c$export$dd02b3e0007dfe28)(this, field, amount, options); + } + /** Converts the time to an ISO 8601 formatted string. */ toString() { + return (0, $7dccf15509582627$export$f59dee82248f5ad4)(this); + } + /** + * Compares this time with another. A negative result indicates that this time is before the given + * one, and a positive time indicates that it is after. + */ compare(b) { + return (0, $8daeb11568269f24$export$c19a80a9721b80f6)(this, b); + } + constructor(hour = 0, minute = 0, second = 0, millisecond = 0){ + (0, $iHuWX$_)(this, $9a4e222e1bd2b190$var$_type1, { + writable: true, + value: void 0 + }); + this.hour = hour; + this.minute = minute; + this.second = second; + this.millisecond = millisecond; + (0, $13bd2ffe0df4e09c$export$7555de1e070510cb)(this); + } +} +var // This prevents TypeScript from allowing other types with the same fields to match. +// @ts-ignore +$9a4e222e1bd2b190$var$_type2 = /*#__PURE__*/ new WeakMap(); +class $9a4e222e1bd2b190$export$ca871e8dbb80966f { + /** Returns a copy of this date. */ copy() { + if (this.era) return new $9a4e222e1bd2b190$export$ca871e8dbb80966f(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + else return new $9a4e222e1bd2b190$export$ca871e8dbb80966f(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `CalendarDateTime` with the given duration added to it. */ add(duration) { + return (0, $13bd2ffe0df4e09c$export$e16d8520af44a096)(this, duration); + } + /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */ subtract(duration) { + return (0, $13bd2ffe0df4e09c$export$4e2d2ead65e5f7e3)(this, duration); + } + /** + * Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields) { + return (0, $13bd2ffe0df4e09c$export$adaa4cf7ef1b65be)((0, $13bd2ffe0df4e09c$export$e5d5e1c1822b6e56)(this, fields), fields); + } + /** + * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + switch(field){ + case 'era': + case 'year': + case 'month': + case 'day': + return (0, $13bd2ffe0df4e09c$export$d52ced6badfb9a4c)(this, field, amount, options); + default: + return (0, $13bd2ffe0df4e09c$export$dd02b3e0007dfe28)(this, field, amount, options); + } + } + /** Converts the date to a native JavaScript Date object in the given time zone. */ toDate(timeZone, disambiguation) { + return (0, $e83297bd1a9e3ddc$export$e67a095c620b86fe)(this, timeZone, disambiguation); + } + /** Converts the date to an ISO 8601 formatted string. */ toString() { + return (0, $7dccf15509582627$export$4223de14708adc63)(this); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + let res = (0, $8daeb11568269f24$export$68781ddf31c0090f)(this, b); + if (res === 0) return (0, $8daeb11568269f24$export$c19a80a9721b80f6)(this, (0, $e83297bd1a9e3ddc$export$b21e0b124e224484)(b)); + return res; + } + constructor(...args){ + (0, $iHuWX$_)(this, $9a4e222e1bd2b190$var$_type2, { + writable: true, + value: void 0 + }); + let [calendar, era, year, month, day] = $9a4e222e1bd2b190$var$shiftArgs(args); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + this.hour = args.shift() || 0; + this.minute = args.shift() || 0; + this.second = args.shift() || 0; + this.millisecond = args.shift() || 0; + (0, $13bd2ffe0df4e09c$export$c4e2ecac49351ef2)(this); + } +} +var // This prevents TypeScript from allowing other types with the same fields to match. +// @ts-ignore +$9a4e222e1bd2b190$var$_type3 = /*#__PURE__*/ new WeakMap(); +class $9a4e222e1bd2b190$export$d3b7288e7994edea { + /** Returns a copy of this date. */ copy() { + if (this.era) return new $9a4e222e1bd2b190$export$d3b7288e7994edea(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond); + else return new $9a4e222e1bd2b190$export$d3b7288e7994edea(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `ZonedDateTime` with the given duration added to it. */ add(duration) { + return (0, $13bd2ffe0df4e09c$export$96b1d28349274637)(this, duration); + } + /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */ subtract(duration) { + return (0, $13bd2ffe0df4e09c$export$6814caac34ca03c7)(this, duration); + } + /** + * Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields, disambiguation) { + return (0, $13bd2ffe0df4e09c$export$31b5430eb18be4f8)(this, fields, disambiguation); + } + /** + * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $13bd2ffe0df4e09c$export$9a297d111fc86b79)(this, field, amount, options); + } + /** Converts the date to a native JavaScript Date object. */ toDate() { + return (0, $e83297bd1a9e3ddc$export$83aac07b4c37b25)(this); + } + /** + * Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone + * identifier. + */ toString() { + return (0, $7dccf15509582627$export$bf79f1ebf4b18792)(this); + } + /** Converts the date to an ISO 8601 formatted string in UTC. */ toAbsoluteString() { + return this.toDate().toISOString(); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + // TODO: Is this a bad idea?? + return this.toDate().getTime() - (0, $e83297bd1a9e3ddc$export$84c95a83c799e074)(b, this.timeZone).toDate().getTime(); + } + constructor(...args){ + (0, $iHuWX$_)(this, $9a4e222e1bd2b190$var$_type3, { + writable: true, + value: void 0 + }); + let [calendar, era, year, month, day] = $9a4e222e1bd2b190$var$shiftArgs(args); + let timeZone = args.shift(); + let offset = args.shift(); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + this.timeZone = timeZone; + this.offset = offset; + this.hour = args.shift() || 0; + this.minute = args.shift() || 0; + this.second = args.shift() || 0; + this.millisecond = args.shift() || 0; + (0, $13bd2ffe0df4e09c$export$c4e2ecac49351ef2)(this); + } +} + + +export {$9a4e222e1bd2b190$export$99faa760c7908e4f as CalendarDate, $9a4e222e1bd2b190$export$680ea196effce5f as Time, $9a4e222e1bd2b190$export$ca871e8dbb80966f as CalendarDateTime, $9a4e222e1bd2b190$export$d3b7288e7994edea as ZonedDateTime}; +//# sourceMappingURL=CalendarDate.js.map diff --git a/node_modules/@internationalized/date/dist/private/CalendarDate.js.map b/node_modules/@internationalized/date/dist/private/CalendarDate.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f84f069a14fd7b3fe219e45090690834c36393df --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/CalendarDate.js.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAwCD,SAAS,gCAAU,IAAW;IAC5B,IAAI,WAAqB,OAAO,IAAI,CAAC,EAAE,KAAK,WAAW,KAAK,KAAK,KAAK,IAAI,CAAA,GAAA,yCAAgB;IAE1F,IAAI;IACJ,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,UACrB,MAAM,KAAK,KAAK;SACX;QACL,IAAI,OAAO,SAAS,OAAO;QAC3B,MAAM,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE;IAC7B;IAEA,IAAI,OAAO,KAAK,KAAK;IACrB,IAAI,QAAQ,KAAK,KAAK;IACtB,IAAI,MAAM,KAAK,KAAK;IAEpB,OAAO;QAAC;QAAU;QAAK;QAAM;QAAO;KAAI;AAC1C;IAIE,oFAAoF;AACpF,2FAA2F;AAC3F,0EAA0E;AAC1E,aAAa;AACb;AALK,MAAM;IAoCX,iCAAiC,GACjC,OAAqB;QACnB,IAAI,IAAI,CAAC,GAAG,EACV,OAAO,IAAI,0CAAa,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG;aAEhF,OAAO,IAAI,0CAAa,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG;IAE1E;IAEA,sEAAsE,GACtE,IAAI,QAAsB,EAAgB;QACxC,OAA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AAG,KAAK,KAAK,MAAM;QAEnC,CAAA,GAAA,yCAAQ,EAAE,IAAI;IAChB;AAsFF","sources":["packages/@internationalized/date/src/CalendarDate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n add,\n addTime,\n addZoned,\n constrain,\n constrainTime,\n cycleDate,\n cycleTime,\n cycleZoned,\n set,\n setTime,\n setZoned,\n subtract,\n subtractTime,\n subtractZoned\n} from './manipulation';\nimport {\n AnyCalendarDate,\n AnyTime,\n Calendar,\n CycleOptions,\n CycleTimeOptions,\n DateDuration,\n DateField,\n DateFields,\n DateTimeDuration,\n Disambiguation,\n TimeDuration,\n TimeField,\n TimeFields\n} from './types';\nimport {compareDate, compareTime} from './queries';\nimport {dateTimeToString, dateToString, timeToString, zonedDateTimeToString} from './string';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {toCalendarDateTime, toDate, toZoned, zonedToDate} from './conversion';\n\nexport type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;\n\nfunction shiftArgs(args: any[]) {\n let calendar: Calendar = typeof args[0] === 'object' ? args.shift() : new GregorianCalendar();\n\n let era: string;\n if (typeof args[0] === 'string') {\n era = args.shift();\n } else {\n let eras = calendar.getEras();\n era = eras[eras.length - 1];\n }\n\n let year = args.shift();\n let month = args.shift();\n let day = args.shift();\n\n return [calendar, era, year, month, day];\n}\n\n/** A CalendarDate represents a date without any time components in a specific calendar system. */\nexport class CalendarDate {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.\n // If that behavior is desired, use the AnyCalendarDate interface instead.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n\n constructor(year: number, month: number, day: number);\n constructor(era: string, year: number, month: number, day: number);\n constructor(calendar: Calendar, year: number, month: number, day: number);\n constructor(calendar: Calendar, era: string, year: number, month: number, day: number);\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDate {\n if (this.era) {\n return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);\n } else {\n return new CalendarDate(this.calendar, this.year, this.month, this.day);\n }\n }\n\n /** Returns a new `CalendarDate` with the given duration added to it. */\n add(duration: DateDuration): CalendarDate {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDate` with the given duration subtracted from it. */\n subtract(duration: DateDuration): CalendarDate {\n return subtract(this, duration);\n }\n\n /**\n * Returns a new `CalendarDate` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields): CalendarDate {\n return set(this, fields);\n }\n\n /**\n * Returns a new `CalendarDate` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField, amount: number, options?: CycleOptions): CalendarDate {\n return cycleDate(this, field, amount, options);\n }\n\n /**\n * Converts the date to a native JavaScript Date object, with the time set to midnight in the\n * given time zone.\n */\n toDate(timeZone: string): Date {\n return toDate(this, timeZone);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateToString(this);\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: AnyCalendarDate): number {\n return compareDate(this, b);\n }\n}\n\n/** A Time represents a clock time without any date components. */\nexport class Time {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The hour, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(hour: number = 0, minute: number = 0, second: number = 0, millisecond: number = 0) {\n this.hour = hour;\n this.minute = minute;\n this.second = second;\n this.millisecond = millisecond;\n constrainTime(this);\n }\n\n /** Returns a copy of this time. */\n copy(): Time {\n return new Time(this.hour, this.minute, this.second, this.millisecond);\n }\n\n /** Returns a new `Time` with the given duration added to it. */\n add(duration: TimeDuration): Time {\n return addTime(this, duration);\n }\n\n /** Returns a new `Time` with the given duration subtracted from it. */\n subtract(duration: TimeDuration): Time {\n return subtractTime(this, duration);\n }\n\n /**\n * Returns a new `Time` with the given fields set to the provided values. Other fields will be\n * constrained accordingly.\n */\n set(fields: TimeFields): Time {\n return setTime(this, fields);\n }\n\n /**\n * Returns a new `Time` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: TimeField, amount: number, options?: CycleTimeOptions): Time {\n return cycleTime(this, field, amount, options);\n }\n\n /** Converts the time to an ISO 8601 formatted string. */\n toString(): string {\n return timeToString(this);\n }\n\n /**\n * Compares this time with another. A negative result indicates that this time is before the given\n * one, and a positive time indicates that it is after.\n */\n compare(b: AnyTime): number {\n return compareTime(this, b);\n }\n}\n\n/** A CalendarDateTime represents a date and time without a time zone, in a specific calendar system. */\nexport class CalendarDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n era: string,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n era: string,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDateTime {\n if (this.era) {\n return new CalendarDateTime(\n this.calendar,\n this.era,\n this.year,\n this.month,\n this.day,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n } else {\n return new CalendarDateTime(\n this.calendar,\n this.year,\n this.month,\n this.day,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n }\n }\n\n /** Returns a new `CalendarDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): CalendarDateTime {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): CalendarDateTime {\n return subtract(this, duration);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields & TimeFields): CalendarDateTime {\n return set(setTime(this, fields), fields);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(\n field: DateField | TimeField,\n amount: number,\n options?: CycleTimeOptions\n ): CalendarDateTime {\n switch (field) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return cycleDate(this, field, amount, options);\n default:\n return cycleTime(this, field, amount, options);\n }\n }\n\n /** Converts the date to a native JavaScript Date object in the given time zone. */\n toDate(timeZone: string, disambiguation?: Disambiguation): Date {\n return toDate(this, timeZone, disambiguation);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateTimeToString(this);\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n let res = compareDate(this, b);\n if (res === 0) {\n return compareTime(this, toCalendarDateTime(b));\n }\n\n return res;\n }\n}\n\n/** A ZonedDateTime represents a date and time in a specific time zone and calendar system. */\nexport class ZonedDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n /** The IANA time zone identifier that this date and time is represented in. */\n public readonly timeZone: string;\n /** The UTC offset for this time, in milliseconds. */\n public readonly offset: number;\n\n constructor(\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n era: string,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n era: string,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n let timeZone = args.shift();\n let offset = args.shift();\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.timeZone = timeZone;\n this.offset = offset;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): ZonedDateTime {\n if (this.era) {\n return new ZonedDateTime(\n this.calendar,\n this.era,\n this.year,\n this.month,\n this.day,\n this.timeZone,\n this.offset,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n } else {\n return new ZonedDateTime(\n this.calendar,\n this.year,\n this.month,\n this.day,\n this.timeZone,\n this.offset,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n }\n }\n\n /** Returns a new `ZonedDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): ZonedDateTime {\n return addZoned(this, duration);\n }\n\n /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): ZonedDateTime {\n return subtractZoned(this, duration);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields & TimeFields, disambiguation?: Disambiguation): ZonedDateTime {\n return setZoned(this, fields, disambiguation);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions): ZonedDateTime {\n return cycleZoned(this, field, amount, options);\n }\n\n /** Converts the date to a native JavaScript Date object. */\n toDate(): Date {\n return zonedToDate(this);\n }\n\n /**\n * Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone\n * identifier.\n */\n toString(): string {\n return zonedDateTimeToString(this);\n }\n\n /** Converts the date to an ISO 8601 formatted string in UTC. */\n toAbsoluteString(): string {\n return this.toDate().toISOString();\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n // TODO: Is this a bad idea??\n return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();\n }\n}\n"],"names":[],"version":3,"file":"CalendarDate.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/CalendarDate.mjs b/node_modules/@internationalized/date/dist/private/CalendarDate.mjs new file mode 100644 index 0000000000000000000000000000000000000000..45bbf4d02414219e7f3309f762174de8e50e0320 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/CalendarDate.mjs @@ -0,0 +1,264 @@ +import {add as $435a2ceaa8778ed8$export$e16d8520af44a096, addTime as $435a2ceaa8778ed8$export$7ed87b6bc2506470, addZoned as $435a2ceaa8778ed8$export$96b1d28349274637, constrain as $435a2ceaa8778ed8$export$c4e2ecac49351ef2, constrainTime as $435a2ceaa8778ed8$export$7555de1e070510cb, cycleDate as $435a2ceaa8778ed8$export$d52ced6badfb9a4c, cycleTime as $435a2ceaa8778ed8$export$dd02b3e0007dfe28, cycleZoned as $435a2ceaa8778ed8$export$9a297d111fc86b79, set as $435a2ceaa8778ed8$export$adaa4cf7ef1b65be, setTime as $435a2ceaa8778ed8$export$e5d5e1c1822b6e56, setZoned as $435a2ceaa8778ed8$export$31b5430eb18be4f8, subtract as $435a2ceaa8778ed8$export$4e2d2ead65e5f7e3, subtractTime as $435a2ceaa8778ed8$export$fe34d3a381cd7501, subtractZoned as $435a2ceaa8778ed8$export$6814caac34ca03c7} from "./manipulation.mjs"; +import {compareDate as $ad063034c8620db8$export$68781ddf31c0090f, compareTime as $ad063034c8620db8$export$c19a80a9721b80f6} from "./queries.mjs"; +import {dateTimeToString as $58246871e4652552$export$4223de14708adc63, dateToString as $58246871e4652552$export$60dfd74aa96791bd, timeToString as $58246871e4652552$export$f59dee82248f5ad4, zonedDateTimeToString as $58246871e4652552$export$bf79f1ebf4b18792} from "./string.mjs"; +import {GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.mjs"; +import {toCalendarDateTime as $d07e34cce18680fd$export$b21e0b124e224484, toDate as $d07e34cce18680fd$export$e67a095c620b86fe, toZoned as $d07e34cce18680fd$export$84c95a83c799e074, zonedToDate as $d07e34cce18680fd$export$83aac07b4c37b25} from "./conversion.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + +function $2aaf608024c21ca1$var$shiftArgs(args) { + let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $93635573935797de$export$80ee6245ec4f29ec)(); + let era; + if (typeof args[0] === 'string') era = args.shift(); + else { + let eras = calendar.getEras(); + era = eras[eras.length - 1]; + } + let year = args.shift(); + let month = args.shift(); + let day = args.shift(); + return [ + calendar, + era, + year, + month, + day + ]; +} +class $2aaf608024c21ca1$export$99faa760c7908e4f { + // This prevents TypeScript from allowing other types with the same fields to match. + // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate. + // If that behavior is desired, use the AnyCalendarDate interface instead. + // @ts-ignore + #type; + constructor(...args){ + let [calendar, era, year, month, day] = $2aaf608024c21ca1$var$shiftArgs(args); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + (0, $435a2ceaa8778ed8$export$c4e2ecac49351ef2)(this); + } + /** Returns a copy of this date. */ copy() { + if (this.era) return new $2aaf608024c21ca1$export$99faa760c7908e4f(this.calendar, this.era, this.year, this.month, this.day); + else return new $2aaf608024c21ca1$export$99faa760c7908e4f(this.calendar, this.year, this.month, this.day); + } + /** Returns a new `CalendarDate` with the given duration added to it. */ add(duration) { + return (0, $435a2ceaa8778ed8$export$e16d8520af44a096)(this, duration); + } + /** Returns a new `CalendarDate` with the given duration subtracted from it. */ subtract(duration) { + return (0, $435a2ceaa8778ed8$export$4e2d2ead65e5f7e3)(this, duration); + } + /** + * Returns a new `CalendarDate` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields) { + return (0, $435a2ceaa8778ed8$export$adaa4cf7ef1b65be)(this, fields); + } + /** + * Returns a new `CalendarDate` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $435a2ceaa8778ed8$export$d52ced6badfb9a4c)(this, field, amount, options); + } + /** + * Converts the date to a native JavaScript Date object, with the time set to midnight in the + * given time zone. + */ toDate(timeZone) { + return (0, $d07e34cce18680fd$export$e67a095c620b86fe)(this, timeZone); + } + /** Converts the date to an ISO 8601 formatted string. */ toString() { + return (0, $58246871e4652552$export$60dfd74aa96791bd)(this); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + return (0, $ad063034c8620db8$export$68781ddf31c0090f)(this, b); + } +} +class $2aaf608024c21ca1$export$680ea196effce5f { + // This prevents TypeScript from allowing other types with the same fields to match. + // @ts-ignore + #type; + constructor(hour = 0, minute = 0, second = 0, millisecond = 0){ + this.hour = hour; + this.minute = minute; + this.second = second; + this.millisecond = millisecond; + (0, $435a2ceaa8778ed8$export$7555de1e070510cb)(this); + } + /** Returns a copy of this time. */ copy() { + return new $2aaf608024c21ca1$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `Time` with the given duration added to it. */ add(duration) { + return (0, $435a2ceaa8778ed8$export$7ed87b6bc2506470)(this, duration); + } + /** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) { + return (0, $435a2ceaa8778ed8$export$fe34d3a381cd7501)(this, duration); + } + /** + * Returns a new `Time` with the given fields set to the provided values. Other fields will be + * constrained accordingly. + */ set(fields) { + return (0, $435a2ceaa8778ed8$export$e5d5e1c1822b6e56)(this, fields); + } + /** + * Returns a new `Time` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $435a2ceaa8778ed8$export$dd02b3e0007dfe28)(this, field, amount, options); + } + /** Converts the time to an ISO 8601 formatted string. */ toString() { + return (0, $58246871e4652552$export$f59dee82248f5ad4)(this); + } + /** + * Compares this time with another. A negative result indicates that this time is before the given + * one, and a positive time indicates that it is after. + */ compare(b) { + return (0, $ad063034c8620db8$export$c19a80a9721b80f6)(this, b); + } +} +class $2aaf608024c21ca1$export$ca871e8dbb80966f { + // This prevents TypeScript from allowing other types with the same fields to match. + // @ts-ignore + #type; + constructor(...args){ + let [calendar, era, year, month, day] = $2aaf608024c21ca1$var$shiftArgs(args); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + this.hour = args.shift() || 0; + this.minute = args.shift() || 0; + this.second = args.shift() || 0; + this.millisecond = args.shift() || 0; + (0, $435a2ceaa8778ed8$export$c4e2ecac49351ef2)(this); + } + /** Returns a copy of this date. */ copy() { + if (this.era) return new $2aaf608024c21ca1$export$ca871e8dbb80966f(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + else return new $2aaf608024c21ca1$export$ca871e8dbb80966f(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `CalendarDateTime` with the given duration added to it. */ add(duration) { + return (0, $435a2ceaa8778ed8$export$e16d8520af44a096)(this, duration); + } + /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */ subtract(duration) { + return (0, $435a2ceaa8778ed8$export$4e2d2ead65e5f7e3)(this, duration); + } + /** + * Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields) { + return (0, $435a2ceaa8778ed8$export$adaa4cf7ef1b65be)((0, $435a2ceaa8778ed8$export$e5d5e1c1822b6e56)(this, fields), fields); + } + /** + * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + switch(field){ + case 'era': + case 'year': + case 'month': + case 'day': + return (0, $435a2ceaa8778ed8$export$d52ced6badfb9a4c)(this, field, amount, options); + default: + return (0, $435a2ceaa8778ed8$export$dd02b3e0007dfe28)(this, field, amount, options); + } + } + /** Converts the date to a native JavaScript Date object in the given time zone. */ toDate(timeZone, disambiguation) { + return (0, $d07e34cce18680fd$export$e67a095c620b86fe)(this, timeZone, disambiguation); + } + /** Converts the date to an ISO 8601 formatted string. */ toString() { + return (0, $58246871e4652552$export$4223de14708adc63)(this); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + let res = (0, $ad063034c8620db8$export$68781ddf31c0090f)(this, b); + if (res === 0) return (0, $ad063034c8620db8$export$c19a80a9721b80f6)(this, (0, $d07e34cce18680fd$export$b21e0b124e224484)(b)); + return res; + } +} +class $2aaf608024c21ca1$export$d3b7288e7994edea { + // This prevents TypeScript from allowing other types with the same fields to match. + // @ts-ignore + #type; + constructor(...args){ + let [calendar, era, year, month, day] = $2aaf608024c21ca1$var$shiftArgs(args); + let timeZone = args.shift(); + let offset = args.shift(); + this.calendar = calendar; + this.era = era; + this.year = year; + this.month = month; + this.day = day; + this.timeZone = timeZone; + this.offset = offset; + this.hour = args.shift() || 0; + this.minute = args.shift() || 0; + this.second = args.shift() || 0; + this.millisecond = args.shift() || 0; + (0, $435a2ceaa8778ed8$export$c4e2ecac49351ef2)(this); + } + /** Returns a copy of this date. */ copy() { + if (this.era) return new $2aaf608024c21ca1$export$d3b7288e7994edea(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond); + else return new $2aaf608024c21ca1$export$d3b7288e7994edea(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond); + } + /** Returns a new `ZonedDateTime` with the given duration added to it. */ add(duration) { + return (0, $435a2ceaa8778ed8$export$96b1d28349274637)(this, duration); + } + /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */ subtract(duration) { + return (0, $435a2ceaa8778ed8$export$6814caac34ca03c7)(this, duration); + } + /** + * Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields + * will be constrained accordingly. + */ set(fields, disambiguation) { + return (0, $435a2ceaa8778ed8$export$31b5430eb18be4f8)(this, fields, disambiguation); + } + /** + * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount. + * When the resulting value reaches the limits of the field, it wraps around. + */ cycle(field, amount, options) { + return (0, $435a2ceaa8778ed8$export$9a297d111fc86b79)(this, field, amount, options); + } + /** Converts the date to a native JavaScript Date object. */ toDate() { + return (0, $d07e34cce18680fd$export$83aac07b4c37b25)(this); + } + /** + * Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone + * identifier. + */ toString() { + return (0, $58246871e4652552$export$bf79f1ebf4b18792)(this); + } + /** Converts the date to an ISO 8601 formatted string in UTC. */ toAbsoluteString() { + return this.toDate().toISOString(); + } + /** + * Compares this date with another. A negative result indicates that this date is before the given + * one, and a positive date indicates that it is after. + */ compare(b) { + // TODO: Is this a bad idea?? + return this.toDate().getTime() - (0, $d07e34cce18680fd$export$84c95a83c799e074)(b, this.timeZone).toDate().getTime(); + } +} + + +export {$2aaf608024c21ca1$export$99faa760c7908e4f as CalendarDate, $2aaf608024c21ca1$export$680ea196effce5f as Time, $2aaf608024c21ca1$export$ca871e8dbb80966f as CalendarDateTime, $2aaf608024c21ca1$export$d3b7288e7994edea as ZonedDateTime}; +//# sourceMappingURL=CalendarDate.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/CalendarDate.mjs.map b/node_modules/@internationalized/date/dist/private/CalendarDate.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..2f4aa8c69ddc1d6d11877e19bd76816b49d483a0 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/CalendarDate.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAwCD,SAAS,gCAAU,IAAW;IAC5B,IAAI,WAAqB,OAAO,IAAI,CAAC,EAAE,KAAK,WAAW,KAAK,KAAK,KAAK,IAAI,CAAA,GAAA,yCAAgB;IAE1F,IAAI;IACJ,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,UACrB,MAAM,KAAK,KAAK;SACX;QACL,IAAI,OAAO,SAAS,OAAO;QAC3B,MAAM,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE;IAC7B;IAEA,IAAI,OAAO,KAAK,KAAK;IACrB,IAAI,QAAQ,KAAK,KAAK;IACtB,IAAI,MAAM,KAAK,KAAK;IAEpB,OAAO;QAAC;QAAU;QAAK;QAAM;QAAO;KAAI;AAC1C;AAGO,MAAM;IACX,oFAAoF;IACpF,2FAA2F;IAC3F,0EAA0E;IAC1E,aAAa;IACb,CAAA,IAAK,CAAC;IAoBN,YAAY,GAAG,IAAW,CAAE;QAC1B,IAAI,CAAC,UAAU,KAAK,MAAM,OAAO,IAAI,GAAG,gCAAU;QAClD,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAA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I,CAAC,MAAM,GAAG,WAAW;IAClC;IAEA;;;GAGC,GACD,QAAQ,CAAkD,EAAU;QAClE,6BAA6B;QAC7B,OAAO,IAAI,CAAC,MAAM,GAAG,OAAO,KAAK,CAAA,GAAA,yCAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAC7E;AACF","sources":["packages/@internationalized/date/src/CalendarDate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n add,\n addTime,\n addZoned,\n constrain,\n constrainTime,\n cycleDate,\n cycleTime,\n cycleZoned,\n set,\n setTime,\n setZoned,\n subtract,\n subtractTime,\n subtractZoned\n} from './manipulation';\nimport {\n AnyCalendarDate,\n AnyTime,\n Calendar,\n CycleOptions,\n CycleTimeOptions,\n DateDuration,\n DateField,\n DateFields,\n DateTimeDuration,\n Disambiguation,\n TimeDuration,\n TimeField,\n TimeFields\n} from './types';\nimport {compareDate, compareTime} from './queries';\nimport {dateTimeToString, dateToString, timeToString, zonedDateTimeToString} from './string';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {toCalendarDateTime, toDate, toZoned, zonedToDate} from './conversion';\n\nexport type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;\n\nfunction shiftArgs(args: any[]) {\n let calendar: Calendar = typeof args[0] === 'object' ? args.shift() : new GregorianCalendar();\n\n let era: string;\n if (typeof args[0] === 'string') {\n era = args.shift();\n } else {\n let eras = calendar.getEras();\n era = eras[eras.length - 1];\n }\n\n let year = args.shift();\n let month = args.shift();\n let day = args.shift();\n\n return [calendar, era, year, month, day];\n}\n\n/** A CalendarDate represents a date without any time components in a specific calendar system. */\nexport class CalendarDate {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.\n // If that behavior is desired, use the AnyCalendarDate interface instead.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n\n constructor(year: number, month: number, day: number);\n constructor(era: string, year: number, month: number, day: number);\n constructor(calendar: Calendar, year: number, month: number, day: number);\n constructor(calendar: Calendar, era: string, year: number, month: number, day: number);\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDate {\n if (this.era) {\n return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);\n } else {\n return new CalendarDate(this.calendar, this.year, this.month, this.day);\n }\n }\n\n /** Returns a new `CalendarDate` with the given duration added to it. */\n add(duration: DateDuration): CalendarDate {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDate` with the given duration subtracted from it. */\n subtract(duration: DateDuration): CalendarDate {\n return subtract(this, duration);\n }\n\n /**\n * Returns a new `CalendarDate` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields): CalendarDate {\n return set(this, fields);\n }\n\n /**\n * Returns a new `CalendarDate` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField, amount: number, options?: CycleOptions): CalendarDate {\n return cycleDate(this, field, amount, options);\n }\n\n /**\n * Converts the date to a native JavaScript Date object, with the time set to midnight in the\n * given time zone.\n */\n toDate(timeZone: string): Date {\n return toDate(this, timeZone);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateToString(this);\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: AnyCalendarDate): number {\n return compareDate(this, b);\n }\n}\n\n/** A Time represents a clock time without any date components. */\nexport class Time {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The hour, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(hour: number = 0, minute: number = 0, second: number = 0, millisecond: number = 0) {\n this.hour = hour;\n this.minute = minute;\n this.second = second;\n this.millisecond = millisecond;\n constrainTime(this);\n }\n\n /** Returns a copy of this time. */\n copy(): Time {\n return new Time(this.hour, this.minute, this.second, this.millisecond);\n }\n\n /** Returns a new `Time` with the given duration added to it. */\n add(duration: TimeDuration): Time {\n return addTime(this, duration);\n }\n\n /** Returns a new `Time` with the given duration subtracted from it. */\n subtract(duration: TimeDuration): Time {\n return subtractTime(this, duration);\n }\n\n /**\n * Returns a new `Time` with the given fields set to the provided values. Other fields will be\n * constrained accordingly.\n */\n set(fields: TimeFields): Time {\n return setTime(this, fields);\n }\n\n /**\n * Returns a new `Time` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: TimeField, amount: number, options?: CycleTimeOptions): Time {\n return cycleTime(this, field, amount, options);\n }\n\n /** Converts the time to an ISO 8601 formatted string. */\n toString(): string {\n return timeToString(this);\n }\n\n /**\n * Compares this time with another. A negative result indicates that this time is before the given\n * one, and a positive time indicates that it is after.\n */\n compare(b: AnyTime): number {\n return compareTime(this, b);\n }\n}\n\n/** A CalendarDateTime represents a date and time without a time zone, in a specific calendar system. */\nexport class CalendarDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n era: string,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n era: string,\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDateTime {\n if (this.era) {\n return new CalendarDateTime(\n this.calendar,\n this.era,\n this.year,\n this.month,\n this.day,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n } else {\n return new CalendarDateTime(\n this.calendar,\n this.year,\n this.month,\n this.day,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n }\n }\n\n /** Returns a new `CalendarDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): CalendarDateTime {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): CalendarDateTime {\n return subtract(this, duration);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields & TimeFields): CalendarDateTime {\n return set(setTime(this, fields), fields);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(\n field: DateField | TimeField,\n amount: number,\n options?: CycleTimeOptions\n ): CalendarDateTime {\n switch (field) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return cycleDate(this, field, amount, options);\n default:\n return cycleTime(this, field, amount, options);\n }\n }\n\n /** Converts the date to a native JavaScript Date object in the given time zone. */\n toDate(timeZone: string, disambiguation?: Disambiguation): Date {\n return toDate(this, timeZone, disambiguation);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateTimeToString(this);\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n let res = compareDate(this, b);\n if (res === 0) {\n return compareTime(this, toCalendarDateTime(b));\n }\n\n return res;\n }\n}\n\n/** A ZonedDateTime represents a date and time in a specific time zone and calendar system. */\nexport class ZonedDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n /** The IANA time zone identifier that this date and time is represented in. */\n public readonly timeZone: string;\n /** The UTC offset for this time, in milliseconds. */\n public readonly offset: number;\n\n constructor(\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n era: string,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(\n calendar: Calendar,\n era: string,\n year: number,\n month: number,\n day: number,\n timeZone: string,\n offset: number,\n hour?: number,\n minute?: number,\n second?: number,\n millisecond?: number\n );\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n let timeZone = args.shift();\n let offset = args.shift();\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.timeZone = timeZone;\n this.offset = offset;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): ZonedDateTime {\n if (this.era) {\n return new ZonedDateTime(\n this.calendar,\n this.era,\n this.year,\n this.month,\n this.day,\n this.timeZone,\n this.offset,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n } else {\n return new ZonedDateTime(\n this.calendar,\n this.year,\n this.month,\n this.day,\n this.timeZone,\n this.offset,\n this.hour,\n this.minute,\n this.second,\n this.millisecond\n );\n }\n }\n\n /** Returns a new `ZonedDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): ZonedDateTime {\n return addZoned(this, duration);\n }\n\n /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): ZonedDateTime {\n return subtractZoned(this, duration);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields\n * will be constrained accordingly.\n */\n set(fields: DateFields & TimeFields, disambiguation?: Disambiguation): ZonedDateTime {\n return setZoned(this, fields, disambiguation);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions): ZonedDateTime {\n return cycleZoned(this, field, amount, options);\n }\n\n /** Converts the date to a native JavaScript Date object. */\n toDate(): Date {\n return zonedToDate(this);\n }\n\n /**\n * Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone\n * identifier.\n */\n toString(): string {\n return zonedDateTimeToString(this);\n }\n\n /** Converts the date to an ISO 8601 formatted string in UTC. */\n toAbsoluteString(): string {\n return this.toDate().toISOString();\n }\n\n /**\n * Compares this date with another. A negative result indicates that this date is before the given\n * one, and a positive date indicates that it is after.\n */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n // TODO: Is this a bad idea??\n return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();\n }\n}\n"],"names":[],"version":3,"file":"CalendarDate.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/DateFormatter.cjs b/node_modules/@internationalized/date/dist/private/DateFormatter.cjs new file mode 100644 index 0000000000000000000000000000000000000000..89365e4a9773f0b1095c8b98c88a0d85cf6bf640 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/DateFormatter.cjs @@ -0,0 +1,148 @@ + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "DateFormatter", function () { return $10afcf45c4831ff7$export$ad991b66133851cf; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ let $10afcf45c4831ff7$var$formatterCache = new Map(); +class $10afcf45c4831ff7$export$ad991b66133851cf { + constructor(locale, options = {}){ + this.formatter = $10afcf45c4831ff7$var$getCachedDateFormatter(locale, options); + this.options = options; + } + /** + * Formats a date as a string according to the locale and format options passed to the + * constructor. + */ format(value) { + return this.formatter.format(value); + } + /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) { + return this.formatter.formatToParts(value); + } + /** Formats a date range as a string. */ formatRange(start, end) { + // @ts-ignore + if (typeof this.formatter.formatRange === 'function') // @ts-ignore + return this.formatter.formatRange(start, end); + if (end < start) throw new RangeError('End date must be >= start date'); + // Very basic fallback for old browsers. + return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`; + } + /** Formats a date range as an array of parts. */ formatRangeToParts(start, end) { + // @ts-ignore + if (typeof this.formatter.formatRangeToParts === 'function') // @ts-ignore + return this.formatter.formatRangeToParts(start, end); + if (end < start) throw new RangeError('End date must be >= start date'); + let startParts = this.formatter.formatToParts(start); + let endParts = this.formatter.formatToParts(end); + return [ + ...startParts.map((p)=>({ + ...p, + source: 'startRange' + })), + { + type: 'literal', + value: " \u2013 ", + source: 'shared' + }, + ...endParts.map((p)=>({ + ...p, + source: 'endRange' + })) + ]; + } + /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() { + let resolvedOptions = this.formatter.resolvedOptions(); + if ($10afcf45c4831ff7$var$hasBuggyResolvedHourCycle()) { + if (!this.resolvedHourCycle) this.resolvedHourCycle = $10afcf45c4831ff7$var$getResolvedHourCycle(resolvedOptions.locale, this.options); + resolvedOptions.hourCycle = this.resolvedHourCycle; + resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12'; + } + // Safari uses a different name for the Ethiopic (Amete Alem) calendar. + // https://bugs.webkit.org/show_bug.cgi?id=241564 + if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa'; + return resolvedOptions; + } +} +// There are multiple bugs involving the hour12 and hourCycle options in various browser engines. +// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59) +// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59) +// rather than h12 (12:00 - 11:59). +// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal +// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3] +// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791 +// [2] https://github.com/tc39/ecma402/issues/402 +// [3] https://bugs.webkit.org/show_bug.cgi?id=229313 +// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802 +const $10afcf45c4831ff7$var$hour12Preferences = { + true: { + // Only Japanese uses the h11 style for 12 hour time. All others use h12. + ja: 'h11' + }, + false: { + } +}; +function $10afcf45c4831ff7$var$getCachedDateFormatter(locale, options = {}) { + // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead. + // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari. + if (typeof options.hour12 === 'boolean' && $10afcf45c4831ff7$var$hasBuggyHour12Behavior()) { + options = { + ...options + }; + let pref = $10afcf45c4831ff7$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]]; + let defaultHourCycle = options.hour12 ? 'h12' : 'h23'; + options.hourCycle = pref ?? defaultHourCycle; + delete options.hour12; + } + let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : ''); + if ($10afcf45c4831ff7$var$formatterCache.has(cacheKey)) return $10afcf45c4831ff7$var$formatterCache.get(cacheKey); + let numberFormatter = new Intl.DateTimeFormat(locale, options); + $10afcf45c4831ff7$var$formatterCache.set(cacheKey, numberFormatter); + return numberFormatter; +} +let $10afcf45c4831ff7$var$_hasBuggyHour12Behavior = null; +function $10afcf45c4831ff7$var$hasBuggyHour12Behavior() { + if ($10afcf45c4831ff7$var$_hasBuggyHour12Behavior == null) $10afcf45c4831ff7$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', { + hour: 'numeric', + hour12: false + }).format(new Date(2020, 2, 3, 0)) === '24'; + return $10afcf45c4831ff7$var$_hasBuggyHour12Behavior; +} +let $10afcf45c4831ff7$var$_hasBuggyResolvedHourCycle = null; +function $10afcf45c4831ff7$var$hasBuggyResolvedHourCycle() { + if ($10afcf45c4831ff7$var$_hasBuggyResolvedHourCycle == null) $10afcf45c4831ff7$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', { + hour: 'numeric', + hour12: false + }).resolvedOptions().hourCycle === 'h12'; + return $10afcf45c4831ff7$var$_hasBuggyResolvedHourCycle; +} +function $10afcf45c4831ff7$var$getResolvedHourCycle(locale, options) { + if (!options.timeStyle && !options.hour) return undefined; + // Work around buggy results in resolved hourCycle and hour12 options in WebKit. + // Format the minimum possible hour and maximum possible hour in a day and parse the results. + locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ''); + locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn'; + let formatter = $10afcf45c4831ff7$var$getCachedDateFormatter(locale, { + ...options, + timeZone: undefined // use local timezone + }); + let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === 'hour').value, 10); + let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === 'hour').value, 10); + if (min === 0 && max === 23) return 'h23'; + if (min === 24 && max === 23) return 'h24'; + if (min === 0 && max === 11) return 'h11'; + if (min === 12 && max === 11) return 'h12'; + throw new Error('Unexpected hour cycle result'); +} + + +//# sourceMappingURL=DateFormatter.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/DateFormatter.cjs.map b/node_modules/@internationalized/date/dist/private/DateFormatter.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..8477c5b8234d710b40aedbe4350d51021946be17 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/DateFormatter.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAOlB,MAAM;IAKX,YAAY,MAAc,EAAE,UAAsC,CAAC,CAAC,CAAE;QACpE,IAAI,CAAC,SAAS,GAAG,6CAAuB,QAAQ;QAChD,IAAI,CAAC,OAAO,GAAG;IACjB;IAEA;;;GAGC,GACD,OAAO,KAAW,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B;IAEA,4FAA4F,GAC5F,cAAc,KAAW,EAA6B;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC;IAEA,sCAAsC,GACtC,YAAY,KAAW,EAAE,GAAS,EAAU;QAC1C,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,YACxC,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO;QAG3C,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,wCAAwC;QACxC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,UAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM;IAC1E;IAEA,+CAA+C,GAC/C,mBAAmB,KAAW,EAAE,GAAS,EAAyB;QAChE,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,KAAK,YAC/C,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO;Q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AAuB,QAAQ;QAC7C,GAAG,OAAO;QACV,UAAU,UAAU,qBAAqB;IAC3C;IAEA,IAAI,MAAM,SACR,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EACpF;IAEF,IAAI,MAAM,SACR,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EACrF;IAGF,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map();\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared';\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /**\n * Formats a date as a string according to the locale and format options passed to the\n * constructor.\n */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'}) as DateRangeFormatPart),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'}) as DateRangeFormatPart)\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions();\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(\n locale: string,\n options: Intl.DateTimeFormatOptions = {}\n): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey =\n locale +\n (options\n ? Object.entries(options)\n .sort((a, b) => (a[0] < b[0] ? -1 : 1))\n .join()\n : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior =\n new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle =\n new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions().hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(\n formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value,\n 10\n );\n let max = parseInt(\n formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value,\n 10\n );\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/DateFormatter.js b/node_modules/@internationalized/date/dist/private/DateFormatter.js new file mode 100644 index 0000000000000000000000000000000000000000..194ed26012d81c1f0f1ee27f561373626e04b2a2 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/DateFormatter.js @@ -0,0 +1,143 @@ +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ let $f48a4033af8eadca$var$formatterCache = new Map(); +class $f48a4033af8eadca$export$ad991b66133851cf { + /** + * Formats a date as a string according to the locale and format options passed to the + * constructor. + */ format(value) { + return this.formatter.format(value); + } + /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) { + return this.formatter.formatToParts(value); + } + /** Formats a date range as a string. */ formatRange(start, end) { + // @ts-ignore + if (typeof this.formatter.formatRange === 'function') // @ts-ignore + return this.formatter.formatRange(start, end); + if (end < start) throw new RangeError('End date must be >= start date'); + // Very basic fallback for old browsers. + return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`; + } + /** Formats a date range as an array of parts. */ formatRangeToParts(start, end) { + // @ts-ignore + if (typeof this.formatter.formatRangeToParts === 'function') // @ts-ignore + return this.formatter.formatRangeToParts(start, end); + if (end < start) throw new RangeError('End date must be >= start date'); + let startParts = this.formatter.formatToParts(start); + let endParts = this.formatter.formatToParts(end); + return [ + ...startParts.map((p)=>({ + ...p, + source: 'startRange' + })), + { + type: 'literal', + value: " \u2013 ", + source: 'shared' + }, + ...endParts.map((p)=>({ + ...p, + source: 'endRange' + })) + ]; + } + /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() { + let resolvedOptions = this.formatter.resolvedOptions(); + if ($f48a4033af8eadca$var$hasBuggyResolvedHourCycle()) { + if (!this.resolvedHourCycle) this.resolvedHourCycle = $f48a4033af8eadca$var$getResolvedHourCycle(resolvedOptions.locale, this.options); + resolvedOptions.hourCycle = this.resolvedHourCycle; + resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12'; + } + // Safari uses a different name for the Ethiopic (Amete Alem) calendar. + // https://bugs.webkit.org/show_bug.cgi?id=241564 + if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa'; + return resolvedOptions; + } + constructor(locale, options = {}){ + this.formatter = $f48a4033af8eadca$var$getCachedDateFormatter(locale, options); + this.options = options; + } +} +// There are multiple bugs involving the hour12 and hourCycle options in various browser engines. +// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59) +// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59) +// rather than h12 (12:00 - 11:59). +// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal +// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3] +// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791 +// [2] https://github.com/tc39/ecma402/issues/402 +// [3] https://bugs.webkit.org/show_bug.cgi?id=229313 +// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802 +const $f48a4033af8eadca$var$hour12Preferences = { + true: { + // Only Japanese uses the h11 style for 12 hour time. All others use h12. + ja: 'h11' + }, + false: { + } +}; +function $f48a4033af8eadca$var$getCachedDateFormatter(locale, options = {}) { + // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead. + // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari. + if (typeof options.hour12 === 'boolean' && $f48a4033af8eadca$var$hasBuggyHour12Behavior()) { + options = { + ...options + }; + let pref = $f48a4033af8eadca$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]]; + let defaultHourCycle = options.hour12 ? 'h12' : 'h23'; + options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle; + delete options.hour12; + } + let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : ''); + if ($f48a4033af8eadca$var$formatterCache.has(cacheKey)) return $f48a4033af8eadca$var$formatterCache.get(cacheKey); + let numberFormatter = new Intl.DateTimeFormat(locale, options); + $f48a4033af8eadca$var$formatterCache.set(cacheKey, numberFormatter); + return numberFormatter; +} +let $f48a4033af8eadca$var$_hasBuggyHour12Behavior = null; +function $f48a4033af8eadca$var$hasBuggyHour12Behavior() { + if ($f48a4033af8eadca$var$_hasBuggyHour12Behavior == null) $f48a4033af8eadca$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', { + hour: 'numeric', + hour12: false + }).format(new Date(2020, 2, 3, 0)) === '24'; + return $f48a4033af8eadca$var$_hasBuggyHour12Behavior; +} +let $f48a4033af8eadca$var$_hasBuggyResolvedHourCycle = null; +function $f48a4033af8eadca$var$hasBuggyResolvedHourCycle() { + if ($f48a4033af8eadca$var$_hasBuggyResolvedHourCycle == null) $f48a4033af8eadca$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', { + hour: 'numeric', + hour12: false + }).resolvedOptions().hourCycle === 'h12'; + return $f48a4033af8eadca$var$_hasBuggyResolvedHourCycle; +} +function $f48a4033af8eadca$var$getResolvedHourCycle(locale, options) { + if (!options.timeStyle && !options.hour) return undefined; + // Work around buggy results in resolved hourCycle and hour12 options in WebKit. + // Format the minimum possible hour and maximum possible hour in a day and parse the results. + locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ''); + locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn'; + let formatter = $f48a4033af8eadca$var$getCachedDateFormatter(locale, { + ...options, + timeZone: undefined // use local timezone + }); + let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === 'hour').value, 10); + let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === 'hour').value, 10); + if (min === 0 && max === 23) return 'h23'; + if (min === 24 && max === 23) return 'h24'; + if (min === 0 && max === 11) return 'h11'; + if (min === 12 && max === 11) return 'h12'; + throw new Error('Unexpected hour cycle result'); +} + + +export {$f48a4033af8eadca$export$ad991b66133851cf as DateFormatter}; +//# sourceMappingURL=DateFormatter.js.map diff --git a/node_modules/@internationalized/date/dist/private/DateFormatter.js.map b/node_modules/@internationalized/date/dist/private/DateFormatter.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1c80a726ac800633d5912e76e64be54e784c6cf8 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/DateFormatter.js.map @@ -0,0 +1 @@ +{"mappings":"AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAOlB,MAAM;IAUX;;;GAGC,GACD,OAAO,KAAW,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B;IAEA,4FAA4F,GAC5F,cAAc,KAAW,EAA6B;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC;IAEA,sCAAsC,GACtC,YAAY,KAAW,EAAE,GAAS,EAAU;QAC1C,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,YACxC,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO;QAG3C,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,wCAAwC;QACxC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,UAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM;IAC1E;IAEA,+CAA+C,GAC/C,mBAAmB,KAAW,EAAE,GAAS,EAAyB;QAChE,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,KAAK,YAC/C,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO;QAGlD,IAAI,MAAM,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6F;IAC7F,SAAS,OAAO,OAAO,CAAC,0BAA0B;IAClD,UAAU,AAAC,CAAA,OAAO,QAAQ,CAAC,SAAS,KAAK,IAAG,IAAK;IACjD,IAAI,YAAY,6CAAuB,QAAQ;QAC7C,GAAG,OAAO;QACV,UAAU,UAAU,qBAAqB;IAC3C;IAEA,IAAI,MAAM,SACR,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EACpF;IAEF,IAAI,MAAM,SACR,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EACrF;IAGF,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map();\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared';\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /**\n * Formats a date as a string according to the locale and format options passed to the\n * constructor.\n */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'}) as DateRangeFormatPart),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'}) as DateRangeFormatPart)\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions();\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(\n locale: string,\n options: Intl.DateTimeFormatOptions = {}\n): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey =\n locale +\n (options\n ? Object.entries(options)\n .sort((a, b) => (a[0] < b[0] ? -1 : 1))\n .join()\n : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior =\n new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle =\n new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions().hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(\n formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value,\n 10\n );\n let max = parseInt(\n formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value,\n 10\n );\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/DateFormatter.mjs b/node_modules/@internationalized/date/dist/private/DateFormatter.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2ff19e07b1d8569f32858b9c3c0507f5fa19a215 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/DateFormatter.mjs @@ -0,0 +1,143 @@ +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ let $12a3c853105e5a70$var$formatterCache = new Map(); +class $12a3c853105e5a70$export$ad991b66133851cf { + constructor(locale, options = {}){ + this.formatter = $12a3c853105e5a70$var$getCachedDateFormatter(locale, options); + this.options = options; + } + /** + * Formats a date as a string according to the locale and format options passed to the + * constructor. + */ format(value) { + return this.formatter.format(value); + } + /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) { + return this.formatter.formatToParts(value); + } + /** Formats a date range as a string. */ formatRange(start, end) { + // @ts-ignore + if (typeof this.formatter.formatRange === 'function') // @ts-ignore + return this.formatter.formatRange(start, end); + if (end < start) throw new RangeError('End date must be >= start date'); + // Very basic fallback for old browsers. + return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`; + } + /** Formats a date range as an array of parts. */ formatRangeToParts(start, end) { + // @ts-ignore + if (typeof this.formatter.formatRangeToParts === 'function') // @ts-ignore + return this.formatter.formatRangeToParts(start, end); + if (end < start) throw new RangeError('End date must be >= start date'); + let startParts = this.formatter.formatToParts(start); + let endParts = this.formatter.formatToParts(end); + return [ + ...startParts.map((p)=>({ + ...p, + source: 'startRange' + })), + { + type: 'literal', + value: " \u2013 ", + source: 'shared' + }, + ...endParts.map((p)=>({ + ...p, + source: 'endRange' + })) + ]; + } + /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() { + let resolvedOptions = this.formatter.resolvedOptions(); + if ($12a3c853105e5a70$var$hasBuggyResolvedHourCycle()) { + if (!this.resolvedHourCycle) this.resolvedHourCycle = $12a3c853105e5a70$var$getResolvedHourCycle(resolvedOptions.locale, this.options); + resolvedOptions.hourCycle = this.resolvedHourCycle; + resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12'; + } + // Safari uses a different name for the Ethiopic (Amete Alem) calendar. + // https://bugs.webkit.org/show_bug.cgi?id=241564 + if (resolvedOptions.calendar === 'ethiopic-amete-alem') resolvedOptions.calendar = 'ethioaa'; + return resolvedOptions; + } +} +// There are multiple bugs involving the hour12 and hourCycle options in various browser engines. +// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59) +// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59) +// rather than h12 (12:00 - 11:59). +// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal +// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3] +// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791 +// [2] https://github.com/tc39/ecma402/issues/402 +// [3] https://bugs.webkit.org/show_bug.cgi?id=229313 +// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802 +const $12a3c853105e5a70$var$hour12Preferences = { + true: { + // Only Japanese uses the h11 style for 12 hour time. All others use h12. + ja: 'h11' + }, + false: { + } +}; +function $12a3c853105e5a70$var$getCachedDateFormatter(locale, options = {}) { + // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead. + // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari. + if (typeof options.hour12 === 'boolean' && $12a3c853105e5a70$var$hasBuggyHour12Behavior()) { + options = { + ...options + }; + let pref = $12a3c853105e5a70$var$hour12Preferences[String(options.hour12)][locale.split('-')[0]]; + let defaultHourCycle = options.hour12 ? 'h12' : 'h23'; + options.hourCycle = pref ?? defaultHourCycle; + delete options.hour12; + } + let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : ''); + if ($12a3c853105e5a70$var$formatterCache.has(cacheKey)) return $12a3c853105e5a70$var$formatterCache.get(cacheKey); + let numberFormatter = new Intl.DateTimeFormat(locale, options); + $12a3c853105e5a70$var$formatterCache.set(cacheKey, numberFormatter); + return numberFormatter; +} +let $12a3c853105e5a70$var$_hasBuggyHour12Behavior = null; +function $12a3c853105e5a70$var$hasBuggyHour12Behavior() { + if ($12a3c853105e5a70$var$_hasBuggyHour12Behavior == null) $12a3c853105e5a70$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', { + hour: 'numeric', + hour12: false + }).format(new Date(2020, 2, 3, 0)) === '24'; + return $12a3c853105e5a70$var$_hasBuggyHour12Behavior; +} +let $12a3c853105e5a70$var$_hasBuggyResolvedHourCycle = null; +function $12a3c853105e5a70$var$hasBuggyResolvedHourCycle() { + if ($12a3c853105e5a70$var$_hasBuggyResolvedHourCycle == null) $12a3c853105e5a70$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', { + hour: 'numeric', + hour12: false + }).resolvedOptions().hourCycle === 'h12'; + return $12a3c853105e5a70$var$_hasBuggyResolvedHourCycle; +} +function $12a3c853105e5a70$var$getResolvedHourCycle(locale, options) { + if (!options.timeStyle && !options.hour) return undefined; + // Work around buggy results in resolved hourCycle and hour12 options in WebKit. + // Format the minimum possible hour and maximum possible hour in a day and parse the results. + locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ''); + locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn'; + let formatter = $12a3c853105e5a70$var$getCachedDateFormatter(locale, { + ...options, + timeZone: undefined // use local timezone + }); + let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === 'hour').value, 10); + let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === 'hour').value, 10); + if (min === 0 && max === 23) return 'h23'; + if (min === 24 && max === 23) return 'h24'; + if (min === 0 && max === 11) return 'h11'; + if (min === 12 && max === 11) return 'h12'; + throw new Error('Unexpected hour cycle result'); +} + + +export {$12a3c853105e5a70$export$ad991b66133851cf as DateFormatter}; +//# sourceMappingURL=DateFormatter.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/DateFormatter.mjs.map b/node_modules/@internationalized/date/dist/private/DateFormatter.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..7521972dab128f0bdf11ca8ac472cd190fbcff87 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/DateFormatter.mjs.map @@ -0,0 +1 @@ +{"mappings":"AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAOlB,MAAM;IAKX,YAAY,MAAc,EAAE,UAAsC,CAAC,CAAC,CAAE;QACpE,IAAI,CAAC,SAAS,GAAG,6CAAuB,QAAQ;QAChD,IAAI,CAAC,OAAO,GAAG;IACjB;IAEA;;;GAGC,GACD,OAAO,KAAW,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B;IAEA,4FAA4F,GAC5F,cAAc,KAAW,EAA6B;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC;IAEA,sCAAsC,GACtC,YAAY,KAAW,EAAE,GAAS,EAAU;QAC1C,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,YACxC,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO;QAG3C,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,wCAAwC;QACxC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,UAAG,EA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MAAc,EAAE,OAAmC;IAC/E,IAAI,CAAC,QAAQ,SAAS,IAAI,CAAC,QAAQ,IAAI,EACrC,OAAO;IAGT,gFAAgF;IAChF,6FAA6F;IAC7F,SAAS,OAAO,OAAO,CAAC,0BAA0B;IAClD,UAAU,AAAC,CAAA,OAAO,QAAQ,CAAC,SAAS,KAAK,IAAG,IAAK;IACjD,IAAI,YAAY,6CAAuB,QAAQ;QAC7C,GAAG,OAAO;QACV,UAAU,UAAU,qBAAqB;IAC3C;IAEA,IAAI,MAAM,SACR,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EACpF;IAEF,IAAI,MAAM,SACR,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EACrF;IAGF,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map();\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared';\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /**\n * Formats a date as a string according to the locale and format options passed to the\n * constructor.\n */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'}) as DateRangeFormatPart),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'}) as DateRangeFormatPart)\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions();\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(\n locale: string,\n options: Intl.DateTimeFormatOptions = {}\n): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey =\n locale +\n (options\n ? Object.entries(options)\n .sort((a, b) => (a[0] < b[0] ? -1 : 1))\n .join()\n : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior =\n new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle =\n new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions().hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(\n formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value,\n 10\n );\n let max = parseInt(\n formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value,\n 10\n );\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..3d75e34b3e5c541e4c0231dec5182b4f5efb9bf3 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.cjs @@ -0,0 +1,53 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $05031860ba2f881f$exports = require("./GregorianCalendar.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "BuddhistCalendar", function () { return $0ce473f03e925476$export$42d20a78301dee44; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $0ce473f03e925476$var$BUDDHIST_ERA_START = -543; +class $0ce473f03e925476$export$42d20a78301dee44 extends (0, $05031860ba2f881f$exports.GregorianCalendar) { + fromJulianDay(jd) { + let gregorianDate = super.fromJulianDay(jd); + let year = (0, $05031860ba2f881f$exports.getExtendedYear)(gregorianDate.era, gregorianDate.year); + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, year - $0ce473f03e925476$var$BUDDHIST_ERA_START, gregorianDate.month, gregorianDate.day); + } + toJulianDay(date) { + return super.toJulianDay($0ce473f03e925476$var$toGregorian(date)); + } + getEras() { + return [ + 'BE' + ]; + } + getDaysInMonth(date) { + return super.getDaysInMonth($0ce473f03e925476$var$toGregorian(date)); + } + balanceDate() {} + constructor(...args){ + super(...args), this.identifier = 'buddhist'; + } +} +function $0ce473f03e925476$var$toGregorian(date) { + let [era, year] = (0, $05031860ba2f881f$exports.fromExtendedYear)(date.year + $0ce473f03e925476$var$BUDDHIST_ERA_START); + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(era, year, date.month, date.day); +} + + +//# sourceMappingURL=BuddhistCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..d98b8eef753d40958e925487bc5279279a71db92 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,2CAAqB;AAOpB,MAAM,kDAAyB,CAAA,GAAA,2CAAgB;IAGpD,cAAc,EAAU,EAAgB;QACtC,IAAI,gBAAgB,KAAK,CAAC,cAAc;QACxC,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,cAAc,GAAG,EAAE,cAAc,IAAI;QAChE,OAAO,IAAI,CAAA,GAAA,sCAAW,EACpB,IAAI,EACJ,OAAO,0CACP,cAAc,KAAK,EACnB,cAAc,GAAG;IAErB;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAoB,CAAC;;QA1BhB,qBACL,aAAiC;;AA0BnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,0CAAe,EAAE,KAAK,IAAI,GAAG;IAC/C,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;AACzD","sources":["packages/@internationalized/date/src/calendars/BuddhistCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\n\nconst BUDDHIST_ERA_START = -543;\n\n/**\n * The Buddhist calendar is the same as the Gregorian calendar, but counts years\n * starting from the birth of Buddha in 543 BC (Gregorian). It supports only one\n * era, identified as 'BE'.\n */\nexport class BuddhistCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'buddhist';\n\n fromJulianDay(jd: number): CalendarDate {\n let gregorianDate = super.fromJulianDay(jd);\n let year = getExtendedYear(gregorianDate.era, gregorianDate.year);\n return new CalendarDate(\n this,\n year - BUDDHIST_ERA_START,\n gregorianDate.month,\n gregorianDate.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['BE'];\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n balanceDate(): void {}\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(date.year + BUDDHIST_ERA_START);\n return new CalendarDate(era, year, date.month, date.day);\n}\n"],"names":[],"version":3,"file":"BuddhistCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..3520e6d8d8c94a5efd564be0ab61474130c0857d --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.js @@ -0,0 +1,48 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {fromExtendedYear as $f25df78da1f6b40f$export$4475b7e617eb123c, getExtendedYear as $f25df78da1f6b40f$export$c36e0ecb2d4fa69d, GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./GregorianCalendar.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $6f54c4fe66fc5ed5$var$BUDDHIST_ERA_START = -543; +class $6f54c4fe66fc5ed5$export$42d20a78301dee44 extends (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + let gregorianDate = super.fromJulianDay(jd); + let year = (0, $f25df78da1f6b40f$export$c36e0ecb2d4fa69d)(gregorianDate.era, gregorianDate.year); + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, year - $6f54c4fe66fc5ed5$var$BUDDHIST_ERA_START, gregorianDate.month, gregorianDate.day); + } + toJulianDay(date) { + return super.toJulianDay($6f54c4fe66fc5ed5$var$toGregorian(date)); + } + getEras() { + return [ + 'BE' + ]; + } + getDaysInMonth(date) { + return super.getDaysInMonth($6f54c4fe66fc5ed5$var$toGregorian(date)); + } + balanceDate() {} + constructor(...args){ + super(...args), this.identifier = 'buddhist'; + } +} +function $6f54c4fe66fc5ed5$var$toGregorian(date) { + let [era, year] = (0, $f25df78da1f6b40f$export$4475b7e617eb123c)(date.year + $6f54c4fe66fc5ed5$var$BUDDHIST_ERA_START); + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(era, year, date.month, date.day); +} + + +export {$6f54c4fe66fc5ed5$export$42d20a78301dee44 as BuddhistCalendar}; +//# sourceMappingURL=BuddhistCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..97432ac0f240afe11228bd587445af157086eb14 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,2CAAqB;AAOpB,MAAM,kDAAyB,CAAA,GAAA,yCAAgB;IAGpD,cAAc,EAAU,EAAgB;QACtC,IAAI,gBAAgB,KAAK,CAAC,cAAc;QACxC,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,cAAc,GAAG,EAAE,cAAc,IAAI;QAChE,OAAO,IAAI,CAAA,GAAA,yCAAW,EACpB,IAAI,EACJ,OAAO,0CACP,cAAc,KAAK,EACnB,cAAc,GAAG;IAErB;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAoB,CAAC;;QA1BhB,qBACL,aAAiC;;AA0BnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,KAAK,IAAI,GAAG;IAC/C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;AACzD","sources":["packages/@internationalized/date/src/calendars/BuddhistCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\n\nconst BUDDHIST_ERA_START = -543;\n\n/**\n * The Buddhist calendar is the same as the Gregorian calendar, but counts years\n * starting from the birth of Buddha in 543 BC (Gregorian). It supports only one\n * era, identified as 'BE'.\n */\nexport class BuddhistCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'buddhist';\n\n fromJulianDay(jd: number): CalendarDate {\n let gregorianDate = super.fromJulianDay(jd);\n let year = getExtendedYear(gregorianDate.era, gregorianDate.year);\n return new CalendarDate(\n this,\n year - BUDDHIST_ERA_START,\n gregorianDate.month,\n gregorianDate.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['BE'];\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n balanceDate(): void {}\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(date.year + BUDDHIST_ERA_START);\n return new CalendarDate(era, year, date.month, date.day);\n}\n"],"names":[],"version":3,"file":"BuddhistCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4ea347233451003ec4bef8167e380483956f54f8 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.mjs @@ -0,0 +1,48 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {fromExtendedYear as $93635573935797de$export$4475b7e617eb123c, getExtendedYear as $93635573935797de$export$c36e0ecb2d4fa69d, GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $63d4eafd4d826996$var$BUDDHIST_ERA_START = -543; +class $63d4eafd4d826996$export$42d20a78301dee44 extends (0, $93635573935797de$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + let gregorianDate = super.fromJulianDay(jd); + let year = (0, $93635573935797de$export$c36e0ecb2d4fa69d)(gregorianDate.era, gregorianDate.year); + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, year - $63d4eafd4d826996$var$BUDDHIST_ERA_START, gregorianDate.month, gregorianDate.day); + } + toJulianDay(date) { + return super.toJulianDay($63d4eafd4d826996$var$toGregorian(date)); + } + getEras() { + return [ + 'BE' + ]; + } + getDaysInMonth(date) { + return super.getDaysInMonth($63d4eafd4d826996$var$toGregorian(date)); + } + balanceDate() {} + constructor(...args){ + super(...args), this.identifier = 'buddhist'; + } +} +function $63d4eafd4d826996$var$toGregorian(date) { + let [era, year] = (0, $93635573935797de$export$4475b7e617eb123c)(date.year + $63d4eafd4d826996$var$BUDDHIST_ERA_START); + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(era, year, date.month, date.day); +} + + +export {$63d4eafd4d826996$export$42d20a78301dee44 as BuddhistCalendar}; +//# sourceMappingURL=BuddhistCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..d80aad4544297d9d8824db977274fee4eac03438 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/BuddhistCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,2CAAqB;AAOpB,MAAM,kDAAyB,CAAA,GAAA,yCAAgB;IAGpD,cAAc,EAAU,EAAgB;QACtC,IAAI,gBAAgB,KAAK,CAAC,cAAc;QACxC,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,cAAc,GAAG,EAAE,cAAc,IAAI;QAChE,OAAO,IAAI,CAAA,GAAA,yCAAW,EACpB,IAAI,EACJ,OAAO,0CACP,cAAc,KAAK,EACnB,cAAc,GAAG;IAErB;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAoB,CAAC;;QA1BhB,qBACL,aAAiC;;AA0BnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,KAAK,IAAI,GAAG;IAC/C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;AACzD","sources":["packages/@internationalized/date/src/calendars/BuddhistCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\n\nconst BUDDHIST_ERA_START = -543;\n\n/**\n * The Buddhist calendar is the same as the Gregorian calendar, but counts years\n * starting from the birth of Buddha in 543 BC (Gregorian). It supports only one\n * era, identified as 'BE'.\n */\nexport class BuddhistCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'buddhist';\n\n fromJulianDay(jd: number): CalendarDate {\n let gregorianDate = super.fromJulianDay(jd);\n let year = getExtendedYear(gregorianDate.era, gregorianDate.year);\n return new CalendarDate(\n this,\n year - BUDDHIST_ERA_START,\n gregorianDate.month,\n gregorianDate.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['BE'];\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n balanceDate(): void {}\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(date.year + BUDDHIST_ERA_START);\n return new CalendarDate(era, year, date.month, date.day);\n}\n"],"names":[],"version":3,"file":"BuddhistCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..f2318fcefbcccf8f713af32b20e786c29a7685b4 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.cjs @@ -0,0 +1,174 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "EthiopicCalendar", function () { return $b6b43214f5cff964$export$26ba6eab5e20cd7d; }); +$parcel$export(module.exports, "EthiopicAmeteAlemCalendar", function () { return $b6b43214f5cff964$export$d72e0c37005a4914; }); +$parcel$export(module.exports, "CopticCalendar", function () { return $b6b43214f5cff964$export$fe6243cbe1a4b7c1; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + +const $b6b43214f5cff964$var$ETHIOPIC_EPOCH = 1723856; +const $b6b43214f5cff964$var$COPTIC_EPOCH = 1824665; +// The delta between Amete Alem 1 and Amete Mihret 1 +// AA 5501 = AM 1 +const $b6b43214f5cff964$var$AMETE_MIHRET_DELTA = 5500; +function $b6b43214f5cff964$var$ceToJulianDay(epoch, year, month, day) { + return epoch + // difference from Julian epoch to 1,1,1 + 365 * year + // number of days from years + Math.floor(year / 4) + // extra day of leap year + 30 * (month - 1) + // number of days from months (1 based) + day - 1 // number of days for present month (1 based) + ; +} +function $b6b43214f5cff964$var$julianDayToCE(epoch, jd) { + let year = Math.floor(4 * (jd - epoch) / 1461); + let month = 1 + Math.floor((jd - $b6b43214f5cff964$var$ceToJulianDay(epoch, year, 1, 1)) / 30); + let day = jd + 1 - $b6b43214f5cff964$var$ceToJulianDay(epoch, year, month, 1); + return [ + year, + month, + day + ]; +} +function $b6b43214f5cff964$var$getLeapDay(year) { + return Math.floor(year % 4 / 3); +} +function $b6b43214f5cff964$var$getDaysInMonth(year, month) { + // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and + // an intercalary month at the end of the year of 5 or 6 days, depending whether + // the year is a leap year or not. The Leap Year follows the same rules as the + // Julian Calendar so that the extra month always has six days in the year before + // a Julian Leap Year. + if (month % 13 !== 0) // not intercalary month + return 30; + else // intercalary month 5 days + possible leap day + return $b6b43214f5cff964$var$getLeapDay(year) + 5; +} +class $b6b43214f5cff964$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $b6b43214f5cff964$var$julianDayToCE($b6b43214f5cff964$var$ETHIOPIC_EPOCH, jd); + let era = 'AM'; + if (year <= 0) { + era = 'AA'; + year += $b6b43214f5cff964$var$AMETE_MIHRET_DELTA; + } + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, era, year, month, day); + } + toJulianDay(date) { + let year = date.year; + if (date.era === 'AA') year -= $b6b43214f5cff964$var$AMETE_MIHRET_DELTA; + return $b6b43214f5cff964$var$ceToJulianDay($b6b43214f5cff964$var$ETHIOPIC_EPOCH, year, date.month, date.day); + } + getDaysInMonth(date) { + return $b6b43214f5cff964$var$getDaysInMonth(date.year, date.month); + } + getMonthsInYear() { + return 13; + } + getDaysInYear(date) { + return 365 + $b6b43214f5cff964$var$getLeapDay(date.year); + } + getMaximumMonthsInYear() { + return 13; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra(date) { + // 9999-12-31 gregorian is 9992-20-02 ethiopic. + // Round down to 9991 for the last full year. + // AA 9999-01-01 ethiopic is 4506-09-30 gregorian. + return date.era === 'AA' ? 9999 : 9991; + } + getEras() { + return [ + 'AA', + 'AM' + ]; + } + constructor(){ + this.identifier = 'ethiopic'; + } +} +class $b6b43214f5cff964$export$d72e0c37005a4914 extends $b6b43214f5cff964$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $b6b43214f5cff964$var$julianDayToCE($b6b43214f5cff964$var$ETHIOPIC_EPOCH, jd); + year += $b6b43214f5cff964$var$AMETE_MIHRET_DELTA; + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, 'AA', year, month, day); + } + getEras() { + return [ + 'AA' + ]; + } + getYearsInEra() { + // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian. + return 9999; + } + constructor(...args){ + super(...args), this.identifier = 'ethioaa' // also known as 'ethiopic-amete-alem' in ICU + ; + } +} +class $b6b43214f5cff964$export$fe6243cbe1a4b7c1 extends $b6b43214f5cff964$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $b6b43214f5cff964$var$julianDayToCE($b6b43214f5cff964$var$COPTIC_EPOCH, jd); + let era = 'CE'; + if (year <= 0) { + era = 'BCE'; + year = 1 - year; + } + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, era, year, month, day); + } + toJulianDay(date) { + let year = date.year; + if (date.era === 'BCE') year = 1 - year; + return $b6b43214f5cff964$var$ceToJulianDay($b6b43214f5cff964$var$COPTIC_EPOCH, year, date.month, date.day); + } + getDaysInMonth(date) { + let year = date.year; + if (date.era === 'BCE') year = 1 - year; + return $b6b43214f5cff964$var$getDaysInMonth(year, date.month); + } + isInverseEra(date) { + return date.era === 'BCE'; + } + balanceDate(date) { + if (date.year <= 0) { + date.era = date.era === 'BCE' ? 'CE' : 'BCE'; + date.year = 1 - date.year; + } + } + getEras() { + return [ + 'BCE', + 'CE' + ]; + } + getYearsInEra(date) { + // 9999-12-30 gregorian is 9716-02-20 coptic. + // Round down to 9715 for the last full year. + // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian. + return date.era === 'BCE' ? 9999 : 9715; + } + constructor(...args){ + super(...args), this.identifier = 'coptic'; + } +} + + +//# sourceMappingURL=EthiopicCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..1267f25cdb20d178d7f8f10e3ec32ef7a64be3fd --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAMhG,MAAM,uCAAiB;AACvB,MAAM,qCAAe;AAErB,oDAAoD;AACpD,iBAAiB;AACjB,MAAM,2CAAqB;AAE3B,SAAS,oCAAc,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IAC5E,OACE,QAAQ,wCAAwC;IAChD,MAAM,OAAO,4BAA4B;IACzC,KAAK,KAAK,CAAC,OAAO,KAAK,yBAAyB;IAChD,KAAM,CAAA,QAAQ,CAAA,IAAK,uCAAuC;IAC1D,MACA,EAAE,6CAA6C;;AAEnD;AAEA,SAAS,oCAAc,KAAa,EAAE,EAAU;IAC9C,IAAI,OAAO,KAAK,KAAK,CAAC,AAAC,IAAK,CAAA,KAAK,KAAI,IAAM;IAC3C,IAAI,QAAQ,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,oCAAc,OAAO,MAAM,GAAG,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AAqB,EAAU;QAC3C,6CAA6C;QAC7C,6CAA6C;QAC7C,oDAAoD;QACpD,OAAO,KAAK,GAAG,KAAK,QAAQ,OAAO;IACrC;;QApDK,qBACL,aAAiC;;AAoDnC","sources":["packages/@internationalized/date/src/calendars/EthiopicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {Mutable} from '../utils';\n\nconst ETHIOPIC_EPOCH = 1723856;\nconst COPTIC_EPOCH = 1824665;\n\n// The delta between Amete Alem 1 and Amete Mihret 1\n// AA 5501 = AM 1\nconst AMETE_MIHRET_DELTA = 5500;\n\nfunction ceToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return (\n epoch + // difference from Julian epoch to 1,1,1\n 365 * year + // number of days from years\n Math.floor(year / 4) + // extra day of leap year\n 30 * (month - 1) + // number of days from months (1 based)\n day -\n 1 // number of days for present month (1 based)\n );\n}\n\nfunction julianDayToCE(epoch: number, jd: number) {\n let year = Math.floor((4 * (jd - epoch)) / 1461);\n let month = 1 + Math.floor((jd - ceToJulianDay(epoch, year, 1, 1)) / 30);\n let day = jd + 1 - ceToJulianDay(epoch, year, month, 1);\n return [year, month, day];\n}\n\nfunction getLeapDay(year: number) {\n return Math.floor((year % 4) / 3);\n}\n\nfunction getDaysInMonth(year: number, month: number) {\n // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and\n // an intercalary month at the end of the year of 5 or 6 days, depending whether\n // the year is a leap year or not. The Leap Year follows the same rules as the\n // Julian Calendar so that the extra month always has six days in the year before\n // a Julian Leap Year.\n if (month % 13 !== 0) {\n // not intercalary month\n return 30;\n } else {\n // intercalary month 5 days + possible leap day\n return getLeapDay(year) + 5;\n }\n}\n\n/**\n * The Ethiopic calendar system is the official calendar used in Ethiopia.\n * It includes 12 months of 30 days each, plus 5 or 6 intercalary days depending\n * on whether it is a leap year. Two eras are supported: 'AA' and 'AM'.\n */\nexport class EthiopicCalendar implements Calendar {\n identifier: CalendarIdentifier = 'ethiopic';\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(ETHIOPIC_EPOCH, jd);\n let era = 'AM';\n if (year <= 0) {\n era = 'AA';\n year += AMETE_MIHRET_DELTA;\n }\n\n return new CalendarDate(this, era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'AA') {\n year -= AMETE_MIHRET_DELTA;\n }\n\n return ceToJulianDay(ETHIOPIC_EPOCH, year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(): number {\n return 13;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return 365 + getLeapDay(date.year);\n }\n\n getMaximumMonthsInYear(): number {\n return 13;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // 9999-12-31 gregorian is 9992-20-02 ethiopic.\n // Round down to 9991 for the last full year.\n // AA 9999-01-01 ethiopic is 4506-09-30 gregorian.\n return date.era === 'AA' ? 9999 : 9991;\n }\n\n getEras(): string[] {\n return ['AA', 'AM'];\n }\n}\n\n/**\n * The Ethiopic (Amete Alem) calendar is the same as the modern Ethiopic calendar,\n * except years were measured from a different epoch. Only one era is supported: 'AA'.\n */\nexport class EthiopicAmeteAlemCalendar extends EthiopicCalendar {\n identifier: CalendarIdentifier = 'ethioaa'; // also known as 'ethiopic-amete-alem' in ICU\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(ETHIOPIC_EPOCH, jd);\n year += AMETE_MIHRET_DELTA;\n return new CalendarDate(this, 'AA', year, month, day);\n }\n\n getEras(): string[] {\n return ['AA'];\n }\n\n getYearsInEra(): number {\n // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian.\n return 9999;\n }\n}\n\n/**\n * The Coptic calendar is similar to the Ethiopic calendar.\n * It includes 12 months of 30 days each, plus 5 or 6 intercalary days depending\n * on whether it is a leap year. Two eras are supported: 'BCE' and 'CE'.\n */\nexport class CopticCalendar extends EthiopicCalendar {\n identifier: CalendarIdentifier = 'coptic';\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(COPTIC_EPOCH, jd);\n let era = 'CE';\n if (year <= 0) {\n era = 'BCE';\n year = 1 - year;\n }\n\n return new CalendarDate(this, era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'BCE') {\n year = 1 - year;\n }\n\n return ceToJulianDay(COPTIC_EPOCH, year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'BCE') {\n year = 1 - year;\n }\n\n return getDaysInMonth(year, date.month);\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BCE';\n }\n\n balanceDate(date: Mutable): void {\n if (date.year <= 0) {\n date.era = date.era === 'BCE' ? 'CE' : 'BCE';\n date.year = 1 - date.year;\n }\n }\n\n getEras(): string[] {\n return ['BCE', 'CE'];\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // 9999-12-30 gregorian is 9716-02-20 coptic.\n // Round down to 9715 for the last full year.\n // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian.\n return date.era === 'BCE' ? 9999 : 9715;\n }\n}\n"],"names":[],"version":3,"file":"EthiopicCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..284f7e5ab1ca6b4fb507b0c8d8677794ce2fd6bd --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.js @@ -0,0 +1,167 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + +const $ca8f5bca40aaf2d4$var$ETHIOPIC_EPOCH = 1723856; +const $ca8f5bca40aaf2d4$var$COPTIC_EPOCH = 1824665; +// The delta between Amete Alem 1 and Amete Mihret 1 +// AA 5501 = AM 1 +const $ca8f5bca40aaf2d4$var$AMETE_MIHRET_DELTA = 5500; +function $ca8f5bca40aaf2d4$var$ceToJulianDay(epoch, year, month, day) { + return epoch + // difference from Julian epoch to 1,1,1 + 365 * year + // number of days from years + Math.floor(year / 4) + // extra day of leap year + 30 * (month - 1) + // number of days from months (1 based) + day - 1 // number of days for present month (1 based) + ; +} +function $ca8f5bca40aaf2d4$var$julianDayToCE(epoch, jd) { + let year = Math.floor(4 * (jd - epoch) / 1461); + let month = 1 + Math.floor((jd - $ca8f5bca40aaf2d4$var$ceToJulianDay(epoch, year, 1, 1)) / 30); + let day = jd + 1 - $ca8f5bca40aaf2d4$var$ceToJulianDay(epoch, year, month, 1); + return [ + year, + month, + day + ]; +} +function $ca8f5bca40aaf2d4$var$getLeapDay(year) { + return Math.floor(year % 4 / 3); +} +function $ca8f5bca40aaf2d4$var$getDaysInMonth(year, month) { + // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and + // an intercalary month at the end of the year of 5 or 6 days, depending whether + // the year is a leap year or not. The Leap Year follows the same rules as the + // Julian Calendar so that the extra month always has six days in the year before + // a Julian Leap Year. + if (month % 13 !== 0) // not intercalary month + return 30; + else // intercalary month 5 days + possible leap day + return $ca8f5bca40aaf2d4$var$getLeapDay(year) + 5; +} +class $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $ca8f5bca40aaf2d4$var$julianDayToCE($ca8f5bca40aaf2d4$var$ETHIOPIC_EPOCH, jd); + let era = 'AM'; + if (year <= 0) { + era = 'AA'; + year += $ca8f5bca40aaf2d4$var$AMETE_MIHRET_DELTA; + } + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, era, year, month, day); + } + toJulianDay(date) { + let year = date.year; + if (date.era === 'AA') year -= $ca8f5bca40aaf2d4$var$AMETE_MIHRET_DELTA; + return $ca8f5bca40aaf2d4$var$ceToJulianDay($ca8f5bca40aaf2d4$var$ETHIOPIC_EPOCH, year, date.month, date.day); + } + getDaysInMonth(date) { + return $ca8f5bca40aaf2d4$var$getDaysInMonth(date.year, date.month); + } + getMonthsInYear() { + return 13; + } + getDaysInYear(date) { + return 365 + $ca8f5bca40aaf2d4$var$getLeapDay(date.year); + } + getMaximumMonthsInYear() { + return 13; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra(date) { + // 9999-12-31 gregorian is 9992-20-02 ethiopic. + // Round down to 9991 for the last full year. + // AA 9999-01-01 ethiopic is 4506-09-30 gregorian. + return date.era === 'AA' ? 9999 : 9991; + } + getEras() { + return [ + 'AA', + 'AM' + ]; + } + constructor(){ + this.identifier = 'ethiopic'; + } +} +class $ca8f5bca40aaf2d4$export$d72e0c37005a4914 extends $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $ca8f5bca40aaf2d4$var$julianDayToCE($ca8f5bca40aaf2d4$var$ETHIOPIC_EPOCH, jd); + year += $ca8f5bca40aaf2d4$var$AMETE_MIHRET_DELTA; + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, 'AA', year, month, day); + } + getEras() { + return [ + 'AA' + ]; + } + getYearsInEra() { + // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian. + return 9999; + } + constructor(...args){ + super(...args), this.identifier = 'ethioaa' // also known as 'ethiopic-amete-alem' in ICU + ; + } +} +class $ca8f5bca40aaf2d4$export$fe6243cbe1a4b7c1 extends $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $ca8f5bca40aaf2d4$var$julianDayToCE($ca8f5bca40aaf2d4$var$COPTIC_EPOCH, jd); + let era = 'CE'; + if (year <= 0) { + era = 'BCE'; + year = 1 - year; + } + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, era, year, month, day); + } + toJulianDay(date) { + let year = date.year; + if (date.era === 'BCE') year = 1 - year; + return $ca8f5bca40aaf2d4$var$ceToJulianDay($ca8f5bca40aaf2d4$var$COPTIC_EPOCH, year, date.month, date.day); + } + getDaysInMonth(date) { + let year = date.year; + if (date.era === 'BCE') year = 1 - year; + return $ca8f5bca40aaf2d4$var$getDaysInMonth(year, date.month); + } + isInverseEra(date) { + return date.era === 'BCE'; + } + balanceDate(date) { + if (date.year <= 0) { + date.era = date.era === 'BCE' ? 'CE' : 'BCE'; + date.year = 1 - date.year; + } + } + getEras() { + return [ + 'BCE', + 'CE' + ]; + } + getYearsInEra(date) { + // 9999-12-30 gregorian is 9716-02-20 coptic. + // Round down to 9715 for the last full year. + // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian. + return date.era === 'BCE' ? 9999 : 9715; + } + constructor(...args){ + super(...args), this.identifier = 'coptic'; + } +} + + +export {$ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d as EthiopicCalendar, $ca8f5bca40aaf2d4$export$d72e0c37005a4914 as EthiopicAmeteAlemCalendar, $ca8f5bca40aaf2d4$export$fe6243cbe1a4b7c1 as CopticCalendar}; +//# sourceMappingURL=EthiopicCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9a89535129fb5de51460f60341aee2bdce9061a9 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAMhG,MAAM,uCAAiB;AACvB,MAAM,qCAAe;AAErB,oDAAoD;AACpD,iBAAiB;AACjB,MAAM,2CAAqB;AAE3B,SAAS,oCAAc,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IAC5E,OACE,QAAQ,wCAAwC;IAChD,MAAM,OAAO,4BAA4B;IACzC,KAAK,KAAK,CAAC,OAAO,KAAK,yBAAyB;IAChD,KAAM,CAAA,QAAQ,CAAA,IAAK,uCAAuC;IAC1D,MACA,EAAE,6CAA6C;;AAEnD;AAEA,SAAS,oCAAc,KAAa,EAAE,EAAU;IAC9C,IAAI,OAAO,KAAK,KAAK,CAAC,AAAC,IAAK,CAAA,KAAK,KAAI,IAAM;IAC3C,IAAI,QAAQ,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,oCAAc,OAAO,MAAM,GAAG,EAAC,IAAK;IACrE,IAAI,MAAM,KAAK,IAAI,oCAAc,OAAO,MAAM,OAAO;IACrD,OAAO;QAAC;QAAM;QAAO;KAAI;AAC3B;AAEA,SAAS,iCAAW,IAAY;IAC9B,OAAO,KAAK,KAAK,CAAC,AAAC,OAAO,IAAK;AACjC;A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*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {Mutable} from '../utils';\n\nconst ETHIOPIC_EPOCH = 1723856;\nconst COPTIC_EPOCH = 1824665;\n\n// The delta between Amete Alem 1 and Amete Mihret 1\n// AA 5501 = AM 1\nconst AMETE_MIHRET_DELTA = 5500;\n\nfunction ceToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return (\n epoch + // difference from Julian epoch to 1,1,1\n 365 * year + // number of days from years\n Math.floor(year / 4) + // extra day of leap year\n 30 * (month - 1) + // number of days from months (1 based)\n day -\n 1 // number of days for present month (1 based)\n );\n}\n\nfunction julianDayToCE(epoch: number, jd: number) {\n let year = Math.floor((4 * (jd - epoch)) / 1461);\n let month = 1 + Math.floor((jd - ceToJulianDay(epoch, year, 1, 1)) / 30);\n let day = jd + 1 - ceToJulianDay(epoch, year, month, 1);\n return [year, month, day];\n}\n\nfunction getLeapDay(year: number) {\n return Math.floor((year % 4) / 3);\n}\n\nfunction getDaysInMonth(year: number, month: number) {\n // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and\n // an intercalary month at the end of the year of 5 or 6 days, depending whether\n // the year is a leap year or not. The Leap Year follows the same rules as the\n // Julian Calendar so that the extra month always has six days in the year before\n // a Julian Leap Year.\n if (month % 13 !== 0) {\n // not intercalary month\n return 30;\n } else {\n // intercalary month 5 days + possible leap day\n return getLeapDay(year) + 5;\n }\n}\n\n/**\n * The Ethiopic calendar system is the official calendar used in Ethiopia.\n * It includes 12 months of 30 days each, plus 5 or 6 intercalary days depending\n * on whether it is a leap year. Two eras are supported: 'AA' and 'AM'.\n */\nexport class EthiopicCalendar implements Calendar {\n identifier: CalendarIdentifier = 'ethiopic';\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(ETHIOPIC_EPOCH, jd);\n let era = 'AM';\n if (year <= 0) {\n era = 'AA';\n year += AMETE_MIHRET_DELTA;\n }\n\n return new CalendarDate(this, era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'AA') {\n year -= AMETE_MIHRET_DELTA;\n }\n\n return ceToJulianDay(ETHIOPIC_EPOCH, year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(): number {\n return 13;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return 365 + getLeapDay(date.year);\n }\n\n getMaximumMonthsInYear(): number {\n return 13;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // 9999-12-31 gregorian is 9992-20-02 ethiopic.\n // Round down to 9991 for the last full year.\n // AA 9999-01-01 ethiopic is 4506-09-30 gregorian.\n return date.era === 'AA' ? 9999 : 9991;\n }\n\n getEras(): string[] {\n return ['AA', 'AM'];\n }\n}\n\n/**\n * The Ethiopic (Amete Alem) calendar is the same as the modern Ethiopic calendar,\n * except years were measured from a different epoch. Only one era is supported: 'AA'.\n */\nexport class EthiopicAmeteAlemCalendar extends EthiopicCalendar {\n identifier: CalendarIdentifier = 'ethioaa'; // also known as 'ethiopic-amete-alem' in ICU\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(ETHIOPIC_EPOCH, jd);\n year += AMETE_MIHRET_DELTA;\n return new CalendarDate(this, 'AA', year, month, day);\n }\n\n getEras(): string[] {\n return ['AA'];\n }\n\n getYearsInEra(): number {\n // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian.\n return 9999;\n }\n}\n\n/**\n * The Coptic calendar is similar to the Ethiopic calendar.\n * It includes 12 months of 30 days each, plus 5 or 6 intercalary days depending\n * on whether it is a leap year. Two eras are supported: 'BCE' and 'CE'.\n */\nexport class CopticCalendar extends EthiopicCalendar {\n identifier: CalendarIdentifier = 'coptic';\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(COPTIC_EPOCH, jd);\n let era = 'CE';\n if (year <= 0) {\n era = 'BCE';\n year = 1 - year;\n }\n\n return new CalendarDate(this, era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'BCE') {\n year = 1 - year;\n }\n\n return ceToJulianDay(COPTIC_EPOCH, year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'BCE') {\n year = 1 - year;\n }\n\n return getDaysInMonth(year, date.month);\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BCE';\n }\n\n balanceDate(date: Mutable): void {\n if (date.year <= 0) {\n date.era = date.era === 'BCE' ? 'CE' : 'BCE';\n date.year = 1 - date.year;\n }\n }\n\n getEras(): string[] {\n return ['BCE', 'CE'];\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // 9999-12-30 gregorian is 9716-02-20 coptic.\n // Round down to 9715 for the last full year.\n // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian.\n return date.era === 'BCE' ? 9999 : 9715;\n }\n}\n"],"names":[],"version":3,"file":"EthiopicCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..392b46c4379c3351fb187f897b7da5f1656ee591 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.mjs @@ -0,0 +1,167 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + +const $97cfca9efd59523d$var$ETHIOPIC_EPOCH = 1723856; +const $97cfca9efd59523d$var$COPTIC_EPOCH = 1824665; +// The delta between Amete Alem 1 and Amete Mihret 1 +// AA 5501 = AM 1 +const $97cfca9efd59523d$var$AMETE_MIHRET_DELTA = 5500; +function $97cfca9efd59523d$var$ceToJulianDay(epoch, year, month, day) { + return epoch + // difference from Julian epoch to 1,1,1 + 365 * year + // number of days from years + Math.floor(year / 4) + // extra day of leap year + 30 * (month - 1) + // number of days from months (1 based) + day - 1 // number of days for present month (1 based) + ; +} +function $97cfca9efd59523d$var$julianDayToCE(epoch, jd) { + let year = Math.floor(4 * (jd - epoch) / 1461); + let month = 1 + Math.floor((jd - $97cfca9efd59523d$var$ceToJulianDay(epoch, year, 1, 1)) / 30); + let day = jd + 1 - $97cfca9efd59523d$var$ceToJulianDay(epoch, year, month, 1); + return [ + year, + month, + day + ]; +} +function $97cfca9efd59523d$var$getLeapDay(year) { + return Math.floor(year % 4 / 3); +} +function $97cfca9efd59523d$var$getDaysInMonth(year, month) { + // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and + // an intercalary month at the end of the year of 5 or 6 days, depending whether + // the year is a leap year or not. The Leap Year follows the same rules as the + // Julian Calendar so that the extra month always has six days in the year before + // a Julian Leap Year. + if (month % 13 !== 0) // not intercalary month + return 30; + else // intercalary month 5 days + possible leap day + return $97cfca9efd59523d$var$getLeapDay(year) + 5; +} +class $97cfca9efd59523d$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $97cfca9efd59523d$var$julianDayToCE($97cfca9efd59523d$var$ETHIOPIC_EPOCH, jd); + let era = 'AM'; + if (year <= 0) { + era = 'AA'; + year += $97cfca9efd59523d$var$AMETE_MIHRET_DELTA; + } + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, era, year, month, day); + } + toJulianDay(date) { + let year = date.year; + if (date.era === 'AA') year -= $97cfca9efd59523d$var$AMETE_MIHRET_DELTA; + return $97cfca9efd59523d$var$ceToJulianDay($97cfca9efd59523d$var$ETHIOPIC_EPOCH, year, date.month, date.day); + } + getDaysInMonth(date) { + return $97cfca9efd59523d$var$getDaysInMonth(date.year, date.month); + } + getMonthsInYear() { + return 13; + } + getDaysInYear(date) { + return 365 + $97cfca9efd59523d$var$getLeapDay(date.year); + } + getMaximumMonthsInYear() { + return 13; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra(date) { + // 9999-12-31 gregorian is 9992-20-02 ethiopic. + // Round down to 9991 for the last full year. + // AA 9999-01-01 ethiopic is 4506-09-30 gregorian. + return date.era === 'AA' ? 9999 : 9991; + } + getEras() { + return [ + 'AA', + 'AM' + ]; + } + constructor(){ + this.identifier = 'ethiopic'; + } +} +class $97cfca9efd59523d$export$d72e0c37005a4914 extends $97cfca9efd59523d$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $97cfca9efd59523d$var$julianDayToCE($97cfca9efd59523d$var$ETHIOPIC_EPOCH, jd); + year += $97cfca9efd59523d$var$AMETE_MIHRET_DELTA; + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, 'AA', year, month, day); + } + getEras() { + return [ + 'AA' + ]; + } + getYearsInEra() { + // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian. + return 9999; + } + constructor(...args){ + super(...args), this.identifier = 'ethioaa' // also known as 'ethiopic-amete-alem' in ICU + ; + } +} +class $97cfca9efd59523d$export$fe6243cbe1a4b7c1 extends $97cfca9efd59523d$export$26ba6eab5e20cd7d { + fromJulianDay(jd) { + let [year, month, day] = $97cfca9efd59523d$var$julianDayToCE($97cfca9efd59523d$var$COPTIC_EPOCH, jd); + let era = 'CE'; + if (year <= 0) { + era = 'BCE'; + year = 1 - year; + } + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, era, year, month, day); + } + toJulianDay(date) { + let year = date.year; + if (date.era === 'BCE') year = 1 - year; + return $97cfca9efd59523d$var$ceToJulianDay($97cfca9efd59523d$var$COPTIC_EPOCH, year, date.month, date.day); + } + getDaysInMonth(date) { + let year = date.year; + if (date.era === 'BCE') year = 1 - year; + return $97cfca9efd59523d$var$getDaysInMonth(year, date.month); + } + isInverseEra(date) { + return date.era === 'BCE'; + } + balanceDate(date) { + if (date.year <= 0) { + date.era = date.era === 'BCE' ? 'CE' : 'BCE'; + date.year = 1 - date.year; + } + } + getEras() { + return [ + 'BCE', + 'CE' + ]; + } + getYearsInEra(date) { + // 9999-12-30 gregorian is 9716-02-20 coptic. + // Round down to 9715 for the last full year. + // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian. + return date.era === 'BCE' ? 9999 : 9715; + } + constructor(...args){ + super(...args), this.identifier = 'coptic'; + } +} + + +export {$97cfca9efd59523d$export$26ba6eab5e20cd7d as EthiopicCalendar, $97cfca9efd59523d$export$d72e0c37005a4914 as EthiopicAmeteAlemCalendar, $97cfca9efd59523d$export$fe6243cbe1a4b7c1 as CopticCalendar}; +//# sourceMappingURL=EthiopicCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/EthiopicCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..d94dec0bae902ea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OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,OAAO;IAClD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,OAAO,KAAK,IAAI;QACpB,IAAI,KAAK,GAAG,KAAK,OACf,OAAO,IAAI;QAGb,OAAO,oCAAc,oCAAc,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,OAAO,KAAK,IAAI;QACpB,IAAI,KAAK,GAAG,KAAK,OACf,OAAO,IAAI;QAGb,OAAO,qCAAe,MAAM,KAAK,KAAK;IACxC;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,KAAK,IAAI,IAAI,GAAG;YAClB,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,QAAQ,OAAO;YACvC,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI;QAC3B;IACF;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAO;SAAK;IACtB;IAEA,cAAc,IAAqB,EAAU;QAC3C,6CAA6C;QAC7C,6CAA6C;QAC7C,oDAAoD;QACpD,OAAO,KAAK,GAAG,KAAK,QAAQ,OAAO;IACrC;;QApDK,qBACL,aAAiC;;AAoDnC","sources":["packages/@internationalized/date/src/calendars/EthiopicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {Mutable} from '../utils';\n\nconst ETHIOPIC_EPOCH = 1723856;\nconst COPTIC_EPOCH = 1824665;\n\n// The delta between Amete Alem 1 and Amete Mihret 1\n// AA 5501 = AM 1\nconst AMETE_MIHRET_DELTA = 5500;\n\nfunction ceToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return (\n epoch + // difference from Julian epoch to 1,1,1\n 365 * year + // number of days from years\n Math.floor(year / 4) + // extra day of leap year\n 30 * (month - 1) + // number of days from months (1 based)\n day -\n 1 // number of days for present month (1 based)\n );\n}\n\nfunction julianDayToCE(epoch: number, jd: number) {\n let year = Math.floor((4 * (jd - epoch)) / 1461);\n let month = 1 + Math.floor((jd - ceToJulianDay(epoch, year, 1, 1)) / 30);\n let day = jd + 1 - ceToJulianDay(epoch, year, month, 1);\n return [year, month, day];\n}\n\nfunction getLeapDay(year: number) {\n return Math.floor((year % 4) / 3);\n}\n\nfunction getDaysInMonth(year: number, month: number) {\n // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and\n // an intercalary month at the end of the year of 5 or 6 days, depending whether\n // the year is a leap year or not. The Leap Year follows the same rules as the\n // Julian Calendar so that the extra month always has six days in the year before\n // a Julian Leap Year.\n if (month % 13 !== 0) {\n // not intercalary month\n return 30;\n } else {\n // intercalary month 5 days + possible leap day\n return getLeapDay(year) + 5;\n }\n}\n\n/**\n * The Ethiopic calendar system is the official calendar used in Ethiopia.\n * It includes 12 months of 30 days each, plus 5 or 6 intercalary days depending\n * on whether it is a leap year. Two eras are supported: 'AA' and 'AM'.\n */\nexport class EthiopicCalendar implements Calendar {\n identifier: CalendarIdentifier = 'ethiopic';\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(ETHIOPIC_EPOCH, jd);\n let era = 'AM';\n if (year <= 0) {\n era = 'AA';\n year += AMETE_MIHRET_DELTA;\n }\n\n return new CalendarDate(this, era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'AA') {\n year -= AMETE_MIHRET_DELTA;\n }\n\n return ceToJulianDay(ETHIOPIC_EPOCH, year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(): number {\n return 13;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return 365 + getLeapDay(date.year);\n }\n\n getMaximumMonthsInYear(): number {\n return 13;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // 9999-12-31 gregorian is 9992-20-02 ethiopic.\n // Round down to 9991 for the last full year.\n // AA 9999-01-01 ethiopic is 4506-09-30 gregorian.\n return date.era === 'AA' ? 9999 : 9991;\n }\n\n getEras(): string[] {\n return ['AA', 'AM'];\n }\n}\n\n/**\n * The Ethiopic (Amete Alem) calendar is the same as the modern Ethiopic calendar,\n * except years were measured from a different epoch. Only one era is supported: 'AA'.\n */\nexport class EthiopicAmeteAlemCalendar extends EthiopicCalendar {\n identifier: CalendarIdentifier = 'ethioaa'; // also known as 'ethiopic-amete-alem' in ICU\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(ETHIOPIC_EPOCH, jd);\n year += AMETE_MIHRET_DELTA;\n return new CalendarDate(this, 'AA', year, month, day);\n }\n\n getEras(): string[] {\n return ['AA'];\n }\n\n getYearsInEra(): number {\n // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian.\n return 9999;\n }\n}\n\n/**\n * The Coptic calendar is similar to the Ethiopic calendar.\n * It includes 12 months of 30 days each, plus 5 or 6 intercalary days depending\n * on whether it is a leap year. Two eras are supported: 'BCE' and 'CE'.\n */\nexport class CopticCalendar extends EthiopicCalendar {\n identifier: CalendarIdentifier = 'coptic';\n\n fromJulianDay(jd: number): CalendarDate {\n let [year, month, day] = julianDayToCE(COPTIC_EPOCH, jd);\n let era = 'CE';\n if (year <= 0) {\n era = 'BCE';\n year = 1 - year;\n }\n\n return new CalendarDate(this, era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'BCE') {\n year = 1 - year;\n }\n\n return ceToJulianDay(COPTIC_EPOCH, year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let year = date.year;\n if (date.era === 'BCE') {\n year = 1 - year;\n }\n\n return getDaysInMonth(year, date.month);\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BCE';\n }\n\n balanceDate(date: Mutable): void {\n if (date.year <= 0) {\n date.era = date.era === 'BCE' ? 'CE' : 'BCE';\n date.year = 1 - date.year;\n }\n }\n\n getEras(): string[] {\n return ['BCE', 'CE'];\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // 9999-12-30 gregorian is 9716-02-20 coptic.\n // Round down to 9715 for the last full year.\n // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian.\n return date.era === 'BCE' ? 9999 : 9715;\n }\n}\n"],"names":[],"version":3,"file":"EthiopicCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..86f13d478899a8f60f9e239190cba1f0060c76c7 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.cjs @@ -0,0 +1,149 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $09f945753a699862$exports = require("../utils.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "gregorianToJulianDay", function () { return $05031860ba2f881f$export$f297eb839006d339; }); +$parcel$export(module.exports, "getExtendedYear", function () { return $05031860ba2f881f$export$c36e0ecb2d4fa69d; }); +$parcel$export(module.exports, "isLeapYear", function () { return $05031860ba2f881f$export$553d7fa8e3805fc0; }); +$parcel$export(module.exports, "fromExtendedYear", function () { return $05031860ba2f881f$export$4475b7e617eb123c; }); +$parcel$export(module.exports, "GregorianCalendar", function () { return $05031860ba2f881f$export$80ee6245ec4f29ec; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $05031860ba2f881f$var$EPOCH = 1721426; // 001/01/03 Julian C.E. +function $05031860ba2f881f$export$f297eb839006d339(era, year, month, day) { + year = $05031860ba2f881f$export$c36e0ecb2d4fa69d(era, year); + let y1 = year - 1; + let monthOffset = -2; + if (month <= 2) monthOffset = 0; + else if ($05031860ba2f881f$export$553d7fa8e3805fc0(year)) monthOffset = -1; + return $05031860ba2f881f$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day); +} +function $05031860ba2f881f$export$553d7fa8e3805fc0(year) { + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); +} +function $05031860ba2f881f$export$c36e0ecb2d4fa69d(era, year) { + return era === 'BC' ? 1 - year : year; +} +function $05031860ba2f881f$export$4475b7e617eb123c(year) { + let era = 'AD'; + if (year <= 0) { + era = 'BC'; + year = 1 - year; + } + return [ + era, + year + ]; +} +const $05031860ba2f881f$var$daysInMonth = { + standard: [ + 31, + 28, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 + ], + leapyear: [ + 31, + 29, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 + ] +}; +class $05031860ba2f881f$export$80ee6245ec4f29ec { + fromJulianDay(jd) { + let jd0 = jd; + let depoch = jd0 - $05031860ba2f881f$var$EPOCH; + let quadricent = Math.floor(depoch / 146097); + let dqc = (0, $09f945753a699862$exports.mod)(depoch, 146097); + let cent = Math.floor(dqc / 36524); + let dcent = (0, $09f945753a699862$exports.mod)(dqc, 36524); + let quad = Math.floor(dcent / 1461); + let dquad = (0, $09f945753a699862$exports.mod)(dcent, 1461); + let yindex = Math.floor(dquad / 365); + let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0); + let [era, year] = $05031860ba2f881f$export$4475b7e617eb123c(extendedYear); + let yearDay = jd0 - $05031860ba2f881f$export$f297eb839006d339(era, year, 1, 1); + let leapAdj = 2; + if (jd0 < $05031860ba2f881f$export$f297eb839006d339(era, year, 3, 1)) leapAdj = 0; + else if ($05031860ba2f881f$export$553d7fa8e3805fc0(year)) leapAdj = 1; + let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367); + let day = jd0 - $05031860ba2f881f$export$f297eb839006d339(era, year, month, 1) + 1; + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(era, year, month, day); + } + toJulianDay(date) { + return $05031860ba2f881f$export$f297eb839006d339(date.era, date.year, date.month, date.day); + } + getDaysInMonth(date) { + return $05031860ba2f881f$var$daysInMonth[$05031860ba2f881f$export$553d7fa8e3805fc0(date.year) ? 'leapyear' : 'standard'][date.month - 1]; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getMonthsInYear(date) { + return 12; + } + getDaysInYear(date) { + return $05031860ba2f881f$export$553d7fa8e3805fc0(date.year) ? 366 : 365; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 31; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getYearsInEra(date) { + return 9999; + } + getEras() { + return [ + 'BC', + 'AD' + ]; + } + isInverseEra(date) { + return date.era === 'BC'; + } + balanceDate(date) { + if (date.year <= 0) { + date.era = date.era === 'BC' ? 'AD' : 'BC'; + date.year = 1 - date.year; + } + } + constructor(){ + this.identifier = 'gregory'; + } +} + + +//# sourceMappingURL=GregorianCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..81cb5584cf6f7288c20170c346b02061c38bff8f --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,8BAAQ,SAAS,wBAAwB;AACxC,SAAS,0CACd,GAAW,EACX,IAAY,EACZ,KAAa,EACb,GAAW;IAEX,OAAO,0CAAgB,KAAK;IAE5B,IAAI,KAAK,OAAO;IAChB,IAAI,cAAc;IAClB,IAAI,SAAS,GACX,cAAc;SACT,IAAI,0CAAW,OACpB,cAAc;IAGhB,OACE,8BACA,IACA,MAAM,KACN,KAAK,KAAK,CAAC,KAAK,KAChB,KAAK,KAAK,CAAC,KAAK,OAChB,KAAK,KAAK,CAAC,KAAK,OAChB,KAAK,KAAK,CAAC,AAAC,CAAA,MAAM,QAAQ,GAAE,IAAK,KAAK,cAAc;AAExD;AAEO,SAAS,0CAAW,IAAY;IACrC,OAAO,OAAO,MAAM,KAAM,CAAA,OAAO,QAAQ,KAAK,OAAO,QAAQ,CAAA;AAC/D;AAEO,SAAS,0CAAgB,GAAW,EAAE,IAAY;IACvD,OAAO,QAAQ,OAAO,IAAI,OAAO;AACnC;AAEO,SAAS,0CAAiB,IAAY;IAC3C,IAAI,MAAM;IACV,IAAI,QAAQ,GAAG;QACb,MAAM;QACN,OAAO,IAAI;IACb;IAEA,OAAO;QAAC;QAA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AE,KAAK,KAAK,EAAE,KAAK,GAAG;IACvE;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,iCAAW,CAAC,0CAAW,KAAK,IAAI,IAAI,aAAa,WAAW,CAAC,KAAK,KAAK,GAAG,EAAE;IACrF;IAEA,6DAA6D;IAC7D,gBAAgB,IAAqB,EAAU;QAC7C,OAAO;IACT;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,0CAAW,KAAK,IAAI,IAAI,MAAM;IACvC;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,6DAA6D;IAC7D,cAAc,IAAqB,EAAU;QAC3C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAM;SAAK;IACrB;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,KAAK,IAAI,IAAI,GAAG;YAClB,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,OAAO,OAAO;YACtC,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI;QAC3B;IACF;;aAxEA,aAAiC;;AAyEnC","sources":["packages/@internationalized/date/src/calendars/GregorianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst EPOCH = 1721426; // 001/01/03 Julian C.E.\nexport function gregorianToJulianDay(\n era: string,\n year: number,\n month: number,\n day: number\n): number {\n year = getExtendedYear(era, year);\n\n let y1 = year - 1;\n let monthOffset = -2;\n if (month <= 2) {\n monthOffset = 0;\n } else if (isLeapYear(year)) {\n monthOffset = -1;\n }\n\n return (\n EPOCH -\n 1 +\n 365 * y1 +\n Math.floor(y1 / 4) -\n Math.floor(y1 / 100) +\n Math.floor(y1 / 400) +\n Math.floor((367 * month - 362) / 12 + monthOffset + day)\n );\n}\n\nexport function isLeapYear(year: number): boolean {\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n}\n\nexport function getExtendedYear(era: string, year: number): number {\n return era === 'BC' ? 1 - year : year;\n}\n\nexport function fromExtendedYear(year: number): [string, number] {\n let era = 'AD';\n if (year <= 0) {\n era = 'BC';\n year = 1 - year;\n }\n\n return [era, year];\n}\n\nconst daysInMonth = {\n standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],\n leapyear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n};\n\n/**\n * The Gregorian calendar is the most commonly used calendar system in the world. It supports two\n * eras: BC, and AD. Years always contain 12 months, and 365 or 366 days depending on whether it is\n * a leap year.\n */\nexport class GregorianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'gregory';\n\n fromJulianDay(jd: number): CalendarDate {\n let jd0 = jd;\n let depoch = jd0 - EPOCH;\n let quadricent = Math.floor(depoch / 146097);\n let dqc = mod(depoch, 146097);\n let cent = Math.floor(dqc / 36524);\n let dcent = mod(dqc, 36524);\n let quad = Math.floor(dcent / 1461);\n let dquad = mod(dcent, 1461);\n let yindex = Math.floor(dquad / 365);\n\n let extendedYear =\n quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);\n let [era, year] = fromExtendedYear(extendedYear);\n let yearDay = jd0 - gregorianToJulianDay(era, year, 1, 1);\n let leapAdj = 2;\n if (jd0 < gregorianToJulianDay(era, year, 3, 1)) {\n leapAdj = 0;\n } else if (isLeapYear(year)) {\n leapAdj = 1;\n }\n let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);\n let day = jd0 - gregorianToJulianDay(era, year, month, 1) + 1;\n\n return new CalendarDate(era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return gregorianToJulianDay(date.era, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return daysInMonth[isLeapYear(date.year) ? 'leapyear' : 'standard'][date.month - 1];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getMonthsInYear(date: AnyCalendarDate): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 366 : 365;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getYearsInEra(date: AnyCalendarDate): number {\n return 9999;\n }\n\n getEras(): string[] {\n return ['BC', 'AD'];\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BC';\n }\n\n balanceDate(date: Mutable): void {\n if (date.year <= 0) {\n date.era = date.era === 'BC' ? 'AD' : 'BC';\n date.year = 1 - date.year;\n }\n }\n}\n"],"names":[],"version":3,"file":"GregorianCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..e234bb11e5fb0bcc995114633322b92a01b2b4c3 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js @@ -0,0 +1,140 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {mod as $1797f75f9a4d3bd4$export$842a2cf37af977e1} from "../utils.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $f25df78da1f6b40f$var$EPOCH = 1721426; // 001/01/03 Julian C.E. +function $f25df78da1f6b40f$export$f297eb839006d339(era, year, month, day) { + year = $f25df78da1f6b40f$export$c36e0ecb2d4fa69d(era, year); + let y1 = year - 1; + let monthOffset = -2; + if (month <= 2) monthOffset = 0; + else if ($f25df78da1f6b40f$export$553d7fa8e3805fc0(year)) monthOffset = -1; + return $f25df78da1f6b40f$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day); +} +function $f25df78da1f6b40f$export$553d7fa8e3805fc0(year) { + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); +} +function $f25df78da1f6b40f$export$c36e0ecb2d4fa69d(era, year) { + return era === 'BC' ? 1 - year : year; +} +function $f25df78da1f6b40f$export$4475b7e617eb123c(year) { + let era = 'AD'; + if (year <= 0) { + era = 'BC'; + year = 1 - year; + } + return [ + era, + year + ]; +} +const $f25df78da1f6b40f$var$daysInMonth = { + standard: [ + 31, + 28, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 + ], + leapyear: [ + 31, + 29, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 + ] +}; +class $f25df78da1f6b40f$export$80ee6245ec4f29ec { + fromJulianDay(jd) { + let jd0 = jd; + let depoch = jd0 - $f25df78da1f6b40f$var$EPOCH; + let quadricent = Math.floor(depoch / 146097); + let dqc = (0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(depoch, 146097); + let cent = Math.floor(dqc / 36524); + let dcent = (0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(dqc, 36524); + let quad = Math.floor(dcent / 1461); + let dquad = (0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(dcent, 1461); + let yindex = Math.floor(dquad / 365); + let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0); + let [era, year] = $f25df78da1f6b40f$export$4475b7e617eb123c(extendedYear); + let yearDay = jd0 - $f25df78da1f6b40f$export$f297eb839006d339(era, year, 1, 1); + let leapAdj = 2; + if (jd0 < $f25df78da1f6b40f$export$f297eb839006d339(era, year, 3, 1)) leapAdj = 0; + else if ($f25df78da1f6b40f$export$553d7fa8e3805fc0(year)) leapAdj = 1; + let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367); + let day = jd0 - $f25df78da1f6b40f$export$f297eb839006d339(era, year, month, 1) + 1; + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(era, year, month, day); + } + toJulianDay(date) { + return $f25df78da1f6b40f$export$f297eb839006d339(date.era, date.year, date.month, date.day); + } + getDaysInMonth(date) { + return $f25df78da1f6b40f$var$daysInMonth[$f25df78da1f6b40f$export$553d7fa8e3805fc0(date.year) ? 'leapyear' : 'standard'][date.month - 1]; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getMonthsInYear(date) { + return 12; + } + getDaysInYear(date) { + return $f25df78da1f6b40f$export$553d7fa8e3805fc0(date.year) ? 366 : 365; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 31; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getYearsInEra(date) { + return 9999; + } + getEras() { + return [ + 'BC', + 'AD' + ]; + } + isInverseEra(date) { + return date.era === 'BC'; + } + balanceDate(date) { + if (date.year <= 0) { + date.era = date.era === 'BC' ? 'AD' : 'BC'; + date.year = 1 - date.year; + } + } + constructor(){ + this.identifier = 'gregory'; + } +} + + +export {$f25df78da1f6b40f$export$f297eb839006d339 as gregorianToJulianDay, $f25df78da1f6b40f$export$c36e0ecb2d4fa69d as getExtendedYear, $f25df78da1f6b40f$export$553d7fa8e3805fc0 as isLeapYear, $f25df78da1f6b40f$export$4475b7e617eb123c as fromExtendedYear, $f25df78da1f6b40f$export$80ee6245ec4f29ec as GregorianCalendar}; +//# sourceMappingURL=GregorianCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..0534290270da9e6414ccd55e6d996b693a2efe3a --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,8BAAQ,SAAS,wBAAwB;AACxC,SAAS,0CACd,GAAW,EACX,IAAY,EACZ,KAAa,EACb,GAAW;IAEX,OAAO,0CAAgB,KAAK;IAE5B,IAAI,KAAK,OAAO;IAChB,IAAI,cAAc;IAClB,IAAI,SAAS,GACX,cAAc;SACT,IAAI,0CAAW,OACpB,cAAc;IAGhB,OACE,8BACA,IACA,MAAM,KACN,KAAK,KAAK,CAAC,KAAK,KAChB,KAAK,KAAK,CAAC,KAAK,OAChB,KAAK,KAAK,CAAC,KAAK,OAChB,KAAK,KAAK,CAAC,AAAC,CAAA,MAAM,QAAQ,GAAE,IAAK,KAAK,cAAc;AAExD;AAEO,SAAS,0CAAW,IAAY;IACrC,OAAO,OAAO,MAAM,KAAM,CAAA,OAAO,QAAQ,KAAK,OAAO,QAAQ,CAAA;AAC/D;AAEO,SAAS,0CAAgB,GAAW,EAAE,IAAY;IACvD,OAAO,QAAQ,OAAO,IAAI,OAAO;AACnC;AAEO,SAAS,0CAAiB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,KAAK,MAAM,OAAO;IAC5C;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,0CAAqB,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,KAAK,GAAG;IACvE;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,iCAAW,CAAC,0CAAW,KAAK,IAAI,IAAI,aAAa,WAAW,CAAC,KAAK,KAAK,GAAG,EAAE;IACrF;IAEA,6DAA6D;IAC7D,gBAAgB,IAAqB,EAAU;QAC7C,OAAO;IACT;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,0CAAW,KAAK,IAAI,IAAI,MAAM;IACvC;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,6DAA6D;IAC7D,cAAc,IAAqB,EAAU;QAC3C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAM;SAAK;IACrB;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,KAAK,IAAI,IAAI,GAAG;YAClB,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,OAAO,OAAO;YACtC,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI;QAC3B;IACF;;aAxEA,aAAiC;;AAyEnC","sources":["packages/@internationalized/date/src/calendars/GregorianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst EPOCH = 1721426; // 001/01/03 Julian C.E.\nexport function gregorianToJulianDay(\n era: string,\n year: number,\n month: number,\n day: number\n): number {\n year = getExtendedYear(era, year);\n\n let y1 = year - 1;\n let monthOffset = -2;\n if (month <= 2) {\n monthOffset = 0;\n } else if (isLeapYear(year)) {\n monthOffset = -1;\n }\n\n return (\n EPOCH -\n 1 +\n 365 * y1 +\n Math.floor(y1 / 4) -\n Math.floor(y1 / 100) +\n Math.floor(y1 / 400) +\n Math.floor((367 * month - 362) / 12 + monthOffset + day)\n );\n}\n\nexport function isLeapYear(year: number): boolean {\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n}\n\nexport function getExtendedYear(era: string, year: number): number {\n return era === 'BC' ? 1 - year : year;\n}\n\nexport function fromExtendedYear(year: number): [string, number] {\n let era = 'AD';\n if (year <= 0) {\n era = 'BC';\n year = 1 - year;\n }\n\n return [era, year];\n}\n\nconst daysInMonth = {\n standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],\n leapyear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n};\n\n/**\n * The Gregorian calendar is the most commonly used calendar system in the world. It supports two\n * eras: BC, and AD. Years always contain 12 months, and 365 or 366 days depending on whether it is\n * a leap year.\n */\nexport class GregorianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'gregory';\n\n fromJulianDay(jd: number): CalendarDate {\n let jd0 = jd;\n let depoch = jd0 - EPOCH;\n let quadricent = Math.floor(depoch / 146097);\n let dqc = mod(depoch, 146097);\n let cent = Math.floor(dqc / 36524);\n let dcent = mod(dqc, 36524);\n let quad = Math.floor(dcent / 1461);\n let dquad = mod(dcent, 1461);\n let yindex = Math.floor(dquad / 365);\n\n let extendedYear =\n quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);\n let [era, year] = fromExtendedYear(extendedYear);\n let yearDay = jd0 - gregorianToJulianDay(era, year, 1, 1);\n let leapAdj = 2;\n if (jd0 < gregorianToJulianDay(era, year, 3, 1)) {\n leapAdj = 0;\n } else if (isLeapYear(year)) {\n leapAdj = 1;\n }\n let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);\n let day = jd0 - gregorianToJulianDay(era, year, month, 1) + 1;\n\n return new CalendarDate(era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return gregorianToJulianDay(date.era, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return daysInMonth[isLeapYear(date.year) ? 'leapyear' : 'standard'][date.month - 1];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getMonthsInYear(date: AnyCalendarDate): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 366 : 365;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getYearsInEra(date: AnyCalendarDate): number {\n return 9999;\n }\n\n getEras(): string[] {\n return ['BC', 'AD'];\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BC';\n }\n\n balanceDate(date: Mutable): void {\n if (date.year <= 0) {\n date.era = date.era === 'BC' ? 'AD' : 'BC';\n date.year = 1 - date.year;\n }\n }\n}\n"],"names":[],"version":3,"file":"GregorianCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..47f137ad6cf8519652d59b7b39a39afa6307f4a1 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.mjs @@ -0,0 +1,140 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {mod as $09ec6a572d60460f$export$842a2cf37af977e1} from "../utils.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $93635573935797de$var$EPOCH = 1721426; // 001/01/03 Julian C.E. +function $93635573935797de$export$f297eb839006d339(era, year, month, day) { + year = $93635573935797de$export$c36e0ecb2d4fa69d(era, year); + let y1 = year - 1; + let monthOffset = -2; + if (month <= 2) monthOffset = 0; + else if ($93635573935797de$export$553d7fa8e3805fc0(year)) monthOffset = -1; + return $93635573935797de$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day); +} +function $93635573935797de$export$553d7fa8e3805fc0(year) { + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); +} +function $93635573935797de$export$c36e0ecb2d4fa69d(era, year) { + return era === 'BC' ? 1 - year : year; +} +function $93635573935797de$export$4475b7e617eb123c(year) { + let era = 'AD'; + if (year <= 0) { + era = 'BC'; + year = 1 - year; + } + return [ + era, + year + ]; +} +const $93635573935797de$var$daysInMonth = { + standard: [ + 31, + 28, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 + ], + leapyear: [ + 31, + 29, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 + ] +}; +class $93635573935797de$export$80ee6245ec4f29ec { + fromJulianDay(jd) { + let jd0 = jd; + let depoch = jd0 - $93635573935797de$var$EPOCH; + let quadricent = Math.floor(depoch / 146097); + let dqc = (0, $09ec6a572d60460f$export$842a2cf37af977e1)(depoch, 146097); + let cent = Math.floor(dqc / 36524); + let dcent = (0, $09ec6a572d60460f$export$842a2cf37af977e1)(dqc, 36524); + let quad = Math.floor(dcent / 1461); + let dquad = (0, $09ec6a572d60460f$export$842a2cf37af977e1)(dcent, 1461); + let yindex = Math.floor(dquad / 365); + let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0); + let [era, year] = $93635573935797de$export$4475b7e617eb123c(extendedYear); + let yearDay = jd0 - $93635573935797de$export$f297eb839006d339(era, year, 1, 1); + let leapAdj = 2; + if (jd0 < $93635573935797de$export$f297eb839006d339(era, year, 3, 1)) leapAdj = 0; + else if ($93635573935797de$export$553d7fa8e3805fc0(year)) leapAdj = 1; + let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367); + let day = jd0 - $93635573935797de$export$f297eb839006d339(era, year, month, 1) + 1; + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(era, year, month, day); + } + toJulianDay(date) { + return $93635573935797de$export$f297eb839006d339(date.era, date.year, date.month, date.day); + } + getDaysInMonth(date) { + return $93635573935797de$var$daysInMonth[$93635573935797de$export$553d7fa8e3805fc0(date.year) ? 'leapyear' : 'standard'][date.month - 1]; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getMonthsInYear(date) { + return 12; + } + getDaysInYear(date) { + return $93635573935797de$export$553d7fa8e3805fc0(date.year) ? 366 : 365; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 31; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getYearsInEra(date) { + return 9999; + } + getEras() { + return [ + 'BC', + 'AD' + ]; + } + isInverseEra(date) { + return date.era === 'BC'; + } + balanceDate(date) { + if (date.year <= 0) { + date.era = date.era === 'BC' ? 'AD' : 'BC'; + date.year = 1 - date.year; + } + } + constructor(){ + this.identifier = 'gregory'; + } +} + + +export {$93635573935797de$export$f297eb839006d339 as gregorianToJulianDay, $93635573935797de$export$c36e0ecb2d4fa69d as getExtendedYear, $93635573935797de$export$553d7fa8e3805fc0 as isLeapYear, $93635573935797de$export$4475b7e617eb123c as fromExtendedYear, $93635573935797de$export$80ee6245ec4f29ec as GregorianCalendar}; +//# sourceMappingURL=GregorianCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..58c6a029cdc687b4b34425b2af64ac7138c194bf --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,8BAAQ,SAAS,wBAAwB;AACxC,SAAS,0CACd,GAAW,EACX,IAAY,EACZ,KAAa,EACb,GAAW;IAEX,OAAO,0CAAgB,KAAK;IAE5B,IAAI,KAAK,OAAO;IAChB,IAAI,cAAc;IAClB,IAAI,SAAS,GACX,cAAc;SACT,IAAI,0CAAW,OACpB,cAAc;IAGhB,OACE,8BACA,IACA,MAAM,KACN,KAAK,KAAK,CAAC,KAAK,KAChB,KAAK,KAAK,CAAC,KAAK,OAChB,KAAK,KAAK,CAAC,KAAK,OAChB,KAAK,KAAK,CAAC,AAAC,CAAA,MAAM,QAAQ,GAAE,IAAK,KAAK,cAAc;AAExD;AAEO,SAAS,0CAAW,IAAY;IACrC,OAAO,OAAO,MAAM,KAAM,CAAA,OAAO,QAAQ,KAAK,OAAO,QAAQ,CAAA;AAC/D;AAEO,SAAS,0CAAgB,GAAW,EAAE,IAAY;IACvD,OAAO,QAAQ,OAAO,IAAI,OAAO;AACnC;AAEO,SAAS,0CAAiB,IAAY;IAC3C,IAAI,MAAM;IACV,IAAI,QAAQ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qB,EAAU;QACzC,OAAO,0CAAqB,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,KAAK,GAAG;IACvE;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,iCAAW,CAAC,0CAAW,KAAK,IAAI,IAAI,aAAa,WAAW,CAAC,KAAK,KAAK,GAAG,EAAE;IACrF;IAEA,6DAA6D;IAC7D,gBAAgB,IAAqB,EAAU;QAC7C,OAAO;IACT;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,0CAAW,KAAK,IAAI,IAAI,MAAM;IACvC;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,6DAA6D;IAC7D,cAAc,IAAqB,EAAU;QAC3C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAM;SAAK;IACrB;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,KAAK,IAAI,IAAI,GAAG;YAClB,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,OAAO,OAAO;YACtC,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI;QAC3B;IACF;;aAxEA,aAAiC;;AAyEnC","sources":["packages/@internationalized/date/src/calendars/GregorianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst EPOCH = 1721426; // 001/01/03 Julian C.E.\nexport function gregorianToJulianDay(\n era: string,\n year: number,\n month: number,\n day: number\n): number {\n year = getExtendedYear(era, year);\n\n let y1 = year - 1;\n let monthOffset = -2;\n if (month <= 2) {\n monthOffset = 0;\n } else if (isLeapYear(year)) {\n monthOffset = -1;\n }\n\n return (\n EPOCH -\n 1 +\n 365 * y1 +\n Math.floor(y1 / 4) -\n Math.floor(y1 / 100) +\n Math.floor(y1 / 400) +\n Math.floor((367 * month - 362) / 12 + monthOffset + day)\n );\n}\n\nexport function isLeapYear(year: number): boolean {\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n}\n\nexport function getExtendedYear(era: string, year: number): number {\n return era === 'BC' ? 1 - year : year;\n}\n\nexport function fromExtendedYear(year: number): [string, number] {\n let era = 'AD';\n if (year <= 0) {\n era = 'BC';\n year = 1 - year;\n }\n\n return [era, year];\n}\n\nconst daysInMonth = {\n standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],\n leapyear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n};\n\n/**\n * The Gregorian calendar is the most commonly used calendar system in the world. It supports two\n * eras: BC, and AD. Years always contain 12 months, and 365 or 366 days depending on whether it is\n * a leap year.\n */\nexport class GregorianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'gregory';\n\n fromJulianDay(jd: number): CalendarDate {\n let jd0 = jd;\n let depoch = jd0 - EPOCH;\n let quadricent = Math.floor(depoch / 146097);\n let dqc = mod(depoch, 146097);\n let cent = Math.floor(dqc / 36524);\n let dcent = mod(dqc, 36524);\n let quad = Math.floor(dcent / 1461);\n let dquad = mod(dcent, 1461);\n let yindex = Math.floor(dquad / 365);\n\n let extendedYear =\n quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);\n let [era, year] = fromExtendedYear(extendedYear);\n let yearDay = jd0 - gregorianToJulianDay(era, year, 1, 1);\n let leapAdj = 2;\n if (jd0 < gregorianToJulianDay(era, year, 3, 1)) {\n leapAdj = 0;\n } else if (isLeapYear(year)) {\n leapAdj = 1;\n }\n let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);\n let day = jd0 - gregorianToJulianDay(era, year, month, 1) + 1;\n\n return new CalendarDate(era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return gregorianToJulianDay(date.era, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return daysInMonth[isLeapYear(date.year) ? 'leapyear' : 'standard'][date.month - 1];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getMonthsInYear(date: AnyCalendarDate): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 366 : 365;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getYearsInEra(date: AnyCalendarDate): number {\n return 9999;\n }\n\n getEras(): string[] {\n return ['BC', 'AD'];\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BC';\n }\n\n balanceDate(date: Mutable): void {\n if (date.year <= 0) {\n date.era = date.era === 'BC' ? 'AD' : 'BC';\n date.year = 1 - date.year;\n }\n }\n}\n"],"names":[],"version":3,"file":"GregorianCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..ecb689c11b8de6acdb4e3b1e6908c4105dd4472d --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.cjs @@ -0,0 +1,155 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $09f945753a699862$exports = require("../utils.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "HebrewCalendar", function () { return $1aa25867248bd474$export$ca405048b8fb5af; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $1aa25867248bd474$var$HEBREW_EPOCH = 347997; +// Hebrew date calculations are performed in terms of days, hours, and +// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds. +const $1aa25867248bd474$var$HOUR_PARTS = 1080; +const $1aa25867248bd474$var$DAY_PARTS = 24 * $1aa25867248bd474$var$HOUR_PARTS; +// An approximate value for the length of a lunar month. +// It is used to calculate the approximate year and month of a given +// absolute date. +const $1aa25867248bd474$var$MONTH_DAYS = 29; +const $1aa25867248bd474$var$MONTH_FRACT = 12 * $1aa25867248bd474$var$HOUR_PARTS + 793; +const $1aa25867248bd474$var$MONTH_PARTS = $1aa25867248bd474$var$MONTH_DAYS * $1aa25867248bd474$var$DAY_PARTS + $1aa25867248bd474$var$MONTH_FRACT; +function $1aa25867248bd474$var$isLeapYear(year) { + return (0, $09f945753a699862$exports.mod)(year * 7 + 1, 19) < 7; +} +// Test for delay of start of new year and to avoid +// Sunday, Wednesday, and Friday as start of the new year. +function $1aa25867248bd474$var$hebrewDelay1(year) { + let months = Math.floor((235 * year - 234) / 19); + let parts = 12084 + 13753 * months; + let day = months * 29 + Math.floor(parts / 25920); + if ((0, $09f945753a699862$exports.mod)(3 * (day + 1), 7) < 3) day += 1; + return day; +} +// Check for delay in start of new year due to length of adjacent years +function $1aa25867248bd474$var$hebrewDelay2(year) { + let last = $1aa25867248bd474$var$hebrewDelay1(year - 1); + let present = $1aa25867248bd474$var$hebrewDelay1(year); + let next = $1aa25867248bd474$var$hebrewDelay1(year + 1); + if (next - present === 356) return 2; + if (present - last === 382) return 1; + return 0; +} +function $1aa25867248bd474$var$startOfYear(year) { + return $1aa25867248bd474$var$hebrewDelay1(year) + $1aa25867248bd474$var$hebrewDelay2(year); +} +function $1aa25867248bd474$var$getDaysInYear(year) { + return $1aa25867248bd474$var$startOfYear(year + 1) - $1aa25867248bd474$var$startOfYear(year); +} +function $1aa25867248bd474$var$getYearType(year) { + let yearLength = $1aa25867248bd474$var$getDaysInYear(year); + if (yearLength > 380) yearLength -= 30; // Subtract length of leap month. + switch(yearLength){ + case 353: + return 0; // deficient + case 354: + return 1; // normal + case 355: + return 2; // complete + } +} +function $1aa25867248bd474$var$getDaysInMonth(year, month) { + // Normalize month numbers from 1 - 13, even on non-leap years + if (month >= 6 && !$1aa25867248bd474$var$isLeapYear(year)) month++; + // First of all, dispose of fixed-length 29 day months + if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) return 29; + let yearType = $1aa25867248bd474$var$getYearType(year); + // If it's Heshvan, days depend on length of year + if (month === 2) return yearType === 2 ? 30 : 29; + // Similarly, Kislev varies with the length of year + if (month === 3) return yearType === 0 ? 29 : 30; + // Adar I only exists in leap years + if (month === 6) return $1aa25867248bd474$var$isLeapYear(year) ? 30 : 0; + return 30; +} +class $1aa25867248bd474$export$ca405048b8fb5af { + fromJulianDay(jd) { + let d = jd - $1aa25867248bd474$var$HEBREW_EPOCH; + let m = d * $1aa25867248bd474$var$DAY_PARTS / $1aa25867248bd474$var$MONTH_PARTS; // Months (approx) + let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx) + let ys = $1aa25867248bd474$var$startOfYear(year); // 1st day of year + let dayOfYear = Math.floor(d - ys); + // Because of the postponement rules, it's possible to guess wrong. Fix it. + while(dayOfYear < 1){ + year--; + ys = $1aa25867248bd474$var$startOfYear(year); + dayOfYear = Math.floor(d - ys); + } + // Now figure out which month we're in, and the date within that month + let month = 1; + let monthStart = 0; + while(monthStart < dayOfYear){ + monthStart += $1aa25867248bd474$var$getDaysInMonth(year, month); + month++; + } + month--; + monthStart -= $1aa25867248bd474$var$getDaysInMonth(year, month); + let day = dayOfYear - monthStart; + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, year, month, day); + } + toJulianDay(date) { + let jd = $1aa25867248bd474$var$startOfYear(date.year); + for(let month = 1; month < date.month; month++)jd += $1aa25867248bd474$var$getDaysInMonth(date.year, month); + return jd + date.day + $1aa25867248bd474$var$HEBREW_EPOCH; + } + getDaysInMonth(date) { + return $1aa25867248bd474$var$getDaysInMonth(date.year, date.month); + } + getMonthsInYear(date) { + return $1aa25867248bd474$var$isLeapYear(date.year) ? 13 : 12; + } + getDaysInYear(date) { + return $1aa25867248bd474$var$getDaysInYear(date.year); + } + getMaximumMonthsInYear() { + return 13; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra() { + // 6239 gregorian + return 9999; + } + getEras() { + return [ + 'AM' + ]; + } + balanceYearMonth(date, previousDate) { + // Keep date in the same month when switching between leap years and non leap years + if (previousDate.year !== date.year) { + if ($1aa25867248bd474$var$isLeapYear(previousDate.year) && !$1aa25867248bd474$var$isLeapYear(date.year) && previousDate.month > 6) date.month--; + else if (!$1aa25867248bd474$var$isLeapYear(previousDate.year) && $1aa25867248bd474$var$isLeapYear(date.year) && previousDate.month > 6) date.month++; + } + } + constructor(){ + this.identifier = 'hebrew'; + } +} + + +//# sourceMappingURL=HebrewCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..6bd32224a716e0970e89ecce517fe57a38ad30b5 --- /dev/null +++ b/node_modules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kCAAY,KAAK,IAAI;QAC9B,IAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,KAAK,EAAE,QACtC,MAAM,qCAAe,KAAK,IAAI,EAAE;QAGlC,OAAO,KAAK,KAAK,GAAG,GAAG;IACzB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,qCAAe,KAAK,IAAI,EAAE,KAAK,KAAK;IAC7C;IAEA,gBAAgB,IAAqB,EAAU;QAC7C,OAAO,iCAAW,KAAK,IAAI,IAAI,KAAK;IACtC;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,oCAAc,KAAK,IAAI;IAChC;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,gBAAwB;QACtB,iBAAiB;QACjB,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,iBAAiB,IAA8B,EAAE,YAA6B,EAAQ;QACpF,mFAAmF;QACnF,IAAI,aAAa,IAAI,KAAK,KAAK,IAAI,EAAE;YACnC,IAAI,iCAAW,aAAa,IAAI,KAAK,CAAC,iCAAW,KAAK,IAAI,KAAK,aAAa,KAAK,GAAG,GAClF,KAAK,KAAK;iBACL,IACL,CAAC,iCAAW,aAAa,IAAI,KAC7B,iCAAW,KAAK,IAAI,KACpB,aAAa,KAAK,GAAG,GAErB,KAAK,KAAK;QAEd;IACF;;aAlFA,aAAiC;;AAmFnC","sources":["packages/@internationalized/date/src/calendars/HebrewCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst HEBREW_EPOCH = 347997;\n\n// Hebrew date calculations are performed in terms of days, hours, and\n// \"parts\" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.\nconst HOUR_PARTS = 1080;\nconst DAY_PARTS = 24 * HOUR_PARTS;\n\n// An approximate value for the length of a lunar month.\n// It is used to calculate the approximate year and month of a given\n// absolute date.\nconst MONTH_DAYS = 29;\nconst MONTH_FRACT = 12 * HOUR_PARTS + 793;\nconst MONTH_PARTS = MONTH_DAYS * DAY_PARTS + MONTH_FRACT;\n\nfunction isLeapYear(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n// Test for delay of start of new year and to avoid\n// Sunday, Wednesday, and Friday as start of the new year.\nfunction hebrewDelay1(year: number) {\n let months = Math.floor((235 * year - 234) / 19);\n let parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day += 1;\n }\n\n return day;\n}\n\n// Check for delay in start of new year due to length of adjacent years\nfunction hebrewDelay2(year: number) {\n let last = hebrewDelay1(year - 1);\n let present = hebrewDelay1(year);\n let next = hebrewDelay1(year + 1);\n\n if (next - present === 356) {\n return 2;\n }\n\n if (present - last === 382) {\n return 1;\n }\n\n return 0;\n}\n\nfunction startOfYear(year: number) {\n return hebrewDelay1(year) + hebrewDelay2(year);\n}\n\nfunction getDaysInYear(year: number) {\n return startOfYear(year + 1) - startOfYear(year);\n}\n\nfunction getYearType(year: number) {\n let yearLength = getDaysInYear(year);\n\n if (yearLength > 380) {\n yearLength -= 30; // Subtract length of leap month.\n }\n\n switch (yearLength) {\n case 353:\n return 0; // deficient\n case 354:\n return 1; // normal\n case 355:\n return 2; // complete\n }\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n // Normalize month numbers from 1 - 13, even on non-leap years\n if (month >= 6 && !isLeapYear(year)) {\n month++;\n }\n\n // First of all, dispose of fixed-length 29 day months\n if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {\n return 29;\n }\n\n let yearType = getYearType(year);\n\n // If it's Heshvan, days depend on length of year\n if (month === 2) {\n return yearType === 2 ? 30 : 29;\n }\n\n // Similarly, Kislev varies with the length of year\n if (month === 3) {\n return yearType === 0 ? 29 : 30;\n }\n\n // Adar I only exists in leap years\n if (month === 6) {\n return isLeapYear(year) ? 30 : 0;\n }\n\n return 30;\n}\n\n/**\n * The Hebrew calendar is used in Israel and around the world by the Jewish faith.\n * Years include either 12 or 13 months depending on whether it is a leap year.\n * In leap years, an extra month is inserted at month 6.\n */\nexport class HebrewCalendar implements Calendar {\n identifier: CalendarIdentifier = 'hebrew';\n\n fromJulianDay(jd: number): CalendarDate {\n let d = jd - HEBREW_EPOCH;\n let m = (d * DAY_PARTS) / MONTH_PARTS; // Months (approx)\n let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)\n let ys = startOfYear(year); // 1st day of year\n let dayOfYear = Math.floor(d - ys);\n\n // Because of the postponement rules, it's possible to guess wrong. Fix it.\n while (dayOfYear < 1) {\n year--;\n ys = startOfYear(year);\n dayOfYear = Math.floor(d - ys);\n }\n\n // Now figure out which month we're in, and the date within that month\n let month = 1;\n let monthStart = 0;\n while (monthStart < dayOfYear) {\n monthStart += getDaysInMonth(year, month);\n month++;\n }\n\n month--;\n monthStart -= getDaysInMonth(year, month);\n\n let day = dayOfYear - monthStart;\n return new CalendarDate(this, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = startOfYear(date.year);\n for (let month = 1; month < date.month; month++) {\n jd += getDaysInMonth(date.year, month);\n }\n\n return jd + date.day + HEBREW_EPOCH;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 13 : 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return getDaysInYear(date.year);\n }\n\n getMaximumMonthsInYear(): number {\n return 13;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(): number {\n // 6239 gregorian\n return 9999;\n }\n\n getEras(): string[] {\n return ['AM'];\n }\n\n balanceYearMonth(date: Mutable, previousDate: AnyCalendarDate): void {\n // Keep date in the same month when switching between leap years and non leap years\n if (previousDate.year !== date.year) {\n if (isLeapYear(previousDate.year) && !isLeapYear(date.year) && previousDate.month > 6) {\n date.month--;\n } else if (\n !isLeapYear(previousDate.year) &&\n isLeapYear(date.year) &&\n previousDate.month > 6\n ) {\n date.month++;\n }\n }\n }\n}\n"],"names":[],"version":3,"file":"HebrewCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..5357e674f77e9d9d49a5bb08677ba3659731498d --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.js @@ -0,0 +1,150 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {mod as $1797f75f9a4d3bd4$export$842a2cf37af977e1} from "../utils.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $f6eb69e87cd1adc1$var$HEBREW_EPOCH = 347997; +// Hebrew date calculations are performed in terms of days, hours, and +// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds. +const $f6eb69e87cd1adc1$var$HOUR_PARTS = 1080; +const $f6eb69e87cd1adc1$var$DAY_PARTS = 24 * $f6eb69e87cd1adc1$var$HOUR_PARTS; +// An approximate value for the length of a lunar month. +// It is used to calculate the approximate year and month of a given +// absolute date. +const $f6eb69e87cd1adc1$var$MONTH_DAYS = 29; +const $f6eb69e87cd1adc1$var$MONTH_FRACT = 12 * $f6eb69e87cd1adc1$var$HOUR_PARTS + 793; +const $f6eb69e87cd1adc1$var$MONTH_PARTS = $f6eb69e87cd1adc1$var$MONTH_DAYS * $f6eb69e87cd1adc1$var$DAY_PARTS + $f6eb69e87cd1adc1$var$MONTH_FRACT; +function $f6eb69e87cd1adc1$var$isLeapYear(year) { + return (0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(year * 7 + 1, 19) < 7; +} +// Test for delay of start of new year and to avoid +// Sunday, Wednesday, and Friday as start of the new year. +function $f6eb69e87cd1adc1$var$hebrewDelay1(year) { + let months = Math.floor((235 * year - 234) / 19); + let parts = 12084 + 13753 * months; + let day = months * 29 + Math.floor(parts / 25920); + if ((0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(3 * (day + 1), 7) < 3) day += 1; + return day; +} +// Check for delay in start of new year due to length of adjacent years +function $f6eb69e87cd1adc1$var$hebrewDelay2(year) { + let last = $f6eb69e87cd1adc1$var$hebrewDelay1(year - 1); + let present = $f6eb69e87cd1adc1$var$hebrewDelay1(year); + let next = $f6eb69e87cd1adc1$var$hebrewDelay1(year + 1); + if (next - present === 356) return 2; + if (present - last === 382) return 1; + return 0; +} +function $f6eb69e87cd1adc1$var$startOfYear(year) { + return $f6eb69e87cd1adc1$var$hebrewDelay1(year) + $f6eb69e87cd1adc1$var$hebrewDelay2(year); +} +function $f6eb69e87cd1adc1$var$getDaysInYear(year) { + return $f6eb69e87cd1adc1$var$startOfYear(year + 1) - $f6eb69e87cd1adc1$var$startOfYear(year); +} +function $f6eb69e87cd1adc1$var$getYearType(year) { + let yearLength = $f6eb69e87cd1adc1$var$getDaysInYear(year); + if (yearLength > 380) yearLength -= 30; // Subtract length of leap month. + switch(yearLength){ + case 353: + return 0; // deficient + case 354: + return 1; // normal + case 355: + return 2; // complete + } +} +function $f6eb69e87cd1adc1$var$getDaysInMonth(year, month) { + // Normalize month numbers from 1 - 13, even on non-leap years + if (month >= 6 && !$f6eb69e87cd1adc1$var$isLeapYear(year)) month++; + // First of all, dispose of fixed-length 29 day months + if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) return 29; + let yearType = $f6eb69e87cd1adc1$var$getYearType(year); + // If it's Heshvan, days depend on length of year + if (month === 2) return yearType === 2 ? 30 : 29; + // Similarly, Kislev varies with the length of year + if (month === 3) return yearType === 0 ? 29 : 30; + // Adar I only exists in leap years + if (month === 6) return $f6eb69e87cd1adc1$var$isLeapYear(year) ? 30 : 0; + return 30; +} +class $f6eb69e87cd1adc1$export$ca405048b8fb5af { + fromJulianDay(jd) { + let d = jd - $f6eb69e87cd1adc1$var$HEBREW_EPOCH; + let m = d * $f6eb69e87cd1adc1$var$DAY_PARTS / $f6eb69e87cd1adc1$var$MONTH_PARTS; // Months (approx) + let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx) + let ys = $f6eb69e87cd1adc1$var$startOfYear(year); // 1st day of year + let dayOfYear = Math.floor(d - ys); + // Because of the postponement rules, it's possible to guess wrong. Fix it. + while(dayOfYear < 1){ + year--; + ys = $f6eb69e87cd1adc1$var$startOfYear(year); + dayOfYear = Math.floor(d - ys); + } + // Now figure out which month we're in, and the date within that month + let month = 1; + let monthStart = 0; + while(monthStart < dayOfYear){ + monthStart += $f6eb69e87cd1adc1$var$getDaysInMonth(year, month); + month++; + } + month--; + monthStart -= $f6eb69e87cd1adc1$var$getDaysInMonth(year, month); + let day = dayOfYear - monthStart; + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, year, month, day); + } + toJulianDay(date) { + let jd = $f6eb69e87cd1adc1$var$startOfYear(date.year); + for(let month = 1; month < date.month; month++)jd += $f6eb69e87cd1adc1$var$getDaysInMonth(date.year, month); + return jd + date.day + $f6eb69e87cd1adc1$var$HEBREW_EPOCH; + } + getDaysInMonth(date) { + return $f6eb69e87cd1adc1$var$getDaysInMonth(date.year, date.month); + } + getMonthsInYear(date) { + return $f6eb69e87cd1adc1$var$isLeapYear(date.year) ? 13 : 12; + } + getDaysInYear(date) { + return $f6eb69e87cd1adc1$var$getDaysInYear(date.year); + } + getMaximumMonthsInYear() { + return 13; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra() { + // 6239 gregorian + return 9999; + } + getEras() { + return [ + 'AM' + ]; + } + balanceYearMonth(date, previousDate) { + // Keep date in the same month when switching between leap years and non leap years + if (previousDate.year !== date.year) { + if ($f6eb69e87cd1adc1$var$isLeapYear(previousDate.year) && !$f6eb69e87cd1adc1$var$isLeapYear(date.year) && previousDate.month > 6) date.month--; + else if (!$f6eb69e87cd1adc1$var$isLeapYear(previousDate.year) && $f6eb69e87cd1adc1$var$isLeapYear(date.year) && previousDate.month > 6) date.month++; + } + } + constructor(){ + this.identifier = 'hebrew'; + } +} + + +export {$f6eb69e87cd1adc1$export$ca405048b8fb5af as HebrewCalendar}; +//# sourceMappingURL=HebrewCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7ef6d82085646c118651900584c95beda2cb52b7 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,qCAAe;AAErB,sEAAsE;AACtE,uEAAuE;AACvE,MAAM,mCAAa;AACnB,MAAM,kCAAY,KAAK;AAEvB,wDAAwD;AAC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;IAEA,gBAAgB,IAAqB,EAAU;QAC7C,OAAO,iCAAW,KAAK,IAAI,IAAI,KAAK;IACtC;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,oCAAc,KAAK,IAAI;IAChC;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,gBAAwB;QACtB,iBAAiB;QACjB,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,iBAAiB,IAA8B,EAAE,YAA6B,EAAQ;QACpF,mFAAmF;QACnF,IAAI,aAAa,IAAI,KAAK,KAAK,IAAI,EAAE;YACnC,IAAI,iCAAW,aAAa,IAAI,KAAK,CAAC,iCAAW,KAAK,IAAI,KAAK,aAAa,KAAK,GAAG,GAClF,KAAK,KAAK;iBACL,IACL,CAAC,iCAAW,aAAa,IAAI,KAC7B,iCAAW,KAAK,IAAI,KACpB,aAAa,KAAK,GAAG,GAErB,KAAK,KAAK;QAEd;IACF;;aAlFA,aAAiC;;AAmFnC","sources":["packages/@internationalized/date/src/calendars/HebrewCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst HEBREW_EPOCH = 347997;\n\n// Hebrew date calculations are performed in terms of days, hours, and\n// \"parts\" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.\nconst HOUR_PARTS = 1080;\nconst DAY_PARTS = 24 * HOUR_PARTS;\n\n// An approximate value for the length of a lunar month.\n// It is used to calculate the approximate year and month of a given\n// absolute date.\nconst MONTH_DAYS = 29;\nconst MONTH_FRACT = 12 * HOUR_PARTS + 793;\nconst MONTH_PARTS = MONTH_DAYS * DAY_PARTS + MONTH_FRACT;\n\nfunction isLeapYear(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n// Test for delay of start of new year and to avoid\n// Sunday, Wednesday, and Friday as start of the new year.\nfunction hebrewDelay1(year: number) {\n let months = Math.floor((235 * year - 234) / 19);\n let parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day += 1;\n }\n\n return day;\n}\n\n// Check for delay in start of new year due to length of adjacent years\nfunction hebrewDelay2(year: number) {\n let last = hebrewDelay1(year - 1);\n let present = hebrewDelay1(year);\n let next = hebrewDelay1(year + 1);\n\n if (next - present === 356) {\n return 2;\n }\n\n if (present - last === 382) {\n return 1;\n }\n\n return 0;\n}\n\nfunction startOfYear(year: number) {\n return hebrewDelay1(year) + hebrewDelay2(year);\n}\n\nfunction getDaysInYear(year: number) {\n return startOfYear(year + 1) - startOfYear(year);\n}\n\nfunction getYearType(year: number) {\n let yearLength = getDaysInYear(year);\n\n if (yearLength > 380) {\n yearLength -= 30; // Subtract length of leap month.\n }\n\n switch (yearLength) {\n case 353:\n return 0; // deficient\n case 354:\n return 1; // normal\n case 355:\n return 2; // complete\n }\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n // Normalize month numbers from 1 - 13, even on non-leap years\n if (month >= 6 && !isLeapYear(year)) {\n month++;\n }\n\n // First of all, dispose of fixed-length 29 day months\n if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {\n return 29;\n }\n\n let yearType = getYearType(year);\n\n // If it's Heshvan, days depend on length of year\n if (month === 2) {\n return yearType === 2 ? 30 : 29;\n }\n\n // Similarly, Kislev varies with the length of year\n if (month === 3) {\n return yearType === 0 ? 29 : 30;\n }\n\n // Adar I only exists in leap years\n if (month === 6) {\n return isLeapYear(year) ? 30 : 0;\n }\n\n return 30;\n}\n\n/**\n * The Hebrew calendar is used in Israel and around the world by the Jewish faith.\n * Years include either 12 or 13 months depending on whether it is a leap year.\n * In leap years, an extra month is inserted at month 6.\n */\nexport class HebrewCalendar implements Calendar {\n identifier: CalendarIdentifier = 'hebrew';\n\n fromJulianDay(jd: number): CalendarDate {\n let d = jd - HEBREW_EPOCH;\n let m = (d * DAY_PARTS) / MONTH_PARTS; // Months (approx)\n let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)\n let ys = startOfYear(year); // 1st day of year\n let dayOfYear = Math.floor(d - ys);\n\n // Because of the postponement rules, it's possible to guess wrong. Fix it.\n while (dayOfYear < 1) {\n year--;\n ys = startOfYear(year);\n dayOfYear = Math.floor(d - ys);\n }\n\n // Now figure out which month we're in, and the date within that month\n let month = 1;\n let monthStart = 0;\n while (monthStart < dayOfYear) {\n monthStart += getDaysInMonth(year, month);\n month++;\n }\n\n month--;\n monthStart -= getDaysInMonth(year, month);\n\n let day = dayOfYear - monthStart;\n return new CalendarDate(this, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = startOfYear(date.year);\n for (let month = 1; month < date.month; month++) {\n jd += getDaysInMonth(date.year, month);\n }\n\n return jd + date.day + HEBREW_EPOCH;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 13 : 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return getDaysInYear(date.year);\n }\n\n getMaximumMonthsInYear(): number {\n return 13;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(): number {\n // 6239 gregorian\n return 9999;\n }\n\n getEras(): string[] {\n return ['AM'];\n }\n\n balanceYearMonth(date: Mutable, previousDate: AnyCalendarDate): void {\n // Keep date in the same month when switching between leap years and non leap years\n if (previousDate.year !== date.year) {\n if (isLeapYear(previousDate.year) && !isLeapYear(date.year) && previousDate.month > 6) {\n date.month--;\n } else if (\n !isLeapYear(previousDate.year) &&\n isLeapYear(date.year) &&\n previousDate.month > 6\n ) {\n date.month++;\n }\n }\n }\n}\n"],"names":[],"version":3,"file":"HebrewCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8ac4adacff89ac95f54a8d77000644299e99502c --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.mjs @@ -0,0 +1,150 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {mod as $09ec6a572d60460f$export$842a2cf37af977e1} from "../utils.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $f39495b96f9dbac6$var$HEBREW_EPOCH = 347997; +// Hebrew date calculations are performed in terms of days, hours, and +// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds. +const $f39495b96f9dbac6$var$HOUR_PARTS = 1080; +const $f39495b96f9dbac6$var$DAY_PARTS = 24 * $f39495b96f9dbac6$var$HOUR_PARTS; +// An approximate value for the length of a lunar month. +// It is used to calculate the approximate year and month of a given +// absolute date. +const $f39495b96f9dbac6$var$MONTH_DAYS = 29; +const $f39495b96f9dbac6$var$MONTH_FRACT = 12 * $f39495b96f9dbac6$var$HOUR_PARTS + 793; +const $f39495b96f9dbac6$var$MONTH_PARTS = $f39495b96f9dbac6$var$MONTH_DAYS * $f39495b96f9dbac6$var$DAY_PARTS + $f39495b96f9dbac6$var$MONTH_FRACT; +function $f39495b96f9dbac6$var$isLeapYear(year) { + return (0, $09ec6a572d60460f$export$842a2cf37af977e1)(year * 7 + 1, 19) < 7; +} +// Test for delay of start of new year and to avoid +// Sunday, Wednesday, and Friday as start of the new year. +function $f39495b96f9dbac6$var$hebrewDelay1(year) { + let months = Math.floor((235 * year - 234) / 19); + let parts = 12084 + 13753 * months; + let day = months * 29 + Math.floor(parts / 25920); + if ((0, $09ec6a572d60460f$export$842a2cf37af977e1)(3 * (day + 1), 7) < 3) day += 1; + return day; +} +// Check for delay in start of new year due to length of adjacent years +function $f39495b96f9dbac6$var$hebrewDelay2(year) { + let last = $f39495b96f9dbac6$var$hebrewDelay1(year - 1); + let present = $f39495b96f9dbac6$var$hebrewDelay1(year); + let next = $f39495b96f9dbac6$var$hebrewDelay1(year + 1); + if (next - present === 356) return 2; + if (present - last === 382) return 1; + return 0; +} +function $f39495b96f9dbac6$var$startOfYear(year) { + return $f39495b96f9dbac6$var$hebrewDelay1(year) + $f39495b96f9dbac6$var$hebrewDelay2(year); +} +function $f39495b96f9dbac6$var$getDaysInYear(year) { + return $f39495b96f9dbac6$var$startOfYear(year + 1) - $f39495b96f9dbac6$var$startOfYear(year); +} +function $f39495b96f9dbac6$var$getYearType(year) { + let yearLength = $f39495b96f9dbac6$var$getDaysInYear(year); + if (yearLength > 380) yearLength -= 30; // Subtract length of leap month. + switch(yearLength){ + case 353: + return 0; // deficient + case 354: + return 1; // normal + case 355: + return 2; // complete + } +} +function $f39495b96f9dbac6$var$getDaysInMonth(year, month) { + // Normalize month numbers from 1 - 13, even on non-leap years + if (month >= 6 && !$f39495b96f9dbac6$var$isLeapYear(year)) month++; + // First of all, dispose of fixed-length 29 day months + if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) return 29; + let yearType = $f39495b96f9dbac6$var$getYearType(year); + // If it's Heshvan, days depend on length of year + if (month === 2) return yearType === 2 ? 30 : 29; + // Similarly, Kislev varies with the length of year + if (month === 3) return yearType === 0 ? 29 : 30; + // Adar I only exists in leap years + if (month === 6) return $f39495b96f9dbac6$var$isLeapYear(year) ? 30 : 0; + return 30; +} +class $f39495b96f9dbac6$export$ca405048b8fb5af { + fromJulianDay(jd) { + let d = jd - $f39495b96f9dbac6$var$HEBREW_EPOCH; + let m = d * $f39495b96f9dbac6$var$DAY_PARTS / $f39495b96f9dbac6$var$MONTH_PARTS; // Months (approx) + let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx) + let ys = $f39495b96f9dbac6$var$startOfYear(year); // 1st day of year + let dayOfYear = Math.floor(d - ys); + // Because of the postponement rules, it's possible to guess wrong. Fix it. + while(dayOfYear < 1){ + year--; + ys = $f39495b96f9dbac6$var$startOfYear(year); + dayOfYear = Math.floor(d - ys); + } + // Now figure out which month we're in, and the date within that month + let month = 1; + let monthStart = 0; + while(monthStart < dayOfYear){ + monthStart += $f39495b96f9dbac6$var$getDaysInMonth(year, month); + month++; + } + month--; + monthStart -= $f39495b96f9dbac6$var$getDaysInMonth(year, month); + let day = dayOfYear - monthStart; + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, year, month, day); + } + toJulianDay(date) { + let jd = $f39495b96f9dbac6$var$startOfYear(date.year); + for(let month = 1; month < date.month; month++)jd += $f39495b96f9dbac6$var$getDaysInMonth(date.year, month); + return jd + date.day + $f39495b96f9dbac6$var$HEBREW_EPOCH; + } + getDaysInMonth(date) { + return $f39495b96f9dbac6$var$getDaysInMonth(date.year, date.month); + } + getMonthsInYear(date) { + return $f39495b96f9dbac6$var$isLeapYear(date.year) ? 13 : 12; + } + getDaysInYear(date) { + return $f39495b96f9dbac6$var$getDaysInYear(date.year); + } + getMaximumMonthsInYear() { + return 13; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra() { + // 6239 gregorian + return 9999; + } + getEras() { + return [ + 'AM' + ]; + } + balanceYearMonth(date, previousDate) { + // Keep date in the same month when switching between leap years and non leap years + if (previousDate.year !== date.year) { + if ($f39495b96f9dbac6$var$isLeapYear(previousDate.year) && !$f39495b96f9dbac6$var$isLeapYear(date.year) && previousDate.month > 6) date.month--; + else if (!$f39495b96f9dbac6$var$isLeapYear(previousDate.year) && $f39495b96f9dbac6$var$isLeapYear(date.year) && previousDate.month > 6) date.month++; + } + } + constructor(){ + this.identifier = 'hebrew'; + } +} + + +export {$f39495b96f9dbac6$export$ca405048b8fb5af as HebrewCalendar}; +//# sourceMappingURL=HebrewCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..1deb5600bcc9b5a6126b0b3a7149be0e7b524db3 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/HebrewCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,qCAAe;AAErB,sEAAsE;AACtE,uEAAuE;AACvE,MAAM,mCAAa;AACnB,MAAM,kCAAY,KAAK;AAEvB,wDAAwD;AACxD,oEAAoE;AACpE,iBAAiB;AACjB,MAAM,mCAAa;AACnB,MAAM,oCAAc,KAAK,mCAAa;AACtC,MAAM,oCAAc,mCAAa,kCAAY;AAE7C,SAAS,iCAAW,IAAY;IAC9B,OAAO,CAAA,GAAA,yCAAE,EAAE,OAAO,IAAI,GAAG,MAAM;AACjC;AAEA,mDAAmD;AACnD,0DAA0D;AAC1D,SAAS,mCAAa,IAAY;IAChC,IAAI,SAAS,KAAK,KAAK,CAAC,AAAC,CAAA,MAAM,OAAO,GAAE,IAAK;IAC7C,I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,mFAAmF;QACnF,IAAI,aAAa,IAAI,KAAK,KAAK,IAAI,EAAE;YACnC,IAAI,iCAAW,aAAa,IAAI,KAAK,CAAC,iCAAW,KAAK,IAAI,KAAK,aAAa,KAAK,GAAG,GAClF,KAAK,KAAK;iBACL,IACL,CAAC,iCAAW,aAAa,IAAI,KAC7B,iCAAW,KAAK,IAAI,KACpB,aAAa,KAAK,GAAG,GAErB,KAAK,KAAK;QAEd;IACF;;aAlFA,aAAiC;;AAmFnC","sources":["packages/@internationalized/date/src/calendars/HebrewCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst HEBREW_EPOCH = 347997;\n\n// Hebrew date calculations are performed in terms of days, hours, and\n// \"parts\" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.\nconst HOUR_PARTS = 1080;\nconst DAY_PARTS = 24 * HOUR_PARTS;\n\n// An approximate value for the length of a lunar month.\n// It is used to calculate the approximate year and month of a given\n// absolute date.\nconst MONTH_DAYS = 29;\nconst MONTH_FRACT = 12 * HOUR_PARTS + 793;\nconst MONTH_PARTS = MONTH_DAYS * DAY_PARTS + MONTH_FRACT;\n\nfunction isLeapYear(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n// Test for delay of start of new year and to avoid\n// Sunday, Wednesday, and Friday as start of the new year.\nfunction hebrewDelay1(year: number) {\n let months = Math.floor((235 * year - 234) / 19);\n let parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day += 1;\n }\n\n return day;\n}\n\n// Check for delay in start of new year due to length of adjacent years\nfunction hebrewDelay2(year: number) {\n let last = hebrewDelay1(year - 1);\n let present = hebrewDelay1(year);\n let next = hebrewDelay1(year + 1);\n\n if (next - present === 356) {\n return 2;\n }\n\n if (present - last === 382) {\n return 1;\n }\n\n return 0;\n}\n\nfunction startOfYear(year: number) {\n return hebrewDelay1(year) + hebrewDelay2(year);\n}\n\nfunction getDaysInYear(year: number) {\n return startOfYear(year + 1) - startOfYear(year);\n}\n\nfunction getYearType(year: number) {\n let yearLength = getDaysInYear(year);\n\n if (yearLength > 380) {\n yearLength -= 30; // Subtract length of leap month.\n }\n\n switch (yearLength) {\n case 353:\n return 0; // deficient\n case 354:\n return 1; // normal\n case 355:\n return 2; // complete\n }\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n // Normalize month numbers from 1 - 13, even on non-leap years\n if (month >= 6 && !isLeapYear(year)) {\n month++;\n }\n\n // First of all, dispose of fixed-length 29 day months\n if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {\n return 29;\n }\n\n let yearType = getYearType(year);\n\n // If it's Heshvan, days depend on length of year\n if (month === 2) {\n return yearType === 2 ? 30 : 29;\n }\n\n // Similarly, Kislev varies with the length of year\n if (month === 3) {\n return yearType === 0 ? 29 : 30;\n }\n\n // Adar I only exists in leap years\n if (month === 6) {\n return isLeapYear(year) ? 30 : 0;\n }\n\n return 30;\n}\n\n/**\n * The Hebrew calendar is used in Israel and around the world by the Jewish faith.\n * Years include either 12 or 13 months depending on whether it is a leap year.\n * In leap years, an extra month is inserted at month 6.\n */\nexport class HebrewCalendar implements Calendar {\n identifier: CalendarIdentifier = 'hebrew';\n\n fromJulianDay(jd: number): CalendarDate {\n let d = jd - HEBREW_EPOCH;\n let m = (d * DAY_PARTS) / MONTH_PARTS; // Months (approx)\n let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)\n let ys = startOfYear(year); // 1st day of year\n let dayOfYear = Math.floor(d - ys);\n\n // Because of the postponement rules, it's possible to guess wrong. Fix it.\n while (dayOfYear < 1) {\n year--;\n ys = startOfYear(year);\n dayOfYear = Math.floor(d - ys);\n }\n\n // Now figure out which month we're in, and the date within that month\n let month = 1;\n let monthStart = 0;\n while (monthStart < dayOfYear) {\n monthStart += getDaysInMonth(year, month);\n month++;\n }\n\n month--;\n monthStart -= getDaysInMonth(year, month);\n\n let day = dayOfYear - monthStart;\n return new CalendarDate(this, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = startOfYear(date.year);\n for (let month = 1; month < date.month; month++) {\n jd += getDaysInMonth(date.year, month);\n }\n\n return jd + date.day + HEBREW_EPOCH;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 13 : 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return getDaysInYear(date.year);\n }\n\n getMaximumMonthsInYear(): number {\n return 13;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(): number {\n // 6239 gregorian\n return 9999;\n }\n\n getEras(): string[] {\n return ['AM'];\n }\n\n balanceYearMonth(date: Mutable, previousDate: AnyCalendarDate): void {\n // Keep date in the same month when switching between leap years and non leap years\n if (previousDate.year !== date.year) {\n if (isLeapYear(previousDate.year) && !isLeapYear(date.year) && previousDate.month > 6) {\n date.month--;\n } else if (\n !isLeapYear(previousDate.year) &&\n isLeapYear(date.year) &&\n previousDate.month > 6\n ) {\n date.month++;\n }\n }\n }\n}\n"],"names":[],"version":3,"file":"HebrewCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..a5b98ecd2e01b341c58107e95f3de9ae269aeab6 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.cjs @@ -0,0 +1,106 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $05031860ba2f881f$exports = require("./GregorianCalendar.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "IndianCalendar", function () { return $9dc8610ad30fbfe5$export$39f31c639fa15726; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +// Starts in 78 AD, +const $9dc8610ad30fbfe5$var$INDIAN_ERA_START = 78; +// The Indian year starts 80 days later than the Gregorian year. +const $9dc8610ad30fbfe5$var$INDIAN_YEAR_START = 80; +class $9dc8610ad30fbfe5$export$39f31c639fa15726 extends (0, $05031860ba2f881f$exports.GregorianCalendar) { + fromJulianDay(jd) { + // Gregorian date for Julian day + let date = super.fromJulianDay(jd); + // Year in Saka era + let indianYear = date.year - $9dc8610ad30fbfe5$var$INDIAN_ERA_START; + // Day number in Gregorian year (starting from 0) + let yDay = jd - (0, $05031860ba2f881f$exports.gregorianToJulianDay)(date.era, date.year, 1, 1); + let leapMonth; + if (yDay < $9dc8610ad30fbfe5$var$INDIAN_YEAR_START) { + // Day is at the end of the preceding Saka year + indianYear--; + // Days in leapMonth this year, previous Gregorian year + leapMonth = (0, $05031860ba2f881f$exports.isLeapYear)(date.year - 1) ? 31 : 30; + yDay += leapMonth + 155 + 90 + 10; + } else { + // Days in leapMonth this year + leapMonth = (0, $05031860ba2f881f$exports.isLeapYear)(date.year) ? 31 : 30; + yDay -= $9dc8610ad30fbfe5$var$INDIAN_YEAR_START; + } + let indianMonth; + let indianDay; + if (yDay < leapMonth) { + indianMonth = 1; + indianDay = yDay + 1; + } else { + let mDay = yDay - leapMonth; + if (mDay < 155) { + indianMonth = Math.floor(mDay / 31) + 2; + indianDay = mDay % 31 + 1; + } else { + mDay -= 155; + indianMonth = Math.floor(mDay / 30) + 7; + indianDay = mDay % 30 + 1; + } + } + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, indianYear, indianMonth, indianDay); + } + toJulianDay(date) { + let extendedYear = date.year + $9dc8610ad30fbfe5$var$INDIAN_ERA_START; + let [era, year] = (0, $05031860ba2f881f$exports.fromExtendedYear)(extendedYear); + let leapMonth; + let jd; + if ((0, $05031860ba2f881f$exports.isLeapYear)(year)) { + leapMonth = 31; + jd = (0, $05031860ba2f881f$exports.gregorianToJulianDay)(era, year, 3, 21); + } else { + leapMonth = 30; + jd = (0, $05031860ba2f881f$exports.gregorianToJulianDay)(era, year, 3, 22); + } + if (date.month === 1) return jd + date.day - 1; + jd += leapMonth + Math.min(date.month - 2, 5) * 31; + if (date.month >= 8) jd += (date.month - 7) * 30; + jd += date.day - 1; + return jd; + } + getDaysInMonth(date) { + if (date.month === 1 && (0, $05031860ba2f881f$exports.isLeapYear)(date.year + $9dc8610ad30fbfe5$var$INDIAN_ERA_START)) return 31; + if (date.month >= 2 && date.month <= 6) return 31; + return 30; + } + getYearsInEra() { + // 9999-12-31 gregorian is 9920-10-10 indian. + // Round down to 9919 for the last full year. + return 9919; + } + getEras() { + return [ + 'saka' + ]; + } + balanceDate() {} + constructor(...args){ + super(...args), this.identifier = 'indian'; + } +} + + +//# sourceMappingURL=IndianCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..1afac3155a52d402bcf47383da80a778a8945376 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAWhG,mBAAmB;AACnB,MAAM,yCAAmB;AAEzB,gEAAgE;AAChE,MAAM,0CAAoB;AAOnB,MAAM,kDAAuB,CAAA,GAAA,2CAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,gCAAgC;QAChC,IAAI,OAAO,KAAK,CAAC,cAAc;QAE/B,mBAAmB;QACnB,IAAI,aAAa,KAAK,IAAI,GAAG;QAE7B,iDAAiD;QACjD,IAAI,OAAO,KAAK,CAAA,GAAA,8CAAmB,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,GAAG;QAE7D,IAAI;QACJ,IAAI,OAAO,yCAAmB;YAC5B,gDAAgD;YAChD;YAEA,uDAAuD;YACvD,YAAY,CAAA,GAAA,oCAAS,EAAE,KAAK,IAAI,GAAG,KAAK,KAAK;YAC7C,QAAQ,YAAY,MAAS,KAAS;QACxC,OAAO;YACL,8BAA8B;YAC9B,YAAY,CAAA,GAAA,oCAAS,EAAE,KAAK,IAAI,IAAI,KAAK;YACzC,QAAQ;QACV;QAEA,IAAI;QACJ,IAAI;QACJ,IAAI,OAAO,WAAW;YACpB,cAAc;YACd,YAAY,OAAO;QACrB,OAAO;YACL,IAAI,OAAO,OAAO;YAClB,IAAI,OAAO,KAAQ;gBACjB,cAAc,KAAK,KAAK,CAAC,OAAO,MAAM;gBACtC,YAAY,AAAC,OAAO,KAAM;YAC5B,OAAO;gBACL,QAAQ;gBACR,cAAc,KAAK,KAAK,CAAC,OAAO,MAAM;gBACtC,YAAY,AAAC,OAAO,KAAM;YAC5B;QACF;QAEA,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,YAAY,aAAa;IACzD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,eAAe,KAAK,IAAI,GAAG;QAC/B,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,0CAAe,EAAE;QAEnC,IAAI;QACJ,IAAI;QACJ,IAAI,CAAA,GAAA,oCAAS,EAAE,OAAO;YACpB,YAAY;YACZ,KAAK,CAAA,GAAA,8CAAmB,EAAE,KAAK,MAAM,GAAG;QAC1C,OAAO;YACL,YAAY;YACZ,KAAK,CAAA,GAAA,8CAAmB,EAAE,KAAK,MAAM,GAAG;QAC1C;QAEA,IAAI,KAAK,KAAK,KAAK,GACjB,OAAO,KAAK,KAAK,GAAG,GAAG;QAGzB,MAAM,YAAY,KAAK,GAAG,CAAC,KAAK,KAAK,GAAG,GAAG,KAAK;QAEhD,IAAI,KAAK,KAAK,IAAI,GAChB,MAAM,AAAC,CAAA,KAAK,KAAK,GAAG,CAAA,IAAK;QAG3B,MAAM,KAAK,GAAG,GAAG;QACjB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,KAAK,KAAK,CAAA,GAAA,oCAAS,EAAE,KAAK,IAAI,GAAG,yCAC7C,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,GACnC,OAAO;QAGT,OAAO;IACT;IAEA,gBAAwB;QACtB,6CAA6C;QAC7C,6CAA6C;QAC7C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAO;IACjB;IAEA,cAAoB,CAAC;;QAjGhB,qBACL,aAAiC;;AAiGnC","sources":["packages/@internationalized/date/src/calendars/IndianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {\n fromExtendedYear,\n GregorianCalendar,\n gregorianToJulianDay,\n isLeapYear\n} from './GregorianCalendar';\n\n// Starts in 78 AD,\nconst INDIAN_ERA_START = 78;\n\n// The Indian year starts 80 days later than the Gregorian year.\nconst INDIAN_YEAR_START = 80;\n\n/**\n * The Indian National Calendar is similar to the Gregorian calendar, but with\n * years numbered since the Saka era in 78 AD (Gregorian). There are 12 months\n * in each year, with either 30 or 31 days. Only one era identifier is supported: 'saka'.\n */\nexport class IndianCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'indian';\n\n fromJulianDay(jd: number): CalendarDate {\n // Gregorian date for Julian day\n let date = super.fromJulianDay(jd);\n\n // Year in Saka era\n let indianYear = date.year - INDIAN_ERA_START;\n\n // Day number in Gregorian year (starting from 0)\n let yDay = jd - gregorianToJulianDay(date.era, date.year, 1, 1);\n\n let leapMonth: number;\n if (yDay < INDIAN_YEAR_START) {\n // Day is at the end of the preceding Saka year\n indianYear--;\n\n // Days in leapMonth this year, previous Gregorian year\n leapMonth = isLeapYear(date.year - 1) ? 31 : 30;\n yDay += leapMonth + 31 * 5 + 30 * 3 + 10;\n } else {\n // Days in leapMonth this year\n leapMonth = isLeapYear(date.year) ? 31 : 30;\n yDay -= INDIAN_YEAR_START;\n }\n\n let indianMonth: number;\n let indianDay: number;\n if (yDay < leapMonth) {\n indianMonth = 1;\n indianDay = yDay + 1;\n } else {\n let mDay = yDay - leapMonth;\n if (mDay < 31 * 5) {\n indianMonth = Math.floor(mDay / 31) + 2;\n indianDay = (mDay % 31) + 1;\n } else {\n mDay -= 31 * 5;\n indianMonth = Math.floor(mDay / 30) + 7;\n indianDay = (mDay % 30) + 1;\n }\n }\n\n return new CalendarDate(this, indianYear, indianMonth, indianDay);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let extendedYear = date.year + INDIAN_ERA_START;\n let [era, year] = fromExtendedYear(extendedYear);\n\n let leapMonth: number;\n let jd: number;\n if (isLeapYear(year)) {\n leapMonth = 31;\n jd = gregorianToJulianDay(era, year, 3, 21);\n } else {\n leapMonth = 30;\n jd = gregorianToJulianDay(era, year, 3, 22);\n }\n\n if (date.month === 1) {\n return jd + date.day - 1;\n }\n\n jd += leapMonth + Math.min(date.month - 2, 5) * 31;\n\n if (date.month >= 8) {\n jd += (date.month - 7) * 30;\n }\n\n jd += date.day - 1;\n return jd;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month === 1 && isLeapYear(date.year + INDIAN_ERA_START)) {\n return 31;\n }\n\n if (date.month >= 2 && date.month <= 6) {\n return 31;\n }\n\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999-12-31 gregorian is 9920-10-10 indian.\n // Round down to 9919 for the last full year.\n return 9919;\n }\n\n getEras(): string[] {\n return ['saka'];\n }\n\n balanceDate(): void {}\n}\n"],"names":[],"version":3,"file":"IndianCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..70324791890f2eb708d098b59fef44259bc0fc3b --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.js @@ -0,0 +1,101 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {fromExtendedYear as $f25df78da1f6b40f$export$4475b7e617eb123c, GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec, gregorianToJulianDay as $f25df78da1f6b40f$export$f297eb839006d339, isLeapYear as $f25df78da1f6b40f$export$553d7fa8e3805fc0} from "./GregorianCalendar.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +// Starts in 78 AD, +const $a07127433beb6bf1$var$INDIAN_ERA_START = 78; +// The Indian year starts 80 days later than the Gregorian year. +const $a07127433beb6bf1$var$INDIAN_YEAR_START = 80; +class $a07127433beb6bf1$export$39f31c639fa15726 extends (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + // Gregorian date for Julian day + let date = super.fromJulianDay(jd); + // Year in Saka era + let indianYear = date.year - $a07127433beb6bf1$var$INDIAN_ERA_START; + // Day number in Gregorian year (starting from 0) + let yDay = jd - (0, $f25df78da1f6b40f$export$f297eb839006d339)(date.era, date.year, 1, 1); + let leapMonth; + if (yDay < $a07127433beb6bf1$var$INDIAN_YEAR_START) { + // Day is at the end of the preceding Saka year + indianYear--; + // Days in leapMonth this year, previous Gregorian year + leapMonth = (0, $f25df78da1f6b40f$export$553d7fa8e3805fc0)(date.year - 1) ? 31 : 30; + yDay += leapMonth + 155 + 90 + 10; + } else { + // Days in leapMonth this year + leapMonth = (0, $f25df78da1f6b40f$export$553d7fa8e3805fc0)(date.year) ? 31 : 30; + yDay -= $a07127433beb6bf1$var$INDIAN_YEAR_START; + } + let indianMonth; + let indianDay; + if (yDay < leapMonth) { + indianMonth = 1; + indianDay = yDay + 1; + } else { + let mDay = yDay - leapMonth; + if (mDay < 155) { + indianMonth = Math.floor(mDay / 31) + 2; + indianDay = mDay % 31 + 1; + } else { + mDay -= 155; + indianMonth = Math.floor(mDay / 30) + 7; + indianDay = mDay % 30 + 1; + } + } + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, indianYear, indianMonth, indianDay); + } + toJulianDay(date) { + let extendedYear = date.year + $a07127433beb6bf1$var$INDIAN_ERA_START; + let [era, year] = (0, $f25df78da1f6b40f$export$4475b7e617eb123c)(extendedYear); + let leapMonth; + let jd; + if ((0, $f25df78da1f6b40f$export$553d7fa8e3805fc0)(year)) { + leapMonth = 31; + jd = (0, $f25df78da1f6b40f$export$f297eb839006d339)(era, year, 3, 21); + } else { + leapMonth = 30; + jd = (0, $f25df78da1f6b40f$export$f297eb839006d339)(era, year, 3, 22); + } + if (date.month === 1) return jd + date.day - 1; + jd += leapMonth + Math.min(date.month - 2, 5) * 31; + if (date.month >= 8) jd += (date.month - 7) * 30; + jd += date.day - 1; + return jd; + } + getDaysInMonth(date) { + if (date.month === 1 && (0, $f25df78da1f6b40f$export$553d7fa8e3805fc0)(date.year + $a07127433beb6bf1$var$INDIAN_ERA_START)) return 31; + if (date.month >= 2 && date.month <= 6) return 31; + return 30; + } + getYearsInEra() { + // 9999-12-31 gregorian is 9920-10-10 indian. + // Round down to 9919 for the last full year. + return 9919; + } + getEras() { + return [ + 'saka' + ]; + } + balanceDate() {} + constructor(...args){ + super(...args), this.identifier = 'indian'; + } +} + + +export {$a07127433beb6bf1$export$39f31c639fa15726 as IndianCalendar}; +//# sourceMappingURL=IndianCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c0aa2b185ba74368844b5bd2d1e3c67250197aff --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAWhG,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,KAAK,CAAA,GAAA,yCAAmB,EAAE,KAAK,MAAM,GAAG;QAC1C,OAAO;YACL,YAAY;YACZ,KAAK,CAAA,GAAA,yCAAmB,EAAE,KAAK,MAAM,GAAG;QAC1C;QAEA,IAAI,KAAK,KAAK,KAAK,GACjB,OAAO,KAAK,KAAK,GAAG,GAAG;QAGzB,MAAM,YAAY,KAAK,GAAG,CAAC,KAAK,KAAK,GAAG,GAAG,KAAK;QAEhD,IAAI,KAAK,KAAK,IAAI,GAChB,MAAM,AAAC,CAAA,KAAK,KAAK,GAAG,CAAA,IAAK;QAG3B,MAAM,KAAK,GAAG,GAAG;QACjB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,KAAK,KAAK,CAAA,GAAA,yCAAS,EAAE,KAAK,IAAI,GAAG,yCAC7C,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,GACnC,OAAO;QAGT,OAAO;IACT;IAEA,gBAAwB;QACtB,6CAA6C;QAC7C,6CAA6C;QAC7C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAO;IACjB;IAEA,cAAoB,CAAC;;QAjGhB,qBACL,aAAiC;;AAiGnC","sources":["packages/@internationalized/date/src/calendars/IndianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {\n fromExtendedYear,\n GregorianCalendar,\n gregorianToJulianDay,\n isLeapYear\n} from './GregorianCalendar';\n\n// Starts in 78 AD,\nconst INDIAN_ERA_START = 78;\n\n// The Indian year starts 80 days later than the Gregorian year.\nconst INDIAN_YEAR_START = 80;\n\n/**\n * The Indian National Calendar is similar to the Gregorian calendar, but with\n * years numbered since the Saka era in 78 AD (Gregorian). There are 12 months\n * in each year, with either 30 or 31 days. Only one era identifier is supported: 'saka'.\n */\nexport class IndianCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'indian';\n\n fromJulianDay(jd: number): CalendarDate {\n // Gregorian date for Julian day\n let date = super.fromJulianDay(jd);\n\n // Year in Saka era\n let indianYear = date.year - INDIAN_ERA_START;\n\n // Day number in Gregorian year (starting from 0)\n let yDay = jd - gregorianToJulianDay(date.era, date.year, 1, 1);\n\n let leapMonth: number;\n if (yDay < INDIAN_YEAR_START) {\n // Day is at the end of the preceding Saka year\n indianYear--;\n\n // Days in leapMonth this year, previous Gregorian year\n leapMonth = isLeapYear(date.year - 1) ? 31 : 30;\n yDay += leapMonth + 31 * 5 + 30 * 3 + 10;\n } else {\n // Days in leapMonth this year\n leapMonth = isLeapYear(date.year) ? 31 : 30;\n yDay -= INDIAN_YEAR_START;\n }\n\n let indianMonth: number;\n let indianDay: number;\n if (yDay < leapMonth) {\n indianMonth = 1;\n indianDay = yDay + 1;\n } else {\n let mDay = yDay - leapMonth;\n if (mDay < 31 * 5) {\n indianMonth = Math.floor(mDay / 31) + 2;\n indianDay = (mDay % 31) + 1;\n } else {\n mDay -= 31 * 5;\n indianMonth = Math.floor(mDay / 30) + 7;\n indianDay = (mDay % 30) + 1;\n }\n }\n\n return new CalendarDate(this, indianYear, indianMonth, indianDay);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let extendedYear = date.year + INDIAN_ERA_START;\n let [era, year] = fromExtendedYear(extendedYear);\n\n let leapMonth: number;\n let jd: number;\n if (isLeapYear(year)) {\n leapMonth = 31;\n jd = gregorianToJulianDay(era, year, 3, 21);\n } else {\n leapMonth = 30;\n jd = gregorianToJulianDay(era, year, 3, 22);\n }\n\n if (date.month === 1) {\n return jd + date.day - 1;\n }\n\n jd += leapMonth + Math.min(date.month - 2, 5) * 31;\n\n if (date.month >= 8) {\n jd += (date.month - 7) * 30;\n }\n\n jd += date.day - 1;\n return jd;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month === 1 && isLeapYear(date.year + INDIAN_ERA_START)) {\n return 31;\n }\n\n if (date.month >= 2 && date.month <= 6) {\n return 31;\n }\n\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999-12-31 gregorian is 9920-10-10 indian.\n // Round down to 9919 for the last full year.\n return 9919;\n }\n\n getEras(): string[] {\n return ['saka'];\n }\n\n balanceDate(): void {}\n}\n"],"names":[],"version":3,"file":"IndianCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..78a2643b45ae127df4da9b57527f069b70a74661 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.mjs @@ -0,0 +1,101 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {fromExtendedYear as $93635573935797de$export$4475b7e617eb123c, GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec, gregorianToJulianDay as $93635573935797de$export$f297eb839006d339, isLeapYear as $93635573935797de$export$553d7fa8e3805fc0} from "./GregorianCalendar.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +// Starts in 78 AD, +const $11fa67a177e45470$var$INDIAN_ERA_START = 78; +// The Indian year starts 80 days later than the Gregorian year. +const $11fa67a177e45470$var$INDIAN_YEAR_START = 80; +class $11fa67a177e45470$export$39f31c639fa15726 extends (0, $93635573935797de$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + // Gregorian date for Julian day + let date = super.fromJulianDay(jd); + // Year in Saka era + let indianYear = date.year - $11fa67a177e45470$var$INDIAN_ERA_START; + // Day number in Gregorian year (starting from 0) + let yDay = jd - (0, $93635573935797de$export$f297eb839006d339)(date.era, date.year, 1, 1); + let leapMonth; + if (yDay < $11fa67a177e45470$var$INDIAN_YEAR_START) { + // Day is at the end of the preceding Saka year + indianYear--; + // Days in leapMonth this year, previous Gregorian year + leapMonth = (0, $93635573935797de$export$553d7fa8e3805fc0)(date.year - 1) ? 31 : 30; + yDay += leapMonth + 155 + 90 + 10; + } else { + // Days in leapMonth this year + leapMonth = (0, $93635573935797de$export$553d7fa8e3805fc0)(date.year) ? 31 : 30; + yDay -= $11fa67a177e45470$var$INDIAN_YEAR_START; + } + let indianMonth; + let indianDay; + if (yDay < leapMonth) { + indianMonth = 1; + indianDay = yDay + 1; + } else { + let mDay = yDay - leapMonth; + if (mDay < 155) { + indianMonth = Math.floor(mDay / 31) + 2; + indianDay = mDay % 31 + 1; + } else { + mDay -= 155; + indianMonth = Math.floor(mDay / 30) + 7; + indianDay = mDay % 30 + 1; + } + } + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, indianYear, indianMonth, indianDay); + } + toJulianDay(date) { + let extendedYear = date.year + $11fa67a177e45470$var$INDIAN_ERA_START; + let [era, year] = (0, $93635573935797de$export$4475b7e617eb123c)(extendedYear); + let leapMonth; + let jd; + if ((0, $93635573935797de$export$553d7fa8e3805fc0)(year)) { + leapMonth = 31; + jd = (0, $93635573935797de$export$f297eb839006d339)(era, year, 3, 21); + } else { + leapMonth = 30; + jd = (0, $93635573935797de$export$f297eb839006d339)(era, year, 3, 22); + } + if (date.month === 1) return jd + date.day - 1; + jd += leapMonth + Math.min(date.month - 2, 5) * 31; + if (date.month >= 8) jd += (date.month - 7) * 30; + jd += date.day - 1; + return jd; + } + getDaysInMonth(date) { + if (date.month === 1 && (0, $93635573935797de$export$553d7fa8e3805fc0)(date.year + $11fa67a177e45470$var$INDIAN_ERA_START)) return 31; + if (date.month >= 2 && date.month <= 6) return 31; + return 30; + } + getYearsInEra() { + // 9999-12-31 gregorian is 9920-10-10 indian. + // Round down to 9919 for the last full year. + return 9919; + } + getEras() { + return [ + 'saka' + ]; + } + balanceDate() {} + constructor(...args){ + super(...args), this.identifier = 'indian'; + } +} + + +export {$11fa67a177e45470$export$39f31c639fa15726 as IndianCalendar}; +//# sourceMappingURL=IndianCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..657856d0d215fdab3afb444122725e8e6d5057e9 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IndianCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAWhG,mBAAmB;AACnB,MAAM,yCAAmB;AAEzB,gEAAgE;AAChE,MAAM,0CAAoB;AAOnB,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,gCAAgC;QAChC,IAAI,OAAO,KAAK,CAAC,cAAc;QAE/B,mBAAmB;QACnB,IAAI,aAAa,KAAK,IAAI,GAAG;QAE7B,iDAAiD;QACjD,IAAI,OAAO,KAAK,CAAA,GAAA,yCAAmB,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,GAAG;QAE7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AA,IAAK;QAG3B,MAAM,KAAK,GAAG,GAAG;QACjB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,KAAK,KAAK,CAAA,GAAA,yCAAS,EAAE,KAAK,IAAI,GAAG,yCAC7C,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,GACnC,OAAO;QAGT,OAAO;IACT;IAEA,gBAAwB;QACtB,6CAA6C;QAC7C,6CAA6C;QAC7C,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAO;IACjB;IAEA,cAAoB,CAAC;;QAjGhB,qBACL,aAAiC;;AAiGnC","sources":["packages/@internationalized/date/src/calendars/IndianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {\n fromExtendedYear,\n GregorianCalendar,\n gregorianToJulianDay,\n isLeapYear\n} from './GregorianCalendar';\n\n// Starts in 78 AD,\nconst INDIAN_ERA_START = 78;\n\n// The Indian year starts 80 days later than the Gregorian year.\nconst INDIAN_YEAR_START = 80;\n\n/**\n * The Indian National Calendar is similar to the Gregorian calendar, but with\n * years numbered since the Saka era in 78 AD (Gregorian). There are 12 months\n * in each year, with either 30 or 31 days. Only one era identifier is supported: 'saka'.\n */\nexport class IndianCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'indian';\n\n fromJulianDay(jd: number): CalendarDate {\n // Gregorian date for Julian day\n let date = super.fromJulianDay(jd);\n\n // Year in Saka era\n let indianYear = date.year - INDIAN_ERA_START;\n\n // Day number in Gregorian year (starting from 0)\n let yDay = jd - gregorianToJulianDay(date.era, date.year, 1, 1);\n\n let leapMonth: number;\n if (yDay < INDIAN_YEAR_START) {\n // Day is at the end of the preceding Saka year\n indianYear--;\n\n // Days in leapMonth this year, previous Gregorian year\n leapMonth = isLeapYear(date.year - 1) ? 31 : 30;\n yDay += leapMonth + 31 * 5 + 30 * 3 + 10;\n } else {\n // Days in leapMonth this year\n leapMonth = isLeapYear(date.year) ? 31 : 30;\n yDay -= INDIAN_YEAR_START;\n }\n\n let indianMonth: number;\n let indianDay: number;\n if (yDay < leapMonth) {\n indianMonth = 1;\n indianDay = yDay + 1;\n } else {\n let mDay = yDay - leapMonth;\n if (mDay < 31 * 5) {\n indianMonth = Math.floor(mDay / 31) + 2;\n indianDay = (mDay % 31) + 1;\n } else {\n mDay -= 31 * 5;\n indianMonth = Math.floor(mDay / 30) + 7;\n indianDay = (mDay % 30) + 1;\n }\n }\n\n return new CalendarDate(this, indianYear, indianMonth, indianDay);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let extendedYear = date.year + INDIAN_ERA_START;\n let [era, year] = fromExtendedYear(extendedYear);\n\n let leapMonth: number;\n let jd: number;\n if (isLeapYear(year)) {\n leapMonth = 31;\n jd = gregorianToJulianDay(era, year, 3, 21);\n } else {\n leapMonth = 30;\n jd = gregorianToJulianDay(era, year, 3, 22);\n }\n\n if (date.month === 1) {\n return jd + date.day - 1;\n }\n\n jd += leapMonth + Math.min(date.month - 2, 5) * 31;\n\n if (date.month >= 8) {\n jd += (date.month - 7) * 30;\n }\n\n jd += date.day - 1;\n return jd;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month === 1 && isLeapYear(date.year + INDIAN_ERA_START)) {\n return 31;\n }\n\n if (date.month >= 2 && date.month <= 6) {\n return 31;\n }\n\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999-12-31 gregorian is 9920-10-10 indian.\n // Round down to 9919 for the last full year.\n return 9919;\n }\n\n getEras(): string[] {\n return ['saka'];\n }\n\n balanceDate(): void {}\n}\n"],"names":[],"version":3,"file":"IndianCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..ff0ac15b9b90bad596983817c4eb5f7b55cbe174 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.cjs @@ -0,0 +1,168 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "IslamicCivilCalendar", function () { return $fbcc6aba7cd7f47c$export$2066795aadd37bfc; }); +$parcel$export(module.exports, "IslamicTabularCalendar", function () { return $fbcc6aba7cd7f47c$export$37f0887f2f9d22f7; }); +$parcel$export(module.exports, "IslamicUmalquraCalendar", function () { return $fbcc6aba7cd7f47c$export$5baab4758c231076; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + +const $fbcc6aba7cd7f47c$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar) +const $fbcc6aba7cd7f47c$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar) +const $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START = 1300; +const $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END = 1600; +const $fbcc6aba7cd7f47c$var$UMALQURA_START_DAYS = 460322; +function $fbcc6aba7cd7f47c$var$islamicToJulianDay(epoch, year, month, day) { + return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1; +} +function $fbcc6aba7cd7f47c$var$julianDayToIslamic(calendar, epoch, jd) { + let year = Math.floor((30 * (jd - epoch) + 10646) / 10631); + let month = Math.min(12, Math.ceil((jd - (29 + $fbcc6aba7cd7f47c$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1); + let day = jd - $fbcc6aba7cd7f47c$var$islamicToJulianDay(epoch, year, month, 1) + 1; + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(calendar, year, month, day); +} +function $fbcc6aba7cd7f47c$var$isLeapYear(year) { + return (14 + 11 * year) % 30 < 11; +} +class $fbcc6aba7cd7f47c$export$2066795aadd37bfc { + fromJulianDay(jd) { + return $fbcc6aba7cd7f47c$var$julianDayToIslamic(this, $fbcc6aba7cd7f47c$var$CIVIL_EPOC, jd); + } + toJulianDay(date) { + return $fbcc6aba7cd7f47c$var$islamicToJulianDay($fbcc6aba7cd7f47c$var$CIVIL_EPOC, date.year, date.month, date.day); + } + getDaysInMonth(date) { + let length = 29 + date.month % 2; + if (date.month === 12 && $fbcc6aba7cd7f47c$var$isLeapYear(date.year)) length++; + return length; + } + getMonthsInYear() { + return 12; + } + getDaysInYear(date) { + return $fbcc6aba7cd7f47c$var$isLeapYear(date.year) ? 355 : 354; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra() { + // 9999 gregorian + return 9665; + } + getEras() { + return [ + 'AH' + ]; + } + constructor(){ + this.identifier = 'islamic-civil'; + } +} +class $fbcc6aba7cd7f47c$export$37f0887f2f9d22f7 extends $fbcc6aba7cd7f47c$export$2066795aadd37bfc { + fromJulianDay(jd) { + return $fbcc6aba7cd7f47c$var$julianDayToIslamic(this, $fbcc6aba7cd7f47c$var$ASTRONOMICAL_EPOC, jd); + } + toJulianDay(date) { + return $fbcc6aba7cd7f47c$var$islamicToJulianDay($fbcc6aba7cd7f47c$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day); + } + constructor(...args){ + super(...args), this.identifier = 'islamic-tbla'; + } +} +// Generated by scripts/generate-umalqura.js +const $fbcc6aba7cd7f47c$var$UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI='; +let $fbcc6aba7cd7f47c$var$UMALQURA_MONTHLENGTH; +let $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE; +function $fbcc6aba7cd7f47c$var$umalquraYearStart(year) { + return $fbcc6aba7cd7f47c$var$UMALQURA_START_DAYS + $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE[year - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START]; +} +function $fbcc6aba7cd7f47c$var$umalquraMonthLength(year, month) { + let idx = year - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START; + let mask = 0x01 << 11 - (month - 1); + if (($fbcc6aba7cd7f47c$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) return 29; + else return 30; +} +function $fbcc6aba7cd7f47c$var$umalquraMonthStart(year, month) { + let day = $fbcc6aba7cd7f47c$var$umalquraYearStart(year); + for(let i = 1; i < month; i++)day += $fbcc6aba7cd7f47c$var$umalquraMonthLength(year, i); + return day; +} +function $fbcc6aba7cd7f47c$var$umalquraYearLength(year) { + return $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE[year + 1 - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START] - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE[year - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START]; +} +class $fbcc6aba7cd7f47c$export$5baab4758c231076 extends $fbcc6aba7cd7f47c$export$2066795aadd37bfc { + constructor(){ + super(), this.identifier = 'islamic-umalqura'; + if (!$fbcc6aba7cd7f47c$var$UMALQURA_MONTHLENGTH) $fbcc6aba7cd7f47c$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($fbcc6aba7cd7f47c$var$UMALQURA_DATA), (c)=>c.charCodeAt(0)).buffer); + if (!$fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE) { + $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START + 1); + let yearStart = 0; + for(let year = $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START; year <= $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END; year++){ + $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START_TABLE[year - $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START] = yearStart; + for(let i = 1; i <= 12; i++)yearStart += $fbcc6aba7cd7f47c$var$umalquraMonthLength(year, i); + } + } + } + fromJulianDay(jd) { + let days = jd - $fbcc6aba7cd7f47c$var$CIVIL_EPOC; + let startDays = $fbcc6aba7cd7f47c$var$umalquraYearStart($fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START); + let endDays = $fbcc6aba7cd7f47c$var$umalquraYearStart($fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END); + if (days < startDays || days > endDays) return super.fromJulianDay(jd); + else { + let y = $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START - 1; + let m = 1; + let d = 1; + while(d > 0){ + y++; + d = days - $fbcc6aba7cd7f47c$var$umalquraYearStart(y) + 1; + let yearLength = $fbcc6aba7cd7f47c$var$umalquraYearLength(y); + if (d === yearLength) { + m = 12; + break; + } else if (d < yearLength) { + let monthLength = $fbcc6aba7cd7f47c$var$umalquraMonthLength(y, m); + m = 1; + while(d > monthLength){ + d -= monthLength; + m++; + monthLength = $fbcc6aba7cd7f47c$var$umalquraMonthLength(y, m); + } + break; + } + } + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, y, m, days - $fbcc6aba7cd7f47c$var$umalquraMonthStart(y, m) + 1); + } + } + toJulianDay(date) { + if (date.year < $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START || date.year > $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END) return super.toJulianDay(date); + return $fbcc6aba7cd7f47c$var$CIVIL_EPOC + $fbcc6aba7cd7f47c$var$umalquraMonthStart(date.year, date.month) + (date.day - 1); + } + getDaysInMonth(date) { + if (date.year < $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START || date.year > $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END) return super.getDaysInMonth(date); + return $fbcc6aba7cd7f47c$var$umalquraMonthLength(date.year, date.month); + } + getDaysInYear(date) { + if (date.year < $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_START || date.year > $fbcc6aba7cd7f47c$var$UMALQURA_YEAR_END) return super.getDaysInYear(date); + return $fbcc6aba7cd7f47c$var$umalquraYearLength(date.year); + } +} + + +//# sourceMappingURL=IslamicCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..c96065f40811a7f3f10f32a2ccaeb71bba56f420 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,MAAM,0CAAoB;AAC1B,MAAM,4CAAsB;AAE5B,SAAS,yCAAmB,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACjF,OACE,MACA,KAAK,IAAI,CAAC,OAAQ,CAAA,QAAQ,CAAA,KAC1B,AAAC,CAAA,OAAO,CAAA,IAAK,MACb,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAG,IAAK,MAC7B,QACA;AAEJ;AAEA,SAAS,yCAAmB,QAAkB,EAAE,KAAa,EAAE,EAAU;IACvE,IAAI,OAAO,KAAK,KAAK,CAAC,AAAC,CAAA,KAAM,CAAA,KAAK,KAAI,IA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L,IAAI,IAAI,4CAAsB;YAC9B,IAAI,IAAI;YACR,IAAI,IAAI;YACR,MAAO,IAAI,EAAG;gBACZ;gBACA,IAAI,OAAO,wCAAkB,KAAK;gBAClC,IAAI,aAAa,yCAAmB;gBACpC,IAAI,MAAM,YAAY;oBACpB,IAAI;oBACJ;gBACF,OAAO,IAAI,IAAI,YAAY;oBACzB,IAAI,cAAc,0CAAoB,GAAG;oBACzC,IAAI;oBACJ,MAAO,IAAI,YAAa;wBACtB,KAAK;wBACL;wBACA,cAAc,0CAAoB,GAAG;oBACvC;oBACA;gBACF;YACF;YAEA,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,yCAAmB,GAAG,KAAK;QACxE;IACF;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,YAAY;QAG3B,OAAO,mCAAa,yCAAmB,KAAK,IAAI,EAAE,KAAK,KAAK,IAAK,CAAA,KAAK,GAAG,GAAG,CAAA;IAC9E;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,eAAe;QAG9B,OAAO,0CAAoB,KAAK,IAAI,EAAE,KAAK,KAAK;IAClD;IAEA,cAAc,IAAqB,EAAU;QAC3C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,cAAc;QAG7B,OAAO,yCAAmB,KAAK,IAAI;IACrC;AACF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return (\n day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch -\n 1\n );\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(\n 12,\n Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1\n );\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The civil variant uses simple arithmetic rules rather than astronomical calculations to\n * approximate the traditional calendar, which is based on sighting of the crescent moon. It uses\n * Friday, July 16 622 CE (Julian) as the epoch. Each year has 12 months, with either 354 or 355\n * days depending on whether it is a leap year. Learn more about the available Islamic calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier: CalendarIdentifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + (date.month % 2);\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras(): string[] {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The tabular variant uses simple arithmetic rules rather than astronomical calculations to\n * approximate the traditional calendar, which is based on sighting of the crescent moon. It uses\n * Thursday, July 15 622 CE (Julian) as the epoch. Each year has 12 months, with either 354 or 355\n * days depending on whether it is a leap year. Learn more about the available Islamic calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA =\n 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = year - UMALQURA_YEAR_START;\n let mask = 0x01 << (11 - (month - 1));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return (\n UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] -\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START]\n );\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on\n * astronomical calculations that predict the sighting of a crescent moon. Month and year lengths\n * vary between years depending on these calculations. Learn more about the available Islamic\n * calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(\n Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer\n );\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, days - umalquraMonthStart(y, m) + 1);\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..c8400b000d92c453386e4485c84ca79f24aa794a --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.js @@ -0,0 +1,161 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + +const $a938ddf4fc940323$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar) +const $a938ddf4fc940323$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar) +const $a938ddf4fc940323$var$UMALQURA_YEAR_START = 1300; +const $a938ddf4fc940323$var$UMALQURA_YEAR_END = 1600; +const $a938ddf4fc940323$var$UMALQURA_START_DAYS = 460322; +function $a938ddf4fc940323$var$islamicToJulianDay(epoch, year, month, day) { + return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1; +} +function $a938ddf4fc940323$var$julianDayToIslamic(calendar, epoch, jd) { + let year = Math.floor((30 * (jd - epoch) + 10646) / 10631); + let month = Math.min(12, Math.ceil((jd - (29 + $a938ddf4fc940323$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1); + let day = jd - $a938ddf4fc940323$var$islamicToJulianDay(epoch, year, month, 1) + 1; + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(calendar, year, month, day); +} +function $a938ddf4fc940323$var$isLeapYear(year) { + return (14 + 11 * year) % 30 < 11; +} +class $a938ddf4fc940323$export$2066795aadd37bfc { + fromJulianDay(jd) { + return $a938ddf4fc940323$var$julianDayToIslamic(this, $a938ddf4fc940323$var$CIVIL_EPOC, jd); + } + toJulianDay(date) { + return $a938ddf4fc940323$var$islamicToJulianDay($a938ddf4fc940323$var$CIVIL_EPOC, date.year, date.month, date.day); + } + getDaysInMonth(date) { + let length = 29 + date.month % 2; + if (date.month === 12 && $a938ddf4fc940323$var$isLeapYear(date.year)) length++; + return length; + } + getMonthsInYear() { + return 12; + } + getDaysInYear(date) { + return $a938ddf4fc940323$var$isLeapYear(date.year) ? 355 : 354; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra() { + // 9999 gregorian + return 9665; + } + getEras() { + return [ + 'AH' + ]; + } + constructor(){ + this.identifier = 'islamic-civil'; + } +} +class $a938ddf4fc940323$export$37f0887f2f9d22f7 extends $a938ddf4fc940323$export$2066795aadd37bfc { + fromJulianDay(jd) { + return $a938ddf4fc940323$var$julianDayToIslamic(this, $a938ddf4fc940323$var$ASTRONOMICAL_EPOC, jd); + } + toJulianDay(date) { + return $a938ddf4fc940323$var$islamicToJulianDay($a938ddf4fc940323$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day); + } + constructor(...args){ + super(...args), this.identifier = 'islamic-tbla'; + } +} +// Generated by scripts/generate-umalqura.js +const $a938ddf4fc940323$var$UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI='; +let $a938ddf4fc940323$var$UMALQURA_MONTHLENGTH; +let $a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE; +function $a938ddf4fc940323$var$umalquraYearStart(year) { + return $a938ddf4fc940323$var$UMALQURA_START_DAYS + $a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE[year - $a938ddf4fc940323$var$UMALQURA_YEAR_START]; +} +function $a938ddf4fc940323$var$umalquraMonthLength(year, month) { + let idx = year - $a938ddf4fc940323$var$UMALQURA_YEAR_START; + let mask = 0x01 << 11 - (month - 1); + if (($a938ddf4fc940323$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) return 29; + else return 30; +} +function $a938ddf4fc940323$var$umalquraMonthStart(year, month) { + let day = $a938ddf4fc940323$var$umalquraYearStart(year); + for(let i = 1; i < month; i++)day += $a938ddf4fc940323$var$umalquraMonthLength(year, i); + return day; +} +function $a938ddf4fc940323$var$umalquraYearLength(year) { + return $a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE[year + 1 - $a938ddf4fc940323$var$UMALQURA_YEAR_START] - $a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE[year - $a938ddf4fc940323$var$UMALQURA_YEAR_START]; +} +class $a938ddf4fc940323$export$5baab4758c231076 extends $a938ddf4fc940323$export$2066795aadd37bfc { + fromJulianDay(jd) { + let days = jd - $a938ddf4fc940323$var$CIVIL_EPOC; + let startDays = $a938ddf4fc940323$var$umalquraYearStart($a938ddf4fc940323$var$UMALQURA_YEAR_START); + let endDays = $a938ddf4fc940323$var$umalquraYearStart($a938ddf4fc940323$var$UMALQURA_YEAR_END); + if (days < startDays || days > endDays) return super.fromJulianDay(jd); + else { + let y = $a938ddf4fc940323$var$UMALQURA_YEAR_START - 1; + let m = 1; + let d = 1; + while(d > 0){ + y++; + d = days - $a938ddf4fc940323$var$umalquraYearStart(y) + 1; + let yearLength = $a938ddf4fc940323$var$umalquraYearLength(y); + if (d === yearLength) { + m = 12; + break; + } else if (d < yearLength) { + let monthLength = $a938ddf4fc940323$var$umalquraMonthLength(y, m); + m = 1; + while(d > monthLength){ + d -= monthLength; + m++; + monthLength = $a938ddf4fc940323$var$umalquraMonthLength(y, m); + } + break; + } + } + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, y, m, days - $a938ddf4fc940323$var$umalquraMonthStart(y, m) + 1); + } + } + toJulianDay(date) { + if (date.year < $a938ddf4fc940323$var$UMALQURA_YEAR_START || date.year > $a938ddf4fc940323$var$UMALQURA_YEAR_END) return super.toJulianDay(date); + return $a938ddf4fc940323$var$CIVIL_EPOC + $a938ddf4fc940323$var$umalquraMonthStart(date.year, date.month) + (date.day - 1); + } + getDaysInMonth(date) { + if (date.year < $a938ddf4fc940323$var$UMALQURA_YEAR_START || date.year > $a938ddf4fc940323$var$UMALQURA_YEAR_END) return super.getDaysInMonth(date); + return $a938ddf4fc940323$var$umalquraMonthLength(date.year, date.month); + } + getDaysInYear(date) { + if (date.year < $a938ddf4fc940323$var$UMALQURA_YEAR_START || date.year > $a938ddf4fc940323$var$UMALQURA_YEAR_END) return super.getDaysInYear(date); + return $a938ddf4fc940323$var$umalquraYearLength(date.year); + } + constructor(){ + super(), this.identifier = 'islamic-umalqura'; + if (!$a938ddf4fc940323$var$UMALQURA_MONTHLENGTH) $a938ddf4fc940323$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($a938ddf4fc940323$var$UMALQURA_DATA), (c)=>c.charCodeAt(0)).buffer); + if (!$a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE) { + $a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($a938ddf4fc940323$var$UMALQURA_YEAR_END - $a938ddf4fc940323$var$UMALQURA_YEAR_START + 1); + let yearStart = 0; + for(let year = $a938ddf4fc940323$var$UMALQURA_YEAR_START; year <= $a938ddf4fc940323$var$UMALQURA_YEAR_END; year++){ + $a938ddf4fc940323$var$UMALQURA_YEAR_START_TABLE[year - $a938ddf4fc940323$var$UMALQURA_YEAR_START] = yearStart; + for(let i = 1; i <= 12; i++)yearStart += $a938ddf4fc940323$var$umalquraMonthLength(year, i); + } + } + } +} + + +export {$a938ddf4fc940323$export$2066795aadd37bfc as IslamicCivilCalendar, $a938ddf4fc940323$export$37f0887f2f9d22f7 as IslamicTabularCalendar, $a938ddf4fc940323$export$5baab4758c231076 as IslamicUmalquraCalendar}; +//# sourceMappingURL=IslamicCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..96a8043c896c6f80d61761fa6a0aa14e26885775 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,MAAM,0CAAoB;AAC1B,MAAM,4CAAsB;AAE5B,SAAS,yCAAmB,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACjF,OACE,MACA,KAAK,IAAI,CAAC,OAAQ,CAAA,QAAQ,CAAA,KAC1B,AAAC,CAAA,OAAO,CAAA,IAAK,MACb,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAG,IAAK,MAC7B,QACA;AAEJ;AAEA,SAAS,yCAAmB,QAAkB,EAAE,KAAa,EAAE,EAAU;IACvE,IAAI,OAAO,KAAK,KAAK,CAAC,AAAC,CAAA,KAAM,CAAA,KAAK,KAAI,IAAK,KAAI,IAAK;IACpD,IAAI,QAAQ,KAAK,GAAG,CAClB,IACA,KAAK,IAAI,CAAC,AAAC,CAAA,KAAM,CAAA,KAAK,yCAAmB,OAAO,MAAM,GAAG,EAAC,CAAC,IAAK,QAAQ;IAE1E,IAAI,MAAM,KAAK,yCAAmB,OAAO,MAAM,OAAO,KAAK;IAE3D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A,KAAK,GAAG,GAAG,CAAA;IAC9E;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,eAAe;QAG9B,OAAO,0CAAoB,KAAK,IAAI,EAAE,KAAK,KAAK;IAClD;IAEA,cAAc,IAAqB,EAAU;QAC3C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,cAAc;QAG7B,OAAO,yCAAmB,KAAK,IAAI;IACrC;IA5EA,aAAc;QACZ,KAAK,SAHP,aAAiC;QAI/B,IAAI,CAAC,4CACH,6CAAuB,IAAI,YACzB,WAAW,IAAI,CAAC,KAAK,sCAAgB,CAAA,IAAK,EAAE,UAAU,CAAC,IAAI,MAAM;QAIrE,IAAI,CAAC,iDAA2B;YAC9B,kDAA4B,IAAI,YAAY,0CAAoB,4CAAsB;YAEtF,IAAI,YAAY;YAChB,IAAK,IAAI,OAAO,2CAAqB,QAAQ,yCAAmB,OAAQ;gBACtE,+CAAyB,CAAC,OAAO,0CAAoB,GAAG;gBACxD,IAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IACvB,aAAa,0CAAoB,MAAM;YAE3C;QACF;IACF;AA0DF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return (\n day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch -\n 1\n );\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(\n 12,\n Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1\n );\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The civil variant uses simple arithmetic rules rather than astronomical calculations to\n * approximate the traditional calendar, which is based on sighting of the crescent moon. It uses\n * Friday, July 16 622 CE (Julian) as the epoch. Each year has 12 months, with either 354 or 355\n * days depending on whether it is a leap year. Learn more about the available Islamic calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier: CalendarIdentifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + (date.month % 2);\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras(): string[] {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The tabular variant uses simple arithmetic rules rather than astronomical calculations to\n * approximate the traditional calendar, which is based on sighting of the crescent moon. It uses\n * Thursday, July 15 622 CE (Julian) as the epoch. Each year has 12 months, with either 354 or 355\n * days depending on whether it is a leap year. Learn more about the available Islamic calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA =\n 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = year - UMALQURA_YEAR_START;\n let mask = 0x01 << (11 - (month - 1));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return (\n UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] -\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START]\n );\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on\n * astronomical calculations that predict the sighting of a crescent moon. Month and year lengths\n * vary between years depending on these calculations. Learn more about the available Islamic\n * calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(\n Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer\n );\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, days - umalquraMonthStart(y, m) + 1);\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2e1354e97817fddfb51cffdec12d353c67492c4b --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.mjs @@ -0,0 +1,161 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + +const $fd4f9bc1ba0e49a8$var$CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar) +const $fd4f9bc1ba0e49a8$var$ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar) +const $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START = 1300; +const $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END = 1600; +const $fd4f9bc1ba0e49a8$var$UMALQURA_START_DAYS = 460322; +function $fd4f9bc1ba0e49a8$var$islamicToJulianDay(epoch, year, month, day) { + return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + epoch - 1; +} +function $fd4f9bc1ba0e49a8$var$julianDayToIslamic(calendar, epoch, jd) { + let year = Math.floor((30 * (jd - epoch) + 10646) / 10631); + let month = Math.min(12, Math.ceil((jd - (29 + $fd4f9bc1ba0e49a8$var$islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1); + let day = jd - $fd4f9bc1ba0e49a8$var$islamicToJulianDay(epoch, year, month, 1) + 1; + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(calendar, year, month, day); +} +function $fd4f9bc1ba0e49a8$var$isLeapYear(year) { + return (14 + 11 * year) % 30 < 11; +} +class $fd4f9bc1ba0e49a8$export$2066795aadd37bfc { + fromJulianDay(jd) { + return $fd4f9bc1ba0e49a8$var$julianDayToIslamic(this, $fd4f9bc1ba0e49a8$var$CIVIL_EPOC, jd); + } + toJulianDay(date) { + return $fd4f9bc1ba0e49a8$var$islamicToJulianDay($fd4f9bc1ba0e49a8$var$CIVIL_EPOC, date.year, date.month, date.day); + } + getDaysInMonth(date) { + let length = 29 + date.month % 2; + if (date.month === 12 && $fd4f9bc1ba0e49a8$var$isLeapYear(date.year)) length++; + return length; + } + getMonthsInYear() { + return 12; + } + getDaysInYear(date) { + return $fd4f9bc1ba0e49a8$var$isLeapYear(date.year) ? 355 : 354; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 30; + } + getYearsInEra() { + // 9999 gregorian + return 9665; + } + getEras() { + return [ + 'AH' + ]; + } + constructor(){ + this.identifier = 'islamic-civil'; + } +} +class $fd4f9bc1ba0e49a8$export$37f0887f2f9d22f7 extends $fd4f9bc1ba0e49a8$export$2066795aadd37bfc { + fromJulianDay(jd) { + return $fd4f9bc1ba0e49a8$var$julianDayToIslamic(this, $fd4f9bc1ba0e49a8$var$ASTRONOMICAL_EPOC, jd); + } + toJulianDay(date) { + return $fd4f9bc1ba0e49a8$var$islamicToJulianDay($fd4f9bc1ba0e49a8$var$ASTRONOMICAL_EPOC, date.year, date.month, date.day); + } + constructor(...args){ + super(...args), this.identifier = 'islamic-tbla'; + } +} +// Generated by scripts/generate-umalqura.js +const $fd4f9bc1ba0e49a8$var$UMALQURA_DATA = 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI='; +let $fd4f9bc1ba0e49a8$var$UMALQURA_MONTHLENGTH; +let $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE; +function $fd4f9bc1ba0e49a8$var$umalquraYearStart(year) { + return $fd4f9bc1ba0e49a8$var$UMALQURA_START_DAYS + $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE[year - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START]; +} +function $fd4f9bc1ba0e49a8$var$umalquraMonthLength(year, month) { + let idx = year - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START; + let mask = 0x01 << 11 - (month - 1); + if (($fd4f9bc1ba0e49a8$var$UMALQURA_MONTHLENGTH[idx] & mask) === 0) return 29; + else return 30; +} +function $fd4f9bc1ba0e49a8$var$umalquraMonthStart(year, month) { + let day = $fd4f9bc1ba0e49a8$var$umalquraYearStart(year); + for(let i = 1; i < month; i++)day += $fd4f9bc1ba0e49a8$var$umalquraMonthLength(year, i); + return day; +} +function $fd4f9bc1ba0e49a8$var$umalquraYearLength(year) { + return $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE[year + 1 - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START] - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE[year - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START]; +} +class $fd4f9bc1ba0e49a8$export$5baab4758c231076 extends $fd4f9bc1ba0e49a8$export$2066795aadd37bfc { + constructor(){ + super(), this.identifier = 'islamic-umalqura'; + if (!$fd4f9bc1ba0e49a8$var$UMALQURA_MONTHLENGTH) $fd4f9bc1ba0e49a8$var$UMALQURA_MONTHLENGTH = new Uint16Array(Uint8Array.from(atob($fd4f9bc1ba0e49a8$var$UMALQURA_DATA), (c)=>c.charCodeAt(0)).buffer); + if (!$fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE) { + $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE = new Uint32Array($fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START + 1); + let yearStart = 0; + for(let year = $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START; year <= $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END; year++){ + $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START_TABLE[year - $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START] = yearStart; + for(let i = 1; i <= 12; i++)yearStart += $fd4f9bc1ba0e49a8$var$umalquraMonthLength(year, i); + } + } + } + fromJulianDay(jd) { + let days = jd - $fd4f9bc1ba0e49a8$var$CIVIL_EPOC; + let startDays = $fd4f9bc1ba0e49a8$var$umalquraYearStart($fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START); + let endDays = $fd4f9bc1ba0e49a8$var$umalquraYearStart($fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END); + if (days < startDays || days > endDays) return super.fromJulianDay(jd); + else { + let y = $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START - 1; + let m = 1; + let d = 1; + while(d > 0){ + y++; + d = days - $fd4f9bc1ba0e49a8$var$umalquraYearStart(y) + 1; + let yearLength = $fd4f9bc1ba0e49a8$var$umalquraYearLength(y); + if (d === yearLength) { + m = 12; + break; + } else if (d < yearLength) { + let monthLength = $fd4f9bc1ba0e49a8$var$umalquraMonthLength(y, m); + m = 1; + while(d > monthLength){ + d -= monthLength; + m++; + monthLength = $fd4f9bc1ba0e49a8$var$umalquraMonthLength(y, m); + } + break; + } + } + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, y, m, days - $fd4f9bc1ba0e49a8$var$umalquraMonthStart(y, m) + 1); + } + } + toJulianDay(date) { + if (date.year < $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START || date.year > $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END) return super.toJulianDay(date); + return $fd4f9bc1ba0e49a8$var$CIVIL_EPOC + $fd4f9bc1ba0e49a8$var$umalquraMonthStart(date.year, date.month) + (date.day - 1); + } + getDaysInMonth(date) { + if (date.year < $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START || date.year > $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END) return super.getDaysInMonth(date); + return $fd4f9bc1ba0e49a8$var$umalquraMonthLength(date.year, date.month); + } + getDaysInYear(date) { + if (date.year < $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_START || date.year > $fd4f9bc1ba0e49a8$var$UMALQURA_YEAR_END) return super.getDaysInYear(date); + return $fd4f9bc1ba0e49a8$var$umalquraYearLength(date.year); + } +} + + +export {$fd4f9bc1ba0e49a8$export$2066795aadd37bfc as IslamicCivilCalendar, $fd4f9bc1ba0e49a8$export$37f0887f2f9d22f7 as IslamicTabularCalendar, $fd4f9bc1ba0e49a8$export$5baab4758c231076 as IslamicUmalquraCalendar}; +//# sourceMappingURL=IslamicCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..dce995edcf6982e6142c387c6da050b0c70b72f5 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/IslamicCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;AAKhG,MAAM,mCAAa,SAAS,gFAAgF;AAC5G,MAAM,0CAAoB,SAAS,4CAA4C;AAC/E,MAAM,4CAAsB;AAC5B,MAAM,0CAAoB;AAC1B,MAAM,4CAAsB;AAE5B,SAAS,yCAAmB,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACjF,OACE,MACA,KAAK,IAAI,CAAC,OAAQ,CAAA,QAAQ,CAAA,KAC1B,AAAC,CAAA,OAAO,CAAA,IAAK,MACb,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAG,IAAK,MAC7B,QACA;AAEJ;AAEA,SAAS,yCAAmB,QAAkB,EAAE,KAAa,EAAE,EAAU;IACvE,IAAI,OAAO,KAAK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aAAa,OAAO,SAC7B,OAAO,KAAK,CAAC,cAAc;aACtB;YACL,IAAI,IAAI,4CAAsB;YAC9B,IAAI,IAAI;YACR,IAAI,IAAI;YACR,MAAO,IAAI,EAAG;gBACZ;gBACA,IAAI,OAAO,wCAAkB,KAAK;gBAClC,IAAI,aAAa,yCAAmB;gBACpC,IAAI,MAAM,YAAY;oBACpB,IAAI;oBACJ;gBACF,OAAO,IAAI,IAAI,YAAY;oBACzB,IAAI,cAAc,0CAAoB,GAAG;oBACzC,IAAI;oBACJ,MAAO,IAAI,YAAa;wBACtB,KAAK;wBACL;wBACA,cAAc,0CAAoB,GAAG;oBACvC;oBACA;gBACF;YACF;YAEA,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,yCAAmB,GAAG,KAAK;QACxE;IACF;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,YAAY;QAG3B,OAAO,mCAAa,yCAAmB,KAAK,IAAI,EAAE,KAAK,KAAK,IAAK,CAAA,KAAK,GAAG,GAAG,CAAA;IAC9E;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,eAAe;QAG9B,OAAO,0CAAoB,KAAK,IAAI,EAAE,KAAK,KAAK;IAClD;IAEA,cAAc,IAAqB,EAAU;QAC3C,IAAI,KAAK,IAAI,GAAG,6CAAuB,KAAK,IAAI,GAAG,yCACjD,OAAO,KAAK,CAAC,cAAc;QAG7B,OAAO,yCAAmB,KAAK,IAAI;IACrC;AACF","sources":["packages/@internationalized/date/src/calendars/IslamicCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\n\nconst CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian calendar) / CE 622 July 19 (Gregorian calendar)\nconst ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Julian calendar)\nconst UMALQURA_YEAR_START = 1300;\nconst UMALQURA_YEAR_END = 1600;\nconst UMALQURA_START_DAYS = 460322;\n\nfunction islamicToJulianDay(epoch: number, year: number, month: number, day: number): number {\n return (\n day +\n Math.ceil(29.5 * (month - 1)) +\n (year - 1) * 354 +\n Math.floor((3 + 11 * year) / 30) +\n epoch -\n 1\n );\n}\n\nfunction julianDayToIslamic(calendar: Calendar, epoch: number, jd: number) {\n let year = Math.floor((30 * (jd - epoch) + 10646) / 10631);\n let month = Math.min(\n 12,\n Math.ceil((jd - (29 + islamicToJulianDay(epoch, year, 1, 1))) / 29.5) + 1\n );\n let day = jd - islamicToJulianDay(epoch, year, month, 1) + 1;\n\n return new CalendarDate(calendar, year, month, day);\n}\n\nfunction isLeapYear(year: number): boolean {\n return (14 + 11 * year) % 30 < 11;\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The civil variant uses simple arithmetic rules rather than astronomical calculations to\n * approximate the traditional calendar, which is based on sighting of the crescent moon. It uses\n * Friday, July 16 622 CE (Julian) as the epoch. Each year has 12 months, with either 354 or 355\n * days depending on whether it is a leap year. Learn more about the available Islamic calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicCivilCalendar implements Calendar {\n identifier: CalendarIdentifier = 'islamic-civil';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, CIVIL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n let length = 29 + (date.month % 2);\n if (date.month === 12 && isLeapYear(date.year)) {\n length++;\n }\n\n return length;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 355 : 354;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 30;\n }\n\n getYearsInEra(): number {\n // 9999 gregorian\n return 9665;\n }\n\n getEras(): string[] {\n return ['AH'];\n }\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The tabular variant uses simple arithmetic rules rather than astronomical calculations to\n * approximate the traditional calendar, which is based on sighting of the crescent moon. It uses\n * Thursday, July 15 622 CE (Julian) as the epoch. Each year has 12 months, with either 354 or 355\n * days depending on whether it is a leap year. Learn more about the available Islamic calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicTabularCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-tbla';\n\n fromJulianDay(jd: number): CalendarDate {\n return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);\n }\n}\n\n// Generated by scripts/generate-umalqura.js\nconst UMALQURA_DATA =\n 'qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=';\nlet UMALQURA_MONTHLENGTH: Uint16Array;\nlet UMALQURA_YEAR_START_TABLE: Uint32Array;\n\nfunction umalquraYearStart(year: number): number {\n return UMALQURA_START_DAYS + UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START];\n}\n\nfunction umalquraMonthLength(year: number, month: number): number {\n let idx = year - UMALQURA_YEAR_START;\n let mask = 0x01 << (11 - (month - 1));\n if ((UMALQURA_MONTHLENGTH[idx] & mask) === 0) {\n return 29;\n } else {\n return 30;\n }\n}\n\nfunction umalquraMonthStart(year: number, month: number): number {\n let day = umalquraYearStart(year);\n for (let i = 1; i < month; i++) {\n day += umalquraMonthLength(year, i);\n }\n return day;\n}\n\nfunction umalquraYearLength(year: number): number {\n return (\n UMALQURA_YEAR_START_TABLE[year + 1 - UMALQURA_YEAR_START] -\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START]\n );\n}\n\n/**\n * The Islamic calendar, also known as the \"Hijri\" calendar, is used throughout much of the Arab\n * world. The Umalqura variant is primarily used in Saudi Arabia. It is a lunar calendar, based on\n * astronomical calculations that predict the sighting of a crescent moon. Month and year lengths\n * vary between years depending on these calculations. Learn more about the available Islamic\n * calendars\n * [here](https://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types).\n */\nexport class IslamicUmalquraCalendar extends IslamicCivilCalendar {\n identifier: CalendarIdentifier = 'islamic-umalqura';\n\n constructor() {\n super();\n if (!UMALQURA_MONTHLENGTH) {\n UMALQURA_MONTHLENGTH = new Uint16Array(\n Uint8Array.from(atob(UMALQURA_DATA), c => c.charCodeAt(0)).buffer\n );\n }\n\n if (!UMALQURA_YEAR_START_TABLE) {\n UMALQURA_YEAR_START_TABLE = new Uint32Array(UMALQURA_YEAR_END - UMALQURA_YEAR_START + 1);\n\n let yearStart = 0;\n for (let year = UMALQURA_YEAR_START; year <= UMALQURA_YEAR_END; year++) {\n UMALQURA_YEAR_START_TABLE[year - UMALQURA_YEAR_START] = yearStart;\n for (let i = 1; i <= 12; i++) {\n yearStart += umalquraMonthLength(year, i);\n }\n }\n }\n }\n\n fromJulianDay(jd: number): CalendarDate {\n let days = jd - CIVIL_EPOC;\n let startDays = umalquraYearStart(UMALQURA_YEAR_START);\n let endDays = umalquraYearStart(UMALQURA_YEAR_END);\n if (days < startDays || days > endDays) {\n return super.fromJulianDay(jd);\n } else {\n let y = UMALQURA_YEAR_START - 1;\n let m = 1;\n let d = 1;\n while (d > 0) {\n y++;\n d = days - umalquraYearStart(y) + 1;\n let yearLength = umalquraYearLength(y);\n if (d === yearLength) {\n m = 12;\n break;\n } else if (d < yearLength) {\n let monthLength = umalquraMonthLength(y, m);\n m = 1;\n while (d > monthLength) {\n d -= monthLength;\n m++;\n monthLength = umalquraMonthLength(y, m);\n }\n break;\n }\n }\n\n return new CalendarDate(this, y, m, days - umalquraMonthStart(y, m) + 1);\n }\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.toJulianDay(date);\n }\n\n return CIVIL_EPOC + umalquraMonthStart(date.year, date.month) + (date.day - 1);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInMonth(date);\n }\n\n return umalquraMonthLength(date.year, date.month);\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n if (date.year < UMALQURA_YEAR_START || date.year > UMALQURA_YEAR_END) {\n return super.getDaysInYear(date);\n }\n\n return umalquraYearLength(date.year);\n }\n}\n"],"names":[],"version":3,"file":"IslamicCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..ecab978aa778c2c7df5b10625ab1319a2d270031 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.cjs @@ -0,0 +1,179 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $05031860ba2f881f$exports = require("./GregorianCalendar.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "JapaneseCalendar", function () { return $a90e2192fa9a0f41$export$b746ab2b60cdffbf; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from the TC39 Temporal proposal. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $a90e2192fa9a0f41$var$ERA_START_DATES = [ + [ + 1868, + 9, + 8 + ], + [ + 1912, + 7, + 30 + ], + [ + 1926, + 12, + 25 + ], + [ + 1989, + 1, + 8 + ], + [ + 2019, + 5, + 1 + ] +]; +const $a90e2192fa9a0f41$var$ERA_END_DATES = [ + [ + 1912, + 7, + 29 + ], + [ + 1926, + 12, + 24 + ], + [ + 1989, + 1, + 7 + ], + [ + 2019, + 4, + 30 + ] +]; +const $a90e2192fa9a0f41$var$ERA_ADDENDS = [ + 1867, + 1911, + 1925, + 1988, + 2018 +]; +const $a90e2192fa9a0f41$var$ERA_NAMES = [ + 'meiji', + 'taisho', + 'showa', + 'heisei', + 'reiwa' +]; +function $a90e2192fa9a0f41$var$findEraFromGregorianDate(date) { + const idx = $a90e2192fa9a0f41$var$ERA_START_DATES.findIndex(([year, month, day])=>{ + if (date.year < year) return true; + if (date.year === year && date.month < month) return true; + if (date.year === year && date.month === month && date.day < day) return true; + return false; + }); + if (idx === -1) return $a90e2192fa9a0f41$var$ERA_START_DATES.length - 1; + if (idx === 0) return 0; + return idx - 1; +} +function $a90e2192fa9a0f41$var$toGregorian(date) { + let eraAddend = $a90e2192fa9a0f41$var$ERA_ADDENDS[$a90e2192fa9a0f41$var$ERA_NAMES.indexOf(date.era)]; + if (!eraAddend) throw new Error('Unknown era: ' + date.era); + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(date.year + eraAddend, date.month, date.day); +} +class $a90e2192fa9a0f41$export$b746ab2b60cdffbf extends (0, $05031860ba2f881f$exports.GregorianCalendar) { + fromJulianDay(jd) { + let date = super.fromJulianDay(jd); + let era = $a90e2192fa9a0f41$var$findEraFromGregorianDate(date); + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, $a90e2192fa9a0f41$var$ERA_NAMES[era], date.year - $a90e2192fa9a0f41$var$ERA_ADDENDS[era], date.month, date.day); + } + toJulianDay(date) { + return super.toJulianDay($a90e2192fa9a0f41$var$toGregorian(date)); + } + balanceDate(date) { + let gregorianDate = $a90e2192fa9a0f41$var$toGregorian(date); + let era = $a90e2192fa9a0f41$var$findEraFromGregorianDate(gregorianDate); + if ($a90e2192fa9a0f41$var$ERA_NAMES[era] !== date.era) { + date.era = $a90e2192fa9a0f41$var$ERA_NAMES[era]; + date.year = gregorianDate.year - $a90e2192fa9a0f41$var$ERA_ADDENDS[era]; + } + // Constrain in case we went before the first supported era. + this.constrainDate(date); + } + constrainDate(date) { + let idx = $a90e2192fa9a0f41$var$ERA_NAMES.indexOf(date.era); + let end = $a90e2192fa9a0f41$var$ERA_END_DATES[idx]; + if (end != null) { + let [endYear, endMonth, endDay] = end; + // Constrain the year to the maximum possible value in the era. + // Then constrain the month and day fields within that. + let maxYear = endYear - $a90e2192fa9a0f41$var$ERA_ADDENDS[idx]; + date.year = Math.max(1, Math.min(maxYear, date.year)); + if (date.year === maxYear) { + date.month = Math.min(endMonth, date.month); + if (date.month === endMonth) date.day = Math.min(endDay, date.day); + } + } + if (date.year === 1 && idx >= 0) { + let [, startMonth, startDay] = $a90e2192fa9a0f41$var$ERA_START_DATES[idx]; + date.month = Math.max(startMonth, date.month); + if (date.month === startMonth) date.day = Math.max(startDay, date.day); + } + } + getEras() { + return $a90e2192fa9a0f41$var$ERA_NAMES; + } + getYearsInEra(date) { + // Get the number of years in the era, taking into account the date's month and day fields. + let era = $a90e2192fa9a0f41$var$ERA_NAMES.indexOf(date.era); + let cur = $a90e2192fa9a0f41$var$ERA_START_DATES[era]; + let next = $a90e2192fa9a0f41$var$ERA_START_DATES[era + 1]; + if (next == null) // 9999 gregorian is the maximum year allowed. + return 9999 - cur[0] + 1; + let years = next[0] - cur[0]; + if (date.month < next[1] || date.month === next[1] && date.day < next[2]) years++; + return years; + } + getDaysInMonth(date) { + return super.getDaysInMonth($a90e2192fa9a0f41$var$toGregorian(date)); + } + getMinimumMonthInYear(date) { + let start = $a90e2192fa9a0f41$var$getMinimums(date); + return start ? start[1] : 1; + } + getMinimumDayInMonth(date) { + let start = $a90e2192fa9a0f41$var$getMinimums(date); + return start && date.month === start[1] ? start[2] : 1; + } + constructor(...args){ + super(...args), this.identifier = 'japanese'; + } +} +function $a90e2192fa9a0f41$var$getMinimums(date) { + if (date.year === 1) { + let idx = $a90e2192fa9a0f41$var$ERA_NAMES.indexOf(date.era); + return $a90e2192fa9a0f41$var$ERA_START_DATES[idx]; + } +} + + +//# sourceMappingURL=JapaneseCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..c3bbf950b1c0a39435e6ade171844ee4b29bbfe6 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IACtB;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAG;IACb;QAAC;QAAM;QAAI;KAAG;IACd;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAE;CACb;AACD,MAAM,sCAAgB;IACpB;QAAC;QAAM;QAAG;KAAG;IACb;QAAC;QAAM;QAAI;KAAG;IACd;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAG;CACd;AACD,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACvD,IAA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CAAC,EAAE,IAAI,KAAK,GAAG,GAAG,IAAI,CAAC,EAAE,EACvE;QAGF,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,sBAAsB,IAAqB,EAAU;QACnD,IAAI,QAAQ,kCAAY;QACxB,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG;IAC5B;IAEA,qBAAqB,IAAqB,EAAU;QAClD,IAAI,QAAQ,kCAAY;QACxB,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG;IACvD;;QAjGK,qBACL,aAAiC;;AAiGnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [\n [1868, 9, 8],\n [1912, 7, 30],\n [1926, 12, 25],\n [1989, 1, 8],\n [2019, 5, 1]\n];\nconst ERA_END_DATES = [\n [1912, 7, 29],\n [1926, 12, 24],\n [1989, 1, 7],\n [2019, 4, 30]\n];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(date.year + eraAddend, date.month, date.day);\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each\n * Japanese emperor. Whenever a new emperor ascends to the throne, a new era begins and the year\n * starts again from 1. Note that eras before 1868 (Gregorian) are not currently supported by this\n * implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable): void {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable): void {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras(): string[] {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..98ee80acb9854fd3de8117b13937064a7e45abeb --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.js @@ -0,0 +1,174 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./GregorianCalendar.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from the TC39 Temporal proposal. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $97f08bcb2befa667$var$ERA_START_DATES = [ + [ + 1868, + 9, + 8 + ], + [ + 1912, + 7, + 30 + ], + [ + 1926, + 12, + 25 + ], + [ + 1989, + 1, + 8 + ], + [ + 2019, + 5, + 1 + ] +]; +const $97f08bcb2befa667$var$ERA_END_DATES = [ + [ + 1912, + 7, + 29 + ], + [ + 1926, + 12, + 24 + ], + [ + 1989, + 1, + 7 + ], + [ + 2019, + 4, + 30 + ] +]; +const $97f08bcb2befa667$var$ERA_ADDENDS = [ + 1867, + 1911, + 1925, + 1988, + 2018 +]; +const $97f08bcb2befa667$var$ERA_NAMES = [ + 'meiji', + 'taisho', + 'showa', + 'heisei', + 'reiwa' +]; +function $97f08bcb2befa667$var$findEraFromGregorianDate(date) { + const idx = $97f08bcb2befa667$var$ERA_START_DATES.findIndex(([year, month, day])=>{ + if (date.year < year) return true; + if (date.year === year && date.month < month) return true; + if (date.year === year && date.month === month && date.day < day) return true; + return false; + }); + if (idx === -1) return $97f08bcb2befa667$var$ERA_START_DATES.length - 1; + if (idx === 0) return 0; + return idx - 1; +} +function $97f08bcb2befa667$var$toGregorian(date) { + let eraAddend = $97f08bcb2befa667$var$ERA_ADDENDS[$97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era)]; + if (!eraAddend) throw new Error('Unknown era: ' + date.era); + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(date.year + eraAddend, date.month, date.day); +} +class $97f08bcb2befa667$export$b746ab2b60cdffbf extends (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + let date = super.fromJulianDay(jd); + let era = $97f08bcb2befa667$var$findEraFromGregorianDate(date); + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, $97f08bcb2befa667$var$ERA_NAMES[era], date.year - $97f08bcb2befa667$var$ERA_ADDENDS[era], date.month, date.day); + } + toJulianDay(date) { + return super.toJulianDay($97f08bcb2befa667$var$toGregorian(date)); + } + balanceDate(date) { + let gregorianDate = $97f08bcb2befa667$var$toGregorian(date); + let era = $97f08bcb2befa667$var$findEraFromGregorianDate(gregorianDate); + if ($97f08bcb2befa667$var$ERA_NAMES[era] !== date.era) { + date.era = $97f08bcb2befa667$var$ERA_NAMES[era]; + date.year = gregorianDate.year - $97f08bcb2befa667$var$ERA_ADDENDS[era]; + } + // Constrain in case we went before the first supported era. + this.constrainDate(date); + } + constrainDate(date) { + let idx = $97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era); + let end = $97f08bcb2befa667$var$ERA_END_DATES[idx]; + if (end != null) { + let [endYear, endMonth, endDay] = end; + // Constrain the year to the maximum possible value in the era. + // Then constrain the month and day fields within that. + let maxYear = endYear - $97f08bcb2befa667$var$ERA_ADDENDS[idx]; + date.year = Math.max(1, Math.min(maxYear, date.year)); + if (date.year === maxYear) { + date.month = Math.min(endMonth, date.month); + if (date.month === endMonth) date.day = Math.min(endDay, date.day); + } + } + if (date.year === 1 && idx >= 0) { + let [, startMonth, startDay] = $97f08bcb2befa667$var$ERA_START_DATES[idx]; + date.month = Math.max(startMonth, date.month); + if (date.month === startMonth) date.day = Math.max(startDay, date.day); + } + } + getEras() { + return $97f08bcb2befa667$var$ERA_NAMES; + } + getYearsInEra(date) { + // Get the number of years in the era, taking into account the date's month and day fields. + let era = $97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era); + let cur = $97f08bcb2befa667$var$ERA_START_DATES[era]; + let next = $97f08bcb2befa667$var$ERA_START_DATES[era + 1]; + if (next == null) // 9999 gregorian is the maximum year allowed. + return 9999 - cur[0] + 1; + let years = next[0] - cur[0]; + if (date.month < next[1] || date.month === next[1] && date.day < next[2]) years++; + return years; + } + getDaysInMonth(date) { + return super.getDaysInMonth($97f08bcb2befa667$var$toGregorian(date)); + } + getMinimumMonthInYear(date) { + let start = $97f08bcb2befa667$var$getMinimums(date); + return start ? start[1] : 1; + } + getMinimumDayInMonth(date) { + let start = $97f08bcb2befa667$var$getMinimums(date); + return start && date.month === start[1] ? start[2] : 1; + } + constructor(...args){ + super(...args), this.identifier = 'japanese'; + } +} +function $97f08bcb2befa667$var$getMinimums(date) { + if (date.year === 1) { + let idx = $97f08bcb2befa667$var$ERA_NAMES.indexOf(date.era); + return $97f08bcb2befa667$var$ERA_START_DATES[idx]; + } +} + + +export {$97f08bcb2befa667$export$b746ab2b60cdffbf as JapaneseCalendar}; +//# sourceMappingURL=JapaneseCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6798a27eda50f5e7e9e8d2dd809cd33ec66e5065 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IACtB;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAG;IACb;QAAC;QAAM;QAAI;KAAG;IACd;QAAC;QAAM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QAClB,OAAO;IACT;IAEA,cAAc,IAAqB,EAAU;QAC3C,2FAA2F;QAC3F,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,IAAI,MAAM,qCAAe,CAAC,IAAI;QAC9B,IAAI,OAAO,qCAAe,CAAC,MAAM,EAAE;QACnC,IAAI,QAAQ,MACV,8CAA8C;QAC9C,OAAO,OAAO,GAAG,CAAC,EAAE,GAAG;QAGzB,IAAI,QAAQ,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE;QAE5B,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC,EAAE,IAAK,KAAK,KAAK,KAAK,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,GAAG,IAAI,CAAC,EAAE,EACvE;QAGF,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,sBAAsB,IAAqB,EAAU;QACnD,IAAI,QAAQ,kCAAY;QACxB,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG;IAC5B;IAEA,qBAAqB,IAAqB,EAAU;QAClD,IAAI,QAAQ,kCAAY;QACxB,OAAO,SAAS,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG;IACvD;;QAjGK,qBACL,aAAiC;;AAiGnC;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [\n [1868, 9, 8],\n [1912, 7, 30],\n [1926, 12, 25],\n [1989, 1, 8],\n [2019, 5, 1]\n];\nconst ERA_END_DATES = [\n [1912, 7, 29],\n [1926, 12, 24],\n [1989, 1, 7],\n [2019, 4, 30]\n];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(date.year + eraAddend, date.month, date.day);\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each\n * Japanese emperor. Whenever a new emperor ascends to the throne, a new era begins and the year\n * starts again from 1. Note that eras before 1868 (Gregorian) are not currently supported by this\n * implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable): void {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable): void {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras(): string[] {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0a16efaf0066f409d3f61dc5a18ccb2525817048 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.mjs @@ -0,0 +1,174 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from the TC39 Temporal proposal. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $34b940b49ba042df$var$ERA_START_DATES = [ + [ + 1868, + 9, + 8 + ], + [ + 1912, + 7, + 30 + ], + [ + 1926, + 12, + 25 + ], + [ + 1989, + 1, + 8 + ], + [ + 2019, + 5, + 1 + ] +]; +const $34b940b49ba042df$var$ERA_END_DATES = [ + [ + 1912, + 7, + 29 + ], + [ + 1926, + 12, + 24 + ], + [ + 1989, + 1, + 7 + ], + [ + 2019, + 4, + 30 + ] +]; +const $34b940b49ba042df$var$ERA_ADDENDS = [ + 1867, + 1911, + 1925, + 1988, + 2018 +]; +const $34b940b49ba042df$var$ERA_NAMES = [ + 'meiji', + 'taisho', + 'showa', + 'heisei', + 'reiwa' +]; +function $34b940b49ba042df$var$findEraFromGregorianDate(date) { + const idx = $34b940b49ba042df$var$ERA_START_DATES.findIndex(([year, month, day])=>{ + if (date.year < year) return true; + if (date.year === year && date.month < month) return true; + if (date.year === year && date.month === month && date.day < day) return true; + return false; + }); + if (idx === -1) return $34b940b49ba042df$var$ERA_START_DATES.length - 1; + if (idx === 0) return 0; + return idx - 1; +} +function $34b940b49ba042df$var$toGregorian(date) { + let eraAddend = $34b940b49ba042df$var$ERA_ADDENDS[$34b940b49ba042df$var$ERA_NAMES.indexOf(date.era)]; + if (!eraAddend) throw new Error('Unknown era: ' + date.era); + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(date.year + eraAddend, date.month, date.day); +} +class $34b940b49ba042df$export$b746ab2b60cdffbf extends (0, $93635573935797de$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + let date = super.fromJulianDay(jd); + let era = $34b940b49ba042df$var$findEraFromGregorianDate(date); + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, $34b940b49ba042df$var$ERA_NAMES[era], date.year - $34b940b49ba042df$var$ERA_ADDENDS[era], date.month, date.day); + } + toJulianDay(date) { + return super.toJulianDay($34b940b49ba042df$var$toGregorian(date)); + } + balanceDate(date) { + let gregorianDate = $34b940b49ba042df$var$toGregorian(date); + let era = $34b940b49ba042df$var$findEraFromGregorianDate(gregorianDate); + if ($34b940b49ba042df$var$ERA_NAMES[era] !== date.era) { + date.era = $34b940b49ba042df$var$ERA_NAMES[era]; + date.year = gregorianDate.year - $34b940b49ba042df$var$ERA_ADDENDS[era]; + } + // Constrain in case we went before the first supported era. + this.constrainDate(date); + } + constrainDate(date) { + let idx = $34b940b49ba042df$var$ERA_NAMES.indexOf(date.era); + let end = $34b940b49ba042df$var$ERA_END_DATES[idx]; + if (end != null) { + let [endYear, endMonth, endDay] = end; + // Constrain the year to the maximum possible value in the era. + // Then constrain the month and day fields within that. + let maxYear = endYear - $34b940b49ba042df$var$ERA_ADDENDS[idx]; + date.year = Math.max(1, Math.min(maxYear, date.year)); + if (date.year === maxYear) { + date.month = Math.min(endMonth, date.month); + if (date.month === endMonth) date.day = Math.min(endDay, date.day); + } + } + if (date.year === 1 && idx >= 0) { + let [, startMonth, startDay] = $34b940b49ba042df$var$ERA_START_DATES[idx]; + date.month = Math.max(startMonth, date.month); + if (date.month === startMonth) date.day = Math.max(startDay, date.day); + } + } + getEras() { + return $34b940b49ba042df$var$ERA_NAMES; + } + getYearsInEra(date) { + // Get the number of years in the era, taking into account the date's month and day fields. + let era = $34b940b49ba042df$var$ERA_NAMES.indexOf(date.era); + let cur = $34b940b49ba042df$var$ERA_START_DATES[era]; + let next = $34b940b49ba042df$var$ERA_START_DATES[era + 1]; + if (next == null) // 9999 gregorian is the maximum year allowed. + return 9999 - cur[0] + 1; + let years = next[0] - cur[0]; + if (date.month < next[1] || date.month === next[1] && date.day < next[2]) years++; + return years; + } + getDaysInMonth(date) { + return super.getDaysInMonth($34b940b49ba042df$var$toGregorian(date)); + } + getMinimumMonthInYear(date) { + let start = $34b940b49ba042df$var$getMinimums(date); + return start ? start[1] : 1; + } + getMinimumDayInMonth(date) { + let start = $34b940b49ba042df$var$getMinimums(date); + return start && date.month === start[1] ? start[2] : 1; + } + constructor(...args){ + super(...args), this.identifier = 'japanese'; + } +} +function $34b940b49ba042df$var$getMinimums(date) { + if (date.year === 1) { + let idx = $34b940b49ba042df$var$ERA_NAMES.indexOf(date.era); + return $34b940b49ba042df$var$ERA_START_DATES[idx]; + } +} + + +export {$34b940b49ba042df$export$b746ab2b60cdffbf as JapaneseCalendar}; +//# sourceMappingURL=JapaneseCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..1460403c74bc252de85d477a172b0cd54a0e445e --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/JapaneseCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;AAOhG,MAAM,wCAAkB;IACtB;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAG;IACb;QAAC;QAAM;QAAI;KAAG;IACd;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAE;CACb;AACD,MAAM,sCAAgB;IACpB;QAAC;QAAM;QAAG;KAAG;IACb;QAAC;QAAM;QAAI;KAAG;IACd;QAAC;QAAM;QAAG;KAAE;IACZ;QAAC;QAAM;QAAG;KAAG;CACd;AACD,MAAM,oCAAc;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAClD,MAAM,kCAAY;IAAC;IAAS;IAAU;IAAS;IAAU;CAAQ;AAEjE,SAAS,+CAAyB,IAAqB;IACrD,MAAM,MAAM,sCAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI;QACvD,IAAI,KAAK,IAAI,GAAG,MACd,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK,GAAG,OACrC,OAAO;QAGT,IAAI,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK,KAAK,SAAS,KAAK,GAAG,GAAG,KAC3D,OAAO;QAGT,OAAO;IACT;IAEA,IAAI,QAAQ,IACV,OAAO,sCAAgB,MAAM,GAAG;IAGlC,IAAI,QAAQ,GACV,OAAO;IAGT,OAAO,MAAM;AACf;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,YAAY,iCAAW,CAAC,gCAAU,OAAO,CAAC,KAAK,GAAG,EAAE;IACxD,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,kBAAkB,KA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,IAAI,KAAK,IAAI,KAAK,GAAG;QACnB,IAAI,MAAM,gCAAU,OAAO,CAAC,KAAK,GAAG;QACpC,OAAO,qCAAe,CAAC,IAAI;IAC7B;AACF","sources":["packages/@internationalized/date/src/calendars/JapaneseCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst ERA_START_DATES = [\n [1868, 9, 8],\n [1912, 7, 30],\n [1926, 12, 25],\n [1989, 1, 8],\n [2019, 5, 1]\n];\nconst ERA_END_DATES = [\n [1912, 7, 29],\n [1926, 12, 24],\n [1989, 1, 7],\n [2019, 4, 30]\n];\nconst ERA_ADDENDS = [1867, 1911, 1925, 1988, 2018];\nconst ERA_NAMES = ['meiji', 'taisho', 'showa', 'heisei', 'reiwa'];\n\nfunction findEraFromGregorianDate(date: AnyCalendarDate) {\n const idx = ERA_START_DATES.findIndex(([year, month, day]) => {\n if (date.year < year) {\n return true;\n }\n\n if (date.year === year && date.month < month) {\n return true;\n }\n\n if (date.year === year && date.month === month && date.day < day) {\n return true;\n }\n\n return false;\n });\n\n if (idx === -1) {\n return ERA_START_DATES.length - 1;\n }\n\n if (idx === 0) {\n return 0;\n }\n\n return idx - 1;\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let eraAddend = ERA_ADDENDS[ERA_NAMES.indexOf(date.era)];\n if (!eraAddend) {\n throw new Error('Unknown era: ' + date.era);\n }\n\n return new CalendarDate(date.year + eraAddend, date.month, date.day);\n}\n\n/**\n * The Japanese calendar is based on the Gregorian calendar, but with eras for the reign of each\n * Japanese emperor. Whenever a new emperor ascends to the throne, a new era begins and the year\n * starts again from 1. Note that eras before 1868 (Gregorian) are not currently supported by this\n * implementation.\n */\nexport class JapaneseCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'japanese';\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let era = findEraFromGregorianDate(date);\n\n return new CalendarDate(\n this,\n ERA_NAMES[era],\n date.year - ERA_ADDENDS[era],\n date.month,\n date.day\n );\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n balanceDate(date: Mutable): void {\n let gregorianDate = toGregorian(date);\n let era = findEraFromGregorianDate(gregorianDate);\n\n if (ERA_NAMES[era] !== date.era) {\n date.era = ERA_NAMES[era];\n date.year = gregorianDate.year - ERA_ADDENDS[era];\n }\n\n // Constrain in case we went before the first supported era.\n this.constrainDate(date);\n }\n\n constrainDate(date: Mutable): void {\n let idx = ERA_NAMES.indexOf(date.era);\n let end = ERA_END_DATES[idx];\n if (end != null) {\n let [endYear, endMonth, endDay] = end;\n\n // Constrain the year to the maximum possible value in the era.\n // Then constrain the month and day fields within that.\n let maxYear = endYear - ERA_ADDENDS[idx];\n date.year = Math.max(1, Math.min(maxYear, date.year));\n if (date.year === maxYear) {\n date.month = Math.min(endMonth, date.month);\n\n if (date.month === endMonth) {\n date.day = Math.min(endDay, date.day);\n }\n }\n }\n\n if (date.year === 1 && idx >= 0) {\n let [, startMonth, startDay] = ERA_START_DATES[idx];\n date.month = Math.max(startMonth, date.month);\n\n if (date.month === startMonth) {\n date.day = Math.max(startDay, date.day);\n }\n }\n }\n\n getEras(): string[] {\n return ERA_NAMES;\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n // Get the number of years in the era, taking into account the date's month and day fields.\n let era = ERA_NAMES.indexOf(date.era);\n let cur = ERA_START_DATES[era];\n let next = ERA_START_DATES[era + 1];\n if (next == null) {\n // 9999 gregorian is the maximum year allowed.\n return 9999 - cur[0] + 1;\n }\n\n let years = next[0] - cur[0];\n\n if (date.month < next[1] || (date.month === next[1] && date.day < next[2])) {\n years++;\n }\n\n return years;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getMinimumMonthInYear(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start ? start[1] : 1;\n }\n\n getMinimumDayInMonth(date: AnyCalendarDate): number {\n let start = getMinimums(date);\n return start && date.month === start[1] ? start[2] : 1;\n }\n}\n\nfunction getMinimums(date: AnyCalendarDate) {\n if (date.year === 1) {\n let idx = ERA_NAMES.indexOf(date.era);\n return ERA_START_DATES[idx];\n }\n}\n"],"names":[],"version":3,"file":"JapaneseCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..fbe30e32ed845d25871aa2c0d89c83696d91202f --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.cjs @@ -0,0 +1,87 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $09f945753a699862$exports = require("../utils.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "PersianCalendar", function () { return $4100faec94dc031c$export$37fccdbfd14c5939; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $4100faec94dc031c$var$PERSIAN_EPOCH = 1948320; +// Number of days from the start of the year to the start of each month. +const $4100faec94dc031c$var$MONTH_START = [ + 0, + 31, + 62, + 93, + 124, + 155, + 186, + 216, + 246, + 276, + 306, + 336 // Esfand +]; +class $4100faec94dc031c$export$37fccdbfd14c5939 { + fromJulianDay(jd) { + let daysSinceEpoch = jd - $4100faec94dc031c$var$PERSIAN_EPOCH; + let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053); + let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33); + let dayOfYear = daysSinceEpoch - farvardin1; + let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30); + let day = dayOfYear - $4100faec94dc031c$var$MONTH_START[month] + 1; + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, year, month + 1, day); + } + toJulianDay(date) { + let jd = $4100faec94dc031c$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33); + jd += $4100faec94dc031c$var$MONTH_START[date.month - 1]; + jd += date.day; + return jd; + } + getMonthsInYear() { + return 12; + } + getDaysInMonth(date) { + if (date.month <= 6) return 31; + if (date.month <= 11) return 30; + let isLeapYear = (0, $09f945753a699862$exports.mod)(25 * date.year + 11, 33) < 8; + return isLeapYear ? 30 : 29; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 31; + } + getEras() { + return [ + 'AP' + ]; + } + getYearsInEra() { + // 9378-10-10 persian is 9999-12-31 gregorian. + // Round down to 9377 to set the maximum full year. + return 9377; + } + constructor(){ + this.identifier = 'persian'; + } +} + + +//# sourceMappingURL=PersianCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..f979ef4562dbd7508100310a1015b4f331136778 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS;CACd;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MAAM,KAAK,KAAK,CAAC,YAAY,MAAM,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACxF,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,6BAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aApDA,aAAiC;;AAqDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..00730c430c3af54e9441ec527fc8637500ec681a --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.js @@ -0,0 +1,82 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {mod as $1797f75f9a4d3bd4$export$842a2cf37af977e1} from "../utils.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $3e485caf6e85028a$var$PERSIAN_EPOCH = 1948320; +// Number of days from the start of the year to the start of each month. +const $3e485caf6e85028a$var$MONTH_START = [ + 0, + 31, + 62, + 93, + 124, + 155, + 186, + 216, + 246, + 276, + 306, + 336 // Esfand +]; +class $3e485caf6e85028a$export$37fccdbfd14c5939 { + fromJulianDay(jd) { + let daysSinceEpoch = jd - $3e485caf6e85028a$var$PERSIAN_EPOCH; + let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053); + let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33); + let dayOfYear = daysSinceEpoch - farvardin1; + let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30); + let day = dayOfYear - $3e485caf6e85028a$var$MONTH_START[month] + 1; + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, year, month + 1, day); + } + toJulianDay(date) { + let jd = $3e485caf6e85028a$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33); + jd += $3e485caf6e85028a$var$MONTH_START[date.month - 1]; + jd += date.day; + return jd; + } + getMonthsInYear() { + return 12; + } + getDaysInMonth(date) { + if (date.month <= 6) return 31; + if (date.month <= 11) return 30; + let isLeapYear = (0, $1797f75f9a4d3bd4$export$842a2cf37af977e1)(25 * date.year + 11, 33) < 8; + return isLeapYear ? 30 : 29; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 31; + } + getEras() { + return [ + 'AP' + ]; + } + getYearsInEra() { + // 9378-10-10 persian is 9999-12-31 gregorian. + // Round down to 9377 to set the maximum full year. + return 9377; + } + constructor(){ + this.identifier = 'persian'; + } +} + + +export {$3e485caf6e85028a$export$37fccdbfd14c5939 as PersianCalendar}; +//# sourceMappingURL=PersianCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..74c402540925a98d1b3a721903d3b3ec7f216db8 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS;CACd;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MAAM,KAAK,KAAK,CAAC,YAAY,MAAM,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACxF,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,yCAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aApDA,aAAiC;;AAqDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d930928fab7697b995071e50f9f12965f9f96261 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.mjs @@ -0,0 +1,82 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {mod as $09ec6a572d60460f$export$842a2cf37af977e1} from "../utils.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $a0cc0739a536c3b1$var$PERSIAN_EPOCH = 1948320; +// Number of days from the start of the year to the start of each month. +const $a0cc0739a536c3b1$var$MONTH_START = [ + 0, + 31, + 62, + 93, + 124, + 155, + 186, + 216, + 246, + 276, + 306, + 336 // Esfand +]; +class $a0cc0739a536c3b1$export$37fccdbfd14c5939 { + fromJulianDay(jd) { + let daysSinceEpoch = jd - $a0cc0739a536c3b1$var$PERSIAN_EPOCH; + let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053); + let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33); + let dayOfYear = daysSinceEpoch - farvardin1; + let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30); + let day = dayOfYear - $a0cc0739a536c3b1$var$MONTH_START[month] + 1; + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, year, month + 1, day); + } + toJulianDay(date) { + let jd = $a0cc0739a536c3b1$var$PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33); + jd += $a0cc0739a536c3b1$var$MONTH_START[date.month - 1]; + jd += date.day; + return jd; + } + getMonthsInYear() { + return 12; + } + getDaysInMonth(date) { + if (date.month <= 6) return 31; + if (date.month <= 11) return 30; + let isLeapYear = (0, $09ec6a572d60460f$export$842a2cf37af977e1)(25 * date.year + 11, 33) < 8; + return isLeapYear ? 30 : 29; + } + getMaximumMonthsInYear() { + return 12; + } + getMaximumDaysInMonth() { + return 31; + } + getEras() { + return [ + 'AP' + ]; + } + getYearsInEra() { + // 9378-10-10 persian is 9999-12-31 gregorian. + // Round down to 9377 to set the maximum full year. + return 9377; + } + constructor(){ + this.identifier = 'persian'; + } +} + + +export {$a0cc0739a536c3b1$export$37fccdbfd14c5939 as PersianCalendar}; +//# sourceMappingURL=PersianCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..4937715931cbaadca2db8aabe3be6ec6b0dbe71f --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/PersianCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,sCAAgB;AAEtB,wEAAwE;AACxE,MAAM,oCAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS;CACd;AAQM,MAAM;IAGX,cAAc,EAAU,EAAgB;QACtC,IAAI,iBAAiB,KAAK;QAC1B,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,AAAC,CAAA,KAAK,iBAAiB,CAAA,IAAK;QACtD,IAAI,aAAa,MAAO,CAAA,OAAO,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,OAAO,EAAC,IAAK;QACjE,IAAI,YAAY,iBAAiB;QACjC,IAAI,QAAQ,YAAY,MAAM,KAAK,KAAK,CAAC,YAAY,MAAM,KAAK,KAAK,CAAC,AAAC,CAAA,YAAY,CAAA,IAAK;QACxF,IAAI,MAAM,YAAY,iCAAW,CAAC,MAAM,GAAG;QAC3C,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,MAAM,QAAQ,GAAG;IACjD;IAEA,YAAY,IAAqB,EAAU;QACzC,IAAI,KAAK,sCAAgB,IAAI,MAAO,CAAA,KAAK,IAAI,GAAG,CAAA,IAAK,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,KAAK,IAAI,GAAG,EAAC,IAAK;QACvF,MAAM,iCAAW,CAAC,KAAK,KAAK,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG;QACd,OAAO;IACT;IAEA,kBAA0B;QACxB,OAAO;IACT;IAEA,eAAe,IAAqB,EAAU;QAC5C,IAAI,KAAK,KAAK,IAAI,GAChB,OAAO;QAGT,IAAI,KAAK,KAAK,IAAI,IAChB,OAAO;QAGT,IAAI,aAAa,CAAA,GAAA,yCAAE,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM;QAChD,OAAO,aAAa,KAAK;IAC3B;IAEA,yBAAiC;QAC/B,OAAO;IACT;IAEA,wBAAgC;QAC9B,OAAO;IACT;IAEA,UAAoB;QAClB,OAAO;YAAC;SAAK;IACf;IAEA,gBAAwB;QACtB,8CAA8C;QAC9C,mDAAmD;QACnD,OAAO;IACT;;aApDA,aAAiC;;AAqDnC","sources":["packages/@internationalized/date/src/calendars/PersianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod} from '../utils';\n\nconst PERSIAN_EPOCH = 1948320;\n\n// Number of days from the start of the year to the start of each month.\nconst MONTH_START = [\n 0, // Farvardin\n 31, // Ordibehesht\n 62, // Khordad\n 93, // Tir\n 124, // Mordad\n 155, // Shahrivar\n 186, // Mehr\n 216, // Aban\n 246, // Azar\n 276, // Dey\n 306, // Bahman\n 336 // Esfand\n];\n\n/**\n * The Persian calendar is the main calendar used in Iran and Afghanistan. It has 12 months\n * in each year, the first 6 of which have 31 days, and the next 5 have 30 days. The 12th month\n * has either 29 or 30 days depending on whether it is a leap year. The Persian year starts\n * around the March equinox.\n */\nexport class PersianCalendar implements Calendar {\n identifier: CalendarIdentifier = 'persian';\n\n fromJulianDay(jd: number): CalendarDate {\n let daysSinceEpoch = jd - PERSIAN_EPOCH;\n let year = 1 + Math.floor((33 * daysSinceEpoch + 3) / 12053);\n let farvardin1 = 365 * (year - 1) + Math.floor((8 * year + 21) / 33);\n let dayOfYear = daysSinceEpoch - farvardin1;\n let month = dayOfYear < 216 ? Math.floor(dayOfYear / 31) : Math.floor((dayOfYear - 6) / 30);\n let day = dayOfYear - MONTH_START[month] + 1;\n return new CalendarDate(this, year, month + 1, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n let jd = PERSIAN_EPOCH - 1 + 365 * (date.year - 1) + Math.floor((8 * date.year + 21) / 33);\n jd += MONTH_START[date.month - 1];\n jd += date.day;\n return jd;\n }\n\n getMonthsInYear(): number {\n return 12;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n if (date.month <= 6) {\n return 31;\n }\n\n if (date.month <= 11) {\n return 30;\n }\n\n let isLeapYear = mod(25 * date.year + 11, 33) < 8;\n return isLeapYear ? 30 : 29;\n }\n\n getMaximumMonthsInYear(): number {\n return 12;\n }\n\n getMaximumDaysInMonth(): number {\n return 31;\n }\n\n getEras(): string[] {\n return ['AP'];\n }\n\n getYearsInEra(): number {\n // 9378-10-10 persian is 9999-12-31 gregorian.\n // Round down to 9377 to set the maximum full year.\n return 9377;\n }\n}\n"],"names":[],"version":3,"file":"PersianCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.cjs b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..9d303d50cf16133e049714bde25ea460617620c0 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.cjs @@ -0,0 +1,80 @@ +var $c51b7e0106f45dea$exports = require("../CalendarDate.cjs"); +var $05031860ba2f881f$exports = require("./GregorianCalendar.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "TaiwanCalendar", function () { return $2dab1d4ea1fc722b$export$65e01080afcb0799; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $2dab1d4ea1fc722b$var$TAIWAN_ERA_START = 1911; +function $2dab1d4ea1fc722b$var$gregorianYear(date) { + return date.era === 'minguo' ? date.year + $2dab1d4ea1fc722b$var$TAIWAN_ERA_START : 1 - date.year + $2dab1d4ea1fc722b$var$TAIWAN_ERA_START; +} +function $2dab1d4ea1fc722b$var$gregorianToTaiwan(year) { + let y = year - $2dab1d4ea1fc722b$var$TAIWAN_ERA_START; + if (y > 0) return [ + 'minguo', + y + ]; + else return [ + 'before_minguo', + 1 - y + ]; +} +class $2dab1d4ea1fc722b$export$65e01080afcb0799 extends (0, $05031860ba2f881f$exports.GregorianCalendar) { + fromJulianDay(jd) { + let date = super.fromJulianDay(jd); + let extendedYear = (0, $05031860ba2f881f$exports.getExtendedYear)(date.era, date.year); + let [era, year] = $2dab1d4ea1fc722b$var$gregorianToTaiwan(extendedYear); + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(this, era, year, date.month, date.day); + } + toJulianDay(date) { + return super.toJulianDay($2dab1d4ea1fc722b$var$toGregorian(date)); + } + getEras() { + return [ + 'before_minguo', + 'minguo' + ]; + } + balanceDate(date) { + let [era, year] = $2dab1d4ea1fc722b$var$gregorianToTaiwan($2dab1d4ea1fc722b$var$gregorianYear(date)); + date.era = era; + date.year = year; + } + isInverseEra(date) { + return date.era === 'before_minguo'; + } + getDaysInMonth(date) { + return super.getDaysInMonth($2dab1d4ea1fc722b$var$toGregorian(date)); + } + getYearsInEra(date) { + return date.era === 'before_minguo' ? 9999 : 9999 - $2dab1d4ea1fc722b$var$TAIWAN_ERA_START; + } + constructor(...args){ + super(...args), this.identifier = 'roc' // Republic of China + ; + } +} +function $2dab1d4ea1fc722b$var$toGregorian(date) { + let [era, year] = (0, $05031860ba2f881f$exports.fromExtendedYear)($2dab1d4ea1fc722b$var$gregorianYear(date)); + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(era, year, date.month, date.day); +} + + +//# sourceMappingURL=TaiwanCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..28ab21c00d469d7c5d7d96a5c0b4df233eec9817 --- /dev/null +++ b/node_modules/@internationalized/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B;;;AAkC9D;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,0CAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;AACzD","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo' ? date.year + TAIWAN_ERA_START : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable): void {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(era, year, date.month, date.day);\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.js b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..1ee1bd6f1689defa30fefb5f104087d7b3afbbf2 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.js @@ -0,0 +1,75 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f} from "../CalendarDate.js"; +import {fromExtendedYear as $f25df78da1f6b40f$export$4475b7e617eb123c, getExtendedYear as $f25df78da1f6b40f$export$c36e0ecb2d4fa69d, GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./GregorianCalendar.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $0e7b6ab888014459$var$TAIWAN_ERA_START = 1911; +function $0e7b6ab888014459$var$gregorianYear(date) { + return date.era === 'minguo' ? date.year + $0e7b6ab888014459$var$TAIWAN_ERA_START : 1 - date.year + $0e7b6ab888014459$var$TAIWAN_ERA_START; +} +function $0e7b6ab888014459$var$gregorianToTaiwan(year) { + let y = year - $0e7b6ab888014459$var$TAIWAN_ERA_START; + if (y > 0) return [ + 'minguo', + y + ]; + else return [ + 'before_minguo', + 1 - y + ]; +} +class $0e7b6ab888014459$export$65e01080afcb0799 extends (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + let date = super.fromJulianDay(jd); + let extendedYear = (0, $f25df78da1f6b40f$export$c36e0ecb2d4fa69d)(date.era, date.year); + let [era, year] = $0e7b6ab888014459$var$gregorianToTaiwan(extendedYear); + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(this, era, year, date.month, date.day); + } + toJulianDay(date) { + return super.toJulianDay($0e7b6ab888014459$var$toGregorian(date)); + } + getEras() { + return [ + 'before_minguo', + 'minguo' + ]; + } + balanceDate(date) { + let [era, year] = $0e7b6ab888014459$var$gregorianToTaiwan($0e7b6ab888014459$var$gregorianYear(date)); + date.era = era; + date.year = year; + } + isInverseEra(date) { + return date.era === 'before_minguo'; + } + getDaysInMonth(date) { + return super.getDaysInMonth($0e7b6ab888014459$var$toGregorian(date)); + } + getYearsInEra(date) { + return date.era === 'before_minguo' ? 9999 : 9999 - $0e7b6ab888014459$var$TAIWAN_ERA_START; + } + constructor(...args){ + super(...args), this.identifier = 'roc' // Republic of China + ; + } +} +function $0e7b6ab888014459$var$toGregorian(date) { + let [era, year] = (0, $f25df78da1f6b40f$export$4475b7e617eb123c)($0e7b6ab888014459$var$gregorianYear(date)); + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(era, year, date.month, date.day); +} + + +export {$0e7b6ab888014459$export$65e01080afcb0799 as TaiwanCalendar}; +//# sourceMappingURL=TaiwanCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.js.map b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a3fe10bacac36a181ffd41b3bff9ee6751e490bf --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAAW,KAAK,IAAI,GAAG,yCAAmB,IAAI,KAAK,IAAI,GAAG;AAChF;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;QAlCK,qBACL,aAAiC,MAAO,oBAAoB;;;AAkC9D;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;AACzD","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo' ? date.year + TAIWAN_ERA_START : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable): void {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(era, year, date.month, date.day);\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.mjs b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1c54f187ff66bd6a21945afdaa33db8612978705 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.mjs @@ -0,0 +1,75 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f} from "../CalendarDate.mjs"; +import {fromExtendedYear as $93635573935797de$export$4475b7e617eb123c, getExtendedYear as $93635573935797de$export$c36e0ecb2d4fa69d, GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from ICU. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + +const $c009cc5f64923054$var$TAIWAN_ERA_START = 1911; +function $c009cc5f64923054$var$gregorianYear(date) { + return date.era === 'minguo' ? date.year + $c009cc5f64923054$var$TAIWAN_ERA_START : 1 - date.year + $c009cc5f64923054$var$TAIWAN_ERA_START; +} +function $c009cc5f64923054$var$gregorianToTaiwan(year) { + let y = year - $c009cc5f64923054$var$TAIWAN_ERA_START; + if (y > 0) return [ + 'minguo', + y + ]; + else return [ + 'before_minguo', + 1 - y + ]; +} +class $c009cc5f64923054$export$65e01080afcb0799 extends (0, $93635573935797de$export$80ee6245ec4f29ec) { + fromJulianDay(jd) { + let date = super.fromJulianDay(jd); + let extendedYear = (0, $93635573935797de$export$c36e0ecb2d4fa69d)(date.era, date.year); + let [era, year] = $c009cc5f64923054$var$gregorianToTaiwan(extendedYear); + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(this, era, year, date.month, date.day); + } + toJulianDay(date) { + return super.toJulianDay($c009cc5f64923054$var$toGregorian(date)); + } + getEras() { + return [ + 'before_minguo', + 'minguo' + ]; + } + balanceDate(date) { + let [era, year] = $c009cc5f64923054$var$gregorianToTaiwan($c009cc5f64923054$var$gregorianYear(date)); + date.era = era; + date.year = year; + } + isInverseEra(date) { + return date.era === 'before_minguo'; + } + getDaysInMonth(date) { + return super.getDaysInMonth($c009cc5f64923054$var$toGregorian(date)); + } + getYearsInEra(date) { + return date.era === 'before_minguo' ? 9999 : 9999 - $c009cc5f64923054$var$TAIWAN_ERA_START; + } + constructor(...args){ + super(...args), this.identifier = 'roc' // Republic of China + ; + } +} +function $c009cc5f64923054$var$toGregorian(date) { + let [era, year] = (0, $93635573935797de$export$4475b7e617eb123c)($c009cc5f64923054$var$gregorianYear(date)); + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(era, year, date.month, date.day); +} + + +export {$c009cc5f64923054$export$65e01080afcb0799 as TaiwanCalendar}; +//# sourceMappingURL=TaiwanCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..34ecf0550e6eed8856a933383f661eb4a718e690 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/calendars/TaiwanCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAAW,KAAK,IAAI,GAAG,yCAAmB,IAAI,KAAK,IAAI,GAAG;AAChF;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAU;QACzC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAoB;QAClB,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAQ;QAChD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;QAlCK,qBACL,aAAiC,MAAO,oBAAoB;;;AAkC9D;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;AACzD","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, CalendarIdentifier} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo' ? date.year + TAIWAN_ERA_START : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier: CalendarIdentifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras(): string[] {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable): void {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(era, year, date.month, date.day);\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/conversion.cjs b/node_modules/@internationalized/date/dist/private/conversion.cjs new file mode 100644 index 0000000000000000000000000000000000000000..0b382e9e54d514c0001276f03f06fa47fed32cdc --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/conversion.cjs @@ -0,0 +1,241 @@ +var $c51b7e0106f45dea$exports = require("./CalendarDate.cjs"); +var $19485913bea41f19$exports = require("./manipulation.cjs"); +var $05031860ba2f881f$exports = require("./calendars/GregorianCalendar.cjs"); +var $84a63d30beb0af0f$exports = require("./queries.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "epochFromDate", function () { return $e13115b3b86b9007$export$bd4fb2bc8bb06fb; }); +$parcel$export(module.exports, "toCalendar", function () { return $e13115b3b86b9007$export$b4a036af3fc0b032; }); +$parcel$export(module.exports, "possibleAbsolutes", function () { return $e13115b3b86b9007$export$136f38efe7caf549; }); +$parcel$export(module.exports, "toAbsolute", function () { return $e13115b3b86b9007$export$5107c82f94518f5c; }); +$parcel$export(module.exports, "toCalendarDateTime", function () { return $e13115b3b86b9007$export$b21e0b124e224484; }); +$parcel$export(module.exports, "toDate", function () { return $e13115b3b86b9007$export$e67a095c620b86fe; }); +$parcel$export(module.exports, "fromAbsolute", function () { return $e13115b3b86b9007$export$1b96692a1ba042ac; }); +$parcel$export(module.exports, "fromDate", function () { return $e13115b3b86b9007$export$e57ff100d91bd4b9; }); +$parcel$export(module.exports, "fromDateToLocal", function () { return $e13115b3b86b9007$export$d7f92bcd3596b086; }); +$parcel$export(module.exports, "toCalendarDate", function () { return $e13115b3b86b9007$export$93522d1a439f3617; }); +$parcel$export(module.exports, "toTime", function () { return $e13115b3b86b9007$export$d33f79e3ffc3dc83; }); +$parcel$export(module.exports, "toZoned", function () { return $e13115b3b86b9007$export$84c95a83c799e074; }); +$parcel$export(module.exports, "toTimeZone", function () { return $e13115b3b86b9007$export$538b00033cc11c75; }); +$parcel$export(module.exports, "zonedToDate", function () { return $e13115b3b86b9007$export$83aac07b4c37b25; }); +$parcel$export(module.exports, "toLocalTimeZone", function () { return $e13115b3b86b9007$export$d9b67bc93c097491; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from the TC39 Temporal proposal. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + + + +function $e13115b3b86b9007$export$bd4fb2bc8bb06fb(date) { + date = $e13115b3b86b9007$export$b4a036af3fc0b032(date, new (0, $05031860ba2f881f$exports.GregorianCalendar)()); + let year = (0, $05031860ba2f881f$exports.getExtendedYear)(date.era, date.year); + return $e13115b3b86b9007$var$epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond); +} +function $e13115b3b86b9007$var$epochFromParts(year, month, day, hour, minute, second, millisecond) { + // Note: Date.UTC() interprets one and two-digit years as being in the + // 20th century, so don't use it + let date = new Date(); + date.setUTCHours(hour, minute, second, millisecond); + date.setUTCFullYear(year, month - 1, day); + return date.getTime(); +} +function $e13115b3b86b9007$export$59c99f3515d3493f(ms, timeZone) { + // Fast path for UTC. + if (timeZone === 'UTC') return 0; + // Fast path: for local timezone after 1970, use native Date. + // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone, + // since native Date always uses the browser's timezone, not the overridden one. + if (ms > 0 && timeZone === (0, $84a63d30beb0af0f$exports.getLocalTimeZone)() && !(0, $84a63d30beb0af0f$exports.isLocalTimeZoneOverridden)()) return new Date(ms).getTimezoneOffset() * -60000; + let { year: year, month: month, day: day, hour: hour, minute: minute, second: second } = $e13115b3b86b9007$var$getTimeZoneParts(ms, timeZone); + let utc = $e13115b3b86b9007$var$epochFromParts(year, month, day, hour, minute, second, 0); + return utc - Math.floor(ms / 1000) * 1000; +} +const $e13115b3b86b9007$var$formattersByTimeZone = new Map(); +function $e13115b3b86b9007$var$getTimeZoneParts(ms, timeZone) { + let formatter = $e13115b3b86b9007$var$formattersByTimeZone.get(timeZone); + if (!formatter) { + formatter = new Intl.DateTimeFormat('en-US', { + timeZone: timeZone, + hour12: false, + era: 'short', + year: 'numeric', + month: 'numeric', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + second: 'numeric' + }); + $e13115b3b86b9007$var$formattersByTimeZone.set(timeZone, formatter); + } + let parts = formatter.formatToParts(new Date(ms)); + let namedParts = {}; + for (let part of parts)if (part.type !== 'literal') namedParts[part.type] = part.value; + return { + // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253 + year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year, + month: +namedParts.month, + day: +namedParts.day, + hour: namedParts.hour === '24' ? 0 : +namedParts.hour, + minute: +namedParts.minute, + second: +namedParts.second + }; +} +const $e13115b3b86b9007$var$DAYMILLIS = 86400000; +function $e13115b3b86b9007$export$136f38efe7caf549(date, timeZone) { + let ms = $e13115b3b86b9007$export$bd4fb2bc8bb06fb(date); + let earlier = ms - $e13115b3b86b9007$export$59c99f3515d3493f(ms - $e13115b3b86b9007$var$DAYMILLIS, timeZone); + let later = ms - $e13115b3b86b9007$export$59c99f3515d3493f(ms + $e13115b3b86b9007$var$DAYMILLIS, timeZone); + return $e13115b3b86b9007$var$getValidWallTimes(date, timeZone, earlier, later); +} +function $e13115b3b86b9007$var$getValidWallTimes(date, timeZone, earlier, later) { + let found = earlier === later ? [ + earlier + ] : [ + earlier, + later + ]; + return found.filter((absolute)=>$e13115b3b86b9007$var$isValidWallTime(date, timeZone, absolute)); +} +function $e13115b3b86b9007$var$isValidWallTime(date, timeZone, absolute) { + let parts = $e13115b3b86b9007$var$getTimeZoneParts(absolute, timeZone); + return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second; +} +function $e13115b3b86b9007$export$5107c82f94518f5c(date, timeZone, disambiguation = 'compatible') { + let dateTime = $e13115b3b86b9007$export$b21e0b124e224484(date); + // Fast path: if the time zone is UTC, use native Date. + if (timeZone === 'UTC') return $e13115b3b86b9007$export$bd4fb2bc8bb06fb(dateTime); + // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date. + // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone, + // since native Date always uses the browser's timezone, not the overridden one. + if (timeZone === (0, $84a63d30beb0af0f$exports.getLocalTimeZone)() && disambiguation === 'compatible' && !(0, $84a63d30beb0af0f$exports.isLocalTimeZoneOverridden)()) { + dateTime = $e13115b3b86b9007$export$b4a036af3fc0b032(dateTime, new (0, $05031860ba2f881f$exports.GregorianCalendar)()); + // Don't use Date constructor here because two-digit years are interpreted in the 20th century. + let date = new Date(); + let year = (0, $05031860ba2f881f$exports.getExtendedYear)(dateTime.era, dateTime.year); + date.setFullYear(year, dateTime.month - 1, dateTime.day); + date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond); + return date.getTime(); + } + let ms = $e13115b3b86b9007$export$bd4fb2bc8bb06fb(dateTime); + let offsetBefore = $e13115b3b86b9007$export$59c99f3515d3493f(ms - $e13115b3b86b9007$var$DAYMILLIS, timeZone); + let offsetAfter = $e13115b3b86b9007$export$59c99f3515d3493f(ms + $e13115b3b86b9007$var$DAYMILLIS, timeZone); + let valid = $e13115b3b86b9007$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter); + if (valid.length === 1) return valid[0]; + if (valid.length > 1) switch(disambiguation){ + // 'compatible' means 'earlier' for "fall back" transitions + case 'compatible': + case 'earlier': + return valid[0]; + case 'later': + return valid[valid.length - 1]; + case 'reject': + throw new RangeError('Multiple possible absolute times found'); + } + switch(disambiguation){ + case 'earlier': + return Math.min(ms - offsetBefore, ms - offsetAfter); + // 'compatible' means 'later' for "spring forward" transitions + case 'compatible': + case 'later': + return Math.max(ms - offsetBefore, ms - offsetAfter); + case 'reject': + throw new RangeError('No such absolute time found'); + } +} +function $e13115b3b86b9007$export$e67a095c620b86fe(dateTime, timeZone, disambiguation = 'compatible') { + return new Date($e13115b3b86b9007$export$5107c82f94518f5c(dateTime, timeZone, disambiguation)); +} +function $e13115b3b86b9007$export$1b96692a1ba042ac(ms, timeZone) { + let offset = $e13115b3b86b9007$export$59c99f3515d3493f(ms, timeZone); + let date = new Date(ms + offset); + let year = date.getUTCFullYear(); + let month = date.getUTCMonth() + 1; + let day = date.getUTCDate(); + let hour = date.getUTCHours(); + let minute = date.getUTCMinutes(); + let second = date.getUTCSeconds(); + let millisecond = date.getUTCMilliseconds(); + return new (0, $c51b7e0106f45dea$exports.ZonedDateTime)(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond); +} +function $e13115b3b86b9007$export$e57ff100d91bd4b9(date, timeZone) { + return $e13115b3b86b9007$export$1b96692a1ba042ac(date.getTime(), timeZone); +} +function $e13115b3b86b9007$export$d7f92bcd3596b086(date) { + return $e13115b3b86b9007$export$e57ff100d91bd4b9(date, (0, $84a63d30beb0af0f$exports.getLocalTimeZone)()); +} +function $e13115b3b86b9007$export$93522d1a439f3617(dateTime) { + return new (0, $c51b7e0106f45dea$exports.CalendarDate)(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day); +} +function $e13115b3b86b9007$export$6f4d78149f3f53ac(date) { + return { + era: date.era, + year: date.year, + month: date.month, + day: date.day + }; +} +function $e13115b3b86b9007$export$4d0393e732857be5(date) { + return { + hour: date.hour, + minute: date.minute, + second: date.second, + millisecond: date.millisecond + }; +} +function $e13115b3b86b9007$export$b21e0b124e224484(date, time) { + let hour = 0, minute = 0, second = 0, millisecond = 0; + if ('timeZone' in date) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = date); + else if ('hour' in date && !time) return date; + if (time) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = time); + return new (0, $c51b7e0106f45dea$exports.CalendarDateTime)(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond); +} +function $e13115b3b86b9007$export$d33f79e3ffc3dc83(dateTime) { + return new (0, $c51b7e0106f45dea$exports.Time)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond); +} +function $e13115b3b86b9007$export$b4a036af3fc0b032(date, calendar) { + if ((0, $84a63d30beb0af0f$exports.isEqualCalendar)(date.calendar, calendar)) return date; + let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date)); + let copy = date.copy(); + copy.calendar = calendar; + copy.era = calendarDate.era; + copy.year = calendarDate.year; + copy.month = calendarDate.month; + copy.day = calendarDate.day; + (0, $19485913bea41f19$exports.constrain)(copy); + return copy; +} +function $e13115b3b86b9007$export$84c95a83c799e074(date, timeZone, disambiguation) { + if (date instanceof (0, $c51b7e0106f45dea$exports.ZonedDateTime)) { + if (date.timeZone === timeZone) return date; + return $e13115b3b86b9007$export$538b00033cc11c75(date, timeZone); + } + let ms = $e13115b3b86b9007$export$5107c82f94518f5c(date, timeZone, disambiguation); + return $e13115b3b86b9007$export$1b96692a1ba042ac(ms, timeZone); +} +function $e13115b3b86b9007$export$83aac07b4c37b25(date) { + let ms = $e13115b3b86b9007$export$bd4fb2bc8bb06fb(date) - date.offset; + return new Date(ms); +} +function $e13115b3b86b9007$export$538b00033cc11c75(date, timeZone) { + let ms = $e13115b3b86b9007$export$bd4fb2bc8bb06fb(date) - date.offset; + return $e13115b3b86b9007$export$b4a036af3fc0b032($e13115b3b86b9007$export$1b96692a1ba042ac(ms, timeZone), date.calendar); +} +function $e13115b3b86b9007$export$d9b67bc93c097491(date) { + return $e13115b3b86b9007$export$538b00033cc11c75(date, (0, $84a63d30beb0af0f$exports.getLocalTimeZone)()); +} + + +//# sourceMappingURL=conversion.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/conversion.cjs.map b/node_modules/@internationalized/date/dist/private/conversion.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..4c6adfe06e7c642d21a8a677f38a59566a440d32 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/conversion.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;;;AAiBzF,SAAS,yCAAc,IAAiB;IAC7C,OAAO,0CAAW,MAAM,IAAI,CAAA,GAAA,2CAAgB;IAC5C,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;IAC9C,OAAO,qCACL,MACA,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,WAAW;AAEpB;AAEA,SAAS,qCACP,IAAY,EACZ,KAAa,EACb,GAAW,EACX,IAAY,EACZ,MAAc,EACd,MAAc,EACd,WAAmB;IAEnB,sEAAsE;IACtE,gCAAgC;IAChC,IAAI,OAAO,IAAI;IACf,KAAK,WAAW,CAAC,MAAM,QAAQ,QAAQ;IACvC,KAAK,cAAc,CAAC,MAAM,QAAQ,GAAG;IACrC,OAAO,KAAK,OAAO;AACrB;AAEO,SAAS,0CAAkB,EAAU,EAAE,QAAgB;IAC5D,qBAAqB;IACrB,IAAI,aAAa,OACf,OAAO;IAGT,6DAA6D;IAC7D,4FAA4F;IAC5F,gFAAgF;IAChF,IAAI,KAAK,KAAK,aAAa,CAAA,GAAA,0CAAe,OAAO,CAAC,CAAA,GAAA,mDAAwB,KACxE,OAAO,IAAI,KAAK,IAAI,iBAAiB,KAA9B;IAGT,IAAI,QAAC,IAAI,SAAE,KAAK,OAAE,GAAG,QAAE,IAAI,UAAE,MAAM,UAAE,MAAM,EAAC,GAAG,uCAAiB,IAAI;IACpE,IAAI,MAAM,qCAAe,MAAM,OAAO,KAAK,MAAM,QAAQ,QAAQ;IACjE,OAAO,MAAM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G,GAAG,aAAa,GAAG;IAC3B,KAAK,IAAI,GAAG,aAAa,IAAI;IAC7B,KAAK,KAAK,GAAG,aAAa,KAAK;IAC/B,KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,CAAA,GAAA,mCAAQ,EAAE;IACV,OAAO;AACT;AAMO,SAAS,0CACd,IAAqD,EACrD,QAAgB,EAChB,cAA+B;IAE/B,IAAI,gBAAgB,CAAA,GAAA,uCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,0CAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {\n AnyCalendarDate,\n AnyDateTime,\n AnyTime,\n Calendar,\n DateFields,\n Disambiguation,\n TimeFields\n} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone, isEqualCalendar, isLocalTimeZoneOverridden} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime): number {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(\n year,\n date.month,\n date.day,\n date.hour,\n date.minute,\n date.second,\n date.millisecond\n );\n}\n\nfunction epochFromParts(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n second: number,\n millisecond: number\n): number {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string): number {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone,\n // since native Date always uses the browser's timezone, not the overridden one.\n if (ms > 0 && timeZone === getLocalTimeZone() && !isLocalTimeZoneOverridden()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year:\n namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(\n date: CalendarDateTime,\n timeZone: string,\n earlier: number,\n later: number\n): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return (\n date.year === parts.year &&\n date.month === parts.month &&\n date.day === parts.day &&\n date.hour === parts.hour &&\n date.minute === parts.minute &&\n date.second === parts.second\n );\n}\n\nexport function toAbsolute(\n date: CalendarDate | CalendarDateTime,\n timeZone: string,\n disambiguation: Disambiguation = 'compatible'\n): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone,\n // since native Date always uses the browser's timezone, not the overridden one.\n if (\n timeZone === getLocalTimeZone() &&\n disambiguation === 'compatible' &&\n !isLocalTimeZoneOverridden()\n ) {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(\n dateTime: CalendarDate | CalendarDateTime,\n timeZone: string,\n disambiguation: Disambiguation = 'compatible'\n): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(\n year < 1 ? 'BC' : 'AD',\n year < 1 ? -year + 1 : year,\n month,\n day,\n timeZone,\n offset,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\n/**\n * Takes a `Date` object and converts it to the time zone identifier for the current user.\n */\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/**\n * Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a\n * `CalendarDate`.\n */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(\n dateTime.calendar,\n dateTime.era,\n dateTime.year,\n dateTime.month,\n dateTime.day\n );\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the\n * time of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(\n date: CalendarDate | CalendarDateTime | ZonedDateTime,\n time?: AnyTime\n): CalendarDateTime {\n let hour = 0,\n minute = 0,\n second = 0,\n millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar(date: T, calendar: Calendar): T {\n if (isEqualCalendar(date.calendar, calendar)) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option\n * can be set to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(\n date: CalendarDate | CalendarDateTime | ZonedDateTime,\n timeZone: string,\n disambiguation?: Disambiguation\n): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime): Date {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/conversion.js b/node_modules/@internationalized/date/dist/private/conversion.js new file mode 100644 index 0000000000000000000000000000000000000000..6eae830a4a2dec17a93526502c1eaaefdfbdd94e --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/conversion.js @@ -0,0 +1,222 @@ +import {CalendarDate as $9a4e222e1bd2b190$export$99faa760c7908e4f, CalendarDateTime as $9a4e222e1bd2b190$export$ca871e8dbb80966f, Time as $9a4e222e1bd2b190$export$680ea196effce5f, ZonedDateTime as $9a4e222e1bd2b190$export$d3b7288e7994edea} from "./CalendarDate.js"; +import {constrain as $13bd2ffe0df4e09c$export$c4e2ecac49351ef2} from "./manipulation.js"; +import {getExtendedYear as $f25df78da1f6b40f$export$c36e0ecb2d4fa69d, GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.js"; +import {getLocalTimeZone as $8daeb11568269f24$export$aa8b41735afcabd2, isEqualCalendar as $8daeb11568269f24$export$dbc69fd56b53d5e, isLocalTimeZoneOverridden as $8daeb11568269f24$export$6ab69b273755230b} from "./queries.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from the TC39 Temporal proposal. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + + + +function $e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb(date) { + date = $e83297bd1a9e3ddc$export$b4a036af3fc0b032(date, new (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec)()); + let year = (0, $f25df78da1f6b40f$export$c36e0ecb2d4fa69d)(date.era, date.year); + return $e83297bd1a9e3ddc$var$epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond); +} +function $e83297bd1a9e3ddc$var$epochFromParts(year, month, day, hour, minute, second, millisecond) { + // Note: Date.UTC() interprets one and two-digit years as being in the + // 20th century, so don't use it + let date = new Date(); + date.setUTCHours(hour, minute, second, millisecond); + date.setUTCFullYear(year, month - 1, day); + return date.getTime(); +} +function $e83297bd1a9e3ddc$export$59c99f3515d3493f(ms, timeZone) { + // Fast path for UTC. + if (timeZone === 'UTC') return 0; + // Fast path: for local timezone after 1970, use native Date. + // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone, + // since native Date always uses the browser's timezone, not the overridden one. + if (ms > 0 && timeZone === (0, $8daeb11568269f24$export$aa8b41735afcabd2)() && !(0, $8daeb11568269f24$export$6ab69b273755230b)()) return new Date(ms).getTimezoneOffset() * -60000; + let { year: year, month: month, day: day, hour: hour, minute: minute, second: second } = $e83297bd1a9e3ddc$var$getTimeZoneParts(ms, timeZone); + let utc = $e83297bd1a9e3ddc$var$epochFromParts(year, month, day, hour, minute, second, 0); + return utc - Math.floor(ms / 1000) * 1000; +} +const $e83297bd1a9e3ddc$var$formattersByTimeZone = new Map(); +function $e83297bd1a9e3ddc$var$getTimeZoneParts(ms, timeZone) { + let formatter = $e83297bd1a9e3ddc$var$formattersByTimeZone.get(timeZone); + if (!formatter) { + formatter = new Intl.DateTimeFormat('en-US', { + timeZone: timeZone, + hour12: false, + era: 'short', + year: 'numeric', + month: 'numeric', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + second: 'numeric' + }); + $e83297bd1a9e3ddc$var$formattersByTimeZone.set(timeZone, formatter); + } + let parts = formatter.formatToParts(new Date(ms)); + let namedParts = {}; + for (let part of parts)if (part.type !== 'literal') namedParts[part.type] = part.value; + return { + // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253 + year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year, + month: +namedParts.month, + day: +namedParts.day, + hour: namedParts.hour === '24' ? 0 : +namedParts.hour, + minute: +namedParts.minute, + second: +namedParts.second + }; +} +const $e83297bd1a9e3ddc$var$DAYMILLIS = 86400000; +function $e83297bd1a9e3ddc$export$136f38efe7caf549(date, timeZone) { + let ms = $e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb(date); + let earlier = ms - $e83297bd1a9e3ddc$export$59c99f3515d3493f(ms - $e83297bd1a9e3ddc$var$DAYMILLIS, timeZone); + let later = ms - $e83297bd1a9e3ddc$export$59c99f3515d3493f(ms + $e83297bd1a9e3ddc$var$DAYMILLIS, timeZone); + return $e83297bd1a9e3ddc$var$getValidWallTimes(date, timeZone, earlier, later); +} +function $e83297bd1a9e3ddc$var$getValidWallTimes(date, timeZone, earlier, later) { + let found = earlier === later ? [ + earlier + ] : [ + earlier, + later + ]; + return found.filter((absolute)=>$e83297bd1a9e3ddc$var$isValidWallTime(date, timeZone, absolute)); +} +function $e83297bd1a9e3ddc$var$isValidWallTime(date, timeZone, absolute) { + let parts = $e83297bd1a9e3ddc$var$getTimeZoneParts(absolute, timeZone); + return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second; +} +function $e83297bd1a9e3ddc$export$5107c82f94518f5c(date, timeZone, disambiguation = 'compatible') { + let dateTime = $e83297bd1a9e3ddc$export$b21e0b124e224484(date); + // Fast path: if the time zone is UTC, use native Date. + if (timeZone === 'UTC') return $e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb(dateTime); + // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date. + // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone, + // since native Date always uses the browser's timezone, not the overridden one. + if (timeZone === (0, $8daeb11568269f24$export$aa8b41735afcabd2)() && disambiguation === 'compatible' && !(0, $8daeb11568269f24$export$6ab69b273755230b)()) { + dateTime = $e83297bd1a9e3ddc$export$b4a036af3fc0b032(dateTime, new (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec)()); + // Don't use Date constructor here because two-digit years are interpreted in the 20th century. + let date = new Date(); + let year = (0, $f25df78da1f6b40f$export$c36e0ecb2d4fa69d)(dateTime.era, dateTime.year); + date.setFullYear(year, dateTime.month - 1, dateTime.day); + date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond); + return date.getTime(); + } + let ms = $e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb(dateTime); + let offsetBefore = $e83297bd1a9e3ddc$export$59c99f3515d3493f(ms - $e83297bd1a9e3ddc$var$DAYMILLIS, timeZone); + let offsetAfter = $e83297bd1a9e3ddc$export$59c99f3515d3493f(ms + $e83297bd1a9e3ddc$var$DAYMILLIS, timeZone); + let valid = $e83297bd1a9e3ddc$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter); + if (valid.length === 1) return valid[0]; + if (valid.length > 1) switch(disambiguation){ + // 'compatible' means 'earlier' for "fall back" transitions + case 'compatible': + case 'earlier': + return valid[0]; + case 'later': + return valid[valid.length - 1]; + case 'reject': + throw new RangeError('Multiple possible absolute times found'); + } + switch(disambiguation){ + case 'earlier': + return Math.min(ms - offsetBefore, ms - offsetAfter); + // 'compatible' means 'later' for "spring forward" transitions + case 'compatible': + case 'later': + return Math.max(ms - offsetBefore, ms - offsetAfter); + case 'reject': + throw new RangeError('No such absolute time found'); + } +} +function $e83297bd1a9e3ddc$export$e67a095c620b86fe(dateTime, timeZone, disambiguation = 'compatible') { + return new Date($e83297bd1a9e3ddc$export$5107c82f94518f5c(dateTime, timeZone, disambiguation)); +} +function $e83297bd1a9e3ddc$export$1b96692a1ba042ac(ms, timeZone) { + let offset = $e83297bd1a9e3ddc$export$59c99f3515d3493f(ms, timeZone); + let date = new Date(ms + offset); + let year = date.getUTCFullYear(); + let month = date.getUTCMonth() + 1; + let day = date.getUTCDate(); + let hour = date.getUTCHours(); + let minute = date.getUTCMinutes(); + let second = date.getUTCSeconds(); + let millisecond = date.getUTCMilliseconds(); + return new (0, $9a4e222e1bd2b190$export$d3b7288e7994edea)(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond); +} +function $e83297bd1a9e3ddc$export$e57ff100d91bd4b9(date, timeZone) { + return $e83297bd1a9e3ddc$export$1b96692a1ba042ac(date.getTime(), timeZone); +} +function $e83297bd1a9e3ddc$export$d7f92bcd3596b086(date) { + return $e83297bd1a9e3ddc$export$e57ff100d91bd4b9(date, (0, $8daeb11568269f24$export$aa8b41735afcabd2)()); +} +function $e83297bd1a9e3ddc$export$93522d1a439f3617(dateTime) { + return new (0, $9a4e222e1bd2b190$export$99faa760c7908e4f)(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day); +} +function $e83297bd1a9e3ddc$export$6f4d78149f3f53ac(date) { + return { + era: date.era, + year: date.year, + month: date.month, + day: date.day + }; +} +function $e83297bd1a9e3ddc$export$4d0393e732857be5(date) { + return { + hour: date.hour, + minute: date.minute, + second: date.second, + millisecond: date.millisecond + }; +} +function $e83297bd1a9e3ddc$export$b21e0b124e224484(date, time) { + let hour = 0, minute = 0, second = 0, millisecond = 0; + if ('timeZone' in date) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = date); + else if ('hour' in date && !time) return date; + if (time) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = time); + return new (0, $9a4e222e1bd2b190$export$ca871e8dbb80966f)(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond); +} +function $e83297bd1a9e3ddc$export$d33f79e3ffc3dc83(dateTime) { + return new (0, $9a4e222e1bd2b190$export$680ea196effce5f)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond); +} +function $e83297bd1a9e3ddc$export$b4a036af3fc0b032(date, calendar) { + if ((0, $8daeb11568269f24$export$dbc69fd56b53d5e)(date.calendar, calendar)) return date; + let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date)); + let copy = date.copy(); + copy.calendar = calendar; + copy.era = calendarDate.era; + copy.year = calendarDate.year; + copy.month = calendarDate.month; + copy.day = calendarDate.day; + (0, $13bd2ffe0df4e09c$export$c4e2ecac49351ef2)(copy); + return copy; +} +function $e83297bd1a9e3ddc$export$84c95a83c799e074(date, timeZone, disambiguation) { + if (date instanceof (0, $9a4e222e1bd2b190$export$d3b7288e7994edea)) { + if (date.timeZone === timeZone) return date; + return $e83297bd1a9e3ddc$export$538b00033cc11c75(date, timeZone); + } + let ms = $e83297bd1a9e3ddc$export$5107c82f94518f5c(date, timeZone, disambiguation); + return $e83297bd1a9e3ddc$export$1b96692a1ba042ac(ms, timeZone); +} +function $e83297bd1a9e3ddc$export$83aac07b4c37b25(date) { + let ms = $e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb(date) - date.offset; + return new Date(ms); +} +function $e83297bd1a9e3ddc$export$538b00033cc11c75(date, timeZone) { + let ms = $e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb(date) - date.offset; + return $e83297bd1a9e3ddc$export$b4a036af3fc0b032($e83297bd1a9e3ddc$export$1b96692a1ba042ac(ms, timeZone), date.calendar); +} +function $e83297bd1a9e3ddc$export$d9b67bc93c097491(date) { + return $e83297bd1a9e3ddc$export$538b00033cc11c75(date, (0, $8daeb11568269f24$export$aa8b41735afcabd2)()); +} + + +export {$e83297bd1a9e3ddc$export$bd4fb2bc8bb06fb as epochFromDate, $e83297bd1a9e3ddc$export$b4a036af3fc0b032 as toCalendar, $e83297bd1a9e3ddc$export$59c99f3515d3493f as getTimeZoneOffset, $e83297bd1a9e3ddc$export$136f38efe7caf549 as possibleAbsolutes, $e83297bd1a9e3ddc$export$5107c82f94518f5c as toAbsolute, $e83297bd1a9e3ddc$export$b21e0b124e224484 as toCalendarDateTime, $e83297bd1a9e3ddc$export$e67a095c620b86fe as toDate, $e83297bd1a9e3ddc$export$1b96692a1ba042ac as fromAbsolute, $e83297bd1a9e3ddc$export$e57ff100d91bd4b9 as fromDate, $e83297bd1a9e3ddc$export$d7f92bcd3596b086 as fromDateToLocal, $e83297bd1a9e3ddc$export$93522d1a439f3617 as toCalendarDate, $e83297bd1a9e3ddc$export$6f4d78149f3f53ac as toDateFields, $e83297bd1a9e3ddc$export$4d0393e732857be5 as toTimeFields, $e83297bd1a9e3ddc$export$d33f79e3ffc3dc83 as toTime, $e83297bd1a9e3ddc$export$84c95a83c799e074 as toZoned, $e83297bd1a9e3ddc$export$538b00033cc11c75 as toTimeZone, $e83297bd1a9e3ddc$export$83aac07b4c37b25 as zonedToDate, $e83297bd1a9e3ddc$export$d9b67bc93c097491 as toLocalTimeZone}; +//# sourceMappingURL=conversion.js.map diff --git a/node_modules/@internationalized/date/dist/private/conversion.js.map b/node_modules/@internationalized/date/dist/private/conversion.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3857646c7abd29646d4fcc0090b4f34dbe71ba38 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/conversion.js.map @@ -0,0 +1 @@ +{"mappings":";;;;;AAAA;;;;;;;;;;CAUC,GAED,uFAAuF;AACvF,gGAAgG;;;;;AAiBzF,SAAS,yCAAc,IAAiB;IAC7C,OAAO,0CAAW,MAAM,IAAI,CAAA,GAAA,yCAAgB;IAC5C,IAAI,OAAO,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;IAC9C,OAAO,qCACL,MACA,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,WAAW;AAEpB;AAEA,SAAS,qCACP,IAAY,EACZ,KAAa,EACb,GAAW,EACX,IAAY,EACZ,MAAc,EACd,MAAc,EACd,WAAmB;IAEnB,sEAAsE;IACtE,gCAAgC;IAChC,IAAI,OAAO,IAAI;IACf,KAAK,WAAW,CAAC,MAAM,QAAQ,QAAQ;IACvC,KAAK,cAAc,CAAC,MAAM,QAAQ,GAAG;IACrC,OAAO,KAAK,OAAO;AACrB;AAEO,SAAS,0CAAkB,EAAU,EAAE,QAAgB;IAC5D,qBAAqB;IACrB,IAAI,aAAa,OACf,OAAO;IAGT,6DAA6D;IAC7D,4FAA4F;IAC5F,gFAAgF;IAChF,IAAI,KAAK,KAAK,aAAa,CAAA,GAAA,yCAAe,OAAO,CAAC,CAAA,GAAA,yCAAwB,KACxE,OAAO,IAAI,KAAK,IAAI,iBAAiB,KAA9B;IAGT,IAAI,QAAC,IAAI,SAAE,KAAK,OAAE,GAAG,QAAE,IAAI,UAAE,MAAM,UAAE,M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a,CAAC,KAAK,QAAQ,CAAC,WAAW,CAAC;IACpE,IAAI,OAAmB,KAAK,IAAI;IAChC,KAAK,QAAQ,GAAG;IAChB,KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,KAAK,IAAI,GAAG,aAAa,IAAI;IAC7B,KAAK,KAAK,GAAG,aAAa,KAAK;IAC/B,KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,CAAA,GAAA,yCAAQ,EAAE;IACV,OAAO;AACT;AAMO,SAAS,0CACd,IAAqD,EACrD,QAAgB,EAChB,cAA+B;IAE/B,IAAI,gBAAgB,CAAA,GAAA,yCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,yCAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {\n AnyCalendarDate,\n AnyDateTime,\n AnyTime,\n Calendar,\n DateFields,\n Disambiguation,\n TimeFields\n} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone, isEqualCalendar, isLocalTimeZoneOverridden} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime): number {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(\n year,\n date.month,\n date.day,\n date.hour,\n date.minute,\n date.second,\n date.millisecond\n );\n}\n\nfunction epochFromParts(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n second: number,\n millisecond: number\n): number {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string): number {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone,\n // since native Date always uses the browser's timezone, not the overridden one.\n if (ms > 0 && timeZone === getLocalTimeZone() && !isLocalTimeZoneOverridden()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year:\n namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(\n date: CalendarDateTime,\n timeZone: string,\n earlier: number,\n later: number\n): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return (\n date.year === parts.year &&\n date.month === parts.month &&\n date.day === parts.day &&\n date.hour === parts.hour &&\n date.minute === parts.minute &&\n date.second === parts.second\n );\n}\n\nexport function toAbsolute(\n date: CalendarDate | CalendarDateTime,\n timeZone: string,\n disambiguation: Disambiguation = 'compatible'\n): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone,\n // since native Date always uses the browser's timezone, not the overridden one.\n if (\n timeZone === getLocalTimeZone() &&\n disambiguation === 'compatible' &&\n !isLocalTimeZoneOverridden()\n ) {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(\n dateTime: CalendarDate | CalendarDateTime,\n timeZone: string,\n disambiguation: Disambiguation = 'compatible'\n): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(\n year < 1 ? 'BC' : 'AD',\n year < 1 ? -year + 1 : year,\n month,\n day,\n timeZone,\n offset,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\n/**\n * Takes a `Date` object and converts it to the time zone identifier for the current user.\n */\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/**\n * Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a\n * `CalendarDate`.\n */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(\n dateTime.calendar,\n dateTime.era,\n dateTime.year,\n dateTime.month,\n dateTime.day\n );\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the\n * time of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(\n date: CalendarDate | CalendarDateTime | ZonedDateTime,\n time?: AnyTime\n): CalendarDateTime {\n let hour = 0,\n minute = 0,\n second = 0,\n millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar(date: T, calendar: Calendar): T {\n if (isEqualCalendar(date.calendar, calendar)) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option\n * can be set to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(\n date: CalendarDate | CalendarDateTime | ZonedDateTime,\n timeZone: string,\n disambiguation?: Disambiguation\n): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime): Date {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/conversion.mjs b/node_modules/@internationalized/date/dist/private/conversion.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f8193b89d3c8a1b48149554de476b651c0e85913 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/conversion.mjs @@ -0,0 +1,222 @@ +import {CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f, CalendarDateTime as $2aaf608024c21ca1$export$ca871e8dbb80966f, Time as $2aaf608024c21ca1$export$680ea196effce5f, ZonedDateTime as $2aaf608024c21ca1$export$d3b7288e7994edea} from "./CalendarDate.mjs"; +import {constrain as $435a2ceaa8778ed8$export$c4e2ecac49351ef2} from "./manipulation.mjs"; +import {getExtendedYear as $93635573935797de$export$c36e0ecb2d4fa69d, GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.mjs"; +import {getLocalTimeZone as $ad063034c8620db8$export$aa8b41735afcabd2, isEqualCalendar as $ad063034c8620db8$export$dbc69fd56b53d5e, isLocalTimeZoneOverridden as $ad063034c8620db8$export$6ab69b273755230b} from "./queries.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ // Portions of the code in this file are based on code from the TC39 Temporal proposal. +// Original licensing can be found in the NOTICE file in the root directory of this source tree. + + + + +function $d07e34cce18680fd$export$bd4fb2bc8bb06fb(date) { + date = $d07e34cce18680fd$export$b4a036af3fc0b032(date, new (0, $93635573935797de$export$80ee6245ec4f29ec)()); + let year = (0, $93635573935797de$export$c36e0ecb2d4fa69d)(date.era, date.year); + return $d07e34cce18680fd$var$epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond); +} +function $d07e34cce18680fd$var$epochFromParts(year, month, day, hour, minute, second, millisecond) { + // Note: Date.UTC() interprets one and two-digit years as being in the + // 20th century, so don't use it + let date = new Date(); + date.setUTCHours(hour, minute, second, millisecond); + date.setUTCFullYear(year, month - 1, day); + return date.getTime(); +} +function $d07e34cce18680fd$export$59c99f3515d3493f(ms, timeZone) { + // Fast path for UTC. + if (timeZone === 'UTC') return 0; + // Fast path: for local timezone after 1970, use native Date. + // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone, + // since native Date always uses the browser's timezone, not the overridden one. + if (ms > 0 && timeZone === (0, $ad063034c8620db8$export$aa8b41735afcabd2)() && !(0, $ad063034c8620db8$export$6ab69b273755230b)()) return new Date(ms).getTimezoneOffset() * -60000; + let { year: year, month: month, day: day, hour: hour, minute: minute, second: second } = $d07e34cce18680fd$var$getTimeZoneParts(ms, timeZone); + let utc = $d07e34cce18680fd$var$epochFromParts(year, month, day, hour, minute, second, 0); + return utc - Math.floor(ms / 1000) * 1000; +} +const $d07e34cce18680fd$var$formattersByTimeZone = new Map(); +function $d07e34cce18680fd$var$getTimeZoneParts(ms, timeZone) { + let formatter = $d07e34cce18680fd$var$formattersByTimeZone.get(timeZone); + if (!formatter) { + formatter = new Intl.DateTimeFormat('en-US', { + timeZone: timeZone, + hour12: false, + era: 'short', + year: 'numeric', + month: 'numeric', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + second: 'numeric' + }); + $d07e34cce18680fd$var$formattersByTimeZone.set(timeZone, formatter); + } + let parts = formatter.formatToParts(new Date(ms)); + let namedParts = {}; + for (let part of parts)if (part.type !== 'literal') namedParts[part.type] = part.value; + return { + // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253 + year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year, + month: +namedParts.month, + day: +namedParts.day, + hour: namedParts.hour === '24' ? 0 : +namedParts.hour, + minute: +namedParts.minute, + second: +namedParts.second + }; +} +const $d07e34cce18680fd$var$DAYMILLIS = 86400000; +function $d07e34cce18680fd$export$136f38efe7caf549(date, timeZone) { + let ms = $d07e34cce18680fd$export$bd4fb2bc8bb06fb(date); + let earlier = ms - $d07e34cce18680fd$export$59c99f3515d3493f(ms - $d07e34cce18680fd$var$DAYMILLIS, timeZone); + let later = ms - $d07e34cce18680fd$export$59c99f3515d3493f(ms + $d07e34cce18680fd$var$DAYMILLIS, timeZone); + return $d07e34cce18680fd$var$getValidWallTimes(date, timeZone, earlier, later); +} +function $d07e34cce18680fd$var$getValidWallTimes(date, timeZone, earlier, later) { + let found = earlier === later ? [ + earlier + ] : [ + earlier, + later + ]; + return found.filter((absolute)=>$d07e34cce18680fd$var$isValidWallTime(date, timeZone, absolute)); +} +function $d07e34cce18680fd$var$isValidWallTime(date, timeZone, absolute) { + let parts = $d07e34cce18680fd$var$getTimeZoneParts(absolute, timeZone); + return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second; +} +function $d07e34cce18680fd$export$5107c82f94518f5c(date, timeZone, disambiguation = 'compatible') { + let dateTime = $d07e34cce18680fd$export$b21e0b124e224484(date); + // Fast path: if the time zone is UTC, use native Date. + if (timeZone === 'UTC') return $d07e34cce18680fd$export$bd4fb2bc8bb06fb(dateTime); + // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date. + // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone, + // since native Date always uses the browser's timezone, not the overridden one. + if (timeZone === (0, $ad063034c8620db8$export$aa8b41735afcabd2)() && disambiguation === 'compatible' && !(0, $ad063034c8620db8$export$6ab69b273755230b)()) { + dateTime = $d07e34cce18680fd$export$b4a036af3fc0b032(dateTime, new (0, $93635573935797de$export$80ee6245ec4f29ec)()); + // Don't use Date constructor here because two-digit years are interpreted in the 20th century. + let date = new Date(); + let year = (0, $93635573935797de$export$c36e0ecb2d4fa69d)(dateTime.era, dateTime.year); + date.setFullYear(year, dateTime.month - 1, dateTime.day); + date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond); + return date.getTime(); + } + let ms = $d07e34cce18680fd$export$bd4fb2bc8bb06fb(dateTime); + let offsetBefore = $d07e34cce18680fd$export$59c99f3515d3493f(ms - $d07e34cce18680fd$var$DAYMILLIS, timeZone); + let offsetAfter = $d07e34cce18680fd$export$59c99f3515d3493f(ms + $d07e34cce18680fd$var$DAYMILLIS, timeZone); + let valid = $d07e34cce18680fd$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter); + if (valid.length === 1) return valid[0]; + if (valid.length > 1) switch(disambiguation){ + // 'compatible' means 'earlier' for "fall back" transitions + case 'compatible': + case 'earlier': + return valid[0]; + case 'later': + return valid[valid.length - 1]; + case 'reject': + throw new RangeError('Multiple possible absolute times found'); + } + switch(disambiguation){ + case 'earlier': + return Math.min(ms - offsetBefore, ms - offsetAfter); + // 'compatible' means 'later' for "spring forward" transitions + case 'compatible': + case 'later': + return Math.max(ms - offsetBefore, ms - offsetAfter); + case 'reject': + throw new RangeError('No such absolute time found'); + } +} +function $d07e34cce18680fd$export$e67a095c620b86fe(dateTime, timeZone, disambiguation = 'compatible') { + return new Date($d07e34cce18680fd$export$5107c82f94518f5c(dateTime, timeZone, disambiguation)); +} +function $d07e34cce18680fd$export$1b96692a1ba042ac(ms, timeZone) { + let offset = $d07e34cce18680fd$export$59c99f3515d3493f(ms, timeZone); + let date = new Date(ms + offset); + let year = date.getUTCFullYear(); + let month = date.getUTCMonth() + 1; + let day = date.getUTCDate(); + let hour = date.getUTCHours(); + let minute = date.getUTCMinutes(); + let second = date.getUTCSeconds(); + let millisecond = date.getUTCMilliseconds(); + return new (0, $2aaf608024c21ca1$export$d3b7288e7994edea)(year < 1 ? 'BC' : 'AD', year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond); +} +function $d07e34cce18680fd$export$e57ff100d91bd4b9(date, timeZone) { + return $d07e34cce18680fd$export$1b96692a1ba042ac(date.getTime(), timeZone); +} +function $d07e34cce18680fd$export$d7f92bcd3596b086(date) { + return $d07e34cce18680fd$export$e57ff100d91bd4b9(date, (0, $ad063034c8620db8$export$aa8b41735afcabd2)()); +} +function $d07e34cce18680fd$export$93522d1a439f3617(dateTime) { + return new (0, $2aaf608024c21ca1$export$99faa760c7908e4f)(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day); +} +function $d07e34cce18680fd$export$6f4d78149f3f53ac(date) { + return { + era: date.era, + year: date.year, + month: date.month, + day: date.day + }; +} +function $d07e34cce18680fd$export$4d0393e732857be5(date) { + return { + hour: date.hour, + minute: date.minute, + second: date.second, + millisecond: date.millisecond + }; +} +function $d07e34cce18680fd$export$b21e0b124e224484(date, time) { + let hour = 0, minute = 0, second = 0, millisecond = 0; + if ('timeZone' in date) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = date); + else if ('hour' in date && !time) return date; + if (time) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = time); + return new (0, $2aaf608024c21ca1$export$ca871e8dbb80966f)(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond); +} +function $d07e34cce18680fd$export$d33f79e3ffc3dc83(dateTime) { + return new (0, $2aaf608024c21ca1$export$680ea196effce5f)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond); +} +function $d07e34cce18680fd$export$b4a036af3fc0b032(date, calendar) { + if ((0, $ad063034c8620db8$export$dbc69fd56b53d5e)(date.calendar, calendar)) return date; + let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date)); + let copy = date.copy(); + copy.calendar = calendar; + copy.era = calendarDate.era; + copy.year = calendarDate.year; + copy.month = calendarDate.month; + copy.day = calendarDate.day; + (0, $435a2ceaa8778ed8$export$c4e2ecac49351ef2)(copy); + return copy; +} +function $d07e34cce18680fd$export$84c95a83c799e074(date, timeZone, disambiguation) { + if (date instanceof (0, $2aaf608024c21ca1$export$d3b7288e7994edea)) { + if (date.timeZone === timeZone) return date; + return $d07e34cce18680fd$export$538b00033cc11c75(date, timeZone); + } + let ms = $d07e34cce18680fd$export$5107c82f94518f5c(date, timeZone, disambiguation); + return $d07e34cce18680fd$export$1b96692a1ba042ac(ms, timeZone); +} +function $d07e34cce18680fd$export$83aac07b4c37b25(date) { + let ms = $d07e34cce18680fd$export$bd4fb2bc8bb06fb(date) - date.offset; + return new Date(ms); +} +function $d07e34cce18680fd$export$538b00033cc11c75(date, timeZone) { + let ms = $d07e34cce18680fd$export$bd4fb2bc8bb06fb(date) - date.offset; + return $d07e34cce18680fd$export$b4a036af3fc0b032($d07e34cce18680fd$export$1b96692a1ba042ac(ms, timeZone), date.calendar); +} +function $d07e34cce18680fd$export$d9b67bc93c097491(date) { + return $d07e34cce18680fd$export$538b00033cc11c75(date, (0, $ad063034c8620db8$export$aa8b41735afcabd2)()); +} + + +export {$d07e34cce18680fd$export$bd4fb2bc8bb06fb as epochFromDate, $d07e34cce18680fd$export$b4a036af3fc0b032 as toCalendar, $d07e34cce18680fd$export$59c99f3515d3493f as getTimeZoneOffset, $d07e34cce18680fd$export$136f38efe7caf549 as possibleAbsolutes, $d07e34cce18680fd$export$5107c82f94518f5c as toAbsolute, $d07e34cce18680fd$export$b21e0b124e224484 as toCalendarDateTime, $d07e34cce18680fd$export$e67a095c620b86fe as toDate, $d07e34cce18680fd$export$1b96692a1ba042ac as fromAbsolute, $d07e34cce18680fd$export$e57ff100d91bd4b9 as fromDate, $d07e34cce18680fd$export$d7f92bcd3596b086 as fromDateToLocal, $d07e34cce18680fd$export$93522d1a439f3617 as toCalendarDate, $d07e34cce18680fd$export$6f4d78149f3f53ac as toDateFields, $d07e34cce18680fd$export$4d0393e732857be5 as toTimeFields, $d07e34cce18680fd$export$d33f79e3ffc3dc83 as toTime, $d07e34cce18680fd$export$84c95a83c799e074 as toZoned, $d07e34cce18680fd$export$538b00033cc11c75 as toTimeZone, $d07e34cce18680fd$export$83aac07b4c37b25 as zonedToDate, $d07e34cce18680fd$export$d9b67bc93c097491 as toLocalTimeZone}; +//# sourceMappingURL=conversion.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/conversion.mjs.map b/node_modules/@internationalized/date/dist/private/conversion.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..2aca963c961fec97f84e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a,KAAK;IAC/B,KAAK,GAAG,GAAG,aAAa,GAAG;IAC3B,CAAA,GAAA,yCAAQ,EAAE;IACV,OAAO;AACT;AAMO,SAAS,0CACd,IAAqD,EACrD,QAAgB,EAChB,cAA+B;IAE/B,IAAI,gBAAgB,CAAA,GAAA,yCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,yCAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {\n AnyCalendarDate,\n AnyDateTime,\n AnyTime,\n Calendar,\n DateFields,\n Disambiguation,\n TimeFields\n} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone, isEqualCalendar, isLocalTimeZoneOverridden} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime): number {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(\n year,\n date.month,\n date.day,\n date.hour,\n date.minute,\n date.second,\n date.millisecond\n );\n}\n\nfunction epochFromParts(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n second: number,\n millisecond: number\n): number {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string): number {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone,\n // since native Date always uses the browser's timezone, not the overridden one.\n if (ms > 0 && timeZone === getLocalTimeZone() && !isLocalTimeZoneOverridden()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year:\n namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(\n date: CalendarDateTime,\n timeZone: string,\n earlier: number,\n later: number\n): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return (\n date.year === parts.year &&\n date.month === parts.month &&\n date.day === parts.day &&\n date.hour === parts.hour &&\n date.minute === parts.minute &&\n date.second === parts.second\n );\n}\n\nexport function toAbsolute(\n date: CalendarDate | CalendarDateTime,\n timeZone: string,\n disambiguation: Disambiguation = 'compatible'\n): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n // Skip this fast path if the local timezone was explicitly overridden via setLocalTimeZone,\n // since native Date always uses the browser's timezone, not the overridden one.\n if (\n timeZone === getLocalTimeZone() &&\n disambiguation === 'compatible' &&\n !isLocalTimeZoneOverridden()\n ) {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(\n dateTime: CalendarDate | CalendarDateTime,\n timeZone: string,\n disambiguation: Disambiguation = 'compatible'\n): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(\n year < 1 ? 'BC' : 'AD',\n year < 1 ? -year + 1 : year,\n month,\n day,\n timeZone,\n offset,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\n/**\n * Takes a `Date` object and converts it to the time zone identifier for the current user.\n */\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/**\n * Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a\n * `CalendarDate`.\n */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(\n dateTime.calendar,\n dateTime.era,\n dateTime.year,\n dateTime.month,\n dateTime.day\n );\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the\n * time of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(\n date: CalendarDate | CalendarDateTime | ZonedDateTime,\n time?: AnyTime\n): CalendarDateTime {\n let hour = 0,\n minute = 0,\n second = 0,\n millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar(date: T, calendar: Calendar): T {\n if (isEqualCalendar(date.calendar, calendar)) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option\n * can be set to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(\n date: CalendarDate | CalendarDateTime | ZonedDateTime,\n timeZone: string,\n disambiguation?: Disambiguation\n): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime): Date {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/createCalendar.cjs b/node_modules/@internationalized/date/dist/private/createCalendar.cjs new file mode 100644 index 0000000000000000000000000000000000000000..72f2df53f76a8b018911a407bc6daa1241be9629 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/createCalendar.cjs @@ -0,0 +1,69 @@ +var $0ce473f03e925476$exports = require("./calendars/BuddhistCalendar.cjs"); +var $b6b43214f5cff964$exports = require("./calendars/EthiopicCalendar.cjs"); +var $05031860ba2f881f$exports = require("./calendars/GregorianCalendar.cjs"); +var $1aa25867248bd474$exports = require("./calendars/HebrewCalendar.cjs"); +var $9dc8610ad30fbfe5$exports = require("./calendars/IndianCalendar.cjs"); +var $fbcc6aba7cd7f47c$exports = require("./calendars/IslamicCalendar.cjs"); +var $a90e2192fa9a0f41$exports = require("./calendars/JapaneseCalendar.cjs"); +var $4100faec94dc031c$exports = require("./calendars/PersianCalendar.cjs"); +var $2dab1d4ea1fc722b$exports = require("./calendars/TaiwanCalendar.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "createCalendar", function () { return $9d3159c6111892aa$export$dd0bbc9b26defe37; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + + + + +function $9d3159c6111892aa$export$dd0bbc9b26defe37(name) { + switch(name){ + case 'buddhist': + return new (0, $0ce473f03e925476$exports.BuddhistCalendar)(); + case 'ethiopic': + return new (0, $b6b43214f5cff964$exports.EthiopicCalendar)(); + case 'ethioaa': + return new (0, $b6b43214f5cff964$exports.EthiopicAmeteAlemCalendar)(); + case 'coptic': + return new (0, $b6b43214f5cff964$exports.CopticCalendar)(); + case 'hebrew': + return new (0, $1aa25867248bd474$exports.HebrewCalendar)(); + case 'indian': + return new (0, $9dc8610ad30fbfe5$exports.IndianCalendar)(); + case 'islamic-civil': + return new (0, $fbcc6aba7cd7f47c$exports.IslamicCivilCalendar)(); + case 'islamic-tbla': + return new (0, $fbcc6aba7cd7f47c$exports.IslamicTabularCalendar)(); + case 'islamic-umalqura': + return new (0, $fbcc6aba7cd7f47c$exports.IslamicUmalquraCalendar)(); + case 'japanese': + return new (0, $a90e2192fa9a0f41$exports.JapaneseCalendar)(); + case 'persian': + return new (0, $4100faec94dc031c$exports.PersianCalendar)(); + case 'roc': + return new (0, $2dab1d4ea1fc722b$exports.TaiwanCalendar)(); + case 'gregory': + default: + return new (0, $05031860ba2f881f$exports.GregorianCalendar)(); + } +} + + +//# sourceMappingURL=createCalendar.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/createCalendar.cjs.map b/node_modules/@internationalized/date/dist/private/createCalendar.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..8cc9b3137aabdd0f2e1f45a958f2a6385baa8f29 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/createCalendar.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAsBM,SAAS,0CAAe,IAAwB;IACrD,OAAQ;QACN,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,0CAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,0CAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,mDAAwB;QACrC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,wCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,wCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,wCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,8CAAmB;QAChC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,gDAAqB;QAClC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,iDAAsB;QACnC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,0CAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAc;QAC3B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,wCAAa;QAC1B,KAAK;QACL;YACE,OAAO,IAAI,CAAA,GAAA,2CAAgB;IAC/B;AACF","sources":["packages/@internationalized/date/src/createCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {BuddhistCalendar} from './calendars/BuddhistCalendar';\nimport {Calendar, CalendarIdentifier} from './types';\nimport {\n CopticCalendar,\n EthiopicAmeteAlemCalendar,\n EthiopicCalendar\n} from './calendars/EthiopicCalendar';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {HebrewCalendar} from './calendars/HebrewCalendar';\nimport {IndianCalendar} from './calendars/IndianCalendar';\nimport {\n IslamicCivilCalendar,\n IslamicTabularCalendar,\n IslamicUmalquraCalendar\n} from './calendars/IslamicCalendar';\nimport {JapaneseCalendar} from './calendars/JapaneseCalendar';\nimport {PersianCalendar} from './calendars/PersianCalendar';\nimport {TaiwanCalendar} from './calendars/TaiwanCalendar';\n\n/** Creates a `Calendar` instance from a Unicode calendar identifier string. */\nexport function createCalendar(name: CalendarIdentifier): Calendar {\n switch (name) {\n case 'buddhist':\n return new BuddhistCalendar();\n case 'ethiopic':\n return new EthiopicCalendar();\n case 'ethioaa':\n return new EthiopicAmeteAlemCalendar();\n case 'coptic':\n return new CopticCalendar();\n case 'hebrew':\n return new HebrewCalendar();\n case 'indian':\n return new IndianCalendar();\n case 'islamic-civil':\n return new IslamicCivilCalendar();\n case 'islamic-tbla':\n return new IslamicTabularCalendar();\n case 'islamic-umalqura':\n return new IslamicUmalquraCalendar();\n case 'japanese':\n return new JapaneseCalendar();\n case 'persian':\n return new PersianCalendar();\n case 'roc':\n return new TaiwanCalendar();\n case 'gregory':\n default:\n return new GregorianCalendar();\n }\n}\n"],"names":[],"version":3,"file":"createCalendar.cjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/createCalendar.js b/node_modules/@internationalized/date/dist/private/createCalendar.js new file mode 100644 index 0000000000000000000000000000000000000000..2646bf4b1ca31db2812cbee9941f73f6743cc50a --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/createCalendar.js @@ -0,0 +1,64 @@ +import {BuddhistCalendar as $6f54c4fe66fc5ed5$export$42d20a78301dee44} from "./calendars/BuddhistCalendar.js"; +import {CopticCalendar as $ca8f5bca40aaf2d4$export$fe6243cbe1a4b7c1, EthiopicAmeteAlemCalendar as $ca8f5bca40aaf2d4$export$d72e0c37005a4914, EthiopicCalendar as $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d} from "./calendars/EthiopicCalendar.js"; +import {GregorianCalendar as $f25df78da1f6b40f$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.js"; +import {HebrewCalendar as $f6eb69e87cd1adc1$export$ca405048b8fb5af} from "./calendars/HebrewCalendar.js"; +import {IndianCalendar as $a07127433beb6bf1$export$39f31c639fa15726} from "./calendars/IndianCalendar.js"; +import {IslamicCivilCalendar as $a938ddf4fc940323$export$2066795aadd37bfc, IslamicTabularCalendar as $a938ddf4fc940323$export$37f0887f2f9d22f7, IslamicUmalquraCalendar as $a938ddf4fc940323$export$5baab4758c231076} from "./calendars/IslamicCalendar.js"; +import {JapaneseCalendar as $97f08bcb2befa667$export$b746ab2b60cdffbf} from "./calendars/JapaneseCalendar.js"; +import {PersianCalendar as $3e485caf6e85028a$export$37fccdbfd14c5939} from "./calendars/PersianCalendar.js"; +import {TaiwanCalendar as $0e7b6ab888014459$export$65e01080afcb0799} from "./calendars/TaiwanCalendar.js"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + + + + +function $d36eda2e2bc2be5a$export$dd0bbc9b26defe37(name) { + switch(name){ + case 'buddhist': + return new (0, $6f54c4fe66fc5ed5$export$42d20a78301dee44)(); + case 'ethiopic': + return new (0, $ca8f5bca40aaf2d4$export$26ba6eab5e20cd7d)(); + case 'ethioaa': + return new (0, $ca8f5bca40aaf2d4$export$d72e0c37005a4914)(); + case 'coptic': + return new (0, $ca8f5bca40aaf2d4$export$fe6243cbe1a4b7c1)(); + case 'hebrew': + return new (0, $f6eb69e87cd1adc1$export$ca405048b8fb5af)(); + case 'indian': + return new (0, $a07127433beb6bf1$export$39f31c639fa15726)(); + case 'islamic-civil': + return new (0, $a938ddf4fc940323$export$2066795aadd37bfc)(); + case 'islamic-tbla': + return new (0, $a938ddf4fc940323$export$37f0887f2f9d22f7)(); + case 'islamic-umalqura': + return new (0, $a938ddf4fc940323$export$5baab4758c231076)(); + case 'japanese': + return new (0, $97f08bcb2befa667$export$b746ab2b60cdffbf)(); + case 'persian': + return new (0, $3e485caf6e85028a$export$37fccdbfd14c5939)(); + case 'roc': + return new (0, $0e7b6ab888014459$export$65e01080afcb0799)(); + case 'gregory': + default: + return new (0, $f25df78da1f6b40f$export$80ee6245ec4f29ec)(); + } +} + + +export {$d36eda2e2bc2be5a$export$dd0bbc9b26defe37 as createCalendar}; +//# sourceMappingURL=createCalendar.js.map diff --git a/node_modules/@internationalized/date/dist/private/createCalendar.js.map b/node_modules/@internationalized/date/dist/private/createCalendar.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6317e5b0571b07c43500c6bffe4378189edb3222 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/createCalendar.js.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAsBM,SAAS,0CAAe,IAAwB;IACrD,OAAQ;QACN,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAwB;QACrC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,wCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAmB;QAChC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAqB;QAClC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAsB;QACnC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAc;QAC3B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAa;QAC1B,KAAK;QACL;YACE,OAAO,IAAI,CAAA,GAAA,yCAAgB;IAC/B;AACF","sources":["packages/@internationalized/date/src/createCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {BuddhistCalendar} from './calendars/BuddhistCalendar';\nimport {Calendar, CalendarIdentifier} from './types';\nimport {\n CopticCalendar,\n EthiopicAmeteAlemCalendar,\n EthiopicCalendar\n} from './calendars/EthiopicCalendar';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {HebrewCalendar} from './calendars/HebrewCalendar';\nimport {IndianCalendar} from './calendars/IndianCalendar';\nimport {\n IslamicCivilCalendar,\n IslamicTabularCalendar,\n IslamicUmalquraCalendar\n} from './calendars/IslamicCalendar';\nimport {JapaneseCalendar} from './calendars/JapaneseCalendar';\nimport {PersianCalendar} from './calendars/PersianCalendar';\nimport {TaiwanCalendar} from './calendars/TaiwanCalendar';\n\n/** Creates a `Calendar` instance from a Unicode calendar identifier string. */\nexport function createCalendar(name: CalendarIdentifier): Calendar {\n switch (name) {\n case 'buddhist':\n return new BuddhistCalendar();\n case 'ethiopic':\n return new EthiopicCalendar();\n case 'ethioaa':\n return new EthiopicAmeteAlemCalendar();\n case 'coptic':\n return new CopticCalendar();\n case 'hebrew':\n return new HebrewCalendar();\n case 'indian':\n return new IndianCalendar();\n case 'islamic-civil':\n return new IslamicCivilCalendar();\n case 'islamic-tbla':\n return new IslamicTabularCalendar();\n case 'islamic-umalqura':\n return new IslamicUmalquraCalendar();\n case 'japanese':\n return new JapaneseCalendar();\n case 'persian':\n return new PersianCalendar();\n case 'roc':\n return new TaiwanCalendar();\n case 'gregory':\n default:\n return new GregorianCalendar();\n }\n}\n"],"names":[],"version":3,"file":"createCalendar.js.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/createCalendar.mjs b/node_modules/@internationalized/date/dist/private/createCalendar.mjs new file mode 100644 index 0000000000000000000000000000000000000000..289a100525348e8d495fbc6efd497cba261361b4 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/createCalendar.mjs @@ -0,0 +1,64 @@ +import {BuddhistCalendar as $63d4eafd4d826996$export$42d20a78301dee44} from "./calendars/BuddhistCalendar.mjs"; +import {CopticCalendar as $97cfca9efd59523d$export$fe6243cbe1a4b7c1, EthiopicAmeteAlemCalendar as $97cfca9efd59523d$export$d72e0c37005a4914, EthiopicCalendar as $97cfca9efd59523d$export$26ba6eab5e20cd7d} from "./calendars/EthiopicCalendar.mjs"; +import {GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.mjs"; +import {HebrewCalendar as $f39495b96f9dbac6$export$ca405048b8fb5af} from "./calendars/HebrewCalendar.mjs"; +import {IndianCalendar as $11fa67a177e45470$export$39f31c639fa15726} from "./calendars/IndianCalendar.mjs"; +import {IslamicCivilCalendar as $fd4f9bc1ba0e49a8$export$2066795aadd37bfc, IslamicTabularCalendar as $fd4f9bc1ba0e49a8$export$37f0887f2f9d22f7, IslamicUmalquraCalendar as $fd4f9bc1ba0e49a8$export$5baab4758c231076} from "./calendars/IslamicCalendar.mjs"; +import {JapaneseCalendar as $34b940b49ba042df$export$b746ab2b60cdffbf} from "./calendars/JapaneseCalendar.mjs"; +import {PersianCalendar as $a0cc0739a536c3b1$export$37fccdbfd14c5939} from "./calendars/PersianCalendar.mjs"; +import {TaiwanCalendar as $c009cc5f64923054$export$65e01080afcb0799} from "./calendars/TaiwanCalendar.mjs"; + +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + + + + + + + + +function $84102b64e5ca022f$export$dd0bbc9b26defe37(name) { + switch(name){ + case 'buddhist': + return new (0, $63d4eafd4d826996$export$42d20a78301dee44)(); + case 'ethiopic': + return new (0, $97cfca9efd59523d$export$26ba6eab5e20cd7d)(); + case 'ethioaa': + return new (0, $97cfca9efd59523d$export$d72e0c37005a4914)(); + case 'coptic': + return new (0, $97cfca9efd59523d$export$fe6243cbe1a4b7c1)(); + case 'hebrew': + return new (0, $f39495b96f9dbac6$export$ca405048b8fb5af)(); + case 'indian': + return new (0, $11fa67a177e45470$export$39f31c639fa15726)(); + case 'islamic-civil': + return new (0, $fd4f9bc1ba0e49a8$export$2066795aadd37bfc)(); + case 'islamic-tbla': + return new (0, $fd4f9bc1ba0e49a8$export$37f0887f2f9d22f7)(); + case 'islamic-umalqura': + return new (0, $fd4f9bc1ba0e49a8$export$5baab4758c231076)(); + case 'japanese': + return new (0, $34b940b49ba042df$export$b746ab2b60cdffbf)(); + case 'persian': + return new (0, $a0cc0739a536c3b1$export$37fccdbfd14c5939)(); + case 'roc': + return new (0, $c009cc5f64923054$export$65e01080afcb0799)(); + case 'gregory': + default: + return new (0, $93635573935797de$export$80ee6245ec4f29ec)(); + } +} + + +export {$84102b64e5ca022f$export$dd0bbc9b26defe37 as createCalendar}; +//# sourceMappingURL=createCalendar.mjs.map diff --git a/node_modules/@internationalized/date/dist/private/createCalendar.mjs.map b/node_modules/@internationalized/date/dist/private/createCalendar.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..37adf4a99ca5a55bd435c76103ebfb1f87cd8aa4 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/createCalendar.mjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAsBM,SAAS,0CAAe,IAAwB;IACrD,OAAQ;QACN,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAwB;QACrC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,wCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAa;QAC1B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAmB;QAChC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAqB;QAClC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAsB;QACnC,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAe;QAC5B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAc;QAC3B,KAAK;YACH,OAAO,IAAI,CAAA,GAAA,yCAAa;QAC1B,KAAK;QACL;YACE,OAAO,IAAI,CAAA,GAAA,yCAAgB;IAC/B;AACF","sources":["packages/@internationalized/date/src/createCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {BuddhistCalendar} from './calendars/BuddhistCalendar';\nimport {Calendar, CalendarIdentifier} from './types';\nimport {\n CopticCalendar,\n EthiopicAmeteAlemCalendar,\n EthiopicCalendar\n} from './calendars/EthiopicCalendar';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {HebrewCalendar} from './calendars/HebrewCalendar';\nimport {IndianCalendar} from './calendars/IndianCalendar';\nimport {\n IslamicCivilCalendar,\n IslamicTabularCalendar,\n IslamicUmalquraCalendar\n} from './calendars/IslamicCalendar';\nimport {JapaneseCalendar} from './calendars/JapaneseCalendar';\nimport {PersianCalendar} from './calendars/PersianCalendar';\nimport {TaiwanCalendar} from './calendars/TaiwanCalendar';\n\n/** Creates a `Calendar` instance from a Unicode calendar identifier string. */\nexport function createCalendar(name: CalendarIdentifier): Calendar {\n switch (name) {\n case 'buddhist':\n return new BuddhistCalendar();\n case 'ethiopic':\n return new EthiopicCalendar();\n case 'ethioaa':\n return new EthiopicAmeteAlemCalendar();\n case 'coptic':\n return new CopticCalendar();\n case 'hebrew':\n return new HebrewCalendar();\n case 'indian':\n return new IndianCalendar();\n case 'islamic-civil':\n return new IslamicCivilCalendar();\n case 'islamic-tbla':\n return new IslamicTabularCalendar();\n case 'islamic-umalqura':\n return new IslamicUmalquraCalendar();\n case 'japanese':\n return new JapaneseCalendar();\n case 'persian':\n return new PersianCalendar();\n case 'roc':\n return new TaiwanCalendar();\n case 'gregory':\n default:\n return new GregorianCalendar();\n }\n}\n"],"names":[],"version":3,"file":"createCalendar.mjs.map"} \ No newline at end of file diff --git a/node_modules/@internationalized/date/dist/private/manipulation.cjs b/node_modules/@internationalized/date/dist/private/manipulation.cjs new file mode 100644 index 0000000000000000000000000000000000000000..a8f0a03ea7bb0187514b36a81e5b7807bb75806d --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/manipulation.cjs @@ -0,0 +1,359 @@ +var $e13115b3b86b9007$exports = require("./conversion.cjs"); +var $05031860ba2f881f$exports = require("./calendars/GregorianCalendar.cjs"); + + +function $parcel$export(e, n, v, s) { + Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); +} + +$parcel$export(module.exports, "add", function () { return $19485913bea41f19$export$e16d8520af44a096; }); +$parcel$export(module.exports, "constrain", function () { return $19485913bea41f19$export$c4e2ecac49351ef2; }); +$parcel$export(module.exports, "subtract", function () { return $19485913bea41f19$export$4e2d2ead65e5f7e3; }); +$parcel$export(module.exports, "set", function () { return $19485913bea41f19$export$adaa4cf7ef1b65be; }); +$parcel$export(module.exports, "setTime", function () { return $19485913bea41f19$export$e5d5e1c1822b6e56; }); +$parcel$export(module.exports, "constrainTime", function () { return $19485913bea41f19$export$7555de1e070510cb; }); +$parcel$export(module.exports, "addTime", function () { return $19485913bea41f19$export$7ed87b6bc2506470; }); +$parcel$export(module.exports, "subtractTime", function () { return $19485913bea41f19$export$fe34d3a381cd7501; }); +$parcel$export(module.exports, "cycleDate", function () { return $19485913bea41f19$export$d52ced6badfb9a4c; }); +$parcel$export(module.exports, "cycleTime", function () { return $19485913bea41f19$export$dd02b3e0007dfe28; }); +$parcel$export(module.exports, "addZoned", function () { return $19485913bea41f19$export$96b1d28349274637; }); +$parcel$export(module.exports, "subtractZoned", function () { return $19485913bea41f19$export$6814caac34ca03c7; }); +$parcel$export(module.exports, "cycleZoned", function () { return $19485913bea41f19$export$9a297d111fc86b79; }); +$parcel$export(module.exports, "setZoned", function () { return $19485913bea41f19$export$31b5430eb18be4f8; }); +/* + * Copyright 2020 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +const $19485913bea41f19$var$ONE_HOUR = 3600000; +function $19485913bea41f19$export$e16d8520af44a096(date, duration) { + let mutableDate = date.copy(); + let days = 'hour' in mutableDate ? $19485913bea41f19$var$addTimeFields(mutableDate, duration) : 0; + $19485913bea41f19$var$addYears(mutableDate, duration.years || 0); + if (mutableDate.calendar.balanceYearMonth) mutableDate.calendar.balanceYearMonth(mutableDate, date); + mutableDate.month += duration.months || 0; + $19485913bea41f19$var$balanceYearMonth(mutableDate); + $19485913bea41f19$var$constrainMonthDay(mutableDate); + mutableDate.day += (duration.weeks || 0) * 7; + mutableDate.day += duration.days || 0; + mutableDate.day += days; + $19485913bea41f19$var$balanceDay(mutableDate); + if (mutableDate.calendar.balanceDate) mutableDate.calendar.balanceDate(mutableDate); + // Constrain in case adding ended up with a date outside the valid range for the calendar system. + // The behavior here is slightly different than when constraining in the `set` function in that + // we adjust smaller fields to their minimum/maximum values rather than constraining each field + // individually. This matches the general behavior of `add` vs `set` regarding how fields are balanced. + if (mutableDate.year < 1) { + mutableDate.year = 1; + mutableDate.month = 1; + mutableDate.day = 1; + } + let maxYear = mutableDate.calendar.getYearsInEra(mutableDate); + if (mutableDate.year > maxYear) { + let isInverseEra = mutableDate.calendar.isInverseEra?.(mutableDate); + mutableDate.year = maxYear; + mutableDate.month = isInverseEra ? 1 : mutableDate.calendar.getMonthsInYear(mutableDate); + mutableDate.day = isInverseEra ? 1 : mutableDate.calendar.getDaysInMonth(mutableDate); + } + if (mutableDate.month < 1) { + mutableDate.month = 1; + mutableDate.day = 1; + } + let maxMonth = mutableDate.calendar.getMonthsInYear(mutableDate); + if (mutableDate.month > maxMonth) { + mutableDate.month = maxMonth; + mutableDate.day = mutableDate.calendar.getDaysInMonth(mutableDate); + } + mutableDate.day = Math.max(1, Math.min(mutableDate.calendar.getDaysInMonth(mutableDate), mutableDate.day)); + return mutableDate; +} +function $19485913bea41f19$var$addYears(date, years) { + if (date.calendar.isInverseEra?.(date)) years = -years; + date.year += years; +} +function $19485913bea41f19$var$balanceYearMonth(date) { + while(date.month < 1){ + $19485913bea41f19$var$addYears(date, -1); + date.month += date.calendar.getMonthsInYear(date); + } + let monthsInYear = 0; + while(date.month > (monthsInYear = date.calendar.getMonthsInYear(date))){ + date.month -= monthsInYear; + $19485913bea41f19$var$addYears(date, 1); + } +} +function $19485913bea41f19$var$balanceDay(date) { + while(date.day < 1){ + date.month--; + $19485913bea41f19$var$balanceYearMonth(date); + date.day += date.calendar.getDaysInMonth(date); + } + while(date.day > date.calendar.getDaysInMonth(date)){ + date.day -= date.calendar.getDaysInMonth(date); + date.month++; + $19485913bea41f19$var$balanceYearMonth(date); + } +} +function $19485913bea41f19$var$constrainMonthDay(date) { + date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month)); + date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day)); +} +function $19485913bea41f19$export$c4e2ecac49351ef2(date) { + if (date.calendar.constrainDate) date.calendar.constrainDate(date); + date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year)); + $19485913bea41f19$var$constrainMonthDay(date); +} +function $19485913bea41f19$export$3e2544e88a25bff8(duration) { + let inverseDuration = {}; + for(let key in duration)if (typeof duration[key] === 'number') inverseDuration[key] = -duration[key]; + return inverseDuration; +} +function $19485913bea41f19$export$4e2d2ead65e5f7e3(date, duration) { + return $19485913bea41f19$export$e16d8520af44a096(date, $19485913bea41f19$export$3e2544e88a25bff8(duration)); +} +function $19485913bea41f19$export$adaa4cf7ef1b65be(date, fields) { + let mutableDate = date.copy(); + if (fields.era != null) mutableDate.era = fields.era; + if (fields.year != null) mutableDate.year = fields.year; + if (fields.month != null) mutableDate.month = fields.month; + if (fields.day != null) mutableDate.day = fields.day; + $19485913bea41f19$export$c4e2ecac49351ef2(mutableDate); + return mutableDate; +} +function $19485913bea41f19$export$e5d5e1c1822b6e56(value, fields) { + let mutableValue = value.copy(); + if (fields.hour != null) mutableValue.hour = fields.hour; + if (fields.minute != null) mutableValue.minute = fields.minute; + if (fields.second != null) mutableValue.second = fields.second; + if (fields.millisecond != null) mutableValue.millisecond = fields.millisecond; + $19485913bea41f19$export$7555de1e070510cb(mutableValue); + return mutableValue; +} +function $19485913bea41f19$var$balanceTime(time) { + time.second += Math.floor(time.millisecond / 1000); + time.millisecond = $19485913bea41f19$var$nonNegativeMod(time.millisecond, 1000); + time.minute += Math.floor(time.second / 60); + time.second = $19485913bea41f19$var$nonNegativeMod(time.second, 60); + time.hour += Math.floor(time.minute / 60); + time.minute = $19485913bea41f19$var$nonNegativeMod(time.minute, 60); + let days = Math.floor(time.hour / 24); + time.hour = $19485913bea41f19$var$nonNegativeMod(time.hour, 24); + return days; +} +function $19485913bea41f19$export$7555de1e070510cb(time) { + time.millisecond = Math.max(0, Math.min(time.millisecond, 999)); + time.second = Math.max(0, Math.min(time.second, 59)); + time.minute = Math.max(0, Math.min(time.minute, 59)); + time.hour = Math.max(0, Math.min(time.hour, 23)); +} +function $19485913bea41f19$var$nonNegativeMod(a, b) { + let result = a % b; + if (result < 0) result += b; + return result; +} +function $19485913bea41f19$var$addTimeFields(time, duration) { + time.hour += duration.hours || 0; + time.minute += duration.minutes || 0; + time.second += duration.seconds || 0; + time.millisecond += duration.milliseconds || 0; + return $19485913bea41f19$var$balanceTime(time); +} +function $19485913bea41f19$export$7ed87b6bc2506470(time, duration) { + let res = time.copy(); + $19485913bea41f19$var$addTimeFields(res, duration); + return res; +} +function $19485913bea41f19$export$fe34d3a381cd7501(time, duration) { + return $19485913bea41f19$export$7ed87b6bc2506470(time, $19485913bea41f19$export$3e2544e88a25bff8(duration)); +} +function $19485913bea41f19$export$d52ced6badfb9a4c(value, field, amount, options) { + let mutable = value.copy(); + switch(field){ + case 'era': + { + let eras = value.calendar.getEras(); + let eraIndex = eras.indexOf(value.era); + if (eraIndex < 0) throw new Error('Invalid era: ' + value.era); + eraIndex = $19485913bea41f19$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options?.round); + mutable.era = eras[eraIndex]; + // Constrain the year and other fields within the era, so the era doesn't change when we balance below. + $19485913bea41f19$export$c4e2ecac49351ef2(mutable); + break; + } + case 'year': + if (mutable.calendar.isInverseEra?.(mutable)) amount = -amount; + // The year field should not cycle within the era as that can cause weird behavior affecting other fields. + // We need to also allow values < 1 so that decrementing goes to the previous era. If we get -Infinity back + // we know we wrapped around after reaching 9999 (the maximum), so set the year back to 1. + mutable.year = $19485913bea41f19$var$cycleValue(value.year, amount, -Infinity, 9999, options?.round); + if (mutable.year === -Infinity) mutable.year = 1; + if (mutable.calendar.balanceYearMonth) mutable.calendar.balanceYearMonth(mutable, value); + break; + case 'month': + mutable.month = $19485913bea41f19$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options?.round); + break; + case 'day': + mutable.day = $19485913bea41f19$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options?.round); + break; + default: + throw new Error('Unsupported field ' + field); + } + if (value.calendar.balanceDate) value.calendar.balanceDate(mutable); + $19485913bea41f19$export$c4e2ecac49351ef2(mutable); + return mutable; +} +function $19485913bea41f19$export$dd02b3e0007dfe28(value, field, amount, options) { + let mutable = value.copy(); + switch(field){ + case 'hour': + { + let hours = value.hour; + let min = 0; + let max = 23; + if (options?.hourCycle === 12) { + let isPM = hours >= 12; + min = isPM ? 12 : 0; + max = isPM ? 23 : 11; + } + mutable.hour = $19485913bea41f19$var$cycleValue(hours, amount, min, max, options?.round); + break; + } + case 'minute': + mutable.minute = $19485913bea41f19$var$cycleValue(value.minute, amount, 0, 59, options?.round); + break; + case 'second': + mutable.second = $19485913bea41f19$var$cycleValue(value.second, amount, 0, 59, options?.round); + break; + case 'millisecond': + mutable.millisecond = $19485913bea41f19$var$cycleValue(value.millisecond, amount, 0, 999, options?.round); + break; + default: + throw new Error('Unsupported field ' + field); + } + return mutable; +} +function $19485913bea41f19$var$cycleValue(value, amount, min, max, round = false) { + if (round) { + value += Math.sign(amount); + if (value < min) value = max; + let div = Math.abs(amount); + if (amount > 0) value = Math.ceil(value / div) * div; + else value = Math.floor(value / div) * div; + if (value > max) value = min; + } else { + value += amount; + if (value < min) value = max - (min - value - 1); + else if (value > max) value = min + (value - max - 1); + } + return value; +} +function $19485913bea41f19$export$96b1d28349274637(dateTime, duration) { + let ms; + if (duration.years != null && duration.years !== 0 || duration.months != null && duration.months !== 0 || duration.weeks != null && duration.weeks !== 0 || duration.days != null && duration.days !== 0) { + let res = $19485913bea41f19$export$e16d8520af44a096((0, $e13115b3b86b9007$exports.toCalendarDateTime)(dateTime), { + years: duration.years, + months: duration.months, + weeks: duration.weeks, + days: duration.days + }); + // Changing the date may change the timezone offset, so we need to recompute + // using the 'compatible' disambiguation. + ms = (0, $e13115b3b86b9007$exports.toAbsolute)(res, dateTime.timeZone); + } else // Otherwise, preserve the offset of the original date. + ms = (0, $e13115b3b86b9007$exports.epochFromDate)(dateTime) - dateTime.offset; + // Perform time manipulation in milliseconds rather than on the original time fields to account for DST. + // For example, adding one hour during a DST transition may result in the hour field staying the same or + // skipping an hour. This results in the offset field changing value instead of the specified field. + ms += duration.milliseconds || 0; + ms += (duration.seconds || 0) * 1000; + ms += (duration.minutes || 0) * 60000; + ms += (duration.hours || 0) * 3600000; + let res = (0, $e13115b3b86b9007$exports.fromAbsolute)(ms, dateTime.timeZone); + return (0, $e13115b3b86b9007$exports.toCalendar)(res, dateTime.calendar); +} +function $19485913bea41f19$export$6814caac34ca03c7(dateTime, duration) { + return $19485913bea41f19$export$96b1d28349274637(dateTime, $19485913bea41f19$export$3e2544e88a25bff8(duration)); +} +function $19485913bea41f19$export$9a297d111fc86b79(dateTime, field, amount, options) { + // For date fields, we want the time to remain consistent and the UTC offset to potentially change to account for DST changes. + // For time fields, we want the time to change by the amount given. This may result in the hour field staying the same, but the UTC + // offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition. + switch(field){ + case 'hour': + { + let min = 0; + let max = 23; + if (options?.hourCycle === 12) { + let isPM = dateTime.hour >= 12; + min = isPM ? 12 : 0; + max = isPM ? 23 : 11; + } + // The minimum and maximum hour may be affected by daylight saving time. + // For example, it might jump forward at midnight, and skip 1am. + // Or it might end at midnight and repeat the 11pm hour. To handle this, we get + // the possible absolute times for the min and max, and find the maximum range + // that is within the current day. + let plainDateTime = (0, $e13115b3b86b9007$exports.toCalendarDateTime)(dateTime); + let minDate = (0, $e13115b3b86b9007$exports.toCalendar)($19485913bea41f19$export$e5d5e1c1822b6e56(plainDateTime, { + hour: min + }), new (0, $05031860ba2f881f$exports.GregorianCalendar)()); + let minAbsolute = [ + (0, $e13115b3b86b9007$exports.toAbsolute)(minDate, dateTime.timeZone, 'earlier'), + (0, $e13115b3b86b9007$exports.toAbsolute)(minDate, dateTime.timeZone, 'later') + ].filter((ms)=>(0, $e13115b3b86b9007$exports.fromAbsolute)(ms, dateTime.timeZone).day === minDate.day)[0]; + let maxDate = (0, $e13115b3b86b9007$exports.toCalendar)($19485913bea41f19$export$e5d5e1c1822b6e56(plainDateTime, { + hour: max + }), new (0, $05031860ba2f881f$exports.GregorianCalendar)()); + let maxAbsolute = [ + (0, $e13115b3b86b9007$exports.toAbsolute)(maxDate, dateTime.timeZone, 'earlier'), + (0, $e13115b3b86b9007$exports.toAbsolute)(maxDate, dateTime.timeZone, 'later') + ].filter((ms)=>(0, $e13115b3b86b9007$exports.fromAbsolute)(ms, dateTime.timeZone).day === maxDate.day).pop(); + // Since hours may repeat, we need to operate on the absolute time in milliseconds. + // This is done in hours from the Unix epoch so that cycleValue works correctly, + // and then converted back to milliseconds. + let ms = (0, $e13115b3b86b9007$exports.epochFromDate)(dateTime) - dateTime.offset; + let hours = Math.floor(ms / $19485913bea41f19$var$ONE_HOUR); + let remainder = ms % $19485913bea41f19$var$ONE_HOUR; + ms = $19485913bea41f19$var$cycleValue(hours, amount, Math.floor(minAbsolute / $19485913bea41f19$var$ONE_HOUR), Math.floor(maxAbsolute / $19485913bea41f19$var$ONE_HOUR), options?.round) * $19485913bea41f19$var$ONE_HOUR + remainder; + // Now compute the new timezone offset, and convert the absolute time back to local time. + return (0, $e13115b3b86b9007$exports.toCalendar)((0, $e13115b3b86b9007$exports.fromAbsolute)(ms, dateTime.timeZone), dateTime.calendar); + } + case 'minute': + case 'second': + case 'millisecond': + // @ts-ignore + return $19485913bea41f19$export$dd02b3e0007dfe28(dateTime, field, amount, options); + case 'era': + case 'year': + case 'month': + case 'day': + { + let res = $19485913bea41f19$export$d52ced6badfb9a4c((0, $e13115b3b86b9007$exports.toCalendarDateTime)(dateTime), field, amount, options); + let ms = (0, $e13115b3b86b9007$exports.toAbsolute)(res, dateTime.timeZone); + return (0, $e13115b3b86b9007$exports.toCalendar)((0, $e13115b3b86b9007$exports.fromAbsolute)(ms, dateTime.timeZone), dateTime.calendar); + } + default: + throw new Error('Unsupported field ' + field); + } +} +function $19485913bea41f19$export$31b5430eb18be4f8(dateTime, fields, disambiguation) { + // Set the date/time fields, and recompute the UTC offset to account for DST changes. + // We also need to validate by converting back to a local time in case hours are skipped during forward DST transitions. + let plainDateTime = (0, $e13115b3b86b9007$exports.toCalendarDateTime)(dateTime); + let res = $19485913bea41f19$export$e5d5e1c1822b6e56($19485913bea41f19$export$adaa4cf7ef1b65be(plainDateTime, fields), fields); + // If the resulting plain date time values are equal, return the original time. + // We don't want to change the offset when setting the time to the same value. + if (res.compare(plainDateTime) === 0) return dateTime; + let ms = (0, $e13115b3b86b9007$exports.toAbsolute)(res, dateTime.timeZone, disambiguation); + return (0, $e13115b3b86b9007$exports.toCalendar)((0, $e13115b3b86b9007$exports.fromAbsolute)(ms, dateTime.timeZone), dateTime.calendar); +} + + +//# sourceMappingURL=manipulation.cjs.map diff --git a/node_modules/@internationalized/date/dist/private/manipulation.cjs.map b/node_modules/@internationalized/date/dist/private/manipulation.cjs.map new file mode 100644 index 0000000000000000000000000000000000000000..6ef04d9be336c9e4212bb4602b3489c07c55b2c6 --- /dev/null +++ b/node_modules/@internationalized/date/dist/private/manipulation.cjs.map @@ -0,0 +1 @@ +{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA4BD,MAAM,iCAAW;AAQV,SAAS,0CACd,IAAqC,EACrC,QAA0B;IAE1B,IAAI,cAAsD,KAAK,IAAI;IACnE,IAAI,OAAO,UAAU,cAAc,oCAAc,aAAa,YAAY;IAE1E,+BAAS,aAAa,SAAS,KAAK,IAAI;IACxC,IAAI,YAAY,QAAQ,CAAC,gBAAgB,EACvC,YAAY,QAAQ,CAAC,gBAAgB,CAAC,aAAa;IAGrD,YAAY,KAAK,IAAI,SAAS,MAAM,IAAI;IAExC,uCAAiB;IACjB,wCAAkB;IAElB,YAAY,GAAG,IAAI,AAAC,CAAA,SAAS,KAAK,IAAI,CAAA,IAAK;IAC3C,YAAY,GAAG,IAAI,SAAS,IAAI,IAAI;IACpC,YAAY,GAAG,IAAI;IAEnB,iCAAW;IAEX,IAAI,YAAY,QAAQ,CAAC,WAAW,EAClC,YAAY,QAAQ,CAAC,WAAW,CAAC;IAGnC,iGAAiG;IACjG,+FAA+F;IAC/F,+FAA+F;IAC/F,uGAAuG;IACvG,IAAI,YAAY,IAAI,GAAG,GAAG;QACxB,YAAY,IAAI,GAAG;QACnB,YAAY,KAAK,GAAG;QACpB,YAAY,GAAG,GAAG;IACpB;IAEA,IAAI,UAAU,YAAY,QAAQ,CAAC,aAAa,CAAC;IACjD,IAAI,YAAY,IAAI,GAAG,SAAS;QAC9B,IAAI,eAAe,YAA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IACvC,IAAI,MAAM,0CAAQ,0CAAI,eAAe,SAAS;IAE9C,+EAA+E;IAC/E,8EAA8E;IAC9E,IAAI,IAAI,OAAO,CAAC,mBAAmB,GACjC,OAAO;IAGT,IAAI,KAAK,CAAA,GAAA,oCAAS,EAAE,KAAK,SAAS,QAAQ,EAAE;IAC5C,OAAO,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,sCAAW,EAAE,IAAI,SAAS,QAAQ,GAAG,SAAS,QAAQ;AAC1E","sources":["packages/@internationalized/date/src/manipulation.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnyCalendarDate,\n AnyDateTime,\n AnyTime,\n CycleOptions,\n CycleTimeOptions,\n DateDuration,\n DateField,\n DateFields,\n DateTimeDuration,\n Disambiguation,\n TimeDuration,\n TimeField,\n TimeFields\n} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {\n epochFromDate,\n fromAbsolute,\n toAbsolute,\n toCalendar,\n toCalendarDateTime\n} from './conversion';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {Mutable} from './utils';\n\nconst ONE_HOUR = 3600000;\n\nexport function add(date: CalendarDateTime, duration: DateTimeDuration): CalendarDateTime;\nexport function add(date: CalendarDate, duration: DateDuration): CalendarDate;\nexport function add(\n date: CalendarDate | CalendarDateTime,\n duration: DateTimeDuration\n): CalendarDate | CalendarDateTime;\nexport function add(\n date: CalendarDate | CalendarDateTime,\n duration: DateTimeDuration\n): Mutable {\n let mutableDate: Mutable = date.copy();\n let days = 'hour' in mutableDate ? addTimeFields(mutableDate, duration) : 0;\n\n addYears(mutableDate, duration.years || 0);\n if (mutableDate.calendar.balanceYearMonth) {\n mutableDate.calendar.balanceYearMonth(mutableDate, date);\n }\n\n mutableDate.month += duration.months || 0;\n\n balanceYearMonth(mutableDate);\n constrainMonthDay(mutableDate);\n\n mutableDate.day += (duration.weeks || 0) * 7;\n mutableDate.day += duration.days || 0;\n mutableDate.day += days;\n\n balanceDay(mutableDate);\n\n if (mutableDate.calendar.balanceDate) {\n mutableDate.calendar.balanceDate(mutableDate);\n }\n\n // Constrain in case adding ended up with a date outside the valid range for the calendar system.\n // The behavior here is slightly different than when constraining in the `set` function in that\n // we adjust smaller fields to their minimum/maximum values rather than constraining each field\n // individually. This matches the general behavior of `add` vs `set` regarding how fields are balanced.\n if (mutableDate.year < 1) {\n mutableDate.year = 1;\n mutableDate.month = 1;\n mutableDate.day = 1;\n }\n\n let maxYear = mutableDate.calendar.getYearsInEra(mutableDate);\n if (mutableDate.year > maxYear) {\n let isInverseEra = mutableDate.calendar.isInverseEra?.(mutableDate);\n mutableDate.year = maxYear;\n mutableDate.month = isInverseEra ? 1 : mutableDate.calendar.getMonthsInYear(mutableDate);\n mutableDate.day = isInverseEra ? 1 : mutableDate.calendar.getDaysInMonth(mutableDate);\n }\n\n if (mutableDate.month < 1) {\n mutableDate.month = 1;\n mutableDate.day = 1;\n }\n\n let maxMonth = mutableDate.calendar.getMonthsInYear(mutableDate);\n if (mutableDate.month > maxMonth) {\n mutableDate.month = maxMonth;\n mutableDate.day = mutableDate.calendar.getDaysInMonth(mutableDate);\n }\n\n mutableDate.day = Math.max(\n 1,\n Math.min(mutableDate.calendar.getDaysInMonth(mutableDate), mutableDate.day)\n );\n return mutableDate;\n}\n\nfunction addYears(date: Mutable, years: number) {\n if (date.calendar.isInverseEra?.(date)) {\n years = -years;\n }\n\n date.year += years;\n}\n\nfunction balanceYearMonth(date: Mutable) {\n while (date.month < 1) {\n addYears(date, -1);\n date.month += date.calendar.getMonthsInYear(date);\n }\n\n let monthsInYear = 0;\n while (date.month > (monthsInYear = date.calendar.getMonthsInYear(date))) {\n date.month -= monthsInYear;\n addYears(date, 1);\n }\n}\n\nfunction balanceDay(date: Mutable) {\n while (date.day < 1) {\n date.month--;\n balanceYearMonth(date);\n date.day += date.calendar.getDaysInMonth(date);\n }\n\n while (date.day > date.calendar.getDaysInMonth(date)) {\n date.day -= date.calendar.getDaysInMonth(date);\n date.month++;\n balanceYearMonth(date);\n }\n}\n\nfunction constrainMonthDay(date: Mutable) {\n date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));\n date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));\n}\n\nexport function constrain(date: Mutable): void {\n if (date.calendar.constrainDate) {\n date.calendar.constrainDate(date);\n }\n\n date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));\n constrainMonthDay(date);\n}\n\nexport function invertDuration(duration: DateTimeDuration): DateTimeDuration {\n let inverseDuration = {};\n for (let key in duration) {\n if (typeof duration[key] === 'number') {\n inverseDuration[key] = -duration[key];\n }\n }\n\n return inverseDuration;\n}\n\nexport function subtract(date: CalendarDateTime, duration: DateTimeDuration): CalendarDateTime;\nexport function subtract(date: CalendarDate, duration: DateDuration): CalendarDate;\nexport function subtract(\n date: CalendarDate | CalendarDateTime,\n duration: DateTimeDuration\n): CalendarDate | CalendarDateTime {\n return add(date, invertDuration(duration));\n}\n\nexport function set(date: CalendarDateTime, fields: DateFields): CalendarDateTime;\nexport function set(date: CalendarDate, fields: DateFields): CalendarDate;\nexport function set(\n date: CalendarDate | CalendarDateTime,\n fields: DateFields\n): Mutable {\n let mutableDate: Mutable = date.copy();\n\n if (fields.era != null) {\n mutableDate.era = fields.era;\n }\n\n if (fields.year != null) {\n mutableDate.year = fields.year;\n }\n\n if (fields.month != null) {\n mutableDate.month = fields.month;\n }\n\n if (fields.day != null) {\n mutableDate.day = fields.day;\n }\n\n constrain(mutableDate);\n return mutableDate;\n}\n\nexport function setTime(value: CalendarDateTime, fields: TimeFields): CalendarDateTime;\nexport function setTime(value: Time, fields: TimeFields): Time;\nexport function setTime(\n value: Time | CalendarDateTime,\n fields: TimeFields\n): Mutable