Skip to content

Commit

Permalink
XS-414 weekdays bug fix and removed unnecessary console log (xola#348)
Browse files Browse the repository at this point in the history
* 2.3.13

* XS-414 Fixed issue
  • Loading branch information
manojx031 authored Sep 18, 2024
1 parent b27eae8 commit ff00cfe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xola/ui-kit",
"version": "2.3.12",
"version": "2.3.13",
"description": "Xola UI Kit",
"license": "MIT",
"repository": {
Expand Down
10 changes: 5 additions & 5 deletions src/components/DatePicker/DatePicker.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { DayPickerProps } from "react-day-picker";
export type LocaleCode = keyof typeof locales;

interface ExtendedDayPickerProps extends DayPickerProps {
monthsShort?: string;
monthsShort?: string[];
}

export type LocalizationProps = Pick<
Expand All @@ -19,12 +19,12 @@ export type LocalizationProps = Pick<

const locales = {
en: en,
en_US: en,
en_GB: enGB,
"en-US": en,
"en-GB": enGB,

es: es,
es_ES: es,
es_MX: esMX,
"es-ES": es,
"es-MX": esMX,

fr: fr,
de: de,
Expand Down
8 changes: 6 additions & 2 deletions src/components/DatePicker/LocalizedDayPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import clsx from "clsx";
import React, { forwardRef, useContext, useEffect, useState } from "react";
import DayPicker, { DayPickerProps } from "react-day-picker";
import { kebabCase } from "lodash";
import { Context } from "../Provider";
import { getLocalizationProps, LocaleCode, LocalizationProps } from "./DatePicker.helpers";

export const LocalizedDayPicker = forwardRef<any, DayPickerProps>(({ className, ...rest }, ref) => {
const { locale } = useContext(Context);
const [localizationProps, setLocalizationProps] = useState<Partial<LocalizationProps>>({});
console.log("Locale", locale);

useEffect(() => {
setLocalizationProps({});
const localeCode = kebabCase(locale).toLowerCase();

/** We don't want any localization-related props for "English" */
if (!locale || locale === "en" || locale === "en_US") return;
if (!localeCode || localeCode === "en" || localeCode === "en-us") return;

getLocalizationProps(locale as LocaleCode).then(setLocalizationProps);
}, [locale]);

/**
* Note: DayPicker expects locale in en-US, es, en-GB format
*/
return <DayPicker ref={ref} className={clsx(className)} {...localizationProps} {...rest} />;
});

0 comments on commit ff00cfe

Please sign in to comment.