@itwin/itwinui-react 3.0.0-dev.6 → 3.0.0-dev.8
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 +101 -0
- package/cjs/core/Alert/Alert.d.ts +20 -9
- package/cjs/core/Alert/Alert.js +48 -10
- 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/ButtonGroup/ButtonGroup.js +41 -36
- 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.js +1 -1
- package/cjs/core/Buttons/IconButton/IconButton.d.ts +5 -1
- package/cjs/core/Buttons/IconButton/IconButton.js +27 -38
- package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
- package/cjs/core/Buttons/SplitButton/SplitButton.js +25 -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/ColorPicker/ColorInputPanel.js +172 -231
- package/cjs/core/ComboBox/ComboBox.js +3 -3
- package/cjs/core/ComboBox/ComboBoxDropdown.js +4 -9
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +3 -22
- package/cjs/core/ComboBox/ComboBoxInput.js +1 -1
- package/cjs/core/ComboBox/ComboBoxMenu.d.ts +2 -2
- package/cjs/core/ComboBox/ComboBoxMenu.js +5 -5
- package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +8 -6
- package/cjs/core/ComboBox/helpers.d.ts +1 -2
- package/cjs/core/DatePicker/DatePicker.d.ts +30 -8
- package/cjs/core/DatePicker/DatePicker.js +47 -6
- package/cjs/core/Dialog/Dialog.js +10 -17
- package/cjs/core/Dialog/DialogContext.d.ts +3 -4
- package/cjs/core/Dialog/DialogMain.js +5 -5
- package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +39 -18
- 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/HeaderDropdownButton.js +1 -1
- package/cjs/core/Header/HeaderSplitButton.js +3 -4
- package/cjs/core/Input/Input.d.ts +4 -0
- package/cjs/core/Input/Input.js +2 -1
- package/cjs/core/InputGrid/InputGrid.d.ts +25 -0
- package/cjs/core/InputGrid/InputGrid.js +39 -0
- package/cjs/core/InputGrid/index.d.ts +3 -0
- package/cjs/core/InputGrid/index.js +15 -0
- package/cjs/core/InputGroup/InputGroup.d.ts +13 -0
- package/cjs/core/InputGroup/InputGroup.js +35 -9
- package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
- package/cjs/core/InputWithDecorations/InputWithDecorations.js +81 -0
- package/cjs/core/InputWithDecorations/index.d.ts +3 -0
- package/cjs/core/InputWithDecorations/index.js +15 -0
- package/cjs/core/Label/Label.d.ts +5 -0
- package/cjs/core/Label/Label.js +2 -0
- package/cjs/core/LabeledInput/LabeledInput.d.ts +22 -16
- package/cjs/core/LabeledInput/LabeledInput.js +52 -29
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +17 -7
- package/cjs/core/LabeledSelect/LabeledSelect.js +36 -17
- package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +12 -45
- package/cjs/core/Menu/Menu.d.ts +1 -1
- package/cjs/core/Menu/Menu.js +1 -1
- package/cjs/core/Menu/MenuDivider.d.ts +2 -1
- package/cjs/core/Menu/MenuDivider.js +1 -1
- package/cjs/core/Menu/MenuItem.d.ts +1 -1
- package/cjs/core/Menu/MenuItem.js +1 -0
- package/cjs/core/Menu/MenuItemSkeleton.d.ts +1 -1
- package/cjs/core/Menu/MenuItemSkeleton.js +0 -1
- package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
- package/cjs/core/ProgressIndicators/ProgressLinear.js +9 -1
- package/cjs/core/SearchBox/SearchBox.js +1 -1
- package/cjs/core/Select/Select.d.ts +4 -0
- package/cjs/core/Select/Select.js +12 -11
- package/cjs/core/SideNavigation/SideNavigation.d.ts +16 -0
- package/cjs/core/SideNavigation/SideNavigation.js +42 -9
- package/cjs/core/Slider/Slider.d.ts +24 -0
- package/cjs/core/Slider/Slider.js +58 -10
- package/cjs/core/Slider/Thumb.js +3 -2
- package/cjs/core/Slider/Track.d.ts +1 -1
- package/cjs/core/Slider/Track.js +17 -6
- package/cjs/core/StatusMessage/StatusMessage.d.ts +12 -2
- package/cjs/core/StatusMessage/StatusMessage.js +23 -9
- 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 +3 -1
- package/cjs/core/Table/Table.js +0 -1
- package/cjs/core/Table/TableCell.js +1 -1
- package/cjs/core/Table/TablePaginator.js +1 -3
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +46 -18
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
- package/cjs/core/Tabs/Tab.js +1 -2
- package/cjs/core/Textarea/Textarea.d.ts +7 -1
- package/cjs/core/Textarea/Textarea.js +6 -11
- 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 +142 -17
- package/cjs/core/Tile/Tile.js +107 -16
- package/cjs/core/Toast/Toast.d.ts +12 -4
- package/cjs/core/Toast/Toast.js +24 -13
- package/cjs/core/Tooltip/Tooltip.d.ts +35 -28
- package/cjs/core/Tooltip/Tooltip.js +116 -118
- package/cjs/core/TransferList/TransferList.js +4 -12
- package/cjs/core/Tree/TreeNode.js +1 -1
- package/cjs/core/index.d.ts +2 -0
- package/cjs/core/index.js +20 -4
- package/cjs/core/utils/components/ButtonBase.d.ts +14 -0
- package/cjs/core/utils/components/ButtonBase.js +46 -0
- package/cjs/core/utils/components/Icon.d.ts +5 -0
- package/cjs/core/utils/components/Icon.js +8 -1
- package/cjs/core/utils/components/InputContainer.d.ts +0 -1
- package/cjs/core/utils/components/InputContainer.js +14 -34
- package/cjs/core/utils/components/InputFlexContainer.d.ts +1 -0
- package/cjs/core/utils/components/InputFlexContainer.js +3 -1
- package/cjs/core/utils/components/Popover.js +5 -3
- package/cjs/core/utils/components/Portal.d.ts +27 -0
- package/cjs/core/utils/components/Portal.js +43 -0
- package/cjs/core/utils/components/VirtualScroll.js +4 -4
- package/cjs/core/utils/components/index.d.ts +2 -0
- package/cjs/core/utils/components/index.js +2 -0
- package/cjs/core/utils/functions/colors.d.ts +1 -1
- package/cjs/core/utils/functions/colors.js +1 -13
- package/cjs/core/utils/functions/index.d.ts +1 -0
- package/cjs/core/utils/functions/index.js +1 -0
- package/cjs/core/utils/functions/react.d.ts +8 -0
- package/cjs/core/utils/functions/react.js +40 -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/useControlledState.d.ts +13 -0
- package/cjs/core/utils/hooks/useControlledState.js +39 -0
- package/cjs/core/utils/hooks/useGlobals.d.ts +1 -1
- package/cjs/styles.js +11 -35
- package/esm/core/Alert/Alert.d.ts +20 -9
- package/esm/core/Alert/Alert.js +49 -10
- 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/ButtonGroup/ButtonGroup.js +41 -36
- 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.js +1 -1
- package/esm/core/Buttons/IconButton/IconButton.d.ts +5 -1
- package/esm/core/Buttons/IconButton/IconButton.js +25 -37
- package/esm/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
- package/esm/core/Buttons/SplitButton/SplitButton.js +31 -14
- 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/ColorPicker/ColorInputPanel.js +173 -232
- package/esm/core/ComboBox/ComboBox.js +3 -3
- package/esm/core/ComboBox/ComboBoxDropdown.js +4 -9
- package/esm/core/ComboBox/ComboBoxEndIcon.js +4 -25
- package/esm/core/ComboBox/ComboBoxInput.js +1 -1
- package/esm/core/ComboBox/ComboBoxMenu.d.ts +2 -2
- package/esm/core/ComboBox/ComboBoxMenu.js +5 -5
- package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenuItem.js +9 -7
- package/esm/core/ComboBox/helpers.d.ts +1 -2
- package/esm/core/DatePicker/DatePicker.d.ts +30 -8
- package/esm/core/DatePicker/DatePicker.js +33 -6
- package/esm/core/Dialog/Dialog.js +11 -23
- package/esm/core/Dialog/DialogContext.d.ts +3 -4
- package/esm/core/Dialog/DialogMain.js +5 -5
- package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
- package/esm/core/ExpandableBlock/ExpandableBlock.js +41 -20
- 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/HeaderDropdownButton.js +1 -1
- package/esm/core/Header/HeaderSplitButton.js +9 -5
- package/esm/core/Input/Input.d.ts +4 -0
- package/esm/core/Input/Input.js +2 -1
- package/esm/core/InputGrid/InputGrid.d.ts +25 -0
- package/esm/core/InputGrid/InputGrid.js +35 -0
- package/esm/core/InputGrid/index.d.ts +3 -0
- package/esm/core/InputGrid/index.js +6 -0
- package/esm/core/InputGroup/InputGroup.d.ts +13 -0
- package/esm/core/InputGroup/InputGroup.js +34 -10
- package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
- package/esm/core/InputWithDecorations/InputWithDecorations.js +80 -0
- package/esm/core/InputWithDecorations/index.d.ts +3 -0
- package/esm/core/InputWithDecorations/index.js +6 -0
- package/esm/core/Label/Label.d.ts +5 -0
- package/esm/core/Label/Label.js +2 -0
- package/esm/core/LabeledInput/LabeledInput.d.ts +22 -16
- package/esm/core/LabeledInput/LabeledInput.js +53 -29
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +17 -7
- package/esm/core/LabeledSelect/LabeledSelect.js +37 -18
- package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
- package/esm/core/LabeledTextarea/LabeledTextarea.js +14 -45
- package/esm/core/Menu/Menu.d.ts +1 -1
- package/esm/core/Menu/Menu.js +1 -1
- package/esm/core/Menu/MenuDivider.d.ts +2 -1
- package/esm/core/Menu/MenuDivider.js +1 -1
- package/esm/core/Menu/MenuItem.d.ts +1 -1
- package/esm/core/Menu/MenuItem.js +1 -0
- package/esm/core/Menu/MenuItemSkeleton.d.ts +1 -1
- package/esm/core/Menu/MenuItemSkeleton.js +0 -1
- package/esm/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
- package/esm/core/ProgressIndicators/ProgressLinear.js +9 -1
- package/esm/core/SearchBox/SearchBox.js +1 -1
- package/esm/core/Select/Select.d.ts +4 -0
- package/esm/core/Select/Select.js +12 -11
- package/esm/core/SideNavigation/SideNavigation.d.ts +16 -0
- package/esm/core/SideNavigation/SideNavigation.js +33 -9
- package/esm/core/Slider/Slider.d.ts +24 -0
- package/esm/core/Slider/Slider.js +43 -10
- package/esm/core/Slider/Thumb.js +3 -2
- package/esm/core/Slider/Track.d.ts +1 -1
- package/esm/core/Slider/Track.js +14 -6
- package/esm/core/StatusMessage/StatusMessage.d.ts +12 -2
- package/esm/core/StatusMessage/StatusMessage.js +23 -16
- 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 +3 -1
- package/esm/core/Table/Table.js +0 -1
- package/esm/core/Table/TableCell.js +1 -1
- package/esm/core/Table/TablePaginator.js +2 -3
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +45 -17
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
- package/esm/core/Tabs/Tab.js +2 -3
- package/esm/core/Textarea/Textarea.d.ts +7 -1
- package/esm/core/Textarea/Textarea.js +6 -11
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +23 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +65 -24
- package/esm/core/Tile/Tile.d.ts +142 -17
- package/esm/core/Tile/Tile.js +107 -16
- package/esm/core/Toast/Toast.d.ts +12 -4
- package/esm/core/Toast/Toast.js +26 -13
- package/esm/core/Tooltip/Tooltip.d.ts +35 -28
- package/esm/core/Tooltip/Tooltip.js +119 -116
- package/esm/core/TransferList/TransferList.js +4 -9
- package/esm/core/Tree/TreeNode.js +1 -1
- package/esm/core/index.d.ts +2 -0
- package/esm/core/index.js +2 -0
- package/esm/core/utils/components/ButtonBase.d.ts +14 -0
- package/esm/core/utils/components/ButtonBase.js +42 -0
- package/esm/core/utils/components/Icon.d.ts +5 -0
- package/esm/core/utils/components/Icon.js +8 -1
- package/esm/core/utils/components/InputContainer.d.ts +0 -1
- package/esm/core/utils/components/InputContainer.js +14 -30
- package/esm/core/utils/components/InputFlexContainer.d.ts +1 -0
- package/esm/core/utils/components/InputFlexContainer.js +3 -1
- package/esm/core/utils/components/Popover.js +5 -3
- package/esm/core/utils/components/Portal.d.ts +27 -0
- package/esm/core/utils/components/Portal.js +36 -0
- package/esm/core/utils/components/VirtualScroll.js +4 -4
- package/esm/core/utils/components/index.d.ts +2 -0
- package/esm/core/utils/components/index.js +2 -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/index.d.ts +1 -0
- package/esm/core/utils/functions/index.js +1 -0
- package/esm/core/utils/functions/react.d.ts +8 -0
- package/esm/core/utils/functions/react.js +35 -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/useControlledState.d.ts +13 -0
- package/esm/core/utils/hooks/useControlledState.js +34 -0
- package/esm/core/utils/hooks/useGlobals.d.ts +1 -1
- package/esm/styles.js +11 -35
- package/package.json +3 -3
- package/styles.css +49 -46
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.Portal = 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 ReactDOM = tslib_1.__importStar(require('react-dom'));
|
|
11
|
+
const ThemeContext_js_1 = require('../../ThemeProvider/ThemeContext.js');
|
|
12
|
+
const dom_js_1 = require('../functions/dom.js');
|
|
13
|
+
const useIsClient_js_1 = require('../hooks/useIsClient.js');
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Helper component that portals children according to the following conditions:
|
|
17
|
+
* - renders null on server
|
|
18
|
+
* - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
|
|
19
|
+
* - if `portal` is set to false, renders as-is without portal
|
|
20
|
+
* - otherwise renders into `portal.to` (can be an element or a function)
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
const Portal = (props) => {
|
|
25
|
+
const { portal = true, children } = props;
|
|
26
|
+
const isClient = (0, useIsClient_js_1.useIsClient)();
|
|
27
|
+
const portalTo = usePortalTo(portal);
|
|
28
|
+
if (!isClient) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return portalTo ? ReactDOM.createPortal(children, portalTo) : children;
|
|
32
|
+
};
|
|
33
|
+
exports.Portal = Portal;
|
|
34
|
+
// ----------------------------------------------------------------------------
|
|
35
|
+
const usePortalTo = (portal) => {
|
|
36
|
+
const themeInfo = React.useContext(ThemeContext_js_1.ThemeContext);
|
|
37
|
+
if (typeof portal === 'boolean') {
|
|
38
|
+
return portal
|
|
39
|
+
? themeInfo?.portalContainer ?? (0, dom_js_1.getDocument)()?.body
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
return typeof portal.to === 'function' ? portal.to() : portal.to;
|
|
43
|
+
};
|
|
@@ -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,5 @@ 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);
|
|
24
|
+
tslib_1.__exportStar(require('./Portal.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.
|
|
@@ -13,3 +13,4 @@ tslib_1.__exportStar(require('./focusable.js'), exports);
|
|
|
13
13
|
tslib_1.__exportStar(require('./supports.js'), exports);
|
|
14
14
|
tslib_1.__exportStar(require('./polymorphic.js'), exports);
|
|
15
15
|
tslib_1.__exportStar(require('./import.js'), exports);
|
|
16
|
+
tslib_1.__exportStar(require('./react.js'), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper over `cloneElement` that automatically checks for `isValidElement`
|
|
4
|
+
* and automatically merges `children.ref` with the ref passed in props.
|
|
5
|
+
*
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
export declare const cloneElementWithRef: (children: React.ReactNode, getProps: (children: JSX.Element) => Record<string, unknown>) => string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.cloneElementWithRef = 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 useMergedRefs_js_1 = require('../hooks/useMergedRefs.js');
|
|
11
|
+
/**
|
|
12
|
+
* Wrapper over `cloneElement` that automatically checks for `isValidElement`
|
|
13
|
+
* and automatically merges `children.ref` with the ref passed in props.
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
const cloneElementWithRef = (children, getProps) => {
|
|
18
|
+
if (!children) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (!React.isValidElement(children)) {
|
|
22
|
+
return children;
|
|
23
|
+
}
|
|
24
|
+
const props = getProps(children);
|
|
25
|
+
const ref = (0, useMergedRefs_js_1.mergeRefs)(
|
|
26
|
+
...[
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
'ref' in children ? children.ref : null,
|
|
29
|
+
'ref' in props ? props.ref : null,
|
|
30
|
+
].filter(Boolean),
|
|
31
|
+
);
|
|
32
|
+
return React.cloneElement(children, {
|
|
33
|
+
...props,
|
|
34
|
+
// we already checked ref above and handled null, so ts-ignore is ok
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
ref,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.cloneElementWithRef = cloneElementWithRef;
|
|
@@ -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('./useControlledState.js'), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper over `useState` that always gives preference to the
|
|
4
|
+
* controlled state (which often comes from a prop).
|
|
5
|
+
*
|
|
6
|
+
* This is helpful when a component needs to support both uncontrolled
|
|
7
|
+
* and controlled states. If controlled value/setter is not passed,
|
|
8
|
+
* then it will work just like a regular `useState`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const [state, setState] = useControlledState(null, props.value, props.onChange);
|
|
12
|
+
*/
|
|
13
|
+
export declare const useControlledState: <T>(initialValue: T, controlledState: T, setControlledState?: React.Dispatch<React.SetStateAction<T>> | undefined) => readonly [T, React.Dispatch<React.SetStateAction<T>>];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.useControlledState = 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
|
+
* controlled state (which often comes from a prop).
|
|
13
|
+
*
|
|
14
|
+
* This is helpful when a component needs to support both uncontrolled
|
|
15
|
+
* and controlled states. If controlled value/setter is not passed,
|
|
16
|
+
* then it will work just like a regular `useState`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const [state, setState] = useControlledState(null, props.value, props.onChange);
|
|
20
|
+
*/
|
|
21
|
+
const useControlledState = (
|
|
22
|
+
initialValue,
|
|
23
|
+
controlledState,
|
|
24
|
+
setControlledState,
|
|
25
|
+
) => {
|
|
26
|
+
const [uncontrolledState, setUncontrolledState] =
|
|
27
|
+
React.useState(initialValue);
|
|
28
|
+
const state =
|
|
29
|
+
controlledState !== undefined ? controlledState : uncontrolledState;
|
|
30
|
+
const setState = React.useCallback(
|
|
31
|
+
(value) => {
|
|
32
|
+
setUncontrolledState(value);
|
|
33
|
+
setControlledState?.(value);
|
|
34
|
+
},
|
|
35
|
+
[setControlledState, setUncontrolledState],
|
|
36
|
+
);
|
|
37
|
+
return [state, setState];
|
|
38
|
+
};
|
|
39
|
+
exports.useControlledState = useControlledState;
|
|
@@ -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;
|
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',
|
|
@@ -41,8 +34,9 @@ const styles = {
|
|
|
41
34
|
'iui-button-dropdown': '_iui3-button-dropdown',
|
|
42
35
|
'iui-button-split': '_iui3-button-split',
|
|
43
36
|
'iui-button-group': '_iui3-button-group',
|
|
44
|
-
'iui-input-container': '_iui3-input-container',
|
|
37
|
+
'iui-input-flex-container': '_iui3-input-flex-container',
|
|
45
38
|
'iui-input': '_iui3-input',
|
|
39
|
+
'iui-input-grid': '_iui3-input-grid',
|
|
46
40
|
'iui-disabled': '_iui3-disabled',
|
|
47
41
|
'iui-button-group-vertical': '_iui3-button-group-vertical',
|
|
48
42
|
'iui-button-group-overflow-x': '_iui3-button-group-overflow-x',
|
|
@@ -185,36 +179,18 @@ const styles = {
|
|
|
185
179
|
'iui-information-body-content': '_iui3-information-body-content',
|
|
186
180
|
'iui-input-label': '_iui3-input-label',
|
|
187
181
|
'iui-inline': '_iui3-inline',
|
|
188
|
-
'iui-required': '_iui3-required',
|
|
189
182
|
'iui-input-with-icon': '_iui3-input-with-icon',
|
|
190
183
|
'iui-select-tag-container': '_iui3-select-tag-container',
|
|
191
184
|
'iui-end-icon': '_iui3-end-icon',
|
|
192
|
-
'iui-actionable': '_iui3-actionable',
|
|
193
185
|
'iui-open': '_iui3-open',
|
|
194
|
-
'iui-
|
|
195
|
-
'iui-with-message': '_iui3-with-message',
|
|
196
|
-
'iui-input-icon': '_iui3-input-icon',
|
|
186
|
+
'iui-required': '_iui3-required',
|
|
197
187
|
'iui-input-group': '_iui3-input-group',
|
|
188
|
+
'iui-status-message': '_iui3-status-message',
|
|
189
|
+
'iui-select-button': '_iui3-select-button',
|
|
190
|
+
'iui-input-group-wrapper': '_iui3-input-group-wrapper',
|
|
198
191
|
'iui-toggle-switch-wrapper': '_iui3-toggle-switch-wrapper',
|
|
199
192
|
'iui-radio-wrapper': '_iui3-radio-wrapper',
|
|
200
|
-
'iui-inline-label': '_iui3-inline-label',
|
|
201
|
-
'iui-label': '_iui3-label',
|
|
202
|
-
'iui-message': '_iui3-message',
|
|
203
|
-
'iui-select-button': '_iui3-select-button',
|
|
204
|
-
'iui-input-flex-container': '_iui3-input-flex-container',
|
|
205
193
|
'iui-keyboard': '_iui3-keyboard',
|
|
206
|
-
'iui-location-marker': '_iui3-location-marker',
|
|
207
|
-
'iui-location-marker-default': '_iui3-location-marker-default',
|
|
208
|
-
'iui-location-marker-default-pin': '_iui3-location-marker-default-pin',
|
|
209
|
-
'iui-location-marker-default-pin-dot':
|
|
210
|
-
'_iui3-location-marker-default-pin-dot',
|
|
211
|
-
'iui-location-marker-data-rich': '_iui3-location-marker-data-rich',
|
|
212
|
-
'iui-location-marker-data-rich-body': '_iui3-location-marker-data-rich-body',
|
|
213
|
-
'iui-location-marker-data-rich-icon': '_iui3-location-marker-data-rich-icon',
|
|
214
|
-
'iui-location-marker-data-rich-icon-monochrome':
|
|
215
|
-
'_iui3-location-marker-data-rich-icon-monochrome',
|
|
216
|
-
'iui-location-marker-me': '_iui3-location-marker-me',
|
|
217
|
-
'iui-location-marker-me-dot': '_iui3-location-marker-me-dot',
|
|
218
194
|
'iui-list': '_iui3-list',
|
|
219
195
|
'iui-menu': '_iui3-menu',
|
|
220
196
|
'iui-header-menu-icon': '_iui3-header-menu-icon',
|
|
@@ -243,10 +219,10 @@ const styles = {
|
|
|
243
219
|
'iui-overlay-exiting': '_iui3-overlay-exiting',
|
|
244
220
|
closeAnimation,
|
|
245
221
|
'iui-progress-indicator-radial': '_iui3-progress-indicator-radial',
|
|
246
|
-
'iui-
|
|
222
|
+
'iui-ubn95wp': '_iui3-ubn95wp',
|
|
247
223
|
'iui-progress-indicator-linear-label':
|
|
248
224
|
'_iui3-progress-indicator-linear-label',
|
|
249
|
-
'iui-
|
|
225
|
+
'iui-ubn95xj': '_iui3-ubn95xj',
|
|
250
226
|
'iui-radio': '_iui3-radio',
|
|
251
227
|
'iui-radio-tile': '_iui3-radio-tile',
|
|
252
228
|
'iui-radio-tile-icon': '_iui3-radio-tile-icon',
|
|
@@ -313,6 +289,7 @@ const styles = {
|
|
|
313
289
|
'iui-table-body': '_iui3-table-body',
|
|
314
290
|
'iui-table-header-wrapper': '_iui3-table-header-wrapper',
|
|
315
291
|
'iui-slot': '_iui3-slot',
|
|
292
|
+
'iui-actionable': '_iui3-actionable',
|
|
316
293
|
'iui-table-filter-button': '_iui3-table-filter-button',
|
|
317
294
|
'iui-table-resizer': '_iui3-table-resizer',
|
|
318
295
|
'iui-table-resizer-bar': '_iui3-table-resizer-bar',
|
|
@@ -409,6 +386,7 @@ const styles = {
|
|
|
409
386
|
'iui-placement-bottom-start': '_iui3-placement-bottom-start',
|
|
410
387
|
'iui-placement-bottom-end': '_iui3-placement-bottom-end',
|
|
411
388
|
'iui-status-area': '_iui3-status-area',
|
|
389
|
+
'iui-message': '_iui3-message',
|
|
412
390
|
'iui-toast-anchor': '_iui3-toast-anchor',
|
|
413
391
|
'iui-informational': '_iui3-informational',
|
|
414
392
|
'iui-label-on-left': '_iui3-label-on-left',
|
|
@@ -416,11 +394,8 @@ const styles = {
|
|
|
416
394
|
'iui-toggle-switch-icon': '_iui3-toggle-switch-icon',
|
|
417
395
|
'iui-toggle-switch': '_iui3-toggle-switch',
|
|
418
396
|
'iui-toggle-switch-label': '_iui3-toggle-switch-label',
|
|
419
|
-
'iui-tooltip-container': '_iui3-tooltip-container',
|
|
420
397
|
'iui-tooltip': '_iui3-tooltip',
|
|
421
|
-
'iui-tooltip-visible': '_iui3-tooltip-visible',
|
|
422
398
|
'iui-transfer-list-wrapper': '_iui3-transfer-list-wrapper',
|
|
423
|
-
'iui-transfer-list-listbox-label': '_iui3-transfer-list-listbox-label',
|
|
424
399
|
'iui-transfer-list-listbox-wrapper': '_iui3-transfer-list-listbox-wrapper',
|
|
425
400
|
'iui-transfer-list-listbox': '_iui3-transfer-list-listbox',
|
|
426
401
|
'iui-transfer-list-toolbar': '_iui3-transfer-list-toolbar',
|
|
@@ -438,6 +413,7 @@ const styles = {
|
|
|
438
413
|
'iui-tree-node-content-label': '_iui3-tree-node-content-label',
|
|
439
414
|
'iui-tree-node-content-title': '_iui3-tree-node-content-title',
|
|
440
415
|
'iui-tree-node-content-caption': '_iui3-tree-node-content-caption',
|
|
416
|
+
'iui-button-base': '_iui3-button-base',
|
|
441
417
|
'iui-svg-icon': '_iui3-svg-icon',
|
|
442
418
|
'iui-notification-marker': '_iui3-notification-marker',
|
|
443
419
|
pulse,
|
|
@@ -12,20 +12,26 @@ type AlertOwnProps = {
|
|
|
12
12
|
*/
|
|
13
13
|
isSticky?: boolean;
|
|
14
14
|
};
|
|
15
|
+
type AlertLegacyProps = {
|
|
16
|
+
/** @deprecated Use `Alert.Action` subcomponent. */
|
|
17
|
+
clickableText?: React.ReactNode;
|
|
18
|
+
/** @deprecated Use `Alert.Action` subcomponent. */
|
|
19
|
+
clickableTextProps?: React.ComponentPropsWithoutRef<'a'>;
|
|
20
|
+
/** @deprecated Use `Alert.CloseButton` subcomponent. */
|
|
21
|
+
onClose?: () => void;
|
|
22
|
+
};
|
|
15
23
|
/**
|
|
16
24
|
* A small box to quickly grab user attention and communicate a brief message
|
|
17
25
|
* @example
|
|
18
|
-
* <Alert>
|
|
19
|
-
* <Alert.Message>This is an alert.</Alert.Message>
|
|
20
|
-
* </Alert>
|
|
26
|
+
* <Alert>This is an alert.</Alert>
|
|
21
27
|
* @example
|
|
22
|
-
* <Alert type='informational'>
|
|
28
|
+
* <Alert.Wrapper type='informational'>
|
|
23
29
|
* <Alert.Icon />
|
|
24
30
|
* <Alert.Message>This is an informational alert.</Alert.Message>
|
|
25
31
|
* <Alert.CloseButton onClick={() => {}} />
|
|
26
|
-
* </Alert>
|
|
32
|
+
* </Alert.Wrapper>
|
|
27
33
|
* @example
|
|
28
|
-
* <Alert type='positive'>
|
|
34
|
+
* <Alert.Wrapper type='positive'>
|
|
29
35
|
* <Alert.Icon>
|
|
30
36
|
* <SvgSmileyHappy />
|
|
31
37
|
* </Alert.Icon>
|
|
@@ -36,17 +42,22 @@ type AlertOwnProps = {
|
|
|
36
42
|
* <Alert.CloseButton onClick={() => {}}>
|
|
37
43
|
* <SvgCollapse />
|
|
38
44
|
* </Alert.CloseButton>
|
|
39
|
-
* </Alert>
|
|
45
|
+
* </Alert.Wrapper>
|
|
40
46
|
*/
|
|
41
|
-
export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps> & {
|
|
47
|
+
export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps & AlertLegacyProps> & {
|
|
48
|
+
/**
|
|
49
|
+
* Alert wrapper subcomponent
|
|
50
|
+
*/
|
|
51
|
+
Wrapper: PolymorphicForwardRefComponent<"div", AlertOwnProps>;
|
|
42
52
|
/**
|
|
43
53
|
* Alert icon subcomponent
|
|
44
54
|
*/
|
|
45
55
|
Icon: PolymorphicForwardRefComponent<"span", Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
46
56
|
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
47
|
-
}, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement
|
|
57
|
+
}, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement> | "padded"> & {
|
|
48
58
|
size?: "small" | "large" | "auto" | "medium" | import("../utils/types.js").AnyString | undefined;
|
|
49
59
|
fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
|
|
60
|
+
padded?: boolean | undefined;
|
|
50
61
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
51
62
|
as?: "span" | undefined;
|
|
52
63
|
}>;
|
package/esm/core/Alert/Alert.js
CHANGED
|
@@ -11,10 +11,47 @@ import {
|
|
|
11
11
|
StatusIconMap,
|
|
12
12
|
SvgCloseSmall,
|
|
13
13
|
Box,
|
|
14
|
+
ButtonBase,
|
|
14
15
|
} from '../utils/index.js';
|
|
15
16
|
import { IconButton } from '../Buttons/index.js';
|
|
16
17
|
const AlertContext = React.createContext(undefined);
|
|
17
|
-
|
|
18
|
+
// ----------------------------------------------------------------------------
|
|
19
|
+
// Alert component
|
|
20
|
+
const AlertComponent = React.forwardRef((props, forwardedRef) => {
|
|
21
|
+
const {
|
|
22
|
+
children,
|
|
23
|
+
type = 'informational',
|
|
24
|
+
isSticky = false,
|
|
25
|
+
clickableText,
|
|
26
|
+
clickableTextProps,
|
|
27
|
+
onClose,
|
|
28
|
+
...rest
|
|
29
|
+
} = props;
|
|
30
|
+
return React.createElement(
|
|
31
|
+
Alert.Wrapper,
|
|
32
|
+
{ type: type, isSticky: isSticky, ref: forwardedRef, ...rest },
|
|
33
|
+
React.createElement(Alert.Icon, null),
|
|
34
|
+
React.createElement(
|
|
35
|
+
Alert.Message,
|
|
36
|
+
null,
|
|
37
|
+
children,
|
|
38
|
+
clickableText
|
|
39
|
+
? React.createElement(
|
|
40
|
+
Alert.Action,
|
|
41
|
+
{ ...clickableTextProps },
|
|
42
|
+
clickableText,
|
|
43
|
+
)
|
|
44
|
+
: null,
|
|
45
|
+
),
|
|
46
|
+
onClose
|
|
47
|
+
? React.createElement(Alert.CloseButton, { onClick: onClose })
|
|
48
|
+
: null,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
AlertComponent.displayName = 'Alert';
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
// Alert.Wrapper component
|
|
54
|
+
const AlertWrapper = React.forwardRef((props, ref) => {
|
|
18
55
|
const {
|
|
19
56
|
children,
|
|
20
57
|
className,
|
|
@@ -34,7 +71,7 @@ const AlertComponent = React.forwardRef((props, ref) => {
|
|
|
34
71
|
React.createElement(AlertContext.Provider, { value: { type } }, children),
|
|
35
72
|
);
|
|
36
73
|
});
|
|
37
|
-
|
|
74
|
+
AlertWrapper.displayName = 'Alert.Wrapper';
|
|
38
75
|
// ----------------------------------------------------------------------------
|
|
39
76
|
// Alert.Icon component
|
|
40
77
|
const AlertIcon = React.forwardRef((props, ref) => {
|
|
@@ -57,7 +94,7 @@ AlertMessage.displayName = 'Alert.Message';
|
|
|
57
94
|
const AlertAction = React.forwardRef((props, ref) => {
|
|
58
95
|
const { children, className, ...rest } = props;
|
|
59
96
|
return React.createElement(
|
|
60
|
-
|
|
97
|
+
ButtonBase,
|
|
61
98
|
{
|
|
62
99
|
as: !!props.href ? 'a' : 'button',
|
|
63
100
|
className: cx('iui-alert-link', className),
|
|
@@ -88,17 +125,15 @@ AlertCloseButton.displayName = 'Alert.CloseButton';
|
|
|
88
125
|
/**
|
|
89
126
|
* A small box to quickly grab user attention and communicate a brief message
|
|
90
127
|
* @example
|
|
91
|
-
* <Alert>
|
|
92
|
-
* <Alert.Message>This is an alert.</Alert.Message>
|
|
93
|
-
* </Alert>
|
|
128
|
+
* <Alert>This is an alert.</Alert>
|
|
94
129
|
* @example
|
|
95
|
-
* <Alert type='informational'>
|
|
130
|
+
* <Alert.Wrapper type='informational'>
|
|
96
131
|
* <Alert.Icon />
|
|
97
132
|
* <Alert.Message>This is an informational alert.</Alert.Message>
|
|
98
133
|
* <Alert.CloseButton onClick={() => {}} />
|
|
99
|
-
* </Alert>
|
|
134
|
+
* </Alert.Wrapper>
|
|
100
135
|
* @example
|
|
101
|
-
* <Alert type='positive'>
|
|
136
|
+
* <Alert.Wrapper type='positive'>
|
|
102
137
|
* <Alert.Icon>
|
|
103
138
|
* <SvgSmileyHappy />
|
|
104
139
|
* </Alert.Icon>
|
|
@@ -109,9 +144,13 @@ AlertCloseButton.displayName = 'Alert.CloseButton';
|
|
|
109
144
|
* <Alert.CloseButton onClick={() => {}}>
|
|
110
145
|
* <SvgCollapse />
|
|
111
146
|
* </Alert.CloseButton>
|
|
112
|
-
* </Alert>
|
|
147
|
+
* </Alert.Wrapper>
|
|
113
148
|
*/
|
|
114
149
|
export const Alert = Object.assign(AlertComponent, {
|
|
150
|
+
/**
|
|
151
|
+
* Alert wrapper subcomponent
|
|
152
|
+
*/
|
|
153
|
+
Wrapper: AlertWrapper,
|
|
115
154
|
/**
|
|
116
155
|
* Alert icon subcomponent
|
|
117
156
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
2
|
+
import { SoftBackgrounds } from '../utils/index.js';
|
|
3
|
+
import type { AnyString, PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
3
4
|
export type AvatarStatus = 'online' | 'busy' | 'away' | 'offline';
|
|
4
5
|
type StatusTitles = {
|
|
5
6
|
[key in Exclude<AvatarStatus, ''>]: string;
|
|
@@ -29,7 +30,7 @@ type AvatarProps = {
|
|
|
29
30
|
/**
|
|
30
31
|
* Color of the icon. You can use `getUserColor` function to generate color from user name or email. If not provided, default background color from CSS styling will be used (hsl(72, 51%, 56%) / olive green).
|
|
31
32
|
*/
|
|
32
|
-
backgroundColor?:
|
|
33
|
+
backgroundColor?: keyof typeof SoftBackgrounds | AnyString;
|
|
33
34
|
/**
|
|
34
35
|
* Translated status messages shown on hover.
|
|
35
36
|
*/
|
|
@@ -4,7 +4,21 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Box,
|
|
9
|
+
VisuallyHidden,
|
|
10
|
+
SoftBackgrounds,
|
|
11
|
+
isSoftBackground,
|
|
12
|
+
} from '../utils/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* Helper function that returns one of the preset badge color values.
|
|
15
|
+
*/
|
|
16
|
+
const getBackground = (color) => {
|
|
17
|
+
if (!color) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
return isSoftBackground(color) ? SoftBackgrounds[color] : color;
|
|
21
|
+
};
|
|
8
22
|
export const defaultStatusTitles = {
|
|
9
23
|
away: 'Away',
|
|
10
24
|
busy: 'Busy',
|
|
@@ -49,27 +63,17 @@ export const Avatar = React.forwardRef((props, ref) => {
|
|
|
49
63
|
{ [`iui-${size}`]: size !== 'medium' },
|
|
50
64
|
className,
|
|
51
65
|
),
|
|
66
|
+
'data-iui-status': status,
|
|
52
67
|
title: title,
|
|
53
|
-
style: { backgroundColor, ...style },
|
|
68
|
+
style: { backgroundColor: getBackground(backgroundColor), ...style },
|
|
54
69
|
ref: ref,
|
|
55
70
|
...rest,
|
|
56
71
|
},
|
|
57
|
-
!image
|
|
58
|
-
React.createElement(
|
|
59
|
-
Box,
|
|
60
|
-
{ as: 'abbr', className: 'iui-initials' },
|
|
61
|
-
abbreviation?.substring(0, 2),
|
|
62
|
-
),
|
|
72
|
+
!image ? abbreviation?.substring(0, 2) : null,
|
|
63
73
|
image,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
as: 'span',
|
|
68
|
-
title: statusTitles[status],
|
|
69
|
-
className: cx('iui-status', {
|
|
70
|
-
[`iui-${status}`]: !!status,
|
|
71
|
-
}),
|
|
72
|
-
}),
|
|
74
|
+
status
|
|
75
|
+
? React.createElement(VisuallyHidden, null, statusTitles[status])
|
|
76
|
+
: null,
|
|
73
77
|
);
|
|
74
78
|
});
|
|
75
79
|
export default Avatar;
|
|
@@ -85,14 +85,9 @@ export const AvatarGroup = React.forwardRef((props, ref) => {
|
|
|
85
85
|
countIconProps?.className,
|
|
86
86
|
),
|
|
87
87
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
childrenLength <= maxLength
|
|
92
|
-
? `${childrenLength - maxIcons}`
|
|
93
|
-
: `${maxLength}+`,
|
|
94
|
-
),
|
|
95
|
-
React.createElement(Box, { className: 'iui-stroke' }),
|
|
88
|
+
childrenLength <= maxLength
|
|
89
|
+
? `${childrenLength - maxIcons}`
|
|
90
|
+
: `${maxLength}+`,
|
|
96
91
|
),
|
|
97
92
|
),
|
|
98
93
|
);
|