@itwin/itwinui-react 1.25.0 → 1.26.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/cjs/core/Buttons/Button/Button.d.ts +1 -1
  3. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  4. package/cjs/core/DatePicker/DatePicker.d.ts +1 -1
  5. package/cjs/core/InformationPanel/InformationPanel.d.ts +4 -1
  6. package/cjs/core/InformationPanel/InformationPanel.js +4 -1
  7. package/cjs/core/InformationPanel/InformationPanelContent.d.ts +42 -0
  8. package/cjs/core/InformationPanel/InformationPanelContent.js +66 -0
  9. package/cjs/core/InformationPanel/index.d.ts +2 -0
  10. package/cjs/core/InformationPanel/index.js +3 -1
  11. package/cjs/core/LabeledInput/LabeledInput.d.ts +2 -2
  12. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  13. package/cjs/core/Table/TablePaginator.d.ts +1 -1
  14. package/cjs/core/Table/TablePaginator.js +9 -4
  15. package/cjs/core/Tabs/Tabs.js +1 -6
  16. package/cjs/core/index.d.ts +4 -4
  17. package/cjs/core/index.js +4 -2
  18. package/cjs/core/utils/components/MiddleTextTruncation.d.ts +21 -0
  19. package/cjs/core/utils/components/MiddleTextTruncation.js +56 -0
  20. package/cjs/core/utils/components/index.d.ts +1 -0
  21. package/cjs/core/utils/components/index.js +1 -0
  22. package/cjs/core/utils/hooks/index.d.ts +1 -0
  23. package/cjs/core/utils/hooks/index.js +1 -0
  24. package/cjs/core/utils/hooks/useContainerWidth.d.ts +17 -0
  25. package/cjs/core/utils/hooks/useContainerWidth.js +50 -0
  26. package/cjs/core/utils/hooks/useOverflow.d.ts +1 -1
  27. package/esm/core/Buttons/Button/Button.d.ts +1 -1
  28. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  29. package/esm/core/DatePicker/DatePicker.d.ts +1 -1
  30. package/esm/core/InformationPanel/InformationPanel.d.ts +4 -1
  31. package/esm/core/InformationPanel/InformationPanel.js +4 -1
  32. package/esm/core/InformationPanel/InformationPanelContent.d.ts +42 -0
  33. package/esm/core/InformationPanel/InformationPanelContent.js +59 -0
  34. package/esm/core/InformationPanel/index.d.ts +2 -0
  35. package/esm/core/InformationPanel/index.js +1 -0
  36. package/esm/core/LabeledInput/LabeledInput.d.ts +2 -2
  37. package/esm/core/Menu/MenuItem.d.ts +1 -1
  38. package/esm/core/Table/TablePaginator.d.ts +1 -1
  39. package/esm/core/Table/TablePaginator.js +9 -4
  40. package/esm/core/Tabs/Tabs.js +2 -7
  41. package/esm/core/index.d.ts +4 -4
  42. package/esm/core/index.js +2 -2
  43. package/esm/core/utils/components/MiddleTextTruncation.d.ts +21 -0
  44. package/esm/core/utils/components/MiddleTextTruncation.js +49 -0
  45. package/esm/core/utils/components/index.d.ts +1 -0
  46. package/esm/core/utils/components/index.js +1 -0
  47. package/esm/core/utils/hooks/index.d.ts +1 -0
  48. package/esm/core/utils/hooks/index.js +1 -0
  49. package/esm/core/utils/hooks/useContainerWidth.d.ts +17 -0
  50. package/esm/core/utils/hooks/useContainerWidth.js +43 -0
  51. package/esm/core/utils/hooks/useOverflow.d.ts +1 -1
  52. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.26.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.25.0...v1.26.0) (2021-11-30)
