jattac.libs.web.responsive-table 0.7.5 → 0.8.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.
@@ -0,0 +1,40 @@
1
+ # Architecture and Contribution Guide
2
+ ## Internal System Design and Development Workflows
3
+
4
+ The ResponsiveTable component is engineered using an **Atomized Architecture**. This design principle decouples logic orchestration from presentation units to ensure high reusability and predictable state transitions.
5
+
6
+ ## Table of Contents
7
+ * [Architectural Layers](#architectural-layers)
8
+ * [Development Environment Initialization](#development-environment-initialization)
9
+ * [Technical Command Reference](#technical-command-reference)
10
+
11
+ ---
12
+
13
+ [← Previous: Configuration Specification](./configuration.md) | [Next: Version Transition Guide →](./breaking-changes.md)
14
+
15
+ ### Architectural Layers
16
+ The system is partitioned into three distinct functional layers:
17
+ 1. **Logic Orchestration (`useTablePlugins`)**: A centralized hook that manages the data processing pipeline, plugin lifecycle, and persistent state management using non-reactive references.
18
+ 2. **Pure Presentation Components**:
19
+ * `DesktopView`: Manages standard tabular rendering and intelligent footer scaling logic.
20
+ * `MobileView`: Manages card-based interface generation.
21
+ * `SkeletonView`: Unified structural placeholder logic.
22
+ 3. **Shell Orchestrators**:
23
+ * `ResponsiveTable`: The primary entry point for synchronous datasets.
24
+ * `InfiniteTable`: A specialized orchestrator for asynchronous data streams and scroll event interception.
25
+
26
+ ### Development Environment Initialization
27
+ To initialize the development environment, execute the following procedures:
28
+ 1. Clone the source repository.
29
+ 2. Install required dependencies: `npm install`
30
+ 3. Initialize the visual development environment: `npm run storybook`
31
+ 4. Execute the validation suite: `npm test`
32
+
33
+ ### Technical Command Reference
34
+ * `npm run build`: Generates production-ready distribution bundles via Rollup.
35
+ * `npm run lint`: Performs static analysis to ensure adherence to architectural standards.
36
+ * `npm test`: Executes the Jest-based unit and integration test suites.
37
+ * `npm run storybook`: Launches the component isolation and visual testing environment.
38
+
39
+ ---
40
+ **Previous:** [Configuration Specification](./configuration.md) | **Next:** [Version Transition Guide](./breaking-changes.md)
@@ -0,0 +1,207 @@
1
+ # Technical Implementation Guide
2
+ ## Implementation Patterns for the ResponsiveTable Component
3
+
4
+ This guide details standard implementation patterns for the ResponsiveTable component, ordered by increasing complexity. Each section contains a production-ready example designed for integration into enterprise applications.
5
+
6
+ ## Table of Contents
7
+ * [Standard Tabular Implementation](#1-standard-tabular-implementation)
8
+ * [Implementing Sortable Columns](#2-implementing-sortable-columns)
9
+ * [Asynchronous Data Filtering](#3-asynchronous-data-filtering)
10
+ * [Row Selection Mechanisms](#4-row-selection-mechanisms)
11
+ * [Navigation and Master-Detail Patterns](#5-navigation-and-master-detail-patterns)
12
+ * [Programmatic Column Visibility Management](#6-programmatic-column-visibility-management)
13
+ * [Automated Footer Scaling Logic](#7-automated-footer-scaling-logic)
14
+ * [High-Volume Data: Asynchronous Infinite Scroll](#8-high-volume-data-asynchronous-infinite-scroll)
15
+ * [Internal Plugin Development](#9-internal-plugin-development)
16
+
17
+ ---
18
+
19
+ [← Return to Overview](../README.md)
20
+
21
+ ### 1. Standard Tabular Implementation
22
+ A baseline implementation for displaying structured data. The component will automatically transition to a card-based layout when the viewport width is less than 600px.
23
+
24
+ ```tsx
25
+ import ResponsiveTable from 'jattac.libs.web.responsive-table';
26
+
27
+ const data = [
28
+ { id: 1, name: 'Administrative User', role: 'Administrator' },
29
+ { id: 2, name: 'Standard User', role: 'User' },
30
+ ];
31
+
32
+ const columns = [
33
+ { displayLabel: 'User Name', cellRenderer: (row) => row.name },
34
+ { displayLabel: 'Assigned Role', cellRenderer: (row) => row.role },
35
+ ];
36
+
37
+ export const BasicTable = () => (
38
+ <ResponsiveTable data={data} columnDefinitions={columns} />
39
+ );
40
+ ```
41
+
42
+ ### 2. Implementing Sortable Columns
43
+ Enable sorting by defining a unique `columnId` and an associated sorting strategy via `getSortableValue` or a custom `sortComparer`.
44
+
45
+ ```tsx
46
+ const columns = [
47
+ {
48
+ columnId: 'name',
49
+ displayLabel: 'Name',
50
+ cellRenderer: (row) => row.name,
51
+ getSortableValue: (row) => row.name // Lexicographical sort
52
+ },
53
+ {
54
+ columnId: 'date',
55
+ displayLabel: 'Registration Date',
56
+ cellRenderer: (row) => row.date.toLocaleDateString(),
57
+ sortComparer: (a, b, dir) => { // Chronological sort implementation
58
+ const diff = a.date.getTime() - b.date.getTime();
59
+ return dir === 'asc' ? diff : -diff;
60
+ }
61
+ },
62
+ ];
63
+ ```
64
+
65
+ ### 3. Asynchronous Data Filtering
66
+ Implement client-side data filtering by providing the `filterProps` configuration object.
67
+
68
+ ```tsx
69
+ const columns = [
70
+ {
71
+ displayLabel: 'Name',
72
+ cellRenderer: (row) => row.name,
73
+ getFilterableValue: (row) => row.name // Search target definition
74
+ },
75
+ ];
76
+
77
+ <ResponsiveTable
78
+ data={data}
79
+ columnDefinitions={columns}
80
+ filterProps={{ showFilter: true, filterPlaceholder: 'Filter by name...' }}
81
+ />
82
+ ```
83
+
84
+ ### 4. Row Selection Mechanisms
85
+ The component supports persistent row selection in both single and multiple selection modes. State is maintained across re-renders via internal plugin orchestration.
86
+
87
+ ```tsx
88
+ <ResponsiveTable
89
+ data={data}
90
+ columnDefinitions={columns}
91
+ selectionProps={{
92
+ mode: 'multiple',
93
+ rowIdKey: 'id',
94
+ onSelectionChange: (items) => console.info('Current Selection:', items)
95
+ }}
96
+ />
97
+ ```
98
+
99
+ ### 5. Navigation and Master-Detail Patterns
100
+ The `onRowClick` callback allows for the implementation of navigation patterns or detailed data inspection.
101
+
102
+ ```tsx
103
+ <ResponsiveTable
104
+ data={data}
105
+ columnDefinitions={columns}
106
+ onRowClick={(row) => navigateToDetail(row.id)}
107
+ />
108
+ ```
109
+
110
+ ### 6. Programmatic Column Visibility Management
111
+ Toggle column visibility dynamically. The component will automatically adjust the layout to reflect changes in the visible column set.
112
+
113
+ ```tsx
114
+ const [isRoleVisible, setIsRoleVisible] = useState(false);
115
+
116
+ const columns = [
117
+ { displayLabel: 'User Name', cellRenderer: (row) => row.name },
118
+ {
119
+ displayLabel: 'Assigned Role',
120
+ cellRenderer: (row) => row.role,
121
+ visible: isRoleVisible // State-driven visibility
122
+ },
123
+ ];
124
+ ```
125
+
126
+ ### 7. Automated Footer Scaling Logic
127
+ When columns are programmatically hidden, the component automatically recalculates the `colSpan` of defined footer cells to maintain structural integrity.
128
+
129
+ ```tsx
130
+ const footerRows = [
131
+ {
132
+ columns: [
133
+ { colSpan: 2, cellRenderer: () => <strong>Aggregate Totals</strong> },
134
+ { colSpan: 1, cellRenderer: () => <span>Count: {data.length}</span> },
135
+ ]
136
+ }
137
+ ];
138
+
139
+ <ResponsiveTable
140
+ data={data}
141
+ columnDefinitions={columns}
142
+ footerRows={footerRows}
143
+ />
144
+ ```
145
+
146
+ ### 8. High-Volume Data: Asynchronous Infinite Scroll
147
+ For datasets that exceed standard memory constraints, the infinite scroll feature allows for incremental data fetching during vertical scrolling.
148
+
149
+ #### 1. Data Fetching Logic
150
+ Define an asynchronous function to retrieve subsequent data increments.
151
+
152
+ ```tsx
153
+ const fetchAdditionalData = async (currentDataset) => {
154
+ const pageIndex = Math.floor(currentDataset.length / 10) + 1;
155
+ const response = await api.users.get({ page: pageIndex });
156
+ return response.data; // Return null to indicate EOF
157
+ };
158
+ ```
159
+
160
+ #### 2. Component Configuration
161
+ Enable the feature by providing the `infiniteScrollProps` configuration.
162
+
163
+ ```tsx
164
+ import ResponsiveTable from 'jattac.libs.web.responsive-table';
165
+
166
+ const UserManagementTable = () => {
167
+ return (
168
+ <ResponsiveTable
169
+ data={[]}
170
+ columnDefinitions={columns}
171
+ maxHeight="600px" // Necessary for scroll event interception
172
+ infiniteScrollProps={{
173
+ onLoadMore: fetchAdditionalData,
174
+ hasMore: true,
175
+ loadingMoreComponent: <LoadingIndicator />,
176
+ noMoreDataComponent: <EndOfDataNotification />
177
+ }}
178
+ />
179
+ );
180
+ };
181
+ ```
182
+
183
+ ### 9. Internal Plugin Development
184
+ Extend the functional capabilities of the component by implementing the `IResponsiveTablePlugin` interface.
185
+
186
+ ```tsx
187
+ import { IResponsiveTablePlugin } from 'jattac.libs.web.responsive-table';
188
+
189
+ class CustomStylingPlugin<TData> implements IResponsiveTablePlugin<TData> {
190
+ public id = 'status-styler';
191
+
192
+ public getRowProps = (row: any) => {
193
+ if (row.isActive) return { className: 'row-active' };
194
+ return { className: 'row-inactive' };
195
+ };
196
+ }
197
+
198
+ // Integration
199
+ <ResponsiveTable
200
+ data={data}
201
+ columnDefinitions={columns}
202
+ plugins={[new CustomStylingPlugin()]}
203
+ />
204
+ ```
205
+
206
+ ---
207
+ **Previous:** [Overview](../README.md) | **Next:** [Functional Capabilities](./features.md)
@@ -0,0 +1,33 @@
1
+ # Functional Capabilities
2
+ ## Architectural Features of the ResponsiveTable Component
3
+
4
+ This document provides a high-level overview of the technical capabilities and architectural patterns integrated into the ResponsiveTable component.
5
+
6
+ ## Table of Contents
7
+ * [Automated Layout Orchestration](#automated-layout-orchestration)
8
+ * [Asynchronous Data Stream Support](#asynchronous-data-stream-support)
9
+ * [Persistent Plugin Lifecycle](#persistent-plugin-lifecycle)
10
+ * [Structural Alignment Management](#structural-alignment-management)
11
+
12
+ ---
13
+
14
+ [← Previous: Implementation Guide](./examples.md) | [Next: API Reference →](./api.md)
15
+
16
+ ### Automated Layout Orchestration
17
+ ResponsiveTable performs real-time viewport analysis to transition between a standard tabular structure and an optimized card-based mobile interface. This ensures data density is managed appropriately for the available screen real estate.
18
+ * [Implementation Example: Standard Tabular Implementation](./examples.md#1-standard-tabular-implementation)
19
+
20
+ ### Asynchronous Data Stream Support
21
+ Native integration for high-volume data sets via an infinite scrolling orchestrator. The component handles event interception, asynchronous state transitions, and subsequent data integration without disrupting the internal processing pipeline.
22
+ * [Implementation Example: Asynchronous Infinite Scroll](./examples.md#8-high-volume-data-asynchronous-infinite-scroll)
23
+
24
+ ### Persistent Plugin Lifecycle
25
+ The component features a robust internal lifecycle management system for plugins. State for sorting, filtering, and selection is persisted across re-renders and data updates using non-reactive references, optimizing performance and ensuring data consistency.
26
+ * [Implementation Example: Sortable Columns](./examples.md#2-implementing-sortable-columns)
27
+
28
+ ### Structural Alignment Management
29
+ Integrated logic for intelligent layout scaling automatically recalculates footer ranges. This ensures that column-level visibility toggles do not compromise the structural integrity or visual alignment of complex data grids.
30
+ * [Implementation Example: Column Visibility](./examples.md#6-programmatic-column-visibility-management)
31
+
32
+ ---
33
+ **Previous:** [Implementation Guide](./examples.md) | **Next:** [API Reference](./api.md)
package/package.json CHANGED
@@ -1,71 +1,117 @@
1
- {
2
- "name": "jattac.libs.web.responsive-table",
3
- "version": "0.7.5",
4
- "description": "A fully responsive, customizable, and lightweight React table component with a modern, mobile-first design and a powerful plugin system.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.es.js",
7
- "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "scripts": {
12
- "build": "rollup -c",
13
- "watch": "rollup -c -w",
14
- "lint": "eslint \"./{src,app}/**/*.{ts,tsx}\"",
15
- "test": "jest",
16
- "size": "size-limit",
17
- "prepare": "npm run build"
18
- },
19
- "keywords": [
20
- "react",
21
- "typescript",
22
- "table",
23
- "responsive",
24
- "component"
25
- ],
26
- "author": "Nyingi Maina",
27
- "license": "MIT",
28
- "peerDependencies": {
29
- "react": ">=18.2.0",
30
- "react-dom": ">=18.2.0",
31
- "typescript": ">=3.7.0"
32
- },
33
- "devDependencies": {
34
- "@rollup/plugin-commonjs": "^25.0.7",
35
- "@rollup/plugin-node-resolve": "^15.2.3",
36
- "@rollup/plugin-terser": "^0.4.4",
37
- "@rollup/plugin-typescript": "^11.1.5",
38
- "@size-limit/preset-small-lib": "^10.0.1",
39
- "@testing-library/jest-dom": "^6.9.1",
40
- "@testing-library/react": "^14.0.0",
41
- "@types/jest": "^30.0.0",
42
- "@types/react": "^18.2.33",
43
- "@types/react-dom": "^18.2.14",
44
- "@types/react-window": "^1.8.8",
45
- "@typescript-eslint/eslint-plugin": "^6.9.1",
46
- "@typescript-eslint/parser": "^6.9.1",
47
- "eslint": "^8.52.0",
48
- "eslint-config-prettier": "^9.0.0",
49
- "eslint-plugin-prettier": "^5.0.1",
50
- "eslint-plugin-react": "^7.33.2",
51
- "identity-obj-proxy": "^3.0.0",
52
- "jest": "^30.2.0",
53
- "jest-environment-jsdom": "^30.2.0",
54
- "postcss": "^8.4.31",
55
- "prettier": "^3.0.3",
56
- "react": "^18.2.0",
57
- "react-dom": "^18.2.0",
58
- "rollup": "^4.2.0",
59
- "rollup-plugin-copy": "^3.5.0",
60
- "rollup-plugin-delete": "^2.0.0",
61
- "rollup-plugin-generate-package-json": "^3.2.0",
62
- "rollup-plugin-peer-deps-external": "^2.2.4",
63
- "rollup-plugin-postcss": "^4.0.2",
64
- "size-limit": "^10.0.1",
65
- "ts-jest": "^29.4.6",
66
- "typescript": "^5.2.2"
67
- },
68
- "dependencies": {
69
- "tslib": "^2.6.2"
70
- }
71
- }
1
+ {
2
+ "name": "jattac.libs.web.responsive-table",
3
+ "version": "0.8.0",
4
+ "description": "A fully responsive, customizable, and lightweight React table component with a modern, mobile-first design and a powerful plugin system.",
5
+ "author": {
6
+ "name": "Nyingi Maina",
7
+ "email": "nyingi@jattac.com"
8
+ },
9
+ "license": "MIT",
10
+ "main": "./dist/index.js",
11
+ "module": "./dist/index.es.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.es.js",
17
+ "require": "./dist/index.js"
18
+ },
19
+ "./dist/*.css": "./dist/*.css"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "docs",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "sideEffects": [
28
+ "**/*.css",
29
+ "**/*.scss"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://nyingi.visualstudio.com/DefaultCollection/Jattac.Libs.Web.ResponsiveTable/_git/Jattac.Libs.Web.ResponsiveTable"
34
+ },
35
+ "bugs": {
36
+ "url": "https://nyingi.visualstudio.com/DefaultCollection/Jattac.Libs.Web.ResponsiveTable/_workitems"
37
+ },
38
+ "homepage": "https://nyingi.visualstudio.com/DefaultCollection/Jattac.Libs.Web.ResponsiveTable/_git/Jattac.Libs.Web.ResponsiveTable#readme",
39
+ "engines": {
40
+ "node": ">=18.0.0"
41
+ },
42
+ "scripts": {
43
+ "dev": "rollup -c -w",
44
+ "build": "rollup -c",
45
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
46
+ "lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
47
+ "format": "prettier --write \"src/**/*.{ts,tsx,css,md}\"",
48
+ "test": "jest",
49
+ "test:coverage": "jest --coverage",
50
+ "size": "size-limit",
51
+ "type-check": "tsc --noEmit",
52
+ "prepare": "npm run build",
53
+ "prepublishOnly": "npm run type-check && npm run lint && npm test"
54
+ },
55
+ "keywords": [
56
+ "react",
57
+ "typescript",
58
+ "table",
59
+ "datagrid",
60
+ "responsive",
61
+ "mobile-first",
62
+ "infinite-scroll",
63
+ "plugin-system"
64
+ ],
65
+ "peerDependencies": {
66
+ "react": ">=18.2.0",
67
+ "react-dom": ">=18.2.0"
68
+ },
69
+ "devDependencies": {
70
+ "@rollup/plugin-commonjs": "^25.0.7",
71
+ "@rollup/plugin-node-resolve": "^15.2.3",
72
+ "@rollup/plugin-terser": "^0.4.4",
73
+ "@rollup/plugin-typescript": "^11.1.5",
74
+ "@size-limit/preset-small-lib": "^10.0.1",
75
+ "@testing-library/jest-dom": "^6.9.1",
76
+ "@testing-library/react": "^14.0.0",
77
+ "@types/jest": "^30.0.0",
78
+ "@types/react": "^18.2.33",
79
+ "@types/react-dom": "^18.2.14",
80
+ "@types/react-window": "^1.8.8",
81
+ "@typescript-eslint/eslint-plugin": "^6.9.1",
82
+ "@typescript-eslint/parser": "^6.9.1",
83
+ "eslint": "^8.52.0",
84
+ "eslint-config-prettier": "^9.0.0",
85
+ "eslint-plugin-prettier": "^5.0.1",
86
+ "eslint-plugin-react": "^7.33.2",
87
+ "identity-obj-proxy": "^3.0.0",
88
+ "jest": "^30.2.0",
89
+ "jest-environment-jsdom": "^30.2.0",
90
+ "postcss": "^8.4.31",
91
+ "prettier": "^3.0.3",
92
+ "react": "^18.2.0",
93
+ "react-dom": "^18.2.0",
94
+ "rollup": "^4.2.0",
95
+ "rollup-plugin-copy": "^3.5.0",
96
+ "rollup-plugin-delete": "^2.0.0",
97
+ "rollup-plugin-generate-package-json": "^3.2.0",
98
+ "rollup-plugin-peer-deps-external": "^2.2.4",
99
+ "rollup-plugin-postcss": "^4.0.2",
100
+ "size-limit": "^10.0.1",
101
+ "ts-jest": "^29.4.6",
102
+ "typescript": "^5.2.2"
103
+ },
104
+ "dependencies": {
105
+ "tslib": "^2.6.2"
106
+ },
107
+ "jest": {
108
+ "preset": "ts-jest",
109
+ "testEnvironment": "jsdom",
110
+ "moduleNameMapper": {
111
+ "\\.(css|less|sass|scss)$": "identity-obj-proxy"
112
+ },
113
+ "setupFilesAfterEnv": [
114
+ "<rootDir>/jest-setup.ts"
115
+ ]
116
+ }
117
+ }