@itwin/core-react 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/lib/cjs/core-react/base/Gap.js +1 -1
- package/lib/cjs/core-react/base/Gap.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.js +2 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +5 -3
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.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 +2 -1
- package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js +2 -2
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js +2 -1
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
- package/lib/cjs/core-react/listbox/Listbox.js +3 -2
- package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.d.ts +7 -3
- package/lib/cjs/core-react/messagebox/MessageBox.d.ts.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.js +2 -7
- package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/cjs/core-react/popup/Popup.js +8 -4
- package/lib/cjs/core-react/popup/Popup.js.map +1 -1
- package/lib/cjs/core-react/tree/Node.js +2 -1
- package/lib/cjs/core-react/tree/Node.js.map +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/cjs/core-react/utils/Point.d.ts +3 -3
- package/lib/cjs/core-react/utils/Point.d.ts.map +1 -1
- package/lib/cjs/core-react/utils/Point.js +2 -2
- package/lib/cjs/core-react/utils/Point.js.map +1 -1
- package/lib/cjs/core-react/utils/PointProps.d.ts +9 -0
- package/lib/cjs/core-react/utils/PointProps.d.ts.map +1 -0
- package/lib/cjs/core-react/utils/PointProps.js +3 -0
- package/lib/cjs/core-react/utils/PointProps.js.map +1 -0
- package/lib/cjs/core-react/utils/Rectangle.d.ts +1 -1
- package/lib/cjs/core-react/utils/Rectangle.d.ts.map +1 -1
- package/lib/cjs/core-react/utils/Rectangle.js.map +1 -1
- package/lib/cjs/core-react/utils/getCssVariable.js +1 -1
- package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +2 -1
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +14 -8
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/lib/esm/core-react/base/Gap.js +1 -1
- package/lib/esm/core-react/base/Gap.js.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.js +2 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +5 -3
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.js +2 -2
- package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
- package/lib/esm/core-react/dialog/GlobalDialog.js +2 -1
- package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/esm/core-react/elementseparator/ElementSeparator.js +2 -2
- package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/esm/core-react/hocs/withOnOutsideClick.js +2 -1
- package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.js +1 -1
- package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
- package/lib/esm/core-react/listbox/Listbox.js +3 -2
- package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.d.ts +7 -3
- package/lib/esm/core-react/messagebox/MessageBox.d.ts.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.js +2 -7
- package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/esm/core-react/popup/Popup.js +8 -4
- package/lib/esm/core-react/popup/Popup.js.map +1 -1
- package/lib/esm/core-react/tree/Node.js +2 -1
- package/lib/esm/core-react/tree/Node.js.map +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/esm/core-react/utils/Point.d.ts +3 -3
- package/lib/esm/core-react/utils/Point.d.ts.map +1 -1
- package/lib/esm/core-react/utils/Point.js +2 -2
- package/lib/esm/core-react/utils/Point.js.map +1 -1
- package/lib/esm/core-react/utils/PointProps.d.ts +9 -0
- package/lib/esm/core-react/utils/PointProps.d.ts.map +1 -0
- package/lib/esm/core-react/utils/PointProps.js +2 -0
- package/lib/esm/core-react/utils/PointProps.js.map +1 -0
- package/lib/esm/core-react/utils/Rectangle.d.ts +1 -1
- package/lib/esm/core-react/utils/Rectangle.d.ts.map +1 -1
- package/lib/esm/core-react/utils/Rectangle.js.map +1 -1
- package/lib/esm/core-react/utils/getCssVariable.js +1 -1
- package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +2 -1
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js +14 -8
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Listbox.js","sourceRoot":"","sources":["../../../../src/core-react/listbox/Listbox.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA2DnD;;;GAGG;AACH,uBAAuB;AACvB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAsB;IACrE,oBAAoB,EAAE,CAAC,SAAmC,EAAE,EAAE,GAAE,CAAC;CAClE,CAAC,CAAC;AAEH,SAAS,MAAM,CAAC,GAAG,IAA+C;IAChE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,mBAAmB,CAAC,UAA2B;IACtD,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;SACtC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;SAChE,GAAG,CACF,CAAC,UAAU,EAAE,EAAE,CACZ,UAAiC,CAAC,KAAyB,CAC/D,CAAC;AACN,CAAC;AAED,SAAS,yBAAyB,CAChC,YAAgC,EAChC,SAAiB,EACjB,GAAW;IAEX,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,QAAQ,GAAG,SAAS,IA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AAC,CAAC;IAClD,MAAM,UAAU,GAAG,YAAY,KAAK,KAAK,CAAC;IAE1C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACnC,CAAC,KAAkD,EAAE,EAAE;QACrD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,uBAAuB;QACvB,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1D,uBAAuB;QACvB,IAAI,SAAS,KAAK,aAAa,EAAE;YAC/B,oBAAoB,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SACpD;IACH,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACvC,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,OAAO;IACL,iEAAiE;IACjE,6CAIiB,UAAU,mBAIV,QAAQ,IAAI,SAAS;QACpC,uEAAuE;QACvE,sCAAsC;QACtC,wDAAwD;QACxD,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,KACd,UAAU,EACd,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,SAAS,EAAE,gBAEH,KAAK,EACjB,OAAO,EAAE,WAAW,IAEnB,QAAQ,CACN,CACN,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport classnames from \"classnames\";\n\nimport \"./Listbox.scss\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\n\n/** Ideas borrowed from https://reacttraining.com/reach-ui/listbox */\n\n/**\n * `Listbox` value.\n * @alpha\n */\nexport type ListboxValue = string;\n\n/**\n * `Listbox` Props.\n * @alpha\n */\nexport interface ListboxProps\n extends React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLUListElement>,\n HTMLUListElement\n > {\n id?: string;\n selectedValue?: ListboxValue;\n ariaLabel?: any;\n ariaLabelledBy?: any;\n onListboxValueChange?: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n}\n\n/**\n * `ListboxItem` Props.\n * @alpha\n */\nexport interface ListboxItemProps\n extends React.DetailedHTMLProps<\n React.LiHTMLAttributes<HTMLLIElement>,\n HTMLLIElement\n > {\n /** The unique item's value. */\n value: ListboxValue;\n /** set if item is disabled. */\n disabled?: boolean;\n}\n\n/**\n * `Listbox` Context.\n * @alpha\n */\nexport interface ListboxContextProps {\n listboxId?: string;\n listboxValue?: ListboxValue;\n focusValue?: ListboxValue;\n onListboxValueChange: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n listboxRef?: React.RefObject<HTMLUListElement>;\n}\n\n/**\n * Context set up by listbox for use by `ListboxItems` .\n * @alpha\n */\n// istanbul ignore next\nexport const ListboxContext = React.createContext<ListboxContextProps>({\n onListboxValueChange: (_newValue: ListboxValue | undefined) => {},\n});\n\nfunction makeId(...args: Array<string | number | null | undefined>) {\n return args.filter((val) => val != null).join(\"--\");\n}\n\nfunction getOptionValueArray(childNodes: React.ReactNode): ListboxItemProps[] {\n return React.Children.toArray(childNodes)\n .filter((node) => React.isValidElement(node) && node.props.value)\n .map(\n (optionNode) =>\n (optionNode as React.ReactElement).props as ListboxItemProps\n );\n}\n\nfunction processKeyboardNavigation(\n optionValues: ListboxItemProps[],\n itemIndex: number,\n key: string\n): [number, boolean] {\n let keyProcessed = false;\n let newIndex = itemIndex >= 0 ? itemIndex : 0;\n\n // Note: In aria example Page Up/Down just moves up or down by one item. See https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/js/listbox.js\n if (key === SpecialKey.ArrowDown || key === SpecialKey.PageDown) {\n for (let i = itemIndex + 1; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.ArrowUp || key === SpecialKey.PageUp) {\n for (let i = itemIndex - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.Home) {\n for (let i = 0; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.End) {\n for (let i = optionValues.length - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n }\n return [newIndex, keyProcessed];\n}\n\n/**\n * Single select `Listbox` component\n * @alpha\n */\nexport function Listbox(props: ListboxProps) {\n const {\n ariaLabel,\n ariaLabelledBy,\n id,\n children,\n selectedValue,\n className,\n onListboxValueChange,\n onKeyDown,\n ...otherProps\n } = props;\n const listRef = React.useRef<HTMLUListElement>(null);\n const [listId] = React.useState(() => {\n return id ?? Guid.createValue();\n });\n const optionValues = React.useMemo(\n () => getOptionValueArray(children),\n [children]\n );\n const classes = React.useMemo(\n () => classnames(\"core-listbox\", className),\n [className]\n );\n const [currentValue, setCurrentValue] = React.useState<\n ListboxValue | undefined\n >(selectedValue);\n const [focusValue, setFocusValue] = React.useState<ListboxValue | undefined>(\n currentValue\n );\n\n React.useEffect(() => {\n setCurrentValue(selectedValue);\n setFocusValue(selectedValue);\n }, [selectedValue]);\n\n const scrollTopRef = React.useRef(0);\n const handleValueChange = React.useCallback(\n (newValue: ListboxValue, isControlOrCommandPressed?: boolean) => {\n // istanbul ignore else\n if (newValue !== currentValue) {\n setCurrentValue(newValue);\n setFocusValue(newValue);\n if (onListboxValueChange)\n onListboxValueChange(newValue, isControlOrCommandPressed);\n }\n },\n [setCurrentValue, currentValue, onListboxValueChange]\n );\n\n const focusOption = React.useCallback(\n (itemIndex: number) => {\n // istanbul ignore else\n if (itemIndex >= 0 && itemIndex < optionValues.length) {\n const newSelection = optionValues[itemIndex];\n const listElement = listRef.current as HTMLUListElement;\n const optionToFocus = listElement.querySelector<HTMLLIElement>(\n `li[data-value=\"${newSelection.value}\"]`\n );\n // istanbul ignore else\n if (optionToFocus && listElement) {\n let newScrollTop = listElement.scrollTop;\n\n // istanbul ignore next\n if (listElement.scrollHeight > listElement.clientHeight) {\n const scrollBottom =\n listElement.clientHeight + listElement.scrollTop;\n const elementBottom =\n optionToFocus.offsetTop + optionToFocus.offsetHeight;\n if (elementBottom > scrollBottom) {\n newScrollTop = elementBottom - listElement.clientHeight;\n } else if (optionToFocus.offsetTop < listElement.scrollTop) {\n newScrollTop = optionToFocus.offsetTop;\n }\n scrollTopRef.current = newScrollTop;\n }\n setFocusValue(newSelection.value);\n }\n }\n },\n [optionValues]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (optionValues.length < 1) return;\n\n const itemIndex =\n undefined === focusValue\n ? -1\n : optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n\n if (event.key === SpecialKey.Space) {\n event.preventDefault();\n // istanbul ignore else\n if (focusValue)\n handleValueChange(\n focusValue,\n event.getModifierState(\"Control\") || event.getModifierState(\"Meta\")\n ); // Control or Command\n return;\n } else {\n const [newItemIndex, keyProcessed] = processKeyboardNavigation(\n optionValues,\n itemIndex,\n event.key\n );\n // istanbul ignore else\n if (keyProcessed) {\n event.preventDefault();\n focusOption(newItemIndex);\n return;\n }\n }\n\n // istanbul ignore else\n if (onKeyDown) onKeyDown(event);\n },\n [focusValue, optionValues, focusOption, onKeyDown, handleValueChange]\n );\n\n const isInitialMount = React.useRef(true);\n\n React.useEffect(() => {\n const list = listRef.current as HTMLUListElement;\n\n if (isInitialMount.current) {\n isInitialMount.current = false;\n\n if (undefined !== focusValue) {\n const itemIndex = optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n focusOption(itemIndex);\n }\n } else {\n list.scrollTop = scrollTopRef.current;\n }\n }, [focusValue, focusOption, optionValues]);\n\n // istanbul ignore next\n const handleOnScroll = React.useCallback(\n (_event: React.UIEvent<HTMLUListElement, UIEvent>) => {\n if (listRef.current) scrollTopRef.current = listRef.current.scrollTop;\n },\n []\n );\n\n // istanbul ignore next\n const handleOnFocus = React.useCallback(\n (_event: React.FocusEvent<HTMLUListElement>) => {\n if (!focusValue || 0 === focusValue.length) {\n if (currentValue) {\n setFocusValue(currentValue);\n } else {\n if (optionValues.length > 0) setFocusValue(optionValues[0].value);\n }\n }\n },\n [currentValue, focusValue, optionValues]\n );\n\n return (\n <ul\n className={classes}\n // If the listbox is not part of another widget, then it has a visible\n // label referenced by `aria-labelledby` on the element with role\n // `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n // If an `aria-label` is passed, we should skip `aria-labelledby` to\n // avoid confusion.\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy}\n aria-label={ariaLabel}\n // An element that contains or owns all the listbox options has role\n // listbox.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"listbox\"\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-collapsible.html\n tabIndex={0}\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-scrollable.html\n aria-activedescendant={makeId(currentValue, listId)}\n {...otherProps}\n ref={listRef}\n id={listId}\n onKeyDown={handleKeyDown}\n onScroll={handleOnScroll}\n data-value={currentValue}\n data-focusvalue={focusValue}\n onFocus={handleOnFocus}\n >\n <ListboxContext.Provider\n value={{\n listboxValue: currentValue,\n focusValue,\n listboxId: listId,\n onListboxValueChange: handleValueChange,\n listboxRef: listRef,\n }}\n >\n {children}\n </ListboxContext.Provider>\n </ul>\n );\n}\n\n/**\n * `ListboxItem` component.\n * @alpha\n */\nexport function ListboxItem(props: ListboxItemProps) {\n const { children, value, className, disabled, ...otherProps } = props;\n\n const { listboxValue, focusValue, listboxId, onListboxValueChange } =\n React.useContext(ListboxContext);\n\n const hasFocus = focusValue === value;\n\n const classes = React.useMemo(\n () => classnames(\"core-listbox-item\", hasFocus && \"focused\", className),\n [className, hasFocus]\n );\n const itemRef = React.useRef<HTMLLIElement>(null);\n const isSelected = listboxValue === value;\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLLIElement, MouseEvent>) => {\n event.preventDefault();\n // istanbul ignore next\n const selectedValue = event.currentTarget?.dataset?.value;\n // istanbul ignore else\n if (undefined !== selectedValue) {\n onListboxValueChange(selectedValue, event.ctrlKey);\n }\n },\n [onListboxValueChange]\n );\n\n const getItemId = React.useCallback(() => {\n return makeId(value, listboxId);\n }, [listboxId, value]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <li\n // In a single-select listbox, the selected option has `aria-selected`\n // set to `true`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n aria-selected={isSelected}\n // Applicable to all host language elements regardless of whether a\n // `role` is applied.\n // https://www.w3.org/WAI/PF/aria/states_and_properties#global_states_header\n aria-disabled={disabled || undefined}\n // Each option in the listbox has role `option` and is a DOM descendant\n // of the element with role `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"option\"\n className={classes}\n {...otherProps}\n ref={itemRef}\n id={getItemId()}\n // used for css styling\n data-value={value}\n onClick={handleClick}\n >\n {children}\n </li>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Listbox.js","sourceRoot":"","sources":["../../../../src/core-react/listbox/Listbox.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA2DnD;;;GAGG;AACH,uBA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M,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACvC,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,OAAO;IACL,iEAAiE;IACjE,6CAIiB,UAAU,mBAIV,QAAQ,IAAI,SAAS;QACpC,uEAAuE;QACvE,sCAAsC;QACtC,wDAAwD;QACxD,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,KACd,UAAU,EACd,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,SAAS,EAAE,gBAEH,KAAK,EACjB,OAAO,EAAE,WAAW,IAEnB,QAAQ,CACN,CACN,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport classnames from \"classnames\";\n\nimport \"./Listbox.scss\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\n\n/** Ideas borrowed from https://reacttraining.com/reach-ui/listbox */\n\n/**\n * `Listbox` value.\n * @alpha\n */\nexport type ListboxValue = string;\n\n/**\n * `Listbox` Props.\n * @alpha\n */\nexport interface ListboxProps\n extends React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLUListElement>,\n HTMLUListElement\n > {\n id?: string;\n selectedValue?: ListboxValue;\n ariaLabel?: any;\n ariaLabelledBy?: any;\n onListboxValueChange?: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n}\n\n/**\n * `ListboxItem` Props.\n * @alpha\n */\nexport interface ListboxItemProps\n extends React.DetailedHTMLProps<\n React.LiHTMLAttributes<HTMLLIElement>,\n HTMLLIElement\n > {\n /** The unique item's value. */\n value: ListboxValue;\n /** set if item is disabled. */\n disabled?: boolean;\n}\n\n/**\n * `Listbox` Context.\n * @alpha\n */\nexport interface ListboxContextProps {\n listboxId?: string;\n listboxValue?: ListboxValue;\n focusValue?: ListboxValue;\n onListboxValueChange: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n listboxRef?: React.RefObject<HTMLUListElement>;\n}\n\n/**\n * Context set up by listbox for use by `ListboxItems` .\n * @alpha\n */\n// istanbul ignore next\nexport const ListboxContext = React.createContext<ListboxContextProps>({\n onListboxValueChange: (_newValue: ListboxValue | undefined) => {},\n});\n\nfunction makeId(...args: Array<string | number | null | undefined>) {\n return args.filter((val) => val != null).join(\"--\");\n}\n\nfunction getOptionValueArray(childNodes: React.ReactNode): ListboxItemProps[] {\n return React.Children.toArray(childNodes)\n .filter((node) => React.isValidElement(node) && node.props.value)\n .map(\n (optionNode) =>\n (optionNode as React.ReactElement).props as ListboxItemProps\n );\n}\n\nfunction processKeyboardNavigation(\n optionValues: ListboxItemProps[],\n itemIndex: number,\n key: string\n): [number, boolean] {\n let keyProcessed = false;\n let newIndex = itemIndex >= 0 ? itemIndex : 0;\n\n // Note: In aria example Page Up/Down just moves up or down by one item. See https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/js/listbox.js\n if (key === SpecialKey.ArrowDown || key === SpecialKey.PageDown) {\n for (let i = itemIndex + 1; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.ArrowUp || key === SpecialKey.PageUp) {\n for (let i = itemIndex - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.Home) {\n for (let i = 0; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.End) {\n for (let i = optionValues.length - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n }\n return [newIndex, keyProcessed];\n}\n\n/**\n * Single select `Listbox` component\n * @alpha\n */\nexport function Listbox(props: ListboxProps) {\n const {\n ariaLabel,\n ariaLabelledBy,\n id,\n children,\n selectedValue,\n className,\n onListboxValueChange,\n onKeyDown,\n ...otherProps\n } = props;\n const listRef = React.useRef<HTMLUListElement>(null);\n const [listId] = React.useState(() => {\n return id ?? Guid.createValue();\n });\n const optionValues = React.useMemo(\n () => getOptionValueArray(children),\n [children]\n );\n const classes = React.useMemo(\n () => classnames(\"core-listbox\", className),\n [className]\n );\n const [currentValue, setCurrentValue] = React.useState<\n ListboxValue | undefined\n >(selectedValue);\n const [focusValue, setFocusValue] = React.useState<ListboxValue | undefined>(\n currentValue\n );\n\n React.useEffect(() => {\n setCurrentValue(selectedValue);\n setFocusValue(selectedValue);\n }, [selectedValue]);\n\n const scrollTopRef = React.useRef(0);\n const handleValueChange = React.useCallback(\n (newValue: ListboxValue, isControlOrCommandPressed?: boolean) => {\n // istanbul ignore else\n if (newValue !== currentValue) {\n setCurrentValue(newValue);\n setFocusValue(newValue);\n if (onListboxValueChange)\n onListboxValueChange(newValue, isControlOrCommandPressed);\n }\n },\n [setCurrentValue, currentValue, onListboxValueChange]\n );\n\n const focusOption = React.useCallback(\n (itemIndex: number) => {\n // istanbul ignore else\n if (itemIndex >= 0 && itemIndex < optionValues.length) {\n const newSelection = optionValues[itemIndex];\n const listElement = listRef.current as HTMLUListElement;\n const optionToFocus = listElement.querySelector<HTMLLIElement>(\n `li[data-value=\"${newSelection.value}\"]`\n );\n // istanbul ignore else\n if (optionToFocus && listElement) {\n let newScrollTop = listElement.scrollTop;\n\n // istanbul ignore next\n if (listElement.scrollHeight > listElement.clientHeight) {\n const scrollBottom =\n listElement.clientHeight + listElement.scrollTop;\n const elementBottom =\n optionToFocus.offsetTop + optionToFocus.offsetHeight;\n if (elementBottom > scrollBottom) {\n newScrollTop = elementBottom - listElement.clientHeight;\n } else if (optionToFocus.offsetTop < listElement.scrollTop) {\n newScrollTop = optionToFocus.offsetTop;\n }\n scrollTopRef.current = newScrollTop;\n }\n setFocusValue(newSelection.value);\n }\n }\n },\n [optionValues]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (optionValues.length < 1) return;\n\n const itemIndex =\n undefined === focusValue\n ? -1\n : optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n\n if (event.key === SpecialKey.Space) {\n event.preventDefault();\n // istanbul ignore else\n if (focusValue)\n handleValueChange(\n focusValue,\n event.getModifierState(\"Control\") || event.getModifierState(\"Meta\")\n ); // Control or Command\n return;\n } else {\n const [newItemIndex, keyProcessed] = processKeyboardNavigation(\n optionValues,\n itemIndex,\n event.key\n );\n // istanbul ignore else\n if (keyProcessed) {\n event.preventDefault();\n focusOption(newItemIndex);\n return;\n }\n }\n\n // istanbul ignore else\n if (onKeyDown) onKeyDown(event);\n },\n [focusValue, optionValues, focusOption, onKeyDown, handleValueChange]\n );\n\n const isInitialMount = React.useRef(true);\n\n React.useEffect(() => {\n const list = listRef.current as HTMLUListElement;\n\n if (isInitialMount.current) {\n isInitialMount.current = false;\n\n if (undefined !== focusValue) {\n const itemIndex = optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n focusOption(itemIndex);\n }\n } else {\n list.scrollTop = scrollTopRef.current;\n }\n }, [focusValue, focusOption, optionValues]);\n\n // istanbul ignore next\n const handleOnScroll = React.useCallback(\n (_event: React.UIEvent<HTMLUListElement, UIEvent>) => {\n if (listRef.current) scrollTopRef.current = listRef.current.scrollTop;\n },\n []\n );\n\n // istanbul ignore next\n const handleOnFocus = React.useCallback(\n (_event: React.FocusEvent<HTMLUListElement>) => {\n if (!focusValue || 0 === focusValue.length) {\n if (currentValue) {\n setFocusValue(currentValue);\n } else {\n if (optionValues.length > 0) setFocusValue(optionValues[0].value);\n }\n }\n },\n [currentValue, focusValue, optionValues]\n );\n\n return (\n <ul\n className={classes}\n // If the listbox is not part of another widget, then it has a visible\n // label referenced by `aria-labelledby` on the element with role\n // `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n // If an `aria-label` is passed, we should skip `aria-labelledby` to\n // avoid confusion.\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy}\n aria-label={ariaLabel}\n // An element that contains or owns all the listbox options has role\n // listbox.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"listbox\"\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-collapsible.html\n tabIndex={0}\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-scrollable.html\n aria-activedescendant={makeId(currentValue, listId)}\n {...otherProps}\n ref={listRef}\n id={listId}\n onKeyDown={handleKeyDown}\n onScroll={handleOnScroll}\n data-value={currentValue}\n data-focusvalue={focusValue}\n onFocus={handleOnFocus}\n >\n <ListboxContext.Provider\n value={{\n listboxValue: currentValue,\n focusValue,\n listboxId: listId,\n onListboxValueChange: handleValueChange,\n listboxRef: listRef,\n }}\n >\n {children}\n </ListboxContext.Provider>\n </ul>\n );\n}\n\n/**\n * `ListboxItem` component.\n * @alpha\n */\nexport function ListboxItem(props: ListboxItemProps) {\n const { children, value, className, disabled, ...otherProps } = props;\n\n const { listboxValue, focusValue, listboxId, onListboxValueChange } =\n React.useContext(ListboxContext);\n\n const hasFocus = focusValue === value;\n\n const classes = React.useMemo(\n () => classnames(\"core-listbox-item\", hasFocus && \"focused\", className),\n [className, hasFocus]\n );\n const itemRef = React.useRef<HTMLLIElement>(null);\n const isSelected = listboxValue === value;\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLLIElement, MouseEvent>) => {\n event.preventDefault();\n // istanbul ignore next\n const selectedValue = event.currentTarget?.dataset?.value;\n // istanbul ignore else\n if (undefined !== selectedValue) {\n onListboxValueChange(selectedValue, event.ctrlKey);\n }\n },\n [onListboxValueChange]\n );\n\n const getItemId = React.useCallback(() => {\n return makeId(value, listboxId);\n }, [listboxId, value]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <li\n // In a single-select listbox, the selected option has `aria-selected`\n // set to `true`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n aria-selected={isSelected}\n // Applicable to all host language elements regardless of whether a\n // `role` is applied.\n // https://www.w3.org/WAI/PF/aria/states_and_properties#global_states_header\n aria-disabled={disabled || undefined}\n // Each option in the listbox has role `option` and is a DOM descendant\n // of the element with role `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"option\"\n className={classes}\n {...otherProps}\n ref={itemRef}\n id={getItemId()}\n // used for css styling\n data-value={value}\n onClick={handleClick}\n >\n {children}\n </li>\n );\n}\n"]}
|
|
@@ -65,12 +65,16 @@ export interface MessageContainerProps extends CommonProps {
|
|
|
65
65
|
* @public
|
|
66
66
|
*/
|
|
67
67
|
export declare class MessageContainer extends React.PureComponent<MessageContainerProps> {
|
|
68
|
+
/** Returns the class name corresponding to the MessageSeverity.
|
|
69
|
+
* @param severity MessageSeverity
|
|
70
|
+
*/
|
|
71
|
+
static getIconClassName(severity: MessageSeverity): string;
|
|
68
72
|
/** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.
|
|
69
73
|
* @param severity MessageSeverity
|
|
70
|
-
* @param
|
|
71
|
-
* @deprecated in 4.0.
|
|
74
|
+
* @param hollow Should the icon be hollow
|
|
75
|
+
* @deprecated in 4.0. Hollow parameter ignored, WebFont is not returned, only the color.
|
|
72
76
|
*/
|
|
73
|
-
static getIconClassName(severity: MessageSeverity,
|
|
77
|
+
static getIconClassName(severity: MessageSeverity, hollow?: boolean): string;
|
|
74
78
|
/** Returns the React icon corresponding to the MessageSeverity.
|
|
75
79
|
* @param severity MessageSeverity
|
|
76
80
|
* @param hollow set to true to return the hollow form of the icon.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageBox.d.ts","sourceRoot":"","sources":["../../../../src/core-react/messagebox/MessageBox.tsx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AS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACnC,sBAAsB;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC;IAClE,OAAc,YAAY,EAAE,OAAO,CAAC,eAAe,CAAC,CAKlD;IAEc,MAAM,IAAI,KAAK,CAAC,YAAY;CAuB7C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,QAAQ,EAAE,eAAe,CAAC;IAC1B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC;IAC9E;;OAEG;WACW,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM;IACjE;;;;OAIG;WACW,gBAAgB,CAC5B,QAAQ,EAAE,eAAe,EAEzB,MAAM,CAAC,EAAE,OAAO,GACf,MAAM;IAmCT;;;;OAIG;WAGW,OAAO,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ;IA4B5D,MAAM,IAAI,KAAK,CAAC,YAAY;CA0B7C"}
|
|
@@ -32,11 +32,6 @@ export { MessageBox };
|
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
34
|
export class MessageContainer extends React.PureComponent {
|
|
35
|
-
/** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.
|
|
36
|
-
* @param severity MessageSeverity
|
|
37
|
-
* @param _hollow @deprecated in 4.0. Ignored.
|
|
38
|
-
* @deprecated in 4.0. Please use getIcon method
|
|
39
|
-
*/
|
|
40
35
|
/* istanbul ignore next */
|
|
41
36
|
static getIconClassName(severity, _hollow) {
|
|
42
37
|
let iconClassName = "";
|
|
@@ -54,7 +49,7 @@ export class MessageContainer extends React.PureComponent {
|
|
|
54
49
|
iconClassName = "core-message-box-question";
|
|
55
50
|
break;
|
|
56
51
|
case MessageSeverity.Warning:
|
|
57
|
-
iconClassName = "core-message-box-warning";
|
|
52
|
+
iconClassName = "core-message-box-warning";
|
|
58
53
|
break;
|
|
59
54
|
case MessageSeverity.Error:
|
|
60
55
|
iconClassName = "core-message-box-error";
|
|
@@ -100,7 +95,7 @@ export class MessageContainer extends React.PureComponent {
|
|
|
100
95
|
return iconSpec;
|
|
101
96
|
}
|
|
102
97
|
render() {
|
|
103
|
-
const iconClassName = classnames("icon", "core-message-box-icon");
|
|
98
|
+
const iconClassName = classnames("icon", "core-message-box-icon", MessageContainer.getIconClassName(this.props.severity));
|
|
104
99
|
const iconSpec = MessageContainer.getIcon(this.props.severity);
|
|
105
100
|
return (React.createElement("div", { className: "core-message-box-container" },
|
|
106
101
|
React.createElement("div", { className: iconClassName },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageBox.js","sourceRoot":"","sources":["../../../../src/core-react/messagebox/MessageBox.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,iBAAi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AAM;YACR,KAAK,eAAe,CAAC,QAAQ;gBAC3B,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,qBAAqB,OAAG,CAAC,CAAC,CAAC,oBAAC,eAAe,OAAG,CAAC;gBACpE,MAAM;YACR,KAAK,eAAe,CAAC,OAAO;gBAC1B,QAAQ,GAAG,oBAAC,gBAAgB,OAAG,CAAC,CAAC,8CAA8C;gBAC/E,MAAM;YACR,KAAK,eAAe,CAAC,KAAK;gBACxB,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,oBAAoB,OAAG,CAAC,CAAC,CAAC,oBAAC,cAAc,OAAG,CAAC;gBAClE,MAAM;YACR,KAAK,eAAe,CAAC,KAAK;gBACxB,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,uBAAuB,OAAG,CAAC,CAAC,CAAC,oBAAC,iBAAiB,OAAG,CAAC;gBACxE,MAAM;SACT;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEe,MAAM;QACpB,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;QAElE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/D,OAAO,CACL,6BAAK,SAAS,EAAC,4BAA4B;YACzC,6BAAK,SAAS,EAAE,aAAa;gBAC3B,oBAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACxB;YACN,6BACE,SAAS,EAAE,UAAU,CACnB,0BAA0B,EAC1B,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAEtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACF,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Dialog\n */\n\nimport \"./MessageBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { MessageSeverity } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport {\n SvgHelpCircular,\n SvgHelpCircularHollow,\n SvgInfoCircular,\n SvgInfoCircularHollow,\n SvgStatusError,\n SvgStatusErrorHollow,\n SvgStatusRejected,\n SvgStatusRejectedHollow,\n SvgStatusSuccess,\n SvgStatusSuccessHollow,\n SvgStatusWarning,\n} from \"@itwin/itwinui-icons-react\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Dialog } from \"../dialog/Dialog\";\n\n/** Properties for the [[MessageBox]] component\n * @public\n */\nexport interface MessageBoxProps extends CommonProps {\n /** Severity of MessageBox */\n severity: MessageSeverity;\n /** whether to show dialog or not */\n opened: boolean;\n /** List of [[DialogButtonDef]] objects specifying buttons and associated onClick events */\n buttonCluster: DialogButtonDef[];\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for <Esc> key */\n onEscape?: () => void;\n /** minimum width that the dialog may be resized to. Default: 400 */\n minWidth?: number;\n /** minimum height that the dialog may be resized to. Default: 400 */\n minHeight?: number;\n /** initial width of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"50%\"\n */\n width?: string | number;\n /** initial height of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"\"\n */\n height?: string | number;\n /** Whether to show background overlay. Default: true */\n modal?: boolean;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n /** Message content */\n children?: React.ReactNode;\n}\n\n/** Message Box React component.\n * @public\n */\nexport class MessageBox extends React.PureComponent<MessageBoxProps> {\n public static defaultProps: Partial<MessageBoxProps> = {\n minWidth: 400,\n minHeight: 400,\n width: \"512px\",\n modal: true,\n };\n\n public override render(): React.ReactElement {\n return (\n <Dialog\n title={this.props.title}\n buttonCluster={this.props.buttonCluster}\n opened={this.props.opened}\n onClose={this.props.onClose}\n onEscape={this.props.onEscape}\n modal={this.props.modal}\n className={this.props.className}\n style={this.props.style}\n width={this.props.width}\n >\n <MessageContainer\n severity={this.props.severity}\n className={this.props.contentClassName}\n style={this.props.contentStyle}\n >\n {this.props.children}\n </MessageContainer>\n </Dialog>\n );\n }\n}\n\n/** Properties for the [[MessageContainer]] component\n * @public\n */\nexport interface MessageContainerProps extends CommonProps {\n severity: MessageSeverity;\n /** Message Content */\n children?: React.ReactNode;\n}\n\n/** Message Container React component.\n * @public\n */\nexport class MessageContainer extends React.PureComponent<MessageContainerProps> {\n /** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param _hollow @deprecated in 4.0. Ignored.\n * @deprecated in 4.0. Please use getIcon method\n */\n /* istanbul ignore next */\n public static getIconClassName(\n severity: MessageSeverity,\n _hollow?: boolean\n ): string {\n let iconClassName = \"\";\n\n switch (severity) {\n case MessageSeverity.None:\n iconClassName = \"\";\n break;\n case MessageSeverity.Success:\n iconClassName = \"core-message-box-success\";\n break;\n case MessageSeverity.Information:\n iconClassName = \"core-message-box-information\";\n break;\n case MessageSeverity.Question:\n iconClassName = \"core-message-box-question\";\n break;\n case MessageSeverity.Warning:\n iconClassName = \"core-message-box-warning\"; // TODO - need icon-status-warning-hollow icon\n break;\n case MessageSeverity.Error:\n iconClassName = \"core-message-box-error\";\n break;\n case MessageSeverity.Fatal:\n iconClassName = \"core-message-box-fatal\";\n break;\n }\n\n return iconClassName;\n }\n\n /** Returns the React icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param hollow set to true to return the hollow form of the icon.\n * @returns IconSpec\n */\n /* ignore for unit tests and replace with visual testing */\n /* istanbul ignore next */\n public static getIcon(severity: MessageSeverity, hollow?: boolean): IconSpec {\n let iconSpec: IconSpec = \"\";\n switch (severity) {\n case MessageSeverity.None:\n iconSpec = \"\";\n break;\n case MessageSeverity.Success:\n iconSpec = hollow ? <SvgStatusSuccessHollow /> : <SvgStatusSuccess />;\n break;\n case MessageSeverity.Information:\n iconSpec = hollow ? <SvgInfoCircularHollow /> : <SvgInfoCircular />;\n break;\n case MessageSeverity.Question:\n iconSpec = hollow ? <SvgHelpCircularHollow /> : <SvgHelpCircular />;\n break;\n case MessageSeverity.Warning:\n iconSpec = <SvgStatusWarning />; // TODO - need icon-status-warning-hollow icon\n break;\n case MessageSeverity.Error:\n iconSpec = hollow ? <SvgStatusErrorHollow /> : <SvgStatusError />;\n break;\n case MessageSeverity.Fatal:\n iconSpec = hollow ? <SvgStatusRejectedHollow /> : <SvgStatusRejected />;\n break;\n }\n return iconSpec;\n }\n\n public override render(): React.ReactElement {\n const iconClassName = classnames(\"icon\", \"core-message-box-icon\");\n\n const iconSpec = MessageContainer.getIcon(this.props.severity);\n\n return (\n <div className=\"core-message-box-container\">\n <div className={iconClassName}>\n <Icon iconSpec={iconSpec} />\n </div>\n <div\n className={classnames(\n \"core-message-box-content\",\n this.props.className\n )}\n style={this.props.style}\n >\n {this.props.children}\n </div>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MessageBox.js","sourceRoot":"","sources":["../../../../src/core-react/messagebox/MessageBox.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,uBA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B,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,qBAAqB,OAAG,CAAC,CAAC,CAAC,oBAAC,eAAe,OAAG,CAAC;gBACpE,MAAM;YACR,KAAK,eAAe,CAAC,OAAO;gBAC1B,QAAQ,GAAG,oBAAC,gBAAgB,OAAG,CAAC,CAAC,8CAA8C;gBAC/E,MAAM;YACR,KAAK,eAAe,CAAC,KAAK;gBACxB,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,oBAAoB,OAAG,CAAC,CAAC,CAAC,oBAAC,cAAc,OAAG,CAAC;gBAClE,MAAM;YACR,KAAK,eAAe,CAAC,KAAK;gBACxB,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,uBAAuB,OAAG,CAAC,CAAC,CAAC,oBAAC,iBAAiB,OAAG,CAAC;gBACxE,MAAM;SACT;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEe,MAAM;QACpB,MAAM,aAAa,GAAG,UAAU,CAC9B,MAAM,EACN,uBAAuB,EACvB,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CACvD,CAAC;QAEF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/D,OAAO,CACL,6BAAK,SAAS,EAAC,4BAA4B;YACzC,6BAAK,SAAS,EAAE,aAAa;gBAC3B,oBAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACxB;YACN,6BACE,SAAS,EAAE,UAAU,CACnB,0BAA0B,EAC1B,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAEtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACF,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Dialog\n */\n\nimport \"./MessageBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { MessageSeverity } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport {\n SvgHelpCircular,\n SvgHelpCircularHollow,\n SvgInfoCircular,\n SvgInfoCircularHollow,\n SvgStatusError,\n SvgStatusErrorHollow,\n SvgStatusRejected,\n SvgStatusRejectedHollow,\n SvgStatusSuccess,\n SvgStatusSuccessHollow,\n SvgStatusWarning,\n} from \"@itwin/itwinui-icons-react\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Dialog } from \"../dialog/Dialog\";\n\n/** Properties for the [[MessageBox]] component\n * @public\n */\nexport interface MessageBoxProps extends CommonProps {\n /** Severity of MessageBox */\n severity: MessageSeverity;\n /** whether to show dialog or not */\n opened: boolean;\n /** List of [[DialogButtonDef]] objects specifying buttons and associated onClick events */\n buttonCluster: DialogButtonDef[];\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for <Esc> key */\n onEscape?: () => void;\n /** minimum width that the dialog may be resized to. Default: 400 */\n minWidth?: number;\n /** minimum height that the dialog may be resized to. Default: 400 */\n minHeight?: number;\n /** initial width of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"50%\"\n */\n width?: string | number;\n /** initial height of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"\"\n */\n height?: string | number;\n /** Whether to show background overlay. Default: true */\n modal?: boolean;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n /** Message content */\n children?: React.ReactNode;\n}\n\n/** Message Box React component.\n * @public\n */\nexport class MessageBox extends React.PureComponent<MessageBoxProps> {\n public static defaultProps: Partial<MessageBoxProps> = {\n minWidth: 400,\n minHeight: 400,\n width: \"512px\",\n modal: true,\n };\n\n public override render(): React.ReactElement {\n return (\n <Dialog\n title={this.props.title}\n buttonCluster={this.props.buttonCluster}\n opened={this.props.opened}\n onClose={this.props.onClose}\n onEscape={this.props.onEscape}\n modal={this.props.modal}\n className={this.props.className}\n style={this.props.style}\n width={this.props.width}\n >\n <MessageContainer\n severity={this.props.severity}\n className={this.props.contentClassName}\n style={this.props.contentStyle}\n >\n {this.props.children}\n </MessageContainer>\n </Dialog>\n );\n }\n}\n\n/** Properties for the [[MessageContainer]] component\n * @public\n */\nexport interface MessageContainerProps extends CommonProps {\n severity: MessageSeverity;\n /** Message Content */\n children?: React.ReactNode;\n}\n\n/** Message Container React component.\n * @public\n */\nexport class MessageContainer extends React.PureComponent<MessageContainerProps> {\n /** Returns the class name corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n */\n public static getIconClassName(severity: MessageSeverity): string;\n /** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param hollow Should the icon be hollow\n * @deprecated in 4.0. Hollow parameter ignored, WebFont is not returned, only the color.\n */\n public static getIconClassName(\n severity: MessageSeverity,\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n hollow?: boolean\n ): string;\n /* istanbul ignore next */\n public static getIconClassName(\n severity: MessageSeverity,\n _hollow?: boolean\n ): string {\n let iconClassName = \"\";\n\n switch (severity) {\n case MessageSeverity.None:\n iconClassName = \"\";\n break;\n case MessageSeverity.Success:\n iconClassName = \"core-message-box-success\";\n break;\n case MessageSeverity.Information:\n iconClassName = \"core-message-box-information\";\n break;\n case MessageSeverity.Question:\n iconClassName = \"core-message-box-question\";\n break;\n case MessageSeverity.Warning:\n iconClassName = \"core-message-box-warning\";\n break;\n case MessageSeverity.Error:\n iconClassName = \"core-message-box-error\";\n break;\n case MessageSeverity.Fatal:\n iconClassName = \"core-message-box-fatal\";\n break;\n }\n\n return iconClassName;\n }\n\n /** Returns the React icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param hollow set to true to return the hollow form of the icon.\n * @returns IconSpec\n */\n /* ignore for unit tests and replace with visual testing */\n /* istanbul ignore next */\n public static getIcon(severity: MessageSeverity, hollow?: boolean): IconSpec {\n let iconSpec: IconSpec = \"\";\n switch (severity) {\n case MessageSeverity.None:\n iconSpec = \"\";\n break;\n case MessageSeverity.Success:\n iconSpec = hollow ? <SvgStatusSuccessHollow /> : <SvgStatusSuccess />;\n break;\n case MessageSeverity.Information:\n iconSpec = hollow ? <SvgInfoCircularHollow /> : <SvgInfoCircular />;\n break;\n case MessageSeverity.Question:\n iconSpec = hollow ? <SvgHelpCircularHollow /> : <SvgHelpCircular />;\n break;\n case MessageSeverity.Warning:\n iconSpec = <SvgStatusWarning />; // TODO - need icon-status-warning-hollow icon\n break;\n case MessageSeverity.Error:\n iconSpec = hollow ? <SvgStatusErrorHollow /> : <SvgStatusError />;\n break;\n case MessageSeverity.Fatal:\n iconSpec = hollow ? <SvgStatusRejectedHollow /> : <SvgStatusRejected />;\n break;\n }\n return iconSpec;\n }\n\n public override render(): React.ReactElement {\n const iconClassName = classnames(\n \"icon\",\n \"core-message-box-icon\",\n MessageContainer.getIconClassName(this.props.severity)\n );\n\n const iconSpec = MessageContainer.getIcon(this.props.severity);\n\n return (\n <div className=\"core-message-box-container\">\n <div className={iconClassName}>\n <Icon iconSpec={iconSpec} />\n </div>\n <div\n className={classnames(\n \"core-message-box-content\",\n this.props.className\n )}\n style={this.props.style}\n >\n {this.props.children}\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -21,7 +21,7 @@ export function MessageRenderer(props) {
|
|
|
21
21
|
// the esm build of dompurify has a default import but the cjs build does not
|
|
22
22
|
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
23
23
|
// istanbul ignore next
|
|
24
|
-
const sanitizer = DOMPurify
|
|
24
|
+
const sanitizer = DOMPurify !== null && DOMPurify !== void 0 ? DOMPurify : DOMPurifyNS; // `sanitizer` is default function name for "jam3/no-sanitizer-with-danger" ESLint rule
|
|
25
25
|
let validAnchors = false;
|
|
26
26
|
let hasAnchors = false;
|
|
27
27
|
// verify that the tag has proper relationships
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS,EAAE,KAAK,WAAW,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAe9D;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAElD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QACrC,WAAW,GAAG,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,OAAO,CAAc,CACrE,CAAC;KACH;SAAM,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACvC,6EAA6E;QAC7E,iFAAiF;QACjF,uBAAuB;QACvB,MAAM,SAAS,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS,EAAE,KAAK,WAAW,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,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nC,KAAK,CAAC,OAAO,CAAC,SAAS,CACb,CACd,CAAC;KACL;IAED,OAAO,WAAW,CAAC;AACrB,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 Notification\n */\n\nimport * as React from \"react\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport type { MessageType } from \"./MessageType\";\nimport { isHTMLElement, isReactMessage } from \"./MessageType\";\nimport type { ClassNameProps } from \"../utils/Props\";\n\n// cSpell:ignore dompurify\n\n/** Properties for the [[MessageRenderer]] component\n * @public\n */\nexport interface MessageRendererProps extends ClassNameProps {\n /** Message to render */\n message: MessageType;\n /** Indicates whether to use a `span` or `div` element for rendering */\n useSpan?: boolean;\n}\n\n/** React component renders a string, HTMLElement or React node in a `div` or `span`\n * @public\n */\nexport function MessageRenderer(props: MessageRendererProps) {\n let messageNode = null;\n const OutElement = props.useSpan ? \"span\" : \"div\";\n\n if (typeof props.message === \"string\") {\n messageNode = (\n <OutElement className={props.className}>{props.message}</OutElement>\n );\n } else if (isHTMLElement(props.message)) {\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS; // `sanitizer` is default function name for \"jam3/no-sanitizer-with-danger\" ESLint rule\n\n let validAnchors = false;\n let hasAnchors = false;\n\n // verify that the tag has proper relationships\n const isAnchorValid = (anchor: HTMLAnchorElement): boolean => {\n return (\n anchor.hasAttribute(\"rel\") &&\n (anchor.rel.includes(\"noopener\") || anchor.rel.includes(\"noreferrer\"))\n );\n };\n\n // recursively check child elements for valid anchor tags\n const checkChildAnchors = (parent: Element) => {\n const children = Array.from(parent.children);\n for (const child of children) {\n if (\n child.hasAttribute(\"target\") &&\n (child as HTMLAnchorElement).target === \"_blank\"\n ) {\n hasAnchors = true;\n validAnchors = isAnchorValid(child as HTMLAnchorElement);\n if (!validAnchors) {\n return;\n }\n }\n checkChildAnchors(child);\n }\n };\n\n // check for anchor tags in the message that have target _blank also have a relationship that avoids security holes\n // https://web.dev/external-anchors-use-rel-noopener/\n // first check the message element\n /* istanbul ignore else */\n if (\n props.message.hasAttribute(\"target\") &&\n (props.message as HTMLAnchorElement).target === \"_blank\"\n ) {\n hasAnchors = true;\n validAnchors = isAnchorValid(props.message as HTMLAnchorElement);\n } else {\n // if the message element is not an anchor, recursively verify it's children\n if (props.message.children) {\n checkChildAnchors(props.message);\n }\n }\n\n let sanitizedHtml;\n if (hasAnchors && validAnchors) {\n // all anchors are valid. do not remove the target attr\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, {\n ADD_ATTR: [\"target\"],\n });\n } else {\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);\n }\n\n messageNode = (\n <OutElement\n className={props.className}\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n dangerouslySetInnerHTML={{ __html: sanitizedHtml }}\n />\n );\n } else {\n /* istanbul ignore else */\n if (isReactMessage(props.message))\n messageNode = (\n <OutElement className={props.className}>\n {props.message.reactNode}\n </OutElement>\n );\n }\n\n return messageNode;\n}\n"]}
|
|
@@ -16,6 +16,7 @@ import { FocusTrap } from "../focustrap/FocusTrap";
|
|
|
16
16
|
*/
|
|
17
17
|
class Popup extends React.Component {
|
|
18
18
|
constructor(props) {
|
|
19
|
+
var _a, _b;
|
|
19
20
|
super(props);
|
|
20
21
|
this._popup = null;
|
|
21
22
|
this._bindWindowEvents = () => {
|
|
@@ -197,7 +198,7 @@ class Popup extends React.Component {
|
|
|
197
198
|
this.setState({ animationEnded: true });
|
|
198
199
|
}
|
|
199
200
|
};
|
|
200
|
-
const parentDocument = this.props.target
|
|
201
|
+
const parentDocument = (_b = (_a = this.props.target) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
|
|
201
202
|
this.state = {
|
|
202
203
|
animationEnded: false,
|
|
203
204
|
isOpen: this.props.isOpen,
|
|
@@ -213,17 +214,19 @@ class Popup extends React.Component {
|
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
getParentWindow() {
|
|
217
|
+
var _a;
|
|
216
218
|
// istanbul ignore next
|
|
217
|
-
return this.state.parentDocument.defaultView
|
|
219
|
+
return (_a = this.state.parentDocument.defaultView) !== null && _a !== void 0 ? _a : window;
|
|
218
220
|
}
|
|
219
221
|
componentDidUpdate(previousProps, prevState) {
|
|
222
|
+
var _a, _b;
|
|
220
223
|
if (this.state.position !== prevState.position) {
|
|
221
224
|
this.setState({ animationEnded: false });
|
|
222
225
|
}
|
|
223
226
|
if (this.props.target !== previousProps.target) {
|
|
224
227
|
// istanbul ignore next
|
|
225
228
|
{
|
|
226
|
-
const parentDocument = this.props.target
|
|
229
|
+
const parentDocument = (_b = (_a = this.props.target) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
|
|
227
230
|
if (parentDocument !== this.state.parentDocument) {
|
|
228
231
|
this._unBindWindowEvents();
|
|
229
232
|
this.setState({ parentDocument });
|
|
@@ -398,6 +401,7 @@ class Popup extends React.Component {
|
|
|
398
401
|
return newPosition;
|
|
399
402
|
}
|
|
400
403
|
render() {
|
|
404
|
+
var _a;
|
|
401
405
|
const animate = this.props.animate !== undefined ? this.props.animate : true;
|
|
402
406
|
const className = classnames("core-popup", this._getClassNameByPosition(this.state.position), this.props.showShadow && "core-popup-shadow", this.props.showArrow && "arrow", !animate && "core-popup-animation-none", this.props.className, this.state.animationEnded && "core-animation-ended", !this.props.isOpen &&
|
|
403
407
|
this.props.keepContentsMounted &&
|
|
@@ -416,7 +420,7 @@ class Popup extends React.Component {
|
|
|
416
420
|
}, style: style, role: role, "aria-modal": true, tabIndex: -1, "aria-label": this.props.ariaLabel, onAnimationEnd: this._handleAnimationEnd },
|
|
417
421
|
React.createElement(FocusTrap, { active: !!this.props.moveFocus, initialFocusElement: this.props.focusTarget, returnFocusOnDeactivate: true }, this.props.children)),
|
|
418
422
|
// istanbul ignore next
|
|
419
|
-
this.state.parentDocument.body.querySelector('[data-root-container="iui-root-id"]')
|
|
423
|
+
(_a = this.state.parentDocument.body.querySelector('[data-root-container="iui-root-id"]')) !== null && _a !== void 0 ? _a : this.state.parentDocument.body);
|
|
420
424
|
}
|
|
421
425
|
}
|
|
422
426
|
Popup.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popup.js","sourceRoot":"","sources":["../../../../src/core-react/popup/Popup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,cAAc,CAAC;AACtB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAuFnD;;GAEG;AACH,MAAa,KAAM,SAAQ,KAAK,CAAC,SAAiC;IAGhE,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;QAHP,WAAM,GAAuB,IAAI,CAAC;QAuFlC,sBAAiB,GAAG,GAAG,EAAE;YAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YAC5C,YAAY,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvE,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACtD,YAAY,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtE,YAAY,CAAC,gBAAgB,CAAC,QAAQ,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AAK,CAAC,SAAS,EAC9B,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAC3C,uBAAuB,EAAE,IAAI,IAE5B,IAAI,CAAC,KAAK,CAAC,QAAQ,CACV,CACR;QACN,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,qCAAqC,CACtC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CAAC;IACJ,CAAC;;AAlgBa,kBAAY,GAAwB;IAChD,QAAQ,EAAE,gBAAgB,CAAC,MAAM;IACjC,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC,CAAC;IACP,IAAI,EAAE,CAAC,CAAC;CACT,AARyB,CAQxB;SAzBS,KAAK;AAshBlB,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,MAAM,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,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 Popup\n */\n\nimport \"./Popup.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport { FocusTrap } from \"../focustrap/FocusTrap\";\nimport type { CommonProps } from \"../utils/Props\";\n\n// cSpell:ignore focustrap focusable alertdialog\n\n/** @internal */\ninterface PopupPoint {\n x: number;\n y: number;\n}\n\n/** Properties for the [[Popup]] component\n * @public\n */\nexport interface PopupProps extends CommonProps {\n /** Show or hide the box shadow (defaults to true) */\n showShadow: boolean;\n /** Show or hide the arrow (defaults to false) */\n showArrow: boolean;\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position: RelativePosition;\n /** Top position (absolute positioning - defaults to 0) */\n top: number;\n /** Left position (absolute positioning - defaults to 0) */\n left: number;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Function called when the wheel is used */\n onWheel?: (e: WheelEvent) => void;\n /** Function called when the right mouse button is pressed */\n onContextMenu?: (e: MouseEvent) => void;\n /** Offset from the parent (defaults to 4) */\n offset: number;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Role - if not specified \"dialog\" is used */\n role?: \"dialog\" | \"alert\" | \"alertdialog\";\n /** accessibility label */\n ariaLabel?: string;\n /** set focus to popup - default to not set focus */\n moveFocus?: boolean;\n /** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */\n focusTarget?: React.RefObject<HTMLElement> | string;\n /** Indicates whether the popup is pinned. */\n isPinned?: boolean;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n /** Indicates whether to close the popup when Enter is pressed (defaults to true) */\n closeOnEnter?: boolean;\n /** Indicates whether to close the popup when the wheel is used (defaults to true) */\n closeOnWheel?: boolean;\n /** Indicates whether to close the popup when the right mouse button is pressed (defaults to true) */\n closeOnContextMenu?: boolean;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n /** If true the children are mounted once and unmounted when this component is unmounted. If false the\n * children are unmounted each time the popup is closed. */\n keepContentsMounted?: boolean;\n\n /**\n * If true the popup will remain open and will be repositioned when window resize events occur, default to false.\n * @beta\n * */\n repositionOnResize?: boolean;\n\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface PopupState {\n isOpen: boolean;\n top: number;\n left: number;\n position: RelativePosition;\n parentDocument: Document;\n animationEnded: boolean;\n}\n\n/** Popup React component displays a popup relative to an optional target element.\n * @public\n */\nexport class Popup extends React.Component<PopupProps, PopupState> {\n private _popup: HTMLElement | null = null;\n\n constructor(props: PopupProps) {\n super(props);\n const parentDocument = this.props.target?.ownerDocument ?? document;\n\n this.state = {\n animationEnded: false,\n isOpen: this.props.isOpen,\n top: 0,\n left: 0,\n position: this.props.position,\n parentDocument,\n };\n }\n\n public static defaultProps: Partial<PopupProps> = {\n position: RelativePosition.Bottom,\n showShadow: true,\n showArrow: false,\n isOpen: false,\n offset: 4,\n top: -1,\n left: -1,\n };\n\n public override componentDidMount() {\n if (this.props.isOpen) {\n this._onShow();\n }\n }\n\n private getParentWindow() {\n // istanbul ignore next\n return this.state.parentDocument.defaultView ?? window;\n }\n\n public override componentDidUpdate(\n previousProps: PopupProps,\n prevState: PopupState\n ) {\n if (this.state.position !== prevState.position) {\n this.setState({ animationEnded: false });\n }\n\n if (this.props.target !== previousProps.target) {\n // istanbul ignore next\n {\n const parentDocument = this.props.target?.ownerDocument ?? document;\n if (parentDocument !== this.state.parentDocument) {\n this._unBindWindowEvents();\n this.setState({ parentDocument });\n }\n }\n }\n\n if (this.props.isOpen === previousProps.isOpen) {\n if (this.props.isOpen) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n if (\n Math.abs(this.state.left - point.x) < 3 &&\n Math.abs(this.state.top - point.y) < 3 &&\n this.state.position === position\n )\n return;\n\n this.setState({\n left: point.x,\n top: point.y,\n position,\n });\n }\n return;\n }\n\n if (this.props.isOpen) {\n this._onShow();\n } else {\n this._onClose();\n }\n }\n\n public override componentWillUnmount() {\n this._unBindWindowEvents();\n }\n\n private _bindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.addEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.addEventListener(\"resize\", this._resize);\n activeWindow.addEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.addEventListener(\"scroll\", this._hide);\n activeWindow.addEventListener(\"wheel\", this._handleWheel);\n activeWindow.addEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _unBindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.removeEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.removeEventListener(\"resize\", this._resize);\n activeWindow.removeEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.removeEventListener(\"scroll\", this._hide);\n activeWindow.removeEventListener(\"wheel\", this._handleWheel);\n activeWindow.removeEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _handleWheel = (event: WheelEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onWheel) return this.props.onWheel(event);\n\n const closeOnWheel =\n this.props.closeOnWheel !== undefined ? this.props.closeOnWheel : true;\n if (closeOnWheel) this._hide();\n };\n\n private 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 private _handleOutsideClick = (event: MouseEvent): void => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.isPinned) return;\n\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(event.target as HTMLElement)\n )\n return;\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(event);\n\n if (this.props.target && this.props.target.contains(event.target as Node))\n return;\n\n this._onClose();\n };\n\n private _handleContextMenu = (event: MouseEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onContextMenu) return this.props.onContextMenu(event);\n\n const closeOnContextMenu =\n this.props.closeOnContextMenu !== undefined\n ? this.props.closeOnContextMenu\n : true;\n if (closeOnContextMenu) this._hide();\n };\n\n private _handleKeyboard = (event: KeyboardEvent): void => {\n if (this.props.isPinned) return;\n\n if (event.key === SpecialKey.Escape || event.key === SpecialKey.Enter) {\n const closeOnEnter =\n this.props.closeOnEnter !== undefined ? this.props.closeOnEnter : true;\n if (event.key === SpecialKey.Enter) {\n if (closeOnEnter) this._onClose(true);\n else this.props.onEnter && this.props.onEnter();\n } else {\n this._onClose(false);\n }\n }\n };\n\n private _resize = () => {\n if (this.props.repositionOnResize) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n this.setState({ left: point.x, top: point.y, position });\n } else {\n this._hide(); // legacy behavior\n }\n };\n\n private _hide = () => {\n if (this.props.isPinned) return;\n\n this._onClose();\n };\n\n private _onShow() {\n this._bindWindowEvents();\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n\n this.setState(\n { left: point.x, top: point.y, isOpen: true, position },\n () => {\n if (this.props.onOpen) this.props.onOpen();\n }\n );\n }\n\n private _onClose(enterKey?: boolean) {\n if (!this.state.isOpen) return;\n\n this._unBindWindowEvents();\n\n this.setState({ isOpen: false }, () => {\n if (enterKey && this.props.onEnter) this.props.onEnter();\n if (this.props.onClose) this.props.onClose();\n });\n }\n\n private _isPositionAbsolute(): boolean {\n return this.props.top !== -1 && this.props.left !== -1;\n }\n\n private _getClassNameByPosition(position: RelativePosition): string {\n if (!this._isPositionAbsolute()) {\n switch (position) {\n case RelativePosition.TopLeft:\n return \"core-popup-top-left\";\n case RelativePosition.TopRight:\n return \"core-popup-top-right\";\n case RelativePosition.BottomLeft:\n return \"core-popup-bottom-left\";\n case RelativePosition.BottomRight:\n return \"core-popup-bottom-right\";\n case RelativePosition.Top:\n return \"core-popup-top\";\n case RelativePosition.Left:\n return \"core-popup-left\";\n case RelativePosition.Right:\n return \"core-popup-right\";\n case RelativePosition.Bottom:\n return \"core-popup-bottom\";\n case RelativePosition.LeftTop:\n return \"core-popup-left-top\";\n case RelativePosition.RightTop:\n return \"core-popup-right-top\";\n }\n }\n\n return \"\";\n }\n\n private _getPopupDimensions(): { popupWidth: number; popupHeight: number } {\n let popupWidth = 0;\n let popupHeight = 0;\n // istanbul ignore else\n if (this._popup) {\n const activeWindow = this.getParentWindow();\n const style = activeWindow.getComputedStyle(this._popup);\n const borderLeftWidth = parsePxString(style.borderLeftWidth);\n const borderRightWidth = parsePxString(style.borderRightWidth);\n const borderTopWidth = parsePxString(style.borderTopWidth);\n const borderBottomWidth = parsePxString(style.borderBottomWidth);\n popupWidth = this._popup.clientWidth + borderLeftWidth + borderRightWidth;\n popupHeight =\n this._popup.clientHeight + borderTopWidth + borderBottomWidth;\n }\n\n return { popupWidth, popupHeight };\n }\n\n private _getPosition = (position: RelativePosition) => {\n const activeWindow = this.getParentWindow();\n const { target, offset, top, left } = this.props;\n const offsetArrow = this.props.showArrow ? 6 : 0;\n\n // absolute position\n if (this._isPositionAbsolute()) return { x: left, y: top };\n\n // sanity check\n const point = { x: 0, y: 0 };\n if (!this._popup || !target) return point;\n\n // relative position\n const scrollY = activeWindow.scrollY;\n const scrollX = activeWindow.scrollX;\n\n const targetRect = target.getBoundingClientRect();\n\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n\n switch (position) {\n case RelativePosition.Top:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.TopLeft:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.TopRight:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Bottom:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.BottomLeft:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.BottomRight:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Left:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.LeftTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.Right:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n\n case RelativePosition.RightTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n }\n\n return point;\n };\n\n private _toggleRelativePosition(): RelativePosition {\n const { target, position, offset } = this.props;\n\n if (!this._popup || !target) return position;\n\n // istanbul ignore if\n if (this._isPositionAbsolute()) return position;\n\n let newPosition = position;\n\n interface Rect {\n left: number;\n top: number;\n right: number;\n bottom: number;\n }\n\n const activeWindow = this.getParentWindow();\n\n // Note: Cannot use DOMRect yet since it's experimental and not available in all browsers (Nov. 2018)\n const viewportRect: Rect = {\n left: activeWindow.scrollX,\n top: activeWindow.scrollY,\n right: activeWindow.scrollX + activeWindow.innerWidth,\n bottom: activeWindow.scrollY + activeWindow.innerHeight,\n };\n const targetRect = target.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const containerStyle = activeWindow.getComputedStyle(target);\n const offsetArrow = this.props.showArrow\n ? /* istanbul ignore next */ 10\n : 2;\n\n const bottomMargin = parseMargin(containerStyle.marginBottom);\n if (\n targetRect.bottom + popupHeight + bottomMargin + offsetArrow + offset >\n viewportRect.bottom\n ) {\n if (newPosition === RelativePosition.Bottom)\n newPosition = RelativePosition.Top;\n else if (newPosition === RelativePosition.BottomLeft)\n newPosition = RelativePosition.TopLeft;\n else if (newPosition === RelativePosition.BottomRight)\n newPosition = RelativePosition.TopRight;\n }\n\n const topMargin = parseMargin(containerStyle.marginTop);\n if (\n targetRect.top - popupHeight - topMargin - offsetArrow - offset <\n viewportRect.top\n ) {\n if (newPosition === RelativePosition.Top)\n newPosition = RelativePosition.Bottom;\n else if (newPosition === RelativePosition.TopLeft)\n newPosition = RelativePosition.BottomLeft;\n else if (newPosition === RelativePosition.TopRight)\n newPosition = RelativePosition.BottomRight;\n }\n\n const leftMargin = parseMargin(containerStyle.marginLeft);\n if (\n targetRect.left - popupWidth - leftMargin - offsetArrow - offset <\n viewportRect.left\n ) {\n if (newPosition === RelativePosition.Left)\n newPosition = RelativePosition.Right;\n else if (newPosition === RelativePosition.LeftTop)\n newPosition = RelativePosition.RightTop;\n }\n\n const rightMargin = parseMargin(containerStyle.marginRight);\n if (\n targetRect.right + popupWidth + rightMargin + offsetArrow + offset >\n viewportRect.right\n ) {\n if (newPosition === RelativePosition.Right)\n newPosition = RelativePosition.Left;\n else if (newPosition === RelativePosition.RightTop)\n newPosition = RelativePosition.LeftTop;\n }\n\n return newPosition;\n }\n\n // fit the popup within the extents of the view port\n private _fitPopup = (point: PopupPoint) => {\n const fittedPoint = point;\n\n // istanbul ignore if\n if (!this._popup) {\n return fittedPoint;\n }\n\n // const popupRect = this._popup.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const { innerWidth, innerHeight } = window;\n\n // istanbul ignore if\n if (fittedPoint.y + popupHeight > innerHeight) {\n fittedPoint.y = innerHeight - popupHeight;\n }\n\n // istanbul ignore if\n if (fittedPoint.x + popupWidth > innerWidth) {\n fittedPoint.x = innerWidth - popupWidth;\n }\n\n // istanbul ignore if\n if (fittedPoint.y < 0) {\n fittedPoint.y = 0;\n }\n\n if (fittedPoint.x < 0) {\n fittedPoint.x = 0;\n }\n\n return fittedPoint;\n };\n\n private _handleAnimationEnd = (\n event: React.AnimationEvent<HTMLDivElement>\n ) => {\n if (event.target === this._popup) {\n this.setState({ animationEnded: true });\n }\n };\n\n public override render() {\n const animate =\n this.props.animate !== undefined ? this.props.animate : true;\n const className = classnames(\n \"core-popup\",\n this._getClassNameByPosition(this.state.position),\n this.props.showShadow && \"core-popup-shadow\",\n this.props.showArrow && \"arrow\",\n !animate && \"core-popup-animation-none\",\n this.props.className,\n this.state.animationEnded && \"core-animation-ended\",\n !this.props.isOpen &&\n this.props.keepContentsMounted &&\n \"core-popup-hidden\"\n );\n\n const style: React.CSSProperties = {\n top: this.state.top,\n left: this.state.left,\n ...this.props.style,\n };\n\n const role = this.props.role ? this.props.role : \"dialog\"; // accessibility property\n\n if (!this.props.isOpen && !this.props.keepContentsMounted) {\n return null;\n }\n\n return ReactDOM.createPortal(\n <div\n className={className}\n data-testid=\"core-popup\"\n ref={(element) => {\n this._popup = element;\n }}\n style={style}\n role={role}\n aria-modal={true}\n tabIndex={-1}\n aria-label={this.props.ariaLabel}\n onAnimationEnd={this._handleAnimationEnd}\n >\n <FocusTrap\n active={!!this.props.moveFocus}\n initialFocusElement={this.props.focusTarget}\n returnFocusOnDeactivate={true}\n >\n {this.props.children}\n </FocusTrap>\n </div>,\n // istanbul ignore next\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"iui-root-id\"]'\n ) ?? this.state.parentDocument.body\n );\n }\n}\n\nfunction parsePxString(pxStr: string): number {\n const parsed = parseInt(pxStr, 10);\n return parsed || 0;\n}\n\nfunction parseMargin(value: string) {\n return value ? /* istanbul ignore next */ parseFloat(value) : 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Popup.js","sourceRoot":"","sources":["../../../../src/core-react/popup/Popup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,cAAc,CAAC;AACtB,OAAO,UAAU,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AM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC,CAAC;IACP,IAAI,EAAE,CAAC,CAAC;CACT,AARyB,CAQxB;SAzBS,KAAK;AAshBlB,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,MAAM,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,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 Popup\n */\n\nimport \"./Popup.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport { FocusTrap } from \"../focustrap/FocusTrap\";\nimport type { CommonProps } from \"../utils/Props\";\n\n// cSpell:ignore focustrap focusable alertdialog\n\n/** @internal */\ninterface PopupPoint {\n x: number;\n y: number;\n}\n\n/** Properties for the [[Popup]] component\n * @public\n */\nexport interface PopupProps extends CommonProps {\n /** Show or hide the box shadow (defaults to true) */\n showShadow: boolean;\n /** Show or hide the arrow (defaults to false) */\n showArrow: boolean;\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position: RelativePosition;\n /** Top position (absolute positioning - defaults to 0) */\n top: number;\n /** Left position (absolute positioning - defaults to 0) */\n left: number;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Function called when the wheel is used */\n onWheel?: (e: WheelEvent) => void;\n /** Function called when the right mouse button is pressed */\n onContextMenu?: (e: MouseEvent) => void;\n /** Offset from the parent (defaults to 4) */\n offset: number;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Role - if not specified \"dialog\" is used */\n role?: \"dialog\" | \"alert\" | \"alertdialog\";\n /** accessibility label */\n ariaLabel?: string;\n /** set focus to popup - default to not set focus */\n moveFocus?: boolean;\n /** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */\n focusTarget?: React.RefObject<HTMLElement> | string;\n /** Indicates whether the popup is pinned. */\n isPinned?: boolean;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n /** Indicates whether to close the popup when Enter is pressed (defaults to true) */\n closeOnEnter?: boolean;\n /** Indicates whether to close the popup when the wheel is used (defaults to true) */\n closeOnWheel?: boolean;\n /** Indicates whether to close the popup when the right mouse button is pressed (defaults to true) */\n closeOnContextMenu?: boolean;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n /** If true the children are mounted once and unmounted when this component is unmounted. If false the\n * children are unmounted each time the popup is closed. */\n keepContentsMounted?: boolean;\n\n /**\n * If true the popup will remain open and will be repositioned when window resize events occur, default to false.\n * @beta\n * */\n repositionOnResize?: boolean;\n\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface PopupState {\n isOpen: boolean;\n top: number;\n left: number;\n position: RelativePosition;\n parentDocument: Document;\n animationEnded: boolean;\n}\n\n/** Popup React component displays a popup relative to an optional target element.\n * @public\n */\nexport class Popup extends React.Component<PopupProps, PopupState> {\n private _popup: HTMLElement | null = null;\n\n constructor(props: PopupProps) {\n super(props);\n const parentDocument = this.props.target?.ownerDocument ?? document;\n\n this.state = {\n animationEnded: false,\n isOpen: this.props.isOpen,\n top: 0,\n left: 0,\n position: this.props.position,\n parentDocument,\n };\n }\n\n public static defaultProps: Partial<PopupProps> = {\n position: RelativePosition.Bottom,\n showShadow: true,\n showArrow: false,\n isOpen: false,\n offset: 4,\n top: -1,\n left: -1,\n };\n\n public override componentDidMount() {\n if (this.props.isOpen) {\n this._onShow();\n }\n }\n\n private getParentWindow() {\n // istanbul ignore next\n return this.state.parentDocument.defaultView ?? window;\n }\n\n public override componentDidUpdate(\n previousProps: PopupProps,\n prevState: PopupState\n ) {\n if (this.state.position !== prevState.position) {\n this.setState({ animationEnded: false });\n }\n\n if (this.props.target !== previousProps.target) {\n // istanbul ignore next\n {\n const parentDocument = this.props.target?.ownerDocument ?? document;\n if (parentDocument !== this.state.parentDocument) {\n this._unBindWindowEvents();\n this.setState({ parentDocument });\n }\n }\n }\n\n if (this.props.isOpen === previousProps.isOpen) {\n if (this.props.isOpen) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n if (\n Math.abs(this.state.left - point.x) < 3 &&\n Math.abs(this.state.top - point.y) < 3 &&\n this.state.position === position\n )\n return;\n\n this.setState({\n left: point.x,\n top: point.y,\n position,\n });\n }\n return;\n }\n\n if (this.props.isOpen) {\n this._onShow();\n } else {\n this._onClose();\n }\n }\n\n public override componentWillUnmount() {\n this._unBindWindowEvents();\n }\n\n private _bindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.addEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.addEventListener(\"resize\", this._resize);\n activeWindow.addEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.addEventListener(\"scroll\", this._hide);\n activeWindow.addEventListener(\"wheel\", this._handleWheel);\n activeWindow.addEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _unBindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.removeEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.removeEventListener(\"resize\", this._resize);\n activeWindow.removeEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.removeEventListener(\"scroll\", this._hide);\n activeWindow.removeEventListener(\"wheel\", this._handleWheel);\n activeWindow.removeEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _handleWheel = (event: WheelEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onWheel) return this.props.onWheel(event);\n\n const closeOnWheel =\n this.props.closeOnWheel !== undefined ? this.props.closeOnWheel : true;\n if (closeOnWheel) this._hide();\n };\n\n private 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 private _handleOutsideClick = (event: MouseEvent): void => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.isPinned) return;\n\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(event.target as HTMLElement)\n )\n return;\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(event);\n\n if (this.props.target && this.props.target.contains(event.target as Node))\n return;\n\n this._onClose();\n };\n\n private _handleContextMenu = (event: MouseEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onContextMenu) return this.props.onContextMenu(event);\n\n const closeOnContextMenu =\n this.props.closeOnContextMenu !== undefined\n ? this.props.closeOnContextMenu\n : true;\n if (closeOnContextMenu) this._hide();\n };\n\n private _handleKeyboard = (event: KeyboardEvent): void => {\n if (this.props.isPinned) return;\n\n if (event.key === SpecialKey.Escape || event.key === SpecialKey.Enter) {\n const closeOnEnter =\n this.props.closeOnEnter !== undefined ? this.props.closeOnEnter : true;\n if (event.key === SpecialKey.Enter) {\n if (closeOnEnter) this._onClose(true);\n else this.props.onEnter && this.props.onEnter();\n } else {\n this._onClose(false);\n }\n }\n };\n\n private _resize = () => {\n if (this.props.repositionOnResize) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n this.setState({ left: point.x, top: point.y, position });\n } else {\n this._hide(); // legacy behavior\n }\n };\n\n private _hide = () => {\n if (this.props.isPinned) return;\n\n this._onClose();\n };\n\n private _onShow() {\n this._bindWindowEvents();\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n\n this.setState(\n { left: point.x, top: point.y, isOpen: true, position },\n () => {\n if (this.props.onOpen) this.props.onOpen();\n }\n );\n }\n\n private _onClose(enterKey?: boolean) {\n if (!this.state.isOpen) return;\n\n this._unBindWindowEvents();\n\n this.setState({ isOpen: false }, () => {\n if (enterKey && this.props.onEnter) this.props.onEnter();\n if (this.props.onClose) this.props.onClose();\n });\n }\n\n private _isPositionAbsolute(): boolean {\n return this.props.top !== -1 && this.props.left !== -1;\n }\n\n private _getClassNameByPosition(position: RelativePosition): string {\n if (!this._isPositionAbsolute()) {\n switch (position) {\n case RelativePosition.TopLeft:\n return \"core-popup-top-left\";\n case RelativePosition.TopRight:\n return \"core-popup-top-right\";\n case RelativePosition.BottomLeft:\n return \"core-popup-bottom-left\";\n case RelativePosition.BottomRight:\n return \"core-popup-bottom-right\";\n case RelativePosition.Top:\n return \"core-popup-top\";\n case RelativePosition.Left:\n return \"core-popup-left\";\n case RelativePosition.Right:\n return \"core-popup-right\";\n case RelativePosition.Bottom:\n return \"core-popup-bottom\";\n case RelativePosition.LeftTop:\n return \"core-popup-left-top\";\n case RelativePosition.RightTop:\n return \"core-popup-right-top\";\n }\n }\n\n return \"\";\n }\n\n private _getPopupDimensions(): { popupWidth: number; popupHeight: number } {\n let popupWidth = 0;\n let popupHeight = 0;\n // istanbul ignore else\n if (this._popup) {\n const activeWindow = this.getParentWindow();\n const style = activeWindow.getComputedStyle(this._popup);\n const borderLeftWidth = parsePxString(style.borderLeftWidth);\n const borderRightWidth = parsePxString(style.borderRightWidth);\n const borderTopWidth = parsePxString(style.borderTopWidth);\n const borderBottomWidth = parsePxString(style.borderBottomWidth);\n popupWidth = this._popup.clientWidth + borderLeftWidth + borderRightWidth;\n popupHeight =\n this._popup.clientHeight + borderTopWidth + borderBottomWidth;\n }\n\n return { popupWidth, popupHeight };\n }\n\n private _getPosition = (position: RelativePosition) => {\n const activeWindow = this.getParentWindow();\n const { target, offset, top, left } = this.props;\n const offsetArrow = this.props.showArrow ? 6 : 0;\n\n // absolute position\n if (this._isPositionAbsolute()) return { x: left, y: top };\n\n // sanity check\n const point = { x: 0, y: 0 };\n if (!this._popup || !target) return point;\n\n // relative position\n const scrollY = activeWindow.scrollY;\n const scrollX = activeWindow.scrollX;\n\n const targetRect = target.getBoundingClientRect();\n\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n\n switch (position) {\n case RelativePosition.Top:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.TopLeft:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.TopRight:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Bottom:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.BottomLeft:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.BottomRight:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Left:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.LeftTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.Right:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n\n case RelativePosition.RightTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n }\n\n return point;\n };\n\n private _toggleRelativePosition(): RelativePosition {\n const { target, position, offset } = this.props;\n\n if (!this._popup || !target) return position;\n\n // istanbul ignore if\n if (this._isPositionAbsolute()) return position;\n\n let newPosition = position;\n\n interface Rect {\n left: number;\n top: number;\n right: number;\n bottom: number;\n }\n\n const activeWindow = this.getParentWindow();\n\n // Note: Cannot use DOMRect yet since it's experimental and not available in all browsers (Nov. 2018)\n const viewportRect: Rect = {\n left: activeWindow.scrollX,\n top: activeWindow.scrollY,\n right: activeWindow.scrollX + activeWindow.innerWidth,\n bottom: activeWindow.scrollY + activeWindow.innerHeight,\n };\n const targetRect = target.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const containerStyle = activeWindow.getComputedStyle(target);\n const offsetArrow = this.props.showArrow\n ? /* istanbul ignore next */ 10\n : 2;\n\n const bottomMargin = parseMargin(containerStyle.marginBottom);\n if (\n targetRect.bottom + popupHeight + bottomMargin + offsetArrow + offset >\n viewportRect.bottom\n ) {\n if (newPosition === RelativePosition.Bottom)\n newPosition = RelativePosition.Top;\n else if (newPosition === RelativePosition.BottomLeft)\n newPosition = RelativePosition.TopLeft;\n else if (newPosition === RelativePosition.BottomRight)\n newPosition = RelativePosition.TopRight;\n }\n\n const topMargin = parseMargin(containerStyle.marginTop);\n if (\n targetRect.top - popupHeight - topMargin - offsetArrow - offset <\n viewportRect.top\n ) {\n if (newPosition === RelativePosition.Top)\n newPosition = RelativePosition.Bottom;\n else if (newPosition === RelativePosition.TopLeft)\n newPosition = RelativePosition.BottomLeft;\n else if (newPosition === RelativePosition.TopRight)\n newPosition = RelativePosition.BottomRight;\n }\n\n const leftMargin = parseMargin(containerStyle.marginLeft);\n if (\n targetRect.left - popupWidth - leftMargin - offsetArrow - offset <\n viewportRect.left\n ) {\n if (newPosition === RelativePosition.Left)\n newPosition = RelativePosition.Right;\n else if (newPosition === RelativePosition.LeftTop)\n newPosition = RelativePosition.RightTop;\n }\n\n const rightMargin = parseMargin(containerStyle.marginRight);\n if (\n targetRect.right + popupWidth + rightMargin + offsetArrow + offset >\n viewportRect.right\n ) {\n if (newPosition === RelativePosition.Right)\n newPosition = RelativePosition.Left;\n else if (newPosition === RelativePosition.RightTop)\n newPosition = RelativePosition.LeftTop;\n }\n\n return newPosition;\n }\n\n // fit the popup within the extents of the view port\n private _fitPopup = (point: PopupPoint) => {\n const fittedPoint = point;\n\n // istanbul ignore if\n if (!this._popup) {\n return fittedPoint;\n }\n\n // const popupRect = this._popup.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const { innerWidth, innerHeight } = window;\n\n // istanbul ignore if\n if (fittedPoint.y + popupHeight > innerHeight) {\n fittedPoint.y = innerHeight - popupHeight;\n }\n\n // istanbul ignore if\n if (fittedPoint.x + popupWidth > innerWidth) {\n fittedPoint.x = innerWidth - popupWidth;\n }\n\n // istanbul ignore if\n if (fittedPoint.y < 0) {\n fittedPoint.y = 0;\n }\n\n if (fittedPoint.x < 0) {\n fittedPoint.x = 0;\n }\n\n return fittedPoint;\n };\n\n private _handleAnimationEnd = (\n event: React.AnimationEvent<HTMLDivElement>\n ) => {\n if (event.target === this._popup) {\n this.setState({ animationEnded: true });\n }\n };\n\n public override render() {\n const animate =\n this.props.animate !== undefined ? this.props.animate : true;\n const className = classnames(\n \"core-popup\",\n this._getClassNameByPosition(this.state.position),\n this.props.showShadow && \"core-popup-shadow\",\n this.props.showArrow && \"arrow\",\n !animate && \"core-popup-animation-none\",\n this.props.className,\n this.state.animationEnded && \"core-animation-ended\",\n !this.props.isOpen &&\n this.props.keepContentsMounted &&\n \"core-popup-hidden\"\n );\n\n const style: React.CSSProperties = {\n top: this.state.top,\n left: this.state.left,\n ...this.props.style,\n };\n\n const role = this.props.role ? this.props.role : \"dialog\"; // accessibility property\n\n if (!this.props.isOpen && !this.props.keepContentsMounted) {\n return null;\n }\n\n return ReactDOM.createPortal(\n <div\n className={className}\n data-testid=\"core-popup\"\n ref={(element) => {\n this._popup = element;\n }}\n style={style}\n role={role}\n aria-modal={true}\n tabIndex={-1}\n aria-label={this.props.ariaLabel}\n onAnimationEnd={this._handleAnimationEnd}\n >\n <FocusTrap\n active={!!this.props.moveFocus}\n initialFocusElement={this.props.focusTarget}\n returnFocusOnDeactivate={true}\n >\n {this.props.children}\n </FocusTrap>\n </div>,\n // istanbul ignore next\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"iui-root-id\"]'\n ) ?? this.state.parentDocument.body\n );\n }\n}\n\nfunction parsePxString(pxStr: string): number {\n const parsed = parseInt(pxStr, 10);\n return parsed || 0;\n}\n\nfunction parseMargin(value: string) {\n return value ? /* istanbul ignore next */ parseFloat(value) : 0;\n}\n"]}
|
|
@@ -37,8 +37,9 @@ export class TreeNode extends React.Component {
|
|
|
37
37
|
this.props.onClickExpansionToggle();
|
|
38
38
|
};
|
|
39
39
|
this._onClick = (e) => {
|
|
40
|
+
var _a, _b;
|
|
40
41
|
e.stopPropagation();
|
|
41
|
-
this.props.onClick
|
|
42
|
+
(_b = (_a = this.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Node.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAA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,MAAM,EAAE,iBAChB,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC;gBAErD,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CACvB,oBAAC,cAAc,IAAC,IAAI,EAAC,SAAS,EAAC,aAAa,SAAG,CAChD;gBACA,MAAM;gBACN,QAAQ;gBACR,IAAI;gBACJ,IAAI,CAAC,KAAK,CAAC,KAAK,CACb;YACL,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,KAAa;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YAAE,OAAO,SAAS,CAAC;QACjD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;IACjD,CAAC;CA0BF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./Node.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CheckboxProps } from \"@itwin/itwinui-react\";\nimport { Checkbox, ProgressRadial } from \"@itwin/itwinui-react\";\nimport { CheckBoxState } from \"../enums/CheckBoxState\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { ExpansionToggle } from \"./ExpansionToggle\";\n\n/** Props for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderProps = Omit<\n CheckboxProps,\n \"onChange\" | \"onClick\"\n> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/** Type for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderer = (\n props: NodeCheckboxRenderProps\n) => React.ReactNode;\n\n/** Number of pixels the node gets offset per each hierarchy level\n * @internal\n */\nexport const LEVEL_OFFSET = 20;\n\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/** Properties for Tree Node CheckBox\n * @public\n */\nexport interface NodeCheckboxProps {\n /** State of the checkbox */\n state?: CheckBoxState;\n /** Click event callback */\n onClick?: (newState: CheckBoxState) => void;\n /** Indicates whether checkbox is disabled */\n isDisabled?: boolean;\n /** Tooltip to be displayed when mouse is hovered over checkbox */\n tooltip?: string;\n}\n\n/** Properties for the [[TreeNode]] React component\n * @public\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactChild;\n /** Properties for the checkbox.\n * @public */\n checkboxProps?: NodeCheckboxProps;\n isLeaf?: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isFocused?: boolean;\n isSelected?: boolean;\n isHoverDisabled?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onContextMenu?: (e: React.MouseEvent) => void;\n onMouseMove?: (e: React.MouseEvent) => void;\n onMouseDown?: (e: React.MouseEvent) => void;\n onMouseUp?: (e: React.MouseEvent) => void;\n onClickExpansionToggle?: () => void;\n children?: React.ReactNode;\n\n /** Contains render overrides for different pieces of the node component. */\n renderOverrides?: {\n /** Callback to render a checkbox. Only called when checkbox is displayed. */\n renderCheckbox?: NodeCheckboxRenderer;\n };\n [\"data-testid\"]?: string;\n}\n\n/** Presentation React component for a Tree node\n * @public\n */\nexport class TreeNode extends React.Component<TreeNodeProps> {\n constructor(props: TreeNodeProps) {\n super(props);\n }\n\n public override render() {\n const className = classnames(\n \"core-tree-node\",\n this.props.isFocused && \"is-focused\",\n this.props.isSelected && \"is-selected\",\n this.props.isHoverDisabled && \"is-hover-disabled\",\n this.props.className\n );\n let offset = this.props.level * LEVEL_OFFSET;\n if (!this.props.isLoading && this.props.isLeaf)\n offset += EXPANSION_TOGGLE_WIDTH; // Add expansion toggle/loader width if they're not rendered\n\n let checkbox: React.ReactNode;\n if (this.props.checkboxProps) {\n const props: NodeCheckboxRenderProps = {\n label: \"\",\n checked: this.props.checkboxProps.state === CheckBoxState.On,\n indeterminate: this.props.checkboxProps.state === CheckBoxState.Partial,\n disabled: this.props.checkboxProps.isDisabled,\n title: this.props.checkboxProps.tooltip,\n onClick: this._onCheckboxClick,\n onChange: this._onCheckboxChange,\n };\n if (\n this.props.renderOverrides &&\n this.props.renderOverrides.renderCheckbox\n ) {\n checkbox = this.props.renderOverrides.renderCheckbox(props);\n } else {\n checkbox = (\n <Checkbox\n {...props}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n this._onCheckboxChange(e.target.checked)\n }\n data-testid={this.createSubComponentTestId(\"checkbox\")}\n />\n );\n }\n }\n\n const icon = this.props.icon ? (\n <div className=\"core-tree-node-icon\">{this.props.icon}</div>\n ) : undefined;\n\n const toggle = this.props.isLoading ? undefined : this.props.isLeaf ? (\n <div />\n ) : (\n <ExpansionToggle\n className=\"expansion-toggle\"\n data-testid={this.createSubComponentTestId(\"expansion-toggle\")}\n onClick={this._onClickExpansionToggle}\n isExpanded={this.props.isExpanded}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n className={className}\n style={this.props.style}\n data-testid={this.props[\"data-testid\"]}\n onClick={this._onClick}\n onContextMenu={this.props.onContextMenu}\n onMouseDown={this.props.onMouseDown}\n onMouseUp={this.props.onMouseUp}\n onMouseMove={this.props.onMouseMove}\n role=\"treeitem\"\n aria-selected={this.props.isSelected ? \"true\" : \"false\"}\n tabIndex={-1}\n >\n <div\n className=\"contents\"\n style={{ marginLeft: offset }}\n data-testid={this.createSubComponentTestId(\"contents\")}\n >\n {this.props.isLoading && (\n <ProgressRadial size=\"x-small\" indeterminate />\n )}\n {toggle}\n {checkbox}\n {icon}\n {this.props.label}\n </div>\n {this.props.children}\n </div>\n );\n }\n\n private createSubComponentTestId(subId: string): string | undefined {\n if (!this.props[\"data-testid\"]) return undefined;\n return `${this.props[\"data-testid\"]}-${subId}`;\n }\n\n private _onCheckboxChange = (checked: boolean) => {\n if (\n this.props.checkboxProps &&\n this.props.checkboxProps.onClick &&\n !this.props.checkboxProps.isDisabled\n )\n this.props.checkboxProps.onClick(\n checked ? CheckBoxState.On : CheckBoxState.Off\n );\n };\n\n private _onCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _onClickExpansionToggle = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (this.props.onClickExpansionToggle) this.props.onClickExpansionToggle();\n };\n\n private _onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n this.props.onClick?.(e);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Node.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAoBpD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAgDlC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAC1D,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAiGP,sBAAiB,GAAG,CAAC,OAAgB,EAAE,EAAE;YAC/C,IACE,IAAI,CAAC,KAAK,CAAC,aAAa;gBACxB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO;gBAChC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU;gBAEpC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAC9B,OAAO,CAAC,CAAC,CAAC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BAAuB,EACrC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GACjC,CACH,CAAC;QAEF,OAAO;QACL,iEAAiE;QACjE,6BACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACV,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EACtC,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,IAAI,EAAC,UAAU,mBACA,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,EAAE,CAAC,CAAC;YAEZ,6BACE,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,iBAChB,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC;gBAErD,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CACvB,oBAAC,cAAc,IAAC,IAAI,EAAC,SAAS,EAAC,aAAa,SAAG,CAChD;gBACA,MAAM;gBACN,QAAQ;gBACR,IAAI;gBACJ,IAAI,CAAC,KAAK,CAAC,KAAK,CACb;YACL,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,KAAa;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YAAE,OAAO,SAAS,CAAC;QACjD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;IACjD,CAAC;CA0BF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./Node.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CheckboxProps } from \"@itwin/itwinui-react\";\nimport { Checkbox, ProgressRadial } from \"@itwin/itwinui-react\";\nimport { CheckBoxState } from \"../enums/CheckBoxState\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { ExpansionToggle } from \"./ExpansionToggle\";\n\n/** Props for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderProps = Omit<\n CheckboxProps,\n \"onChange\" | \"onClick\"\n> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/** Type for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderer = (\n props: NodeCheckboxRenderProps\n) => React.ReactNode;\n\n/** Number of pixels the node gets offset per each hierarchy level\n * @internal\n */\nexport const LEVEL_OFFSET = 20;\n\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/** Properties for Tree Node CheckBox\n * @public\n */\nexport interface NodeCheckboxProps {\n /** State of the checkbox */\n state?: CheckBoxState;\n /** Click event callback */\n onClick?: (newState: CheckBoxState) => void;\n /** Indicates whether checkbox is disabled */\n isDisabled?: boolean;\n /** Tooltip to be displayed when mouse is hovered over checkbox */\n tooltip?: string;\n}\n\n/** Properties for the [[TreeNode]] React component\n * @public\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactChild;\n /** Properties for the checkbox.\n * @public */\n checkboxProps?: NodeCheckboxProps;\n isLeaf?: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isFocused?: boolean;\n isSelected?: boolean;\n isHoverDisabled?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onContextMenu?: (e: React.MouseEvent) => void;\n onMouseMove?: (e: React.MouseEvent) => void;\n onMouseDown?: (e: React.MouseEvent) => void;\n onMouseUp?: (e: React.MouseEvent) => void;\n onClickExpansionToggle?: () => void;\n children?: React.ReactNode;\n\n /** Contains render overrides for different pieces of the node component. */\n renderOverrides?: {\n /** Callback to render a checkbox. Only called when checkbox is displayed. */\n renderCheckbox?: NodeCheckboxRenderer;\n };\n [\"data-testid\"]?: string;\n}\n\n/** Presentation React component for a Tree node\n * @public\n */\nexport class TreeNode extends React.Component<TreeNodeProps> {\n constructor(props: TreeNodeProps) {\n super(props);\n }\n\n public override render() {\n const className = classnames(\n \"core-tree-node\",\n this.props.isFocused && \"is-focused\",\n this.props.isSelected && \"is-selected\",\n this.props.isHoverDisabled && \"is-hover-disabled\",\n this.props.className\n );\n let offset = this.props.level * LEVEL_OFFSET;\n if (!this.props.isLoading && this.props.isLeaf)\n offset += EXPANSION_TOGGLE_WIDTH; // Add expansion toggle/loader width if they're not rendered\n\n let checkbox: React.ReactNode;\n if (this.props.checkboxProps) {\n const props: NodeCheckboxRenderProps = {\n label: \"\",\n checked: this.props.checkboxProps.state === CheckBoxState.On,\n indeterminate: this.props.checkboxProps.state === CheckBoxState.Partial,\n disabled: this.props.checkboxProps.isDisabled,\n title: this.props.checkboxProps.tooltip,\n onClick: this._onCheckboxClick,\n onChange: this._onCheckboxChange,\n };\n if (\n this.props.renderOverrides &&\n this.props.renderOverrides.renderCheckbox\n ) {\n checkbox = this.props.renderOverrides.renderCheckbox(props);\n } else {\n checkbox = (\n <Checkbox\n {...props}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n this._onCheckboxChange(e.target.checked)\n }\n data-testid={this.createSubComponentTestId(\"checkbox\")}\n />\n );\n }\n }\n\n const icon = this.props.icon ? (\n <div className=\"core-tree-node-icon\">{this.props.icon}</div>\n ) : undefined;\n\n const toggle = this.props.isLoading ? undefined : this.props.isLeaf ? (\n <div />\n ) : (\n <ExpansionToggle\n className=\"expansion-toggle\"\n data-testid={this.createSubComponentTestId(\"expansion-toggle\")}\n onClick={this._onClickExpansionToggle}\n isExpanded={this.props.isExpanded}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n className={className}\n style={this.props.style}\n data-testid={this.props[\"data-testid\"]}\n onClick={this._onClick}\n onContextMenu={this.props.onContextMenu}\n onMouseDown={this.props.onMouseDown}\n onMouseUp={this.props.onMouseUp}\n onMouseMove={this.props.onMouseMove}\n role=\"treeitem\"\n aria-selected={this.props.isSelected ? \"true\" : \"false\"}\n tabIndex={-1}\n >\n <div\n className=\"contents\"\n style={{ marginLeft: offset }}\n data-testid={this.createSubComponentTestId(\"contents\")}\n >\n {this.props.isLoading && (\n <ProgressRadial size=\"x-small\" indeterminate />\n )}\n {toggle}\n {checkbox}\n {icon}\n {this.props.label}\n </div>\n {this.props.children}\n </div>\n );\n }\n\n private createSubComponentTestId(subId: string): string | undefined {\n if (!this.props[\"data-testid\"]) return undefined;\n return `${this.props[\"data-testid\"]}-${subId}`;\n }\n\n private _onCheckboxChange = (checked: boolean) => {\n if (\n this.props.checkboxProps &&\n this.props.checkboxProps.onClick &&\n !this.props.checkboxProps.isDisabled\n )\n this.props.checkboxProps.onClick(\n checked ? CheckBoxState.On : CheckBoxState.Off\n );\n };\n\n private _onCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _onClickExpansionToggle = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (this.props.onClickExpansionToggle) this.props.onClickExpansionToggle();\n };\n\n private _onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n this.props.onClick?.(e);\n };\n}\n"]}
|
|
@@ -33,7 +33,7 @@ function parseSvgFromDataUri(src, element) {
|
|
|
33
33
|
// the esm build of dompurify has a default import but the cjs build does not
|
|
34
34
|
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
35
35
|
// istanbul ignore next
|
|
36
|
-
const sanitizer = DOMPurify
|
|
36
|
+
const sanitizer = DOMPurify !== null && DOMPurify !== void 0 ? DOMPurify : DOMPurifyNS;
|
|
37
37
|
// eslint-disable-next-line deprecation/deprecation
|
|
38
38
|
const sanitizedSvg = sanitizer.sanitize(atob(dataUriParts[1]));
|
|
39
39
|
const parsedSvg = new window.DOMParser().parseFromString(sanitizedSvg, "text/xml");
|