@linzjs/step-ag-grid 2.4.0 → 2.4.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.
@@ -5,11 +5,13 @@ import { CellEditorCommon } from "../GridCell";
5
5
  export interface GridPopoutEditDropDownSelectedItem<RowType, ValueType> {
6
6
  selectedRows: RowType[];
7
7
  value: ValueType;
8
+ subComponentValue?: ValueType;
8
9
  }
9
10
  interface FinalSelectOption<ValueType> {
10
11
  value: ValueType;
11
12
  label?: JSX.Element | string;
12
13
  disabled?: boolean | string;
14
+ subComponent?: (props: any, ref: any) => any;
13
15
  }
14
16
  export declare const MenuSeparatorString = "_____MENU_SEPARATOR_____";
15
17
  export declare const MenuSeparator: Readonly<{
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface GridFormSubComponentTextInput {
3
+ setValue: (value: string) => void;
4
+ keyDown: (key: string) => void;
5
+ placeholder?: string;
6
+ }
7
+ export declare const GridFormSubComponentTextInput: ({ keyDown, placeholder, setValue }: GridFormSubComponentTextInput) => JSX.Element;
@@ -6,4 +6,4 @@ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
6
6
  /**
7
7
  * Popout burger menu
8
8
  */
9
- export declare const GridPopoverMenu: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>) => ColDefT<RowType>;
9
+ export declare const GridPopoverMenu: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, custom: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>) => ColDefT<RowType>;
@@ -23,6 +23,7 @@ export { GridPopoverEditDropDown } from "./components/gridPopoverEdit/GridPopove
23
23
  export { GridPopoverMessage } from "./components/gridPopoverEdit/GridPopoverMessage";
24
24
  export { GridPopoverTextArea } from "./components/gridPopoverEdit/GridPopoverTextArea";
25
25
  export { GridPopoverTextInput } from "./components/gridPopoverEdit/GridPopoverTextInput";
26
+ export { GridFormSubComponentTextInput } from "./components/gridForm/GridFormSubComponentTextInput";
26
27
  export * from "./components/gridForm/GridFormDropDown";
27
28
  export * from "./components/gridForm/GridFormMultiSelect";
28
29
  export * from "./components/gridForm/GridFormPopoutMenu";
@@ -9,7 +9,7 @@ export interface ActionButtonProps {
9
9
  dataTestId?: string;
10
10
  size?: "xs" | "sm" | "md" | "lg" | "xl" | "ns";
11
11
  className?: string;
12
- onClick?: () => void;
13
- inProgress?: boolean;
12
+ onAction: () => Promise<void>;
13
+ externalSetInProgress?: () => void;
14
14
  }
15
- export declare const ActionButton: ({ icon, name, inProgressName, dataTestId, inProgress, className, title, onClick, size, }: ActionButtonProps) => JSX.Element;
15
+ export declare const ActionButton: ({ icon, name, inProgressName, dataTestId, className, title, onAction, externalSetInProgress, size, }: ActionButtonProps) => JSX.Element;
@@ -2838,7 +2838,8 @@ var GridFormDropDown = function (_props) {
2838
2838
  var _c = useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
2839
2839
  var optionsInitialising = useRef(false);
2840
2840
  var _d = useState(null), options = _d[0], setOptions = _d[1];
2841
- var selectItemHandler = useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
2841
+ var _e = useState([]), subComponentValues = _e[0], setSubComponentValues = _e[1];
2842
+ var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
2842
2843
  var field;
2843
2844
  return __generator(this, function (_a) {
2844
2845
  switch (_a.label) {
@@ -2852,7 +2853,7 @@ var GridFormDropDown = function (_props) {
2852
2853
  hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
2853
2854
  if (!hasChanged) return [3 /*break*/, 3];
2854
2855
  if (!props.onSelectedItem) return [3 /*break*/, 2];
2855
- return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value })];
2856
+ return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value, subComponentValue: subComponentValue })];
2856
2857
  case 1:
2857
2858
  _a.sent();
2858
2859
  return [3 /*break*/, 3];
@@ -2994,7 +2995,40 @@ var GridFormDropDown = function (_props) {
2994
2995
  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()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
2995
2996
  } })), 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]" }), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2996
