From ac5d031d7cf985a9edebfa533d62712f7b3ea14d Mon Sep 17 00:00:00 2001 From: kirtesh-xola Date: Thu, 29 Feb 2024 15:33:20 +0530 Subject: [PATCH 01/21] XS-25 feat(purchase-guests): adds `CircleCheckFilledIcon` and `WarningFilledIcon` --- src/icons/index.js | 2 ++ src/icons/src/CircleCheckFilledIcon.jsx | 24 ++++++++++++++++++++++++ src/icons/src/WarningFilledIcon.jsx | 25 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/icons/src/CircleCheckFilledIcon.jsx create mode 100644 src/icons/src/WarningFilledIcon.jsx diff --git a/src/icons/index.js b/src/icons/index.js index 3b102377e..a8b6f36b2 100644 --- a/src/icons/index.js +++ b/src/icons/index.js @@ -42,6 +42,7 @@ export { ChevronRightIcon } from "./src/ChevronRightIcon"; export { ChevronUpIcon } from "./src/ChevronUpIcon"; export { ChipIcon } from "./src/ChipIcon"; export { CircleCheckIcon } from "./src/CircleCheckIcon"; +export { CircleCheckFilledIcon } from "./src/CircleCheckFilledIcon"; export { CircleCrossIcon } from "./src/CircleCrossIcon"; export { CircleCrossImage } from "./src/images/CircleCrossImage"; export { CircleCrownIcon } from "./src/CircleCrownIcon"; @@ -202,6 +203,7 @@ export { VoucherIcon } from "./src/VoucherIcon"; export { WaitlistIcon } from "./src/WaitlistIcon"; export { WarningDiamondIcon } from "./src/WarningDiamondIcon"; export { WarningIcon } from "./src/WarningIcon"; +export { WarningFilledIcon } from "./src/WarningFilledIcon"; export { WarningTriangleIcon } from "./src/WarningTriangleIcon"; export { WeightIcon } from "./src/WeightIcon"; export { WifiIcon } from "./src/WifiIcon"; diff --git a/src/icons/src/CircleCheckFilledIcon.jsx b/src/icons/src/CircleCheckFilledIcon.jsx new file mode 100644 index 000000000..420d157b8 --- /dev/null +++ b/src/icons/src/CircleCheckFilledIcon.jsx @@ -0,0 +1,24 @@ +import React from "react"; +import { createIcon } from "./helpers/icon"; + +export const CircleCheckFilledIcon = createIcon((props) => { + return ( + + + + + ); +}); + +CircleCheckFilledIcon.tags = ["tick", "correct", "filled"]; diff --git a/src/icons/src/WarningFilledIcon.jsx b/src/icons/src/WarningFilledIcon.jsx new file mode 100644 index 000000000..198b3b49c --- /dev/null +++ b/src/icons/src/WarningFilledIcon.jsx @@ -0,0 +1,25 @@ +import React from "react"; +import { createIcon } from "./helpers/icon"; + +export const WarningFilledIcon = createIcon((props) => { + return ( + + + + + + ); +}); + +WarningFilledIcon.tags = ["exclamation", "filled"]; From 4f9545179b4481ab92822eb16b692931e9f30ae3 Mon Sep 17 00:00:00 2001 From: kirtesh-xola Date: Wed, 3 Apr 2024 12:28:54 +0530 Subject: [PATCH 02/21] feat: adds localization support for DatePicker --- .../DatePicker/DatePicker.helpers.ts | 35 +++++++++++++++++++ src/components/DatePicker/DatePicker.jsx | 5 +-- .../DatePicker/LocalizedDayPicker.tsx | 21 +++++++++++ src/components/DatePicker/RangeDatePicker.jsx | 6 ++-- src/components/Provider.jsx | 8 +++-- 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 src/components/DatePicker/DatePicker.helpers.ts create mode 100644 src/components/DatePicker/LocalizedDayPicker.tsx diff --git a/src/components/DatePicker/DatePicker.helpers.ts b/src/components/DatePicker/DatePicker.helpers.ts new file mode 100644 index 000000000..c2354a1d2 --- /dev/null +++ b/src/components/DatePicker/DatePicker.helpers.ts @@ -0,0 +1,35 @@ +import type { DayPickerProps } from "react-day-picker"; + +export type LocaleCode = keyof typeof locales; + +export type LocalizationProps = Pick< + DayPickerProps, + "locale" | "months" | "weekdaysLong" | "weekdaysShort" | "firstDayOfWeek" +>; + +const locales = { + en: import("dayjs/locale/en"), + en_US: import("dayjs/locale/en"), + en_GB: import("dayjs/locale/en-gb"), + + es: import("dayjs/locale/es"), + es_ES: import("dayjs/locale/es"), + es_MX: import("dayjs/locale/es-mx"), +}; + +export const getLocalizationProps = async (localeCode: LocaleCode): Promise> => { + try { + const locale = await locales[localeCode]; + + return { + locale: localeCode, + weekdaysLong: locale.weekdays, + weekdaysShort: locale.weekdaysShort, + months: locale.months, + firstDayOfWeek: locale.weekStart, + }; + } catch (error) { + console.error("Error: React Day Picker localization error", error); + throw error; + } +}; diff --git a/src/components/DatePicker/DatePicker.jsx b/src/components/DatePicker/DatePicker.jsx index a2a21306f..740cce1b6 100644 --- a/src/components/DatePicker/DatePicker.jsx +++ b/src/components/DatePicker/DatePicker.jsx @@ -2,7 +2,7 @@ import clsx from "clsx"; import dayjs from "dayjs"; import PropTypes from "prop-types"; import React, { useEffect, useState } from "react"; -import DayPicker, { DateUtils } from "react-day-picker"; +import { DateUtils } from "react-day-picker"; import "react-day-picker/lib/style.css"; import "./DatePicker.css"; import { isArray, isFunction } from "lodash"; @@ -14,6 +14,7 @@ import { RelativeDateRange } from "./RelativeDateRange"; import RangeDatePicker from "./RangeDatePicker"; import { UpcomingDatePicker } from "./UpcomingDatePicker"; import { NavbarElement } from "./NavbarElement"; +import { LocalizedDayPicker } from "./LocalizedDayPicker"; const variants = { single: "single", @@ -227,7 +228,7 @@ export const DatePicker = ({ {...rest} /> ) : ( - ((props, ref) => { + const { locale } = useContext(Context); + const [localizationProps, setLocalizationProps] = useState>({}); + + useEffect(() => { + setLocalizationProps({}); + + /** We don't want any localization-related props for "English" */ + if (locale === "en") return; + + getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); + }, [locale]); + + return ; +}); diff --git a/src/components/DatePicker/RangeDatePicker.jsx b/src/components/DatePicker/RangeDatePicker.jsx index 06d83994f..c5daf57bc 100644 --- a/src/components/DatePicker/RangeDatePicker.jsx +++ b/src/components/DatePicker/RangeDatePicker.jsx @@ -1,6 +1,5 @@ import React from "react"; import PropTypes from "prop-types"; -import DayPicker from "react-day-picker"; import clsx from "clsx"; import { isArray, isFunction } from "lodash"; import { Tooltip } from "../Tooltip"; @@ -8,6 +7,7 @@ import { now } from "../../helpers/date"; import { NavbarElement } from "./NavbarElement"; import { MonthYearSelector } from "./MonthYearSelector"; import { Day } from "./Day"; +import { LocalizedDayPicker } from "./LocalizedDayPicker"; const RangeDatePicker = ({ getTooltip, @@ -90,7 +90,7 @@ const RangeDatePicker = ({ return (
- - { +export const Provider = ({ children, localize = true, locale = "en" }) => { const idCounterRef = useRef(1); const generateId = useCallback(() => { return idCounterRef.current++; }, [idCounterRef]); - const value = useMemo(() => ({ generateId }), [generateId]); + const value = useMemo(() => ({ generateId, localize, locale }), [generateId, localize, locale]); return {children}; }; From 1607d45e51551005f37dcabcb4cc985aaf69d5dc Mon Sep 17 00:00:00 2001 From: kirtesh-xola Date: Fri, 12 Apr 2024 19:23:55 +0530 Subject: [PATCH 03/21] XS-30: adds translation-blacklist tag for DatePicker and Key --- src/components/DatePicker/DatePickerPopover.jsx | 2 +- src/components/DatePicker/LocalizedDayPicker.tsx | 5 +++-- src/components/Key.jsx | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/DatePicker/DatePickerPopover.jsx b/src/components/DatePicker/DatePickerPopover.jsx index 0477168fa..a5cb05a45 100644 --- a/src/components/DatePicker/DatePickerPopover.jsx +++ b/src/components/DatePicker/DatePickerPopover.jsx @@ -110,7 +110,7 @@ const DefaultInput = forwardRef(({ className, ...rest }, reference) => {
- +
diff --git a/src/components/DatePicker/LocalizedDayPicker.tsx b/src/components/DatePicker/LocalizedDayPicker.tsx index f6adb4543..e3becb6a2 100644 --- a/src/components/DatePicker/LocalizedDayPicker.tsx +++ b/src/components/DatePicker/LocalizedDayPicker.tsx @@ -3,8 +3,9 @@ import { Context } from "../Provider"; import DayPicker, { DayPickerProps } from "react-day-picker"; import { forwardRef, useEffect, useState } from "react"; import { getLocalizationProps, LocaleCode, LocalizationProps } from "./DatePicker.helpers"; +import clsx from "clsx"; -export const LocalizedDayPicker = forwardRef((props, ref) => { +export const LocalizedDayPicker = forwardRef(({ className, ...rest }, ref) => { const { locale } = useContext(Context); const [localizationProps, setLocalizationProps] = useState>({}); @@ -17,5 +18,5 @@ export const LocalizedDayPicker = forwardRef((props, ref) = getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); }, [locale]); - return ; + return ; }); diff --git a/src/components/Key.jsx b/src/components/Key.jsx index 0039c137d..e15cf1f0e 100644 --- a/src/components/Key.jsx +++ b/src/components/Key.jsx @@ -10,7 +10,7 @@ export const Key = ({ char, className, ...rest }) => {
Date: Fri, 12 Jul 2024 14:43:51 +0530 Subject: [PATCH 04/21] fix: updates sidebar component to support `className` and `align` props --- src/components/Sidebar/Sidebar.Button.jsx | 8 ++++++-- src/components/Sidebar/Sidebar.Link.jsx | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/Sidebar/Sidebar.Button.jsx b/src/components/Sidebar/Sidebar.Button.jsx index a84817a6a..8cf2dee14 100644 --- a/src/components/Sidebar/Sidebar.Button.jsx +++ b/src/components/Sidebar/Sidebar.Button.jsx @@ -1,11 +1,15 @@ import PropTypes from "prop-types"; import React from "react"; +import clsx from "clsx"; -export const SidebarButton = ({ icon: Icon, label, ...rest }) => { +export const SidebarButton = ({ icon: Icon, label, className, ...rest }) => { return ( ); @@ -34,6 +42,7 @@ export const SidebarLink = ({ isActive = false, icon: Icon, children, isSubMenuI SidebarLink.displayName = "Sidebar.Link"; SidebarLink.propTypes = { + align: PropTypes.oneOf(["center", "left", "right"]), isActive: PropTypes.bool, icon: PropTypes.func, children: PropTypes.node.isRequired, From ebc760dd65316cea78d3ed20594221bebb4edbe6 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 31 Jul 2024 15:53:31 +0530 Subject: [PATCH 05/21] XS-30 fixed date picker locale issues --- src/components/DatePicker/DatePicker.helpers.ts | 3 +++ src/components/DatePicker/DatePicker.jsx | 9 +++++++-- src/components/DatePicker/LocalizedDayPicker.tsx | 9 ++++----- src/components/DatePicker/RangeDatePicker.jsx | 3 ++- src/components/Provider.jsx | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/DatePicker/DatePicker.helpers.ts b/src/components/DatePicker/DatePicker.helpers.ts index c2354a1d2..befbf0aad 100644 --- a/src/components/DatePicker/DatePicker.helpers.ts +++ b/src/components/DatePicker/DatePicker.helpers.ts @@ -15,6 +15,9 @@ const locales = { es: import("dayjs/locale/es"), es_ES: import("dayjs/locale/es"), es_MX: import("dayjs/locale/es-mx"), + + fr: import("dayjs/locale/fr"), + de: import("dayjs/locale/de"), }; export const getLocalizationProps = async (localeCode: LocaleCode): Promise> => { diff --git a/src/components/DatePicker/DatePicker.jsx b/src/components/DatePicker/DatePicker.jsx index 334e2c8c0..425e5f476 100644 --- a/src/components/DatePicker/DatePicker.jsx +++ b/src/components/DatePicker/DatePicker.jsx @@ -1,7 +1,7 @@ import clsx from "clsx"; import dayjs from "dayjs"; import PropTypes from "prop-types"; -import React, { useEffect, useMemo, useState } from "react"; +import React, { useEffect, useMemo, useState, useContext } from "react"; import { DateUtils } from "react-day-picker"; import "react-day-picker/lib/style.css"; import "./DatePicker.css"; @@ -15,6 +15,7 @@ import { RelativeDateRange } from "./RelativeDateRange"; import { UpcomingDatePicker } from "./UpcomingDatePicker"; import { NavbarElement } from "./NavbarElement"; import { LocalizedDayPicker } from "./LocalizedDayPicker"; +import { Context } from "../Provider"; const variants = { single: "single", @@ -39,9 +40,11 @@ export const DatePicker = ({ components = {}, getTooltip, upcomingDates, + locale, timezoneName = null, // seller timezone (e.g. "America/Los_Angeles") to return correct today date ...rest }) => { + const { locale:contextLocale } = useContext(Context); const initialValue = value ? (variant === variants.single ? value : value.from) : null; const [currentMonth, setCurrentMonth] = useState(initialValue ?? now(null, timezoneName).toDate()); const [startMonth, setStartMonth] = useState(() => { @@ -161,7 +164,7 @@ export const DatePicker = ({ // TODO: Should be outside this component because this returns JSX const CaptionElement = useMemo(() => { return shouldShowYearPicker && currentMonth - ? ({ date }) => + ? ({ date }) => : undefined; // Adding `handleMonthChange` causes a lot of re-renders, and closes drop-down. // eslint-disable-next-line react-hooks/exhaustive-deps @@ -228,6 +231,7 @@ export const DatePicker = ({ handleEndMonthChange={handleEndMonthChange} handleTodayClick={handleTodayClick} selectedDays={selectedDays} + locale={locale ?? contextLocale} timezoneName={timezoneName} {...rest} /> @@ -290,5 +294,6 @@ DatePicker.propTypes = { shouldShowRelativeRanges: PropTypes.bool, components: PropTypes.shape({ Footer: PropTypes.oneOfType([PropTypes.node, PropTypes.func]) }), getTooltip: PropTypes.func, + locale: PropTypes.string, timezoneName: PropTypes.string, }; diff --git a/src/components/DatePicker/LocalizedDayPicker.tsx b/src/components/DatePicker/LocalizedDayPicker.tsx index e3becb6a2..5103c0807 100644 --- a/src/components/DatePicker/LocalizedDayPicker.tsx +++ b/src/components/DatePicker/LocalizedDayPicker.tsx @@ -1,9 +1,8 @@ -import React, { useContext } from "react"; -import { Context } from "../Provider"; +import clsx from "clsx"; +import React, { forwardRef, useContext, useEffect, useState } from "react"; import DayPicker, { DayPickerProps } from "react-day-picker"; -import { forwardRef, useEffect, useState } from "react"; +import { Context } from "../Provider"; import { getLocalizationProps, LocaleCode, LocalizationProps } from "./DatePicker.helpers"; -import clsx from "clsx"; export const LocalizedDayPicker = forwardRef(({ className, ...rest }, ref) => { const { locale } = useContext(Context); @@ -18,5 +17,5 @@ export const LocalizedDayPicker = forwardRef(({ className, getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); }, [locale]); - return ; + return ; }); diff --git a/src/components/DatePicker/RangeDatePicker.jsx b/src/components/DatePicker/RangeDatePicker.jsx index e7022144c..af227401c 100644 --- a/src/components/DatePicker/RangeDatePicker.jsx +++ b/src/components/DatePicker/RangeDatePicker.jsx @@ -24,6 +24,7 @@ const RangeDatePicker = ({ handleStartMonthChange, handleEndMonthChange, handleTodayClick, + locale, timezoneName, ...rest }) => { @@ -32,7 +33,7 @@ const RangeDatePicker = ({ const createCaptionElement = (currentMonth, handleChange) => shouldShowYearPicker && currentMonth - ? ({ date }) => + ? ({ date }) => : undefined; const CaptionStartElement = createCaptionElement(startMonth, handleStartMonthChange); diff --git a/src/components/Provider.jsx b/src/components/Provider.jsx index d60fc8305..07136efd0 100644 --- a/src/components/Provider.jsx +++ b/src/components/Provider.jsx @@ -14,7 +14,7 @@ export const Context = createContext({ localize: true, - locale: "en", + locale: "en_US", }); /** @@ -22,7 +22,7 @@ export const Context = createContext({ * Must be used from now on in order to generate correct component IDs. * Also a good place to implement any global state required for the UI Kit in the future. */ -export const Provider = ({ children, localize = true, locale = "en" }) => { +export const Provider = ({ children, localize = true, locale = "en_US" }) => { const idCounterRef = useRef(1); const generateId = useCallback(() => { From 1291542235505984fd0cf5f8c8d1b66a4d94fd55 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 31 Jul 2024 15:54:49 +0530 Subject: [PATCH 06/21] XS-30 fixed locale in month year selector --- src/components/DatePicker/MonthYearSelector.jsx | 8 ++++---- src/components/Utilities/Currency.jsx | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/DatePicker/MonthYearSelector.jsx b/src/components/DatePicker/MonthYearSelector.jsx index c29c20883..dd3b6b888 100644 --- a/src/components/DatePicker/MonthYearSelector.jsx +++ b/src/components/DatePicker/MonthYearSelector.jsx @@ -1,6 +1,6 @@ +import React from "react"; import dayjs from "dayjs"; import PropTypes from "prop-types"; -import React from "react"; import { Select } from "../Forms/Select"; const today = dayjs(); @@ -9,11 +9,11 @@ const getDiffInMonths = (to, from) => { return 12 * (to.getFullYear() - from.getFullYear()) + (to.getMonth() - from.getMonth()); }; -export const MonthYearSelector = ({ date, onChange, currentMonth }) => { - const months = [...Array.from({ length: 12 }).keys()].map((m) => today.month(m).format("MMM")); +export const MonthYearSelector = ({ date, locale, onChange, currentMonth }) => { + const months = [...Array.from({ length: 12 }).keys()].map((m) => today.locale(locale).month(m).format("MMM")); // 2012 as baseline + 5 years in future const years = [...Array.from({ length: today.year() - 2012 + 5 + 1 }).keys()].map((y) => - today.year(2012 + y).format("YYYY"), + today.locale(locale).year(2012 + y).format("YYYY"), ); /** diff --git a/src/components/Utilities/Currency.jsx b/src/components/Utilities/Currency.jsx index 1c42e1ded..bf28b2854 100644 --- a/src/components/Utilities/Currency.jsx +++ b/src/components/Utilities/Currency.jsx @@ -1,8 +1,9 @@ import getUserLocale from "get-user-locale"; import PropTypes from "prop-types"; -import React from "react"; +import React, { useContext } from "react"; import { getSymbol, isZeroDecimal } from "../../helpers/currency"; import { almostZero, numberFormat, roundNumber } from "../../helpers/numbers"; +import { Context } from "../Provider"; const userLocale = getUserLocale(); @@ -15,7 +16,10 @@ export const Currency = ({ isNarrowSymbolForm, children, }) => { + const {locale} = useContext(Context); + let amount = children; + if (almostZero(amount)) { amount = 0; } @@ -25,7 +29,7 @@ export const Currency = ({ if (compact) { return ( - {getSymbol(currency, locale, isNarrowSymbolForm)} + {getSymbol(currency, locale , isNarrowSymbolForm)} {formattedAmount} ); From 3ff0046d9eacdeb7ca96169f1ee8f08332b0afe7 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 31 Jul 2024 15:55:48 +0530 Subject: [PATCH 07/21] XS-30 refactor --- src/components/Utilities/Currency.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Utilities/Currency.jsx b/src/components/Utilities/Currency.jsx index bf28b2854..6d2181a65 100644 --- a/src/components/Utilities/Currency.jsx +++ b/src/components/Utilities/Currency.jsx @@ -19,7 +19,6 @@ export const Currency = ({ const {locale} = useContext(Context); let amount = children; - if (almostZero(amount)) { amount = 0; } @@ -29,7 +28,7 @@ export const Currency = ({ if (compact) { return ( - {getSymbol(currency, locale , isNarrowSymbolForm)} + {getSymbol(currency, locale, isNarrowSymbolForm)} {formattedAmount} ); From a34cf45d57e55aa358c19ebd938f4d965ce78d9f Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 31 Jul 2024 16:16:07 +0530 Subject: [PATCH 08/21] XS-30 fixed currency --- src/components/Utilities/Currency.jsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/Utilities/Currency.jsx b/src/components/Utilities/Currency.jsx index 6d2181a65..1c42e1ded 100644 --- a/src/components/Utilities/Currency.jsx +++ b/src/components/Utilities/Currency.jsx @@ -1,9 +1,8 @@ import getUserLocale from "get-user-locale"; import PropTypes from "prop-types"; -import React, { useContext } from "react"; +import React from "react"; import { getSymbol, isZeroDecimal } from "../../helpers/currency"; import { almostZero, numberFormat, roundNumber } from "../../helpers/numbers"; -import { Context } from "../Provider"; const userLocale = getUserLocale(); @@ -16,8 +15,6 @@ export const Currency = ({ isNarrowSymbolForm, children, }) => { - const {locale} = useContext(Context); - let amount = children; if (almostZero(amount)) { amount = 0; From fae85b75387071ad3c94fe6dd89c79afdb27f354 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Tue, 20 Aug 2024 15:14:34 +0530 Subject: [PATCH 09/21] XS-30 Added short months --- src/components/DatePicker/DatePicker.helpers.ts | 3 ++- src/components/DatePicker/LocalizedDayPicker.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/DatePicker/DatePicker.helpers.ts b/src/components/DatePicker/DatePicker.helpers.ts index befbf0aad..efaff0d31 100644 --- a/src/components/DatePicker/DatePicker.helpers.ts +++ b/src/components/DatePicker/DatePicker.helpers.ts @@ -4,7 +4,7 @@ export type LocaleCode = keyof typeof locales; export type LocalizationProps = Pick< DayPickerProps, - "locale" | "months" | "weekdaysLong" | "weekdaysShort" | "firstDayOfWeek" + "locale" | "months" | "monthsShort" | "weekdaysLong" | "weekdaysShort" | "firstDayOfWeek" >; const locales = { @@ -29,6 +29,7 @@ export const getLocalizationProps = async (localeCode: LocaleCode): Promise(({ className, setLocalizationProps({}); /** We don't want any localization-related props for "English" */ - if (locale === "en") return; + if (locale === "en" || locale === "en_US") return; getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); }, [locale]); From 098c6205c1763992670a5d6b3c507b61a56a3156 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Tue, 20 Aug 2024 18:11:30 +0530 Subject: [PATCH 10/21] XS-30 added console.logs --- src/components/DatePicker/DatePicker.jsx | 1 + src/components/DatePicker/LocalizedDayPicker.tsx | 2 ++ src/components/Provider.jsx | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/DatePicker/DatePicker.jsx b/src/components/DatePicker/DatePicker.jsx index 4c46c064d..779f456a1 100644 --- a/src/components/DatePicker/DatePicker.jsx +++ b/src/components/DatePicker/DatePicker.jsx @@ -45,6 +45,7 @@ export const DatePicker = ({ ...rest }) => { const { locale:contextLocale } = useContext(Context); + console.log("Date Picker - ui - kit ", contextLocale); const initialValue = value ? (variant === variants.single ? value : value.from) : null; const [currentMonth, setCurrentMonth] = useState(initialValue ?? now(null, timezoneName).toDate()); const [startMonth, setStartMonth] = useState(() => { diff --git a/src/components/DatePicker/LocalizedDayPicker.tsx b/src/components/DatePicker/LocalizedDayPicker.tsx index 05ed1e565..563e51f2b 100644 --- a/src/components/DatePicker/LocalizedDayPicker.tsx +++ b/src/components/DatePicker/LocalizedDayPicker.tsx @@ -17,5 +17,7 @@ export const LocalizedDayPicker = forwardRef(({ className, getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); }, [locale]); + console.log("Loca-day-picker ", localizationProps); + return ; }); diff --git a/src/components/Provider.jsx b/src/components/Provider.jsx index 07136efd0..85b87cffd 100644 --- a/src/components/Provider.jsx +++ b/src/components/Provider.jsx @@ -24,7 +24,7 @@ export const Context = createContext({ */ export const Provider = ({ children, localize = true, locale = "en_US" }) => { const idCounterRef = useRef(1); - + console.log("Logging from ui-kit ", locale); const generateId = useCallback(() => { return idCounterRef.current++; }, [idCounterRef]); From ef5e5311eb122bc0857d3093f35574459d0566d1 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 21 Aug 2024 13:13:42 +0530 Subject: [PATCH 11/21] Moved locale files to import block --- .../DatePicker/DatePicker.helpers.ts | 28 +++++++++++++------ src/components/DatePicker/DatePicker.jsx | 21 +++++++++----- .../DatePicker/LocalizedDayPicker.tsx | 2 +- .../DatePicker/MonthYearSelector.jsx | 7 +++-- src/components/DatePicker/RangeDatePicker.jsx | 10 ++++--- src/components/Drawer.jsx | 2 +- src/components/Provider.jsx | 2 +- src/components/Sidebar/Sidebar.Button.jsx | 2 +- src/hooks/useViewportHeight.js | 2 +- 9 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/components/DatePicker/DatePicker.helpers.ts b/src/components/DatePicker/DatePicker.helpers.ts index efaff0d31..c0ea08847 100644 --- a/src/components/DatePicker/DatePicker.helpers.ts +++ b/src/components/DatePicker/DatePicker.helpers.ts @@ -1,23 +1,33 @@ +import * as de from "dayjs/locale/de"; +import * as en from "dayjs/locale/en"; +import * as enGB from "dayjs/locale/en-gb"; +import * as es from "dayjs/locale/es"; +import * as esMX from "dayjs/locale/es-MX"; +import * as fr from "dayjs/locale/fr"; import type { DayPickerProps } from "react-day-picker"; export type LocaleCode = keyof typeof locales; +interface ExtendedDayPickerProps extends DayPickerProps { + monthsShort?: string; +} + export type LocalizationProps = Pick< - DayPickerProps, + ExtendedDayPickerProps, "locale" | "months" | "monthsShort" | "weekdaysLong" | "weekdaysShort" | "firstDayOfWeek" >; const locales = { - en: import("dayjs/locale/en"), - en_US: import("dayjs/locale/en"), - en_GB: import("dayjs/locale/en-gb"), + en: en, + en_US: en, + en_GB: enGB, - es: import("dayjs/locale/es"), - es_ES: import("dayjs/locale/es"), - es_MX: import("dayjs/locale/es-mx"), + es: es, + es_ES: es, + es_MX: esMX, - fr: import("dayjs/locale/fr"), - de: import("dayjs/locale/de"), + fr: fr, + de: de, }; export const getLocalizationProps = async (localeCode: LocaleCode): Promise> => { diff --git a/src/components/DatePicker/DatePicker.jsx b/src/components/DatePicker/DatePicker.jsx index 779f456a1..4adb3bd17 100644 --- a/src/components/DatePicker/DatePicker.jsx +++ b/src/components/DatePicker/DatePicker.jsx @@ -1,21 +1,21 @@ import clsx from "clsx"; import dayjs from "dayjs"; import PropTypes from "prop-types"; -import React, { useEffect, useMemo, useState, useContext } from "react"; +import React, { useContext, useEffect, useMemo, useState } from "react"; import { DateUtils } from "react-day-picker"; import "react-day-picker/lib/style.css"; import "./DatePicker.css"; import { isArray, isFunction } from "lodash"; import { Tooltip } from "../.."; import { isSame, isValidTimeZoneName, now, toDate } from "../../helpers/date"; +import { Context } from "../Provider"; import { Day } from "./Day"; +import { LocalizedDayPicker } from "./LocalizedDayPicker"; import { MonthYearSelector } from "./MonthYearSelector"; +import { NavbarElement } from "./NavbarElement"; import RangeDatePicker from "./RangeDatePicker"; import { RelativeDateRange } from "./RelativeDateRange"; import { UpcomingDatePicker } from "./UpcomingDatePicker"; -import { NavbarElement } from "./NavbarElement"; -import { LocalizedDayPicker } from "./LocalizedDayPicker"; -import { Context } from "../Provider"; const variants = { single: "single", @@ -44,8 +44,8 @@ export const DatePicker = ({ timezoneName = null, // seller timezone (e.g. "America/Los_Angeles") to return correct today date ...rest }) => { - const { locale:contextLocale } = useContext(Context); - console.log("Date Picker - ui - kit ", contextLocale); + const { locale: contextLocale } = useContext(Context); + console.log("Date Picker - ui - kit", contextLocale); const initialValue = value ? (variant === variants.single ? value : value.from) : null; const [currentMonth, setCurrentMonth] = useState(initialValue ?? now(null, timezoneName).toDate()); const [startMonth, setStartMonth] = useState(() => { @@ -180,7 +180,14 @@ export const DatePicker = ({ // TODO: Should be outside this component because this returns JSX const CaptionElement = useMemo(() => { return shouldShowYearPicker && currentMonth - ? ({ date }) => + ? ({ date }) => ( + + ) : undefined; // Adding `handleMonthChange` causes a lot of re-renders, and closes drop-down. // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/components/DatePicker/LocalizedDayPicker.tsx b/src/components/DatePicker/LocalizedDayPicker.tsx index 563e51f2b..2db8b05cd 100644 --- a/src/components/DatePicker/LocalizedDayPicker.tsx +++ b/src/components/DatePicker/LocalizedDayPicker.tsx @@ -17,7 +17,7 @@ export const LocalizedDayPicker = forwardRef(({ className, getLocalizationProps(locale as LocaleCode).then(setLocalizationProps); }, [locale]); - console.log("Loca-day-picker ", localizationProps); + console.log("Loca-day-picker", localizationProps); return ; }); diff --git a/src/components/DatePicker/MonthYearSelector.jsx b/src/components/DatePicker/MonthYearSelector.jsx index dd3b6b888..5f2731668 100644 --- a/src/components/DatePicker/MonthYearSelector.jsx +++ b/src/components/DatePicker/MonthYearSelector.jsx @@ -1,6 +1,6 @@ -import React from "react"; import dayjs from "dayjs"; import PropTypes from "prop-types"; +import React from "react"; import { Select } from "../Forms/Select"; const today = dayjs(); @@ -13,7 +13,10 @@ export const MonthYearSelector = ({ date, locale, onChange, currentMonth }) => { const months = [...Array.from({ length: 12 }).keys()].map((m) => today.locale(locale).month(m).format("MMM")); // 2012 as baseline + 5 years in future const years = [...Array.from({ length: today.year() - 2012 + 5 + 1 }).keys()].map((y) => - today.locale(locale).year(2012 + y).format("YYYY"), + today + .locale(locale) + .year(2012 + y) + .format("YYYY"), ); /** diff --git a/src/components/DatePicker/RangeDatePicker.jsx b/src/components/DatePicker/RangeDatePicker.jsx index af227401c..46dac73dd 100644 --- a/src/components/DatePicker/RangeDatePicker.jsx +++ b/src/components/DatePicker/RangeDatePicker.jsx @@ -1,13 +1,13 @@ -import React from "react"; -import PropTypes from "prop-types"; import clsx from "clsx"; import { isArray, isFunction } from "lodash"; +import PropTypes from "prop-types"; +import React from "react"; import { now } from "../../helpers/date"; import { Tooltip } from "../Tooltip"; import { Day } from "./Day"; +import { LocalizedDayPicker } from "./LocalizedDayPicker"; import { MonthYearSelector } from "./MonthYearSelector"; import { NavbarElement } from "./NavbarElement"; -import { LocalizedDayPicker } from "./LocalizedDayPicker"; const RangeDatePicker = ({ getTooltip, @@ -33,7 +33,9 @@ const RangeDatePicker = ({ const createCaptionElement = (currentMonth, handleChange) => shouldShowYearPicker && currentMonth - ? ({ date }) => + ? ({ date }) => ( + + ) : undefined; const CaptionStartElement = createCaptionElement(startMonth, handleStartMonthChange); diff --git a/src/components/Drawer.jsx b/src/components/Drawer.jsx index 3d94575cf..18f8cc22b 100644 --- a/src/components/Drawer.jsx +++ b/src/components/Drawer.jsx @@ -2,9 +2,9 @@ import { Dialog, Transition } from "@headlessui/react"; import clsx from "clsx"; import PropTypes from "prop-types"; import React, { forwardRef, Fragment } from "react"; -import { CloseIcon } from "../icons"; import { isIosBrowser } from "../helpers/browser"; import { useViewportHeight } from "../hooks/useViewportHeight"; +import { CloseIcon } from "../icons"; import { Button } from "./Buttons/Button"; const sizes = { diff --git a/src/components/Provider.jsx b/src/components/Provider.jsx index 85b87cffd..e3778ec34 100644 --- a/src/components/Provider.jsx +++ b/src/components/Provider.jsx @@ -24,7 +24,7 @@ export const Context = createContext({ */ export const Provider = ({ children, localize = true, locale = "en_US" }) => { const idCounterRef = useRef(1); - console.log("Logging from ui-kit ", locale); + console.log("Logging from ui-kit Provider -", locale); const generateId = useCallback(() => { return idCounterRef.current++; }, [idCounterRef]); diff --git a/src/components/Sidebar/Sidebar.Button.jsx b/src/components/Sidebar/Sidebar.Button.jsx index 8cf2dee14..493e62639 100644 --- a/src/components/Sidebar/Sidebar.Button.jsx +++ b/src/components/Sidebar/Sidebar.Button.jsx @@ -1,6 +1,6 @@ +import clsx from "clsx"; import PropTypes from "prop-types"; import React from "react"; -import clsx from "clsx"; export const SidebarButton = ({ icon: Icon, label, className, ...rest }) => { return ( diff --git a/src/hooks/useViewportHeight.js b/src/hooks/useViewportHeight.js index a2c7b74e6..4ea31c6db 100644 --- a/src/hooks/useViewportHeight.js +++ b/src/hooks/useViewportHeight.js @@ -1,4 +1,4 @@ -import { useState, useEffect } from "react"; +import { useEffect, useState } from "react"; export const useViewportHeight = () => { const [viewportHeight, setViewportHeight] = useState(0); From 309155e311defb76e54e57372e59b7086875b198 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 21 Aug 2024 17:58:47 +0530 Subject: [PATCH 12/21] XS-30 changed lot messge --- src/components/Provider.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Provider.jsx b/src/components/Provider.jsx index e3778ec34..80b562cd5 100644 --- a/src/components/Provider.jsx +++ b/src/components/Provider.jsx @@ -24,7 +24,7 @@ export const Context = createContext({ */ export const Provider = ({ children, localize = true, locale = "en_US" }) => { const idCounterRef = useRef(1); - console.log("Logging from ui-kit Provider -", locale); + console.log("Locale in UI-KIT Provider -", locale); const generateId = useCallback(() => { return idCounterRef.current++; }, [idCounterRef]); From ec7be9421777420c7cb590d61ac6d587877d1081 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Thu, 22 Aug 2024 09:54:34 +0530 Subject: [PATCH 13/21] XS-30 fixed es-MX issue --- src/components/DatePicker/DatePicker.helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/DatePicker/DatePicker.helpers.ts b/src/components/DatePicker/DatePicker.helpers.ts index c0ea08847..33dd7e23d 100644 --- a/src/components/DatePicker/DatePicker.helpers.ts +++ b/src/components/DatePicker/DatePicker.helpers.ts @@ -2,7 +2,7 @@ import * as de from "dayjs/locale/de"; import * as en from "dayjs/locale/en"; import * as enGB from "dayjs/locale/en-gb"; import * as es from "dayjs/locale/es"; -import * as esMX from "dayjs/locale/es-MX"; +import * as esMX from "dayjs/locale/es-mx"; import * as fr from "dayjs/locale/fr"; import type { DayPickerProps } from "react-day-picker"; From 50d8d0778cdc4a6e5bf80b6f9b0846f71880c83e Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Thu, 22 Aug 2024 18:29:24 +0530 Subject: [PATCH 14/21] XS-30 Added Support for classnames to sidemenubar text --- src/components/Sidebar/Sidebar.Link.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Sidebar/Sidebar.Link.jsx b/src/components/Sidebar/Sidebar.Link.jsx index 6b9fa6213..678d5b008 100644 --- a/src/components/Sidebar/Sidebar.Link.jsx +++ b/src/components/Sidebar/Sidebar.Link.jsx @@ -4,7 +4,7 @@ import React from "react"; import { ChevronRightIcon } from "../../icons"; import { Dot } from "../Dot/Dot"; -export const SidebarLink = ({ isActive = false, icon: Icon, children, isSubMenuItem, align, ...rest }) => { +export const SidebarLink = ({ isActive = false, icon: Icon, children, isSubMenuItem, align, classNames, ...rest }) => { return (