@czi-sds/components 15.2.0 → 15.3.0

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.
@@ -7,7 +7,7 @@ export interface NavigationJumpToProps extends NavigationJumpToExtraProps {
7
7
  elementRef: React.MutableRefObject<HTMLElement | null>;
8
8
  }>;
9
9
  offsetTop?: number;
10
- onChange?: (event: React.SyntheticEvent, value: number) => void;
10
+ onChange?: (value: number) => void;
11
11
  }
12
12
  declare const NavigationJumpTo: React.ForwardRefExoticComponent<Pick<NavigationJumpToProps, "className" | "style" | "classes" | "onChange" | "children" | "sx" | "variant" | "color" | "translate" | "disabled" | "form" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "theme" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "name" | "type" | "orientation" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "slotProps" | "slots" | "allowScrollButtonsMobile" | "centered" | "indicatorColor" | "ScrollButtonComponent" | "scrollButtons" | "selectionFollowsFocus" | "TabIndicatorProps" | "TabScrollButtonProps" | "textColor" | "visibleScrollbar" | "sdsIndicatorColor" | "items" | "offsetTop"> & React.RefAttributes<HTMLButtonElement>>;
13
13
  export default NavigationJumpTo;
@@ -35,6 +35,7 @@ var NavigationJumpTo = (0, react_1.forwardRef)(function (props, ref) {
35
35
  var items = props.items, indicatorColor = props.indicatorColor, _a = props.offsetTop, offsetTop = _a === void 0 ? 0 : _a, onChange = props.onChange, rest = __rest(props, ["items", "indicatorColor", "offsetTop", "onChange"]);
36
36
  var _b = (0, react_1.useState)(false), navItemClicked = _b[0], setNavItemClicked = _b[1];
37
37
  var _c = (0, react_1.useState)(0), firstTabIndexInview = _c[0], setFirstTabIndexInview = _c[1];
38
+ var _d = (0, react_1.useState)(-1), emittedValue = _d[0], setEmittedValue = _d[1];
38
39
  var sectionIsInView = (0, useIntersection_1.default)(items);
39
40
  (0, react_1.useEffect)(function () {
40
41
  items.forEach(function (item) {
@@ -61,6 +62,13 @@ var NavigationJumpTo = (0, react_1.forwardRef)(function (props, ref) {
61
62
  id: "navigation-tab-".concat(title),
62
63
  };
63
64
  };
65
+ // Emit changes only once
66
+ var handleOnChange = function (value) {
67
+ if (value !== emittedValue) {
68
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
69
+ setEmittedValue(value);
70
+ }
71
+ };
64
72
  var handleChange = function (event, newValue) {
65
73
  var _a, _b, _c, _d, _e, _f;
66
74
  // Set navItemClicked to true to disable changing the tab value
@@ -83,7 +91,7 @@ var NavigationJumpTo = (0, react_1.forwardRef)(function (props, ref) {
83
91
  // Update the tab value to newValue to adjust the position of the tabsIndicator
84
92
  setFirstTabIndexInview(newValue);
85
93
  // Envoke the custom onChange prop
86
- onChange === null || onChange === void 0 ? void 0 : onChange(event, newValue);
94
+ handleOnChange(newValue);
87
95
  };
88
96
  // Observe changes in the sectionIsInView object to update the tabs value
89
97
  // based on the index of the visible sections in the viewport.
@@ -93,8 +101,11 @@ var NavigationJumpTo = (0, react_1.forwardRef)(function (props, ref) {
93
101
  // Update the tabs value only if a section is present in the viewport
94
102
  // and no navigation item has been clicked, preventing updates during window scroll
95
103
  // and unnecessary movement of the tabs indicator.
96
- if (sectionInView > -1 && !navItemClicked)
104
+ if (sectionInView > -1 && !navItemClicked) {
97
105
  setFirstTabIndexInview(sectionInView);
106
+ // Envoke the custom onChange prop
107
+ handleOnChange(sectionInView);
108
+ }
98
109
  }, [sectionIsInView]);
99
110
  // Set navItemClicked to false to re-enable the option
100
111
  // to update the tab value based on scroll.
@@ -102,7 +102,9 @@ var NavigationJumpTo = function (props) {
102
102
  { elementRef: sectionRef2, title: "Section 3" },
103
103
  { elementRef: sectionRef3, title: "Section 4" },
104
104
  { elementRef: sectionRef4, title: "Section 5" },
105
- ] })) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
105
+ ], onChange: function (value) {
106
+ console.log(value);
107
+ } })) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
106
108
  position: "relative",
107
109
  width: "100%",
108
110
  }, children: [(0, jsx_runtime_1.jsx)(TabPanel, { id: "navigation-panel-1", ref: sectionRef0, sdsDemoHeight: navPanelHeight, children: "Section #1" }), (0, jsx_runtime_1.jsx)(TabPanel, { id: "navigation-panel-2", ref: sectionRef1, sdsDemoHeight: navPanelHeight, children: "Section #2" }), (0, jsx_runtime_1.jsx)(TabPanel, { id: "navigation-panel-3", ref: sectionRef2, sdsDemoHeight: navPanelHeight, children: "Section #3" }), (0, jsx_runtime_1.jsx)(TabPanel, { id: "navigation-panel-4", ref: sectionRef3, sdsDemoHeight: navPanelHeight, children: "Section #4" }), (0, jsx_runtime_1.jsx)(TabPanel, { id: "navigation-panel-5", ref: sectionRef4, sdsDemoHeight: navPanelHeight, children: "Section #5" })] })] })] }));
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { TabsProps } from "@mui/material";
3
3
  import { CommonThemeProps } from "../styles";
4
- export interface NavigationJumpToExtraProps extends Omit<TabsProps, "indicatorColor" | "nonce" | "rev" | "rel" | "autoFocus" | "content">, CommonThemeProps {
4
+ export interface NavigationJumpToExtraProps extends Omit<TabsProps, "indicatorColor" | "nonce" | "rev" | "rel" | "autoFocus" | "content" | "onChange">, CommonThemeProps {
5
5
  sdsIndicatorColor?: "primary" | "error" | "info" | "success" | "warning" | "gray" | "beta";
6
6
  }
7
7
  export declare const StyledTabs: import("@emotion/styled").StyledComponent<{