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