@itwin/itwinui-react 3.4.2 → 3.6.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 +46 -0
- package/cjs/core/Carousel/Carousel.d.ts +4 -4
- package/cjs/core/Carousel/CarouselNavigation.d.ts +4 -4
- package/cjs/core/Dialog/Dialog.js +19 -17
- package/cjs/core/Dialog/DialogContext.d.ts +4 -0
- package/cjs/core/Dialog/DialogMain.js +1 -1
- package/cjs/core/Dialog/DialogTitleBar.js +1 -1
- package/cjs/core/InputGroup/InputGroup.d.ts +4 -0
- package/cjs/core/InputGroup/InputGroup.js +20 -4
- package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +18 -62
- package/cjs/core/InputWithDecorations/InputWithDecorations.js +21 -6
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +376 -4
- package/cjs/core/LabeledSelect/LabeledSelect.js +1 -1
- package/cjs/core/Popover/Popover.d.ts +6 -3
- package/cjs/core/ProgressIndicators/ProgressLinear.js +6 -1
- package/cjs/core/ProgressIndicators/ProgressRadial.js +8 -3
- package/cjs/core/SearchBox/SearchBox.js +4 -6
- package/cjs/core/Select/Select.d.ts +197 -102
- package/cjs/core/Select/Select.js +72 -19
- package/cjs/core/Table/Table.js +2 -1
- package/cjs/core/Tabs/Tabs.js +19 -3
- package/cjs/core/Tile/Tile.d.ts +2 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +4 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +5 -11
- package/cjs/core/Typography/Anchor.d.ts +21 -1
- package/cjs/core/Typography/Anchor.js +38 -3
- package/cjs/core/VisuallyHidden/VisuallyHidden.js +19 -3
- package/cjs/core/utils/components/InputFlexContainer.d.ts +25 -0
- package/cjs/core/utils/components/InputFlexContainer.js +19 -1
- package/cjs/core/utils/components/LineClamp.d.ts +5 -0
- package/cjs/core/utils/components/LineClamp.js +49 -0
- package/cjs/core/utils/components/ShadowRoot.d.ts +2 -1
- package/cjs/core/utils/components/ShadowRoot.js +19 -4
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/cjs/core/utils/functions/polymorphic.d.ts +5 -3
- package/cjs/core/utils/functions/polymorphic.js +20 -5
- package/cjs/core/utils/icons/Svg.js +5 -1
- package/cjs/core/utils/icons/SvgStatusError.js +1 -1
- package/esm/core/Carousel/Carousel.d.ts +4 -4
- package/esm/core/Carousel/CarouselNavigation.d.ts +4 -4
- package/esm/core/Dialog/Dialog.js +19 -17
- package/esm/core/Dialog/DialogContext.d.ts +4 -0
- package/esm/core/Dialog/DialogMain.js +1 -1
- package/esm/core/Dialog/DialogTitleBar.js +1 -1
- package/esm/core/InputGroup/InputGroup.d.ts +4 -0
- package/esm/core/InputGroup/InputGroup.js +20 -4
- package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +18 -62
- package/esm/core/InputWithDecorations/InputWithDecorations.js +22 -7
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +376 -4
- package/esm/core/LabeledSelect/LabeledSelect.js +1 -1
- package/esm/core/Popover/Popover.d.ts +6 -3
- package/esm/core/ProgressIndicators/ProgressLinear.js +7 -2
- package/esm/core/ProgressIndicators/ProgressRadial.js +9 -4
- package/esm/core/SearchBox/SearchBox.js +5 -7
- package/esm/core/Select/Select.d.ts +197 -102
- package/esm/core/Select/Select.js +73 -20
- package/esm/core/Table/Table.js +2 -1
- package/esm/core/Tabs/Tabs.js +19 -3
- package/esm/core/Tile/Tile.d.ts +2 -2
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +4 -2
- package/esm/core/ToggleSwitch/ToggleSwitch.js +6 -12
- package/esm/core/Typography/Anchor.d.ts +21 -1
- package/esm/core/Typography/Anchor.js +11 -2
- package/esm/core/VisuallyHidden/VisuallyHidden.js +19 -3
- package/esm/core/utils/components/InputFlexContainer.d.ts +25 -0
- package/esm/core/utils/components/InputFlexContainer.js +18 -0
- package/esm/core/utils/components/LineClamp.d.ts +5 -0
- package/esm/core/utils/components/LineClamp.js +23 -0
- package/esm/core/utils/components/ShadowRoot.d.ts +2 -1
- package/esm/core/utils/components/ShadowRoot.js +19 -4
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/esm/core/utils/functions/polymorphic.d.ts +5 -3
- package/esm/core/utils/functions/polymorphic.js +20 -5
- package/esm/core/utils/icons/Svg.js +5 -1
- package/esm/core/utils/icons/SvgStatusError.js +1 -1
- package/package.json +27 -27
- package/styles.css +39 -38
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
2
|
+
type AnchorProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the anchor links to an external site.
|
|
5
|
+
*
|
|
6
|
+
* When true, there will be an icon added at the end of the anchor text. This is useful
|
|
7
|
+
* to indicate that the link will open in a new tab.
|
|
8
|
+
*
|
|
9
|
+
* Not all external links should open in a new tab, so this prop should be used with caution.
|
|
10
|
+
*/
|
|
11
|
+
isExternal?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the anchor should be underlined in its idle state.
|
|
14
|
+
*
|
|
15
|
+
* By default, the anchor is underlined only on hover, or when using a high-contrast theme.
|
|
16
|
+
*/
|
|
17
|
+
underline?: boolean;
|
|
18
|
+
};
|
|
1
19
|
/**
|
|
2
20
|
* A consistently styled anchor component.
|
|
3
21
|
*
|
|
@@ -7,9 +25,11 @@
|
|
|
7
25
|
* @example
|
|
8
26
|
* <Anchor href='/'>Home</Anchor>
|
|
9
27
|
* <Anchor href='/projects'>Projects</Anchor>
|
|
28
|
+
* <Anchor href='/help' underline>Help</Anchor>
|
|
10
29
|
*
|
|
11
30
|
* @example
|
|
12
31
|
* <Anchor as={Link} to='/'>Home</Anchor>
|
|
13
32
|
* <Anchor as='button' onClick={() => {}}>click me</Anchor>
|
|
14
33
|
*/
|
|
15
|
-
export declare const Anchor:
|
|
34
|
+
export declare const Anchor: PolymorphicForwardRefComponent<"a", AnchorProps>;
|
|
35
|
+
export {};
|
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Anchor = void 0;
|
|
4
2
|
/*---------------------------------------------------------------------------------------------
|
|
5
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.Anchor = void 0;
|
|
34
|
+
const React = __importStar(require("react"));
|
|
35
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
8
36
|
const index_js_1 = require("../utils/index.js");
|
|
37
|
+
const VisuallyHidden_js_1 = require("../VisuallyHidden/VisuallyHidden.js");
|
|
9
38
|
/**
|
|
10
39
|
* A consistently styled anchor component.
|
|
11
40
|
*
|
|
@@ -15,9 +44,15 @@ const index_js_1 = require("../utils/index.js");
|
|
|
15
44
|
* @example
|
|
16
45
|
* <Anchor href='/'>Home</Anchor>
|
|
17
46
|
* <Anchor href='/projects'>Projects</Anchor>
|
|
47
|
+
* <Anchor href='/help' underline>Help</Anchor>
|
|
18
48
|
*
|
|
19
49
|
* @example
|
|
20
50
|
* <Anchor as={Link} to='/'>Home</Anchor>
|
|
21
51
|
* <Anchor as='button' onClick={() => {}}>click me</Anchor>
|
|
22
52
|
*/
|
|
23
|
-
exports.Anchor =
|
|
53
|
+
exports.Anchor = React.forwardRef((props, forwardedRef) => {
|
|
54
|
+
const { isExternal, underline, children, ...rest } = props;
|
|
55
|
+
return (React.createElement(index_js_1.Box, { as: 'a', "data-iui-underline": underline ? 'true' : undefined, ...rest, ref: forwardedRef, className: (0, classnames_1.default)('iui-anchor', { 'iui-anchor-external': isExternal }, props.className) },
|
|
56
|
+
children,
|
|
57
|
+
props.target === '_blank' && (React.createElement(VisuallyHidden_js_1.VisuallyHidden, null, " (opens in new tab)"))));
|
|
58
|
+
});
|
|
@@ -33,7 +33,7 @@ exports.VisuallyHidden = void 0;
|
|
|
33
33
|
*--------------------------------------------------------------------------------------------*/
|
|
34
34
|
const React = __importStar(require("react"));
|
|
35
35
|
const classnames_1 = __importDefault(require("classnames"));
|
|
36
|
-
const
|
|
36
|
+
const index_js_1 = require("../utils/index.js");
|
|
37
37
|
/**
|
|
38
38
|
* Hides content visually but keeps it still accessible to screen readers
|
|
39
39
|
* and other assistive technologies.
|
|
@@ -45,6 +45,22 @@ const Box_js_1 = require("../utils/components/Box.js");
|
|
|
45
45
|
* @see https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html
|
|
46
46
|
*/
|
|
47
47
|
exports.VisuallyHidden = React.forwardRef((props, ref) => {
|
|
48
|
-
const { className, unhideOnFocus = true, ...rest } = props;
|
|
49
|
-
|
|
48
|
+
const { as: asProp = 'span', className, unhideOnFocus = true, children: childrenProp, ...rest } = props;
|
|
49
|
+
// ShadowRoot is not supported on all elements, so we only use it for few common ones.
|
|
50
|
+
const children = !['div', 'span', 'p'].includes(asProp) ? (childrenProp) : (React.createElement(React.Fragment, null,
|
|
51
|
+
React.createElement(index_js_1.ShadowRoot, { css: css },
|
|
52
|
+
React.createElement("slot", null)),
|
|
53
|
+
childrenProp));
|
|
54
|
+
return (React.createElement(index_js_1.Box, { as: asProp, className: (0, classnames_1.default)('iui-visually-hidden', className), "data-iui-unhide-on-focus": unhideOnFocus ? true : undefined, ref: ref, ...rest }, children));
|
|
50
55
|
});
|
|
56
|
+
// ----------------------------------------------------------------------------
|
|
57
|
+
const css = /* css */ `
|
|
58
|
+
:host(:where(:not([data-iui-unhide-on-focus]:is(:focus-within, :active)))) {
|
|
59
|
+
clip-path: inset(50%) !important;
|
|
60
|
+
overflow: hidden !important;
|
|
61
|
+
position: absolute !important;
|
|
62
|
+
white-space: nowrap !important;
|
|
63
|
+
block-size: 1px !important;
|
|
64
|
+
inline-size: 1px !important;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { PolymorphicForwardRefComponent } from '../props.js';
|
|
2
|
+
import type { IconProps } from '../../Icon/Icon.js';
|
|
3
|
+
import type { IconButtonProps } from '../../Buttons/IconButton.js';
|
|
2
4
|
export type InputFlexContainerProps = {
|
|
3
5
|
isDisabled?: boolean;
|
|
4
6
|
status?: 'positive' | 'warning' | 'negative';
|
|
@@ -9,3 +11,26 @@ export type InputFlexContainerProps = {
|
|
|
9
11
|
* @private
|
|
10
12
|
*/
|
|
11
13
|
export declare const InputFlexContainer: PolymorphicForwardRefComponent<"div", InputFlexContainerProps>;
|
|
14
|
+
/**
|
|
15
|
+
* Button inside InputFlexContainer that collapses the padding between the button and the input/textarea.
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export declare const InputFlexContainerButton: PolymorphicForwardRefComponent<"button", Omit<IconButtonProps, "styleType"> & {
|
|
19
|
+
/**
|
|
20
|
+
* Style of the button.
|
|
21
|
+
* Use 'borderless' to hide outline.
|
|
22
|
+
* @default 'borderless'
|
|
23
|
+
*/
|
|
24
|
+
styleType?: IconButtonProps['styleType'];
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Icon inside InputFlexContainer that collapses the padding between the icon and the input/textarea.
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
export declare const InputFlexContainerIcon: PolymorphicForwardRefComponent<"span", Omit<IconProps, "padded"> & {
|
|
31
|
+
/**
|
|
32
|
+
* Option to add padding to the icon.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
padded?: IconProps['padded'];
|
|
36
|
+
}>;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.InputFlexContainer = void 0;
|
|
6
|
+
exports.InputFlexContainerIcon = exports.InputFlexContainerButton = exports.InputFlexContainer = void 0;
|
|
7
7
|
/*---------------------------------------------------------------------------------------------
|
|
8
8
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
9
9
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -11,6 +11,8 @@ exports.InputFlexContainer = void 0;
|
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const classnames_1 = __importDefault(require("classnames"));
|
|
13
13
|
const Box_js_1 = require("./Box.js");
|
|
14
|
+
const Icon_js_1 = require("../../Icon/Icon.js");
|
|
15
|
+
const IconButton_js_1 = require("../../Buttons/IconButton.js");
|
|
14
16
|
/**
|
|
15
17
|
* Utility component for input container with display flex abilities.
|
|
16
18
|
* @private
|
|
@@ -19,3 +21,19 @@ exports.InputFlexContainer = react_1.default.forwardRef((props, ref) => {
|
|
|
19
21
|
const { isDisabled, status, children, className, size, style, ...rest } = props;
|
|
20
22
|
return (react_1.default.createElement(Box_js_1.Box, { className: (0, classnames_1.default)('iui-input-flex-container', className), "data-iui-status": status, "data-iui-size": size, "data-iui-disabled": isDisabled ? 'true' : undefined, ref: ref, style: style, ...rest }, children));
|
|
21
23
|
});
|
|
24
|
+
/**
|
|
25
|
+
* Button inside InputFlexContainer that collapses the padding between the button and the input/textarea.
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
exports.InputFlexContainerButton = react_1.default.forwardRef((props, ref) => {
|
|
29
|
+
const { className, ...rest } = props;
|
|
30
|
+
return (react_1.default.createElement(IconButton_js_1.IconButton, { ref: ref, className: (0, classnames_1.default)('iui-input-flex-container-icon', className), styleType: 'borderless', ...rest }));
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Icon inside InputFlexContainer that collapses the padding between the icon and the input/textarea.
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
exports.InputFlexContainerIcon = react_1.default.forwardRef((props, ref) => {
|
|
37
|
+
const { className, ...rest } = props;
|
|
38
|
+
return (react_1.default.createElement(Icon_js_1.Icon, { ref: ref, className: (0, classnames_1.default)('iui-input-flex-container-icon', className), padded: true, ...rest }));
|
|
39
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.LineClamp = void 0;
|
|
27
|
+
/*---------------------------------------------------------------------------------------------
|
|
28
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
29
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
30
|
+
*--------------------------------------------------------------------------------------------*/
|
|
31
|
+
const React = __importStar(require("react"));
|
|
32
|
+
const Box_js_1 = require("./Box.js");
|
|
33
|
+
const ShadowRoot_js_1 = require("./ShadowRoot.js");
|
|
34
|
+
/** @private */
|
|
35
|
+
exports.LineClamp = React.forwardRef((props, forwardedRef) => {
|
|
36
|
+
const { lines, children, ...rest } = props;
|
|
37
|
+
return (React.createElement(Box_js_1.Box, { ref: forwardedRef, ...rest, style: { '--_iui-line-clamp': lines, ...props.style } },
|
|
38
|
+
React.createElement(ShadowRoot_js_1.ShadowRoot, { css: css },
|
|
39
|
+
React.createElement("slot", null)),
|
|
40
|
+
children));
|
|
41
|
+
});
|
|
42
|
+
const css = /* css */ `
|
|
43
|
+
:host {
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
display: -webkit-box;
|
|
46
|
+
-webkit-line-clamp: var(--_iui-line-clamp, 3);
|
|
47
|
+
-webkit-box-orient: vertical;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
@@ -32,24 +32,39 @@ const React = __importStar(require("react"));
|
|
|
32
32
|
const ReactDOM = __importStar(require("react-dom"));
|
|
33
33
|
const isBrowser = typeof document !== 'undefined';
|
|
34
34
|
const supportsDSD = isBrowser && 'shadowRootMode' in HTMLTemplateElement.prototype;
|
|
35
|
+
const supportsAdoptedStylesheets = isBrowser && 'adoptedStyleSheets' in Document.prototype;
|
|
35
36
|
/**
|
|
36
37
|
* Wrapper around `<template>` element that attaches shadow root to its parent
|
|
37
38
|
* and moves its children into the shadow root.
|
|
38
39
|
*
|
|
39
40
|
* @private
|
|
40
41
|
*/
|
|
41
|
-
const ShadowRoot = ({ children }) => {
|
|
42
|
+
const ShadowRoot = ({ children, css, }) => {
|
|
42
43
|
const [shadowRoot, setShadowRoot] = React.useState();
|
|
43
44
|
const isFirstRender = useIsFirstRender();
|
|
45
|
+
const styleSheet = React.useRef();
|
|
44
46
|
const attachShadowRef = React.useCallback((template) => {
|
|
45
47
|
const parent = template?.parentElement;
|
|
46
48
|
if (!template || !parent) {
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
if (parent.shadowRoot) {
|
|
52
|
+
parent.shadowRoot.replaceChildren(); // Remove previous shadowroot content
|
|
53
|
+
}
|
|
54
|
+
queueMicrotask(() => {
|
|
55
|
+
const shadow = parent.shadowRoot || parent.attachShadow({ mode: 'open' });
|
|
56
|
+
if (css && supportsAdoptedStylesheets) {
|
|
57
|
+
styleSheet.current || (styleSheet.current = new CSSStyleSheet());
|
|
58
|
+
styleSheet.current.replaceSync(css);
|
|
59
|
+
shadow.adoptedStyleSheets = [styleSheet.current];
|
|
60
|
+
}
|
|
61
|
+
ReactDOM.flushSync(() => setShadowRoot(shadow));
|
|
62
|
+
});
|
|
63
|
+
}, [css]);
|
|
51
64
|
if (!isBrowser) {
|
|
52
|
-
return React.createElement("template", { shadowrootmode: 'open' },
|
|
65
|
+
return (React.createElement("template", { shadowrootmode: 'open' },
|
|
66
|
+
css && React.createElement("style", null, css),
|
|
67
|
+
children));
|
|
53
68
|
}
|
|
54
69
|
// In browsers that support DSD, the template will be automatically removed as soon as it's parsed.
|
|
55
70
|
// To pass hydration, the first client render needs to emulate this browser behavior and return null.
|
|
@@ -3,11 +3,13 @@ import type { PolymorphicForwardRefComponent } from '../props.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Utility to create a type-safe polymorphic component with a simple class.
|
|
5
5
|
*
|
|
6
|
-
* Can be called directly or as a property of the `
|
|
6
|
+
* Can be called directly or as a property of the `polymorphic` object.
|
|
7
7
|
* In both cases, returns a component that:
|
|
8
|
+
* - uses CSS-modules scoped classes
|
|
8
9
|
* - supports `as` prop with default element
|
|
9
|
-
* - forwards ref and rest props
|
|
10
|
-
* - adds and merges
|
|
10
|
+
* - forwards ref and spreads rest props
|
|
11
|
+
* - adds and merges CSS classes
|
|
12
|
+
* - adds tabIndex to interactive elements (Safari workaround)
|
|
11
13
|
*
|
|
12
14
|
* @example
|
|
13
15
|
* const MyPolyDiv = polymorphic('my-poly-div');
|
|
@@ -31,6 +31,7 @@ exports.polymorphic = void 0;
|
|
|
31
31
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
32
32
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
33
33
|
*--------------------------------------------------------------------------------------------*/
|
|
34
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
34
35
|
const React = __importStar(require("react"));
|
|
35
36
|
const classnames_1 = __importDefault(require("classnames"));
|
|
36
37
|
const useGlobals_js_1 = require("../hooks/useGlobals.js");
|
|
@@ -38,9 +39,21 @@ const styles_js_1 = __importDefault(require("../../../styles.js"));
|
|
|
38
39
|
const _base = (defaultElement) => {
|
|
39
40
|
return (className, attrs) => {
|
|
40
41
|
const Comp = React.forwardRef(({ as = defaultElement, ...props }, ref) => {
|
|
41
|
-
|
|
42
|
+
props = {
|
|
43
|
+
...attrs,
|
|
44
|
+
...props,
|
|
45
|
+
className: getScopedClassName((0, classnames_1.default)(className, attrs?.className, props.className)),
|
|
46
|
+
};
|
|
47
|
+
const Element = as || 'div';
|
|
48
|
+
// Add tabIndex to interactive elements if not already set.
|
|
49
|
+
// Workaround for Safari refusing to focus links/buttons/non-text inputs.
|
|
50
|
+
if (Element === 'button' ||
|
|
51
|
+
Element === 'a' ||
|
|
52
|
+
(Element === 'input' && props.type === 'checkbox')) {
|
|
53
|
+
props.tabIndex ?? (props.tabIndex = 0);
|
|
54
|
+
}
|
|
42
55
|
(0, useGlobals_js_1.useGlobals)();
|
|
43
|
-
return
|
|
56
|
+
return React.createElement(Element, { ref: ref, ...props });
|
|
44
57
|
});
|
|
45
58
|
Comp.displayName = getDisplayNameFromClass(className);
|
|
46
59
|
return Comp;
|
|
@@ -49,11 +62,13 @@ const _base = (defaultElement) => {
|
|
|
49
62
|
/**
|
|
50
63
|
* Utility to create a type-safe polymorphic component with a simple class.
|
|
51
64
|
*
|
|
52
|
-
* Can be called directly or as a property of the `
|
|
65
|
+
* Can be called directly or as a property of the `polymorphic` object.
|
|
53
66
|
* In both cases, returns a component that:
|
|
67
|
+
* - uses CSS-modules scoped classes
|
|
54
68
|
* - supports `as` prop with default element
|
|
55
|
-
* - forwards ref and rest props
|
|
56
|
-
* - adds and merges
|
|
69
|
+
* - forwards ref and spreads rest props
|
|
70
|
+
* - adds and merges CSS classes
|
|
71
|
+
* - adds tabIndex to interactive elements (Safari workaround)
|
|
57
72
|
*
|
|
58
73
|
* @example
|
|
59
74
|
* const MyPolyDiv = polymorphic('my-poly-div');
|
|
@@ -6,4 +6,8 @@ exports.Svg = void 0;
|
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const polymorphic_js_1 = require("../functions/polymorphic.js");
|
|
9
|
-
exports.Svg = polymorphic_js_1.polymorphic.svg('', {
|
|
9
|
+
exports.Svg = polymorphic_js_1.polymorphic.svg('', {
|
|
10
|
+
viewBox: '0 0 16 16',
|
|
11
|
+
width: 16,
|
|
12
|
+
height: 16,
|
|
13
|
+
});
|
|
@@ -32,6 +32,6 @@ const React = __importStar(require("react"));
|
|
|
32
32
|
const Svg_js_1 = require("./Svg.js");
|
|
33
33
|
const SvgStatusError = (props) => {
|
|
34
34
|
return (React.createElement(Svg_js_1.Svg, { ...props },
|
|
35
|
-
React.createElement("path", { d: '
|
|
35
|
+
React.createElement("path", { d: 'M9 12H7v-2h2v2Zm0-3H7V4h2v5Zm2.314-9H4.686L0 4.686v6.628L4.686 16h6.628L16 11.314V4.686L11.314 0Z' })));
|
|
36
36
|
};
|
|
37
37
|
exports.SvgStatusError = SvgStatusError;
|
|
@@ -48,7 +48,7 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
48
48
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
49
49
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
50
50
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
51
|
-
placement?: import("@floating-ui/
|
|
51
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
52
52
|
visible?: boolean | undefined;
|
|
53
53
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
54
54
|
autoUpdateOptions?: {
|
|
@@ -92,7 +92,7 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
92
92
|
*/
|
|
93
93
|
children?: React.ReactNode;
|
|
94
94
|
} & import("../utils/index.js").PortalProps & {
|
|
95
|
-
placement?: import("@floating-ui/
|
|
95
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
96
96
|
visible?: boolean | undefined;
|
|
97
97
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
98
98
|
autoUpdateOptions?: {
|
|
@@ -129,7 +129,7 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
129
129
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
130
130
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
131
131
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
132
|
-
placement?: import("@floating-ui/
|
|
132
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
133
133
|
visible?: boolean | undefined;
|
|
134
134
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
135
135
|
autoUpdateOptions?: {
|
|
@@ -173,7 +173,7 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
|
|
|
173
173
|
*/
|
|
174
174
|
children?: React.ReactNode;
|
|
175
175
|
} & import("../utils/index.js").PortalProps & {
|
|
176
|
-
placement?: import("@floating-ui/
|
|
176
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
177
177
|
visible?: boolean | undefined;
|
|
178
178
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
179
179
|
autoUpdateOptions?: {
|
|
@@ -15,7 +15,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
15
15
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
16
16
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
17
17
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
18
|
-
placement?: import("@floating-ui/
|
|
18
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
19
19
|
visible?: boolean | undefined;
|
|
20
20
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
21
21
|
autoUpdateOptions?: {
|
|
@@ -41,7 +41,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
41
41
|
content: React.ReactNode;
|
|
42
42
|
children?: React.ReactNode;
|
|
43
43
|
} & import("../utils/index.js").PortalProps & {
|
|
44
|
-
placement?: import("@floating-ui/
|
|
44
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
45
45
|
visible?: boolean | undefined;
|
|
46
46
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
47
47
|
autoUpdateOptions?: {
|
|
@@ -78,7 +78,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
78
78
|
labelProps?: Omit<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
79
79
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
80
80
|
}, "as" | "children" | "content" | "portal" | keyof {
|
|
81
|
-
placement?: import("@floating-ui/
|
|
81
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
82
82
|
visible?: boolean | undefined;
|
|
83
83
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
84
84
|
autoUpdateOptions?: {
|
|
@@ -104,7 +104,7 @@ export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {
|
|
|
104
104
|
content: React.ReactNode;
|
|
105
105
|
children?: React.ReactNode;
|
|
106
106
|
} & import("../utils/index.js").PortalProps & {
|
|
107
|
-
placement?: import("@floating-ui/
|
|
107
|
+
placement?: import("@floating-ui/core").Placement | undefined;
|
|
108
108
|
visible?: boolean | undefined;
|
|
109
109
|
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
110
110
|
autoUpdateOptions?: {
|
|
@@ -11,26 +11,28 @@ import { DialogContext } from './DialogContext.js';
|
|
|
11
11
|
import { DialogButtonBar } from './DialogButtonBar.js';
|
|
12
12
|
import { DialogMain } from './DialogMain.js';
|
|
13
13
|
import { useMergedRefs, Box, Portal } from '../utils/index.js';
|
|
14
|
+
import { Transition } from 'react-transition-group';
|
|
14
15
|
const DialogComponent = React.forwardRef((props, ref) => {
|
|
15
16
|
const { trapFocus = false, setFocus = false, preventDocumentScroll = false, isOpen = false, isDismissible = true, closeOnEsc = true, closeOnExternalClick = false, onClose, isDraggable = false, isResizable = false, relativeTo = 'viewport', placement, className, portal = false, ...rest } = props;
|
|
16
17
|
const dialogRootRef = React.useRef(null);
|
|
17
|
-
return (React.createElement(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
React.createElement(
|
|
18
|
+
return (React.createElement(Transition, { in: isOpen, timeout: { exit: 600 }, mountOnEnter: true, unmountOnExit: true },
|
|
19
|
+
React.createElement(DialogContext.Provider, { value: {
|
|
20
|
+
isOpen,
|
|
21
|
+
onClose,
|
|
22
|
+
closeOnEsc,
|
|
23
|
+
closeOnExternalClick,
|
|
24
|
+
isDismissible,
|
|
25
|
+
preventDocumentScroll,
|
|
26
|
+
trapFocus,
|
|
27
|
+
setFocus,
|
|
28
|
+
isDraggable,
|
|
29
|
+
isResizable,
|
|
30
|
+
relativeTo,
|
|
31
|
+
dialogRootRef,
|
|
32
|
+
placement,
|
|
33
|
+
} },
|
|
34
|
+
React.createElement(Portal, { portal: portal },
|
|
35
|
+
React.createElement(Box, { className: cx('iui-dialog-wrapper', className), "data-iui-relative": relativeTo === 'container', ref: useMergedRefs(ref, dialogRootRef), ...rest })))));
|
|
34
36
|
});
|
|
35
37
|
/**
|
|
36
38
|
* Dialog component.
|
|
@@ -3,6 +3,10 @@ import type { PortalProps } from '../utils/index.js';
|
|
|
3
3
|
export type DialogContextProps = {
|
|
4
4
|
/**
|
|
5
5
|
* Flag whether dialog should be shown.
|
|
6
|
+
*
|
|
7
|
+
* It is recommended to directly pass the boolean condition to this prop instead of rendering the `Dialog`
|
|
8
|
+
* conditionally with `isOpen` hard-coded to `true`. One benefit of this is getting an exit animation.
|
|
9
|
+
*
|
|
6
10
|
* @default false
|
|
7
11
|
*/
|
|
8
12
|
isOpen?: boolean;
|
|
@@ -120,7 +120,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
|
|
|
120
120
|
}
|
|
121
121
|
}, onResizeEnd: setResizeStyle }))),
|
|
122
122
|
children));
|
|
123
|
-
return (React.createElement(Transition, { in: isOpen, timeout: { exit: 600 },
|
|
123
|
+
return (React.createElement(Transition, { in: isOpen, appear: true, timeout: { exit: 600 },
|
|
124
124
|
// Focuses dialog when opened
|
|
125
125
|
onEntered: () => {
|
|
126
126
|
previousFocusedElement.current = dialogRef.current?.ownerDocument
|
|
@@ -34,7 +34,7 @@ export const DialogTitleBar = Object.assign(React.forwardRef((props, ref) => {
|
|
|
34
34
|
'iui-dialog-title-bar-filled': isDraggable,
|
|
35
35
|
}), ref: ref, onPointerDown: mergeEventHandlers(onPointerDownProp, onPointerDown), ...rest }, children ? (children) : (React.createElement(React.Fragment, null,
|
|
36
36
|
React.createElement(DialogTitleBarTitle, null, titleText),
|
|
37
|
-
isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
37
|
+
isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close', "data-iui-shift": 'right' },
|
|
38
38
|
React.createElement(SvgClose, null)))))));
|
|
39
39
|
}), {
|
|
40
40
|
Title: DialogTitleBarTitle,
|
|
@@ -12,6 +12,10 @@ type InputGroupProps = {
|
|
|
12
12
|
status?: 'positive' | 'warning' | 'negative';
|
|
13
13
|
/**
|
|
14
14
|
* Message below the group. Does not apply to 'inline' group.
|
|
15
|
+
*
|
|
16
|
+
* When `typeof message === "string"`, it is automatically wrapped with {@link StatusMessage}.
|
|
17
|
+
* If you are passing a non-string message that is not `<StatusMessage>`, you may need to wrap it with
|
|
18
|
+
* `<StatusMessage>` yourself for proper styling of `message`.
|
|
15
19
|
*/
|
|
16
20
|
message?: React.ReactNode;
|
|
17
21
|
/**
|
|
@@ -24,11 +24,27 @@ import { StatusMessage } from '../StatusMessage/StatusMessage.js';
|
|
|
24
24
|
* </InputGroup>
|
|
25
25
|
*/
|
|
26
26
|
export const InputGroup = React.forwardRef((props, forwardedRef) => {
|
|
27
|
-
const { className, children, disabled = false, displayStyle = 'default', label,
|
|
27
|
+
const { className, children, disabled = false, displayStyle = 'default', label, status, required = false, labelProps, innerProps, message, svgIcon, messageProps, ...rest } = props;
|
|
28
28
|
return (React.createElement(InputGrid, { ref: forwardedRef, as: 'div', labelPlacement: displayStyle, className: cx('iui-input-group-wrapper', className), "data-iui-status": status, ...rest },
|
|
29
29
|
label && (React.createElement(Label, { as: 'label', required: required, disabled: disabled, ...labelProps }, label)),
|
|
30
30
|
React.createElement(Box, { as: 'div', ...innerProps, className: cx('iui-input-group', innerProps?.className) }, children),
|
|
31
|
-
(message
|
|
32
|
-
'aria-hidden': true,
|
|
33
|
-
}, startIcon: svgIcon, status: status, ...messageProps }, displayStyle !== 'inline' && message))));
|
|
31
|
+
React.createElement(BottomMessage, { message: message, status: status, svgIcon: svgIcon, displayStyle: displayStyle, messageProps: messageProps })));
|
|
34
32
|
});
|
|
33
|
+
// ------------------------------------------------------------------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
* - When `typeof message !== 'string'`, `message` is returned as-is (e.g. when `message=<StatusMessage />`).
|
|
37
|
+
* - Else, it is wrapped in a `<StatusMessage />`.
|
|
38
|
+
*/
|
|
39
|
+
const BottomMessage = (props) => {
|
|
40
|
+
const { message, status, svgIcon, displayStyle, messageProps } = props;
|
|
41
|
+
if (message && typeof message !== 'string') {
|
|
42
|
+
return message;
|
|
43
|
+
}
|
|
44
|
+
if (message || status || svgIcon) {
|
|
45
|
+
return (React.createElement(StatusMessage, { iconProps: {
|
|
46
|
+
'aria-hidden': true,
|
|
47
|
+
}, startIcon: svgIcon, status: status, ...messageProps }, displayStyle !== 'inline' && message));
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|