@itwin/itwinui-react 3.7.0 → 3.7.2

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1939](https://github.com/iTwin/iTwinUI/pull/1939): Fixed an issue in `ButtonGroup` where the overflow logic was running even when `overflowButton` prop was not passed.
8
+
9
+ ## 3.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1934](https://github.com/iTwin/iTwinUI/pull/1934): Fixed the types for `Table` column `filter` to allow `"includesSome"`, which is an already-supported filter function. Also improved the types for the `filter` prop to improve TS autocompletion.
14
+ - [#1936](https://github.com/iTwin/iTwinUI/pull/1936): Fixed an issue in `ProgressRadial` where the visually hidden "Loading." text was sometimes incorrectly displayed for a short while in the beginning.
15
+
3
16
  ## 3.7.0
4
17
 
5
18
  ### Minor Changes
@@ -68,7 +68,7 @@ exports.defaultStatusTitles = {
68
68
  exports.Avatar = React.forwardRef((props, ref) => {
69
69
  const { size = 'small', status, abbreviation, image, backgroundColor, title, translatedStatusTitles, className, style, ...rest } = props;
70
70
  const statusTitles = { ...exports.defaultStatusTitles, ...translatedStatusTitles };
71
- return (React.createElement(index_js_1.Box, { as: 'span', className: (0, classnames_1.default)('iui-avatar', { [`iui-${size}`]: size !== 'medium' }, className), "data-iui-status": status, title: title, style: { backgroundColor: getBackground(backgroundColor), ...style }, ref: ref, ...rest },
71
+ return (React.createElement(index_js_1.Box, { as: 'span', className: (0, classnames_1.default)('iui-avatar', className), "data-iui-size": size !== 'medium' ? size : undefined, "data-iui-status": status, title: title, style: { backgroundColor: getBackground(backgroundColor), ...style }, ref: ref, ...rest },
72
72
  !image ? abbreviation?.substring(0, 2) : null,
73
73
  image,
74
74
  status ? React.createElement(VisuallyHidden_js_1.VisuallyHidden, null, statusTitles[status]) : null));
@@ -79,7 +79,7 @@ exports.AvatarGroup = React.forwardRef((props, ref) => {
79
79
  childrenArray.length <= maxIcons + 1 && getAvatarList(maxIcons + 1),
80
80
  childrenArray.length > maxIcons + 1 && (React.createElement(React.Fragment, null,
81
81
  getAvatarList(maxIcons),
82
- React.createElement(index_js_1.Box, { ...countIconProps, className: (0, classnames_1.default)('iui-avatar', { [`iui-${iconSize}`]: iconSize !== 'medium' }, 'iui-avatar-count', countIconProps?.className) }, childrenLength <= maxLength
82
+ React.createElement(index_js_1.Box, { ...countIconProps, className: (0, classnames_1.default)('iui-avatar', 'iui-avatar-count', countIconProps?.className), "data-iui-size": iconSize !== 'medium' ? iconSize : undefined }, childrenLength <= maxLength
83
83
  ? `${childrenLength - maxIcons}`
84
84
  : `${maxLength}+`)))));
85
85
  });
@@ -71,12 +71,15 @@ exports.ButtonGroup = React.forwardRef((props, ref) => {
71
71
  const { children, className, overflowButton, overflowPlacement = 'end', orientation = 'horizontal', ...rest } = props;
72
72
  const items = React.useMemo(() => React.Children.toArray(children).filter(Boolean), [children]);
73
73
  const [overflowRef, visibleCount] = (0, index_js_1.useOverflow)(items, !overflowButton, orientation);
74
- const refs = (0, index_js_1.useMergedRefs)(overflowRef, ref);
74
+ const refs = (0, index_js_1.useMergedRefs)(!!overflowButton ? overflowRef : null, ref);
75
75
  return (React.createElement(react_1.FloatingDelayGroup, { delay: { open: 50, close: 250 } },
76
76
  React.createElement(exports.ButtonGroupContext.Provider, { value: orientation },
77
77
  React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-button-group', {
78
78
  'iui-button-group-overflow-x': !!overflowButton && orientation === 'horizontal',
79
79
  }, className), "data-iui-orientation": orientation === 'vertical' ? orientation : undefined, ref: refs, ...rest }, (() => {
80
+ if (!overflowButton) {
81
+ return children;
82
+ }
80
83
  if (!(visibleCount < items.length)) {
81
84
  return items;
82
85
  }
@@ -46,8 +46,8 @@ const index_js_1 = require("../utils/index.js");
46
46
  */
47
47
  exports.HeaderBreadcrumbs = React.forwardRef((props, forwardedRef) => {
48
48
  const { className, items, ...rest } = props;
49
- return (React.createElement(index_js_1.Box, { as: 'nav', "aria-label": 'breadcrumbs', className: (0, classnames_1.default)('iui-header-breadcrumbs', className), ref: forwardedRef, ...rest },
50
- React.createElement(index_js_1.Box, { as: 'ol', className: 'iui-header-breadcrumbs-list' }, items.reduce((previous, current, index) => [
49
+ return (React.createElement(index_js_1.Box, { as: 'nav', "aria-label": 'breadcrumbs', className: (0, classnames_1.default)('iui-breadcrumbs', 'iui-header-breadcrumbs', className), ref: forwardedRef, ...rest },
50
+ React.createElement(index_js_1.Box, { as: 'ol', className: (0, classnames_1.default)('iui-breadcrumbs-list', 'iui-header-breadcrumbs-list') }, items.reduce((previous, current, index) => [
51
51
  ...previous,
52
52
  current,
53
53
  index !== items.length - 1 && (React.createElement(index_js_1.Box, { as: 'li', className: 'iui-breadcrumbs-separator', key: index },
@@ -46,11 +46,12 @@ const index_js_1 = require("../utils/index.js");
46
46
  */
47
47
  exports.VisuallyHidden = React.forwardRef((props, ref) => {
48
48
  const { as: asProp = 'span', className, unhideOnFocus = true, children: childrenProp, ...rest } = props;
49
+ const isMounted = (0, index_js_1.useIsClient)();
49
50
  // ShadowRoot is not supported on all elements, so we only use it for few common ones.
50
51
  const children = !['div', 'span', 'p'].includes(asProp) ? (childrenProp) : (React.createElement(React.Fragment, null,
51
52
  React.createElement(index_js_1.ShadowRoot, { css: css },
52
53
  React.createElement("slot", null)),
53
- childrenProp));
54
+ isMounted && childrenProp));
54
55
  return (React.createElement(index_js_1.Box, { as: asProp, className: (0, classnames_1.default)('iui-visually-hidden', className), "data-iui-unhide-on-focus": unhideOnFocus ? true : undefined, ref: ref, ...rest }, children));
55
56
  });
56
57
  // ----------------------------------------------------------------------------
@@ -1,4 +1,9 @@
1
1
  import type { ChangeEvent, ComponentType, CSSProperties, DependencyList, EffectCallback, MouseEvent, ReactElement, ReactFragment, ReactNode } from 'react';
2
+ /**
3
+ * This allows custom strings and keeps intellisense for string unions.
4
+ * See https://github.com/Microsoft/TypeScript/issues/29729
5
+ */
6
+ type AnyString = string & {};
2
7
  export type FieldType = 'text' | 'number' | 'date' | string;
3
8
  export type CellRendererProps<D extends Record<string, unknown> = {}> = {
4
9
  /**
@@ -109,10 +114,10 @@ export interface ColumnInterface<D extends Record<string, unknown> = {}> extends
109
114
  Filter?: Renderer<FilterProps<D>> | Renderer<TableFilterProps<D>>;
110
115
  /**
111
116
  * String value or custom function to use for filtering.
112
- * Possible string values: `text`, `exactText`, `exactTextCase`, `includes`, `includesAll`, `exact`, `equals`, `between`.
113
- * More info about these filters: https://github.com/tannerlinsley/react-table/blob/master/src/filterTypes.js
117
+ * Possible string values: `text`, `exactText`, `exactTextCase`, `includes`, `includesAll`, `includesSome`, `exact`, `equals`, `between`.
118
+ * More info about these filters: https://github.com/TanStack/table/blob/v7/src/filterTypes.js
114
119
  */
115
- filter?: FilterType<D> | DefaultFilterTypes | string;
120
+ filter?: FilterType<D> | DefaultFilterTypes | AnyString;
116
121
  /**
117
122
  * Function that should return whole cell element not only the content.
118
123
  * Must be memoized.
@@ -428,7 +433,7 @@ export type UseFiltersColumnOptions<D extends Record<string, unknown>> = Partial
428
433
  Filter: Renderer<FilterProps<D>>;
429
434
  disableFilters: boolean;
430
435
  defaultCanFilter: boolean;
431
- filter: FilterType<D> | DefaultFilterTypes | string;
436
+ filter: FilterType<D> | DefaultFilterTypes | AnyString;
432
437
  }>;
433
438
  export interface UseFiltersInstanceProps<D extends Record<string, unknown>> {
434
439
  preFilteredRows: Array<Row<D>>;
@@ -457,7 +462,7 @@ export type Filters<D extends Record<string, unknown>> = Array<{
457
462
  value: FilterValue;
458
463
  }>;
459
464
  export type FilterTypes<D extends Record<string, unknown>> = Record<string, FilterType<D>>;
460
- export type DefaultFilterTypes = 'text' | 'exactText' | 'exactTextCase' | 'includes' | 'includesAll' | 'exact' | 'equals' | 'between';
465
+ export type DefaultFilterTypes = 'text' | 'exactText' | 'exactTextCase' | 'includes' | 'includesAll' | 'includesSome' | 'exact' | 'equals' | 'between';
461
466
  export interface FilterType<D extends Record<string, unknown>> {
462
467
  (rows: Array<Row<D>>, columnIds: Array<IdType<D>>, filterValue: FilterValue): Array<Row<D>>;
463
468
  autoRemove?: ((filterValue: FilterValue) => boolean) | undefined;
@@ -39,7 +39,7 @@ export const defaultStatusTitles = {
39
39
  export const Avatar = React.forwardRef((props, ref) => {
40
40
  const { size = 'small', status, abbreviation, image, backgroundColor, title, translatedStatusTitles, className, style, ...rest } = props;
41
41
  const statusTitles = { ...defaultStatusTitles, ...translatedStatusTitles };
42
- return (React.createElement(Box, { as: 'span', className: cx('iui-avatar', { [`iui-${size}`]: size !== 'medium' }, className), "data-iui-status": status, title: title, style: { backgroundColor: getBackground(backgroundColor), ...style }, ref: ref, ...rest },
42
+ return (React.createElement(Box, { as: 'span', className: cx('iui-avatar', className), "data-iui-size": size !== 'medium' ? size : undefined, "data-iui-status": status, title: title, style: { backgroundColor: getBackground(backgroundColor), ...style }, ref: ref, ...rest },
43
43
  !image ? abbreviation?.substring(0, 2) : null,
44
44
  image,
45
45
  status ? React.createElement(VisuallyHidden, null, statusTitles[status]) : null));
@@ -50,7 +50,7 @@ export const AvatarGroup = React.forwardRef((props, ref) => {
50
50
  childrenArray.length <= maxIcons + 1 && getAvatarList(maxIcons + 1),
51
51
  childrenArray.length > maxIcons + 1 && (React.createElement(React.Fragment, null,
52
52
  getAvatarList(maxIcons),
53
- React.createElement(Box, { ...countIconProps, className: cx('iui-avatar', { [`iui-${iconSize}`]: iconSize !== 'medium' }, 'iui-avatar-count', countIconProps?.className) }, childrenLength <= maxLength
53
+ React.createElement(Box, { ...countIconProps, className: cx('iui-avatar', 'iui-avatar-count', countIconProps?.className), "data-iui-size": iconSize !== 'medium' ? iconSize : undefined }, childrenLength <= maxLength
54
54
  ? `${childrenLength - maxIcons}`
55
55
  : `${maxLength}+`)))));
56
56
  });
@@ -42,12 +42,15 @@ export const ButtonGroup = React.forwardRef((props, ref) => {
42
42
  const { children, className, overflowButton, overflowPlacement = 'end', orientation = 'horizontal', ...rest } = props;
43
43
  const items = React.useMemo(() => React.Children.toArray(children).filter(Boolean), [children]);
44
44
  const [overflowRef, visibleCount] = useOverflow(items, !overflowButton, orientation);
45
- const refs = useMergedRefs(overflowRef, ref);
45
+ const refs = useMergedRefs(!!overflowButton ? overflowRef : null, ref);
46
46
  return (React.createElement(FloatingDelayGroup, { delay: { open: 50, close: 250 } },
47
47
  React.createElement(ButtonGroupContext.Provider, { value: orientation },
48
48
  React.createElement(Box, { className: cx('iui-button-group', {
49
49
  'iui-button-group-overflow-x': !!overflowButton && orientation === 'horizontal',
50
50
  }, className), "data-iui-orientation": orientation === 'vertical' ? orientation : undefined, ref: refs, ...rest }, (() => {
51
+ if (!overflowButton) {
52
+ return children;
53
+ }
51
54
  if (!(visibleCount < items.length)) {
52
55
  return items;
53
56
  }
@@ -17,8 +17,8 @@ import { SvgChevronRight, Box } from '../utils/index.js';
17
17
  */
18
18
  export const HeaderBreadcrumbs = React.forwardRef((props, forwardedRef) => {
19
19
  const { className, items, ...rest } = props;
20
- return (React.createElement(Box, { as: 'nav', "aria-label": 'breadcrumbs', className: cx('iui-header-breadcrumbs', className), ref: forwardedRef, ...rest },
21
- React.createElement(Box, { as: 'ol', className: 'iui-header-breadcrumbs-list' }, items.reduce((previous, current, index) => [
20
+ return (React.createElement(Box, { as: 'nav', "aria-label": 'breadcrumbs', className: cx('iui-breadcrumbs', 'iui-header-breadcrumbs', className), ref: forwardedRef, ...rest },
21
+ React.createElement(Box, { as: 'ol', className: cx('iui-breadcrumbs-list', 'iui-header-breadcrumbs-list') }, items.reduce((previous, current, index) => [
22
22
  ...previous,
23
23
  current,
24
24
  index !== items.length - 1 && (React.createElement(Box, { as: 'li', className: 'iui-breadcrumbs-separator', key: index },
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
6
  import cx from 'classnames';
7
- import { Box, ShadowRoot } from '../utils/index.js';
7
+ import { Box, ShadowRoot, useIsClient } from '../utils/index.js';
8
8
  /**
9
9
  * Hides content visually but keeps it still accessible to screen readers
10
10
  * and other assistive technologies.
@@ -17,11 +17,12 @@ import { Box, ShadowRoot } from '../utils/index.js';
17
17
  */
18
18
  export const VisuallyHidden = React.forwardRef((props, ref) => {
19
19
  const { as: asProp = 'span', className, unhideOnFocus = true, children: childrenProp, ...rest } = props;
20
+ const isMounted = useIsClient();
20
21
  // ShadowRoot is not supported on all elements, so we only use it for few common ones.
21
22
  const children = !['div', 'span', 'p'].includes(asProp) ? (childrenProp) : (React.createElement(React.Fragment, null,
22
23
  React.createElement(ShadowRoot, { css: css },
23
24
  React.createElement("slot", null)),
24
- childrenProp));
25
+ isMounted && childrenProp));
25
26
  return (React.createElement(Box, { as: asProp, className: cx('iui-visually-hidden', className), "data-iui-unhide-on-focus": unhideOnFocus ? true : undefined, ref: ref, ...rest }, children));
26
27
  });
27
28
  // ----------------------------------------------------------------------------
@@ -1,4 +1,9 @@
1
1
  import type { ChangeEvent, ComponentType, CSSProperties, DependencyList, EffectCallback, MouseEvent, ReactElement, ReactFragment, ReactNode } from 'react';
2
+ /**
3
+ * This allows custom strings and keeps intellisense for string unions.
4
+ * See https://github.com/Microsoft/TypeScript/issues/29729
5
+ */
6
+ type AnyString = string & {};
2
7
  export type FieldType = 'text' | 'number' | 'date' | string;
3
8
  export type CellRendererProps<D extends Record<string, unknown> = {}> = {
4
9
  /**
@@ -109,10 +114,10 @@ export interface ColumnInterface<D extends Record<string, unknown> = {}> extends
109
114
  Filter?: Renderer<FilterProps<D>> | Renderer<TableFilterProps<D>>;
110
115
  /**
111
116
  * String value or custom function to use for filtering.
112
- * Possible string values: `text`, `exactText`, `exactTextCase`, `includes`, `includesAll`, `exact`, `equals`, `between`.
113
- * More info about these filters: https://github.com/tannerlinsley/react-table/blob/master/src/filterTypes.js
117
+ * Possible string values: `text`, `exactText`, `exactTextCase`, `includes`, `includesAll`, `includesSome`, `exact`, `equals`, `between`.
118
+ * More info about these filters: https://github.com/TanStack/table/blob/v7/src/filterTypes.js
114
119
  */
115
- filter?: FilterType<D> | DefaultFilterTypes | string;
120
+ filter?: FilterType<D> | DefaultFilterTypes | AnyString;
116
121
  /**
117
122
  * Function that should return whole cell element not only the content.
118
123
  * Must be memoized.
@@ -428,7 +433,7 @@ export type UseFiltersColumnOptions<D extends Record<string, unknown>> = Partial
428
433
  Filter: Renderer<FilterProps<D>>;
429
434
  disableFilters: boolean;
430
435
  defaultCanFilter: boolean;
431
- filter: FilterType<D> | DefaultFilterTypes | string;
436
+ filter: FilterType<D> | DefaultFilterTypes | AnyString;
432
437
  }>;
433
438
  export interface UseFiltersInstanceProps<D extends Record<string, unknown>> {
434
439
  preFilteredRows: Array<Row<D>>;
@@ -457,7 +462,7 @@ export type Filters<D extends Record<string, unknown>> = Array<{
457
462
  value: FilterValue;
458
463
  }>;
459
464
  export type FilterTypes<D extends Record<string, unknown>> = Record<string, FilterType<D>>;
460
- export type DefaultFilterTypes = 'text' | 'exactText' | 'exactTextCase' | 'includes' | 'includesAll' | 'exact' | 'equals' | 'between';
465
+ export type DefaultFilterTypes = 'text' | 'exactText' | 'exactTextCase' | 'includes' | 'includesAll' | 'includesSome' | 'exact' | 'equals' | 'between';
461
466
  export interface FilterType<D extends Record<string, unknown>> {
462
467
  (rows: Array<Row<D>>, columnIds: Array<IdType<D>>, filterValue: FilterValue): Array<Row<D>>;
463
468
  autoRemove?: ((filterValue: FilterValue) => boolean) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "3.7.0",
3
+ "version": "3.7.2",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/react-table.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import type { ChangeEvent, ComponentType, CSSProperties, DependencyList, EffectCallback, MouseEvent, ReactElement, ReactFragment, ReactNode } from 'react';
2
+ /**
3
+ * This allows custom strings and keeps intellisense for string unions.
4
+ * See https://github.com/Microsoft/TypeScript/issues/29729
5
+ */
6
+ type AnyString = string & {};
2
7
  export type FieldType = 'text' | 'number' | 'date' | string;
3
8
  export type CellRendererProps<D extends Record<string, unknown> = {}> = {
4
9
  /**
@@ -109,10 +114,10 @@ export interface ColumnInterface<D extends Record<string, unknown> = {}> extends
109
114
  Filter?: Renderer<FilterProps<D>> | Renderer<TableFilterProps<D>>;
110
115
  /**
111
116
  * String value or custom function to use for filtering.
112
- * Possible string values: `text`, `exactText`, `exactTextCase`, `includes`, `includesAll`, `exact`, `equals`, `between`.
113
- * More info about these filters: https://github.com/tannerlinsley/react-table/blob/master/src/filterTypes.js
117
+ * Possible string values: `text`, `exactText`, `exactTextCase`, `includes`, `includesAll`, `includesSome`, `exact`, `equals`, `between`.
118
+ * More info about these filters: https://github.com/TanStack/table/blob/v7/src/filterTypes.js
114
119
  */
115
- filter?: FilterType<D> | DefaultFilterTypes | string;
120
+ filter?: FilterType<D> | DefaultFilterTypes | AnyString;
116
121
  /**
117
122
  * Function that should return whole cell element not only the content.
118
123
  * Must be memoized.
@@ -428,7 +433,7 @@ export type UseFiltersColumnOptions<D extends Record<string, unknown>> = Partial
428
433
  Filter: Renderer<FilterProps<D>>;
429
434
  disableFilters: boolean;
430
435
  defaultCanFilter: boolean;
431
- filter: FilterType<D> | DefaultFilterTypes | string;
436
+ filter: FilterType<D> | DefaultFilterTypes | AnyString;
432
437
  }>;
433
438
  export interface UseFiltersInstanceProps<D extends Record<string, unknown>> {
434
439
  preFilteredRows: Array<Row<D>>;
@@ -457,7 +462,7 @@ export type Filters<D extends Record<string, unknown>> = Array<{
457
462
  value: FilterValue;
458
463
  }>;
459
464
  export type FilterTypes<D extends Record<string, unknown>> = Record<string, FilterType<D>>;
460
- export type DefaultFilterTypes = 'text' | 'exactText' | 'exactTextCase' | 'includes' | 'includesAll' | 'exact' | 'equals' | 'between';
465
+ export type DefaultFilterTypes = 'text' | 'exactText' | 'exactTextCase' | 'includes' | 'includesAll' | 'includesSome' | 'exact' | 'equals' | 'between';
461
466
  export interface FilterType<D extends Record<string, unknown>> {
462
467
  (rows: Array<Row<D>>, columnIds: Array<IdType<D>>, filterValue: FilterValue): Array<Row<D>>;
463
468
  autoRemove?: ((filterValue: FilterValue) => boolean) | undefined;