@itwin/itwinui-react 1.48.0 → 2.0.0-dev.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 +6 -0
- package/README.md +4 -22
- package/cjs/core/Alert/Alert.d.ts +7 -6
- package/cjs/core/Alert/Alert.js +12 -7
- package/cjs/core/Avatar/Avatar.d.ts +69 -0
- package/cjs/core/{UserIcon/UserIcon.js → Avatar/Avatar.js} +15 -11
- package/cjs/core/Avatar/index.d.ts +4 -0
- package/cjs/core/{UserIcon → Avatar}/index.js +5 -4
- package/cjs/core/AvatarGroup/AvatarGroup.d.ts +70 -0
- package/cjs/core/{UserIconGroup/UserIconGroup.js → AvatarGroup/AvatarGroup.js} +23 -19
- package/cjs/core/AvatarGroup/index.d.ts +4 -0
- package/cjs/core/{UserIconGroup → AvatarGroup}/index.js +5 -4
- package/cjs/core/Badge/Badge.js +2 -4
- package/cjs/core/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/cjs/core/Buttons/Button/Button.js +5 -14
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +1 -1
- package/cjs/core/Buttons/IconButton/IconButton.js +3 -9
- package/cjs/core/Buttons/IdeasButton/IdeasButton.js +1 -1
- package/cjs/core/Buttons/SplitButton/SplitButton.js +4 -6
- package/cjs/core/Checkbox/Checkbox.d.ts +1 -29
- package/cjs/core/Checkbox/Checkbox.js +3 -3
- package/cjs/core/ColorPicker/ColorBuilder.js +16 -27
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/ColorPicker/ColorSwatch.js +1 -6
- package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenu.js +2 -4
- package/cjs/core/Dialog/Dialog.d.ts +4 -4
- package/cjs/core/Dialog/Dialog.js +1 -1
- package/cjs/core/Dialog/DialogBackdrop.d.ts +1 -1
- package/cjs/core/Dialog/DialogBackdrop.js +5 -2
- package/cjs/core/Dialog/DialogMain.d.ts +1 -1
- package/cjs/core/Dialog/DialogMain.js +7 -1
- package/cjs/core/Dialog/DialogTitleBar.d.ts +1 -1
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +4 -4
- package/cjs/core/Header/Header.d.ts +16 -6
- package/cjs/core/Header/Header.js +7 -9
- package/cjs/core/Header/HeaderBasicButton.d.ts +6 -0
- package/cjs/core/Header/HeaderBasicButton.js +52 -0
- package/cjs/core/Header/HeaderBreadcrumbs.js +6 -4
- package/cjs/core/Header/HeaderButton.d.ts +3 -2
- package/cjs/core/Header/HeaderButton.js +10 -18
- package/cjs/core/Header/HeaderDropdownButton.d.ts +6 -0
- package/cjs/core/Header/HeaderDropdownButton.js +56 -0
- package/cjs/core/Header/HeaderLogo.js +3 -3
- package/cjs/core/Header/HeaderSplitButton.d.ts +6 -0
- package/cjs/core/Header/HeaderSplitButton.js +56 -0
- package/cjs/core/Input/Input.d.ts +1 -1
- package/cjs/core/Input/Input.js +3 -4
- package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
- package/cjs/core/InputGroup/InputGroup.js +1 -1
- package/cjs/core/Label/Label.d.ts +1 -1
- package/cjs/core/Label/Label.js +1 -1
- package/cjs/core/LabeledInput/LabeledInput.d.ts +2 -2
- package/cjs/core/LabeledInput/LabeledInput.js +1 -1
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +1 -1
- package/cjs/core/LabeledSelect/LabeledSelect.js +1 -1
- package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/cjs/core/Radio/Radio.d.ts +1 -29
- package/cjs/core/Radio/Radio.js +3 -3
- package/cjs/core/RadioTiles/RadioTileGroup.d.ts +1 -1
- package/cjs/core/RadioTiles/RadioTileGroup.js +1 -1
- package/cjs/core/Select/Select.d.ts +1 -1
- package/cjs/core/Select/Select.js +9 -12
- package/cjs/core/Select/SelectTag.d.ts +1 -1
- package/cjs/core/Select/SelectTag.js +1 -1
- package/cjs/core/SideNavigation/SidenavButton.js +1 -2
- package/cjs/core/Stepper/Stepper.d.ts +40 -0
- package/cjs/core/{Wizard/Wizard.js → Stepper/Stepper.js} +11 -28
- package/cjs/core/{Wizard/Step.d.ts → Stepper/StepperStep.d.ts} +6 -7
- package/cjs/core/{Wizard/Step.js → Stepper/StepperStep.js} +10 -10
- package/cjs/core/Stepper/Wizard.d.ts +46 -0
- package/cjs/core/Stepper/Wizard.js +55 -0
- package/cjs/core/Stepper/WorkflowDiagram.d.ts +6 -0
- package/cjs/core/Stepper/WorkflowDiagram.js +43 -0
- package/cjs/core/Stepper/WorkflowDiagramStep.d.ts +5 -0
- package/cjs/core/Stepper/WorkflowDiagramStep.js +42 -0
- package/cjs/core/Stepper/index.d.ts +8 -0
- package/cjs/core/{Wizard → Stepper}/index.js +5 -1
- package/cjs/core/Surface/Surface.js +2 -4
- package/cjs/core/Table/SubRowExpander.js +1 -1
- package/cjs/core/Table/Table.d.ts +5 -4
- package/cjs/core/Table/Table.js +30 -21
- package/cjs/core/Table/TableCell.js +4 -4
- package/cjs/core/Table/TablePaginator.js +14 -15
- package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
- package/cjs/core/Table/TableRowMemoized.js +10 -13
- package/cjs/core/Table/cells/DefaultCell.js +4 -9
- package/cjs/core/Table/columns/actionColumn.js +1 -1
- package/cjs/core/Table/columns/expanderColumn.js +1 -1
- package/cjs/core/Table/filters/BaseFilter.js +1 -1
- package/cjs/core/Table/filters/FilterToggle.js +1 -1
- package/cjs/core/Table/hooks/useColumnDragAndDrop.js +4 -4
- package/cjs/core/Table/hooks/useResizeColumns.js +110 -106
- package/cjs/core/Tabs/Tab.d.ts +0 -8
- package/cjs/core/Tabs/Tab.js +1 -5
- package/cjs/core/Tabs/Tabs.js +8 -11
- package/cjs/core/Tabs/index.d.ts +2 -2
- package/cjs/core/Tabs/index.js +1 -2
- package/cjs/core/Textarea/Textarea.d.ts +1 -1
- package/cjs/core/Textarea/Textarea.js +2 -2
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +27 -17
- package/cjs/core/ThemeProvider/ThemeProvider.js +64 -7
- package/cjs/core/Tile/Tile.d.ts +19 -1
- package/cjs/core/Tile/Tile.js +35 -12
- package/cjs/core/Toast/Toast.d.ts +3 -3
- package/cjs/core/Toast/Toast.js +3 -3
- package/cjs/core/Toast/ToastWrapper.d.ts +1 -1
- package/cjs/core/Toast/ToastWrapper.js +1 -1
- package/cjs/core/Tree/TreeNode.js +1 -7
- package/cjs/core/index.d.ts +8 -8
- package/cjs/core/index.js +13 -10
- package/cjs/core/utils/components/Popover.d.ts +2 -2
- package/cjs/core/utils/components/Popover.js +1 -1
- package/cjs/core/utils/components/Resizer.d.ts +5 -0
- package/cjs/core/utils/components/Resizer.js +7 -1
- package/cjs/core/utils/components/VisuallyHidden.d.ts +1 -0
- package/cjs/core/utils/components/VisuallyHidden.js +1 -0
- package/cjs/core/utils/functions/colors.d.ts +1 -1
- package/cjs/core/utils/functions/colors.js +1 -1
- package/cjs/core/utils/functions/dom.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/useIsomorphicLayoutEffect.d.ts +7 -0
- package/cjs/core/utils/hooks/useIsomorphicLayoutEffect.js +17 -0
- package/cjs/core/utils/hooks/useMediaQuery.js +2 -1
- package/cjs/core/utils/hooks/useTheme.d.ts +20 -3
- package/cjs/core/utils/hooks/useTheme.js +57 -58
- package/esm/core/Alert/Alert.d.ts +7 -6
- package/esm/core/Alert/Alert.js +12 -7
- package/esm/core/Avatar/Avatar.d.ts +69 -0
- package/esm/core/{UserIcon/UserIcon.js → Avatar/Avatar.js} +13 -9
- package/esm/core/Avatar/index.d.ts +4 -0
- package/esm/core/{UserIcon → Avatar}/index.js +2 -2
- package/esm/core/AvatarGroup/AvatarGroup.d.ts +70 -0
- package/esm/core/{UserIconGroup/UserIconGroup.js → AvatarGroup/AvatarGroup.js} +21 -17
- package/esm/core/AvatarGroup/index.d.ts +4 -0
- package/esm/core/{UserIconGroup → AvatarGroup}/index.js +2 -2
- package/esm/core/Badge/Badge.js +3 -5
- package/esm/core/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/esm/core/Buttons/Button/Button.js +5 -14
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -1
- package/esm/core/Buttons/IconButton/IconButton.js +3 -9
- package/esm/core/Buttons/IdeasButton/IdeasButton.js +1 -1
- package/esm/core/Buttons/SplitButton/SplitButton.js +4 -6
- package/esm/core/Checkbox/Checkbox.d.ts +1 -29
- package/esm/core/Checkbox/Checkbox.js +3 -3
- package/esm/core/ColorPicker/ColorBuilder.js +17 -28
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/ColorPicker/ColorSwatch.js +2 -7
- package/esm/core/ComboBox/ComboBoxDropdown.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenu.js +2 -4
- package/esm/core/Dialog/Dialog.d.ts +4 -4
- package/esm/core/Dialog/Dialog.js +1 -1
- package/esm/core/Dialog/DialogBackdrop.d.ts +1 -1
- package/esm/core/Dialog/DialogBackdrop.js +5 -2
- package/esm/core/Dialog/DialogMain.d.ts +1 -1
- package/esm/core/Dialog/DialogMain.js +7 -1
- package/esm/core/Dialog/DialogTitleBar.d.ts +1 -1
- package/esm/core/ExpandableBlock/ExpandableBlock.js +4 -4
- package/esm/core/Header/Header.d.ts +16 -6
- package/esm/core/Header/Header.js +7 -9
- package/esm/core/Header/HeaderBasicButton.d.ts +6 -0
- package/esm/core/Header/HeaderBasicButton.js +46 -0
- package/esm/core/Header/HeaderBreadcrumbs.js +6 -4
- package/esm/core/Header/HeaderButton.d.ts +3 -2
- package/esm/core/Header/HeaderButton.js +10 -18
- package/esm/core/Header/HeaderDropdownButton.d.ts +6 -0
- package/esm/core/Header/HeaderDropdownButton.js +50 -0
- package/esm/core/Header/HeaderLogo.js +3 -3
- package/esm/core/Header/HeaderSplitButton.d.ts +6 -0
- package/esm/core/Header/HeaderSplitButton.js +50 -0
- package/esm/core/Input/Input.d.ts +1 -1
- package/esm/core/Input/Input.js +3 -4
- package/esm/core/InputGroup/InputGroup.d.ts +1 -1
- package/esm/core/InputGroup/InputGroup.js +1 -1
- package/esm/core/Label/Label.d.ts +1 -1
- package/esm/core/Label/Label.js +1 -1
- package/esm/core/LabeledInput/LabeledInput.d.ts +2 -2
- package/esm/core/LabeledInput/LabeledInput.js +1 -1
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +1 -1
- package/esm/core/LabeledSelect/LabeledSelect.js +1 -1
- package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
- package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/esm/core/Radio/Radio.d.ts +1 -29
- package/esm/core/Radio/Radio.js +3 -3
- package/esm/core/RadioTiles/RadioTileGroup.d.ts +1 -1
- package/esm/core/RadioTiles/RadioTileGroup.js +1 -1
- package/esm/core/Select/Select.d.ts +1 -1
- package/esm/core/Select/Select.js +9 -12
- package/esm/core/Select/SelectTag.d.ts +1 -1
- package/esm/core/Select/SelectTag.js +1 -1
- package/esm/core/SideNavigation/SidenavButton.js +1 -2
- package/esm/core/Stepper/Stepper.d.ts +40 -0
- package/esm/core/{Wizard/Wizard.js → Stepper/Stepper.js} +10 -27
- package/esm/core/{Wizard/Step.d.ts → Stepper/StepperStep.d.ts} +6 -7
- package/esm/core/{Wizard/Step.js → Stepper/StepperStep.js} +8 -8
- package/esm/core/Stepper/Wizard.d.ts +46 -0
- package/esm/core/Stepper/Wizard.js +49 -0
- package/esm/core/Stepper/WorkflowDiagram.d.ts +6 -0
- package/esm/core/Stepper/WorkflowDiagram.js +37 -0
- package/esm/core/Stepper/WorkflowDiagramStep.d.ts +5 -0
- package/esm/core/Stepper/WorkflowDiagramStep.js +35 -0
- package/esm/core/Stepper/index.d.ts +8 -0
- package/esm/core/{Wizard → Stepper}/index.js +2 -0
- package/esm/core/Surface/Surface.js +3 -5
- package/esm/core/Table/SubRowExpander.js +1 -1
- package/esm/core/Table/Table.d.ts +5 -4
- package/esm/core/Table/Table.js +30 -21
- package/esm/core/Table/TableCell.js +4 -4
- package/esm/core/Table/TablePaginator.js +14 -15
- package/esm/core/Table/TableRowMemoized.d.ts +2 -0
- package/esm/core/Table/TableRowMemoized.js +10 -13
- package/esm/core/Table/cells/DefaultCell.js +4 -9
- package/esm/core/Table/columns/actionColumn.js +1 -1
- package/esm/core/Table/columns/expanderColumn.js +1 -1
- package/esm/core/Table/filters/BaseFilter.js +1 -1
- package/esm/core/Table/filters/FilterToggle.js +1 -1
- package/esm/core/Table/hooks/useColumnDragAndDrop.js +4 -4
- package/esm/core/Table/hooks/useResizeColumns.js +110 -106
- package/esm/core/Tabs/Tab.d.ts +0 -8
- package/esm/core/Tabs/Tab.js +0 -4
- package/esm/core/Tabs/Tabs.js +9 -12
- package/esm/core/Tabs/index.d.ts +2 -2
- package/esm/core/Tabs/index.js +1 -1
- package/esm/core/Textarea/Textarea.d.ts +1 -1
- package/esm/core/Textarea/Textarea.js +2 -2
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +27 -17
- package/esm/core/ThemeProvider/ThemeProvider.js +64 -6
- package/esm/core/Tile/Tile.d.ts +19 -1
- package/esm/core/Tile/Tile.js +36 -13
- package/esm/core/Toast/Toast.d.ts +3 -3
- package/esm/core/Toast/Toast.js +3 -3
- package/esm/core/Toast/ToastWrapper.d.ts +1 -1
- package/esm/core/Toast/ToastWrapper.js +1 -1
- package/esm/core/Tree/TreeNode.js +2 -8
- package/esm/core/index.d.ts +8 -8
- package/esm/core/index.js +4 -4
- package/esm/core/utils/components/Popover.d.ts +2 -2
- package/esm/core/utils/components/Popover.js +1 -1
- package/esm/core/utils/components/Resizer.d.ts +5 -0
- package/esm/core/utils/components/Resizer.js +7 -1
- package/esm/core/utils/components/VisuallyHidden.d.ts +1 -0
- package/esm/core/utils/components/VisuallyHidden.js +1 -0
- package/esm/core/utils/functions/colors.d.ts +1 -1
- package/esm/core/utils/functions/colors.js +1 -1
- package/esm/core/utils/functions/dom.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/useIsomorphicLayoutEffect.d.ts +7 -0
- package/esm/core/utils/hooks/useIsomorphicLayoutEffect.js +11 -0
- package/esm/core/utils/hooks/useMediaQuery.js +2 -1
- package/esm/core/utils/hooks/useTheme.d.ts +20 -3
- package/esm/core/utils/hooks/useTheme.js +56 -57
- package/package.json +3 -2
- package/cjs/core/UserIcon/UserIcon.d.ts +0 -57
- package/cjs/core/UserIcon/index.d.ts +0 -4
- package/cjs/core/UserIconGroup/UserIconGroup.d.ts +0 -62
- package/cjs/core/UserIconGroup/index.d.ts +0 -4
- package/cjs/core/Wizard/Wizard.d.ts +0 -54
- package/cjs/core/Wizard/index.d.ts +0 -4
- package/esm/core/UserIcon/UserIcon.d.ts +0 -57
- package/esm/core/UserIcon/index.d.ts +0 -4
- package/esm/core/UserIconGroup/UserIconGroup.d.ts +0 -62
- package/esm/core/UserIconGroup/index.d.ts +0 -4
- package/esm/core/Wizard/Wizard.d.ts +0 -54
- package/esm/core/Wizard/index.d.ts +0 -4
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import '@itwin/itwinui-css/css/global.css';
|
|
2
|
+
import '@itwin/itwinui-variables/index.css';
|
|
2
3
|
export declare type ThemeOptions = {
|
|
3
4
|
/**
|
|
4
5
|
* Document to which the theme will be applied.
|
|
5
6
|
* Can be specified to handle popup windows.
|
|
6
7
|
* @default document
|
|
8
|
+
*
|
|
9
|
+
* @deprecated This prop will continue to work in `useTheme` but
|
|
10
|
+
* we recommend rendering `ThemeProvider` in the correct document instead.
|
|
7
11
|
*/
|
|
8
12
|
ownerDocument?: Document;
|
|
9
13
|
/**
|
|
@@ -13,10 +17,23 @@ export declare type ThemeOptions = {
|
|
|
13
17
|
highContrast?: boolean;
|
|
14
18
|
};
|
|
15
19
|
export declare type ThemeType = 'light' | 'dark' | 'os';
|
|
20
|
+
export declare type UseThemeProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Theme to be applied. If not set, light theme will be used.
|
|
23
|
+
*/
|
|
24
|
+
theme?: ThemeType;
|
|
25
|
+
/**
|
|
26
|
+
* Options that can be specified to override default theming behavior.
|
|
27
|
+
*/
|
|
28
|
+
themeOptions?: ThemeOptions;
|
|
29
|
+
};
|
|
16
30
|
/**
|
|
17
|
-
* Hook that applies styling and theme to all components.
|
|
18
|
-
* Defaults to light theme if none provided
|
|
31
|
+
* Hook that conditionally applies styling and theme to all components.
|
|
32
|
+
* Defaults to light theme if none provided.
|
|
33
|
+
*
|
|
34
|
+
* If ThemeProvider is used as an ancestor, this hook will not do anything.
|
|
35
|
+
*
|
|
19
36
|
* @param theme Light, dark, or based on OS setting.
|
|
20
37
|
* @param themeOptions Options that override default theming behavior.
|
|
21
38
|
*/
|
|
22
|
-
export declare const useTheme: (theme?:
|
|
39
|
+
export declare const useTheme: (theme?: UseThemeProps['theme'], themeOptions?: UseThemeProps['themeOptions']) => void;
|
|
@@ -9,78 +9,77 @@ exports.useTheme = void 0;
|
|
|
9
9
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
10
10
|
*--------------------------------------------------------------------------------------------*/
|
|
11
11
|
var react_1 = __importDefault(require("react"));
|
|
12
|
+
var ThemeProvider_1 = require("../../ThemeProvider/ThemeProvider");
|
|
13
|
+
var functions_1 = require("../functions");
|
|
14
|
+
var useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
|
|
12
15
|
require("@itwin/itwinui-css/css/global.css");
|
|
13
|
-
|
|
14
|
-
var useMediaQuery_1 = require("./useMediaQuery");
|
|
16
|
+
require("@itwin/itwinui-variables/index.css");
|
|
15
17
|
/**
|
|
16
|
-
* Hook that applies styling and theme to all components.
|
|
17
|
-
* Defaults to light theme if none provided
|
|
18
|
+
* Hook that conditionally applies styling and theme to all components.
|
|
19
|
+
* Defaults to light theme if none provided.
|
|
20
|
+
*
|
|
21
|
+
* If ThemeProvider is used as an ancestor, this hook will not do anything.
|
|
22
|
+
*
|
|
18
23
|
* @param theme Light, dark, or based on OS setting.
|
|
19
24
|
* @param themeOptions Options that override default theming behavior.
|
|
20
25
|
*/
|
|
21
26
|
var useTheme = function (theme, themeOptions) {
|
|
22
27
|
var _a;
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.add('iui-body');
|
|
29
|
-
}
|
|
30
|
-
}, [ownerDocument]);
|
|
31
|
-
react_1.default.useLayoutEffect(function () {
|
|
32
|
-
var _a, _b, _c, _d, _e;
|
|
33
|
-
if (!ownerDocument) {
|
|
28
|
+
var themeContext = react_1.default.useContext(ThemeProvider_1.ThemeContext);
|
|
29
|
+
var ownerDocument = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.ownerDocument) !== null && _a !== void 0 ? _a : (0, functions_1.getDocument)();
|
|
30
|
+
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(function () {
|
|
31
|
+
// exit early if theme was already set by provider
|
|
32
|
+
if (themeContext || !ownerDocument) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
var addOSTheme = function (_a) {
|
|
38
|
-
var isDark = _a.matches;
|
|
39
|
-
if (isDark) {
|
|
40
|
-
applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
44
|
-
}
|
|
45
|
-
};
|
|
35
|
+
ownerDocument.body.classList.toggle('iui-root', true);
|
|
46
36
|
switch (theme) {
|
|
47
37
|
case 'light':
|
|
48
|
-
(_c = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
49
|
-
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
50
|
-
break;
|
|
51
38
|
case 'dark':
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
default:
|
|
65
|
-
if (ownerDocument.documentElement.className.indexOf('iui-theme') === -1) {
|
|
66
|
-
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
39
|
+
case 'os': {
|
|
40
|
+
return handleTheme(theme, ownerDocument, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast);
|
|
41
|
+
}
|
|
42
|
+
default: {
|
|
43
|
+
// set light theme by default
|
|
44
|
+
if (ownerDocument.documentElement.dataset.iuiTheme == null) {
|
|
45
|
+
return handleTheme('light', ownerDocument, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast);
|
|
67
46
|
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
68
49
|
}
|
|
69
|
-
|
|
70
|
-
var _a;
|
|
71
|
-
(_a = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
72
|
-
};
|
|
73
|
-
}, [highContrast, ownerDocument, theme]);
|
|
50
|
+
}, [theme, themeContext, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast, ownerDocument]);
|
|
74
51
|
};
|
|
75
52
|
exports.useTheme = useTheme;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Helper function to apply the specified theme, or detect the OS theme.
|
|
55
|
+
* Returns a cleanup function to remove the change handlers.
|
|
56
|
+
*/
|
|
57
|
+
var handleTheme = function (theme, ownerDocument, highContrast) {
|
|
58
|
+
var _a, _b, _c, _d, _e;
|
|
59
|
+
var root = ownerDocument.documentElement;
|
|
60
|
+
var _window = (_a = ownerDocument.defaultView) !== null && _a !== void 0 ? _a : (0, functions_1.getWindow)();
|
|
61
|
+
var applyThemeAttributes = function (isDark, isHC) {
|
|
62
|
+
if (isDark === void 0) { isDark = false; }
|
|
63
|
+
if (isHC === void 0) { isHC = false; }
|
|
64
|
+
root.dataset.iuiTheme = isDark ? 'dark' : 'light';
|
|
65
|
+
root.dataset.iuiContrast = isHC ? 'high' : 'default';
|
|
66
|
+
};
|
|
67
|
+
var prefersDarkQuery = (_b = _window === null || _window === void 0 ? void 0 : _window.matchMedia) === null || _b === void 0 ? void 0 : _b.call(_window, '(prefers-color-scheme: dark)');
|
|
68
|
+
var prefersHCQuery = (_c = _window === null || _window === void 0 ? void 0 : _window.matchMedia) === null || _c === void 0 ? void 0 : _c.call(_window, '(prefers-contrast: more)');
|
|
69
|
+
var changeHandler = function () {
|
|
70
|
+
var isDark = theme === 'dark' || (theme === 'os' && (prefersDarkQuery === null || prefersDarkQuery === void 0 ? void 0 : prefersDarkQuery.matches));
|
|
71
|
+
var isHC = highContrast !== null && highContrast !== void 0 ? highContrast : prefersHCQuery === null || prefersHCQuery === void 0 ? void 0 : prefersHCQuery.matches;
|
|
72
|
+
applyThemeAttributes(isDark, isHC);
|
|
73
|
+
};
|
|
74
|
+
// call handler once to set initial theme
|
|
75
|
+
changeHandler();
|
|
76
|
+
// add listeners in supported browsers
|
|
77
|
+
(_d = prefersDarkQuery === null || prefersDarkQuery === void 0 ? void 0 : prefersDarkQuery.addEventListener) === null || _d === void 0 ? void 0 : _d.call(prefersDarkQuery, 'change', changeHandler);
|
|
78
|
+
(_e = prefersHCQuery === null || prefersHCQuery === void 0 ? void 0 : prefersHCQuery.addEventListener) === null || _e === void 0 ? void 0 : _e.call(prefersHCQuery, 'change', changeHandler);
|
|
79
|
+
// return cleanup function to remove event listeners (should be returned from useEffect)
|
|
80
|
+
return function () {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
(_a = prefersDarkQuery === null || prefersDarkQuery === void 0 ? void 0 : prefersDarkQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkQuery, 'change', changeHandler);
|
|
83
|
+
(_b = prefersHCQuery === null || prefersHCQuery === void 0 ? void 0 : prefersHCQuery.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(prefersHCQuery, 'change', changeHandler);
|
|
84
|
+
};
|
|
86
85
|
};
|
|
@@ -15,11 +15,6 @@ export declare type AlertProps = {
|
|
|
15
15
|
* Props for the clickable text. Used for providing `href` and other attributes.
|
|
16
16
|
*/
|
|
17
17
|
clickableTextProps?: React.ComponentPropsWithRef<'a'>;
|
|
18
|
-
/**
|
|
19
|
-
* Action handler for the clickable text.
|
|
20
|
-
* @deprecated `clickableTextProps` should be used instead.
|
|
21
|
-
*/
|
|
22
|
-
onClick?: () => void;
|
|
23
18
|
/**
|
|
24
19
|
* Action handler for close.
|
|
25
20
|
*/
|
|
@@ -41,7 +36,13 @@ export declare type AlertProps = {
|
|
|
41
36
|
* <Alert type='positive'>This is a positive alert.</Alert>
|
|
42
37
|
* <Alert type='warning'>This is a warning alert.</Alert>
|
|
43
38
|
* <Alert type='negative'>This is a negative alert.</Alert>
|
|
44
|
-
* <Alert
|
|
39
|
+
* <Alert
|
|
40
|
+
* type='positive'
|
|
41
|
+
* clickableText="I am a clickable text"
|
|
42
|
+
* clickableTextProps={{ href: 'https://www.example.com' }}
|
|
43
|
+
* >
|
|
44
|
+
* This is a positive alert with a clickable text
|
|
45
|
+
* </Alert>
|
|
45
46
|
*/
|
|
46
47
|
export declare const Alert: (props: AlertProps) => JSX.Element;
|
|
47
48
|
export default Alert;
|
package/esm/core/Alert/Alert.js
CHANGED
|
@@ -29,7 +29,6 @@ import cx from 'classnames';
|
|
|
29
29
|
import React from 'react';
|
|
30
30
|
import { useTheme, StatusIconMap } from '../utils';
|
|
31
31
|
import '@itwin/itwinui-css/css/alert.css';
|
|
32
|
-
import { IconButton } from '../Buttons/IconButton';
|
|
33
32
|
/**
|
|
34
33
|
* A small box to quickly grab user attention and communicate a brief message
|
|
35
34
|
* @example
|
|
@@ -37,18 +36,24 @@ import { IconButton } from '../Buttons/IconButton';
|
|
|
37
36
|
* <Alert type='positive'>This is a positive alert.</Alert>
|
|
38
37
|
* <Alert type='warning'>This is a warning alert.</Alert>
|
|
39
38
|
* <Alert type='negative'>This is a negative alert.</Alert>
|
|
40
|
-
* <Alert
|
|
39
|
+
* <Alert
|
|
40
|
+
* type='positive'
|
|
41
|
+
* clickableText="I am a clickable text"
|
|
42
|
+
* clickableTextProps={{ href: 'https://www.example.com' }}
|
|
43
|
+
* >
|
|
44
|
+
* This is a positive alert with a clickable text
|
|
45
|
+
* </Alert>
|
|
41
46
|
*/
|
|
42
47
|
export var Alert = function (props) {
|
|
43
|
-
var children = props.children, className = props.className, _a = props.type, type = _a === void 0 ? 'informational' : _a, clickableText = props.clickableText, clickableTextProps = props.clickableTextProps,
|
|
48
|
+
var children = props.children, className = props.className, _a = props.type, type = _a === void 0 ? 'informational' : _a, clickableText = props.clickableText, clickableTextProps = props.clickableTextProps, onClose = props.onClose, style = props.style, _b = props.isSticky, isSticky = _b === void 0 ? false : _b, rest = __rest(props, ["children", "className", "type", "clickableText", "clickableTextProps", "onClose", "style", "isSticky"]);
|
|
44
49
|
useTheme();
|
|
45
50
|
var StatusIcon = StatusIconMap[type];
|
|
46
|
-
return (React.createElement("div", __assign({ className: cx(
|
|
51
|
+
return (React.createElement("div", __assign({ className: cx("iui-alert-".concat(type), { 'iui-sticky': isSticky }, className), style: style }, rest),
|
|
47
52
|
React.createElement(StatusIcon, { className: 'iui-alert-icon' }),
|
|
48
53
|
React.createElement("span", { className: 'iui-alert-message' },
|
|
49
54
|
children,
|
|
50
|
-
clickableText && (React.createElement("a", __assign({
|
|
51
|
-
onClose && (React.createElement(
|
|
52
|
-
React.createElement(SvgCloseSmall, { "aria-hidden": true })))));
|
|
55
|
+
clickableText && (React.createElement("a", __assign({}, clickableTextProps, { className: cx('iui-alert-link', clickableTextProps === null || clickableTextProps === void 0 ? void 0 : clickableTextProps.className) }), clickableText))),
|
|
56
|
+
onClose && (React.createElement("button", { onClick: onClose, "aria-label": 'Close', type: 'button', className: 'iui-alert-button' },
|
|
57
|
+
React.createElement(SvgCloseSmall, { "aria-hidden": true, className: 'iui-alert-button-icon' })))));
|
|
53
58
|
};
|
|
54
59
|
export default Alert;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/avatar.css';
|
|
4
|
+
export declare type AvatarStatus = 'online' | 'busy' | 'away' | 'offline';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Since v2, this has been renamed to `AvatarStatus` (Use with `Avatar`)
|
|
7
|
+
*/
|
|
8
|
+
export declare type UserIconStatus = AvatarStatus;
|
|
9
|
+
export declare type StatusTitles = {
|
|
10
|
+
[key in Exclude<AvatarStatus, ''>]: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type AvatarProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Size of a avatar.
|
|
15
|
+
* @default 'small'
|
|
16
|
+
*/
|
|
17
|
+
size?: 'small' | 'medium' | 'large' | 'x-large';
|
|
18
|
+
/**
|
|
19
|
+
* Status/Availability of a user.
|
|
20
|
+
*/
|
|
21
|
+
status?: AvatarStatus;
|
|
22
|
+
/**
|
|
23
|
+
* Text which will appear when hovering over the icon.
|
|
24
|
+
*/
|
|
25
|
+
title?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Abbreviation to be displayed.
|
|
28
|
+
*/
|
|
29
|
+
abbreviation?: string;
|
|
30
|
+
/**
|
|
31
|
+
* User image to be displayed. MUST be an <img> element!
|
|
32
|
+
*/
|
|
33
|
+
image?: JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* Color of the icon. You can use `getUserColor` function to generate color from user name or email.
|
|
36
|
+
* @default 'white'
|
|
37
|
+
*/
|
|
38
|
+
backgroundColor?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Translated status messages shown on hover.
|
|
41
|
+
*/
|
|
42
|
+
translatedStatusTitles?: StatusTitles;
|
|
43
|
+
} & Omit<CommonProps, 'title'>;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Since v2, this has been renamed to `AvatarProps` (Use with `Avatar`)
|
|
46
|
+
*/
|
|
47
|
+
export declare type UserIconProps = AvatarProps;
|
|
48
|
+
export declare const defaultStatusTitles: StatusTitles;
|
|
49
|
+
/**
|
|
50
|
+
* Basic avatar component
|
|
51
|
+
* @example
|
|
52
|
+
* <caption>Small icon with abbreviation</caption>
|
|
53
|
+
* <Avatar size='small' title='Terry Rivers' abbreviation='TR' backgroundColor='green'/>
|
|
54
|
+
* @example
|
|
55
|
+
* <caption>Medium icon with image</caption>
|
|
56
|
+
* <Avatar size='medium' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
|
|
57
|
+
* @example
|
|
58
|
+
* <caption>Large icon with status</caption>
|
|
59
|
+
* <Avatar size='large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' status='online' />
|
|
60
|
+
* @example
|
|
61
|
+
* <caption>X-large icon with image</caption>
|
|
62
|
+
* <Avatar size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
|
|
63
|
+
*/
|
|
64
|
+
export declare const Avatar: (props: AvatarProps) => JSX.Element;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Since v2, this has been renamed to `Avatar`
|
|
67
|
+
*/
|
|
68
|
+
export declare const UserIcon: (props: AvatarProps) => JSX.Element;
|
|
69
|
+
export default Avatar;
|
|
@@ -27,7 +27,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
import cx from 'classnames';
|
|
28
28
|
import React from 'react';
|
|
29
29
|
import { useTheme } from '../utils';
|
|
30
|
-
import '@itwin/itwinui-css/css/
|
|
30
|
+
import '@itwin/itwinui-css/css/avatar.css';
|
|
31
31
|
export var defaultStatusTitles = {
|
|
32
32
|
away: 'Away',
|
|
33
33
|
busy: 'Busy',
|
|
@@ -35,29 +35,33 @@ export var defaultStatusTitles = {
|
|
|
35
35
|
online: 'Online',
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
|
-
* Basic
|
|
38
|
+
* Basic avatar component
|
|
39
39
|
* @example
|
|
40
40
|
* <caption>Small icon with abbreviation</caption>
|
|
41
|
-
* <
|
|
41
|
+
* <Avatar size='small' title='Terry Rivers' abbreviation='TR' backgroundColor='green'/>
|
|
42
42
|
* @example
|
|
43
43
|
* <caption>Medium icon with image</caption>
|
|
44
|
-
* <
|
|
44
|
+
* <Avatar size='medium' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
|
|
45
45
|
* @example
|
|
46
46
|
* <caption>Large icon with status</caption>
|
|
47
|
-
* <
|
|
47
|
+
* <Avatar size='large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' status='online' />
|
|
48
48
|
* @example
|
|
49
49
|
* <caption>X-large icon with image</caption>
|
|
50
|
-
* <
|
|
50
|
+
* <Avatar size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
|
|
51
51
|
*/
|
|
52
|
-
export var
|
|
52
|
+
export var Avatar = function (props) {
|
|
53
53
|
var _a, _b;
|
|
54
54
|
var _c = props.size, size = _c === void 0 ? 'small' : _c, status = props.status, abbreviation = props.abbreviation, image = props.image, _d = props.backgroundColor, backgroundColor = _d === void 0 ? 'white' : _d, title = props.title, translatedStatusTitles = props.translatedStatusTitles, className = props.className, style = props.style, rest = __rest(props, ["size", "status", "abbreviation", "image", "backgroundColor", "title", "translatedStatusTitles", "className", "style"]);
|
|
55
55
|
useTheme();
|
|
56
56
|
var statusTitles = __assign(__assign({}, defaultStatusTitles), translatedStatusTitles);
|
|
57
|
-
return (React.createElement("span", __assign({ className: cx('iui-
|
|
57
|
+
return (React.createElement("span", __assign({ className: cx('iui-avatar', (_a = {}, _a["iui-".concat(size)] = size !== 'medium', _a), className), title: title, style: style }, rest), image !== null && image !== void 0 ? image : (React.createElement("abbr", { className: 'iui-initials', style: { backgroundColor: backgroundColor } }, abbreviation === null || abbreviation === void 0 ? void 0 : abbreviation.substring(0, 2))),
|
|
58
58
|
React.createElement("span", { className: 'iui-stroke' }),
|
|
59
59
|
status && (React.createElement("span", { title: statusTitles[status], className: cx('iui-status', (_b = {},
|
|
60
60
|
_b["iui-".concat(status)] = !!status,
|
|
61
61
|
_b)), "aria-label": statusTitles[status] }))));
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated Since v2, this has been renamed to `Avatar`
|
|
65
|
+
*/
|
|
66
|
+
export var UserIcon = Avatar;
|
|
67
|
+
export default Avatar;
|
|
@@ -2,5 +2,5 @@
|
|
|
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 { UserIcon } from './
|
|
6
|
-
export default './
|
|
5
|
+
export { Avatar, UserIcon } from './Avatar';
|
|
6
|
+
export default './Avatar';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/avatar.css';
|
|
4
|
+
export declare type AvatarGroupProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Max number of avatars unstacked.
|
|
7
|
+
* @default 5
|
|
8
|
+
*/
|
|
9
|
+
maxIcons?: number;
|
|
10
|
+
/**
|
|
11
|
+
* If true, group will be stacked to take less space.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
stacked?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If true, group will be animated on hover.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
animated?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Size of avatars and count avatars.
|
|
22
|
+
* @default 'small'
|
|
23
|
+
*/
|
|
24
|
+
iconSize?: 'small' | 'medium' | 'large' | 'x-large';
|
|
25
|
+
/**
|
|
26
|
+
* Avatars in the group.
|
|
27
|
+
*/
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Count Avatar props.
|
|
31
|
+
*/
|
|
32
|
+
countIconProps?: React.ComponentPropsWithRef<'div'>;
|
|
33
|
+
} & Omit<CommonProps, 'title'>;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Since v2, this has been renamed to `AvatarGroupProps` (Use with `AvatarGroup`)
|
|
36
|
+
*/
|
|
37
|
+
export declare type UserIconGroupProps = AvatarGroupProps;
|
|
38
|
+
/**
|
|
39
|
+
* Group Avatars together.
|
|
40
|
+
*
|
|
41
|
+
* Avatars stacking is based on `maxAvatars` count. If you provide 8 Avatars and keep default 5 `maxAvatars` count,
|
|
42
|
+
* this component will show 5 Avatars and Count Avatar with "3" in it.
|
|
43
|
+
*
|
|
44
|
+
* You can add custom Count Avatar behavior by using `countAvatarProps`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <AvatarGroup avatarSize='medium'>
|
|
48
|
+
* <Avatar
|
|
49
|
+
* abbreviation="TR"
|
|
50
|
+
* backgroundColor={getUserColor("Terry Rivers")}
|
|
51
|
+
* title="Terry Rivers"
|
|
52
|
+
* />
|
|
53
|
+
* <Avatar
|
|
54
|
+
* abbreviation="RM"
|
|
55
|
+
* backgroundColor={getUserColor("Robin Mercer")}
|
|
56
|
+
* title="Robin Mercer"
|
|
57
|
+
* />
|
|
58
|
+
* <Avatar
|
|
59
|
+
* abbreviation="JM"
|
|
60
|
+
* backgroundColor={getUserColor("Jean Mullins")}
|
|
61
|
+
* title="Jean Mullins"
|
|
62
|
+
* />
|
|
63
|
+
* </AvatarGroup>
|
|
64
|
+
*/
|
|
65
|
+
export declare const AvatarGroup: (props: AvatarGroupProps) => JSX.Element;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Since v2, this has been renamed to `AvatarGroup`
|
|
68
|
+
*/
|
|
69
|
+
export declare const UserIconGroup: (props: AvatarGroupProps) => JSX.Element;
|
|
70
|
+
export default AvatarGroup;
|
|
@@ -27,42 +27,42 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
import React from 'react';
|
|
28
28
|
import cx from 'classnames';
|
|
29
29
|
import { useTheme } from '../utils';
|
|
30
|
-
import '@itwin/itwinui-css/css/
|
|
30
|
+
import '@itwin/itwinui-css/css/avatar.css';
|
|
31
31
|
/**
|
|
32
|
-
* Group
|
|
32
|
+
* Group Avatars together.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
* this component will show 5
|
|
34
|
+
* Avatars stacking is based on `maxAvatars` count. If you provide 8 Avatars and keep default 5 `maxAvatars` count,
|
|
35
|
+
* this component will show 5 Avatars and Count Avatar with "3" in it.
|
|
36
36
|
*
|
|
37
|
-
* You can add custom
|
|
37
|
+
* You can add custom Count Avatar behavior by using `countAvatarProps`.
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
|
-
* <
|
|
41
|
-
* <
|
|
40
|
+
* <AvatarGroup avatarSize='medium'>
|
|
41
|
+
* <Avatar
|
|
42
42
|
* abbreviation="TR"
|
|
43
43
|
* backgroundColor={getUserColor("Terry Rivers")}
|
|
44
44
|
* title="Terry Rivers"
|
|
45
45
|
* />
|
|
46
|
-
* <
|
|
46
|
+
* <Avatar
|
|
47
47
|
* abbreviation="RM"
|
|
48
48
|
* backgroundColor={getUserColor("Robin Mercer")}
|
|
49
49
|
* title="Robin Mercer"
|
|
50
50
|
* />
|
|
51
|
-
* <
|
|
51
|
+
* <Avatar
|
|
52
52
|
* abbreviation="JM"
|
|
53
53
|
* backgroundColor={getUserColor("Jean Mullins")}
|
|
54
54
|
* title="Jean Mullins"
|
|
55
55
|
* />
|
|
56
|
-
* </
|
|
56
|
+
* </AvatarGroup>
|
|
57
57
|
*/
|
|
58
|
-
export var
|
|
58
|
+
export var AvatarGroup = function (props) {
|
|
59
59
|
var _a;
|
|
60
60
|
var maxLength = 99;
|
|
61
61
|
var children = props.children, _b = props.animated, animated = _b === void 0 ? false : _b, _c = props.stacked, stacked = _c === void 0 ? true : _c, _d = props.maxIcons, maxIcons = _d === void 0 ? 5 : _d, _e = props.iconSize, iconSize = _e === void 0 ? 'small' : _e, countIconProps = props.countIconProps, className = props.className, rest = __rest(props, ["children", "animated", "stacked", "maxIcons", "iconSize", "countIconProps", "className"]);
|
|
62
62
|
var childrenArray = React.Children.toArray(children);
|
|
63
63
|
var childrenLength = childrenArray.length;
|
|
64
64
|
useTheme();
|
|
65
|
-
var
|
|
65
|
+
var getAvatarList = function (count) {
|
|
66
66
|
return childrenArray.slice(0, count).map(function (child) {
|
|
67
67
|
return React.cloneElement(child, {
|
|
68
68
|
status: undefined,
|
|
@@ -71,17 +71,21 @@ export var UserIconGroup = function (props) {
|
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
73
|
return (React.createElement(React.Fragment, null,
|
|
74
|
-
React.createElement("div", __assign({ className: cx('iui-
|
|
74
|
+
React.createElement("div", __assign({ className: cx('iui-avatar-list', {
|
|
75
75
|
'iui-animated': animated,
|
|
76
76
|
'iui-stacked': stacked,
|
|
77
77
|
}, className) }, rest),
|
|
78
|
-
childrenArray.length <= maxIcons + 1 &&
|
|
78
|
+
childrenArray.length <= maxIcons + 1 && getAvatarList(maxIcons + 1),
|
|
79
79
|
childrenArray.length > maxIcons + 1 && (React.createElement(React.Fragment, null,
|
|
80
|
-
|
|
81
|
-
React.createElement("div", __assign({}, countIconProps, { className: cx('iui-
|
|
80
|
+
getAvatarList(maxIcons),
|
|
81
|
+
React.createElement("div", __assign({}, countIconProps, { className: cx('iui-avatar', (_a = {}, _a["iui-".concat(iconSize)] = iconSize !== 'medium', _a), 'iui-avatar-count', countIconProps === null || countIconProps === void 0 ? void 0 : countIconProps.className) }),
|
|
82
82
|
React.createElement("abbr", { className: 'iui-initials' }, childrenLength <= maxLength
|
|
83
83
|
? "".concat(childrenLength - maxIcons)
|
|
84
84
|
: "".concat(maxLength, "+")),
|
|
85
85
|
React.createElement("span", { className: 'iui-stroke' })))))));
|
|
86
86
|
};
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Since v2, this has been renamed to `AvatarGroup`
|
|
89
|
+
*/
|
|
90
|
+
export var UserIconGroup = AvatarGroup;
|
|
91
|
+
export default AvatarGroup;
|
|
@@ -2,5 +2,5 @@
|
|
|
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 { UserIconGroup } from './
|
|
6
|
-
export default './
|
|
5
|
+
export { AvatarGroup, UserIconGroup } from './AvatarGroup';
|
|
6
|
+
export default './AvatarGroup';
|
package/esm/core/Badge/Badge.js
CHANGED
|
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
*--------------------------------------------------------------------------------------------*/
|
|
27
27
|
import React from 'react';
|
|
28
28
|
import cx from 'classnames';
|
|
29
|
-
import { useTheme,
|
|
29
|
+
import { useTheme, isSoftBackground, SoftBackgrounds, } from '../utils';
|
|
30
30
|
import '@itwin/itwinui-css/css/badge.css';
|
|
31
31
|
/**
|
|
32
32
|
* Helper function that returns one of the preset badge color values.
|
|
@@ -56,12 +56,10 @@ var getBadgeColorValue = function (color) {
|
|
|
56
56
|
* <Badge backgroundColor="positive">Label</Badge>
|
|
57
57
|
*/
|
|
58
58
|
export var Badge = function (props) {
|
|
59
|
-
var _a, _b, _c;
|
|
60
59
|
var backgroundColor = props.backgroundColor, style = props.style, className = props.className, children = props.children, rest = __rest(props, ["backgroundColor", "style", "className", "children"]);
|
|
61
60
|
useTheme();
|
|
62
|
-
var _style = backgroundColor
|
|
63
|
-
|
|
64
|
-
? __assign({ '--iui-badge-background-color': getBadgeColorValue(backgroundColor) }, style) : __assign({ backgroundColor: getBadgeColorValue(backgroundColor) }, style);
|
|
61
|
+
var _style = backgroundColor
|
|
62
|
+
? __assign({ '--iui-badge-background-color': getBadgeColorValue(backgroundColor) }, style) : __assign({}, style);
|
|
65
63
|
return (React.createElement("span", __assign({ className: cx('iui-badge', className), style: _style }, rest), children));
|
|
66
64
|
};
|
|
67
65
|
export default Badge;
|
|
@@ -54,5 +54,5 @@ export declare type ButtonGroupProps = {
|
|
|
54
54
|
* {buttons}
|
|
55
55
|
* </ButtonGroup>
|
|
56
56
|
*/
|
|
57
|
-
export declare const ButtonGroup: React.ForwardRefExoticComponent<Pick<ButtonGroupProps, "
|
|
57
|
+
export declare const ButtonGroup: React.ForwardRefExoticComponent<Pick<ButtonGroupProps, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "orientation" | "overflowButton" | "overflowPlacement"> & React.RefAttributes<HTMLDivElement>>;
|
|
58
58
|
export default ButtonGroup;
|
|
@@ -38,20 +38,11 @@ import '@itwin/itwinui-css/css/button.css';
|
|
|
38
38
|
* <Button startIcon={<SvgAdd />}>New</Button>
|
|
39
39
|
*/
|
|
40
40
|
export var Button = React.forwardRef(function (props, ref) {
|
|
41
|
-
var _a;
|
|
42
|
-
var children = props.children, className = props.className, size = props.size, style = props.style, _b = props.styleType, styleType = _b === void 0 ? 'default' : _b, _c = props.type, type = _c === void 0 ? 'button' : _c, startIcon = props.startIcon, endIcon = props.endIcon, _d = props.as, Element = _d === void 0 ? 'button' : _d, rest = __rest(props, ["children", "className", "size", "style", "styleType", "type", "startIcon", "endIcon", "as"]);
|
|
41
|
+
var children = props.children, className = props.className, size = props.size, style = props.style, _a = props.styleType, styleType = _a === void 0 ? 'default' : _a, _b = props.type, type = _b === void 0 ? 'button' : _b, startIcon = props.startIcon, endIcon = props.endIcon, _c = props.as, Element = _c === void 0 ? 'button' : _c, rest = __rest(props, ["children", "className", "size", "style", "styleType", "type", "startIcon", "endIcon", "as"]);
|
|
43
42
|
useTheme();
|
|
44
|
-
return (React.createElement(Element, __assign({ ref: ref, className: cx('iui-button', "iui-"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
React.cloneElement(startIcon, {
|
|
49
|
-
className: cx('iui-button-icon', startIcon.props.className),
|
|
50
|
-
}),
|
|
51
|
-
children && React.createElement("span", { className: 'iui-button-label' }, children),
|
|
52
|
-
endIcon &&
|
|
53
|
-
React.cloneElement(endIcon, {
|
|
54
|
-
className: cx('iui-button-icon', endIcon.props.className),
|
|
55
|
-
})));
|
|
43
|
+
return (React.createElement(Element, __assign({ ref: ref, className: cx('iui-button', className), "data-iui-variant": styleType !== 'default' ? styleType : undefined, "data-iui-size": size, style: style, type: type }, rest),
|
|
44
|
+
startIcon && (React.createElement("span", { className: 'iui-button-icon', "aria-hidden": true }, startIcon)),
|
|
45
|
+
children && React.createElement("span", null, children),
|
|
46
|
+
endIcon && (React.createElement("span", { className: 'iui-button-icon', "aria-hidden": true }, endIcon))));
|
|
56
47
|
});
|
|
57
48
|
export default Button;
|
|
@@ -54,6 +54,6 @@ export var DropdownButton = React.forwardRef(function (props, ref) {
|
|
|
54
54
|
}
|
|
55
55
|
}, [children, size, styleType]);
|
|
56
56
|
return (React.createElement(DropdownMenu, { menuItems: menuItems, style: { minWidth: menuWidth }, onShow: function () { return setIsMenuOpen(true); }, onHide: function () { return setIsMenuOpen(false); } },
|
|
57
|
-
React.createElement(Button, __assign({ className: cx('iui-dropdown', className), size: size, styleType: styleType, endIcon: isMenuOpen ? (React.createElement(SvgCaretUpSmall, { "aria-hidden": true })) : (React.createElement(SvgCaretDownSmall, { "aria-hidden": true })), ref: refs, "aria-label": 'Dropdown' }, rest), children)));
|
|
57
|
+
React.createElement(Button, __assign({ className: cx('iui-button-dropdown', className), size: size, styleType: styleType, endIcon: isMenuOpen ? (React.createElement(SvgCaretUpSmall, { "aria-hidden": true })) : (React.createElement(SvgCaretDownSmall, { "aria-hidden": true })), ref: refs, "aria-label": 'Dropdown' }, rest), children)));
|
|
58
58
|
});
|
|
59
59
|
export default DropdownButton;
|