@linzjs/step-ag-grid 3.0.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +283 -217
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +13 -1
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +11 -0
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +8 -8
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +3 -4
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/lui/TextAreaInput.d.ts +4 -5
- package/dist/src/lui/TextInputFormatted.d.ts +4 -10
- package/dist/src/utils/textValidator.d.ts +6 -0
- package/dist/step-ag-grid.esm.js +283 -217
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +2 -2
- package/src/components/GridCell.tsx +5 -0
- package/src/components/GridPopoverHook.tsx +79 -1
- package/src/components/gridForm/GridFormDropDown.tsx +63 -56
- package/src/components/gridForm/GridFormEditBearing.tsx +7 -8
- package/src/components/gridForm/GridFormMultiSelect.tsx +6 -10
- package/src/components/gridForm/GridFormPopoverMenu.tsx +7 -10
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +58 -0
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +48 -55
- package/src/components/gridForm/GridFormTextArea.tsx +10 -18
- package/src/components/gridForm/GridFormTextInput.tsx +12 -25
- package/src/contexts/GridPopoverContextProvider.tsx +11 -4
- package/src/index.ts +1 -1
- package/src/lui/TextAreaInput.tsx +34 -18
- package/src/lui/TextInputFormatted.tsx +19 -35
- package/src/react-menu3/components/MenuItem.tsx +5 -2
- package/src/stories/grid/FormTest.tsx +16 -3
- package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +20 -17
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +2 -2
- package/src/stories/grid/GridReadOnly.stories.tsx +15 -3
- package/src/utils/textValidator.ts +24 -0
- package/dist/src/components/GridSubComponentTextArea.d.ts +0 -10
- package/src/components/GridSubComponentTextArea.tsx +0 -62
package/dist/index.js
CHANGED
|
@@ -1687,7 +1687,10 @@ var MenuItemFr = function (_a) {
|
|
|
1687
1687
|
safeCall(radioGroup.onRadioChange, event);
|
|
1688
1688
|
eventHandlers.handleClick(event, isCheckBox || isRadio);
|
|
1689
1689
|
};
|
|
1690
|
-
|
|
1690
|
+
/**
|
|
1691
|
+
* Keyboard events are triggered on up, otherwise sub-components get spaces and enters typed in them
|
|
1692
|
+
*/
|
|
1693
|
+
var handleKeyUp = function (e) {
|
|
1691
1694
|
if (!isHovering)
|
|
1692
1695
|
return;
|
|
1693
1696
|
switch (e.key) {
|
|
@@ -1709,7 +1712,7 @@ var MenuItemFr = function (_a) {
|
|
|
1709
1712
|
checked: isChecked,
|
|
1710
1713
|
anchor: isAnchor
|
|
1711
1714
|
}); }, [type, isDisabled, isHovering, isChecked, isAnchor]);
|
|
1712
|
-
var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover,
|
|
1715
|
+
var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
|
|
1713
1716
|
// Order of props overriding (same in all components):
|
|
1714
1717
|
// 1. Preset props adhering to WAI-ARIA Authoring Practices.
|
|
1715
1718
|
// 2. Merged outer and local props
|
|
@@ -2203,7 +2206,7 @@ var useGridPopoverContext = function () {
|
|
|
2203
2206
|
var GridPopoverContextProvider = function (_a) {
|
|
2204
2207
|
var _b, _c, _d;
|
|
2205
2208
|
var props = _a.props, children = _a.children;
|
|
2206
|
-
var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
|
|
2209
|
+
var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing;
|
|
2207
2210
|
var anchorRef = react.useRef(props.eGridCell);
|
|
2208
2211
|
var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
|
|
2209
2212
|
var colDef = props.colDef;
|
|
@@ -2212,18 +2215,23 @@ var GridPopoverContextProvider = function (_a) {
|
|
|
2212
2215
|
// Then item that is clicked on will always be first in the list
|
|
2213
2216
|
var selectedRows = react.useMemo(function () { return (multiEdit ? lodashEs.sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
|
|
2214
2217
|
var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
|
|
2215
|
-
var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2218
|
+
var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2219
|
+
var result;
|
|
2220
|
+
return __generator(this, function (_a) {
|
|
2221
|
+
switch (_a.label) {
|
|
2222
|
+
case 0:
|
|
2223
|
+
result = false;
|
|
2224
|
+
if (!!saving) return [3 /*break*/, 2];
|
|
2225
|
+
return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
|
|
2226
|
+
case 1:
|
|
2227
|
+
result = _a.sent();
|
|
2228
|
+
if (result)
|
|
2229
|
+
stopEditing();
|
|
2230
|
+
_a.label = 2;
|
|
2231
|
+
case 2: return [2 /*return*/, result];
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
}); }, [field, saving, selectedRows, stopEditing, updatingCells]);
|
|
2227
2235
|
return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
|
|
2228
2236
|
anchorRef: anchorRef,
|
|
2229
2237
|
saving: saving,
|
|
@@ -2622,7 +2630,7 @@ var Grid = function (params) {
|
|
|
2622
2630
|
startCellEditing(event);
|
|
2623
2631
|
}
|
|
2624
2632
|
}, [startCellEditing]);
|
|
2625
|
-
var
|
|
2633
|
+
var onCellKeyPress = react.useCallback(function (e) {
|
|
2626
2634
|
if (e.event.key === "Enter")
|
|
2627
2635
|
startCellEditing(e);
|
|
2628
2636
|
}, [startCellEditing]);
|
|
@@ -2640,7 +2648,7 @@ var Grid = function (params) {
|
|
|
2640
2648
|
}, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
|
|
2641
2649
|
return (jsxRuntime.jsxs("div", __assign({ "data-testid": params.dataTestId, className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2642
2650
|
setInternalQuickFilter(event.target.value);
|
|
2643
|
-
} }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true,
|
|
2651
|
+
} }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_b = params.postSortRows) !== null && _b !== void 0 ? _b : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
|
|
2644
2652
|
};
|
|
2645
2653
|
|
|
2646
2654
|
var GenericMultiEditCellClass = function (props) {
|
|
@@ -2683,12 +2691,12 @@ function styleInject(css, ref) {
|
|
|
2683
2691
|
}
|
|
2684
2692
|
}
|
|
2685
2693
|
|
|
2686
|
-
var css_248z$
|
|
2687
|
-
styleInject(css_248z$8);
|
|
2688
|
-
|
|
2689
|
-
var css_248z$7 = ".GridLoadableCell-container{align-items:center;display:flex}";
|
|
2694
|
+
var css_248z$7 = ".AgGridGenericCellRenderer-icon{margin-right:4px}.AgGridGenericCellRenderer-ic_infoIcon{fill:#3a7cdf;margin-right:4px}.AgGridGenericCellRenderer-ic_warningIcon{fill:#ea6a2e;margin-right:4px}";
|
|
2690
2695
|
styleInject(css_248z$7);
|
|
2691
2696
|
|
|
2697
|
+
var css_248z$6 = ".GridLoadableCell-container{align-items:center;display:flex}";
|
|
2698
|
+
styleInject(css_248z$6);
|
|
2699
|
+
|
|
2692
2700
|
var GridLoadableCell = function (props) {
|
|
2693
2701
|
if (props.isLoading) {
|
|
2694
2702
|
return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 22, divProps: { role: "status", "aria-label": "Loading", style: { marginBottom: 4 } } }) })));
|
|
@@ -2734,11 +2742,15 @@ var GridCellRenderer = function (props) {
|
|
|
2734
2742
|
*/
|
|
2735
2743
|
var GridCell = function (props, custom) {
|
|
2736
2744
|
var _a;
|
|
2737
|
-
return __assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
|
|
2745
|
+
return __assign(__assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
|
|
2738
2746
|
cellClass: (custom === null || custom === void 0 ? void 0 : custom.multiEdit) ? GenericMultiEditCellClass : undefined,
|
|
2739
2747
|
editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
|
|
2740
2748
|
cellEditor: GenericCellEditorComponentWrapper(custom)
|
|
2741
|
-
})),
|
|
2749
|
+
})), { suppressKeyboardEvent: function (e) {
|
|
2750
|
+
// It's important that aggrid doesn't trigger edit on enter
|
|
2751
|
+
// as the incorrect selected rows will be returned
|
|
2752
|
+
return e.event.key === "Enter";
|
|
2753
|
+
} }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
|
|
2742
2754
|
cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
|
|
2743
2755
|
})), {
|
|
2744
2756
|
// Default value formatter, otherwise react freaks out on objects
|
|
@@ -2807,8 +2819,77 @@ var useGridPopoverHook = function (props) {
|
|
|
2807
2819
|
}
|
|
2808
2820
|
});
|
|
2809
2821
|
}); }, [props.save, stopEditing, updateValue]);
|
|
2822
|
+
var onlyInputKeyboardEventHandlers = {
|
|
2823
|
+
onKeyUp: function (e) {
|
|
2824
|
+
var isTextArea = e.currentTarget.type === "textarea";
|
|
2825
|
+
if (e.key === "Enter" && !isTextArea) {
|
|
2826
|
+
e.preventDefault();
|
|
2827
|
+
e.stopPropagation();
|
|
2828
|
+
triggerSave().then();
|
|
2829
|
+
}
|
|
2830
|
+
else if (e.key === "Tab") {
|
|
2831
|
+
e.preventDefault();
|
|
2832
|
+
e.stopPropagation();
|
|
2833
|
+
}
|
|
2834
|
+
},
|
|
2835
|
+
onKeyDown: function (e) {
|
|
2836
|
+
var isTextArea = e.currentTarget.type === "textarea";
|
|
2837
|
+
if (e.key === "Enter" && !isTextArea) {
|
|
2838
|
+
e.preventDefault();
|
|
2839
|
+
e.stopPropagation();
|
|
2840
|
+
}
|
|
2841
|
+
else if (e.key === "Tab") {
|
|
2842
|
+
e.preventDefault();
|
|
2843
|
+
e.stopPropagation();
|
|
2844
|
+
!e.shiftKey && triggerSave().then();
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
};
|
|
2848
|
+
var firstInputKeyboardEventHandlers = {
|
|
2849
|
+
onKeyUp: function (e) {
|
|
2850
|
+
if (e.key === "Tab" && e.shiftKey) {
|
|
2851
|
+
e.preventDefault();
|
|
2852
|
+
e.stopPropagation();
|
|
2853
|
+
}
|
|
2854
|
+
},
|
|
2855
|
+
onKeyDown: function (e) {
|
|
2856
|
+
if (e.key === "Tab" && e.shiftKey) {
|
|
2857
|
+
e.preventDefault();
|
|
2858
|
+
e.stopPropagation();
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
};
|
|
2862
|
+
var lastInputKeyboardEventHandlers = {
|
|
2863
|
+
onKeyUp: function (e) {
|
|
2864
|
+
var isTextArea = e.currentTarget.type === "textarea";
|
|
2865
|
+
if (e.key === "Enter" && !isTextArea) {
|
|
2866
|
+
e.preventDefault();
|
|
2867
|
+
e.stopPropagation();
|
|
2868
|
+
triggerSave().then();
|
|
2869
|
+
}
|
|
2870
|
+
else if (e.key === "Tab" && !e.shiftKey) {
|
|
2871
|
+
e.preventDefault();
|
|
2872
|
+
e.stopPropagation();
|
|
2873
|
+
}
|
|
2874
|
+
},
|
|
2875
|
+
onKeyDown: function (e) {
|
|
2876
|
+
var isTextArea = e.currentTarget.type === "textarea";
|
|
2877
|
+
if (e.key === "Enter" && !isTextArea) {
|
|
2878
|
+
e.preventDefault();
|
|
2879
|
+
e.stopPropagation();
|
|
2880
|
+
}
|
|
2881
|
+
else if (e.key === "Tab" && !e.shiftKey) {
|
|
2882
|
+
e.preventDefault();
|
|
2883
|
+
e.stopPropagation();
|
|
2884
|
+
triggerSave().then();
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
};
|
|
2810
2888
|
var popoverWrapper = react.useCallback(function (children) {
|
|
2811
2889
|
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) {
|
|
2890
|
+
// Prevent menu from closing when modals are invoked
|
|
2891
|
+
if (event.reason === "blur")
|
|
2892
|
+
return;
|
|
2812
2893
|
triggerSave(event.reason).then();
|
|
2813
2894
|
}, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className, closeMenuExclusionClassName: "ReactModal__Content" }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
|
|
2814
2895
|
jsxRuntime.jsx("div", { style: {
|
|
@@ -2823,7 +2904,10 @@ var useGridPopoverHook = function (props) {
|
|
|
2823
2904
|
}, [anchorRef, isOpen, props.className, saving, triggerSave]);
|
|
2824
2905
|
return {
|
|
2825
2906
|
popoverWrapper: popoverWrapper,
|
|
2826
|
-
triggerSave: triggerSave
|
|
2907
|
+
triggerSave: triggerSave,
|
|
2908
|
+
onlyInputKeyboardEventHandlers: onlyInputKeyboardEventHandlers,
|
|
2909
|
+
firstInputKeyboardEventHandlers: firstInputKeyboardEventHandlers,
|
|
2910
|
+
lastInputKeyboardEventHandlers: lastInputKeyboardEventHandlers
|
|
2827
2911
|
};
|
|
2828
2912
|
};
|
|
2829
2913
|
|
|
@@ -2846,12 +2930,12 @@ var GridRenderPopoutMenuCell = function (props) {
|
|
|
2846
2930
|
return (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: isLoading, className: disabled ? "GridPopoutMenu-burgerDisabled" : "GridPopoutMenu-burger" }, { children: jsxRuntime.jsx(lui.LuiIcon, { name: "ic_more_vert", alt: "More actions", size: "md" }) })));
|
|
2847
2931
|
};
|
|
2848
2932
|
|
|
2849
|
-
var css_248z$
|
|
2850
|
-
styleInject(css_248z$6);
|
|
2851
|
-
|
|
2852
|
-
var css_248z$5 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:200px;overflow-y:auto}.GridPopoverEditDropDown-containerLarge .GridFormDropDown-options{max-height:400px;overflow-y:auto}.GridPopoverEditDropDown-containerUnlimited .GridFormDropDown-options{overflow-y:auto}";
|
|
2933
|
+
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}";
|
|
2853
2934
|
styleInject(css_248z$5);
|
|
2854
2935
|
|
|
2936
|
+
var css_248z$4 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:200px;overflow-y:auto}.GridPopoverEditDropDown-containerLarge .GridFormDropDown-options{max-height:400px;overflow-y:auto}.GridPopoverEditDropDown-containerUnlimited .GridFormDropDown-options{overflow-y:auto}";
|
|
2937
|
+
styleInject(css_248z$4);
|
|
2938
|
+
|
|
2855
2939
|
/* global setTimeout, clearTimeout */
|
|
2856
2940
|
|
|
2857
2941
|
var dist = function debounce(fn) {
|
|
@@ -2939,9 +3023,13 @@ var GridFormDropDown = function (props) {
|
|
|
2939
3023
|
var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
|
|
2940
3024
|
var optionsInitialising = react.useRef(false);
|
|
2941
3025
|
var _d = react.useState(null), options = _d[0], setOptions = _d[1];
|
|
2942
|
-
var
|
|
3026
|
+
var subComponentIsValid = react.useRef(false);
|
|
3027
|
+
var _e = react.useState(), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
|
|
3028
|
+
var _f = react.useState(), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
|
|
2943
3029
|
var selectItemHandler = react.useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2944
3030
|
return __generator(this, function (_a) {
|
|
3031
|
+
if (subComponentValue !== undefined && !subComponentIsValid.current)
|
|
3032
|
+
return [2 /*return*/, false];
|
|
2945
3033
|
return [2 /*return*/, updateValue(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2946
3034
|
var hasChanged;
|
|
2947
3035
|
return __generator(this, function (_a) {
|
|
@@ -3084,48 +3172,58 @@ var GridFormDropDown = function (props) {
|
|
|
3084
3172
|
}
|
|
3085
3173
|
});
|
|
3086
3174
|
}); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props]);
|
|
3087
|
-
var
|
|
3175
|
+
var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3176
|
+
return __generator(this, function (_a) {
|
|
3177
|
+
switch (_a.label) {
|
|
3178
|
+
case 0:
|
|
3179
|
+
// Handler for sub-selected value
|
|
3180
|
+
if (!selectedSubComponent)
|
|
3181
|
+
return [2 /*return*/, true];
|
|
3182
|
+
if (!subComponentIsValid.current)
|
|
3183
|
+
return [2 /*return*/, false];
|
|
3184
|
+
return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
|
|
3185
|
+
case 1:
|
|
3186
|
+
_a.sent();
|
|
3187
|
+
return [2 /*return*/, true];
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
}); }, [selectItemHandler, selectedSubComponent, subSelectedValue]);
|
|
3191
|
+
var popoverWrapper = useGridPopoverHook({ className: props.className, save: save }).popoverWrapper;
|
|
3088
3192
|
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) {
|
|
3089
3193
|
var _b;
|
|
3090
3194
|
var ref = _a.ref;
|
|
3091
3195
|
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()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
|
|
3092
3196
|
} })), 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) {
|
|
3093
3197
|
var _a;
|
|
3094
|
-
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.
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
|
|
3100
|
-
var optionValue = _a.optionValue;
|
|
3101
|
-
return optionValue === item.value;
|
|
3102
|
-
});
|
|
3103
|
-
if (subComponentValueIndex !== -1) {
|
|
3104
|
-
localSubComponentValues[subComponentValueIndex].subComponentValue = value;
|
|
3198
|
+
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.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
|
|
3199
|
+
if (item.subComponent) {
|
|
3200
|
+
if (selectedSubComponent === item) {
|
|
3201
|
+
setSelectedSubComponent(null);
|
|
3202
|
+
subComponentIsValid.current = true;
|
|
3105
3203
|
}
|
|
3106
3204
|
else {
|
|
3107
|
-
|
|
3108
|
-
subComponentValue: value,
|
|
3109
|
-
optionValue: item.value
|
|
3110
|
-
});
|
|
3205
|
+
setSelectedSubComponent(item);
|
|
3111
3206
|
}
|
|
3112
|
-
|
|
3113
|
-
}
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3207
|
+
e.keepOpen = true;
|
|
3208
|
+
}
|
|
3209
|
+
else {
|
|
3210
|
+
selectItemHandler(item.value).then();
|
|
3211
|
+
}
|
|
3212
|
+
} }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".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: {
|
|
3213
|
+
value: subSelectedValue,
|
|
3214
|
+
setValue: function (value) {
|
|
3215
|
+
setSubSelectedValue(value);
|
|
3216
|
+
},
|
|
3217
|
+
setValid: function (valid) {
|
|
3218
|
+
subComponentIsValid.current = valid;
|
|
3219
|
+
},
|
|
3220
|
+
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3221
|
+
return __generator(this, function (_a) {
|
|
3122
3222
|
ref.closeMenu();
|
|
3123
|
-
return
|
|
3223
|
+
return [2 /*return*/];
|
|
3124
3224
|
});
|
|
3125
|
-
}
|
|
3126
|
-
|
|
3127
|
-
} }, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")));
|
|
3128
|
-
} }), "".concat(fieldToString(field), "-").concat(index, "_subcomponent"))) }, "menu-wrapper-".concat(index)));
|
|
3225
|
+
}); }
|
|
3226
|
+
} }, { children: item.subComponent && (jsxRuntime.jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner"))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index)));
|
|
3129
3227
|
})] }) }))] }));
|
|
3130
3228
|
};
|
|
3131
3229
|
|
|
@@ -3233,7 +3331,10 @@ var GridFormMultiSelect = function (props) {
|
|
|
3233
3331
|
setSelectedValues(__assign(__assign({}, selectedValues), (_a = {}, _a["".concat(item.value)] = null, _a)));
|
|
3234
3332
|
}
|
|
3235
3333
|
}, [selectedValues]);
|
|
3236
|
-
var _e = useGridPopoverHook({
|
|
3334
|
+
var _e = useGridPopoverHook({
|
|
3335
|
+
className: props.className,
|
|
3336
|
+
save: save
|
|
3337
|
+
}), popoverWrapper = _e.popoverWrapper, lastInputKeyboardEventHandlers = _e.lastInputKeyboardEventHandlers, triggerSave = _e.triggerSave;
|
|
3237
3338
|
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) {
|
|
3238
3339
|
var _b;
|
|
3239
3340
|
var ref = _a.ref;
|
|
@@ -3243,18 +3344,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3243
3344
|
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) {
|
|
3244
3345
|
e.keepOpen = true;
|
|
3245
3346
|
toggleValue(item);
|
|
3246
|
-
},
|
|
3247
|
-
return __generator(this, function (_a) {
|
|
3248
|
-
if (e.key === "Enter")
|
|
3249
|
-
triggerSave().then();
|
|
3250
|
-
else if (e.key === " ") {
|
|
3251
|
-
toggleValue(item);
|
|
3252
|
-
e.preventDefault();
|
|
3253
|
-
e.stopPropagation();
|
|
3254
|
-
}
|
|
3255
|
-
return [2 /*return*/];
|
|
3256
|
-
});
|
|
3257
|
-
}); } }, { 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: {
|
|
3347
|
+
} }, lastInputKeyboardEventHandlers, { 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: {
|
|
3258
3348
|
onClick: function (e) {
|
|
3259
3349
|
e.preventDefault();
|
|
3260
3350
|
e.stopPropagation();
|
|
@@ -3282,8 +3372,8 @@ var GridPopoutEditMultiSelect = function (colDef, props) {
|
|
|
3282
3372
|
return GridCell(colDef, __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
|
|
3283
3373
|
};
|
|
3284
3374
|
|
|
3285
|
-
var css_248z$
|
|
3286
|
-
styleInject(css_248z$
|
|
3375
|
+
var css_248z$3 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
|
|
3376
|
+
styleInject(css_248z$3);
|
|
3287
3377
|
|
|
3288
3378
|
/** Menu configuration types **/
|
|
3289
3379
|
var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
|
|
@@ -3381,8 +3471,8 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3381
3471
|
e.keepOpen = true;
|
|
3382
3472
|
}
|
|
3383
3473
|
else {
|
|
3384
|
-
setSubComponentSelected(null);
|
|
3385
3474
|
actionClick(item).then();
|
|
3475
|
+
e.keepOpen = true;
|
|
3386
3476
|
}
|
|
3387
3477
|
}, [actionClick, subComponentSelected]);
|
|
3388
3478
|
var selectedRowCount = selectedRows.length;
|
|
@@ -3399,21 +3489,16 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3399
3489
|
return [4 /*yield*/, actionClick(subComponentSelected)];
|
|
3400
3490
|
case 1:
|
|
3401
3491
|
_a.sent();
|
|
3402
|
-
|
|
3403
|
-
case 2:
|
|
3492
|
+
return [2 /*return*/, false];
|
|
3493
|
+
case 2:
|
|
3494
|
+
// Otherwise assume it's a cancel, either way we close the menu
|
|
3495
|
+
return [2 /*return*/, true];
|
|
3404
3496
|
}
|
|
3405
3497
|
});
|
|
3406
3498
|
}); }, [actionClick, subComponentSelected]);
|
|
3407
3499
|
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
|
|
3408
|
-
var localTriggerSave = function (reason) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3409
|
-
return __generator(this, function (_a) {
|
|
3410
|
-
if (!subComponentIsValid.current)
|
|
3411
|
-
return [2 /*return*/];
|
|
3412
|
-
return [2 /*return*/, triggerSave(reason)];
|
|
3413
|
-
});
|
|
3414
|
-
}); };
|
|
3415
3500
|
return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !filteredOptions, className: "GridFormPopupMenu" }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3416
|
-
return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsxs(
|
|
3501
|
+
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 || !(filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.includes(item)), 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 (_) {
|
|
3417
3502
|
return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3418
3503
|
value: subSelectedValue,
|
|
3419
3504
|
setValue: function (value) {
|
|
@@ -3422,9 +3507,9 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3422
3507
|
setValid: function (valid) {
|
|
3423
3508
|
subComponentIsValid.current = valid;
|
|
3424
3509
|
},
|
|
3425
|
-
triggerSave:
|
|
3510
|
+
triggerSave: triggerSave
|
|
3426
3511
|
} }, { children: jsxRuntime.jsx(item.subComponent, {}) })));
|
|
3427
|
-
} }), "".concat(item.label, "_subcomponent")))] })));
|
|
3512
|
+
} }), "".concat(item.label, "_subcomponent")))] }, "".concat(item.label))));
|
|
3428
3513
|
}) }) })));
|
|
3429
3514
|
};
|
|
3430
3515
|
|
|
@@ -3516,16 +3601,19 @@ var convertDDToDMS = function (dd, showPositiveSymbol, addTrailingZeros) {
|
|
|
3516
3601
|
return dmsString;
|
|
3517
3602
|
};
|
|
3518
3603
|
|
|
3519
|
-
var css_248z$
|
|
3520
|
-
styleInject(css_248z$3);
|
|
3521
|
-
|
|
3522
|
-
var css_248z$2 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
|
|
3604
|
+
var css_248z$2 = ".GridFormEditBearing-input{width:320px}";
|
|
3523
3605
|
styleInject(css_248z$2);
|
|
3524
3606
|
|
|
3607
|
+
var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
|
|
3608
|
+
styleInject(css_248z$1);
|
|
3609
|
+
|
|
3525
3610
|
var TextInputFormatted = function (props) {
|
|
3526
|
-
return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.
|
|
3611
|
+
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) {
|
|
3527
3612
|
e.currentTarget.focus();
|
|
3528
|
-
|
|
3613
|
+
props.onMouseEnter && props.onMouseEnter(e);
|
|
3614
|
+
} })), jsxRuntime.jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), 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: {
|
|
3615
|
+
fontSize: "0.7rem"
|
|
3616
|
+
} }, { children: props.helpText })))] })));
|
|
3529
3617
|
};
|
|
3530
3618
|
|
|
3531
3619
|
var GridFormEditBearing = function (props) {
|
|
@@ -3560,18 +3648,13 @@ var GridFormEditBearing = function (props) {
|
|
|
3560
3648
|
}
|
|
3561
3649
|
});
|
|
3562
3650
|
}); }, [field, initialValue, props, value]);
|
|
3563
|
-
var _c = useGridPopoverHook({
|
|
3564
|
-
|
|
3651
|
+
var _c = useGridPopoverHook({
|
|
3652
|
+
className: props.className,
|
|
3653
|
+
save: save
|
|
3654
|
+
}), popoverWrapper = _c.popoverWrapper, onlyInputKeyboardEventHandlers = _c.onlyInputKeyboardEventHandlers;
|
|
3655
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsxRuntime.jsx(TextInputFormatted, __assign({ value: value !== null && value !== void 0 ? value : "", onChange: function (e) {
|
|
3565
3656
|
setValue(e.target.value.trim());
|
|
3566
|
-
},
|
|
3567
|
-
autoFocus: true,
|
|
3568
|
-
placeholder: props.placeHolder,
|
|
3569
|
-
disabled: false,
|
|
3570
|
-
maxLength: 16,
|
|
3571
|
-
onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3572
|
-
return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
|
|
3573
|
-
}); }); }
|
|
3574
|
-
}, formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range) }) })));
|
|
3657
|
+
}, autoFocus: true, placeholder: props.placeHolder }, onlyInputKeyboardEventHandlers, { formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range) })) })));
|
|
3575
3658
|
};
|
|
3576
3659
|
|
|
3577
3660
|
var GridPopoverEditBearingLike = function (colDef, props) {
|
|
@@ -3708,32 +3791,44 @@ var useGenerateOrDefaultId = function (idFromProps) {
|
|
|
3708
3791
|
return id;
|
|
3709
3792
|
};
|
|
3710
3793
|
var TextAreaInput = function (props) {
|
|
3711
|
-
var _a
|
|
3712
|
-
var id = useGenerateOrDefaultId(
|
|
3713
|
-
return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer",
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3794
|
+
var _a;
|
|
3795
|
+
var id = useGenerateOrDefaultId(props === null || props === void 0 ? void 0 : props.id);
|
|
3796
|
+
return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer", props.disabled ? "isDisabled" : "", props.error ? "hasError" : "", props.className) }, { children: [jsxRuntime.jsxs("label", __assign({ htmlFor: id }, { children: [props.mandatory != null && jsxRuntime.jsx("span", __assign({ className: "LuiTextAreaInput-mandatory" }, { children: "*" })), props.label != null && jsxRuntime.jsx("span", __assign({ className: "LuiTextAreaInput-label" }, { children: props.label })), jsxRuntime.jsx("div", __assign({ className: "LuiTextAreaInput-wrapper" }, { children: jsxRuntime.jsx("textarea", __assign({ rows: 5 }, lodashEs.omit(props, ["error", "value", "helpText", "formatted", "className"]), { id: id, value: (_a = props.value) !== null && _a !== void 0 ? _a : "", spellCheck: true, onMouseEnter: function (e) {
|
|
3797
|
+
if (document.activeElement != e.currentTarget) {
|
|
3798
|
+
e.currentTarget.focus();
|
|
3799
|
+
e.currentTarget.selectionStart = e.currentTarget.value.length;
|
|
3800
|
+
}
|
|
3801
|
+
props.onMouseEnter && props.onMouseEnter(e);
|
|
3802
|
+
} }, { children: props.value })) }))] })), props.error && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextAreaInput-error" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextAreaInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsxRuntime.jsx("span", __assign({ style: {
|
|
3803
|
+
fontSize: "0.7rem"
|
|
3804
|
+
} }, { children: props.helpText })))] })));
|
|
3719
3805
|
};
|
|
3720
3806
|
|
|
3721
|
-
var
|
|
3722
|
-
|
|
3723
|
-
var _b = useGridPopoverContext(), field = _b.field, initialVale = _b.value;
|
|
3724
|
-
var _c = react.useState(initialVale != null ? "".concat(initialVale) : ""), value = _c[0], setValue = _c[1];
|
|
3725
|
-
var invalid = react.useCallback(function () {
|
|
3726
|
-
if (props.required && value.length == 0) {
|
|
3727
|
-
return "Some text is required";
|
|
3728
|
-
}
|
|
3729
|
-
if (props.maxLength && value.length > props.maxLength) {
|
|
3730
|
-
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3731
|
-
}
|
|
3732
|
-
if (props.validate) {
|
|
3733
|
-
return props.validate(value);
|
|
3734
|
-
}
|
|
3807
|
+
var TextInputValidator = function (props, value) {
|
|
3808
|
+
if (value == null)
|
|
3735
3809
|
return null;
|
|
3736
|
-
|
|
3810
|
+
// This can happen because subcomponent is invoked without type safety
|
|
3811
|
+
if (typeof value !== "string") {
|
|
3812
|
+
console.error("Value is not a string", value);
|
|
3813
|
+
}
|
|
3814
|
+
if (props.required && value.length === 0) {
|
|
3815
|
+
return "Some text is required";
|
|
3816
|
+
}
|
|
3817
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3818
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3819
|
+
}
|
|
3820
|
+
if (props.validate) {
|
|
3821
|
+
return props.validate(value);
|
|
3822
|
+
}
|
|
3823
|
+
return null;
|
|
3824
|
+
};
|
|
3825
|
+
|
|
3826
|
+
var GridFormTextArea = function (props) {
|
|
3827
|
+
var _a, _b;
|
|
3828
|
+
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
|
|
3829
|
+
var _d = react.useState(initialVale != null ? "".concat(initialVale) : ""), value = _d[0], setValue = _d[1];
|
|
3830
|
+
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
|
|
3831
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3737
3832
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3738
3833
|
return __generator(this, function (_a) {
|
|
3739
3834
|
switch (_a.label) {
|
|
@@ -3757,30 +3852,19 @@ var GridFormTextArea = function (props) {
|
|
|
3757
3852
|
}
|
|
3758
3853
|
});
|
|
3759
3854
|
}); }, [invalid, initialVale, value, props, field]);
|
|
3760
|
-
var
|
|
3761
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (
|
|
3855
|
+
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
|
|
3856
|
+
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, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }, onlyInputKeyboardEventHandlers)) })));
|
|
3762
3857
|
};
|
|
3763
3858
|
|
|
3764
3859
|
var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
|
|
3765
3860
|
|
|
3766
3861
|
var GridFormTextInput = function (props) {
|
|
3767
|
-
var _a;
|
|
3768
|
-
var
|
|
3862
|
+
var _a, _b;
|
|
3863
|
+
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
|
|
3864
|
+
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
|
|
3769
3865
|
var initValue = initialVale == null ? "" : "".concat(initialVale);
|
|
3770
|
-
var
|
|
3771
|
-
var invalid = react.useCallback(function () {
|
|
3772
|
-
var trimmedValue = value.trim();
|
|
3773
|
-
if (props.required && trimmedValue.length == 0) {
|
|
3774
|
-
return "Some text is required";
|
|
3775
|
-
}
|
|
3776
|
-
if (props.maxLength && trimmedValue.length > props.maxLength) {
|
|
3777
|
-
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3778
|
-
}
|
|
3779
|
-
if (props.validate) {
|
|
3780
|
-
return props.validate(trimmedValue, data);
|
|
3781
|
-
}
|
|
3782
|
-
return null;
|
|
3783
|
-
}, [data, props, value]);
|
|
3866
|
+
var _d = react.useState(initValue), value = _d[0], setValue = _d[1];
|
|
3867
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3784
3868
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3785
3869
|
var trimmedValue;
|
|
3786
3870
|
return __generator(this, function (_a) {
|
|
@@ -3806,90 +3890,72 @@ var GridFormTextInput = function (props) {
|
|
|
3806
3890
|
}
|
|
3807
3891
|
});
|
|
3808
3892
|
}); }, [invalid, value, initValue, props, field]);
|
|
3809
|
-
var
|
|
3810
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (
|
|
3811
|
-
style: { width: "100%" },
|
|
3812
|
-
placeholder: props.placeholder,
|
|
3813
|
-
onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3814
|
-
return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
|
|
3815
|
-
}); }); }
|
|
3816
|
-
} }) })));
|
|
3893
|
+
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
|
|
3894
|
+
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, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, style: { width: "100%" }, placeholder: props.placeholder }, onlyInputKeyboardEventHandlers, { helpText: helpText })) })));
|
|
3817
3895
|
};
|
|
3818
3896
|
|
|
3819
3897
|
var GridPopoverTextInput = function (colDef, params) {
|
|
3820
3898
|
return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
|
|
3821
3899
|
};
|
|
3822
3900
|
|
|
3823
|
-
var
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
var
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
fontSize: "0.7rem"
|
|
3856
|
-
} }, { children: helpText }))] })));
|
|
3901
|
+
var GridFormSubComponentTextInput = function (props) {
|
|
3902
|
+
var _a;
|
|
3903
|
+
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
|
|
3904
|
+
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
|
|
3905
|
+
// If is not initialised yet as it's just been created then set the default value
|
|
3906
|
+
react.useEffect(function () {
|
|
3907
|
+
if (value == null)
|
|
3908
|
+
setValue(props.defaultValue);
|
|
3909
|
+
}, [props.defaultValue, setValue, value]);
|
|
3910
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3911
|
+
react.useEffect(function () {
|
|
3912
|
+
setValid(value != null && invalid() == null);
|
|
3913
|
+
}, [setValid, invalid, value]);
|
|
3914
|
+
return (jsxRuntime.jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, onKeyDown: function (e) {
|
|
3915
|
+
if (e.key === "Tab" || e.key === "Enter") {
|
|
3916
|
+
e.preventDefault();
|
|
3917
|
+
e.stopPropagation();
|
|
3918
|
+
}
|
|
3919
|
+
}, onKeyUp: function (e) {
|
|
3920
|
+
if (e.key === "Tab") {
|
|
3921
|
+
e.preventDefault();
|
|
3922
|
+
e.stopPropagation();
|
|
3923
|
+
!e.shiftKey && triggerSave().then();
|
|
3924
|
+
}
|
|
3925
|
+
else if (e.key === "Enter") {
|
|
3926
|
+
triggerSave().then();
|
|
3927
|
+
e.preventDefault();
|
|
3928
|
+
e.stopPropagation();
|
|
3929
|
+
}
|
|
3930
|
+
}, placeholder: props.placeholder, style: {
|
|
3931
|
+
width: "100%"
|
|
3932
|
+
} }));
|
|
3857
3933
|
};
|
|
3858
3934
|
|
|
3859
|
-
var
|
|
3860
|
-
var _a
|
|
3935
|
+
var GridFormSubComponentTextArea = function (props) {
|
|
3936
|
+
var _a;
|
|
3937
|
+
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
|
|
3938
|
+
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
|
|
3861
3939
|
// If is not initialised yet as it's just been created then set the default value
|
|
3862
3940
|
react.useEffect(function () {
|
|
3863
3941
|
if (value == null)
|
|
3864
3942
|
setValue(props.defaultValue);
|
|
3865
3943
|
}, [props.defaultValue, setValue, value]);
|
|
3866
|
-
var
|
|
3867
|
-
if (value == null)
|
|
3868
|
-
return null;
|
|
3869
|
-
// This can happen because subcomponent is invoked without type safety
|
|
3870
|
-
if (typeof value !== "string") {
|
|
3871
|
-
console.error("Value is not a string", value);
|
|
3872
|
-
}
|
|
3873
|
-
if (props.required && value.length === 0) {
|
|
3874
|
-
return "Some text is required";
|
|
3875
|
-
}
|
|
3876
|
-
if (props.maxLength && value.length > props.maxLength) {
|
|
3877
|
-
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3878
|
-
}
|
|
3879
|
-
if (props.validate) {
|
|
3880
|
-
return props.validate(value);
|
|
3881
|
-
}
|
|
3882
|
-
return null;
|
|
3883
|
-
}, [props]);
|
|
3944
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3884
3945
|
react.useEffect(function () {
|
|
3885
|
-
setValid(value != null &&
|
|
3886
|
-
}, [setValid,
|
|
3887
|
-
return (jsxRuntime.jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsxRuntime.jsx(
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3946
|
+
setValid(value != null && invalid() == null);
|
|
3947
|
+
}, [setValid, invalid, value]);
|
|
3948
|
+
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, onKeyDown: function (e) {
|
|
3949
|
+
if (e.key === "Tab") {
|
|
3950
|
+
e.preventDefault();
|
|
3951
|
+
e.stopPropagation();
|
|
3952
|
+
}
|
|
3953
|
+
}, onKeyUp: function (e) {
|
|
3954
|
+
if (e.key === "Tab") {
|
|
3955
|
+
e.preventDefault();
|
|
3956
|
+
e.stopPropagation();
|
|
3957
|
+
!e.shiftKey && triggerSave().then();
|
|
3958
|
+
}
|
|
3893
3959
|
} }) })));
|
|
3894
3960
|
};
|
|
3895
3961
|
|
|
@@ -4019,6 +4085,7 @@ exports.GridContextProvider = GridContextProvider;
|
|
|
4019
4085
|
exports.GridFormDropDown = GridFormDropDown;
|
|
4020
4086
|
exports.GridFormMultiSelect = GridFormMultiSelect;
|
|
4021
4087
|
exports.GridFormPopoverMenu = GridFormPopoverMenu;
|
|
4088
|
+
exports.GridFormSubComponentTextArea = GridFormSubComponentTextArea;
|
|
4022
4089
|
exports.GridFormSubComponentTextInput = GridFormSubComponentTextInput;
|
|
4023
4090
|
exports.GridHeaderSelect = GridHeaderSelect;
|
|
4024
4091
|
exports.GridIcon = GridIcon;
|
|
@@ -4036,7 +4103,6 @@ exports.GridPopoverTextInput = GridPopoverTextInput;
|
|
|
4036
4103
|
exports.GridRenderPopoutMenuCell = GridRenderPopoutMenuCell;
|
|
4037
4104
|
exports.GridRendererGenericCell = GridRendererGenericCell;
|
|
4038
4105
|
exports.GridSubComponentContext = GridSubComponentContext;
|
|
4039
|
-
exports.GridSubComponentTextArea = GridSubComponentTextArea;
|
|
4040
4106
|
exports.GridUpdatingContext = GridUpdatingContext;
|
|
4041
4107
|
exports.GridUpdatingContextProvider = GridUpdatingContextProvider;
|
|
4042
4108
|
exports.Menu = Menu;
|