Skip to content

Commit dee9f19

Browse files
authored
Publish ready (#109)
* feat: update React to version 18.2.0 and fix compatibility issues - Update React and React-DOM from 0.14.7 to 18.2.0 - Update build tools (browserify, budo, uglify-js, faker) - Update lodash to latest version for security - Replace deprecated componentWillMount with componentDidMount - Replace deprecated componentWillReceiveProps with componentDidUpdate - Update all examples to use React 18's createRoot API instead of ReactDOM.render - Update load.js helper for React 18 compatibility * feat: update to React 19.1.0 and verify compatibility - Update React and React-DOM to latest version 19.1.0 - Test basic and demo examples - both working correctly - Build process successful with no errors or warnings - Generated new standalone build file * feat: migrate from browserify/budo to Vite - Convert all CommonJS modules to ES modules (import/export) - Replace budo/browserify with Vite for dev server and build - Add Vite configuration with React plugin - Create HTML files for examples with proper module loading - Update package.json scripts to use Vite commands - Remove legacy browserify transforms and dependencies - Generate modern ES/UMD bundles with CSS extraction - Improve dev experience with HMR and faster builds * fix: improve Vite dev server configuration - Add environment variable support with loadEnv() - Enable flexible port handling with strictPort: false - Add allowedHosts: true for development flexibility - Implement smart HMR management for production - Set modern build target to esnext - Add JSON stringify support - Add index.html in root directory pointing to demo - Update npm example script to use 'vite --host' instead of specific HTML file - Follow standard Vite project structure for better jump.sh compatibility * feat: make package publish-ready for npm - Add proper package.json fields for modern npm publishing - Set type: 'module' for ES modules support - Add main/module/browser fields pointing to built dist files - Add exports field for dual ESM/CommonJS support - Add files field to control what gets published - Add prepublishOnly script to ensure build before publish - Update README with modern React 19 usage examples - ES modules import syntax (recommended) - CommonJS require syntax (legacy support) - UMD browser global usage - Updated React 18+ createRoot API - Remove duplicate and legacy fields - Remove old browserify build scripts - Package now includes: dist builds, source files, styles, docs
1 parent cbb14f2 commit dee9f19

25 files changed

+5645
-5338
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
*.log

CLAUDE.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Common Development Commands
6+
7+
### Running Examples
8+
- `npm run example` - Run the main demo with live reload (uses PORT env var, defaults to 9966)
9+
- `npm run example-basic` - Run basic example
10+
- `npm run example-persist` - Run persistence example
11+
12+
### Building
13+
- `npm run dist` - Build standalone distribution file
14+
- `npm run build-standalone` - Build minified standalone version
15+
- `npm run remove-dist` - Clean dist directory
16+
17+
## Project Architecture
18+
19+
### Core Component Structure
20+
The main ReactPivot component (`index.jsx`) orchestrates the entire pivot table functionality:
21+
- Uses DataFrame library for data processing and calculations
22+
- Manages state for dimensions, sorting, filtering, and pagination
23+
- Renders three main sub-components: Dimensions, ColumnControl, and PivotTable
24+
25+
### Key Components
26+
- **ReactPivot** (`index.jsx`) - Main component that handles data processing and state management
27+
- **PivotTable** (`lib/pivot-table.jsx`) - Renders the actual table with pagination and sorting
28+
- **Dimensions** (`lib/dimensions.jsx`) - Handles dimension selection and grouping controls
29+
- **ColumnControl** (`lib/column-control.jsx`) - Manages column visibility
30+
31+
### Data Flow
32+
1. Raw data (`rows`) is processed through DataFrame with `dimensions` and `reduce` function
33+
2. User interactions (sorting, filtering, dimension changes) update state
34+
3. `updateRows()` recalculates the DataFrame based on current state
35+
4. Processed data flows to PivotTable for rendering
36+
37+
### Key Libraries
38+
- **dataframe** - Core data processing and pivot calculations
39+
- **lodash** - Utility functions (uses individual imports for better tree-shaking)
40+
- **wildemitter** - Event bus for component communication
41+
- **create-react-class** - React class component creation (legacy syntax)
42+
43+
### Build System
44+
- Uses **browserify** with **budo** for development server
45+
- **Reactify**, **envify**, and **cssify** transforms
46+
- Standalone builds use **uglify-js** for minification
47+
- Port configuration respects PORT environment variable
48+
49+
### Development Server
50+
The project uses a local jump.sh proxy system. Check `pivot.jump.sh.log` for the current development URL (typically https://pivot.jump.sh).

README.md

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,87 @@
11
# ReactPivot #
22

3-
ReactPivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration. Can be used without React.
3+
ReactPivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration.
4+
5+
**Now compatible with React 19+ and modern build tools!**
46

57
Demo: [http://davidguttman.github.io/react-pivot/](http://davidguttman.github.io/react-pivot/)
68

79
![Demo](http://i.imgur.com/BhPF2Cv.gif)
810

911
## Installation & Usage ##
1012

11-
<strong> Default (Browserify/webpack): </strong>
12-
13+
```bash
14+
npm install react-pivot
1315
```
14-
npm i -S react-pivot
15-
```
16-
17-
```js
18-
var React = require('react')
19-
var ReactPivot = require('react-pivot')
2016

21-
React.render(
22-
<ReactPivot rows={rows}
23-
dimensions={dimensions}
24-
reduce={reduce}
25-
calculations={calculations}
26-
nPaginateRows={25} />,
27-
document.body
17+
### Modern ES Modules (Recommended)
18+
19+
```jsx
20+
import React from 'react'
21+
import { createRoot } from 'react-dom/client'
22+
import ReactPivot from 'react-pivot'
23+
24+
const root = createRoot(document.getElementById('root'))
25+
root.render(
26+
<ReactPivot
27+
rows={rows}
28+
dimensions={dimensions}
29+
reduce={reduce}
30+
calculations={calculations}
31+
nPaginateRows={25}
32+
/>
2833
)
2934
```
3035

31-
<strong> Classic (no React or Browserify): </strong>
36+
### CommonJS (Legacy Support)
3237

33-
Download [react-pivot-standalone-3.0.0.min.js](https://raw.githubusercontent.com/davidguttman/react-pivot/master/dist/react-pivot-standalone-3.0.0.min.js)
38+
```js
39+
const React = require('react')
40+
const { createRoot } = require('react-dom/client')
41+
const ReactPivot = require('react-pivot')
3442

35-
```html
36-
<script src='react-pivot-standalone-3.0.0.min.js'></script>
37-
<script>
38-
ReactPivot(document.body, {
43+
const root = createRoot(document.getElementById('root'))
44+
root.render(
45+
React.createElement(ReactPivot, {
3946
rows: rows,
4047
dimensions: dimensions,
48+
reduce: reduce,
4149
calculations: calculations,
42-
reduce: reduce
50+
nPaginateRows: 25
4351
})
44-
</script>
45-
```
46-
47-
<strong> Custom (Browserify, no React): </strong>
48-
49-
```js
50-
var ReactPivot = require('react-pivot/load')
51-
52-
ReactPivot(document.body, {
53-
rows: rows,
54-
dimensions: dimensions,
55-
reduce: reduce,
56-
calculations: calculations
57-
})
58-
52+
)
5953
```
6054

55+
### UMD (Browser Global)
6156

57+
```html
58+
<script src="https://unpkg.com/react-pivot/dist/react-pivot.umd.js"></script>
59+
<script>
60+
const root = ReactDOM.createRoot(document.getElementById('root'))
61+
root.render(
62+
React.createElement(ReactPivot, {
63+
rows: rows,
64+
dimensions: dimensions,
65+
calculations: calculations,
66+
reduce: reduce
67+
})
68+
)
69+
</script>
6270
## Example ##
6371

64-
```js
65-
var React = require('react')
66-
var ReactPivot = require('react-pivot')
67-
68-
React.render(
69-
<ReactPivot rows={rows}
70-
dimensions={dimensions}
71-
reduce={reduce}
72-
calculations={calculations} />,
73-
document.body
72+
```jsx
73+
import React from 'react'
74+
import { createRoot } from 'react-dom/client'
75+
import ReactPivot from 'react-pivot'
76+
77+
const root = createRoot(document.getElementById('root'))
78+
root.render(
79+
<ReactPivot
80+
rows={rows}
81+
dimensions={dimensions}
82+
reduce={reduce}
83+
calculations={calculations}
84+
/>
7485
)
7586
```
7687

dist/react-pivot-standalone-4.1.1.min.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

dist/react-pivot.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)