@agile-team/mach-table-react 0.5.0 → 0.14.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 +74 -3
- package/dist/chunk-VVQCWQ2C.js +2 -0
- package/dist/chunk-VVQCWQ2C.js.map +1 -0
- package/dist/chunk-Z5XSUQ5O.cjs +2 -0
- package/dist/chunk-Z5XSUQ5O.cjs.map +1 -0
- package/dist/index.cjs +1 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -8
- package/dist/index.d.ts +62 -8
- package/dist/index.js +1 -176
- package/dist/index.js.map +1 -1
- package/dist/mach-table.css +517 -3
- package/dist/workflows-BhNumPcR.d.cts +129 -0
- package/dist/workflows-BhNumPcR.d.ts +129 -0
- package/dist/workflows.cjs +2 -0
- package/dist/workflows.cjs.map +1 -0
- package/dist/workflows.d.cts +3 -0
- package/dist/workflows.d.ts +3 -0
- package/dist/workflows.js +2 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +14 -4
package/dist/index.cjs
CHANGED
|
@@ -1,206 +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
|
-
default: () => index_default,
|
|
27
|
-
reactCellRenderer: () => reactCellRenderer,
|
|
28
|
-
reactDetailRenderer: () => reactDetailRenderer,
|
|
29
|
-
useMachGrid: () => useMachGrid
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(index_exports);
|
|
32
|
-
|
|
33
|
-
// src/RobotGrid.tsx
|
|
34
|
-
var import_react = require("react");
|
|
35
|
-
var import_mach_table = require("@agile-team/mach-table");
|
|
36
|
-
var UPDATABLE_KEYS = import_mach_table.DIRECT_GRID_OPTION_KEYS.filter((key) => key !== "className");
|
|
37
|
-
function RobotGrid(props) {
|
|
38
|
-
const { className, style, apiRef } = props;
|
|
39
|
-
const hostRef = (0, import_react.useRef)(null);
|
|
40
|
-
const gridApiRef = (0, import_react.useRef)(null);
|
|
41
|
-
const propsRef = (0, import_react.useRef)(props);
|
|
42
|
-
propsRef.current = props;
|
|
43
|
-
(0, import_react.useEffect)(() => {
|
|
44
|
-
const host = hostRef.current;
|
|
45
|
-
if (!host) return;
|
|
46
|
-
const initial = propsRef.current;
|
|
47
|
-
const options = {};
|
|
48
|
-
for (const key of Object.keys(initial)) {
|
|
49
|
-
if (key === "className" || key === "gridClassName" || key === "style" || key === "apiRef") continue;
|
|
50
|
-
if (key.startsWith("on")) continue;
|
|
51
|
-
options[key] = initial[key];
|
|
52
|
-
}
|
|
53
|
-
if (initial.gridClassName !== void 0) options.className = initial.gridClassName;
|
|
54
|
-
for (const eventType of import_mach_table.EVENT_TYPES) {
|
|
55
|
-
const handlerKey = `on${eventType.charAt(0).toUpperCase()}${eventType.slice(1)}`;
|
|
56
|
-
options[handlerKey] = (event) => {
|
|
57
|
-
const latest = propsRef.current;
|
|
58
|
-
const handler = latest[handlerKey];
|
|
59
|
-
if (typeof handler === "function") handler(event);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const api = (0, import_mach_table.createGrid)(host, options);
|
|
63
|
-
gridApiRef.current = api;
|
|
64
|
-
return () => {
|
|
65
|
-
api.destroy();
|
|
66
|
-
gridApiRef.current = null;
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
(0, import_react.useEffect)(() => {
|
|
70
|
-
if (!apiRef) return;
|
|
71
|
-
const assigned = gridApiRef.current;
|
|
72
|
-
apiRef.current = assigned;
|
|
73
|
-
return () => {
|
|
74
|
-
if (apiRef.current === assigned) apiRef.current = null;
|
|
75
|
-
};
|
|
76
|
-
}, [apiRef]);
|
|
77
|
-
const rowDataReady = (0, import_react.useRef)(false);
|
|
78
|
-
(0, import_react.useEffect)(() => {
|
|
79
|
-
if (!rowDataReady.current) {
|
|
80
|
-
rowDataReady.current = true;
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
gridApiRef.current?.setRowData(props.rowData);
|
|
84
|
-
}, [props.rowData]);
|
|
85
|
-
const columnDefsReady = (0, import_react.useRef)(false);
|
|
86
|
-
(0, import_react.useEffect)(() => {
|
|
87
|
-
if (!columnDefsReady.current) {
|
|
88
|
-
columnDefsReady.current = true;
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
gridApiRef.current?.setColumnDefs(props.columnDefs);
|
|
92
|
-
}, [props.columnDefs]);
|
|
93
|
-
const quickFilterReady = (0, import_react.useRef)(false);
|
|
94
|
-
(0, import_react.useEffect)(() => {
|
|
95
|
-
if (!quickFilterReady.current) {
|
|
96
|
-
quickFilterReady.current = true;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
gridApiRef.current?.setQuickFilter(props.quickFilterText);
|
|
100
|
-
}, [props.quickFilterText]);
|
|
101
|
-
const gridClassNameReady = (0, import_react.useRef)(false);
|
|
102
|
-
(0, import_react.useEffect)(() => {
|
|
103
|
-
if (!gridClassNameReady.current) {
|
|
104
|
-
gridClassNameReady.current = true;
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
gridApiRef.current?.updateOptions({ className: props.gridClassName });
|
|
108
|
-
}, [props.gridClassName]);
|
|
109
|
-
const optionValues = UPDATABLE_KEYS.map((key) => props[key]);
|
|
110
|
-
const previousOptionValues = (0, import_react.useRef)(null);
|
|
111
|
-
(0, import_react.useEffect)(() => {
|
|
112
|
-
const previous = previousOptionValues.current;
|
|
113
|
-
previousOptionValues.current = optionValues;
|
|
114
|
-
if (!previous) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const changed = {};
|
|
118
|
-
optionValues.forEach((value, index) => {
|
|
119
|
-
if (!Object.is(value, previous[index])) changed[UPDATABLE_KEYS[index]] = value;
|
|
120
|
-
});
|
|
121
|
-
if (Object.keys(changed).length > 0) {
|
|
122
|
-
gridApiRef.current?.updateOptions(changed);
|
|
123
|
-
}
|
|
124
|
-
}, optionValues);
|
|
125
|
-
return (0, import_react.createElement)("div", {
|
|
126
|
-
ref: hostRef,
|
|
127
|
-
className: `mach-react-host ${className ?? ""}`.trim() || void 0,
|
|
128
|
-
style
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/useMachGrid.ts
|
|
133
|
-
var import_react2 = require("react");
|
|
134
|
-
function useMachGrid() {
|
|
135
|
-
const [api, setApi] = (0, import_react2.useState)(null);
|
|
136
|
-
const apiRef = (0, import_react2.useMemo)(() => {
|
|
137
|
-
let current = null;
|
|
138
|
-
return Object.defineProperty({}, "current", {
|
|
139
|
-
enumerable: true,
|
|
140
|
-
get: () => current,
|
|
141
|
-
set: (next) => {
|
|
142
|
-
if (next === current) return;
|
|
143
|
-
current = next;
|
|
144
|
-
setApi(next);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}, []);
|
|
148
|
-
return { apiRef, api };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/adapters.ts
|
|
152
|
-
var import_react3 = require("react");
|
|
153
|
-
var import_client = require("react-dom/client");
|
|
154
|
-
function reactCellRenderer(Component) {
|
|
155
|
-
return (params) => {
|
|
156
|
-
const host = document.createElement("div");
|
|
157
|
-
host.className = "mach-cell-react";
|
|
158
|
-
host.style.width = "100%";
|
|
159
|
-
const root = (0, import_client.createRoot)(host);
|
|
160
|
-
root.render((0, import_react3.createElement)(Component, params));
|
|
161
|
-
let destroyed = false;
|
|
162
|
-
return {
|
|
163
|
-
el: host,
|
|
164
|
-
destroy: () => {
|
|
165
|
-
if (destroyed) return;
|
|
166
|
-
destroyed = true;
|
|
167
|
-
window.setTimeout(() => {
|
|
168
|
-
root.unmount();
|
|
169
|
-
}, 0);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function reactDetailRenderer(Component) {
|
|
175
|
-
return (params) => {
|
|
176
|
-
const host = document.createElement("div");
|
|
177
|
-
host.style.height = "100%";
|
|
178
|
-
const root = (0, import_client.createRoot)(host);
|
|
179
|
-
root.render((0, import_react3.createElement)(Component, params));
|
|
180
|
-
let destroyed = false;
|
|
181
|
-
return {
|
|
182
|
-
el: host,
|
|
183
|
-
destroy: () => {
|
|
184
|
-
if (destroyed) return;
|
|
185
|
-
destroyed = true;
|
|
186
|
-
window.setTimeout(() => {
|
|
187
|
-
root.unmount();
|
|
188
|
-
}, 0);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// src/index.ts
|
|
195
|
-
__reExport(index_exports, require("@agile-team/mach-table"), module.exports);
|
|
196
|
-
var index_default = RobotGrid;
|
|
197
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
198
|
-
0 && (module.exports = {
|
|
199
|
-
MachTable,
|
|
200
|
-
RobotGrid,
|
|
201
|
-
reactCellRenderer,
|
|
202
|
-
reactDetailRenderer,
|
|
203
|
-
useMachGrid,
|
|
204
|
-
...require("@agile-team/mach-table")
|
|
205
|
-
});
|
|
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]}); }); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkZ5XSUQ5Ocjs = require('./chunk-Z5XSUQ5O.cjs');var _react = require('react');var _machtable = require('@agile-team/mach-table'); _createStarExport(_machtable);var I=_machtable.normalizeMachTableConfig.call(void 0, ),T=_react.createContext.call(void 0, I);function Q({config:e,defaults:a,children:r}){let t=_react.useContext.call(void 0, T),n=_react.useMemo.call(void 0, ()=>_machtable.mergeMachTableConfig.call(void 0, t,{..._nullishCoalesce(e, () => ({})),...a?{defaults:a}:{}}),[t,e,a]);return _react.createElement.call(void 0, T.Provider,{value:n},r)}function j(){return _react.useContext.call(void 0, T).defaults}function P(){return _react.useContext.call(void 0, T)}function W(e,a){let r={};for(let t of _machtable.GRID_OPTION_KEYS){if(t==="className")continue;let n=t==="ariaLabel"?e.gridAriaLabel:t==="ariaLabelledBy"?e.gridAriaLabelledBy:t==="ariaDescribedBy"?e.gridAriaDescribedBy:e[t];n!==void 0&&(r[t]=n)}return e.gridClassName!==void 0&&(r.className=e.gridClassName),_machtable.resolveMachTableGridOptions.call(void 0, a,e.preset,r).options}function N(e){let{className:a,style:r,apiRef:t}=e,n=_react.useRef.call(void 0, null),b=_react.useRef.call(void 0, null),G=_react.useRef.call(void 0, e);G.current=e;let O=P(),y=[O,e.preset,..._machtable.GRID_OPTION_KEYS.map(o=>o==="className"?e.gridClassName:o==="ariaLabel"?e.gridAriaLabel:o==="ariaLabelledBy"?e.gridAriaLabelledBy:o==="ariaDescribedBy"?e.gridAriaDescribedBy:e[o])],u=_react.useRef.call(void 0, null);(!u.current||u.current.inputs.length!==y.length||y.some((o,i)=>!Object.is(o,_optionalChain([u, 'access', _2 => _2.current, 'optionalAccess', _3 => _3.inputs, 'access', _4 => _4[i]]))))&&(u.current={inputs:y,options:W(e,O)});let R=u.current.options,g=_react.useRef.call(void 0, R);g.current=R,_react.useEffect.call(void 0, ()=>{let o=n.current;if(!o)return;let i={...g.current};for(let f of _machtable.EVENT_TYPES){let p=`on${f.charAt(0).toUpperCase()}${f.slice(1)}`;i[p]=A=>{let D=g.current[p];typeof D=="function"&&D(A);let C=G.current[p];typeof C=="function"&&C!==D&&C(A)}}let m=_machtable.createGrid.call(void 0, o,i);return b.current=m,()=>{m.destroy(),b.current=null}},[]),_react.useEffect.call(void 0, ()=>{if(!t)return;let o=b.current;return t.current=o,()=>{t.current===o&&(t.current=null)}},[t]);let M=_machtable.GRID_OPTION_KEYS.map(o=>R[o]),E=_react.useRef.call(void 0, null);return _react.useEffect.call(void 0, ()=>{let o=E.current;if(E.current=M,!o)return;let i={};M.forEach((m,f)=>{Object.is(m,o[f])||(i[_machtable.GRID_OPTION_KEYS[f]]=m)}),Object.keys(i).length>0&&_optionalChain([b, 'access', _5 => _5.current, 'optionalAccess', _6 => _6.updateOptions, 'call', _7 => _7(i)])},M),_react.createElement.call(void 0, "div",{ref:n,className:`mach-react-host ${_nullishCoalesce(a, () => (""))}`.trim()||void 0,style:r,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],"aria-describedby":e["aria-describedby"]})}var J=N;var X={search:!0,refresh:!0,columns:!0,density:!0,export:!0,undoRedo:!1,fullscreen:!1};function c(e,a){return _nullishCoalesce(_optionalChain([e, 'optionalAccess', _8 => _8[a]]), () => (X[a]))}function d(e,a,r,t=!1){return _react.createElement.call(void 0, "button",{key:e,type:"button",className:"mach-toolbar__button",title:e,"aria-label":e,disabled:t,onClick:r},a)}function Z(e){let a=[e.start],r=_nullishCoalesce(e.searchPlaceholder, () => ("\u641C\u7D22\u5F53\u524D\u7ED3\u679C"));return c(e.features,"search")&&a.push(_react.createElement.call(void 0, "label",{className:"mach-toolbar__search",key:"search"},_react.createElement.call(void 0, "span",{className:"mach-sr-only"},r),_react.createElement.call(void 0, "span",{"aria-hidden":!0},"\u2315"),_react.createElement.call(void 0, "input",{type:"search",value:_nullishCoalesce(e.search, () => ("")),placeholder:r,onChange:t=>{let n=t.currentTarget.value;_optionalChain([e, 'access', _9 => _9.onSearchChange, 'optionalCall', _10 => _10(n)]),e.onSearchChange||(e.commands?e.commands.search(n||null):_optionalChain([e, 'access', _11 => _11.api, 'optionalAccess', _12 => _12.setQuickFilter, 'call', _13 => _13(n||null)]))}}))),c(e.features,"refresh")&&a.push(d("\u5237\u65B0",e.loading?"\u2026":"\u21BB",()=>{_optionalChain([e, 'access', _14 => _14.onRefresh, 'optionalCall', _15 => _15()]),e.onRefresh||(e.commands?e.commands.refresh():_optionalChain([e, 'access', _16 => _16.api, 'optionalAccess', _17 => _17.isInfinite, 'call', _18 => _18()])?e.api.reload():_optionalChain([e, 'access', _19 => _19.api, 'optionalAccess', _20 => _20.refreshCells, 'call', _21 => _21()]))},e.loading)),c(e.features,"columns")&&a.push(d("\u5217\u8BBE\u7F6E","\u2637",t=>{e.commands?e.commands.openColumns(t.currentTarget):_optionalChain([e, 'access', _22 => _22.api, 'optionalAccess', _23 => _23.openColumnWorkbench, 'call', _24 => _24(t.currentTarget)])})),c(e.features,"density")&&a.push(_react.createElement.call(void 0, "select",{key:"density",className:"mach-toolbar__select",value:_nullishCoalesce(_optionalChain([e, 'access', _25 => _25.api, 'optionalAccess', _26 => _26.getGridOption, 'call', _27 => _27("size")]), () => ("normal")),"aria-label":"\u8868\u683C\u5BC6\u5EA6",onChange:t=>{let n=t.currentTarget.value;e.commands?e.commands.setDensity(n):_optionalChain([e, 'access', _28 => _28.api, 'optionalAccess', _29 => _29.setGridOption, 'call', _30 => _30("size",n)])}},_react.createElement.call(void 0, "option",{value:"compact"},"\u7D27\u51D1"),_react.createElement.call(void 0, "option",{value:"normal"},"\u6807\u51C6"),_react.createElement.call(void 0, "option",{value:"large"},"\u5BBD\u677E"))),a.push(e.children),a}function ee(e){e.commands?e.commands.undo():_optionalChain([e, 'access', _31 => _31.api, 'optionalAccess', _32 => _32.undo, 'call', _33 => _33()])}function ae(e){e.commands?e.commands.redo():_optionalChain([e, 'access', _34 => _34.api, 'optionalAccess', _35 => _35.redo, 'call', _36 => _36()])}function te(e){let a=[];return(_nullishCoalesce(e.selectedCount, () => (0)))>0&&a.push(_react.createElement.call(void 0, "button",{type:"button",className:"mach-toolbar__selection",onClick:()=>_optionalChain([e, 'access', _37 => _37.onClearSelection, 'optionalCall', _38 => _38()])},`\u5DF2\u9009 ${e.selectedCount} \u9879 \xD7`)),c(e.features,"undoRedo")&&(a.push(d("\u64A4\u9500","\u21B6",()=>ee(e),e.commands?!e.commands.canUndo():!_optionalChain([e, 'access', _39 => _39.api, 'optionalAccess', _40 => _40.canUndo, 'call', _41 => _41()]))),a.push(d("\u91CD\u505A","\u21B7",()=>ae(e),e.commands?!e.commands.canRedo():!_optionalChain([e, 'access', _42 => _42.api, 'optionalAccess', _43 => _43.canRedo, 'call', _44 => _44()])))),c(e.features,"export")&&a.push(d("\u5BFC\u51FA CSV","\u21E9",()=>{_optionalChain([e, 'access', _45 => _45.commands, 'optionalAccess', _46 => _46.exportCsv, 'call', _47 => _47(e.exportFilename)])},!e.commands)),c(e.features,"fullscreen")&&a.push(d("\u5168\u5C4F","\u26F6",()=>{_optionalChain([e, 'access', _48 => _48.commands, 'optionalAccess', _49 => _49.toggleFullscreen, 'call', _50 => _50()])},!e.commands)),a.push(e.end),a}function re(e){return _react.createElement.call(void 0, "div",{className:"mach-toolbar",role:"toolbar","aria-label":"\u8868\u683C\u5DE5\u5177\u680F"},_react.createElement.call(void 0, "div",{className:"mach-toolbar__main"},...Z(e)),_react.createElement.call(void 0, "div",{className:"mach-toolbar__aside"},...te(e)))}var _client = require('react-dom/client');function ne(e){return a=>{let r=document.createElement("div");r.className="mach-cell-react",r.style.width="100%";let t=_client.createRoot.call(void 0, r);t.render(_react.createElement.call(void 0, e,a));let n=!1;return{el:r,destroy:()=>{n||(n=!0,window.setTimeout(()=>{t.unmount()},0))}}}}function oe(e){return a=>{let r=document.createElement("div");r.style.height="100%";let t=_client.createRoot.call(void 0, r);t.render(_react.createElement.call(void 0, e,a));let n=!1;return{el:r,destroy:()=>{n||(n=!0,window.setTimeout(()=>{t.unmount()},0))}}}}var pe=N;exports.MachTable = N; exports.MachTableProvider = Q; exports.MachTableToolbar = re; exports.RobotGrid = J; exports.default = pe; exports.reactCellRenderer = ne; exports.reactDetailRenderer = oe; exports.useMachGrid = _chunkZ5XSUQ5Ocjs.a; exports.useMachTableConfig = P; exports.useMachTableController = _chunkZ5XSUQ5Ocjs.d; exports.useMachTableDefaults = j; exports.useMachTableEditing = _chunkZ5XSUQ5Ocjs.b; exports.useMachTableQuery = _chunkZ5XSUQ5Ocjs.c;
|
|
206
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":["import { RobotGrid } from \"./RobotGrid\";\n\nexport { RobotGrid };\nexport { RobotGrid as MachTable };\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\n/** Enables `React.lazy(() => import(\"@agile-team/mach-table-react\"))`. */\nexport default RobotGrid;\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 };\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,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,2BAAC,IAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,iBAAC,CAAC,qBAAC,OAAO,6BAAE,MAAM,qBAAC,CAAC,GAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,2BAAC,CAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,8BAAC,CAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,sBAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAA","file":"D:\\office-project\\wl\\MachTable\\packages\\react\\dist\\index.cjs","sourcesContent":[null]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,27 +1,81 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, MutableRefObject, ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { GridOptions, GridApi, CellRendererParams, RowNode, CellRendererFn, DetailRowRendererParams } from '@agile-team/mach-table';
|
|
3
|
+
import { GridOptions, MachTablePresetSelection, GridApi, MachTableCommands, MachTableRuntimeConfig, ResolvedMachTableConfig, CellRendererParams, RowNode, CellRendererFn, DetailRowRendererParams } from '@agile-team/mach-table';
|
|
4
4
|
export * from '@agile-team/mach-table';
|
|
5
|
+
export { M as MachTablePageRequest, a as MachTablePageResult, b as MachTableQuerySource, c as MachTableRemoteSelectionState, U as UseMachGridReturn, d as UseMachTableControllerOptions, e as UseMachTableControllerReturn, f as UseMachTableEditingOptions, g as UseMachTableEditingReturn, h as UseMachTableQueryOptions, i as UseMachTableQueryReturn, u as useMachGrid, j as useMachTableController, k as useMachTableEditing, l as useMachTableQuery } from './workflows-BhNumPcR.cjs';
|
|
5
6
|
|
|
6
|
-
type
|
|
7
|
+
type AdapterOnlyGridOption = "className" | "ariaLabel" | "ariaLabelledBy" | "ariaDescribedBy";
|
|
8
|
+
type MachTableReactProps<TData = any> = Omit<GridOptions<TData>, AdapterOnlyGridOption> & {
|
|
9
|
+
/** Named application preset(s). Explicit component props still win. */
|
|
10
|
+
preset?: MachTablePresetSelection;
|
|
7
11
|
/** CSS class applied to the React host element. */
|
|
8
12
|
className?: string;
|
|
9
13
|
/** CSS class forwarded to MachTable's inner grid root. */
|
|
10
14
|
gridClassName?: string;
|
|
15
|
+
gridAriaLabel?: string;
|
|
16
|
+
gridAriaLabelledBy?: string;
|
|
17
|
+
gridAriaDescribedBy?: string;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
"aria-labelledby"?: string;
|
|
20
|
+
"aria-describedby"?: string;
|
|
11
21
|
style?: CSSProperties;
|
|
12
22
|
apiRef?: MutableRefObject<GridApi<TData> | null>;
|
|
13
23
|
};
|
|
14
|
-
declare function
|
|
24
|
+
declare function MachTable<TData = any>(props: MachTableReactProps<TData>): react.DetailedReactHTMLElement<{
|
|
15
25
|
ref: MutableRefObject<HTMLDivElement | null>;
|
|
16
26
|
className: string | undefined;
|
|
17
27
|
style: CSSProperties | undefined;
|
|
28
|
+
"aria-label": string | undefined;
|
|
29
|
+
"aria-labelledby": string | undefined;
|
|
30
|
+
"aria-describedby": string | undefined;
|
|
18
31
|
}, HTMLDivElement>;
|
|
32
|
+
/** @deprecated Use MachTable. Kept as a source-compatible alias through 0.x. */
|
|
33
|
+
declare const RobotGrid: typeof MachTable;
|
|
34
|
+
/** @deprecated Use MachTableReactProps. */
|
|
35
|
+
type RobotGridReactProps<TData = any> = MachTableReactProps<TData>;
|
|
19
36
|
|
|
20
|
-
interface
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
interface MachTableToolbarFeatures {
|
|
38
|
+
search?: boolean;
|
|
39
|
+
refresh?: boolean;
|
|
40
|
+
columns?: boolean;
|
|
41
|
+
density?: boolean;
|
|
42
|
+
export?: boolean;
|
|
43
|
+
undoRedo?: boolean;
|
|
44
|
+
fullscreen?: boolean;
|
|
23
45
|
}
|
|
24
|
-
|
|
46
|
+
interface MachTableToolbarProps<TData = any> {
|
|
47
|
+
api?: GridApi<TData> | null;
|
|
48
|
+
commands?: MachTableCommands | null;
|
|
49
|
+
search?: string;
|
|
50
|
+
onSearchChange?(value: string): void;
|
|
51
|
+
onRefresh?(): void;
|
|
52
|
+
onClearSelection?(): void;
|
|
53
|
+
loading?: boolean;
|
|
54
|
+
selectedCount?: number;
|
|
55
|
+
searchPlaceholder?: string;
|
|
56
|
+
exportFilename?: string;
|
|
57
|
+
features?: MachTableToolbarFeatures;
|
|
58
|
+
start?: ReactNode;
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
end?: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
declare function MachTableToolbar<TData = any>(props: MachTableToolbarProps<TData>): react.DetailedReactHTMLElement<{
|
|
63
|
+
className: string;
|
|
64
|
+
role: "toolbar";
|
|
65
|
+
"aria-label": string;
|
|
66
|
+
}, HTMLElement>;
|
|
67
|
+
|
|
68
|
+
interface MachTableProviderProps<TData = any> {
|
|
69
|
+
/** Full app/route configuration. Prefer importing this from mach-table.config.ts. */
|
|
70
|
+
config?: MachTableRuntimeConfig;
|
|
71
|
+
/** Backwards-compatible shorthand for config.defaults. */
|
|
72
|
+
defaults?: Partial<GridOptions<TData>>;
|
|
73
|
+
children?: ReactNode;
|
|
74
|
+
}
|
|
75
|
+
/** Supplies app-, route- or layout-scoped defaults without making tables eager. */
|
|
76
|
+
declare function MachTableProvider<TData = any>({ config, defaults, children }: MachTableProviderProps<TData>): react.FunctionComponentElement<react.ProviderProps<ResolvedMachTableConfig>>;
|
|
77
|
+
declare function useMachTableDefaults<TData = any>(): Partial<GridOptions<TData>>;
|
|
78
|
+
declare function useMachTableConfig(): ResolvedMachTableConfig;
|
|
25
79
|
|
|
26
80
|
interface ReactCellRendererProps<TData = any, TValue = any> extends CellRendererParams<TData, TValue> {
|
|
27
81
|
children?: ReactNode;
|
|
@@ -37,4 +91,4 @@ declare function reactDetailRenderer<TData = any>(Component: ComponentType<React
|
|
|
37
91
|
destroy?: () => void;
|
|
38
92
|
};
|
|
39
93
|
|
|
40
|
-
export {
|
|
94
|
+
export { MachTable, MachTableProvider, type MachTableProviderProps, type MachTableReactProps, MachTableToolbar, type MachTableToolbarFeatures, type MachTableToolbarProps, type ReactCellRendererProps, type ReactDetailProps, RobotGrid, type RobotGridReactProps, MachTable as default, reactCellRenderer, reactDetailRenderer, useMachTableConfig, useMachTableDefaults };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,81 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, MutableRefObject, ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { GridOptions, GridApi, CellRendererParams, RowNode, CellRendererFn, DetailRowRendererParams } from '@agile-team/mach-table';
|
|
3
|
+
import { GridOptions, MachTablePresetSelection, GridApi, MachTableCommands, MachTableRuntimeConfig, ResolvedMachTableConfig, CellRendererParams, RowNode, CellRendererFn, DetailRowRendererParams } from '@agile-team/mach-table';
|
|
4
4
|
export * from '@agile-team/mach-table';
|
|
5
|
+
export { M as MachTablePageRequest, a as MachTablePageResult, b as MachTableQuerySource, c as MachTableRemoteSelectionState, U as UseMachGridReturn, d as UseMachTableControllerOptions, e as UseMachTableControllerReturn, f as UseMachTableEditingOptions, g as UseMachTableEditingReturn, h as UseMachTableQueryOptions, i as UseMachTableQueryReturn, u as useMachGrid, j as useMachTableController, k as useMachTableEditing, l as useMachTableQuery } from './workflows-BhNumPcR.js';
|
|
5
6
|
|
|
6
|
-
type
|
|
7
|
+
type AdapterOnlyGridOption = "className" | "ariaLabel" | "ariaLabelledBy" | "ariaDescribedBy";
|
|
8
|
+
type MachTableReactProps<TData = any> = Omit<GridOptions<TData>, AdapterOnlyGridOption> & {
|
|
9
|
+
/** Named application preset(s). Explicit component props still win. */
|
|
10
|
+
preset?: MachTablePresetSelection;
|
|
7
11
|
/** CSS class applied to the React host element. */
|
|
8
12
|
className?: string;
|
|
9
13
|
/** CSS class forwarded to MachTable's inner grid root. */
|
|
10
14
|
gridClassName?: string;
|
|
15
|
+
gridAriaLabel?: string;
|
|
16
|
+
gridAriaLabelledBy?: string;
|
|
17
|
+
gridAriaDescribedBy?: string;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
"aria-labelledby"?: string;
|
|
20
|
+
"aria-describedby"?: string;
|
|
11
21
|
style?: CSSProperties;
|
|
12
22
|
apiRef?: MutableRefObject<GridApi<TData> | null>;
|
|
13
23
|
};
|
|
14
|
-
declare function
|
|
24
|
+
declare function MachTable<TData = any>(props: MachTableReactProps<TData>): react.DetailedReactHTMLElement<{
|
|
15
25
|
ref: MutableRefObject<HTMLDivElement | null>;
|
|
16
26
|
className: string | undefined;
|
|
17
27
|
style: CSSProperties | undefined;
|
|
28
|
+
"aria-label": string | undefined;
|
|
29
|
+
"aria-labelledby": string | undefined;
|
|
30
|
+
"aria-describedby": string | undefined;
|
|
18
31
|
}, HTMLDivElement>;
|
|
32
|
+
/** @deprecated Use MachTable. Kept as a source-compatible alias through 0.x. */
|
|
33
|
+
declare const RobotGrid: typeof MachTable;
|
|
34
|
+
/** @deprecated Use MachTableReactProps. */
|
|
35
|
+
type RobotGridReactProps<TData = any> = MachTableReactProps<TData>;
|
|
19
36
|
|
|
20
|
-
interface
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
interface MachTableToolbarFeatures {
|
|
38
|
+
search?: boolean;
|
|
39
|
+
refresh?: boolean;
|
|
40
|
+
columns?: boolean;
|
|
41
|
+
density?: boolean;
|
|
42
|
+
export?: boolean;
|
|
43
|
+
undoRedo?: boolean;
|
|
44
|
+
fullscreen?: boolean;
|
|
23
45
|
}
|
|
24
|
-
|
|
46
|
+
interface MachTableToolbarProps<TData = any> {
|
|
47
|
+
api?: GridApi<TData> | null;
|
|
48
|
+
commands?: MachTableCommands | null;
|
|
49
|
+
search?: string;
|
|
50
|
+
onSearchChange?(value: string): void;
|
|
51
|
+
onRefresh?(): void;
|
|
52
|
+
onClearSelection?(): void;
|
|
53
|
+
loading?: boolean;
|
|
54
|
+
selectedCount?: number;
|
|
55
|
+
searchPlaceholder?: string;
|
|
56
|
+
exportFilename?: string;
|
|
57
|
+
features?: MachTableToolbarFeatures;
|
|
58
|
+
start?: ReactNode;
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
end?: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
declare function MachTableToolbar<TData = any>(props: MachTableToolbarProps<TData>): react.DetailedReactHTMLElement<{
|
|
63
|
+
className: string;
|
|
64
|
+
role: "toolbar";
|
|
65
|
+
"aria-label": string;
|
|
66
|
+
}, HTMLElement>;
|
|
67
|
+
|
|
68
|
+
interface MachTableProviderProps<TData = any> {
|
|
69
|
+
/** Full app/route configuration. Prefer importing this from mach-table.config.ts. */
|
|
70
|
+
config?: MachTableRuntimeConfig;
|
|
71
|
+
/** Backwards-compatible shorthand for config.defaults. */
|
|
72
|
+
defaults?: Partial<GridOptions<TData>>;
|
|
73
|
+
children?: ReactNode;
|
|
74
|
+
}
|
|
75
|
+
/** Supplies app-, route- or layout-scoped defaults without making tables eager. */
|
|
76
|
+
declare function MachTableProvider<TData = any>({ config, defaults, children }: MachTableProviderProps<TData>): react.FunctionComponentElement<react.ProviderProps<ResolvedMachTableConfig>>;
|
|
77
|
+
declare function useMachTableDefaults<TData = any>(): Partial<GridOptions<TData>>;
|
|
78
|
+
declare function useMachTableConfig(): ResolvedMachTableConfig;
|
|
25
79
|
|
|
26
80
|
interface ReactCellRendererProps<TData = any, TValue = any> extends CellRendererParams<TData, TValue> {
|
|
27
81
|
children?: ReactNode;
|
|
@@ -37,4 +91,4 @@ declare function reactDetailRenderer<TData = any>(Component: ComponentType<React
|
|
|
37
91
|
destroy?: () => void;
|
|
38
92
|
};
|
|
39
93
|
|
|
40
|
-
export {
|
|
94
|
+
export { MachTable, MachTableProvider, type MachTableProviderProps, type MachTableReactProps, MachTableToolbar, type MachTableToolbarFeatures, type MachTableToolbarProps, type ReactCellRendererProps, type ReactDetailProps, RobotGrid, type RobotGridReactProps, MachTable as default, reactCellRenderer, reactDetailRenderer, useMachTableConfig, useMachTableDefaults };
|
package/dist/index.js
CHANGED
|
@@ -1,177 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
createElement,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef
|
|
6
|
-
} from "react";
|
|
7
|
-
import { createGrid, DIRECT_GRID_OPTION_KEYS, EVENT_TYPES } from "@agile-team/mach-table";
|
|
8
|
-
var UPDATABLE_KEYS = DIRECT_GRID_OPTION_KEYS.filter((key) => key !== "className");
|
|
9
|
-
function RobotGrid(props) {
|
|
10
|
-
const { className, style, apiRef } = props;
|
|
11
|
-
const hostRef = useRef(null);
|
|
12
|
-
const gridApiRef = useRef(null);
|
|
13
|
-
const propsRef = useRef(props);
|
|
14
|
-
propsRef.current = props;
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const host = hostRef.current;
|
|
17
|
-
if (!host) return;
|
|
18
|
-
const initial = propsRef.current;
|
|
19
|
-
const options = {};
|
|
20
|
-
for (const key of Object.keys(initial)) {
|
|
21
|
-
if (key === "className" || key === "gridClassName" || key === "style" || key === "apiRef") continue;
|
|
22
|
-
if (key.startsWith("on")) continue;
|
|
23
|
-
options[key] = initial[key];
|
|
24
|
-
}
|
|
25
|
-
if (initial.gridClassName !== void 0) options.className = initial.gridClassName;
|
|
26
|
-
for (const eventType of EVENT_TYPES) {
|
|
27
|
-
const handlerKey = `on${eventType.charAt(0).toUpperCase()}${eventType.slice(1)}`;
|
|
28
|
-
options[handlerKey] = (event) => {
|
|
29
|
-
const latest = propsRef.current;
|
|
30
|
-
const handler = latest[handlerKey];
|
|
31
|
-
if (typeof handler === "function") handler(event);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const api = createGrid(host, options);
|
|
35
|
-
gridApiRef.current = api;
|
|
36
|
-
return () => {
|
|
37
|
-
api.destroy();
|
|
38
|
-
gridApiRef.current = null;
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (!apiRef) return;
|
|
43
|
-
const assigned = gridApiRef.current;
|
|
44
|
-
apiRef.current = assigned;
|
|
45
|
-
return () => {
|
|
46
|
-
if (apiRef.current === assigned) apiRef.current = null;
|
|
47
|
-
};
|
|
48
|
-
}, [apiRef]);
|
|
49
|
-
const rowDataReady = useRef(false);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!rowDataReady.current) {
|
|
52
|
-
rowDataReady.current = true;
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
gridApiRef.current?.setRowData(props.rowData);
|
|
56
|
-
}, [props.rowData]);
|
|
57
|
-
const columnDefsReady = useRef(false);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!columnDefsReady.current) {
|
|
60
|
-
columnDefsReady.current = true;
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
gridApiRef.current?.setColumnDefs(props.columnDefs);
|
|
64
|
-
}, [props.columnDefs]);
|
|
65
|
-
const quickFilterReady = useRef(false);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (!quickFilterReady.current) {
|
|
68
|
-
quickFilterReady.current = true;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
gridApiRef.current?.setQuickFilter(props.quickFilterText);
|
|
72
|
-
}, [props.quickFilterText]);
|
|
73
|
-
const gridClassNameReady = useRef(false);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (!gridClassNameReady.current) {
|
|
76
|
-
gridClassNameReady.current = true;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
gridApiRef.current?.updateOptions({ className: props.gridClassName });
|
|
80
|
-
}, [props.gridClassName]);
|
|
81
|
-
const optionValues = UPDATABLE_KEYS.map((key) => props[key]);
|
|
82
|
-
const previousOptionValues = useRef(null);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
const previous = previousOptionValues.current;
|
|
85
|
-
previousOptionValues.current = optionValues;
|
|
86
|
-
if (!previous) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const changed = {};
|
|
90
|
-
optionValues.forEach((value, index) => {
|
|
91
|
-
if (!Object.is(value, previous[index])) changed[UPDATABLE_KEYS[index]] = value;
|
|
92
|
-
});
|
|
93
|
-
if (Object.keys(changed).length > 0) {
|
|
94
|
-
gridApiRef.current?.updateOptions(changed);
|
|
95
|
-
}
|
|
96
|
-
}, optionValues);
|
|
97
|
-
return createElement("div", {
|
|
98
|
-
ref: hostRef,
|
|
99
|
-
className: `mach-react-host ${className ?? ""}`.trim() || void 0,
|
|
100
|
-
style
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/useMachGrid.ts
|
|
105
|
-
import { useMemo, useState } from "react";
|
|
106
|
-
function useMachGrid() {
|
|
107
|
-
const [api, setApi] = useState(null);
|
|
108
|
-
const apiRef = useMemo(() => {
|
|
109
|
-
let current = null;
|
|
110
|
-
return Object.defineProperty({}, "current", {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
get: () => current,
|
|
113
|
-
set: (next) => {
|
|
114
|
-
if (next === current) return;
|
|
115
|
-
current = next;
|
|
116
|
-
setApi(next);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}, []);
|
|
120
|
-
return { apiRef, api };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/adapters.ts
|
|
124
|
-
import { createElement as createElement2, isValidElement } from "react";
|
|
125
|
-
import { createRoot } from "react-dom/client";
|
|
126
|
-
function reactCellRenderer(Component) {
|
|
127
|
-
return (params) => {
|
|
128
|
-
const host = document.createElement("div");
|
|
129
|
-
host.className = "mach-cell-react";
|
|
130
|
-
host.style.width = "100%";
|
|
131
|
-
const root = createRoot(host);
|
|
132
|
-
root.render(createElement2(Component, params));
|
|
133
|
-
let destroyed = false;
|
|
134
|
-
return {
|
|
135
|
-
el: host,
|
|
136
|
-
destroy: () => {
|
|
137
|
-
if (destroyed) return;
|
|
138
|
-
destroyed = true;
|
|
139
|
-
window.setTimeout(() => {
|
|
140
|
-
root.unmount();
|
|
141
|
-
}, 0);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function reactDetailRenderer(Component) {
|
|
147
|
-
return (params) => {
|
|
148
|
-
const host = document.createElement("div");
|
|
149
|
-
host.style.height = "100%";
|
|
150
|
-
const root = createRoot(host);
|
|
151
|
-
root.render(createElement2(Component, params));
|
|
152
|
-
let destroyed = false;
|
|
153
|
-
return {
|
|
154
|
-
el: host,
|
|
155
|
-
destroy: () => {
|
|
156
|
-
if (destroyed) return;
|
|
157
|
-
destroyed = true;
|
|
158
|
-
window.setTimeout(() => {
|
|
159
|
-
root.unmount();
|
|
160
|
-
}, 0);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// src/index.ts
|
|
167
|
-
export * from "@agile-team/mach-table";
|
|
168
|
-
var index_default = RobotGrid;
|
|
169
|
-
export {
|
|
170
|
-
RobotGrid as MachTable,
|
|
171
|
-
RobotGrid,
|
|
172
|
-
index_default as default,
|
|
173
|
-
reactCellRenderer,
|
|
174
|
-
reactDetailRenderer,
|
|
175
|
-
useMachGrid
|
|
176
|
-
};
|
|
1
|
+
import{a as L,b as _,c as k,d as F}from"./chunk-VVQCWQ2C.js";import{createElement as $,useEffect as x,useRef as s}from"react";import{createGrid as q,GRID_OPTION_KEYS as h,EVENT_TYPES as K,resolveMachTableGridOptions as Y}from"@agile-team/mach-table";import{createContext as B,createElement as U,useContext as v,useMemo as V}from"react";import{mergeMachTableConfig as z,normalizeMachTableConfig as H}from"@agile-team/mach-table";var I=H(),T=B(I);function Q({config:e,defaults:a,children:r}){let t=v(T),n=V(()=>z(t,{...e??{},...a?{defaults:a}:{}}),[t,e,a]);return U(T.Provider,{value:n},r)}function j(){return v(T).defaults}function P(){return v(T)}function W(e,a){let r={};for(let t of h){if(t==="className")continue;let n=t==="ariaLabel"?e.gridAriaLabel:t==="ariaLabelledBy"?e.gridAriaLabelledBy:t==="ariaDescribedBy"?e.gridAriaDescribedBy:e[t];n!==void 0&&(r[t]=n)}return e.gridClassName!==void 0&&(r.className=e.gridClassName),Y(a,e.preset,r).options}function N(e){let{className:a,style:r,apiRef:t}=e,n=s(null),b=s(null),G=s(e);G.current=e;let O=P(),y=[O,e.preset,...h.map(o=>o==="className"?e.gridClassName:o==="ariaLabel"?e.gridAriaLabel:o==="ariaLabelledBy"?e.gridAriaLabelledBy:o==="ariaDescribedBy"?e.gridAriaDescribedBy:e[o])],u=s(null);(!u.current||u.current.inputs.length!==y.length||y.some((o,i)=>!Object.is(o,u.current?.inputs[i])))&&(u.current={inputs:y,options:W(e,O)});let R=u.current.options,g=s(R);g.current=R,x(()=>{let o=n.current;if(!o)return;let i={...g.current};for(let f of K){let p=`on${f.charAt(0).toUpperCase()}${f.slice(1)}`;i[p]=A=>{let D=g.current[p];typeof D=="function"&&D(A);let C=G.current[p];typeof C=="function"&&C!==D&&C(A)}}let m=q(o,i);return b.current=m,()=>{m.destroy(),b.current=null}},[]),x(()=>{if(!t)return;let o=b.current;return t.current=o,()=>{t.current===o&&(t.current=null)}},[t]);let M=h.map(o=>R[o]),E=s(null);return x(()=>{let o=E.current;if(E.current=M,!o)return;let i={};M.forEach((m,f)=>{Object.is(m,o[f])||(i[h[f]]=m)}),Object.keys(i).length>0&&b.current?.updateOptions(i)},M),$("div",{ref:n,className:`mach-react-host ${a??""}`.trim()||void 0,style:r,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],"aria-describedby":e["aria-describedby"]})}var J=N;import{createElement as l}from"react";var X={search:!0,refresh:!0,columns:!0,density:!0,export:!0,undoRedo:!1,fullscreen:!1};function c(e,a){return e?.[a]??X[a]}function d(e,a,r,t=!1){return l("button",{key:e,type:"button",className:"mach-toolbar__button",title:e,"aria-label":e,disabled:t,onClick:r},a)}function Z(e){let a=[e.start],r=e.searchPlaceholder??"\u641C\u7D22\u5F53\u524D\u7ED3\u679C";return c(e.features,"search")&&a.push(l("label",{className:"mach-toolbar__search",key:"search"},l("span",{className:"mach-sr-only"},r),l("span",{"aria-hidden":!0},"\u2315"),l("input",{type:"search",value:e.search??"",placeholder:r,onChange:t=>{let n=t.currentTarget.value;e.onSearchChange?.(n),e.onSearchChange||(e.commands?e.commands.search(n||null):e.api?.setQuickFilter(n||null))}}))),c(e.features,"refresh")&&a.push(d("\u5237\u65B0",e.loading?"\u2026":"\u21BB",()=>{e.onRefresh?.(),e.onRefresh||(e.commands?e.commands.refresh():e.api?.isInfinite()?e.api.reload():e.api?.refreshCells())},e.loading)),c(e.features,"columns")&&a.push(d("\u5217\u8BBE\u7F6E","\u2637",t=>{e.commands?e.commands.openColumns(t.currentTarget):e.api?.openColumnWorkbench(t.currentTarget)})),c(e.features,"density")&&a.push(l("select",{key:"density",className:"mach-toolbar__select",value:e.api?.getGridOption("size")??"normal","aria-label":"\u8868\u683C\u5BC6\u5EA6",onChange:t=>{let n=t.currentTarget.value;e.commands?e.commands.setDensity(n):e.api?.setGridOption("size",n)}},l("option",{value:"compact"},"\u7D27\u51D1"),l("option",{value:"normal"},"\u6807\u51C6"),l("option",{value:"large"},"\u5BBD\u677E"))),a.push(e.children),a}function ee(e){e.commands?e.commands.undo():e.api?.undo()}function ae(e){e.commands?e.commands.redo():e.api?.redo()}function te(e){let a=[];return(e.selectedCount??0)>0&&a.push(l("button",{type:"button",className:"mach-toolbar__selection",onClick:()=>e.onClearSelection?.()},`\u5DF2\u9009 ${e.selectedCount} \u9879 \xD7`)),c(e.features,"undoRedo")&&(a.push(d("\u64A4\u9500","\u21B6",()=>ee(e),e.commands?!e.commands.canUndo():!e.api?.canUndo())),a.push(d("\u91CD\u505A","\u21B7",()=>ae(e),e.commands?!e.commands.canRedo():!e.api?.canRedo()))),c(e.features,"export")&&a.push(d("\u5BFC\u51FA CSV","\u21E9",()=>{e.commands?.exportCsv(e.exportFilename)},!e.commands)),c(e.features,"fullscreen")&&a.push(d("\u5168\u5C4F","\u26F6",()=>{e.commands?.toggleFullscreen()},!e.commands)),a.push(e.end),a}function re(e){return l("div",{className:"mach-toolbar",role:"toolbar","aria-label":"\u8868\u683C\u5DE5\u5177\u680F"},l("div",{className:"mach-toolbar__main"},...Z(e)),l("div",{className:"mach-toolbar__aside"},...te(e)))}import{createElement as S,isValidElement as ye}from"react";import{createRoot as w}from"react-dom/client";function ne(e){return a=>{let r=document.createElement("div");r.className="mach-cell-react",r.style.width="100%";let t=w(r);t.render(S(e,a));let n=!1;return{el:r,destroy:()=>{n||(n=!0,window.setTimeout(()=>{t.unmount()},0))}}}}function oe(e){return a=>{let r=document.createElement("div");r.style.height="100%";let t=w(r);t.render(S(e,a));let n=!1;return{el:r,destroy:()=>{n||(n=!0,window.setTimeout(()=>{t.unmount()},0))}}}}export*from"@agile-team/mach-table";var pe=N;export{N as MachTable,Q as MachTableProvider,re as MachTableToolbar,J as RobotGrid,pe as default,ne as reactCellRenderer,oe as reactDetailRenderer,L as useMachGrid,P as useMachTableConfig,F as useMachTableController,j as useMachTableDefaults,_ as useMachTableEditing,k as useMachTableQuery};
|
|
177
2
|
//# sourceMappingURL=index.js.map
|