2997
  var _a;
2997
- return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () { return selectItemHandler(item.value); } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index)));
2998
+ return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsx(Fragment$1, { children: !item.subComponent ? (jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
2999
+ selectItemHandler(item.value);
3000
+ } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index))) : (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
3001
+ return item.subComponent &&
3002
+ item.subComponent({
3003
+ setValue: function (value) {
3004
+ var localSubComponentValues = __spreadArray([], subComponentValues, true);
3005
+ var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3006
+ var optionValue = _a.optionValue;
3007
+ return optionValue === item.value;
3008
+ });
3009
+ if (subComponentValueIndex !== -1) {
3010
+ localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3011
+ }
3012
+ else {
3013
+ localSubComponentValues.push({
3014
+ subComponentValue: value,
3015
+ optionValue: item.value
3016
+ });
3017
+ }
3018
+ setSubComponentValues(localSubComponentValues);
3019
+ },
3020
+ keyDown: function (key) {
3021
+ var subComponentItem = subComponentValues.find(function (_a) {
3022
+ var optionValue = _a.optionValue;
3023
+ return optionValue === item.value;
3024
+ });
3025
+ if (key === "Enter" && subComponentItem) {
3026
+ selectItemHandler(item.value, subComponentItem.subComponentValue);
3027
+ ref.closeMenu();
3028
+ }
3029
+ }
3030
+ }, ref);
3031
+ } }), "".concat(props.field, "-").concat(index, "_subcomponent"))) }));
2998
3032
  })] }) }))] }));
2999
3033
  };
3000
3034
 
@@ -3238,12 +3272,11 @@ var GridFormPopoutMenu = function (_props) {
3238
3272
  /**
3239
3273
  * Popout burger menu
3240
3274
  */
3241
- var GridPopoverMenu = function (colDef, props) {
3242
- var _a;
3243
- return GridCell(__assign(__assign({ maxWidth: 64, editable: colDef.editable != null ? colDef.editable : true, cellRenderer: GridRenderPopoutMenuCell, cellClass: ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) === null || _a === void 0 ? void 0 : _a.multiEdit) !== false ? GenericMultiEditCellClass : undefined }, colDef), { cellRendererParams: {
3275
+ var GridPopoverMenu = function (colDef, custom) {
3276
+ return GridCell(__assign(__assign({ maxWidth: 64, editable: colDef.editable != null ? colDef.editable : true, cellRenderer: GridRenderPopoutMenuCell, cellClass: (custom === null || custom === void 0 ? void 0 : custom.multiEdit) ? GenericMultiEditCellClass : undefined }, colDef), { cellRendererParams: {
3244
3277
  // Menus open on single click, this parameter is picked up in Grid.tsx
3245
3278
  singleClickEdit: true
3246
- } }), __assign({ editor: GridFormPopoutMenu }, props));
3279
+ } }), __assign({ editor: GridFormPopoutMenu }, custom));
3247
3280
  };
3248
3281
 
