UNPKG

@renderlesskit/react

Version:

Collection of headless components/hooks that are accessible, composable, customizable from low level to build your own UI & Design System powered by Reakit

122 lines (117 loc) 1.8 kB
/** * All credit goes to [React Spectrum](https://github.com/adobe/react-spectrum) * We improved the Calendar from Stately [useWeekStart](https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/calendar/src/useWeekStart.ts) * to work with Reakit System */ import { useLocale } from "@react-aria/i18n"; // Data from https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json // Locales starting on Sunday have been removed for compression. var data = { "001": 1, AD: 1, AE: 6, AF: 6, AI: 1, AL: 1, AM: 1, AN: 1, AT: 1, AX: 1, AZ: 1, BA: 1, BE: 1, BG: 1, BH: 6, BM: 1, BN: 1, BY: 1, CH: 1, CL: 1, CM: 1, CR: 1, CY: 1, CZ: 1, DE: 1, DJ: 6, DK: 1, DZ: 6, EC: 1, EE: 1, EG: 6, ES: 1, FI: 1, FJ: 1, FO: 1, FR: 1, GB: 1, GE: 1, GF: 1, GP: 1, GR: 1, HR: 1, HU: 1, IE: 1, IQ: 6, IR: 6, IS: 1, IT: 1, JO: 6, KG: 1, KW: 6, KZ: 1, LB: 1, LI: 1, LK: 1, LT: 1, LU: 1, LV: 1, LY: 6, MC: 1, MD: 1, ME: 1, MK: 1, MN: 1, MQ: 1, MV: 5, MY: 1, NL: 1, NO: 1, NZ: 1, OM: 6, PL: 1, QA: 6, RE: 1, RO: 1, RS: 1, RU: 1, SD: 6, SE: 1, SI: 1, SK: 1, SM: 1, SY: 6, TJ: 1, TM: 1, TR: 1, UA: 1, UY: 1, UZ: 1, VA: 1, VN: 1, XK: 1 }; export function useWeekStart() { var region = useRegion(); return data[region] || 0; } function useRegion() { var { locale } = useLocale(); // If the Intl.Locale API is available, use it to get the region for the locale. // @ts-ignore if (Intl.Locale) { // @ts-ignore return new Intl.Locale(locale).maximize().region; } // If not, just try splitting the string. return locale.split("-")[1]; } //# sourceMappingURL=useWeekStart.js.map