@linzjs/step-ag-grid 2.1.3 → 2.2.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.
Files changed (35) hide show
  1. package/dist/index.js +123 -20
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/index.d.ts +4 -0
  4. package/dist/src/lui/ActionButton.d.ts +15 -0
  5. package/dist/src/lui/reactUtils.d.ts +6 -0
  6. package/dist/src/lui/reactUtils.test.d.ts +1 -0
  7. package/dist/src/lui/stateDeferredHook.d.ts +4 -0
  8. package/dist/src/lui/timeoutHook.d.ts +8 -0
  9. package/dist/src/lui/timeoutHook.test.d.ts +1 -0
  10. package/dist/src/react-menu3/components/ControlledMenu.d.ts +2 -2
  11. package/dist/src/react-menu3/types.d.ts +4 -0
  12. package/dist/step-ag-grid.esm.js +116 -22
  13. package/dist/step-ag-grid.esm.js.map +1 -1
  14. package/package.json +4 -3
  15. package/src/components/GridPopoverHook.tsx +1 -0
  16. package/src/index.ts +5 -0
  17. package/src/lui/ActionButton.scss +32 -0
  18. package/src/lui/ActionButton.tsx +76 -0
  19. package/src/lui/reactUtils.test.tsx +47 -0
  20. package/src/lui/reactUtils.tsx +14 -0
  21. package/src/lui/stateDeferredHook.tsx +29 -0
  22. package/src/lui/timeoutHook.test.tsx +38 -0
  23. package/src/lui/timeoutHook.tsx +40 -0
  24. package/src/react-menu3/components/ControlledMenu.tsx +7 -4
  25. package/src/react-menu3/types.ts +5 -0
  26. package/src/stories/components/ActionButton.stories.tsx +33 -0
  27. package/src/stories/{components → grid}/FormTest.scss +0 -0
  28. package/src/stories/{components → grid}/FormTest.tsx +0 -0
  29. package/src/stories/{components → grid}/GridPopoutBearing.stories.tsx +7 -10
  30. package/src/stories/{components → grid}/GridPopoutEditDropDown.stories.tsx +20 -23
  31. package/src/stories/{components → grid}/GridPopoutEditGeneric.stories.tsx +6 -9
  32. package/src/stories/{components → grid}/GridPopoutEditGenericTextArea.stories.tsx +57 -18
  33. package/src/stories/{components → grid}/GridPopoutEditMultiSelect.stories.tsx +6 -9
  34. package/src/stories/{components → grid}/GridReadOnly.stories.tsx +6 -8
  35. /package/src/stories/{components → react-menu}/ReactMenu.stories.tsx +0 -0
package/dist/index.js CHANGED
@@ -1278,7 +1278,7 @@ var EventHandlersContext = react.createContext({
1278
1278
  });
1279
1279
 
1280
1280
  var ControlledMenuFr = function (_a, externalRef) {
1281
- var ariaLabel = _a["aria-label"], className = _a.className, containerProps = _a.containerProps, initialMounted = _a.initialMounted, unmountOnClose = _a.unmountOnClose, transition = _a.transition, transitionTimeout = _a.transitionTimeout, boundingBoxRef = _a.boundingBoxRef, boundingBoxPadding = _a.boundingBoxPadding, _b = _a.reposition, reposition = _b === void 0 ? "auto" : _b, _c = _a.submenuOpenDelay, submenuOpenDelay = _c === void 0 ? 300 : _c, _d = _a.submenuCloseDelay, submenuCloseDelay = _d === void 0 ? 150 : _d, skipOpen = _a.skipOpen, _e = _a.viewScroll, viewScroll = _e === void 0 ? "initial" : _e, portal = _a.portal, theming = _a.theming, onItemClick = _a.onItemClick, onClose = _a.onClose, saveButtonRef = _a.saveButtonRef, restProps = __rest(_a, ["aria-label", "className", "containerProps", "initialMounted", "unmountOnClose", "transition", "transitionTimeout", "boundingBoxRef", "boundingBoxPadding", "reposition", "submenuOpenDelay", "submenuCloseDelay", "skipOpen", "viewScroll", "portal", "theming", "onItemClick", "onClose", "saveButtonRef"]);
1281
+ var ariaLabel = _a["aria-label"], className = _a.className, containerProps = _a.containerProps, initialMounted = _a.initialMounted, unmountOnClose = _a.unmountOnClose, transition = _a.transition, transitionTimeout = _a.transitionTimeout, boundingBoxRef = _a.boundingBoxRef, boundingBoxPadding = _a.boundingBoxPadding, _b = _a.reposition, reposition = _b === void 0 ? "auto" : _b, _c = _a.submenuOpenDelay, submenuOpenDelay = _c === void 0 ? 300 : _c, _d = _a.submenuCloseDelay, submenuCloseDelay = _d === void 0 ? 150 : _d, skipOpen = _a.skipOpen, _e = _a.viewScroll, viewScroll = _e === void 0 ? "initial" : _e, portal = _a.portal, theming = _a.theming, onItemClick = _a.onItemClick, onClose = _a.onClose, saveButtonRef = _a.saveButtonRef, closeMenuExclusionClassName = _a.closeMenuExclusionClassName, restProps = __rest(_a, ["aria-label", "className", "containerProps", "initialMounted", "unmountOnClose", "transition", "transitionTimeout", "boundingBoxRef", "boundingBoxPadding", "reposition", "submenuOpenDelay", "submenuCloseDelay", "skipOpen", "viewScroll", "portal", "theming", "onItemClick", "onClose", "saveButtonRef", "closeMenuExclusionClassName"]);
1282
1282
  var containerRef = react.useRef();
1283
1283
  var scrollNodesRef = react.useRef({});
1284
1284
  var anchorRef = restProps.anchorRef, state = restProps.state;
@@ -1306,11 +1306,11 @@ var ControlledMenuFr = function (_a, externalRef) {
1306
1306
  viewScroll,
1307
1307
  ]);