3249
3282
  var bearingValueFormatter = function (params) {
@@ -3625,6 +3658,25 @@ var GridPopoverTextInput = function (colDef, params) {
3625
3658
  return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
3626
3659
  };
3627
3660
 
3661
+ var GridFormSubComponentTextInput = function (_a) {
3662
+ var keyDown = _a.keyDown, placeholder = _a.placeholder, setValue = _a.setValue;
3663
+ var placeholderText = placeholder || "Other...";
3664
+ var _b = useState(""), inputValue = _b[0], setInputValue = _b[1];
3665
+ return (jsx(Fragment$1, { children: jsx(TextInputFormatted, { value: inputValue, onChange: function (e) {
3666
+ var value = e.target.value;
3667
+ setValue(value);
3668
+ setInputValue(value);
3669
+ }, inputProps: {
3670
+ onKeyDown: function (k) { return keyDown(k.key); },
3671
+ placeholder: placeholderText,
3672
+ onMouseEnter: function (e) {
3673
+ if (document.activeElement != e.currentTarget) {
3674
+ e.currentTarget.focus();
3675
+ }
3676
+ }
3677
+ } }) }));
3678
+ };
3679
+
3628
3680
  var GridSubComponentTextArea = function (props) {
3629
3681
  var _a = useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
3630
3682
  // If is not initialised yet as it's just been created then set the default value
@@ -3741,15 +3793,30 @@ var minimumInProgressTimeMs = 950;
3741
3793
  var ActionButton = function (_a) {
3742
3794
  var _b;
3743
3795
  var _c;
3744
- var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, dataTestId = _a.dataTestId, inProgress = _a.inProgress, className = _a.className, title = _a.title, onClick = _a.onClick, _d = _a.size, size = _d === void 0 ? "sm" : _d;
3796
+ var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, dataTestId = _a.dataTestId, className = _a.className, title = _a.title, onAction = _a.onAction, externalSetInProgress = _a.externalSetInProgress, _d = _a.size, size = _d === void 0 ? "sm" : _d;
3797
+ var _e = useState(false), inProgress = _e[0], setInProgress = _e[1];
3745
3798
  var lastInProgress = usePrevious(inProgress !== null && inProgress !== void 0 ? inProgress : false);
3746
- var _e = useStateDeferred(!!inProgress), localInProgress = _e[0], setLocalInProgress = _e[1], setLocalInProgressDeferred = _e[2];
3799
+ var _f = useStateDeferred(inProgress), localInProgress = _f[0], setLocalInProgress = _f[1], setLocalInProgressDeferred = _f[2];
3747
3800
  useEffect(function () {
3748
3801
  if (inProgress == lastInProgress)
3749
3802
  return;
3750
3803
  inProgress ? setLocalInProgress(true) : setLocalInProgressDeferred(false, minimumInProgressTimeMs);
3751
3804
  }, [inProgress, lastInProgress, setLocalInProgress, setLocalInProgressDeferred]);
3752
- return (jsxs(LuiButton, __assign({ "data-testid": dataTestId, type: "button", level: "tertiary", title: title !== null && title !== void 0 ? title : name, "aria-label": name, className: clsx("lui-button-icon", "ActionButton", className, localInProgress && "ActionButton-inProgress"), size: "lg", onClick: onClick, disabled: localInProgress }, { children: [localInProgress ? (jsx(LuiMiniSpinner, { size: 16, divProps: (_b = {
3805
+ return (jsxs(LuiButton, __assign({ "data-testid": dataTestId, type: "button", level: "tertiary", title: title !== null && title !== void 0 ? title : name, "aria-label": name, className: clsx("lui-button-icon", "ActionButton", className, localInProgress && "ActionButton-inProgress"), size: "lg", onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
3806
+ return __generator(this, function (_a) {
3807
+ switch (_a.label) {
3808
+ case 0:
3809
+ setInProgress(true);
3810
+ externalSetInProgress && setInProgress(true);
3811
+ return [4 /*yield*/, onAction()];
3812
+ case 1:
3813
+ _a.sent();
3814
+ externalSetInProgress && setInProgress(false);
3815
+ setInProgress(false);
3816
+ return [2 /*return*/];
3817
+ }
3818
+ });
3819
+ }); }, disabled: localInProgress }, { children: [localInProgress ? (jsx(LuiMiniSpinner, { size: 16, divProps: (_b = {
3753
3820
  "data-testid": "loading-spinner",
3754
3821
  style: { padding: 0, margin: 0, paddingRight: 8 },
3755
3822
  role: "status"
@@ -3758,5 +3825,5 @@ var ActionButton = function (_a) {
3758
3825
  _b) })) : (jsx(LuiIcon, { name: icon, alt: name, size: size })), jsxs("span", __assign({ className: "ActionButton-minimalArea" }, { children: [jsx("span", __assign({ className: "ActionButton-minimalAreaDisplay" }, { children: (_c = (localInProgress ? inProgressName : name)) !== null && _c !== void 0 ? _c : name })), jsx("span", __assign({ className: "ActionButton-minimalAreaExpand" }, { children: name }))] }))] })));
3759
3826
  };
3760
3827
 
3761
- export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponent, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoutMenu, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
3828
+ export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponent, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoutMenu, GridFormSubComponentTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
3762
3829
  //# sourceMappingURL=step-ag-grid.esm.js.map