@itwin/itwinui-react 1.28.0 → 1.29.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.
- package/CHANGELOG.md +8 -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/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 +31 -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/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 +31 -1
- package/package.json +8 -5
|
@@ -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,33 @@ 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 '' ? {
|
|
45
|
+
as: keyof JSX.IntrinsicElements;
|
|
46
|
+
} : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
47
|
+
as: As;
|
|
48
|
+
}> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
49
|
+
as: As;
|
|
50
|
+
}> : never): React.ReactElement | null;
|
|
51
|
+
}
|
|
52
|
+
declare type Merge<P1, P2> = Omit<P1, keyof P2> & P2;
|
|
53
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
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.0",
|
|
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,8 @@
|
|
|
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"
|
|
122
125
|
},
|
|
123
126
|
"husky": {
|
|
124
127
|
"hooks": {
|