1308
1308
  var clickIsWithinMenu = react.useCallback(function (ev) {
1309
- return hasParentClass("szh-menu--state-open", ev.target);
1310
- }, []);
1309
+ return hasParentClass("szh-menu--state-open", ev.target) ||
1310
+ (closeMenuExclusionClassName && hasParentClass(closeMenuExclusionClassName, ev.target));
1311
+ }, [closeMenuExclusionClassName]);
1311
1312
  var handleScreenEventForSave = react.useCallback(function (ev) {
1312
1313
  if (!clickIsWithinMenu(ev)) {
1313
- //!ev.currentTarget.contains(ev.relatedTarget || document.activeElement)) {
1314
1314
  ev.preventDefault();
1315
1315
  ev.stopPropagation();
1316
1316
  // FIXME There's an issue in React17
@@ -2520,11 +2520,11 @@ function styleInject(css, ref) {
2520
2520
  }
2521
2521
  }
2522
2522
 
2523
- var css_248z$6 = ".AgGridGenericCellRenderer-icon{margin-right:4px}.AgGridGenericCellRenderer-ic_infoIcon{fill:#3a7cdf;margin-right:4px}.AgGridGenericCellRenderer-ic_warningIcon{fill:#ea6a2e;margin-right:4px}";
2524
- styleInject(css_248z$6);
2523
+ 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}";
2524
+ styleInject(css_248z$7);
2525
2525
 
2526
- var css_248z$5 = ".GridLoadableCell-container{align-items:center;display:flex}";
2527
- styleInject(css_248z$5);
2526
+ var css_248z$6 = ".GridLoadableCell-container{align-items:center;display:flex}";
2527
+ styleInject(css_248z$6);
2528
2528
 
2529
2529
  var GridLoadableCell = function (props) {
2530
2530
  if (props.isLoading) {
@@ -2710,7 +2710,7 @@ var useGridPopoverHook = function (props) {
2710
2710
  });
2711
2711
  }); }, [props, stopEditing, propsRef]);
