@itwin/core-react 4.13.2 → 4.13.3
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 +8 -1
- package/lib/cjs/core-react/UiCore.js +1 -1
- package/lib/cjs/core-react/UiCore.js.map +1 -1
- package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
- package/lib/cjs/core-react/button/UnderlinedButton.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.js +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenuItem.js +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +1 -1
- package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/PopupContextMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/TildeFinder.js +1 -1
- package/lib/cjs/core-react/contextmenu/TildeFinder.js.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.js +2 -2
- package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
- package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/cjs/core-react/enums/Alignment.js +2 -2
- package/lib/cjs/core-react/enums/Alignment.js.map +1 -1
- package/lib/cjs/core-react/enums/CheckBoxState.js +1 -1
- package/lib/cjs/core-react/enums/CheckBoxState.js.map +1 -1
- package/lib/cjs/core-react/enums/Orientation.js +1 -1
- package/lib/cjs/core-react/enums/Orientation.js.map +1 -1
- package/lib/cjs/core-react/enums/SortDirection.js +1 -1
- package/lib/cjs/core-react/enums/SortDirection.js.map +1 -1
- package/lib/cjs/core-react/enums/TimeFormat.js +1 -1
- package/lib/cjs/core-react/enums/TimeFormat.js.map +1 -1
- package/lib/cjs/core-react/expandable/ExpandableList.js +1 -1
- package/lib/cjs/core-react/expandable/ExpandableList.js.map +1 -1
- package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
- package/lib/cjs/core-react/focustrap/FocusTrap.js.map +1 -1
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/cjs/core-react/icons/ConditionalIconItem.js.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
- package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
- package/lib/cjs/core-react/inputs/Input.js.map +1 -1
- package/lib/cjs/core-react/inputs/InputStatus.js +1 -1
- package/lib/cjs/core-react/inputs/InputStatus.js.map +1 -1
- package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
- package/lib/cjs/core-react/l10n/usePackageTranslation.js.map +1 -1
- package/lib/cjs/core-react/l10n/useTranslation.js.map +1 -1
- package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingBar.js +1 -1
- package/lib/cjs/core-react/loading/LoadingBar.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingPrompt.js +1 -1
- package/lib/cjs/core-react/loading/LoadingPrompt.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingSpinner.js +1 -1
- package/lib/cjs/core-react/loading/LoadingSpinner.js.map +1 -1
- package/lib/cjs/core-react/loading/LoadingStatus.js +1 -1
- package/lib/cjs/core-react/loading/LoadingStatus.js.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.js +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/cjs/core-react/popup/Popup.js +1 -1
- package/lib/cjs/core-react/popup/Popup.js.map +1 -1
- package/lib/cjs/core-react/radialmenu/RadialMenu.js +2 -2
- package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
- package/lib/cjs/core-react/settings/SettingsContainer.js.map +1 -1
- package/lib/cjs/core-react/settings/SettingsManager.js.map +1 -1
- package/lib/cjs/core-react/tabs/Tabs.js.map +1 -1
- package/lib/cjs/core-react/text/FilteredText.js.map +1 -1
- package/lib/cjs/core-react/tree/Node.js.map +1 -1
- package/lib/cjs/core-react/tree/Tree.js.map +1 -1
- package/lib/cjs/core-react/uistate/UiStateEntry.js.map +1 -1
- package/lib/cjs/core-react/uistate/UiStateStorage.js +1 -1
- package/lib/cjs/core-react/uistate/UiStateStorage.js.map +1 -1
- package/lib/cjs/core-react/utils/IconHelper.js.map +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/cjs/core-react/utils/Rectangle.js +1 -1
- package/lib/cjs/core-react/utils/Rectangle.js.map +1 -1
- package/lib/cjs/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
- package/lib/cjs/core-react/utils/flattenChildren.js.map +1 -1
- package/lib/cjs/core-react/utils/getUserColor.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useDisposable.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useEffectSkipFirst.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useEventListener.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useInterval.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useLifecycleLogging.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useOnOutsideClick.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useRefs.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/lib/cjs/core-react/utils/reuseOrCreatePromise.js.map +1 -1
- package/lib/cjs/core-react/utils/shallowDiffers.js.map +1 -1
- package/lib/esm/core-react/UiCore.js +1 -2
- package/lib/esm/core-react/UiCore.js.map +1 -1
- package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
- package/lib/esm/core-react/button/UnderlinedButton.js.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/ContextMenuItem.js +1 -2
- package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextSubMenu.js +1 -2
- package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/PopupContextMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/TildeFinder.js +1 -2
- package/lib/esm/core-react/contextmenu/TildeFinder.js.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.js +1 -2
- package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
- package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/esm/core-react/expandable/ExpandableList.js +1 -2
- package/lib/esm/core-react/expandable/ExpandableList.js.map +1 -1
- package/lib/esm/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
- package/lib/esm/core-react/focustrap/FocusTrap.js.map +1 -1
- package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/esm/core-react/icons/ConditionalIconItem.js.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
- package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
- package/lib/esm/core-react/inputs/Input.js.map +1 -1
- package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
- package/lib/esm/core-react/l10n/usePackageTranslation.js.map +1 -1
- package/lib/esm/core-react/l10n/useTranslation.js.map +1 -1
- package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingBar.js +1 -2
- package/lib/esm/core-react/loading/LoadingBar.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingPrompt.js +1 -2
- package/lib/esm/core-react/loading/LoadingPrompt.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingSpinner.js +1 -2
- package/lib/esm/core-react/loading/LoadingSpinner.js.map +1 -1
- package/lib/esm/core-react/loading/LoadingStatus.js +1 -2
- package/lib/esm/core-react/loading/LoadingStatus.js.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.js +1 -2
- package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/esm/core-react/popup/Popup.js +1 -2
- package/lib/esm/core-react/popup/Popup.js.map +1 -1
- package/lib/esm/core-react/radialmenu/RadialMenu.js +2 -3
- package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
- package/lib/esm/core-react/settings/SettingsContainer.js.map +1 -1
- package/lib/esm/core-react/settings/SettingsManager.js.map +1 -1
- package/lib/esm/core-react/tabs/Tabs.js.map +1 -1
- package/lib/esm/core-react/text/FilteredText.js.map +1 -1
- package/lib/esm/core-react/tree/Node.js.map +1 -1
- package/lib/esm/core-react/tree/Tree.js.map +1 -1
- package/lib/esm/core-react/uistate/UiStateEntry.js.map +1 -1
- package/lib/esm/core-react/utils/IconHelper.js.map +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/esm/core-react/utils/Rectangle.js.map +1 -1
- package/lib/esm/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
- package/lib/esm/core-react/utils/flattenChildren.js.map +1 -1
- package/lib/esm/core-react/utils/getUserColor.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useDisposable.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useEffectSkipFirst.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useEventListener.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useInterval.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useLifecycleLogging.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useOnOutsideClick.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useRefs.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/lib/esm/core-react/utils/reuseOrCreatePromise.js.map +1 -1
- package/lib/esm/core-react/utils/shallowDiffers.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TildeFinder.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/TildeFinder.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAE/B;;GAEG;AACH,MAAa,WAAW;;
|
|
1
|
+
{"version":3,"file":"TildeFinder.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/TildeFinder.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAE/B;;GAEG;AACH,MAAa,WAAW;;AAAxB,kCAiEC;AAhEC;;;;GAIG;AACW,0BAAc,GAAG,CAC7B,IAAqB,EACqC,EAAE;IAC5D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,SAAS;QACT,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI,UAAU,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvD,MAAM,EA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;aACL,CAAC;YACF,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;gBAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAC1B,IAAI,CAAC,KAAK,CAAC,QAA2B,EACtC,CAAC,KAAsB,EAAE,EAAE;oBACzB,MAAM,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;oBAC5C,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;wBAChB,4EAA4E;wBAC5E,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;wBAC5B,OAAO,CAAC,CAAC,IAAI,CAAC;oBAChB,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CACF;aACF,CAAC,CAAC;YACH,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;gBAClB,OAAO,GAAG,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACxC,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 ContextMenu\n */\n\nimport * as React from \"react\";\n\n/** Finds a tilde character in ContextMenu item label for hot key support\n * @internal\n */\nexport class TildeFinder {\n /**\n * Find character following a tilde character within a React.ReactNode.\n * @param node react node to search within for a tilde.\n * @returns character that was found, and the same node with tilde removed, and following character with an underline.\n */\n public static findAfterTilde = (\n node: React.ReactNode\n ): { character: string | undefined; node: React.ReactNode } => {\n if (typeof node === \"string\") {\n // String\n const tildeIndex = node.indexOf(\"~\");\n if (tildeIndex !== -1 && tildeIndex <= node.length - 2) {\n const ch = node.charAt(tildeIndex + 1);\n const s1 = node.substring(0, tildeIndex);\n const n = <u key=\"hotkey\">{ch}</u>;\n const s2 = node.substring(tildeIndex + 2);\n return { character: ch.toUpperCase(), node: [s1, n, s2] };\n }\n } else if (node && typeof node === \"object\") {\n if (Array.isArray(node)) {\n // Array\n let ret: { character: string | undefined; node: React.ReactNode } = {\n character: undefined,\n node,\n };\n node = node.map((child) => {\n const r = TildeFinder.findAfterTilde(child);\n if (r.character) {\n // if character is found, modify node instead of returning unmodified child.\n ret = r;\n return r.node;\n }\n return child;\n });\n if (ret.character) {\n return { character: ret.character, node };\n }\n } else if (\"props\" in node) {\n // React Node\n const ret: { character: string | undefined; node: React.ReactNode } = {\n character: undefined,\n node,\n };\n ret.node = React.cloneElement(node, {\n children: React.Children.map(\n node.props.children as React.ReactNode,\n (child: React.ReactNode) => {\n const r = TildeFinder.findAfterTilde(child);\n if (r.character) {\n // if character is found, modify node instead of returning unmodified child.\n ret.character = r.character;\n return r.node;\n }\n return child;\n }\n ),\n });\n if (ret.character) {\n return ret;\n }\n }\n }\n return { character: undefined, node };\n };\n}\n"]}
|
|
@@ -31,7 +31,7 @@ var DialogAlignment;
|
|
|
31
31
|
DialogAlignment["BottomLeft"] = "bottom-left";
|
|
32
32
|
DialogAlignment["Bottom"] = "bottom";
|
|
33
33
|
DialogAlignment["BottomRight"] = "bottom-right";
|
|
34
|
-
})(DialogAlignment
|
|
34
|
+
})(DialogAlignment || (exports.DialogAlignment = DialogAlignment = {}));
|
|
35
35
|
/** Dialog React component with optional resizing and dragging functionality
|
|
36
36
|
* @public
|
|
37
37
|
* @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.
|
|
@@ -149,6 +149,7 @@ class Dialog extends React.Component {
|
|
|
149
149
|
return buttons;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
+
exports.Dialog = Dialog;
|
|
152
153
|
// eslint-disable-next-line deprecation/deprecation
|
|
153
154
|
Dialog.defaultProps = {
|
|
154
155
|
maxWidth: "100%",
|
|
@@ -160,7 +161,6 @@ Dialog.defaultProps = {
|
|
|
160
161
|
inset: true,
|
|
161
162
|
trapFocus: false,
|
|
162
163
|
};
|
|
163
|
-
exports.Dialog = Dialog;
|
|
164
164
|
function DialogButton({ button, primaryStyleType, noCoreButtonClasses, }) {
|
|
165
165
|
const { translate } = (0, useTranslation_1.useTranslation)();
|
|
166
166
|
let buttonText = "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,2CAAoC;AACpC,+BAA+B;AAC/B,6CAAkC;AAElC,0DAAyD;AACzD,wDAAoE;AACpE,qEAAkE;AAGlE,yBAAuB;AACvB,2DAAwD;AAIxD;;;GAGG;AACH,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,uCAAoB,CAAA;IACpB,8BAAW,CAAA;IACX,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,kCAAe,CAAA;IACf,6CAA0B,CAAA;IAC1B,oCAAiB,CAAA;IACjB,+CAA4B,CAAA;AAC9B,CAAC,EAVW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAU1B;AAiFD;;;GAGG;AACH,mDAAmD;AACnD,MAAa,MAAO,SAAQ,KAAK,CAAC,SAAsB;IActD,mDAAmD;IACnD,YAAY,KAAkB;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;QAfP,oBAAe,GAAG,QAAQ,CAAC;QA0BnC,uBAAuB;QAChB,iBAAY,GAAG,CAAC,YAAmC,EAAE,EAAE;YAC5D,IAAI,YAAY;gBAAE,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,aAAa,CAAC;QACtE,CAAC,CAAC;QAsLM,iBAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC9C,IACE,KAAK,CAAC,GAAG,KAAK,iBAAG,CAAC,MAAM,CAAC,OAAO,EAAE;gBAClC,IAAI,CAAC,KAAK,CAAC,MAAM;gB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CAAC,CAAC;YAC1D,mBAAmB,GAAG,IAAI,CAAC;YAC3B,MAAM;QACR,KAAK,iCAAgB,CAAC,QAAQ;YAC5B,UAAU,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;YAC1C,WAAW,GAAG,IAAA,oBAAU,EAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC1D,mBAAmB,GAAG,IAAI,CAAC;YAC3B,MAAM;KACT;IAED,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC;IAExC,OAAO,CACL,oBAAC,sBAAM,IACL,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAC7D,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,UAAU,CACJ,CACV,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 Dialog\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { Dialog as BaseDialog, Button } from \"@itwin/itwinui-react\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport \"./Dialog.scss\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\ntype ButtonProps = React.ComponentPropsWithoutRef<typeof Button>;\n\n/** Enum for dialog alignment\n * @public\n * @deprecated in 4.12.x. Enum used in a deprecated component {@link Dialog}.\n */\nexport enum DialogAlignment {\n TopLeft = \"top-left\",\n Top = \"top\",\n TopRight = \"top-right\",\n Left = \"left\",\n Center = \"center\",\n Right = \"right\",\n BottomLeft = \"bottom-left\",\n Bottom = \"bottom\",\n BottomRight = \"bottom-right\",\n}\n\n/** Properties for the [[Dialog]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link Dialog}.\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n CommonProps {\n /** Indicates whether to show dialog or not */\n opened: boolean;\n\n /** Indicates whether the user can resize dialog with cursor. Default: false */\n resizable?: boolean;\n /** Indicates whether the user can move dialog with cursor. Default: false */\n movable?: boolean;\n /** Indicates whether the content should be inset. Default: true */\n inset?: boolean;\n /** Indicates whether the focus should be trapped within the dialog. Default: false */\n trapFocus?: boolean;\n\n /** Whether the hide the header. Default: false */\n hideHeader?: boolean;\n /** Override for the header */\n header?: React.ReactNode;\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** Footer to show at bottom of dialog. Note: will override buttonCluster */\n footer?: string | React.ReactElement;\n /** List of DialogButtonDef objects specifying buttons and associated onClick events */\n buttonCluster?: DialogButtonDef[];\n\n /** Default alignment of dialog. */\n // eslint-disable-next-line deprecation/deprecation\n alignment?: DialogAlignment;\n /** Initial x/left position of dialog in px. */\n x?: number;\n /** Initial y/top position of dialog in px. */\n y?: number;\n\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for Esc key */\n onEscape?: () => void;\n /** Triggered when a click is triggered outside of this dialog. */\n onOutsideClick?: (event: MouseEvent) => any;\n\n /** Initial width of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: \"50%\" */\n width?: string | number;\n /** Initial height of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n height?: string | number;\n /** Minimum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 300px */\n minWidth?: string | number;\n /** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 135px */\n minHeight?: string | number;\n /** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 100% */\n maxWidth?: string | number;\n /** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxHeight?: string | number;\n\n /** Whether to show background overlay. Default: true.\n * @note Modeless dialogs require an id and an implementation of onModelessPointerDown.\n */\n modal?: boolean;\n /** An id for a modeless dialog */\n modelessId?: string;\n /** Pointer Down event handler when modeless (modal = false) */\n onModelessPointerDown?: (event: React.PointerEvent, id: string) => void;\n\n /** Custom CSS Style for overlay */\n backgroundStyle?: React.CSSProperties;\n /** Custom CSS Style for title */\n titleStyle?: React.CSSProperties;\n /** Custom CSS Style for footer */\n footerStyle?: React.CSSProperties;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n}\n\n/** Dialog React component with optional resizing and dragging functionality\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class Dialog extends React.Component<DialogProps> {\n private _parentDocument = document;\n // eslint-disable-next-line deprecation/deprecation\n public static defaultProps: Partial<DialogProps> = {\n maxWidth: \"100%\",\n width: \"50%\",\n hideHeader: false,\n resizable: false,\n movable: false,\n modal: true,\n inset: true,\n trapFocus: false,\n };\n\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: DialogProps) {\n super(props);\n }\n\n public override componentWillUnmount(): void {\n this._parentDocument.removeEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n public override componentDidMount(): void {\n this._parentDocument.addEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n // istanbul ignore next\n public handleRefSet = (containerDiv: HTMLDivElement | null) => {\n if (containerDiv) this._parentDocument = containerDiv.ownerDocument;\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n title,\n footer,\n buttonCluster,\n onClose,\n onEscape,\n onOutsideClick,\n minWidth,\n minHeight,\n x,\n y,\n width,\n height,\n maxHeight,\n maxWidth,\n backgroundStyle,\n titleStyle,\n footerStyle,\n style,\n contentStyle,\n contentClassName,\n modal,\n resizable,\n movable,\n className,\n alignment,\n inset,\n trapFocus,\n modelessId,\n onModelessPointerDown,\n hideHeader,\n header,\n as,\n ...props\n } = this.props;\n\n let initialOffset: React.CSSProperties = {};\n if (x || y) {\n initialOffset = {\n left: x ?? 0,\n top: y ?? 0,\n transform: \"none\",\n };\n }\n\n const containerStyle: React.CSSProperties = {\n ...initialOffset,\n margin: \"\",\n width,\n height,\n };\n\n const minMaxStyle: React.CSSProperties = {\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n };\n const dialogBaseContainerStyle: React.CSSProperties = {\n ...containerStyle,\n ...minMaxStyle,\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const buttons = this.getFooterButtons(\n buttonCluster,\n \"high-visibility\",\n true\n );\n\n return (\n <BaseDialog\n isOpen={opened}\n onClose={onClose}\n closeOnExternalClick={false}\n closeOnEsc={false}\n style={style}\n className={classnames(\"core-dialog\", className)}\n isDraggable={movable}\n isResizable={resizable}\n trapFocus={trapFocus && /* istanbul ignore next */ modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n {/* eslint-disable-next-line deprecation/deprecation */}\n <DivWithOutsideClick onOutsideClick={onOutsideClick}>\n <BaseDialog.Main\n className={classnames(\n \"core-dialog-main\",\n alignment && this.getCSSClassNameFromAlignment(alignment)\n )}\n data-testid=\"core-dialog-container\"\n style={dialogBaseContainerStyle}\n onPointerDown={this._handleContainerPointerDown}\n >\n {!hideHeader &&\n (header || (\n <BaseDialog.TitleBar\n titleText={title}\n style={titleStyle}\n data-testid=\"core-dialog-head\"\n />\n ))}\n <BaseDialog.Content\n className={contentClassName}\n style={{ padding: inset ? undefined : 0, ...contentStyle }}\n >\n {this.props.children}\n </BaseDialog.Content>\n {footer ||\n (buttons && (\n <BaseDialog.ButtonBar style={footerStyle}>\n {buttons}\n </BaseDialog.ButtonBar>\n ))}\n </BaseDialog.Main>\n </DivWithOutsideClick>\n </BaseDialog>\n );\n }\n\n // eslint-disable-next-line deprecation/deprecation\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Top:\n return \"core-align-top\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Left:\n return \"core-align-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Center:\n return \"core-align-center\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Right:\n return \"core-align-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n /** @deprecated in 4.12.x. Use iTwinUI Button instead. */\n protected getFooterButtons(\n buttonCluster: DialogButtonDef[] | undefined,\n primaryStyleType: ButtonProps[\"styleType\"] = \"cta\",\n noCoreButtonClasses: boolean = false\n ): React.ReactNode[] | undefined {\n if (buttonCluster === undefined) return undefined;\n\n const buttons: React.ReactNode[] = [];\n buttonCluster.forEach((button: DialogButtonDef, index: number) => {\n buttons.push(\n <DialogButton\n key={index.toString()}\n button={button}\n primaryStyleType={primaryStyleType}\n noCoreButtonClasses={noCoreButtonClasses}\n />\n );\n });\n return buttons;\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === Key.Escape.valueOf() &&\n this.props.opened &&\n this.props.onEscape\n ) {\n this.props.onEscape();\n }\n };\n\n protected _handleContainerPointerDown = (event: React.PointerEvent): void => {\n // istanbul ignore next\n if (!this.props.modal) {\n if (this.props.onModelessPointerDown && this.props.modelessId)\n this.props.onModelessPointerDown(event, this.props.modelessId);\n }\n };\n}\n\nfunction DialogButton({\n button,\n primaryStyleType,\n noCoreButtonClasses,\n}: {\n button: DialogButtonDef;\n primaryStyleType: ButtonProps[\"styleType\"];\n noCoreButtonClasses: boolean;\n}) {\n const { translate } = useTranslation();\n\n let buttonText = \"\";\n\n let buttonClass = classnames(\n !noCoreButtonClasses && \"core-dialog-button\",\n !noCoreButtonClasses && `dialog-button-${button.type}`,\n button.className\n );\n let usePrimaryStyleType = false;\n\n switch (button.type) {\n case DialogButtonType.OK:\n buttonText = translate(\"dialog.ok\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Retry:\n buttonText = translate(\"dialog.retry\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Yes:\n buttonText = translate(\"dialog.yes\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.No:\n buttonText = translate(\"dialog.no\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Cancel:\n buttonText = translate(\"dialog.cancel\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Close:\n buttonText = translate(\"dialog.close\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Next:\n buttonText = translate(\"dialog.next\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Previous:\n buttonText = translate(\"dialog.previous\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n }\n\n buttonText = button.label || buttonText;\n\n return (\n <Button\n className={buttonClass}\n disabled={button.disabled}\n styleType={usePrimaryStyleType ? primaryStyleType : undefined}\n onClick={button.onClick}\n >\n {buttonText}\n </Button>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,2CAAoC;AACpC,+BAA+B;AAC/B,6CAAkC;AAElC,0DAAyD;AACzD,wDAAoE;AACpE,qEAAkE;AAGlE,yBAAuB;AACvB,2DAAwD;AAIxD;;;GAGG;AACH,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,uCAAoB,CAAA;IACpB,8BAAW,CAAA;IACX,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,kCAAe,CAAA;IACf,6CAA0B,CAAA;IAC1B,oCAAiB,CAAA;IACjB,+CAA4B,CAAA;AAC9B,CAAC,EAVW,eAAe,+BAAf,eAAe,QAU1B;AAiFD;;;GAGG;AACH,mDAAmD;AACnD,MAAa,MAAO,SAAQ,KAAK,CAAC,SAAsB;IActD,mDAAmD;IACnD,YAAY,KAAkB;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;QAfP,oBAAe,GAAG,QAAQ,CAAC;QA0BnC,uBAAuB;QAChB,iBAAY,GAAG,CAAC,YAAmC,EAAE,EAAE;YAC5D,IAAI,YAAY;gBAAE,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,aAAa,CAAC;QACtE,CAAC,CAAC;QAsLM,iBAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC9C,IACE,KAAK,CAAC,GAAG,KAAK,iBAAG,CAAC,MAAM,CAAC,OAAO,EAAE;gBAClC,IAAI,CAAC,KAAK,CAAC,MAAM;gBACjB,IAAI,CAAC,KAAK,CAAC,QAAQ,EACnB,CAAC;gBACD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC;QACH,CAAC,CAAC;QAEQ,gCAA2B,GAAG,CA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YAC5B,UAAU,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;YAC1C,WAAW,GAAG,IAAA,oBAAU,EAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC1D,mBAAmB,GAAG,IAAI,CAAC;YAC3B,MAAM;IACV,CAAC;IAED,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC;IAExC,OAAO,CACL,oBAAC,sBAAM,IACL,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAC7D,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,UAAU,CACJ,CACV,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 Dialog\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { Dialog as BaseDialog, Button } from \"@itwin/itwinui-react\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport \"./Dialog.scss\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\ntype ButtonProps = React.ComponentPropsWithoutRef<typeof Button>;\n\n/** Enum for dialog alignment\n * @public\n * @deprecated in 4.12.x. Enum used in a deprecated component {@link Dialog}.\n */\nexport enum DialogAlignment {\n TopLeft = \"top-left\",\n Top = \"top\",\n TopRight = \"top-right\",\n Left = \"left\",\n Center = \"center\",\n Right = \"right\",\n BottomLeft = \"bottom-left\",\n Bottom = \"bottom\",\n BottomRight = \"bottom-right\",\n}\n\n/** Properties for the [[Dialog]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link Dialog}.\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n CommonProps {\n /** Indicates whether to show dialog or not */\n opened: boolean;\n\n /** Indicates whether the user can resize dialog with cursor. Default: false */\n resizable?: boolean;\n /** Indicates whether the user can move dialog with cursor. Default: false */\n movable?: boolean;\n /** Indicates whether the content should be inset. Default: true */\n inset?: boolean;\n /** Indicates whether the focus should be trapped within the dialog. Default: false */\n trapFocus?: boolean;\n\n /** Whether the hide the header. Default: false */\n hideHeader?: boolean;\n /** Override for the header */\n header?: React.ReactNode;\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** Footer to show at bottom of dialog. Note: will override buttonCluster */\n footer?: string | React.ReactElement;\n /** List of DialogButtonDef objects specifying buttons and associated onClick events */\n buttonCluster?: DialogButtonDef[];\n\n /** Default alignment of dialog. */\n // eslint-disable-next-line deprecation/deprecation\n alignment?: DialogAlignment;\n /** Initial x/left position of dialog in px. */\n x?: number;\n /** Initial y/top position of dialog in px. */\n y?: number;\n\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for Esc key */\n onEscape?: () => void;\n /** Triggered when a click is triggered outside of this dialog. */\n onOutsideClick?: (event: MouseEvent) => any;\n\n /** Initial width of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: \"50%\" */\n width?: string | number;\n /** Initial height of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n height?: string | number;\n /** Minimum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 300px */\n minWidth?: string | number;\n /** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 135px */\n minHeight?: string | number;\n /** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 100% */\n maxWidth?: string | number;\n /** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxHeight?: string | number;\n\n /** Whether to show background overlay. Default: true.\n * @note Modeless dialogs require an id and an implementation of onModelessPointerDown.\n */\n modal?: boolean;\n /** An id for a modeless dialog */\n modelessId?: string;\n /** Pointer Down event handler when modeless (modal = false) */\n onModelessPointerDown?: (event: React.PointerEvent, id: string) => void;\n\n /** Custom CSS Style for overlay */\n backgroundStyle?: React.CSSProperties;\n /** Custom CSS Style for title */\n titleStyle?: React.CSSProperties;\n /** Custom CSS Style for footer */\n footerStyle?: React.CSSProperties;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n}\n\n/** Dialog React component with optional resizing and dragging functionality\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class Dialog extends React.Component<DialogProps> {\n private _parentDocument = document;\n // eslint-disable-next-line deprecation/deprecation\n public static defaultProps: Partial<DialogProps> = {\n maxWidth: \"100%\",\n width: \"50%\",\n hideHeader: false,\n resizable: false,\n movable: false,\n modal: true,\n inset: true,\n trapFocus: false,\n };\n\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: DialogProps) {\n super(props);\n }\n\n public override componentWillUnmount(): void {\n this._parentDocument.removeEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n public override componentDidMount(): void {\n this._parentDocument.addEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n // istanbul ignore next\n public handleRefSet = (containerDiv: HTMLDivElement | null) => {\n if (containerDiv) this._parentDocument = containerDiv.ownerDocument;\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n title,\n footer,\n buttonCluster,\n onClose,\n onEscape,\n onOutsideClick,\n minWidth,\n minHeight,\n x,\n y,\n width,\n height,\n maxHeight,\n maxWidth,\n backgroundStyle,\n titleStyle,\n footerStyle,\n style,\n contentStyle,\n contentClassName,\n modal,\n resizable,\n movable,\n className,\n alignment,\n inset,\n trapFocus,\n modelessId,\n onModelessPointerDown,\n hideHeader,\n header,\n as,\n ...props\n } = this.props;\n\n let initialOffset: React.CSSProperties = {};\n if (x || y) {\n initialOffset = {\n left: x ?? 0,\n top: y ?? 0,\n transform: \"none\",\n };\n }\n\n const containerStyle: React.CSSProperties = {\n ...initialOffset,\n margin: \"\",\n width,\n height,\n };\n\n const minMaxStyle: React.CSSProperties = {\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n };\n const dialogBaseContainerStyle: React.CSSProperties = {\n ...containerStyle,\n ...minMaxStyle,\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const buttons = this.getFooterButtons(\n buttonCluster,\n \"high-visibility\",\n true\n );\n\n return (\n <BaseDialog\n isOpen={opened}\n onClose={onClose}\n closeOnExternalClick={false}\n closeOnEsc={false}\n style={style}\n className={classnames(\"core-dialog\", className)}\n isDraggable={movable}\n isResizable={resizable}\n trapFocus={trapFocus && /* istanbul ignore next */ modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n {/* eslint-disable-next-line deprecation/deprecation */}\n <DivWithOutsideClick onOutsideClick={onOutsideClick}>\n <BaseDialog.Main\n className={classnames(\n \"core-dialog-main\",\n alignment && this.getCSSClassNameFromAlignment(alignment)\n )}\n data-testid=\"core-dialog-container\"\n style={dialogBaseContainerStyle}\n onPointerDown={this._handleContainerPointerDown}\n >\n {!hideHeader &&\n (header || (\n <BaseDialog.TitleBar\n titleText={title}\n style={titleStyle}\n data-testid=\"core-dialog-head\"\n />\n ))}\n <BaseDialog.Content\n className={contentClassName}\n style={{ padding: inset ? undefined : 0, ...contentStyle }}\n >\n {this.props.children}\n </BaseDialog.Content>\n {footer ||\n (buttons && (\n <BaseDialog.ButtonBar style={footerStyle}>\n {buttons}\n </BaseDialog.ButtonBar>\n ))}\n </BaseDialog.Main>\n </DivWithOutsideClick>\n </BaseDialog>\n );\n }\n\n // eslint-disable-next-line deprecation/deprecation\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Top:\n return \"core-align-top\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Left:\n return \"core-align-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Center:\n return \"core-align-center\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Right:\n return \"core-align-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n /** @deprecated in 4.12.x. Use iTwinUI Button instead. */\n protected getFooterButtons(\n buttonCluster: DialogButtonDef[] | undefined,\n primaryStyleType: ButtonProps[\"styleType\"] = \"cta\",\n noCoreButtonClasses: boolean = false\n ): React.ReactNode[] | undefined {\n if (buttonCluster === undefined) return undefined;\n\n const buttons: React.ReactNode[] = [];\n buttonCluster.forEach((button: DialogButtonDef, index: number) => {\n buttons.push(\n <DialogButton\n key={index.toString()}\n button={button}\n primaryStyleType={primaryStyleType}\n noCoreButtonClasses={noCoreButtonClasses}\n />\n );\n });\n return buttons;\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === Key.Escape.valueOf() &&\n this.props.opened &&\n this.props.onEscape\n ) {\n this.props.onEscape();\n }\n };\n\n protected _handleContainerPointerDown = (event: React.PointerEvent): void => {\n // istanbul ignore next\n if (!this.props.modal) {\n if (this.props.onModelessPointerDown && this.props.modelessId)\n this.props.onModelessPointerDown(event, this.props.modelessId);\n }\n };\n}\n\nfunction DialogButton({\n button,\n primaryStyleType,\n noCoreButtonClasses,\n}: {\n button: DialogButtonDef;\n primaryStyleType: ButtonProps[\"styleType\"];\n noCoreButtonClasses: boolean;\n}) {\n const { translate } = useTranslation();\n\n let buttonText = \"\";\n\n let buttonClass = classnames(\n !noCoreButtonClasses && \"core-dialog-button\",\n !noCoreButtonClasses && `dialog-button-${button.type}`,\n button.className\n );\n let usePrimaryStyleType = false;\n\n switch (button.type) {\n case DialogButtonType.OK:\n buttonText = translate(\"dialog.ok\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Retry:\n buttonText = translate(\"dialog.retry\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Yes:\n buttonText = translate(\"dialog.yes\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.No:\n buttonText = translate(\"dialog.no\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Cancel:\n buttonText = translate(\"dialog.cancel\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Close:\n buttonText = translate(\"dialog.close\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Next:\n buttonText = translate(\"dialog.next\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Previous:\n buttonText = translate(\"dialog.previous\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n }\n\n buttonText = button.label || buttonText;\n\n return (\n <Button\n className={buttonClass}\n disabled={button.disabled}\n styleType={usePrimaryStyleType ? primaryStyleType : undefined}\n onClick={button.onClick}\n >\n {buttonText}\n </Button>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalDialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/GlobalDialog.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sCAAsC;AAEtC,qCAAkC;AAmBlC;;;GAGG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAKvC;IAQC,mDAAmD;IACnD,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QAPf,mDAAmD;QAC1B,UAAK,GAAsB;YAClD,cAAc,EAAE,IAAI;SACrB,CAAC;QAOM,kBAAa,GAAG,CAAC,QAA4B,EAAE,EAAE;YACvD,MAAM,cAAc,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;YACvD,IAAI,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":"GlobalDialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/GlobalDialog.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sCAAsC;AAEtC,qCAAkC;AAmBlC;;;GAGG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAKvC;IAQC,mDAAmD;IACnD,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QAPf,mDAAmD;QAC1B,UAAK,GAAsB;YAClD,cAAc,EAAE,IAAI;SACrB,CAAC;QAOM,kBAAa,GAAG,CAAC,QAA4B,EAAE,EAAE;YACvD,MAAM,cAAc,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;YACvD,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,CAAC,UAAU,CAAC,EAAE;oBAChB,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;wBACjC,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;wBACnC,CAAC,CAAC,aAAa,CAAC;gBACpB,IAAI,EAAE,GAAG,cAAc,CAAC,cAAc,CACpC,kBAAkB,CACD,CAAC;gBACpB,IAAI,CAAC,EAAE,EAAE,CAAC;oBACR,EAAE,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;oBACzC,EAAE,CAAC,EAAE,GAAG,kBAAkB,CAAC;oBAC3B,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;gBACtC,CAAC;gBACD,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAEhC,wDAAwD;gBACxD,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;IAvBF,CAAC;IAyBe,oBAAoB;QAClC,uBAAuB;QACvB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACrD,UAAU;YACV,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5C,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,aAAa,IACzB,IAAI,CAAC,KAAK,CAAC,cAAc;YACxB,QAAQ,CAAC,YAAY;YACnB,mDAAmD;YACnD,oBAAC,eAAM,OAAK,KAAK,GAAI,EACrB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAC/B,CACC,CACP,CAAC;IACJ,CAAC;CACF;AA9DD,oCA8DC","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 Dialog\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { DialogProps } from \"./Dialog\";\nimport { Dialog } from \"./Dialog\";\n\n/** Properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link GlobalDialog}.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface GlobalDialogProps extends DialogProps {\n identifier?: string;\n}\n\n/** State properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.x. State of deprecated component {@link GlobalDialog}.\n */\nexport interface GlobalDialogState {\n parentDocument: Document | null;\n}\n\n/** GlobalDialog React component used to display a [[Dialog]] on the top of screen\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\nexport class GlobalDialog extends React.Component<\n // eslint-disable-next-line deprecation/deprecation\n GlobalDialogProps,\n // eslint-disable-next-line deprecation/deprecation\n GlobalDialogState\n> {\n private _container?: HTMLDivElement;\n\n // eslint-disable-next-line deprecation/deprecation\n public override readonly state: GlobalDialogState = {\n parentDocument: null,\n };\n\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: GlobalDialogProps) {\n super(props);\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-dialog\";\n let rt = parentDocument.getElementById(\n \"core-dialog-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-dialog-root\";\n parentDocument.body.appendChild(rt);\n }\n rt.appendChild(this._container);\n\n // used to support component rendering in pop-out window\n this.setState({ parentDocument });\n }\n };\n\n public override componentWillUnmount() {\n // istanbul ignore else\n if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n public override render(): React.ReactNode {\n const { identifier, ...props } = this.props;\n return (\n <div ref={this._handleRefSet}>\n {this.state.parentDocument &&\n ReactDOM.createPortal(\n // eslint-disable-next-line deprecation/deprecation\n <Dialog {...props} />,\n this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementSeparator.js","sourceRoot":"","sources":["../../../../src/core-react/elementseparator/ElementSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,mCAAiC;AACjC,+BAA+B;AAC/B,iCAOe;AACf,2CAAoC;AACpC,sDAAmD;AAEnD,kEAA+D;AAC/D,2DAAwD;AAoCxD,SAAS,wBAAwB,CAC/B,WAAwB,EACxB,CAAoC;IAEpC,OAAO,WAAW,KAAK,yBAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,qBAAqB,GAAG,CAAC,SAAkB,EAAE,OAAmB,EAAE,EAAE;IACxE,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,SAAS,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,OAAO,CAAC,CAAC;IAEnC,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;IACjC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO;gBAAE,UAAU,CAAC,OAAO,EAAE,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,iCAAiC,GAAG,CAAC,EACzC,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,WAAW,EACX,KAAK,EACL,WAAW,EACX,cAAc,G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AAU,EAC3B,wBAAwB,EACxB,KAAK,CAAC,WAAW,KAAK,yBAAW,CAAC,UAAU;QAC1C,CAAC,CAAC,oCAAoC;QACtC,CAAC,CAAC,kCAAkC,EACtC,KAAK,CAAC,SAAS,EACf,aAAa,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,YAAY,CACtE,CAAC;IAEF,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,EAC1C,CAAC,WAAW,EAAE,aAAa,CAAC,CAC7B,CAAC;IACF,MAAM,MAAM,GAAwB;QAClC,GAAG,KAAK;QACR,GAAG,KAAK,CAAC,KAAK;KACf,CAAC;IAEF,OAAO,CACL,gCACE,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,gBACd,SAAS,CAAC,wBAAwB,CAAC,GAC/C,CACH,CAAC;AACJ,CAAC,CAAC;AA7CW,QAAA,gBAAgB,oBA6C3B","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 ElementSeparator\n */\n\nimport \"./ElementSeparator.scss\";\nimport * as React from \"react\";\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classnames from \"classnames\";\nimport { Orientation } from \"../enums/Orientation\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { useThrottledFn } from \"../utils/hooks/useThrottledFn\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/** Results returned by onRatioChanged callback for determining new ratio and whether the ratio was updated.\n * @public\n * @deprecated in 4.12.x. Interface used in a deprecated component {@link ElementSeparator}.\n */\nexport interface RatioChangeResult {\n ratio: number;\n}\n\n/** Properties of [[ElementSeparator]] React component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link ElementSeparator}.\n */\nexport interface ElementSeparatorProps extends CommonProps {\n /** Separator orientation */\n orientation: Orientation;\n /** Ratio between left cell and right cell */\n ratio: number;\n /** Area width or height (depending on orientation) in pixels */\n movableArea?: number;\n /** Separator width or height in pixels. 30 by default */\n separatorSize?: number;\n /** Callback to ratio changed event */\n // eslint-disable-next-line deprecation/deprecation\n onRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n}\n\nfunction getCurrentGlobalPosition(\n orientation: Orientation,\n e: PointerEvent | React.PointerEvent\n) {\n return orientation === Orientation.Horizontal ? e.clientX : e.clientY;\n}\n\nconst useConditionalCleanup = (condition: boolean, cleanup: () => void) => {\n const conditionRef = useRef(condition);\n const cleanupRef = useRef(cleanup);\n\n conditionRef.current = condition;\n cleanupRef.current = cleanup;\n\n useEffect(() => {\n return () => {\n if (conditionRef.current) cleanupRef.current();\n };\n }, []);\n};\n\nconst useElementSeparatorPointerHandler = ({\n onResizeHandleDragChanged,\n onResizeHandleHoverChanged,\n isResizeHandleBeingDragged,\n isResizeHandleHovered,\n movableArea,\n ratio,\n orientation,\n onRatioChanged,\n}: // eslint-disable-next-line deprecation/deprecation\nElementSeparatorProps) => {\n const globalPosition = useRef(0);\n const pointerOutOfBounds = useRef(false);\n\n const [isElementDragged, setIsDragged] = useState(false);\n const [isElementHovered, setIsHovered] = useState(false);\n const isGroupDragged = isResizeHandleBeingDragged ?? isElementDragged;\n const isGroupHovered = isResizeHandleHovered ?? isElementHovered;\n\n useConditionalCleanup(isElementDragged && !!onResizeHandleDragChanged, () =>\n onResizeHandleDragChanged!(false)\n );\n useConditionalCleanup(isElementHovered && !!onResizeHandleHoverChanged, () =>\n onResizeHandleHoverChanged!(false)\n );\n\n if (isGroupHovered && pointerOutOfBounds.current)\n pointerOutOfBounds.current = false;\n\n const stopDrag = useCallback(() => {\n // istanbul ignore else\n if (isGroupDragged) {\n setIsDragged(false);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(false);\n }\n }, [isGroupDragged, onResizeHandleDragChanged]);\n\n const startDrag = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n globalPosition.current = getCurrentGlobalPosition(orientation, e);\n\n // istanbul ignore else\n if (!isGroupDragged) {\n setIsDragged(true);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(true);\n }\n },\n [isGroupDragged, orientation, onResizeHandleDragChanged]\n );\n\n const onPointerUp = useCallback(() => {\n stopDrag();\n }, [stopDrag]);\n\n const onThrottledPointerMove = useThrottledFn(\n (e: PointerEvent | React.PointerEvent) => {\n if (!movableArea) {\n stopDrag();\n return;\n }\n\n const currentPosition = getCurrentGlobalPosition(orientation, e);\n const positionChange = currentPosition - globalPosition.current;\n\n // Should not need to recalculate if position on our movement axis does not change\n if (Math.abs(positionChange) < 1) return;\n\n const currentLocalPosition = movableArea * ratio + positionChange;\n const newRatio = currentLocalPosition / movableArea;\n\n globalPosition.current = currentPosition;\n if (pointerOutOfBounds.current || !onRatioChanged) return;\n\n const result = onRatioChanged(newRatio);\n if (\n result &&\n result.ratio === ratio &&\n !isGroupHovered &&\n !pointerOutOfBounds.current\n )\n pointerOutOfBounds.current = true;\n },\n 16,\n [stopDrag, isGroupHovered, ratio, movableArea, onRatioChanged, orientation]\n );\n\n useEffect(() => {\n return () => onThrottledPointerMove.cancel();\n }, [onThrottledPointerMove]);\n\n useLayoutEffect(() => {\n if (isElementDragged) {\n document.addEventListener(\"pointerup\", onPointerUp);\n document.addEventListener(\"pointermove\", onThrottledPointerMove);\n }\n\n return () => {\n document.removeEventListener(\"pointerup\", onPointerUp);\n document.removeEventListener(\"pointermove\", onThrottledPointerMove);\n };\n }, [isElementDragged, onPointerUp, onThrottledPointerMove]);\n\n const onPointerDown = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n if (!isGroupDragged) {\n startDrag(e);\n } else {\n stopDrag();\n }\n },\n [isGroupDragged, startDrag, stopDrag]\n );\n\n const onPointerOver = useCallback(() => {\n // istanbul ignore next\n if (isGroupHovered) return;\n\n setIsHovered(true);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(true);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n const onPointerOut = useCallback(() => {\n // istanbul ignore next\n if (!isGroupHovered) return;\n\n setIsHovered(false);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(false);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n return {\n isHovered: isGroupHovered,\n isDragged: isGroupDragged,\n onPointerDown,\n onPointerOver,\n onPointerOut,\n };\n};\n\nfunction getStyle(\n orientation: Orientation,\n separatorSize?: number\n): React.CSSProperties {\n separatorSize = separatorSize || 30;\n\n if (orientation === Orientation.Horizontal)\n return {\n width: separatorSize,\n margin: `0px ${-Math.floor(separatorSize / 2)}px`,\n };\n return {\n height: separatorSize,\n margin: `${-Math.floor(separatorSize / 2)}px 1px`,\n };\n}\n\n/** A movable button, which allows to change the ratio between left element and right element\n * @public\n * @deprecated in 4.12.x. Basic components that need to be user-resized support this out of the box. Use {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent pointer events} API to implement a custom resizer.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport const ElementSeparator = (props: ElementSeparatorProps) => {\n const { translate } = useTranslation();\n\n const [hasHoverHappened, setHasHoverHappened] = useState(false);\n const { isDragged, isHovered, onPointerDown, onPointerOver, onPointerOut } =\n useElementSeparatorPointerHandler(props);\n\n const isHoverNeeded = isHovered || isDragged;\n if (!hasHoverHappened && isHoverNeeded) setHasHoverHappened(isHoverNeeded);\n\n // This is done to avoid fade-out animation when first rendering.\n const unhoverClass = hasHoverHappened\n ? \"core-element-separator-group-unhovered\"\n : \"\";\n\n const classNames = classnames(\n \"core-element-separator\",\n props.orientation === Orientation.Horizontal\n ? \"core-element-separator--horizontal\"\n : \"core-element-separator--vertical\",\n props.className,\n isHoverNeeded ? \"core-element-separator-group-hovered\" : unhoverClass\n );\n\n const orientation = props.orientation;\n const separatorSize = props.separatorSize;\n const style = useMemo(\n () => getStyle(orientation, separatorSize),\n [orientation, separatorSize]\n );\n const styles: React.CSSProperties = {\n ...style,\n ...props.style,\n };\n\n return (\n <button\n style={styles}\n className={classNames}\n onPointerDown={onPointerDown}\n onPointerOver={onPointerOver}\n onPointerOut={onPointerOut}\n aria-label={translate(\"elementSeparator.label\")}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ElementSeparator.js","sourceRoot":"","sources":["../../../../src/core-react/elementseparator/ElementSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,mCAAiC;AACjC,+BAA+B;AAC/B,iCAOe;AACf,2CAAoC;AACpC,sDAAmD;AAEnD,kEAA+D;AAC/D,2DAAwD;AAoCxD,SAAS,wBAAwB,CAC/B,WAAwB,EACxB,CAAoC;IAEpC,OAAO,WAAW,KAAK,yBAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,qBAAqB,GAAG,CAAC,SAAkB,EAAE,OAAmB,EAAE,EAAE;IACxE,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,SAAS,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,OAAO,CAAC,CAAC;IAEnC,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;IACjC,UAAU,CAAC,OAAO,GAAG,OAA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------------\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 ElementSeparator\n */\n\nimport \"./ElementSeparator.scss\";\nimport * as React from \"react\";\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classnames from \"classnames\";\nimport { Orientation } from \"../enums/Orientation\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { useThrottledFn } from \"../utils/hooks/useThrottledFn\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/** Results returned by onRatioChanged callback for determining new ratio and whether the ratio was updated.\n * @public\n * @deprecated in 4.12.x. Interface used in a deprecated component {@link ElementSeparator}.\n */\nexport interface RatioChangeResult {\n ratio: number;\n}\n\n/** Properties of [[ElementSeparator]] React component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link ElementSeparator}.\n */\nexport interface ElementSeparatorProps extends CommonProps {\n /** Separator orientation */\n orientation: Orientation;\n /** Ratio between left cell and right cell */\n ratio: number;\n /** Area width or height (depending on orientation) in pixels */\n movableArea?: number;\n /** Separator width or height in pixels. 30 by default */\n separatorSize?: number;\n /** Callback to ratio changed event */\n // eslint-disable-next-line deprecation/deprecation\n onRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n}\n\nfunction getCurrentGlobalPosition(\n orientation: Orientation,\n e: PointerEvent | React.PointerEvent\n) {\n return orientation === Orientation.Horizontal ? e.clientX : e.clientY;\n}\n\nconst useConditionalCleanup = (condition: boolean, cleanup: () => void) => {\n const conditionRef = useRef(condition);\n const cleanupRef = useRef(cleanup);\n\n conditionRef.current = condition;\n cleanupRef.current = cleanup;\n\n useEffect(() => {\n return () => {\n if (conditionRef.current) cleanupRef.current();\n };\n }, []);\n};\n\nconst useElementSeparatorPointerHandler = ({\n onResizeHandleDragChanged,\n onResizeHandleHoverChanged,\n isResizeHandleBeingDragged,\n isResizeHandleHovered,\n movableArea,\n ratio,\n orientation,\n onRatioChanged,\n}: // eslint-disable-next-line deprecation/deprecation\nElementSeparatorProps) => {\n const globalPosition = useRef(0);\n const pointerOutOfBounds = useRef(false);\n\n const [isElementDragged, setIsDragged] = useState(false);\n const [isElementHovered, setIsHovered] = useState(false);\n const isGroupDragged = isResizeHandleBeingDragged ?? isElementDragged;\n const isGroupHovered = isResizeHandleHovered ?? isElementHovered;\n\n useConditionalCleanup(isElementDragged && !!onResizeHandleDragChanged, () =>\n onResizeHandleDragChanged!(false)\n );\n useConditionalCleanup(isElementHovered && !!onResizeHandleHoverChanged, () =>\n onResizeHandleHoverChanged!(false)\n );\n\n if (isGroupHovered && pointerOutOfBounds.current)\n pointerOutOfBounds.current = false;\n\n const stopDrag = useCallback(() => {\n // istanbul ignore else\n if (isGroupDragged) {\n setIsDragged(false);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(false);\n }\n }, [isGroupDragged, onResizeHandleDragChanged]);\n\n const startDrag = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n globalPosition.current = getCurrentGlobalPosition(orientation, e);\n\n // istanbul ignore else\n if (!isGroupDragged) {\n setIsDragged(true);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(true);\n }\n },\n [isGroupDragged, orientation, onResizeHandleDragChanged]\n );\n\n const onPointerUp = useCallback(() => {\n stopDrag();\n }, [stopDrag]);\n\n const onThrottledPointerMove = useThrottledFn(\n (e: PointerEvent | React.PointerEvent) => {\n if (!movableArea) {\n stopDrag();\n return;\n }\n\n const currentPosition = getCurrentGlobalPosition(orientation, e);\n const positionChange = currentPosition - globalPosition.current;\n\n // Should not need to recalculate if position on our movement axis does not change\n if (Math.abs(positionChange) < 1) return;\n\n const currentLocalPosition = movableArea * ratio + positionChange;\n const newRatio = currentLocalPosition / movableArea;\n\n globalPosition.current = currentPosition;\n if (pointerOutOfBounds.current || !onRatioChanged) return;\n\n const result = onRatioChanged(newRatio);\n if (\n result &&\n result.ratio === ratio &&\n !isGroupHovered &&\n !pointerOutOfBounds.current\n )\n pointerOutOfBounds.current = true;\n },\n 16,\n [stopDrag, isGroupHovered, ratio, movableArea, onRatioChanged, orientation]\n );\n\n useEffect(() => {\n return () => onThrottledPointerMove.cancel();\n }, [onThrottledPointerMove]);\n\n useLayoutEffect(() => {\n if (isElementDragged) {\n document.addEventListener(\"pointerup\", onPointerUp);\n document.addEventListener(\"pointermove\", onThrottledPointerMove);\n }\n\n return () => {\n document.removeEventListener(\"pointerup\", onPointerUp);\n document.removeEventListener(\"pointermove\", onThrottledPointerMove);\n };\n }, [isElementDragged, onPointerUp, onThrottledPointerMove]);\n\n const onPointerDown = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n if (!isGroupDragged) {\n startDrag(e);\n } else {\n stopDrag();\n }\n },\n [isGroupDragged, startDrag, stopDrag]\n );\n\n const onPointerOver = useCallback(() => {\n // istanbul ignore next\n if (isGroupHovered) return;\n\n setIsHovered(true);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(true);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n const onPointerOut = useCallback(() => {\n // istanbul ignore next\n if (!isGroupHovered) return;\n\n setIsHovered(false);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(false);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n return {\n isHovered: isGroupHovered,\n isDragged: isGroupDragged,\n onPointerDown,\n onPointerOver,\n onPointerOut,\n };\n};\n\nfunction getStyle(\n orientation: Orientation,\n separatorSize?: number\n): React.CSSProperties {\n separatorSize = separatorSize || 30;\n\n if (orientation === Orientation.Horizontal)\n return {\n width: separatorSize,\n margin: `0px ${-Math.floor(separatorSize / 2)}px`,\n };\n return {\n height: separatorSize,\n margin: `${-Math.floor(separatorSize / 2)}px 1px`,\n };\n}\n\n/** A movable button, which allows to change the ratio between left element and right element\n * @public\n * @deprecated in 4.12.x. Basic components that need to be user-resized support this out of the box. Use {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent pointer events} API to implement a custom resizer.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport const ElementSeparator = (props: ElementSeparatorProps) => {\n const { translate } = useTranslation();\n\n const [hasHoverHappened, setHasHoverHappened] = useState(false);\n const { isDragged, isHovered, onPointerDown, onPointerOver, onPointerOut } =\n useElementSeparatorPointerHandler(props);\n\n const isHoverNeeded = isHovered || isDragged;\n if (!hasHoverHappened && isHoverNeeded) setHasHoverHappened(isHoverNeeded);\n\n // This is done to avoid fade-out animation when first rendering.\n const unhoverClass = hasHoverHappened\n ? \"core-element-separator-group-unhovered\"\n : \"\";\n\n const classNames = classnames(\n \"core-element-separator\",\n props.orientation === Orientation.Horizontal\n ? \"core-element-separator--horizontal\"\n : \"core-element-separator--vertical\",\n props.className,\n isHoverNeeded ? \"core-element-separator-group-hovered\" : unhoverClass\n );\n\n const orientation = props.orientation;\n const separatorSize = props.separatorSize;\n const style = useMemo(\n () => getStyle(orientation, separatorSize),\n [orientation, separatorSize]\n );\n const styles: React.CSSProperties = {\n ...style,\n ...props.style,\n };\n\n return (\n <button\n style={styles}\n className={classNames}\n onPointerDown={onPointerDown}\n onPointerOver={onPointerOver}\n onPointerOut={onPointerOut}\n aria-label={translate(\"elementSeparator.label\")}\n />\n );\n};\n"]}
|
|
@@ -18,7 +18,7 @@ var HorizontalAlignment;
|
|
|
18
18
|
HorizontalAlignment["Center"] = "center";
|
|
19
19
|
HorizontalAlignment["Right"] = "right";
|
|
20
20
|
HorizontalAlignment["Justify"] = "justify";
|
|
21
|
-
})(HorizontalAlignment
|
|
21
|
+
})(HorizontalAlignment || (exports.HorizontalAlignment = HorizontalAlignment = {}));
|
|
22
22
|
/**
|
|
23
23
|
* Enumeration for vertical alignment.
|
|
24
24
|
* @public
|
|
@@ -28,5 +28,5 @@ var VerticalAlignment;
|
|
|
28
28
|
VerticalAlignment[VerticalAlignment["Top"] = 1] = "Top";
|
|
29
29
|
VerticalAlignment[VerticalAlignment["Middle"] = 2] = "Middle";
|
|
30
30
|
VerticalAlignment[VerticalAlignment["Bottom"] = 3] = "Bottom";
|
|
31
|
-
})(VerticalAlignment
|
|
31
|
+
})(VerticalAlignment || (exports.VerticalAlignment = VerticalAlignment = {}));
|
|
32
32
|
//# sourceMappingURL=Alignment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alignment.js","sourceRoot":"","sources":["../../../../src/core-react/enums/Alignment.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,oCAAa,CAAA;IACb,wCAAiB,CAAA;IACjB,sCAAe,CAAA;IACf,0CAAmB,CAAA;AACrB,CAAC,EALW,mBAAmB,
|
|
1
|
+
{"version":3,"file":"Alignment.js","sourceRoot":"","sources":["../../../../src/core-react/enums/Alignment.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,oCAAa,CAAA;IACb,wCAAiB,CAAA;IACjB,sCAAe,CAAA;IACf,0CAAmB,CAAA;AACrB,CAAC,EALW,mBAAmB,mCAAnB,mBAAmB,QAK9B;AAED;;;GAGG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,uDAAO,CAAA;IACP,6DAAU,CAAA;IACV,6DAAU,CAAA;AACZ,CAAC,EAJW,iBAAiB,iCAAjB,iBAAiB,QAI5B","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 Common\n */\n\n/**\n * Enumeration for horizontal alignment.\n * @public\n */\nexport enum HorizontalAlignment {\n Left = \"left\",\n Center = \"center\",\n Right = \"right\",\n Justify = \"justify\",\n}\n\n/**\n * Enumeration for vertical alignment.\n * @public\n */\nexport enum VerticalAlignment {\n Top = 1,\n Middle = 2,\n Bottom = 3,\n}\n"]}
|
|
@@ -16,5 +16,5 @@ var CheckBoxState;
|
|
|
16
16
|
CheckBoxState[CheckBoxState["Off"] = 0] = "Off";
|
|
17
17
|
CheckBoxState[CheckBoxState["On"] = 1] = "On";
|
|
18
18
|
CheckBoxState[CheckBoxState["Partial"] = 2] = "Partial";
|
|
19
|
-
})(CheckBoxState
|
|
19
|
+
})(CheckBoxState || (exports.CheckBoxState = CheckBoxState = {}));
|
|
20
20
|
//# sourceMappingURL=CheckBoxState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBoxState.js","sourceRoot":"","sources":["../../../../src/core-react/enums/CheckBoxState.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+CAAG,CAAA;IACH,6CAAE,CAAA;IACF,uDAAO,CAAA;AACT,CAAC,EAJW,aAAa,
|
|
1
|
+
{"version":3,"file":"CheckBoxState.js","sourceRoot":"","sources":["../../../../src/core-react/enums/CheckBoxState.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+CAAG,CAAA;IACH,6CAAE,CAAA;IACF,uDAAO,CAAA;AACT,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB","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 Common\n */\n\n/** State of a checkbox\n * @public\n */\nexport enum CheckBoxState {\n Off,\n On,\n Partial,\n}\n\n/** A data type that holds all the checkbox display attributes\n * @public\n */\nexport interface CheckBoxInfo {\n isVisible?: boolean;\n isDisabled?: boolean;\n state?: CheckBoxState;\n tooltip?: string;\n}\n"]}
|
|
@@ -16,5 +16,5 @@ var Orientation;
|
|
|
16
16
|
(function (Orientation) {
|
|
17
17
|
Orientation[Orientation["Horizontal"] = 0] = "Horizontal";
|
|
18
18
|
Orientation[Orientation["Vertical"] = 1] = "Vertical";
|
|
19
|
-
})(Orientation
|
|
19
|
+
})(Orientation || (exports.Orientation = Orientation = {}));
|
|
20
20
|
//# sourceMappingURL=Orientation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orientation.js","sourceRoot":"","sources":["../../../../src/core-react/enums/Orientation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,yDAAU,CAAA;IACV,qDAAQ,CAAA;AACV,CAAC,EAHW,WAAW,
|
|
1
|
+
{"version":3,"file":"Orientation.js","sourceRoot":"","sources":["../../../../src/core-react/enums/Orientation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,yDAAU,CAAA;IACV,qDAAQ,CAAA;AACV,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB","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 Common\n */\n\n/**\n * Enumeration of orientation.\n * @public\n */\nexport enum Orientation {\n Horizontal,\n Vertical,\n}\n"]}
|
|
@@ -17,5 +17,5 @@ var SortDirection;
|
|
|
17
17
|
SortDirection[SortDirection["NoSort"] = 0] = "NoSort";
|
|
18
18
|
SortDirection[SortDirection["Ascending"] = 1] = "Ascending";
|
|
19
19
|
SortDirection[SortDirection["Descending"] = 2] = "Descending";
|
|
20
|
-
})(SortDirection
|
|
20
|
+
})(SortDirection || (exports.SortDirection = SortDirection = {}));
|
|
21
21
|
//# sourceMappingURL=SortDirection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortDirection.js","sourceRoot":"","sources":["../../../../src/core-react/enums/SortDirection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,qDAAM,CAAA;IACN,2DAAS,CAAA;IACT,6DAAU,CAAA;AACZ,CAAC,EAJW,aAAa,
|
|
1
|
+
{"version":3,"file":"SortDirection.js","sourceRoot":"","sources":["../../../../src/core-react/enums/SortDirection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,qDAAM,CAAA;IACN,2DAAS,CAAA;IACT,6DAAU,CAAA;AACZ,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB","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 Common\n */\n\n/**\n * Enumeration for sorting direction.\n * @public\n */\nexport enum SortDirection {\n NoSort,\n Ascending,\n Descending,\n}\n"]}
|
|
@@ -19,5 +19,5 @@ var TimeFormat;
|
|
|
19
19
|
TimeFormat[TimeFormat["Short"] = 1] = "Short";
|
|
20
20
|
/** Show Date Time using toLocaleString */
|
|
21
21
|
TimeFormat[TimeFormat["Long"] = 2] = "Long";
|
|
22
|
-
})(TimeFormat
|
|
22
|
+
})(TimeFormat || (exports.TimeFormat = TimeFormat = {}));
|
|
23
23
|
//# sourceMappingURL=TimeFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeFormat.js","sourceRoot":"","sources":["../../../../src/core-react/enums/TimeFormat.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;GAEG;AACH,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,2CAA2C;IAC3C,2CAAQ,CAAA;IACR,yCAAyC;IACzC,6CAAK,CAAA;IACL,0CAA0C;IAC1C,2CAAI,CAAA;AACN,CAAC,EAPW,UAAU,
|
|
1
|
+
{"version":3,"file":"TimeFormat.js","sourceRoot":"","sources":["../../../../src/core-react/enums/TimeFormat.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;GAEG;AACH,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,2CAA2C;IAC3C,2CAAQ,CAAA;IACR,yCAAyC;IACzC,6CAAK,CAAA;IACL,0CAA0C;IAC1C,2CAAI,CAAA;AACN,CAAC,EAPW,UAAU,0BAAV,UAAU,QAOrB","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 Common\n */\n\n/** Enumeration of time formats.\n * @public\n */\nexport enum TimeFormat {\n /** Show Date and time using toISOString */\n None = 0,\n /** Show Date using toLocaleDateString */\n Short,\n /** Show Date Time using toLocaleString */\n Long,\n}\n"]}
|
|
@@ -54,10 +54,10 @@ class ExpandableList extends React.PureComponent {
|
|
|
54
54
|
return (React.createElement("div", { className: (0, classnames_1.default)("uicore-expandable-blocks-list", this.props.className), style: this.props.style }, this.renderBlocks()));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
exports.ExpandableList = ExpandableList;
|
|
57
58
|
// eslint-disable-next-line deprecation/deprecation
|
|
58
59
|
ExpandableList.defaultProps = {
|
|
59
60
|
singleExpandOnly: false,
|
|
60
61
|
defaultActiveBlock: 0,
|
|
61
62
|
};
|
|
62
|
-
exports.ExpandableList = ExpandableList;
|
|
63
63
|
//# sourceMappingURL=ExpandableList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandableList.js","sourceRoot":"","sources":["../../../../src/core-react/expandable/ExpandableList.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,2CAAoC;AACpC,+BAA+B;AAsB/B;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK,CAAC,aAIzC;IACC,mDAAmD;IACnD,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAWf,mBAAmB;QACX,uBAAkB,GAAG,CAC3B,KAAa,EACb,QAAuC,EACvC,EAAE;YACF,IAAI,WAAW,GAAG,KAAK,CAAC;YAExB,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW;gBACpE,WAAW,GAAG,CAAC,CAAC,CAAC;YAEnB,IAAI,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;YAE/B,uBAAuB;YACvB,IAAI,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"ExpandableList.js","sourceRoot":"","sources":["../../../../src/core-react/expandable/ExpandableList.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,2CAAoC;AACpC,+BAA+B;AAsB/B;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK,CAAC,aAIzC;IACC,mDAAmD;IACnD,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAWf,mBAAmB;QACX,uBAAkB,GAAG,CAC3B,KAAa,EACb,QAAuC,EACvC,EAAE;YACF,IAAI,WAAW,GAAG,KAAK,CAAC;YAExB,IAAI,IAAI,CAAC,KAAK,CA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E,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,kBAAmB,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,OAAO,CACL,6BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,+BAA+B,EAC/B,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAEtB,IAAI,CAAC,YAAY,EAAE,CAChB,CACP,CAAC;IACJ,CAAC;;AAvEH,wCAwEC;AA5DC,mDAAmD;AACrC,2BAAY,GAAiC;IACzD,gBAAgB,EAAE,KAAK;IACvB,kBAAkB,EAAE,CAAC;CACtB,AAHyB,CAGxB","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 Expandable\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for [[ExpandableList]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link ExpandableList}.\n */\nexport interface ExpandableListProps extends CommonProps {\n /** Index of the default active block */\n defaultActiveBlock?: number;\n /** Indicates whether to allow only one expanded block */\n singleExpandOnly?: boolean;\n /** Indicates whether the single expanded block is collapsible */\n singleIsCollapsible?: boolean;\n /** Content */\n children?: React.ReactNode;\n}\n\ninterface ExpandableListState {\n activeBlock: number;\n}\n\n/** ExpandableList React component is a container for ExpandableBlock components.\n * @public\n * @deprecated in 4.12.x. Use a custom container and manage {@link https://itwinui.bentley.com/docs/expandableblock expandable block} state manually.\n */\nexport class ExpandableList extends React.PureComponent<\n // eslint-disable-next-line deprecation/deprecation\n ExpandableListProps,\n ExpandableListState\n> {\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: ExpandableListProps) {\n super(props);\n\n this.state = { activeBlock: this.props.defaultActiveBlock! };\n }\n\n // eslint-disable-next-line deprecation/deprecation\n public static defaultProps: Partial<ExpandableListProps> = {\n singleExpandOnly: false,\n defaultActiveBlock: 0,\n };\n\n // set active block\n private _handleBlockToggle = (\n index: number,\n onToggle: (isExpanding: boolean) => any\n ) => {\n let activeBlock = index;\n\n if (this.props.singleIsCollapsible && index === this.state.activeBlock)\n activeBlock = -1;\n\n this.setState({ activeBlock });\n\n // istanbul ignore else\n if (onToggle) {\n onToggle(activeBlock === index); // fire the ExpandableBlock onToggle\n }\n };\n\n private renderBlocks() {\n return React.Children.map(this.props.children, (child: any, i) => {\n return React.cloneElement(child, {\n key: i,\n isExpanded: this.props.singleExpandOnly\n ? i === this.state.activeBlock\n : child.props.isExpanded,\n onToggle: this._handleBlockToggle.bind(this, i, child.props.onToggle),\n });\n });\n }\n\n /** @internal */\n // eslint-disable-next-line deprecation/deprecation\n public override componentDidUpdate(prevProps: ExpandableListProps) {\n if (\n this.props.defaultActiveBlock !== prevProps.defaultActiveBlock &&\n this.props.defaultActiveBlock !== this.state.activeBlock\n ) {\n this.setState((_, props) => ({ activeBlock: props.defaultActiveBlock! }));\n }\n }\n\n public override render(): React.ReactElement {\n return (\n <div\n className={classnames(\n \"uicore-expandable-blocks-list\",\n this.props.className\n )}\n style={this.props.style}\n >\n {this.renderBlocks()}\n </div>\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,6CAAkC;AAClC,sDAAmD;AAOnD;;GAEG;AACH,MAAa,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,yBAAW,CAAC,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AAK,iBAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAChC,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 Focus\n */\n\nimport { Key } from \"ts-key-enum\";\nimport { Orientation } from \"../enums/Orientation\";\n\n/** Cross-Axis Arrow Key Callback\n * @internal\n */\nexport type CrossAxisArrowKeyFunc = (forward: boolean) => void;\n\n/** Keyboard Navigator for parent components\n * @internal\n */\nexport class ItemKeyboardNavigator {\n private _direction: Map<string, number>;\n private _itemCount = 0;\n private _orientation = Orientation.Horizontal;\n private _allowWrap = true;\n private _crossAxisArrowKeyHandler?: CrossAxisArrowKeyFunc;\n\n constructor(\n public onFocusItem: (index: number) => void,\n public onActivateItem: (index: number) => void\n ) {\n this._direction = new Map<string, number>([\n [Key.ArrowLeft, -1],\n [Key.ArrowUp, -1],\n [Key.ArrowRight, 1],\n [Key.ArrowDown, 1],\n ]);\n }\n\n /** The item count */\n public get itemCount(): number {\n return this._itemCount;\n }\n public set itemCount(count: number) {\n this._itemCount = count;\n }\n\n /** The primary orientation */\n public get orientation(): Orientation {\n return this._orientation;\n }\n public set orientation(orientation: Orientation) {\n this._orientation = orientation;\n }\n\n /** The allow wrap property controls whether the movement will stop at the first and last items or wrap */\n public get allowWrap(): boolean {\n return this._allowWrap;\n }\n public set allowWrap(v: boolean) {\n this._allowWrap = v;\n }\n\n /** Called when the arrow keys that run perpendicular to the primary orientation are pressed */\n public get crossAxisArrowKeyHandler(): CrossAxisArrowKeyFunc | undefined {\n return this._crossAxisArrowKeyHandler;\n }\n public set crossAxisArrowKeyHandler(v: CrossAxisArrowKeyFunc | undefined) {\n this._crossAxisArrowKeyHandler = v;\n }\n\n /** Handle KeyDown on items */\n public handleKeyDownEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.Home.valueOf():\n event.preventDefault();\n // Activate first item\n this.focusFirstItem();\n break;\n case Key.End.valueOf():\n event.preventDefault();\n // Activate last item\n this.focusLastItem();\n break;\n\n // Up and down are in keydown\n // because we need to prevent page scroll >:)\n case Key.ArrowUp.valueOf():\n case Key.ArrowDown.valueOf():\n this.determineOrientation(event, index);\n break;\n\n case Key.Enter.valueOf():\n case \" \":\n this.activateItem(index);\n break;\n }\n }\n\n /** Handle KeyUp on items */\n public handleKeyUpEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.ArrowLeft.valueOf():\n case Key.ArrowRight.valueOf():\n this.determineOrientation(event, index);\n break;\n }\n }\n\n private focusFirstItem(): void {\n this.onFocusItem(0);\n }\n\n private focusLastItem(): void {\n const index = this._itemCount - 1;\n this.onFocusItem(index);\n }\n\n /** When an item list's orientation is set to vertical,\n * only up and down arrow should function.\n * In all other cases only left and right arrow function.\n */\n private determineOrientation(\n event: React.KeyboardEvent,\n index: number\n ): void {\n const key = event.key;\n const vertical = this._orientation === Orientation.Vertical;\n let proceed = false;\n\n if (vertical) {\n if (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf()) {\n event.preventDefault();\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowRight.valueOf());\n }\n } else {\n if (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf()) {\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowDown.valueOf());\n }\n }\n\n if (proceed) {\n this.switchItemOnArrowPress(event, index);\n }\n }\n\n /** Either focus the next, previous, first, or last item depending on key pressed\n */\n private switchItemOnArrowPress(\n event: React.KeyboardEvent,\n index: number\n ): void {\n // Add or subtract depending on key pressed\n const pressed = event.key;\n const targetDirection = this._direction.get(pressed);\n\n // istanbul ignore else\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n // istanbul ignore else\n if (this._allowWrap) {\n if (\n pressed === Key.ArrowLeft.valueOf() ||\n pressed === Key.ArrowUp.valueOf()\n ) {\n this.focusLastItem();\n } else {\n this.focusFirstItem();\n }\n }\n }\n }\n }\n\n private activateItem(index: number): void {\n this.onActivateItem(index);\n }\n}\n\n/** Determines if a KeyboardEvent.key is an Item Navigation key\n * @internal\n */\nexport function isNavigationKey(key: string): boolean {\n return (\n isArrowKey(key) ||\n key === Key.Home.valueOf() ||\n key === Key.End.valueOf() ||\n key === \" \" ||\n key === Key.Enter.valueOf()\n );\n}\n\nfunction isArrowKey(key: string): boolean {\n return (\n key === Key.ArrowLeft.valueOf() ||\n key === Key.ArrowRight.valueOf() ||\n key === Key.ArrowUp.valueOf() ||\n key === Key.ArrowDown.valueOf()\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,6CAAkC;AAClC,sDAAmD;AAOnD;;GAEG;AACH,MAAa,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,yBAAW,CAAC,UAAU,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;QAOxB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,iBAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,iBAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CA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SAAS,CAAC,OAAO,EAAE,CAChC,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 Focus\n */\n\nimport { Key } from \"ts-key-enum\";\nimport { Orientation } from \"../enums/Orientation\";\n\n/** Cross-Axis Arrow Key Callback\n * @internal\n */\nexport type CrossAxisArrowKeyFunc = (forward: boolean) => void;\n\n/** Keyboard Navigator for parent components\n * @internal\n */\nexport class ItemKeyboardNavigator {\n private _direction: Map<string, number>;\n private _itemCount = 0;\n private _orientation = Orientation.Horizontal;\n private _allowWrap = true;\n private _crossAxisArrowKeyHandler?: CrossAxisArrowKeyFunc;\n\n constructor(\n public onFocusItem: (index: number) => void,\n public onActivateItem: (index: number) => void\n ) {\n this._direction = new Map<string, number>([\n [Key.ArrowLeft, -1],\n [Key.ArrowUp, -1],\n [Key.ArrowRight, 1],\n [Key.ArrowDown, 1],\n ]);\n }\n\n /** The item count */\n public get itemCount(): number {\n return this._itemCount;\n }\n public set itemCount(count: number) {\n this._itemCount = count;\n }\n\n /** The primary orientation */\n public get orientation(): Orientation {\n return this._orientation;\n }\n public set orientation(orientation: Orientation) {\n this._orientation = orientation;\n }\n\n /** The allow wrap property controls whether the movement will stop at the first and last items or wrap */\n public get allowWrap(): boolean {\n return this._allowWrap;\n }\n public set allowWrap(v: boolean) {\n this._allowWrap = v;\n }\n\n /** Called when the arrow keys that run perpendicular to the primary orientation are pressed */\n public get crossAxisArrowKeyHandler(): CrossAxisArrowKeyFunc | undefined {\n return this._crossAxisArrowKeyHandler;\n }\n public set crossAxisArrowKeyHandler(v: CrossAxisArrowKeyFunc | undefined) {\n this._crossAxisArrowKeyHandler = v;\n }\n\n /** Handle KeyDown on items */\n public handleKeyDownEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.Home.valueOf():\n event.preventDefault();\n // Activate first item\n this.focusFirstItem();\n break;\n case Key.End.valueOf():\n event.preventDefault();\n // Activate last item\n this.focusLastItem();\n break;\n\n // Up and down are in keydown\n // because we need to prevent page scroll >:)\n case Key.ArrowUp.valueOf():\n case Key.ArrowDown.valueOf():\n this.determineOrientation(event, index);\n break;\n\n case Key.Enter.valueOf():\n case \" \":\n this.activateItem(index);\n break;\n }\n }\n\n /** Handle KeyUp on items */\n public handleKeyUpEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.ArrowLeft.valueOf():\n case Key.ArrowRight.valueOf():\n this.determineOrientation(event, index);\n break;\n }\n }\n\n private focusFirstItem(): void {\n this.onFocusItem(0);\n }\n\n private focusLastItem(): void {\n const index = this._itemCount - 1;\n this.onFocusItem(index);\n }\n\n /** When an item list's orientation is set to vertical,\n * only up and down arrow should function.\n * In all other cases only left and right arrow function.\n */\n private determineOrientation(\n event: React.KeyboardEvent,\n index: number\n ): void {\n const key = event.key;\n const vertical = this._orientation === Orientation.Vertical;\n let proceed = false;\n\n if (vertical) {\n if (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf()) {\n event.preventDefault();\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowRight.valueOf());\n }\n } else {\n if (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf()) {\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowDown.valueOf());\n }\n }\n\n if (proceed) {\n this.switchItemOnArrowPress(event, index);\n }\n }\n\n /** Either focus the next, previous, first, or last item depending on key pressed\n */\n private switchItemOnArrowPress(\n event: React.KeyboardEvent,\n index: number\n ): void {\n // Add or subtract depending on key pressed\n const pressed = event.key;\n const targetDirection = this._direction.get(pressed);\n\n // istanbul ignore else\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n // istanbul ignore else\n if (this._allowWrap) {\n if (\n pressed === Key.ArrowLeft.valueOf() ||\n pressed === Key.ArrowUp.valueOf()\n ) {\n this.focusLastItem();\n } else {\n this.focusFirstItem();\n }\n }\n }\n }\n }\n\n private activateItem(index: number): void {\n this.onActivateItem(index);\n }\n}\n\n/** Determines if a KeyboardEvent.key is an Item Navigation key\n * @internal\n */\nexport function isNavigationKey(key: string): boolean {\n return (\n isArrowKey(key) ||\n key === Key.Home.valueOf() ||\n key === Key.End.valueOf() ||\n key === \" \" ||\n key === Key.Enter.valueOf()\n );\n}\n\nfunction isArrowKey(key: string): boolean {\n return (\n key === Key.ArrowLeft.valueOf() ||\n key === Key.ArrowRight.valueOf() ||\n key === Key.ArrowUp.valueOf() ||\n key === Key.ArrowDown.valueOf()\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusTrap.js","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sDAA6C;AAC7C,sCAAmC;AAEnC,0BAA0B;AAE1B,SAAS,WAAW,CAAC,OAAoB;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,IACE,OAAO,CAAC,SAAS;QACjB,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QAE5D,OAAO,KAAK,CAAC;IAEf,IACE,OAAO,CAAC,YAAY;QACpB,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU;QAC1C,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI;QAEzC,OAAO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ACvB,IAAI,SAAS,EAAE;gBACb,SAAS,CAAC,KAAK,EAAE,CAAC;aACnB;iBAAM;gBACL,IACE,mBAAmB,CAAC,OAAO;oBAC3B,mBAAmB,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa;oBAEtD,YAAY,CAAC,mBAAmB,CAAC,OAAsB,EAAE,IAAI,CAAC,CAAC;aAClE;SACF;IACH,CAAC,EACD,CAAC,KAAK,CAAC,MAAM,CAAC,CACf,CAAC;IAEF,wEAAwE;IACxE,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,CAAC,KAAuC,EAAE,EAAE;QAC1C,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO;QAE1B,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,uBAAuB;QACvB,IACE,mBAAmB,CAAC,OAAO;YAC3B,mBAAmB,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa;YAErD,mBAAmB,CAAC,OAAuB,CAAC,KAAK,EAAE,CAAC;IACzD,CAAC,EACD,CAAC,KAAK,CAAC,MAAM,CAAC,CACf,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,CACL;QACE,4CACc,gBAAgB,EAC5B,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,cAAc;YACnB,kEAAkE;YAClE,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,IAEnE,KAAK,CAAC,QAAQ,CACX;QACN,4CACc,sBAAsB,EAClC,OAAO,EAAE,iBAAiB;YAC1B,kEAAkE;YAClE,QAAQ,EAAE,CAAC,GACX,CACD,CACJ,CAAC;AACJ,CAAC;AA/GD,8BA+GC","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 Popup\n */\n\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiCore } from \"../UiCore\";\n\n// cSpell:ignore focusable\n\nfunction isFocusable(element: HTMLElement): boolean {\n if (!element || element.tabIndex < 0) return false;\n\n if (\n element.classList &&\n element.classList.contains(\"core-focus-trap-ignore-initial\")\n )\n return false;\n\n if (\n element.getAttribute &&\n typeof element.getAttribute === \"function\" &&\n element.getAttribute(\"disabled\") !== null\n )\n return false;\n\n if (\n element.tabIndex > 0 ||\n (element.tabIndex === 0 && element.getAttribute(\"tabIndex\") !== null)\n )\n return true;\n\n switch (element.nodeName) {\n case \"A\":\n const anchorElement = element as HTMLAnchorElement;\n return !!anchorElement.href && anchorElement.rel !== \"ignore\";\n case \"INPUT\":\n const inputElement = element as HTMLInputElement;\n return inputElement.type !== \"hidden\" && inputElement.type !== \"file\";\n case \"BUTTON\":\n case \"SELECT\":\n case \"TEXTAREA\":\n return true;\n default:\n return false;\n }\n}\n\nfunction processFindFocusableDescendant(\n element: HTMLElement | null\n): HTMLElement | null {\n // istanbul ignore next\n if (!element) return null;\n\n for (const child of element.childNodes) {\n // istanbul ignore else\n if (isFocusable(child as HTMLElement)) return child as HTMLElement;\n\n const focusable = processFindFocusableDescendant(child as HTMLElement);\n if (focusable) return focusable;\n }\n return null;\n}\n\nfunction findFirstFocusableDescendant(\n focusContainer: HTMLDivElement | null\n): HTMLElement | null {\n return processFindFocusableDescendant(focusContainer);\n}\n\nfunction processFindLastFocusableDescendant(\n element: HTMLElement\n): HTMLElement | null {\n for (let i = element.childNodes.length - 1; i >= 0; i--) {\n const child = element.childNodes[i] as HTMLElement;\n\n const focusable = processFindLastFocusableDescendant(child);\n // istanbul ignore else\n if (focusable) return focusable;\n\n // istanbul ignore else\n if (isFocusable(child)) return child;\n }\n return null;\n}\n\nfunction findLastFocusableDescendant(\n focusContainer: HTMLDivElement\n): HTMLElement | null {\n return processFindLastFocusableDescendant(focusContainer);\n}\n\nfunction getInitialFocusElement(\n focusContainer: HTMLDivElement | null,\n initialFocusSpec: React.RefObject<HTMLElement> | string | undefined\n): HTMLElement | null {\n // istanbul ignore next\n if (!focusContainer) return null;\n\n if (initialFocusSpec) {\n if (typeof initialFocusSpec === \"string\") {\n const node = focusContainer.querySelector(initialFocusSpec);\n if (node) {\n return node as HTMLElement;\n } else {\n Logger.logError(\n `${UiCore.packageName}.FocusTrap`,\n `Unable to locate element via selector ${initialFocusSpec}`\n );\n }\n } else {\n return initialFocusSpec.current;\n }\n }\n return findFirstFocusableDescendant(focusContainer);\n}\n\nfunction attemptFocus(element: HTMLElement, preventScroll: boolean): boolean {\n // istanbul ignore next\n if (!isFocusable(element)) return false;\n\n try {\n // istanbul ignore else\n if (document.activeElement !== element)\n element.focus({\n preventScroll: preventScroll ? true : /* istanbul ignore next */ false,\n });\n } catch (e) {\n // istanbul ignore next\n return false;\n }\n return document.activeElement === element;\n} // end attemptFocus\n\n/** Focus into first focusable element of a container.\n * @internal\n */\nexport function focusIntoContainer(\n focusContainer: HTMLDivElement,\n initialFocusElement?: React.RefObject<HTMLElement> | string\n): boolean {\n let result = false;\n const focusElement = getInitialFocusElement(\n focusContainer,\n initialFocusElement\n );\n if (focusElement) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n setTimeout(() => {\n attemptFocus(focusElement, true);\n }, 60);\n result = true;\n }\n return result;\n}\n\n/** Properties supported by [[FocusTrap]] component.\n * @internal\n */\nexport interface FocusTrapProps extends React.AllHTMLAttributes<any> {\n /** child components */\n children: React.ReactNode;\n /** if active is not true then no trapping of focus is attempted. */\n active?: boolean;\n /** restore focus to element that had focus before trap was activated */\n returnFocusOnDeactivate: boolean;\n /** Optional reference to element to receive focus when trap is activated. Optionally a CSS Selector\n * string can be supplied to locate an element in the FocusTrap container. If no specification is defined\n * the first focusable element is used.\n */\n initialFocusElement?: React.RefObject<HTMLElement> | string;\n}\n\n/** Trap Focus in container while trap is active.\n * @internal\n */\nexport function FocusTrap(props: FocusTrapProps) {\n const restoreFocusElement = React.useRef<Element | null>(null);\n const initialFocusElement = React.useRef<Element | null>(null);\n const focusContainer = React.useRef<HTMLDivElement | null>(null);\n const isInitialMount = React.useRef(true);\n const timeoutRef = React.useRef<number | undefined>();\n\n // Run on initial mount and when dependencies change. which could happen often.\n React.useEffect(() => {\n // istanbul ignore else\n if (isInitialMount.current) {\n isInitialMount.current = false;\n if (props.active) {\n if (props.returnFocusOnDeactivate) {\n restoreFocusElement.current = document.activeElement;\n }\n\n initialFocusElement.current = getInitialFocusElement(\n focusContainer.current,\n props.initialFocusElement\n );\n if (initialFocusElement.current) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n timeoutRef.current = window.setTimeout(() => {\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }, 60);\n }\n }\n }\n }, [\n props.children,\n props.initialFocusElement,\n props.active,\n props.returnFocusOnDeactivate,\n ]);\n\n // Return function to run only when FocusTrap is unmounted to restore focus\n React.useEffect(() => {\n return () => {\n window.clearTimeout(timeoutRef.current);\n if (restoreFocusElement.current)\n (restoreFocusElement.current as HTMLElement).focus({\n preventScroll: true,\n });\n };\n }, []);\n\n // this is hit if Shift tab is used.\n const cycleFocusToEnd = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n // istanbul ignore next\n if (!props.active) return;\n\n if (focusContainer.current && event.target === focusContainer.current) {\n event.stopPropagation();\n event.preventDefault();\n const focusable = findLastFocusableDescendant(focusContainer.current);\n\n // istanbul ignore else\n if (focusable) {\n focusable.focus();\n } else {\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }\n }\n },\n [props.active]\n );\n\n // this is hit if tab is used on last focusable item in child container.\n const cycleFocusToStart = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n // istanbul ignore next\n if (!props.active) return;\n\n event.stopPropagation();\n // istanbul ignore else\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n (initialFocusElement.current as HTMLElement).focus();\n },\n [props.active]\n );\n\n if (!props.children) return null;\n return (\n <>\n <div\n data-testid=\"focus-trap-div\"\n onFocus={cycleFocusToEnd}\n ref={focusContainer}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n style={{ outline: \"none\", WebkitTapHighlightColor: \"rgba(0,0,0,0)\" }}\n >\n {props.children}\n </div>\n <div\n data-testid=\"focus-trap-limit-div\"\n onFocus={cycleFocusToStart}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n />\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FocusTrap.js","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sDAA6C;AAC7C,sCAAmC;AAEnC,0BAA0B;AAE1B,SAAS,WAAW,CAAC,OAAoB;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,IACE,OAAO,CAAC,SAAS;QACjB,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QAE5D,OAAO,KAAK,CAAC;IAEf,IACE,OAAO,CAAC,YAAY;QACpB,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU;QAC1C,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI;QAEzC,OAAO,KAAK,CAAC;IAEf,IACE,OAAO,CAAC,QAAQ,GAAG,CAAC;QACpB,CAAC,OAAO,CAAC,QAAQ,KAAK,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;QAErE,OAAO,IAAI,CAAC;IAEd,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,GAAG;Y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CAAC;YACpB,CAAC;iBAAM,CAAC;gBACN,IACE,mBAAmB,CAAC,OAAO;oBAC3B,mBAAmB,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa;oBAEtD,YAAY,CAAC,mBAAmB,CAAC,OAAsB,EAAE,IAAI,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,KAAK,CAAC,MAAM,CAAC,CACf,CAAC;IAEF,wEAAwE;IACxE,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,CAAC,KAAuC,EAAE,EAAE;QAC1C,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO;QAE1B,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,uBAAuB;QACvB,IACE,mBAAmB,CAAC,OAAO;YAC3B,mBAAmB,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa;YAErD,mBAAmB,CAAC,OAAuB,CAAC,KAAK,EAAE,CAAC;IACzD,CAAC,EACD,CAAC,KAAK,CAAC,MAAM,CAAC,CACf,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,CACL;QACE,4CACc,gBAAgB,EAC5B,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,cAAc;YACnB,kEAAkE;YAClE,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,IAEnE,KAAK,CAAC,QAAQ,CACX;QACN,4CACc,sBAAsB,EAClC,OAAO,EAAE,iBAAiB;YAC1B,kEAAkE;YAClE,QAAQ,EAAE,CAAC,GACX,CACD,CACJ,CAAC;AACJ,CAAC;AA/GD,8BA+GC","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 Popup\n */\n\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiCore } from \"../UiCore\";\n\n// cSpell:ignore focusable\n\nfunction isFocusable(element: HTMLElement): boolean {\n if (!element || element.tabIndex < 0) return false;\n\n if (\n element.classList &&\n element.classList.contains(\"core-focus-trap-ignore-initial\")\n )\n return false;\n\n if (\n element.getAttribute &&\n typeof element.getAttribute === \"function\" &&\n element.getAttribute(\"disabled\") !== null\n )\n return false;\n\n if (\n element.tabIndex > 0 ||\n (element.tabIndex === 0 && element.getAttribute(\"tabIndex\") !== null)\n )\n return true;\n\n switch (element.nodeName) {\n case \"A\":\n const anchorElement = element as HTMLAnchorElement;\n return !!anchorElement.href && anchorElement.rel !== \"ignore\";\n case \"INPUT\":\n const inputElement = element as HTMLInputElement;\n return inputElement.type !== \"hidden\" && inputElement.type !== \"file\";\n case \"BUTTON\":\n case \"SELECT\":\n case \"TEXTAREA\":\n return true;\n default:\n return false;\n }\n}\n\nfunction processFindFocusableDescendant(\n element: HTMLElement | null\n): HTMLElement | null {\n // istanbul ignore next\n if (!element) return null;\n\n for (const child of element.childNodes) {\n // istanbul ignore else\n if (isFocusable(child as HTMLElement)) return child as HTMLElement;\n\n const focusable = processFindFocusableDescendant(child as HTMLElement);\n if (focusable) return focusable;\n }\n return null;\n}\n\nfunction findFirstFocusableDescendant(\n focusContainer: HTMLDivElement | null\n): HTMLElement | null {\n return processFindFocusableDescendant(focusContainer);\n}\n\nfunction processFindLastFocusableDescendant(\n element: HTMLElement\n): HTMLElement | null {\n for (let i = element.childNodes.length - 1; i >= 0; i--) {\n const child = element.childNodes[i] as HTMLElement;\n\n const focusable = processFindLastFocusableDescendant(child);\n // istanbul ignore else\n if (focusable) return focusable;\n\n // istanbul ignore else\n if (isFocusable(child)) return child;\n }\n return null;\n}\n\nfunction findLastFocusableDescendant(\n focusContainer: HTMLDivElement\n): HTMLElement | null {\n return processFindLastFocusableDescendant(focusContainer);\n}\n\nfunction getInitialFocusElement(\n focusContainer: HTMLDivElement | null,\n initialFocusSpec: React.RefObject<HTMLElement> | string | undefined\n): HTMLElement | null {\n // istanbul ignore next\n if (!focusContainer) return null;\n\n if (initialFocusSpec) {\n if (typeof initialFocusSpec === \"string\") {\n const node = focusContainer.querySelector(initialFocusSpec);\n if (node) {\n return node as HTMLElement;\n } else {\n Logger.logError(\n `${UiCore.packageName}.FocusTrap`,\n `Unable to locate element via selector ${initialFocusSpec}`\n );\n }\n } else {\n return initialFocusSpec.current;\n }\n }\n return findFirstFocusableDescendant(focusContainer);\n}\n\nfunction attemptFocus(element: HTMLElement, preventScroll: boolean): boolean {\n // istanbul ignore next\n if (!isFocusable(element)) return false;\n\n try {\n // istanbul ignore else\n if (document.activeElement !== element)\n element.focus({\n preventScroll: preventScroll ? true : /* istanbul ignore next */ false,\n });\n } catch (e) {\n // istanbul ignore next\n return false;\n }\n return document.activeElement === element;\n} // end attemptFocus\n\n/** Focus into first focusable element of a container.\n * @internal\n */\nexport function focusIntoContainer(\n focusContainer: HTMLDivElement,\n initialFocusElement?: React.RefObject<HTMLElement> | string\n): boolean {\n let result = false;\n const focusElement = getInitialFocusElement(\n focusContainer,\n initialFocusElement\n );\n if (focusElement) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n setTimeout(() => {\n attemptFocus(focusElement, true);\n }, 60);\n result = true;\n }\n return result;\n}\n\n/** Properties supported by [[FocusTrap]] component.\n * @internal\n */\nexport interface FocusTrapProps extends React.AllHTMLAttributes<any> {\n /** child components */\n children: React.ReactNode;\n /** if active is not true then no trapping of focus is attempted. */\n active?: boolean;\n /** restore focus to element that had focus before trap was activated */\n returnFocusOnDeactivate: boolean;\n /** Optional reference to element to receive focus when trap is activated. Optionally a CSS Selector\n * string can be supplied to locate an element in the FocusTrap container. If no specification is defined\n * the first focusable element is used.\n */\n initialFocusElement?: React.RefObject<HTMLElement> | string;\n}\n\n/** Trap Focus in container while trap is active.\n * @internal\n */\nexport function FocusTrap(props: FocusTrapProps) {\n const restoreFocusElement = React.useRef<Element | null>(null);\n const initialFocusElement = React.useRef<Element | null>(null);\n const focusContainer = React.useRef<HTMLDivElement | null>(null);\n const isInitialMount = React.useRef(true);\n const timeoutRef = React.useRef<number | undefined>();\n\n // Run on initial mount and when dependencies change. which could happen often.\n React.useEffect(() => {\n // istanbul ignore else\n if (isInitialMount.current) {\n isInitialMount.current = false;\n if (props.active) {\n if (props.returnFocusOnDeactivate) {\n restoreFocusElement.current = document.activeElement;\n }\n\n initialFocusElement.current = getInitialFocusElement(\n focusContainer.current,\n props.initialFocusElement\n );\n if (initialFocusElement.current) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n timeoutRef.current = window.setTimeout(() => {\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }, 60);\n }\n }\n }\n }, [\n props.children,\n props.initialFocusElement,\n props.active,\n props.returnFocusOnDeactivate,\n ]);\n\n // Return function to run only when FocusTrap is unmounted to restore focus\n React.useEffect(() => {\n return () => {\n window.clearTimeout(timeoutRef.current);\n if (restoreFocusElement.current)\n (restoreFocusElement.current as HTMLElement).focus({\n preventScroll: true,\n });\n };\n }, []);\n\n // this is hit if Shift tab is used.\n const cycleFocusToEnd = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n // istanbul ignore next\n if (!props.active) return;\n\n if (focusContainer.current && event.target === focusContainer.current) {\n event.stopPropagation();\n event.preventDefault();\n const focusable = findLastFocusableDescendant(focusContainer.current);\n\n // istanbul ignore else\n if (focusable) {\n focusable.focus();\n } else {\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }\n }\n },\n [props.active]\n );\n\n // this is hit if tab is used on last focusable item in child container.\n const cycleFocusToStart = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n // istanbul ignore next\n if (!props.active) return;\n\n event.stopPropagation();\n // istanbul ignore else\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n (initialFocusElement.current as HTMLElement).focus();\n },\n [props.active]\n );\n\n if (!props.children) return null;\n return (\n <>\n <div\n data-testid=\"focus-trap-div\"\n onFocus={cycleFocusToEnd}\n ref={focusContainer}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n style={{ outline: \"none\", WebkitTapHighlightColor: \"rgba(0,0,0,0)\" }}\n >\n {props.children}\n </div>\n <div\n data-testid=\"focus-trap-limit-div\"\n onFocus={cycleFocusToStart}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n />\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withOnOutsideClick.js","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAY/B;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAChC,SAA8C,EAC9C,qBAAkD,EAClD,aAAsB,IAAI,EAC1B,mBAA4B,IAAI,EAChC,EAAE;IACF,OAAO,MAAM,kBAAmB,SAAQ,KAAK,CAAC,aAE7C;QAFM;;YAGL,gBAAgB;YACT,6BAAwB,GAA2B,IAAI,CAAC;YAC/D,gBAAgB;YACT,kBAAa,GAAG,KAAK,CAAC;YAiC7B,gBAAgB;YACT,wBAAmB,GAAG,CAAC,CAAa,EAAE,EAAE;gBAC7C,IACE,CAAC,IAAI,CAAC,wBAAwB;oBAC9B,CAAC,CAAC,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC;oBAC3B,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;oBAEhD,OAAO;gBAET,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAChC,CAAC,CAAC;YAEF,gBAAgB;YACT,8BAAyB,GAAG,CAAC,CAAe,EAAE,EAAE;gBACrD,IAAI,CAAC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EACP,IAAI,CAAC,mBAAmB,EACxB,UAAU,CACX,CAAC;QACN,CAAC;QAEe,MAAM;YACpB,MAAM,EAAE,cAAc,EAAE,8BAA8B,EAAE,GAAG,KAAK,EAAE,GAChE,IAAI,CAAC,KAAK,CAAC;YACb,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAM,KAAwB,GAAI,CACxC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AArJW,QAAA,kBAAkB,sBAqJ7B","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 Common\n */\n\nimport * as React from \"react\";\n\n/** Properties for [[withOnOutsideClick]] React higher-order component\n * @public\n */\nexport interface WithOnOutsideClickProps {\n /** Outside click callback function */\n onOutsideClick?: (event: MouseEvent) => any;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n}\n\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\n * @public\n */\nexport const withOnOutsideClick = <ComponentProps extends {}>(\n Component: React.ComponentType<ComponentProps>,\n defaultOnOutsideClick?: (event: MouseEvent) => any,\n useCapture: boolean = true,\n usePointerEvents: boolean = true\n) => {\n return class WithOnOutsideClick extends React.PureComponent<\n ComponentProps & WithOnOutsideClickProps\n > {\n /** @internal */\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\n /** @internal */\n public isDownOutside = false;\n\n /** @internal */\n public isInCorePopup(element: HTMLElement): boolean {\n if (element.nodeName === \"DIV\") {\n if (element.classList && element.classList.contains(\"core-popup\"))\n return true;\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n } else {\n // istanbul ignore else\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n }\n return false;\n }\n\n /** @internal */\n public onOutsideClick(e: MouseEvent) {\n // istanbul ignore else\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\n // istanbul ignore else\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(e.target as HTMLElement)\n )\n return;\n }\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(e);\n else if (defaultOnOutsideClick) return defaultOnOutsideClick(e);\n }\n\n /** @internal */\n public handleDocumentClick = (e: MouseEvent) => {\n if (\n !this.outsideClickContainerDiv ||\n !(e.target instanceof Node) ||\n this.outsideClickContainerDiv.contains(e.target)\n )\n return;\n\n return this.onOutsideClick(e);\n };\n\n /** @internal */\n public handleDocumentPointerDown = (e: PointerEvent) => {\n this.isDownOutside = true;\n // istanbul ignore else\n if (this.outsideClickContainerDiv) {\n // typically e.target test for instance of Node, but this is not working from pop out windows\n this.isDownOutside =\n !!e.target &&\n !this.outsideClickContainerDiv.contains(e.target as any);\n }\n };\n\n /** @internal */\n public handleDocumentPointerUp = (e: PointerEvent) => {\n let isUpOutside = true;\n // istanbul ignore else\n if (this.outsideClickContainerDiv) {\n // typically e.target test for instance of Node, but this is not working from pop out windows\n isUpOutside =\n !!e.target &&\n !this.outsideClickContainerDiv.contains(e.target as any);\n }\n\n const isOutsideClick = isUpOutside && this.isDownOutside;\n this.isDownOutside = false;\n isOutsideClick && this.onOutsideClick(e);\n };\n\n public handleOutsideClickContainerDivSet = (\n outsideClickContainerDiv: HTMLDivElement | null\n ) => {\n this.outsideClickContainerDiv = outsideClickContainerDiv;\n };\n\n public getParentDocument() {\n // istanbul ignore next\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\n }\n\n public override componentDidMount() {\n const outsideClickParentDocument = this.getParentDocument();\n if (usePointerEvents) {\n outsideClickParentDocument.addEventListener(\n \"pointerdown\",\n this.handleDocumentPointerDown,\n useCapture\n );\n outsideClickParentDocument.addEventListener(\n \"pointerup\",\n this.handleDocumentPointerUp,\n useCapture\n );\n } else\n outsideClickParentDocument.addEventListener(\n \"click\",\n this.handleDocumentClick,\n useCapture\n );\n }\n\n /** @internal */\n public override componentWillUnmount() {\n const outsideClickParentDocument = this.getParentDocument();\n if (usePointerEvents) {\n outsideClickParentDocument.removeEventListener(\n \"pointerdown\",\n this.handleDocumentPointerDown,\n useCapture\n );\n outsideClickParentDocument.removeEventListener(\n \"pointerup\",\n this.handleDocumentPointerUp,\n useCapture\n );\n } else\n outsideClickParentDocument.removeEventListener(\n \"click\",\n this.handleDocumentClick,\n useCapture\n );\n }\n\n public override render() {\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } =\n this.props;\n return (\n <div ref={this.handleOutsideClickContainerDivSet}>\n <Component {...(props as ComponentProps)} />\n </div>\n );\n }\n };\n};\n"]}
|