From 9590493e171d17ba8421e0310afccb33d444ca73 Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Wed, 1 May 2024 11:21:30 +0330 Subject: [PATCH 01/16] fix babel-plugin-replace-imports patch --- babel.config.js | 3 ++- patches/babel-plugin-replace-imports@1.0.2.patch | 4 ++-- pnpm-lock.yaml | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/babel.config.js b/babel.config.js index c778fb946a352..d51d180e4931e 100644 --- a/babel.config.js +++ b/babel.config.js @@ -91,7 +91,8 @@ module.exports = function getBabelConfig(api) { { test: /date-fns/i, replacer: 'date-fns-v3', - ignoreFilenames: 'AdapterDateFns.ts', + // This option is provided by the `patches/babel-plugin-replace-imports@1.0.2.patch` patch + filenameIncludes: 'src/AdapterDateFnsV3/', }, ]); } diff --git a/patches/babel-plugin-replace-imports@1.0.2.patch b/patches/babel-plugin-replace-imports@1.0.2.patch index 0394347226df6..be94600572cda 100644 --- a/patches/babel-plugin-replace-imports@1.0.2.patch +++ b/patches/babel-plugin-replace-imports@1.0.2.patch @@ -1,8 +1,8 @@ diff --git a/lib/index.js b/lib/index.js -index 8da63adc141b73774c50363b31ee00001ccd9156..9712bcce64bfce59043f9a16c1f14d464bf82e8d 100644 +index 8da63adc141b73774c50363b31ee00001ccd9156..db49ed11479699f329f6b0bfb70fa73d6ad960e2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1 +1 @@ -'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.optionLabels=void 0,exports.getErrorMessage=getErrorMessage;var _lodash=require('lodash.isempty'),_lodash2=_interopRequireDefault(_lodash),_lodash3=require('lodash.isstring'),_lodash4=_interopRequireDefault(_lodash3),_lodash5=require('lodash.isregexp'),_lodash6=_interopRequireDefault(_lodash5),_lodash7=require('lodash.isobject'),_lodash8=_interopRequireDefault(_lodash7),_lodash9=require('lodash.isfunction'),_lodash10=_interopRequireDefault(_lodash9);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var PLUGIN='babel-plugin-replace-imports',ERRORS={0:'options are required.',1:'option is required.',2:'option must be a RegExp.',3:'option must be a String or a Function',4:'options item must be an Object.'},optionLabels=exports.optionLabels={test:'test',replacer:'replacer'};function getErrorMessage(code,text){var msg=((text?'\xAB'+text+'\xBB':'')+' '+ERRORS[code]).trim();return'\n'+PLUGIN+': '+msg}function init(_ref){function throwError(code,text){var msg=getErrorMessage(code,text);throw new Error(msg)}function getOption(option){return(!(0,_lodash8.default)(option)||(0,_lodash6.default)(option)||Array.isArray(option))&&throwError(4),option}function getTestOption(option){return!(0,_lodash6.default)(option)&&(0,_lodash2.default)(option)&&throwError(1,optionLabels.test),(0,_lodash6.default)(option)||throwError(2,optionLabels.test),option}function getReplacerListOption(option){return(0,_lodash10.default)(option)?[option]:((0,_lodash2.default)(option)&&throwError(1,optionLabels.replacer),Array.isArray(option)?option:[option])}function getReplacerOption(option){return(0,_lodash4.default)(option)||(0,_lodash10.default)(option)||throwError(3,optionLabels.replacer),option}var types=_ref.types;return{visitor:{ImportDeclaration:function ImportDeclaration(path,_ref2){var opts=_ref2.opts;if(!path.node.__processed){(0,_lodash2.default)(opts)&&throwError(0);var source=path.node.source.value,transforms=[],options=opts;Array.isArray(options)||(options=[opts]);for(var _ret,_loop=function(i){var opt=getOption(options[i]),regex=getTestOption(opt[optionLabels.test]);if(regex.test(source)){var replacerList=getReplacerListOption(opt[optionLabels.replacer]);return replacerList.forEach(function(replacer){var repl=getReplacerOption(replacer),importDeclaration=types.importDeclaration(path.node.specifiers,types.stringLiteral(source.replace(regex,repl)));importDeclaration.__processed=!0,transforms.push(importDeclaration)}),'break'}},i=0;i Date: Tue, 7 May 2024 05:32:31 +0330 Subject: [PATCH 02/16] install date-fns-jalali-v3 --- package.json | 1 + pnpm-lock.yaml | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/package.json b/package.json index b66de5e6c9f74..cb5cc6c89d686 100644 --- a/package.json +++ b/package.json @@ -129,6 +129,7 @@ "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", "danger": "^11.3.1", + "date-fns-jalali-v3": "npm:date-fns-jalali@3.6.0-0", "date-fns-v3": "npm:date-fns@3.6.0", "enzyme": "^3.11.0", "eslint": "^8.57.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9d7dfbc91931..f43d0b99b77e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -215,6 +215,9 @@ importers: danger: specifier: ^11.3.1 version: 11.3.1 + date-fns-jalali-v3: + specifier: npm:date-fns-jalali@3.6.0-0 + version: /date-fns-jalali@3.6.0-0 date-fns-v3: specifier: npm:date-fns@3.6.0 version: /date-fns@3.6.0 @@ -8205,6 +8208,10 @@ packages: engines: {node: '>=0.11'} dev: false + /date-fns-jalali@3.6.0-0: + resolution: {integrity: sha512-rcOocwhBFgEN4i+vXPoEp/irCxAmX8yloK/l/oeMOVCLpaFQfkq7jVn0vCWK91P2H9I/doSAPEN4WSWQeqwsug==} + dev: true + /date-fns@2.30.0: resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==} engines: {node: '>=0.11'} From d99d2dff546174d83afa01c10899fb614b9ca382 Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 05:35:28 +0330 Subject: [PATCH 03/16] copy AdapterDateFnsJalali to AdapterDateFnsJalaliV3 --- .../AdapterDateFnsJalali.test.tsx | 95 ++++ .../AdapterDateFnsJalali.ts | 522 ++++++++++++++++++ .../src/AdapterDateFnsJalaliV3/index.ts | 1 + 3 files changed, 618 insertions(+) create mode 100644 packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx create mode 100644 packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.ts create mode 100644 packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx new file mode 100644 index 0000000000000..a49981020364b --- /dev/null +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx @@ -0,0 +1,95 @@ +import { expect } from 'chai'; +import { DateTimeField } from '@mui/x-date-pickers'; +import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali'; +import { + createPickerRenderer, + expectFieldValueV7, + describeJalaliAdapter, + buildFieldInteractions, +} from 'test/utils/pickers'; +import { enUS } from 'date-fns/locale'; +import faIR from 'date-fns-jalali/locale/fa-IR'; +import faJalaliIR from 'date-fns-jalali/locale/fa-jalali-IR'; +import { AdapterMomentJalaali } from '@mui/x-date-pickers/AdapterMomentJalaali'; +import { AdapterFormats } from '@mui/x-date-pickers/models'; + +describe('', () => { + describeJalaliAdapter(AdapterDateFnsJalali, {}); + + describe('Adapter localization', () => { + it('Formatting', () => { + const adapter = new AdapterMomentJalaali(); + + const expectDate = (format: keyof AdapterFormats, expectedWithFaIR: string) => { + const date = adapter.date('2020-02-01T23:44:00.000Z')!; + + expect(adapter.format(date, format)).to.equal(expectedWithFaIR); + }; + + expectDate('fullDate', '۱۳۹۸، Bahman ۱م'); + expectDate('keyboardDate', '۱۳۹۸/۱۱/۱۲'); + expectDate('keyboardDateTime', '۱۳۹۸/۱۱/۱۲ ۲۳:۴۴'); + expectDate('keyboardDateTime12h', '۱۳۹۸/۱۱/۱۲ ۱۱:۴۴ بعد از ظهر'); + expectDate('keyboardDateTime24h', '۱۳۹۸/۱۱/۱۲ ۲۳:۴۴'); + }); + }); + + describe('Picker localization', () => { + const testDate = '2018-05-15T09:35:00'; + const localizedTexts = { + enUS: { + placeholder: 'MM/DD/YYYY hh:mm aa', + value: '02/25/1397 09:35 AM', + }, + faIR: { + placeholder: 'YYYY/MM/DD hh:mm aa', + value: '1397/02/25 09:35 ق.ظ.', + }, + faJalaliIR: { + // Not sure about what's the difference between this and fa-IR + placeholder: 'YYYY/MM/DD hh:mm aa', + value: '1397/02/25 09:35 ق.ظ.', + }, + }; + + Object.keys(localizedTexts).forEach((localeKey) => { + const localeObject = { + faIR, + faJalaliIR, + enUS, + }[localeKey]; + + describe(`test with the "${localeKey}" locale`, () => { + const { render, adapter, clock } = createPickerRenderer({ + clock: 'fake', + adapterName: 'date-fns-jalali', + locale: localeObject, + }); + + const { renderWithProps } = buildFieldInteractions({ + render, + clock, + Component: DateTimeField, + }); + + it('should have correct placeholder', () => { + const v7Response = renderWithProps({ enableAccessibleFieldDOMStructure: true }); + + expectFieldValueV7( + v7Response.getSectionsContainer(), + localizedTexts[localeKey].placeholder, + ); + }); + + it('should have well formatted value', () => { + const v7Response = renderWithProps({ + enableAccessibleFieldDOMStructure: true, + value: adapter.date(testDate), + }); + + expectFieldValueV7(v7Response.getSectionsContainer(), localizedTexts[localeKey].value); + }); + }); + }); + }); +}); diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.ts new file mode 100644 index 0000000000000..df45f1b686fba --- /dev/null +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.ts @@ -0,0 +1,522 @@ +/* eslint-disable class-methods-use-this */ +import addSeconds from 'date-fns-jalali/addSeconds'; +import addMinutes from 'date-fns-jalali/addMinutes'; +import addHours from 'date-fns-jalali/addHours'; +import addDays from 'date-fns-jalali/addDays'; +import addWeeks from 'date-fns-jalali/addWeeks'; +import addMonths from 'date-fns-jalali/addMonths'; +import addYears from 'date-fns-jalali/addYears'; +import endOfDay from 'date-fns-jalali/endOfDay'; +import endOfWeek from 'date-fns-jalali/endOfWeek'; +import endOfYear from 'date-fns-jalali/endOfYear'; +import dateFnsFormat from 'date-fns-jalali/format'; +import getHours from 'date-fns-jalali/getHours'; +import getSeconds from 'date-fns-jalali/getSeconds'; +import getMilliseconds from 'date-fns-jalali/getMilliseconds'; +import getWeek from 'date-fns-jalali/getWeek'; +import getYear from 'date-fns-jalali/getYear'; +import getMonth from 'date-fns-jalali/getMonth'; +import getDate from 'date-fns-jalali/getDate'; +import getDaysInMonth from 'date-fns-jalali/getDaysInMonth'; +import getMinutes from 'date-fns-jalali/getMinutes'; +import isAfter from 'date-fns-jalali/isAfter'; +import isBefore from 'date-fns-jalali/isBefore'; +import isEqual from 'date-fns-jalali/isEqual'; +import isSameDay from 'date-fns-jalali/isSameDay'; +import isSameYear from 'date-fns-jalali/isSameYear'; +import isSameMonth from 'date-fns-jalali/isSameMonth'; +import isSameHour from 'date-fns-jalali/isSameHour'; +import isValid from 'date-fns-jalali/isValid'; +import dateFnsParse from 'date-fns-jalali/parse'; +import setDate from 'date-fns-jalali/setDate'; +import setHours from 'date-fns-jalali/setHours'; +import setMinutes from 'date-fns-jalali/setMinutes'; +import setMonth from 'date-fns-jalali/setMonth'; +import setSeconds from 'date-fns-jalali/setSeconds'; +import setMilliseconds from 'date-fns-jalali/setMilliseconds'; +import setYear from 'date-fns-jalali/setYear'; +import startOfDay from 'date-fns-jalali/startOfDay'; +import startOfMonth from 'date-fns-jalali/startOfMonth'; +import endOfMonth from 'date-fns-jalali/endOfMonth'; +import startOfWeek from 'date-fns-jalali/startOfWeek'; +import startOfYear from 'date-fns-jalali/startOfYear'; +import isWithinInterval from 'date-fns-jalali/isWithinInterval'; +import defaultLocale from 'date-fns-jalali/locale/fa-IR'; +// @ts-ignore +import longFormatters from 'date-fns-jalali/_lib/format/longFormatters'; +import { + AdapterFormats, + AdapterOptions, + DateBuilderReturnType, + FieldFormatTokenMap, + MuiPickersAdapter, +} from '../models'; + +type DateFnsLocale = typeof defaultLocale; + +const formatTokenMap: FieldFormatTokenMap = { + // Year + y: { sectionType: 'year', contentType: 'digit', maxLength: 4 }, + yy: 'year', + yyy: { sectionType: 'year', contentType: 'digit', maxLength: 4 }, + yyyy: 'year', + + // Month + M: { sectionType: 'month', contentType: 'digit', maxLength: 2 }, + MM: 'month', + MMMM: { sectionType: 'month', contentType: 'letter' }, + MMM: { sectionType: 'month', contentType: 'letter' }, + L: { sectionType: 'month', contentType: 'digit', maxLength: 2 }, + LL: 'month', + LLL: { sectionType: 'month', contentType: 'letter' }, + LLLL: { sectionType: 'month', contentType: 'letter' }, + + // Day of the month + d: { sectionType: 'day', contentType: 'digit', maxLength: 2 }, + dd: 'day', + do: { sectionType: 'day', contentType: 'digit-with-letter' }, + + // Day of the week + E: { sectionType: 'weekDay', contentType: 'letter' }, + EE: { sectionType: 'weekDay', contentType: 'letter' }, + EEE: { sectionType: 'weekDay', contentType: 'letter' }, + EEEE: { sectionType: 'weekDay', contentType: 'letter' }, + EEEEE: { sectionType: 'weekDay', contentType: 'letter' }, + i: { sectionType: 'weekDay', contentType: 'digit', maxLength: 1 }, + ii: 'weekDay', + iii: { sectionType: 'weekDay', contentType: 'letter' }, + iiii: { sectionType: 'weekDay', contentType: 'letter' }, + e: { sectionType: 'weekDay', contentType: 'digit', maxLength: 1 }, + ee: 'weekDay', + eee: { sectionType: 'weekDay', contentType: 'letter' }, + eeee: { sectionType: 'weekDay', contentType: 'letter' }, + eeeee: { sectionType: 'weekDay', contentType: 'letter' }, + eeeeee: { sectionType: 'weekDay', contentType: 'letter' }, + c: { sectionType: 'weekDay', contentType: 'digit', maxLength: 1 }, + cc: 'weekDay', + ccc: { sectionType: 'weekDay', contentType: 'letter' }, + cccc: { sectionType: 'weekDay', contentType: 'letter' }, + ccccc: { sectionType: 'weekDay', contentType: 'letter' }, + cccccc: { sectionType: 'weekDay', contentType: 'letter' }, + + // Meridiem + a: 'meridiem', + aa: 'meridiem', + aaa: 'meridiem', + + // Hours + H: { sectionType: 'hours', contentType: 'digit', maxLength: 2 }, + HH: 'hours', + h: { sectionType: 'hours', contentType: 'digit', maxLength: 2 }, + hh: 'hours', + + // Minutes + m: { sectionType: 'minutes', contentType: 'digit', maxLength: 2 }, + mm: 'minutes', + + // Seconds + s: { sectionType: 'seconds', contentType: 'digit', maxLength: 2 }, + ss: 'seconds', +}; + +const defaultFormats: AdapterFormats = { + year: 'yyyy', + month: 'LLLL', + monthShort: 'MMM', + dayOfMonth: 'd', + dayOfMonthFull: 'do', + weekday: 'EEEE', + weekdayShort: 'EEEEEE', + hours24h: 'HH', + hours12h: 'hh', + meridiem: 'aa', + minutes: 'mm', + seconds: 'ss', + + fullDate: 'PPP', + keyboardDate: 'P', + shortDate: 'd MMM', + normalDate: 'd MMMM', + normalDateWithWeekday: 'EEE, d MMMM', + + fullTime: 'p', + fullTime12h: 'hh:mm aaa', + fullTime24h: 'HH:mm', + keyboardDateTime: 'P p', + keyboardDateTime12h: 'P hh:mm aa', + keyboardDateTime24h: 'P HH:mm', +}; + +const NUMBER_SYMBOL_MAP = { + '1': '۱', + '2': '۲', + '3': '۳', + '4': '۴', + '5': '۵', + '6': '۶', + '7': '۷', + '8': '۸', + '9': '۹', + '0': '۰', +}; + +declare module '@mui/x-date-pickers/models' { + interface PickerValidDateLookup { + 'date-fns-jalali': Date; + } +} + +/** + * Based on `@date-io/date-fns-jalali` + * + * MIT License + * + * Copyright (c) 2017 Dmitriy Kovalenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +export class AdapterDateFnsJalali implements MuiPickersAdapter { + public isMUIAdapter = true; + + public isTimezoneCompatible = false; + + public lib = 'date-fns-jalali'; + + public locale?: DateFnsLocale; + + public formats: AdapterFormats; + + public formatTokenMap = formatTokenMap; + + public escapedCharacters = { start: "'", end: "'" }; + + constructor({ locale, formats }: AdapterOptions = {}) { + this.locale = locale; + this.formats = { ...defaultFormats, ...formats }; + } + + public date = ( + value?: T, + ): DateBuilderReturnType => { + type R = DateBuilderReturnType; + if (typeof value === 'undefined') { + return new Date(); + } + + if (value === null) { + return null; + } + + return new Date(value); + }; + + public getInvalidDate = () => new Date('Invalid Date'); + + public getTimezone = (): string => { + return 'default'; + }; + + public setTimezone = (value: Date): Date => { + return value; + }; + + public toJsDate = (value: Date) => { + return value; + }; + + public parse = (value: string, format: string) => { + if (value === '') { + return null; + } + + return dateFnsParse(value, format, new Date(), { locale: this.locale }); + }; + + public getCurrentLocaleCode = () => { + return this.locale?.code || 'fa-IR'; + }; + + // Note: date-fns input types are more lenient than this adapter, so we need to expose our more + // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage. + public is12HourCycleInCurrentLocale = () => { + if (this.locale) { + return /a/.test(this.locale.formatLong!.time()); + } + + // By default, date-fns-jalali is using fa-IR locale with am/pm enabled + return true; + }; + + public expandFormat = (format: string) => { + // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31 + const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; + const locale = this.locale ?? defaultLocale; + return format + .match(longFormatRegexp)! + .map((token) => { + const firstCharacter = token[0]; + if (firstCharacter === 'p' || firstCharacter === 'P') { + const longFormatter = longFormatters[firstCharacter]; + return longFormatter(token, locale.formatLong, {}); + } + return token; + }) + .join(''); + }; + + public isValid = (value: Date | null) => { + if (value == null) { + return false; + } + + return isValid(value); + }; + + public format = (value: Date, formatKey: keyof AdapterFormats) => { + return this.formatByString(value, this.formats[formatKey]); + }; + + public formatByString = (value: Date, formatString: string) => { + return dateFnsFormat(value, formatString, { locale: this.locale }); + }; + + public formatNumber = (numberToFormat: string) => { + return numberToFormat + .replace(/\d/g, (match) => NUMBER_SYMBOL_MAP[match as keyof typeof NUMBER_SYMBOL_MAP]) + .replace(/,/g, '،'); + }; + + public isEqual = (value: Date | null, comparing: Date | null) => { + if (value === null && comparing === null) { + return true; + } + + if (value === null || comparing === null) { + return false; + } + + return isEqual(value, comparing); + }; + + public isSameYear = (value: Date, comparing: Date) => { + return isSameYear(value, comparing); + }; + + public isSameMonth = (value: Date, comparing: Date) => { + return isSameMonth(value, comparing); + }; + + public isSameDay = (value: Date, comparing: Date) => { + return isSameDay(value, comparing); + }; + + public isSameHour = (value: Date, comparing: Date) => { + return isSameHour(value, comparing); + }; + + public isAfter = (value: Date, comparing: Date) => { + return isAfter(value, comparing); + }; + + public isAfterYear = (value: Date, comparing: Date) => { + return isAfter(value, this.endOfYear(comparing)); + }; + + public isAfterDay = (value: Date, comparing: Date) => { + return isAfter(value, this.endOfDay(comparing)); + }; + + public isBefore = (value: Date, comparing: Date) => { + return isBefore(value, comparing); + }; + + public isBeforeYear = (value: Date, comparing: Date) => { + return isBefore(value, this.startOfYear(comparing)); + }; + + public isBeforeDay = (value: Date, comparing: Date) => { + return isBefore(value, this.startOfDay(comparing)); + }; + + public isWithinRange = (value: Date, [start, end]: [Date, Date]) => { + return isWithinInterval(value, { start, end }); + }; + + public startOfYear = (value: Date) => { + return startOfYear(value); + }; + + public startOfMonth = (value: Date) => { + return startOfMonth(value); + }; + + public startOfWeek = (value: Date) => { + return startOfWeek(value, { locale: this.locale }); + }; + + public startOfDay = (value: Date) => { + return startOfDay(value); + }; + + public endOfYear = (value: Date) => { + return endOfYear(value); + }; + + public endOfMonth = (value: Date) => { + return endOfMonth(value); + }; + + public endOfWeek = (value: Date) => { + return endOfWeek(value, { locale: this.locale }); + }; + + public endOfDay = (value: Date) => { + return endOfDay(value); + }; + + public addYears = (value: Date, amount: number) => { + return addYears(value, amount); + }; + + public addMonths = (value: Date, amount: number) => { + return addMonths(value, amount); + }; + + public addWeeks = (value: Date, amount: number) => { + return addWeeks(value, amount); + }; + + public addDays = (value: Date, amount: number) => { + return addDays(value, amount); + }; + + public addHours = (value: Date, amount: number) => { + return addHours(value, amount); + }; + + public addMinutes = (value: Date, amount: number) => { + return addMinutes(value, amount); + }; + + public addSeconds = (value: Date, amount: number) => { + return addSeconds(value, amount); + }; + + public getYear = (value: Date) => { + return getYear(value); + }; + + public getMonth = (value: Date) => { + return getMonth(value); + }; + + public getDate = (value: Date) => { + return getDate(value); + }; + + public getHours = (value: Date) => { + return getHours(value); + }; + + public getMinutes = (value: Date) => { + return getMinutes(value); + }; + + public getSeconds = (value: Date) => { + return getSeconds(value); + }; + + public getMilliseconds = (value: Date) => { + return getMilliseconds(value); + }; + + public setYear = (value: Date, year: number) => { + return setYear(value, year); + }; + + public setMonth = (value: Date, month: number) => { + return setMonth(value, month); + }; + + public setDate = (value: Date, date: number) => { + return setDate(value, date); + }; + + public setHours = (value: Date, hours: number) => { + return setHours(value, hours); + }; + + public setMinutes = (value: Date, minutes: number) => { + return setMinutes(value, minutes); + }; + + public setSeconds = (value: Date, seconds: number) => { + return setSeconds(value, seconds); + }; + + public setMilliseconds = (value: Date, milliseconds: number) => { + return setMilliseconds(value, milliseconds); + }; + + public getDaysInMonth = (value: Date) => { + return getDaysInMonth(value); + }; + + public getWeekArray = (value: Date) => { + const start = this.startOfWeek(this.startOfMonth(value)); + const end = this.endOfWeek(this.endOfMonth(value)); + + let count = 0; + let current = start; + const nestedWeeks: Date[][] = []; + + while (this.isBefore(current, end)) { + const weekNumber = Math.floor(count / 7); + nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || []; + nestedWeeks[weekNumber].push(current); + + current = this.addDays(current, 1); + count += 1; + } + + return nestedWeeks; + }; + + public getWeekNumber = (date: Date) => { + return getWeek(date, { locale: this.locale }); + }; + + public getDayOfWeek(value: Date) { + return value.getDay() + 1; + } + + public getYearRange = ([start, end]: [Date, Date]) => { + const startDate = this.startOfYear(start); + const endDate = this.endOfYear(end); + const years: Date[] = []; + + let current = startDate; + while (this.isBefore(current, endDate)) { + years.push(current); + current = this.addYears(current, 1); + } + + return years; + }; +} diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts new file mode 100644 index 0000000000000..04079bdadd7a3 --- /dev/null +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts @@ -0,0 +1 @@ +export { AdapterDateFnsJalali } from './AdapterDateFnsJalali'; From e7357b7a1cf796b45fdb9a4686d16313a27231b0 Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 05:38:07 +0330 Subject: [PATCH 04/16] rename AdapterDateFnsJalali.ts to AdapterDateFnsJalaliV3.ts --- ...erDateFnsJalali.test.tsx => AdapterDateFnsJalaliV3.test.tsx} | 2 +- .../{AdapterDateFnsJalali.ts => AdapterDateFnsJalaliV3.ts} | 0 packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename packages/x-date-pickers/src/AdapterDateFnsJalaliV3/{AdapterDateFnsJalali.test.tsx => AdapterDateFnsJalaliV3.test.tsx} (99%) rename packages/x-date-pickers/src/AdapterDateFnsJalaliV3/{AdapterDateFnsJalali.ts => AdapterDateFnsJalaliV3.ts} (100%) diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx similarity index 99% rename from packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx rename to packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx index a49981020364b..09e981fedc6a2 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.test.tsx +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { DateTimeField } from '@mui/x-date-pickers'; -import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali'; +import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3'; import { createPickerRenderer, expectFieldValueV7, diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts similarity index 100% rename from packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalali.ts rename to packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts index 04079bdadd7a3..056183daac31f 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/index.ts @@ -1 +1 @@ -export { AdapterDateFnsJalali } from './AdapterDateFnsJalali'; +export { AdapterDateFnsJalali } from './AdapterDateFnsJalaliV3'; From 5579dc802389ac4b8f65838b1ed33b9c06b557cf Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 05:40:07 +0330 Subject: [PATCH 05/16] add version check to constructors --- .../AdapterDateFnsJalali/AdapterDateFnsJalali.ts | 8 ++++++++ .../AdapterDateFnsJalaliV3.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts b/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts index df45f1b686fba..b0e672542daad 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts @@ -207,6 +207,14 @@ export class AdapterDateFnsJalali implements MuiPickersAdapter = {}) { + if (typeof addDays !== 'function') { + throw new Error( + [ + 'MUI: The `date-fns-jalali` package v3.x is not compatible with this adapter.', + 'Please, install v2.x of the package or use the `AdapterDateFnsJalaliV3` instead.', + ].join('\n'), + ); + } this.locale = locale; this.formats = { ...defaultFormats, ...formats }; } diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts index df45f1b686fba..20182141af8c6 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts @@ -207,6 +207,19 @@ export class AdapterDateFnsJalali implements MuiPickersAdapter = {}) { + if (typeof addDays !== 'function') { + throw new Error( + [ + `MUI: The \`date-fns-jalali\` package v2.x is not compatible with this adapter.`, + 'Please, install v3.x of the package or use the `AdapterDateFns` instead.', + ].join('\n'), + ); + } + if (!longFormatters) { + throw new Error( + 'MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.', + ); + } this.locale = locale; this.formats = { ...defaultFormats, ...formats }; } From 6b2d16a8372769074a6943bb28279c5673eabcb0 Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 05:46:33 +0330 Subject: [PATCH 06/16] fix imports --- .../AdapterDateFnsJalaliV3.test.tsx | 11 +-- .../AdapterDateFnsJalaliV3.ts | 95 ++++++++++--------- 2 files changed, 50 insertions(+), 56 deletions(-) diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx index 09e981fedc6a2..ff0f913287aa9 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx @@ -7,9 +7,8 @@ import { describeJalaliAdapter, buildFieldInteractions, } from 'test/utils/pickers'; -import { enUS } from 'date-fns/locale'; -import faIR from 'date-fns-jalali/locale/fa-IR'; -import faJalaliIR from 'date-fns-jalali/locale/fa-jalali-IR'; +import { enUS } from 'date-fns-jalali/locale/en-US'; +import { faIR } from 'date-fns-jalali/locale/fa-IR'; import { AdapterMomentJalaali } from '@mui/x-date-pickers/AdapterMomentJalaali'; import { AdapterFormats } from '@mui/x-date-pickers/models'; @@ -45,17 +44,11 @@ describe('', () => { placeholder: 'YYYY/MM/DD hh:mm aa', value: '1397/02/25 09:35 ق.ظ.', }, - faJalaliIR: { - // Not sure about what's the difference between this and fa-IR - placeholder: 'YYYY/MM/DD hh:mm aa', - value: '1397/02/25 09:35 ق.ظ.', - }, }; Object.keys(localizedTexts).forEach((localeKey) => { const localeObject = { faIR, - faJalaliIR, enUS, }[localeKey]; diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts index 20182141af8c6..0b1f822a79301 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts @@ -1,49 +1,52 @@ /* eslint-disable class-methods-use-this */ -import addSeconds from 'date-fns-jalali/addSeconds'; -import addMinutes from 'date-fns-jalali/addMinutes'; -import addHours from 'date-fns-jalali/addHours'; -import addDays from 'date-fns-jalali/addDays'; -import addWeeks from 'date-fns-jalali/addWeeks'; -import addMonths from 'date-fns-jalali/addMonths'; -import addYears from 'date-fns-jalali/addYears'; -import endOfDay from 'date-fns-jalali/endOfDay'; -import endOfWeek from 'date-fns-jalali/endOfWeek'; -import endOfYear from 'date-fns-jalali/endOfYear'; -import dateFnsFormat from 'date-fns-jalali/format'; -import getHours from 'date-fns-jalali/getHours'; -import getSeconds from 'date-fns-jalali/getSeconds'; -import getMilliseconds from 'date-fns-jalali/getMilliseconds'; -import getWeek from 'date-fns-jalali/getWeek'; -import getYear from 'date-fns-jalali/getYear'; -import getMonth from 'date-fns-jalali/getMonth'; -import getDate from 'date-fns-jalali/getDate'; -import getDaysInMonth from 'date-fns-jalali/getDaysInMonth'; -import getMinutes from 'date-fns-jalali/getMinutes'; -import isAfter from 'date-fns-jalali/isAfter'; -import isBefore from 'date-fns-jalali/isBefore'; -import isEqual from 'date-fns-jalali/isEqual'; -import isSameDay from 'date-fns-jalali/isSameDay'; -import isSameYear from 'date-fns-jalali/isSameYear'; -import isSameMonth from 'date-fns-jalali/isSameMonth'; -import isSameHour from 'date-fns-jalali/isSameHour'; -import isValid from 'date-fns-jalali/isValid'; -import dateFnsParse from 'date-fns-jalali/parse'; -import setDate from 'date-fns-jalali/setDate'; -import setHours from 'date-fns-jalali/setHours'; -import setMinutes from 'date-fns-jalali/setMinutes'; -import setMonth from 'date-fns-jalali/setMonth'; -import setSeconds from 'date-fns-jalali/setSeconds'; -import setMilliseconds from 'date-fns-jalali/setMilliseconds'; -import setYear from 'date-fns-jalali/setYear'; -import startOfDay from 'date-fns-jalali/startOfDay'; -import startOfMonth from 'date-fns-jalali/startOfMonth'; -import endOfMonth from 'date-fns-jalali/endOfMonth'; -import startOfWeek from 'date-fns-jalali/startOfWeek'; -import startOfYear from 'date-fns-jalali/startOfYear'; -import isWithinInterval from 'date-fns-jalali/isWithinInterval'; -import defaultLocale from 'date-fns-jalali/locale/fa-IR'; -// @ts-ignore -import longFormatters from 'date-fns-jalali/_lib/format/longFormatters'; +// TODO remove when date-fns-v3 is the default +// @ts-nocheck +import { addSeconds } from 'date-fns-jalali/addSeconds'; +import { addMinutes } from 'date-fns-jalali/addMinutes'; +import { addHours } from 'date-fns-jalali/addHours'; +import { addDays } from 'date-fns-jalali/addDays'; +import { addWeeks } from 'date-fns-jalali/addWeeks'; +import { addMonths } from 'date-fns-jalali/addMonths'; +import { addYears } from 'date-fns-jalali/addYears'; +import { endOfDay } from 'date-fns-jalali/endOfDay'; +import { endOfWeek } from 'date-fns-jalali/endOfWeek'; +import { endOfYear } from 'date-fns-jalali/endOfYear'; +import { format as dateFnsFormat, longFormatters } from 'date-fns-jalali/format'; +import { getHours } from 'date-fns-jalali/getHours'; +import { getSeconds } from 'date-fns-jalali/getSeconds'; +import { getMilliseconds } from 'date-fns-jalali/getMilliseconds'; +import { getWeek } from 'date-fns-jalali/getWeek'; +import { getYear } from 'date-fns-jalali/getYear'; +import { getMonth } from 'date-fns-jalali/getMonth'; +import { getDate } from 'date-fns-jalali/getDate'; +import { getDaysInMonth } from 'date-fns-jalali/getDaysInMonth'; +import { getMinutes } from 'date-fns-jalali/getMinutes'; +import { isAfter } from 'date-fns-jalali/isAfter'; +import { isBefore } from 'date-fns-jalali/isBefore'; +import { isEqual } from 'date-fns-jalali/isEqual'; +import { isSameDay } from 'date-fns-jalali/isSameDay'; +import { isSameYear } from 'date-fns-jalali/isSameYear'; +import { isSameMonth } from 'date-fns-jalali/isSameMonth'; +import { isSameHour } from 'date-fns-jalali/isSameHour'; +import { isValid } from 'date-fns-jalali/isValid'; +import { parse as dateFnsParse } from 'date-fns-jalali/parse'; +import { setDate } from 'date-fns-jalali/setDate'; +import { setHours } from 'date-fns-jalali/setHours'; +import { setMinutes } from 'date-fns-jalali/setMinutes'; +import { setMonth } from 'date-fns-jalali/setMonth'; +import { setSeconds } from 'date-fns-jalali/setSeconds'; +import { setMilliseconds } from 'date-fns-jalali/setMilliseconds'; +import { setYear } from 'date-fns-jalali/setYear'; +import { startOfDay } from 'date-fns-jalali/startOfDay'; +import { startOfMonth } from 'date-fns-jalali/startOfMonth'; +import { endOfMonth } from 'date-fns-jalali/endOfMonth'; +import { startOfWeek } from 'date-fns-jalali/startOfWeek'; +import { startOfYear } from 'date-fns-jalali/startOfYear'; +import { isWithinInterval } from 'date-fns-jalali/isWithinInterval'; +import { faIR as defaultLocale } from 'date-fns-jalali/locale/fa-IR'; +// date-fns v2 does not export types +// @ts-ignore TODO remove when date-fns-v3 is the default +import { Locale as DateFnsLocale } from 'date-fns-jalali/locale/types'; import { AdapterFormats, AdapterOptions, @@ -52,8 +55,6 @@ import { MuiPickersAdapter, } from '../models'; -type DateFnsLocale = typeof defaultLocale; - const formatTokenMap: FieldFormatTokenMap = { // Year y: { sectionType: 'year', contentType: 'digit', maxLength: 4 }, From b90e8f8399f9d9fcb2b775f6e07a100dfec9c99c Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 05:47:10 +0330 Subject: [PATCH 07/16] fix package.json --- packages/x-date-pickers/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/x-date-pickers/package.json b/packages/x-date-pickers/package.json index 70e6ad498b7bc..f62de512fd688 100644 --- a/packages/x-date-pickers/package.json +++ b/packages/x-date-pickers/package.json @@ -59,7 +59,7 @@ "@emotion/styled": "^11.8.1", "@mui/material": "^5.15.14", "date-fns": "^2.25.0 || ^3.2.0", - "date-fns-jalali": "^2.13.0-0", + "date-fns-jalali": "^2.13.0-0 || ^3.2.0-0", "dayjs": "^1.10.7", "luxon": "^3.0.2", "moment": "^2.29.4", From 1018a204469dca61c38370ee808c568fae61beaa Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 06:02:17 +0330 Subject: [PATCH 08/16] fix babel config --- babel.config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/babel.config.js b/babel.config.js index d51d180e4931e..d8d15499e33a4 100644 --- a/babel.config.js +++ b/babel.config.js @@ -95,6 +95,16 @@ module.exports = function getBabelConfig(api) { filenameIncludes: 'src/AdapterDateFnsV3/', }, ]); + plugins.push([ + 'babel-plugin-replace-imports', + { + test: /date-fns-jalali/i, + replacer: 'date-fns-jalali-v3', + // This option is provided by the `patches/babel-plugin-replace-imports@1.0.2.patch` patch + filenameIncludes: 'src/AdapterDateFnsJalaliV3/', + }, + 'replace-date-fns-jalali-imports', + ]); } if (process.env.NODE_ENV === 'production') { From 52f2e3e2199355ab24851b5f4c1bb871e8585213 Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Tue, 7 May 2024 06:38:51 +0330 Subject: [PATCH 09/16] fix tests --- .../AdapterDateFnsJalaliV3.test.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx index ff0f913287aa9..035b469ac89e7 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx @@ -9,7 +9,6 @@ import { } from 'test/utils/pickers'; import { enUS } from 'date-fns-jalali/locale/en-US'; import { faIR } from 'date-fns-jalali/locale/fa-IR'; -import { AdapterMomentJalaali } from '@mui/x-date-pickers/AdapterMomentJalaali'; import { AdapterFormats } from '@mui/x-date-pickers/models'; describe('', () => { @@ -17,7 +16,7 @@ describe('', () => { describe('Adapter localization', () => { it('Formatting', () => { - const adapter = new AdapterMomentJalaali(); + const adapter = new AdapterDateFnsJalali(); const expectDate = (format: keyof AdapterFormats, expectedWithFaIR: string) => { const date = adapter.date('2020-02-01T23:44:00.000Z')!; @@ -25,11 +24,11 @@ describe('', () => { expect(adapter.format(date, format)).to.equal(expectedWithFaIR); }; - expectDate('fullDate', '۱۳۹۸، Bahman ۱م'); - expectDate('keyboardDate', '۱۳۹۸/۱۱/۱۲'); - expectDate('keyboardDateTime', '۱۳۹۸/۱۱/۱۲ ۲۳:۴۴'); - expectDate('keyboardDateTime12h', '۱۳۹۸/۱۱/۱۲ ۱۱:۴۴ بعد از ظهر'); - expectDate('keyboardDateTime24h', '۱۳۹۸/۱۱/۱۲ ۲۳:۴۴'); + expectDate('fullDate', '12-ام بهمن 1398'); + expectDate('keyboardDate', '1398/11/12'); + expectDate('keyboardDateTime', '1398/11/12 11:44 ب.ظ.'); + expectDate('keyboardDateTime12h', '1398/11/12 11:44 ب.ظ.'); + expectDate('keyboardDateTime24h', '1398/11/12 23:44'); }); }); From 07965c85e243d8ebd77b1dfe65630d3e4f4c3ec0 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 8 May 2024 16:17:50 +0300 Subject: [PATCH 10/16] Add to codecov --- codecov.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codecov.yml b/codecov.yml index 1a14b3aa46023..426667acdf10e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -8,7 +8,9 @@ coverage: target: 100% paths: - 'packages/x-date-pickers/src/AdapterDateFns/AdapterDateFns.ts' + - 'packages/x-date-pickers/src/AdapterDateFnsV3/AdapterDateFnsV3.ts' - 'packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts' + - 'packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts' - 'packages/x-date-pickers/src/AdapterDayjs/AdapterDayjs.ts' - 'packages/x-date-pickers/src/AdapterLuxon/AdapterLuxon.ts' - 'packages/x-date-pickers/src/AdapterMoment/AdapterMoment.ts' From dc2e5fc21343433ae123db5bd46bf0436b6315fd Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 8 May 2024 16:22:57 +0300 Subject: [PATCH 11/16] Minor fixes --- .../AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx | 5 ++--- .../src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx index 035b469ac89e7..5f505a3d4ea50 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx @@ -7,11 +7,10 @@ import { describeJalaliAdapter, buildFieldInteractions, } from 'test/utils/pickers'; -import { enUS } from 'date-fns-jalali/locale/en-US'; -import { faIR } from 'date-fns-jalali/locale/fa-IR'; +import { enUS, faIR } from 'date-fns-jalali/locale'; import { AdapterFormats } from '@mui/x-date-pickers/models'; -describe('', () => { +describe('', () => { describeJalaliAdapter(AdapterDateFnsJalali, {}); describe('Adapter localization', () => { diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts index 0b1f822a79301..7d6a5053ab743 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts @@ -212,7 +212,7 @@ export class AdapterDateFnsJalali implements MuiPickersAdapter Date: Wed, 8 May 2024 16:37:06 +0300 Subject: [PATCH 12/16] prettier --- .../src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts | 8 ++++---- .../AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts b/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts index b0e672542daad..e5194e5b2f516 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalali/AdapterDateFnsJalali.ts @@ -209,10 +209,10 @@ export class AdapterDateFnsJalali implements MuiPickersAdapter = {}) { if (typeof addDays !== 'function') { throw new Error( - [ - 'MUI: The `date-fns-jalali` package v3.x is not compatible with this adapter.', - 'Please, install v2.x of the package or use the `AdapterDateFnsJalaliV3` instead.', - ].join('\n'), + [ + 'MUI: The `date-fns-jalali` package v3.x is not compatible with this adapter.', + 'Please, install v2.x of the package or use the `AdapterDateFnsJalaliV3` instead.', + ].join('\n'), ); } this.locale = locale; diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts index 7d6a5053ab743..540bf1a750496 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts @@ -210,15 +210,15 @@ export class AdapterDateFnsJalali implements MuiPickersAdapter = {}) { if (typeof addDays !== 'function') { throw new Error( - [ - `MUI: The \`date-fns-jalali\` package v2.x is not compatible with this adapter.`, - 'Please, install v3.x of the package or use the `AdapterDateFnsJalali` instead.', - ].join('\n'), + [ + `MUI: The \`date-fns-jalali\` package v2.x is not compatible with this adapter.`, + 'Please, install v3.x of the package or use the `AdapterDateFnsJalali` instead.', + ].join('\n'), ); } if (!longFormatters) { throw new Error( - 'MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.', + 'MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.', ); } this.locale = locale; From 38acb8caf07220eeafa8f9a352a06ec2a22908bd Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 8 May 2024 16:37:39 +0300 Subject: [PATCH 13/16] Add documentation about `date-fns-jalali`@v3 support --- .../calendar-systems/calendar-systems.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/data/date-pickers/calendar-systems/calendar-systems.md b/docs/data/date-pickers/calendar-systems/calendar-systems.md index 10766267d5c54..aff4661cfe085 100644 --- a/docs/data/date-pickers/calendar-systems/calendar-systems.md +++ b/docs/data/date-pickers/calendar-systems/calendar-systems.md @@ -15,10 +15,26 @@ packageName: '@mui/x-date-pickers' You can use either the `AdapterDateFnsJalali` adapter, which is based on [date-fns-jalali](https://www.npmjs.com/package/date-fns-jalali), or the `AdapterMomentJalaali` adapter, which is based on [moment-jalaali](https://www.npmjs.com/package/moment-jalaali). -The following demo shows how to use the date-fns plugin: +The following demo shows how to use the `date-fns-jalali` adapter: {{"demo": "AdapterJalali.js"}} +:::info +Both `date-fns-jalali` major versions (v2.x and v3.x) are supported. + +A single adapter cannot work for both `date-fns-jalali` v2.x and v3.x, because the way functions are exported has been changed in v3.x. + +To use `date-fns-jalali` v3.x, you will have to import the adapter from `@mui/x-date-pickers/AdapterDateFnsJalaliV3` instead of `@mui/x-date-pickers/AdapterDateFnsJalali`. + +```tsx +// with date-fns-jalali v2.x +import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali'; +// with date-fns-jalali v3.x +import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3'; +``` + +::: + ## Hijri :::error From ffd19f412906b99decbc40da4bfa3b32ad79373b Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 8 May 2024 16:58:56 +0300 Subject: [PATCH 14/16] Add support to `@mui/x-date-pickers-pro` package --- packages/x-date-pickers-pro/package.json | 2 +- packages/x-date-pickers-pro/src/AdapterDateFnsJalaliV3/index.ts | 1 + pnpm-lock.yaml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 packages/x-date-pickers-pro/src/AdapterDateFnsJalaliV3/index.ts diff --git a/packages/x-date-pickers-pro/package.json b/packages/x-date-pickers-pro/package.json index 70b8b80fe6a70..fc811f7f082d5 100644 --- a/packages/x-date-pickers-pro/package.json +++ b/packages/x-date-pickers-pro/package.json @@ -57,7 +57,7 @@ "@emotion/styled": "^11.8.1", "@mui/material": "^5.15.14", "date-fns": "^2.25.0 || ^3.2.0", - "date-fns-jalali": "^2.13.0-0", + "date-fns-jalali": "^2.13.0-0 || ^3.2.0-0", "dayjs": "^1.10.7", "luxon": "^3.0.2", "moment": "^2.29.4", diff --git a/packages/x-date-pickers-pro/src/AdapterDateFnsJalaliV3/index.ts b/packages/x-date-pickers-pro/src/AdapterDateFnsJalaliV3/index.ts new file mode 100644 index 0000000000000..ee8f537fd113f --- /dev/null +++ b/packages/x-date-pickers-pro/src/AdapterDateFnsJalaliV3/index.ts @@ -0,0 +1 @@ +export { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9488b6c20206b..d6b3b526fac34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1107,7 +1107,7 @@ importers: specifier: ^2.1.1 version: 2.1.1 date-fns-jalali: - specifier: ^2.13.0-0 + specifier: ^2.13.0-0 || ^3.2.0-0 version: 2.13.0-0(patch_hash=knk56uiq6xxn77bv6lgrgre7si) moment-hijri: specifier: ^2.1.2 From c7ecaa1b5b55eb6c640edb1e459976ed94f44b46 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 8 May 2024 19:20:31 +0300 Subject: [PATCH 15/16] Fix build and bump `date-fns-jalali` to latest v2.x --- docs/package.json | 2 +- package.json | 1 - packages/x-date-pickers-pro/package.json | 1 + packages/x-date-pickers/package.json | 2 +- .../AdapterDateFnsJalaliV3.ts | 6 +- patches/date-fns-jalali@2.13.0-0.patch | 1807 ----------------- pnpm-lock.yaml | 28 +- 7 files changed, 17 insertions(+), 1830 deletions(-) delete mode 100644 patches/date-fns-jalali@2.13.0-0.patch diff --git a/docs/package.json b/docs/package.json index e6a75452b8234..88735bebc31da 100644 --- a/docs/package.json +++ b/docs/package.json @@ -58,7 +58,7 @@ "core-js": "^2.6.12", "cross-env": "^7.0.3", "date-fns": "^2.30.0", - "date-fns-jalali": "^2.21.3-1", + "date-fns-jalali": "^2.30.0-0", "dayjs": "^1.11.11", "doctrine": "^3.0.0", "exceljs": "^4.4.0", diff --git a/package.json b/package.json index b9bc58a0b3cc5..0c14e7bccaec7 100644 --- a/package.json +++ b/package.json @@ -196,7 +196,6 @@ "packageManager": "pnpm@8.15.8", "pnpm": { "patchedDependencies": { - "date-fns-jalali@2.13.0-0": "patches/date-fns-jalali@2.13.0-0.patch", "karma-mocha@2.0.1": "patches/karma-mocha@2.0.1.patch", "babel-plugin-replace-imports@1.0.2": "patches/babel-plugin-replace-imports@1.0.2.patch" } diff --git a/packages/x-date-pickers-pro/package.json b/packages/x-date-pickers-pro/package.json index fc811f7f082d5..e160f1e2e5a50 100644 --- a/packages/x-date-pickers-pro/package.json +++ b/packages/x-date-pickers-pro/package.json @@ -99,6 +99,7 @@ "@types/luxon": "^3.4.2", "@types/prop-types": "^15.7.12", "date-fns": "^2.30.0", + "date-fns-jalali": "^2.30.0-0", "dayjs": "^1.11.11", "luxon": "^3.4.4", "moment": "^2.30.1", diff --git a/packages/x-date-pickers/package.json b/packages/x-date-pickers/package.json index af9f7f2eb4af0..17372d3f15f9b 100644 --- a/packages/x-date-pickers/package.json +++ b/packages/x-date-pickers/package.json @@ -103,7 +103,7 @@ "@types/moment-jalaali": "^0.7.9", "@types/prop-types": "^15.7.12", "date-fns": "^2.30.0", - "date-fns-jalali": "^2.13.0-0", + "date-fns-jalali": "^2.30.0-0", "dayjs": "^1.11.11", "luxon": "^3.4.4", "moment": "^2.30.1", diff --git a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts index 540bf1a750496..112da595ed4c3 100644 --- a/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts +++ b/packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.ts @@ -1,5 +1,5 @@ /* eslint-disable class-methods-use-this */ -// TODO remove when date-fns-v3 is the default +// TODO remove when date-fns-jalali-v3 is the default // @ts-nocheck import { addSeconds } from 'date-fns-jalali/addSeconds'; import { addMinutes } from 'date-fns-jalali/addMinutes'; @@ -44,8 +44,8 @@ import { startOfWeek } from 'date-fns-jalali/startOfWeek'; import { startOfYear } from 'date-fns-jalali/startOfYear'; import { isWithinInterval } from 'date-fns-jalali/isWithinInterval'; import { faIR as defaultLocale } from 'date-fns-jalali/locale/fa-IR'; -// date-fns v2 does not export types -// @ts-ignore TODO remove when date-fns-v3 is the default +// date-fns-jalali v2 does not export types +// @ts-ignore TODO remove when date-fns-jalali-v3 is the default import { Locale as DateFnsLocale } from 'date-fns-jalali/locale/types'; import { AdapterFormats, diff --git a/patches/date-fns-jalali@2.13.0-0.patch b/patches/date-fns-jalali@2.13.0-0.patch deleted file mode 100644 index 7dd5cddf5016d..0000000000000 --- a/patches/date-fns-jalali@2.13.0-0.patch +++ /dev/null @@ -1,1807 +0,0 @@ -diff --git a/typings.d.ts b/typings.d.ts -index ff89673733e3ef0f68eade1b681bad1f61a18c0e..0502c2b42e5a0f812fe9e07d479ceb71e0858650 100644 ---- a/typings.d.ts -+++ b/typings.d.ts -@@ -26,13 +26,13 @@ interface CurriedFn4 { - - // Type Aliases - --type Interval = { -+type IntervalJalali = { - start: Date | number - end: Date | number - } --type IntervalAliased = Interval -+type IntervalAliasedJalali = IntervalJalali - --type Locale = { -+type LocaleJalali = { - code?: string - formatDistance?: (...args: Array) => any - formatRelative?: (...args: Array) => any -@@ -62,9 +62,9 @@ type Locale = { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } - } --type LocaleAliased = Locale -+type LocaleAliasedJalali = LocaleJalali - --type Duration = { -+type DurationJalali = { - years?: number - months?: number - weeks?: number -@@ -73,16 +73,16 @@ type Duration = { - minutes?: number - seconds?: number - } --type DurationAliased = Duration -+type DurationAliasedJalali = DurationJalali - - // Exported Type Aliases - - declare module 'date-fns-jalali' { -- export type Interval = IntervalAliased -+ export type Interval = IntervalAliasedJalali - -- export type Locale = LocaleAliased -+ export type Locale = LocaleAliasedJalali - -- export type Duration = DurationAliased -+ export type Duration = DurationAliasedJalali - } - - // Regular Functions -@@ -3858,7 +3858,7 @@ declare module 'date-fns-jalali/toDate/index.js' { - // FP Functions - - declare module 'date-fns-jalali/fp' { -- const add: CurriedFn2 -+ const add: CurriedFn2 - namespace add {} - - const addBusinessDays: CurriedFn2 -@@ -3894,15 +3894,15 @@ declare module 'date-fns-jalali/fp' { - const addYears: CurriedFn2 - namespace addYears {} - -- const areIntervalsOverlapping: CurriedFn2 -+ const areIntervalsOverlapping: CurriedFn2 - namespace areIntervalsOverlapping {} - - const areIntervalsOverlappingWithOptions: CurriedFn3< - { - inclusive?: boolean - }, -- Interval, -- Interval, -+ IntervalJalali, -+ IntervalJalali, - boolean - > - namespace areIntervalsOverlappingWithOptions {} -@@ -3971,7 +3971,7 @@ declare module 'date-fns-jalali/fp' { - const differenceInCalendarWeeksWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date | number, -@@ -4024,22 +4024,22 @@ declare module 'date-fns-jalali/fp' { - const differenceInYears: CurriedFn2 - namespace differenceInYears {} - -- const eachDayOfInterval: CurriedFn1 -+ const eachDayOfInterval: CurriedFn1 - namespace eachDayOfInterval {} - - const eachDayOfIntervalWithOptions: CurriedFn2< - { - step?: number - }, -- Interval, -+ IntervalJalali, - Date[] - > - namespace eachDayOfIntervalWithOptions {} - -- const eachMonthOfInterval: CurriedFn1 -+ const eachMonthOfInterval: CurriedFn1 - namespace eachMonthOfInterval {} - -- const eachWeekendOfInterval: CurriedFn1 -+ const eachWeekendOfInterval: CurriedFn1 - namespace eachWeekendOfInterval {} - - const eachWeekendOfMonth: CurriedFn1 -@@ -4048,20 +4048,20 @@ declare module 'date-fns-jalali/fp' { - const eachWeekendOfYear: CurriedFn1 - namespace eachWeekendOfYear {} - -- const eachWeekOfInterval: CurriedFn1 -+ const eachWeekOfInterval: CurriedFn1 - namespace eachWeekOfInterval {} - - const eachWeekOfIntervalWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, -- Interval, -+ IntervalJalali, - Date[] - > - namespace eachWeekOfIntervalWithOptions {} - -- const eachYearOfInterval: CurriedFn1 -+ const eachYearOfInterval: CurriedFn1 - namespace eachYearOfInterval {} - - const endOfDay: CurriedFn1 -@@ -4106,7 +4106,7 @@ declare module 'date-fns-jalali/fp' { - const endOfWeekWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -4127,7 +4127,7 @@ declare module 'date-fns-jalali/fp' { - - const formatDistanceStrictWithOptions: CurriedFn3< - { -- locale?: Locale -+ locale?: LocaleJalali - roundingMethod?: 'floor' | 'ceil' | 'round' - unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' - addSuffix?: boolean -@@ -4140,7 +4140,7 @@ declare module 'date-fns-jalali/fp' { - - const formatDistanceWithOptions: CurriedFn3< - { -- locale?: Locale -+ locale?: LocaleJalali - addSuffix?: boolean - includeSeconds?: boolean - }, -@@ -4166,7 +4166,7 @@ declare module 'date-fns-jalali/fp' { - > - namespace formatISO9075WithOptions {} - -- const formatISODuration: CurriedFn1 -+ const formatISODuration: CurriedFn1 - namespace formatISODuration {} - - const formatISOWithOptions: CurriedFn2< -@@ -4185,7 +4185,7 @@ declare module 'date-fns-jalali/fp' { - const formatRelativeWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date | number, -@@ -4214,7 +4214,7 @@ declare module 'date-fns-jalali/fp' { - useAdditionalWeekYearTokens?: boolean - firstWeekContainsDate?: number - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - string, - Date | number, -@@ -4267,7 +4267,7 @@ declare module 'date-fns-jalali/fp' { - const getMonth: CurriedFn1 - namespace getMonth {} - -- const getOverlappingDaysInIntervals: CurriedFn2 -+ const getOverlappingDaysInIntervals: CurriedFn2 - namespace getOverlappingDaysInIntervals {} - - const getQuarter: CurriedFn1 -@@ -4291,7 +4291,7 @@ declare module 'date-fns-jalali/fp' { - const getWeekOfMonthWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -4304,7 +4304,7 @@ declare module 'date-fns-jalali/fp' { - const getWeeksInMonthWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -4315,7 +4315,7 @@ declare module 'date-fns-jalali/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -4329,7 +4329,7 @@ declare module 'date-fns-jalali/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -4339,7 +4339,7 @@ declare module 'date-fns-jalali/fp' { - const getYear: CurriedFn1 - namespace getYear {} - -- const intervalToDuration: CurriedFn1 -+ const intervalToDuration: CurriedFn1 - namespace intervalToDuration {} - - const isAfter: CurriedFn2 -@@ -4402,7 +4402,7 @@ declare module 'date-fns-jalali/fp' { - const isSameWeekWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date | number, -@@ -4434,7 +4434,7 @@ declare module 'date-fns-jalali/fp' { - const isWeekend: CurriedFn1 - namespace isWeekend {} - -- const isWithinInterval: CurriedFn2 -+ const isWithinInterval: CurriedFn2 - namespace isWithinInterval {} - - const lastDayOfDecade: CurriedFn1 -@@ -4467,7 +4467,7 @@ declare module 'date-fns-jalali/fp' { - const lastDayOfWeekWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -4510,7 +4510,7 @@ declare module 'date-fns-jalali/fp' { - useAdditionalWeekYearTokens?: boolean - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - string, -@@ -4558,7 +4558,7 @@ declare module 'date-fns-jalali/fp' { - const setDayWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - number, - Date | number, -@@ -4600,7 +4600,7 @@ declare module 'date-fns-jalali/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - number, - Date | number, -@@ -4615,7 +4615,7 @@ declare module 'date-fns-jalali/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - number, - Date | number, -@@ -4659,7 +4659,7 @@ declare module 'date-fns-jalali/fp' { - const startOfWeekWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -4673,7 +4673,7 @@ declare module 'date-fns-jalali/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -4683,7 +4683,7 @@ declare module 'date-fns-jalali/fp' { - const startOfYear: CurriedFn1 - namespace startOfYear {} - -- const sub: CurriedFn2 -+ const sub: CurriedFn2 - namespace sub {} - - const subBusinessDays: CurriedFn2 -@@ -7715,7 +7715,7 @@ declare module 'date-fns-jalali/fp/toDate/index.js' { - // ECMAScript Module Functions - - declare module 'date-fns-jalali/esm' { -- function add(date: Date | number, duration: Duration): Date -+ function add(date: Date | number, duration: DurationJalali): Date - namespace add {} - - function addBusinessDays(date: Date | number, amount: number): Date -@@ -7752,8 +7752,8 @@ declare module 'date-fns-jalali/esm' { - namespace addYears {} - - function areIntervalsOverlapping( -- intervalLeft: Interval, -- intervalRight: Interval, -+ intervalLeft: IntervalJalali, -+ intervalRight: IntervalJalali, - options?: { - inclusive?: boolean - } -@@ -7821,7 +7821,7 @@ declare module 'date-fns-jalali/esm' { - dateLeft: Date | number, - dateRight: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): number -@@ -7894,17 +7894,17 @@ declare module 'date-fns-jalali/esm' { - namespace differenceInYears {} - - function eachDayOfInterval( -- interval: Interval, -+ interval: IntervalJalali, - options?: { - step?: number - } - ): Date[] - namespace eachDayOfInterval {} - -- function eachMonthOfInterval(interval: Interval): Date[] -+ function eachMonthOfInterval(interval: IntervalJalali): Date[] - namespace eachMonthOfInterval {} - -- function eachWeekendOfInterval(interval: Interval): Date[] -+ function eachWeekendOfInterval(interval: IntervalJalali): Date[] - namespace eachWeekendOfInterval {} - - function eachWeekendOfMonth(date: Date | number): Date[] -@@ -7914,15 +7914,15 @@ declare module 'date-fns-jalali/esm' { - namespace eachWeekendOfYear {} - - function eachWeekOfInterval( -- interval: Interval, -+ interval: IntervalJalali, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date[] - namespace eachWeekOfInterval {} - -- function eachYearOfInterval(interval: Interval): Date[] -+ function eachYearOfInterval(interval: IntervalJalali): Date[] - namespace eachYearOfInterval {} - - function endOfDay(date: Date | number): Date -@@ -7966,7 +7966,7 @@ declare module 'date-fns-jalali/esm' { - function endOfWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -7982,7 +7982,7 @@ declare module 'date-fns-jalali/esm' { - date: Date | number, - format: string, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: number - useAdditionalWeekYearTokens?: boolean -@@ -7997,7 +7997,7 @@ declare module 'date-fns-jalali/esm' { - options?: { - includeSeconds?: boolean - addSuffix?: boolean -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - namespace formatDistance {} -@@ -8009,7 +8009,7 @@ declare module 'date-fns-jalali/esm' { - addSuffix?: boolean - unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' - roundingMethod?: 'floor' | 'ceil' | 'round' -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - namespace formatDistanceStrict {} -@@ -8019,7 +8019,7 @@ declare module 'date-fns-jalali/esm' { - options?: { - includeSeconds?: boolean - addSuffix?: boolean -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - namespace formatDistanceToNow {} -@@ -8030,7 +8030,7 @@ declare module 'date-fns-jalali/esm' { - addSuffix?: boolean - unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' - roundingMethod?: 'floor' | 'ceil' | 'round' -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - namespace formatDistanceToNowStrict {} -@@ -8053,14 +8053,14 @@ declare module 'date-fns-jalali/esm' { - ): string - namespace formatISO9075 {} - -- function formatISODuration(duration: Duration): string -+ function formatISODuration(duration: DurationJalali): string - namespace formatISODuration {} - - function formatRelative( - date: Date | number, - baseDate: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): string -@@ -8123,8 +8123,8 @@ declare module 'date-fns-jalali/esm' { - namespace getMonth {} - - function getOverlappingDaysInIntervals( -- intervalLeft: Interval, -- intervalRight: Interval -+ intervalLeft: IntervalJalali, -+ intervalRight: IntervalJalali - ): number - namespace getOverlappingDaysInIntervals {} - -@@ -8143,7 +8143,7 @@ declare module 'date-fns-jalali/esm' { - function getWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -8153,7 +8153,7 @@ declare module 'date-fns-jalali/esm' { - function getWeekOfMonth( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): number -@@ -8162,7 +8162,7 @@ declare module 'date-fns-jalali/esm' { - function getWeeksInMonth( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): number -@@ -8171,7 +8171,7 @@ declare module 'date-fns-jalali/esm' { - function getWeekYear( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -8181,7 +8181,7 @@ declare module 'date-fns-jalali/esm' { - function getYear(date: Date | number): number - namespace getYear {} - -- function intervalToDuration(interval: Interval): Duration -+ function intervalToDuration(interval: IntervalJalali): DurationJalali - namespace intervalToDuration {} - - function isAfter(date: Date | number, dateToCompare: Date | number): boolean -@@ -8269,7 +8269,7 @@ declare module 'date-fns-jalali/esm' { - dateLeft: Date | number, - dateRight: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): boolean -@@ -8308,7 +8308,7 @@ declare module 'date-fns-jalali/esm' { - function isThisWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): boolean -@@ -8338,7 +8338,7 @@ declare module 'date-fns-jalali/esm' { - function isWeekend(date: Date | number): boolean - namespace isWeekend {} - -- function isWithinInterval(date: Date | number, interval: Interval): boolean -+ function isWithinInterval(date: Date | number, interval: IntervalJalali): boolean - namespace isWithinInterval {} - - function isYesterday(date: Date | number): boolean -@@ -8367,7 +8367,7 @@ declare module 'date-fns-jalali/esm' { - function lastDayOfWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -8390,7 +8390,7 @@ declare module 'date-fns-jalali/esm' { - formatString: string, - referenceDate: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - useAdditionalWeekYearTokens?: boolean -@@ -8439,7 +8439,7 @@ declare module 'date-fns-jalali/esm' { - date: Date | number, - day: number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -8479,7 +8479,7 @@ declare module 'date-fns-jalali/esm' { - date: Date | number, - week: number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -8490,7 +8490,7 @@ declare module 'date-fns-jalali/esm' { - date: Date | number, - weekYear: number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -8536,7 +8536,7 @@ declare module 'date-fns-jalali/esm' { - function startOfWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -8545,7 +8545,7 @@ declare module 'date-fns-jalali/esm' { - function startOfWeekYear( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -8558,7 +8558,7 @@ declare module 'date-fns-jalali/esm' { - function startOfYesterday(): Date - namespace startOfYesterday {} - -- function sub(date: Date | number, duration: Duration): Date -+ function sub(date: Date | number, duration: DurationJalali): Date - namespace sub {} - - function subBusinessDays(date: Date | number, amount: number): Date -@@ -11485,7 +11485,7 @@ declare module 'date-fns-jalali/esm/toDate/index.js' { - // ECMAScript Module FP Functions - - declare module 'date-fns-jalali/esm/fp' { -- const add: CurriedFn2 -+ const add: CurriedFn2 - namespace add {} - - const addBusinessDays: CurriedFn2 -@@ -11521,15 +11521,15 @@ declare module 'date-fns-jalali/esm/fp' { - const addYears: CurriedFn2 - namespace addYears {} - -- const areIntervalsOverlapping: CurriedFn2 -+ const areIntervalsOverlapping: CurriedFn2 - namespace areIntervalsOverlapping {} - - const areIntervalsOverlappingWithOptions: CurriedFn3< - { - inclusive?: boolean - }, -- Interval, -- Interval, -+ IntervalJalali, -+ IntervalJalali, - boolean - > - namespace areIntervalsOverlappingWithOptions {} -@@ -11598,7 +11598,7 @@ declare module 'date-fns-jalali/esm/fp' { - const differenceInCalendarWeeksWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date | number, -@@ -11651,22 +11651,22 @@ declare module 'date-fns-jalali/esm/fp' { - const differenceInYears: CurriedFn2 - namespace differenceInYears {} - -- const eachDayOfInterval: CurriedFn1 -+ const eachDayOfInterval: CurriedFn1 - namespace eachDayOfInterval {} - - const eachDayOfIntervalWithOptions: CurriedFn2< - { - step?: number - }, -- Interval, -+ IntervalJalali, - Date[] - > - namespace eachDayOfIntervalWithOptions {} - -- const eachMonthOfInterval: CurriedFn1 -+ const eachMonthOfInterval: CurriedFn1 - namespace eachMonthOfInterval {} - -- const eachWeekendOfInterval: CurriedFn1 -+ const eachWeekendOfInterval: CurriedFn1 - namespace eachWeekendOfInterval {} - - const eachWeekendOfMonth: CurriedFn1 -@@ -11675,20 +11675,20 @@ declare module 'date-fns-jalali/esm/fp' { - const eachWeekendOfYear: CurriedFn1 - namespace eachWeekendOfYear {} - -- const eachWeekOfInterval: CurriedFn1 -+ const eachWeekOfInterval: CurriedFn1 - namespace eachWeekOfInterval {} - - const eachWeekOfIntervalWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, -- Interval, -+ IntervalJalali, - Date[] - > - namespace eachWeekOfIntervalWithOptions {} - -- const eachYearOfInterval: CurriedFn1 -+ const eachYearOfInterval: CurriedFn1 - namespace eachYearOfInterval {} - - const endOfDay: CurriedFn1 -@@ -11733,7 +11733,7 @@ declare module 'date-fns-jalali/esm/fp' { - const endOfWeekWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -11754,7 +11754,7 @@ declare module 'date-fns-jalali/esm/fp' { - - const formatDistanceStrictWithOptions: CurriedFn3< - { -- locale?: Locale -+ locale?: LocaleJalali - roundingMethod?: 'floor' | 'ceil' | 'round' - unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' - addSuffix?: boolean -@@ -11767,7 +11767,7 @@ declare module 'date-fns-jalali/esm/fp' { - - const formatDistanceWithOptions: CurriedFn3< - { -- locale?: Locale -+ locale?: LocaleJalali - addSuffix?: boolean - includeSeconds?: boolean - }, -@@ -11793,7 +11793,7 @@ declare module 'date-fns-jalali/esm/fp' { - > - namespace formatISO9075WithOptions {} - -- const formatISODuration: CurriedFn1 -+ const formatISODuration: CurriedFn1 - namespace formatISODuration {} - - const formatISOWithOptions: CurriedFn2< -@@ -11812,7 +11812,7 @@ declare module 'date-fns-jalali/esm/fp' { - const formatRelativeWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date | number, -@@ -11841,7 +11841,7 @@ declare module 'date-fns-jalali/esm/fp' { - useAdditionalWeekYearTokens?: boolean - firstWeekContainsDate?: number - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - string, - Date | number, -@@ -11894,7 +11894,7 @@ declare module 'date-fns-jalali/esm/fp' { - const getMonth: CurriedFn1 - namespace getMonth {} - -- const getOverlappingDaysInIntervals: CurriedFn2 -+ const getOverlappingDaysInIntervals: CurriedFn2 - namespace getOverlappingDaysInIntervals {} - - const getQuarter: CurriedFn1 -@@ -11918,7 +11918,7 @@ declare module 'date-fns-jalali/esm/fp' { - const getWeekOfMonthWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -11931,7 +11931,7 @@ declare module 'date-fns-jalali/esm/fp' { - const getWeeksInMonthWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -11942,7 +11942,7 @@ declare module 'date-fns-jalali/esm/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -11956,7 +11956,7 @@ declare module 'date-fns-jalali/esm/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - number -@@ -11966,7 +11966,7 @@ declare module 'date-fns-jalali/esm/fp' { - const getYear: CurriedFn1 - namespace getYear {} - -- const intervalToDuration: CurriedFn1 -+ const intervalToDuration: CurriedFn1 - namespace intervalToDuration {} - - const isAfter: CurriedFn2 -@@ -12029,7 +12029,7 @@ declare module 'date-fns-jalali/esm/fp' { - const isSameWeekWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date | number, -@@ -12061,7 +12061,7 @@ declare module 'date-fns-jalali/esm/fp' { - const isWeekend: CurriedFn1 - namespace isWeekend {} - -- const isWithinInterval: CurriedFn2 -+ const isWithinInterval: CurriedFn2 - namespace isWithinInterval {} - - const lastDayOfDecade: CurriedFn1 -@@ -12094,7 +12094,7 @@ declare module 'date-fns-jalali/esm/fp' { - const lastDayOfWeekWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -12137,7 +12137,7 @@ declare module 'date-fns-jalali/esm/fp' { - useAdditionalWeekYearTokens?: boolean - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - string, -@@ -12185,7 +12185,7 @@ declare module 'date-fns-jalali/esm/fp' { - const setDayWithOptions: CurriedFn3< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - number, - Date | number, -@@ -12227,7 +12227,7 @@ declare module 'date-fns-jalali/esm/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - number, - Date | number, -@@ -12242,7 +12242,7 @@ declare module 'date-fns-jalali/esm/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - number, - Date | number, -@@ -12286,7 +12286,7 @@ declare module 'date-fns-jalali/esm/fp' { - const startOfWeekWithOptions: CurriedFn2< - { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -12300,7 +12300,7 @@ declare module 'date-fns-jalali/esm/fp' { - { - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 -- locale?: Locale -+ locale?: LocaleJalali - }, - Date | number, - Date -@@ -12310,7 +12310,7 @@ declare module 'date-fns-jalali/esm/fp' { - const startOfYear: CurriedFn1 - namespace startOfYear {} - -- const sub: CurriedFn2 -+ const sub: CurriedFn2 - namespace sub {} - - const subBusinessDays: CurriedFn2 -@@ -15342,223 +15342,223 @@ declare module 'date-fns-jalali/esm/fp/toDate/index.js' { - // Regular Locales - - declare module 'date-fns-jalali/locale' { -- const af: Locale -+ const af: LocaleJalali - namespace af {} - -- const ar: Locale -+ const ar: LocaleJalali - namespace ar {} - -- const arDZ: Locale -+ const arDZ: LocaleJalali - namespace arDZ {} - -- const arMA: Locale -+ const arMA: LocaleJalali - namespace arMA {} - -- const arSA: Locale -+ const arSA: LocaleJalali - namespace arSA {} - -- const az: Locale -+ const az: LocaleJalali - namespace az {} - -- const be: Locale -+ const be: LocaleJalali - namespace be {} - -- const bg: Locale -+ const bg: LocaleJalali - namespace bg {} - -- const bn: Locale -+ const bn: LocaleJalali - namespace bn {} - -- const ca: Locale -+ const ca: LocaleJalali - namespace ca {} - -- const cs: Locale -+ const cs: LocaleJalali - namespace cs {} - -- const cy: Locale -+ const cy: LocaleJalali - namespace cy {} - -- const da: Locale -+ const da: LocaleJalali - namespace da {} - -- const de: Locale -+ const de: LocaleJalali - namespace de {} - -- const el: Locale -+ const el: LocaleJalali - namespace el {} - -- const enAU: Locale -+ const enAU: LocaleJalali - namespace enAU {} - -- const enCA: Locale -+ const enCA: LocaleJalali - namespace enCA {} - -- const enGB: Locale -+ const enGB: LocaleJalali - namespace enGB {} - -- const enUS: Locale -+ const enUS: LocaleJalali - namespace enUS {} - -- const eo: Locale -+ const eo: LocaleJalali - namespace eo {} - -- const es: Locale -+ const es: LocaleJalali - namespace es {} - -- const et: Locale -+ const et: LocaleJalali - namespace et {} - -- const faIR: Locale -+ const faIR: LocaleJalali - namespace faIR {} - -- const fajalaliIR: Locale -+ const fajalaliIR: LocaleJalali - namespace fajalaliIR {} - -- const fi: Locale -+ const fi: LocaleJalali - namespace fi {} - -- const fil: Locale -+ const fil: LocaleJalali - namespace fil {} - -- const fr: Locale -+ const fr: LocaleJalali - namespace fr {} - -- const frCA: Locale -+ const frCA: LocaleJalali - namespace frCA {} - -- const frCH: Locale -+ const frCH: LocaleJalali - namespace frCH {} - -- const gl: Locale -+ const gl: LocaleJalali - namespace gl {} - -- const gu: Locale -+ const gu: LocaleJalali - namespace gu {} - -- const he: Locale -+ const he: LocaleJalali - namespace he {} - -- const hi: Locale -+ const hi: LocaleJalali - namespace hi {} - -- const hr: Locale -+ const hr: LocaleJalali - namespace hr {} - -- const hu: Locale -+ const hu: LocaleJalali - namespace hu {} - -- const hy: Locale -+ const hy: LocaleJalali - namespace hy {} - -- const id: Locale -+ const id: LocaleJalali - namespace id {} - -- const is: Locale -+ const is: LocaleJalali - namespace is {} - -- const it: Locale -+ const it: LocaleJalali - namespace it {} - -- const ja: Locale -+ const ja: LocaleJalali - namespace ja {} - -- const ka: Locale -+ const ka: LocaleJalali - namespace ka {} - -- const kk: Locale -+ const kk: LocaleJalali - namespace kk {} - -- const kn: Locale -+ const kn: LocaleJalali - namespace kn {} - -- const ko: Locale -+ const ko: LocaleJalali - namespace ko {} - -- const lt: Locale -+ const lt: LocaleJalali - namespace lt {} - -- const lv: Locale -+ const lv: LocaleJalali - namespace lv {} - -- const mk: Locale -+ const mk: LocaleJalali - namespace mk {} - -- const ms: Locale -+ const ms: LocaleJalali - namespace ms {} - -- const mt: Locale -+ const mt: LocaleJalali - namespace mt {} - -- const nb: Locale -+ const nb: LocaleJalali - namespace nb {} - -- const nl: Locale -+ const nl: LocaleJalali - namespace nl {} - -- const nlBE: Locale -+ const nlBE: LocaleJalali - namespace nlBE {} - -- const nn: Locale -+ const nn: LocaleJalali - namespace nn {} - -- const pl: Locale -+ const pl: LocaleJalali - namespace pl {} - -- const pt: Locale -+ const pt: LocaleJalali - namespace pt {} - -- const ptBR: Locale -+ const ptBR: LocaleJalali - namespace ptBR {} - -- const ro: Locale -+ const ro: LocaleJalali - namespace ro {} - -- const ru: Locale -+ const ru: LocaleJalali - namespace ru {} - -- const sk: Locale -+ const sk: LocaleJalali - namespace sk {} - -- const sl: Locale -+ const sl: LocaleJalali - namespace sl {} - -- const sr: Locale -+ const sr: LocaleJalali - namespace sr {} - -- const srLatn: Locale -+ const srLatn: LocaleJalali - namespace srLatn {} - -- const sv: Locale -+ const sv: LocaleJalali - namespace sv {} - -- const ta: Locale -+ const ta: LocaleJalali - namespace ta {} - -- const te: Locale -+ const te: LocaleJalali - namespace te {} - -- const th: Locale -+ const th: LocaleJalali - namespace th {} - -- const tr: Locale -+ const tr: LocaleJalali - namespace tr {} - -- const ug: Locale -+ const ug: LocaleJalali - namespace ug {} - -- const uk: Locale -+ const uk: LocaleJalali - namespace uk {} - -- const uz: Locale -+ const uz: LocaleJalali - namespace uz {} - -- const vi: Locale -+ const vi: LocaleJalali - namespace vi {} - -- const zhCN: Locale -+ const zhCN: LocaleJalali - namespace zhCN {} - -- const zhTW: Locale -+ const zhTW: LocaleJalali - namespace zhTW {} - } - -@@ -16660,223 +16660,223 @@ declare module 'date-fns-jalali/locale/zh-TW/index.js' { - // ECMAScript Module Locales - - declare module 'date-fns-jalali/esm/locale' { -- const af: Locale -+ const af: LocaleJalali - namespace af {} - -- const ar: Locale -+ const ar: LocaleJalali - namespace ar {} - -- const arDZ: Locale -+ const arDZ: LocaleJalali - namespace arDZ {} - -- const arMA: Locale -+ const arMA: LocaleJalali - namespace arMA {} - -- const arSA: Locale -+ const arSA: LocaleJalali - namespace arSA {} - -- const az: Locale -+ const az: LocaleJalali - namespace az {} - -- const be: Locale -+ const be: LocaleJalali - namespace be {} - -- const bg: Locale -+ const bg: LocaleJalali - namespace bg {} - -- const bn: Locale -+ const bn: LocaleJalali - namespace bn {} - -- const ca: Locale -+ const ca: LocaleJalali - namespace ca {} - -- const cs: Locale -+ const cs: LocaleJalali - namespace cs {} - -- const cy: Locale -+ const cy: LocaleJalali - namespace cy {} - -- const da: Locale -+ const da: LocaleJalali - namespace da {} - -- const de: Locale -+ const de: LocaleJalali - namespace de {} - -- const el: Locale -+ const el: LocaleJalali - namespace el {} - -- const enAU: Locale -+ const enAU: LocaleJalali - namespace enAU {} - -- const enCA: Locale -+ const enCA: LocaleJalali - namespace enCA {} - -- const enGB: Locale -+ const enGB: LocaleJalali - namespace enGB {} - -- const enUS: Locale -+ const enUS: LocaleJalali - namespace enUS {} - -- const eo: Locale -+ const eo: LocaleJalali - namespace eo {} - -- const es: Locale -+ const es: LocaleJalali - namespace es {} - -- const et: Locale -+ const et: LocaleJalali - namespace et {} - -- const faIR: Locale -+ const faIR: LocaleJalali - namespace faIR {} - -- const fajalaliIR: Locale -+ const fajalaliIR: LocaleJalali - namespace fajalaliIR {} - -- const fi: Locale -+ const fi: LocaleJalali - namespace fi {} - -- const fil: Locale -+ const fil: LocaleJalali - namespace fil {} - -- const fr: Locale -+ const fr: LocaleJalali - namespace fr {} - -- const frCA: Locale -+ const frCA: LocaleJalali - namespace frCA {} - -- const frCH: Locale -+ const frCH: LocaleJalali - namespace frCH {} - -- const gl: Locale -+ const gl: LocaleJalali - namespace gl {} - -- const gu: Locale -+ const gu: LocaleJalali - namespace gu {} - -- const he: Locale -+ const he: LocaleJalali - namespace he {} - -- const hi: Locale -+ const hi: LocaleJalali - namespace hi {} - -- const hr: Locale -+ const hr: LocaleJalali - namespace hr {} - -- const hu: Locale -+ const hu: LocaleJalali - namespace hu {} - -- const hy: Locale -+ const hy: LocaleJalali - namespace hy {} - -- const id: Locale -+ const id: LocaleJalali - namespace id {} - -- const is: Locale -+ const is: LocaleJalali - namespace is {} - -- const it: Locale -+ const it: LocaleJalali - namespace it {} - -- const ja: Locale -+ const ja: LocaleJalali - namespace ja {} - -- const ka: Locale -+ const ka: LocaleJalali - namespace ka {} - -- const kk: Locale -+ const kk: LocaleJalali - namespace kk {} - -- const kn: Locale -+ const kn: LocaleJalali - namespace kn {} - -- const ko: Locale -+ const ko: LocaleJalali - namespace ko {} - -- const lt: Locale -+ const lt: LocaleJalali - namespace lt {} - -- const lv: Locale -+ const lv: LocaleJalali - namespace lv {} - -- const mk: Locale -+ const mk: LocaleJalali - namespace mk {} - -- const ms: Locale -+ const ms: LocaleJalali - namespace ms {} - -- const mt: Locale -+ const mt: LocaleJalali - namespace mt {} - -- const nb: Locale -+ const nb: LocaleJalali - namespace nb {} - -- const nl: Locale -+ const nl: LocaleJalali - namespace nl {} - -- const nlBE: Locale -+ const nlBE: LocaleJalali - namespace nlBE {} - -- const nn: Locale -+ const nn: LocaleJalali - namespace nn {} - -- const pl: Locale -+ const pl: LocaleJalali - namespace pl {} - -- const pt: Locale -+ const pt: LocaleJalali - namespace pt {} - -- const ptBR: Locale -+ const ptBR: LocaleJalali - namespace ptBR {} - -- const ro: Locale -+ const ro: LocaleJalali - namespace ro {} - -- const ru: Locale -+ const ru: LocaleJalali - namespace ru {} - -- const sk: Locale -+ const sk: LocaleJalali - namespace sk {} - -- const sl: Locale -+ const sl: LocaleJalali - namespace sl {} - -- const sr: Locale -+ const sr: LocaleJalali - namespace sr {} - -- const srLatn: Locale -+ const srLatn: LocaleJalali - namespace srLatn {} - -- const sv: Locale -+ const sv: LocaleJalali - namespace sv {} - -- const ta: Locale -+ const ta: LocaleJalali - namespace ta {} - -- const te: Locale -+ const te: LocaleJalali - namespace te {} - -- const th: Locale -+ const th: LocaleJalali - namespace th {} - -- const tr: Locale -+ const tr: LocaleJalali - namespace tr {} - -- const ug: Locale -+ const ug: LocaleJalali - namespace ug {} - -- const uk: Locale -+ const uk: LocaleJalali - namespace uk {} - -- const uz: Locale -+ const uz: LocaleJalali - namespace uz {} - -- const vi: Locale -+ const vi: LocaleJalali - namespace vi {} - -- const zhCN: Locale -+ const zhCN: LocaleJalali - namespace zhCN {} - -- const zhTW: Locale -+ const zhTW: LocaleJalali - namespace zhTW {} - } - -@@ -17978,7 +17978,7 @@ declare module 'date-fns-jalali/esm/locale/zh-TW/index.js' { - // dateFns Global Interface - - interface dateFns { -- add(date: Date | number, duration: Duration): Date -+ add(date: Date | number, duration: DurationJalali): Date - - addBusinessDays(date: Date | number, amount: number): Date - -@@ -18003,8 +18003,8 @@ interface dateFns { - addYears(date: Date | number, amount: number): Date - - areIntervalsOverlapping( -- intervalLeft: Interval, -- intervalRight: Interval, -+ intervalLeft: IntervalJalali, -+ intervalRight: IntervalJalali, - options?: { - inclusive?: boolean - } -@@ -18055,7 +18055,7 @@ interface dateFns { - dateLeft: Date | number, - dateRight: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): number -@@ -18095,29 +18095,29 @@ interface dateFns { - differenceInYears(dateLeft: Date | number, dateRight: Date | number): number - - eachDayOfInterval( -- interval: Interval, -+ interval: IntervalJalali, - options?: { - step?: number - } - ): Date[] - -- eachMonthOfInterval(interval: Interval): Date[] -+ eachMonthOfInterval(interval: IntervalJalali): Date[] - -- eachWeekendOfInterval(interval: Interval): Date[] -+ eachWeekendOfInterval(interval: IntervalJalali): Date[] - - eachWeekendOfMonth(date: Date | number): Date[] - - eachWeekendOfYear(date: Date | number): Date[] - - eachWeekOfInterval( -- interval: Interval, -+ interval: IntervalJalali, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date[] - -- eachYearOfInterval(interval: Interval): Date[] -+ eachYearOfInterval(interval: IntervalJalali): Date[] - - endOfDay(date: Date | number): Date - -@@ -18149,7 +18149,7 @@ interface dateFns { - endOfWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -18162,7 +18162,7 @@ interface dateFns { - date: Date | number, - format: string, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: number - useAdditionalWeekYearTokens?: boolean -@@ -18176,7 +18176,7 @@ interface dateFns { - options?: { - includeSeconds?: boolean - addSuffix?: boolean -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - -@@ -18187,7 +18187,7 @@ interface dateFns { - addSuffix?: boolean - unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' - roundingMethod?: 'floor' | 'ceil' | 'round' -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - -@@ -18196,7 +18196,7 @@ interface dateFns { - options?: { - includeSeconds?: boolean - addSuffix?: boolean -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - -@@ -18206,7 +18206,7 @@ interface dateFns { - addSuffix?: boolean - unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' - roundingMethod?: 'floor' | 'ceil' | 'round' -- locale?: Locale -+ locale?: LocaleJalali - } - ): string - -@@ -18226,13 +18226,13 @@ interface dateFns { - } - ): string - -- formatISODuration(duration: Duration): string -+ formatISODuration(duration: DurationJalali): string - - formatRelative( - date: Date | number, - baseDate: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): string -@@ -18277,8 +18277,8 @@ interface dateFns { - getMonth(date: Date | number): number - - getOverlappingDaysInIntervals( -- intervalLeft: Interval, -- intervalRight: Interval -+ intervalLeft: IntervalJalali, -+ intervalRight: IntervalJalali - ): number - - getQuarter(date: Date | number): number -@@ -18292,7 +18292,7 @@ interface dateFns { - getWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -18301,7 +18301,7 @@ interface dateFns { - getWeekOfMonth( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): number -@@ -18309,7 +18309,7 @@ interface dateFns { - getWeeksInMonth( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): number -@@ -18317,7 +18317,7 @@ interface dateFns { - getWeekYear( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -18325,7 +18325,7 @@ interface dateFns { - - getYear(date: Date | number): number - -- intervalToDuration(interval: Interval): Duration -+ intervalToDuration(interval: IntervalJalali): DurationJalali - - isAfter(date: Date | number, dateToCompare: Date | number): boolean - -@@ -18371,7 +18371,7 @@ interface dateFns { - dateLeft: Date | number, - dateRight: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): boolean -@@ -18397,7 +18397,7 @@ interface dateFns { - isThisWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): boolean -@@ -18418,7 +18418,7 @@ interface dateFns { - - isWeekend(date: Date | number): boolean - -- isWithinInterval(date: Date | number, interval: Interval): boolean -+ isWithinInterval(date: Date | number, interval: IntervalJalali): boolean - - isYesterday(date: Date | number): boolean - -@@ -18440,7 +18440,7 @@ interface dateFns { - lastDayOfWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -18458,7 +18458,7 @@ interface dateFns { - formatString: string, - referenceDate: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - useAdditionalWeekYearTokens?: boolean -@@ -18501,7 +18501,7 @@ interface dateFns { - date: Date | number, - day: number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -18530,7 +18530,7 @@ interface dateFns { - date: Date | number, - week: number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -18540,7 +18540,7 @@ interface dateFns { - date: Date | number, - weekYear: number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -18573,7 +18573,7 @@ interface dateFns { - startOfWeek( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - } - ): Date -@@ -18581,7 +18581,7 @@ interface dateFns { - startOfWeekYear( - date: Date | number, - options?: { -- locale?: Locale -+ locale?: LocaleJalali - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 - firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 - } -@@ -18591,7 +18591,7 @@ interface dateFns { - - startOfYesterday(): Date - -- sub(date: Date | number, duration: Duration): Date -+ sub(date: Date | number, duration: DurationJalali): Date - - subBusinessDays(date: Date | number, amount: number): Date - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d6b3b526fac34..279f8fe6d16a3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,9 +12,6 @@ patchedDependencies: babel-plugin-replace-imports@1.0.2: hash: 7wlacyoi44skuhtzjdjwgtjyxe path: patches/babel-plugin-replace-imports@1.0.2.patch - date-fns-jalali@2.13.0-0: - hash: knk56uiq6xxn77bv6lgrgre7si - path: patches/date-fns-jalali@2.13.0-0.patch karma-mocha@2.0.1: hash: r6idlcdpax26bbzwxyjicxb5ra path: patches/karma-mocha@2.0.1.patch @@ -513,8 +510,8 @@ importers: specifier: ^2.30.0 version: 2.30.0 date-fns-jalali: - specifier: ^2.21.3-1 - version: 2.21.3-1 + specifier: ^2.30.0-0 + version: 2.30.0-0 dayjs: specifier: ^1.11.11 version: 1.11.11 @@ -1049,8 +1046,8 @@ importers: specifier: ^2.30.0 version: 2.30.0 date-fns-jalali: - specifier: ^2.13.0-0 - version: 2.13.0-0(patch_hash=knk56uiq6xxn77bv6lgrgre7si) + specifier: ^2.30.0-0 + version: 2.30.0-0 dayjs: specifier: ^1.11.11 version: 1.11.11 @@ -1106,9 +1103,6 @@ importers: clsx: specifier: ^2.1.1 version: 2.1.1 - date-fns-jalali: - specifier: ^2.13.0-0 || ^3.2.0-0 - version: 2.13.0-0(patch_hash=knk56uiq6xxn77bv6lgrgre7si) moment-hijri: specifier: ^2.1.2 version: 2.1.2 @@ -1137,6 +1131,9 @@ importers: date-fns: specifier: ^2.30.0 version: 2.30.0 + date-fns-jalali: + specifier: ^2.30.0-0 + version: 2.30.0-0 dayjs: specifier: ^1.11.11 version: 1.11.11 @@ -8189,14 +8186,11 @@ packages: is-data-view: 1.0.1 dev: true - /date-fns-jalali@2.13.0-0(patch_hash=knk56uiq6xxn77bv6lgrgre7si): - resolution: {integrity: sha512-yjlI9O18Z6ryGNagryrLO8OQ+3rishM3+A0UOX2UX10cWMn2NTlQcQ+ywTEJvF5IJz0FwX/slt2nCcpyQ/c8gw==} - patched: true - - /date-fns-jalali@2.21.3-1: - resolution: {integrity: sha512-Sgw1IdgCgyWDKCpq6uwAu24vPMOtvmcXXXuETr1jQO/aVj4h23XAltcP7hLbo+osqoiJnPmiydbI/q1W7TYAjA==} + /date-fns-jalali@2.30.0-0: + resolution: {integrity: sha512-2wz5AOzd3oQ+PnL3E/iKvJZ14i6oTp15sW047ZFCOgM9OSP8ggbb9jm/4SKI8ejdUGH96Krb5dfEQe8zbkVyZw==} engines: {node: '>=0.11'} - dev: false + dependencies: + '@babel/runtime': 7.24.4 /date-fns-jalali@3.6.0-0: resolution: {integrity: sha512-rcOocwhBFgEN4i+vXPoEp/irCxAmX8yloK/l/oeMOVCLpaFQfkq7jVn0vCWK91P2H9I/doSAPEN4WSWQeqwsug==} From 4a68033a50d40915aef8e021a809e72ed03eab24 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 8 May 2024 19:20:43 +0300 Subject: [PATCH 16/16] Remove no longer needed patch file --- patches/@mui__monorepo@6.0.0-alpha.0.patch | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 patches/@mui__monorepo@6.0.0-alpha.0.patch diff --git a/patches/@mui__monorepo@6.0.0-alpha.0.patch b/patches/@mui__monorepo@6.0.0-alpha.0.patch deleted file mode 100644 index 1d4fdf8800af0..0000000000000 --- a/patches/@mui__monorepo@6.0.0-alpha.0.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/packages/api-docs-builder/utils/parseTest.ts b/packages/api-docs-builder/utils/parseTest.ts -index 14d2c70c9939cb2e71e7664c06e8f51700711772..e21e06960ffbaf05aff6e5d4d7faa123cb6105bc 100644 ---- a/packages/api-docs-builder/utils/parseTest.ts -+++ b/packages/api-docs-builder/utils/parseTest.ts -@@ -3,7 +3,7 @@ import * as babel from '@babel/core'; - import { readFile } from 'fs-extra'; - import glob from 'fast-glob'; - --const workspaceRoot = path.join(__dirname, '../../../'); -+const workspaceRoot = process.cwd(); - const babelConfigPath = path.join(workspaceRoot, 'babel.config.js'); - - function getTestFilesNames(filepath: string) {