@itwin/itwinui-react 3.0.0-dev.5 → 3.0.0-dev.7
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 +98 -1
- package/cjs/core/Avatar/Avatar.d.ts +3 -2
- package/cjs/core/Avatar/Avatar.js +21 -19
- package/cjs/core/AvatarGroup/AvatarGroup.js +3 -8
- package/cjs/core/Buttons/Button/Button.d.ts +15 -2
- package/cjs/core/Buttons/Button/Button.js +23 -9
- package/cjs/core/Buttons/DropdownButton/DropdownButton.d.ts +1 -1
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +1 -1
- package/cjs/core/Buttons/IconButton/IconButton.d.ts +5 -1
- package/cjs/core/Buttons/IconButton/IconButton.js +11 -5
- package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
- package/cjs/core/Buttons/SplitButton/SplitButton.js +22 -13
- package/cjs/core/Carousel/Carousel.d.ts +6 -4
- package/cjs/core/Carousel/Carousel.js +2 -2
- package/cjs/core/Carousel/CarouselDot.js +1 -3
- package/cjs/core/Carousel/CarouselNavigation.d.ts +6 -4
- package/cjs/core/ColorPicker/ColorBuilder.js +2 -1
- package/cjs/core/ComboBox/ComboBoxInput.js +1 -1
- package/cjs/core/ComboBox/ComboBoxMenu.js +5 -5
- package/cjs/core/DatePicker/DatePicker.js +7 -1
- package/cjs/core/Dialog/Dialog.js +1 -2
- package/cjs/core/Dialog/DialogContent.d.ts +2 -1
- package/cjs/core/Dialog/DialogContent.js +25 -1
- package/cjs/core/Dialog/DialogMain.js +5 -6
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +1 -3
- package/cjs/core/FileUpload/FileUpload.d.ts +4 -0
- package/cjs/core/FileUpload/FileUpload.js +24 -3
- package/cjs/core/Header/HeaderBasicButton.js +3 -16
- package/cjs/core/Header/HeaderButton.d.ts +4 -0
- package/cjs/core/Header/HeaderButton.js +2 -0
- package/cjs/core/Header/HeaderDropdownButton.js +1 -1
- package/cjs/core/Header/HeaderSplitButton.js +2 -4
- package/cjs/core/Input/Input.d.ts +5 -0
- package/cjs/core/Input/Input.js +2 -1
- package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
- package/cjs/core/ProgressIndicators/ProgressLinear.js +9 -1
- package/cjs/core/Radio/Radio.d.ts +8 -0
- package/cjs/core/Radio/Radio.js +22 -9
- package/cjs/core/RadioTiles/RadioTile.d.ts +16 -0
- package/cjs/core/RadioTiles/RadioTile.js +61 -27
- package/cjs/core/Select/Select.js +2 -2
- package/cjs/core/SideNavigation/SideNavigation.d.ts +16 -0
- package/cjs/core/SideNavigation/SideNavigation.js +40 -9
- package/cjs/core/Slider/Slider.d.ts +24 -0
- package/cjs/core/Slider/Slider.js +58 -10
- package/cjs/core/Slider/Thumb.js +2 -2
- package/cjs/core/Slider/Track.d.ts +1 -1
- package/cjs/core/Slider/Track.js +17 -6
- package/cjs/core/Stepper/Stepper.d.ts +26 -1
- package/cjs/core/Stepper/Stepper.js +35 -6
- package/cjs/core/Stepper/StepperStep.d.ts +17 -0
- package/cjs/core/Stepper/StepperStep.js +33 -8
- package/cjs/core/Stepper/WorkflowDiagram.d.ts +11 -1
- package/cjs/core/Stepper/WorkflowDiagram.js +23 -10
- package/cjs/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
- package/cjs/core/Stepper/WorkflowDiagramStep.js +9 -2
- package/cjs/core/Table/SubRowExpander.js +1 -1
- package/cjs/core/Table/Table.d.ts +16 -0
- package/cjs/core/Table/Table.js +50 -9
- package/cjs/core/Table/TableCell.js +1 -1
- package/cjs/core/Table/TablePaginator.js +1 -3
- package/cjs/core/Tabs/Tab.js +1 -2
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +23 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +56 -23
- package/cjs/core/Tile/Tile.d.ts +3 -2
- package/cjs/core/Toast/Toast.js +4 -9
- package/cjs/core/Tooltip/Tooltip.d.ts +1 -1
- package/cjs/core/Tooltip/Tooltip.js +1 -2
- package/cjs/core/Tree/TreeNode.js +1 -1
- package/cjs/core/utils/components/ButtonBase.d.ts +14 -0
- package/cjs/core/utils/components/ButtonBase.js +46 -0
- package/cjs/core/utils/components/Popover.js +5 -3
- package/cjs/core/utils/components/Resizer.js +21 -13
- package/cjs/core/utils/components/VirtualScroll.js +4 -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/colors.d.ts +1 -1
- package/cjs/core/utils/functions/colors.js +1 -13
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useGlobals.d.ts +1 -1
- package/cjs/core/utils/hooks/useUncontrolledState.d.ts +6 -0
- package/cjs/core/utils/hooks/useUncontrolledState.js +18 -0
- package/cjs/styles.js +4 -11
- package/esm/core/Avatar/Avatar.d.ts +3 -2
- package/esm/core/Avatar/Avatar.js +21 -17
- package/esm/core/AvatarGroup/AvatarGroup.js +3 -8
- package/esm/core/Buttons/Button/Button.d.ts +15 -2
- package/esm/core/Buttons/Button/Button.js +18 -10
- package/esm/core/Buttons/DropdownButton/DropdownButton.d.ts +1 -1
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -1
- package/esm/core/Buttons/IconButton/IconButton.d.ts +5 -1
- package/esm/core/Buttons/IconButton/IconButton.js +9 -6
- package/esm/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
- package/esm/core/Buttons/SplitButton/SplitButton.js +22 -13
- package/esm/core/Carousel/Carousel.d.ts +6 -4
- package/esm/core/Carousel/Carousel.js +8 -3
- package/esm/core/Carousel/CarouselDot.js +2 -4
- package/esm/core/Carousel/CarouselNavigation.d.ts +6 -4
- package/esm/core/ColorPicker/ColorBuilder.js +2 -1
- package/esm/core/ComboBox/ComboBoxInput.js +1 -1
- package/esm/core/ComboBox/ComboBoxMenu.js +5 -5
- package/esm/core/DatePicker/DatePicker.js +8 -1
- package/esm/core/Dialog/Dialog.js +1 -1
- package/esm/core/Dialog/DialogContent.d.ts +2 -1
- package/esm/core/Dialog/DialogContent.js +25 -2
- package/esm/core/Dialog/DialogMain.js +5 -6
- package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -3
- package/esm/core/FileUpload/FileUpload.d.ts +4 -0
- package/esm/core/FileUpload/FileUpload.js +26 -3
- package/esm/core/Header/HeaderBasicButton.js +4 -17
- package/esm/core/Header/HeaderButton.d.ts +4 -0
- package/esm/core/Header/HeaderButton.js +2 -0
- package/esm/core/Header/HeaderDropdownButton.js +1 -1
- package/esm/core/Header/HeaderSplitButton.js +8 -5
- package/esm/core/Input/Input.d.ts +5 -0
- package/esm/core/Input/Input.js +2 -1
- package/esm/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
- package/esm/core/ProgressIndicators/ProgressLinear.js +9 -1
- package/esm/core/Radio/Radio.d.ts +8 -0
- package/esm/core/Radio/Radio.js +19 -6
- package/esm/core/RadioTiles/RadioTile.d.ts +16 -0
- package/esm/core/RadioTiles/RadioTile.js +52 -22
- package/esm/core/Select/Select.js +2 -2
- package/esm/core/SideNavigation/SideNavigation.d.ts +16 -0
- package/esm/core/SideNavigation/SideNavigation.js +31 -9
- package/esm/core/Slider/Slider.d.ts +24 -0
- package/esm/core/Slider/Slider.js +43 -10
- package/esm/core/Slider/Thumb.js +2 -2
- package/esm/core/Slider/Track.d.ts +1 -1
- package/esm/core/Slider/Track.js +14 -6
- package/esm/core/Stepper/Stepper.d.ts +26 -1
- package/esm/core/Stepper/Stepper.js +32 -6
- package/esm/core/Stepper/StepperStep.d.ts +17 -0
- package/esm/core/Stepper/StepperStep.js +27 -8
- package/esm/core/Stepper/WorkflowDiagram.d.ts +11 -1
- package/esm/core/Stepper/WorkflowDiagram.js +10 -7
- package/esm/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
- package/esm/core/Stepper/WorkflowDiagramStep.js +6 -2
- package/esm/core/Table/SubRowExpander.js +1 -1
- package/esm/core/Table/Table.d.ts +16 -0
- package/esm/core/Table/Table.js +47 -9
- package/esm/core/Table/TableCell.js +1 -1
- package/esm/core/Table/TablePaginator.js +2 -3
- package/esm/core/Tabs/Tab.js +2 -3
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +23 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +64 -24
- package/esm/core/Tile/Tile.d.ts +3 -2
- package/esm/core/Toast/Toast.js +5 -9
- package/esm/core/Tooltip/Tooltip.d.ts +1 -1
- package/esm/core/Tooltip/Tooltip.js +1 -1
- package/esm/core/Tree/TreeNode.js +1 -1
- package/esm/core/utils/components/ButtonBase.d.ts +14 -0
- package/esm/core/utils/components/ButtonBase.js +42 -0
- package/esm/core/utils/components/Popover.js +5 -3
- package/esm/core/utils/components/Resizer.js +21 -13
- package/esm/core/utils/components/VirtualScroll.js +4 -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/colors.d.ts +1 -1
- package/esm/core/utils/functions/colors.js +1 -13
- package/esm/core/utils/functions/import.js +2 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useGlobals.d.ts +1 -1
- package/esm/core/utils/hooks/useUncontrolledState.d.ts +6 -0
- package/esm/core/utils/hooks/useUncontrolledState.js +13 -0
- package/esm/styles.js +4 -11
- package/package.json +2 -2
- package/styles.css +723 -1566
|
@@ -82,11 +82,9 @@ const TablePaginator = (props) => {
|
|
|
82
82
|
const pageButton = React.useCallback(
|
|
83
83
|
(index, tabIndex = index === focusedIndex ? 0 : -1) =>
|
|
84
84
|
React.createElement(
|
|
85
|
-
index_js_4.
|
|
85
|
+
index_js_4.ButtonBase,
|
|
86
86
|
{
|
|
87
|
-
as: 'button',
|
|
88
87
|
key: index,
|
|
89
|
-
type: 'button',
|
|
90
88
|
className: (0, classnames_1.default)(
|
|
91
89
|
'iui-table-paginator-page-button',
|
|
92
90
|
{
|
package/cjs/core/Tabs/Tab.js
CHANGED
|
@@ -28,9 +28,8 @@ exports.Tab = React.forwardRef((props, forwardedRef) => {
|
|
|
28
28
|
...rest
|
|
29
29
|
} = props;
|
|
30
30
|
return React.createElement(
|
|
31
|
-
index_js_1.
|
|
31
|
+
index_js_1.ButtonBase,
|
|
32
32
|
{
|
|
33
|
-
as: 'button',
|
|
34
33
|
className: (0, classnames_1.default)(
|
|
35
34
|
'iui-tab',
|
|
36
35
|
{ 'iui-active': active },
|
|
@@ -3,5 +3,5 @@ import type { ThemeOptions, ThemeType } from './ThemeProvider.js';
|
|
|
3
3
|
export declare const ThemeContext: React.Context<{
|
|
4
4
|
theme?: ThemeType | undefined;
|
|
5
5
|
themeOptions?: ThemeOptions | undefined;
|
|
6
|
-
|
|
6
|
+
portalContainer?: HTMLElement | null | undefined;
|
|
7
7
|
} | undefined>;
|
|
@@ -44,11 +44,31 @@ type RootProps = {
|
|
|
44
44
|
type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
|
|
45
45
|
themeOptions?: RootProps['themeOptions'];
|
|
46
46
|
children: Required<React.ReactNode>;
|
|
47
|
+
/**
|
|
48
|
+
* The element used as the portal for floating elements (Tooltip, Toast, DropdownMenu, Dialog, etc).
|
|
49
|
+
*
|
|
50
|
+
* Defaults to a `<div>` rendered at the end of the ThemeProvider.
|
|
51
|
+
*
|
|
52
|
+
* When passing an element, it is recommended to use state.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const [myPortal, setMyPortal] = React.useState(null);
|
|
56
|
+
*
|
|
57
|
+
* <div ref={setMyPortal} />
|
|
58
|
+
* <ThemeProvider
|
|
59
|
+
* portalContainer={myPortal}
|
|
60
|
+
* >
|
|
61
|
+
* ...
|
|
62
|
+
* </ThemeProvider>
|
|
63
|
+
*/
|
|
64
|
+
portalContainer?: HTMLElement;
|
|
47
65
|
};
|
|
48
66
|
/**
|
|
49
|
-
* This component provides global
|
|
50
|
-
* that it is wrapping around.
|
|
51
|
-
*
|
|
67
|
+
* This component provides global state and applies theme to the entire tree
|
|
68
|
+
* that it is wrapping around.
|
|
69
|
+
*
|
|
70
|
+
* The `theme` prop defaults to "inherit", which looks upwards for closest ThemeProvider
|
|
71
|
+
* and falls back to "light" theme if one is not found.
|
|
52
72
|
*
|
|
53
73
|
* If you want to theme the entire app, you should use this component at the root. You can also
|
|
54
74
|
* use this component to apply a different theme to only a part of the tree.
|
|
@@ -7,14 +7,17 @@ const tslib_1 = require('tslib');
|
|
|
7
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
8
|
*--------------------------------------------------------------------------------------------*/
|
|
9
9
|
const React = tslib_1.__importStar(require('react'));
|
|
10
|
+
const ReactDOM = tslib_1.__importStar(require('react-dom'));
|
|
10
11
|
const classnames_1 = tslib_1.__importDefault(require('classnames'));
|
|
11
12
|
const index_js_1 = require('../utils/index.js');
|
|
12
13
|
const ThemeContext_js_1 = require('./ThemeContext.js');
|
|
13
14
|
const Toaster_js_1 = require('../Toast/Toaster.js');
|
|
14
15
|
/**
|
|
15
|
-
* This component provides global
|
|
16
|
-
* that it is wrapping around.
|
|
17
|
-
*
|
|
16
|
+
* This component provides global state and applies theme to the entire tree
|
|
17
|
+
* that it is wrapping around.
|
|
18
|
+
*
|
|
19
|
+
* The `theme` prop defaults to "inherit", which looks upwards for closest ThemeProvider
|
|
20
|
+
* and falls back to "light" theme if one is not found.
|
|
18
21
|
*
|
|
19
22
|
* If you want to theme the entire app, you should use this component at the root. You can also
|
|
20
23
|
* use this component to apply a different theme to only a part of the tree.
|
|
@@ -37,18 +40,22 @@ const Toaster_js_1 = require('../Toast/Toaster.js');
|
|
|
37
40
|
* <App />
|
|
38
41
|
* </ThemeProvider>
|
|
39
42
|
*/
|
|
40
|
-
exports.ThemeProvider = React.forwardRef((props,
|
|
41
|
-
const {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
exports.ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
44
|
+
const {
|
|
45
|
+
theme: themeProp = 'inherit',
|
|
46
|
+
children,
|
|
47
|
+
themeOptions,
|
|
48
|
+
portalContainer: portalContainerProp,
|
|
49
|
+
...rest
|
|
50
|
+
} = props;
|
|
51
|
+
const [portalContainer, setPortalContainer] = (0,
|
|
52
|
+
index_js_1.useUncontrolledState)(portalContainerProp || null);
|
|
53
|
+
const [parentTheme, rootRef] = useParentTheme();
|
|
54
|
+
const theme = themeProp === 'inherit' ? parentTheme || 'light' : themeProp;
|
|
55
|
+
const shouldApplyBackground = themeOptions?.applyBackground ?? !parentTheme;
|
|
49
56
|
const contextValue = React.useMemo(
|
|
50
|
-
() => ({ theme, themeOptions,
|
|
51
|
-
[theme, themeOptions],
|
|
57
|
+
() => ({ theme, themeOptions, portalContainer }),
|
|
58
|
+
[theme, themeOptions, portalContainer],
|
|
52
59
|
);
|
|
53
60
|
return React.createElement(
|
|
54
61
|
ThemeContext_js_1.ThemeContext.Provider,
|
|
@@ -59,23 +66,29 @@ exports.ThemeProvider = React.forwardRef((props, ref) => {
|
|
|
59
66
|
theme: theme,
|
|
60
67
|
shouldApplyBackground: shouldApplyBackground,
|
|
61
68
|
themeOptions: themeOptions,
|
|
62
|
-
ref:
|
|
69
|
+
ref: (0, index_js_1.useMergedRefs)(forwardedRef, rootRef),
|
|
63
70
|
...rest,
|
|
64
71
|
},
|
|
65
72
|
React.createElement(
|
|
66
73
|
Toaster_js_1.ToastProvider,
|
|
67
74
|
null,
|
|
68
75
|
children,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
portalContainerProp
|
|
77
|
+
? ReactDOM.createPortal(
|
|
78
|
+
React.createElement(Toaster_js_1.Toaster, null),
|
|
79
|
+
portalContainerProp,
|
|
80
|
+
)
|
|
81
|
+
: React.createElement(
|
|
82
|
+
'div',
|
|
83
|
+
{ ref: setPortalContainer },
|
|
84
|
+
React.createElement(Toaster_js_1.Toaster, null),
|
|
85
|
+
),
|
|
74
86
|
),
|
|
75
87
|
),
|
|
76
88
|
);
|
|
77
89
|
});
|
|
78
90
|
exports.default = exports.ThemeProvider;
|
|
91
|
+
// ----------------------------------------------------------------------------
|
|
79
92
|
const Root = React.forwardRef((props, forwardedRef) => {
|
|
80
93
|
const {
|
|
81
94
|
theme,
|
|
@@ -85,8 +98,6 @@ const Root = React.forwardRef((props, forwardedRef) => {
|
|
|
85
98
|
className,
|
|
86
99
|
...rest
|
|
87
100
|
} = props;
|
|
88
|
-
const ref = React.useRef(null);
|
|
89
|
-
const mergedRefs = (0, index_js_1.useMergedRefs)(ref, forwardedRef);
|
|
90
101
|
const prefersDark = (0, index_js_1.useMediaQuery)(
|
|
91
102
|
'(prefers-color-scheme: dark)',
|
|
92
103
|
);
|
|
@@ -105,9 +116,31 @@ const Root = React.forwardRef((props, forwardedRef) => {
|
|
|
105
116
|
),
|
|
106
117
|
'data-iui-theme': shouldApplyDark ? 'dark' : 'light',
|
|
107
118
|
'data-iui-contrast': shouldApplyHC ? 'high' : 'default',
|
|
108
|
-
ref:
|
|
119
|
+
ref: forwardedRef,
|
|
109
120
|
...rest,
|
|
110
121
|
},
|
|
111
122
|
children,
|
|
112
123
|
);
|
|
113
124
|
});
|
|
125
|
+
// ----------------------------------------------------------------------------
|
|
126
|
+
/**
|
|
127
|
+
* Returns theme from either parent context or by reading the closest
|
|
128
|
+
* data-iui-theme attribute if context is not found.
|
|
129
|
+
*/
|
|
130
|
+
const useParentTheme = () => {
|
|
131
|
+
const parentContext = React.useContext(ThemeContext_js_1.ThemeContext);
|
|
132
|
+
const rootRef = React.useRef(null);
|
|
133
|
+
const [parentThemeState, setParentTheme] = React.useState(
|
|
134
|
+
parentContext?.theme,
|
|
135
|
+
);
|
|
136
|
+
(0, index_js_1.useIsomorphicLayoutEffect)(() => {
|
|
137
|
+
setParentTheme(
|
|
138
|
+
(old) =>
|
|
139
|
+
old ||
|
|
140
|
+
rootRef.current?.parentElement
|
|
141
|
+
?.closest('[data-iui-theme]')
|
|
142
|
+
?.getAttribute('data-iui-theme'),
|
|
143
|
+
);
|
|
144
|
+
}, []);
|
|
145
|
+
return [parentContext?.theme ?? parentThemeState, rootRef];
|
|
146
|
+
};
|
package/cjs/core/Tile/Tile.d.ts
CHANGED
|
@@ -125,10 +125,11 @@ export declare const Tile: PolymorphicForwardRefComponent<"div", TileOwnProps> &
|
|
|
125
125
|
*/
|
|
126
126
|
IconButton: PolymorphicForwardRefComponent<"button", Omit<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
127
127
|
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
128
|
-
}, "label" | "as" | "size" | "styleType" | "isActive"> & {
|
|
128
|
+
}, "label" | "as" | "size" | "htmlDisabled" | "styleType" | "isActive" | "iconProps"> & {
|
|
129
129
|
isActive?: boolean | undefined;
|
|
130
130
|
label?: React.ReactNode;
|
|
131
|
-
|
|
131
|
+
iconProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | undefined;
|
|
132
|
+
} & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
|
|
132
133
|
as?: "button" | undefined;
|
|
133
134
|
}, "ref">>;
|
|
134
135
|
/**
|
package/cjs/core/Toast/Toast.js
CHANGED
|
@@ -48,9 +48,9 @@ const Toast = (props) => {
|
|
|
48
48
|
const [margin, setMargin] = React.useState(0);
|
|
49
49
|
const marginStyle = () => {
|
|
50
50
|
if (placementPosition === 'top') {
|
|
51
|
-
return {
|
|
51
|
+
return { marginBlockEnd: margin };
|
|
52
52
|
}
|
|
53
|
-
return {
|
|
53
|
+
return { marginBlockStart: margin };
|
|
54
54
|
};
|
|
55
55
|
React.useEffect(() => {
|
|
56
56
|
if (type === 'temporary') {
|
|
@@ -194,13 +194,8 @@ const ToastPresentation = (props) => {
|
|
|
194
194
|
React.createElement(index_js_1.Box, { className: 'iui-message' }, content),
|
|
195
195
|
link &&
|
|
196
196
|
React.createElement(
|
|
197
|
-
index_js_1.
|
|
198
|
-
{
|
|
199
|
-
as: 'button',
|
|
200
|
-
className: 'iui-toast-anchor',
|
|
201
|
-
...link,
|
|
202
|
-
title: undefined,
|
|
203
|
-
},
|
|
197
|
+
index_js_1.ButtonBase,
|
|
198
|
+
{ className: 'iui-toast-anchor', ...link, title: undefined },
|
|
204
199
|
link.title,
|
|
205
200
|
),
|
|
206
201
|
(type === 'persisting' || hasCloseButton) &&
|
|
@@ -55,7 +55,7 @@ type TooltipOwnProps = {
|
|
|
55
55
|
children?: React.ReactNode;
|
|
56
56
|
/**
|
|
57
57
|
* Element to portal tooltip to.
|
|
58
|
-
* Portals to ThemeProvider
|
|
58
|
+
* Portals to ThemeProvider portalContainer by default.
|
|
59
59
|
* @default true;
|
|
60
60
|
*/
|
|
61
61
|
portal?: boolean | {
|
|
@@ -124,8 +124,7 @@ exports.Tooltip = React.forwardRef((props, forwardRef) => {
|
|
|
124
124
|
typeof portal !== 'boolean'
|
|
125
125
|
? portal.to
|
|
126
126
|
: portal
|
|
127
|
-
? context?.
|
|
128
|
-
(0, index_js_1.getDocument)()?.body
|
|
127
|
+
? context?.portalContainer || (0, index_js_1.getDocument)()?.body
|
|
129
128
|
: null;
|
|
130
129
|
const contentBox = React.createElement(
|
|
131
130
|
index_js_1.Box,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PolymorphicForwardRefComponent } from '../props.js';
|
|
2
|
+
export declare const ButtonBase: PolymorphicForwardRefComponent<"button", ButtonBaseProps>;
|
|
3
|
+
type ButtonBaseProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Custom `disabled` prop that keeps the button focusable, prevents
|
|
6
|
+
* clicks, applied disabled styling, and adds `aria-disabled`.
|
|
7
|
+
*/
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Built-in html `disabled` attribute
|
|
11
|
+
*/
|
|
12
|
+
htmlDisabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.ButtonBase = void 0;
|
|
4
|
+
const tslib_1 = require('tslib');
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
const React = tslib_1.__importStar(require('react'));
|
|
10
|
+
const classnames_1 = tslib_1.__importDefault(require('classnames'));
|
|
11
|
+
const Box_js_1 = require('./Box.js');
|
|
12
|
+
const useIsClient_js_1 = require('../hooks/useIsClient.js');
|
|
13
|
+
exports.ButtonBase = React.forwardRef((props, forwardedRef) => {
|
|
14
|
+
const {
|
|
15
|
+
as: asProp = 'button',
|
|
16
|
+
disabled: disabledProp,
|
|
17
|
+
htmlDisabled,
|
|
18
|
+
...rest
|
|
19
|
+
} = props;
|
|
20
|
+
const isClient = (0, useIsClient_js_1.useIsClient)();
|
|
21
|
+
const ariaDisabled =
|
|
22
|
+
disabledProp &&
|
|
23
|
+
!htmlDisabled && // htmlDisabled prop takes preference
|
|
24
|
+
isClient && // progressively enhance after first render
|
|
25
|
+
asProp === 'button'; // ignore if not button, e.g. links
|
|
26
|
+
const handleIfEnabled = (handler) => (e) => {
|
|
27
|
+
if (disabledProp) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
handler?.(e);
|
|
31
|
+
};
|
|
32
|
+
return React.createElement(Box_js_1.Box, {
|
|
33
|
+
as: asProp,
|
|
34
|
+
type: asProp === 'button' ? 'button' : undefined,
|
|
35
|
+
ref: forwardedRef,
|
|
36
|
+
'aria-disabled': ariaDisabled ? 'true' : undefined,
|
|
37
|
+
'data-iui-disabled': disabledProp ? 'true' : undefined,
|
|
38
|
+
disabled: htmlDisabled ?? (!isClient && disabledProp) ? true : undefined,
|
|
39
|
+
...rest,
|
|
40
|
+
className: (0, classnames_1.default)('iui-button-base', props.className),
|
|
41
|
+
onClick: handleIfEnabled(props.onClick),
|
|
42
|
+
onPointerDown: handleIfEnabled(props.onPointerDown),
|
|
43
|
+
onPointerUp: handleIfEnabled(props.onPointerUp),
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
exports.ButtonBase.displayName = 'ButtonBase';
|
|
@@ -40,8 +40,7 @@ exports.Popover = React.forwardRef((props, ref) => {
|
|
|
40
40
|
const computedProps = {
|
|
41
41
|
allowHTML: true,
|
|
42
42
|
animation: false,
|
|
43
|
-
appendTo: (el) =>
|
|
44
|
-
themeInfo?.portalContainerRef?.current || el.ownerDocument.body,
|
|
43
|
+
appendTo: (el) => themeInfo?.portalContainer || el.ownerDocument.body,
|
|
45
44
|
arrow: false,
|
|
46
45
|
duration: 0,
|
|
47
46
|
interactive: true,
|
|
@@ -66,7 +65,10 @@ exports.Popover = React.forwardRef((props, ref) => {
|
|
|
66
65
|
...props.popperOptions,
|
|
67
66
|
modifiers: [
|
|
68
67
|
{ name: 'flip' },
|
|
69
|
-
{
|
|
68
|
+
{
|
|
69
|
+
name: 'preventOverflow',
|
|
70
|
+
options: { padding: 0 },
|
|
71
|
+
},
|
|
70
72
|
...(props.popperOptions?.modifiers || []),
|
|
71
73
|
],
|
|
72
74
|
},
|
|
@@ -37,7 +37,10 @@ const Resizer = (props) => {
|
|
|
37
37
|
let height = `${initialHeight}px`;
|
|
38
38
|
let translateX = initialTranslateX;
|
|
39
39
|
let translateY = initialTranslateY;
|
|
40
|
-
|
|
40
|
+
let minWidth = parseFloat(getComputedStyle(elementRef.current).minWidth);
|
|
41
|
+
if (Number.isNaN(minWidth)) {
|
|
42
|
+
minWidth = 380;
|
|
43
|
+
}
|
|
41
44
|
const minHeight = parseFloat(
|
|
42
45
|
getComputedStyle(elementRef.current).minHeight,
|
|
43
46
|
);
|
|
@@ -105,6 +108,8 @@ const Resizer = (props) => {
|
|
|
105
108
|
}
|
|
106
109
|
case 'right': {
|
|
107
110
|
width = elementRef.current.style.width = `${initialWidth - diffX}px`;
|
|
111
|
+
height = elementRef.current.style.height = `${initialHeight}px`;
|
|
112
|
+
elementRef.current.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
108
113
|
break;
|
|
109
114
|
}
|
|
110
115
|
case 'bottom-right': {
|
|
@@ -112,12 +117,14 @@ const Resizer = (props) => {
|
|
|
112
117
|
height = elementRef.current.style.height = `${
|
|
113
118
|
initialHeight - diffY
|
|
114
119
|
}px`;
|
|
120
|
+
elementRef.current.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
115
121
|
break;
|
|
116
122
|
}
|
|
117
123
|
case 'bottom': {
|
|
118
124
|
height = elementRef.current.style.height = `${
|
|
119
125
|
initialHeight - diffY
|
|
120
126
|
}px`;
|
|
127
|
+
elementRef.current.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
121
128
|
break;
|
|
122
129
|
}
|
|
123
130
|
case 'bottom-left': {
|
|
@@ -138,6 +145,7 @@ const Resizer = (props) => {
|
|
|
138
145
|
break;
|
|
139
146
|
}
|
|
140
147
|
width = elementRef.current.style.width = `${newWidth}px`;
|
|
148
|
+
height = elementRef.current.style.height = `${initialHeight}px`;
|
|
141
149
|
translateX = initialTranslateX - diffX;
|
|
142
150
|
elementRef.current.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
143
151
|
break;
|
|
@@ -172,8 +180,8 @@ const Resizer = (props) => {
|
|
|
172
180
|
onPointerDown: onResizePointerDown,
|
|
173
181
|
style: {
|
|
174
182
|
position: 'absolute',
|
|
175
|
-
top:
|
|
176
|
-
left:
|
|
183
|
+
top: 0,
|
|
184
|
+
left: 0,
|
|
177
185
|
width: 12,
|
|
178
186
|
height: 12,
|
|
179
187
|
cursor: 'nw-resize',
|
|
@@ -184,7 +192,7 @@ const Resizer = (props) => {
|
|
|
184
192
|
onPointerDown: onResizePointerDown,
|
|
185
193
|
style: {
|
|
186
194
|
position: 'absolute',
|
|
187
|
-
top:
|
|
195
|
+
top: 0,
|
|
188
196
|
left: 8,
|
|
189
197
|
right: 8,
|
|
190
198
|
height: 8,
|
|
@@ -196,8 +204,8 @@ const Resizer = (props) => {
|
|
|
196
204
|
onPointerDown: onResizePointerDown,
|
|
197
205
|
style: {
|
|
198
206
|
position: 'absolute',
|
|
199
|
-
top:
|
|
200
|
-
right:
|
|
207
|
+
top: 0,
|
|
208
|
+
right: 0,
|
|
201
209
|
width: 12,
|
|
202
210
|
height: 12,
|
|
203
211
|
cursor: 'ne-resize',
|
|
@@ -209,7 +217,7 @@ const Resizer = (props) => {
|
|
|
209
217
|
style: {
|
|
210
218
|
position: 'absolute',
|
|
211
219
|
top: 8,
|
|
212
|
-
right:
|
|
220
|
+
right: 0,
|
|
213
221
|
bottom: 8,
|
|
214
222
|
width: 8,
|
|
215
223
|
cursor: 'e-resize',
|
|
@@ -220,8 +228,8 @@ const Resizer = (props) => {
|
|
|
220
228
|
onPointerDown: onResizePointerDown,
|
|
221
229
|
style: {
|
|
222
230
|
position: 'absolute',
|
|
223
|
-
bottom:
|
|
224
|
-
right:
|
|
231
|
+
bottom: 0,
|
|
232
|
+
right: 0,
|
|
225
233
|
width: 12,
|
|
226
234
|
height: 12,
|
|
227
235
|
cursor: 'se-resize',
|
|
@@ -232,7 +240,7 @@ const Resizer = (props) => {
|
|
|
232
240
|
onPointerDown: onResizePointerDown,
|
|
233
241
|
style: {
|
|
234
242
|
position: 'absolute',
|
|
235
|
-
bottom:
|
|
243
|
+
bottom: 0,
|
|
236
244
|
left: 8,
|
|
237
245
|
right: 8,
|
|
238
246
|
height: 8,
|
|
@@ -244,8 +252,8 @@ const Resizer = (props) => {
|
|
|
244
252
|
onPointerDown: onResizePointerDown,
|
|
245
253
|
style: {
|
|
246
254
|
position: 'absolute',
|
|
247
|
-
bottom:
|
|
248
|
-
left:
|
|
255
|
+
bottom: 0,
|
|
256
|
+
left: 0,
|
|
249
257
|
width: 12,
|
|
250
258
|
height: 12,
|
|
251
259
|
cursor: 'sw-resize',
|
|
@@ -257,7 +265,7 @@ const Resizer = (props) => {
|
|
|
257
265
|
style: {
|
|
258
266
|
position: 'absolute',
|
|
259
267
|
top: 8,
|
|
260
|
-
left:
|
|
268
|
+
left: 0,
|
|
261
269
|
bottom: 8,
|
|
262
270
|
width: 8,
|
|
263
271
|
cursor: 'w-resize',
|
|
@@ -36,8 +36,8 @@ const getElementHeightWithMargins = (element) => {
|
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
const margin =
|
|
39
|
-
parseFloat(getElementStyle(element, 'margin-
|
|
40
|
-
parseFloat(getElementStyle(element, 'margin-
|
|
39
|
+
parseFloat(getElementStyle(element, 'margin-block-start')) +
|
|
40
|
+
parseFloat(getElementStyle(element, 'margin-block-end'));
|
|
41
41
|
return getElementHeight(element) + (isNaN(margin) ? 0 : margin);
|
|
42
42
|
};
|
|
43
43
|
const getNumberOfNodesInHeight = (childHeight, totalHeight) => {
|
|
@@ -350,13 +350,13 @@ const useVirtualization = (props) => {
|
|
|
350
350
|
return {
|
|
351
351
|
outerProps: {
|
|
352
352
|
style: {
|
|
353
|
-
|
|
353
|
+
minBlockSize:
|
|
354
354
|
itemsLength > 1
|
|
355
355
|
? Math.max(itemsLength - 2, 0) * childHeight.current.middle +
|
|
356
356
|
childHeight.current.first +
|
|
357
357
|
childHeight.current.last
|
|
358
358
|
: childHeight.current.middle,
|
|
359
|
-
|
|
359
|
+
minInlineSize: '100%',
|
|
360
360
|
...style,
|
|
361
361
|
},
|
|
362
362
|
...rest,
|
|
@@ -20,3 +20,4 @@ tslib_1.__exportStar(require('./Divider.js'), exports);
|
|
|
20
20
|
tslib_1.__exportStar(require('./LinkAction.js'), exports);
|
|
21
21
|
tslib_1.__exportStar(require('./AutoclearingHiddenLiveRegion.js'), exports);
|
|
22
22
|
tslib_1.__exportStar(require('./Box.js'), exports);
|
|
23
|
+
tslib_1.__exportStar(require('./ButtonBase.js'), exports);
|
|
@@ -17,4 +17,4 @@ export declare const isSoftBackground: (value: string) => value is "skyblue" | "
|
|
|
17
17
|
* Generate color from user name or email.
|
|
18
18
|
* Recommended to use for `backgroundColor` in `Avatar` component.
|
|
19
19
|
*/
|
|
20
|
-
export declare const getUserColor: (emailOrName: string) =>
|
|
20
|
+
export declare const getUserColor: (emailOrName: string) => "var(--iui-color-background-skyblue)" | "var(--iui-color-background-celery)" | "var(--iui-color-background-froly)" | "var(--iui-color-background-steelblue)" | "var(--iui-color-background-sunglow)" | "var(--iui-color-background-seabuckthorn)" | "var(--iui-color-background-montecarlo)" | "var(--iui-color-background-poloblue)" | "var(--iui-color-background-bouquet)" | "var(--iui-color-background-ash)" | "var(--iui-color-background-oak)";
|
|
@@ -26,19 +26,7 @@ const isSoftBackground = (value) => {
|
|
|
26
26
|
return Object.keys(exports.SoftBackgrounds).includes(value);
|
|
27
27
|
};
|
|
28
28
|
exports.isSoftBackground = isSoftBackground;
|
|
29
|
-
const USER_COLORS =
|
|
30
|
-
'#6AB9EC',
|
|
31
|
-
'#B1C854',
|
|
32
|
-
'#F7706C',
|
|
33
|
-
'#4585A5',
|
|
34
|
-
'#FFC335',
|
|
35
|
-
'#F7963E',
|
|
36
|
-
'#73C7C1',
|
|
37
|
-
'#85A9CF',
|
|
38
|
-
'#A3779F',
|
|
39
|
-
'#C8C2B4',
|
|
40
|
-
'#A47854',
|
|
41
|
-
];
|
|
29
|
+
const USER_COLORS = Object.values(exports.SoftBackgrounds);
|
|
42
30
|
/**
|
|
43
31
|
* Generate color from user name or email.
|
|
44
32
|
* Recommended to use for `backgroundColor` in `Avatar` component.
|
|
@@ -18,3 +18,4 @@ tslib_1.__exportStar(require('./useLatestRef.js'), exports);
|
|
|
18
18
|
tslib_1.__exportStar(require('./useIsomorphicLayoutEffect.js'), exports);
|
|
19
19
|
tslib_1.__exportStar(require('./useIsClient.js'), exports);
|
|
20
20
|
tslib_1.__exportStar(require('./useId.js'), exports);
|
|
21
|
+
tslib_1.__exportStar(require('./useUncontrolledState.js'), exports);
|
|
@@ -9,7 +9,7 @@ import { ThemeContext } from '../../ThemeProvider/ThemeContext.js';
|
|
|
9
9
|
export declare const useGlobals: () => {
|
|
10
10
|
theme?: import("../../index.js").ThemeType | undefined;
|
|
11
11
|
themeOptions?: import("../../ThemeProvider/ThemeProvider.js").ThemeOptions | undefined;
|
|
12
|
-
|
|
12
|
+
portalContainer?: HTMLElement | null | undefined;
|
|
13
13
|
} | undefined;
|
|
14
14
|
/** Shows console error if ThemeProvider is not used */
|
|
15
15
|
export declare const useThemeProviderWarning: (themeContext: React.ContextType<typeof ThemeContext>) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper over `useState` that always gives preference to the
|
|
4
|
+
* uncontrolled state (which often comes from a prop).
|
|
5
|
+
*/
|
|
6
|
+
export declare const useUncontrolledState: <T>(uncontrolledState: T) => readonly [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.useUncontrolledState = void 0;
|
|
4
|
+
const tslib_1 = require('tslib');
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
const React = tslib_1.__importStar(require('react'));
|
|
10
|
+
/**
|
|
11
|
+
* Wrapper over `useState` that always gives preference to the
|
|
12
|
+
* uncontrolled state (which often comes from a prop).
|
|
13
|
+
*/
|
|
14
|
+
const useUncontrolledState = (uncontrolledState) => {
|
|
15
|
+
const [controlledState, setControlledState] = React.useState();
|
|
16
|
+
return [uncontrolledState ?? controlledState, setControlledState];
|
|
17
|
+
};
|
|
18
|
+
exports.useUncontrolledState = useUncontrolledState;
|
package/cjs/styles.js
CHANGED
|
@@ -11,13 +11,6 @@ const styles = {
|
|
|
11
11
|
'iui-anchor': '_iui3-anchor',
|
|
12
12
|
'iui-anchor-external': '_iui3-anchor-external',
|
|
13
13
|
'iui-avatar': '_iui3-avatar',
|
|
14
|
-
'iui-stroke': '_iui3-stroke',
|
|
15
|
-
'iui-initials': '_iui3-initials',
|
|
16
|
-
'iui-status': '_iui3-status',
|
|
17
|
-
'iui-online': '_iui3-online',
|
|
18
|
-
'iui-away': '_iui3-away',
|
|
19
|
-
'iui-busy': '_iui3-busy',
|
|
20
|
-
'iui-offline': '_iui3-offline',
|
|
21
14
|
'iui-avatar-count': '_iui3-avatar-count',
|
|
22
15
|
'iui-small': '_iui3-small',
|
|
23
16
|
'iui-large': '_iui3-large',
|
|
@@ -108,6 +101,7 @@ const styles = {
|
|
|
108
101
|
'iui-calendar-day-range-today': '_iui3-calendar-day-range-today',
|
|
109
102
|
'iui-dialog-wrapper': '_iui3-dialog-wrapper',
|
|
110
103
|
'iui-dialog': '_iui3-dialog',
|
|
104
|
+
'iui-dialog-content': '_iui3-dialog-content',
|
|
111
105
|
'iui-dialog-visible': '_iui3-dialog-visible',
|
|
112
106
|
'iui-dialog-default': '_iui3-dialog-default',
|
|
113
107
|
'iui-dialog-full-page': '_iui3-dialog-full-page',
|
|
@@ -117,7 +111,6 @@ const styles = {
|
|
|
117
111
|
'iui-dialog-title': '_iui3-dialog-title',
|
|
118
112
|
'iui-dialog-title-bar': '_iui3-dialog-title-bar',
|
|
119
113
|
'iui-dialog-title-bar-filled': '_iui3-dialog-title-bar-filled',
|
|
120
|
-
'iui-dialog-content': '_iui3-dialog-content',
|
|
121
114
|
'iui-dialog-button-bar': '_iui3-dialog-button-bar',
|
|
122
115
|
'iui-expandable-block': '_iui3-expandable-block',
|
|
123
116
|
'iui-expandable-header': '_iui3-expandable-header',
|
|
@@ -243,13 +236,12 @@ const styles = {
|
|
|
243
236
|
'iui-overlay-exiting': '_iui3-overlay-exiting',
|
|
244
237
|
closeAnimation,
|
|
245
238
|
'iui-progress-indicator-radial': '_iui3-progress-indicator-radial',
|
|
246
|
-
'iui-
|
|
239
|
+
'iui-u8bwhh6': '_iui3-u8bwhh6',
|
|
247
240
|
'iui-progress-indicator-linear-label':
|
|
248
241
|
'_iui3-progress-indicator-linear-label',
|
|
249
|
-
'iui-
|
|
242
|
+
'iui-u8bwhhv': '_iui3-u8bwhhv',
|
|
250
243
|
'iui-radio': '_iui3-radio',
|
|
251
244
|
'iui-radio-tile': '_iui3-radio-tile',
|
|
252
|
-
'iui-radio-tile-content': '_iui3-radio-tile-content',
|
|
253
245
|
'iui-radio-tile-icon': '_iui3-radio-tile-icon',
|
|
254
246
|
'iui-radio-tile-container': '_iui3-radio-tile-container',
|
|
255
247
|
'iui-radio-tile-input': '_iui3-radio-tile-input',
|
|
@@ -439,6 +431,7 @@ const styles = {
|
|
|
439
431
|
'iui-tree-node-content-label': '_iui3-tree-node-content-label',
|
|
440
432
|
'iui-tree-node-content-title': '_iui3-tree-node-content-title',
|
|
441
433
|
'iui-tree-node-content-caption': '_iui3-tree-node-content-caption',
|
|
434
|
+
'iui-button-base': '_iui3-button-base',
|
|
442
435
|
'iui-svg-icon': '_iui3-svg-icon',
|
|
443
436
|
'iui-notification-marker': '_iui3-notification-marker',
|
|
444
437
|
pulse,
|