@machinemetrics/mm-react-components 0.2.3-3 → 0.2.3-5

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/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ @keyframes mm-progress-shimmer{0%{transform:translate(-100%);opacity:0}10%{opacity:.15}50%{opacity:.25}to{transform:translate(100%);opacity:0}}[data-slot=progress-indicator]:before{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,.15) 50%,transparent 100%);transform:translate(-100%);pointer-events:none;animation:mm-progress-shimmer 2.4s ease-in-out infinite}@keyframes mm-progress-head-flash{0%{opacity:0;transform:translate(0)}30%{opacity:.6}to{opacity:0;transform:translate(8px)}}@keyframes mm-progress-breathe{0%,to{filter:brightness(1);opacity:1}50%{filter:brightness(1.35);opacity:.8}}[data-slot=progress] [data-slot=progress-indicator]:after{content:"";position:absolute;right:-2px;top:0;bottom:0;width:12px;pointer-events:none;background:radial-gradient(12px 12px at 100% 50%,rgba(255,255,255,.6),transparent 70%);opacity:0}.mmc-progress[data-animating=true] [data-slot=progress-indicator]:after{animation:mm-progress-head-flash .6s ease-out 1}[data-slot=progress-indicator]{animation:mm-progress-breathe 1.65s ease-in-out infinite}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinemetrics/mm-react-components",
3
- "version": "0.2.3-3",
3
+ "version": "0.2.3-5",
4
4
  "description": "Industrial-grade React components for manufacturing applications",
5
5
  "keywords": [
6
6
  "react",
@@ -29,20 +29,28 @@
29
29
  "import": "./dist/mm-react-components.es.js",
30
30
  "require": "./dist/mm-react-components.umd.js"
31
31
  },
32
- "./styles": "./dist/index.css",
33
- "./themes/base": "./dist/index.css",
32
+ "./styles": "./dist/lib/styles.css",
34
33
  "./themes/carbide": "./dist/themes/carbide.css",
35
- "./themes/complete": "./dist/themes/complete.css",
36
34
  "./tailwind.config": "./tailwind.base.config.js",
37
35
  "./docs/tailwind-setup": "./docs/TAILWIND_SETUP.md",
38
36
  "./docs/getting-started": "./dist/docs/GETTING_STARTED.md",
39
- "./README": "./dist/README.md"
37
+ "./README": "./dist/README.md",
38
+ "./migration/config": "./scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.config.json",
39
+ "./agent-docs": "./agent-docs/"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=20"
43
43
  },
44
+ "peerDependencies": {
45
+ "autoprefixer": "^10.0.0",
46
+ "postcss": "^8.5.6",
47
+ "react": "^19.1.1",
48
+ "react-dom": "^19.1.1",
49
+ "tailwindcss": "^4.0.0"
50
+ },
44
51
  "bin": {
45
- "chakra-to-shadcn": "scripts/chakra-to-shadcn-migrator/bin/chakra-to-shadcn.js"
52
+ "chakra-to-shadcn": "scripts/chakra-to-shadcn-migrator/bin/chakra-to-shadcn.js",
53
+ "mm-init": "scripts/init.cjs"
46
54
  },
