@linzjs/step-ag-grid 3.0.1 → 3.0.2

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 CHANGED
@@ -1784,54 +1784,6 @@ var MenuRadioGroupFr = function (_a, externalRef) {
1784
1784
  };
1785
1785
  var MenuRadioGroup = react.forwardRef(MenuRadioGroupFr);
1786
1786
 
1787
- var GridUpdatingContext = react.createContext({
1788
- checkUpdating: function () {
1789
- console.error("Missing GridUpdatingContext");
1790
- return false;
1791
- },
1792
- modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1793
- return __generator(this, function (_a) {
1794
- console.error("Missing GridUpdatingContext");
1795
- return [2 /*return*/];
1796
- });
1797
- }); }
1798
- });
1799
-
1800
- var GridUpdatingContextProvider = function (props) {
1801
- var updatingBlocks = react.useRef({});
1802
- var updating = react.useRef({});
1803
- var resetUpdating = function () {
1804
- var mergedUpdatingBlocks = {};
1805
- for (var key in updatingBlocks.current) {
1806
- mergedUpdatingBlocks[key] = lodashEs.flatten(updatingBlocks.current[key]);
1807
- }
1808
- updating.current = mergedUpdatingBlocks;
1809
- };
1810
- var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
1811
- var fieldUpdatingIds, idRef;
1812
- var _a;
1813
- return __generator(this, function (_b) {
1814
- switch (_b.label) {
1815
- case 0:
1816
- fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
1817
- idRef = __spreadArray([], ids, true);
1818
- fieldUpdatingIds.push(idRef);
1819
- resetUpdating();
1820
- return [4 /*yield*/, fn()];
1821
- case 1:
1822
- _b.sent();
1823
- lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
1824
- resetUpdating();
1825
- return [2 /*return*/];
1826
- }
1827
- });
1828
- }); };
1829
- var checkUpdating = function (fields, id) {
1830
- return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
1831
- };
1832
- return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
1833
- };
1834
-
1835
1787
  var GridContext = react.createContext({
1836
1788
  gridReady: function () {
1837
1789
  console.error("no context provider for gridReady");
@@ -1905,6 +1857,19 @@ var GridContext = react.createContext({
1905
1857
  }
1906
1858
  });
1907
1859
 
1860
+ var GridUpdatingContext = react.createContext({
1861
+ checkUpdating: function () {
1862
+ console.error("Missing GridUpdatingContext");
1863
+ return false;
1864
+ },
1865
+ modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1866
+ return __generator(this, function (_a) {
1867
+ console.error("Missing GridUpdatingContext");
1868
+ return [2 /*return*/];
1869
+ });
1870
+ }); }
1871
+ });
1872
+
1908
1873
  /**
1909
1874
  * Context for AgGrid operations.
1910
1875
  * Make sure you wrap AgGrid in this.
@@ -2184,6 +2149,109 @@ var GridContextProvider = function (props) {
2184
2149
  } }, { children: props.children })));
2185
2150
  };
2186
2151
 
2152
+ var GridUpdatingContextProvider = function (props) {
2153
+ var updatingBlocks = react.useRef({});
2154
+ var updating = react.useRef({});
2155
+ var resetUpdating = function () {
2156
+ var mergedUpdatingBlocks = {};
2157
+ for (var key in updatingBlocks.current) {
2158
+ mergedUpdatingBlocks[key] = lodashEs.flatten(updatingBlocks.current[key]);
2159
+ }
2160
+ updating.current = mergedUpdatingBlocks;
2161
+ };
2162
+ var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2163
+ var fieldUpdatingIds, idRef;
2164
+ var _a;
2165
+ return __generator(this, function (_b) {
2166
+ switch (_b.label) {
2167
+ case 0:
2168
+ fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2169
+ idRef = __spreadArray([], ids, true);
2170
+ fieldUpdatingIds.push(idRef);
2171
+ resetUpdating();
2172
+ return [4 /*yield*/, fn()];
2173
+ case 1:
2174
+ _b.sent();
2175
+ lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2176
+ resetUpdating();
2177
+ return [2 /*return*/];
2178
+ }
2179
+ });
2180
+ }); };
2181
+ var checkUpdating = function (fields, id) {
2182
+ return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
2183
+ };
2184
+ return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
2185
+ };
2186
+
2187
+ var GridPopoverContext = react.createContext({
2188
+ anchorRef: { current: null },
2189
+ saving: false,
2190
+ setSaving: function () { },
2191
+ field: "",
2192
+ value: null,
2193
+ data: {},
2194
+ selectedRows: [],
2195
+ updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2196
+ return [2 /*return*/, false];
2197
+ }); }); }
2198
+ });
2199
+ var useGridPopoverContext = function () {
2200
+ return react.useContext(GridPopoverContext);
2201
+ };
2202
+
2203
+ var GridPopoverContextProvider = function (_a) {
2204
+ var _b, _c, _d;
2205
+ var props = _a.props, children = _a.children;
2206
+ var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2207
+ var anchorRef = react.useRef(props.eGridCell);
2208
+ var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
2209
+ var colDef = props.colDef;
2210
+ var cellEditorParams = colDef.cellEditorParams;
2211
+ var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2212
+ // Then item that is clicked on will always be first in the list
2213
+ 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
+ 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 () { var _a; return __generator(this, function (_b) {
2216
+ switch (_b.label) {
2217
+ case 0:
2218
+ _a = !saving;
2219
+ if (!_a) return [3 /*break*/, 2];
2220
+ return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2221
+ case 1:
2222
+ _a = (_b.sent());
2223
+ _b.label = 2;
2224
+ case 2: return [2 /*return*/, _a];
2225
+ }
2226
+ }); }); }, [field, saving, selectedRows, updatingCells]);
2227
+ return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
2228
+ anchorRef: anchorRef,
2229
+ saving: saving,
2230
+ setSaving: setSaving,
2231
+ selectedRows: selectedRows,
2232
+ field: field,
2233
+ data: props.data,
2234
+ value: props.value,
2235
+ updateValue: updateValue
2236
+ } }, { children: children })));
2237
+ };
2238
+
2239
+ var GridSubComponentContext = react.createContext({
2240
+ value: "GridSubComponentContext value no context",
2241
+ setValue: function () {
2242
+ console.error("GridSubComponentContext setValue no context");
2243
+ },
2244
+ setValid: function () {
2245
+ console.error("GridSubComponentContext setValid no context");
2246
+ },
2247
+ triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
2248
+ return __generator(this, function (_a) {
2249
+ console.error("GridSubComponentContext triggerSave no context");
2250
+ return [2 /*return*/];
2251
+ });
2252
+ }); }
2253
+ });
2254
+
2187
2255
  function toVal(mix) {
2188
2256
  var k, y, str='';
2189
2257
  if (mix) {
@@ -2650,58 +2718,6 @@ var GridRendererGenericCell = function (props) {
2650
2718
  return (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_c = (_b = colDef.field) !== null && _b !== void 0 ? _b : colDef.colId) !== null && _c !== void 0 ? _c : "", props.data.id) }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.jsx("span", __assign({ title: formatted }, { children: formatted }))] }) })));
