@agile-team/mach-table-react 0.18.1 → 0.19.1

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
@@ -4,7 +4,7 @@
4
4
 
5
5
  # @agile-team/mach-table-react
6
6
 
7
- Official React 18+ adapter for MachTable 0.18. It provides a generic `<MachTable>`, full app/route configuration, advanced-filter aware remote query, conflict-aware editing workflows, persistent named views, a cohesive controller, optional and persistent column resizing, a standard toolbar, in-place React cell refresh, latest-closure event handling and StrictMode-safe cleanup. `RobotGrid` remains a deprecated 0.x alias.
7
+ Official React 18+ adapter for MachTable 0.19. It provides a generic `<MachTable>`, full app/route configuration, advanced-filter aware remote query, conflict-aware editing workflows, persistent named views, a cohesive controller, optional and persistent column resizing, random-access remote blocks, batched/domain APIs, optional Worker processing, a standard toolbar, in-place React cell refresh, latest-closure event handling and StrictMode-safe cleanup. `RobotGrid` remains a deprecated 0.x alias.
8
8
 
9
9
  ## Install
10
10
 
@@ -12,6 +12,12 @@ Official React 18+ adapter for MachTable 0.18. It provides a generic `<MachTable
12
12
  pnpm add @agile-team/mach-table-react
13
13
  ```
14
14
 
15
+ Optional large local-data Worker helpers use the same installed package but a separate chunk:
16
+
17
+ ```ts
18
+ import { createWorkerDataProcessor } from "@agile-team/mach-table-react/worker";
19
+ ```
20
+
15
21
  Import the stylesheet once from your application entry:
16
22
 