47
55
  "scripts": {
48
56
  "build": "vite build --mode production && tsc --project tsconfig.build.json",
@@ -124,6 +132,7 @@
124
132
  "devDependencies": {
125
133
  "@eslint/js": "^9.33.0",
126
134
  "@playwright/test": "^1.55.0",
135
+ "@tailwindcss/postcss": "^4.1.13",
127
136
  "@tailwindcss/vite": "^4.1.13",
128
137
  "@types/node": "^24.5.0",
129
138
  "@types/react": "^19.1.10",
@@ -132,6 +141,7 @@
132
141
  "@typescript-eslint/eslint-plugin": "^8.43.0",
133
142
  "@typescript-eslint/parser": "^8.43.0",
134
143
  "@vitejs/plugin-react": "^5.0.0",
144
+ "autoprefixer": "^10.4.21",
135
145
  "eslint": "^9.33.0",
136
146
  "eslint-config-prettier": "^10.1.8",
137
147
  "eslint-plugin-jsx-a11y": "^6.10.2",
@@ -142,7 +152,7 @@
142
152
  "globals": "^16.3.0",
143
153
  "playwright": "^1.55.0",
144
154
  "prettier": "^3.6.2",
145
- "tailwindcss": "^4.1.13",
155
+ "tailwindcss": "^4.1.14",
146
156
  "terser": "^5.44.0",
147
157
  "tsx": "^4.19.2",
148
158
  "typescript": "~5.8.3",
package/scripts/README.md CHANGED
@@ -1,171 +1,171 @@
1
- # Scripts Directory
1
+ # MM React Components - Initialization Scripts
2
2
 
3
- This directory contains scripts for maintaining shadcn/ui components and visual regression tests.
3
+ This directory contains initialization scripts to help users quickly set up the MachineMetrics React Components library in their projects.
4
4
 
5
- ## Component Creation Script
5
+ ## Available Scripts
6
6
 
7
- ### Create New Component
7
+ ### 1. Quick Initialization Script (`init.js`)
8
8
 
9
- ```bash
10
- npm run create-component <component-name>
11
- ```
9
+ **Usage:** `npm run init`
12
10
 
13
- Creates a new shadcn/ui component with automatic linting, formatting, and preview generation.
11
+ A streamlined initialization script that:
14
12
 
15
- **Options:**
13
+ - Installs the component library and core dependencies
14
+ - Sets up basic CSS imports
15
+ - Provides minimal configuration
16
16
 
17
- - `--skip-preview` - Skip generating preview component
18
- - `--skip-lint` - Skip running ESLint fixes
19
- - `--skip-format` - Skip running Prettier formatting
20
- - `--skip-tests` - Skip generating Playwright tests
21
- - `--help` - Show help message
17
+ **Features:**
22
18
 
23
- **Examples:**
19
+ - āœ… Fast setup (no interactive prompts)
20
+ - āœ… Installs only essential dependencies
21
+ - āœ… Basic theme integration
22
+ - āœ… Perfect for quick prototyping
24
23
 
25
- ```bash
26
- npm run create-component card
27
- npm run create-component dialog --skip-preview
28
- npm run create-component select --skip-lint --skip-format
29
- npm run create-component button --skip-tests
30
- ```
24
+ ### 2. NPX CLI Tool (`npx-init.js`)
31
25
 
32
- **Workflow:**
26
+ **Usage:** `npx @machinemetrics/mm-react-components init`
33
27
 
34
- 1. Add component using shadcn CLI
35
- 2. Apply ESLint fixes (unless --skip-lint)
36
- 3. Apply Prettier formatting (unless --skip-format)
37
- 4. Generate preview component (unless --skip-preview)
38
- 5. Generate Playwright tests (unless --skip-tests)
39
- 6. Update main index.ts exports
28
+ An NPX CLI tool that can be run from any directory:
40
29
 
41
- ## Component Update Scripts
30
+ - Installs the component library
31
+ - Sets up peer dependencies
32
+ - Creates example components
33
+ - Configures CSS imports
42
34
 
43
- ### TypeScript Version
35
+ **Features:**
44
36
 
45
- ```bash
46
- npm run update-components
47
- ```
37
+ - āœ… Can be run via npx (no global installation needed)
38
+ - āœ… Works in any React project
39
+ - āœ… Creates example components
40
+ - āœ… Minimal setup process
41
+
42
+ ## Usage Examples
48
43
 
49
- ### Bash Version
44
+ ### For New Projects
50
45
 
51
46
  ```bash
52
- npm run update-components:bash
53
- ```
47
+ # Create a new React project
48
+ npx create-react-app my-app
49
+ cd my-app
54
50
 
55
- ## Visual Test Generation Scripts
51
+ # Install MM React Components
52
+ npx @machinemetrics/mm-react-components init
53
+ ```
56
54
 
57
- ### Generate Missing Tests (Default)
55
+ ### For Existing Projects
58
56
 
59
57
  ```bash
60
- npm run generate-visual-tests
61
- ```
58
+ # Quick setup
59
+ npm run init
62
60
 
63
- Only generates tests for components that don't have test files yet. Existing tests are preserved.
61
+ # Or use npx (recommended)
62
+ npx @machinemetrics/mm-react-components init
63
+ ```
64
64
 
65
- ### Generate All Tests (Overwrite)
65
+ ### NPX Usage
66
66
 
67
67
  ```bash
68
- npm run generate-visual-tests:overwrite
68
+ # Use directly with npx (no installation needed)
69
+ npx @machinemetrics/mm-react-components init
69
70
  ```
70
71
 
71
- Regenerates all test files, overwriting existing ones. Useful after template changes or major updates.
72
+ ## What Gets Installed
72
73
 
73
- ## What the Component Update Scripts Do
74
+ ### Core Dependencies
74
75
 
75
- Both component update scripts will:
76
+ - `@machinemetrics/mm-react-components` - The component library
77
+ - `class-variance-authority` - Component variant management
78
+ - `clsx` - Conditional class names
79
+ - `tailwind-merge` - Tailwind class merging
80
+ - `@radix-ui/react-slot` - Radix UI primitives
81
+ - `lucide-react` - Icon library
76
82
 
77
- 1. **Scan** `src/components/ui/` for all installed components
78
- 2. **Filter** out custom components (like `theme-toggle`)
79
- 3. **Update** each remaining component using `npx shadcn@latest add <component> --yes --overwrite`
80
- 4. **Report** a summary of what was updated, skipped, or failed
83
+ ### Optional Dependencies
81
84
 
82
- The scripts automatically discover components from your folder - no need to maintain a hardcoded list!
85
+ - `react-hook-form` - Form handling
86
+ - `@hookform/resolvers` - Form validation resolvers
87
+ - `zod` - Schema validation
88
+ - `sonner` - Toast notifications
83
89
 
84
- ## What the Visual Test Generation Scripts Do
90
+ ## What Gets Created
85
91
 
86
- The visual test generation script will:
92
+ ### CSS Imports
87
93
 
88
- 1. **Scan** all preview routes in `src/App.tsx` for component previews
89
- 2. **Check** existing test files in `tests/visual/`
90
- 3. **Generate** Playwright test files using TypeScript templates from `scripts/templates/`
91
- 4. **Smart Wait Logic**: Automatically adds table-specific wait conditions for data table components
92
- 5. **Skip or Overwrite**: Either skip existing tests (default) or overwrite them (with `--overwrite`)
93
- 6. **Report** a summary of generated, skipped, and total test files
94
+ ```css
95
+ @import '@machinemetrics/mm-react-components/styles';
96
+ @import '@machinemetrics/mm-react-components/themes/carbide';
97
+ ```
94
98
 
95
- ### Generated Test Types
99
+ ### Example Components
96
100
 
97
- Each component gets tests for:
101
+ - Basic usage examples
102
+ - Advanced form examples
103
+ - Industrial/manufacturing use cases
98
104
 
99
- - **Main Component Screenshot**: Captures the component in its default state
100
- - **Mobile Responsive Screenshot**: Tests the component at mobile viewport (375x667)
105
+ ### Configuration Files
101
106
 
102
- ## Features
107
+ - TypeScript declarations
108
+ - Vite configuration (if needed)
109
+ - Example documentation
103
110
 
104
- ### Component Creation Script
111
+ ## Theme Integration
105
112
 
106
- - āœ… **Smart Component Detection**: Automatically detects component structure and exports
107
- - āœ… **Intelligent Preview Generation**: Creates appropriate preview components based on component type
108
- - āœ… **Special Component Handling**: Custom preview templates for complex components (card, dialog, etc.)
109
- - āœ… **Automatic Linting**: Applies ESLint fixes after component creation
110
- - āœ… **Automatic Formatting**: Applies Prettier formatting for consistent code style
111
- - āœ… **Playwright Test Generation**: Automatically generates visual regression tests
112
- - āœ… **Export Management**: Automatically updates index.ts with new component exports
113
- - āœ… **Error Handling**: Comprehensive error handling with detailed progress reporting
114
- - āœ… **Flexible Options**: Skip any step with command-line flags
115
- - āœ… **Help Documentation**: Built-in help with usage examples
113
+ The scripts automatically set up the Carbide theme for industrial applications:
116
114
 
117
- ### Component Update Scripts
115
+ ```tsx
116
+ // Add to your root element
117
+ <div className="carbide">
118
+ <App />
119
+ </div>
120
+ ```
118
121
 
119
- - āœ… **Auto-Discovery**: Automatically finds all components in your `ui/` folder
120
- - āœ… **Smart Filtering**: Skips custom components automatically
121
- - āœ… **CLI Validation**: Let shadcn CLI determine if components are valid/updatable
122
- - āœ… **Detailed Progress**: Shows real-time updates and comprehensive summary
123
- - āœ… **Error Handling**: Reports failures and continues with other components
124
- - āœ… **Overwrite**: Uses `--overwrite` flag to ensure components are properly updated
122
+ ## Troubleshooting
125
123
 
126
- ### Visual Test Generation Scripts
124
+ ### Common Issues
127
125
 
128
- - āœ… **TypeScript Templates**: Uses proper `.ts` template files for full linting and type-checking
129
- - āœ… **Smart Generation**: Only generates missing tests by default, preserves existing customizations
130
- - āœ… **Overwrite Mode**: `--overwrite` flag regenerates all tests when needed
131
- - āœ… **Dynamic Wait Logic**: Automatically adapts wait conditions for data tables vs regular components
132
- - āœ… **Mobile Testing**: Includes responsive testing at mobile viewport sizes
133
- - āœ… **Route Auto-Discovery**: Automatically finds all component preview routes
126
+ 1. **"React not found"**
127
+ - Ensure you're in a React project directory
128
+ - Check that React is installed in package.json
134
129
 
135
- ## Custom Components
130
+ 2. **"Permission denied"**
131
+ - Make sure the script is executable: `chmod +x scripts/*.js`
136
132
 
137
- Components listed in `CUSTOM_COMPONENTS` will be skipped during updates:
133
+ 3. **"Module not found"**
134
+ - Run `npm install` to install dependencies
135
+ - Check that the component library is properly installed
138
136
 
139
- - `theme-toggle` - Custom component, not from shadcn/ui
137
+ ### Manual Setup
140
138
 
141
- To add more custom components to skip, edit the `CUSTOM_COMPONENTS` array in either script.
139
+ If the scripts fail, you can set up manually:
142
140
 
143
- ## Requirements
141
+ ```bash
142
+ # Install the library
143
+ npm install @machinemetrics/mm-react-components
144
144
 
145
- ### TypeScript Version
145
+ # Install peer dependencies
146
+ npm install class-variance-authority clsx tailwind-merge @radix-ui/react-slot lucide-react
146
147
 
147
- - `tsx` package (included in devDependencies)
148
- - Node.js
148
+ # Add to your CSS
149
+ @import '@machinemetrics/mm-react-components/styles';
150
+ @import '@machinemetrics/mm-react-components/themes/carbide';
151
+ ```
149
152
 
150
- ### Bash Version
153
+ ## Support
151
154
 
152
- - Bash shell
153
- - `npx` command available
155
+ For issues or questions:
154
156
 
155
- ## Help
157
+ - GitHub Issues: https://github.com/machinemetrics/mm-react-components/issues
158
+ - Documentation: https://github.com/machinemetrics/mm-react-components#readme
156
159
 
157
- Both scripts support `--help` flag:
160
+ ## Contributing
158
161
 
159
- ```bash
160
- npm run update-components -- --help
161
- ./scripts/update-components.sh --help
162
- ```
162
+ To improve the initialization scripts:
163
163
 
164
- ## Troubleshooting
164
+ 1. Fork the repository
165
+ 2. Make your changes
166
+ 3. Test with different React setups
167
+ 4. Submit a pull request
165
168
 
166
- If updates fail:
169
+ ## License
167
170
 
168
- 1. Ensure you have internet connection
169
- 2. Make sure `npx` can access the shadcn CLI
170
- 3. Check that `src/components/ui/` directory exists
171
- 4. Verify you're in the project root directory
171
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MM React Components - Quick Init Script
5
+ *
6
+ * Simple initialization script for the MachineMetrics React Components library
7
+ */
8
+
9
+ /* eslint-disable no-undef */
10
+
11
+ const { execSync } = require('child_process');
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+
15
+ // Colors for console output
16
+ const colors = {
17
+ reset: '\x1b[0m',
18
+ bright: '\x1b[1m',
19
+ green: '\x1b[32m',
20
+ blue: '\x1b[34m',
21
+ cyan: '\x1b[36m',
22
+ };
23
+
24
+ function log(message, color = 'reset') {
25
+ console.log(`${colors[color]}${message}${colors.reset}`);
26
+ }
27
+
28
+ function main() {
29
+ log('šŸš€ MM React Components - Quick Setup', 'bright');
30
+ log(
31
+ 'Installing and configuring MachineMetrics React Components...\n',
32
+ 'blue',
33
+ );
34
+
35
+ try {
36
+ // Install the component library
37
+ log('šŸ“¦ Installing MM React Components...', 'cyan');
38
+ execSync('npm install @machinemetrics/mm-react-components@beta', {
39
+ stdio: 'inherit',
40
+ });
41
+ log('āœ… MM React Components installed', 'green');
42
+
43
+ // Install peer dependencies
44
+ log('šŸ“¦ Installing peer dependencies...', 'cyan');
45
+ const peerDeps = [
46
+ 'class-variance-authority',
47
+ 'clsx',
48
+ 'tailwind-merge',
49
+ '@radix-ui/react-slot',
50
+ 'lucide-react',
51
+ 'tailwindcss',
52
+ 'autoprefixer',
53
+ 'postcss',
54
+ ];
55
+ execSync(`npm install ${peerDeps.join(' ')}`, { stdio: 'inherit' });
56
+ log('āœ… Peer dependencies installed', 'green');
57
+
58
+ // Create basic CSS import
59
+ const srcPath = path.join(process.cwd(), 'src');
60
+ const indexCssPath = path.join(srcPath, 'index.css');
61
+
62
+ // Ensure src directory exists
63
+ if (!fs.existsSync(srcPath)) {
64
+ fs.mkdirSync(srcPath, { recursive: true });
65
+ log('āœ… Created src/ directory', 'green');
66
+ }
67
+
68
+ if (fs.existsSync(indexCssPath)) {
69
+ const cssContent = fs.readFileSync(indexCssPath, 'utf8');
70
+ if (!cssContent.includes('@machinemetrics/mm-react-components')) {
71
+ const newCssContent = `@import '@machinemetrics/mm-react-components/themes/carbide';
72
+
73
+ ${cssContent}`;
74
+ fs.writeFileSync(indexCssPath, newCssContent);
75
+ log('āœ… Added Carbide theme import to existing index.css', 'green');
76
+ } else {
77
+ log('āœ… Carbide theme import already present in index.css', 'green');
78
+ }
79
+ } else {
80
+ const cssContent = `@import '@machinemetrics/mm-react-components/themes/carbide';`;
81
+
82
+ fs.writeFileSync(indexCssPath, cssContent);
83
+ log('āœ… Created index.css with Carbide theme import', 'green');
84
+ }
85
+
86
+ // Always use the exported Tailwind config from the package
87
+ const tailwindConfigPath = path.join(process.cwd(), 'tailwind.config.js');
88
+ const packageConfigPath = path.join(
89
+ process.cwd(),
90
+ 'node_modules/@machinemetrics/mm-react-components/tailwind.base.config.js',
91
+ );
92
+
93
+ if (!fs.existsSync(packageConfigPath)) {
94
+ log('āŒ Could not find exported Tailwind config in package', 'red');
95
+ log(
96
+ ' This indicates the package installation may be incomplete.',
97
+ 'red',
98
+ );
99
+ process.exit(1);
100
+ }
101
+
102
+ const configContent = fs.readFileSync(packageConfigPath, 'utf8');
103
+ // Convert ES module to CommonJS for compatibility
104
+ const commonJsConfig = configContent
105
+ .replace('export default', 'module.exports =')
106
+ .replace(/^\/\*\* @type \{import\('tailwindcss'\)\.Config\} \*\/\n/, '');
107
+
108
+ if (fs.existsSync(tailwindConfigPath)) {
109
+ log('āœ… Replacing existing Tailwind config with package config', 'green');
110
+ } else {
111
+ log('āœ… Creating tailwind.config.js from package config', 'green');
112
+ }
113
+
114
+ fs.writeFileSync(tailwindConfigPath, commonJsConfig);
115
+
116
+ // Check if PostCSS config exists and update it if needed
117
+ const postcssConfigPath = path.join(process.cwd(), 'postcss.config.js');
118
+ if (fs.existsSync(postcssConfigPath)) {
119
+ log('āœ… Found existing PostCSS config', 'green');
120
+ } else {
121
+ // Create a basic PostCSS config
122
+ const postcssConfigContent = `module.exports = {
123
+ plugins: {
124
+ tailwindcss: {},
125
+ autoprefixer: {},
126
+ },
127
+ }`;
128
+ fs.writeFileSync(postcssConfigPath, postcssConfigContent);
129
+ log('āœ… Created postcss.config.js', 'green');
130
+ }
131
+
132
+ // Success message
133
+ log('\nšŸŽ‰ Setup complete!', 'green');
134
+ log('\nšŸ“š Next steps:');
135
+ log(
136
+ ' 1. Import components: import { Button } from "@machinemetrics/mm-react-components"',
137
+ );
138
+ log(
139
+ ' 2. Add "carbide" class to your root element to activate the industrial theme',
140
+ );
141
+ log(' 3. The Carbide theme is already imported and ready to use!');
142
+ log(' 4. Check the documentation for examples');
143
+
144
+ log(
145
+ '\nšŸ’” Pro tip: The Carbide theme provides industrial-appropriate colors and styling',
146
+ );
147
+ log('\nšŸ”§ Tailwind CSS and PostCSS have been configured for you');
148
+ log('šŸš€ Happy coding!', 'cyan');
149
+ } catch (error) {
150
+ log(`āŒ Setup failed: ${error.message}`, 'red');
151
+ process.exit(1);
152
+ }
153
+ }
154
+
155
+ if (require.main === module) {
156
+ main();
157
+ }
158
+
159
+ module.exports = { main };