4
+
5
+ ### What's new
6
+
7
+ * **InformationPanel:** Add `InformationPanelContent` for inner rows ([#433](https://www.github.com/iTwin/iTwinUI-react/issues/433)) ([a706bcb](https://www.github.com/iTwin/iTwinUI-react/commit/a706bcb04f9af512131d9ed08fef1529314d2bb1))
8
+ * **MiddleTextTruncation:** Utility to truncate text with ellipsis in the middle ([#330](https://www.github.com/iTwin/iTwinUI-react/issues/330)) ([371b56f](https://www.github.com/iTwin/iTwinUI-react/commit/371b56fa9150fdd110c92d05b3944f376d37441c))
9
+
10
+ ### Fixes
11
+
12
+ * **DatePicker:** Make date arg required in `onChange` ([#437](https://www.github.com/iTwin/iTwinUI-react/issues/437)) ([ee79248](https://www.github.com/iTwin/iTwinUI-react/commit/ee792488a10e43a9b0f8ea6d77c30ef1897eb86c))
13
+ * **Table:** Don't show paginator when there is only one page ([#441](https://www.github.com/iTwin/iTwinUI-react/issues/441)) ([e40cbc8](https://www.github.com/iTwin/iTwinUI-react/commit/e40cbc81929da14ea2754e5d847c0efe8af70203))
14
+
3
15
  ## [1.25.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.24.0...v1.25.0) (2021-11-16)
4
16
 
5
17
  ### What's new
@@ -43,7 +43,7 @@ export declare const Button: React.ForwardRefExoticComponent<{
43
43
  * Use 'borderless' to hide outline.
44
44
  * @default 'default'
45
45
  */
46
- styleType?: "cta" | "high-visibility" | "default" | "borderless" | undefined;
46
+ styleType?: "default" | "cta" | "high-visibility" | "borderless" | undefined;
47
47
  /**
48
48
  * Icon shown before the main button content.
49
49
  */
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
17
17
  * <ColorSwatch color='#23450b' onClick={onClick}/>
18
18
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
19
19
  */
20
- export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "isActive" | "key"> & React.RefAttributes<HTMLDivElement>>;
20
+ export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "isActive" | "key"> & React.RefAttributes<HTMLDivElement>>;
21
21
  export default ColorSwatch;
@@ -18,7 +18,7 @@ export declare type DatePickerProps = {
18
18
  /**
19
19
  * Callback when date is changed.
20
20
  */
21
- onChange?: (date?: Date) => void;
21
+ onChange?: (date: Date) => void;
22
22
  /**
23
23
  * Pass localized week days (start from sunday) and months.
24
24
  * Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
@@ -35,7 +35,10 @@ export declare type InformationPanelProps = {
35
35
  * <Text variant='subheading'>InfoPanel heading</Text>
36
36
  * </InformationPanelHeader>
37
37
  * <InformationPanelBody>
38
- * <span>Info panel content</span>
38
+ * <Text>Metadata</Text>
39
+ * <InformationPanelContent ... />
40
+ * <Text>Attributes</Text>
41
+ * <InformationPanelContent ... />
39
42
  * </InformationPanelBody>
40
43
  * </InformationPanel>
41
44
  * </InformationPanelWrapper>
@@ -47,7 +47,10 @@ require("@itwin/itwinui-css/css/information-panel.css");
47
47
  * <Text variant='subheading'>InfoPanel heading</Text>
48
48
  * </InformationPanelHeader>
49
49
  * <InformationPanelBody>
50
- * <span>Info panel content</span>
50
+ * <Text>Metadata</Text>
51
+ * <InformationPanelContent ... />
52
+ * <Text>Attributes</Text>
53
+ * <InformationPanelContent ... />
51
54
  * </InformationPanelBody>
52
55
  * </InformationPanel>
53
56
  * </InformationPanelWrapper>
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { CommonProps } from '../utils';
3
+ import '@itwin/itwinui-css/css/information-panel.css';
4
+ export declare type InformationPanelContentProps = {
5
+ /**
6
+ * If set to 'inline', the label/input pairs will be shown on the same line.
7
+ * The component handles the spacing and alignment automatically.
8
+ *
9
+ * @default 'default'
10
+ */
11
+ displayStyle?: 'default' | 'inline';
12
+ /**
13
+ * Content of the component.
14
+ * Should ideally be pairs of `Label` and input components.
15
+ */
16
+ children: React.ReactNode;
17
+ } & Omit<CommonProps, 'title'>;
18
+ /**
19
+ * The `InformationPanelContent` component should be used inside `InformationPanelBody`
20
+ * to style rows of key/value pairs, where the key is ideally represented by a `Label` component
21
+ * and the value can be any input element (including readonly inputs for non-modifiable fields).
22
+ *
23
+ * By default, the pairs are displayed of label and input are displayed in separate lines,
24
+ * but displayStyle can be set to 'inline' to show them in the same line with correct alignment.
25
+ *
26
+ * You can use multiple `InformationPanelContent` instances inside one `InformationPanelBody`; this is
27
+ * useful when you want to show other content, e.g. separate headings for different sections of key/value pairs.
28
+ *
29
+ * @example
30
+ * <InformationPanelContent displayStyle='inline'>
31
+ * <Label htmlFor='name-input'>File name</Label>
32
+ * <Input id='name-input' value='Alpha.mp3' />
33
+ *
34
+ * <Label htmlFor='year-input'>Year</Label>
35
+ * <Input id='year-input' value='2021' />
36
+ *
37
+ * <Label htmlFor='path-input'>Path</Label>
38
+ * <Input id='path-input' value='/Shared/Music/' />
39
+ * </InformationPanelContent>
40
+ */
41
+ export declare const InformationPanelContent: (props: InformationPanelContentProps) => JSX.Element;
42
+ export default InformationPanelContent;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.InformationPanelContent = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ var classnames_1 = __importDefault(require("classnames"));
34
+ var react_1 = __importDefault(require("react"));
35
+ var utils_1 = require("../utils");
36
+ require("@itwin/itwinui-css/css/information-panel.css");
37
+ /**
38
+ * The `InformationPanelContent` component should be used inside `InformationPanelBody`
39
+ * to style rows of key/value pairs, where the key is ideally represented by a `Label` component
40
+ * and the value can be any input element (including readonly inputs for non-modifiable fields).
41
+ *
42
+ * By default, the pairs are displayed of label and input are displayed in separate lines,
43
+ * but displayStyle can be set to 'inline' to show them in the same line with correct alignment.
44
+ *
45
+ * You can use multiple `InformationPanelContent` instances inside one `InformationPanelBody`; this is
46
+ * useful when you want to show other content, e.g. separate headings for different sections of key/value pairs.
47
+ *
48
+ * @example
49
+ * <InformationPanelContent displayStyle='inline'>
50
+ * <Label htmlFor='name-input'>File name</Label>
51
+ * <Input id='name-input' value='Alpha.mp3' />
52
+ *
53
+ * <Label htmlFor='year-input'>Year</Label>
54
+ * <Input id='year-input' value='2021' />
55
+ *
56
+ * <Label htmlFor='path-input'>Path</Label>
57
+ * <Input id='path-input' value='/Shared/Music/' />
58
+ * </InformationPanelContent>
59
+ */
60
+ var InformationPanelContent = function (props) {
61
+ var className = props.className, _a = props.displayStyle, displayStyle = _a === void 0 ? 'default' : _a, children = props.children, rest = __rest(props, ["className", "displayStyle", "children"]);
62
+ (0, utils_1.useTheme)();
63
+ return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-information-body-content', { 'iui-inline': displayStyle === 'inline' }, className) }, rest), children));
64
+ };
65
+ exports.InformationPanelContent = InformationPanelContent;
66
+ exports.default = exports.InformationPanelContent;
@@ -8,3 +8,5 @@ export { InformationPanelHeader } from './InformationPanelHeader';
8
8
  export type { InformationPanelHeaderProps } from './InformationPanelHeader';
9
9
  export { InformationPanelBody } from './InformationPanelBody';
10
10
  export type { InformationPanelBodyProps } from './InformationPanelBody';
11
+ export { InformationPanelContent } from './InformationPanelContent';
12
+ export type { InformationPanelContentProps } from './InformationPanelContent';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = void 0;
3
+ exports.InformationPanelContent = exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = void 0;
4
4
  /*---------------------------------------------------------------------------------------------
5
5
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
6
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -14,3 +14,5 @@ var InformationPanelHeader_1 = require("./InformationPanelHeader");
14
14
  Object.defineProperty(exports, "InformationPanelHeader", { enumerable: true, get: function () { return InformationPanelHeader_1.InformationPanelHeader; } });
15
15
  var InformationPanelBody_1 = require("./InformationPanelBody");
16
16
  Object.defineProperty(exports, "InformationPanelBody", { enumerable: true, get: function () { return InformationPanelBody_1.InformationPanelBody; } });
17
+ var InformationPanelContent_1 = require("./InformationPanelContent");
18
+ Object.defineProperty(exports, "InformationPanelContent", { enumerable: true, get: function () { return InformationPanelContent_1.InformationPanelContent; } });
@@ -84,7 +84,7 @@ export declare const LabeledInput: React.ForwardRefExoticComponent<{
84
84
  * - 'inline' - appears in the same line as input.
85
85
  * @default 'default'
86
86
  */
87
- displayStyle?: "default" | "inline" | undefined;
87
+ displayStyle?: "inline" | "default" | undefined;
88
88
  /**
89
89
  * Set display style of icon.
90
90
  * Supported values:
@@ -93,7 +93,7 @@ export declare const LabeledInput: React.ForwardRefExoticComponent<{
93
93
  *
94
94
  * Defaults to 'block' if `displayStyle` is `default`, else 'inline'.
95
95
  */
96
- iconDisplayStyle?: "inline" | "block" | undefined;
96
+ iconDisplayStyle?: "block" | "inline" | undefined;
97
97
  } & {
98
98
  setFocus?: boolean | undefined;
99
99
  size?: "small" | "large" | undefined;
@@ -77,7 +77,7 @@ export declare const MenuItem: React.ForwardRefExoticComponent<{
77
77
  *
78
78
  * Defaults to 'large' if `sublabel` provided, otherwise 'default'.
79
79
  */
80
- size?: "large" | "default" | undefined;
80
+ size?: "default" | "large" | undefined;
81
81
  /**
82
82
  * Sub label shown below the main content of the item.
83
83
  */
@@ -67,5 +67,5 @@ export declare type TablePaginatorProps = {
67
67
  * paginatorRenderer={(props) => <TablePaginator {...props} />}
68
68
  * />
69
69
  */
70
- export declare const TablePaginator: (props: TablePaginatorProps) => JSX.Element;
70
+ export declare const TablePaginator: (props: TablePaginatorProps) => JSX.Element | null;
71
71
  export default TablePaginator;
@@ -144,12 +144,17 @@ var TablePaginator = function (props) {
144
144
  endPage = totalPagesCount;
145
145
  }
146
146
  var hasNoRows = totalPagesCount === 0;
147
+ var showPagesList = totalPagesCount > 1 || isLoading;
148
+ var showPageSizeList = pageSizeList && onPageSizeChange && !!totalRowsCount;
147
149
  var ellipsis = (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-ellipsis', { 'iui-small': size === 'small' }) }, "\u2026"));
148
150
  var noRowsContent = (react_1.default.createElement(react_1.default.Fragment, null, isLoading ? (react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true, size: 'small' })) : (react_1.default.createElement(Buttons_1.Button, { styleType: 'borderless', disabled: true, size: buttonSize }, "1"))));
151
+ if (!showPagesList && !showPageSizeList) {
152
+ return null;
153
+ }
149
154
  return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-paginator', className) }, rest),
150
155
  react_1.default.createElement("div", { className: 'iui-left' }),
151
- react_1.default.createElement("div", { className: 'iui-center', ref: overflowRef },
152
- react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === 0 || hasNoRows, onClick: function () { return onPageChange(currentPage - 1); }, size: buttonSize, "aria-label": localization.previousPage },
156
+ showPagesList && (react_1.default.createElement("div", { className: 'iui-center', ref: overflowRef },
157
+ react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === 0, onClick: function () { return onPageChange(currentPage - 1); }, size: buttonSize, "aria-label": localization.previousPage },
153
158
  react_1.default.createElement(ChevronLeft_1.default, null)),
154
159
  react_1.default.createElement(ButtonGroup_1.ButtonGroup, { onKeyDown: onKeyDown, ref: pageListRef }, (function () {
155
160
  if (hasNoRows) {
@@ -171,8 +176,8 @@ var TablePaginator = function (props) {
171
176
  react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true, size: 'small' })))));
172
177
  })()),
173
178
  react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === totalPagesCount - 1 || hasNoRows, onClick: function () { return onPageChange(currentPage + 1); }, size: buttonSize, "aria-label": localization.nextPage },
174
- react_1.default.createElement(ChevronRight_1.default, null))),
175
- react_1.default.createElement("div", { className: 'iui-right' }, pageSizeList && onPageSizeChange && !!totalRowsCount && (react_1.default.createElement(Buttons_1.DropdownButton, { styleType: 'borderless', size: buttonSize, menuItems: function (close) {
179
+ react_1.default.createElement(ChevronRight_1.default, null)))),
180
+ react_1.default.createElement("div", { className: 'iui-right' }, showPageSizeList && (react_1.default.createElement(Buttons_1.DropdownButton, { styleType: 'borderless', size: buttonSize, menuItems: function (close) {
176
181
  return pageSizeList.map(function (size) { return (react_1.default.createElement(Menu_1.MenuItem, { key: size, isSelected: size === pageSize, onClick: function () {
177
182
  close();
178
183
  onPageSizeChange(size);
@@ -64,12 +64,7 @@ var Tabs = function (props) {
64
64
  var labels = props.labels, activeIndex = props.activeIndex, onTabSelected = props.onTabSelected, _d = props.focusActivationMode, focusActivationMode = _d === void 0 ? 'auto' : _d, _e = props.type, type = _e === void 0 ? 'default' : _e, _f = props.color, color = _f === void 0 ? 'blue' : _f, _g = props.orientation, orientation = _g === void 0 ? 'horizontal' : _g, tabsClassName = props.tabsClassName, contentClassName = props.contentClassName, children = props.children, rest = __rest(props, ["labels", "activeIndex", "onTabSelected", "focusActivationMode", "type", "color", "orientation", "tabsClassName", "contentClassName", "children"]);
65
65
  (0, utils_1.useTheme)();
66
66
  var tablistRef = react_1.default.useRef(null);
67
- var _h = react_1.default.useState(function () { var _a; return (_a = tablistRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width; }), tabsWidth = _h[0], setTabsWidth = _h[1];
68
- var updateTabsWidth = react_1.default.useCallback(function (_a) {
69
- var width = _a.width;
70
- return setTabsWidth(width);
71
- }, []);
72
- var tablistSizeRef = (0, utils_1.useResizeObserver)(updateTabsWidth)[0];
67
+ var _h = (0, utils_1.useContainerWidth)(type !== 'default'), tablistSizeRef = _h[0], tabsWidth = _h[1];
73
68
  var refs = (0, utils_1.useMergedRefs)(tablistRef, tablistSizeRef);
74
69
  var _j = react_1.default.useState(function () {
75
70
  return activeIndex != null
@@ -32,8 +32,8 @@ export { Header, HeaderBreadcrumbs, HeaderButton, HeaderLogo } from './Header';
32
32
  export type { HeaderProps, HeaderBreadcrumbsProps, HeaderButtonProps, HeaderLogoProps, } from './Header';
33
33
  export { VerticalTabs, Tab, HorizontalTabs, HorizontalTab } from './Tabs';
34
34
  export type { VerticalTabsProps, TabProps, HorizontalTabsProps, HorizontalTabProps, } from './Tabs';
35
- export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, } from './InformationPanel';
36
- export type { InformationPanelProps, InformationPanelWrapperProps, InformationPanelHeaderProps, InformationPanelBodyProps, } from './InformationPanel';
35
+ export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, InformationPanelContent, } from './InformationPanel';
36
+ export type { InformationPanelProps, InformationPanelWrapperProps, InformationPanelHeaderProps, InformationPanelBodyProps, InformationPanelContentProps, } from './InformationPanel';
37
37
  export { Input } from './Input';
38
38
  export type { InputProps } from './Input';
39
39
  export { Label } from './Label';
@@ -88,5 +88,5 @@ export { UserIconGroup } from './UserIconGroup';
88
88
  export type { UserIconGroupProps } from './UserIconGroup';
89
89
  export { Wizard } from './Wizard';
90
90
  export type { WizardProps, StepProperties, WizardType, WizardLocalization, } from './Wizard';
91
- export { getUserColor, useTheme, ColorValue } from './utils';
92
- export type { ThemeType } from './utils';
91
+ export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, } from './utils';
92
+ export type { ThemeType, MiddleTextTruncationProps } from './utils';
package/cjs/core/index.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ProgressLinear = exports.ModalButtonBar = exports.Modal = exports.MenuExtraContent = exports.MenuDivider = exports.MenuItem = exports.Menu = exports.LabeledTextarea = exports.LabeledSelect = exports.InputGroup = exports.LabeledInput = exports.Label = exports.Input = exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = exports.HorizontalTab = exports.HorizontalTabs = exports.Tab = exports.VerticalTabs = exports.HeaderLogo = exports.HeaderButton = exports.HeaderBreadcrumbs = exports.Header = exports.Footer = exports.FileUploadTemplate = exports.FileUpload = exports.Fieldset = exports.ExpandableBlock = exports.ErrorPage = exports.DropdownMenu = exports.generateLocalizedStrings = exports.DatePicker = exports.ComboBox = exports.ColorPalette = exports.ColorInputPanel = exports.ColorBuilder = exports.ColorSwatch = exports.ColorPicker = exports.Checkbox = exports.ButtonGroup = exports.SplitButton = exports.IdeasButton = exports.IconButton = exports.DropdownButton = exports.Button = exports.Breadcrumbs = exports.Badge = exports.Alert = void 0;
7
- exports.ColorValue = exports.useTheme = exports.getUserColor = exports.Wizard = exports.UserIconGroup = exports.UserIcon = exports.Text = exports.KbdKeys = exports.Kbd = exports.Code = exports.Blockquote = exports.Title = exports.Subheading = exports.Small = exports.Leading = exports.Headline = exports.Body = exports.Tooltip = exports.ToggleSwitch = exports.ThemeProvider = exports.toaster = exports.TimePicker = exports.Tile = exports.Textarea = exports.TagContainer = exports.Tag = exports.TablePaginator = exports.EditableCell = exports.DefaultCell = exports.FilterButtonBar = exports.tableFilters = exports.Table = exports.Slider = exports.SidenavSubmenuHeader = exports.SidenavSubmenu = exports.SidenavButton = exports.SideNavigation = exports.Select = exports.RadioTileGroup = exports.RadioTile = exports.Radio = exports.ProgressRadial = void 0;
6
+ exports.ModalButtonBar = exports.Modal = exports.MenuExtraContent = exports.MenuDivider = exports.MenuItem = exports.Menu = exports.LabeledTextarea = exports.LabeledSelect = exports.InputGroup = exports.LabeledInput = exports.Label = exports.Input = exports.InformationPanelContent = exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = exports.HorizontalTab = exports.HorizontalTabs = exports.Tab = exports.VerticalTabs = exports.HeaderLogo = exports.HeaderButton = exports.HeaderBreadcrumbs = exports.Header = exports.Footer = exports.FileUploadTemplate = exports.FileUpload = exports.Fieldset = exports.ExpandableBlock = exports.ErrorPage = exports.DropdownMenu = exports.generateLocalizedStrings = exports.DatePicker = exports.ComboBox = exports.ColorPalette = exports.ColorInputPanel = exports.ColorBuilder = exports.ColorSwatch = exports.ColorPicker = exports.Checkbox = exports.ButtonGroup = exports.SplitButton = exports.IdeasButton = exports.IconButton = exports.DropdownButton = exports.Button = exports.Breadcrumbs = exports.Badge = exports.Alert = void 0;
7
+ exports.MiddleTextTruncation = exports.ColorValue = exports.useTheme = exports.getUserColor = exports.Wizard = exports.UserIconGroup = exports.UserIcon = exports.Text = exports.KbdKeys = exports.Kbd = exports.Code = exports.Blockquote = exports.Title = exports.Subheading = exports.Small = exports.Leading = exports.Headline = exports.Body = exports.Tooltip = exports.ToggleSwitch = exports.ThemeProvider = exports.toaster = exports.TimePicker = exports.Tile = exports.Textarea = exports.TagContainer = exports.Tag = exports.TablePaginator = exports.EditableCell = exports.DefaultCell = exports.FilterButtonBar = exports.tableFilters = exports.Table = exports.Slider = exports.SidenavSubmenuHeader = exports.SidenavSubmenu = exports.SidenavButton = exports.SideNavigation = exports.Select = exports.RadioTileGroup = exports.RadioTile = exports.Radio = exports.ProgressRadial = exports.ProgressLinear = void 0;
8
8
  /*---------------------------------------------------------------------------------------------
9
9
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
10
10
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -64,6 +64,7 @@ Object.defineProperty(exports, "InformationPanel", { enumerable: true, get: func
64
64
  Object.defineProperty(exports, "InformationPanelWrapper", { enumerable: true, get: function () { return InformationPanel_1.InformationPanelWrapper; } });
65
65
  Object.defineProperty(exports, "InformationPanelHeader", { enumerable: true, get: function () { return InformationPanel_1.InformationPanelHeader; } });
66
66
  Object.defineProperty(exports, "InformationPanelBody", { enumerable: true, get: function () { return InformationPanel_1.InformationPanelBody; } });
67
+ Object.defineProperty(exports, "InformationPanelContent", { enumerable: true, get: function () { return InformationPanel_1.InformationPanelContent; } });
67
68
  var Input_1 = require("./Input");
68
69
  Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return Input_1.Input; } });
69
70
  var Label_1 = require("./Label");
@@ -147,3 +148,4 @@ var utils_1 = require("./utils");
147
148
  Object.defineProperty(exports, "getUserColor", { enumerable: true, get: function () { return utils_1.getUserColor; } });
148
149
  Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return utils_1.useTheme; } });
149
150
  Object.defineProperty(exports, "ColorValue", { enumerable: true, get: function () { return utils_1.ColorValue; } });
151
+ Object.defineProperty(exports, "MiddleTextTruncation", { enumerable: true, get: function () { return utils_1.MiddleTextTruncation; } });
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from '../props';
3
+ export declare type MiddleTextTruncationProps = {
4
+ /**
5
+ * Text to truncate.
6
+ */
7
+ text: string;
8
+ /**
9
+ * Number of characters to leave at the end.
10
+ * @default 6
11
+ */
12
+ endCharsCount?: number;
13
+ } & CommonProps;
14
+ /**
15
+ * Truncates text with the ellipsis in the middle,
16
+ * leaving defined number of chars at the end.
17
+ * @example
18
+ * <MiddleTextTruncation text='ThisIsMyVeryLongFileName.dgn' />
19
+ */
20
+ export declare const MiddleTextTruncation: (props: MiddleTextTruncationProps) => JSX.Element;
21
+ export default MiddleTextTruncation;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.MiddleTextTruncation = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ var react_1 = __importDefault(require("react"));
34
+ var useOverflow_1 = require("../hooks/useOverflow");
35
+ var ELLIPSIS_CHAR = '…';
36
+ /**
37
+ * Truncates text with the ellipsis in the middle,
38
+ * leaving defined number of chars at the end.
39
+ * @example
40
+ * <MiddleTextTruncation text='ThisIsMyVeryLongFileName.dgn' />
41
+ */
42
+ var MiddleTextTruncation = function (props) {
43
+ var text = props.text, _a = props.endCharsCount, endCharsCount = _a === void 0 ? 6 : _a, style = props.style, rest = __rest(props, ["text", "endCharsCount", "style"]);
44
+ var _b = (0, useOverflow_1.useOverflow)(text), ref = _b[0], visibleCount = _b[1];
45
+ var truncatedText = react_1.default.useMemo(function () {
46
+ if (visibleCount < text.length) {
47
+ return "" + text.substr(0, visibleCount - endCharsCount - ELLIPSIS_CHAR.length) + ELLIPSIS_CHAR + text.substr(text.length - endCharsCount);
48
+ }
49
+ else {
50
+ return text;
51
+ }
52
+ }, [endCharsCount, text, visibleCount]);
53
+ return (react_1.default.createElement("span", __assign({ style: __assign({ display: 'flex', minWidth: 0, whiteSpace: 'nowrap' }, style), ref: ref }, rest), truncatedText));
54
+ };
55
+ exports.MiddleTextTruncation = MiddleTextTruncation;
56
+ exports.default = exports.MiddleTextTruncation;
@@ -3,3 +3,4 @@ export * from './FocusTrap';
3
3
  export * from './InputContainer';
4
4
  export * from './icons';
5
5
  export * from './WithCSSTransition';
6
+ export * from './MiddleTextTruncation';
@@ -19,3 +19,4 @@ __exportStar(require("./FocusTrap"), exports);
19
19
  __exportStar(require("./InputContainer"), exports);
20
20
  __exportStar(require("./icons"), exports);
21
21
  __exportStar(require("./WithCSSTransition"), exports);
22
+ __exportStar(require("./MiddleTextTruncation"), exports);
@@ -2,5 +2,6 @@ export * from './useEventListener';
2
2
  export * from './useMergedRefs';
3
3
  export * from './useOverflow';
4
4
  export * from './useResizeObserver';
5
+ export * from './useContainerWidth';
5
6
  export * from './useTheme';
6
7
  export * from './useIntersection';
@@ -18,5 +18,6 @@ __exportStar(require("./useEventListener"), exports);
18
18
  __exportStar(require("./useMergedRefs"), exports);
19
19
  __exportStar(require("./useOverflow"), exports);
20
20
  __exportStar(require("./useResizeObserver"), exports);
21
+ __exportStar(require("./useContainerWidth"), exports);
21
22
  __exportStar(require("./useTheme"), exports);
22
23
  __exportStar(require("./useIntersection"), exports);
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Hook that returns the width of an element in three stages:
3
+ * - initialized with 0
4
+ * - immediately set to element's initial width as soon as it's mounted
5
+ * - update to new width every time it changes (using `useResizeObserver` hook)
6
+ *
7
+ * @private
8
+ * @param watchResizes If false, ResizeObserver will not be connected and only the initial width will be returned
9
+ * @returns [ref to attach to the element, stateful width of the element]
10
+ *
11
+ * @example
12
+ * const [ref, width] = useContainerWidth();
13
+ * ... // do something with width
14
+ * return <div ref={ref}>...</div>;
15
+ */
16
+ export declare const useContainerWidth: <T extends HTMLElement>(watchResizes?: boolean) => readonly [(instance: HTMLElement | null) => void, number];
17
+ export default useContainerWidth;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useContainerWidth = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ var react_1 = __importDefault(require("react"));
12
+ var useMergedRefs_1 = require("./useMergedRefs");
13
+ var useResizeObserver_1 = require("./useResizeObserver");
14
+ /**
15
+ * Hook that returns the width of an element in three stages:
16
+ * - initialized with 0
17
+ * - immediately set to element's initial width as soon as it's mounted
18
+ * - update to new width every time it changes (using `useResizeObserver` hook)
19
+ *
20
+ * @private
21
+ * @param watchResizes If false, ResizeObserver will not be connected and only the initial width will be returned
22
+ * @returns [ref to attach to the element, stateful width of the element]
23
+ *
24
+ * @example
25
+ * const [ref, width] = useContainerWidth();
26
+ * ... // do something with width
27
+ * return <div ref={ref}>...</div>;
28
+ */
29
+ var useContainerWidth = function (watchResizes) {
30
+ if (watchResizes === void 0) { watchResizes = true; }
31
+ var _a = react_1.default.useState(0), contentWidth = _a[0], setContentWidth = _a[1];
32
+ var ref = react_1.default.useCallback(function (element) {
33
+ if (!element) {
34
+ return;
35
+ }
36
+ setContentWidth(element.getBoundingClientRect().width);
37
+ }, []);
38
+ var updateWidth = react_1.default.useCallback(function (_a) {
39
+ var width = _a.width;
40
+ return setContentWidth(width);
41
+ }, []);
42
+ var _b = (0, useResizeObserver_1.useResizeObserver)(updateWidth), resizeRef = _b[0], resizeObserver = _b[1];
43
+ if (!watchResizes) {
44
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
45
+ }
46
+ var refs = (0, useMergedRefs_1.useMergedRefs)(ref, watchResizes ? resizeRef : undefined);
47
+ return [refs, contentWidth];
48
+ };
49
+ exports.useContainerWidth = useContainerWidth;
50
+ exports.default = exports.useContainerWidth;
@@ -20,4 +20,4 @@ import React from 'react';
20
20
  * </div>
21
21
  * );
22
22
  */
23
- export declare const useOverflow: <T extends HTMLElement>(items: React.ReactNode[], disabled?: boolean) => readonly [(instance: T | null) => void, number];
23
+ export declare const useOverflow: <T extends HTMLElement>(items: React.ReactNode[] | string, disabled?: boolean) => readonly [(instance: T | null) => void, number];
@@ -43,7 +43,7 @@ export declare const Button: React.ForwardRefExoticComponent<{
43
43
  * Use 'borderless' to hide outline.
44
44
  * @default 'default'
45
45
  */
46
- styleType?: "cta" | "high-visibility" | "default" | "borderless" | undefined;
46
+ styleType?: "default" | "cta" | "high-visibility" | "borderless" | undefined;
47
47
  /**
48
48
  * Icon shown before the main button content.
49
49
  */
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
17
17
  * <ColorSwatch color='#23450b' onClick={onClick}/>
18
18
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
19
19
  */
20
- export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "isActive" | "key"> & React.RefAttributes<HTMLDivElement>>;
20
+ export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "isActive" | "key"> & React.RefAttributes<HTMLDivElement>>;
21
21
  export default ColorSwatch;
@@ -18,7 +18,7 @@ export declare type DatePickerProps = {
18
18
  /**
19
19
  * Callback when date is changed.
20
20
  */
21
- onChange?: (date?: Date) => void;
21
+ onChange?: (date: Date) => void;
22
22
  /**
23
23
  * Pass localized week days (start from sunday) and months.
24
24
  * Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
@@ -35,7 +35,10 @@ export declare type InformationPanelProps = {
35
35
  * <Text variant='subheading'>InfoPanel heading</Text>
36
36
  * </InformationPanelHeader>
37
37
  * <InformationPanelBody>
38
- * <span>Info panel content</span>
38
+ * <Text>Metadata</Text>
39
+ * <InformationPanelContent ... />
40
+ * <Text>Attributes</Text>
41
+ * <InformationPanelContent ... />
39
42
  * </InformationPanelBody>
40
43
  * </InformationPanel>
41
44
  * </InformationPanelWrapper>
@@ -41,7 +41,10 @@ import '@itwin/itwinui-css/css/information-panel.css';
41
41
  * <Text variant='subheading'>InfoPanel heading</Text>
42
42
  * </InformationPanelHeader>
43
43
  * <InformationPanelBody>
44
- * <span>Info panel content</span>
44
+ * <Text>Metadata</Text>
45
+ * <InformationPanelContent ... />
46
+ * <Text>Attributes</Text>
47
+ * <InformationPanelContent ... />
45
48
  * </InformationPanelBody>
46
49
  * </InformationPanel>
47
50
  * </InformationPanelWrapper>
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { CommonProps } from '../utils';
3
+ import '@itwin/itwinui-css/css/information-panel.css';
4
+ export declare type InformationPanelContentProps = {
5
+ /**
6
+ * If set to 'inline', the label/input pairs will be shown on the same line.
7
+ * The component handles the spacing and alignment automatically.
8
+ *
9
+ * @default 'default'
10
+ */
11
+ displayStyle?: 'default' | 'inline';
12
+ /**
13
+ * Content of the component.
14
+ * Should ideally be pairs of `Label` and input components.
15
+ */
16
+ children: React.ReactNode;
17
+ } & Omit<CommonProps, 'title'>;
18
+ /**
19
+ * The `InformationPanelContent` component should be used inside `InformationPanelBody`
20
+ * to style rows of key/value pairs, where the key is ideally represented by a `Label` component
21
+ * and the value can be any input element (including readonly inputs for non-modifiable fields).
22
+ *
23
+ * By default, the pairs are displayed of label and input are displayed in separate lines,
24
+ * but displayStyle can be set to 'inline' to show them in the same line with correct alignment.
25
+ *
26
+ * You can use multiple `InformationPanelContent` instances inside one `InformationPanelBody`; this is
27
+ * useful when you want to show other content, e.g. separate headings for different sections of key/value pairs.
28
+ *
29
+ * @example
30
+ * <InformationPanelContent displayStyle='inline'>
31
+ * <Label htmlFor='name-input'>File name</Label>
32
+ * <Input id='name-input' value='Alpha.mp3' />
33
+ *
34
+ * <Label htmlFor='year-input'>Year</Label>
35
+ * <Input id='year-input' value='2021' />
36
+ *
37
+ * <Label htmlFor='path-input'>Path</Label>
38
+ * <Input id='path-input' value='/Shared/Music/' />
39
+ * </InformationPanelContent>
40
+ */
41
+ export declare const InformationPanelContent: (props: InformationPanelContentProps) => JSX.Element;
42
+ export default InformationPanelContent;
@@ -0,0 +1,59 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import cx from 'classnames';
28
+ import React from 'react';
29
+ import { useTheme } from '../utils';
30
+ import '@itwin/itwinui-css/css/information-panel.css';
31
+ /**
32
+ * The `InformationPanelContent` component should be used inside `InformationPanelBody`
33
+ * to style rows of key/value pairs, where the key is ideally represented by a `Label` component
34
+ * and the value can be any input element (including readonly inputs for non-modifiable fields).
35
+ *
36
+ * By default, the pairs are displayed of label and input are displayed in separate lines,
37
+ * but displayStyle can be set to 'inline' to show them in the same line with correct alignment.
38
+ *
39
+ * You can use multiple `InformationPanelContent` instances inside one `InformationPanelBody`; this is
40
+ * useful when you want to show other content, e.g. separate headings for different sections of key/value pairs.
41
+ *
42
+ * @example
43
+ * <InformationPanelContent displayStyle='inline'>
44
+ * <Label htmlFor='name-input'>File name</Label>
45
+ * <Input id='name-input' value='Alpha.mp3' />
46
+ *
47
+ * <Label htmlFor='year-input'>Year</Label>
48
+ * <Input id='year-input' value='2021' />
49
+ *
50
+ * <Label htmlFor='path-input'>Path</Label>
51
+ * <Input id='path-input' value='/Shared/Music/' />
52
+ * </InformationPanelContent>
53
+ */
54
+ export var InformationPanelContent = function (props) {
55
+ var className = props.className, _a = props.displayStyle, displayStyle = _a === void 0 ? 'default' : _a, children = props.children, rest = __rest(props, ["className", "displayStyle", "children"]);
56
+ useTheme();
57
+ return (React.createElement("div", __assign({ className: cx('iui-information-body-content', { 'iui-inline': displayStyle === 'inline' }, className) }, rest), children));
58
+ };
59
+ export default InformationPanelContent;
@@ -8,3 +8,5 @@ export { InformationPanelHeader } from './InformationPanelHeader';
8
8
  export type { InformationPanelHeaderProps } from './InformationPanelHeader';
9
9
  export { InformationPanelBody } from './InformationPanelBody';
10
10
  export type { InformationPanelBodyProps } from './InformationPanelBody';
11
+ export { InformationPanelContent } from './InformationPanelContent';
12
+ export type { InformationPanelContentProps } from './InformationPanelContent';
@@ -7,3 +7,4 @@ export default './InformationPanel';
7
7
  export { InformationPanelWrapper } from './InformationPanelWrapper';
8
8
  export { InformationPanelHeader } from './InformationPanelHeader';
9
9
  export { InformationPanelBody } from './InformationPanelBody';
10
+ export { InformationPanelContent } from './InformationPanelContent';
@@ -84,7 +84,7 @@ export declare const LabeledInput: React.ForwardRefExoticComponent<{
84
84
  * - 'inline' - appears in the same line as input.
85
85
  * @default 'default'
86
86
  */
87
- displayStyle?: "default" | "inline" | undefined;
87
+ displayStyle?: "inline" | "default" | undefined;
88
88
  /**
89
89
  * Set display style of icon.
90
90
  * Supported values:
@@ -93,7 +93,7 @@ export declare const LabeledInput: React.ForwardRefExoticComponent<{
93
93
  *
94
94
  * Defaults to 'block' if `displayStyle` is `default`, else 'inline'.
95
95
  */
96
- iconDisplayStyle?: "inline" | "block" | undefined;
96
+ iconDisplayStyle?: "block" | "inline" | undefined;
97
97
  } & {
98
98
  setFocus?: boolean | undefined;
99
99
  size?: "small" | "large" | undefined;
@@ -77,7 +77,7 @@ export declare const MenuItem: React.ForwardRefExoticComponent<{
77
77
  *
78
78
  * Defaults to 'large' if `sublabel` provided, otherwise 'default'.
79
79
  */
80
- size?: "large" | "default" | undefined;
80
+ size?: "default" | "large" | undefined;
81
81
  /**
82
82
  * Sub label shown below the main content of the item.
83
83
  */
@@ -67,5 +67,5 @@ export declare type TablePaginatorProps = {
67
67
  * paginatorRenderer={(props) => <TablePaginator {...props} />}
68
68
  * />
69
69
  */
70
- export declare const TablePaginator: (props: TablePaginatorProps) => JSX.Element;
70
+ export declare const TablePaginator: (props: TablePaginatorProps) => JSX.Element | null;
71
71
  export default TablePaginator;
@@ -138,12 +138,17 @@ export var TablePaginator = function (props) {
138
138
  endPage = totalPagesCount;
139
139
  }
140
140
  var hasNoRows = totalPagesCount === 0;
141
+ var showPagesList = totalPagesCount > 1 || isLoading;
142
+ var showPageSizeList = pageSizeList && onPageSizeChange && !!totalRowsCount;
141
143
  var ellipsis = (React.createElement("span", { className: cx('iui-ellipsis', { 'iui-small': size === 'small' }) }, "\u2026"));
142
144
  var noRowsContent = (React.createElement(React.Fragment, null, isLoading ? (React.createElement(ProgressRadial, { indeterminate: true, size: 'small' })) : (React.createElement(Button, { styleType: 'borderless', disabled: true, size: buttonSize }, "1"))));
145
+ if (!showPagesList && !showPageSizeList) {
146
+ return null;
147
+ }
143
148
  return (React.createElement("div", __assign({ className: cx('iui-paginator', className) }, rest),
144
149
  React.createElement("div", { className: 'iui-left' }),
145
- React.createElement("div", { className: 'iui-center', ref: overflowRef },
146
- React.createElement(IconButton, { styleType: 'borderless', disabled: currentPage === 0 || hasNoRows, onClick: function () { return onPageChange(currentPage - 1); }, size: buttonSize, "aria-label": localization.previousPage },
150
+ showPagesList && (React.createElement("div", { className: 'iui-center', ref: overflowRef },
151
+ React.createElement(IconButton, { styleType: 'borderless', disabled: currentPage === 0, onClick: function () { return onPageChange(currentPage - 1); }, size: buttonSize, "aria-label": localization.previousPage },
147
152
  React.createElement(SvgChevronLeft, null)),
148
153
  React.createElement(ButtonGroup, { onKeyDown: onKeyDown, ref: pageListRef }, (function () {
149
154
  if (hasNoRows) {
@@ -165,8 +170,8 @@ export var TablePaginator = function (props) {
165
170
  React.createElement(ProgressRadial, { indeterminate: true, size: 'small' })))));
166
171
  })()),
167
172
  React.createElement(IconButton, { styleType: 'borderless', disabled: currentPage === totalPagesCount - 1 || hasNoRows, onClick: function () { return onPageChange(currentPage + 1); }, size: buttonSize, "aria-label": localization.nextPage },
168
- React.createElement(SvgChevronRight, null))),
169
- React.createElement("div", { className: 'iui-right' }, pageSizeList && onPageSizeChange && !!totalRowsCount && (React.createElement(DropdownButton, { styleType: 'borderless', size: buttonSize, menuItems: function (close) {
173
+ React.createElement(SvgChevronRight, null)))),
174
+ React.createElement("div", { className: 'iui-right' }, showPageSizeList && (React.createElement(DropdownButton, { styleType: 'borderless', size: buttonSize, menuItems: function (close) {
170
175
  return pageSizeList.map(function (size) { return (React.createElement(MenuItem, { key: size, isSelected: size === pageSize, onClick: function () {
171
176
  close();
172
177
  onPageSizeChange(size);
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  *--------------------------------------------------------------------------------------------*/
27
27
  import cx from 'classnames';
28
28
  import React from 'react';
29
- import { useTheme, useResizeObserver, useMergedRefs, getBoundedValue, getWindow, } from '../utils';
29
+ import { useTheme, useMergedRefs, getBoundedValue, getWindow, useContainerWidth, } from '../utils';
30
30
  import '@itwin/itwinui-css/css/tabs.css';
31
31
  import { Tab } from './Tab';
32
32
  /**
@@ -58,12 +58,7 @@ export var Tabs = function (props) {
58
58
  var labels = props.labels, activeIndex = props.activeIndex, onTabSelected = props.onTabSelected, _d = props.focusActivationMode, focusActivationMode = _d === void 0 ? 'auto' : _d, _e = props.type, type = _e === void 0 ? 'default' : _e, _f = props.color, color = _f === void 0 ? 'blue' : _f, _g = props.orientation, orientation = _g === void 0 ? 'horizontal' : _g, tabsClassName = props.tabsClassName, contentClassName = props.contentClassName, children = props.children, rest = __rest(props, ["labels", "activeIndex", "onTabSelected", "focusActivationMode", "type", "color", "orientation", "tabsClassName", "contentClassName", "children"]);
59
59
  useTheme();
60
60
  var tablistRef = React.useRef(null);
61
- var _h = React.useState(function () { var _a; return (_a = tablistRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width; }), tabsWidth = _h[0], setTabsWidth = _h[1];
62
- var updateTabsWidth = React.useCallback(function (_a) {
63
- var width = _a.width;
64
- return setTabsWidth(width);
65
- }, []);
66
- var tablistSizeRef = useResizeObserver(updateTabsWidth)[0];
61
+ var _h = useContainerWidth(type !== 'default'), tablistSizeRef = _h[0], tabsWidth = _h[1];
67
62
  var refs = useMergedRefs(tablistRef, tablistSizeRef);
68
63
  var _j = React.useState(function () {
69
64
  return activeIndex != null
@@ -32,8 +32,8 @@ export { Header, HeaderBreadcrumbs, HeaderButton, HeaderLogo } from './Header';
32
32
  export type { HeaderProps, HeaderBreadcrumbsProps, HeaderButtonProps, HeaderLogoProps, } from './Header';
33
33
  export { VerticalTabs, Tab, HorizontalTabs, HorizontalTab } from './Tabs';
34
34
  export type { VerticalTabsProps, TabProps, HorizontalTabsProps, HorizontalTabProps, } from './Tabs';
35
- export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, } from './InformationPanel';
36
- export type { InformationPanelProps, InformationPanelWrapperProps, InformationPanelHeaderProps, InformationPanelBodyProps, } from './InformationPanel';
35
+ export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, InformationPanelContent, } from './InformationPanel';
36
+ export type { InformationPanelProps, InformationPanelWrapperProps, InformationPanelHeaderProps, InformationPanelBodyProps, InformationPanelContentProps, } from './InformationPanel';
37
37
  export { Input } from './Input';
38
38
  export type { InputProps } from './Input';
39
39
  export { Label } from './Label';
@@ -88,5 +88,5 @@ export { UserIconGroup } from './UserIconGroup';
88
88
  export type { UserIconGroupProps } from './UserIconGroup';
89
89
  export { Wizard } from './Wizard';
90
90
  export type { WizardProps, StepProperties, WizardType, WizardLocalization, } from './Wizard';
91
- export { getUserColor, useTheme, ColorValue } from './utils';
92
- export type { ThemeType } from './utils';
91
+ export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, } from './utils';
92
+ export type { ThemeType, MiddleTextTruncationProps } from './utils';
package/esm/core/index.js CHANGED
@@ -19,7 +19,7 @@ export { FileUpload, FileUploadTemplate } from './FileUpload';
19
19
  export { Footer } from './Footer';
20
20
  export { Header, HeaderBreadcrumbs, HeaderButton, HeaderLogo } from './Header';
21
21
  export { VerticalTabs, Tab, HorizontalTabs, HorizontalTab } from './Tabs';
22
- export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, } from './InformationPanel';
22
+ export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, InformationPanelContent, } from './InformationPanel';
23
23
  export { Input } from './Input';
24
24
  export { Label } from './Label';
25
25
  export { LabeledInput } from './LabeledInput';
@@ -47,4 +47,4 @@ export { Body, Headline, Leading, Small, Subheading, Title, Blockquote, Code, Kb
47
47
  export { UserIcon } from './UserIcon';
48
48
  export { UserIconGroup } from './UserIconGroup';
49
49
  export { Wizard } from './Wizard';
50
- export { getUserColor, useTheme, ColorValue } from './utils';
50
+ export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, } from './utils';
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from '../props';
3
+ export declare type MiddleTextTruncationProps = {
4
+ /**
5
+ * Text to truncate.
6
+ */
7
+ text: string;
8
+ /**
9
+ * Number of characters to leave at the end.
10
+ * @default 6
11
+ */
12
+ endCharsCount?: number;
13
+ } & CommonProps;
14
+ /**
15
+ * Truncates text with the ellipsis in the middle,
16
+ * leaving defined number of chars at the end.
17
+ * @example
18
+ * <MiddleTextTruncation text='ThisIsMyVeryLongFileName.dgn' />
19
+ */
20
+ export declare const MiddleTextTruncation: (props: MiddleTextTruncationProps) => JSX.Element;
21
+ export default MiddleTextTruncation;
@@ -0,0 +1,49 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import React from 'react';
28
+ import { useOverflow } from '../hooks/useOverflow';
29
+ var ELLIPSIS_CHAR = '…';
30
+ /**
31
+ * Truncates text with the ellipsis in the middle,
32
+ * leaving defined number of chars at the end.
33
+ * @example
34
+ * <MiddleTextTruncation text='ThisIsMyVeryLongFileName.dgn' />
35
+ */
36
+ export var MiddleTextTruncation = function (props) {
37
+ var text = props.text, _a = props.endCharsCount, endCharsCount = _a === void 0 ? 6 : _a, style = props.style, rest = __rest(props, ["text", "endCharsCount", "style"]);
38
+ var _b = useOverflow(text), ref = _b[0], visibleCount = _b[1];
39
+ var truncatedText = React.useMemo(function () {
40
+ if (visibleCount < text.length) {
41
+ return "" + text.substr(0, visibleCount - endCharsCount - ELLIPSIS_CHAR.length) + ELLIPSIS_CHAR + text.substr(text.length - endCharsCount);
42
+ }
43
+ else {
44
+ return text;
45
+ }
46
+ }, [endCharsCount, text, visibleCount]);
47
+ return (React.createElement("span", __assign({ style: __assign({ display: 'flex', minWidth: 0, whiteSpace: 'nowrap' }, style), ref: ref }, rest), truncatedText));
48
+ };
49
+ export default MiddleTextTruncation;
@@ -3,3 +3,4 @@ export * from './FocusTrap';
3
3
  export * from './InputContainer';
4
4
  export * from './icons';
5
5
  export * from './WithCSSTransition';
6
+ export * from './MiddleTextTruncation';
@@ -7,3 +7,4 @@ export * from './FocusTrap';
7
7
  export * from './InputContainer';
8
8
  export * from './icons';
9
9
  export * from './WithCSSTransition';
10
+ export * from './MiddleTextTruncation';
@@ -2,5 +2,6 @@ export * from './useEventListener';
2
2
  export * from './useMergedRefs';
3
3
  export * from './useOverflow';
4
4
  export * from './useResizeObserver';
5
+ export * from './useContainerWidth';
5
6
  export * from './useTheme';
6
7
  export * from './useIntersection';
@@ -6,5 +6,6 @@ export * from './useEventListener';
6
6
  export * from './useMergedRefs';
7
7
  export * from './useOverflow';
8
8
  export * from './useResizeObserver';
9
+ export * from './useContainerWidth';
9
10
  export * from './useTheme';
10
11
  export * from './useIntersection';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Hook that returns the width of an element in three stages:
3
+ * - initialized with 0
4
+ * - immediately set to element's initial width as soon as it's mounted
5
+ * - update to new width every time it changes (using `useResizeObserver` hook)
6
+ *
7
+ * @private
8
+ * @param watchResizes If false, ResizeObserver will not be connected and only the initial width will be returned
9
+ * @returns [ref to attach to the element, stateful width of the element]
10
+ *
11
+ * @example
12
+ * const [ref, width] = useContainerWidth();
13
+ * ... // do something with width
14
+ * return <div ref={ref}>...</div>;
15
+ */
16
+ export declare const useContainerWidth: <T extends HTMLElement>(watchResizes?: boolean) => readonly [(instance: HTMLElement | null) => void, number];
17
+ export default useContainerWidth;
@@ -0,0 +1,43 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import React from 'react';
6
+ import { useMergedRefs } from './useMergedRefs';
7
+ import { useResizeObserver } from './useResizeObserver';
8
+ /**
9
+ * Hook that returns the width of an element in three stages:
10
+ * - initialized with 0
11
+ * - immediately set to element's initial width as soon as it's mounted
12
+ * - update to new width every time it changes (using `useResizeObserver` hook)
13
+ *
14
+ * @private
15
+ * @param watchResizes If false, ResizeObserver will not be connected and only the initial width will be returned
16
+ * @returns [ref to attach to the element, stateful width of the element]
17
+ *
18
+ * @example
19
+ * const [ref, width] = useContainerWidth();
20
+ * ... // do something with width
21
+ * return <div ref={ref}>...</div>;
22
+ */
23
+ export var useContainerWidth = function (watchResizes) {
24
+ if (watchResizes === void 0) { watchResizes = true; }
25
+ var _a = React.useState(0), contentWidth = _a[0], setContentWidth = _a[1];
26
+ var ref = React.useCallback(function (element) {
27
+ if (!element) {
28
+ return;
29
+ }
30
+ setContentWidth(element.getBoundingClientRect().width);
31
+ }, []);
32
+ var updateWidth = React.useCallback(function (_a) {
33
+ var width = _a.width;
34
+ return setContentWidth(width);
35
+ }, []);
36
+ var _b = useResizeObserver(updateWidth), resizeRef = _b[0], resizeObserver = _b[1];
37
+ if (!watchResizes) {
38
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
39
+ }
40
+ var refs = useMergedRefs(ref, watchResizes ? resizeRef : undefined);
41
+ return [refs, contentWidth];
42
+ };
43
+ export default useContainerWidth;
@@ -20,4 +20,4 @@ import React from 'react';
20
20
  * </div>
21
21
  * );
22
22
  */
23
- export declare const useOverflow: <T extends HTMLElement>(items: React.ReactNode[], disabled?: boolean) => readonly [(instance: T | null) => void, number];
23
+ export declare const useOverflow: <T extends HTMLElement>(items: React.ReactNode[] | string, disabled?: boolean) => readonly [(instance: T | null) => void, number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "main": "cjs/index.js",