@itwin/appui-react 5.1.0 → 5.2.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 +10 -1
- package/lib/appui-react/UiFramework.d.ts.map +1 -1
- package/lib/appui-react/UiFramework.js +2 -0
- package/lib/appui-react/UiFramework.js.map +1 -1
- package/lib/appui-react/configurableui/ConfigurableUiContent.d.ts +3 -1
- package/lib/appui-react/configurableui/ConfigurableUiContent.d.ts.map +1 -1
- package/lib/appui-react/configurableui/ConfigurableUiContent.js +14 -6
- package/lib/appui-react/configurableui/ConfigurableUiContent.js.map +1 -1
- package/lib/appui-react/cursor/CursorInformation.d.ts +7 -0
- package/lib/appui-react/cursor/CursorInformation.d.ts.map +1 -1
- package/lib/appui-react/cursor/CursorInformation.js +13 -0
- package/lib/appui-react/cursor/CursorInformation.js.map +1 -1
- package/lib/appui-react/cursor/cursorpopup/CursorPopup.js +1 -1
- package/lib/appui-react/cursor/cursorpopup/CursorPopup.js.map +1 -1
- package/lib/appui-react/cursor/cursorpopup/CursorPopupManager.d.ts +3 -0
- package/lib/appui-react/cursor/cursorpopup/CursorPopupManager.d.ts.map +1 -1
- package/lib/appui-react/cursor/cursorpopup/CursorPopupManager.js +45 -30
- package/lib/appui-react/cursor/cursorpopup/CursorPopupManager.js.map +1 -1
- package/lib/appui-react/cursor/cursorprompt/CursorPrompt.d.ts +12 -15
- package/lib/appui-react/cursor/cursorprompt/CursorPrompt.d.ts.map +1 -1
- package/lib/appui-react/cursor/cursorprompt/CursorPrompt.js +47 -38
- package/lib/appui-react/cursor/cursorprompt/CursorPrompt.js.map +1 -1
- package/lib/appui-react/layout/StandardLayout.d.ts.map +1 -1
- package/lib/appui-react/layout/StandardLayout.js +5 -1
- package/lib/appui-react/layout/StandardLayout.js.map +1 -1
- package/lib/appui-react/redux/FrameworkState.d.ts +1 -1
- package/lib/appui-react/redux/SessionState.d.ts +2 -2
- package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.d.ts +11 -7
- package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.d.ts.map +1 -1
- package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.js +22 -4
- package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.js.map +1 -1
- package/lib/appui-react/theme/ThemeManager.d.ts +1 -1
- package/lib/appui-react/theme/ThemeManager.js +1 -1
- package/lib/appui-react/theme/ThemeManager.js.map +1 -1
- package/lib/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
- package/lib/appui-react/widget-panels/Frontstage.js +2 -0
- package/lib/appui-react/widget-panels/Frontstage.js.map +1 -1
- package/lib/appui-react/widgets/Widget.d.ts +11 -2
- package/lib/appui-react/widgets/Widget.d.ts.map +1 -1
- package/lib/appui-react/widgets/Widget.js.map +1 -1
- package/package.json +11 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurableUiContent.js","sourceRoot":"","sources":["../../../src/appui-react/configurableui/ConfigurableUiContent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EA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Q,EAAE;YAAE,OAAO;QACxD,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CACxC,uBAAuB,EACvB,OAAO,CAAC,QAAQ,EAAE,CACnB,CAAC;QACF,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;QACzE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB;AACxB,+DAA+D;AAC/D,cAA4D;IAE5D,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3D,4DAA4D;QAC5D,OAAO,KAAK,EAAE,mBAAmB,CAAC,cAAc,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GACX,cAAc,IAAI,mBAAmB,IAAI,uBAAuB,CAAC;IAEnE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,qBAAqB,GACzB,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;QAC5E,IAAI,qBAAqB,KAAK,OAAO,CAAC,QAAQ,EAAE;YAAE,OAAO;QACzD,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CACxC,wBAAwB,EACxB,OAAO,CAAC,QAAQ,EAAE,CACnB,CAAC;QACF,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC;QAC1E,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,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 ConfigurableUi\n */\n\nimport \"./ConfigurableUiContent.scss\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Point } from \"@itwin/core-react/internal\";\nimport { ThemeProvider } from \"@itwin/itwinui-react\";\nimport { CursorInformation } from \"../cursor/CursorInformation.js\";\nimport { CursorPopupMenu } from \"../cursor/cursormenu/CursorMenu.js\";\nimport { CursorPopupRenderer } from \"../cursor/cursorpopup/CursorPopupManager.js\";\nimport { ModalDialogRenderer } from \"../dialog/ModalDialogManager.js\";\nimport { ModelessDialogRenderer } from \"../dialog/ModelessDialogManager.js\";\nimport { ElementTooltip } from \"../feedback/ElementTooltip.js\";\nimport { KeyboardShortcutMenu } from \"../keyboardshortcut/KeyboardShortcutMenu.js\";\nimport { InputFieldMessage } from \"../messages/InputField.js\";\nimport { PointerMessage } from \"../messages/Pointer.js\";\nimport { PopupRenderer } from \"../popup/PopupManager.js\";\nimport { WidgetPanelsFrontstage } from \"../widget-panels/Frontstage.js\";\nimport { ContentDialogRenderer } from \"../dialog/ContentDialogManager.js\";\nimport { appUi, UiFramework } from \"../UiFramework.js\";\nimport { InternalConfigurableUiManager } from \"./InternalConfigurableUiManager.js\";\nimport { MessageRenderer } from \"../messages/MessageRenderer.js\";\nimport {\n TOOLBAR_OPACITY_DEFAULT,\n WIDGET_OPACITY_DEFAULT,\n} from \"../theme/ThemeId.js\";\nimport { useReduxFrameworkState } from \"../uistate/useReduxFrameworkState.js\";\nimport type { ContentProps } from \"../content/ContentGroup.js\";\nimport { ChildWindowRenderer } from \"../childwindow/ChildWindowRenderer.js\";\n\n/** @internal */\nexport const ConfigurableUiContext = React.createContext<\n Pick<\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n ConfigurableUiContentProps,\n | \"viewOverlay\"\n | \"widgetOpacity\"\n | \"widgetIcon\"\n | \"collapsePanels\"\n | \"animateToolSettings\"\n | \"toolAsToolSettingsLabel\"\n | \"childWindow\"\n >\n>({});\n\n/** Properties for [[ConfigurableUiContent]]\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ConfigurableUiContent>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ConfigurableUiContentProps extends CommonProps {\n /** React node of the Backstage */\n appBackstage?: React.ReactNode;\n /** Controls if the view overlay should be displayed. Uses redux store as a fallback. Defaults to `true`.\n * @note Only used by configurable control APIs. See {@link ContentProps.classId}.\n * @deprecated in 4.16.0. View overlay visibility should be controlled by the components used in {@link ContentProps.content}.\n */\n viewOverlay?: boolean;\n /** Describes the opacity of widgets. Uses redux store as a fallback. Defaults to {@link WIDGET_OPACITY_DEFAULT}. */\n widgetOpacity?: number;\n /** Controls if the widget icons should be displayed. Uses redux store as a fallback. Defaults to `true`. */\n widgetIcon?: boolean;\n /** Controls if the unpinned panels should be collapsed automatically. Uses redux store as a fallback. Defaults to `false`. */\n collapsePanels?: boolean;\n /** Controls if the tool settings should be animated. Uses redux store as a fallback. Defaults to `false`. */\n animateToolSettings?: boolean;\n /** Controls if the tool settings label should be set based on activated tool. Uses redux store as a fallback. Defaults to `false`. */\n toolAsToolSettingsLabel?: boolean;\n /** Describes the opacity of toolbars. Uses redux store as a fallback. Defaults to {@link TOOLBAR_OPACITY_DEFAULT}. */\n toolbarOpacity?: number;\n /** Component to wrap all popout widgets and other child windows opened via {@link UiFramework.childWindows}. */\n childWindow?: React.ComponentType;\n\n /** @internal */\n idleTimeout?: number;\n /** @internal */\n intervalTimeout?: number;\n}\n\n/**\n * Allows children to get the bounds or other properties of the wrapper element.\n * @internal\n */\nexport const WrapperContext = React.createContext<HTMLElement>(document.body);\n\n/** The ConfigurableUiContent component is the component the pages specified using ConfigurableUi\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ConfigurableUiContent(props: ConfigurableUiContentProps) {\n useWidgetOpacity(props.widgetOpacity);\n useToolbarOpacity(props.toolbarOpacity);\n const [mainElement, setMainElement] = React.useState<HTMLElement>();\n const [portalContainer, setPortalContainer] = React.useState<HTMLElement>();\n React.useEffect(() => {\n UiFramework.keyboardShortcuts.setFocusToHome();\n }, []);\n\n React.useEffect(() => {\n InternalConfigurableUiManager.activityTracker.initialize({\n idleTimeout: props.idleTimeout,\n intervalTimeout: props.intervalTimeout,\n });\n return () => {\n InternalConfigurableUiManager.activityTracker.terminate();\n };\n }, [props.idleTimeout, props.intervalTimeout]);\n\n const handleMouseMove = React.useCallback((e: React.MouseEvent) => {\n const point = new Point(e.pageX, e.pageY);\n CursorInformation.handleMouseMove(point);\n }, []);\n\n return (\n <ConfigurableUiContext.Provider\n value={{\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n viewOverlay: props.viewOverlay,\n widgetOpacity: props.widgetOpacity,\n widgetIcon: props.widgetIcon,\n collapsePanels: props.collapsePanels,\n animateToolSettings: props.animateToolSettings,\n toolAsToolSettingsLabel: props.toolAsToolSettingsLabel,\n childWindow: props.childWindow,\n }}\n >\n <main\n role=\"main\"\n id=\"uifw-configurableui-wrapper\"\n className={props.className}\n style={props.style}\n onMouseMove={handleMouseMove}\n ref={(el) => setMainElement(el ?? undefined)}\n >\n <WrapperContext.Provider value={mainElement ?? document.body}>\n <ThemeProvider\n style={{ height: \"100%\" }}\n portalContainer={portalContainer}\n >\n {props.appBackstage}\n <WidgetPanelsFrontstage />\n\n <ElementTooltip />\n <PointerMessage />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <KeyboardShortcutMenu />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <InputFieldMessage />\n <CursorPopupMenu />\n <CursorPopupRenderer />\n <PopupRenderer />\n <MessageRenderer />\n <ChildWindowRenderer windowManager={appUi.windowManager} />\n <div\n className=\"uifw-configurableui-portalContainer\"\n ref={(instance) => setPortalContainer(instance ?? undefined)}\n >\n <ContentDialogRenderer />\n <ModelessDialogRenderer />\n <ModalDialogRenderer />\n </div>\n </ThemeProvider>\n </WrapperContext.Provider>\n </main>\n </ConfigurableUiContext.Provider>\n );\n}\n\nfunction useWidgetOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n widgetOpacity: ConfigurableUiContentProps[\"widgetOpacity\"]\n) {\n const reduxWidgetOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.widgetOpacity;\n });\n const opacity = widgetOpacity ?? reduxWidgetOpacity ?? WIDGET_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentWidgetOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-widget-opacity\");\n if (currentWidgetOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-widget-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-widget-opacity\");\n };\n }, [opacity]);\n}\n\nfunction useToolbarOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n toolbarOpacity: ConfigurableUiContentProps[\"toolbarOpacity\"]\n) {\n const reduxToolbarOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.toolbarOpacity;\n });\n\n const opacity =\n toolbarOpacity ?? reduxToolbarOpacity ?? TOOLBAR_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentToolbarOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-toolbar-opacity\");\n if (currentToolbarOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-toolbar-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-toolbar-opacity\");\n };\n }, [opacity]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigurableUiContent.js","sourceRoot":"","sources":["../../../src/appui-react/configurableui/ConfigurableUiContent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,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BAAsB,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3D,4DAA4D;QAC5D,OAAO,KAAK,EAAE,mBAAmB,CAAC,cAAc,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GACX,cAAc,IAAI,mBAAmB,IAAI,uBAAuB,CAAC;IAEnE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,qBAAqB,GACzB,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;QAC5E,IAAI,qBAAqB,KAAK,OAAO,CAAC,QAAQ,EAAE;YAAE,OAAO;QACzD,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CACxC,wBAAwB,EACxB,OAAO,CAAC,QAAQ,EAAE,CACnB,CAAC;QACF,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC;QAC1E,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,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 ConfigurableUi\n */\n\nimport \"./ConfigurableUiContent.scss\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Point } from \"@itwin/core-react/internal\";\nimport { ThemeProvider } from \"@itwin/itwinui-react\";\nimport {\n CursorInformation,\n useCursorInformationStore,\n} from \"../cursor/CursorInformation.js\";\nimport { CursorPopupMenu } from \"../cursor/cursormenu/CursorMenu.js\";\nimport { CursorPopupRenderer } from \"../cursor/cursorpopup/CursorPopupManager.js\";\nimport { ModalDialogRenderer } from \"../dialog/ModalDialogManager.js\";\nimport { ModelessDialogRenderer } from \"../dialog/ModelessDialogManager.js\";\nimport { ElementTooltip } from \"../feedback/ElementTooltip.js\";\nimport { KeyboardShortcutMenu } from \"../keyboardshortcut/KeyboardShortcutMenu.js\";\nimport { InputFieldMessage } from \"../messages/InputField.js\";\nimport { PointerMessage } from \"../messages/Pointer.js\";\nimport { PopupRenderer } from \"../popup/PopupManager.js\";\nimport { WidgetPanelsFrontstage } from \"../widget-panels/Frontstage.js\";\nimport { ContentDialogRenderer } from \"../dialog/ContentDialogManager.js\";\nimport { appUi, UiFramework } from \"../UiFramework.js\";\nimport { InternalConfigurableUiManager } from \"./InternalConfigurableUiManager.js\";\nimport { MessageRenderer } from \"../messages/MessageRenderer.js\";\nimport {\n TOOLBAR_OPACITY_DEFAULT,\n WIDGET_OPACITY_DEFAULT,\n} from \"../theme/ThemeId.js\";\nimport { useReduxFrameworkState } from \"../uistate/useReduxFrameworkState.js\";\nimport type { ContentProps } from \"../content/ContentGroup.js\";\nimport { ChildWindowRenderer } from \"../childwindow/ChildWindowRenderer.js\";\n\n/** @internal */\nexport const ConfigurableUiContext = React.createContext<\n Pick<\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n ConfigurableUiContentProps,\n | \"viewOverlay\"\n | \"widgetOpacity\"\n | \"widgetIcon\"\n | \"collapsePanels\"\n | \"animateToolSettings\"\n | \"toolAsToolSettingsLabel\"\n | \"childWindow\"\n > & {\n contentElementRef?: React.RefObject<HTMLElement>;\n }\n>({});\n\n/** Properties for [[ConfigurableUiContent]]\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ConfigurableUiContent>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ConfigurableUiContentProps extends CommonProps {\n /** React node of the Backstage */\n appBackstage?: React.ReactNode;\n /** Controls if the view overlay should be displayed. Uses redux store as a fallback. Defaults to `true`.\n * @note Only used by configurable control APIs. See {@link ContentProps.classId}.\n * @deprecated in 4.16.0. View overlay visibility should be controlled by the components used in {@link ContentProps.content}.\n */\n viewOverlay?: boolean;\n /** Describes the opacity of widgets. Uses redux store as a fallback. Defaults to {@link WIDGET_OPACITY_DEFAULT}. */\n widgetOpacity?: number;\n /** Controls if the widget icons should be displayed. Uses redux store as a fallback. Defaults to `true`. */\n widgetIcon?: boolean;\n /** Controls if the unpinned panels should be collapsed automatically. Uses redux store as a fallback. Defaults to `false`. */\n collapsePanels?: boolean;\n /** Controls if the tool settings should be animated. Uses redux store as a fallback. Defaults to `false`. */\n animateToolSettings?: boolean;\n /** Controls if the tool settings label should be set based on activated tool. Uses redux store as a fallback. Defaults to `false`. */\n toolAsToolSettingsLabel?: boolean;\n /** Describes the opacity of toolbars. Uses redux store as a fallback. Defaults to {@link TOOLBAR_OPACITY_DEFAULT}. */\n toolbarOpacity?: number;\n /** Component to wrap all popout widgets and other child windows opened via {@link UiFramework.childWindows}. */\n childWindow?: React.ComponentType;\n\n /** @internal */\n idleTimeout?: number;\n /** @internal */\n intervalTimeout?: number;\n}\n\n/**\n * Allows children to get the bounds or other properties of the wrapper element.\n * @internal\n */\nexport const WrapperContext = React.createContext<HTMLElement>(document.body);\n\n/** The ConfigurableUiContent component is the component the pages specified using ConfigurableUi\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ConfigurableUiContent(props: ConfigurableUiContentProps) {\n const contentElementRef = React.useRef<HTMLElement>(null);\n\n useWidgetOpacity(props.widgetOpacity);\n useToolbarOpacity(props.toolbarOpacity);\n const [mainElement, setMainElement] = React.useState<HTMLElement>();\n const [portalContainer, setPortalContainer] = React.useState<HTMLElement>();\n React.useEffect(() => {\n UiFramework.keyboardShortcuts.setFocusToHome();\n }, []);\n\n React.useEffect(() => {\n InternalConfigurableUiManager.activityTracker.initialize({\n idleTimeout: props.idleTimeout,\n intervalTimeout: props.intervalTimeout,\n });\n return () => {\n InternalConfigurableUiManager.activityTracker.terminate();\n };\n }, [props.idleTimeout, props.intervalTimeout]);\n\n const setContentHovered = useCursorInformationStore(\n (state) => state.setContentHovered\n );\n return (\n <ConfigurableUiContext.Provider\n value={{\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n viewOverlay: props.viewOverlay,\n widgetOpacity: props.widgetOpacity,\n widgetIcon: props.widgetIcon,\n collapsePanels: props.collapsePanels,\n animateToolSettings: props.animateToolSettings,\n toolAsToolSettingsLabel: props.toolAsToolSettingsLabel,\n childWindow: props.childWindow,\n contentElementRef,\n }}\n >\n <main\n role=\"main\"\n id=\"uifw-configurableui-wrapper\"\n className={props.className}\n style={props.style}\n onMouseMove={(e) => {\n const point = new Point(e.pageX, e.pageY);\n CursorInformation.handleMouseMove(point);\n\n if (!(e.target instanceof Node)) return;\n const contentHovered = contentElementRef.current?.contains(e.target);\n setContentHovered(contentHovered ?? false);\n }}\n onMouseLeave={() => {\n setContentHovered(false);\n }}\n ref={(el) => setMainElement(el ?? undefined)}\n >\n <WrapperContext.Provider value={mainElement ?? document.body}>\n <ThemeProvider\n style={{ height: \"100%\" }}\n portalContainer={portalContainer}\n >\n {props.appBackstage}\n <WidgetPanelsFrontstage />\n\n <ElementTooltip />\n <PointerMessage />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <KeyboardShortcutMenu />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <InputFieldMessage />\n <CursorPopupMenu />\n <CursorPopupRenderer />\n <PopupRenderer />\n <MessageRenderer />\n <ChildWindowRenderer windowManager={appUi.windowManager} />\n <div\n className=\"uifw-configurableui-portalContainer\"\n ref={(instance) => setPortalContainer(instance ?? undefined)}\n >\n <ContentDialogRenderer />\n <ModelessDialogRenderer />\n <ModalDialogRenderer />\n </div>\n </ThemeProvider>\n </WrapperContext.Provider>\n </main>\n </ConfigurableUiContext.Provider>\n );\n}\n\nfunction useWidgetOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n widgetOpacity: ConfigurableUiContentProps[\"widgetOpacity\"]\n) {\n const reduxWidgetOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.widgetOpacity;\n });\n const opacity = widgetOpacity ?? reduxWidgetOpacity ?? WIDGET_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentWidgetOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-widget-opacity\");\n if (currentWidgetOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-widget-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-widget-opacity\");\n };\n }, [opacity]);\n}\n\nfunction useToolbarOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n toolbarOpacity: ConfigurableUiContentProps[\"toolbarOpacity\"]\n) {\n const reduxToolbarOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.toolbarOpacity;\n });\n\n const opacity =\n toolbarOpacity ?? reduxToolbarOpacity ?? TOOLBAR_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentToolbarOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-toolbar-opacity\");\n if (currentToolbarOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-toolbar-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-toolbar-opacity\");\n };\n }, [opacity]);\n}\n"]}
|
|
@@ -69,4 +69,11 @@ export declare class CursorInformation {
|
|
|
69
69
|
/** @internal - for testing */
|
|
70
70
|
static clearCursorDirections(): void;
|
|
71
71
|
}
|
|
72
|
+
/** Returns additional information about cursor.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export declare const useCursorInformationStore: import("zustand").UseBoundStore<import("zustand").StoreApi<{
|
|
76
|
+
contentHovered: boolean;
|
|
77
|
+
setContentHovered: (hovered: boolean) => void;
|
|
78
|
+
}>>;
|
|
72
79
|
//# sourceMappingURL=CursorInformation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorInformation.d.ts","sourceRoot":"","sources":["../../../src/appui-react/cursor/CursorInformation.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"CursorInformation.d.ts","sourceRoot":"","sources":["../../../src/appui-react/cursor/CursorInformation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGlE;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,GAAG,OAAS;IACZ,IAAI,MAAS;IACb,KAAK,KAAS;IACd,MAAM,IAAS;CAChB;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,IAAI,IAAI;IACR,GAAG,OAA2B;IAC9B,IAAI,MAA4B;IAChC,KAAK,KAA6B;IAClC,MAAM,IAA8B;IACpC,OAAO,OAAuD;IAC9D,QAAQ,OAAwD;IAChE,UAAU,MAA0D;IACpE,WAAW,KAA2D;CACvE;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,eAAe,CAAC;CAC5B;AAED;;;GAGG;AAEH,qBAAa,kBAAmB,SAAQ,OAAO,CAAC,sBAAsB,CAAC;CAAG;AAE1E;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,eAAe,CAAsB;IACpD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CACD;IAE9B,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAgC;IAEhE,2BAA2B;IAC3B,WAAkB,cAAc,IAAI,KAAK,CAExC;IACD,WAAkB,cAAc,CAAC,EAAE,EAAE,KAAK,EAEzC;IAED,kCAAkC;IAClC,WAAkB,OAAO,IAAI,MAAM,CAElC;IACD,kCAAkC;IAClC,WAAkB,OAAO,IAAI,MAAM,CAElC;IAED,kDAAkD;IAClD,WAAkB,eAAe,IAAI,eAAe,CAEnD;IAED,uCAAuC;IAEvC,gBAAuB,oBAAoB,qBAA4B;IAEvE,0GAA0G;WAC5F,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAcjD,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAW9C,OAAO,CAAC,MAAM,CAAC,aAAa;IAuB5B,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAiBxC,gEAAgE;WAClD,sCAAsC,CAClD,eAAe,EAAE,eAAe,GAC/B,gBAAgB;IAiCnB,8BAA8B;WAChB,qBAAqB,IAAI,IAAI;CAG5C;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB;oBACpB,OAAO;uBACJ,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI;GAU5C,CAAC"}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Cursor
|
|
7
7
|
*/
|
|
8
|
+
import { create } from "zustand";
|
|
9
|
+
import { produce } from "immer";
|
|
8
10
|
import { RelativePosition, UiEvent } from "@itwin/appui-abstract";
|
|
9
11
|
import { Point } from "@itwin/core-react/internal";
|
|
10
12
|
/** Enum for Cursor Direction parts
|
|
@@ -150,4 +152,15 @@ CursorInformation._cursorDirections = new Array();
|
|
|
150
152
|
/** Gets the [[CursorUpdatedEvent]]. */
|
|
151
153
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
152
154
|
CursorInformation.onCursorUpdatedEvent = new CursorUpdatedEvent();
|
|
155
|
+
/** Returns additional information about cursor.
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
export const useCursorInformationStore = create((set) => ({
|
|
159
|
+
contentHovered: false,
|
|
160
|
+
setContentHovered: (hovered) => {
|
|
161
|
+
set((state) => produce(state, (draft) => {
|
|
162
|
+
draft.contentHovered = hovered;
|
|
163
|
+
}));
|
|
164
|
+
},
|
|
165
|
+
}));
|
|
153
166
|
//# sourceMappingURL=CursorInformation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorInformation.js","sourceRoot":"","sources":["../../../src/appui-react/cursor/CursorInformation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,gEAAY,CAAA;IACZ,iEAAa,CAAA;IACb,kEAAc,CAAA;IACd,mEAAe,CAAA;AACjB,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,qDAAQ,CAAA;IACR,sDAA8B,CAAA;IAC9B,uDAAgC,CAAA;IAChC,wDAAkC,CAAA;IAClC,yDAAoC,CAAA;IACpC,8DAA8D,CAAA;IAC9D,gEAAgE,CAAA;IAChE,mEAAoE,CAAA;IACpE,oEAAsE,CAAA;AACxE,CAAC,EAVW,eAAe,KAAf,eAAe,QAU1B;AAYD;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,OAAO,kBAAmB,SAAQ,OAA+B;CAAG;AAE1E;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAO5B,2BAA2B;IACpB,MAAM,KAAK,cAAc;QAC9B,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IACM,MAAM,KAAK,cAAc,CAAC,EAAS;QACxC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,kCAAkC;IAC3B,MAAM,KAAK,OAAO;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,kCAAkC;IAC3B,MAAM,KAAK,OAAO;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IA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,CAAC,KAAK;gBACxB,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC;gBAC1C,MAAM;YACR,KAAK,eAAe,CAAC,MAAM;gBACzB,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC;gBAC3C,MAAM;YACR,KAAK,eAAe,CAAC,OAAO;gBAC1B,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC;gBAC5C,MAAM;YACR,KAAK,eAAe,CAAC,QAAQ;gBAC3B,gBAAgB,GAAG,gBAAgB,CAAC,QAAQ,CAAC;gBAC7C,MAAM;YACR,KAAK,eAAe,CAAC,UAAU;gBAC7B,gBAAgB,GAAG,gBAAgB,CAAC,UAAU,CAAC;gBAC/C,MAAM;YACR,KAAK,eAAe,CAAC,WAAW;gBAC9B,gBAAgB,GAAG,gBAAgB,CAAC,WAAW,CAAC;gBAChD,MAAM;QACV,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,8BAA8B;IACvB,MAAM,CAAC,qBAAqB;QACjC,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;;AAzIc,iCAAe,GAAU,IAAI,KAAK,EAAE,CAAC;AACrC,kCAAgB,GAC7B,eAAe,CAAC,WAAW,CAAC;AAEf,mCAAiB,GAAG,IAAI,KAAK,EAAmB,CAAC;AAwBhE,uCAAuC;AACvC,4DAA4D;AACrC,sCAAoB,GAAG,IAAI,kBAAkB,EAAE,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 Cursor\n */\n\nimport type { XAndY } from \"@itwin/core-geometry\";\nimport { RelativePosition, UiEvent } from \"@itwin/appui-abstract\";\nimport { Point } from \"@itwin/core-react/internal\";\n\n/** Enum for Cursor Direction parts\n * @public\n */\nexport enum CursorDirectionParts {\n Top = 0x1000,\n Left = 0x0100,\n Right = 0x0010,\n Bottom = 0x0001,\n}\n\n/** Enum for Cursor Direction\n * @public\n */\nexport enum CursorDirection {\n None = 0,\n Top = CursorDirectionParts.Top,\n Left = CursorDirectionParts.Left,\n Right = CursorDirectionParts.Right,\n Bottom = CursorDirectionParts.Bottom,\n TopLeft = CursorDirectionParts.Top | CursorDirectionParts.Left,\n TopRight = CursorDirectionParts.Top | CursorDirectionParts.Right,\n BottomLeft = CursorDirectionParts.Bottom | CursorDirectionParts.Left,\n BottomRight = CursorDirectionParts.Bottom | CursorDirectionParts.Right,\n}\n\n/** Cursor Updated Event Args interface.\n * @public\n * @deprecated in 4.13.0. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface CursorUpdatedEventArgs {\n oldPt: XAndY;\n newPt: XAndY;\n direction: CursorDirection;\n}\n\n/** Cursor Updated Event class.\n * @public\n * @deprecated in 4.13.0. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class CursorUpdatedEvent extends UiEvent<CursorUpdatedEventArgs> {}\n\n/** Cursor Information class\n * @public\n */\nexport class CursorInformation {\n private static _cursorPosition: Point = new Point();\n private static _cursorDirection: CursorDirection =\n CursorDirection.BottomRight;\n\n private static _cursorDirections = new Array<CursorDirection>();\n\n /** The cursor position. */\n public static get cursorPosition(): XAndY {\n return this._cursorPosition;\n }\n public static set cursorPosition(pt: XAndY) {\n this._cursorPosition = Point.create(pt);\n }\n\n /** Gets the cursor X position. */\n public static get cursorX(): number {\n return this._cursorPosition.x;\n }\n /** Gets the cursor Y position. */\n public static get cursorY(): number {\n return this._cursorPosition.y;\n }\n\n /** Gets the general cursor movement direction. */\n public static get cursorDirection(): CursorDirection {\n return this._cursorDirection;\n }\n\n /** Gets the [[CursorUpdatedEvent]]. */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public static readonly onCursorUpdatedEvent = new CursorUpdatedEvent();\n\n /** Handles the mouse movement. Sets the cursor position and direction and emits onCursorUpdatedEvent. */\n public static handleMouseMove(point: XAndY): void {\n const oldPt = CursorInformation.cursorPosition;\n const direction = this._determineMostFrequentDirection(\n this._cursorDirections,\n this._cursorPosition,\n Point.create(point)\n );\n\n this.cursorPosition = point;\n this._cursorDirection = direction;\n\n this.onCursorUpdatedEvent.emit({ oldPt, newPt: point, direction });\n }\n\n private static _determineMostFrequentDirection(\n cursorDirections: CursorDirection[],\n oldPt: Point,\n newPt: Point\n ): CursorDirection {\n const cursorDirection = this._determineCursorDirection(oldPt, newPt);\n cursorDirections.push(cursorDirection);\n if (cursorDirections.length > 10) cursorDirections.shift();\n return this._mostFrequent(cursorDirections);\n }\n\n private static _mostFrequent(array: CursorDirection[]): CursorDirection {\n const hashMap = new Map<CursorDirection, number>();\n let maxCount = 0,\n mostFrequent = CursorDirection.None;\n\n array.forEach((value: CursorDirection) => {\n const key = value;\n let frequency = hashMap.get(key);\n\n if (frequency !== undefined) frequency++;\n else frequency = 1;\n\n hashMap.set(key, frequency);\n\n if (frequency > maxCount) {\n mostFrequent = key;\n maxCount = frequency;\n }\n });\n\n return mostFrequent;\n }\n\n private static _determineCursorDirection(\n oldPt: Point,\n newPt: Point\n ): CursorDirection {\n let directionParts: number = 0;\n\n if (newPt.x < oldPt.x) directionParts |= CursorDirectionParts.Left;\n else if (newPt.x > oldPt.x) directionParts |= CursorDirectionParts.Right;\n\n if (newPt.y < oldPt.y) directionParts |= CursorDirectionParts.Top;\n else if (newPt.y > oldPt.y) directionParts |= CursorDirectionParts.Bottom;\n\n const direction = directionParts as CursorDirection;\n\n return direction;\n }\n\n /** Gets the relative position based on the cursor direction. */\n public static getRelativePositionFromCursorDirection(\n cursorDirection: CursorDirection\n ): RelativePosition {\n let relativePosition: RelativePosition = RelativePosition.BottomRight;\n\n switch (cursorDirection) {\n case CursorDirection.Top:\n relativePosition = RelativePosition.Top;\n break;\n case CursorDirection.Left:\n relativePosition = RelativePosition.Left;\n break;\n case CursorDirection.Right:\n relativePosition = RelativePosition.Right;\n break;\n case CursorDirection.Bottom:\n relativePosition = RelativePosition.Bottom;\n break;\n case CursorDirection.TopLeft:\n relativePosition = RelativePosition.TopLeft;\n break;\n case CursorDirection.TopRight:\n relativePosition = RelativePosition.TopRight;\n break;\n case CursorDirection.BottomLeft:\n relativePosition = RelativePosition.BottomLeft;\n break;\n case CursorDirection.BottomRight:\n relativePosition = RelativePosition.BottomRight;\n break;\n }\n\n return relativePosition;\n }\n\n /** @internal - for testing */\n public static clearCursorDirections(): void {\n this._cursorDirections.length = 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CursorInformation.js","sourceRoot":"","sources":["../../../src/appui-react/cursor/CursorInformation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,gEAAY,CAAA;IACZ,iEAAa,CAAA;IACb,kEAAc,CAAA;IACd,mEAAe,CAAA;AACjB,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,qDAAQ,CAAA;IACR,sDAA8B,CAAA;IAC9B,uDAAgC,CAAA;IAChC,wDAAkC,CAAA;IAClC,yDAAoC,CAAA;IACpC,8DAA8D,CAAA;IAC9D,gEAAgE,CAAA;IAChE,mEAAoE,CAAA;IACpE,oEAAsE,CAAA;AACxE,CAAC,EAVW,eAAe,KAAf,eAAe,QAU1B;AAYD;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,OAAO,kBAAmB,SAAQ,OAA+B;CAA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f,mCAAiB,GAAG,IAAI,KAAK,EAAmB,CAAC;AAwBhE,uCAAuC;AACvC,4DAA4D;AACrC,sCAAoB,GAAG,IAAI,kBAAkB,EAAE,CAAC;AA8GzE;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAG5C,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACX,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,CAAC,OAAgB,EAAE,EAAE;QACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACZ,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YACvB,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC;QACjC,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC,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 Cursor\n */\n\nimport { create } from \"zustand\";\nimport { produce } from \"immer\";\nimport type { XAndY } from \"@itwin/core-geometry\";\nimport { RelativePosition, UiEvent } from \"@itwin/appui-abstract\";\nimport { Point } from \"@itwin/core-react/internal\";\n\n/** Enum for Cursor Direction parts\n * @public\n */\nexport enum CursorDirectionParts {\n Top = 0x1000,\n Left = 0x0100,\n Right = 0x0010,\n Bottom = 0x0001,\n}\n\n/** Enum for Cursor Direction\n * @public\n */\nexport enum CursorDirection {\n None = 0,\n Top = CursorDirectionParts.Top,\n Left = CursorDirectionParts.Left,\n Right = CursorDirectionParts.Right,\n Bottom = CursorDirectionParts.Bottom,\n TopLeft = CursorDirectionParts.Top | CursorDirectionParts.Left,\n TopRight = CursorDirectionParts.Top | CursorDirectionParts.Right,\n BottomLeft = CursorDirectionParts.Bottom | CursorDirectionParts.Left,\n BottomRight = CursorDirectionParts.Bottom | CursorDirectionParts.Right,\n}\n\n/** Cursor Updated Event Args interface.\n * @public\n * @deprecated in 4.13.0. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface CursorUpdatedEventArgs {\n oldPt: XAndY;\n newPt: XAndY;\n direction: CursorDirection;\n}\n\n/** Cursor Updated Event class.\n * @public\n * @deprecated in 4.13.0. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class CursorUpdatedEvent extends UiEvent<CursorUpdatedEventArgs> {}\n\n/** Cursor Information class\n * @public\n */\nexport class CursorInformation {\n private static _cursorPosition: Point = new Point();\n private static _cursorDirection: CursorDirection =\n CursorDirection.BottomRight;\n\n private static _cursorDirections = new Array<CursorDirection>();\n\n /** The cursor position. */\n public static get cursorPosition(): XAndY {\n return this._cursorPosition;\n }\n public static set cursorPosition(pt: XAndY) {\n this._cursorPosition = Point.create(pt);\n }\n\n /** Gets the cursor X position. */\n public static get cursorX(): number {\n return this._cursorPosition.x;\n }\n /** Gets the cursor Y position. */\n public static get cursorY(): number {\n return this._cursorPosition.y;\n }\n\n /** Gets the general cursor movement direction. */\n public static get cursorDirection(): CursorDirection {\n return this._cursorDirection;\n }\n\n /** Gets the [[CursorUpdatedEvent]]. */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public static readonly onCursorUpdatedEvent = new CursorUpdatedEvent();\n\n /** Handles the mouse movement. Sets the cursor position and direction and emits onCursorUpdatedEvent. */\n public static handleMouseMove(point: XAndY): void {\n const oldPt = CursorInformation.cursorPosition;\n const direction = this._determineMostFrequentDirection(\n this._cursorDirections,\n this._cursorPosition,\n Point.create(point)\n );\n\n this.cursorPosition = point;\n this._cursorDirection = direction;\n\n this.onCursorUpdatedEvent.emit({ oldPt, newPt: point, direction });\n }\n\n private static _determineMostFrequentDirection(\n cursorDirections: CursorDirection[],\n oldPt: Point,\n newPt: Point\n ): CursorDirection {\n const cursorDirection = this._determineCursorDirection(oldPt, newPt);\n cursorDirections.push(cursorDirection);\n if (cursorDirections.length > 10) cursorDirections.shift();\n return this._mostFrequent(cursorDirections);\n }\n\n private static _mostFrequent(array: CursorDirection[]): CursorDirection {\n const hashMap = new Map<CursorDirection, number>();\n let maxCount = 0,\n mostFrequent = CursorDirection.None;\n\n array.forEach((value: CursorDirection) => {\n const key = value;\n let frequency = hashMap.get(key);\n\n if (frequency !== undefined) frequency++;\n else frequency = 1;\n\n hashMap.set(key, frequency);\n\n if (frequency > maxCount) {\n mostFrequent = key;\n maxCount = frequency;\n }\n });\n\n return mostFrequent;\n }\n\n private static _determineCursorDirection(\n oldPt: Point,\n newPt: Point\n ): CursorDirection {\n let directionParts: number = 0;\n\n if (newPt.x < oldPt.x) directionParts |= CursorDirectionParts.Left;\n else if (newPt.x > oldPt.x) directionParts |= CursorDirectionParts.Right;\n\n if (newPt.y < oldPt.y) directionParts |= CursorDirectionParts.Top;\n else if (newPt.y > oldPt.y) directionParts |= CursorDirectionParts.Bottom;\n\n const direction = directionParts as CursorDirection;\n\n return direction;\n }\n\n /** Gets the relative position based on the cursor direction. */\n public static getRelativePositionFromCursorDirection(\n cursorDirection: CursorDirection\n ): RelativePosition {\n let relativePosition: RelativePosition = RelativePosition.BottomRight;\n\n switch (cursorDirection) {\n case CursorDirection.Top:\n relativePosition = RelativePosition.Top;\n break;\n case CursorDirection.Left:\n relativePosition = RelativePosition.Left;\n break;\n case CursorDirection.Right:\n relativePosition = RelativePosition.Right;\n break;\n case CursorDirection.Bottom:\n relativePosition = RelativePosition.Bottom;\n break;\n case CursorDirection.TopLeft:\n relativePosition = RelativePosition.TopLeft;\n break;\n case CursorDirection.TopRight:\n relativePosition = RelativePosition.TopRight;\n break;\n case CursorDirection.BottomLeft:\n relativePosition = RelativePosition.BottomLeft;\n break;\n case CursorDirection.BottomRight:\n relativePosition = RelativePosition.BottomRight;\n break;\n }\n\n return relativePosition;\n }\n\n /** @internal - for testing */\n public static clearCursorDirections(): void {\n this._cursorDirections.length = 0;\n }\n}\n\n/** Returns additional information about cursor.\n * @internal\n */\nexport const useCursorInformationStore = create<{\n contentHovered: boolean;\n setContentHovered: (hovered: boolean) => void;\n}>((set) => ({\n contentHovered: false,\n setContentHovered: (hovered: boolean) => {\n set((state) =>\n produce(state, (draft) => {\n draft.contentHovered = hovered;\n })\n );\n },\n}));\n"]}
|
|
@@ -30,7 +30,7 @@ export class CursorPopup extends React.Component {
|
|
|
30
30
|
this._handleCursorPopupFadeOutEvent = (args) => {
|
|
31
31
|
if (this.props.id === args.id) {
|
|
32
32
|
if (this._isMounted)
|
|
33
|
-
this.setState({ showPopup: CursorPopupShow.FadeOut });
|
|
33
|
+
this.setState({ showPopup: args.show ?? CursorPopupShow.FadeOut });
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
this.state = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorPopup.js","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorpopup/CursorPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAyB7D;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,qDAAI,CAAA;IACJ,2DAAO,CAAA;AACT,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAUD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAGtC;IAMC,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QANP,eAAU,GAAY,KAAK,CAAC;QA4B5B,mCAA8B,GAEl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,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAC7B,KAAK,EAAE,gBAAgB;YAEtB,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CACnB,oBAAC,eAAe,CAAC,QAAQ,IACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAC,wBAAwB,GAClC,CACH;YACA,IAAI,CAAC,KAAK,CAAC,OAAO,CACf,CACP,CAAC;IACJ,CAAC;;AA1MD,gBAAgB;AACF,uBAAW,GAAG,GAAG,AAAN,CAAO;AA4MlC;;GAEG;AACH,4DAA4D;AAC5D,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACtD,4DAA4D;IAC5D,OAAO,oBAAC,GAAG,OAAK,KAAK,EAAE,aAAa,EAAC,0BAA0B,GAAG,CAAC;AACrE,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 Cursor\n */\n\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { XAndY } from \"@itwin/core-geometry\";\nimport type { CommonDivProps, CommonProps } from \"@itwin/core-react\";\nimport type { ListenerType } from \"@itwin/core-react/internal\";\nimport { Div } from \"@itwin/core-react\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { StatusBarDialog } from \"../../statusbar/dialog/Dialog.js\";\nimport \"./CursorPopup.scss\";\nimport { CursorPopupManager } from \"./CursorPopupManager.js\";\nimport { type Placement } from \"../../utils/Placement.js\";\nimport type { RequireAtLeastOne } from \"@itwin/core-bentley\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\nimport type { RectangleProps } from \"../../utils/RectangleProps.js\";\n\n/** Properties for the [[CursorPopup]] React component\n * @public\n */\nexport type CursorPopupProps = {\n id: string;\n content: React.ReactNode;\n pt: XAndY;\n offset: XAndY;\n title?: string;\n shadow?: boolean;\n /** Function called when size is known. */\n onSizeKnown?: (size: SizeProps) => void;\n} & CommonProps & // eslint-disable-line @typescript-eslint/no-deprecated\n RequireAtLeastOne<{\n /** @deprecated in 4.16.0. Use `placement` property instead. */\n relativePosition: RelativePosition;\n placement: Placement;\n }>;\n\n/** Enum for showing CursorPopup\n * @internal - unit testing\n */\nexport enum CursorPopupShow {\n Open,\n FadeOut,\n}\n\n/** State for the [[CursorPopup]] React component\n * @internal\n */\ninterface CursorPopupState {\n showPopup: CursorPopupShow;\n size: SizeProps;\n}\n\n/** CursorPopup React component\n * @public\n */\nexport class CursorPopup extends React.Component<\n CursorPopupProps,\n CursorPopupState\n> {\n private _isMounted: boolean = false;\n\n /** @internal */\n public static fadeOutTime = 500;\n\n constructor(props: CursorPopupProps) {\n super(props);\n\n this.state = {\n showPopup: CursorPopupShow.Open,\n size: { width: -1, height: -1 },\n };\n }\n\n public override componentDidMount() {\n this._isMounted = true;\n CursorPopupManager.onCursorPopupFadeOutEvent.addListener(\n this._handleCursorPopupFadeOutEvent\n );\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n CursorPopupManager.onCursorPopupFadeOutEvent.removeListener(\n this._handleCursorPopupFadeOutEvent\n );\n }\n\n private _handleCursorPopupFadeOutEvent: ListenerType<\n typeof CursorPopupManager.onCursorPopupFadeOutEvent\n > = (args) => {\n if (this.props.id === args.id) {\n if (this._isMounted)\n this.setState({ showPopup: CursorPopupShow.FadeOut });\n }\n };\n\n /** @internal */\n public static getPopupRect(\n pt: XAndY,\n offset: XAndY,\n popupSize: SizeProps | undefined,\n relativePosition: RelativePosition | Placement\n ): RectangleProps {\n const popupRect = { top: 0, left: 0, right: 0, bottom: 0 };\n if (popupSize === undefined) return popupRect;\n\n if (typeof relativePosition === \"string\") {\n const placement = relativePosition.split(\"-\");\n const [mainPlacement, subPlacement] = placement;\n\n switch (mainPlacement) {\n case \"top\":\n popupRect.left = pt.x - popupSize.width / 2 - offset.x;\n popupRect.top = pt.y - offset.y + popupSize.height;\n break;\n case \"left\":\n popupRect.left = pt.x - popupSize.width - offset.x;\n popupRect.top = pt.y + popupSize.height / 2 - offset.y;\n break;\n case \"right\":\n popupRect.left = pt.x + offset.x;\n popupRect.top = pt.y + popupSize.height / 2 - offset.y;\n break;\n case \"bottom\":\n popupRect.left = pt.x - popupSize.width / 2 - offset.x;\n popupRect.top = pt.y + offset.y;\n break;\n }\n\n if (subPlacement === \"start\") {\n switch (mainPlacement) {\n case \"top\":\n case \"bottom\":\n popupRect.left = pt.x - offset.x;\n\n break;\n case \"left\":\n case \"right\":\n popupRect.top = pt.y - offset.y;\n break;\n }\n } else if (subPlacement === \"end\") {\n switch (mainPlacement) {\n case \"top\":\n case \"bottom\":\n popupRect.left = pt.x - popupSize.width - offset.x;\n break;\n case \"left\":\n case \"right\":\n popupRect.top = popupSize.height + pt.y - offset.y;\n break;\n }\n }\n\n popupRect.right = popupRect.left + popupSize.width;\n popupRect.bottom = popupRect.top + popupSize.height;\n } else {\n switch (relativePosition) {\n case RelativePosition.Top:\n popupRect.bottom = pt.y - offset.y;\n popupRect.left = pt.x - popupSize.width / 2;\n popupRect.top = popupRect.bottom - popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n case RelativePosition.Left:\n popupRect.right = pt.x - offset.x;\n popupRect.top = pt.y - popupSize.height / 2;\n popupRect.left = popupRect.right - popupSize.width;\n popupRect.bottom = popupRect.top + popupSize.height;\n break;\n case RelativePosition.Right:\n popupRect.left = pt.x + offset.x;\n popupRect.top = pt.y - popupSize.height / 2;\n popupRect.right = popupRect.left + popupSize.width;\n popupRect.bottom = popupRect.top + popupSize.height;\n break;\n case RelativePosition.Bottom:\n popupRect.top = pt.y + offset.y;\n popupRect.left = pt.x - popupSize.width / 2;\n popupRect.bottom = popupRect.top + popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n case RelativePosition.TopLeft:\n popupRect.bottom = pt.y - offset.y;\n popupRect.right = pt.x - offset.x;\n popupRect.top = popupRect.bottom - popupSize.height;\n popupRect.left = popupRect.right - popupSize.width;\n break;\n case RelativePosition.TopRight:\n popupRect.bottom = pt.y - offset.y;\n popupRect.left = pt.x + offset.x;\n popupRect.top = popupRect.bottom - popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n case RelativePosition.BottomLeft:\n popupRect.top = pt.y + offset.y;\n popupRect.right = pt.x - offset.x;\n popupRect.bottom = popupRect.top + popupSize.height;\n popupRect.left = popupRect.right - popupSize.width;\n break;\n case RelativePosition.BottomRight:\n popupRect.top = pt.y + offset.y;\n popupRect.left = pt.x + offset.x;\n popupRect.bottom = popupRect.top + popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n }\n }\n\n return popupRect;\n }\n\n private setDivRef(div: HTMLDivElement | null) {\n if (div) {\n const rect = div.getBoundingClientRect();\n const newSize = { width: rect.width, height: rect.height };\n if (\n newSize.height === this.state.size.height &&\n newSize.width === this.state.size.width\n )\n return;\n\n this.props.onSizeKnown?.(newSize);\n if (this._isMounted) this.setState({ size: newSize });\n }\n }\n\n public override render() {\n const popupRect = CursorPopup.getPopupRect(\n this.props.pt,\n this.props.offset,\n this.state.size,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.props.placement || this.props.relativePosition\n );\n\n const positioningStyle: React.CSSProperties = {\n left: popupRect.left,\n top: popupRect.top,\n };\n\n const classNames = classnames(\n \"uifw-cursorpopup\",\n this.props.shadow && \"core-popup-shadow\",\n this.state.showPopup === CursorPopupShow.FadeOut &&\n \"uifw-cursorpopup-fadeOut\"\n );\n\n return (\n <div\n className={classNames}\n ref={(e) => this.setDivRef(e)}\n style={positioningStyle}\n >\n {this.props.title && (\n <StatusBarDialog.TitleBar\n title={this.props.title}\n className=\"uifw-cursorpopup-title\"\n />\n )}\n {this.props.content}\n </div>\n );\n }\n}\n\n/** CursorPopup content with padding\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function CursorPopupContent(props: CommonDivProps) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <Div {...props} mainClassName=\"uifw-cursorpopup-content\" />;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CursorPopup.js","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorpopup/CursorPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAyB7D;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,qDAAI,CAAA;IACJ,2DAAO,CAAA;AACT,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAUD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAGtC;IAMC,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QANP,eAAU,GAAY,KAAK,CAAC;QA4B5B,mCAA8B,GAElC,CAAC,IAAI,EAAE,EAAE;YACX,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;gBAC9B,IAAI,IAAI,CAAC,UAAU;oBACjB,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC,CAAC;QA3BA,IAAI,CAAC,KAAK,GAAG;YACX,SAAS,EAAE,eAAe,CAAC,IAAI;YAC/B,IAAI,EAAE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AgB;AACF,uBAAW,GAAG,GAAG,AAAN,CAAO;AA4MlC;;GAEG;AACH,4DAA4D;AAC5D,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACtD,4DAA4D;IAC5D,OAAO,oBAAC,GAAG,OAAK,KAAK,EAAE,aAAa,EAAC,0BAA0B,GAAG,CAAC;AACrE,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 Cursor\n */\n\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { XAndY } from \"@itwin/core-geometry\";\nimport type { CommonDivProps, CommonProps } from \"@itwin/core-react\";\nimport type { ListenerType } from \"@itwin/core-react/internal\";\nimport { Div } from \"@itwin/core-react\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { StatusBarDialog } from \"../../statusbar/dialog/Dialog.js\";\nimport \"./CursorPopup.scss\";\nimport { CursorPopupManager } from \"./CursorPopupManager.js\";\nimport { type Placement } from \"../../utils/Placement.js\";\nimport type { RequireAtLeastOne } from \"@itwin/core-bentley\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\nimport type { RectangleProps } from \"../../utils/RectangleProps.js\";\n\n/** Properties for the [[CursorPopup]] React component\n * @public\n */\nexport type CursorPopupProps = {\n id: string;\n content: React.ReactNode;\n pt: XAndY;\n offset: XAndY;\n title?: string;\n shadow?: boolean;\n /** Function called when size is known. */\n onSizeKnown?: (size: SizeProps) => void;\n} & CommonProps & // eslint-disable-line @typescript-eslint/no-deprecated\n RequireAtLeastOne<{\n /** @deprecated in 4.16.0. Use `placement` property instead. */\n relativePosition: RelativePosition;\n placement: Placement;\n }>;\n\n/** Enum for showing CursorPopup\n * @internal - unit testing\n */\nexport enum CursorPopupShow {\n Open,\n FadeOut,\n}\n\n/** State for the [[CursorPopup]] React component\n * @internal\n */\ninterface CursorPopupState {\n showPopup: CursorPopupShow;\n size: SizeProps;\n}\n\n/** CursorPopup React component\n * @public\n */\nexport class CursorPopup extends React.Component<\n CursorPopupProps,\n CursorPopupState\n> {\n private _isMounted: boolean = false;\n\n /** @internal */\n public static fadeOutTime = 500;\n\n constructor(props: CursorPopupProps) {\n super(props);\n\n this.state = {\n showPopup: CursorPopupShow.Open,\n size: { width: -1, height: -1 },\n };\n }\n\n public override componentDidMount() {\n this._isMounted = true;\n CursorPopupManager.onCursorPopupFadeOutEvent.addListener(\n this._handleCursorPopupFadeOutEvent\n );\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n CursorPopupManager.onCursorPopupFadeOutEvent.removeListener(\n this._handleCursorPopupFadeOutEvent\n );\n }\n\n private _handleCursorPopupFadeOutEvent: ListenerType<\n typeof CursorPopupManager.onCursorPopupFadeOutEvent\n > = (args) => {\n if (this.props.id === args.id) {\n if (this._isMounted)\n this.setState({ showPopup: args.show ?? CursorPopupShow.FadeOut });\n }\n };\n\n /** @internal */\n public static getPopupRect(\n pt: XAndY,\n offset: XAndY,\n popupSize: SizeProps | undefined,\n relativePosition: RelativePosition | Placement\n ): RectangleProps {\n const popupRect = { top: 0, left: 0, right: 0, bottom: 0 };\n if (popupSize === undefined) return popupRect;\n\n if (typeof relativePosition === \"string\") {\n const placement = relativePosition.split(\"-\");\n const [mainPlacement, subPlacement] = placement;\n\n switch (mainPlacement) {\n case \"top\":\n popupRect.left = pt.x - popupSize.width / 2 - offset.x;\n popupRect.top = pt.y - offset.y + popupSize.height;\n break;\n case \"left\":\n popupRect.left = pt.x - popupSize.width - offset.x;\n popupRect.top = pt.y + popupSize.height / 2 - offset.y;\n break;\n case \"right\":\n popupRect.left = pt.x + offset.x;\n popupRect.top = pt.y + popupSize.height / 2 - offset.y;\n break;\n case \"bottom\":\n popupRect.left = pt.x - popupSize.width / 2 - offset.x;\n popupRect.top = pt.y + offset.y;\n break;\n }\n\n if (subPlacement === \"start\") {\n switch (mainPlacement) {\n case \"top\":\n case \"bottom\":\n popupRect.left = pt.x - offset.x;\n\n break;\n case \"left\":\n case \"right\":\n popupRect.top = pt.y - offset.y;\n break;\n }\n } else if (subPlacement === \"end\") {\n switch (mainPlacement) {\n case \"top\":\n case \"bottom\":\n popupRect.left = pt.x - popupSize.width - offset.x;\n break;\n case \"left\":\n case \"right\":\n popupRect.top = popupSize.height + pt.y - offset.y;\n break;\n }\n }\n\n popupRect.right = popupRect.left + popupSize.width;\n popupRect.bottom = popupRect.top + popupSize.height;\n } else {\n switch (relativePosition) {\n case RelativePosition.Top:\n popupRect.bottom = pt.y - offset.y;\n popupRect.left = pt.x - popupSize.width / 2;\n popupRect.top = popupRect.bottom - popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n case RelativePosition.Left:\n popupRect.right = pt.x - offset.x;\n popupRect.top = pt.y - popupSize.height / 2;\n popupRect.left = popupRect.right - popupSize.width;\n popupRect.bottom = popupRect.top + popupSize.height;\n break;\n case RelativePosition.Right:\n popupRect.left = pt.x + offset.x;\n popupRect.top = pt.y - popupSize.height / 2;\n popupRect.right = popupRect.left + popupSize.width;\n popupRect.bottom = popupRect.top + popupSize.height;\n break;\n case RelativePosition.Bottom:\n popupRect.top = pt.y + offset.y;\n popupRect.left = pt.x - popupSize.width / 2;\n popupRect.bottom = popupRect.top + popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n case RelativePosition.TopLeft:\n popupRect.bottom = pt.y - offset.y;\n popupRect.right = pt.x - offset.x;\n popupRect.top = popupRect.bottom - popupSize.height;\n popupRect.left = popupRect.right - popupSize.width;\n break;\n case RelativePosition.TopRight:\n popupRect.bottom = pt.y - offset.y;\n popupRect.left = pt.x + offset.x;\n popupRect.top = popupRect.bottom - popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n case RelativePosition.BottomLeft:\n popupRect.top = pt.y + offset.y;\n popupRect.right = pt.x - offset.x;\n popupRect.bottom = popupRect.top + popupSize.height;\n popupRect.left = popupRect.right - popupSize.width;\n break;\n case RelativePosition.BottomRight:\n popupRect.top = pt.y + offset.y;\n popupRect.left = pt.x + offset.x;\n popupRect.bottom = popupRect.top + popupSize.height;\n popupRect.right = popupRect.left + popupSize.width;\n break;\n }\n }\n\n return popupRect;\n }\n\n private setDivRef(div: HTMLDivElement | null) {\n if (div) {\n const rect = div.getBoundingClientRect();\n const newSize = { width: rect.width, height: rect.height };\n if (\n newSize.height === this.state.size.height &&\n newSize.width === this.state.size.width\n )\n return;\n\n this.props.onSizeKnown?.(newSize);\n if (this._isMounted) this.setState({ size: newSize });\n }\n }\n\n public override render() {\n const popupRect = CursorPopup.getPopupRect(\n this.props.pt,\n this.props.offset,\n this.state.size,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this.props.placement || this.props.relativePosition\n );\n\n const positioningStyle: React.CSSProperties = {\n left: popupRect.left,\n top: popupRect.top,\n };\n\n const classNames = classnames(\n \"uifw-cursorpopup\",\n this.props.shadow && \"core-popup-shadow\",\n this.state.showPopup === CursorPopupShow.FadeOut &&\n \"uifw-cursorpopup-fadeOut\"\n );\n\n return (\n <div\n className={classNames}\n ref={(e) => this.setDivRef(e)}\n style={positioningStyle}\n >\n {this.props.title && (\n <StatusBarDialog.TitleBar\n title={this.props.title}\n className=\"uifw-cursorpopup-title\"\n />\n )}\n {this.props.content}\n </div>\n );\n }\n}\n\n/** CursorPopup content with padding\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function CursorPopupContent(props: CommonDivProps) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <Div {...props} mainClassName=\"uifw-cursorpopup-content\" />;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { BeUiEvent } from "@itwin/core-bentley";
|
|
|
6
6
|
import type { XAndY } from "@itwin/core-geometry";
|
|
7
7
|
import { RelativePosition } from "@itwin/appui-abstract";
|
|
8
8
|
import { Point } from "@itwin/core-react/internal";
|
|
9
|
+
import { CursorPopupShow } from "./CursorPopup.js";
|
|
9
10
|
import type { SizeProps } from "../../utils/SizeProps.js";
|
|
10
11
|
/** Options for the [[CursorPopupManager]] open method
|
|
11
12
|
* @public
|
|
@@ -30,6 +31,7 @@ interface CursorPopupInfo {
|
|
|
30
31
|
options?: CursorPopupOptions;
|
|
31
32
|
renderRelativePosition: RelativePosition;
|
|
32
33
|
popupSize?: SizeProps;
|
|
34
|
+
cancelFadeOut?: () => void;
|
|
33
35
|
}
|
|
34
36
|
/** CursorPopup component
|
|
35
37
|
* @public
|
|
@@ -43,6 +45,7 @@ export declare class CursorPopupManager {
|
|
|
43
45
|
/** @internal */
|
|
44
46
|
static readonly onCursorPopupFadeOutEvent: BeUiEvent<{
|
|
45
47
|
id: string;
|
|
48
|
+
show?: CursorPopupShow;
|
|
46
49
|
}>;
|
|
47
50
|
/** @internal */
|
|
48
51
|
static readonly onCursorPopupsChangedEvent: BeUiEvent<object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorPopupManager.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorpopup/CursorPopupManager.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"CursorPopupManager.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorpopup/CursorPopupManager.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;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logger } from "@itwin/core-bentley";
|
|
|
10
10
|
import { RelativePosition } from "@itwin/appui-abstract";
|
|
11
11
|
import { Point } from "@itwin/core-react/internal";
|
|
12
12
|
import { UiFramework } from "../../UiFramework.js";
|
|
13
|
+
import { CursorPopupShow } from "./CursorPopup.js";
|
|
13
14
|
import { CursorPopup } from "./CursorPopup.js";
|
|
14
15
|
/** CursorPopup component
|
|
15
16
|
* @public
|
|
@@ -38,25 +39,33 @@ export class CursorPopupManager {
|
|
|
38
39
|
static open(id, content, pt, offset, relativePosition, priority = 0, options) {
|
|
39
40
|
const popupInfo = CursorPopupManager._popups.find((info) => id === info.id);
|
|
40
41
|
if (popupInfo) {
|
|
42
|
+
CursorPopupManager.onCursorPopupFadeOutEvent.emit({
|
|
43
|
+
id,
|
|
44
|
+
show: CursorPopupShow.Open,
|
|
45
|
+
});
|
|
41
46
|
popupInfo.content = content;
|
|
42
47
|
popupInfo.offset = Point.create(offset);
|
|
43
48
|
popupInfo.relativePosition = relativePosition;
|
|
44
49
|
popupInfo.renderRelativePosition = relativePosition;
|
|
45
50
|
popupInfo.priority = priority;
|
|
46
51
|
popupInfo.options = options;
|
|
52
|
+
CursorPopupManager.updatePosition(pt);
|
|
53
|
+
if (popupInfo.cancelFadeOut) {
|
|
54
|
+
popupInfo.cancelFadeOut();
|
|
55
|
+
popupInfo.cancelFadeOut = undefined;
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
CursorPopupManager.pushPopup(newPopupInfo);
|
|
59
|
-
}
|
|
59
|
+
const newPopupInfo = {
|
|
60
|
+
id,
|
|
61
|
+
content,
|
|
62
|
+
offset: Point.create(offset),
|
|
63
|
+
relativePosition,
|
|
64
|
+
options,
|
|
65
|
+
renderRelativePosition: relativePosition,
|
|
66
|
+
priority,
|
|
67
|
+
};
|
|
68
|
+
CursorPopupManager.pushPopup(newPopupInfo);
|
|
60
69
|
CursorPopupManager.updatePosition(pt);
|
|
61
70
|
}
|
|
62
71
|
/** Called to update popup with a new set of properties
|
|
@@ -85,26 +94,32 @@ export class CursorPopupManager {
|
|
|
85
94
|
*/
|
|
86
95
|
static close(id, apply, fadeOut) {
|
|
87
96
|
const popupInfo = CursorPopupManager._popups.find((info) => id === info.id);
|
|
88
|
-
if (popupInfo) {
|
|
89
|
-
if (popupInfo.options) {
|
|
90
|
-
if (apply && popupInfo.options.onApply)
|
|
91
|
-
popupInfo.options.onApply();
|
|
92
|
-
if (popupInfo.options.onClose)
|
|
93
|
-
popupInfo.options.onClose();
|
|
94
|
-
}
|
|
95
|
-
if (fadeOut) {
|
|
96
|
-
CursorPopupManager.onCursorPopupFadeOutEvent.emit({ id });
|
|
97
|
-
setTimeout(() => {
|
|
98
|
-
CursorPopupManager.removePopup(id);
|
|
99
|
-
}, CursorPopup.fadeOutTime);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
CursorPopupManager.removePopup(id);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
97
|
+
if (!popupInfo) {
|
|
106
98
|
Logger.logError(UiFramework.loggerCategory("CursorPopupManager"), `close: Could not find popup with id of '${id}'`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (apply)
|
|
102
|
+
popupInfo.options?.onApply?.();
|
|
103
|
+
popupInfo.options?.onClose?.();
|
|
104
|
+
if (fadeOut) {
|
|
105
|
+
// Already closing
|
|
106
|
+
if (popupInfo.cancelFadeOut)
|
|
107
|
+
return;
|
|
108
|
+
let cancelled = false;
|
|
109
|
+
popupInfo.cancelFadeOut = () => {
|
|
110
|
+
cancelled = true;
|
|
111
|
+
};
|
|
112
|
+
CursorPopupManager.onCursorPopupFadeOutEvent.emit({ id });
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
if (cancelled)
|
|
115
|
+
return;
|
|
116
|
+
CursorPopupManager.removePopup(id);
|
|
117
|
+
}, CursorPopup.fadeOutTime);
|
|
118
|
+
return;
|
|
107
119
|
}
|
|
120
|
+
popupInfo.cancelFadeOut?.();
|
|
121
|
+
popupInfo.cancelFadeOut = undefined;
|
|
122
|
+
CursorPopupManager.removePopup(id);
|
|
108
123
|
}
|
|
109
124
|
static removePopup(id) {
|
|
110
125
|
const index = CursorPopupManager._popups.findIndex((popupInfo) => id === popupInfo.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorPopupManager.js","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorpopup/CursorPopupManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA+B/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAa7B,gBAAgB;IACT,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,kBAAkB,CAAC,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAEM,MAAM,KAAK,MAAM;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,MAAM,KAAK,UAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAEO,MAAM,CAAC,uBAAuB;QACpC,kBAAkB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IAEO,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AC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;gBACnE,MAAM;QACV,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEe,iBAAiB;QAC/B,kBAAkB,CAAC,0BAA0B,CAAC,WAAW,CACvD,IAAI,CAAC,wBAAwB,CAC9B,CAAC;QACF,kBAAkB,CAAC,gCAAgC,CAAC,WAAW,CAC7D,IAAI,CAAC,qCAAqC,CAC3C,CAAC;IACJ,CAAC;IAEe,oBAAoB;QAClC,kBAAkB,CAAC,0BAA0B,CAAC,cAAc,CAC1D,IAAI,CAAC,wBAAwB,CAC9B,CAAC;QACF,kBAAkB,CAAC,gCAAgC,CAAC,cAAc,CAChE,IAAI,CAAC,qCAAqC,CAC3C,CAAC;IACJ,CAAC;CAaF","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 Cursor\n */\n\nimport * as React from \"react\";\nimport { BeUiEvent, Logger } from \"@itwin/core-bentley\";\nimport type { XAndY } from \"@itwin/core-geometry\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { ListenerType } from \"@itwin/core-react/internal\";\nimport { Point } from \"@itwin/core-react/internal\";\nimport { UiFramework } from \"../../UiFramework.js\";\nimport { CursorPopup } from \"./CursorPopup.js\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\nimport type { RectangleProps } from \"../../utils/RectangleProps.js\";\n\n/** Options for the [[CursorPopupManager]] open method\n * @public\n */\nexport interface CursorPopupOptions {\n /** Title of the popup */\n title?: string;\n /** Called on popup close */\n onClose?: () => void;\n /** Callback to apply changes */\n onApply?: () => void;\n /** Draw shadow */\n shadow?: boolean;\n}\n\n/** Information maintained by CursorPopupManager about a CursorPopup. */\ninterface CursorPopupInfo {\n id: string;\n content: React.ReactNode;\n relativePosition: RelativePosition;\n offset: Point;\n priority: number;\n options?: CursorPopupOptions;\n\n renderRelativePosition: RelativePosition;\n popupSize?: SizeProps;\n}\n\n/** CursorPopup component\n * @public\n */\nexport class CursorPopupManager {\n private static _popups: CursorPopupInfo[] = new Array<CursorPopupInfo>();\n\n /** @internal */\n public static readonly onCursorPopupUpdatePositionEvent = new BeUiEvent<{\n pt: XAndY;\n }>();\n /** @internal */\n public static readonly onCursorPopupFadeOutEvent = new BeUiEvent<{\n id: string;\n }>();\n /** @internal */\n public static readonly onCursorPopupsChangedEvent = new BeUiEvent<object>();\n /** @internal */\n public static clearPopups() {\n this._popups.length = 0;\n CursorPopupManager._emitPopupsChangedEvent();\n }\n\n public static get popups() {\n return this._popups;\n }\n\n public static get popupCount() {\n return this._popups.length;\n }\n\n private static _emitPopupsChangedEvent(): void {\n CursorPopupManager.onCursorPopupsChangedEvent.emit({});\n }\n\n private static pushPopup(popupInfo: CursorPopupInfo): void {\n CursorPopupManager._popups.push(popupInfo);\n CursorPopupManager._emitPopupsChangedEvent();\n }\n\n /** Called to open popup with a new set of properties\n */\n public static open(\n id: string,\n content: React.ReactNode,\n pt: XAndY,\n offset: XAndY,\n relativePosition: RelativePosition,\n priority: number = 0,\n options?: CursorPopupOptions\n ) {\n const popupInfo = CursorPopupManager._popups.find(\n (info: CursorPopupInfo) => id === info.id\n );\n if (popupInfo) {\n popupInfo.content = content;\n popupInfo.offset = Point.create(offset);\n popupInfo.relativePosition = relativePosition;\n popupInfo.renderRelativePosition = relativePosition;\n popupInfo.priority = priority;\n popupInfo.options = options;\n } else {\n const newPopupInfo: CursorPopupInfo = {\n id,\n content,\n offset: Point.create(offset),\n relativePosition,\n options,\n renderRelativePosition: relativePosition,\n priority,\n };\n CursorPopupManager.pushPopup(newPopupInfo);\n }\n\n CursorPopupManager.updatePosition(pt);\n }\n\n /** Called to update popup with a new set of properties\n */\n public static update(\n id: string,\n content: React.ReactNode,\n pt: XAndY,\n offset: XAndY,\n relativePosition: RelativePosition,\n priority: number = 0\n ) {\n const popupInfo = CursorPopupManager._popups.find(\n (info: CursorPopupInfo) => id === info.id\n );\n if (popupInfo) {\n popupInfo.content = content;\n popupInfo.offset = Point.create(offset);\n popupInfo.relativePosition = relativePosition;\n popupInfo.renderRelativePosition = relativePosition;\n popupInfo.priority = priority;\n } else {\n Logger.logError(\n UiFramework.loggerCategory(\"CursorPopupManager\"),\n `update: Could not find popup with id of '${id}'`\n );\n }\n\n CursorPopupManager.updatePosition(pt);\n }\n\n /** Called to move the open popup to new location\n */\n public static updatePosition(pt: XAndY) {\n CursorPopupManager.resetPopupsRenderRelativePosition(Point.create(pt));\n CursorPopupManager.onCursorPopupUpdatePositionEvent.emit({ pt });\n }\n\n /** Called when tool wants to close the popup\n */\n public static close(id: string, apply: boolean, fadeOut?: boolean) {\n const popupInfo = CursorPopupManager._popups.find(\n (info: CursorPopupInfo) => id === info.id\n );\n\n if (popupInfo) {\n if (popupInfo.options) {\n if (apply && popupInfo.options.onApply) popupInfo.options.onApply();\n\n if (popupInfo.options.onClose) popupInfo.options.onClose();\n }\n\n if (fadeOut) {\n CursorPopupManager.onCursorPopupFadeOutEvent.emit({ id });\n setTimeout(() => {\n CursorPopupManager.removePopup(id);\n }, CursorPopup.fadeOutTime);\n } else {\n CursorPopupManager.removePopup(id);\n }\n } else {\n Logger.logError(\n UiFramework.loggerCategory(\"CursorPopupManager\"),\n `close: Could not find popup with id of '${id}'`\n );\n }\n }\n\n private static removePopup(id: string): void {\n const index = CursorPopupManager._popups.findIndex(\n (popupInfo: CursorPopupInfo) => id === popupInfo.id\n );\n if (index >= 0) {\n CursorPopupManager._popups.splice(index, 1);\n CursorPopupManager._emitPopupsChangedEvent();\n }\n }\n\n private static resetPopupsRenderRelativePosition(pt: Point) {\n CursorPopupManager.popups.forEach((popupInfo: CursorPopupInfo) => {\n popupInfo.renderRelativePosition = popupInfo.relativePosition;\n\n const flipped = CursorPopupManager.validateRenderRelativePosition(\n pt,\n popupInfo\n );\n\n // If flipped, call again to validate again.\n if (flipped) {\n CursorPopupManager.validateRenderRelativePosition(pt, popupInfo);\n }\n });\n }\n\n private static validateRenderRelativePosition(\n pt: Point,\n popupInfo: CursorPopupInfo\n ): boolean {\n const popupRect = CursorPopup.getPopupRect(\n pt,\n Point.create(popupInfo.offset),\n popupInfo.popupSize,\n popupInfo.renderRelativePosition\n );\n const { outPos, flipped } = CursorPopupManager.autoFlip(\n popupInfo.renderRelativePosition,\n popupRect,\n window.innerWidth,\n window.innerHeight\n );\n\n if (flipped) popupInfo.renderRelativePosition = outPos;\n\n return flipped;\n }\n\n private static autoFlip(\n inPos: RelativePosition,\n rect: RectangleProps,\n windowWidth: number,\n windowHeight: number\n ): { outPos: RelativePosition; flipped: boolean } {\n let flipped = false;\n let outPos = inPos;\n\n if (rect.right > windowWidth) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Top:\n case RelativePosition.TopRight:\n outPos = RelativePosition.TopLeft;\n break;\n case RelativePosition.Right:\n outPos = RelativePosition.Left;\n break;\n case RelativePosition.Bottom:\n case RelativePosition.BottomRight:\n outPos = RelativePosition.BottomLeft;\n break;\n }\n }\n\n if (rect.left < 0) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Top:\n case RelativePosition.TopLeft:\n outPos = RelativePosition.TopRight;\n break;\n case RelativePosition.Left:\n outPos = RelativePosition.Right;\n break;\n case RelativePosition.Bottom:\n case RelativePosition.BottomLeft:\n outPos = RelativePosition.BottomRight;\n break;\n }\n }\n\n if (rect.bottom > windowHeight) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Left:\n case RelativePosition.BottomLeft:\n outPos = RelativePosition.TopLeft;\n break;\n case RelativePosition.Bottom:\n outPos = RelativePosition.Top;\n break;\n case RelativePosition.Right:\n case RelativePosition.BottomRight:\n outPos = RelativePosition.TopRight;\n break;\n }\n }\n\n if (rect.top < 0) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Left:\n case RelativePosition.TopLeft:\n outPos = RelativePosition.BottomLeft;\n break;\n case RelativePosition.Top:\n outPos = RelativePosition.Bottom;\n break;\n case RelativePosition.Right:\n case RelativePosition.TopRight:\n outPos = RelativePosition.BottomRight;\n break;\n }\n }\n\n return { outPos, flipped };\n }\n}\n\n/** State for the [[CursorPopupRenderer]] React component */\ninterface CursorPopupRendererState {\n pt: Point;\n}\n\n/** CursorPopupRenderer React component.\n * @public\n */\nexport class CursorPopupRenderer extends React.Component<\n any,\n CursorPopupRendererState\n> {\n constructor(props: any) {\n super(props);\n\n this.state = {\n pt: new Point(),\n };\n }\n\n public override render(): React.ReactNode {\n if (CursorPopupManager.popupCount <= 0) return null;\n\n return <>{this.renderPositions()}</>;\n }\n\n private _handleSizeKnown(popupInfo: CursorPopupInfo, size: SizeProps) {\n popupInfo.popupSize = size;\n }\n\n private renderPositions(): React.ReactNode[] {\n const positions = new Array<React.ReactNode>();\n let renderedPosition: React.ReactNode;\n const begin = RelativePosition.Left;\n const end = RelativePosition.BottomRight;\n\n for (let position = begin; position <= end; position++) {\n renderedPosition = this.renderRelativePosition(position);\n if (renderedPosition) positions.push(renderedPosition);\n }\n\n return positions;\n }\n\n private renderRelativePosition(\n relativePosition: RelativePosition\n ): React.ReactNode {\n const filteredInfo = CursorPopupManager.popups.filter(\n (popupInfo: CursorPopupInfo) =>\n popupInfo.renderRelativePosition === relativePosition\n );\n\n if (filteredInfo.length > 0) {\n let totalDimension = 0;\n const ascending =\n relativePosition === RelativePosition.Right ||\n relativePosition === RelativePosition.BottomRight ||\n relativePosition === RelativePosition.Bottom ||\n relativePosition === RelativePosition.BottomLeft;\n\n const positionPopups = filteredInfo\n .sort((a: CursorPopupInfo, b: CursorPopupInfo): number =>\n ascending ? a.priority - b.priority : b.priority - a.priority\n )\n .map((popupInfo: CursorPopupInfo, index: number) => {\n const title =\n popupInfo.options !== undefined ? popupInfo.options.title : \"\";\n const shadow =\n popupInfo.options !== undefined ? popupInfo.options.shadow : false;\n let offset = popupInfo.offset;\n\n if (index > 0)\n offset = this.adjustOffset(\n offset,\n popupInfo.renderRelativePosition,\n totalDimension\n );\n\n if (popupInfo.popupSize)\n totalDimension += this.getDimension(\n popupInfo.popupSize,\n relativePosition\n );\n\n return (\n <CursorPopup\n key={popupInfo.id}\n id={popupInfo.id}\n content={popupInfo.content}\n pt={this.state.pt}\n offset={offset}\n relativePosition={popupInfo.renderRelativePosition}\n title={title}\n shadow={shadow}\n onSizeKnown={(size: SizeProps) =>\n this._handleSizeKnown(popupInfo, size)\n }\n />\n );\n });\n\n return (\n <React.Fragment key={relativePosition.toString()}>\n {positionPopups}\n </React.Fragment>\n );\n }\n\n return null;\n }\n\n private getDimension(\n popupSize: SizeProps,\n relativePosition: RelativePosition\n ): number {\n let dimension = 0;\n\n switch (relativePosition) {\n case RelativePosition.Top:\n case RelativePosition.Bottom:\n case RelativePosition.TopLeft:\n case RelativePosition.TopRight:\n case RelativePosition.BottomLeft:\n case RelativePosition.BottomRight:\n dimension = popupSize.height;\n break;\n case RelativePosition.Left:\n case RelativePosition.Right:\n dimension = popupSize.width;\n break;\n }\n\n return dimension;\n }\n\n private adjustOffset(\n offset: Point,\n relativePosition: RelativePosition,\n dimension: number\n ): Point {\n let outOffset = Point.create(offset.toProps());\n\n switch (relativePosition) {\n case RelativePosition.Top:\n case RelativePosition.Bottom:\n case RelativePosition.TopLeft:\n case RelativePosition.TopRight:\n case RelativePosition.BottomLeft:\n case RelativePosition.BottomRight:\n outOffset = Point.create({ x: offset.x, y: offset.y + dimension });\n break;\n case RelativePosition.Left:\n case RelativePosition.Right:\n outOffset = Point.create({ x: offset.x + dimension, y: offset.y });\n break;\n }\n\n return outOffset;\n }\n\n public override componentDidMount(): void {\n CursorPopupManager.onCursorPopupsChangedEvent.addListener(\n this._handlePopupChangedEvent\n );\n CursorPopupManager.onCursorPopupUpdatePositionEvent.addListener(\n this._handleCursorPopupUpdatePositionEvent\n );\n }\n\n public override componentWillUnmount(): void {\n CursorPopupManager.onCursorPopupsChangedEvent.removeListener(\n this._handlePopupChangedEvent\n );\n CursorPopupManager.onCursorPopupUpdatePositionEvent.removeListener(\n this._handleCursorPopupUpdatePositionEvent\n );\n }\n\n private _handlePopupChangedEvent: ListenerType<\n typeof CursorPopupManager.onCursorPopupsChangedEvent\n > = () => {\n this.forceUpdate();\n };\n\n private _handleCursorPopupUpdatePositionEvent: ListenerType<\n typeof CursorPopupManager.onCursorPopupUpdatePositionEvent\n > = (args) => {\n this.setState({ pt: Point.create(args.pt) });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CursorPopupManager.js","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorpopup/CursorPopupManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAiC/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAc7B,gBAAgB;IACT,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,kBAAkB,CAAC,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAEM,MAAM,KAAK,MAAM;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,MAAM,KAAK,UAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAEO,MAAM,CAAC,uBAAuB;QACpC,kBAAkB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;I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C9B,KAAK,gBAAgB,CAAC,QAAQ,CAAC;YAC/B,KAAK,gBAAgB,CAAC,UAAU,CAAC;YACjC,KAAK,gBAAgB,CAAC,WAAW;gBAC/B,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC;gBACnE,MAAM;YACR,KAAK,gBAAgB,CAAC,IAAI,CAAC;YAC3B,KAAK,gBAAgB,CAAC,KAAK;gBACzB,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;gBACnE,MAAM;QACV,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEe,iBAAiB;QAC/B,kBAAkB,CAAC,0BAA0B,CAAC,WAAW,CACvD,IAAI,CAAC,wBAAwB,CAC9B,CAAC;QACF,kBAAkB,CAAC,gCAAgC,CAAC,WAAW,CAC7D,IAAI,CAAC,qCAAqC,CAC3C,CAAC;IACJ,CAAC;IAEe,oBAAoB;QAClC,kBAAkB,CAAC,0BAA0B,CAAC,cAAc,CAC1D,IAAI,CAAC,wBAAwB,CAC9B,CAAC;QACF,kBAAkB,CAAC,gCAAgC,CAAC,cAAc,CAChE,IAAI,CAAC,qCAAqC,CAC3C,CAAC;IACJ,CAAC;CAaF","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 Cursor\n */\n\nimport * as React from \"react\";\nimport { BeUiEvent, Logger } from \"@itwin/core-bentley\";\nimport type { XAndY } from \"@itwin/core-geometry\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { ListenerType } from \"@itwin/core-react/internal\";\nimport { Point } from \"@itwin/core-react/internal\";\nimport { UiFramework } from \"../../UiFramework.js\";\nimport { CursorPopupShow } from \"./CursorPopup.js\";\nimport { CursorPopup } from \"./CursorPopup.js\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\nimport type { RectangleProps } from \"../../utils/RectangleProps.js\";\n\n/** Options for the [[CursorPopupManager]] open method\n * @public\n */\nexport interface CursorPopupOptions {\n /** Title of the popup */\n title?: string;\n /** Called on popup close */\n onClose?: () => void;\n /** Callback to apply changes */\n onApply?: () => void;\n /** Draw shadow */\n shadow?: boolean;\n}\n\n/** Information maintained by CursorPopupManager about a CursorPopup. */\ninterface CursorPopupInfo {\n id: string;\n content: React.ReactNode;\n relativePosition: RelativePosition;\n offset: Point;\n priority: number;\n options?: CursorPopupOptions;\n\n renderRelativePosition: RelativePosition;\n popupSize?: SizeProps;\n\n cancelFadeOut?: () => void;\n}\n\n/** CursorPopup component\n * @public\n */\nexport class CursorPopupManager {\n private static _popups: CursorPopupInfo[] = new Array<CursorPopupInfo>();\n\n /** @internal */\n public static readonly onCursorPopupUpdatePositionEvent = new BeUiEvent<{\n pt: XAndY;\n }>();\n /** @internal */\n public static readonly onCursorPopupFadeOutEvent = new BeUiEvent<{\n id: string;\n show?: CursorPopupShow;\n }>();\n /** @internal */\n public static readonly onCursorPopupsChangedEvent = new BeUiEvent<object>();\n /** @internal */\n public static clearPopups() {\n this._popups.length = 0;\n CursorPopupManager._emitPopupsChangedEvent();\n }\n\n public static get popups() {\n return this._popups;\n }\n\n public static get popupCount() {\n return this._popups.length;\n }\n\n private static _emitPopupsChangedEvent(): void {\n CursorPopupManager.onCursorPopupsChangedEvent.emit({});\n }\n\n private static pushPopup(popupInfo: CursorPopupInfo): void {\n CursorPopupManager._popups.push(popupInfo);\n CursorPopupManager._emitPopupsChangedEvent();\n }\n\n /** Called to open popup with a new set of properties\n */\n public static open(\n id: string,\n content: React.ReactNode,\n pt: XAndY,\n offset: XAndY,\n relativePosition: RelativePosition,\n priority: number = 0,\n options?: CursorPopupOptions\n ) {\n const popupInfo = CursorPopupManager._popups.find(\n (info: CursorPopupInfo) => id === info.id\n );\n if (popupInfo) {\n CursorPopupManager.onCursorPopupFadeOutEvent.emit({\n id,\n show: CursorPopupShow.Open,\n });\n\n popupInfo.content = content;\n popupInfo.offset = Point.create(offset);\n popupInfo.relativePosition = relativePosition;\n popupInfo.renderRelativePosition = relativePosition;\n popupInfo.priority = priority;\n popupInfo.options = options;\n CursorPopupManager.updatePosition(pt);\n\n if (popupInfo.cancelFadeOut) {\n popupInfo.cancelFadeOut();\n popupInfo.cancelFadeOut = undefined;\n }\n return;\n }\n\n const newPopupInfo: CursorPopupInfo = {\n id,\n content,\n offset: Point.create(offset),\n relativePosition,\n options,\n renderRelativePosition: relativePosition,\n priority,\n };\n CursorPopupManager.pushPopup(newPopupInfo);\n CursorPopupManager.updatePosition(pt);\n }\n\n /** Called to update popup with a new set of properties\n */\n public static update(\n id: string,\n content: React.ReactNode,\n pt: XAndY,\n offset: XAndY,\n relativePosition: RelativePosition,\n priority: number = 0\n ) {\n const popupInfo = CursorPopupManager._popups.find(\n (info: CursorPopupInfo) => id === info.id\n );\n if (popupInfo) {\n popupInfo.content = content;\n popupInfo.offset = Point.create(offset);\n popupInfo.relativePosition = relativePosition;\n popupInfo.renderRelativePosition = relativePosition;\n popupInfo.priority = priority;\n } else {\n Logger.logError(\n UiFramework.loggerCategory(\"CursorPopupManager\"),\n `update: Could not find popup with id of '${id}'`\n );\n }\n\n CursorPopupManager.updatePosition(pt);\n }\n\n /** Called to move the open popup to new location\n */\n public static updatePosition(pt: XAndY) {\n CursorPopupManager.resetPopupsRenderRelativePosition(Point.create(pt));\n CursorPopupManager.onCursorPopupUpdatePositionEvent.emit({ pt });\n }\n\n /** Called when tool wants to close the popup\n */\n public static close(id: string, apply: boolean, fadeOut?: boolean) {\n const popupInfo = CursorPopupManager._popups.find(\n (info: CursorPopupInfo) => id === info.id\n );\n if (!popupInfo) {\n Logger.logError(\n UiFramework.loggerCategory(\"CursorPopupManager\"),\n `close: Could not find popup with id of '${id}'`\n );\n return;\n }\n\n if (apply) popupInfo.options?.onApply?.();\n popupInfo.options?.onClose?.();\n\n if (fadeOut) {\n // Already closing\n if (popupInfo.cancelFadeOut) return;\n\n let cancelled = false;\n popupInfo.cancelFadeOut = () => {\n cancelled = true;\n };\n CursorPopupManager.onCursorPopupFadeOutEvent.emit({ id });\n\n setTimeout(() => {\n if (cancelled) return;\n CursorPopupManager.removePopup(id);\n }, CursorPopup.fadeOutTime);\n return;\n }\n\n popupInfo.cancelFadeOut?.();\n popupInfo.cancelFadeOut = undefined;\n CursorPopupManager.removePopup(id);\n }\n\n private static removePopup(id: string): void {\n const index = CursorPopupManager._popups.findIndex(\n (popupInfo: CursorPopupInfo) => id === popupInfo.id\n );\n if (index >= 0) {\n CursorPopupManager._popups.splice(index, 1);\n CursorPopupManager._emitPopupsChangedEvent();\n }\n }\n\n private static resetPopupsRenderRelativePosition(pt: Point) {\n CursorPopupManager.popups.forEach((popupInfo: CursorPopupInfo) => {\n popupInfo.renderRelativePosition = popupInfo.relativePosition;\n\n const flipped = CursorPopupManager.validateRenderRelativePosition(\n pt,\n popupInfo\n );\n\n // If flipped, call again to validate again.\n if (flipped) {\n CursorPopupManager.validateRenderRelativePosition(pt, popupInfo);\n }\n });\n }\n\n private static validateRenderRelativePosition(\n pt: Point,\n popupInfo: CursorPopupInfo\n ): boolean {\n const popupRect = CursorPopup.getPopupRect(\n pt,\n Point.create(popupInfo.offset),\n popupInfo.popupSize,\n popupInfo.renderRelativePosition\n );\n const { outPos, flipped } = CursorPopupManager.autoFlip(\n popupInfo.renderRelativePosition,\n popupRect,\n window.innerWidth,\n window.innerHeight\n );\n\n if (flipped) popupInfo.renderRelativePosition = outPos;\n\n return flipped;\n }\n\n private static autoFlip(\n inPos: RelativePosition,\n rect: RectangleProps,\n windowWidth: number,\n windowHeight: number\n ): { outPos: RelativePosition; flipped: boolean } {\n let flipped = false;\n let outPos = inPos;\n\n if (rect.right > windowWidth) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Top:\n case RelativePosition.TopRight:\n outPos = RelativePosition.TopLeft;\n break;\n case RelativePosition.Right:\n outPos = RelativePosition.Left;\n break;\n case RelativePosition.Bottom:\n case RelativePosition.BottomRight:\n outPos = RelativePosition.BottomLeft;\n break;\n }\n }\n\n if (rect.left < 0) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Top:\n case RelativePosition.TopLeft:\n outPos = RelativePosition.TopRight;\n break;\n case RelativePosition.Left:\n outPos = RelativePosition.Right;\n break;\n case RelativePosition.Bottom:\n case RelativePosition.BottomLeft:\n outPos = RelativePosition.BottomRight;\n break;\n }\n }\n\n if (rect.bottom > windowHeight) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Left:\n case RelativePosition.BottomLeft:\n outPos = RelativePosition.TopLeft;\n break;\n case RelativePosition.Bottom:\n outPos = RelativePosition.Top;\n break;\n case RelativePosition.Right:\n case RelativePosition.BottomRight:\n outPos = RelativePosition.TopRight;\n break;\n }\n }\n\n if (rect.top < 0) {\n flipped = true;\n switch (inPos) {\n case RelativePosition.Left:\n case RelativePosition.TopLeft:\n outPos = RelativePosition.BottomLeft;\n break;\n case RelativePosition.Top:\n outPos = RelativePosition.Bottom;\n break;\n case RelativePosition.Right:\n case RelativePosition.TopRight:\n outPos = RelativePosition.BottomRight;\n break;\n }\n }\n\n return { outPos, flipped };\n }\n}\n\n/** State for the [[CursorPopupRenderer]] React component */\ninterface CursorPopupRendererState {\n pt: Point;\n}\n\n/** CursorPopupRenderer React component.\n * @public\n */\nexport class CursorPopupRenderer extends React.Component<\n any,\n CursorPopupRendererState\n> {\n constructor(props: any) {\n super(props);\n\n this.state = {\n pt: new Point(),\n };\n }\n\n public override render(): React.ReactNode {\n if (CursorPopupManager.popupCount <= 0) return null;\n\n return <>{this.renderPositions()}</>;\n }\n\n private _handleSizeKnown(popupInfo: CursorPopupInfo, size: SizeProps) {\n popupInfo.popupSize = size;\n }\n\n private renderPositions(): React.ReactNode[] {\n const positions = new Array<React.ReactNode>();\n let renderedPosition: React.ReactNode;\n const begin = RelativePosition.Left;\n const end = RelativePosition.BottomRight;\n\n for (let position = begin; position <= end; position++) {\n renderedPosition = this.renderRelativePosition(position);\n if (renderedPosition) positions.push(renderedPosition);\n }\n\n return positions;\n }\n\n private renderRelativePosition(\n relativePosition: RelativePosition\n ): React.ReactNode {\n const filteredInfo = CursorPopupManager.popups.filter(\n (popupInfo: CursorPopupInfo) =>\n popupInfo.renderRelativePosition === relativePosition\n );\n\n if (filteredInfo.length > 0) {\n let totalDimension = 0;\n const ascending =\n relativePosition === RelativePosition.Right ||\n relativePosition === RelativePosition.BottomRight ||\n relativePosition === RelativePosition.Bottom ||\n relativePosition === RelativePosition.BottomLeft;\n\n const positionPopups = filteredInfo\n .sort((a: CursorPopupInfo, b: CursorPopupInfo): number =>\n ascending ? a.priority - b.priority : b.priority - a.priority\n )\n .map((popupInfo: CursorPopupInfo, index: number) => {\n const title =\n popupInfo.options !== undefined ? popupInfo.options.title : \"\";\n const shadow =\n popupInfo.options !== undefined ? popupInfo.options.shadow : false;\n let offset = popupInfo.offset;\n\n if (index > 0)\n offset = this.adjustOffset(\n offset,\n popupInfo.renderRelativePosition,\n totalDimension\n );\n\n if (popupInfo.popupSize)\n totalDimension += this.getDimension(\n popupInfo.popupSize,\n relativePosition\n );\n\n return (\n <CursorPopup\n key={popupInfo.id}\n id={popupInfo.id}\n content={popupInfo.content}\n pt={this.state.pt}\n offset={offset}\n relativePosition={popupInfo.renderRelativePosition}\n title={title}\n shadow={shadow}\n onSizeKnown={(size: SizeProps) =>\n this._handleSizeKnown(popupInfo, size)\n }\n />\n );\n });\n\n return (\n <React.Fragment key={relativePosition.toString()}>\n {positionPopups}\n </React.Fragment>\n );\n }\n\n return null;\n }\n\n private getDimension(\n popupSize: SizeProps,\n relativePosition: RelativePosition\n ): number {\n let dimension = 0;\n\n switch (relativePosition) {\n case RelativePosition.Top:\n case RelativePosition.Bottom:\n case RelativePosition.TopLeft:\n case RelativePosition.TopRight:\n case RelativePosition.BottomLeft:\n case RelativePosition.BottomRight:\n dimension = popupSize.height;\n break;\n case RelativePosition.Left:\n case RelativePosition.Right:\n dimension = popupSize.width;\n break;\n }\n\n return dimension;\n }\n\n private adjustOffset(\n offset: Point,\n relativePosition: RelativePosition,\n dimension: number\n ): Point {\n let outOffset = Point.create(offset.toProps());\n\n switch (relativePosition) {\n case RelativePosition.Top:\n case RelativePosition.Bottom:\n case RelativePosition.TopLeft:\n case RelativePosition.TopRight:\n case RelativePosition.BottomLeft:\n case RelativePosition.BottomRight:\n outOffset = Point.create({ x: offset.x, y: offset.y + dimension });\n break;\n case RelativePosition.Left:\n case RelativePosition.Right:\n outOffset = Point.create({ x: offset.x + dimension, y: offset.y });\n break;\n }\n\n return outOffset;\n }\n\n public override componentDidMount(): void {\n CursorPopupManager.onCursorPopupsChangedEvent.addListener(\n this._handlePopupChangedEvent\n );\n CursorPopupManager.onCursorPopupUpdatePositionEvent.addListener(\n this._handleCursorPopupUpdatePositionEvent\n );\n }\n\n public override componentWillUnmount(): void {\n CursorPopupManager.onCursorPopupsChangedEvent.removeListener(\n this._handlePopupChangedEvent\n );\n CursorPopupManager.onCursorPopupUpdatePositionEvent.removeListener(\n this._handleCursorPopupUpdatePositionEvent\n );\n }\n\n private _handlePopupChangedEvent: ListenerType<\n typeof CursorPopupManager.onCursorPopupsChangedEvent\n > = () => {\n this.forceUpdate();\n };\n\n private _handleCursorPopupUpdatePositionEvent: ListenerType<\n typeof CursorPopupManager.onCursorPopupUpdatePositionEvent\n > = (args) => {\n this.setState({ pt: Point.create(args.pt) });\n };\n}\n"]}
|
|
@@ -2,23 +2,20 @@
|
|
|
2
2
|
* @module Notification
|
|
3
3
|
*/
|
|
4
4
|
import "./CursorPrompt.scss";
|
|
5
|
-
import type { ToolAssistanceInstruction } from "@itwin/core-frontend";
|
|
6
|
-
import type { XAndY } from "@itwin/core-geometry";
|
|
7
|
-
import { RelativePosition } from "@itwin/appui-abstract";
|
|
8
5
|
/** @internal */
|
|
9
6
|
export declare class CursorPrompt {
|
|
10
|
-
private _timeOut;
|
|
11
|
-
private _fadeOut;
|
|
12
|
-
private _timer;
|
|
13
|
-
private _relativePosition;
|
|
14
|
-
private _offset;
|
|
15
7
|
private _popupId;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
private _timer;
|
|
9
|
+
private _removeListeners;
|
|
10
|
+
open({ timeout, fadeout, iconSpec, instruction, promptAtContent, }: {
|
|
11
|
+
timeout: number;
|
|
12
|
+
fadeout: boolean;
|
|
13
|
+
iconSpec: string;
|
|
14
|
+
instruction: string;
|
|
15
|
+
promptAtContent: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
close(fadeout: boolean): void;
|
|
18
|
+
private show;
|
|
19
|
+
private hide;
|
|
23
20
|
}
|
|
24
21
|
//# sourceMappingURL=CursorPrompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorPrompt.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorprompt/CursorPrompt.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"CursorPrompt.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/cursor/cursorprompt/CursorPrompt.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAY7B,gBAAgB;AAChB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAmB;IAEnC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,gBAAgB,CAA2B;IAE5C,IAAI,CAAC,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,WAAW,EACX,eAAe,GAChB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;KAC1B;IAmCM,KAAK,CAAC,OAAO,EAAE,OAAO;IAS7B,OAAO,CAAC,IAAI;IAgCZ,OAAO,CAAC,IAAI;CAGb"}
|