@availity/theme-provider 0.5.0 → 1.0.0-alpha.0
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.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.0.0-alpha.0](https://github.com/Availity/element/compare/@availity/theme-provider@0.5.1...@availity/theme-provider@1.0.0-alpha.0) (2025-02-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* upgraded to @mui/material v6
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* upgrade @mui/material ([571453a](https://github.com/Availity/element/commit/571453a34b21c344594ab4c03bc497d19aba942b))
|
|
15
|
+
* upgrade to MUI v6 ([7febd6f](https://github.com/Availity/element/commit/7febd6fd4fd58e87e1c97a832cea3b4595a35d58))
|
|
16
|
+
|
|
17
|
+
## [0.5.1](https://github.com/Availity/element/compare/@availity/theme-provider@0.5.0...@availity/theme-provider@0.5.1) (2025-02-05)
|
|
18
|
+
|
|
19
|
+
### Dependency Updates
|
|
20
|
+
|
|
21
|
+
* `theme` updated to version `0.5.0`
|
|
5
22
|
## [0.5.0](https://github.com/Availity/element/compare/@availity/theme-provider@0.4.96...@availity/theme-provider@0.5.0) (2025-02-04)
|
|
6
23
|
|
|
7
24
|
### Dependency Updates
|
package/dist/index.js
CHANGED
|
@@ -28,11 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
ThemeProvider: () => ThemeProvider
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/lib/theme-provider.tsx
|
|
38
38
|
var import_theme = require("@availity/theme");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/theme-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"description": "Theme provider for the Element design system",
|
|
5
5
|
"browser": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@availity/theme": "0.67.0",
|
|
27
|
-
"@emotion/react": "^11.
|
|
28
|
-
"@emotion/styled": "^11.
|
|
29
|
-
"@mui/material": "^
|
|
30
|
-
"@mui/x-date-pickers": "^7.
|
|
26
|
+
"@availity/theme": "0.67.2-alpha.0",
|
|
27
|
+
"@emotion/react": "^11.14.0",
|
|
28
|
+
"@emotion/styled": "^11.14.0",
|
|
29
|
+
"@mui/material": "^6.4.5",
|
|
30
|
+
"@mui/x-date-pickers": "^7.26.0",
|
|
31
31
|
"dayjs": "^1.11.13"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"react": "18.2.0",
|
|
35
35
|
"react-dom": "18.2.0",
|
|
36
|
-
"tsup": "^8.
|
|
36
|
+
"tsup": "^8.3.6",
|
|
37
37
|
"typescript": "~5.4.5"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { lightTheme as lightThemeOptions, legacyTheme as legacyThemeOptions } from '@availity/theme';
|
|
3
|
+
import CssBaseline from '@mui/material/CssBaseline';
|
|
4
|
+
import { ThemeProvider as MuiThemeProvider, createTheme } from '@mui/material/styles';
|
|
5
|
+
import type { Theme, ThemeOptions } from '@mui/material/styles';
|
|
6
|
+
import { deepmerge } from '@mui/utils';
|
|
7
|
+
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
8
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
9
|
+
import { enUS as enUSDate, esES as esESDate } from '@mui/x-date-pickers/locales';
|
|
10
|
+
import { enUS, esES } from '@mui/material/locale';
|
|
11
|
+
// import type { Dayjs } from 'dayjs';
|
|
12
|
+
// import "dayjs/locale/es-pr";
|
|
13
|
+
// import "dayjs/locale/en";
|
|
14
|
+
const muiTheme = createTheme();
|
|
15
|
+
|
|
16
|
+
export type ThemeProviderProps = {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
/** Availity theme to use */
|
|
19
|
+
theme?: 'lightTheme' | 'legacyBS' | 'mui';
|
|
20
|
+
/** Internationalization locale */
|
|
21
|
+
locale?: 'en' | 'es';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// dayjs
|
|
25
|
+
const dayjsLocales = {
|
|
26
|
+
en: 'en',
|
|
27
|
+
es: 'es-pr'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// @mui/x-date-pickers
|
|
31
|
+
const dateLocales = {
|
|
32
|
+
en: enUSDate,
|
|
33
|
+
es: esESDate
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// @mui/material
|
|
37
|
+
const coreLocales = {
|
|
38
|
+
en: enUS,
|
|
39
|
+
es: esES
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const lightTheme = lightThemeOptions as ThemeOptions;
|
|
43
|
+
const legacyTheme = deepmerge(legacyThemeOptions as ThemeOptions, legacyDatePickerOptions);
|
|
44
|
+
|
|
45
|
+
const themeOptions: Record<string, ThemeOptions> = {
|
|
46
|
+
lightTheme: lightTheme,
|
|
47
|
+
legacyBS: legacyTheme,
|
|
48
|
+
mui: undefined
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function ThemeProvider({ children, theme = 'lightTheme', locale = 'en' }: ThemeProviderProps) {
|
|
52
|
+
// is localization provider still needed because of the dateadapter? or should we use themeprovider to handle locale globally?
|
|
53
|
+
// const themeWithLocale = createTheme(themeOptions[theme], {...locales[locale]});
|
|
54
|
+
const themeWithLocale = useMemo(
|
|
55
|
+
() => createTheme(themeOptions[theme], dateLocales[locale], coreLocales[locale]),
|
|
56
|
+
[locale, theme],
|
|
57
|
+
);
|
|
58
|
+
return (
|
|
59
|
+
<LocalizationProvider
|
|
60
|
+
dateAdapter={AdapterDayjs}
|
|
61
|
+
adapterLocale={dayjsLocales[locale]}
|
|
62
|
+
localeText={dateLocales[locale].components.MuiLocalizationProvider.defaultProps.localeText}
|
|
63
|
+
>
|
|
64
|
+
<MuiThemeProvider theme={themeWithLocale}>
|
|
65
|
+
<CssBaseline />
|
|
66
|
+
{children}
|
|
67
|
+
</MuiThemeProvider>
|
|
68
|
+
</LocalizationProvider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default ThemeProvider;
|
|
File without changes
|