17
23
  ```ts
@@ -65,6 +65,7 @@
65
65
  -webkit-font-smoothing: antialiased;
66
66
  -moz-osx-font-smoothing: grayscale;
67
67
  font-variant-numeric: tabular-nums;
68
+ contain: layout style;
68
69
  }
69
70
 
70
71
  .mach-root.mach-dom-layout--auto-height {
@@ -562,6 +563,29 @@
562
563
  line-height: calc(var(--mach-row-h) - 2px);
563
564
  }
564
565
 
566
+ .mach-cell--loading {
567
+ pointer-events: none;
568
+ }
569
+
570
+ .mach-cell-loading-bar {
571
+ display: block;
572
+ height: 8px;
573
+ max-width: 132px;
574
+ border-radius: 999px;
575
+ background: linear-gradient(90deg, var(--mach-row-hover-bg), var(--mach-border-color), var(--mach-row-hover-bg));
576
+ background-size: 200% 100%;
577
+ animation: mach-cell-loading 1.25s ease-in-out infinite;
578
+ }
579
+
580
+ @keyframes mach-cell-loading {
581
+ from { background-position: 200% 0; }
582
+ to { background-position: -200% 0; }
583
+ }
584
+
585
+ @media (prefers-reduced-motion: reduce) {
586
+ .mach-cell-loading-bar { animation: none; }
587
+ }
588
+
565
589
  .mach-cell--num {
566
590
  justify-content: flex-end;
567
591
  }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _worker = require('@agile-team/mach-table/worker'); _createStarExport(_worker);
2
+ //# sourceMappingURL=worker.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["d:\\office-project\\wl\\MachTable\\packages\\react\\dist\\worker.cjs"],"names":[],"mappings":"AAAA,obAA0C","file":"D:\\office-project\\wl\\MachTable\\packages\\react\\dist\\worker.cjs","sourcesContent":[null]}
@@ -0,0 +1 @@
1
+ export * from '@agile-team/mach-table/worker';
@@ -0,0 +1 @@
1
+ export * from '@agile-team/mach-table/worker';
package/dist/worker.js ADDED
@@ -0,0 +1,2 @@
1
+ export*from"@agile-team/mach-table/worker";
2
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/worker.ts"],"sourcesContent":["export * from \"@agile-team/mach-table/worker\";\n"],"mappings":"AAAA,WAAc","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agile-team/mach-table-react",
3
- "version": "0.18.1",
3
+ "version": "0.19.1",
4
4
  "description": "Official React 18+ adapter for the MachTable enterprise data grid",
5
5
  "keywords": [
6
6
  "react",
@@ -51,6 +51,16 @@
51
51
  "default": "./dist/workflows.cjs"
52
52
  }
53
53
  },
54
+ "./worker": {
55
+ "import": {
56
+ "types": "./dist/worker.d.ts",
57
+ "default": "./dist/worker.js"
58
+ },
59
+ "require": {
60
+ "types": "./dist/worker.d.cts",
61
+ "default": "./dist/worker.cjs"
62
+ }
63
+ },
54
64
  "./styles.css": {
55
65
  "types": "./dist/mach-table.css.d.ts",
56
66
  "default": "./dist/mach-table.css"
@@ -67,7 +77,7 @@
67
77
  "**/*.css"
68
78
  ],
69
79
  "dependencies": {
70
- "@agile-team/mach-table": "0.18.1"
80
+ "@agile-team/mach-table": "0.19.1"
71
81
  },
72
82
  "peerDependencies": {
73
83
  "react": ">=18.0.0",
@@ -82,5 +92,6 @@
82
92
  "typecheck": "tsc --noEmit",
83
93
  "test": "vitest run",
84
94
  "test:coverage": "vitest run --coverage"
85
- }
95
+ },
96
+ "readme": "<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/ChenyCHENYU/MachTable/main/assets/mach-table-logo.svg\" alt=\"MachTable\" width=\"760\" />\n</p>\n\n# @agile-team/mach-table-react\n\nOfficial React 18+ adapter for MachTable 0.19. It provides a generic `<MachTable>`, full app/route configuration, advanced-filter aware remote query, conflict-aware editing workflows, persistent named views, a cohesive controller, optional and persistent column resizing, random-access remote blocks, batched/domain APIs, optional Worker processing, a standard toolbar, in-place React cell refresh, latest-closure event handling and StrictMode-safe cleanup. `RobotGrid` remains a deprecated 0.x alias.\n\n## Install\n\n```bash\npnpm add @agile-team/mach-table-react\n```\n\nOptional large local-data Worker helpers use the same installed package but a separate chunk:\n\n```ts\nimport { createWorkerDataProcessor } from \"@agile-team/mach-table-react/worker\";\n```\n\nImport the stylesheet once from your application entry:\n\n```ts\nimport \"@agile-team/mach-table-react/styles.css\";\n```\n\n## Direct import\n\n```tsx\nimport { useMemo } from \"react\";\nimport { MachTable, useMachGrid, type ColDef } from \"@agile-team/mach-table-react\";\n\ninterface Row { id: string; name: string }\n\nexport function App({ rows }: { rows: Row[] }) {\n const grid = useMachGrid<Row>();\n const columns = useMemo<ColDef<Row>[]>(\n () => [{ field: \"name\", headerName: \"Name\", flex: 1 }],\n []\n );\n\n return (\n <div style={{ height: 520 }}>\n <MachTable<Row>\n apiRef={grid.apiRef}\n rowData={rows}\n columnDefs={columns}\n rowKey=\"id\"\n stateKey=\"customer-list\"\n enableColumnResize\n />\n </div>\n );\n}\n```\n\n## Route-level lazy loading\n\nReact intentionally has no global component registry. MachTable provides a default component export so the standard `React.lazy` API works without a mapping wrapper:\n\n```tsx\nimport { lazy, Suspense } from \"react\";\n\nconst MachTable = lazy(() => import(\"@agile-team/mach-table-react\"));\n\nexport function OrdersPage() {\n return (\n <Suspense fallback={<div>Loading table...</div>}>\n <MachTable columnDefs={columns} rowData={rows} />\n </Suspense>\n );\n}\n```\n\nWhen the page itself is route-lazy, a normal named import inside that page already produces the same route-level split. Use `React.lazy` when the grid should be split independently from the page.\n\n## Application and route defaults\n\nKeep table conventions in one file. Providers can be nested; the nearest configuration is merged, named presets are reusable, and explicit table props win:\n\n```tsx\n// mach-table.config.ts\nimport { defineMachTableConfig, defineMachTablePreset } from \"@agile-team/mach-table-react\";\nexport default defineMachTableConfig({\n defaults: {\n size: \"compact\",\n enableColumnResize: true,\n defaultColDef: { sortable: true, resizable: true, filter: true }\n },\n defaultPreset: \"list\",\n presets: {\n list: defineMachTablePreset({ pagination: false }),\n crud: defineMachTablePreset({ rowSelection: \"multiple\", editType: \"fullRow\" })\n }\n});\n\n// main.tsx\n<MachTableProvider config={machTableConfig}>\n <App />\n</MachTableProvider>\n```\n\nThe adapter installs the matching `@agile-team/mach-table` core automatically and re-exports its complete API and types. Only `react >= 18` and `react-dom >= 18` remain peer dependencies supplied by the host application.\n\n## Remote lists and standard workflows\n\nImport heavier page workflows from the tree-shakeable subpath:\n\n```tsx\nimport { useMachTableQuery, useMachTableController } from \"@agile-team/mach-table-react/workflows\";\nimport { MachTable, MachTableToolbar } from \"@agile-team/mach-table-react\";\n\nconst query = useMachTableQuery({\n query: filters,\n queryKey: filters,\n rowKey: \"id\",\n request: orderApi.page,\n mode: \"manual\"\n});\nconst controller = useMachTableController({ query });\n\n<MachTableToolbar\n api={controller.table.api}\n commands={controller.commands}\n search={controller.search}\n onSearchChange={controller.setSearch}\n loading={controller.busy}\n/>;\n<MachTable apiRef={controller.table.apiRef} {...controller.bindings} />;\n```\n\nThe query hook cancels superseded requests, ignores stale responses, forwards nested advanced filters, exposes an error overlay and supports cross-page or select-all-matching selection. `useMachTableEditing()` adds dirty state, detailed partial-save/conflict results, guarded saves, conflict resolution, rollback and reveal helpers.\n\n```tsx\nconst editing = useMachTableEditing(grid, { guardBeforeUnload: true });\nconst result = await editing.saveDetailed(orderApi.saveChanges);\nif (result.conflicts.length) editing.reveal(result.conflicts[0].rowId);\n\nasync function saveCurrentView() {\n const api = grid.apiRef.current;\n if (!api) return;\n const views = createGridViewManager(api, {\n scope: `${tenantId}:${userId}:orders`\n });\n await views.save(\"My pending orders\");\n}\n```\n\nSee the [advanced filter](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/advanced-filter.md), [named views](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/saved-views.md), and [batch save](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/batch-save.md) guides.\n\n## Cell and full-row editing\n\n```tsx\nimport { MachTable, rowActionsColumn } from \"@agile-team/mach-table-react\";\n\nconst columns = [\n { field: \"name\", editable: true },\n { field: \"age\", editable: true, cellEditor: \"number\" },\n rowActionsColumn({ onView, onDelete, overflow: \"drawer\" })\n];\n\n<MachTable editType=\"fullRow\" columnDefs={columns} rowData={rows} />;\n```\n\nCell mode is the default and provides a pencil plus inline confirm/cancel controls. Use `editableIndicator=\"always\" | \"hover\" | \"none\"` to match the page density.\n\nDocumentation: [React guide](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/react.md) · [Enterprise integration](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/enterprise-integration.md) · [Next.js / SSR](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/ssr.md)\n\nSource-available © ChenyCHENYU (Agile Team). Any use requires prior written authorization. See the [license](https://github.com/ChenyCHENYU/MachTable/blob/main/LICENSE) and [authorization process](https://github.com/ChenyCHENYU/MachTable/blob/main/LICENSING.md).\n"
86
97
  }