@agile-team/mach-table-react 0.4.1 → 0.13.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/LICENSE +110 -21
- package/README.md +64 -3
- package/dist/index.cjs +1 -203
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -3
- package/dist/index.d.ts +26 -3
- package/dist/index.js +1 -174
- package/dist/index.js.map +1 -1
- package/dist/mach-table.css +410 -3
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,21 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
MachTable Source-Available License 1.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ChenyCHENYU (Agile Team). All rights reserved.
|
|
4
|
+
|
|
5
|
+
IMPORTANT: The source code is publicly visible for review, but it is not
|
|
6
|
+
open-source software as defined by the Open Source Initiative. Except for the
|
|
7
|
+
limited inspection permission below, no permission is granted unless the
|
|
8
|
+
copyright holder gives you prior written authorization.
|
|
9
|
+
|
|
10
|
+
1. Definitions
|
|
11
|
+
|
|
12
|
+
"Software" means MachTable and all source code, object code, packages,
|
|
13
|
+
documentation, examples, designs, assets, and other materials distributed with
|
|
14
|
+
this license.
|
|
15
|
+
|
|
16
|
+
"Licensor" means ChenyCHENYU (Agile Team), the copyright holder of the
|
|
17
|
+
Software.
|
|
18
|
+
|
|
19
|
+
"Written Authorization" means a durable written permission issued directly by
|
|
20
|
+
the Licensor that identifies the licensee and the permitted scope, purpose,
|
|
21
|
+
environment, term, and any other applicable conditions.
|
|
22
|
+
|
|
23
|
+
2. Limited Inspection Permission
|
|
24
|
+
|
|
25
|
+
You may view the Software on the repository hosting service solely to inspect
|
|
26
|
+
and evaluate it, to link to its public repository, to discuss it, and to submit
|
|
27
|
+
good-faith issue reports. This limited permission does not include permission
|
|
28
|
+
to use, run, build, compile, copy, download for reuse, install, integrate,
|
|
29
|
+
modify, create derivative works from, deploy, distribute, sublicense, sell,
|
|
30
|
+
lease, provide as a service, or otherwise exploit the Software.
|
|
31
|
+
|
|
32
|
+
3. Authorization Required
|
|
33
|
+
|
|
34
|
+
Any use beyond Section 2 requires the Licensor's prior Written Authorization.
|
|
35
|
+
This requirement applies to personal, educational, research, governmental,
|
|
36
|
+
non-profit, internal, evaluation, testing, development, staging, production,
|
|
37
|
+
and commercial use. Possession of a copy, cloning the repository, downloading
|
|
38
|
+
an npm package, receiving the Software from another person, or submitting a
|
|
39
|
+
contribution does not grant any additional rights.
|
|
40
|
+
|
|
41
|
+
The Licensor may grant separate commercial or non-commercial terms in a
|
|
42
|
+
written agreement. If such an agreement conflicts with this license, that
|
|
43
|
+
agreement controls only for the licensee and scope identified in it.
|
|
44
|
+
|
|
45
|
+
4. Restrictions
|
|
46
|
+
|
|
47
|
+
Without prior Written Authorization, you must not, directly or indirectly:
|
|
48
|
+
|
|
49
|
+
a. use, execute, build, compile, install, test, or integrate the Software;
|
|
50
|
+
b. copy, reproduce, modify, adapt, translate, or create derivative works;
|
|
51
|
+
c. publish, distribute, sublicense, sell, rent, lease, transfer, host, or make
|
|
52
|
+
the Software available to any third party;
|
|
53
|
+
d. use the Software to provide a hosted, managed, consulting, outsourcing,
|
|
54
|
+
software-as-a-service, or other service;
|
|
55
|
+
e. remove or alter copyright, authorization, trademark, attribution, or other
|
|
56
|
+
proprietary notices; or
|
|
57
|
+
f. represent the Software as open source or represent that you have received
|
|
58
|
+
authorization when you have not.
|
|
59
|
+
|
|
60
|
+
5. Contributions
|
|
61
|
+
|
|
62
|
+
Submitting a patch, pull request, code, documentation, design, or other
|
|
63
|
+
material to the project does not authorize you to use the Software. Unless a
|
|
64
|
+
separate written contributor agreement applies, by intentionally submitting a
|
|
65
|
+
contribution you represent that you have the right to submit it and grant the
|
|
66
|
+
Licensor a perpetual, worldwide, irrevocable, transferable, sublicensable,
|
|
67
|
+
royalty-free license to use, reproduce, modify, create derivative works from,
|
|
68
|
+
distribute, license, and relicense that contribution as part of the Software.
|
|
69
|
+
|
|
70
|
+
6. Ownership and Trademarks
|
|
71
|
+
|
|
72
|
+
The Software is licensed, not sold. The Licensor and applicable contributors
|
|
73
|
+
retain all right, title, and interest in the Software. No trademark, service
|
|
74
|
+
mark, trade name, logo, or branding rights are granted by this license.
|
|
75
|
+
|
|
76
|
+
7. Termination
|
|
77
|
+
|
|
78
|
+
Any permission granted under this license terminates automatically upon breach.
|
|
79
|
+
On termination, you must immediately stop all use and destroy all copies in
|
|
80
|
+
your possession or control, except where retention is required by law. Sections
|
|
81
|
+
4 through 9 survive termination.
|
|
82
|
+
|
|
83
|
+
8. Disclaimer
|
|
84
|
+
|
|
85
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" AND
|
|
86
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
|
88
|
+
NON-INFRINGEMENT.
|
|
89
|
+
|
|
90
|
+
9. Limitation of Liability
|
|
91
|
+
|
|
92
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSOR AND CONTRIBUTORS WILL NOT
|
|
93
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
94
|
+
CONSEQUENTIAL, OR OTHER DAMAGES, OR FOR LOSS OF DATA, PROFITS, REVENUE,
|
|
95
|
+
GOODWILL, OR BUSINESS INTERRUPTION, ARISING FROM OR RELATED TO THE SOFTWARE OR
|
|
96
|
+
THIS LICENSE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
97
|
+
|
|
98
|
+
10. Contact and Authorization
|
|
99
|
+
|
|
100
|
+
See LICENSING.md in the repository for the authorization request process. No
|
|
101
|
+
request, discussion, issue, payment, or contribution constitutes authorization
|
|
102
|
+
unless and until the Licensor issues explicit Written Authorization.
|
|
103
|
+
|
|
104
|
+
中文说明(仅为阅读便利;如有冲突,以英文条款为准)
|
|
105
|
+
|
|
106
|
+
本项目源代码公开可查看,但不是 OSI 定义下的开源软件。除查看、链接、
|
|
107
|
+
讨论和善意提交问题外,任何个人、教育、研究、公益、政府、内部、测试、
|
|
108
|
+
开发、生产或商业用途,均须事先取得作者明确的书面授权。未经授权,不得
|
|
109
|
+
运行、构建、复制、修改、集成、部署、分发、转授权、销售、出租、托管或
|
|
110
|
+
以服务形式提供本软件。公开仓库、克隆代码或下载 npm 包不代表获得授权。
|
package/README.md
CHANGED
|
@@ -4,16 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
# @agile-team/mach-table-react
|
|
6
6
|
|
|
7
|
-
Official React 18+ adapter for MachTable. It provides `<MachTable
|
|
7
|
+
Official React 18+ adapter for MachTable 0.13. It provides `<MachTable>`, `MachTableProvider`, `useMachGrid`, React cell/detail renderer factories, the complete workbench/lazy-tree/semantic-column/action/state Core API, latest-closure event handling and StrictMode-safe cleanup. `RobotGrid` remains a deprecated 0.x alias.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
pnpm add @agile-team/mach-table-react
|
|
11
13
|
```
|
|
12
14
|
|
|
15
|
+
Import the stylesheet once from your application entry:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import "@agile-team/mach-table-react/styles.css";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Direct import
|
|
22
|
+
|
|
13
23
|
```tsx
|
|
14
24
|
import { useMemo } from "react";
|
|
15
25
|
import { MachTable, useMachGrid, type ColDef } from "@agile-team/mach-table-react";
|
|
16
|
-
import "@agile-team/mach-table-react/styles.css";
|
|
17
26
|
|
|
18
27
|
interface Row { id: string; name: string }
|
|
19
28
|
|
|
@@ -37,8 +46,60 @@ export function App({ rows }: { rows: Row[] }) {
|
|
|
37
46
|
}
|
|
38
47
|
```
|
|
39
48
|
|
|
49
|
+
## Route-level lazy loading
|
|
50
|
+
|
|
51
|
+
React intentionally has no global component registry. MachTable provides a default component export so the standard `React.lazy` API works without a mapping wrapper:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { lazy, Suspense } from "react";
|
|
55
|
+
|
|
56
|
+
const MachTable = lazy(() => import("@agile-team/mach-table-react"));
|
|
57
|
+
|
|
58
|
+
export function OrdersPage() {
|
|
59
|
+
return (
|
|
60
|
+
<Suspense fallback={<div>Loading table...</div>}>
|
|
61
|
+
<MachTable columnDefs={columns} rowData={rows} />
|
|
62
|
+
</Suspense>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
When 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.
|
|
68
|
+
|
|
69
|
+
## Application and route defaults
|
|
70
|
+
|
|
71
|
+
Providers can be nested; the nearest defaults are merged and table props win:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { MachTableProvider } from "@agile-team/mach-table-react";
|
|
75
|
+
|
|
76
|
+
<MachTableProvider defaults={{
|
|
77
|
+
size: "compact",
|
|
78
|
+
pagination: false,
|
|
79
|
+
defaultColDef: { sortable: true, resizable: true, filter: true }
|
|
80
|
+
}}>
|
|
81
|
+
<App />
|
|
82
|
+
</MachTableProvider>
|
|
83
|
+
```
|
|
84
|
+
|
|
40
85
|
The 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.
|
|
41
86
|
|
|
87
|
+
## Cell and full-row editing
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { MachTable, rowActionsColumn } from "@agile-team/mach-table-react";
|
|
91
|
+
|
|
92
|
+
const columns = [
|
|
93
|
+
{ field: "name", editable: true },
|
|
94
|
+
{ field: "age", editable: true, cellEditor: "number" },
|
|
95
|
+
rowActionsColumn({ onView, onDelete, overflow: "drawer" })
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
<MachTable editType="fullRow" columnDefs={columns} rowData={rows} />;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Cell mode is the default and provides a pencil plus inline confirm/cancel controls. Use `editableIndicator="always" | "hover" | "none"` to match the page density.
|
|
102
|
+
|
|
42
103
|
Documentation: [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)
|
|
43
104
|
|
|
44
|
-
|
|
105
|
+
Source-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).
|
package/dist/index.cjs
CHANGED
|
@@ -1,204 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var index_exports = {};
|
|
23
|
-
__export(index_exports, {
|
|
24
|
-
MachTable: () => RobotGrid,
|
|
25
|
-
RobotGrid: () => RobotGrid,
|
|
26
|
-
reactCellRenderer: () => reactCellRenderer,
|
|
27
|
-
reactDetailRenderer: () => reactDetailRenderer,
|
|
28
|
-
useMachGrid: () => useMachGrid
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
|
|
32
|
-
// src/RobotGrid.tsx
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
var import_mach_table = require("@agile-team/mach-table");
|
|
35
|
-
var UPDATABLE_KEYS = import_mach_table.DIRECT_GRID_OPTION_KEYS.filter((key) => key !== "className");
|
|
36
|
-
function RobotGrid(props) {
|
|
37
|
-
const { className, style, apiRef } = props;
|
|
38
|
-
const hostRef = (0, import_react.useRef)(null);
|
|
39
|
-
const gridApiRef = (0, import_react.useRef)(null);
|
|
40
|
-
const propsRef = (0, import_react.useRef)(props);
|
|
41
|
-
propsRef.current = props;
|
|
42
|
-
(0, import_react.useEffect)(() => {
|
|
43
|
-
const host = hostRef.current;
|
|
44
|
-
if (!host) return;
|
|
45
|
-
const initial = propsRef.current;
|
|
46
|
-
const options = {};
|
|
47
|
-
for (const key of Object.keys(initial)) {
|
|
48
|
-
if (key === "className" || key === "gridClassName" || key === "style" || key === "apiRef") continue;
|
|
49
|
-
if (key.startsWith("on")) continue;
|
|
50
|
-
options[key] = initial[key];
|
|
51
|
-
}
|
|
52
|
-
if (initial.gridClassName !== void 0) options.className = initial.gridClassName;
|
|
53
|
-
for (const eventType of import_mach_table.EVENT_TYPES) {
|
|
54
|
-
const handlerKey = `on${eventType.charAt(0).toUpperCase()}${eventType.slice(1)}`;
|
|
55
|
-
options[handlerKey] = (event) => {
|
|
56
|
-
const latest = propsRef.current;
|
|
57
|
-
const handler = latest[handlerKey];
|
|
58
|
-
if (typeof handler === "function") handler(event);
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const api = (0, import_mach_table.createGrid)(host, options);
|
|
62
|
-
gridApiRef.current = api;
|
|
63
|
-
return () => {
|
|
64
|
-
api.destroy();
|
|
65
|
-
gridApiRef.current = null;
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
(0, import_react.useEffect)(() => {
|
|
69
|
-
if (!apiRef) return;
|
|
70
|
-
const assigned = gridApiRef.current;
|
|
71
|
-
apiRef.current = assigned;
|
|
72
|
-
return () => {
|
|
73
|
-
if (apiRef.current === assigned) apiRef.current = null;
|
|
74
|
-
};
|
|
75
|
-
}, [apiRef]);
|
|
76
|
-
const rowDataReady = (0, import_react.useRef)(false);
|
|
77
|
-
(0, import_react.useEffect)(() => {
|
|
78
|
-
if (!rowDataReady.current) {
|
|
79
|
-
rowDataReady.current = true;
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
gridApiRef.current?.setRowData(props.rowData);
|
|
83
|
-
}, [props.rowData]);
|
|
84
|
-
const columnDefsReady = (0, import_react.useRef)(false);
|
|
85
|
-
(0, import_react.useEffect)(() => {
|
|
86
|
-
if (!columnDefsReady.current) {
|
|
87
|
-
columnDefsReady.current = true;
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
gridApiRef.current?.setColumnDefs(props.columnDefs);
|
|
91
|
-
}, [props.columnDefs]);
|
|
92
|
-
const quickFilterReady = (0, import_react.useRef)(false);
|
|
93
|
-
(0, import_react.useEffect)(() => {
|
|
94
|
-
if (!quickFilterReady.current) {
|
|
95
|
-
quickFilterReady.current = true;
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
gridApiRef.current?.setQuickFilter(props.quickFilterText);
|
|
99
|
-
}, [props.quickFilterText]);
|
|
100
|
-
const gridClassNameReady = (0, import_react.useRef)(false);
|
|
101
|
-
(0, import_react.useEffect)(() => {
|
|
102
|
-
if (!gridClassNameReady.current) {
|
|
103
|
-
gridClassNameReady.current = true;
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
gridApiRef.current?.updateOptions({ className: props.gridClassName });
|
|
107
|
-
}, [props.gridClassName]);
|
|
108
|
-
const optionValues = UPDATABLE_KEYS.map((key) => props[key]);
|
|
109
|
-
const previousOptionValues = (0, import_react.useRef)(null);
|
|
110
|
-
(0, import_react.useEffect)(() => {
|
|
111
|
-
const previous = previousOptionValues.current;
|
|
112
|
-
previousOptionValues.current = optionValues;
|
|
113
|
-
if (!previous) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const changed = {};
|
|
117
|
-
optionValues.forEach((value, index) => {
|
|
118
|
-
if (!Object.is(value, previous[index])) changed[UPDATABLE_KEYS[index]] = value;
|
|
119
|
-
});
|
|
120
|
-
if (Object.keys(changed).length > 0) {
|
|
121
|
-
gridApiRef.current?.updateOptions(changed);
|
|
122
|
-
}
|
|
123
|
-
}, optionValues);
|
|
124
|
-
return (0, import_react.createElement)("div", {
|
|
125
|
-
ref: hostRef,
|
|
126
|
-
className: `mach-react-host ${className ?? ""}`.trim() || void 0,
|
|
127
|
-
style
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/useMachGrid.ts
|
|
132
|
-
var import_react2 = require("react");
|
|
133
|
-
function useMachGrid() {
|
|
134
|
-
const [api, setApi] = (0, import_react2.useState)(null);
|
|
135
|
-
const apiRef = (0, import_react2.useMemo)(() => {
|
|
136
|
-
let current = null;
|
|
137
|
-
return Object.defineProperty({}, "current", {
|
|
138
|
-
enumerable: true,
|
|
139
|
-
get: () => current,
|
|
140
|
-
set: (next) => {
|
|
141
|
-
if (next === current) return;
|
|
142
|
-
current = next;
|
|
143
|
-
setApi(next);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}, []);
|
|
147
|
-
return { apiRef, api };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/adapters.ts
|
|
151
|
-
var import_react3 = require("react");
|
|
152
|
-
var import_client = require("react-dom/client");
|
|
153
|
-
function reactCellRenderer(Component) {
|
|
154
|
-
return (params) => {
|
|
155
|
-
const host = document.createElement("div");
|
|
156
|
-
host.className = "mach-cell-react";
|
|
157
|
-
host.style.width = "100%";
|
|
158
|
-
const root = (0, import_client.createRoot)(host);
|
|
159
|
-
root.render((0, import_react3.createElement)(Component, params));
|
|
160
|
-
let destroyed = false;
|
|
161
|
-
return {
|
|
162
|
-
el: host,
|
|
163
|
-
destroy: () => {
|
|
164
|
-
if (destroyed) return;
|
|
165
|
-
destroyed = true;
|
|
166
|
-
window.setTimeout(() => {
|
|
167
|
-
root.unmount();
|
|
168
|
-
}, 0);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
function reactDetailRenderer(Component) {
|
|
174
|
-
return (params) => {
|
|
175
|
-
const host = document.createElement("div");
|
|
176
|
-
host.style.height = "100%";
|
|
177
|
-
const root = (0, import_client.createRoot)(host);
|
|
178
|
-
root.render((0, import_react3.createElement)(Component, params));
|
|
179
|
-
let destroyed = false;
|
|
180
|
-
return {
|
|
181
|
-
el: host,
|
|
182
|
-
destroy: () => {
|
|
183
|
-
if (destroyed) return;
|
|
184
|
-
destroyed = true;
|
|
185
|
-
window.setTimeout(() => {
|
|
186
|
-
root.unmount();
|
|
187
|
-
}, 0);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/index.ts
|
|
194
|
-
__reExport(index_exports, require("@agile-team/mach-table"), module.exports);
|
|
195
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
196
|
-
0 && (module.exports = {
|
|
197
|
-
MachTable,
|
|
198
|
-
RobotGrid,
|
|
199
|
-
reactCellRenderer,
|
|
200
|
-
reactDetailRenderer,
|
|
201
|
-
useMachGrid,
|
|
202
|
-
...require("@agile-team/mach-table")
|
|
203
|
-
});
|
|
1
|
+
"use strict";var x=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var F=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},v=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of _(r))!$.call(e,n)&&n!==t&&x(e,n,{get:()=>r[n],enumerable:!(a=I(r,n))||a.enumerable});return e},f=(e,r,t)=>(v(e,r,"default"),t&&v(t,r,"default"));var K=e=>v(x({},"__esModule",{value:!0}),e);var u={};F(u,{MachTable:()=>D,MachTableProvider:()=>k,RobotGrid:()=>V,default:()=>q,reactCellRenderer:()=>U,reactDetailRenderer:()=>H,useMachGrid:()=>S,useMachTableDefaults:()=>R});module.exports=K(u);var o=require("react"),l=require("@agile-team/mach-table");var d=require("react"),j=require("@agile-team/mach-table"),w=(0,d.createContext)({});function k({defaults:e,children:r}){let t=(0,d.useContext)(w),a=(0,d.useMemo)(()=>(0,j.createMachTablePreset)(t,e),[t,e]);return(0,d.createElement)(w.Provider,{value:a},r)}function R(){return(0,d.useContext)(w)}function Y(e,r){let t={};for(let a of l.GRID_OPTION_KEYS){if(a==="className")continue;let n=a==="ariaLabel"?e.gridAriaLabel:a==="ariaLabelledBy"?e.gridAriaLabelledBy:a==="ariaDescribedBy"?e.gridAriaDescribedBy:e[a];n!==void 0&&(t[a]=n)}return e.gridClassName!==void 0&&(t.className=e.gridClassName),(0,l.createMachTablePreset)(r,t)}function D(e){let{className:r,style:t,apiRef:a}=e,n=(0,o.useRef)(null),c=(0,o.useRef)(null),s=(0,o.useRef)(e);s.current=e;let E=R(),P=[E,...l.GRID_OPTION_KEYS.map(i=>i==="className"?e.gridClassName:i==="ariaLabel"?e.gridAriaLabel:i==="ariaLabelledBy"?e.gridAriaLabelledBy:i==="ariaDescribedBy"?e.gridAriaDescribedBy:e[i])],m=(0,o.useRef)(null);(!m.current||m.current.inputs.length!==P.length||P.some((i,p)=>!Object.is(i,m.current?.inputs[p])))&&(m.current={inputs:P,options:Y(e,E)});let G=m.current.options,g=(0,o.useRef)(G);g.current=G,(0,o.useEffect)(()=>{let i=n.current;if(!i)return;let p={...g.current};for(let b of l.EVENT_TYPES){let O=`on${b.charAt(0).toUpperCase()}${b.slice(1)}`;p[O]=B=>{let A=g.current[O];typeof A=="function"&&A(B);let C=s.current[O];typeof C=="function"&&C!==A&&C(B)}}let T=(0,l.createGrid)(i,p);return c.current=T,()=>{T.destroy(),c.current=null}},[]),(0,o.useEffect)(()=>{if(!a)return;let i=c.current;return a.current=i,()=>{a.current===i&&(a.current=null)}},[a]);let M=l.GRID_OPTION_KEYS.map(i=>G[i]),L=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let i=L.current;if(L.current=M,!i)return;let p={};M.forEach((T,b)=>{Object.is(T,i[b])||(p[l.GRID_OPTION_KEYS[b]]=T)}),Object.keys(p).length>0&&c.current?.updateOptions(p)},M),(0,o.createElement)("div",{ref:n,className:`mach-react-host ${r??""}`.trim()||void 0,style:t,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],"aria-describedby":e["aria-describedby"]})}var V=D;var y=require("react");function S(){let[e,r]=(0,y.useState)(null),[t,a]=(0,y.useState)(!1);return{apiRef:(0,y.useMemo)(()=>{let c=null;return Object.defineProperty({},"current",{enumerable:!0,get:()=>c,set:s=>{s!==c&&(c=s,r(s),a(!1),s&&s.whenReady().then(()=>{c===s&&!s.isDestroyed()&&a(!0)}))}})},[]),api:e,ready:t}}var h=require("react"),N=require("react-dom/client");function U(e){return r=>{let t=document.createElement("div");t.className="mach-cell-react",t.style.width="100%";let a=(0,N.createRoot)(t);a.render((0,h.createElement)(e,r));let n=!1;return{el:t,destroy:()=>{n||(n=!0,window.setTimeout(()=>{a.unmount()},0))}}}}function H(e){return r=>{let t=document.createElement("div");t.style.height="100%";let a=(0,N.createRoot)(t);a.render((0,h.createElement)(e,r));let n=!1;return{el:t,destroy:()=>{n||(n=!0,window.setTimeout(()=>{a.unmount()},0))}}}}f(u,require("@agile-team/mach-table"),module.exports);var q=D;0&&(module.exports={MachTable,MachTableProvider,RobotGrid,reactCellRenderer,reactDetailRenderer,useMachGrid,useMachTableDefaults,...require("@agile-team/mach-table")});
|
|
204
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/RobotGrid.tsx","../src/useMachGrid.ts","../src/adapters.ts"],"sourcesContent":["export { RobotGrid } from \"./RobotGrid\";\nexport { RobotGrid as MachTable } from \"./RobotGrid\";\nexport type { RobotGridReactProps } from \"./RobotGrid\";\nexport { useMachGrid } from \"./useMachGrid\";\nexport type { UseMachGridReturn } from \"./useMachGrid\";\nexport { reactCellRenderer, reactDetailRenderer } from \"./adapters\";\nexport type { ReactCellRendererProps, ReactDetailProps } from \"./adapters\";\nexport * from \"@agile-team/mach-table\";\n","import {\n createElement,\n useEffect,\n useRef,\n type CSSProperties,\n type MutableRefObject\n} from \"react\";\nimport { createGrid, DIRECT_GRID_OPTION_KEYS, EVENT_TYPES } from \"@agile-team/mach-table\";\nimport type { GridApi, GridOptions } from \"@agile-team/mach-table\";\n\nexport type RobotGridReactProps<TData = any> = Omit<GridOptions<TData>, \"className\"> & {\n /** CSS class applied to the React host element. */\n className?: string;\n /** CSS class forwarded to MachTable's inner grid root. */\n gridClassName?: string;\n style?: CSSProperties;\n apiRef?: MutableRefObject<GridApi<TData> | null>;\n};\n\nconst UPDATABLE_KEYS = DIRECT_GRID_OPTION_KEYS.filter((key) => key !== \"className\");\n\nexport function RobotGrid<TData = any>(props: RobotGridReactProps<TData>) {\n const { className, style, apiRef } = props;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const gridApiRef = useRef<GridApi<TData> | null>(null);\n const propsRef = useRef(props);\n propsRef.current = props;\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n\n const initial = propsRef.current;\n const options: Record<string, unknown> = {};\n for (const key of Object.keys(initial) as string[]) {\n if (key === \"className\" || key === \"gridClassName\" || key === \"style\" || key === \"apiRef\") continue;\n if (key.startsWith(\"on\")) continue;\n options[key] = (initial as Record<string, unknown>)[key];\n }\n if (initial.gridClassName !== undefined) options.className = initial.gridClassName;\n for (const eventType of EVENT_TYPES) {\n const handlerKey = `on${eventType.charAt(0).toUpperCase()}${eventType.slice(1)}`;\n options[handlerKey] = (event: unknown) => {\n const latest = propsRef.current as Record<string, unknown>;\n const handler = latest[handlerKey];\n if (typeof handler === \"function\") (handler as (event: unknown) => void)(event);\n };\n }\n\n const api = createGrid<TData>(host, options as GridOptions<TData>);\n gridApiRef.current = api;\n return () => {\n api.destroy();\n gridApiRef.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (!apiRef) return;\n const assigned = gridApiRef.current;\n apiRef.current = assigned;\n return () => {\n if (apiRef.current === assigned) apiRef.current = null;\n };\n }, [apiRef]);\n\n const rowDataReady = useRef(false);\n useEffect(() => {\n if (!rowDataReady.current) {\n rowDataReady.current = true;\n return;\n }\n gridApiRef.current?.setRowData(props.rowData);\n }, [props.rowData]);\n\n const columnDefsReady = useRef(false);\n useEffect(() => {\n if (!columnDefsReady.current) {\n columnDefsReady.current = true;\n return;\n }\n gridApiRef.current?.setColumnDefs(props.columnDefs);\n }, [props.columnDefs]);\n\n const quickFilterReady = useRef(false);\n useEffect(() => {\n if (!quickFilterReady.current) {\n quickFilterReady.current = true;\n return;\n }\n gridApiRef.current?.setQuickFilter(props.quickFilterText);\n }, [props.quickFilterText]);\n\n const gridClassNameReady = useRef(false);\n useEffect(() => {\n if (!gridClassNameReady.current) {\n gridClassNameReady.current = true;\n return;\n }\n gridApiRef.current?.updateOptions({ className: props.gridClassName });\n }, [props.gridClassName]);\n\n const optionValues = UPDATABLE_KEYS.map((key) => props[key]);\n const previousOptionValues = useRef<readonly unknown[] | null>(null);\n useEffect(() => {\n const previous = previousOptionValues.current;\n previousOptionValues.current = optionValues;\n if (!previous) {\n return;\n }\n const changed: Record<string, unknown> = {};\n optionValues.forEach((value, index) => {\n if (!Object.is(value, previous[index])) changed[UPDATABLE_KEYS[index]] = value;\n });\n if (Object.keys(changed).length > 0) {\n gridApiRef.current?.updateOptions(changed as Partial<GridOptions<TData>>);\n }\n }, optionValues);\n\n return createElement(\"div\", {\n ref: hostRef,\n className: `mach-react-host ${className ?? \"\"}`.trim() || undefined,\n style\n });\n}\n","import { useMemo, useState, type MutableRefObject } from \"react\";\nimport type { GridApi } from \"@agile-team/mach-table\";\n\nexport interface UseMachGridReturn<TData = any> {\n apiRef: MutableRefObject<GridApi<TData> | null>;\n api: GridApi<TData> | null;\n}\n\nexport function useMachGrid<TData = any>(): UseMachGridReturn<TData> {\n const [api, setApi] = useState<GridApi<TData> | null>(null);\n const apiRef = useMemo(() => {\n let current: GridApi<TData> | null = null;\n return Object.defineProperty({}, \"current\", {\n enumerable: true,\n get: () => current,\n set: (next: GridApi<TData> | null) => {\n if (next === current) return;\n current = next;\n setApi(next);\n }\n }) as MutableRefObject<GridApi<TData> | null>;\n }, []);\n\n return { apiRef, api };\n}\n","import { createElement, isValidElement, type ComponentType, type ReactNode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport type { CellRendererParams, CellRendererFn, DetailRowRendererParams, GridApi, RowNode } from \"@agile-team/mach-table\";\n\nexport interface ReactCellRendererProps<TData = any, TValue = any> extends CellRendererParams<TData, TValue> {\n children?: ReactNode;\n}\n\nexport interface ReactDetailProps<TData = any> {\n data: TData | null;\n node: RowNode<TData>;\n api: GridApi<TData>;\n}\n\nexport function reactCellRenderer<TData = any, TValue = any>(\n Component: ComponentType<ReactCellRendererProps<TData, TValue>>\n): CellRendererFn {\n return (params) => {\n const host = document.createElement(\"div\");\n host.className = \"mach-cell-react\";\n host.style.width = \"100%\";\n const root = createRoot(host);\n root.render(createElement(Component, params as ReactCellRendererProps<TData, TValue>));\n let destroyed = false;\n return {\n el: host,\n destroy: () => {\n if (destroyed) return;\n destroyed = true;\n window.setTimeout(() => {\n root.unmount();\n }, 0);\n }\n };\n };\n}\n\nexport function reactDetailRenderer<TData = any>(\n Component: ComponentType<ReactDetailProps<TData>>\n): (params: DetailRowRendererParams<TData>) => { el: HTMLElement; destroy?: () => void } {\n return (params) => {\n const host = document.createElement(\"div\");\n host.style.height = \"100%\";\n const root = createRoot(host);\n root.render(createElement(Component, params));\n let destroyed = false;\n return {\n el: host,\n destroy: () => {\n if (destroyed) return;\n destroyed = true;\n window.setTimeout(() => {\n root.unmount();\n }, 0);\n }\n };\n };\n}\n\nexport function isReactElement(value: unknown): boolean {\n return isValidElement(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAMO;AACP,wBAAiE;AAYjE,IAAM,iBAAiB,0CAAwB,OAAO,CAAC,QAAQ,QAAQ,WAAW;AAE3E,SAAS,UAAuB,OAAmC;AACxE,QAAM,EAAE,WAAW,OAAO,OAAO,IAAI;AACrC,QAAM,cAAU,qBAA8B,IAAI;AAClD,QAAM,iBAAa,qBAA8B,IAAI;AACrD,QAAM,eAAW,qBAAO,KAAK;AAC7B,WAAS,UAAU;AAEnB,8BAAU,MAAM;AACd,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,KAAM;AAEX,UAAM,UAAU,SAAS;AACzB,UAAM,UAAmC,CAAC;AAC1C,eAAW,OAAO,OAAO,KAAK,OAAO,GAAe;AAClD,UAAI,QAAQ,eAAe,QAAQ,mBAAmB,QAAQ,W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AAM;AAAA,MACX,KAAK,CAAC,SAAgC;AACpC,YAAI,SAAS,QAAS;AACtB,kBAAU;AACV,eAAO,IAAI;AAAA,MACb;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,SAAO,EAAE,QAAQ,IAAI;AACvB;;;ACxBA,IAAAC,gBAAkF;AAClF,oBAA2B;AAapB,SAAS,kBACd,WACgB;AAChB,SAAO,CAAC,WAAW;AACjB,UAAM,OAAO,SAAS,cAAc,KAAK;AACzC,SAAK,YAAY;AACjB,SAAK,MAAM,QAAQ;AACnB,UAAM,WAAO,0BAAW,IAAI;AAC5B,SAAK,WAAO,6BAAc,WAAW,MAA+C,CAAC;AACrF,QAAI,YAAY;AAChB,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,MAAM;AACb,YAAI,UAAW;AACf,oBAAY;AACZ,eAAO,WAAW,MAAM;AACtB,eAAK,QAAQ;AAAA,QACf,GAAG,CAAC;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACuF;AACvF,SAAO,CAAC,WAAW;AACjB,UAAM,OAAO,SAAS,cAAc,KAAK;AACzC,SAAK,MAAM,SAAS;AACpB,UAAM,WAAO,0BAAW,IAAI;AAC5B,SAAK,WAAO,6BAAc,WAAW,MAAM,CAAC;AAC5C,QAAI,YAAY;AAChB,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,MAAM;AACb,YAAI,UAAW;AACf,oBAAY;AACZ,eAAO,WAAW,MAAM;AACtB,eAAK,QAAQ;AAAA,QACf,GAAG,CAAC;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;;;AHlDA,0BAAc,mCAPd;","names":["import_react","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/MachTable.tsx","../src/defaults.tsx","../src/useMachGrid.ts","../src/adapters.ts"],"sourcesContent":["import { MachTable, RobotGrid } from \"./MachTable\";\n\nexport { MachTable, RobotGrid };\nexport type { MachTableReactProps, RobotGridReactProps } from \"./MachTable\";\nexport { useMachGrid } from \"./useMachGrid\";\nexport type { UseMachGridReturn } from \"./useMachGrid\";\nexport { MachTableProvider, useMachTableDefaults } from \"./defaults\";\nexport type { MachTableProviderProps } from \"./defaults\";\nexport { reactCellRenderer, reactDetailRenderer } from \"./adapters\";\nexport type { ReactCellRendererProps, ReactDetailProps } from \"./adapters\";\nexport * from \"@agile-team/mach-table\";\n\n/** Enables `React.lazy(() => import(\"@agile-team/mach-table-react\"))`. */\nexport default MachTable;\n","import {\n createElement,\n useEffect,\n useRef,\n type CSSProperties,\n type MutableRefObject\n} from \"react\";\nimport { createGrid, createMachTablePreset, GRID_OPTION_KEYS, EVENT_TYPES } from \"@agile-team/mach-table\";\nimport type { GridApi, GridOptions } from \"@agile-team/mach-table\";\nimport { useMachTableDefaults } from \"./defaults\";\n\ntype AdapterOnlyGridOption = \"className\" | \"ariaLabel\" | \"ariaLabelledBy\" | \"ariaDescribedBy\";\n\nexport type MachTableReactProps<TData = any> = Omit<GridOptions<TData>, AdapterOnlyGridOption> & {\n /** CSS class applied to the React host element. */\n className?: string;\n /** CSS class forwarded to MachTable's inner grid root. */\n gridClassName?: string;\n gridAriaLabel?: string;\n gridAriaLabelledBy?: string;\n gridAriaDescribedBy?: string;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n \"aria-describedby\"?: string;\n style?: CSSProperties;\n apiRef?: MutableRefObject<GridApi<TData> | null>;\n};\n\nfunction collectGridOptions<TData>(\n props: MachTableReactProps<TData>,\n defaults: Partial<GridOptions<TData>>\n): GridOptions<TData> {\n const explicit: Record<string, unknown> = {};\n for (const key of GRID_OPTION_KEYS) {\n if (key === \"className\") continue;\n const value = key === \"ariaLabel\"\n ? props.gridAriaLabel\n : key === \"ariaLabelledBy\"\n ? props.gridAriaLabelledBy\n : key === \"ariaDescribedBy\"\n ? props.gridAriaDescribedBy\n : props[key];\n if (value !== undefined) explicit[key] = value;\n }\n if (props.gridClassName !== undefined) explicit.className = props.gridClassName;\n return createMachTablePreset(defaults, explicit as Partial<GridOptions<TData>>);\n}\n\nexport function MachTable<TData = any>(props: MachTableReactProps<TData>) {\n const { className, style, apiRef } = props;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const gridApiRef = useRef<GridApi<TData> | null>(null);\n const propsRef = useRef(props);\n propsRef.current = props;\n const defaults = useMachTableDefaults<TData>();\n const effectiveInputs = [\n defaults,\n ...GRID_OPTION_KEYS.map((key) => key === \"className\"\n ? props.gridClassName\n : key === \"ariaLabel\"\n ? props.gridAriaLabel\n : key === \"ariaLabelledBy\"\n ? props.gridAriaLabelledBy\n : key === \"ariaDescribedBy\"\n ? props.gridAriaDescribedBy\n : props[key])\n ];\n const effectiveCache = useRef<{ inputs: readonly unknown[]; options: GridOptions<TData> } | null>(null);\n if (\n !effectiveCache.current ||\n effectiveCache.current.inputs.length !== effectiveInputs.length ||\n effectiveInputs.some((value, index) => !Object.is(value, effectiveCache.current?.inputs[index]))\n ) {\n effectiveCache.current = { inputs: effectiveInputs, options: collectGridOptions(props, defaults) };\n }\n const effectiveOptions = effectiveCache.current.options;\n const effectiveRef = useRef(effectiveOptions);\n effectiveRef.current = effectiveOptions;\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n\n const options = { ...effectiveRef.current } as Record<string, unknown>;\n for (const eventType of EVENT_TYPES) {\n const handlerKey = `on${eventType.charAt(0).toUpperCase()}${eventType.slice(1)}`;\n options[handlerKey] = (event: unknown) => {\n const defaultHandler = (effectiveRef.current as Record<string, unknown>)[handlerKey];\n if (typeof defaultHandler === \"function\") (defaultHandler as (value: unknown) => void)(event);\n const latest = propsRef.current as Record<string, unknown>;\n const handler = latest[handlerKey];\n if (typeof handler === \"function\" && handler !== defaultHandler) {\n (handler as (value: unknown) => void)(event);\n }\n };\n }\n\n const api = createGrid<TData>(host, options);\n gridApiRef.current = api;\n return () => {\n api.destroy();\n gridApiRef.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (!apiRef) return;\n const assigned = gridApiRef.current;\n apiRef.current = assigned;\n return () => {\n if (apiRef.current === assigned) apiRef.current = null;\n };\n }, [apiRef]);\n\n const optionValues = GRID_OPTION_KEYS.map((key) => effectiveOptions[key]);\n const previousOptionValues = useRef<readonly unknown[] | null>(null);\n useEffect(() => {\n const previous = previousOptionValues.current;\n previousOptionValues.current = optionValues;\n if (!previous) {\n return;\n }\n const changed: Record<string, unknown> = {};\n optionValues.forEach((value, index) => {\n if (Object.is(value, previous[index])) return;\n changed[GRID_OPTION_KEYS[index]] = value;\n });\n if (Object.keys(changed).length > 0) {\n gridApiRef.current?.updateOptions(changed);\n }\n }, optionValues);\n\n return createElement(\"div\", {\n ref: hostRef,\n className: `mach-react-host ${className ?? \"\"}`.trim() || undefined,\n style,\n \"aria-label\": props[\"aria-label\"],\n \"aria-labelledby\": props[\"aria-labelledby\"],\n \"aria-describedby\": props[\"aria-describedby\"]\n });\n}\n\n/** @deprecated Use MachTable. Kept as a source-compatible alias through 0.x. */\nexport const RobotGrid = MachTable;\n/** @deprecated Use MachTableReactProps. */\nexport type RobotGridReactProps<TData = any> = MachTableReactProps<TData>;\n","import { createContext, createElement, useContext, useMemo, type ReactNode } from \"react\";\nimport { createMachTablePreset, type GridOptions } from \"@agile-team/mach-table\";\n\nconst MachTableDefaultsContext = createContext<Partial<GridOptions<any>>>({});\n\nexport interface MachTableProviderProps<TData = any> {\n defaults: Partial<GridOptions<TData>>;\n children?: ReactNode;\n}\n\n/** Supplies app-, route- or layout-scoped defaults without making tables eager. */\nexport function MachTableProvider<TData = any>({ defaults, children }: MachTableProviderProps<TData>) {\n const parent = useContext(MachTableDefaultsContext);\n const value = useMemo(() => createMachTablePreset(parent, defaults), [parent, defaults]);\n return createElement(MachTableDefaultsContext.Provider, { value }, children);\n}\n\nexport function useMachTableDefaults<TData = any>(): Partial<GridOptions<TData>> {\n return useContext(MachTableDefaultsContext) as Partial<GridOptions<TData>>;\n}\n","import { useMemo, useState, type MutableRefObject } from \"react\";\nimport type { GridApi } from \"@agile-team/mach-table\";\n\nexport interface UseMachGridReturn<TData = any> {\n apiRef: MutableRefObject<GridApi<TData> | null>;\n api: GridApi<TData> | null;\n ready: boolean;\n}\n\nexport function useMachGrid<TData = any>(): UseMachGridReturn<TData> {\n const [api, setApi] = useState<GridApi<TData> | null>(null);\n const [ready, setReady] = useState(false);\n const apiRef = useMemo(() => {\n let current: GridApi<TData> | null = null;\n return Object.defineProperty({}, \"current\", {\n enumerable: true,\n get: () => current,\n set: (next: GridApi<TData> | null) => {\n if (next === current) return;\n current = next;\n setApi(next);\n setReady(false);\n if (next) {\n void next.whenReady().then(() => {\n if (current === next && !next.isDestroyed()) setReady(true);\n });\n }\n }\n }) as MutableRefObject<GridApi<TData> | null>;\n }, []);\n\n return { apiRef, api, ready };\n}\n","import { createElement, isValidElement, type ComponentType, type ReactNode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport type { CellRendererParams, CellRendererFn, DetailRowRendererParams, GridApi, RowNode } from \"@agile-team/mach-table\";\n\nexport interface ReactCellRendererProps<TData = any, TValue = any> extends CellRendererParams<TData, TValue> {\n children?: ReactNode;\n}\n\nexport interface ReactDetailProps<TData = any> {\n data: TData | null;\n node: RowNode<TData>;\n api: GridApi<TData>;\n}\n\nexport function reactCellRenderer<TData = any, TValue = any>(\n Component: ComponentType<ReactCellRendererProps<TData, TValue>>\n): CellRendererFn {\n return (params) => {\n const host = document.createElement(\"div\");\n host.className = \"mach-cell-react\";\n host.style.width = \"100%\";\n const root = createRoot(host);\n root.render(createElement(Component, params as ReactCellRendererProps<TData, TValue>));\n let destroyed = false;\n return {\n el: host,\n destroy: () => {\n if (destroyed) return;\n destroyed = true;\n window.setTimeout(() => {\n root.unmount();\n }, 0);\n }\n };\n };\n}\n\nexport function reactDetailRenderer<TData = any>(\n Component: ComponentType<ReactDetailProps<TData>>\n): (params: DetailRowRendererParams<TData>) => { el: HTMLElement; destroy?: () => void } {\n return (params) => {\n const host = document.createElement(\"div\");\n host.style.height = \"100%\";\n const root = createRoot(host);\n root.render(createElement(Component, params));\n let destroyed = false;\n return {\n el: host,\n destroy: () => {\n if (destroyed) return;\n destroyed = true;\n window.setTimeout(() => {\n root.unmount();\n }, 0);\n }\n };\n };\n}\n\nexport function isReactElement(value: unknown): boolean {\n return isValidElement(value);\n}\n"],"mappings":"2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,sBAAAC,EAAA,cAAAC,EAAA,YAAAC,EAAA,sBAAAC,EAAA,wBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAV,GCAA,IAAAW,EAMO,iBACPC,EAAiF,kCCPjF,IAAAC,EAAkF,iBAClFC,EAAwD,kCAElDC,KAA2B,iBAAyC,CAAC,CAAC,EAQrE,SAASC,EAA+B,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAkC,CACpG,IAAMC,KAAS,cAAWJ,CAAwB,EAC5CK,KAAQ,WAAQ,OAAM,yBAAsBD,EAAQF,CAAQ,EAAG,CAACE,EAAQF,CAAQ,CAAC,EACvF,SAAO,iBAAcF,EAAyB,SAAU,CAAE,MAAAK,CAAM,EAAGF,CAAQ,CAC7E,CAEO,SAASG,GAAiE,CAC/E,SAAO,cAAWN,CAAwB,CAC5C,CDSA,SAASO,EACPC,EACAC,EACoB,CACpB,IAAMC,EAAoC,CAAC,EAC3C,QAAWC,KAAO,mBAAkB,CAClC,GAAIA,IAAQ,YAAa,SACzB,IAAMC,EAAQD,IAAQ,YAClBH,EAAM,cACNG,IAAQ,iBACNH,EAAM,mBACNG,IAAQ,kBACNH,EAAM,oBACNA,EAAMG,CAAG,EACbC,IAAU,SAAWF,EAASC,CAAG,EAAIC,EAC3C,CACA,OAAIJ,EAAM,gBAAkB,SAAWE,EAAS,UAAYF,EAAM,kBAC3D,yBAAsBC,EAAUC,CAAuC,CAChF,CAEO,SAASG,EAAuBL,EAAmC,CACxE,GAAM,CAAE,UAAAM,EAAW,MAAAC,EAAO,O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IAASD,IACbA,EAAUC,EACVJ,EAAOI,CAAI,EACXF,EAAS,EAAK,EACVE,GACGA,EAAK,UAAU,EAAE,KAAK,IAAM,CAC3BD,IAAYC,GAAQ,CAACA,EAAK,YAAY,GAAGF,EAAS,EAAI,CAC5D,CAAC,EAEL,CACF,CAAC,CACH,EAAG,CAAC,CAAC,EAEY,IAAAH,EAAK,MAAAE,CAAM,CAC9B,CChCA,IAAAI,EAAkF,iBAClFC,EAA2B,4BAapB,SAASC,EACdC,EACgB,CAChB,OAAQC,GAAW,CACjB,IAAMC,EAAO,SAAS,cAAc,KAAK,EACzCA,EAAK,UAAY,kBACjBA,EAAK,MAAM,MAAQ,OACnB,IAAMC,KAAO,cAAWD,CAAI,EAC5BC,EAAK,UAAO,iBAAcH,EAAWC,CAA+C,CAAC,EACrF,IAAIG,EAAY,GAChB,MAAO,CACL,GAAIF,EACJ,QAAS,IAAM,CACTE,IACJA,EAAY,GACZ,OAAO,WAAW,IAAM,CACtBD,EAAK,QAAQ,CACf,EAAG,CAAC,EACN,CACF,CACF,CACF,CAEO,SAASE,EACdL,EACuF,CACvF,OAAQC,GAAW,CACjB,IAAMC,EAAO,SAAS,cAAc,KAAK,EACzCA,EAAK,MAAM,OAAS,OACpB,IAAMC,KAAO,cAAWD,CAAI,EAC5BC,EAAK,UAAO,iBAAcH,EAAWC,CAAM,CAAC,EAC5C,IAAIG,EAAY,GAChB,MAAO,CACL,GAAIF,EACJ,QAAS,IAAM,CACTE,IACJA,EAAY,GACZ,OAAO,WAAW,IAAM,CACtBD,EAAK,QAAQ,CACf,EAAG,CAAC,EACN,CACF,CACF,CACF,CJ/CAG,EAAAC,EAAc,kCAVd,gBAaA,IAAOC,EAAQC","names":["index_exports","__export","MachTable","MachTableProvider","RobotGrid","index_default","reactCellRenderer","reactDetailRenderer","useMachGrid","useMachTableDefaults","__toCommonJS","import_react","import_mach_table","import_react","import_mach_table","MachTableDefaultsContext","MachTableProvider","defaults","children","parent","value","useMachTableDefaults","collectGridOptions","props","defaults","explicit","key","value","MachTable","className","style","apiRef","hostRef","gridApiRef","propsRef","useMachTableDefaults","effectiveInputs","effectiveCache","index","effectiveOptions","effectiveRef","host","options","eventType","handlerKey","event","defaultHandler","handler","api","assigned","optionValues","previousOptionValues","previous","changed","RobotGrid","import_react","useMachGrid","api","setApi","ready","setReady","current","next","import_react","import_client","reactCellRenderer","Component","params","host","root","destroyed","reactDetailRenderer","__reExport","index_exports","index_default","MachTable"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,26 +3,49 @@ import { CSSProperties, MutableRefObject, ReactNode, ComponentType } from 'react
|
|
|
3
3
|
import { GridOptions, GridApi, CellRendererParams, RowNode, CellRendererFn, DetailRowRendererParams } from '@agile-team/mach-table';
|
|
4
4
|
export * from '@agile-team/mach-table';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type AdapterOnlyGridOption = "className" | "ariaLabel" | "ariaLabelledBy" | "ariaDescribedBy";
|
|
7
|
+
type MachTableReactProps<TData = any> = Omit<GridOptions<TData>, AdapterOnlyGridOption> & {
|
|
7
8
|
/** CSS class applied to the React host element. */
|
|
8
9
|
className?: string;
|
|
9
10
|
/** CSS class forwarded to MachTable's inner grid root. */
|
|
10
11
|
gridClassName?: string;
|
|
12
|
+
gridAriaLabel?: string;
|
|
13
|
+
gridAriaLabelledBy?: string;
|
|
14
|
+
gridAriaDescribedBy?: string;
|
|
15
|
+
"aria-label"?: string;
|
|
16
|
+
"aria-labelledby"?: string;
|
|
17
|
+
"aria-describedby"?: string;
|
|
11
18
|
style?: CSSProperties;
|
|
12
19
|
apiRef?: MutableRefObject<GridApi<TData> | null>;
|
|
13
20
|
};
|
|
14
|
-
declare function
|
|
21
|
+
declare function MachTable<TData = any>(props: MachTableReactProps<TData>): react.DetailedReactHTMLElement<{
|
|
15
22
|
ref: MutableRefObject<HTMLDivElement | null>;
|
|
16
23
|
className: string | undefined;
|
|
17
24
|
style: CSSProperties | undefined;
|
|
25
|
+
"aria-label": string | undefined;
|
|
26
|
+
"aria-labelledby": string | undefined;
|
|
27
|
+
"aria-describedby": string | undefined;
|
|
18
28
|
}, HTMLDivElement>;
|
|
29
|
+
/** @deprecated Use MachTable. Kept as a source-compatible alias through 0.x. */
|
|
30
|
+
declare const RobotGrid: typeof MachTable;
|
|
31
|
+
/** @deprecated Use MachTableReactProps. */
|
|
32
|
+
type RobotGridReactProps<TData = any> = MachTableReactProps<TData>;
|
|
19
33
|
|
|
20
34
|
interface UseMachGridReturn<TData = any> {
|
|
21
35
|
apiRef: MutableRefObject<GridApi<TData> | null>;
|
|
22
36
|
api: GridApi<TData> | null;
|
|
37
|
+
ready: boolean;
|
|
23
38
|
}
|
|
24
39
|
declare function useMachGrid<TData = any>(): UseMachGridReturn<TData>;
|
|
25
40
|
|
|
41
|
+
interface MachTableProviderProps<TData = any> {
|
|
42
|
+
defaults: Partial<GridOptions<TData>>;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/** Supplies app-, route- or layout-scoped defaults without making tables eager. */
|
|
46
|
+
declare function MachTableProvider<TData = any>({ defaults, children }: MachTableProviderProps<TData>): react.FunctionComponentElement<react.ProviderProps<Partial<GridOptions<any>>>>;
|
|
47
|
+
declare function useMachTableDefaults<TData = any>(): Partial<GridOptions<TData>>;
|
|
48
|
+
|
|
26
49
|
interface ReactCellRendererProps<TData = any, TValue = any> extends CellRendererParams<TData, TValue> {
|
|
27
50
|
children?: ReactNode;
|
|
28
51
|
}
|
|
@@ -37,4 +60,4 @@ declare function reactDetailRenderer<TData = any>(Component: ComponentType<React
|
|
|
37
60
|
destroy?: () => void;
|
|
38
61
|
};
|
|
39
62
|
|
|
40
|
-
export {
|
|
63
|
+
export { MachTable, MachTableProvider, type MachTableProviderProps, type MachTableReactProps, type ReactCellRendererProps, type ReactDetailProps, RobotGrid, type RobotGridReactProps, type UseMachGridReturn, MachTable as default, reactCellRenderer, reactDetailRenderer, useMachGrid, useMachTableDefaults };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,26 +3,49 @@ import { CSSProperties, MutableRefObject, ReactNode, ComponentType } from 'react
|
|
|
3
3
|
import { GridOptions, GridApi, CellRendererParams, RowNode, CellRendererFn, DetailRowRendererParams } from '@agile-team/mach-table';
|
|
4
4
|
export * from '@agile-team/mach-table';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type AdapterOnlyGridOption = "className" | "ariaLabel" | "ariaLabelledBy" | "ariaDescribedBy";
|
|
7
|
+
type MachTableReactProps<TData = any> = Omit<GridOptions<TData>, AdapterOnlyGridOption> & {
|
|
7
8
|
/** CSS class applied to the React host element. */
|
|
8
9
|
className?: string;
|
|
9
10
|
/** CSS class forwarded to MachTable's inner grid root. */
|
|
10
11
|
gridClassName?: string;
|
|
12
|
+
gridAriaLabel?: string;
|
|
13
|
+
gridAriaLabelledBy?: string;
|
|
14
|
+
gridAriaDescribedBy?: string;
|
|
15
|
+
"aria-label"?: string;
|
|
16
|
+
"aria-labelledby"?: string;
|
|
17
|
+
"aria-describedby"?: string;
|
|
11
18
|
style?: CSSProperties;
|
|
12
19
|
apiRef?: MutableRefObject<GridApi<TData> | null>;
|
|
13
20
|
};
|
|
14
|
-
declare function
|
|
21
|
+
declare function MachTable<TData = any>(props: MachTableReactProps<TData>): react.DetailedReactHTMLElement<{
|
|
15
22
|
ref: MutableRefObject<HTMLDivElement | null>;
|
|
16
23
|
className: string | undefined;
|
|
17
24
|
style: CSSProperties | undefined;
|
|
25
|
+
"aria-label": string | undefined;
|
|
26
|
+
"aria-labelledby": string | undefined;
|
|
27
|
+
"aria-describedby": string | undefined;
|
|
18
28
|
}, HTMLDivElement>;
|
|
29
|
+
/** @deprecated Use MachTable. Kept as a source-compatible alias through 0.x. */
|
|
30
|
+
declare const RobotGrid: typeof MachTable;
|
|
31
|
+
/** @deprecated Use MachTableReactProps. */
|
|
32
|
+
type RobotGridReactProps<TData = any> = MachTableReactProps<TData>;
|
|
19
33
|
|
|
20
34
|
interface UseMachGridReturn<TData = any> {
|
|
21
35
|
apiRef: MutableRefObject<GridApi<TData> | null>;
|
|
22
36
|
api: GridApi<TData> | null;
|
|
37
|
+
ready: boolean;
|
|
23
38
|
}
|
|
24
39
|
declare function useMachGrid<TData = any>(): UseMachGridReturn<TData>;
|
|
25
40
|
|
|
41
|
+
interface MachTableProviderProps<TData = any> {
|
|
42
|
+
defaults: Partial<GridOptions<TData>>;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/** Supplies app-, route- or layout-scoped defaults without making tables eager. */
|
|
46
|
+
declare function MachTableProvider<TData = any>({ defaults, children }: MachTableProviderProps<TData>): react.FunctionComponentElement<react.ProviderProps<Partial<GridOptions<any>>>>;
|
|
47
|
+
declare function useMachTableDefaults<TData = any>(): Partial<GridOptions<TData>>;
|
|
48
|
+
|
|
26
49
|
interface ReactCellRendererProps<TData = any, TValue = any> extends CellRendererParams<TData, TValue> {
|
|
27
50
|
children?: ReactNode;
|
|
28
51
|
}
|
|
@@ -37,4 +60,4 @@ declare function reactDetailRenderer<TData = any>(Component: ComponentType<React
|
|
|
37
60
|
destroy?: () => void;
|
|
38
61
|
};
|
|
39
62
|
|
|
40
|
-
export {
|
|
63
|
+
export { MachTable, MachTableProvider, type MachTableProviderProps, type MachTableReactProps, type ReactCellRendererProps, type ReactDetailProps, RobotGrid, type RobotGridReactProps, type UseMachGridReturn, MachTable as default, reactCellRenderer, reactDetailRenderer, useMachGrid, useMachTableDefaults };
|