2651
2719
  };
2652
2720
 
2653
- var GridPopoverContext = react.createContext({
2654
- anchorRef: { current: null },
2655
- saving: false,
2656
- setSaving: function () { },
2657
- field: "",
2658
- value: null,
2659
- data: {},
2660
- selectedRows: [],
2661
- updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2662
- return [2 /*return*/, false];
2663
- }); }); }
2664
- });
2665
- var useGridPopoverContext = function () {
2666
- return react.useContext(GridPopoverContext);
2667
- };
2668
-
2669
- var GridPopoverContextProvider = function (_a) {
2670
- var _b, _c, _d;
2671
- var props = _a.props, children = _a.children;
2672
- var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2673
- var anchorRef = react.useRef(props.eGridCell);
2674
- var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
2675
- var colDef = props.colDef;
2676
- var cellEditorParams = colDef.cellEditorParams;
2677
- var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2678
- // Then item that is clicked on will always be first in the list
2679
- var selectedRows = react.useMemo(function () { return (multiEdit ? lodashEs.sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2680
- var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2681
- var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
2682
- switch (_b.label) {
2683
- case 0:
2684
- _a = !saving;
2685
- if (!_a) return [3 /*break*/, 2];
2686
- return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2687
- case 1:
2688
- _a = (_b.sent());
2689
- _b.label = 2;
2690
- case 2: return [2 /*return*/, _a];
2691
- }
2692
- }); }); }, [field, saving, selectedRows, updatingCells]);
2693
- return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
2694
- anchorRef: anchorRef,
2695
- saving: saving,
2696
- setSaving: setSaving,
2697
- selectedRows: selectedRows,
2698
- field: field,
2699
- data: props.data,
2700
- value: props.value,
2701
- updateValue: updateValue
2702
- } }, { children: children })));
2703
- };
2704
-
2705
2721
  var GridCellRenderer = function (props) {
2706
2722
  var _a, _b, _c;
2707
2723
  var checkUpdating = react.useContext(GridUpdatingContext).checkUpdating;
@@ -3113,22 +3129,6 @@ var GridFormDropDown = function (props) {
3113
3129
  })] }) }))] }));
