-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pickers] Add AdapterDateFnsJalaliV3
adapter
#12891
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9590493
fix babel-plugin-replace-imports patch
smmoosavi 772f59a
install date-fns-jalali-v3
smmoosavi d99d2df
copy AdapterDateFnsJalali to AdapterDateFnsJalaliV3
smmoosavi e7357b7
rename AdapterDateFnsJalali.ts to AdapterDateFnsJalaliV3.ts
smmoosavi 5579dc8
add version check to constructors
smmoosavi 6b2d16a
fix imports
smmoosavi b90e8f8
fix package.json
smmoosavi 1018a20
fix babel config
smmoosavi 52f2e3e
fix tests
smmoosavi 5751d9f
Merge remote-tracking branch 'upstream/master' into date-fns-jalali-v3
LukasTy 07965c8
Add to codecov
LukasTy dc2e5fc
Minor fixes
LukasTy 1d25c92
prettier
LukasTy 38acb8c
Add documentation about `date-fns-jalali`@v3 support
LukasTy ffd19f4
Add support to `@mui/x-date-pickers-pro` package
LukasTy c7ecaa1
Fix build and bump `date-fns-jalali` to latest v2.x
LukasTy 4a68033
Remove no longer needed patch file
LukasTy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,9 +91,20 @@ module.exports = function getBabelConfig(api) { | |
{ | ||
test: /date-fns/i, | ||
replacer: 'date-fns-v3', | ||
ignoreFilenames: 'AdapterDateFns.ts', | ||
// This option is provided by the `patches/[email protected]` patch | ||
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/[email protected]` patch | ||
filenameIncludes: 'src/AdapterDateFnsJalaliV3/', | ||
}, | ||
'replace-date-fns-jalali-imports', | ||
]); | ||
} | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,7 @@ | |
"cpy-cli": "^5.0.0", | ||
"cross-env": "^7.0.3", | ||
"danger": "^11.3.1", | ||
"date-fns-jalali-v3": "npm:[email protected]", | ||
"date-fns-v3": "npm:[email protected]", | ||
"enzyme": "^3.11.0", | ||
"eslint": "^8.57.0", | ||
|
@@ -195,7 +196,6 @@ | |
"packageManager": "[email protected]", | ||
"pnpm": { | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did not seem needed anymore! 👏 🥳 |
||
"[email protected]": "patches/[email protected]", | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/x-date-pickers-pro/src/AdapterDateFnsJalaliV3/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to bump the version to have the exported |
||
"dayjs": "^1.11.11", | ||
"luxon": "^3.4.4", | ||
"moment": "^2.30.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/x-date-pickers/src/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { expect } from 'chai'; | ||
import { DateTimeField } from '@mui/x-date-pickers'; | ||
import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3'; | ||
import { | ||
createPickerRenderer, | ||
expectFieldValueV7, | ||
describeJalaliAdapter, | ||
buildFieldInteractions, | ||
} from 'test/utils/pickers'; | ||
import { enUS, faIR } from 'date-fns-jalali/locale'; | ||
import { AdapterFormats } from '@mui/x-date-pickers/models'; | ||
|
||
describe('<AdapterDateFnsJalaliV3 />', () => { | ||
describeJalaliAdapter(AdapterDateFnsJalali, {}); | ||
|
||
describe('Adapter localization', () => { | ||
it('Formatting', () => { | ||
const adapter = new AdapterDateFnsJalali(); | ||
|
||
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', '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'); | ||
}); | ||
}); | ||
|
||
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 ق.ظ.', | ||
}, | ||
}; | ||
|
||
Object.keys(localizedTexts).forEach((localeKey) => { | ||
const localeObject = { | ||
faIR, | ||
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); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strangely, it has not been picked up by renovate...
The version format could be to blame. 🙈