2712
2712
  var popoverWrapper = react.useCallback(function (children) {
2713
- 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) { return triggerSave(event.reason).then(); }, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
2713
+ 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) { return triggerSave(event.reason).then(); }, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className, closeMenuExclusionClassName: "ReactModal__Content" }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
2714
2714
  jsxRuntime.jsx("div", { style: {
2715
2715
  position: "absolute",
2716
2716
  left: 0,
@@ -2746,11 +2746,11 @@ var GridRenderPopoutMenuCell = function (props) {
2746
2746
  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" }) })));
2747
2747
  };
2748
2748
 
2749
- var css_248z$4 = ".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}";
2750
- styleInject(css_248z$4);
2749
+ 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}";
2750
+ styleInject(css_248z$5);
2751
2751
 
2752
- var css_248z$3 = ".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}";
2753
- styleInject(css_248z$3);
2752
+ 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}";
2753
+ styleInject(css_248z$4);
2754
2754
 
2755
2755
  /* global setTimeout, clearTimeout */
2756
2756
 
@@ -2824,8 +2824,11 @@ function defer() {
2824
2824
  }
2825
2825
 
2826
2826
  var MenuSeparatorString = "_____MENU_SEPARATOR_____";
2827
- Object.freeze({ value: MenuSeparatorString });
2827
+ var MenuSeparator = Object.freeze({ value: MenuSeparatorString });
2828
2828
  var MenuHeaderString = "_____MENU_HEADER_____";
2829
+ var MenuHeaderItem = function (title) {
2830
+ return { label: title, value: MenuHeaderString };
2831
+ };
2829
2832
  var GridFormDropDown = function (_props) {
2830
2833
  var props = _props;
2831
2834
  var _a = react.useContext(GridContext), updatingCells = _a.updatingCells, stopEditing = _a.stopEditing;
@@ -3122,8 +3125,8 @@ var GridPopoutEditMultiSelect = function (colDef, props) {
3122
3125
  return GridCell(__assign({ initialWidth: 65, maxWidth: 150 }, colDef), __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
3123
3126
  };
3124
3127
 
3125
- var css_248z$2 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
3126
- styleInject(css_248z$2);
3128
+ var css_248z$3 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
3129
+ styleInject(css_248z$3);
3127
3130
 
3128
3131
  /** Menu configuration types **/
3129
3132
  var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
@@ -3286,11 +3289,11 @@ var convertDDToDMS = function (dd, showPositiveSymbol, addTrailingZeros) {
3286
3289
  return dmsString;
3287
3290
  };
3288
3291
 
3289
- var css_248z$1 = ".GridFormEditBearing-input{width:320px}";
3290
- styleInject(css_248z$1);
3292
+ var css_248z$2 = ".GridFormEditBearing-input{width:320px}";
3293
+ styleInject(css_248z$2);
3291
3294
 
3292
- var css_248z = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3293
- styleInject(css_248z);
3295
+ var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3296
+ styleInject(css_248z$1);
3294
3297
 
3295
3298
  var TextInputFormatted = function (props) {
3296
3299
  return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.warning && "hasWarning", props.className) }, { children: [jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsxRuntime.jsx("input", __assign({ type: "text", className: "LuiTextInput-input", min: "0", value: props.value, onChange: props.onChange }, props.inputProps)), 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.warning && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-warning" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "warning", name: "ic_warning", className: "LuiTextInput-warning-icon", size: "sm", status: "warning" }), props.warning] })))] })));
@@ -3592,6 +3595,98 @@ var GridSubComponentTextArea = function (props) {
3592
3595
  return (jsxRuntime.jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsxRuntime.jsx("textarea", { autoFocus: true, maxLength: 10000, spellCheck: true, className: "free-text-input", onChange: function (e) { return setValue(e.target.value); }, defaultValue: value }) })));
3593
3596
  };
3594
3597
 
3598
+ var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton .LuiIcon{margin:0 4px!important}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress{background-color:#e2f3f7!important;color:#007198!important;cursor:progress}.ActionButton-inProgress svg *{fill:#0000!important}";
3599
+ styleInject(css_248z);
3600
+
3601
+ /**
3602
+ * Track previous values of states.
3603
+ *
3604
+ * @param value Value to track.
3605
+ */
3606
+ var usePrevious = function (value) {
3607
+ var ref = react.useRef();
3608
+ react.useEffect(function () {
3609
+ ref.current = value;
3610
+ }, [value]);
3611
+ return ref.current;
3612
+ };
3613
+
3614
+ /**
3615
+ * Cancels timeouts on scope being destroyed.
3616
+ *
3617
+ * This could almost be a debounce, but debounce tracks by function reference, this tracks by hook reference.
3618
+ * This could have been implemented using debounce if the callers function was wrapped in useCallback,
3619
+ * but there's no way to enforce that, so it would lead to bugs.
3620
+ */
3621
+ var useTimeoutHook = function () {
3622
+ var timeout = react.useRef();
3623
+ /**
3624
+ * Clear any pending timeouts.
3625
+ */
3626
+ var clearTimeouts = function () {
3627
+ if (timeout.current) {
3628
+ var tc = timeout.current;
3629
+ timeout.current = undefined;
3630
+ clearTimeout(tc);
3631
+ }
3632
+ };
3633
+ /**
3634
+ * Call this when your action has completed.
3635
+ */
3636
+ var invoke = react.useCallback(function (fn, waitTimeMs) {
3637
+ clearTimeouts();
3638
+ timeout.current = setTimeout(fn, waitTimeMs);
3639
+ }, []);
3640
+ /**
3641
+ * Clear timeout on loss of scope.
3642
+ */
3643
+ react.useEffect(function () {
3644
+ return function () { return clearTimeouts(); };
3645
+ }, []);
3646
+ return invoke;
3647
+ };
3648
+
3649
+ /**
3650
+ * Defers state change up to a minimum time since last state change.
3651
+ */
3652
+ var useStateDeferred = function (initialValue) {
3653
+ var startTime = react.useRef(0);
3654
+ var timeoutHook = useTimeoutHook();
3655
+ var _a = react.useState(initialValue), value = _a[0], _setValue = _a[1];
3656
+ var setValue = react.useCallback(function (newValue) {
3657
+ startTime.current = Date.now();
3658
+ _setValue(newValue);
3659
+ }, []);
3660
+ var setValueDeferred = react.useCallback(function (newValue, minimumWaitTimeMs) {
3661
+ var waitTimeMs = Math.max(minimumWaitTimeMs - (Date.now() - startTime.current), 0);
3662
+ timeoutHook(function () { return _setValue(newValue); }, waitTimeMs);
3663
+ }, [timeoutHook]);
3664
+ return [value, setValue, setValueDeferred];
3665
+ };
3666
+
3667
+ // Kept this less than one second, so I don't have issues with waitFor as it defaults to 1s
3668
+ var minimumInProgressTimeMs = 950;
3669
+ var ActionButton = function (_a) {
3670
+ var _b;
3671
+ var _c;
3672
+ 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;
3673
+ var lastInProgress = usePrevious(inProgress !== null && inProgress !== void 0 ? inProgress : false);
3674
+ var _e = useStateDeferred(!!inProgress), localInProgress = _e[0], setLocalInProgress = _e[1], setLocalInProgressDeferred = _e[2];
3675
+ react.useEffect(function () {
3676
+ if (inProgress == lastInProgress)
3677
+ return;
3678
+ inProgress ? setLocalInProgress(true) : setLocalInProgressDeferred(false, minimumInProgressTimeMs);
3679
+ }, [inProgress, lastInProgress, setLocalInProgress, setLocalInProgressDeferred]);
3680
+ return (jsxRuntime.jsxs(lui.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 ? (jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 16, divProps: (_b = {
3681
+ "data-testid": "loading-spinner",
3682
+ style: { padding: 0, margin: 0, paddingRight: 8 },
3683
+ role: "status"
3684
+ },
3685
+ _b["aria-label"] = "Loading",
3686
+ _b) })) : (jsxRuntime.jsx(lui.LuiIcon, { name: icon, alt: name, size: size })), jsxRuntime.jsxs("span", __assign({ className: "ActionButton-minimalArea" }, { children: [jsxRuntime.jsx("span", __assign({ className: "ActionButton-minimalAreaDisplay" }, { children: (_c = (localInProgress ? inProgressName : name)) !== null && _c !== void 0 ? _c : name })), jsxRuntime.jsx("span", __assign({ className: "ActionButton-minimalAreaExpand" }, { children: name }))] }))] })));
3687
+ };
3688
+
3689
+ exports.ActionButton = ActionButton;
3595
3690
  exports.ComponentLoadingWrapper = ComponentLoadingWrapper;
