onekijs-ui 1.0.3 → 1.0.5

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.
@@ -77,7 +77,7 @@ export type ListConfig<T = any, I extends ListItem<T> = ListItem<T>> = {
77
77
  onItemUnselect?: ListItemHandler<T, I>;
78
78
  paddingEnd?: number;
79
79
  paddingStart?: number;
80
- parentRef?: React.RefObject<HTMLDivElement>;
80
+ parentRef?: React.RefObject<HTMLDivElement | null>;
81
81
  overscan?: number;
82
82
  preload?: number;
83
83
  style?: React.CSSProperties;
package/dist/index.js CHANGED
@@ -1692,8 +1692,9 @@ const DropdownButtonComponent = ({ animationTimeout = 100, attachDropdownToBody
1692
1692
  const classNames = addClassname('o-button-dropdown', className);
1693
1693
  const ref = React.useRef(null);
1694
1694
  const [Dropdown, triggerRef] = useDropdown();
1695
- useClickOutside(ref, () => onCollapse && onCollapse());
1696
- return (jsxRuntimeExports.jsxs("span", { ref: ref, children: [jsxRuntimeExports.jsxs(Button, { ...buttonProps, className: classNames, onClick: onClick ? undefined : open ? onCollapse : onDrop, ref: triggerRef, children: [jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-content", onClick: onClick, children: children }), jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-icon", children: jsxRuntimeExports.jsx(TogglerIcon, { width: "16px", height: "16px", open: open, closeArrowPosition: "s", openArrowPosition: "n", onClick: onClick ? (open ? onCollapse : onDrop) : undefined }) })] }), jsxRuntimeExports.jsx(Dropdown, { attachToBody: attachDropdownToBody, skidding: skidding, distance: distance, onUpdate: onUpdate, onDropStart: onDropStart, onDropping: onDropping, onDropDone: onDropDone, onCollapseStart: onCollapseStart, onCollapseDone: onCollapseDone, onCollapsing: onCollapsing, widthModifier: widthModifier, zIndex: zIndex, open: open, placement: placement, animationTimeout: animationTimeout, children: listElement })] }));
1695
+ const dropdownRef = React.useRef(null);
1696
+ useClickOutside([ref, dropdownRef], () => onCollapse && onCollapse());
1697
+ return (jsxRuntimeExports.jsxs("span", { ref: ref, children: [jsxRuntimeExports.jsxs(Button, { ...buttonProps, className: classNames, onClick: onClick ? undefined : open ? onCollapse : onDrop, ref: triggerRef, children: [jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-content", onClick: onClick, children: children }), jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-icon", children: jsxRuntimeExports.jsx(TogglerIcon, { width: "16px", height: "16px", open: open, closeArrowPosition: "s", openArrowPosition: "n", onClick: onClick ? (open ? onCollapse : onDrop) : undefined }) })] }), jsxRuntimeExports.jsx(Dropdown, { attachToBody: attachDropdownToBody, skidding: skidding, distance: distance, onUpdate: onUpdate, onDropStart: onDropStart, onDropping: onDropping, onDropDone: onDropDone, onCollapseStart: onCollapseStart, onCollapseDone: onCollapseDone, onCollapsing: onCollapsing, widthModifier: widthModifier, zIndex: zIndex, open: open, placement: placement, animationTimeout: animationTimeout, children: jsxRuntimeExports.jsx("div", { ref: dropdownRef, children: listElement }) })] }));
1697
1698
  };
1698
1699
 
1699
1700
  const DropdownButton = styled(DropdownButtonComponent) `
@@ -1705,7 +1706,7 @@ const TooltipComponent = (props) => {
1705
1706
  const [show, setShow] = React.useState(true);
1706
1707
  const [open, setOpen] = React.useState(false);
1707
1708
  const arrowRef = React.useRef(null);
1708
- const { context, floatingStyles, middlewareData, refs } = react.useFloating({
1709
+ const { context, floatingStyles, middlewareData, placement: resolvedPlacement, refs } = react.useFloating({
1709
1710
  open,
1710
1711
  onOpenChange: setOpen,
1711
1712
  placement,
@@ -1737,7 +1738,7 @@ const TooltipComponent = (props) => {
1737
1738
  document.removeEventListener('tooltipVisible', listener);
1738
1739
  };
1739
1740
  }, [uid]);
1740
- const element = (jsxRuntimeExports.jsxs("div", { ref: refs.setFloating, style: floatingStyles, ...getFloatingProps({ className: 'o-tooltip-container' }), children: [jsxRuntimeExports.jsx("div", { ref: arrowRef, className: "o-tooltip-arrow", style: { left: middlewareData.arrow?.x, top: middlewareData.arrow?.y } }), content] }));
1741
+ const element = (jsxRuntimeExports.jsxs("div", { ref: refs.setFloating, style: floatingStyles, "data-popper-placement": resolvedPlacement, ...getFloatingProps({ className: 'o-tooltip-container' }), children: [jsxRuntimeExports.jsx("div", { ref: arrowRef, className: "o-tooltip-arrow", style: { left: middlewareData.arrow?.x, top: middlewareData.arrow?.y } }), content] }));
1741
1742
  if (attachToBody) {
1742
1743
  return (jsxRuntimeExports.jsxs("div", { ref: refs.setReference, ...getReferenceProps(), children: [children, show && open && content && ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: classNames, children: element }), document.body)] }));
1743
1744
  }
@@ -5183,7 +5184,10 @@ const useElementScroll = ({ parentRef, horizontal, useObserver, initialRect }) =
5183
5184
  const [scrollOffset, setScrollOffset] = React.useState(0);
5184
5185
  const [element, setElement] = React.useState(parentRef.current);
5185
5186
  useIsomorphicLayoutEffect(() => {
5186
- setElement(parentRef.current);
5187
+ const currentElement = parentRef.current;
5188
+ if (currentElement !== element) {
5189
+ setElement(currentElement);
5190
+ }
5187
5191
  });
5188
5192
  useIsomorphicLayoutEffect(() => {
5189
5193
  if (!element) {
@@ -5220,7 +5224,10 @@ const useWindowRect = (windowRef, initialRect = { width: 0, height: 0 }) => {
5220
5224
  const [rect, setRect] = React.useState(initialRect);
5221
5225
  const [element, setElement] = React.useState(windowRef.current);
5222
5226
  useIsomorphicLayoutEffect(() => {
5223
- setElement(windowRef.current);
5227
+ const currentElement = windowRef.current;
5228
+ if (currentElement !== element) {
5229
+ setElement(currentElement);
5230
+ }
5224
5231
  });
5225
5232
  useIsomorphicLayoutEffect(() => {
5226
5233
  if (!element) {
@@ -5248,7 +5255,10 @@ const useWindowScroll = ({ windowRef, parentRef, horizontal, useWindowObserver,
5248
5255
  const rectKey = horizontal ? 'left' : 'top';
5249
5256
  const scrollKey = horizontal ? 'scrollX' : 'scrollY';
5250
5257
  useIsomorphicLayoutEffect(() => {
5251
- setElement(windowRef.current);
5258
+ const currentElement = windowRef.current;
5259
+ if (currentElement !== element) {
5260
+ setElement(currentElement);
5261
+ }
5252
5262
  });
5253
5263
  useIsomorphicLayoutEffect(() => {
5254
5264
  if (!element) {