@itwin/core-react 4.12.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -1
- package/lib/cjs/core-react/autosuggest/AutoSuggest.d.ts +1 -1
- package/lib/cjs/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
- package/lib/cjs/core-react/autosuggest/AutoSuggest.js +2 -2
- package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
- package/lib/cjs/core-react/base/Centered.d.ts +1 -0
- package/lib/cjs/core-react/base/Centered.d.ts.map +1 -1
- package/lib/cjs/core-react/base/Centered.js +2 -0
- package/lib/cjs/core-react/base/Centered.js.map +1 -1
- package/lib/cjs/core-react/base/Div.d.ts +2 -0
- package/lib/cjs/core-react/base/Div.d.ts.map +1 -1
- package/lib/cjs/core-react/base/Div.js +2 -0
- package/lib/cjs/core-react/base/Div.js.map +1 -1
- package/lib/cjs/core-react/base/DivWithOutsideClick.d.ts +1 -0
- package/lib/cjs/core-react/base/DivWithOutsideClick.d.ts.map +1 -1
- package/lib/cjs/core-react/base/DivWithOutsideClick.js +1 -0
- package/lib/cjs/core-react/base/DivWithOutsideClick.js.map +1 -1
- package/lib/cjs/core-react/base/FillCentered.d.ts +1 -0
- package/lib/cjs/core-react/base/FillCentered.d.ts.map +1 -1
- package/lib/cjs/core-react/base/FillCentered.js +2 -0
- package/lib/cjs/core-react/base/FillCentered.js.map +1 -1
- package/lib/cjs/core-react/base/FlexWrapContainer.d.ts +1 -0
- package/lib/cjs/core-react/base/FlexWrapContainer.d.ts.map +1 -1
- package/lib/cjs/core-react/base/FlexWrapContainer.js +2 -0
- package/lib/cjs/core-react/base/FlexWrapContainer.js.map +1 -1
- package/lib/cjs/core-react/base/Gap.d.ts +2 -0
- package/lib/cjs/core-react/base/Gap.d.ts.map +1 -1
- package/lib/cjs/core-react/base/Gap.js +3 -1
- package/lib/cjs/core-react/base/Gap.js.map +1 -1
- package/lib/cjs/core-react/base/ScrollView.d.ts +1 -0
- package/lib/cjs/core-react/base/ScrollView.d.ts.map +1 -1
- package/lib/cjs/core-react/base/ScrollView.js +2 -0
- package/lib/cjs/core-react/base/ScrollView.js.map +1 -1
- package/lib/cjs/core-react/button/UnderlinedButton.d.ts +2 -0
- package/lib/cjs/core-react/button/UnderlinedButton.d.ts.map +1 -1
- package/lib/cjs/core-react/button/UnderlinedButton.js +2 -0
- package/lib/cjs/core-react/button/UnderlinedButton.js.map +1 -1
- package/lib/cjs/core-react/checklistbox/CheckListBox.d.ts +4 -0
- package/lib/cjs/core-react/checklistbox/CheckListBox.d.ts.map +1 -1
- package/lib/cjs/core-react/checklistbox/CheckListBox.js +4 -0
- package/lib/cjs/core-react/checklistbox/CheckListBox.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.js +1 -2
- package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +3 -5
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.d.ts +3 -0
- package/lib/cjs/core-react/dialog/Dialog.d.ts.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.js +17 -3
- package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
- package/lib/cjs/core-react/dialog/GlobalDialog.d.ts +3 -0
- package/lib/cjs/core-react/dialog/GlobalDialog.d.ts.map +1 -1
- package/lib/cjs/core-react/dialog/GlobalDialog.js +7 -3
- package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/cjs/core-react/elementseparator/ElementSeparator.d.ts +4 -2
- package/lib/cjs/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js +4 -2
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/cjs/core-react/expandable/ExpandableList.d.ts +3 -3
- package/lib/cjs/core-react/expandable/ExpandableList.d.ts.map +1 -1
- package/lib/cjs/core-react/expandable/ExpandableList.js +5 -2
- package/lib/cjs/core-react/expandable/ExpandableList.js.map +1 -1
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js +1 -2
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.d.ts.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js +22 -12
- package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
- package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.d.ts +3 -2
- package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.d.ts.map +1 -1
- package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js +3 -2
- package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
- package/lib/cjs/core-react/inputs/InputLabel.d.ts +2 -0
- package/lib/cjs/core-react/inputs/InputLabel.d.ts.map +1 -1
- package/lib/cjs/core-react/inputs/InputLabel.js +5 -0
- package/lib/cjs/core-react/inputs/InputLabel.js.map +1 -1
- package/lib/cjs/core-react/inputs/InputStatus.d.ts +1 -0
- package/lib/cjs/core-react/inputs/InputStatus.d.ts.map +1 -1
- package/lib/cjs/core-react/inputs/InputStatus.js +1 -0
- package/lib/cjs/core-react/inputs/InputStatus.js.map +1 -1
- package/lib/cjs/core-react/inputs/LabeledComponentProps.d.ts +2 -0
- package/lib/cjs/core-react/inputs/LabeledComponentProps.d.ts.map +1 -1
- package/lib/cjs/core-react/inputs/LabeledComponentProps.js.map +1 -1
- package/lib/cjs/core-react/inputs/iconinput/IconInput.d.ts +2 -0
- package/lib/cjs/core-react/inputs/iconinput/IconInput.d.ts.map +1 -1
- package/lib/cjs/core-react/inputs/iconinput/IconInput.js +3 -0
- package/lib/cjs/core-react/inputs/iconinput/IconInput.js.map +1 -1
- package/lib/cjs/core-react/inputs/numberinput/NumberInput.d.ts +3 -0
- package/lib/cjs/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
- package/lib/cjs/core-react/inputs/numberinput/NumberInput.js +1 -0
- package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
- package/lib/cjs/core-react/l10n/usePackageTranslation.js +1 -1
- package/lib/cjs/core-react/l10n/usePackageTranslation.js.map +1 -1
- package/lib/cjs/core-react/listbox/Listbox.d.ts +14 -14
- package/lib/cjs/core-react/listbox/Listbox.d.ts.map +1 -1
- package/lib/cjs/core-react/listbox/Listbox.js +8 -10
- package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingBar.d.ts +3 -2
- package/lib/cjs/core-react/loading/LoadingBar.d.ts.map +1 -1
- package/lib/cjs/core-react/loading/LoadingBar.js +2 -2
- package/lib/cjs/core-react/loading/LoadingBar.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingPrompt.d.ts +3 -2
- package/lib/cjs/core-react/loading/LoadingPrompt.d.ts.map +1 -1
- package/lib/cjs/core-react/loading/LoadingPrompt.js +2 -2
- package/lib/cjs/core-react/loading/LoadingPrompt.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingSpinner.d.ts +4 -2
- package/lib/cjs/core-react/loading/LoadingSpinner.d.ts.map +1 -1
- package/lib/cjs/core-react/loading/LoadingSpinner.js +2 -2
- package/lib/cjs/core-react/loading/LoadingSpinner.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingStatus.d.ts +3 -2
- package/lib/cjs/core-react/loading/LoadingStatus.d.ts.map +1 -1
- package/lib/cjs/core-react/loading/LoadingStatus.js +2 -2
- package/lib/cjs/core-react/loading/LoadingStatus.js.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.d.ts.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.js +3 -1
- package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/cjs/core-react/popup/Popup.js +4 -8
- package/lib/cjs/core-react/popup/Popup.js.map +1 -1
- package/lib/cjs/core-react/radialmenu/Annulus.d.ts +7 -8
- package/lib/cjs/core-react/radialmenu/Annulus.d.ts.map +1 -1
- package/lib/cjs/core-react/radialmenu/Annulus.js +7 -8
- package/lib/cjs/core-react/radialmenu/Annulus.js.map +1 -1
- package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts +0 -1
- package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
- package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/cjs/core-react/searchbox/SearchBox.d.ts +3 -3
- package/lib/cjs/core-react/searchbox/SearchBox.d.ts.map +1 -1
- package/lib/cjs/core-react/searchbox/SearchBox.js +2 -2
- package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
- package/lib/cjs/core-react/settings/SettingsContainer.d.ts.map +1 -1
- package/lib/cjs/core-react/settings/SettingsContainer.js +8 -4
- package/lib/cjs/core-react/settings/SettingsContainer.js.map +1 -1
- package/lib/cjs/core-react/settings/SettingsManager.d.ts +10 -7
- package/lib/cjs/core-react/settings/SettingsManager.d.ts.map +1 -1
- package/lib/cjs/core-react/settings/SettingsManager.js +14 -12
- package/lib/cjs/core-react/settings/SettingsManager.js.map +1 -1
- package/lib/cjs/core-react/tabs/Tabs.d.ts +5 -5
- package/lib/cjs/core-react/tabs/Tabs.d.ts.map +1 -1
- package/lib/cjs/core-react/tabs/Tabs.js +1 -0
- package/lib/cjs/core-react/tabs/Tabs.js.map +1 -1
- package/lib/cjs/core-react/tabs/VerticalTabs.d.ts +1 -0
- package/lib/cjs/core-react/tabs/VerticalTabs.d.ts.map +1 -1
- package/lib/cjs/core-react/tabs/VerticalTabs.js +2 -0
- package/lib/cjs/core-react/tabs/VerticalTabs.js.map +1 -1
- package/lib/cjs/core-react/text/BlockText.d.ts +1 -0
- package/lib/cjs/core-react/text/BlockText.d.ts.map +1 -1
- package/lib/cjs/core-react/text/BlockText.js +2 -0
- package/lib/cjs/core-react/text/BlockText.js.map +1 -1
- package/lib/cjs/core-react/text/BodyText.d.ts +1 -1
- package/lib/cjs/core-react/text/BodyText.d.ts.map +1 -1
- package/lib/cjs/core-react/text/BodyText.js +2 -1
- package/lib/cjs/core-react/text/BodyText.js.map +1 -1
- package/lib/cjs/core-react/text/DisabledText.d.ts +1 -0
- package/lib/cjs/core-react/text/DisabledText.d.ts.map +1 -1
- package/lib/cjs/core-react/text/DisabledText.js +2 -1
- package/lib/cjs/core-react/text/DisabledText.js.map +1 -1
- package/lib/cjs/core-react/text/MutedText.d.ts.map +1 -1
- package/lib/cjs/core-react/text/MutedText.js +1 -0
- package/lib/cjs/core-react/text/MutedText.js.map +1 -1
- package/lib/cjs/core-react/text/StyledText.d.ts +1 -0
- package/lib/cjs/core-react/text/StyledText.d.ts.map +1 -1
- package/lib/cjs/core-react/text/StyledText.js.map +1 -1
- package/lib/cjs/core-react/text/TextProps.d.ts +1 -0
- package/lib/cjs/core-react/text/TextProps.d.ts.map +1 -1
- package/lib/cjs/core-react/text/TextProps.js.map +1 -1
- package/lib/cjs/core-react/tree/ExpansionToggle.d.ts.map +1 -1
- package/lib/cjs/core-react/tree/ExpansionToggle.js +1 -1
- package/lib/cjs/core-react/tree/ExpansionToggle.js.map +1 -1
- package/lib/cjs/core-react/tree/Node.js +1 -2
- package/lib/cjs/core-react/tree/Node.js.map +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/cjs/core-react/utils/getCssVariable.js +1 -1
- package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
- package/lib/cjs/core-react/utils/getObjectClassName.js +2 -3
- package/lib/cjs/core-react/utils/getObjectClassName.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.d.ts +4 -1
- package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.d.ts.map +1 -1
- package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.js +5 -2
- package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.d.ts +1 -1
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +2 -3
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +12 -16
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/lib/esm/core-react/autosuggest/AutoSuggest.d.ts +1 -1
- package/lib/esm/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
- package/lib/esm/core-react/autosuggest/AutoSuggest.js +1 -1
- package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
- package/lib/esm/core-react/base/Centered.d.ts +1 -0
- package/lib/esm/core-react/base/Centered.d.ts.map +1 -1
- package/lib/esm/core-react/base/Centered.js +2 -0
- package/lib/esm/core-react/base/Centered.js.map +1 -1
- package/lib/esm/core-react/base/Div.d.ts +2 -0
- package/lib/esm/core-react/base/Div.d.ts.map +1 -1
- package/lib/esm/core-react/base/Div.js +2 -0
- package/lib/esm/core-react/base/Div.js.map +1 -1
- package/lib/esm/core-react/base/DivWithOutsideClick.d.ts +1 -0
- package/lib/esm/core-react/base/DivWithOutsideClick.d.ts.map +1 -1
- package/lib/esm/core-react/base/DivWithOutsideClick.js +1 -0
- package/lib/esm/core-react/base/DivWithOutsideClick.js.map +1 -1
- package/lib/esm/core-react/base/FillCentered.d.ts +1 -0
- package/lib/esm/core-react/base/FillCentered.d.ts.map +1 -1
- package/lib/esm/core-react/base/FillCentered.js +2 -0
- package/lib/esm/core-react/base/FillCentered.js.map +1 -1
- package/lib/esm/core-react/base/FlexWrapContainer.d.ts +1 -0
- package/lib/esm/core-react/base/FlexWrapContainer.d.ts.map +1 -1
- package/lib/esm/core-react/base/FlexWrapContainer.js +2 -0
- package/lib/esm/core-react/base/FlexWrapContainer.js.map +1 -1
- package/lib/esm/core-react/base/Gap.d.ts +2 -0
- package/lib/esm/core-react/base/Gap.d.ts.map +1 -1
- package/lib/esm/core-react/base/Gap.js +3 -1
- package/lib/esm/core-react/base/Gap.js.map +1 -1
- package/lib/esm/core-react/base/ScrollView.d.ts +1 -0
- package/lib/esm/core-react/base/ScrollView.d.ts.map +1 -1
- package/lib/esm/core-react/base/ScrollView.js +2 -0
- package/lib/esm/core-react/base/ScrollView.js.map +1 -1
- package/lib/esm/core-react/button/UnderlinedButton.d.ts +2 -0
- package/lib/esm/core-react/button/UnderlinedButton.d.ts.map +1 -1
- package/lib/esm/core-react/button/UnderlinedButton.js +2 -0
- package/lib/esm/core-react/button/UnderlinedButton.js.map +1 -1
- package/lib/esm/core-react/checklistbox/CheckListBox.d.ts +4 -0
- package/lib/esm/core-react/checklistbox/CheckListBox.d.ts.map +1 -1
- package/lib/esm/core-react/checklistbox/CheckListBox.js +4 -0
- package/lib/esm/core-react/checklistbox/CheckListBox.js.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.js +1 -2
- package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +3 -5
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.d.ts +3 -0
- package/lib/esm/core-react/dialog/Dialog.d.ts.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.js +17 -3
- package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
- package/lib/esm/core-react/dialog/GlobalDialog.d.ts +3 -0
- package/lib/esm/core-react/dialog/GlobalDialog.d.ts.map +1 -1
- package/lib/esm/core-react/dialog/GlobalDialog.js +7 -3
- package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/esm/core-react/elementseparator/ElementSeparator.d.ts +4 -2
- package/lib/esm/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
- package/lib/esm/core-react/elementseparator/ElementSeparator.js +4 -2
- package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/esm/core-react/expandable/ExpandableList.d.ts +3 -3
- package/lib/esm/core-react/expandable/ExpandableList.d.ts.map +1 -1
- package/lib/esm/core-react/expandable/ExpandableList.js +5 -2
- package/lib/esm/core-react/expandable/ExpandableList.js.map +1 -1
- package/lib/esm/core-react/hocs/withOnOutsideClick.js +1 -2
- package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.d.ts.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.js +21 -11
- package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
- package/lib/esm/core-react/imagecheckbox/ImageCheckBox.d.ts +3 -2
- package/lib/esm/core-react/imagecheckbox/ImageCheckBox.d.ts.map +1 -1
- package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js +3 -2
- package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
- package/lib/esm/core-react/inputs/InputLabel.d.ts +2 -0
- package/lib/esm/core-react/inputs/InputLabel.d.ts.map +1 -1
- package/lib/esm/core-react/inputs/InputLabel.js +5 -0
- package/lib/esm/core-react/inputs/InputLabel.js.map +1 -1
- package/lib/esm/core-react/inputs/InputStatus.d.ts +1 -0
- package/lib/esm/core-react/inputs/InputStatus.d.ts.map +1 -1
- package/lib/esm/core-react/inputs/InputStatus.js +1 -0
- package/lib/esm/core-react/inputs/InputStatus.js.map +1 -1
- package/lib/esm/core-react/inputs/LabeledComponentProps.d.ts +2 -0
- package/lib/esm/core-react/inputs/LabeledComponentProps.d.ts.map +1 -1
- package/lib/esm/core-react/inputs/LabeledComponentProps.js.map +1 -1
- package/lib/esm/core-react/inputs/iconinput/IconInput.d.ts +2 -0
- package/lib/esm/core-react/inputs/iconinput/IconInput.d.ts.map +1 -1
- package/lib/esm/core-react/inputs/iconinput/IconInput.js +3 -0
- package/lib/esm/core-react/inputs/iconinput/IconInput.js.map +1 -1
- package/lib/esm/core-react/inputs/numberinput/NumberInput.d.ts +3 -0
- package/lib/esm/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
- package/lib/esm/core-react/inputs/numberinput/NumberInput.js +1 -0
- package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
- package/lib/esm/core-react/l10n/usePackageTranslation.js +1 -1
- package/lib/esm/core-react/l10n/usePackageTranslation.js.map +1 -1
- package/lib/esm/core-react/listbox/Listbox.d.ts +14 -14
- package/lib/esm/core-react/listbox/Listbox.d.ts.map +1 -1
- package/lib/esm/core-react/listbox/Listbox.js +8 -10
- package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingBar.d.ts +3 -2
- package/lib/esm/core-react/loading/LoadingBar.d.ts.map +1 -1
- package/lib/esm/core-react/loading/LoadingBar.js +2 -2
- package/lib/esm/core-react/loading/LoadingBar.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingPrompt.d.ts +3 -2
- package/lib/esm/core-react/loading/LoadingPrompt.d.ts.map +1 -1
- package/lib/esm/core-react/loading/LoadingPrompt.js +2 -2
- package/lib/esm/core-react/loading/LoadingPrompt.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingSpinner.d.ts +4 -2
- package/lib/esm/core-react/loading/LoadingSpinner.d.ts.map +1 -1
- package/lib/esm/core-react/loading/LoadingSpinner.js +2 -2
- package/lib/esm/core-react/loading/LoadingSpinner.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingStatus.d.ts +3 -2
- package/lib/esm/core-react/loading/LoadingStatus.d.ts.map +1 -1
- package/lib/esm/core-react/loading/LoadingStatus.js +2 -2
- package/lib/esm/core-react/loading/LoadingStatus.js.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.d.ts.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.js +3 -1
- package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/esm/core-react/popup/Popup.js +4 -8
- package/lib/esm/core-react/popup/Popup.js.map +1 -1
- package/lib/esm/core-react/radialmenu/Annulus.d.ts +7 -8
- package/lib/esm/core-react/radialmenu/Annulus.d.ts.map +1 -1
- package/lib/esm/core-react/radialmenu/Annulus.js +7 -8
- package/lib/esm/core-react/radialmenu/Annulus.js.map +1 -1
- package/lib/esm/core-react/radialmenu/RadialMenu.d.ts +0 -1
- package/lib/esm/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
- package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/esm/core-react/searchbox/SearchBox.d.ts +3 -3
- package/lib/esm/core-react/searchbox/SearchBox.d.ts.map +1 -1
- package/lib/esm/core-react/searchbox/SearchBox.js +2 -2
- package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
- package/lib/esm/core-react/settings/SettingsContainer.d.ts.map +1 -1
- package/lib/esm/core-react/settings/SettingsContainer.js +8 -4
- package/lib/esm/core-react/settings/SettingsContainer.js.map +1 -1
- package/lib/esm/core-react/settings/SettingsManager.d.ts +10 -7
- package/lib/esm/core-react/settings/SettingsManager.d.ts.map +1 -1
- package/lib/esm/core-react/settings/SettingsManager.js +13 -10
- package/lib/esm/core-react/settings/SettingsManager.js.map +1 -1
- package/lib/esm/core-react/tabs/Tabs.d.ts +5 -5
- package/lib/esm/core-react/tabs/Tabs.d.ts.map +1 -1
- package/lib/esm/core-react/tabs/Tabs.js +1 -0
- package/lib/esm/core-react/tabs/Tabs.js.map +1 -1
- package/lib/esm/core-react/tabs/VerticalTabs.d.ts +1 -0
- package/lib/esm/core-react/tabs/VerticalTabs.d.ts.map +1 -1
- package/lib/esm/core-react/tabs/VerticalTabs.js +2 -0
- package/lib/esm/core-react/tabs/VerticalTabs.js.map +1 -1
- package/lib/esm/core-react/text/BlockText.d.ts +1 -0
- package/lib/esm/core-react/text/BlockText.d.ts.map +1 -1
- package/lib/esm/core-react/text/BlockText.js +2 -0
- package/lib/esm/core-react/text/BlockText.js.map +1 -1
- package/lib/esm/core-react/text/BodyText.d.ts +1 -1
- package/lib/esm/core-react/text/BodyText.d.ts.map +1 -1
- package/lib/esm/core-react/text/BodyText.js +2 -1
- package/lib/esm/core-react/text/BodyText.js.map +1 -1
- package/lib/esm/core-react/text/DisabledText.d.ts +1 -0
- package/lib/esm/core-react/text/DisabledText.d.ts.map +1 -1
- package/lib/esm/core-react/text/DisabledText.js +2 -1
- package/lib/esm/core-react/text/DisabledText.js.map +1 -1
- package/lib/esm/core-react/text/MutedText.d.ts.map +1 -1
- package/lib/esm/core-react/text/MutedText.js +1 -0
- package/lib/esm/core-react/text/MutedText.js.map +1 -1
- package/lib/esm/core-react/text/StyledText.d.ts +1 -0
- package/lib/esm/core-react/text/StyledText.d.ts.map +1 -1
- package/lib/esm/core-react/text/StyledText.js.map +1 -1
- package/lib/esm/core-react/text/TextProps.d.ts +1 -0
- package/lib/esm/core-react/text/TextProps.d.ts.map +1 -1
- package/lib/esm/core-react/text/TextProps.js.map +1 -1
- package/lib/esm/core-react/tree/ExpansionToggle.d.ts.map +1 -1
- package/lib/esm/core-react/tree/ExpansionToggle.js +1 -1
- package/lib/esm/core-react/tree/ExpansionToggle.js.map +1 -1
- package/lib/esm/core-react/tree/Node.js +1 -2
- package/lib/esm/core-react/tree/Node.js.map +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/esm/core-react/utils/getCssVariable.js +1 -1
- package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
- package/lib/esm/core-react/utils/getObjectClassName.js +2 -3
- package/lib/esm/core-react/utils/getObjectClassName.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.d.ts +4 -1
- package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.d.ts.map +1 -1
- package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.js +3 -1
- package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.d.ts +1 -1
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +2 -3
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js +13 -17
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/package.json +7 -31
|
@@ -5,6 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
import type { TextProps } from "./TextProps";
|
|
6
6
|
/** Properties for [[StyledText]] component
|
|
7
7
|
* @public
|
|
8
|
+
* @deprecated in 4.12.x. Props of deprecated component {@link StyledText}.
|
|
8
9
|
*/
|
|
9
10
|
export interface StyledTextProps extends TextProps {
|
|
10
11
|
/** Main CSS class name */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledText.d.ts","sourceRoot":"","sources":["../../../../src/core-react/text/StyledText.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledText.d.ts","sourceRoot":"","sources":["../../../../src/core-react/text/StyledText.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,qBAYhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledText.js","sourceRoot":"","sources":["../../../../src/core-react/text/StyledText.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledText.js","sourceRoot":"","sources":["../../../../src/core-react/text/StyledText.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE1E,OAAO,CACL,iCACM,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,EAC/C,KAAK,EAAE,KAAK,IAEX,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Text\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { TextProps } from \"./TextProps\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Properties for [[StyledText]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link StyledText}.\n */\nexport interface StyledTextProps extends TextProps {\n /** Main CSS class name */\n mainClassName: string;\n}\n\n/** The base component for other text components that pass a main CSS class name.\n * @public\n * @deprecated in 4.0 Use \\<Text /\\> component from iTwinUI-react library.\n */\nexport function StyledText(props: StyledTextProps) {\n const { mainClassName, className, style, children, ...spanProps } = props;\n\n return (\n <span\n {...spanProps}\n className={classnames(mainClassName, className)}\n style={style}\n >\n {children}\n </span>\n );\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import type * as React from "react";
|
|
|
5
5
|
import type { CommonProps } from "../utils/Props";
|
|
6
6
|
/** Properties for various text components
|
|
7
7
|
* @public
|
|
8
|
+
* @deprecated in 4.12.x. Props of deprecated text components.
|
|
8
9
|
*/
|
|
9
10
|
export interface TextProps extends React.AllHTMLAttributes<HTMLSpanElement>, CommonProps {
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextProps.d.ts","sourceRoot":"","sources":["../../../../src/core-react/text/TextProps.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"TextProps.d.ts","sourceRoot":"","sources":["../../../../src/core-react/text/TextProps.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,SACf,SAAQ,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAC9C,WAAW;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextProps.js","sourceRoot":"","sources":["../../../../src/core-react/text/TextProps.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG","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 Text\n */\n\nimport type * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for various text components\n * @public\n */\nexport interface TextProps\n extends React.AllHTMLAttributes<HTMLSpanElement>,\n CommonProps {}\n"]}
|
|
1
|
+
{"version":3,"file":"TextProps.js","sourceRoot":"","sources":["../../../../src/core-react/text/TextProps.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG","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 Text\n */\n\nimport type * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for various text components\n * @public\n * @deprecated in 4.12.x. Props of deprecated text components.\n */\nexport interface TextProps\n extends React.AllHTMLAttributes<HTMLSpanElement>,\n CommonProps {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpansionToggle.d.ts","sourceRoot":"","sources":["../../../../src/core-react/tree/ExpansionToggle.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACxD,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ExpansionToggle.d.ts","sourceRoot":"","sources":["../../../../src/core-react/tree/ExpansionToggle.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACxD,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAwB1D"}
|
|
@@ -20,7 +20,7 @@ export function ExpansionToggle(props) {
|
|
|
20
20
|
const label = translate(props.isExpanded ? "tree.collapse" : "tree.expand");
|
|
21
21
|
return (
|
|
22
22
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
23
|
-
React.createElement("div", { onClick: props.onClick, className: className, style: props.style, "data-testid": props["data-testid"], role: "button", tabIndex: -1, "aria-label": label },
|
|
23
|
+
React.createElement("div", { onMouseDown: (e) => e.stopPropagation(), onClick: props.onClick, className: className, style: props.style, "data-testid": props["data-testid"], role: "button", tabIndex: -1, "aria-label": label },
|
|
24
24
|
React.createElement(Icon, { className: "toggle icon", iconSpec: React.createElement(SvgChevronRight, null) })));
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=ExpansionToggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpansionToggle.js","sourceRoot":"","sources":["../../../../src/core-react/tree/ExpansionToggle.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAWxD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,UAAU,CAC1B,2BAA2B,EAC3B,KAAK,CAAC,UAAU,IAAI,aAAa,EACjC,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAE5E,OAAO;IACL,iEAAiE;IACjE,6BACE,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,iBACL,KAAK,CAAC,aAAa,CAAC,EACjC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,gBACA,KAAK;QAEjB,oBAAC,IAAI,IAAC,SAAS,EAAC,aAAa,EAAC,QAAQ,EAAE,oBAAC,eAAe,OAAG,GAAI,CAC3D,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./ExpansionToggle.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/** Properties for the [[ExpansionToggle]] component\n * @public\n */\nexport interface ExpansionToggleProps extends CommonProps {\n isExpanded?: boolean;\n onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;\n [\"data-testid\"]?: string;\n}\n\n/** ExpansionToggle React component used by the [[TreeNode]] component to show collapsed or expanded state\n * @public\n */\nexport function ExpansionToggle(props: ExpansionToggleProps) {\n const { translate } = useTranslation();\n const className = classnames(\n \"core-tree-expansionToggle\",\n props.isExpanded && \"is-expanded\",\n props.className\n );\n const label = translate(props.isExpanded ? \"tree.collapse\" : \"tree.expand\");\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n onClick={props.onClick}\n className={className}\n style={props.style}\n data-testid={props[\"data-testid\"]}\n role=\"button\"\n tabIndex={-1}\n aria-label={label}\n >\n <Icon className=\"toggle icon\" iconSpec={<SvgChevronRight />} />\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExpansionToggle.js","sourceRoot":"","sources":["../../../../src/core-react/tree/ExpansionToggle.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAWxD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,UAAU,CAC1B,2BAA2B,EAC3B,KAAK,CAAC,UAAU,IAAI,aAAa,EACjC,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAE5E,OAAO;IACL,iEAAiE;IACjE,6BACE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACvC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,iBACL,KAAK,CAAC,aAAa,CAAC,EACjC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,gBACA,KAAK;QAEjB,oBAAC,IAAI,IAAC,SAAS,EAAC,aAAa,EAAC,QAAQ,EAAE,oBAAC,eAAe,OAAG,GAAI,CAC3D,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./ExpansionToggle.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/** Properties for the [[ExpansionToggle]] component\n * @public\n */\nexport interface ExpansionToggleProps extends CommonProps {\n isExpanded?: boolean;\n onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;\n [\"data-testid\"]?: string;\n}\n\n/** ExpansionToggle React component used by the [[TreeNode]] component to show collapsed or expanded state\n * @public\n */\nexport function ExpansionToggle(props: ExpansionToggleProps) {\n const { translate } = useTranslation();\n const className = classnames(\n \"core-tree-expansionToggle\",\n props.isExpanded && \"is-expanded\",\n props.className\n );\n const label = translate(props.isExpanded ? \"tree.collapse\" : \"tree.expand\");\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n onMouseDown={(e) => e.stopPropagation()}\n onClick={props.onClick}\n className={className}\n style={props.style}\n data-testid={props[\"data-testid\"]}\n role=\"button\"\n tabIndex={-1}\n aria-label={label}\n >\n <Icon className=\"toggle icon\" iconSpec={<SvgChevronRight />} />\n </div>\n );\n}\n"]}
|
|
@@ -37,9 +37,8 @@ export class TreeNode extends React.Component {
|
|
|
37
37
|
this.props.onClickExpansionToggle();
|
|
38
38
|
};
|
|
39
39
|
this._onClick = (e) => {
|
|
40
|
-
var _a, _b;
|
|
41
40
|
e.stopPropagation();
|
|
42
|
-
|
|
41
|
+
this.props.onClick?.(e);
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Node.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsBpD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAgDlC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAC1D,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAqGP,sBAAiB,GAAG,CAAC,OAAgB,EAAE,EAAE;YAC/C,IACE,IAAI,CAAC,KAAK,CAAC,aAAa;gBACxB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO;gBAChC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU;gBAEpC,IAAI,CAAC,KA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IACjD,CAAC;CA0BF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./Node.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Checkbox, ProgressRadial } from \"@itwin/itwinui-react\";\nimport { CheckBoxState } from \"../enums/CheckBoxState\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { ExpansionToggle } from \"./ExpansionToggle\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\n/** Props for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderProps = Omit<\n CheckboxProps,\n \"onChange\" | \"onClick\"\n> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/** Type for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderer = (\n props: NodeCheckboxRenderProps\n) => React.ReactNode;\n\n/** Number of pixels the node gets offset per each hierarchy level\n * @internal\n */\nexport const LEVEL_OFFSET = 20;\n\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/** Properties for Tree Node CheckBox\n * @public\n */\nexport interface NodeCheckboxProps {\n /** State of the checkbox */\n state?: CheckBoxState;\n /** Click event callback */\n onClick?: (newState: CheckBoxState) => void;\n /** Indicates whether checkbox is disabled */\n isDisabled?: boolean;\n /** Tooltip to be displayed when mouse is hovered over checkbox */\n tooltip?: string;\n}\n\n/** Properties for the [[TreeNode]] React component\n * @public\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactChild;\n /** Properties for the checkbox.\n * @public */\n checkboxProps?: NodeCheckboxProps;\n isLeaf?: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isFocused?: boolean;\n isSelected?: boolean;\n isHoverDisabled?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onContextMenu?: (e: React.MouseEvent) => void;\n onMouseMove?: (e: React.MouseEvent) => void;\n onMouseDown?: (e: React.MouseEvent) => void;\n onMouseUp?: (e: React.MouseEvent) => void;\n onClickExpansionToggle?: () => void;\n children?: React.ReactNode;\n\n /** Contains render overrides for different pieces of the node component. */\n renderOverrides?: {\n /** Callback to render a checkbox. Only called when checkbox is displayed. */\n renderCheckbox?: NodeCheckboxRenderer;\n };\n [\"data-testid\"]?: string;\n}\n\n/** Presentation React component for a Tree node\n * @public\n */\nexport class TreeNode extends React.Component<TreeNodeProps> {\n constructor(props: TreeNodeProps) {\n super(props);\n }\n\n public override render() {\n const className = classnames(\n \"core-tree-node\",\n this.props.isFocused && \"is-focused\",\n this.props.isSelected && \"is-selected\",\n this.props.isHoverDisabled && \"is-hover-disabled\",\n this.props.className\n );\n let offset = this.props.level * LEVEL_OFFSET;\n if (!this.props.isLoading && this.props.isLeaf)\n offset += EXPANSION_TOGGLE_WIDTH; // Add expansion toggle/loader width if they're not rendered\n\n let checkbox: React.ReactNode;\n if (this.props.checkboxProps) {\n const props: NodeCheckboxRenderProps = {\n label: \"\",\n checked: this.props.checkboxProps.state === CheckBoxState.On,\n indeterminate: this.props.checkboxProps.state === CheckBoxState.Partial,\n disabled: this.props.checkboxProps.isDisabled,\n title: this.props.checkboxProps.tooltip,\n onClick: this._onCheckboxClick,\n onChange: this._onCheckboxChange,\n };\n if (\n this.props.renderOverrides &&\n this.props.renderOverrides.renderCheckbox\n ) {\n checkbox = this.props.renderOverrides.renderCheckbox(props);\n } else {\n checkbox = (\n <Checkbox\n {...props}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n this._onCheckboxChange(e.target.checked)\n }\n data-testid={this.createSubComponentTestId(\"checkbox\")}\n />\n );\n }\n }\n\n const icon = this.props.icon ? (\n <div className=\"core-tree-node-icon\">{this.props.icon}</div>\n ) : undefined;\n\n const toggle = this.props.isLoading ? undefined : this.props.isLeaf ? (\n <div />\n ) : (\n <ExpansionToggle\n className=\"expansion-toggle\"\n data-testid={this.createSubComponentTestId(\"expansion-toggle\")}\n onClick={this._onClickExpansionToggle}\n isExpanded={this.props.isExpanded}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n className={className}\n style={this.props.style}\n data-testid={this.props[\"data-testid\"]}\n onClick={this._onClick}\n onContextMenu={this.props.onContextMenu}\n onMouseDown={this.props.onMouseDown}\n onMouseUp={this.props.onMouseUp}\n onMouseMove={this.props.onMouseMove}\n role=\"treeitem\"\n aria-selected={this.props.isSelected ? \"true\" : \"false\"}\n tabIndex={-1}\n >\n <div\n className=\"contents\"\n style={{ marginLeft: offset }}\n data-testid={this.createSubComponentTestId(\"contents\")}\n >\n {this.props.isLoading && (\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n className=\"core-progress-indicator\"\n />\n )}\n {toggle}\n {checkbox}\n {icon}\n {this.props.label}\n </div>\n {this.props.children}\n </div>\n );\n }\n\n private createSubComponentTestId(subId: string): string | undefined {\n if (!this.props[\"data-testid\"]) return undefined;\n return `${this.props[\"data-testid\"]}-${subId}`;\n }\n\n private _onCheckboxChange = (checked: boolean) => {\n if (\n this.props.checkboxProps &&\n this.props.checkboxProps.onClick &&\n !this.props.checkboxProps.isDisabled\n )\n this.props.checkboxProps.onClick(\n checked ? CheckBoxState.On : CheckBoxState.Off\n );\n };\n\n private _onCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _onClickExpansionToggle = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (this.props.onClickExpansionToggle) this.props.onClickExpansionToggle();\n };\n\n private _onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n this.props.onClick?.(e);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Node.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GA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AAU,mBACA,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,EAAE,CAAC,CAAC;YAEZ,6BACE,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,iBAChB,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC;gBAErD,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CACvB,oBAAC,cAAc,IACb,IAAI,EAAC,SAAS,EACd,aAAa,QACb,SAAS,EAAC,yBAAyB,GACnC,CACH;gBACA,MAAM;gBACN,QAAQ;gBACR,IAAI;gBACJ,IAAI,CAAC,KAAK,CAAC,KAAK,CACb;YACL,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,KAAa;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YAAE,OAAO,SAAS,CAAC;QACjD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;IACjD,CAAC;CA0BF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./Node.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Checkbox, ProgressRadial } from \"@itwin/itwinui-react\";\nimport { CheckBoxState } from \"../enums/CheckBoxState\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { ExpansionToggle } from \"./ExpansionToggle\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\n/** Props for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderProps = Omit<\n CheckboxProps,\n \"onChange\" | \"onClick\"\n> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/** Type for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderer = (\n props: NodeCheckboxRenderProps\n) => React.ReactNode;\n\n/** Number of pixels the node gets offset per each hierarchy level\n * @internal\n */\nexport const LEVEL_OFFSET = 20;\n\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/** Properties for Tree Node CheckBox\n * @public\n */\nexport interface NodeCheckboxProps {\n /** State of the checkbox */\n state?: CheckBoxState;\n /** Click event callback */\n onClick?: (newState: CheckBoxState) => void;\n /** Indicates whether checkbox is disabled */\n isDisabled?: boolean;\n /** Tooltip to be displayed when mouse is hovered over checkbox */\n tooltip?: string;\n}\n\n/** Properties for the [[TreeNode]] React component\n * @public\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactChild;\n /** Properties for the checkbox.\n * @public */\n checkboxProps?: NodeCheckboxProps;\n isLeaf?: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isFocused?: boolean;\n isSelected?: boolean;\n isHoverDisabled?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onContextMenu?: (e: React.MouseEvent) => void;\n onMouseMove?: (e: React.MouseEvent) => void;\n onMouseDown?: (e: React.MouseEvent) => void;\n onMouseUp?: (e: React.MouseEvent) => void;\n onClickExpansionToggle?: () => void;\n children?: React.ReactNode;\n\n /** Contains render overrides for different pieces of the node component. */\n renderOverrides?: {\n /** Callback to render a checkbox. Only called when checkbox is displayed. */\n renderCheckbox?: NodeCheckboxRenderer;\n };\n [\"data-testid\"]?: string;\n}\n\n/** Presentation React component for a Tree node\n * @public\n */\nexport class TreeNode extends React.Component<TreeNodeProps> {\n constructor(props: TreeNodeProps) {\n super(props);\n }\n\n public override render() {\n const className = classnames(\n \"core-tree-node\",\n this.props.isFocused && \"is-focused\",\n this.props.isSelected && \"is-selected\",\n this.props.isHoverDisabled && \"is-hover-disabled\",\n this.props.className\n );\n let offset = this.props.level * LEVEL_OFFSET;\n if (!this.props.isLoading && this.props.isLeaf)\n offset += EXPANSION_TOGGLE_WIDTH; // Add expansion toggle/loader width if they're not rendered\n\n let checkbox: React.ReactNode;\n if (this.props.checkboxProps) {\n const props: NodeCheckboxRenderProps = {\n label: \"\",\n checked: this.props.checkboxProps.state === CheckBoxState.On,\n indeterminate: this.props.checkboxProps.state === CheckBoxState.Partial,\n disabled: this.props.checkboxProps.isDisabled,\n title: this.props.checkboxProps.tooltip,\n onClick: this._onCheckboxClick,\n onChange: this._onCheckboxChange,\n };\n if (\n this.props.renderOverrides &&\n this.props.renderOverrides.renderCheckbox\n ) {\n checkbox = this.props.renderOverrides.renderCheckbox(props);\n } else {\n checkbox = (\n <Checkbox\n {...props}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n this._onCheckboxChange(e.target.checked)\n }\n data-testid={this.createSubComponentTestId(\"checkbox\")}\n />\n );\n }\n }\n\n const icon = this.props.icon ? (\n <div className=\"core-tree-node-icon\">{this.props.icon}</div>\n ) : undefined;\n\n const toggle = this.props.isLoading ? undefined : this.props.isLeaf ? (\n <div />\n ) : (\n <ExpansionToggle\n className=\"expansion-toggle\"\n data-testid={this.createSubComponentTestId(\"expansion-toggle\")}\n onClick={this._onClickExpansionToggle}\n isExpanded={this.props.isExpanded}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n className={className}\n style={this.props.style}\n data-testid={this.props[\"data-testid\"]}\n onClick={this._onClick}\n onContextMenu={this.props.onContextMenu}\n onMouseDown={this.props.onMouseDown}\n onMouseUp={this.props.onMouseUp}\n onMouseMove={this.props.onMouseMove}\n role=\"treeitem\"\n aria-selected={this.props.isSelected ? \"true\" : \"false\"}\n tabIndex={-1}\n >\n <div\n className=\"contents\"\n style={{ marginLeft: offset }}\n data-testid={this.createSubComponentTestId(\"contents\")}\n >\n {this.props.isLoading && (\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n className=\"core-progress-indicator\"\n />\n )}\n {toggle}\n {checkbox}\n {icon}\n {this.props.label}\n </div>\n {this.props.children}\n </div>\n );\n }\n\n private createSubComponentTestId(subId: string): string | undefined {\n if (!this.props[\"data-testid\"]) return undefined;\n return `${this.props[\"data-testid\"]}-${subId}`;\n }\n\n private _onCheckboxChange = (checked: boolean) => {\n if (\n this.props.checkboxProps &&\n this.props.checkboxProps.onClick &&\n !this.props.checkboxProps.isDisabled\n )\n this.props.checkboxProps.onClick(\n checked ? CheckBoxState.On : CheckBoxState.Off\n );\n };\n\n private _onCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _onClickExpansionToggle = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (this.props.onClickExpansionToggle) this.props.onClickExpansionToggle();\n };\n\n private _onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n this.props.onClick?.(e);\n };\n}\n"]}
|
|
@@ -42,7 +42,7 @@ function parseSvgFromDataUri(src, element) {
|
|
|
42
42
|
// the esm build of dompurify has a default import but the cjs build does not
|
|
43
43
|
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
44
44
|
// istanbul ignore next
|
|
45
|
-
const sanitizer = DOMPurify
|
|
45
|
+
const sanitizer = DOMPurify ?? DOMPurifyNS;
|
|
46
46
|
const sanitizedSvg = sanitizer.sanitize(rawSvg);
|
|
47
47
|
const parsedSvg = new window.DOMParser().parseFromString(sanitizedSvg, "text/xml");
|
|
48
48
|
const errorNode = parsedSvg.querySelector("parsererror");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconWebComponent.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,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,EAAE,OAAY;IAC7C,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;KAC1C;IACD,OAAO,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IACvC,KAAK,CAAC,iBAAiB;QAC7B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,qDAAqD;QACrD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM;YAAE,OAAO;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,MAAM,GAAG,GAAG,MAAM,oBAAoB,CACpC,GAAG,EACH,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAC7B,KAAK,CACN,CAAC;QACF,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB;IACtC,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,SAAS;QACvD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport { UiError } from \"@itwin/appui-abstract\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiCore } from \"../UiCore\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport { reuseOrCreatePromise } from \"./reuseOrCreatePromise\";\n\n/**\n * \"getSvg\" list\n * (if multiple icon require the same thing,\n * only do the fetch once, and have all icon use the same result)\n */\nconst cache = new Map<string, Promise<any>>();\n\n/**\n * Parse 'data:' uri to retrieve the Svg component within it.\n * @param src data:image/svg+xml;base64 or data:image/svg+xml\n * @param element Element for logging purpose.\n * @returns HTMLElement (svg)\n */\nfunction parseSvgFromDataUri(src: string, element: any) {\n const dataUriParts = src.split(\",\");\n\n if (\n (dataUriParts.length !== 2 &&\n \"data:image/svg+xml;base64\" === dataUriParts[0]) ||\n (\"data:image/svg+xml;base64\" !== dataUriParts[0] &&\n \"data:image/svg+xml\" !== dataUriParts[0])\n ) {\n Logger.logError(UiCore.loggerCategory(element), \"Unable to load icon.\");\n return;\n }\n\n let rawSvg = \"\";\n if (\"data:image/svg+xml;base64\" === dataUriParts[0]) {\n rawSvg = window.atob(dataUriParts[1]);\n } else {\n // `,` is valid character in data when not in base64, rebuild the data correctly\n rawSvg = decodeURIComponent(dataUriParts.slice(1).join(\",\"));\n }\n\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS;\n const sanitizedSvg = sanitizer.sanitize(rawSvg);\n\n const parsedSvg = new window.DOMParser().parseFromString(\n sanitizedSvg,\n \"text/xml\"\n );\n const errorNode = parsedSvg.querySelector(\"parsererror\");\n if (errorNode || \"svg\" !== parsedSvg.documentElement.nodeName.toLowerCase()) {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(UiCore.loggerCategory(element), \"Unable to load icon.\");\n }\n\n return parsedSvg.documentElement;\n}\n\n/**\n * Fetch the src from the network and return the SVG element.\n * @param src URL representing a .svg file\n * @param element Element for logging purpose\n * @returns HTMLElement (svg)\n */\nasync function fetchSvg(src: string, element: any) {\n const response = await fetch(src).catch((_error) => {\n Logger.logError(UiCore.loggerCategory(element), \"Unable to load icon.\");\n });\n if (!response || !response.ok) {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(UiCore.loggerCategory(element), \"Unable to load icon.\");\n }\n const str = await response.text();\n if (str === undefined) {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(UiCore.loggerCategory(element), \"Unable to load icon.\");\n }\n const data = new window.DOMParser().parseFromString(str, \"text/xml\");\n return data.documentElement;\n}\n\n/**\n * Get the svg (fetch and parse for url, or decode and parse for data: url)\n * @param src URL of the content to download/parse\n * @param element Element for logging purpose.\n * @returns HTMLElement (svg)\n */\nasync function getSvg(src: string, element: any) {\n if (src.startsWith(\"data:\")) {\n return parseSvgFromDataUri(src, element);\n }\n return fetchSvg(src, element);\n}\n\n/** IconWebComponent loads icon from an svg path\n * @internal\n */\nexport class IconWebComponent extends HTMLElement {\n private async connectedCallback() {\n await this.loadSvg();\n this.dispatchEvent(new CustomEvent(\"load\"));\n }\n\n private async loadSvg() {\n // if svg was already appended don't request it again\n if (this.childNodes.length) return;\n const src = this.getAttribute(\"src\") || \"\";\n if (!src) return;\n\n const svg = await reuseOrCreatePromise(\n src,\n async () => getSvg(src, this),\n cache\n );\n if (svg && !this.childNodes.length) {\n this.append(svg.cloneNode(true));\n }\n }\n}\n\n/** @internal */\nexport function registerIconWebComponent() {\n if (window.customElements.get(\"svg-loader\") === undefined)\n window.customElements.define(\"svg-loader\", IconWebComponent);\n}\n"]}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
export function getCssVariable(variableName, htmlElement) {
|
|
12
|
-
const element = htmlElement
|
|
12
|
+
const element = htmlElement ?? document.documentElement;
|
|
13
13
|
const cssStyles = getComputedStyle(element, null);
|
|
14
14
|
const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();
|
|
15
15
|
return cssVal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCssVariable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAoB,EACpB,WAAyB;IAEzB,MAAM,OAAO,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"getCssVariable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAoB,EACpB,WAAyB;IAEzB,MAAM,OAAO,GAAG,WAAW,IAAI,QAAQ,CAAC,eAAe,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAAoB,EACpB,WAAyB;IAEzB,IAAI,SAAS,GAAW,GAAG,CAAC;IAC5B,MAAM,SAAS,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,IAAI,SAAS;QAAE,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\n/** Get CSS variable\n * @public\n */\nexport function getCssVariable(\n variableName: string,\n htmlElement?: HTMLElement\n): string {\n const element = htmlElement ?? document.documentElement;\n const cssStyles = getComputedStyle(element, null);\n const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();\n return cssVal;\n}\n\n/** Get CSS variable as number\n * @public\n */\nexport function getCssVariableAsNumber(\n variableName: string,\n htmlElement?: HTMLElement\n): number {\n let cssValNum: number = NaN;\n const cssValStr = getCssVariable(variableName, htmlElement);\n if (cssValStr) cssValNum = parseFloat(cssValStr);\n return cssValNum;\n}\n"]}
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export const getObjectClassName = (obj) => {
|
|
13
|
-
|
|
14
|
-
return (obj === null || obj === void 0 ? void 0 : obj.name)
|
|
13
|
+
return obj?.name
|
|
15
14
|
? obj.name
|
|
16
|
-
:
|
|
15
|
+
: obj?.constructor?.name
|
|
17
16
|
? obj.constructor.name
|
|
18
17
|
: "";
|
|
19
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getObjectClassName.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getObjectClassName.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAQ,EAAU,EAAE
|
|
1
|
+
{"version":3,"file":"getObjectClassName.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getObjectClassName.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAQ,EAAU,EAAE;IACrD,OAAO,GAAG,EAAE,IAAI;QACd,CAAC,CAAC,GAAG,CAAC,IAAI;QACV,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI;YACxB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI;YACtB,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\n/**\n * Returns the name of a class from a static or instance object.\n * @internal\n */\nexport const getObjectClassName = (obj: any): string => {\n return obj?.name\n ? obj.name\n : obj?.constructor?.name\n ? obj.constructor.name\n : \"\";\n};\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** @internal */
|
|
2
2
|
export type ResizeObserverType = typeof import("resize-observer-polyfill").default;
|
|
3
3
|
/** @internal */
|
|
4
|
-
export declare
|
|
4
|
+
export declare function getResizeObserver(): {
|
|
5
|
+
new (callback: ResizeObserverCallback): ResizeObserver;
|
|
6
|
+
prototype: ResizeObserver;
|
|
7
|
+
};
|
|
5
8
|
//# sourceMappingURL=ResizeObserverPolyfill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeObserverPolyfill.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/ResizeObserverPolyfill.tsx"],"names":[],"mappings":"AASA,gBAAgB;AAChB,MAAM,MAAM,kBAAkB,GAC5B,cAAc,0BAA0B,EAAE,OAAO,CAAC;AAQpD,gBAAgB;AAChB,
|
|
1
|
+
{"version":3,"file":"ResizeObserverPolyfill.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/ResizeObserverPolyfill.tsx"],"names":[],"mappings":"AASA,gBAAgB;AAChB,MAAM,MAAM,kBAAkB,GAC5B,cAAc,0BAA0B,EAAE,OAAO,CAAC;AAQpD,gBAAgB;AAChB,wBAAgB,iBAAiB;;;EAEhC"}
|
|
@@ -13,5 +13,7 @@ function getModule(mod) {
|
|
|
13
13
|
return mod;
|
|
14
14
|
}
|
|
15
15
|
/** @internal */
|
|
16
|
-
export
|
|
16
|
+
export function getResizeObserver() {
|
|
17
|
+
return window.ResizeObserver ?? getModule(ResizeObserverPolyfill);
|
|
18
|
+
}
|
|
17
19
|
//# sourceMappingURL=ResizeObserverPolyfill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeObserverPolyfill.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/ResizeObserverPolyfill.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAMnE,SAAS,SAAS,CAAC,GAAQ;IACzB,wBAAwB;IACxB,IAAI,GAAG,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gBAAgB;AAChB,MAAM,
|
|
1
|
+
{"version":3,"file":"ResizeObserverPolyfill.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/ResizeObserverPolyfill.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAMnE,SAAS,SAAS,CAAC,GAAQ;IACzB,wBAAwB;IACxB,IAAI,GAAG,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CAAC,cAAc,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport * as ResizeObserverPolyfill from \"resize-observer-polyfill\";\n\n/** @internal */\nexport type ResizeObserverType =\n typeof import(\"resize-observer-polyfill\").default; // eslint-disable-line @typescript-eslint/consistent-type-imports\n\nfunction getModule(mod: any) {\n /* istanbul ignore if */\n if (mod.default) return mod.default;\n return mod;\n}\n\n/** @internal */\nexport function getResizeObserver() {\n return window.ResizeObserver ?? getModule(ResizeObserverPolyfill);\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module Utilities
|
|
3
3
|
*/
|
|
4
4
|
/** Hook that will show a popup window
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export declare function useCrossOriginPopup(visible: boolean, url: string | undefined, title: string, width: number, height: number, onClose: () => void): void;
|
|
8
8
|
//# sourceMappingURL=useCrossOriginPopup.d.ts.map
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { useInterval } from "./useInterval";
|
|
10
10
|
/** Hook that will show a popup window
|
|
11
|
-
* @
|
|
11
|
+
* @public
|
|
12
12
|
*/
|
|
13
13
|
export function useCrossOriginPopup(visible, url, title, width, height, onClose) {
|
|
14
14
|
const [checkPopupAliveDelay, setCheckPopupAliveDelay] = React.useState();
|
|
@@ -48,8 +48,7 @@ export function useCrossOriginPopup(visible, url, title, width, height, onClose)
|
|
|
48
48
|
}
|
|
49
49
|
}, [handleClosedPopup]);
|
|
50
50
|
const checkPopupClosed = React.useCallback(() => {
|
|
51
|
-
|
|
52
|
-
if ((_a = popupWindow.current) === null || _a === void 0 ? void 0 : _a.closed) {
|
|
51
|
+
if (popupWindow.current?.closed) {
|
|
53
52
|
// Popup has been closed by end-user, inform our host and cleanup
|
|
54
53
|
handleClosedPopup();
|
|
55
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossOriginPopup.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useCrossOriginPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;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AI,KAAK,EAAE;gBACT,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;gBAE5B,iEAAiE;gBACjE,uBAAuB,CAAC,IAAI,CAAC,CAAC;aAC/B;SACF;QAED,sEAAsE;QACtE,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS,EAAE;YACjD,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAE5B,iBAAiB,EAAE,CAAC;SACrB;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport * as React from \"react\";\nimport { useInterval } from \"./useInterval\";\n\n/** Hook that will show a popup window\n * @public\n */\nexport function useCrossOriginPopup(\n visible: boolean,\n url: string | undefined,\n title: string,\n width: number,\n height: number,\n onClose: () => void\n) {\n const [checkPopupAliveDelay, setCheckPopupAliveDelay] = React.useState<\n number | undefined\n >();\n\n // ONLY re-render the popup when visibility changes, any other changes get deferred until next visibility change\n // hence the massive use of 'useRef'\n const popupWindow = React.useRef<Window>();\n const savedUrl = React.useRef(url);\n const savedTitle = React.useRef(title);\n const savedWidth = React.useRef(width);\n const savedHeight = React.useRef(height);\n const savedOnClose = React.useRef(onClose);\n\n React.useEffect(() => {\n savedUrl.current = url;\n }, [url]);\n React.useEffect(() => {\n savedTitle.current = title;\n }, [title]);\n React.useEffect(() => {\n savedWidth.current = width;\n }, [width]);\n React.useEffect(() => {\n savedHeight.current = height;\n }, [height]);\n React.useEffect(() => {\n savedOnClose.current = onClose;\n }, [onClose]);\n\n // Cleanup method after a popup closure. Also calls the OnClose callback.\n const handleClosedPopup = React.useCallback(() => {\n savedOnClose.current();\n setCheckPopupAliveDelay(undefined);\n popupWindow.current = undefined;\n }, []);\n\n const closePopup = React.useCallback(() => {\n if (popupWindow.current !== undefined) {\n popupWindow.current.close(); // Manually close the popup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n const checkPopupClosed = React.useCallback(() => {\n if (popupWindow.current?.closed) {\n // Popup has been closed by end-user, inform our host and cleanup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n // Close popup when parent window get closed\n React.useEffect(() => {\n window.onbeforeunload = (_event) => {\n closePopup();\n };\n return () => {\n window.onbeforeunload = null;\n };\n }, [closePopup]);\n\n // Whenever the hook is unloaded, make sure the underlying popup get closed.\n // Note: An interval is used to check if popup was closed by user: because we access\n // a cross domain resource inside the popup, we don't have access to popup window events.\n // As a workaround, we periodically check if popup is still alive.\n // Reference: https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128\n React.useEffect(() => {\n return () => {\n closePopup();\n };\n }, [closePopup]);\n\n // Timer that checks if popup was closed by end-user\n useInterval(checkPopupClosed, checkPopupAliveDelay);\n\n // ==> Main render effect\n // Monitors visibility changes and open/close the popup accordingly.\n React.useEffect(() => {\n // If visible and a popup window is not already open, open a new popup window\n if (visible && popupWindow.current === undefined) {\n const popup = window.open(\n savedUrl.current,\n savedTitle.current,\n `width=${savedWidth.current},height=${savedHeight.current}`\n );\n if (popup) {\n popup.focus();\n popupWindow.current = popup;\n\n // Start and interval that will check if popup got closed by user\n setCheckPopupAliveDelay(1000);\n }\n }\n\n // If not visible but a previous popup window is still open, close it.\n if (!visible && popupWindow.current !== undefined) {\n popupWindow.current.close();\n\n handleClosedPopup();\n }\n }, [handleClosedPopup, visible]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCA0HnD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BAgHrD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,CAAC;CACxD,sEAGA;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,qBA2CA"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module Utilities
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { getResizeObserver } from "./ResizeObserverPolyfill";
|
|
10
10
|
import { useRefEffect } from "./useRefEffect";
|
|
11
11
|
import { useRefs } from "./useRefs";
|
|
12
12
|
/** Uses ResizeObserver API to notify about element bound changes.
|
|
@@ -20,20 +20,18 @@ export function useResizeObserver(onResize) {
|
|
|
20
20
|
const owningWindowRef = React.useRef(null);
|
|
21
21
|
// istanbul ignore next
|
|
22
22
|
const resizeObserverCleanup = () => {
|
|
23
|
-
var _a;
|
|
24
23
|
if (rafRef.current)
|
|
25
24
|
owningWindowRef.current.cancelAnimationFrame(rafRef.current);
|
|
26
|
-
|
|
25
|
+
resizeObserver.current?.disconnect();
|
|
27
26
|
resizeObserver.current = null;
|
|
28
27
|
};
|
|
29
28
|
React.useEffect(() => {
|
|
30
29
|
isMountedRef.current = true;
|
|
31
30
|
return () => {
|
|
32
|
-
var _a;
|
|
33
31
|
isMountedRef.current = false;
|
|
34
32
|
if (rafRef.current)
|
|
35
33
|
owningWindowRef.current.cancelAnimationFrame(rafRef.current);
|
|
36
|
-
|
|
34
|
+
owningWindowRef.current?.removeEventListener("beforeunload", resizeObserverCleanup);
|
|
37
35
|
};
|
|
38
36
|
}, []);
|
|
39
37
|
const processResize = React.useCallback((target) => {
|
|
@@ -67,7 +65,8 @@ export function useResizeObserver(onResize) {
|
|
|
67
65
|
}
|
|
68
66
|
}, [processResize]);
|
|
69
67
|
const observerRef = useRefEffect((instance) => {
|
|
70
|
-
|
|
68
|
+
const RO = getResizeObserver();
|
|
69
|
+
resizeObserver.current = new RO(handleResize);
|
|
71
70
|
if (instance) {
|
|
72
71
|
resizeObserver.current.observe(instance);
|
|
73
72
|
const newBounds = instance.getBoundingClientRect();
|
|
@@ -75,10 +74,8 @@ export function useResizeObserver(onResize) {
|
|
|
75
74
|
bounds.current = newBounds;
|
|
76
75
|
}
|
|
77
76
|
return () => {
|
|
78
|
-
var _a;
|
|
79
77
|
instance &&
|
|
80
|
-
(
|
|
81
|
-
/* istanbul ignore next */ (_a = resizeObserver.current) === null || _a === void 0 ? void 0 : _a.unobserve(instance));
|
|
78
|
+
/* istanbul ignore next */ resizeObserver.current?.unobserve(instance);
|
|
82
79
|
resizeObserver.current = null;
|
|
83
80
|
};
|
|
84
81
|
}, [handleResize, onResize]);
|
|
@@ -101,8 +98,8 @@ export function useResizeObserver(onResize) {
|
|
|
101
98
|
* @internal
|
|
102
99
|
*/
|
|
103
100
|
export function useLayoutResizeObserver(inElement, onResize) {
|
|
104
|
-
const inBoundingRect = inElement
|
|
105
|
-
const [bounds, setBounds] = React.useState({ width: inBoundingRect
|
|
101
|
+
const inBoundingRect = inElement?.getBoundingClientRect();
|
|
102
|
+
const [bounds, setBounds] = React.useState({ width: inBoundingRect?.width, height: inBoundingRect?.height });
|
|
106
103
|
const [watchedElement, setWatchedElement] = React.useState(inElement);
|
|
107
104
|
const resizeObserver = React.useRef(null);
|
|
108
105
|
const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active
|
|
@@ -110,10 +107,9 @@ export function useLayoutResizeObserver(inElement, onResize) {
|
|
|
110
107
|
const owningWindowRef = React.useRef(null);
|
|
111
108
|
// istanbul ignore next
|
|
112
109
|
const resizeObserverCleanup = () => {
|
|
113
|
-
var _a;
|
|
114
110
|
if (rafRef.current)
|
|
115
111
|
owningWindowRef.current.cancelAnimationFrame(rafRef.current);
|
|
116
|
-
|
|
112
|
+
resizeObserver.current?.disconnect();
|
|
117
113
|
resizeObserver.current = null;
|
|
118
114
|
};
|
|
119
115
|
React.useEffect(() => {
|
|
@@ -167,12 +163,12 @@ export function useLayoutResizeObserver(inElement, onResize) {
|
|
|
167
163
|
if (!watchedElement) {
|
|
168
164
|
return;
|
|
169
165
|
}
|
|
170
|
-
|
|
166
|
+
const RO = getResizeObserver();
|
|
167
|
+
resizeObserver.current = new RO(handleResize);
|
|
171
168
|
resizeObserver.current.observe(watchedElement);
|
|
172
169
|
return () => {
|
|
173
|
-
var _a;
|
|
174
170
|
// istanbul ignore next
|
|
175
|
-
|
|
171
|
+
resizeObserver.current?.disconnect();
|
|
176
172
|
resizeObserver.current = null;
|
|
177
173
|
};
|
|
178
174
|
}, [handleResize, watchedElement]);
|
|
@@ -210,7 +206,7 @@ export function ResizableContainerObserver({ onResize, children, }) {
|
|
|
210
206
|
}, [hasChildren]);
|
|
211
207
|
const processResize = React.useCallback((width, height) => {
|
|
212
208
|
// istanbul ignore next
|
|
213
|
-
onResize(width
|
|
209
|
+
onResize(width ?? 0, height ?? 0);
|
|
214
210
|
}, [onResize]);
|
|
215
211
|
useLayoutResizeObserver(containerElement, processResize);
|
|
216
212
|
const style = hasChildren
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAkD;IAElD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,kEAAkE;IAClG,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,KAAK,CAAC,MA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AC,CAAC;IACzC,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEzD,oEAAoE;IACpE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,uBAAuB;QACvB,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE;YACjD,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;YAC5B,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC;YACvD,mBAAmB,CACjB,WAAW,IAAI,SAAS;gBACtB,CAAC,CAAC,YAAY,CAAC,OAAO;gBACtB,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CACvC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,KAAc,EAAE,MAAe,EAAE,EAAE;QAClC,uBAAuB;QACvB,QAAQ,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,CAAC,CAAC;IACpC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,KAAK,GAAwB,WAAW;QAC5C,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QACnC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,IAEX,WAAW,IAAI,QAAQ,CACpB,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport * as React from \"react\";\nimport { ResizeObserver } from \"./ResizeObserverPolyfill\";\nimport { useRefEffect } from \"./useRefEffect\";\nimport { useRefs } from \"./useRefs\";\n\n/** Uses ResizeObserver API to notify about element bound changes.\n * @internal\n */\nexport function useResizeObserver<T extends Element>(\n onResize?: (width: number, height: number) => void\n) {\n const bounds = React.useRef({ width: 0, height: 0 });\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current?.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, []);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore else\n if (\n isMountedRef.current &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore if\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n const observerRef = useRefEffect(\n (instance: T | null) => {\n resizeObserver.current = new ResizeObserver(handleResize);\n if (instance) {\n resizeObserver.current.observe(instance);\n const newBounds = instance.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n bounds.current = newBounds;\n }\n\n return () => {\n instance &&\n /* istanbul ignore next */ resizeObserver.current?.unobserve(\n instance\n );\n resizeObserver.current = null;\n };\n },\n [handleResize, onResize]\n );\n\n const handleRef = React.useCallback(\n (instance: Element | null) => {\n const newBounds = instance && instance.getBoundingClientRect();\n // istanbul ignore if\n if (\n newBounds &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const ref = useRefs(handleRef, observerRef);\n return ref;\n}\n\n/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector\n * width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly\n * handles observing element in pop-out/child windows.\n * @internal\n */\nexport function useLayoutResizeObserver(\n inElement: HTMLElement | null,\n onResize?: (width?: number, height?: number) => void\n) {\n const inBoundingRect = inElement?.getBoundingClientRect();\n const [bounds, setBounds] = React.useState<{\n width?: number;\n height?: number;\n }>({ width: inBoundingRect?.width, height: inBoundingRect?.height });\n const [watchedElement, setWatchedElement] = React.useState(inElement);\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n setWatchedElement(inElement);\n\n // istanbul ignore next\n if (inElement) {\n const newBounds = inElement.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n isMountedRef.current = false;\n rafRef.current &&\n owningWindowRef.current &&\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, [onResize, inElement]);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore next\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore next\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n if (owningWindowRef.current)\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n React.useLayoutEffect(() => {\n if (!watchedElement) {\n return;\n }\n resizeObserver.current = new ResizeObserver(handleResize);\n resizeObserver.current.observe(watchedElement);\n return () => {\n // istanbul ignore next\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n }, [handleResize, watchedElement]);\n\n return [bounds.width, bounds.height];\n}\n\n/** Prop the ElementResizeObserver sends to the render function.\n * @public\n */\nexport interface RenderPropsArgs {\n width?: number;\n height?: number;\n}\n\n/** ElementResizeObserver provides functionality similar to ReactResizeDetector when a render function is specified. This implementation properly handles\n * observing element in pop-out/child windows.\n * @public\n */\nexport function ElementResizeObserver({\n watchedElement,\n render,\n}: {\n watchedElement: HTMLElement | null;\n render: (props: RenderPropsArgs) => React.ReactElement;\n}) {\n const [width, height] = useLayoutResizeObserver(watchedElement);\n return render({ width, height });\n}\n\n/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when\n * the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then\n * the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report\n * size changes from its parent container.\n * @public\n */\nexport function ResizableContainerObserver({\n onResize,\n children,\n}: {\n onResize: (width: number, height: number) => void;\n children?: React.ReactNode;\n}) {\n const containerRef = React.useRef<HTMLDivElement>(null); // set to non-zero when requestAnimationFrame processing is active\n const [containerElement, setContainerElement] =\n React.useState<HTMLElement | null>(null);\n const isMountedRef = React.useRef(false);\n const hasChildren = React.Children.count(children) !== 0;\n\n // if no children are specified then monitor size of parent element.\n React.useEffect(() => {\n // istanbul ignore next\n if (!isMountedRef.current && containerRef.current) {\n isMountedRef.current = true;\n const hasParent = !!containerRef.current.parentElement;\n setContainerElement(\n hasChildren && hasParent\n ? containerRef.current\n : containerRef.current.parentElement\n );\n }\n }, [hasChildren]);\n\n const processResize = React.useCallback(\n (width?: number, height?: number) => {\n // istanbul ignore next\n onResize(width ?? 0, height ?? 0);\n },\n [onResize]\n );\n\n useLayoutResizeObserver(containerElement, processResize);\n const style: React.CSSProperties = hasChildren\n ? { width: \"100%\", height: \"100%\" }\n : { display: \"none\" };\n\n return (\n <div\n ref={containerRef}\n className=\"uicore-resizable-container\"\n style={style}\n >\n {hasChildren && children}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useResizeObserver.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAkD;IAElD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,kEAAkE;IAClG,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAM,IAAI,CAAC,CAAC;IAEhD,uBAAuB;IACvB,MAAM,qBAAqB,GAAG,GAAG,EAAE;QACjC,IAAI,MAAM,CAAC,OAAO;YAChB,eAAe,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE/D,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACrC,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;IAChC,CAAC,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,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,CAAC,OAAO,CAAC,aAAa,CACvC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,KAAc,EAAE,MAAe,EAAE,EAAE;QAClC,uBAAuB;QACvB,QAAQ,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,KAAK,GAAwB,WAAW;QAC5C,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QACnC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,IAEX,WAAW,IAAI,QAAQ,CACpB,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport * as React from \"react\";\nimport { getResizeObserver } from \"./ResizeObserverPolyfill\";\nimport { useRefEffect } from \"./useRefEffect\";\nimport { useRefs } from \"./useRefs\";\n\n/** Uses ResizeObserver API to notify about element bound changes.\n * @internal\n */\nexport function useResizeObserver<T extends Element>(\n onResize?: (width: number, height: number) => void\n) {\n const bounds = React.useRef({ width: 0, height: 0 });\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current?.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, []);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore else\n if (\n isMountedRef.current &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore if\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n const observerRef = useRefEffect(\n (instance: T | null) => {\n const RO = getResizeObserver();\n resizeObserver.current = new RO(handleResize);\n if (instance) {\n resizeObserver.current.observe(instance);\n const newBounds = instance.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n bounds.current = newBounds;\n }\n\n return () => {\n instance &&\n /* istanbul ignore next */ resizeObserver.current?.unobserve(\n instance\n );\n resizeObserver.current = null;\n };\n },\n [handleResize, onResize]\n );\n\n const handleRef = React.useCallback(\n (instance: Element | null) => {\n const newBounds = instance && instance.getBoundingClientRect();\n // istanbul ignore if\n if (\n newBounds &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const ref = useRefs(handleRef, observerRef);\n return ref;\n}\n\n/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector\n * width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly\n * handles observing element in pop-out/child windows.\n * @internal\n */\nexport function useLayoutResizeObserver(\n inElement: HTMLElement | null,\n onResize?: (width?: number, height?: number) => void\n) {\n const inBoundingRect = inElement?.getBoundingClientRect();\n const [bounds, setBounds] = React.useState<{\n width?: number;\n height?: number;\n }>({ width: inBoundingRect?.width, height: inBoundingRect?.height });\n const [watchedElement, setWatchedElement] = React.useState(inElement);\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n setWatchedElement(inElement);\n\n // istanbul ignore next\n if (inElement) {\n const newBounds = inElement.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n isMountedRef.current = false;\n rafRef.current &&\n owningWindowRef.current &&\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, [onResize, inElement]);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore next\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore next\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n if (owningWindowRef.current)\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n React.useLayoutEffect(() => {\n if (!watchedElement) {\n return;\n }\n const RO = getResizeObserver();\n resizeObserver.current = new RO(handleResize);\n resizeObserver.current.observe(watchedElement);\n return () => {\n // istanbul ignore next\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n }, [handleResize, watchedElement]);\n\n return [bounds.width, bounds.height];\n}\n\n/** Prop the ElementResizeObserver sends to the render function.\n * @public\n */\nexport interface RenderPropsArgs {\n width?: number;\n height?: number;\n}\n\n/** ElementResizeObserver provides functionality similar to ReactResizeDetector when a render function is specified. This implementation properly handles\n * observing element in pop-out/child windows.\n * @public\n */\nexport function ElementResizeObserver({\n watchedElement,\n render,\n}: {\n watchedElement: HTMLElement | null;\n render: (props: RenderPropsArgs) => React.ReactElement;\n}) {\n const [width, height] = useLayoutResizeObserver(watchedElement);\n return render({ width, height });\n}\n\n/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when\n * the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then\n * the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report\n * size changes from its parent container.\n * @public\n */\nexport function ResizableContainerObserver({\n onResize,\n children,\n}: {\n onResize: (width: number, height: number) => void;\n children?: React.ReactNode;\n}) {\n const containerRef = React.useRef<HTMLDivElement>(null); // set to non-zero when requestAnimationFrame processing is active\n const [containerElement, setContainerElement] =\n React.useState<HTMLElement | null>(null);\n const isMountedRef = React.useRef(false);\n const hasChildren = React.Children.count(children) !== 0;\n\n // if no children are specified then monitor size of parent element.\n React.useEffect(() => {\n // istanbul ignore next\n if (!isMountedRef.current && containerRef.current) {\n isMountedRef.current = true;\n const hasParent = !!containerRef.current.parentElement;\n setContainerElement(\n hasChildren && hasParent\n ? containerRef.current\n : containerRef.current.parentElement\n );\n }\n }, [hasChildren]);\n\n const processResize = React.useCallback(\n (width?: number, height?: number) => {\n // istanbul ignore next\n onResize(width ?? 0, height ?? 0);\n },\n [onResize]\n );\n\n useLayoutResizeObserver(containerElement, processResize);\n const style: React.CSSProperties = hasChildren\n ? { width: \"100%\", height: \"100%\" }\n : { display: \"none\" };\n\n return (\n <div\n ref={containerRef}\n className=\"uicore-resizable-container\"\n style={style}\n >\n {hasChildren && children}\n </div>\n );\n}\n"]}
|