3114
3130
  };
3115
3131
 
3116
- var GridSubComponentContext = react.createContext({
3117
- value: "GridSubComponentContext value no context",
3118
- setValue: function () {
3119
- console.error("GridSubComponentContext setValue no context");
3120
- },
3121
- setValid: function () {
3122
- console.error("GridSubComponentContext setValid no context");
3123
- },
3124
- triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
3125
- return __generator(this, function (_a) {
3126
- console.error("GridSubComponentContext triggerSave no context");
3127
- return [2 /*return*/];
3128
- });
3129
- }); }
3130
- });
3131
-
3132
3132
  var GridFormMultiSelect = function (props) {
3133
3133
  var selectedRows = useGridPopoverContext().selectedRows;
3134
3134
  var initialiseValues = react.useMemo(function () {
@@ -4024,6 +4024,8 @@ exports.GridHeaderSelect = GridHeaderSelect;
4024
4024
  exports.GridIcon = GridIcon;
4025
4025
  exports.GridLoadableCell = GridLoadableCell;
4026
4026
  exports.GridPopoutEditMultiSelect = GridPopoutEditMultiSelect;
4027
+ exports.GridPopoverContext = GridPopoverContext;
4028
+ exports.GridPopoverContextProvider = GridPopoverContextProvider;
4027
4029
  exports.GridPopoverEditBearing = GridPopoverEditBearing;
4028
4030
  exports.GridPopoverEditBearingCorrection = GridPopoverEditBearingCorrection;
4029
4031
  exports.GridPopoverEditDropDown = GridPopoverEditDropDown;
@@ -4033,6 +4035,7 @@ exports.GridPopoverTextArea = GridPopoverTextArea;
4033
4035
  exports.GridPopoverTextInput = GridPopoverTextInput;
4034
4036
  exports.GridRenderPopoutMenuCell = GridRenderPopoutMenuCell;
4035
4037
  exports.GridRendererGenericCell = GridRendererGenericCell;
4038
+ exports.GridSubComponentContext = GridSubComponentContext;
4036
4039
  exports.GridSubComponentTextArea = GridSubComponentTextArea;
4037
4040
  exports.GridUpdatingContext = GridUpdatingContext;
4038
4041
  exports.GridUpdatingContextProvider = GridUpdatingContextProvider;
@@ -4059,6 +4062,7 @@ exports.convertDDToDMS = convertDDToDMS;
4059
4062
  exports.hasParentClass = hasParentClass;
4060
4063
  exports.isFloat = isFloat;
4061
4064
  exports.isNotEmpty = isNotEmpty;
4065
+ exports.useGridPopoverContext = useGridPopoverContext;
4062
4066
  exports.useGridPopoverHook = useGridPopoverHook;
4063
4067
  exports.useMenuState = useMenuState;
4064
4068
  exports.usePostSortRowsHook = usePostSortRowsHook;