@itwin/itwinui-react 2.0.0 → 2.0.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 +28 -4
- package/cjs/core/Avatar/Avatar.d.ts +1 -1
- package/cjs/core/AvatarGroup/AvatarGroup.d.ts +1 -1
- package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
- package/cjs/core/Carousel/CarouselSlider.js +2 -2
- package/cjs/core/ColorPicker/ColorBuilder.js +2 -7
- package/cjs/core/ColorPicker/ColorPalette.js +1 -1
- package/cjs/core/ColorPicker/ColorPicker.js +1 -3
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBox.js +1 -1
- package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenu.js +1 -1
- package/cjs/core/Dialog/DialogMain.js +1 -1
- package/cjs/core/LabeledInput/LabeledInput.d.ts +1 -1
- package/cjs/core/Modal/ModalButtonBar.d.ts +1 -1
- package/cjs/core/Modal/ModalButtonBar.js +10 -1
- package/cjs/core/Modal/ModalContent.d.ts +1 -1
- package/cjs/core/Modal/ModalContent.js +10 -1
- package/cjs/core/Table/Table.js +1 -1
- package/cjs/core/Table/TablePaginator.d.ts +6 -0
- package/cjs/core/Table/TablePaginator.js +2 -1
- package/cjs/core/Table/hooks/useColumnDragAndDrop.js +3 -1
- package/cjs/core/Tabs/Tabs.js +3 -3
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +21 -3
- package/cjs/core/utils/color/ColorValue.js +4 -2
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/components/Resizer.js +3 -2
- package/cjs/core/utils/components/VirtualScroll.js +7 -8
- package/cjs/core/utils/functions/styles.d.ts +1 -1
- package/cjs/core/utils/functions/styles.js +1 -1
- package/cjs/core/utils/hooks/useDragAndDrop.js +1 -1
- package/cjs/core/utils/hooks/useOverflow.js +4 -3
- package/cjs/core/utils/hooks/useTheme.js +2 -2
- package/esm/core/Avatar/Avatar.d.ts +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.d.ts +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
- package/esm/core/Carousel/CarouselSlider.js +3 -3
- package/esm/core/ColorPicker/ColorBuilder.js +2 -7
- package/esm/core/ColorPicker/ColorPalette.js +1 -1
- package/esm/core/ColorPicker/ColorPicker.js +1 -3
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/ComboBox/ComboBox.js +2 -2
- package/esm/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenu.js +1 -1
- package/esm/core/Dialog/DialogMain.js +2 -2
- package/esm/core/LabeledInput/LabeledInput.d.ts +1 -1
- package/esm/core/Modal/ModalButtonBar.d.ts +1 -1
- package/esm/core/Modal/ModalButtonBar.js +6 -1
- package/esm/core/Modal/ModalContent.d.ts +1 -1
- package/esm/core/Modal/ModalContent.js +6 -1
- package/esm/core/Table/Table.js +2 -2
- package/esm/core/Table/TablePaginator.d.ts +6 -0
- package/esm/core/Table/TablePaginator.js +2 -1
- package/esm/core/Table/hooks/useColumnDragAndDrop.js +3 -1
- package/esm/core/Tabs/Tabs.js +4 -4
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +21 -3
- package/esm/core/utils/color/ColorValue.js +4 -2
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/components/Resizer.js +3 -2
- package/esm/core/utils/components/VirtualScroll.js +7 -8
- package/esm/core/utils/functions/styles.d.ts +1 -1
- package/esm/core/utils/functions/styles.js +1 -1
- package/esm/core/utils/hooks/useDragAndDrop.js +1 -1
- package/esm/core/utils/hooks/useOverflow.js +4 -3
- package/esm/core/utils/hooks/useTheme.js +2 -2
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### [2.0.2](https://www.github.com/iTwin/iTwinUI-react/compare/v2.0.1...v2.0.2) (2022-12-07)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
* **ThemeProvider:** Improved types to exclude `ownerDocument` from `themeOptions` if children passed ([#973](https://www.github.com/iTwin/iTwinUI-react/issues/973)) ([36997de](https://www.github.com/iTwin/iTwinUI-react/commit/36997de383c4783c192318f2fb617289a7dce2dd))
|
|
8
|
+
|
|
9
|
+
### [2.0.1](https://www.github.com/iTwin/iTwinUI-react/compare/v2.0.0...v2.0.1) (2022-12-05)
|
|
10
|
+
|
|
11
|
+
### Fixes
|
|
12
|
+
|
|
13
|
+
* **useTheme:** Exit early if theme is already set on body ([#963](https://www.github.com/iTwin/iTwinUI-react/issues/963)) ([29033d4](https://www.github.com/iTwin/iTwinUI-react/commit/29033d488bc6cefb3ea064305898ade85475e2ff))
|
|
14
|
+
* **ModalButtonBar, ModalContent:** Wrap `DialogButtonBar` and `DialogContent` instead of directly assigning ([#961](https://www.github.com/iTwin/iTwinUI-react/issues/961)) ([0881e92](https://www.github.com/iTwin/iTwinUI-react/commit/0881e92f037b7ce717f05742014ac2d6dd8c580d))
|
|
15
|
+
* **Table:** Added localization for selected rows count ([#945](https://www.github.com/iTwin/iTwinUI-react/issues/945)) ([71f2326](https://www.github.com/iTwin/iTwinUI-react/commit/71f232605237e0095ebe0bff4cf01d241c143c49))
|
|
16
|
+
* Replaced all instances of `useLayoutEffect` with `useIsomorphicLayoutEffect` to fix SSR warnings ([#964](https://www.github.com/iTwin/iTwinUI-react/issues/964)) ([15b0389](https://www.github.com/iTwin/iTwinUI-react/commit/15b038934e55d3f61631113d91f2952127426c1d))
|
|
17
|
+
* Fixed css warnings about `start` vs `flex-start` through base itwinui-css update ([#962](https://www.github.com/iTwin/iTwinUI-react/issues/962))
|
|
18
|
+
|
|
3
19
|
## [2.0.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.48.1...v2.0.0) (2022-11-15)
|
|
4
20
|
|
|
5
21
|
Welcome to the v2 release of iTwinUI-react. 🎉
|
|
@@ -10,11 +26,19 @@ These release notes offer a brief summary of the main changes. Check out the [iT
|
|
|
10
26
|
|
|
11
27
|
### ⚠ BREAKING CHANGES
|
|
12
28
|
|
|
13
|
-
|
|
29
|
+
iTwinUI no longer supports Internet Explorer. The build output now targets `es2018` rather than `es5`, and CSS variables and grid are used without fallbacks.
|
|
30
|
+
|
|
31
|
+
As for breaking API changes, there is only one:
|
|
14
32
|
|
|
15
33
|
* **Table:** `columns` prop must now be an array. First level `Header` is no longer required ([#935](https://www.github.com/iTwin/iTwinUI-react/issues/935)) ([83d5cfe](https://www.github.com/iTwin/iTwinUI-react/commit/83d5cfe93980b628c79ec3951d05663a054699fc))
|
|
34
|
+
```diff
|
|
35
|
+
- const columns = { Header: 'Table', columns: [{ accessor: 'name', Header: 'Name' }, … ] };
|
|
36
|
+
+ const columns = [{ accessor: 'name', Header: 'Name' }, … ];
|
|
37
|
+
|
|
38
|
+
<Table columns={columns} data={data} />
|
|
39
|
+
```
|
|
16
40
|
|
|
17
|
-
Other than that,
|
|
41
|
+
Other than that, props and components that were already deprecated in v1 have been removed:
|
|
18
42
|
|
|
19
43
|
* **Tabs:** Remove deprecated `HorizontalTab` and `HorizontalTabProps` ([#852](https://www.github.com/iTwin/iTwinUI-react/issues/852)) ([31ddeae](https://www.github.com/iTwin/iTwinUI-react/commit/31ddeaed3dc5919f69edb1bd9580d766fabc35c2))
|
|
20
44
|
* **Checkbox, Radio:** Remove deprecated `checkmarkClassName` and `checkmarkStyle` ([#855](https://www.github.com/iTwin/iTwinUI-react/issues/855)) ([5c339be](https://www.github.com/iTwin/iTwinUI-react/commit/5c339beddd117bdf5a834b96dff65d4fd67d5255))
|
|
@@ -22,7 +46,7 @@ Other than that, we have removed props and components that were already deprecat
|
|
|
22
46
|
|
|
23
47
|
### Deprecations
|
|
24
48
|
|
|
25
|
-
We have taken this opportunity to deprecate a few more things while not removing them just yet, to minimize the number of breaking changes.
|
|
49
|
+
We have also taken this opportunity to deprecate a few more things while not removing them just yet, to minimize the number of breaking changes.
|
|
26
50
|
|
|
27
51
|
* **Avatar, AvatarGroup:** Deprecate `UserIcon`/`UserIconGroup`, replace with `Avatar`/`AvatarGroup` ([#902](https://www.github.com/iTwin/iTwinUI-react/issues/902)) ([4001bd1](https://www.github.com/iTwin/iTwinUI-react/commit/4001bd12aa9021fdcbb3e49c271eec10ec853a83))
|
|
28
52
|
- Also deprecated `userIcon` prop in `Header`.
|
|
@@ -40,7 +64,7 @@ We have taken this opportunity to deprecate a few more things while not removing
|
|
|
40
64
|
* **Table:** Row selection count for paginator ([#837](https://www.github.com/iTwin/iTwinUI-react/issues/837)) ([e43148a](https://www.github.com/iTwin/iTwinUI-react/commit/e43148af9fc6250cf2470d258831a3ef8d33e582))
|
|
41
65
|
* **Tile:** Add status and loading state ([#872](https://www.github.com/iTwin/iTwinUI-react/issues/872)) ([2fcb41f](https://www.github.com/iTwin/iTwinUI-react/commit/2fcb41f5c41a8a32d32a3312edecf8e2b646033e))
|
|
42
66
|
|
|
43
|
-
If you're interested in more details about every signle change, check out a full diff in [`v1.48.1..v2.0.0`](https://www.github.com/iTwin/iTwinUI/compare/v1.48.1...v2.0.0).
|
|
67
|
+
If you're interested in more details about every signle change, check out a full diff in [`v1.48.1..v2.0.0`](https://www.github.com/iTwin/iTwinUI-react/compare/v1.48.1...v2.0.0).
|
|
44
68
|
|
|
45
69
|
## 1.X
|
|
46
70
|
|
|
@@ -44,7 +44,7 @@ export declare type UserIconGroupProps = AvatarGroupProps;
|
|
|
44
44
|
* You can add custom Count Avatar behavior by using `countAvatarProps`.
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
|
-
* <AvatarGroup
|
|
47
|
+
* <AvatarGroup iconSize='medium'>
|
|
48
48
|
* <Avatar
|
|
49
49
|
* abbreviation="TR"
|
|
50
50
|
* backgroundColor={getUserColor("Terry Rivers")}
|
|
@@ -21,7 +21,7 @@ require("@itwin/itwinui-css/css/avatar.css");
|
|
|
21
21
|
* You can add custom Count Avatar behavior by using `countAvatarProps`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* <AvatarGroup
|
|
24
|
+
* <AvatarGroup iconSize='medium'>
|
|
25
25
|
* <Avatar
|
|
26
26
|
* abbreviation="TR"
|
|
27
27
|
* backgroundColor={getUserColor("Terry Rivers")}
|
|
@@ -21,7 +21,7 @@ exports.CarouselSlider = react_1.default.forwardRef((props, ref) => {
|
|
|
21
21
|
if (!context) {
|
|
22
22
|
throw new Error('CarouselSlider must be used within Carousel');
|
|
23
23
|
}
|
|
24
|
-
const { setSlideCount, idPrefix, scrollToSlide, isManuallyUpdating
|
|
24
|
+
const { setSlideCount, idPrefix, scrollToSlide, isManuallyUpdating } = context;
|
|
25
25
|
const items = react_1.default.useMemo(() => {
|
|
26
26
|
var _a;
|
|
27
27
|
return (_a = react_1.default.Children.map(children, (child, index) => react_1.default.isValidElement(child)
|
|
@@ -31,7 +31,7 @@ exports.CarouselSlider = react_1.default.forwardRef((props, ref) => {
|
|
|
31
31
|
})
|
|
32
32
|
: child)) !== null && _a !== void 0 ? _a : [];
|
|
33
33
|
}, [children, idPrefix]);
|
|
34
|
-
|
|
34
|
+
(0, utils_1.useIsomorphicLayoutEffect)(() => {
|
|
35
35
|
setSlideCount(items.length);
|
|
36
36
|
}, [items.length, setSlideCount]);
|
|
37
37
|
const sliderRef = react_1.default.useRef(null);
|
|
@@ -37,14 +37,9 @@ exports.ColorBuilder = react_1.default.forwardRef((props, ref) => {
|
|
|
37
37
|
// Set values for slider
|
|
38
38
|
const hueSliderColor = react_1.default.useMemo(() => utils_1.ColorValue.create({ h: hsvColor.h, s: 100, v: 100 }), [hsvColor.h]);
|
|
39
39
|
const sliderValue = react_1.default.useMemo(() => hsvColor.h, [hsvColor]);
|
|
40
|
-
const alphaValue = react_1.default.useMemo(() => { var _a; return (showAlpha ? (_a = hsvColor.a) !== null && _a !== void 0 ? _a : 1 : 1); }, [
|
|
41
|
-
hsvColor.a,
|
|
42
|
-
showAlpha,
|
|
43
|
-
]);
|
|
40
|
+
const alphaValue = react_1.default.useMemo(() => { var _a; return (showAlpha ? (_a = hsvColor.a) !== null && _a !== void 0 ? _a : 1 : 1); }, [hsvColor.a, showAlpha]);
|
|
44
41
|
// Set values for color square and color dot
|
|
45
|
-
const dotColorString = react_1.default.useMemo(() => activeColor.toHexString(), [
|
|
46
|
-
activeColor,
|
|
47
|
-
]);
|
|
42
|
+
const dotColorString = react_1.default.useMemo(() => activeColor.toHexString(), [activeColor]);
|
|
48
43
|
const [colorDotActive, setColorDotActive] = react_1.default.useState(false);
|
|
49
44
|
const hueColorString = hueSliderColor.toHexString();
|
|
50
45
|
const squareTop = 100 - hsvColor.v;
|
|
@@ -29,7 +29,7 @@ require("@itwin/itwinui-css/css/color-picker.css");
|
|
|
29
29
|
exports.ColorPalette = react_1.default.forwardRef((props, ref) => {
|
|
30
30
|
const { colors, label, className, children, ...rest } = props;
|
|
31
31
|
(0, utils_1.useTheme)();
|
|
32
|
-
const { activeColor, setActiveColor, onChangeComplete
|
|
32
|
+
const { activeColor, setActiveColor, onChangeComplete } = (0, ColorPickerContext_1.useColorPickerContext)();
|
|
33
33
|
const [focusedIndex, setFocusedIndex] = react_1.default.useState();
|
|
34
34
|
// callback ref to set tabindex=0 on first child if none of the swatches are tabbable
|
|
35
35
|
const setDefaultTabIndex = (el) => {
|
|
@@ -44,9 +44,7 @@ const ColorPicker = (props) => {
|
|
|
44
44
|
tabbableElements[0].focus();
|
|
45
45
|
}
|
|
46
46
|
}, [setFocus]);
|
|
47
|
-
const inColor = react_1.default.useMemo(() => (0, exports.getColorValue)(selectedColor), [
|
|
48
|
-
selectedColor,
|
|
49
|
-
]);
|
|
47
|
+
const inColor = react_1.default.useMemo(() => (0, exports.getColorValue)(selectedColor), [selectedColor]);
|
|
50
48
|
const activeColorTbgr = react_1.default.useRef(inColor.toTbgr());
|
|
51
49
|
const [activeColor, setActiveColor] = react_1.default.useState(inColor); // Color of colorDot or active ColorSwatch
|
|
52
50
|
react_1.default.useEffect(() => {
|
|
@@ -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" | "aria-disabled" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "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-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" | "
|
|
20
|
+
export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "children" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "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-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" | "onFocus" | "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"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
21
|
export default ColorSwatch;
|
|
@@ -3,5 +3,5 @@ import { PopoverProps } from '../utils';
|
|
|
3
3
|
declare type ComboBoxDropdownProps = PopoverProps & {
|
|
4
4
|
children: JSX.Element;
|
|
5
5
|
};
|
|
6
|
-
export declare const ComboBoxDropdown: React.ForwardRefExoticComponent<Pick<ComboBoxDropdownProps, "disabled" | "theme" | "
|
|
6
|
+
export declare const ComboBoxDropdown: React.ForwardRefExoticComponent<Pick<ComboBoxDropdownProps, "disabled" | "theme" | "children" | "className" | "role" | "placement" | "trigger" | "visible" | "content" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "offset" | "plugins" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "zIndex" | "singleton" | "reference"> & React.RefAttributes<Element>>;
|
|
7
7
|
export {};
|
|
@@ -16,7 +16,7 @@ const utils_1 = require("../utils");
|
|
|
16
16
|
const helpers_1 = require("./helpers");
|
|
17
17
|
const VirtualizedComboBoxMenu = react_1.default.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
|
|
18
18
|
var _a, _b, _c;
|
|
19
|
-
const { minWidth, id, filteredOptions, getMenuItem, focusedIndex
|
|
19
|
+
const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = (0, utils_1.useSafeContext)(helpers_1.ComboBoxStateContext);
|
|
20
20
|
const { menuRef } = (0, utils_1.useSafeContext)(helpers_1.ComboBoxRefsContext);
|
|
21
21
|
const virtualItemRenderer = react_1.default.useCallback((index) => filteredOptions.length > 0
|
|
22
22
|
? getMenuItem(filteredOptions[index], index)
|
|
@@ -108,7 +108,7 @@ exports.DialogMain = react_1.default.forwardRef((props, ref) => {
|
|
|
108
108
|
}
|
|
109
109
|
}, [isDraggable, onPointerDown]);
|
|
110
110
|
// Prevents dialog from moving when window is being resized
|
|
111
|
-
|
|
111
|
+
(0, utils_1.useIsomorphicLayoutEffect)(() => {
|
|
112
112
|
var _a;
|
|
113
113
|
if (!isDraggable || !isOpen) {
|
|
114
114
|
return;
|
|
@@ -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?: "
|
|
87
|
+
displayStyle?: "inline" | "default" | undefined;
|
|
88
88
|
/**
|
|
89
89
|
* Set display style of icon.
|
|
90
90
|
* Supported values:
|
|
@@ -9,5 +9,5 @@ export declare type ModalButtonBarProps = {
|
|
|
9
9
|
/**
|
|
10
10
|
* Container for Buttons in modal.
|
|
11
11
|
*/
|
|
12
|
-
export declare const ModalButtonBar:
|
|
12
|
+
export declare const ModalButtonBar: (props: ModalButtonBarProps) => JSX.Element;
|
|
13
13
|
export default ModalButtonBar;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ModalButtonBar = 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
|
+
const react_1 = __importDefault(require("react"));
|
|
4
12
|
const DialogButtonBar_1 = require("../Dialog/DialogButtonBar");
|
|
5
13
|
/**
|
|
6
14
|
* Container for Buttons in modal.
|
|
7
15
|
*/
|
|
8
|
-
|
|
16
|
+
const ModalButtonBar = (props) => (react_1.default.createElement(DialogButtonBar_1.DialogButtonBar, { ...props }));
|
|
17
|
+
exports.ModalButtonBar = ModalButtonBar;
|
|
9
18
|
exports.default = exports.ModalButtonBar;
|
|
@@ -9,5 +9,5 @@ export declare type ModalContentProps = {
|
|
|
9
9
|
/**
|
|
10
10
|
* Container for content in `Modal`.
|
|
11
11
|
*/
|
|
12
|
-
export declare const ModalContent:
|
|
12
|
+
export declare const ModalContent: (props: ModalContentProps) => JSX.Element;
|
|
13
13
|
export default ModalContent;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ModalContent = 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
|
+
const react_1 = __importDefault(require("react"));
|
|
4
12
|
const DialogContent_1 = require("../Dialog/DialogContent");
|
|
5
13
|
/**
|
|
6
14
|
* Container for content in `Modal`.
|
|
7
15
|
*/
|
|
8
|
-
|
|
16
|
+
const ModalContent = (props) => (react_1.default.createElement(DialogContent_1.DialogContent, { ...props }));
|
|
17
|
+
exports.ModalContent = ModalContent;
|
|
9
18
|
exports.default = exports.ModalContent;
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -291,7 +291,7 @@ const Table = (props) => {
|
|
|
291
291
|
}, [dispatch, state.columnResizing.columnWidths, flatHeaders, instance]);
|
|
292
292
|
const [resizeRef] = (0, utils_1.useResizeObserver)(onTableResize);
|
|
293
293
|
// Flexbox handles columns resize so we take new column widths before browser repaints.
|
|
294
|
-
|
|
294
|
+
(0, utils_1.useIsomorphicLayoutEffect)(() => {
|
|
295
295
|
if (state.isTableResizing) {
|
|
296
296
|
const newColumnWidths = {};
|
|
297
297
|
flatHeaders.forEach((column) => {
|
|
@@ -56,6 +56,12 @@ export declare type TablePaginatorProps = {
|
|
|
56
56
|
* @default 'Rows per page'
|
|
57
57
|
*/
|
|
58
58
|
rowsPerPageLabel?: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Function that returns a label shown in the bottom left to notify how many rows are selected.
|
|
61
|
+
* Only used if multi-selection mode is enabled.
|
|
62
|
+
* @default (totalSelectedRowsCount: number) => `${totalSelectedRowsCount} ${totalSelectedRowsCount === 1 ? 'row' : 'rows'} selected`;
|
|
63
|
+
*/
|
|
64
|
+
rowsSelectedLabel?: (totalSelectedRowsCount: number) => string;
|
|
59
65
|
};
|
|
60
66
|
} & TablePaginatorRendererProps & Omit<CommonProps, 'title'>;
|
|
61
67
|
/**
|
|
@@ -24,6 +24,7 @@ const defaultLocalization = {
|
|
|
24
24
|
nextPage: 'Next page',
|
|
25
25
|
goToPageLabel: (page) => `Go to page ${page}`,
|
|
26
26
|
rowsPerPageLabel: 'Rows per page',
|
|
27
|
+
rowsSelectedLabel: (totalSelectedRowsCount) => `${totalSelectedRowsCount} ${totalSelectedRowsCount === 1 ? 'row' : 'rows'} selected`,
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
30
|
* Table paginator component. Recommended to pass to the `Table` as `paginatorRenderer` prop.
|
|
@@ -126,7 +127,7 @@ const TablePaginator = (props) => {
|
|
|
126
127
|
return null;
|
|
127
128
|
}
|
|
128
129
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-table-paginator', className), ref: paginatorResizeRef, ...rest },
|
|
129
|
-
react_1.default.createElement("div", { className: 'iui-left' }, totalSelectedRowsCount > 0 && (react_1.default.createElement("span", null,
|
|
130
|
+
react_1.default.createElement("div", { className: 'iui-left' }, totalSelectedRowsCount > 0 && (react_1.default.createElement("span", null, localization.rowsSelectedLabel(totalSelectedRowsCount)))),
|
|
130
131
|
showPagesList && (react_1.default.createElement("div", { className: 'iui-center', ref: overflowRef },
|
|
131
132
|
react_1.default.createElement(Buttons_1.IconButton, { styleType: 'borderless', disabled: currentPage === 0, onClick: () => onPageChange(currentPage - 1), size: buttonSize, "aria-label": localization.previousPage },
|
|
132
133
|
react_1.default.createElement(utils_1.SvgChevronLeft, null)),
|
|
@@ -43,7 +43,9 @@ const defaultGetDragAndDropProps = (isEnabled) => (props, { instance, header, })
|
|
|
43
43
|
event.preventDefault();
|
|
44
44
|
const headerIndex = instance.flatHeaders.indexOf(header);
|
|
45
45
|
if (instance.state.columnReorderStartIndex !== headerIndex) {
|
|
46
|
-
setOnDragColumnStyle(event, instance.state.columnReorderStartIndex > headerIndex
|
|
46
|
+
setOnDragColumnStyle(event, instance.state.columnReorderStartIndex > headerIndex
|
|
47
|
+
? 'left'
|
|
48
|
+
: 'right');
|
|
47
49
|
}
|
|
48
50
|
};
|
|
49
51
|
const onDragLeave = (event) => {
|
package/cjs/core/Tabs/Tabs.js
CHANGED
|
@@ -49,14 +49,14 @@ const Tabs = (props) => {
|
|
|
49
49
|
const [currentActiveIndex, setCurrentActiveIndex] = react_1.default.useState(() => activeIndex != null
|
|
50
50
|
? (0, utils_1.getBoundedValue)(activeIndex, 0, labels.length - 1)
|
|
51
51
|
: 0);
|
|
52
|
-
|
|
52
|
+
(0, utils_1.useIsomorphicLayoutEffect)(() => {
|
|
53
53
|
if (activeIndex != null && currentActiveIndex !== activeIndex) {
|
|
54
54
|
setCurrentActiveIndex((0, utils_1.getBoundedValue)(activeIndex, 0, labels.length - 1));
|
|
55
55
|
}
|
|
56
56
|
}, [activeIndex, currentActiveIndex, labels.length]);
|
|
57
57
|
// CSS custom properties to place the active stripe
|
|
58
58
|
const [stripeProperties, setStripeProperties] = react_1.default.useState({});
|
|
59
|
-
|
|
59
|
+
(0, utils_1.useIsomorphicLayoutEffect)(() => {
|
|
60
60
|
if (type !== 'default' && tablistRef.current != undefined) {
|
|
61
61
|
const activeTab = tablistRef.current.children[currentActiveIndex];
|
|
62
62
|
const activeTabRect = activeTab.getBoundingClientRect();
|
|
@@ -80,7 +80,7 @@ const Tabs = (props) => {
|
|
|
80
80
|
}
|
|
81
81
|
}, [focusedIndex]);
|
|
82
82
|
const [hasSublabel, setHasSublabel] = react_1.default.useState(false); // used for setting size
|
|
83
|
-
|
|
83
|
+
(0, utils_1.useIsomorphicLayoutEffect)(() => {
|
|
84
84
|
var _a;
|
|
85
85
|
setHasSublabel(type !== 'pill' && // pill tabs should never have sublabels
|
|
86
86
|
!!((_a = tablistRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.iui-tab-description')));
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { PolymorphicComponentProps, PolymorphicForwardRefComponent, ThemeOptions, ThemeType
|
|
2
|
+
import type { PolymorphicComponentProps, PolymorphicForwardRefComponent, ThemeOptions, ThemeType } from '../utils';
|
|
3
3
|
import '@itwin/itwinui-css/css/global.css';
|
|
4
4
|
import '@itwin/itwinui-variables/index.css';
|
|
5
|
-
export declare type ThemeProviderProps<T extends React.ElementType = 'div'> = PolymorphicComponentProps<T,
|
|
5
|
+
export declare type ThemeProviderProps<T extends React.ElementType = 'div'> = PolymorphicComponentProps<T, ThemeProviderOwnProps>;
|
|
6
|
+
declare type ThemeProviderOwnProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Theme to be applied. Can be 'light' or 'dark' or 'os'.
|
|
9
|
+
*
|
|
10
|
+
* Note that 'os' will respect the system preference on client but will fallback to 'light'
|
|
11
|
+
* in SSR environments because it is not possible detect system preference on the server.
|
|
12
|
+
* This can cause a flash of incorrect theme on first render.
|
|
13
|
+
*
|
|
14
|
+
* @default 'light'
|
|
15
|
+
*/
|
|
16
|
+
theme?: ThemeType;
|
|
17
|
+
} & ({
|
|
18
|
+
themeOptions?: Pick<ThemeOptions, 'highContrast'>;
|
|
19
|
+
children: Required<React.ReactNode>;
|
|
20
|
+
} | {
|
|
21
|
+
themeOptions?: ThemeOptions;
|
|
22
|
+
children?: undefined;
|
|
23
|
+
});
|
|
6
24
|
/**
|
|
7
25
|
* This component provides global styles and applies theme to the entire tree
|
|
8
26
|
* that it is wrapping around. The `theme` prop is optional and defaults to the
|
|
@@ -23,7 +41,7 @@ export declare type ThemeProviderProps<T extends React.ElementType = 'div'> = Po
|
|
|
23
41
|
* <App />
|
|
24
42
|
* </ThemeProvider>
|
|
25
43
|
*/
|
|
26
|
-
export declare const ThemeProvider: PolymorphicForwardRefComponent<"div",
|
|
44
|
+
export declare const ThemeProvider: PolymorphicForwardRefComponent<"div", ThemeProviderOwnProps>;
|
|
27
45
|
export default ThemeProvider;
|
|
28
46
|
export declare const ThemeContext: React.Context<{
|
|
29
47
|
theme?: ThemeType | undefined;
|
|
@@ -219,7 +219,8 @@ class ColorValue {
|
|
|
219
219
|
switch (name) {
|
|
220
220
|
case 'rgb':
|
|
221
221
|
case 'rgba':
|
|
222
|
-
color =
|
|
222
|
+
color =
|
|
223
|
+
/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components);
|
|
223
224
|
if (color) {
|
|
224
225
|
// rgb(255,0,0) rgba(255,0,0,0.5)
|
|
225
226
|
return [
|
|
@@ -232,7 +233,8 @@ class ColorValue {
|
|
|
232
233
|
break;
|
|
233
234
|
case 'hsl':
|
|
234
235
|
case 'hsla':
|
|
235
|
-
color =
|
|
236
|
+
color =
|
|
237
|
+
/^(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components);
|
|
236
238
|
if (color) {
|
|
237
239
|
// hsl(120,50%,50%) hsla(120,50%,50%,0.5)
|
|
238
240
|
const h = parseFloat(color[1]);
|
|
@@ -26,7 +26,7 @@ export declare type PopoverProps = {
|
|
|
26
26
|
* with pre-configured props and plugins (e.g. lazy mounting, focus, etc).
|
|
27
27
|
* @private
|
|
28
28
|
*/
|
|
29
|
-
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "theme" | "
|
|
29
|
+
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "theme" | "children" | "className" | "role" | "placement" | "trigger" | "visible" | "content" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "offset" | "plugins" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "zIndex" | "singleton" | "reference"> & React.RefAttributes<unknown>>;
|
|
30
30
|
/**
|
|
31
31
|
* Plugin to hide Popover when either Esc key is pressed,
|
|
32
32
|
* or when the content inside is not tabbable and Tab key is pressed.
|
|
@@ -32,7 +32,7 @@ const Resizer = (props) => {
|
|
|
32
32
|
const initialPointerX = event.clientX;
|
|
33
33
|
const initialPointerY = event.clientY;
|
|
34
34
|
const [initialTranslateX, initialTranslateY] = (0, functions_1.getTranslateValues)(elementRef.current);
|
|
35
|
-
const { width: initialWidth, height: initialHeight
|
|
35
|
+
const { width: initialWidth, height: initialHeight } = elementRef.current.getBoundingClientRect();
|
|
36
36
|
let width = `${initialWidth}px`;
|
|
37
37
|
let height = `${initialHeight}px`;
|
|
38
38
|
let translateX = initialTranslateX;
|
|
@@ -132,7 +132,8 @@ const Resizer = (props) => {
|
|
|
132
132
|
elementRef.current.ownerDocument.addEventListener('pointerup', () => {
|
|
133
133
|
document.removeEventListener('pointermove', onResizePointerMove);
|
|
134
134
|
if (elementRef.current) {
|
|
135
|
-
elementRef.current.ownerDocument.body.style.userSelect =
|
|
135
|
+
elementRef.current.ownerDocument.body.style.userSelect =
|
|
136
|
+
originalUserSelect;
|
|
136
137
|
isResizing.current = false;
|
|
137
138
|
onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd({
|
|
138
139
|
width,
|
|
@@ -10,7 +10,6 @@ exports.useVirtualization = exports.VirtualScroll = void 0;
|
|
|
10
10
|
*--------------------------------------------------------------------------------------------*/
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const hooks_1 = require("../hooks");
|
|
13
|
-
const useResizeObserver_1 = require("../hooks/useResizeObserver");
|
|
14
13
|
const getScrollableParent = (element, ownerDocument = document) => {
|
|
15
14
|
if (!element || element === ownerDocument.body) {
|
|
16
15
|
return ownerDocument.body;
|
|
@@ -149,21 +148,21 @@ const useVirtualization = (props) => {
|
|
|
149
148
|
setScrollContainerHeight(height);
|
|
150
149
|
updateChildHeight();
|
|
151
150
|
}, [updateChildHeight]);
|
|
152
|
-
const [resizeRef, resizeObserver] = (0,
|
|
151
|
+
const [resizeRef, resizeObserver] = (0, hooks_1.useResizeObserver)(onResize);
|
|
153
152
|
// Find scrollable parent
|
|
154
153
|
// Needed only on init
|
|
155
|
-
|
|
154
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
156
155
|
var _a;
|
|
157
156
|
const scrollableParent = getScrollableParent(parentRef.current, (_a = parentRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument);
|
|
158
157
|
scrollContainer.current = scrollableParent;
|
|
159
158
|
resizeRef(scrollableParent);
|
|
160
159
|
}, [resizeRef]);
|
|
161
160
|
// Stop watching resize, when virtual scroll is unmounted
|
|
162
|
-
|
|
161
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
163
162
|
return () => resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
164
163
|
}, [resizeObserver]);
|
|
165
164
|
// Get child height when children available
|
|
166
|
-
|
|
165
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => updateChildHeight(), [updateChildHeight]);
|
|
167
166
|
const updateVirtualScroll = react_1.default.useCallback(() => {
|
|
168
167
|
const scrollableContainer = getScrollableContainer();
|
|
169
168
|
if (!scrollableContainer) {
|
|
@@ -197,7 +196,7 @@ const useVirtualization = (props) => {
|
|
|
197
196
|
: scrollContainer.current.removeEventListener('scroll', onScrollRef.current);
|
|
198
197
|
}, []);
|
|
199
198
|
// Add event listener to the scrollable container.
|
|
200
|
-
|
|
199
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
201
200
|
var _a, _b;
|
|
202
201
|
removeScrollListener();
|
|
203
202
|
onScrollRef.current = onScroll;
|
|
@@ -210,7 +209,7 @@ const useVirtualization = (props) => {
|
|
|
210
209
|
}
|
|
211
210
|
return removeScrollListener;
|
|
212
211
|
}, [onScroll, removeScrollListener]);
|
|
213
|
-
|
|
212
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
214
213
|
if (!isMounted) {
|
|
215
214
|
return;
|
|
216
215
|
}
|
|
@@ -262,7 +261,7 @@ const useVirtualization = (props) => {
|
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
263
|
}, [scrollToIndex, isMounted]);
|
|
265
|
-
|
|
264
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
266
265
|
if (!scrollContainerHeight) {
|
|
267
266
|
return;
|
|
268
267
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns translate values as an array of a given element.
|
|
3
3
|
* @param element HTML element you want to get translate value of
|
|
4
|
-
* @returns Translate values in pixels in
|
|
4
|
+
* @returns Translate values in pixels in an array `[translateX, translateY]`
|
|
5
5
|
*/
|
|
6
6
|
export declare const getTranslateValues: (element: HTMLElement | null | undefined) => number[];
|
|
@@ -8,7 +8,7 @@ exports.getTranslateValues = void 0;
|
|
|
8
8
|
/**
|
|
9
9
|
* Returns translate values as an array of a given element.
|
|
10
10
|
* @param element HTML element you want to get translate value of
|
|
11
|
-
* @returns Translate values in pixels in
|
|
11
|
+
* @returns Translate values in pixels in an array `[translateX, translateY]`
|
|
12
12
|
*/
|
|
13
13
|
const getTranslateValues = (element) => {
|
|
14
14
|
if (!element) {
|
|
@@ -41,7 +41,7 @@ const useDragAndDrop = (elementRef, containerRef, enabled = true) => {
|
|
|
41
41
|
if (!elementRef.current || !enabled) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
const { top, right, bottom, left
|
|
44
|
+
const { top, right, bottom, left } = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
45
45
|
let [newTranslateX, newTranslateY] = (0, functions_1.getTranslateValues)(elementRef.current);
|
|
46
46
|
containerRectRef.current = getContainerRect(containerRef);
|
|
47
47
|
if (bottom > containerRectRef.current.bottom) {
|
|
@@ -11,6 +11,7 @@ exports.useOverflow = void 0;
|
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const useMergedRefs_1 = require("./useMergedRefs");
|
|
13
13
|
const useResizeObserver_1 = require("./useResizeObserver");
|
|
14
|
+
const useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
|
|
14
15
|
const STARTING_MAX_ITEMS_COUNT = 20;
|
|
15
16
|
/**
|
|
16
17
|
* Hook that observes the size of an element and returns the number of items
|
|
@@ -43,7 +44,7 @@ const useOverflow = (items, disabled = false, orientation = 'horizontal') => {
|
|
|
43
44
|
const updateContainerSize = react_1.default.useCallback(({ width, height }) => setContainerSize(orientation === 'horizontal' ? width : height), [orientation]);
|
|
44
45
|
const [resizeRef, observer] = (0, useResizeObserver_1.useResizeObserver)(updateContainerSize);
|
|
45
46
|
const resizeObserverRef = react_1.default.useRef(observer);
|
|
46
|
-
|
|
47
|
+
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(() => {
|
|
47
48
|
if (disabled) {
|
|
48
49
|
setVisibleCount(items.length);
|
|
49
50
|
}
|
|
@@ -53,7 +54,7 @@ const useOverflow = (items, disabled = false, orientation = 'horizontal') => {
|
|
|
53
54
|
}
|
|
54
55
|
}, [containerSize, disabled, items]);
|
|
55
56
|
const mergedRefs = (0, useMergedRefs_1.useMergedRefs)(containerRef, resizeRef);
|
|
56
|
-
|
|
57
|
+
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(() => {
|
|
57
58
|
var _a;
|
|
58
59
|
if (!containerRef.current || disabled) {
|
|
59
60
|
(_a = resizeObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
@@ -81,7 +82,7 @@ const useOverflow = (items, disabled = false, orientation = 'horizontal') => {
|
|
|
81
82
|
}
|
|
82
83
|
needsFullRerender.current = false;
|
|
83
84
|
}, [containerSize, visibleCount, disabled, items.length, orientation]);
|
|
84
|
-
|
|
85
|
+
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(() => {
|
|
85
86
|
previousContainerSize.current = containerSize;
|
|
86
87
|
}, [containerSize]);
|
|
87
88
|
return [mergedRefs, visibleCount];
|
|
@@ -28,8 +28,8 @@ const useTheme = (theme, themeOptions) => {
|
|
|
28
28
|
const themeContext = react_1.default.useContext(ThemeProvider_1.ThemeContext);
|
|
29
29
|
const ownerDocument = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.ownerDocument) !== null && _a !== void 0 ? _a : (0, functions_1.getDocument)();
|
|
30
30
|
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(() => {
|
|
31
|
-
// exit early if theme was already set by provider
|
|
32
|
-
if (themeContext || !ownerDocument) {
|
|
31
|
+
// exit early if theme was already set by provider or is present on <body>
|
|
32
|
+
if (themeContext || !ownerDocument || ownerDocument.body.dataset.iuiTheme) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
ownerDocument.body.classList.toggle('iui-root', true);
|