-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: downgrade mantine to v6 (#2202)
* chore: downgrade mantine to v6 * chore: update * chore: add data-hidden * chore: separate styled props * chore: fix interaction test * chore: update * Create swift-elephants-reflect.md * chore: update * chore: update * chore: update
- Loading branch information
1 parent
3269642
commit d9bb522
Showing
12 changed files
with
337 additions
and
104 deletions.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@razorpay/blade": minor | ||
--- | ||
|
||
refactor(blade): downgrade mantine to v6 |
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
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
49 changes: 49 additions & 0 deletions
49
packages/blade/src/components/DatePicker/shiftTimezone.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,49 @@ | ||
import dayjs from 'dayjs'; | ||
import timezonePlugin from 'dayjs/plugin/timezone'; | ||
import utcPlugin from 'dayjs/plugin/utc'; | ||
import type { DateValue, DatesRangeValue } from './types'; | ||
|
||
dayjs.extend(utcPlugin); | ||
dayjs.extend(timezonePlugin); | ||
|
||
function getTimezoneOffset(date: Date, timezone?: string): number { | ||
if (timezone) { | ||
return dayjs(date).tz(timezone).utcOffset() + date.getTimezoneOffset(); | ||
} | ||
return 0; | ||
} | ||
|
||
type TimeShiftDirection = 'add' | 'remove'; | ||
|
||
const updateTimezone = ( | ||
date: DateValue | undefined, | ||
timezone?: string, | ||
direction?: TimeShiftDirection, | ||
): DateValue => { | ||
if (!date) { | ||
return null; | ||
} | ||
if (!timezone) { | ||
return date; | ||
} | ||
let offset = getTimezoneOffset(date, timezone); | ||
if (direction === 'remove') { | ||
offset *= -1; | ||
} | ||
return dayjs(date).add(offset, 'minutes').toDate(); | ||
}; | ||
|
||
export function shiftTimezone<T extends DateValue | Date[] | DatesRangeValue | undefined>( | ||
direction: TimeShiftDirection, | ||
date: T, | ||
timezone?: string, | ||
disabled?: boolean, | ||
): T { | ||
if (disabled || !date) { | ||
return date; | ||
} | ||
if (Array.isArray(date)) { | ||
return date.map((d) => updateTimezone(d, timezone, direction)) as T; | ||
} | ||
return updateTimezone(date, timezone, direction) as T; | ||
} |
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
Oops, something went wrong.