@autoguru/overdrive 4.54.0 → 4.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,6 +18,15 @@ export interface ProviderProps {
|
|
|
18
18
|
colorOverrides?: Partial<ColorOverrides>;
|
|
19
19
|
/** Reference to an HTML element where portals should be mounted */
|
|
20
20
|
portalMountPoint?: PortalMountPoint;
|
|
21
|
+
/**
|
|
22
|
+
* BCP47 locale string for React Aria components (DateInput, Calendar, etc.).
|
|
23
|
+
* Controls date segment ordering, number formatting, and text direction.
|
|
24
|
+
*
|
|
25
|
+
* @example "en-AU" for Australian English (DD/MM/YYYY)
|
|
26
|
+
* @example "de-DE" for German
|
|
27
|
+
* @default Falls back to browser's navigator.language
|
|
28
|
+
*/
|
|
29
|
+
locale?: string;
|
|
21
30
|
children?: React.ReactNode;
|
|
22
31
|
}
|
|
23
32
|
export interface ProviderContext extends Pick<ProviderProps, 'colorOverrides' | 'portalMountPoint'> {
|
|
@@ -28,7 +37,7 @@ export interface ProviderContext extends Pick<ProviderProps, 'colorOverrides' |
|
|
|
28
37
|
}
|
|
29
38
|
export declare const useTheme: () => ProviderContext;
|
|
30
39
|
export declare const useRuntimeTokens: () => RuntimeTokens;
|
|
31
|
-
export declare const Provider: ({ breakpoints, children, colorOverrides, noBodyLevelTheming, portalMountPoint, theme, }: ProviderProps) => React.JSX.Element;
|
|
40
|
+
export declare const Provider: ({ breakpoints, children, colorOverrides, locale, noBodyLevelTheming, portalMountPoint, theme, }: ProviderProps) => React.JSX.Element;
|
|
32
41
|
export declare const OverdriveProvider: React.NamedExoticComponent<ProviderProps>;
|
|
33
42
|
export {};
|
|
34
43
|
//# sourceMappingURL=OverdriveProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverdriveProvider.d.ts","sourceRoot":"","sources":["../../../lib/components/OverdriveProvider/OverdriveProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
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,CAAC;IACpD,IAAI,EAAE,aAAa,CAAC;CACpB;AAMD,eAAO,MAAM,QAAQ,uBAIpB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,aAInC,CAAC;AAUF,eAAO,MAAM,QAAQ,GAAI,iGAQtB,aAAa,sBA6Df,CAAC;AAEF,eAAO,MAAM,iBAAiB,2CAK7B,CAAC"}
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { invariant } from '@autoguru/utilities';
|
|
5
|
+
import { I18nProvider as ReactAriaI18nProvider } from '@react-aria/i18n';
|
|
5
6
|
import { isEqual } from 'es-toolkit';
|
|
6
7
|
import React, { createContext, useContext, useEffect, useMemo } from 'react';
|
|
7
8
|
import baseTheme from "../../themes/base/index.js";
|
|
@@ -9,6 +10,36 @@ import { makeRuntimeTokens } from "../../themes/makeTheme.js";
|
|
|
9
10
|
import { isBrowser } from "../../utils/index.js";
|
|
10
11
|
import { useColorOverrides } from "./useColorOverrides.js";
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Maps 2-letter language codes to full BCP47 locale codes.
|
|
15
|
+
* English defaults to Australian locale (DD/MM/YYYY format).
|
|
16
|
+
*/
|
|
17
|
+
const LANGUAGE_TO_LOCALE = {
|
|
18
|
+
en: 'en-AU',
|
|
19
|
+
de: 'de-DE',
|
|
20
|
+
fr: 'fr-FR',
|
|
21
|
+
es: 'es-ES',
|
|
22
|
+
it: 'it-IT',
|
|
23
|
+
nl: 'nl-NL',
|
|
24
|
+
pl: 'pl-PL',
|
|
25
|
+
sv: 'sv-SE',
|
|
26
|
+
ja: 'ja-JP'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the locale for React Aria components.
|
|
31
|
+
* Priority: explicit prop > i18next language (mapped to full locale) > undefined (React Aria browser default)
|
|
32
|
+
*/
|
|
33
|
+
function resolveLocale(localeProp) {
|
|
34
|
+
var _i18next;
|
|
35
|
+
if (localeProp) return localeProp;
|
|
36
|
+
if (!isBrowser) return undefined;
|
|
37
|
+
const i18nextLang = (_i18next = window.i18next) === null || _i18next === void 0 ? void 0 : _i18next.language;
|
|
38
|
+
if (i18nextLang) {
|
|
39
|
+
return LANGUAGE_TO_LOCALE[i18nextLang] || i18nextLang;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
12
43
|
const OverdriveContext = /*#__PURE__*/createContext(null);
|
|
13
44
|
const RuntimeTokensContext = /*#__PURE__*/createContext(null);
|
|
14
45
|
const msgInvariantError = "You haven't used an `<OverdriveProvider>`.";
|
|
@@ -29,6 +60,7 @@ export const Provider = ({
|
|
|
29
60
|
breakpoints,
|
|
30
61
|
children,
|
|
31
62
|
colorOverrides,
|
|
63
|
+
locale,
|
|
32
64
|
noBodyLevelTheming = false,
|
|
33
65
|
portalMountPoint,
|
|
34
66
|
theme = baseTheme
|
|
@@ -60,15 +92,19 @@ export const Provider = ({
|
|
|
60
92
|
portalMountPoint.current = null;
|
|
61
93
|
}
|
|
62
94
|
}, [portalMountPoint]);
|
|
95
|
+
const resolvedLocale = resolveLocale(locale);
|
|
63
96
|
return /*#__PURE__*/_jsx(OverdriveContext.Provider, {
|
|
64
97
|
value: themeValues,
|
|
65
98
|
children: /*#__PURE__*/_jsx(RuntimeTokensContext.Provider, {
|
|
66
99
|
value: runtimeTokens,
|
|
67
|
-
children: /*#__PURE__*/_jsx(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
100
|
+
children: /*#__PURE__*/_jsx(ReactAriaI18nProvider, {
|
|
101
|
+
locale: resolvedLocale,
|
|
102
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
103
|
+
className: theme.themeRef,
|
|
104
|
+
style: styles,
|
|
105
|
+
"data-od-component": "provider",
|
|
106
|
+
children: children
|
|
107
|
+
})
|
|
72
108
|
})
|
|
73
109
|
})
|
|
74
110
|
});
|