@itwin/itwinui-react 1.28.0 → 1.29.3
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 +27 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +1 -1
- package/cjs/core/Buttons/Button/Button.d.ts +6 -26
- package/cjs/core/Buttons/Button/Button.js +2 -2
- package/cjs/core/Buttons/DropdownButton/DropdownButton.d.ts +1 -1
- package/cjs/core/Buttons/IconButton/IconButton.d.ts +3 -8
- package/cjs/core/Buttons/IconButton/IconButton.js +2 -2
- package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +9 -7
- package/cjs/core/Buttons/SplitButton/SplitButton.js +7 -4
- package/cjs/core/Checkbox/Checkbox.js +2 -2
- package/cjs/core/ColorPicker/ColorInputPanel.js +2 -2
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/DatePicker/DatePicker.js +14 -15
- package/cjs/core/Header/HeaderButton.d.ts +6 -4
- package/cjs/core/Header/HeaderButton.js +3 -4
- package/cjs/core/LabeledInput/LabeledInput.d.ts +1 -1
- package/cjs/core/Modal/Modal.js +4 -1
- package/cjs/core/Radio/Radio.js +1 -1
- package/cjs/core/SideNavigation/SidenavButton.d.ts +3 -13
- package/cjs/core/Table/TablePaginator.js +11 -5
- package/cjs/core/Typography/Anchor/Anchor.d.ts +3 -0
- package/cjs/core/Typography/Anchor/Anchor.js +41 -0
- package/cjs/core/Typography/Anchor/index.d.ts +3 -0
- package/cjs/core/Typography/Anchor/index.js +10 -0
- package/cjs/core/Typography/Text/Text.d.ts +6 -10
- package/cjs/core/Typography/Text/Text.js +3 -4
- package/cjs/core/Typography/index.d.ts +1 -0
- package/cjs/core/Typography/index.js +3 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +2 -1
- package/cjs/core/utils/hooks/useTheme.js +20 -3
- package/cjs/core/utils/props.d.ts +29 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.js +1 -1
- package/esm/core/Buttons/Button/Button.d.ts +6 -26
- package/esm/core/Buttons/Button/Button.js +3 -3
- package/esm/core/Buttons/DropdownButton/DropdownButton.d.ts +1 -1
- package/esm/core/Buttons/IconButton/IconButton.d.ts +3 -8
- package/esm/core/Buttons/IconButton/IconButton.js +2 -2
- package/esm/core/Buttons/SplitButton/SplitButton.d.ts +9 -7
- package/esm/core/Buttons/SplitButton/SplitButton.js +7 -3
- package/esm/core/Checkbox/Checkbox.js +2 -2
- package/esm/core/ColorPicker/ColorInputPanel.js +2 -2
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/DatePicker/DatePicker.js +14 -15
- package/esm/core/Header/HeaderButton.d.ts +6 -4
- package/esm/core/Header/HeaderButton.js +3 -3
- package/esm/core/LabeledInput/LabeledInput.d.ts +1 -1
- package/esm/core/Modal/Modal.js +4 -1
- package/esm/core/Radio/Radio.js +1 -1
- package/esm/core/SideNavigation/SidenavButton.d.ts +3 -13
- package/esm/core/Table/TablePaginator.js +11 -5
- package/esm/core/Typography/Anchor/Anchor.d.ts +3 -0
- package/esm/core/Typography/Anchor/Anchor.js +35 -0
- package/esm/core/Typography/Anchor/index.d.ts +3 -0
- package/esm/core/Typography/Anchor/index.js +6 -0
- package/esm/core/Typography/Text/Text.d.ts +6 -10
- package/esm/core/Typography/Text/Text.js +4 -4
- package/esm/core/Typography/index.d.ts +1 -0
- package/esm/core/Typography/index.js +1 -0
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/utils/hooks/useTheme.js +20 -3
- package/esm/core/utils/props.d.ts +29 -1
- package/package.json +9 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PolymorphicForwardRefComponent } from '../utils';
|
|
2
2
|
import { ButtonProps } from '../Buttons';
|
|
3
3
|
import '@itwin/itwinui-css/css/side-navigation.css';
|
|
4
4
|
export declare type SidenavButtonProps = {
|
|
@@ -13,20 +13,10 @@ export declare type SidenavButtonProps = {
|
|
|
13
13
|
*/
|
|
14
14
|
isSubmenuOpen?: boolean;
|
|
15
15
|
} & Omit<ButtonProps, 'styleType' | 'size'>;
|
|
16
|
+
declare type SideNavButtonComponent = PolymorphicForwardRefComponent<'button', SidenavButtonProps>;
|
|
16
17
|
/**
|
|
17
18
|
* Wrapper around Button to be used as SideNavigation items.
|
|
18
19
|
* Label is hidden when sidenav is collapsed.
|
|
19
20
|
*/
|
|
20
|
-
export declare const SidenavButton:
|
|
21
|
-
/**
|
|
22
|
-
* Whether the sidenav button is active,
|
|
23
|
-
* i.e. the current page corresponds to this button.
|
|
24
|
-
*/
|
|
25
|
-
isActive?: boolean | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Whether the sidenav button only has submenu open,
|
|
28
|
-
* i.e. submenu is open but the current page does not correspond to this button.
|
|
29
|
-
*/
|
|
30
|
-
isSubmenuOpen?: boolean | undefined;
|
|
31
|
-
} & Omit<ButtonProps, "size" | "styleType"> & React.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
export declare const SidenavButton: SideNavButtonComponent;
|
|
32
22
|
export default SidenavButton;
|
|
@@ -29,7 +29,6 @@ import cx from 'classnames';
|
|
|
29
29
|
import '@itwin/itwinui-css/css/table.css';
|
|
30
30
|
import SvgChevronLeft from '@itwin/itwinui-icons-react/cjs/icons/ChevronLeft';
|
|
31
31
|
import SvgChevronRight from '@itwin/itwinui-icons-react/cjs/icons/ChevronRight';
|
|
32
|
-
import { ButtonGroup } from '../ButtonGroup';
|
|
33
32
|
import { IconButton, Button, DropdownButton } from '../Buttons';
|
|
34
33
|
import { ProgressRadial } from '../ProgressIndicators';
|
|
35
34
|
import { MenuItem } from '../Menu';
|
|
@@ -71,7 +70,7 @@ export var TablePaginator = function (props) {
|
|
|
71
70
|
// Checking `isMounted.current` prevents from focusing on initial load.
|
|
72
71
|
// Checking `needFocus.current` prevents from focusing page when clicked on previous/next page.
|
|
73
72
|
if (isMounted.current && needFocus.current) {
|
|
74
|
-
var buttonToFocus = Array.from((_b = (_a = pageListRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.iui-button')) !== null && _b !== void 0 ? _b : []).find(function (el) { var _a; return ((_a = el.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === (focusedIndex + 1).toString(); });
|
|
73
|
+
var buttonToFocus = Array.from((_b = (_a = pageListRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.iui-paginator-page-button')) !== null && _b !== void 0 ? _b : []).find(function (el) { var _a; return ((_a = el.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === (focusedIndex + 1).toString(); });
|
|
75
74
|
(_c = buttonToFocus) === null || _c === void 0 ? void 0 : _c.focus();
|
|
76
75
|
needFocus.current = false;
|
|
77
76
|
}
|
|
@@ -80,7 +79,11 @@ export var TablePaginator = function (props) {
|
|
|
80
79
|
var buttonSize = size != 'default' ? 'small' : undefined;
|
|
81
80
|
var pageButton = React.useCallback(function (index, tabIndex) {
|
|
82
81
|
if (tabIndex === void 0) { tabIndex = index === focusedIndex ? 0 : -1; }
|
|
83
|
-
return (React.createElement(
|
|
82
|
+
return (React.createElement("div", { key: index },
|
|
83
|
+
React.createElement("button", { className: cx('iui-paginator-page-button', {
|
|
84
|
+
'iui-active': index === currentPage,
|
|
85
|
+
'iui-paginator-page-button-small': buttonSize === 'small',
|
|
86
|
+
}), onClick: function () { return onPageChange(index); }, "aria-current": index === currentPage, "aria-label": localization.goToPageLabel(index + 1), tabIndex: tabIndex }, index + 1)));
|
|
84
87
|
}, [focusedIndex, currentPage, localization, buttonSize, onPageChange]);
|
|
85
88
|
var totalPagesCount = Math.ceil(totalRowsCount / pageSize);
|
|
86
89
|
var pageList = React.useMemo(function () {
|
|
@@ -142,7 +145,10 @@ export var TablePaginator = function (props) {
|
|
|
142
145
|
var hasNoRows = totalPagesCount === 0;
|
|
143
146
|
var showPagesList = totalPagesCount > 1 || isLoading;
|
|
144
147
|
var showPageSizeList = pageSizeList && onPageSizeChange && !!totalRowsCount;
|
|
145
|
-
var ellipsis = (React.createElement("
|
|
148
|
+
var ellipsis = (React.createElement("div", null,
|
|
149
|
+
React.createElement("span", { className: cx('iui-paginator-ellipsis', {
|
|
150
|
+
'iui-paginator-ellipsis-small': size === 'small',
|
|
151
|
+
}) }, "\u2026")));
|
|
146
152
|
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"))));
|
|
147
153
|
if (!showPagesList && !showPageSizeList) {
|
|
148
154
|
return null;
|
|
@@ -152,7 +158,7 @@ export var TablePaginator = function (props) {
|
|
|
152
158
|
showPagesList && (React.createElement("div", { className: 'iui-center', ref: overflowRef },
|
|
153
159
|
React.createElement(IconButton, { styleType: 'borderless', disabled: currentPage === 0, onClick: function () { return onPageChange(currentPage - 1); }, size: buttonSize, "aria-label": localization.previousPage },
|
|
154
160
|
React.createElement(SvgChevronLeft, null)),
|
|
155
|
-
React.createElement(
|
|
161
|
+
React.createElement("span", { className: 'iui-paginator-pages-group', onKeyDown: onKeyDown, ref: pageListRef }, (function () {
|
|
156
162
|
if (hasNoRows) {
|
|
157
163
|
return noRowsContent;
|
|
158
164
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const Anchor: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>> & React.RefAttributes<HTMLAnchorElement>>;
|
|
3
|
+
export default Anchor;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 cx from 'classnames';
|
|
29
|
+
import { useTheme } from '../../utils';
|
|
30
|
+
export var Anchor = React.forwardRef(function (_a, ref) {
|
|
31
|
+
var className = _a.className, rest = __rest(_a, ["className"]);
|
|
32
|
+
useTheme();
|
|
33
|
+
return React.createElement("a", __assign({ className: cx('iui-anchor', className), ref: ref }, rest));
|
|
34
|
+
});
|
|
35
|
+
export default Anchor;
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
export { Anchor } from './Anchor';
|
|
6
|
+
export default './Anchor';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { PolymorphicComponentProps, PolymorphicForwardRefComponent } from '../../utils';
|
|
3
3
|
import '@itwin/itwinui-css/css/text.css';
|
|
4
|
-
declare type TextOwnProps
|
|
5
|
-
/**
|
|
6
|
-
* What element should the text be rendered as?
|
|
7
|
-
* @default 'div'
|
|
8
|
-
*/
|
|
9
|
-
as?: T;
|
|
4
|
+
declare type TextOwnProps = {
|
|
10
5
|
/**
|
|
11
6
|
* Which typography variant/size should be used for the styling?
|
|
12
7
|
*
|
|
@@ -30,8 +25,9 @@ declare type TextOwnProps<T extends React.ElementType | React.ComponentType = 'd
|
|
|
30
25
|
* @default false
|
|
31
26
|
*/
|
|
32
27
|
isSkeleton?: boolean;
|
|
33
|
-
}
|
|
34
|
-
export declare type TextProps<T extends React.ElementType
|
|
28
|
+
};
|
|
29
|
+
export declare type TextProps<T extends React.ElementType = 'div'> = PolymorphicComponentProps<T, TextOwnProps>;
|
|
30
|
+
declare type TextComponent = PolymorphicForwardRefComponent<'div', TextOwnProps>;
|
|
35
31
|
/**
|
|
36
32
|
* Polymorphic typography component to render any kind of text as any kind of element.
|
|
37
33
|
* @example
|
|
@@ -42,5 +38,5 @@ export declare type TextProps<T extends React.ElementType | React.ComponentType
|
|
|
42
38
|
* <Text isMuted>Some muted text.</Text>
|
|
43
39
|
* <Text isSkeleton>Skeleton text</Text>
|
|
44
40
|
*/
|
|
45
|
-
export declare const Text:
|
|
41
|
+
export declare const Text: TextComponent;
|
|
46
42
|
export default Text;
|
|
@@ -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 } from '../../utils';
|
|
29
|
+
import { useTheme, } from '../../utils';
|
|
30
30
|
import '@itwin/itwinui-css/css/text.css';
|
|
31
31
|
/**
|
|
32
32
|
* Polymorphic typography component to render any kind of text as any kind of element.
|
|
@@ -38,7 +38,7 @@ import '@itwin/itwinui-css/css/text.css';
|
|
|
38
38
|
* <Text isMuted>Some muted text.</Text>
|
|
39
39
|
* <Text isSkeleton>Skeleton text</Text>
|
|
40
40
|
*/
|
|
41
|
-
export var Text = function (props) {
|
|
41
|
+
export var Text = React.forwardRef(function (props, ref) {
|
|
42
42
|
var _a;
|
|
43
43
|
var _b = props.variant, variant = _b === void 0 ? 'body' : _b, _c = props.as, Element = _c === void 0 ? 'div' : _c, className = props.className, _d = props.isMuted, isMuted = _d === void 0 ? false : _d, _e = props.isSkeleton, isSkeleton = _e === void 0 ? false : _e, rest = __rest(props, ["variant", "as", "className", "isMuted", "isSkeleton"]);
|
|
44
44
|
useTheme();
|
|
@@ -47,6 +47,6 @@ export var Text = function (props) {
|
|
|
47
47
|
_a['iui-text-block'] = variant === 'body',
|
|
48
48
|
_a['iui-text-muted'] = isMuted,
|
|
49
49
|
_a['iui-skeleton'] = isSkeleton,
|
|
50
|
-
_a), className) }, rest)));
|
|
51
|
-
};
|
|
50
|
+
_a), className), ref: ref }, rest)));
|
|
51
|
+
});
|
|
52
52
|
export default Text;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export { Anchor } from './Anchor';
|
|
5
6
|
export { Headline } from './Headline';
|
|
6
7
|
export { Title } from './Title';
|
|
7
8
|
export { Subheading } from './Subheading';
|
package/esm/core/index.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export { ToggleSwitch } from './ToggleSwitch';
|
|
|
80
80
|
export type { ToggleSwitchProps } from './ToggleSwitch';
|
|
81
81
|
export { Tooltip } from './Tooltip';
|
|
82
82
|
export type { TooltipProps } from './Tooltip';
|
|
83
|
-
export { Body, Headline, Leading, Small, Subheading, Title, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography';
|
|
83
|
+
export { Anchor, Body, Headline, Leading, Small, Subheading, Title, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography';
|
|
84
84
|
export type { BodyProps, HeadlineProps, LeadingProps, SmallProps, SubheadingProps, TitleProps, BlockquoteProps, CodeProps, KbdProps, TextProps, } from './Typography';
|
|
85
85
|
export { UserIcon } from './UserIcon';
|
|
86
86
|
export type { UserIconProps, StatusTitles, UserIconStatus } from './UserIcon';
|
package/esm/core/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export { default as toaster } from './Toast';
|
|
|
43
43
|
export { ThemeProvider } from './ThemeProvider';
|
|
44
44
|
export { ToggleSwitch } from './ToggleSwitch';
|
|
45
45
|
export { Tooltip } from './Tooltip';
|
|
46
|
-
export { Body, Headline, Leading, Small, Subheading, Title, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography';
|
|
46
|
+
export { Anchor, Body, Headline, Leading, Small, Subheading, Title, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography';
|
|
47
47
|
export { UserIcon } from './UserIcon';
|
|
48
48
|
export { UserIconGroup } from './UserIconGroup';
|
|
49
49
|
export { Wizard } from './Wizard';
|
|
@@ -20,20 +20,33 @@ export var useTheme = function (theme, themeOptions) {
|
|
|
20
20
|
}
|
|
21
21
|
}, [ownerDocument]);
|
|
22
22
|
React.useLayoutEffect(function () {
|
|
23
|
-
var _a, _b;
|
|
23
|
+
var _a, _b, _c, _d, _e;
|
|
24
24
|
if (!ownerDocument) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
+
var prefersDarkMediaQuery = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.matchMedia) === null || _b === void 0 ? void 0 : _b.call(_a, '(prefers-color-scheme: dark)');
|
|
28
|
+
var addOSTheme = function (_a) {
|
|
29
|
+
var isDark = _a.matches;
|
|
30
|
+
if (isDark) {
|
|
31
|
+
addDarkTheme(ownerDocument);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
addLightTheme(ownerDocument);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
27
37
|
switch (theme) {
|
|
28
38
|
case 'light':
|
|
39
|
+
(_c = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
29
40
|
addLightTheme(ownerDocument);
|
|
30
41
|
break;
|
|
31
42
|
case 'dark':
|
|
43
|
+
(_d = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _d === void 0 ? void 0 : _d.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
32
44
|
addDarkTheme(ownerDocument);
|
|
33
45
|
break;
|
|
34
46
|
case 'os':
|
|
35
|
-
if (
|
|
36
|
-
|
|
47
|
+
if (prefersDarkMediaQuery != undefined) {
|
|
48
|
+
addOSTheme(prefersDarkMediaQuery);
|
|
49
|
+
(_e = prefersDarkMediaQuery.addEventListener) === null || _e === void 0 ? void 0 : _e.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
37
50
|
}
|
|
38
51
|
else {
|
|
39
52
|
addLightTheme(ownerDocument);
|
|
@@ -44,6 +57,10 @@ export var useTheme = function (theme, themeOptions) {
|
|
|
44
57
|
addLightTheme(ownerDocument);
|
|
45
58
|
}
|
|
46
59
|
}
|
|
60
|
+
return function () {
|
|
61
|
+
var _a;
|
|
62
|
+
(_a = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
63
|
+
};
|
|
47
64
|
}, [ownerDocument, theme]);
|
|
48
65
|
};
|
|
49
66
|
var addLightTheme = function (ownerDocument) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare type ClassNameProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Custom CSS class name.
|
|
@@ -21,3 +21,31 @@ export declare type CommonProps = {
|
|
|
21
21
|
*/
|
|
22
22
|
id?: string;
|
|
23
23
|
} & StylingProps;
|
|
24
|
+
/**
|
|
25
|
+
* Merges provided Props with the props of T.
|
|
26
|
+
*
|
|
27
|
+
* T can be any native HTML element or a custom component.
|
|
28
|
+
*/
|
|
29
|
+
export declare type PolymorphicComponentProps<T extends React.ElementType, Props = Record<string, unknown>> = Merge<React.ComponentPropsWithoutRef<T>, Props>;
|
|
30
|
+
/**
|
|
31
|
+
* Makes `as` prop available and merges original OwnProps and the inferred props from `as` element.
|
|
32
|
+
* Extends ForwardRefExoticComponent so ref gets the correct type.
|
|
33
|
+
*
|
|
34
|
+
* T should be the default element that is used for the `as` prop.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* type ButtonComponent = PolymorphicForwardRefComponent<'button', ButtonOwnProps>;
|
|
38
|
+
* ...
|
|
39
|
+
* const Button: ButtonComponent = React.forwardRef((props, ref) => {});
|
|
40
|
+
*/
|
|
41
|
+
export interface PolymorphicForwardRefComponent<T, OwnProps = Record<string, unknown>> extends React.ForwardRefExoticComponent<Merge<T extends React.ElementType ? React.ComponentPropsWithRef<T> : never, OwnProps & {
|
|
42
|
+
as?: T;
|
|
43
|
+
}>> {
|
|
44
|
+
<As = T>(props: As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
45
|
+
as: As;
|
|
46
|
+
}> : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
47
|
+
as: As;
|
|
48
|
+
}> : never): React.ReactElement | null;
|
|
49
|
+
}
|
|
50
|
+
declare type Merge<P1, P2> = Omit<P1, keyof P2> & P2;
|
|
51
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.3",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"build-storybook": "build-storybook"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@itwin/itwinui-css": "^0.
|
|
44
|
-
"@itwin/itwinui-icons-react": "^1.
|
|
43
|
+
"@itwin/itwinui-css": "^0.44.1",
|
|
44
|
+
"@itwin/itwinui-icons-react": "^1.5.0",
|
|
45
45
|
"@itwin/itwinui-illustrations-react": "^1.0.1",
|
|
46
46
|
"@tippyjs/react": "^4.2.5",
|
|
47
47
|
"@types/react-table": "^7.0.18",
|
|
@@ -55,8 +55,10 @@
|
|
|
55
55
|
"@storybook/addon-storysource": "~6.3.6",
|
|
56
56
|
"@storybook/addons": "~6.3.6",
|
|
57
57
|
"@storybook/api": "~6.3.6",
|
|
58
|
+
"@storybook/builder-webpack5": "~6.3.6",
|
|
58
59
|
"@storybook/components": "~6.3.6",
|
|
59
60
|
"@storybook/core-events": "~6.3.6",
|
|
61
|
+
"@storybook/manager-webpack5": "~6.3.6",
|
|
60
62
|
"@storybook/preset-typescript": "^3.0.0",
|
|
61
63
|
"@storybook/react": "~6.3.6",
|
|
62
64
|
"@storybook/theming": "~6.3.6",
|
|
@@ -100,7 +102,7 @@
|
|
|
100
102
|
"ts-loader": "^8.0.1",
|
|
101
103
|
"ts-node": "^8.0.2",
|
|
102
104
|
"typescript": "^4.4.3",
|
|
103
|
-
"webpack": "
|
|
105
|
+
"webpack": "5"
|
|
104
106
|
},
|
|
105
107
|
"peerDependencies": {
|
|
106
108
|
"react": "^16.8.6 || ^17.0.0",
|
|
@@ -118,7 +120,9 @@
|
|
|
118
120
|
"prismjs": "^1.25.0",
|
|
119
121
|
"nth-check": "^2.0.1",
|
|
120
122
|
"ansi-regex": "^5.0.1",
|
|
121
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1"
|
|
123
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
124
|
+
"postcss": "8",
|
|
125
|
+
"nanoid": "^3.1.31"
|
|
122
126
|
},
|
|
123
127
|
"husky": {
|
|
124
128
|
"hooks": {
|