@availity/theme-provider 0.0.1-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 ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.0.1-alpha.0 (2023-02-20)
6
+
7
+
8
+ ### Features
9
+
10
+ * **theme-provider:** create component ([c532d6e](https://github.com/Availity/element/commit/c532d6e21c29f428c05a3b2159c18d95555dbbbb))
11
+
12
+ # Changelog
13
+
14
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @availity/theme-provider
2
+
3
+ > Theme Provider using MUI and @availity/design-tokens
4
+
5
+ [![Version](https://img.shields.io/npm/v/@availity/theme-provider.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/theme-provider)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/theme-provider.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/theme-provider)
7
+ [![Dependecy Status](https://img.shields.io/librariesio/release/npm/@availity/theme-provider?style=for-the-badge)](https://github.com/Availity/element/blob/master/packages/theme-provider/package.json)
8
+
9
+ ## Installation
10
+
11
+ ### NPM
12
+
13
+ ```bash
14
+ npm install @availity/theme-provider
15
+ ```
16
+
17
+ ### Yarn
18
+
19
+ ```bash
20
+ yarn add @availity/theme-provider
21
+ ```
@@ -0,0 +1,9 @@
1
+ import { Theme } from '@mui/material/styles';
2
+
3
+ interface ThemeProviderProps {
4
+ children: React.ReactNode;
5
+ theme?: Theme;
6
+ }
7
+ declare function ThemeProvider({ children, theme }: ThemeProviderProps): JSX.Element;
8
+
9
+ export { ThemeProvider, ThemeProviderProps };
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/index.ts
27
+ var src_exports = {};
28
+ __export(src_exports, {
29
+ ThemeProvider: () => ThemeProvider
30
+ });
31
+ module.exports = __toCommonJS(src_exports);
32
+
33
+ // src/lib/theme-provider.tsx
34
+ var import_theme = require("@availity/theme");
35
+ var import_styles = require("@mui/material/styles");
36
+ var import_CssBaseline = __toESM(require("@mui/material/CssBaseline"));
37
+ var import_AdapterDateFns = require("@mui/x-date-pickers/AdapterDateFns");
38
+ var import_x_date_pickers = require("@mui/x-date-pickers");
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var defaultTheme = (0, import_styles.createTheme)(import_theme.lightTheme);
41
+ function ThemeProvider({ children, theme = defaultTheme }) {
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_x_date_pickers.LocalizationProvider, {
43
+ dateAdapter: import_AdapterDateFns.AdapterDateFns,
44
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.ThemeProvider, {
45
+ theme,
46
+ children: [
47
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CssBaseline.default, {}),
48
+ children
49
+ ]
50
+ })
51
+ });
52
+ }
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ ThemeProvider
56
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,23 @@
1
+ // src/lib/theme-provider.tsx
2
+ import { lightTheme } from "@availity/theme";
3
+ import { ThemeProvider as MuiThemeProvider, createTheme } from "@mui/material/styles";
4
+ import CssBaseline from "@mui/material/CssBaseline";
5
+ import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
6
+ import { LocalizationProvider } from "@mui/x-date-pickers";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ var defaultTheme = createTheme(lightTheme);
9
+ function ThemeProvider({ children, theme = defaultTheme }) {
10
+ return /* @__PURE__ */ jsx(LocalizationProvider, {
11
+ dateAdapter: AdapterDateFns,
12
+ children: /* @__PURE__ */ jsxs(MuiThemeProvider, {
13
+ theme,
14
+ children: [
15
+ /* @__PURE__ */ jsx(CssBaseline, {}),
16
+ children
17
+ ]
18
+ })
19
+ });
20
+ }
21
+ export {
22
+ ThemeProvider
23
+ };
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const global = require('../../jest.config.global');
2
+
3
+ module.exports = {
4
+ ...global,
5
+ displayName: 'theme-provider',
6
+ coverageDirectory: '../../coverage/theme-provider',
7
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@availity/theme-provider",
3
+ "version": "0.0.1-alpha.0",
4
+ "description": "Theme provider for the Element design system",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.mjs",
10
+ "require": "./dist/index.js"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "tsup src/index.ts --format esm,cjs --dts",
15
+ "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
16
+ "clean": "rm -rf dist",
17
+ "clean:nm": "rm -rf node_modules",
18
+ "bundlesize": "bundlesize",
19
+ "publish": "yarn npm publish --tolerate-republish --access public",
20
+ "publish:canary": "yarn npm publish --access public --tag canary"
21
+ },
22
+ "dependencies": {
23
+ "@availity/theme": "0.0.1-alpha.0",
24
+ "@emotion/react": "^11.10.5",
25
+ "@emotion/styled": "^11.10.5",
26
+ "@mui/material": "^5.11.6",
27
+ "@mui/x-date-pickers": "^5.0.15",
28
+ "date-fns": "^2.29.3"
29
+ },
30
+ "devDependencies": {
31
+ "react": "18.2.0",
32
+ "react-dom": "18.2.0",
33
+ "tsup": "^5.12.7",
34
+ "typescript": "~4.8.2"
35
+ },
36
+ "peerDependencies": {
37
+ "react": ">=16.8.0"
38
+ }
39
+ }
package/project.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "theme-provider",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/theme-provider/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "lint": {
9
+ "executor": "@nrwl/linter:eslint",
10
+ "options": {
11
+ "eslintConfig": ".eslintrc.json",
12
+ "lintFilePatterns": ["packages/theme-provider/**/*.{js,ts}"],
13
+ "silent": false,
14
+ "fix": false,
15
+ "cache": true,
16
+ "cacheLocation": "./node_modules/.cache/theme-provider/.eslintcache",
17
+ "maxWarnings": -1,
18
+ "quiet": false,
19
+ "noEslintrc": false,
20
+ "hasTypeAwareRules": true,
21
+ "cacheStrategy": "metadata"
22
+ }
23
+ },
24
+ "test": {
25
+ "executor": "@nrwl/jest:jest",
26
+ "outputs": ["coverage/theme-provider"],
27
+ "options": {
28
+ "jestConfig": "packages/theme-provider/jest.config.js",
29
+ "passWithNoTests": true
30
+ }
31
+ },
32
+ "version": {
33
+ "executor": "@jscutlery/semver:version",
34
+ "options": {
35
+ "preset": "conventional",
36
+ "commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
37
+ "tagPrefix": "@availity/${projectName}@"
38
+ }
39
+ }
40
+ }
41
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/theme-provider';
@@ -0,0 +1,10 @@
1
+ import { render } from '@testing-library/react';
2
+
3
+ import ThemeProvider from './theme-provider';
4
+
5
+ describe('ThemeProvider', () => {
6
+ test('should render successfully', () => {
7
+ const { getByText } = render(<ThemeProvider>Test</ThemeProvider>);
8
+ expect(getByText('Test')).toBeTruthy();
9
+ });
10
+ });
@@ -0,0 +1,29 @@
1
+ import { lightTheme } from '@availity/theme';
2
+ import { ThemeProvider as MuiThemeProvider, createTheme } from '@mui/material/styles';
3
+ import type { Theme } from '@mui/material/styles';
4
+ import CssBaseline from '@mui/material/CssBaseline';
5
+ import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
6
+ import { LocalizationProvider } from '@mui/x-date-pickers';
7
+
8
+ // TODO: how do we add icon support?
9
+ // import '../styles/material-icons.css'
10
+
11
+ const defaultTheme = createTheme(lightTheme);
12
+
13
+ export interface ThemeProviderProps {
14
+ children: React.ReactNode;
15
+ theme?: Theme;
16
+ }
17
+
18
+ export function ThemeProvider({ children, theme = defaultTheme }: ThemeProviderProps) {
19
+ return (
20
+ <LocalizationProvider dateAdapter={AdapterDateFns}>
21
+ <MuiThemeProvider theme={theme}>
22
+ <CssBaseline />
23
+ {children}
24
+ </MuiThemeProvider>
25
+ </LocalizationProvider>
26
+ );
27
+ }
28
+
29
+ export default ThemeProvider;
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["."],
4
+ "exclude": ["dist", "build", "node_modules"]
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node", "@testing-library/jest-dom"],
7
+ "allowJs": true
8
+ },
9
+ "include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
10
+ }