@itwin/core-react 5.15.2 → 5.17.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.
- package/CHANGELOG.md +12 -0
- package/lib/cjs/core-react/contextmenu/ContextMenu.scss +26 -8
- package/lib/core-react/base/DivWithOutsideClick.d.ts +1 -6
- package/lib/core-react/base/DivWithOutsideClick.d.ts.map +1 -1
- package/lib/core-react/contextmenu/ContextMenu.d.ts +2 -0
- package/lib/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
- package/lib/core-react/contextmenu/ContextMenu.js +7 -3
- package/lib/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/core-react/contextmenu/ContextMenu.scss +26 -8
- package/lib/core-react/contextmenu/TildeFinder.js +1 -1
- package/lib/core-react/contextmenu/TildeFinder.js.map +1 -1
- package/lib/core-react/focustrap/FocusTrap.d.ts +2 -2
- package/lib/core-react/focustrap/FocusTrap.d.ts.map +1 -1
- package/lib/core-react/focustrap/FocusTrap.js +1 -1
- package/lib/core-react/focustrap/FocusTrap.js.map +1 -1
- package/lib/core-react/hocs/withIsPressed.d.ts +1 -6
- package/lib/core-react/hocs/withIsPressed.d.ts.map +1 -1
- package/lib/core-react/hocs/withOnOutsideClick.d.ts +1 -6
- package/lib/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
- package/lib/core-react/hocs/withTimeout.d.ts +1 -6
- package/lib/core-react/hocs/withTimeout.d.ts.map +1 -1
- package/lib/core-react/listbox/Listbox.d.ts +1 -1
- package/lib/core-react/listbox/Listbox.d.ts.map +1 -1
- package/lib/core-react/listbox/Listbox.js +1 -1
- package/lib/core-react/listbox/Listbox.js.map +1 -1
- package/lib/core-react/popup/Popup.d.ts +1 -1
- package/lib/core-react/popup/Popup.d.ts.map +1 -1
- package/lib/core-react/popup/Popup.js.map +1 -1
- package/lib/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
- package/lib/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/core-react/tabs/Tabs.d.ts.map +1 -1
- package/lib/core-react/tabs/Tabs.js.map +1 -1
- package/lib/core-react/tree/Tree.d.ts.map +1 -1
- package/lib/core-react/tree/Tree.js.map +1 -1
- package/lib/core-react/utils/flattenChildren.js.map +1 -1
- package/lib/core-react/utils/hooks/useCrossOriginPopup.js +1 -1
- package/lib/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/core-react/utils/hooks/useOnOutsideClick.d.ts +1 -1
- package/lib/core-react/utils/hooks/useOnOutsideClick.d.ts.map +1 -1
- package/lib/core-react/utils/hooks/useProximityToMouse.d.ts +1 -1
- package/lib/core-react/utils/hooks/useProximityToMouse.d.ts.map +1 -1
- package/lib/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
- package/lib/core-react/utils/hooks/useRefs.js.map +1 -1
- package/lib/core-react/utils/hooks/useResizeObserver.d.ts +1 -1
- package/lib/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
- package/lib/core-react/utils/hooks/useResizeObserver.js +2 -2
- package/lib/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/lib/core-react/utils/hooks/useTargeted.d.ts +1 -1
- package/lib/core-react/utils/hooks/useTargeted.d.ts.map +1 -1
- package/lib/core-react/utils/hooks/useTargeted.js.map +1 -1
- package/lib/core-react/utils/hooks/useWidgetOpacityContext.d.ts +3 -3
- package/lib/core-react/utils/hooks/useWidgetOpacityContext.d.ts.map +1 -1
- package/lib/core-react/utils/hooks/useWidgetOpacityContext.js.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.scss +26 -8
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../src/core-react/tree/Tree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CA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AC7B,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,GAAG,IAAI,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEe,MAAM;QACpB,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAEhE,OAAO,CACL,6BACE,GAAG,EAAE,IAAI,CAAC,YAAY,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,CAAC,IAEX,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./Tree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props.js\";\nimport { Rectangle } from \"../utils/Rectangle.js\";\n\n/** Properties for the [[Tree]] presentational React component\n * @public\n * @deprecated in 4.15.0. Props of deprecated {@link Tree} component.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface TreeProps extends CommonProps {\n children?: React.ReactNode;\n onMouseDown?: React.MouseEventHandler<HTMLDivElement>;\n onMouseMove?: React.MouseEventHandler<HTMLDivElement>;\n onMouseUp?: React.MouseEventHandler<HTMLDivElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;\n}\n\n/** Presentation React component for a Tree\n * @public\n * @deprecated in 4.15.0. Use {@link https://itwinui.bentley.com/docs/tree iTwinUI Tree} instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class Tree extends React.PureComponent<TreeProps> {\n private _treeElement: React.RefObject<HTMLDivElement | null> =\n React.createRef();\n\n private get _scrollableContainer(): Element | undefined {\n if (!this._treeElement.current) return undefined;\n\n const isScrollable = (element: Element) => {\n const style = window.getComputedStyle(element);\n return (\n style.overflow === \"auto\" ||\n style.overflow === \"scroll\" ||\n style.overflowY === \"auto\" ||\n style.overflowY === \"scroll\" ||\n style.overflowX === \"auto\" ||\n style.overflowX === \"scroll\"\n );\n };\n let scrollableContainer: Element | undefined = this._treeElement.current;\n while (scrollableContainer && !isScrollable(scrollableContainer))\n scrollableContainer =\n scrollableContainer.children.length > 0\n ? scrollableContainer.children[0]\n : undefined;\n\n return scrollableContainer;\n }\n\n public scrollToElement(element: Element) {\n const container = this._scrollableContainer;\n if (!container) return;\n\n if (!Element.prototype.scrollTo) {\n // workaround for Edge scrollTo issue https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15534521/\n element.scrollIntoView();\n return;\n }\n\n const elementBox = element.getBoundingClientRect();\n const elementRange = Rectangle.createXYXY(\n elementBox.left,\n elementBox.top,\n elementBox.right,\n elementBox.bottom\n );\n const containerBox = container.getBoundingClientRect();\n const containerRange = Rectangle.createXYXY(\n containerBox.left - container.scrollLeft,\n containerBox.top - container.scrollTop,\n containerBox.right - container.scrollLeft,\n containerBox.bottom - container.scrollTop\n );\n\n let left: number;\n if (\n container.scrollLeft > 0 &&\n elementRange.right <= containerRange.right\n ) {\n // always attempt to keep horizontal scroll at 0\n left = 0;\n } else if (\n containerRange.left <= elementRange.left &&\n containerRange.right >= elementRange.right\n ) {\n // already visible - no need to scroll to\n left = container.scrollLeft;\n } else {\n left = elementRange.left - containerRange.left;\n }\n\n let top: number;\n if (\n containerRange.top <= elementRange.top &&\n containerRange.bottom >= elementRange.bottom\n ) {\n // already visible - no need to scroll to\n top = container.scrollTop;\n } else {\n top = elementRange.top - containerRange.top;\n }\n\n container.scrollTo({ left, top });\n }\n\n public getElementsByClassName(className: string): Element[] {\n if (!this._treeElement.current) return [];\n\n const elements = new Array<Element>();\n const collection =\n this._treeElement.current.getElementsByClassName(className);\n for (let i = 0; i < collection.length; ++i)\n elements.push(collection.item(i)!);\n return elements;\n }\n public setFocusByClassName(selector: string): boolean {\n let status = false;\n if (this._treeElement.current) {\n const element = this._treeElement.current.querySelector(\n selector\n ) as HTMLElement;\n if (element && element.focus) {\n element.focus();\n status = true;\n }\n }\n return status;\n }\n\n public override render() {\n const className = classnames(\"core-tree\", this.props.className);\n\n return (\n <div\n ref={this._treeElement}\n className={className}\n style={this.props.style}\n onMouseDown={this.props.onMouseDown}\n onMouseMove={this.props.onMouseMove}\n onMouseUp={this.props.onMouseUp}\n onKeyDown={this.props.onKeyDown}\n onKeyUp={this.props.onKeyUp}\n role=\"tree\"\n tabIndex={-1}\n >\n {this.props.children}\n </div>\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenChildren.js","sourceRoot":"","sources":["../../../src/core-react/utils/flattenChildren.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAyB,EAAmB,EAAE;IAC5E,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"flattenChildren.js","sourceRoot":"","sources":["../../../src/core-react/utils/flattenChildren.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAyB,EAAmB,EAAE;IAC5E,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAmB,EAAE;QACpE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAiC,KAAK,CAAC;YAC9D,OAAO,KAAK,CAAC;QAEf,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC9B,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\n\n/** Flattens React fragments.\n * @internal\n */\nexport const flattenChildren = (children: React.ReactNode): React.ReactNode => {\n const items = React.Children.map(children, (child): React.ReactNode => {\n if (!React.isValidElement<{ children?: React.ReactNode }>(child))\n return child;\n\n if (child.type === React.Fragment) {\n return child.props.children;\n }\n\n return child;\n });\n return items;\n};\n"]}
|
|
@@ -15,7 +15,7 @@ export function useCrossOriginPopup(visible, url, title, width, height, onClose)
|
|
|
15
15
|
const [checkPopupAliveDelay, setCheckPopupAliveDelay] = React.useState();
|
|
16
16
|
// ONLY re-render the popup when visibility changes, any other changes get deferred until next visibility change
|
|
17
17
|
// hence the massive use of 'useRef'
|
|
18
|
-
const popupWindow = React.useRef();
|
|
18
|
+
const popupWindow = React.useRef(undefined);
|
|
19
19
|
const savedUrl = React.useRef(url);
|
|
20
20
|
const savedTitle = React.useRef(title);
|
|
21
21
|
const savedWidth = React.useRef(width);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossOriginPopup.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useCrossOriginPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,GAAuB,EACvB,KAAa,EACb,KAAa,EACb,MAAc,EACd,OAAmB;IAEnB,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAEnE,CAAC;IAEJ,gHAAgH;IAChH,oCAAoC;IACpC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"useCrossOriginPopup.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useCrossOriginPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,GAAuB,EACvB,KAAa,EACb,KAAa,EACb,MAAc,EACd,OAAmB;IAEnB,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAEnE,CAAC;IAEJ,gHAAgH;IAChH,oCAAoC;IACpC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAqB,SAAS,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,UAAU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E,CAC5D,CAAC;YACF,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;gBAE5B,iEAAiE;gBACjE,uBAAuB,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,sEAAsE;QACtE,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAClD,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAE5B,iBAAiB,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\nimport { useInterval } from \"./useInterval.js\";\n\n/** Hook that will show a popup window\n * @public\n * @deprecated in 4.16.0. Without a replacement, use a custom solution instead.\n */\nexport function useCrossOriginPopup(\n visible: boolean,\n url: string | undefined,\n title: string,\n width: number,\n height: number,\n onClose: () => void\n) {\n const [checkPopupAliveDelay, setCheckPopupAliveDelay] = React.useState<\n number | undefined\n >();\n\n // ONLY re-render the popup when visibility changes, any other changes get deferred until next visibility change\n // hence the massive use of 'useRef'\n const popupWindow = React.useRef<Window | undefined>(undefined);\n const savedUrl = React.useRef(url);\n const savedTitle = React.useRef(title);\n const savedWidth = React.useRef(width);\n const savedHeight = React.useRef(height);\n const savedOnClose = React.useRef(onClose);\n\n React.useEffect(() => {\n savedUrl.current = url;\n }, [url]);\n React.useEffect(() => {\n savedTitle.current = title;\n }, [title]);\n React.useEffect(() => {\n savedWidth.current = width;\n }, [width]);\n React.useEffect(() => {\n savedHeight.current = height;\n }, [height]);\n React.useEffect(() => {\n savedOnClose.current = onClose;\n }, [onClose]);\n\n // Cleanup method after a popup closure. Also calls the OnClose callback.\n const handleClosedPopup = React.useCallback(() => {\n savedOnClose.current();\n setCheckPopupAliveDelay(undefined);\n popupWindow.current = undefined;\n }, []);\n\n const closePopup = React.useCallback(() => {\n if (popupWindow.current !== undefined) {\n popupWindow.current.close(); // Manually close the popup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n const checkPopupClosed = React.useCallback(() => {\n if (popupWindow.current?.closed) {\n // Popup has been closed by end-user, inform our host and cleanup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n // Close popup when parent window get closed\n React.useEffect(() => {\n window.onbeforeunload = (_event) => {\n closePopup();\n };\n return () => {\n window.onbeforeunload = null;\n };\n }, [closePopup]);\n\n // Whenever the hook is unloaded, make sure the underlying popup get closed.\n // Note: An interval is used to check if popup was closed by user: because we access\n // a cross domain resource inside the popup, we don't have access to popup window events.\n // As a workaround, we periodically check if popup is still alive.\n // Reference: https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128\n React.useEffect(() => {\n return () => {\n closePopup();\n };\n }, [closePopup]);\n\n // Timer that checks if popup was closed by end-user\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n useInterval(checkPopupClosed, checkPopupAliveDelay);\n\n // ==> Main render effect\n // Monitors visibility changes and open/close the popup accordingly.\n React.useEffect(() => {\n // If visible and a popup window is not already open, open a new popup window\n if (visible && popupWindow.current === undefined) {\n const popup = window.open(\n savedUrl.current,\n savedTitle.current,\n `width=${savedWidth.current},height=${savedHeight.current}`\n );\n if (popup) {\n popup.focus();\n popupWindow.current = popup;\n\n // Start and interval that will check if popup got closed by user\n setCheckPopupAliveDelay(1000);\n }\n }\n\n // If not visible but a previous popup window is still open, close it.\n if (!visible && popupWindow.current !== undefined) {\n popupWindow.current.close();\n\n handleClosedPopup();\n }\n }, [handleClosedPopup, visible]);\n}\n"]}
|
|
@@ -13,5 +13,5 @@ export type OutsideClickEvent = PointerEvent | MouseEvent | TouchEvent;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function useOnOutsideClick<T extends Element>(onOutsideClick?: () => void,
|
|
15
15
|
/** Invoked for intermediate events. Return `false` to prevent outside click. */
|
|
16
|
-
outsideEventPredicate?: (e: OutsideClickEvent) => boolean): React.RefObject<T>;
|
|
16
|
+
outsideEventPredicate?: (e: OutsideClickEvent) => boolean): React.RefObject<T | null>;
|
|
17
17
|
//# sourceMappingURL=useOnOutsideClick.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,cAAc,CAAC,EAAE,MAAM,IAAI;AAC3B,gFAAgF;AAChF,qBAAqB,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"useOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,cAAc,CAAC,EAAE,MAAM,IAAI;AAC3B,gFAAgF;AAChF,qBAAqB,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,OAAO,6BA6E1D"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
/** @internal */
|
|
6
|
-
export declare class WidgetElementSet extends Set<React.RefObject<Element>> {
|
|
6
|
+
export declare class WidgetElementSet extends Set<React.RefObject<Element | null>> {
|
|
7
7
|
}
|
|
8
8
|
/** Returns the proximity scale associated with the shortest distance from the element(s) to the mouse.
|
|
9
9
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProximityToMouse.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useProximityToMouse.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,gBAAgB;AAChB,qBAAa,gBAAiB,SAAQ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CAAG;
|
|
1
|
+
{"version":3,"file":"useProximityToMouse.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useProximityToMouse.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,gBAAgB;AAChB,qBAAa,gBAAiB,SAAQ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAAG;AAE7E;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAClB,gBAAgB,SACtB,OAAO,+BAiCd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,kCAAkC,OAAO,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,uBAAuB,cACvB,MAAM,SACX,OAAO,yBAEZ,MAIF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,mBAAoB,MAAM,KAAG,MAEhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,mBAAoB,MAAM,KAAG,MAElE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,mBAAoB,MAAM,KAAG,MAEpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,YAAa,MAAM,KAAG,MAE3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,YAAa,MAAM,KAAG,MAErD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,eAAgB,MAAM,KAAG,MAE7D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProximityToMouse.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useProximityToMouse.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,
|
|
1
|
+
{"version":3,"file":"useProximityToMouse.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useProximityToMouse.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,GAAoC;CAAG;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,UAA4B,EAC5B,OAAgB,KAAK,EACrB,SAAS,GAAG,2BAA2B,EACvC,EAAE;IACF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KA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AG,CAAC,UAAkB,EAAU,EAAE;IACrE,OAAO,QAAQ,UAAU,KAAK,CAAC;AACjC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\nimport { Point } from \"../Point.js\";\nimport { Rectangle } from \"../Rectangle.js\";\n\n/** @internal */\nexport class WidgetElementSet extends Set<React.RefObject<Element | null>> {}\n\n/** Returns the proximity scale associated with the shortest distance from the element(s) to the mouse.\n * @internal\n */\nexport const useProximityToMouse = (\n elementSet: WidgetElementSet,\n snap: boolean = false,\n threshold = PROXIMITY_THRESHOLD_DEFAULT\n) => {\n const [proximityScale, setProximityScale] = React.useState(1.0);\n\n React.useEffect(() => {\n const handleDocumentPointerMove = (e: PointerEvent) => {\n let shortestProximity = Number.MAX_SAFE_INTEGER;\n\n for (const ref of elementSet) {\n if (ref.current) {\n const clientRect = ref.current.getBoundingClientRect();\n const rectangle = Rectangle.create(clientRect);\n const point = new Point(e.pageX, e.pageY);\n shortestProximity = Math.min(\n rectangle.getShortestDistanceToPoint(point),\n shortestProximity\n );\n }\n }\n\n const scale = calculateProximityScale(shortestProximity, snap, threshold);\n if (scale !== proximityScale) setProximityScale(scale);\n };\n\n document.addEventListener(\"pointermove\", handleDocumentPointerMove);\n\n return () => {\n document.removeEventListener(\"pointermove\", handleDocumentPointerMove);\n };\n }, [elementSet, proximityScale, snap, threshold]);\n\n return proximityScale;\n};\n\n/** Default proximity threshold.\n * @internal\n */\nexport const PROXIMITY_THRESHOLD_DEFAULT = 100;\n\n/** Default toolbar opacity.\n * @internal\n */\nexport const TOOLBAR_OPACITY_DEFAULT = 0.5;\n\n/** Default toolbar box-shadow opacity.\n * @internal\n */\nexport const TOOLBAR_BOX_SHADOW_OPACITY_DEFAULT = 0.35;\n\n/** Default toolbar backdrop-filter blur.\n * @internal\n */\nexport const TOOLBAR_BACKDROP_FILTER_BLUR_DEFAULT = 10;\n\n/** Calculates a proximity scale for further calculations given the proximity and threshold.\n * @internal\n */\nexport const calculateProximityScale = (\n proximity: number,\n snap: boolean = false,\n threshold = PROXIMITY_THRESHOLD_DEFAULT\n): number => {\n let scale = (proximity < threshold ? threshold - proximity : 0) / threshold;\n if (snap && scale > 0) scale = 1.0;\n return scale;\n};\n\n/** Calculates a toolbar opacity based on a given proximity scale.\n * @internal\n */\nexport const calculateToolbarOpacity = (proximityScale: number): number => {\n return TOOLBAR_OPACITY_DEFAULT * proximityScale;\n};\n\n/** Calculates a box-shadow opacity based on a given proximity scale.\n * @internal\n */\nexport const calculateBoxShadowOpacity = (proximityScale: number): number => {\n return TOOLBAR_BOX_SHADOW_OPACITY_DEFAULT * proximityScale;\n};\n\n/** Calculates a backdrop-filter blur based on a given proximity scale.\n * @internal\n */\nexport const calculateBackdropFilterBlur = (proximityScale: number): number => {\n return TOOLBAR_BACKDROP_FILTER_BLUR_DEFAULT * proximityScale;\n};\n\n/** Gets the Toolbar background-color based on a given opacity.\n * @internal\n */\nexport const getToolbarBackgroundColor = (opacity: number): string => {\n return `hsl(var(--iui-color-background-hsl) / ${opacity})`;\n};\n\n/** Gets the Toolbar box-shadow based on a given opacity.\n * @internal\n */\nexport const getToolbarBoxShadow = (opacity: number): string => {\n return `0 1px 3px 0 rgba(0, 0, 0, ${opacity})`;\n};\n\n/** Gets the Toolbar backdrop-filter based on a given blur amount.\n * @internal\n */\nexport const getToolbarBackdropFilter = (filterBlur: number): string => {\n return `blur(${filterBlur}px)`;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRefs.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useRefs.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,+BAA+B;AAC/B,S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G,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,GAAG,EAAE,CAAC;gBACR,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvB,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\n\n/** Callback ref type guard. */\nfunction isRefCallback<T>(ref: React.Ref<T>): ref is (_: T | null) => void {\n return typeof ref === \"function\";\n}\n\n/** Hook used to combine multiple refs.\n * @internal\n */\nexport function useRefs<T>(...refs: ReadonlyArray<React.Ref<T> | undefined>) {\n return React.useCallback(\n (instance: T | null) => {\n for (const ref of refs) {\n if (ref) {\n if (isRefCallback(ref)) {\n ref(instance);\n } else {\n ref.current = instance;\n }\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs]\n );\n}\n\n/** Used to combine multiple refs for a class component.\n * @internal\n */\nexport function mergeRefs<T>(...refs: ReadonlyArray<React.Ref<T>>) {\n return (instance: T | null) => {\n for (const ref of refs) {\n if (ref) {\n if (isRefCallback(ref)) {\n ref(instance);\n } else {\n ref.current = instance;\n }\n }\n }\n };\n}\n"]}
|
|
@@ -28,7 +28,7 @@ export interface RenderPropsArgs {
|
|
|
28
28
|
export declare function ElementResizeObserver({ watchedElement, render, }: {
|
|
29
29
|
watchedElement: HTMLElement | null;
|
|
30
30
|
render: (props: RenderPropsArgs) => React.ReactElement;
|
|
31
|
-
}): React.ReactElement<
|
|
31
|
+
}): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
32
32
|
/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when
|
|
33
33
|
* the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then
|
|
34
34
|
* the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCAgHnD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BAwGrD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,CAAC;CACxD,
|
|
1
|
+
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCAgHnD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BAwGrD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,CAAC;CACxD,0EAGA;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,qBAyCA"}
|
|
@@ -19,7 +19,7 @@ export function useResizeObserver(onResize) {
|
|
|
19
19
|
const isMountedRef = React.useRef(false);
|
|
20
20
|
const owningWindowRef = React.useRef(null);
|
|
21
21
|
const resizeObserverCleanup = () => {
|
|
22
|
-
if (rafRef.current)
|
|
22
|
+
if (rafRef.current && owningWindowRef.current)
|
|
23
23
|
owningWindowRef.current.cancelAnimationFrame(rafRef.current);
|
|
24
24
|
resizeObserver.current?.disconnect();
|
|
25
25
|
resizeObserver.current = null;
|
|
@@ -28,7 +28,7 @@ export function useResizeObserver(onResize) {
|
|
|
28
28
|
isMountedRef.current = true;
|
|
29
29
|
return () => {
|
|
30
30
|
isMountedRef.current = false;
|
|
31
|
-
if (rafRef.current)
|
|
31
|
+
if (rafRef.current && owningWindowRef.current)
|
|
32
32
|
owningWindowRef.current.cancelAnimationFrame(rafRef.current);
|
|
33
33
|
owningWindowRef.current?.removeEventListener("beforeunload", resizeObserverCleanup);
|
|
34
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,qDAAqD;AAErD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAkD;IAElD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,kEAAkE;IAClG,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAM,IAAI,CAAC,CAAC;IAEhD,MAAM,qBAAqB,GAAG,GAAG,EAAE;QACjC,IAAI,MAAM,CAAC,OAAO;YAChB,eAAe,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE/D,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACrC,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;IAChC,CAAC,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,YAAY,CAAC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C;IAElB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,KAAc,EAAE,MAAe,EAAE,EAAE;QAClC,QAAQ,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,KAAK,GAAwB,WAAW;QAC5C,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QACnC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,IAEX,WAAW,IAAI,QAAQ,CACpB,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport * as React from \"react\";\nimport { useRefEffect } from \"./useRefEffect.js\";\nimport { useRefs } from \"./useRefs.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Uses ResizeObserver API to notify about element bound changes.\n * @internal\n */\nexport function useResizeObserver<T extends Element>(\n onResize?: (width: number, height: number) => void\n) {\n const bounds = React.useRef({ width: 0, height: 0 });\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current?.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, []);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n if (\n isMountedRef.current &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n const observerRef = useRefEffect(\n (instance: T | null) => {\n resizeObserver.current = new ResizeObserver(handleResize);\n if (instance) {\n resizeObserver.current.observe(instance);\n const newBounds = instance.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n bounds.current = newBounds;\n }\n\n return () => {\n instance && resizeObserver.current?.unobserve(instance);\n resizeObserver.current = null;\n };\n },\n [handleResize, onResize]\n );\n\n const handleRef = React.useCallback(\n (instance: Element | null) => {\n const newBounds = instance && instance.getBoundingClientRect();\n if (\n newBounds &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const ref = useRefs(handleRef, observerRef);\n return ref;\n}\n\n/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector\n * width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly\n * handles observing element in pop-out/child windows.\n * @internal\n */\nexport function useLayoutResizeObserver(\n inElement: HTMLElement | null,\n onResize?: (width?: number, height?: number) => void\n) {\n const inBoundingRect = inElement?.getBoundingClientRect();\n const [bounds, setBounds] = React.useState<{\n width?: number;\n height?: number;\n }>({ width: inBoundingRect?.width, height: inBoundingRect?.height });\n const [watchedElement, setWatchedElement] = React.useState(inElement);\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n setWatchedElement(inElement);\n\n if (inElement) {\n const newBounds = inElement.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n isMountedRef.current = false;\n rafRef.current &&\n owningWindowRef.current &&\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, [onResize, inElement]);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n if (owningWindowRef.current)\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n React.useLayoutEffect(() => {\n if (!watchedElement) {\n return;\n }\n resizeObserver.current = new ResizeObserver(handleResize);\n resizeObserver.current.observe(watchedElement);\n return () => {\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n }, [handleResize, watchedElement]);\n\n return [bounds.width, bounds.height];\n}\n\n/** Prop the ElementResizeObserver sends to the render function.\n * @public\n * @deprecated in 4.16.0. Interface used in a deprecated component {@link ElementResizeObserver}.\n */\nexport interface RenderPropsArgs {\n width?: number;\n height?: number;\n}\n\n/** ElementResizeObserver provides functionality similar to ReactResizeDetector when a render function is specified. This implementation properly handles\n * observing element in pop-out/child windows.\n * @public\n * @deprecated in 4.15.0. Used internally.\n */\nexport function ElementResizeObserver({\n watchedElement,\n render,\n}: {\n watchedElement: HTMLElement | null;\n render: (props: RenderPropsArgs) => React.ReactElement;\n}) {\n const [width, height] = useLayoutResizeObserver(watchedElement);\n return render({ width, height });\n}\n\n/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when\n * the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then\n * the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report\n * size changes from its parent container.\n * @public\n * @deprecated in 4.15.0. Please use third party packages.\n */\nexport function ResizableContainerObserver({\n onResize,\n children,\n}: {\n onResize: (width: number, height: number) => void;\n children?: React.ReactNode;\n}) {\n const containerRef = React.useRef<HTMLDivElement>(null); // set to non-zero when requestAnimationFrame processing is active\n const [containerElement, setContainerElement] =\n React.useState<HTMLElement | null>(null);\n const isMountedRef = React.useRef(false);\n const hasChildren = React.Children.count(children) !== 0;\n\n // if no children are specified then monitor size of parent element.\n React.useEffect(() => {\n if (!isMountedRef.current && containerRef.current) {\n isMountedRef.current = true;\n const hasParent = !!containerRef.current.parentElement;\n setContainerElement(\n hasChildren && hasParent\n ? containerRef.current\n : containerRef.current.parentElement\n );\n }\n }, [hasChildren]);\n\n const processResize = React.useCallback(\n (width?: number, height?: number) => {\n onResize(width ?? 0, height ?? 0);\n },\n [onResize]\n );\n\n useLayoutResizeObserver(containerElement, processResize);\n const style: React.CSSProperties = hasChildren\n ? { width: \"100%\", height: \"100%\" }\n : { display: \"none\" };\n\n return (\n <div\n ref={containerRef}\n className=\"uicore-resizable-container\"\n style={style}\n >\n {hasChildren && children}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useResizeObserver.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,qDAAqD;AAErD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAkD;IAElD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,kEAAkE;IAClG,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC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AEzD,oEAAoE;IACpE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YAClD,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;YAC5B,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC;YACvD,mBAAmB,CACjB,WAAW,IAAI,SAAS;gBACtB,CAAC,CAAC,YAAY,CAAC,OAAO;gBACtB,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CACvC,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,KAAc,EAAE,MAAe,EAAE,EAAE;QAClC,QAAQ,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,KAAK,GAAwB,WAAW;QAC5C,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QACnC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,IAEX,WAAW,IAAI,QAAQ,CACpB,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport * as React from \"react\";\nimport { useRefEffect } from \"./useRefEffect.js\";\nimport { useRefs } from \"./useRefs.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Uses ResizeObserver API to notify about element bound changes.\n * @internal\n */\nexport function useResizeObserver<T extends Element>(\n onResize?: (width: number, height: number) => void\n) {\n const bounds = React.useRef({ width: 0, height: 0 });\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<Window | null>(null);\n\n const resizeObserverCleanup = () => {\n if (rafRef.current && owningWindowRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n if (rafRef.current && owningWindowRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current?.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, []);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n if (\n isMountedRef.current &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n const observerRef = useRefEffect(\n (instance: T | null) => {\n resizeObserver.current = new ResizeObserver(handleResize);\n if (instance) {\n resizeObserver.current.observe(instance);\n const newBounds = instance.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n bounds.current = newBounds;\n }\n\n return () => {\n instance && resizeObserver.current?.unobserve(instance);\n resizeObserver.current = null;\n };\n },\n [handleResize, onResize]\n );\n\n const handleRef = React.useCallback(\n (instance: Element | null) => {\n const newBounds = instance && instance.getBoundingClientRect();\n if (\n newBounds &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const ref = useRefs(handleRef, observerRef);\n return ref;\n}\n\n/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector\n * width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly\n * handles observing element in pop-out/child windows.\n * @internal\n */\nexport function useLayoutResizeObserver(\n inElement: HTMLElement | null,\n onResize?: (width?: number, height?: number) => void\n) {\n const inBoundingRect = inElement?.getBoundingClientRect();\n const [bounds, setBounds] = React.useState<{\n width?: number;\n height?: number;\n }>({ width: inBoundingRect?.width, height: inBoundingRect?.height });\n const [watchedElement, setWatchedElement] = React.useState(inElement);\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n setWatchedElement(inElement);\n\n if (inElement) {\n const newBounds = inElement.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n isMountedRef.current = false;\n rafRef.current &&\n owningWindowRef.current &&\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, [onResize, inElement]);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n if (owningWindowRef.current)\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n React.useLayoutEffect(() => {\n if (!watchedElement) {\n return;\n }\n resizeObserver.current = new ResizeObserver(handleResize);\n resizeObserver.current.observe(watchedElement);\n return () => {\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n }, [handleResize, watchedElement]);\n\n return [bounds.width, bounds.height];\n}\n\n/** Prop the ElementResizeObserver sends to the render function.\n * @public\n * @deprecated in 4.16.0. Interface used in a deprecated component {@link ElementResizeObserver}.\n */\nexport interface RenderPropsArgs {\n width?: number;\n height?: number;\n}\n\n/** ElementResizeObserver provides functionality similar to ReactResizeDetector when a render function is specified. This implementation properly handles\n * observing element in pop-out/child windows.\n * @public\n * @deprecated in 4.15.0. Used internally.\n */\nexport function ElementResizeObserver({\n watchedElement,\n render,\n}: {\n watchedElement: HTMLElement | null;\n render: (props: RenderPropsArgs) => React.ReactElement;\n}) {\n const [width, height] = useLayoutResizeObserver(watchedElement);\n return render({ width, height });\n}\n\n/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when\n * the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then\n * the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report\n * size changes from its parent container.\n * @public\n * @deprecated in 4.15.0. Please use third party packages.\n */\nexport function ResizableContainerObserver({\n onResize,\n children,\n}: {\n onResize: (width: number, height: number) => void;\n children?: React.ReactNode;\n}) {\n const containerRef = React.useRef<HTMLDivElement>(null); // set to non-zero when requestAnimationFrame processing is active\n const [containerElement, setContainerElement] =\n React.useState<HTMLElement | null>(null);\n const isMountedRef = React.useRef(false);\n const hasChildren = React.Children.count(children) !== 0;\n\n // if no children are specified then monitor size of parent element.\n React.useEffect(() => {\n if (!isMountedRef.current && containerRef.current) {\n isMountedRef.current = true;\n const hasParent = !!containerRef.current.parentElement;\n setContainerElement(\n hasChildren && hasParent\n ? containerRef.current\n : containerRef.current.parentElement\n );\n }\n }, [hasChildren]);\n\n const processResize = React.useCallback(\n (width?: number, height?: number) => {\n onResize(width ?? 0, height ?? 0);\n },\n [onResize]\n );\n\n useLayoutResizeObserver(containerElement, processResize);\n const style: React.CSSProperties = hasChildren\n ? { width: \"100%\", height: \"100%\" }\n : { display: \"none\" };\n\n return (\n <div\n ref={containerRef}\n className=\"uicore-resizable-container\"\n style={style}\n >\n {hasChildren && children}\n </div>\n );\n}\n"]}
|
|
@@ -5,5 +5,5 @@ import * as React from "react";
|
|
|
5
5
|
/** Returns a stateful value that indicates if the component is targeted/hovered.
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export declare const useTargeted: (ref: React.RefObject<Element>) => boolean;
|
|
8
|
+
export declare const useTargeted: (ref: React.RefObject<Element | null>) => boolean;
|
|
9
9
|
//# sourceMappingURL=useTargeted.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTargeted.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useTargeted.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,WAAW,QAAS,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"useTargeted.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useTargeted.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,WAAW,QAAS,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,YAiB/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTargeted.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useTargeted.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"useTargeted.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useTargeted.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAoC,EAAE,EAAE;IAClE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,yBAAyB,GAAG,CAAC,CAAe,EAAE,EAAE;YACpD,WAAW,CACT,CAAC,CAAC,GAAG,CAAC,OAAO;gBACX,CAAC,CAAC,CAAC,CAAC,MAAM;gBACV,CAAC,CAAC,MAAM,YAAY,IAAI;gBACxB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CACjC,CAAC;QACJ,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC;QACpE,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC;QACzE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACV,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\n\n/** Returns a stateful value that indicates if the component is targeted/hovered.\n * @internal\n */\nexport const useTargeted = (ref: React.RefObject<Element | null>) => {\n const [targeted, setTargeted] = React.useState(false);\n React.useEffect(() => {\n const handleDocumentPointerMove = (e: PointerEvent) => {\n setTargeted(\n !!ref.current &&\n !!e.target &&\n e.target instanceof Node &&\n ref.current.contains(e.target)\n );\n };\n document.addEventListener(\"pointermove\", handleDocumentPointerMove);\n return () => {\n document.removeEventListener(\"pointermove\", handleDocumentPointerMove);\n };\n }, [ref]);\n return targeted;\n};\n"]}
|
|
@@ -7,8 +7,8 @@ import * as React from "react";
|
|
|
7
7
|
*/
|
|
8
8
|
export interface WidgetOpacityContextProps {
|
|
9
9
|
readonly proximityScale: number;
|
|
10
|
-
readonly addRef: (ref: React.RefObject<Element>) => void;
|
|
11
|
-
readonly removeRef: (ref: React.RefObject<Element>) => void;
|
|
10
|
+
readonly addRef: (ref: React.RefObject<Element | null>) => void;
|
|
11
|
+
readonly removeRef: (ref: React.RefObject<Element | null>) => void;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Context used by Widgets and child components to process opacity changes based on mouse proximity.
|
|
@@ -19,7 +19,7 @@ export declare const WidgetOpacityContext: React.Context<WidgetOpacityContextPro
|
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export declare function useWidgetOpacityContext<T extends Element>(): {
|
|
22
|
-
ref: React.RefObject<T>;
|
|
22
|
+
ref: React.RefObject<T | null>;
|
|
23
23
|
proximityScale: number;
|
|
24
24
|
};
|
|
25
25
|
//# sourceMappingURL=useWidgetOpacityContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWidgetOpacityContext.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useWidgetOpacityContext.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"useWidgetOpacityContext.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useWidgetOpacityContext.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IAChE,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;CACpE;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,0CAK7B,CAAC;AAEL;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,OAAO;;;EAWxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWidgetOpacityContext.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useWidgetOpacityContext.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,KAAK,CAAC,aAAa,CAA4B;IAC7C,cAAc,EAAE,GAAG;IACnB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;IAChB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;CACpB,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAI,IAAI,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GACzC,KAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACzC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,CAAC,GAAG,CAAC,CAAC;QACZ,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\n\n/** Properties for [[WidgetOpacityContext]]\n * @internal\n */\nexport interface WidgetOpacityContextProps {\n readonly proximityScale: number;\n readonly addRef: (ref: React.RefObject<Element>) => void;\n readonly removeRef: (ref: React.RefObject<Element>) => void;\n}\n\n/**\n * Context used by Widgets and child components to process opacity changes based on mouse proximity.\n * @internal\n */\nexport const WidgetOpacityContext =\n React.createContext<WidgetOpacityContextProps>({\n proximityScale: 1.0,\n addRef: () => {},\n removeRef: () => {},\n });\n\n/** Hook for using [[WidgetOpacityContext]]\n * @internal\n */\nexport function useWidgetOpacityContext<T extends Element>() {\n const ref = React.useRef<T>(null);\n const { addRef, removeRef, proximityScale } =\n React.useContext(WidgetOpacityContext);\n React.useEffect(() => {\n addRef(ref);\n return () => {\n removeRef(ref);\n };\n }, [addRef, removeRef]);\n return { ref, proximityScale };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useWidgetOpacityContext.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useWidgetOpacityContext.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,KAAK,CAAC,aAAa,CAA4B;IAC7C,cAAc,EAAE,GAAG;IACnB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;IAChB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;CACpB,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAI,IAAI,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GACzC,KAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACzC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,CAAC,GAAG,CAAC,CAAC;QACZ,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\n\n/** Properties for [[WidgetOpacityContext]]\n * @internal\n */\nexport interface WidgetOpacityContextProps {\n readonly proximityScale: number;\n readonly addRef: (ref: React.RefObject<Element | null>) => void;\n readonly removeRef: (ref: React.RefObject<Element | null>) => void;\n}\n\n/**\n * Context used by Widgets and child components to process opacity changes based on mouse proximity.\n * @internal\n */\nexport const WidgetOpacityContext =\n React.createContext<WidgetOpacityContextProps>({\n proximityScale: 1.0,\n addRef: () => {},\n removeRef: () => {},\n });\n\n/** Hook for using [[WidgetOpacityContext]]\n * @internal\n */\nexport function useWidgetOpacityContext<T extends Element>() {\n const ref = React.useRef<T>(null);\n const { addRef, removeRef, proximityScale } =\n React.useContext(WidgetOpacityContext);\n React.useEffect(() => {\n addRef(ref);\n return () => {\n removeRef(ref);\n };\n }, [addRef, removeRef]);\n return { ref, proximityScale };\n}\n"]}
|
|
@@ -59,34 +59,52 @@ $uicore-menu-top-bottom-padding: calc(#{$uicore-menu-padding} * 0.6667);
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
&.core-context-menu-right {
|
|
62
|
-
transform: translate(
|
|
62
|
+
transform: translate(var(--_core-context-menu-offset), -50%);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
&.core-context-menu-left {
|
|
66
|
-
transform: translate(
|
|
66
|
+
transform: translate(
|
|
67
|
+
calc(-100% - var(--_core-context-menu-offset)),
|
|
68
|
+
-50%
|
|
69
|
+
);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
&.core-context-menu-top {
|
|
70
|
-
transform: translate(
|
|
73
|
+
transform: translate(
|
|
74
|
+
-50%,
|
|
75
|
+
calc(-100% - var(--_core-context-menu-offset))
|
|
76
|
+
);
|
|
71
77
|
|
|
72
78
|
&.core-context-menu-right {
|
|
73
|
-
transform: translate(
|
|
79
|
+
transform: translate(
|
|
80
|
+
var(--_core-context-menu-offset),
|
|
81
|
+
calc(-100% - var(--_core-context-menu-offset))
|
|
82
|
+
);
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
&.core-context-menu-left {
|
|
77
|
-
transform: translate(
|
|
86
|
+
transform: translate(
|
|
87
|
+
calc(-100% - var(--_core-context-menu-offset)),
|
|
88
|
+
calc(-100% - var(--_core-context-menu-offset))
|
|
89
|
+
);
|
|
78
90
|
}
|
|
79
91
|
}
|
|
80
92
|
|
|
81
93
|
&.core-context-menu-bottom {
|
|
82
|
-
transform: translate(-50%,
|
|
94
|
+
transform: translate(-50%, var(--_core-context-menu-offset));
|
|
83
95
|
|
|
84
96
|
&.core-context-menu-right {
|
|
85
|
-
transform: translate(
|
|
97
|
+
transform: translate(
|
|
98
|
+
var(--_core-context-menu-offset),
|
|
99
|
+
var(--_core-context-menu-offset)
|
|
100
|
+
);
|
|
86
101
|
}
|
|
87
102
|
|
|
88
103
|
&.core-context-menu-left {
|
|
89
|
-
transform: translate(
|
|
104
|
+
transform: translate(
|
|
105
|
+
calc(-100% - var(--_core-context-menu-offset)),
|
|
106
|
+
var(--_core-context-menu-offset)
|
|
107
|
+
);
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0",
|
|
4
4
|
"description": "A react component library of iTwin.js UI general purpose components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/core-react.d.ts",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@itwin/appui-abstract": "^4.0.0 || ^5.0.0",
|
|
41
41
|
"@itwin/core-bentley": "^4.0.0 || ^5.0.0",
|
|
42
42
|
"@itwin/itwinui-react": "^3.15.0",
|
|
43
|
-
"react": "^18.0.0",
|
|
44
|
-
"react-dom": "^18.0.0"
|
|
43
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
44
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@itwin/appui-abstract": "^5.1.0",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"@itwin/core-i18n": "^5.1.0",
|
|
53
53
|
"@itwin/eslint-plugin": "5.1.0",
|
|
54
54
|
"@itwin/itwinui-react": "^3.19.4",
|
|
55
|
-
"@testing-library/dom": "^10.1
|
|
56
|
-
"@testing-library/react": "^
|
|
57
|
-
"@testing-library/user-event": "^14.
|
|
55
|
+
"@testing-library/dom": "^10.4.1",
|
|
56
|
+
"@testing-library/react": "^16.3.0",
|
|
57
|
+
"@testing-library/user-event": "^14.6.1",
|
|
58
58
|
"@types/lodash": "^4.14.0",
|
|
59
59
|
"@types/node": "20.17.8",
|
|
60
|
-
"@types/react": "^
|
|
60
|
+
"@types/react": "^19.2.0",
|
|
61
61
|
"@types/react-autosuggest": "10.1.2",
|
|
62
|
-
"@types/react-dom": "^
|
|
62
|
+
"@types/react-dom": "^19.2.0",
|
|
63
63
|
"@vitest/coverage-v8": "^3.0.6",
|
|
64
64
|
"cpx2": "^3.0.0",
|
|
65
65
|
"cross-env": "^5.1.4",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"jsdom": "^24.0.0",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"raf": "^3.4.0",
|
|
72
|
-
"react": "^
|
|
73
|
-
"react-dom": "^
|
|
72
|
+
"react": "^19.2.0",
|
|
73
|
+
"react-dom": "^19.2.0",
|
|
74
74
|
"rimraf": "^6.0.1",
|
|
75
75
|
"ts-node": "^10.8.2",
|
|
76
76
|
"typemoq": "^2.1.0",
|