@linzjs/step-ag-grid 2.4.0 → 2.4.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 CHANGED
@@ -2840,7 +2840,8 @@ var GridFormDropDown = function (_props) {
2840
2840
  var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
2841
2841
  var optionsInitialising = react.useRef(false);
2842
2842
  var _d = react.useState(null), options = _d[0], setOptions = _d[1];
2843
- var selectItemHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
2843
+ var _e = react.useState([]), subComponentValues = _e[0], setSubComponentValues = _e[1];
2844
+ var selectItemHandler = react.useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
2844
2845
  var field;
2845
2846
  return __generator(this, function (_a) {
2846
2847
  switch (_a.label) {
@@ -2854,7 +2855,7 @@ var GridFormDropDown = function (_props) {
2854
2855
  hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
2855
2856
  if (!hasChanged) return [3 /*break*/, 3];
2856
2857
  if (!props.onSelectedItem) return [3 /*break*/, 2];
2857
- return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value })];
2858
+ return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value, subComponentValue: subComponentValue })];
2858
2859
  case 1:
2859
2860
  _a.sent();
2860
2861
  return [3 /*break*/, 3];
@@ -2996,7 +2997,40 @@ var GridFormDropDown = function (_props) {
2996
2997
  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); } }) })));
2997
2998
  } })), 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]" }), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2998
2999
  var _a;
2999
- return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsxRuntime.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)));
3000
+ return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !item.subComponent ? (jsxRuntime.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
3001
+ selectItemHandler(item.value);
3002
+ } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index))) : (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
3003
+ return item.subComponent &&
3004
+ item.subComponent({
3005
+ setValue: function (value) {
3006
+ var localSubComponentValues = __spreadArray([], subComponentValues, true);
3007
+ var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3008
+ var optionValue = _a.optionValue;
3009
+ return optionValue === item.value;
3010
+ });
3011
+ if (subComponentValueIndex !== -1) {
3012
+ localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3013
+ }
3014
+ else {
3015
+ localSubComponentValues.push({
3016
+ subComponentValue: value,
3017
+ optionValue: item.value
3018
+ });
3019
+ }
3020
+ setSubComponentValues(localSubComponentValues);
3021
+ },
3022
+ keyDown: function (key) {
3023
+ var subComponentItem = subComponentValues.find(function (_a) {
3024
+ var optionValue = _a.optionValue;
3025
+ return optionValue === item.value;
3026
+ });
3027
+ if (key === "Enter" && subComponentItem) {
3028
+ selectItemHandler(item.value, subComponentItem.subComponentValue);
3029
+ ref.closeMenu();
3030
+ }
3031
+ }
3032
+ }, ref);
3033
+ } }), "".concat(props.field, "-").concat(index, "_subcomponent"))) }));
3000
3034
  })] }) }))] }));
3001
3035
  };
3002
3036
 
@@ -3627,6 +3661,25 @@ var GridPopoverTextInput = function (colDef, params) {
3627
3661
  return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
3628
3662
  };
3629
3663
 
3664
+ var GridFormSubComponentTextInput = function (_a) {
3665
+ var keyDown = _a.keyDown, placeholder = _a.placeholder, setValue = _a.setValue;
3666
+ var placeholderText = placeholder || "Other...";
3667
+ var _b = react.useState(""), inputValue = _b[0], setInputValue = _b[1];
3668
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(TextInputFormatted, { value: inputValue, onChange: function (e) {
3669
+ var value = e.target.value;
3670
+ setValue(value);
3671
+ setInputValue(value);
3672
+ }, inputProps: {
3673
+ onKeyDown: function (k) { return keyDown(k.key); },
3674
+ placeholder: placeholderText,
3675
+ onMouseEnter: function (e) {
3676
+ if (document.activeElement != e.currentTarget) {
3677
+ e.currentTarget.focus();
3678
+ }
3679
+ }
3680
+ } }) }));
3681
+ };
3682
+
3630
3683
  var GridSubComponentTextArea = function (props) {
3631
3684
  var _a = react.useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
3632
3685
  // If is not initialised yet as it's just been created then set the default value
@@ -3774,6 +3827,7 @@ exports.GridContextProvider = GridContextProvider;
3774
3827
  exports.GridFormDropDown = GridFormDropDown;
3775
3828
  exports.GridFormMultiSelect = GridFormMultiSelect;
3776
3829
  exports.GridFormPopoutMenu = GridFormPopoutMenu;
3830
+ exports.GridFormSubComponentTextInput = GridFormSubComponentTextInput;
3777
3831
  exports.GridHeaderSelect = GridHeaderSelect;
3778
3832
  exports.GridIcon = GridIcon;
3779
3833
  exports.GridLoadableCell = GridLoadableCell;