@linzjs/step-ag-grid 7.11.0 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -1
- package/dist/index.js +54 -37
- package/dist/index.js.map +1 -1
- package/dist/step-ag-grid.esm.js +54 -37
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +6 -1
- package/src/utils/testUtil.ts +13 -8
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ Storybook demo deployed at: https://linz.github.io/step-ag-grid/
|
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
|
+
Check `src\stories` for more usage examples
|
|
45
|
+
|
|
44
46
|
```tsx
|
|
45
47
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
46
48
|
import "@linzjs/lui/dist/fonts";
|
|
@@ -133,4 +135,49 @@ const GridDemo = () => {
|
|
|
133
135
|
};
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
## Writing tests
|
|
139
|
+
|
|
140
|
+
The following testing calls can be imported from step-ag-grid:
|
|
141
|
+
|
|
142
|
+
- findRow
|
|
143
|
+
- queryRow
|
|
144
|
+
- selectRow
|
|
145
|
+
- deselectRow
|
|
146
|
+
- findCell
|
|
147
|
+
- selectCell
|
|
148
|
+
- editCell
|
|
149
|
+
- findOpenMenu
|
|
150
|
+
- queryMenuOption
|
|
151
|
+
- findMenuOption
|
|
152
|
+
- clickMenuOption
|
|
153
|
+
- openAndClickMenuOption
|
|
154
|
+
- getMultiSelectOptions
|
|
155
|
+
- findMultiSelectOption
|
|
156
|
+
- clickMultiSelectOption
|
|
157
|
+
- typeOtherInput
|
|
158
|
+
- typeOtherTextArea
|
|
159
|
+
- closeMenu
|
|
160
|
+
- findActionButton
|
|
161
|
+
- clickActionButton
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { render, screen } from "@testing-library/react";
|
|
165
|
+
import { waitFor } from "@testing-library/react";
|
|
166
|
+
import { findRow, GridUpdatingContextProvider, openAndClickMenuOption } from "@linzjs/step-ag-grid";
|
|
167
|
+
|
|
168
|
+
const TestComponent = (): JSX.Element => {
|
|
169
|
+
return (
|
|
170
|
+
<GridUpdatingContextProvider>
|
|
171
|
+
<MyGrid />
|
|
172
|
+
</GridUpdatingContextProvider>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
test("click Delete menu option removes row from the table", async () => {
|
|
177
|
+
await render(<TestComponent />);
|
|
178
|
+
await screen.findByText("My component header");
|
|
179
|
+
expect((await findRow(12345)).getAttribute("row-index")).toBe("1");
|
|
180
|
+
await openAndClickMenuOption(12345, "actions", "Delete");
|
|
181
|
+
await waitFor(async () => expect((await queryRow(12345)).not.toBeDefined());
|
|
182
|
+
});
|
|
183
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -2906,7 +2906,7 @@ var Grid = function (params) {
|
|
|
2906
2906
|
sizeColumnsToFit();
|
|
2907
2907
|
}
|
|
2908
2908
|
}, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
|
|
2909
|
-
return (jsxRuntime.jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2909
|
+
return (jsxRuntime.jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale", gridReady && params.rowData && "Grid-ready") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2910
2910
|
setInternalQuickFilter(event.target.value);
|
|
2911
2911
|
} }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
|
|
2912
2912
|
};
|
|
@@ -24501,17 +24501,36 @@ var _selectRow = function (select, rowId, within) { return __awaiter(void 0, voi
|
|
|
24501
24501
|
return __generator(this, function (_a) {
|
|
24502
24502
|
switch (_a.label) {
|
|
24503
24503
|
case 0: return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24504
|
-
var row, isSelected;
|
|
24504
|
+
var row, isSelected, cell;
|
|
24505
24505
|
return __generator(this, function (_a) {
|
|
24506
24506
|
switch (_a.label) {
|
|
24507
24507
|
case 0: return [4 /*yield*/, findRow(rowId, within)];
|
|
24508
24508
|
case 1:
|
|
24509
24509
|
row = _a.sent();
|
|
24510
|
-
isSelected =
|
|
24511
|
-
if (select === "toggle" || (select === "select" && !isSelected) || (select === "deselect" && isSelected))
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
|
|
24510
|
+
isSelected = row.className.includes("ag-row-selected");
|
|
24511
|
+
if (!(select === "toggle" || (select === "select" && !isSelected) || (select === "deselect" && isSelected))) return [3 /*break*/, 4];
|
|
24512
|
+
return [4 /*yield*/, findCell(rowId, "selection", within)];
|
|
24513
|
+
case 2:
|
|
24514
|
+
cell = _a.sent();
|
|
24515
|
+
userEvent.click(cell);
|
|
24516
|
+
return [4 /*yield*/, waitForWrapper(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24517
|
+
var row, nowSelected;
|
|
24518
|
+
return __generator(this, function (_a) {
|
|
24519
|
+
switch (_a.label) {
|
|
24520
|
+
case 0: return [4 /*yield*/, findRow(rowId, within)];
|
|
24521
|
+
case 1:
|
|
24522
|
+
row = _a.sent();
|
|
24523
|
+
nowSelected = row.className.includes("ag-row-selected");
|
|
24524
|
+
if (nowSelected == isSelected)
|
|
24525
|
+
throw "Row ".concat(rowId, " won't select");
|
|
24526
|
+
return [2 /*return*/];
|
|
24527
|
+
}
|
|
24528
|
+
});
|
|
24529
|
+
}); })];
|
|
24530
|
+
case 3:
|
|
24531
|
+
_a.sent();
|
|
24532
|
+
_a.label = 4;
|
|
24533
|
+
case 4: return [2 /*return*/];
|
|
24515
24534
|
}
|
|
24516
24535
|
});
|
|
24517
24536
|
}); })];
|
|
@@ -24582,22 +24601,25 @@ var selectCell = function (rowId, colId, within) { return __awaiter(void 0, void
|
|
|
24582
24601
|
var editCell = function (rowId, colId, within) { return __awaiter(void 0, void 0, void 0, function () {
|
|
24583
24602
|
return __generator(this, function (_a) {
|
|
24584
24603
|
switch (_a.label) {
|
|
24585
|
-
case 0: return [4 /*yield*/,
|
|
24586
|
-
var cell;
|
|
24587
|
-
return __generator(this, function (_a) {
|
|
24588
|
-
switch (_a.label) {
|
|
24589
|
-
case 0: return [4 /*yield*/, findCell(rowId, colId, within)];
|
|
24590
|
-
case 1:
|
|
24591
|
-
cell = _a.sent();
|
|
24592
|
-
userEvent.dblClick(cell);
|
|
24593
|
-
return [2 /*return*/];
|
|
24594
|
-
}
|
|
24595
|
-
});
|
|
24596
|
-
}); })];
|
|
24604
|
+
case 0: return [4 /*yield*/, selectRow(rowId, within)];
|
|
24597
24605
|
case 1:
|
|
24598
24606
|
_a.sent();
|
|
24599
|
-
return [4 /*yield*/,
|
|
24607
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24608
|
+
var cell;
|
|
24609
|
+
return __generator(this, function (_a) {
|
|
24610
|
+
switch (_a.label) {
|
|
24611
|
+
case 0: return [4 /*yield*/, findCell(rowId, colId, within)];
|
|
24612
|
+
case 1:
|
|
24613
|
+
cell = _a.sent();
|
|
24614
|
+
userEvent.dblClick(cell);
|
|
24615
|
+
return [2 /*return*/];
|
|
24616
|
+
}
|
|
24617
|
+
});
|
|
24618
|
+
}); })];
|
|
24600
24619
|
case 2:
|
|
24620
|
+
_a.sent();
|
|
24621
|
+
return [4 /*yield*/, waitForWrapper(findOpenMenu)];
|
|
24622
|
+
case 3:
|
|
24601
24623
|
_a.sent();
|
|
24602
24624
|
return [2 /*return*/];
|
|
24603
24625
|
}
|
|
@@ -24638,27 +24660,25 @@ var findMenuOption = function (menuOptionText) { return __awaiter(void 0, void 0
|
|
|
24638
24660
|
return [2 /*return*/, menuOption];
|
|
24639
24661
|
}
|
|
24640
24662
|
});
|
|
24641
|
-
}); }, { timeout:
|
|
24663
|
+
}); }, { timeout: 5000 })];
|
|
24642
24664
|
case 1: return [2 /*return*/, _a.sent()];
|
|
24643
24665
|
}
|
|
24644
24666
|
});
|
|
24645
24667
|
}); };
|
|
24646
24668
|
var clickMenuOption = function (menuOptionText) { return __awaiter(void 0, void 0, void 0, function () {
|
|
24669
|
+
var menuOption;
|
|
24647
24670
|
return __generator(this, function (_a) {
|
|
24648
24671
|
switch (_a.label) {
|
|
24649
|
-
case 0: return [4 /*yield*/,
|
|
24650
|
-
var menuOption;
|
|
24651
|
-
return __generator(this, function (_a) {
|
|
24652
|
-
switch (_a.label) {
|
|
24653
|
-
case 0: return [4 /*yield*/, findMenuOption(menuOptionText)];
|
|
24654
|
-
case 1:
|
|
24655
|
-
menuOption = _a.sent();
|
|
24656
|
-
menuOption && userEvent.click(menuOption);
|
|
24657
|
-
return [2 /*return*/];
|
|
24658
|
-
}
|
|
24659
|
-
});
|
|
24660
|
-
}); })];
|
|
24672
|
+
case 0: return [4 /*yield*/, findMenuOption(menuOptionText)];
|
|
24661
24673
|
case 1:
|
|
24674
|
+
menuOption = _a.sent();
|
|
24675
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24676
|
+
return __generator(this, function (_a) {
|
|
24677
|
+
userEvent.click(menuOption);
|
|
24678
|
+
return [2 /*return*/];
|
|
24679
|
+
});
|
|
24680
|
+
}); })];
|
|
24681
|
+
case 2:
|
|
24662
24682
|
_a.sent();
|
|
24663
24683
|
return [2 /*return*/];
|
|
24664
24684
|
}
|
|
@@ -24669,12 +24689,9 @@ var openAndClickMenuOption = function (rowId, colId, menuOptionText, within) { r
|
|
|
24669
24689
|
switch (_a.label) {
|
|
24670
24690
|
case 0: return [4 /*yield*/, editCell(rowId, colId, within)];
|
|
24671
24691
|
case 1:
|
|
24672
|
-
_a.sent();
|
|
24673
|
-
return [4 /*yield*/, wait$2(100)];
|
|
24674
|
-
case 2:
|
|
24675
24692
|
_a.sent();
|
|
24676
24693
|
return [4 /*yield*/, clickMenuOption(menuOptionText)];
|
|
24677
|
-
case
|
|
24694
|
+
case 2:
|
|
24678
24695
|
_a.sent();
|
|
24679
24696
|
return [2 /*return*/];
|
|
24680
24697
|
}
|