@linzjs/step-ag-grid 7.0.3 → 7.0.4

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.
@@ -1,12 +1,5 @@
1
1
  import { RefObject } from "react";
2
2
  import { GridBaseRow } from "../components/Grid";
3
- export interface PropsType {
4
- value: any;
5
- data: any;
6
- field: string;
7
- selectedRows: any[];
8
- updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>;
9
- }
10
3
  export interface GridPopoverContextType<RowType extends GridBaseRow> {
11
4
  anchorRef: RefObject<Element>;
12
5
  saving: boolean;
@@ -16,6 +9,7 @@ export interface GridPopoverContextType<RowType extends GridBaseRow> {
16
9
  data: RowType;
17
10
  selectedRows: RowType[];
18
11
  updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>, tabDirection: 1 | 0 | -1) => Promise<boolean>;
12
+ formatValue: (value: any) => any;
19
13
  }
20
14
  export declare const GridPopoverContext: import("react").Context<GridPopoverContextType<any>>;
21
15
  export declare const useGridPopoverContext: <RowType extends GridBaseRow>() => GridPopoverContextType<RowType>;
@@ -2361,7 +2361,8 @@ var GridPopoverContext = createContext({
2361
2361
  selectedRows: [],
2362
2362
  updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2363
2363
  return [2 /*return*/, false];
2364
- }); }); }
2364
+ }); }); },
2365
+ formatValue: function () { return "! No gridPopoverContextProvider !"; }
2365
2366
  });
2366
2367
  var useGridPopoverContext = function () {
2367
2368
  return useContext(GridPopoverContext);
@@ -2410,7 +2411,8 @@ var GridPopoverContextProvider = function (_a) {
2410
2411
  field: field,
2411
2412
  data: props.data,
2412
2413
  value: props.value,
2413
- updateValue: updateValue
2414
+ updateValue: updateValue,
2415
+ formatValue: props.formatValue
2414
2416
  } }, { children: children })));
2415
2417
  };
2416
2418
 
@@ -2852,13 +2854,9 @@ var GridRendererGenericCell = function (props) {
2852
2854
  var warningText = warningFn ? warningFn(props) : undefined;
2853
2855
  var infoFn = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.info;
2854
2856
  var infoText = infoFn ? infoFn(props) : undefined;
2855
- var defaultFormatter = function (props) { return props.value; };
2856
- var formatter = (_a = colDef.valueFormatter) !== null && _a !== void 0 ? _a : defaultFormatter;
2857
- if (typeof formatter === "string") {
2858
- console.error("valueFormatter must be a function");
2859
- return jsx("span", { children: "valueFormatter must be a function" });
2860
- }
2861
- var formatted = formatter(props);
2857
+ var defaultFormatter = function (value) { return value; };
2858
+ var formatter = (_a = props.formatValue) !== null && _a !== void 0 ? _a : defaultFormatter;
2859
+ var formatted = formatter(props.value);
2862
2860
  return (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: jsxs(Fragment$1, { children: [typeof warningText === "string" && jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsx(GridIcon, { icon: "ic_info", title: infoText }), jsx("span", __assign({ title: formatted }, { children: formatted }))] }) })));
2863
2861
  };
2864
2862
 
@@ -2892,7 +2890,7 @@ var GridCell = function (props, custom) {
2892
2890
  // Default value formatter, otherwise react freaks out on objects
2893
2891
  valueFormatter: function (params) {
2894
2892
  if (params.value == null)
2895
- return "-";
2893
+ return "";
2896
2894
  var types = ["number", "boolean", "string"];
2897
2895
  if (types.includes(typeof params.value))
2898
2896
  return "".concat(params.value);
@@ -3818,14 +3816,14 @@ var GridPopoverMenu = function (colDef, custom) {
3818
3816
  var bearingValueFormatter = function (params) {
3819
3817
  var value = typeof params.value == "string" ? parseFloat(params.value) : params.value;
3820
3818
  if (value == null) {
3821
- return "-";
3819
+ return "";
3822
3820
  }
3823
3821
  return convertDDToDMS(value, false, false);
3824
3822
  };
3825
3823
  var bearingCorrectionValueFormatter = function (params) {
3826
3824
  var value = params.value;
3827
3825
  if (value == null) {
3828
- return "-";
3826
+ return "";
3829
3827
  }
3830
3828
  if (typeof value === "string") {
3831
3829
  return convertDDToDMS(bearingNumberParser(value), true, true);
@@ -3907,7 +3905,7 @@ var TextInputFormatted = function (props) {
3907
3905
  };
3908
3906
 
3909
3907
  var GridFormEditBearing = function (props) {
3910
- var _a = useGridPopoverContext(), field = _a.field, initialValue = _a.value;
3908
+ var _a = useGridPopoverContext(), field = _a.field, initialValue = _a.value, formatValue = _a.formatValue;
3911
3909
  // This clears out any scientific precision
3912
3910
  var defaultValue = useMemo(function () { return (initialValue == null ? "" : parseFloat(parseFloat(initialValue).toFixed(10)).toString()); }, [initialValue]);
3913
3911
  var _b = useState(defaultValue), value = _b[0], setValue = _b[1];
@@ -3946,11 +3944,11 @@ var GridFormEditBearing = function (props) {
3946
3944
  }).popoverWrapper;
3947
3945
  return popoverWrapper(jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsx(TextInputFormatted, { value: defaultValue, onChange: function (e) {
3948
3946
  setValue(e.target.value.trim());
3949
- }, 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" }) })));
3947
+ }, autoFocus: true, placeholder: props.placeHolder, formatted: bearingStringValidator(value, props.range) ? "?" : formatValue(bearingNumberParser(value)), error: bearingStringValidator(value, props.range), helpText: "Press enter or tab to save" }) })));
3950
3948
  };
3951
3949
 
3952
3950
  var GridPopoverEditBearingLike = function (colDef, props) {
3953
- return GridCell(__assign({ initialWidth: 65, maxWidth: 150, valueFormatter: bearingValueFormatter }, colDef), __assign({ editor: GridFormEditBearing }, props));
3951
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150 }, colDef), __assign({ editor: GridFormEditBearing }, props));
3954
3952
  };
3955
3953
  var GridPopoverEditBearing = function (colDef, props) {
3956
3954
  return GridPopoverEditBearingLike(__assign({ valueFormatter: bearingValueFormatter }, colDef), {