@itwin/itwinui-react 2.6.0 → 2.7.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 +43 -0
- package/cjs/core/Badge/Badge.d.ts +1 -1
- package/cjs/core/Badge/Badge.js +14 -15
- package/cjs/core/Carousel/Carousel.js +3 -2
- package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
- package/cjs/core/DatePicker/DatePicker.js +26 -7
- package/cjs/core/Slider/Thumb.js +2 -4
- package/cjs/core/Tabs/Tabs.js +3 -1
- package/cjs/core/Tile/Tile.d.ts +24 -2
- package/cjs/core/Tile/Tile.js +85 -50
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +11 -31
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +8 -1
- package/cjs/core/index.d.ts +2 -2
- package/cjs/core/index.js +3 -1
- package/cjs/core/utils/components/LinkAction.d.ts +30 -0
- package/cjs/core/utils/components/LinkAction.js +44 -0
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useIsClient.d.ts +1 -0
- package/cjs/core/utils/hooks/useIsClient.js +19 -0
- package/cjs/core/utils/hooks/useTheme.js +5 -0
- package/esm/core/Badge/Badge.d.ts +1 -1
- package/esm/core/Badge/Badge.js +14 -15
- package/esm/core/Carousel/Carousel.js +3 -2
- package/esm/core/DatePicker/DatePicker.d.ts +5 -0
- package/esm/core/DatePicker/DatePicker.js +26 -7
- package/esm/core/Slider/Thumb.js +2 -4
- package/esm/core/Tabs/Tabs.js +4 -2
- package/esm/core/Tile/Tile.d.ts +24 -2
- package/esm/core/Tile/Tile.js +84 -49
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +11 -31
- package/esm/core/ToggleSwitch/ToggleSwitch.js +8 -1
- package/esm/core/index.d.ts +2 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/components/LinkAction.d.ts +30 -0
- package/esm/core/utils/components/LinkAction.js +38 -0
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useIsClient.d.ts +1 -0
- package/esm/core/utils/hooks/useIsClient.js +12 -0
- package/esm/core/utils/hooks/useTheme.js +5 -0
- package/package.json +2 -2
|
@@ -15,16 +15,20 @@ export declare type ToggleSwitchProps = {
|
|
|
15
15
|
* @default false
|
|
16
16
|
*/
|
|
17
17
|
setFocus?: boolean;
|
|
18
|
-
|
|
19
|
-
* Icon inside the toggle switch. Shown only when toggle is checked.
|
|
20
|
-
*/
|
|
21
|
-
icon?: JSX.Element;
|
|
18
|
+
} & ({
|
|
22
19
|
/**
|
|
23
20
|
* Size of the toggle switch.
|
|
24
21
|
* @default 'default'
|
|
25
22
|
*/
|
|
26
|
-
size?: 'default'
|
|
27
|
-
|
|
23
|
+
size?: 'default';
|
|
24
|
+
/**
|
|
25
|
+
* Icon inside the toggle switch. Shown only when toggle is checked and size is not small.
|
|
26
|
+
*/
|
|
27
|
+
icon?: JSX.Element;
|
|
28
|
+
} | {
|
|
29
|
+
size: 'small';
|
|
30
|
+
icon?: never;
|
|
31
|
+
}) & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'>;
|
|
28
32
|
/**
|
|
29
33
|
* A switch for turning on and off.
|
|
30
34
|
* @example
|
|
@@ -43,29 +47,5 @@ export declare type ToggleSwitchProps = {
|
|
|
43
47
|
* <caption>Toggle with icon</caption>
|
|
44
48
|
* <ToggleSwitch label='With icon toggle' icon={<svg viewBox='0 0 16 16'><path d='M1 1v14h14V1H1zm13 1.7v10.6L8.7 8 14 2.7zM8 7.3L2.7 2h10.6L8 7.3zm-.7.7L2 13.3V2.7L7.3 8zm.7.7l5.3 5.3H2.7L8 8.7z' /></svg>} />
|
|
45
49
|
*/
|
|
46
|
-
export declare const ToggleSwitch: React.ForwardRefExoticComponent<
|
|
47
|
-
/**
|
|
48
|
-
* Label for the toggle switch.
|
|
49
|
-
*/
|
|
50
|
-
label?: React.ReactNode;
|
|
51
|
-
/**
|
|
52
|
-
* Position of the label.
|
|
53
|
-
* @default 'right'
|
|
54
|
-
*/
|
|
55
|
-
labelPosition?: "right" | "left" | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Set focus on toggle.
|
|
58
|
-
* @default false
|
|
59
|
-
*/
|
|
60
|
-
setFocus?: boolean | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Icon inside the toggle switch. Shown only when toggle is checked.
|
|
63
|
-
*/
|
|
64
|
-
icon?: JSX.Element | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Size of the toggle switch.
|
|
67
|
-
* @default 'default'
|
|
68
|
-
*/
|
|
69
|
-
size?: "small" | "default" | undefined;
|
|
70
|
-
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & React.RefAttributes<HTMLInputElement>>;
|
|
50
|
+
export declare const ToggleSwitch: React.ForwardRefExoticComponent<ToggleSwitchProps & React.RefAttributes<HTMLInputElement>>;
|
|
71
51
|
export default ToggleSwitch;
|
|
@@ -25,7 +25,13 @@ import '@itwin/itwinui-css/css/toggle-switch.css';
|
|
|
25
25
|
* <ToggleSwitch label='With icon toggle' icon={<svg viewBox='0 0 16 16'><path d='M1 1v14h14V1H1zm13 1.7v10.6L8.7 8 14 2.7zM8 7.3L2.7 2h10.6L8 7.3zm-.7.7L2 13.3V2.7L7.3 8zm.7.7l5.3 5.3H2.7L8 8.7z' /></svg>} />
|
|
26
26
|
*/
|
|
27
27
|
export const ToggleSwitch = React.forwardRef((props, ref) => {
|
|
28
|
-
|
|
28
|
+
let icon;
|
|
29
|
+
if (props.size !== 'small') {
|
|
30
|
+
icon = props.icon;
|
|
31
|
+
props = { ...props };
|
|
32
|
+
delete props.icon;
|
|
33
|
+
}
|
|
34
|
+
const { disabled = false, labelPosition = 'right', label, setFocus = false, className, style, size = 'default', ...rest } = props;
|
|
29
35
|
useTheme();
|
|
30
36
|
const inputElementRef = React.useRef(null);
|
|
31
37
|
const refs = useMergedRefs(inputElementRef, ref);
|
|
@@ -42,6 +48,7 @@ export const ToggleSwitch = React.forwardRef((props, ref) => {
|
|
|
42
48
|
}, className), "data-iui-size": size, style: style },
|
|
43
49
|
React.createElement("input", { className: 'iui-toggle-switch', type: 'checkbox', role: 'switch', disabled: disabled, ref: refs, ...rest }),
|
|
44
50
|
icon &&
|
|
51
|
+
size !== 'small' &&
|
|
45
52
|
React.cloneElement(icon, {
|
|
46
53
|
className: cx('iui-toggle-switch-icon', icon.props.className),
|
|
47
54
|
'aria-hidden': true,
|
package/esm/core/index.d.ts
CHANGED
|
@@ -104,5 +104,5 @@ export { Anchor, Body, Headline, Leading, Small, Subheading, Title, Blockquote,
|
|
|
104
104
|
export type { AnchorProps, BodyProps, HeadlineProps, LeadingProps, SmallProps, SubheadingProps, TitleProps, BlockquoteProps, CodeProps, KbdProps, TextProps, } from './Typography';
|
|
105
105
|
export { Wizard, Stepper, WorkflowDiagram } from './Stepper';
|
|
106
106
|
export type { WizardProps, StepProperties, WizardType, WizardLocalization, StepperProps, StepperLocalization, WorkflowDiagramProps, } from './Stepper';
|
|
107
|
-
export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, Icon, Flex, } from './utils';
|
|
108
|
-
export type { ThemeType, MiddleTextTruncationProps, IconProps, FlexProps, FlexItemProps, FlexSpacerProps, } from './utils';
|
|
107
|
+
export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, } from './utils';
|
|
108
|
+
export type { ThemeType, MiddleTextTruncationProps, IconProps, FlexProps, FlexItemProps, FlexSpacerProps, LinkBoxProps, LinkActionProps, } from './utils';
|
package/esm/core/index.js
CHANGED
|
@@ -55,4 +55,4 @@ export { Tooltip } from './Tooltip';
|
|
|
55
55
|
export { Tree, TreeNode, TreeNodeExpander } from './Tree';
|
|
56
56
|
export { Anchor, Body, Headline, Leading, Small, Subheading, Title, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography';
|
|
57
57
|
export { Wizard, Stepper, WorkflowDiagram } from './Stepper';
|
|
58
|
-
export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, Icon, Flex, } from './utils';
|
|
58
|
+
export { getUserColor, useTheme, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, } from './utils';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PolymorphicComponentProps, PolymorphicForwardRefComponent } from '../props';
|
|
2
|
+
import '@itwin/itwinui-css/css/utils.css';
|
|
3
|
+
declare type LinkActionOwnProps = {};
|
|
4
|
+
declare type LinkBoxOwnProps = {};
|
|
5
|
+
export declare type LinkActionProps = PolymorphicComponentProps<'a', LinkActionOwnProps>;
|
|
6
|
+
export declare type LinkBoxProps = PolymorphicComponentProps<'div', LinkBoxOwnProps>;
|
|
7
|
+
/**
|
|
8
|
+
* Polymorphic link action component.
|
|
9
|
+
* It is rendered as `a` by default.
|
|
10
|
+
* @example
|
|
11
|
+
* <LinkBox>
|
|
12
|
+
* <Surface>
|
|
13
|
+
* <LinkAction href='/new-page'>Whole card is clickable</LinkAction>
|
|
14
|
+
* </Surface>
|
|
15
|
+
* </LinkBox>
|
|
16
|
+
*/
|
|
17
|
+
export declare const LinkAction: PolymorphicForwardRefComponent<"a", LinkActionOwnProps>;
|
|
18
|
+
/**
|
|
19
|
+
* Polymorphic link box component.
|
|
20
|
+
* Used to wrap around your component to use LinkAction.
|
|
21
|
+
* Rendered as `div` by default
|
|
22
|
+
* @example
|
|
23
|
+
* <LinkBox>
|
|
24
|
+
* <Surface>
|
|
25
|
+
* <LinkAction href='/new-page'>Whole card is clickable</LinkAction>
|
|
26
|
+
* </Surface>
|
|
27
|
+
* </LinkBox>
|
|
28
|
+
*/
|
|
29
|
+
export declare const LinkBox: PolymorphicForwardRefComponent<"div", LinkBoxOwnProps>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 cx from 'classnames';
|
|
7
|
+
import '@itwin/itwinui-css/css/utils.css';
|
|
8
|
+
/**
|
|
9
|
+
* Polymorphic link action component.
|
|
10
|
+
* It is rendered as `a` by default.
|
|
11
|
+
* @example
|
|
12
|
+
* <LinkBox>
|
|
13
|
+
* <Surface>
|
|
14
|
+
* <LinkAction href='/new-page'>Whole card is clickable</LinkAction>
|
|
15
|
+
* </Surface>
|
|
16
|
+
* </LinkBox>
|
|
17
|
+
*/
|
|
18
|
+
export const LinkAction = React.forwardRef((props, ref) => {
|
|
19
|
+
const { as: Element = 'a', className, ...rest } = props;
|
|
20
|
+
return (React.createElement(Element, { ref: ref, className: cx('iui-link-action', className), ...rest }));
|
|
21
|
+
});
|
|
22
|
+
LinkAction.displayName = 'LinkAction';
|
|
23
|
+
/**
|
|
24
|
+
* Polymorphic link box component.
|
|
25
|
+
* Used to wrap around your component to use LinkAction.
|
|
26
|
+
* Rendered as `div` by default
|
|
27
|
+
* @example
|
|
28
|
+
* <LinkBox>
|
|
29
|
+
* <Surface>
|
|
30
|
+
* <LinkAction href='/new-page'>Whole card is clickable</LinkAction>
|
|
31
|
+
* </Surface>
|
|
32
|
+
* </LinkBox>
|
|
33
|
+
*/
|
|
34
|
+
export const LinkBox = React.forwardRef((props, ref) => {
|
|
35
|
+
const { as: Element = 'div', className, ...rest } = props;
|
|
36
|
+
return (React.createElement(Element, { ref: ref, className: cx('iui-link-box', className), ...rest }));
|
|
37
|
+
});
|
|
38
|
+
LinkBox.displayName = 'LinkBox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsClient: () => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
export const useIsClient = () => {
|
|
7
|
+
const [isClient, setIsClient] = React.useState(false);
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
setIsClient(true);
|
|
10
|
+
}, []);
|
|
11
|
+
return isClient;
|
|
12
|
+
};
|
|
@@ -24,6 +24,11 @@ export const useTheme = (theme, themeOptions) => {
|
|
|
24
24
|
if (!ownerDocument || isThemeAlreadySet.current) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
+
// do nothing if using v1 for the main page (incremental migration)
|
|
28
|
+
if (ownerDocument.documentElement.className.includes('iui-theme-') ||
|
|
29
|
+
ownerDocument.body.classList.contains('iui-body')) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
ownerDocument.body.classList.toggle('iui-root', true);
|
|
28
33
|
switch (theme) {
|
|
29
34
|
case 'light':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"dev:types": "concurrently \"tsc -p tsconfig.cjs.json --emitDeclarationOnly --watch --preserveWatchOutput\" \"tsc -p tsconfig.esm.json --emitDeclarationOnly --watch --preserveWatchOutput\""
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@itwin/itwinui-css": "^1.
|
|
65
|
+
"@itwin/itwinui-css": "^1.8.0",
|
|
66
66
|
"@itwin/itwinui-illustrations-react": "^2.0.0",
|
|
67
67
|
"@itwin/itwinui-variables": "^2.0.0",
|
|
68
68
|
"@tippyjs/react": "^4.2.6",
|