@linzjs/step-ag-grid 4.0.3 → 5.0.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/dist/index.js +272 -238
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +1 -13
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +0 -1
- package/dist/src/contexts/GridContext.d.ts +1 -0
- package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
- package/dist/src/contexts/GridUpdatingContext.d.ts +3 -2
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +1 -1
- package/dist/src/lui/FormError.d.ts +6 -0
- package/dist/src/react-menu3/components/MenuItem.d.ts +1 -1
- package/dist/src/react-menu3/components/SubMenu.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +18 -17
- package/dist/src/react-menu3/utils/constants.d.ts +4 -0
- package/dist/src/react-menu3/utils/utils.d.ts +1 -1
- package/dist/step-ag-grid.esm.js +273 -239
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +11 -80
- package/src/components/gridForm/GridFormDropDown.tsx +49 -43
- package/src/components/gridForm/GridFormEditBearing.tsx +1 -2
- package/src/components/gridForm/GridFormMultiSelect.tsx +12 -4
- package/src/components/gridForm/GridFormPopoverMenu.tsx +25 -22
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -14
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -18
- package/src/components/gridForm/GridFormTextArea.tsx +3 -2
- package/src/components/gridForm/GridFormTextInput.tsx +4 -7
- package/src/contexts/GridContext.tsx +4 -0
- package/src/contexts/GridContextProvider.tsx +8 -0
- package/src/contexts/GridPopoverContext.tsx +1 -1
- package/src/contexts/GridPopoverContextProvider.tsx +7 -4
- package/src/contexts/GridUpdatingContext.tsx +7 -1
- package/src/contexts/GridUpdatingContextProvider.tsx +17 -6
- package/src/lui/FormError.tsx +29 -0
- package/src/lui/TextAreaInput.tsx +2 -18
- package/src/lui/TextInputFormatted.tsx +2 -17
- package/src/react-menu3/components/ControlledMenu.tsx +114 -12
- package/src/react-menu3/components/MenuItem.tsx +19 -2
- package/src/react-menu3/types.ts +2 -0
- package/src/react-menu3/utils/constants.ts +4 -0
- package/src/stories/grid/FormTest.tsx +25 -25
- package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +10 -0
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +1 -1
- package/src/stories/grid/GridReadOnly.stories.tsx +11 -11
- package/src/styles/GridFormDropDown.scss +1 -1
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ var subMenuClass = "submenu";
|
|
|
71
71
|
var radioGroupClass = "radio-group";
|
|
72
72
|
var Keys = Object.freeze({
|
|
73
73
|
ENTER: "Enter",
|
|
74
|
+
TAB: "Tab",
|
|
74
75
|
ESC: "Escape",
|
|
75
76
|
SPACE: " ",
|
|
76
77
|
HOME: "Home",
|
|
@@ -94,7 +95,9 @@ var CloseReason = Object.freeze({
|
|
|
94
95
|
CLICK: "click",
|
|
95
96
|
CANCEL: "cancel",
|
|
96
97
|
BLUR: "blur",
|
|
97
|
-
SCROLL: "scroll"
|
|
98
|
+
SCROLL: "scroll",
|
|
99
|
+
TAB_FORWARD: "tab_forward",
|
|
100
|
+
TAB_BACKWARD: "tab_backward"
|
|
98
101
|
});
|
|
99
102
|
var FocusPositions = Object.freeze({
|
|
100
103
|
FIRST: "first",
|
|
@@ -1366,14 +1369,120 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1366
1369
|
ev.stopPropagation();
|
|
1367
1370
|
}
|
|
1368
1371
|
}, [isWithinMenu]);
|
|
1372
|
+
var lastTabDownEl = react.useRef();
|
|
1373
|
+
var lastEnterDownEl = react.useRef();
|
|
1374
|
+
var handleKeyboardTabAndEnter = react.useCallback(function (isDown) { return function (ev) {
|
|
1375
|
+
var thisDocument = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
|
|
1376
|
+
var activeElement = thisDocument.activeElement;
|
|
1377
|
+
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) || !activeElement)
|
|
1378
|
+
return;
|
|
1379
|
+
if (ev.key !== "Tab" && ev.key !== "Enter")
|
|
1380
|
+
return;
|
|
1381
|
+
if (ev.repeat) {
|
|
1382
|
+
ev.preventDefault();
|
|
1383
|
+
ev.stopPropagation();
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
var inputElsIterator = thisDocument.querySelectorAll(".szh-menu--state-open input,textarea");
|
|
1387
|
+
var inputEls = [];
|
|
1388
|
+
inputElsIterator.forEach(function (el) { return inputEls.push(el); });
|
|
1389
|
+
inputEls = inputEls.filter(function (el) { return !el.disabled; });
|
|
1390
|
+
if (inputEls.length === 0)
|
|
1391
|
+
return;
|
|
1392
|
+
var firstInputEl = inputEls[0];
|
|
1393
|
+
var lastInputEl = inputEls[inputEls.length - 1];
|
|
1394
|
+
if (activeElement !== firstInputEl && activeElement !== lastInputEl)
|
|
1395
|
+
return;
|
|
1396
|
+
var suppressAutoSaveEvents = activeElement.getAttribute("data-suppressAutoSaveEvents");
|
|
1397
|
+
var invokeSave = function (reason) {
|
|
1398
|
+
var _a, _b;
|
|
1399
|
+
if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) || suppressAutoSaveEvents)
|
|
1400
|
+
return;
|
|
1401
|
+
(_a = saveButtonRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-reason", reason);
|
|
1402
|
+
(_b = saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
1403
|
+
};
|
|
1404
|
+
var isTextArea = activeElement.nodeName === "TEXTAREA";
|
|
1405
|
+
switch (activeElement.nodeName) {
|
|
1406
|
+
case "TEXTAREA":
|
|
1407
|
+
case "INPUT": {
|
|
1408
|
+
if (activeElement === lastInputEl && activeElement === firstInputEl) {
|
|
1409
|
+
if (ev.key === "Tab") {
|
|
1410
|
+
// Can't forward/backwards tab out of popup
|
|
1411
|
+
ev.preventDefault();
|
|
1412
|
+
ev.stopPropagation();
|
|
1413
|
+
if (isDown) {
|
|
1414
|
+
lastTabDownEl.current = activeElement;
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
lastTabDownEl.current == activeElement &&
|
|
1418
|
+
invokeSave(ev.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
if (ev.key === "Enter" && !isTextArea) {
|
|
1422
|
+
ev.preventDefault();
|
|
1423
|
+
ev.stopPropagation();
|
|
1424
|
+
if (isDown) {
|
|
1425
|
+
lastEnterDownEl.current = activeElement;
|
|
1426
|
+
}
|
|
1427
|
+
else {
|
|
1428
|
+
lastEnterDownEl.current == activeElement && invokeSave(CloseReason.CLICK);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
else if (activeElement === lastInputEl) {
|
|
1433
|
+
if (ev.key === "Tab" && !ev.shiftKey) {
|
|
1434
|
+
// Can't backward tab out of popup
|
|
1435
|
+
ev.preventDefault();
|
|
1436
|
+
ev.stopPropagation();
|
|
1437
|
+
if (isDown) {
|
|
1438
|
+
lastTabDownEl.current = activeElement;
|
|
1439
|
+
}
|
|
1440
|
+
else {
|
|
1441
|
+
lastTabDownEl.current == activeElement && invokeSave(CloseReason.TAB_FORWARD);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
if (ev.key === "Enter" && !isTextArea) {
|
|
1445
|
+
ev.preventDefault();
|
|
1446
|
+
ev.stopPropagation();
|
|
1447
|
+
if (isDown) {
|
|
1448
|
+
lastEnterDownEl.current = activeElement;
|
|
1449
|
+
}
|
|
1450
|
+
else {
|
|
1451
|
+
lastEnterDownEl.current == activeElement && invokeSave(CloseReason.CLICK);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
else if (activeElement === firstInputEl) {
|
|
1456
|
+
if (ev.key === "Tab" && ev.shiftKey) {
|
|
1457
|
+
// Can't backward tab out of popup
|
|
1458
|
+
ev.preventDefault();
|
|
1459
|
+
ev.stopPropagation();
|
|
1460
|
+
if (isDown) {
|
|
1461
|
+
lastTabDownEl.current = activeElement;
|
|
1462
|
+
}
|
|
1463
|
+
else {
|
|
1464
|
+
lastTabDownEl.current == activeElement && invokeSave(CloseReason.TAB_BACKWARD);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}; }, [anchorRef, saveButtonRef]);
|
|
1472
|
+
var handleKeydownTabAndEnter = react.useMemo(function () { return handleKeyboardTabAndEnter(true); }, [handleKeyboardTabAndEnter]);
|
|
1473
|
+
var handleKeyupTabAndEnter = react.useMemo(function () { return handleKeyboardTabAndEnter(false); }, [handleKeyboardTabAndEnter]);
|
|
1369
1474
|
react.useEffect(function () {
|
|
1370
1475
|
if (isMenuOpen(state)) {
|
|
1371
1476
|
var thisDocument_1 = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
|
|
1477
|
+
thisDocument_1.addEventListener("keydown", handleKeydownTabAndEnter, true);
|
|
1478
|
+
thisDocument_1.addEventListener("keyup", handleKeyupTabAndEnter, true);
|
|
1372
1479
|
thisDocument_1.addEventListener("mousedown", handleScreenEventForSave, true);
|
|
1373
1480
|
thisDocument_1.addEventListener("mouseup", handleScreenEventForCancel, true);
|
|
1374
1481
|
thisDocument_1.addEventListener("click", handleScreenEventForCancel, true);
|
|
1375
1482
|
thisDocument_1.addEventListener("dblclick", handleScreenEventForCancel, true);
|
|
1376
1483
|
return function () {
|
|
1484
|
+
thisDocument_1.addEventListener("keydown", handleKeydownTabAndEnter, true);
|
|
1485
|
+
thisDocument_1.addEventListener("keyup", handleKeyupTabAndEnter, true);
|
|
1377
1486
|
thisDocument_1.removeEventListener("mousedown", handleScreenEventForSave, true);
|
|
1378
1487
|
thisDocument_1.removeEventListener("mouseup", handleScreenEventForCancel, true);
|
|
1379
1488
|
thisDocument_1.removeEventListener("click", handleScreenEventForCancel, true);
|
|
@@ -1381,7 +1490,14 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1381
1490
|
};
|
|
1382
1491
|
}
|
|
1383
1492
|
return function () { };
|
|
1384
|
-
}, [
|
|
1493
|
+
}, [
|
|
1494
|
+
handleScreenEventForSave,
|
|
1495
|
+
handleScreenEventForCancel,
|
|
1496
|
+
state,
|
|
1497
|
+
anchorRef,
|
|
1498
|
+
handleKeydownTabAndEnter,
|
|
1499
|
+
handleKeyupTabAndEnter,
|
|
1500
|
+
]);
|
|
1385
1501
|
var itemSettings = react.useMemo(function () { return ({
|
|
1386
1502
|
submenuOpenDelay: submenuOpenDelay,
|
|
1387
1503
|
submenuCloseDelay: submenuCloseDelay
|
|
@@ -1676,8 +1792,11 @@ var MenuItemFr = function (_a) {
|
|
|
1676
1792
|
value: value,
|
|
1677
1793
|
syntheticEvent: e
|
|
1678
1794
|
};
|
|
1679
|
-
if (e.key !== undefined)
|
|
1680
|
-
|
|
1795
|
+
if (e.key !== undefined) {
|
|
1796
|
+
var ke = e;
|
|
1797
|
+
event.key = ke.key;
|
|
1798
|
+
event.shiftKey = ke.shiftKey;
|
|
1799
|
+
}
|
|
1681
1800
|
if (isCheckBox)
|
|
1682
1801
|
event.checked = !isChecked;
|
|
1683
1802
|
if (isRadio)
|
|
@@ -1687,6 +1806,13 @@ var MenuItemFr = function (_a) {
|
|
|
1687
1806
|
safeCall(radioGroup.onRadioChange, event);
|
|
1688
1807
|
eventHandlers.handleClick(event, isCheckBox || isRadio);
|
|
1689
1808
|
};
|
|
1809
|
+
var handleKeyDown = function (e) {
|
|
1810
|
+
// if tab is allowed the handleKeyUp event can't process the tab
|
|
1811
|
+
if (e.key === "Tab") {
|
|
1812
|
+
e.preventDefault();
|
|
1813
|
+
e.stopPropagation();
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1690
1816
|
/**
|
|
1691
1817
|
* Keyboard events are triggered on up, otherwise sub-components get spaces and enters typed in them
|
|
1692
1818
|
*/
|
|
@@ -1695,7 +1821,10 @@ var MenuItemFr = function (_a) {
|
|
|
1695
1821
|
return;
|
|
1696
1822
|
switch (e.key) {
|
|
1697
1823
|
case Keys.ENTER:
|
|
1824
|
+
case Keys.TAB:
|
|
1698
1825
|
case Keys.SPACE:
|
|
1826
|
+
e.preventDefault();
|
|
1827
|
+
e.stopPropagation();
|
|
1699
1828
|
if (isAnchor) {
|
|
1700
1829
|
(menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.click();
|
|
1701
1830
|
}
|
|
@@ -1712,7 +1841,7 @@ var MenuItemFr = function (_a) {
|
|
|
1712
1841
|
checked: isChecked,
|
|
1713
1842
|
anchor: isAnchor
|
|
1714
1843
|
}); }, [type, isDisabled, isHovering, isChecked, isAnchor]);
|
|
1715
|
-
var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
|
|
1844
|
+
var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
|
|
1716
1845
|
// Order of props overriding (same in all components):
|
|
1717
1846
|
// 1. Preset props adhering to WAI-ARIA Authoring Practices.
|
|
1718
1847
|
// 2. Merged outer and local props
|
|
@@ -1857,6 +1986,9 @@ var GridContext = react.createContext({
|
|
|
1857
1986
|
}); },
|
|
1858
1987
|
redrawRows: function () {
|
|
1859
1988
|
console.error("no context provider for redrawRows");
|
|
1989
|
+
},
|
|
1990
|
+
selectNextCell: function () {
|
|
1991
|
+
console.error("no context provider for selectNextCell");
|
|
1860
1992
|
}
|
|
1861
1993
|
});
|
|
1862
1994
|
|
|
@@ -1870,7 +2002,8 @@ var GridUpdatingContext = react.createContext({
|
|
|
1870
2002
|
console.error("Missing GridUpdatingContext");
|
|
1871
2003
|
return [2 /*return*/];
|
|
1872
2004
|
});
|
|
1873
|
-
}); }
|
|
2005
|
+
}); },
|
|
2006
|
+
updatedDep: 0
|
|
1874
2007
|
});
|
|
1875
2008
|
|
|
1876
2009
|
/**
|
|
@@ -2130,6 +2263,15 @@ var GridContextProvider = function (props) {
|
|
|
2130
2263
|
gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
|
|
2131
2264
|
});
|
|
2132
2265
|
};
|
|
2266
|
+
var selectNextCell = function (tabDirection) {
|
|
2267
|
+
if (tabDirection === void 0) { tabDirection = 0; }
|
|
2268
|
+
gridApiOp(function (gridApi) {
|
|
2269
|
+
if (tabDirection == 1)
|
|
2270
|
+
gridApi.tabToNextCell();
|
|
2271
|
+
if (tabDirection == -1)
|
|
2272
|
+
gridApi.tabToPreviousCell();
|
|
2273
|
+
});
|
|
2274
|
+
};
|
|
2133
2275
|
return (jsxRuntime.jsx(GridContext.Provider, __assign({ value: {
|
|
2134
2276
|
gridReady: gridReady,
|
|
2135
2277
|
setGridApi: setGridApi,
|
|
@@ -2148,34 +2290,42 @@ var GridContextProvider = function (props) {
|
|
|
2148
2290
|
sizeColumnsToFit: sizeColumnsToFit,
|
|
2149
2291
|
stopEditing: stopEditing,
|
|
2150
2292
|
updatingCells: updatingCells,
|
|
2151
|
-
redrawRows: redrawRows
|
|
2293
|
+
redrawRows: redrawRows,
|
|
2294
|
+
selectNextCell: selectNextCell
|
|
2152
2295
|
} }, { children: props.children })));
|
|
2153
2296
|
};
|
|
2154
2297
|
|
|
2155
2298
|
var GridUpdatingContextProvider = function (props) {
|
|
2156
2299
|
var updatingBlocks = react.useRef({});
|
|
2157
2300
|
var updating = react.useRef({});
|
|
2301
|
+
var _a = react.useState(0), updatedDep = _a[0], setUpdatedDep = _a[1];
|
|
2158
2302
|
var resetUpdating = function () {
|
|
2159
2303
|
var mergedUpdatingBlocks = {};
|
|
2160
2304
|
for (var key in updatingBlocks.current) {
|
|
2161
2305
|
mergedUpdatingBlocks[key] = lodashEs.flatten(updatingBlocks.current[key]);
|
|
2162
2306
|
}
|
|
2163
2307
|
updating.current = mergedUpdatingBlocks;
|
|
2308
|
+
setUpdatedDep(function (updatedDep) { return updatedDep + 1; });
|
|
2164
2309
|
};
|
|
2165
|
-
var modifyUpdating = function (
|
|
2166
|
-
var
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
switch (_b.label) {
|
|
2310
|
+
var modifyUpdating = function (fields, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2311
|
+
var idRef;
|
|
2312
|
+
return __generator(this, function (_a) {
|
|
2313
|
+
switch (_a.label) {
|
|
2170
2314
|
case 0:
|
|
2171
|
-
fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
|
|
2172
2315
|
idRef = __spreadArray([], ids, true);
|
|
2173
|
-
|
|
2316
|
+
lodashEs.castArray(fields).forEach(function (field) {
|
|
2317
|
+
var _a;
|
|
2318
|
+
var fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
|
|
2319
|
+
fieldUpdatingIds.push(idRef);
|
|
2320
|
+
});
|
|
2174
2321
|
resetUpdating();
|
|
2175
2322
|
return [4 /*yield*/, fn()];
|
|
2176
2323
|
case 1:
|
|
2177
|
-
|
|
2178
|
-
lodashEs.
|
|
2324
|
+
_a.sent();
|
|
2325
|
+
lodashEs.castArray(fields).forEach(function (field) {
|
|
2326
|
+
var fieldUpdatingIds = updatingBlocks.current[field];
|
|
2327
|
+
lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
|
|
2328
|
+
});
|
|
2179
2329
|
resetUpdating();
|
|
2180
2330
|
return [2 /*return*/];
|
|
2181
2331
|
}
|
|
@@ -2184,7 +2334,7 @@ var GridUpdatingContextProvider = function (props) {
|
|
|
2184
2334
|
var checkUpdating = function (fields, id) {
|
|
2185
2335
|
return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
|
|
2186
2336
|
};
|
|
2187
|
-
return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
|
|
2337
|
+
return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating, updatedDep: updatedDep } }, { children: props.children })));
|
|
2188
2338
|
};
|
|
2189
2339
|
|
|
2190
2340
|
var GridPopoverContext = react.createContext({
|
|
@@ -2206,7 +2356,7 @@ var useGridPopoverContext = function () {
|
|
|
2206
2356
|
var GridPopoverContextProvider = function (_a) {
|
|
2207
2357
|
var _b, _c, _d;
|
|
2208
2358
|
var props = _a.props, children = _a.children;
|
|
2209
|
-
var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing;
|
|
2359
|
+
var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing, selectNextCell = _e.selectNextCell;
|
|
2210
2360
|
var anchorRef = react.useRef(props.eGridCell);
|
|
2211
2361
|
var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
|
|
2212
2362
|
var colDef = props.colDef;
|
|
@@ -2215,7 +2365,7 @@ var GridPopoverContextProvider = function (_a) {
|
|
|
2215
2365
|
// Then item that is clicked on will always be first in the list
|
|
2216
2366
|
var selectedRows = react.useMemo(function () { return (multiEdit ? lodashEs.sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
|
|
2217
2367
|
var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
|
|
2218
|
-
var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2368
|
+
var updateValue = react.useCallback(function (saveFn, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2219
2369
|
var result;
|
|
2220
2370
|
return __generator(this, function (_a) {
|
|
2221
2371
|
switch (_a.label) {
|
|
@@ -2225,13 +2375,15 @@ var GridPopoverContextProvider = function (_a) {
|
|
|
2225
2375
|
return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
|
|
2226
2376
|
case 1:
|
|
2227
2377
|
result = _a.sent();
|
|
2228
|
-
if (result)
|
|
2378
|
+
if (result) {
|
|
2229
2379
|
stopEditing();
|
|
2380
|
+
tabDirection && selectNextCell(tabDirection);
|
|
2381
|
+
}
|
|
2230
2382
|
_a.label = 2;
|
|
2231
2383
|
case 2: return [2 /*return*/, result];
|
|
2232
2384
|
}
|
|
2233
2385
|
});
|
|
2234
|
-
}); }, [field, saving, selectedRows, stopEditing, updatingCells]);
|
|
2386
|
+
}); }, [field, saving, selectNextCell, selectedRows, stopEditing, updatingCells]);
|
|
2235
2387
|
return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
|
|
2236
2388
|
anchorRef: anchorRef,
|
|
2237
2389
|
saving: saving,
|
|
@@ -2261,43 +2413,7 @@ var GridSubComponentContext = react.createContext({
|
|
|
2261
2413
|
}); }
|
|
2262
2414
|
});
|
|
2263
2415
|
|
|
2264
|
-
function
|
|
2265
|
-
var k, y, str='';
|
|
2266
|
-
if (mix) {
|
|
2267
|
-
if (typeof mix === 'object') {
|
|
2268
|
-
if (Array.isArray(mix)) {
|
|
2269
|
-
for (k=0; k < mix.length; k++) {
|
|
2270
|
-
if (mix[k] && (y = toVal(mix[k]))) {
|
|
2271
|
-
str && (str += ' ');
|
|
2272
|
-
str += y;
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
} else {
|
|
2276
|
-
for (k in mix) {
|
|
2277
|
-
if (mix[k] && (y = toVal(k))) {
|
|
2278
|
-
str && (str += ' ');
|
|
2279
|
-
str += y;
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
} else if (typeof mix !== 'boolean' && !mix.call) {
|
|
2284
|
-
str && (str += ' ');
|
|
2285
|
-
str += mix;
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
return str;
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
function clsx () {
|
|
2292
|
-
var i=0, x, str='';
|
|
2293
|
-
while (i < arguments.length) {
|
|
2294
|
-
if (x = toVal(arguments[i++])) {
|
|
2295
|
-
str && (str += ' ');
|
|
2296
|
-
str += x;
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
return str;
|
|
2300
|
-
}
|
|
2416
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
2301
2417
|
|
|
2302
2418
|
/**
|
|
2303
2419
|
* Retains last sort order from via <AgGrid postRowSort>.
|
|
@@ -2814,7 +2930,7 @@ var useGridPopoverHook = function (props) {
|
|
|
2814
2930
|
// forms that don't provide an invalid fn must wait until they have saved to close
|
|
2815
2931
|
if (props.invalid)
|
|
2816
2932
|
stopEditing();
|
|
2817
|
-
return [4 /*yield*/, updateValue(props.save)];
|
|
2933
|
+
return [4 /*yield*/, updateValue(props.save, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
|
|
2818
2934
|
case 2:
|
|
2819
2935
|
if (_a.sent()) {
|
|
2820
2936
|
if (!props.invalid)
|
|
@@ -2825,72 +2941,6 @@ var useGridPopoverHook = function (props) {
|
|
|
2825
2941
|
}
|
|
2826
2942
|
});
|
|
2827
2943
|
}); }, [props, stopEditing, updateValue]);
|
|
2828
|
-
var onlyInputKeyboardEventHandlers = {
|
|
2829
|
-
onKeyUp: function (e) {
|
|
2830
|
-
var isTextArea = e.currentTarget.type === "textarea";
|
|
2831
|
-
if (e.key === "Enter" && !isTextArea) {
|
|
2832
|
-
e.preventDefault();
|
|
2833
|
-
e.stopPropagation();
|
|
2834
|
-
triggerSave().then();
|
|
2835
|
-
}
|
|
2836
|
-
else if (e.key === "Tab") {
|
|
2837
|
-
e.preventDefault();
|
|
2838
|
-
e.stopPropagation();
|
|
2839
|
-
}
|
|
2840
|
-
},
|
|
2841
|
-
onKeyDown: function (e) {
|
|
2842
|
-
var isTextArea = e.currentTarget.type === "textarea";
|
|
2843
|
-
if (e.key === "Enter" && !isTextArea) {
|
|
2844
|
-
e.preventDefault();
|
|
2845
|
-
e.stopPropagation();
|
|
2846
|
-
}
|
|
2847
|
-
else if (e.key === "Tab") {
|
|
2848
|
-
e.preventDefault();
|
|
2849
|
-
e.stopPropagation();
|
|
2850
|
-
!e.shiftKey && triggerSave().then();
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
};
|
|
2854
|
-
var firstInputKeyboardEventHandlers = {
|
|
2855
|
-
onKeyUp: function (e) {
|
|
2856
|
-
if (e.key === "Tab" && e.shiftKey) {
|
|
2857
|
-
e.preventDefault();
|
|
2858
|
-
e.stopPropagation();
|
|
2859
|
-
}
|
|
2860
|
-
},
|
|
2861
|
-
onKeyDown: function (e) {
|
|
2862
|
-
if (e.key === "Tab" && e.shiftKey) {
|
|
2863
|
-
e.preventDefault();
|
|
2864
|
-
e.stopPropagation();
|
|
2865
|
-
}
|
|
2866
|
-
}
|
|
2867
|
-
};
|
|
2868
|
-
var lastInputKeyboardEventHandlers = {
|
|
2869
|
-
onKeyUp: function (e) {
|
|
2870
|
-
var isTextArea = e.currentTarget.type === "textarea";
|
|
2871
|
-
if (e.key === "Enter" && !isTextArea) {
|
|
2872
|
-
e.preventDefault();
|
|
2873
|
-
e.stopPropagation();
|
|
2874
|
-
triggerSave().then();
|
|
2875
|
-
}
|
|
2876
|
-
else if (e.key === "Tab" && !e.shiftKey) {
|
|
2877
|
-
e.preventDefault();
|
|
2878
|
-
e.stopPropagation();
|
|
2879
|
-
}
|
|
2880
|
-
},
|
|
2881
|
-
onKeyDown: function (e) {
|
|
2882
|
-
var isTextArea = e.currentTarget.type === "textarea";
|
|
2883
|
-
if (e.key === "Enter" && !isTextArea) {
|
|
2884
|
-
e.preventDefault();
|
|
2885
|
-
e.stopPropagation();
|
|
2886
|
-
}
|
|
2887
|
-
else if (e.key === "Tab" && !e.shiftKey) {
|
|
2888
|
-
e.preventDefault();
|
|
2889
|
-
e.stopPropagation();
|
|
2890
|
-
triggerSave().then();
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
2944
|
var popoverWrapper = react.useCallback(function (children) {
|
|
2895
2945
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: anchorRef.current && (jsxRuntime.jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
|
|
2896
2946
|
// Prevent menu from closing when modals are invoked
|
|
@@ -2906,16 +2956,14 @@ var useGridPopoverHook = function (props) {
|
|
|
2906
2956
|
right: 0,
|
|
2907
2957
|
backgroundColor: "rgba(64,64,64,0.1)",
|
|
2908
2958
|
zIndex: 1000
|
|
2909
|
-
} })), children, jsxRuntime.jsx("button", { ref: saveButtonRef, onClick: function () {
|
|
2910
|
-
|
|
2959
|
+
} })), children, jsxRuntime.jsx("button", { ref: saveButtonRef, "data-reason": "", onClick: function (e) {
|
|
2960
|
+
var _a;
|
|
2961
|
+
triggerSave((_a = e.currentTarget.getAttribute("data-reason")) !== null && _a !== void 0 ? _a : undefined).then();
|
|
2911
2962
|
}, style: { display: "none" } })] }))) }));
|
|
2912
2963
|
}, [anchorRef, isOpen, props.className, saving, triggerSave]);
|
|
2913
2964
|
return {
|
|
2914
2965
|
popoverWrapper: popoverWrapper,
|
|
2915
|
-
triggerSave: triggerSave
|
|
2916
|
-
onlyInputKeyboardEventHandlers: onlyInputKeyboardEventHandlers,
|
|
2917
|
-
firstInputKeyboardEventHandlers: firstInputKeyboardEventHandlers,
|
|
2918
|
-
lastInputKeyboardEventHandlers: lastInputKeyboardEventHandlers
|
|
2966
|
+
triggerSave: triggerSave
|
|
2919
2967
|
};
|
|
2920
2968
|
};
|
|
2921
2969
|
|
|
@@ -2941,7 +2989,7 @@ var GridRenderPopoutMenuCell = function (props) {
|
|
|
2941
2989
|
var css_248z$5 = ".GridMultiSelect-containerSmall .GridFormMultiSelect-options{max-height:130px;overflow-y:auto}.GridMultiSelect-containerMedium .GridFormMultiSelect-options{max-height:190px;overflow-y:auto}.GridMultiSelect-containerLarge .GridFormMultiSelect-options{max-height:320px;overflow-y:auto}.GridMultiSelect-containerUnlimited .GridFormMultiSelect-options{overflow-y:auto}";
|
|
2942
2990
|
styleInject(css_248z$5);
|
|
2943
2991
|
|
|
2944
|
-
var css_248z$4 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:
|
|
2992
|
+
var css_248z$4 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:220px;overflow-y:auto}.GridPopoverEditDropDown-containerLarge .GridFormDropDown-options{max-height:400px;overflow-y:auto}.GridPopoverEditDropDown-containerUnlimited .GridFormDropDown-options{overflow-y:auto}";
|
|
2945
2993
|
styleInject(css_248z$4);
|
|
2946
2994
|
|
|
2947
2995
|
/* global setTimeout, clearTimeout */
|
|
@@ -3026,7 +3074,6 @@ var fieldToString = function (field) {
|
|
|
3026
3074
|
};
|
|
3027
3075
|
var GridFormDropDown = function (props) {
|
|
3028
3076
|
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
|
|
3029
|
-
var stopEditing = react.useContext(GridContext).stopEditing;
|
|
3030
3077
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
3031
3078
|
var hasSubmitted = react.useRef(false);
|
|
3032
3079
|
var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
|
|
@@ -3036,7 +3083,7 @@ var GridFormDropDown = function (props) {
|
|
|
3036
3083
|
var subComponentIsValid = react.useRef(false);
|
|
3037
3084
|
var _e = react.useState(), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
|
|
3038
3085
|
var _f = react.useState(null), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
|
|
3039
|
-
var selectItemHandler = react.useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3086
|
+
var selectItemHandler = react.useCallback(function (value, subComponentValue, reason) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3040
3087
|
return __generator(this, function (_a) {
|
|
3041
3088
|
if (hasSubmitted.current || (subComponentValue !== undefined && !subComponentIsValid.current))
|
|
3042
3089
|
return [2 /*return*/, false];
|
|
@@ -3059,7 +3106,7 @@ var GridFormDropDown = function (props) {
|
|
|
3059
3106
|
case 3: return [2 /*return*/, true];
|
|
3060
3107
|
}
|
|
3061
3108
|
});
|
|
3062
|
-
}); })];
|
|
3109
|
+
}); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
|
|
3063
3110
|
});
|
|
3064
3111
|
}); }, [field, props, updateValue]);
|
|
3065
3112
|
var selectFilterHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3079,7 +3126,7 @@ var GridFormDropDown = function (props) {
|
|
|
3079
3126
|
return [2 /*return*/, true];
|
|
3080
3127
|
}
|
|
3081
3128
|
});
|
|
3082
|
-
}); })];
|
|
3129
|
+
}); }, 0)];
|
|
3083
3130
|
});
|
|
3084
3131
|
}); }, [props, updateValue]);
|
|
3085
3132
|
// Load up options list if it's async function
|
|
@@ -3153,52 +3200,48 @@ var GridFormDropDown = function (props) {
|
|
|
3153
3200
|
researchOnFilterChange().then();
|
|
3154
3201
|
}
|
|
3155
3202
|
}, [filter, props, researchOnFilterChange]);
|
|
3156
|
-
var
|
|
3203
|
+
var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3157
3204
|
var activeOptions;
|
|
3158
3205
|
return __generator(this, function (_a) {
|
|
3159
3206
|
switch (_a.label) {
|
|
3160
3207
|
case 0:
|
|
3161
3208
|
if (!options)
|
|
3162
|
-
return [2 /*return
|
|
3163
|
-
if (!(e.key == "Enter" || e.key == "Tab")) return [3 /*break*/, 5];
|
|
3209
|
+
return [2 /*return*/, true];
|
|
3164
3210
|
activeOptions = options.filter(function (option) { return !filteredValues.includes(option.value); });
|
|
3165
|
-
if (!(activeOptions.length
|
|
3211
|
+
if (!(activeOptions.length === 1)) return [3 /*break*/, 2];
|
|
3166
3212
|
return [4 /*yield*/, selectItemHandler(activeOptions[0].value)];
|
|
3167
3213
|
case 1:
|
|
3168
3214
|
_a.sent();
|
|
3169
|
-
|
|
3170
|
-
return [3 /*break*/, 5];
|
|
3215
|
+
return [3 /*break*/, 6];
|
|
3171
3216
|
case 2:
|
|
3172
|
-
if (!props.onSelectFilter) return [3 /*break*/, 4];
|
|
3217
|
+
if (!(activeOptions.length === 0 && props.onSelectFilter)) return [3 /*break*/, 4];
|
|
3173
3218
|
return [4 /*yield*/, selectFilterHandler(filter)];
|
|
3174
3219
|
case 3:
|
|
3175
3220
|
_a.sent();
|
|
3176
|
-
|
|
3177
|
-
return [3 /*break*/, 5];
|
|
3221
|
+
return [3 /*break*/, 6];
|
|
3178
3222
|
case 4:
|
|
3179
|
-
e.preventDefault();
|
|
3180
|
-
e.stopPropagation();
|
|
3181
|
-
_a.label = 5;
|
|
3182
|
-
case 5: return [2 /*return*/];
|
|
3183
|
-
}
|
|
3184
|
-
});
|
|
3185
|
-
}); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props]);
|
|
3186
|
-
var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3187
|
-
return __generator(this, function (_a) {
|
|
3188
|
-
switch (_a.label) {
|
|
3189
|
-
case 0:
|
|
3190
3223
|
// Handler for sub-selected value
|
|
3191
3224
|
if (!selectedSubComponent)
|
|
3192
3225
|
return [2 /*return*/, true];
|
|
3193
3226
|
if (selectedSubComponent.subComponent && !subComponentIsValid.current)
|
|
3194
3227
|
return [2 /*return*/, false];
|
|
3195
3228
|
return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
|
|
3196
|
-
case
|
|
3229
|
+
case 5:
|
|
3197
3230
|
_a.sent();
|
|
3198
|
-
|
|
3231
|
+
_a.label = 6;
|
|
3232
|
+
case 6: return [2 /*return*/, true];
|
|
3199
3233
|
}
|
|
3200
3234
|
});
|
|
3201
|
-
}); }, [
|
|
3235
|
+
}); }, [
|
|
3236
|
+
filter,
|
|
3237
|
+
filteredValues,
|
|
3238
|
+
options,
|
|
3239
|
+
props.onSelectFilter,
|
|
3240
|
+
selectFilterHandler,
|
|
3241
|
+
selectItemHandler,
|
|
3242
|
+
selectedSubComponent,
|
|
3243
|
+
subSelectedValue,
|
|
3244
|
+
]);
|
|
3202
3245
|
var popoverWrapper = useGridPopoverHook({
|
|
3203
3246
|
className: props.className,
|
|
3204
3247
|
invalid: function () { return !!(selectedSubComponent && !subComponentIsValid.current); },
|
|
@@ -3207,7 +3250,7 @@ var GridFormDropDown = function (props) {
|
|
|
3207
3250
|
return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
|
|
3208
3251
|
var _b;
|
|
3209
3252
|
var ref = _a.ref;
|
|
3210
|
-
return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }
|
|
3253
|
+
return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); } }) })));
|
|
3211
3254
|
} })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && (jsxRuntime.jsx(MenuItem, { children: "[Empty]" }, "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3212
3255
|
var _a;
|
|
3213
3256
|
return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
|
|
@@ -3224,7 +3267,11 @@ var GridFormDropDown = function (props) {
|
|
|
3224
3267
|
e.keepOpen = true;
|
|
3225
3268
|
}
|
|
3226
3269
|
else {
|
|
3227
|
-
selectItemHandler(item.value
|
|
3270
|
+
selectItemHandler(item.value, undefined, e.key === "Tab"
|
|
3271
|
+
? e.shiftKey
|
|
3272
|
+
? CloseReason.TAB_BACKWARD
|
|
3273
|
+
: CloseReason.TAB_FORWARD
|
|
3274
|
+
: CloseReason.CLICK).then();
|
|
3228
3275
|
}
|
|
3229
3276
|
} }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedSubComponent === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3230
3277
|
data: data,
|
|
@@ -3258,6 +3305,10 @@ var GridFormMultiSelect = function (props) {
|
|
|
3258
3305
|
var _d = react.useState([]), filteredValues = _d[0], setFilteredValues = _d[1];
|
|
3259
3306
|
var optionsInitialising = react.useRef(false);
|
|
3260
3307
|
var _e = react.useState(), options = _e[0], setOptions = _e[1];
|
|
3308
|
+
var invalid = react.useCallback(function () {
|
|
3309
|
+
var validations = lodashEs.pick(subComponentIsValid.current, Object.keys(selectedValues));
|
|
3310
|
+
return Object.values(validations).some(function (v) { return !v; });
|
|
3311
|
+
}, [selectedValues]);
|
|
3261
3312
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3262
3313
|
var validations, notValid, menuOptionSubValueResult;
|
|
3263
3314
|
return __generator(this, function (_a) {
|
|
@@ -3351,8 +3402,9 @@ var GridFormMultiSelect = function (props) {
|
|
|
3351
3402
|
}, [selectedValues]);
|
|
3352
3403
|
var _f = useGridPopoverHook({
|
|
3353
3404
|
className: props.className,
|
|
3405
|
+
invalid: invalid,
|
|
3354
3406
|
save: save
|
|
3355
|
-
}), popoverWrapper = _f.popoverWrapper,
|
|
3407
|
+
}), popoverWrapper = _f.popoverWrapper, triggerSave = _f.triggerSave;
|
|
3356
3408
|
return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && props.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
|
|
3357
3409
|
var _b;
|
|
3358
3410
|
var ref = _a.ref;
|
|
@@ -3360,9 +3412,12 @@ var GridFormMultiSelect = function (props) {
|
|
|
3360
3412
|
} }), "filter"), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), jsxRuntime.jsx("div", __assign({ className: "GridFormMultiSelect-options" }, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3361
3413
|
var _a;
|
|
3362
3414
|
return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3415
|
+
// Global react-menu MenuItem handler handles tabs
|
|
3416
|
+
if (e.key !== "Tab") {
|
|
3417
|
+
e.keepOpen = true;
|
|
3418
|
+
toggleValue(item);
|
|
3419
|
+
}
|
|
3420
|
+
} }, { children: jsxRuntime.jsx(lui.LuiCheckboxInput, { isChecked: "".concat(item.value) in selectedValues, value: "".concat(item.value), label: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), inputProps: {
|
|
3366
3421
|
onClick: function (e) {
|
|
3367
3422
|
e.preventDefault();
|
|
3368
3423
|
e.stopPropagation();
|
|
@@ -3462,7 +3517,7 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3462
3517
|
});
|
|
3463
3518
|
}); })();
|
|
3464
3519
|
}, [options, props.defaultAction, props.options, selectedRows]);
|
|
3465
|
-
var actionClick = react.useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3520
|
+
var actionClick = react.useCallback(function (menuOption, reason) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3466
3521
|
return __generator(this, function (_a) {
|
|
3467
3522
|
actionProcessing.current = true;
|
|
3468
3523
|
return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3479,25 +3534,27 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3479
3534
|
return [2 /*return*/, true];
|
|
3480
3535
|
}
|
|
3481
3536
|
});
|
|
3482
|
-
}); })];
|
|
3537
|
+
}); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
|
|
3483
3538
|
});
|
|
3484
3539
|
}); }, [defaultAction, selectedRows, subSelectedValue, updateValue]);
|
|
3485
|
-
var onMenuItemClick = react.useCallback(function (e, item) {
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3540
|
+
var onMenuItemClick = react.useCallback(function (e, item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3541
|
+
return __generator(this, function (_a) {
|
|
3542
|
+
switch (_a.label) {
|
|
3543
|
+
case 0:
|
|
3544
|
+
if (!item.subComponent) return [3 /*break*/, 1];
|
|
3545
|
+
subComponentIsValid.current = false;
|
|
3546
|
+
setSubSelectedValue(null);
|
|
3547
|
+
setSubComponentSelected(subComponentSelected === item ? null : item);
|
|
3548
|
+
e.keepOpen = true;
|
|
3549
|
+
return [3 /*break*/, 3];
|
|
3550
|
+
case 1: return [4 /*yield*/, actionClick(item, e.key === "Tab" ? (e.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD) : CloseReason.CLICK).then()];
|
|
3551
|
+
case 2:
|
|
3552
|
+
_a.sent();
|
|
3553
|
+
_a.label = 3;
|
|
3554
|
+
case 3: return [2 /*return*/];
|
|
3555
|
+
}
|
|
3556
|
+
});
|
|
3557
|
+
}); }, [actionClick, subComponentSelected]);
|
|
3501
3558
|
var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3502
3559
|
return __generator(this, function (_a) {
|
|
3503
3560
|
switch (_a.label) {
|
|
@@ -3505,19 +3562,23 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3505
3562
|
if (!(!actionProcessing.current && subComponentSelected)) return [3 /*break*/, 2];
|
|
3506
3563
|
if (!subComponentIsValid.current)
|
|
3507
3564
|
return [2 /*return*/, false];
|
|
3508
|
-
return [4 /*yield*/, actionClick(subComponentSelected)];
|
|
3565
|
+
return [4 /*yield*/, actionClick(subComponentSelected, "click")];
|
|
3509
3566
|
case 1:
|
|
3510
3567
|
_a.sent();
|
|
3511
|
-
return [2 /*return*/,
|
|
3568
|
+
return [2 /*return*/, true];
|
|
3512
3569
|
case 2:
|
|
3513
3570
|
// Otherwise assume it's a cancel, either way we close the menu
|
|
3514
3571
|
return [2 /*return*/, true];
|
|
3515
3572
|
}
|
|
3516
3573
|
});
|
|
3517
3574
|
}); }, [actionClick, subComponentSelected]);
|
|
3518
|
-
var _e = useGridPopoverHook({
|
|
3519
|
-
|
|
3520
|
-
|
|
3575
|
+
var _e = useGridPopoverHook({
|
|
3576
|
+
className: props.className,
|
|
3577
|
+
invalid: function () { return subComponentSelected && !subComponentIsValid.current; },
|
|
3578
|
+
save: save
|
|
3579
|
+
}), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
|
|
3580
|
+
return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormPopupMenu" }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3581
|
+
return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) { return onMenuItemClick(e, item); }, disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "" }, { children: item.label }), "".concat(item.label)), item.subComponent && subComponentSelected === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3521
3582
|
return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3522
3583
|
data: data,
|
|
3523
3584
|
value: subSelectedValue,
|
|
@@ -3627,13 +3688,17 @@ styleInject(css_248z$2);
|
|
|
3627
3688
|
var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
|
|
3628
3689
|
styleInject(css_248z$1);
|
|
3629
3690
|
|
|
3691
|
+
var FormError = function (props) {
|
|
3692
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.error && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsxRuntime.jsx("span", __assign({ style: {
|
|
3693
|
+
fontSize: "0.7rem"
|
|
3694
|
+
} }, { children: props.helpText })))] }));
|
|
3695
|
+
};
|
|
3696
|
+
|
|
3630
3697
|
var TextInputFormatted = function (props) {
|
|
3631
3698
|
return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.className) }, { children: [jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsxRuntime.jsx("input", __assign({ type: "text", spellCheck: true, defaultValue: props.value }, lodashEs.omit(props, ["error", "value", "helpText", "formatted", "className"]), { className: "LuiTextInput-input", onMouseEnter: function (e) {
|
|
3632
3699
|
e.currentTarget.focus();
|
|
3633
3700
|
props.onMouseEnter && props.onMouseEnter(e);
|
|
3634
|
-
} })), jsxRuntime.jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })),
|
|
3635
|
-
fontSize: "0.7rem"
|
|
3636
|
-
} }, { children: props.helpText })))] })));
|
|
3701
|
+
} })), jsxRuntime.jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), jsxRuntime.jsx(FormError, { error: props.error, helpText: props.helpText })] })));
|
|
3637
3702
|
};
|
|
3638
3703
|
|
|
3639
3704
|
var GridFormEditBearing = function (props) {
|
|
@@ -3669,14 +3734,14 @@ var GridFormEditBearing = function (props) {
|
|
|
3669
3734
|
}
|
|
3670
3735
|
});
|
|
3671
3736
|
}); }, [defaultValue, field, props, value]);
|
|
3672
|
-
var
|
|
3737
|
+
var popoverWrapper = useGridPopoverHook({
|
|
3673
3738
|
className: props.className,
|
|
3674
3739
|
invalid: invalid,
|
|
3675
3740
|
save: save
|
|
3676
|
-
})
|
|
3677
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsxRuntime.jsx(TextInputFormatted,
|
|
3741
|
+
}).popoverWrapper;
|
|
3742
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: defaultValue, onChange: function (e) {
|
|
3678
3743
|
setValue(e.target.value.trim());
|
|
3679
|
-
}, autoFocus: true, placeholder: props.placeHolder
|
|
3744
|
+
}, autoFocus: true, placeholder: props.placeHolder, formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range), helpText: "Press enter or tab to save" }) })));
|
|
3680
3745
|
};
|
|
3681
3746
|
|
|
3682
3747
|
var GridPopoverEditBearingLike = function (colDef, props) {
|
|
@@ -3821,9 +3886,7 @@ var TextAreaInput = function (props) {
|
|
|
3821
3886
|
e.currentTarget.selectionStart = e.currentTarget.value.length;
|
|
3822
3887
|
}
|
|
3823
3888
|
props.onMouseEnter && props.onMouseEnter(e);
|
|
3824
|
-
} }, { children: props.value })) }))] })),
|
|
3825
|
-
fontSize: "0.7rem"
|
|
3826
|
-
} }, { children: props.helpText })))] })));
|
|
3889
|
+
} }, { children: props.value })) }))] })), jsxRuntime.jsx(FormError, { error: props.error, helpText: props.helpText })] })));
|
|
3827
3890
|
};
|
|
3828
3891
|
|
|
3829
3892
|
var TextInputValidator = function (props, value, data) {
|
|
@@ -3872,19 +3935,18 @@ var GridFormTextArea = function (props) {
|
|
|
3872
3935
|
}
|
|
3873
3936
|
});
|
|
3874
3937
|
}); }, [initialVale, value, props, field]);
|
|
3875
|
-
var
|
|
3938
|
+
var popoverWrapper = useGridPopoverHook({
|
|
3876
3939
|
className: props.className,
|
|
3877
3940
|
invalid: invalid,
|
|
3878
3941
|
save: save
|
|
3879
|
-
})
|
|
3880
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsxRuntime.jsx(TextAreaInput,
|
|
3942
|
+
}).popoverWrapper;
|
|
3943
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsxRuntime.jsx(TextAreaInput, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }) })));
|
|
3881
3944
|
};
|
|
3882
3945
|
|
|
3883
3946
|
var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
|
|
3884
3947
|
|
|
3885
3948
|
var GridFormTextInput = function (props) {
|
|
3886
3949
|
var _a, _b;
|
|
3887
|
-
var stopEditing = react.useContext(GridContext).stopEditing;
|
|
3888
3950
|
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
|
|
3889
3951
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
|
|
3890
3952
|
var initValue = react.useMemo(function () { return (initialVale == null ? "" : "".concat(initialVale)); }, [initialVale]);
|
|
@@ -3897,7 +3959,6 @@ var GridFormTextInput = function (props) {
|
|
|
3897
3959
|
case 0:
|
|
3898
3960
|
if (invalid())
|
|
3899
3961
|
return [2 /*return*/, false];
|
|
3900
|
-
stopEditing();
|
|
3901
3962
|
trimmedValue = value.trim();
|
|
3902
3963
|
if (initValue === trimmedValue)
|
|
3903
3964
|
return [2 /*return*/, true];
|
|
@@ -3915,13 +3976,13 @@ var GridFormTextInput = function (props) {
|
|
|
3915
3976
|
return [2 /*return*/, true];
|
|
3916
3977
|
}
|
|
3917
3978
|
});
|
|
3918
|
-
}); }, [invalid,
|
|
3919
|
-
var
|
|
3979
|
+
}); }, [invalid, value, initValue, props, field]);
|
|
3980
|
+
var popoverWrapper = useGridPopoverHook({
|
|
3920
3981
|
className: props.className,
|
|
3921
3982
|
invalid: invalid,
|
|
3922
3983
|
save: save
|
|
3923
|
-
})
|
|
3924
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted,
|
|
3984
|
+
}).popoverWrapper;
|
|
3985
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, style: { width: "100%" }, placeholder: props.placeholder, helpText: helpText }) })));
|
|
3925
3986
|
};
|
|
3926
3987
|
|
|
3927
3988
|
var GridPopoverTextInput = function (colDef, params) {
|
|
@@ -3930,7 +3991,7 @@ var GridPopoverTextInput = function (colDef, params) {
|
|
|
3930
3991
|
|
|
3931
3992
|
var GridFormSubComponentTextInput = function (props) {
|
|
3932
3993
|
var _a;
|
|
3933
|
-
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid,
|
|
3994
|
+
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, data = _b.data;
|
|
3934
3995
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
|
|
3935
3996
|
// If is not initialised yet as it's just been created then set the default value
|
|
3936
3997
|
react.useEffect(function () {
|
|
@@ -3941,30 +4002,14 @@ var GridFormSubComponentTextInput = function (props) {
|
|
|
3941
4002
|
react.useEffect(function () {
|
|
3942
4003
|
setValid(value != null && invalid() == null);
|
|
3943
4004
|
}, [setValid, invalid, value]);
|
|
3944
|
-
return (jsxRuntime.jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true,
|
|
3945
|
-
if (e.key === "Tab" || e.key === "Enter") {
|
|
3946
|
-
e.preventDefault();
|
|
3947
|
-
e.stopPropagation();
|
|
3948
|
-
}
|
|
3949
|
-
}, onKeyUp: function (e) {
|
|
3950
|
-
if (e.key === "Tab") {
|
|
3951
|
-
e.preventDefault();
|
|
3952
|
-
e.stopPropagation();
|
|
3953
|
-
!e.shiftKey && triggerSave().then();
|
|
3954
|
-
}
|
|
3955
|
-
else if (e.key === "Enter") {
|
|
3956
|
-
triggerSave().then();
|
|
3957
|
-
e.preventDefault();
|
|
3958
|
-
e.stopPropagation();
|
|
3959
|
-
}
|
|
3960
|
-
}, placeholder: props.placeholder, style: {
|
|
4005
|
+
return (jsxRuntime.jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, placeholder: props.placeholder, style: {
|
|
3961
4006
|
width: "100%"
|
|
3962
4007
|
} }));
|
|
3963
4008
|
};
|
|
3964
4009
|
|
|
3965
4010
|
var GridFormSubComponentTextArea = function (props) {
|
|
3966
4011
|
var _a;
|
|
3967
|
-
var _b = react.useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid
|
|
4012
|
+
var _b = react.useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid;
|
|
3968
4013
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
|
|
3969
4014
|
// If is not initialised yet as it's just been created then set the default value
|
|
3970
4015
|
react.useEffect(function () {
|
|
@@ -3975,18 +4020,7 @@ var GridFormSubComponentTextArea = function (props) {
|
|
|
3975
4020
|
react.useEffect(function () {
|
|
3976
4021
|
setValid(value != null && invalid() == null);
|
|
3977
4022
|
}, [setValid, invalid, value]);
|
|
3978
|
-
return (jsxRuntime.jsx("div", __assign({ className: clsx("FreeTextInput LuiDeprecatedForms", props.className) }, { children: jsxRuntime.jsx(TextAreaInput, { className: "free-text-input", value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), helpText: helpText, autoFocus: true, placeholder: props.placeholder
|
|
3979
|
-
if (e.key === "Tab") {
|
|
3980
|
-
e.preventDefault();
|
|
3981
|
-
e.stopPropagation();
|
|
3982
|
-
}
|
|
3983
|
-
}, onKeyUp: function (e) {
|
|
3984
|
-
if (e.key === "Tab") {
|
|
3985
|
-
e.preventDefault();
|
|
3986
|
-
e.stopPropagation();
|
|
3987
|
-
!e.shiftKey && triggerSave().then();
|
|
3988
|
-
}
|
|
3989
|
-
} }) })));
|
|
4023
|
+
return (jsxRuntime.jsx("div", __assign({ className: clsx("FreeTextInput LuiDeprecatedForms", props.className) }, { children: jsxRuntime.jsx(TextAreaInput, { className: "free-text-input", value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), helpText: helpText, autoFocus: true, placeholder: props.placeholder }) })));
|
|
3990
4024
|
};
|
|
3991
4025
|
|
|
3992
4026
|
var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton .LuiIcon{margin:0 4px!important}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress{background-color:#e2f3f7!important;color:#007198!important;cursor:progress}.ActionButton-inProgress svg *{fill:#0000!important}";
|