@itwin/itwinui-react 2.0.2 → 2.0.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ### 2.0.4 (2022-12-16)
4
+
5
+ ### Fixes
6
+
7
+ * Use `import type` instead of `import { type }` for supporting older typescript versions ([#996](https://www.github.com/iTwin/iTwinUI-react/issues/996))
8
+
9
+ ### 2.0.3 (2022-12-12)
10
+
11
+ ### Fixes
12
+
13
+ * **ComboBox:** Move max-height to outer element to fix virtual scroll ([#986](https://www.github.com/iTwin/iTwinUI-react/issues/986))
14
+
3
15
  ### [2.0.2](https://www.github.com/iTwin/iTwinUI-react/compare/v2.0.1...v2.0.2) (2022-12-07)
4
16
 
5
17
  ### Fixes
@@ -14,8 +14,8 @@ const Menu_1 = require("../Menu");
14
14
  const Surface_1 = require("../Surface");
15
15
  const utils_1 = require("../utils");
16
16
  const helpers_1 = require("./helpers");
17
+ const isOverflowOverlaySupported = () => { var _a, _b, _c; return (_c = (_b = (_a = (0, utils_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow: overlay'); };
17
18
  const VirtualizedComboBoxMenu = react_1.default.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
18
- var _a, _b, _c;
19
19
  const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = (0, utils_1.useSafeContext)(helpers_1.ComboBoxStateContext);
20
20
  const { menuRef } = (0, utils_1.useSafeContext)(helpers_1.ComboBoxRefsContext);
21
21
  const virtualItemRenderer = react_1.default.useCallback((index) => filteredOptions.length > 0
@@ -37,16 +37,17 @@ const VirtualizedComboBoxMenu = react_1.default.forwardRef(({ children, classNam
37
37
  itemRenderer: virtualItemRenderer,
38
38
  scrollToIndex: focusedVisibleIndex,
39
39
  });
40
- const overflowY = ((_c = (_b = (_a = (0, utils_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow-x: overlay'))
41
- ? { overflowY: 'overlay' }
42
- : { overflowY: 'auto' };
43
- const styles = react_1.default.useMemo(() => ({
40
+ const surfaceStyles = {
44
41
  minWidth,
45
42
  maxWidth: `min(${minWidth * 2}px, 90vw)`,
46
- }), [minWidth]);
47
- return (react_1.default.createElement(Surface_1.Surface, { elevation: 1, style: { ...styles, ...overflowY, ...style }, ...rest },
43
+ // max-height must be on the outermost element for virtual scroll
44
+ maxHeight: 'calc((var(--iui-component-height) - 1px) * 8.5)',
45
+ overflowY: isOverflowOverlaySupported() ? 'overlay' : 'auto',
46
+ ...style,
47
+ };
48
+ return (react_1.default.createElement(Surface_1.Surface, { style: surfaceStyles, ...rest },
48
49
  react_1.default.createElement("div", { ...outerProps },
49
- react_1.default.createElement(Menu_1.Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: (0, utils_1.mergeRefs)(menuRef, innerProps.ref, forwardedRef), className: (0, classnames_1.default)('iui-scroll', className), style: innerProps.style }, visibleChildren))));
50
+ react_1.default.createElement(Menu_1.Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: (0, utils_1.mergeRefs)(menuRef, innerProps.ref, forwardedRef), className: className, style: innerProps.style }, visibleChildren))));
50
51
  });
51
52
  exports.ComboBoxMenu = react_1.default.forwardRef((props, forwardedRef) => {
52
53
  const { className, style, ...rest } = props;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type CommonProps } from '../props';
2
+ import type { CommonProps } from '../props';
3
3
  export declare const StatusIconMap: {
4
4
  negative: (args?: CommonProps) => JSX.Element;
5
5
  positive: (args?: CommonProps) => JSX.Element;
@@ -8,8 +8,8 @@ import { Menu } from '../Menu';
8
8
  import { Surface } from '../Surface';
9
9
  import { useSafeContext, useMergedRefs, useVirtualization, mergeRefs, getWindow, } from '../utils';
10
10
  import { ComboBoxStateContext, ComboBoxRefsContext } from './helpers';
11
+ const isOverflowOverlaySupported = () => { var _a, _b, _c; return (_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow: overlay'); };
11
12
  const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
12
- var _a, _b, _c;
13
13
  const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = useSafeContext(ComboBoxStateContext);
14
14
  const { menuRef } = useSafeContext(ComboBoxRefsContext);
15
15
  const virtualItemRenderer = React.useCallback((index) => filteredOptions.length > 0
@@ -31,16 +31,17 @@ const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style,
31
31
  itemRenderer: virtualItemRenderer,
32
32
  scrollToIndex: focusedVisibleIndex,
33
33
  });
34
- const overflowY = ((_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow-x: overlay'))
35
- ? { overflowY: 'overlay' }
36
- : { overflowY: 'auto' };
37
- const styles = React.useMemo(() => ({
34
+ const surfaceStyles = {
38
35
  minWidth,
39
36
  maxWidth: `min(${minWidth * 2}px, 90vw)`,
40
- }), [minWidth]);
41
- return (React.createElement(Surface, { elevation: 1, style: { ...styles, ...overflowY, ...style }, ...rest },
37
+ // max-height must be on the outermost element for virtual scroll
38
+ maxHeight: 'calc((var(--iui-component-height) - 1px) * 8.5)',
39
+ overflowY: isOverflowOverlaySupported() ? 'overlay' : 'auto',
40
+ ...style,
41
+ };
42
+ return (React.createElement(Surface, { style: surfaceStyles, ...rest },
42
43
  React.createElement("div", { ...outerProps },
43
- React.createElement(Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: mergeRefs(menuRef, innerProps.ref, forwardedRef), className: cx('iui-scroll', className), style: innerProps.style }, visibleChildren))));
44
+ React.createElement(Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: mergeRefs(menuRef, innerProps.ref, forwardedRef), className: className, style: innerProps.style }, visibleChildren))));
44
45
  });
45
46
  export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
46
47
  const { className, style, ...rest } = props;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type CommonProps } from '../props';
2
+ import type { CommonProps } from '../props';
3
3
  export declare const StatusIconMap: {
4
4
  negative: (args?: CommonProps) => JSX.Element;
5
5
  positive: (args?: CommonProps) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "main": "cjs/index.js",