@cmotino/cm-web-components 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,67 @@
1
- # Temporary Holding Version
1
+ # cm-web-components
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A React component library built on Material UI.
4
+
5
+ ## Requirements
6
+
7
+ - React 19 and MUI 9, with Emotion
8
+ - ES modules only
9
+ - TypeScript consumers need `moduleResolution` set to `bundler`, `node16` or `nodenext`
10
+
11
+ ## Theming
12
+
13
+ `CmThemeProvider` applies the default look. Use `createCmTheme` to override it for your project:
14
+
15
+ ```tsx
16
+ import Button from '@mui/material/Button'
17
+ import { CmThemeProvider, createCmTheme } from '@cmotino/cm-web-components'
18
+
19
+ const theme = createCmTheme({
20
+ palette: { primary: { main: '#0b6e4f' } },
21
+ shape: { borderRadius: 4 },
22
+ })
23
+
24
+ export function App() {
25
+ return (
26
+ <CmThemeProvider theme={theme}>
27
+ <Button sx={{ mt: 2 }}>Save</Button>
28
+ </CmThemeProvider>
29
+ )
30
+ }
31
+ ```
32
+
33
+ **A top-level `palette` override only changes light mode.** To change dark mode, override `colorSchemes.dark`:
34
+
35
+ ```ts
36
+ createCmTheme({
37
+ palette: { primary: { main: '#0b6e4f' } },
38
+ colorSchemes: { dark: { palette: { primary: { main: '#7fd8b6' } } } },
39
+ })
40
+ ```
41
+
42
+ **Colors follow the operating system by default.** For a manual light and dark toggle, set a color scheme selector:
43
+
44
+ ```ts
45
+ createCmTheme({ cssVariables: { colorSchemeSelector: 'class' } })
46
+ ```
47
+
48
+ `CmThemeProvider` adds no global styles. Pass `baseline` to include MUI's `CssBaseline`. Fonts are up to your project.
49
+
50
+ ## Development
51
+
52
+ Use the Node version in `.nvmrc`, then:
53
+
54
+ ```sh
55
+ npm install
56
+ npm run dev
57
+ ```
58
+
59
+ `npm run dev` starts Storybook. Before opening a pull request, run:
60
+
61
+ ```sh
62
+ npm run lint && npm run typecheck && npm test && npm run build && npm run test:dist
63
+ ```
64
+
65
+ Pull requests with user-facing changes need a changelog entry from `npm run changeset`.
66
+
67
+ Design decisions are in [`docs/specs`](./docs/specs/README.md). Start with the [architecture spec](./docs/specs/0000-architecture.md) and the [roadmap](./docs/specs/roadmap.md).
@@ -0,0 +1 @@
1
+ export * from './theme/index.ts';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { createCmTheme } from "./theme/createCmTheme.js";
2
+ import { CmThemeProvider } from "./theme/CmThemeProvider.js";
3
+ export { CmThemeProvider, createCmTheme };
@@ -0,0 +1,14 @@
1
+ import type { Theme, ThemeProviderProps } from '@mui/material/styles';
2
+ export interface CmThemeProviderProps extends Omit<ThemeProviderProps<Theme>, 'theme'> {
3
+ /**
4
+ * The theme to apply. Build one with `createCmTheme`.
5
+ * @default the library theme
6
+ */
7
+ theme?: ThemeProviderProps<Theme>['theme'];
8
+ /**
9
+ * If `true`, adds MUI's `CssBaseline` global styles.
10
+ * @default false
11
+ */
12
+ baseline?: boolean;
13
+ }
14
+ export declare function CmThemeProvider({ theme, baseline, children, ...other }: CmThemeProviderProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { createCmTheme } from "./createCmTheme.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import CssBaseline from "@mui/material/CssBaseline";
5
+ import { ThemeProvider } from "@mui/material/styles";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ // src/theme/CmThemeProvider.tsx
8
+ var libraryTheme = createCmTheme();
9
+ function CmThemeProvider(t0) {
10
+ const $ = c(12);
11
+ let children;
12
+ let other;
13
+ let t1;
14
+ let t2;
15
+ if ($[0] !== t0) {
16
+ ({theme: t1, baseline: t2, children, ...other} = t0);
17
+ $[0] = t0;
18
+ $[1] = children;
19
+ $[2] = other;
20
+ $[3] = t1;
21
+ $[4] = t2;
22
+ } else {
23
+ children = $[1];
24
+ other = $[2];
25
+ t1 = $[3];
26
+ t2 = $[4];
27
+ }
28
+ const theme = t1 === void 0 ? libraryTheme : t1;
29
+ const baseline = t2 === void 0 ? false : t2;
30
+ let t3;
31
+ if ($[5] !== baseline) {
32
+ t3 = baseline ? /* @__PURE__ */ jsx(CssBaseline, {}) : null;
33
+ $[5] = baseline;
34
+ $[6] = t3;
35
+ } else t3 = $[6];
36
+ let t4;
37
+ if ($[7] !== children || $[8] !== other || $[9] !== t3 || $[10] !== theme) {
38
+ t4 = /* @__PURE__ */ jsxs(ThemeProvider, {
39
+ theme,
40
+ ...other,
41
+ children: [t3, children]
42
+ });
43
+ $[7] = children;
44
+ $[8] = other;
45
+ $[9] = t3;
46
+ $[10] = theme;
47
+ $[11] = t4;
48
+ } else t4 = $[11];
49
+ return t4;
50
+ }
51
+ export { CmThemeProvider };
@@ -0,0 +1,11 @@
1
+ import type { Theme, ThemeOptions } from '@mui/material/styles';
2
+ /**
3
+ * Creates a theme from the library defaults and a project's overrides.
4
+ *
5
+ * A top-level `palette` override applies to the default color scheme only,
6
+ * which is light. To change dark mode, override `colorSchemes.dark`.
7
+ *
8
+ * The overrides must be merged before calling `createTheme`. With color
9
+ * schemes defined, `createTheme(defaults, overrides)` silently ignores them.
10
+ */
11
+ export declare function createCmTheme(overrides?: ThemeOptions): Theme;
@@ -0,0 +1,17 @@
1
+ import { defaultThemeOptions } from "./defaultTheme.js";
2
+ import { createTheme } from "@mui/material/styles";
3
+ import deepmerge from "@mui/utils/deepmerge";
4
+ // src/theme/createCmTheme.ts
5
+ /**
6
+ * Creates a theme from the library defaults and a project's overrides.
7
+ *
8
+ * A top-level `palette` override applies to the default color scheme only,
9
+ * which is light. To change dark mode, override `colorSchemes.dark`.
10
+ *
11
+ * The overrides must be merged before calling `createTheme`. With color
12
+ * schemes defined, `createTheme(defaults, overrides)` silently ignores them.
13
+ */
14
+ function createCmTheme(overrides = {}) {
15
+ return createTheme(deepmerge(defaultThemeOptions, overrides));
16
+ }
17
+ export { createCmTheme };
@@ -0,0 +1,2 @@
1
+ import type { ThemeOptions } from '@mui/material/styles';
2
+ export declare const defaultThemeOptions: ThemeOptions;
@@ -0,0 +1,9 @@
1
+ // src/theme/defaultTheme.ts
2
+ var defaultThemeOptions = {
3
+ cssVariables: true,
4
+ colorSchemes: {
5
+ light: true,
6
+ dark: true
7
+ }
8
+ };
9
+ export { defaultThemeOptions };
@@ -0,0 +1,3 @@
1
+ export { CmThemeProvider } from './CmThemeProvider.tsx';
2
+ export type { CmThemeProviderProps } from './CmThemeProvider.tsx';
3
+ export { createCmTheme } from './createCmTheme.ts';
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
2
  "name": "@cmotino/cm-web-components",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "storybook dev -p 6006",
7
+ "build": "tsc -b && vite build && tsc -p tsconfig.build.json",
8
+ "build-storybook": "storybook build",
9
+ "lint": "eslint .",
10
+ "typecheck": "tsc -b",
11
+ "test": "vitest run --project unit",
12
+ "test:watch": "vitest --project unit",
13
+ "test:dist": "vitest run --project dist",
14
+ "changeset": "changeset",
15
+ "release": "npm run build && changeset publish"
16
+ },
17
+ "devDependencies": {
18
+ "@babel/core": "^7.29.7",
19
+ "@changesets/cli": "^3.0.3",
20
+ "@emotion/react": "^11.14.0",
21
+ "@emotion/styled": "^11.14.1",
22
+ "@eslint/js": "^10.0.1",
23
+ "@fontsource/roboto": "^5.3.0",
24
+ "@mui/icons-material": "^9.5.0",
25
+ "@mui/material": "^9.5.0",
26
+ "@rolldown/plugin-babel": "^0.3.0",
27
+ "@storybook/addon-a11y": "^10.6.6",
28
+ "@storybook/addon-docs": "^10.6.6",
29
+ "@storybook/react-vite": "^10.6.6",
30
+ "@testing-library/dom": "^10.4.2",
31
+ "@testing-library/jest-dom": "^7.0.1",
32
+ "@testing-library/react": "^16.3.3",
33
+ "@testing-library/user-event": "^14.6.8",
34
+ "@types/babel__core": "^7.20.5",
35
+ "@types/node": "^24.19.2",
36
+ "@types/react": "^19.3.0",
37
+ "@types/react-dom": "^19.3.0",
38
+ "@vitejs/plugin-react": "^6.1.2",
39
+ "babel-plugin-react-compiler": "^1.0.0",
40
+ "eslint": "^10.14.0",
41
+ "eslint-plugin-react-hooks": "^7.1.1",
42
+ "eslint-plugin-react-refresh": "^0.5.7",
43
+ "globals": "^17.13.0",
44
+ "jsdom": "^31.0.0",
45
+ "react": "^19.3.1",
46
+ "react-dom": "^19.3.1",
47
+ "storybook": "^10.6.6",
48
+ "typescript": "~6.0.3",
49
+ "typescript-eslint": "^8.72.1",
50
+ "vite": "^8.3.6",
51
+ "vitest": "^5.1.0"
52
+ },
53
+ "dependencies": {
54
+ "@mui/utils": "^9.0.0"
55
+ },
56
+ "peerDependencies": {
57
+ "@emotion/react": "^11.0.0",
58
+ "@emotion/styled": "^11.0.0",
59
+ "@mui/material": "^9.0.0",
60
+ "react": "^19.0.0",
61
+ "react-dom": "^19.0.0"
62
+ },
63
+ "sideEffects": false,
64
+ "files": [
65
+ "dist"
66
+ ],
67
+ "exports": {
68
+ ".": {
69
+ "types": "./dist/index.d.ts",
70
+ "import": "./dist/index.js"
71
+ },
72
+ "./package.json": "./package.json"
73
+ },
74
+ "publishConfig": {
75
+ "access": "public"
76
+ }
77
+ }