3596
3691
  exports.ControlledMenu = ControlledMenu;
3597
3692
  exports.FocusableItem = FocusableItem;
@@ -3602,6 +3697,9 @@ exports.GridCell = GridCell;
3602
3697
  exports.GridCellRenderer = GridCellRenderer;
3603
3698
  exports.GridContext = GridContext;
3604
3699
  exports.GridContextProvider = GridContextProvider;
3700
+ exports.GridFormDropDown = GridFormDropDown;
3701
+ exports.GridFormMultiSelect = GridFormMultiSelect;
3702
+ exports.GridFormPopoutMenu = GridFormPopoutMenu;
3605
3703
  exports.GridHeaderSelect = GridHeaderSelect;
3606
3704
  exports.GridIcon = GridIcon;
3607
3705
  exports.GridLoadableCell = GridLoadableCell;
@@ -3623,8 +3721,13 @@ exports.MenuButton = MenuButton;
3623
3721
  exports.MenuDivider = MenuDivider;
3624
3722
  exports.MenuGroup = MenuGroup;
3625
3723
  exports.MenuHeader = MenuHeader;
3724
+ exports.MenuHeaderItem = MenuHeaderItem;
3725
+ exports.MenuHeaderString = MenuHeaderString;
3626
3726
  exports.MenuItem = MenuItem;
3627
3727
  exports.MenuRadioGroup = MenuRadioGroup;
3728
+ exports.MenuSeparator = MenuSeparator;
3729
+ exports.MenuSeparatorString = MenuSeparatorString;
3730
+ exports.PopoutMenuSeparator = PopoutMenuSeparator;
3628
3731
  exports.SubMenu = SubMenu;
3629
3732
  exports.TextAreaInput = TextAreaInput;
3630
3733
  exports.TextInputFormatted = TextInputFormatted;