@itwin/itwinui-react 3.0.0-dev.1 → 3.0.0-dev.3
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 +25 -0
- package/cjs/core/Alert/Alert.d.ts +47 -28
- package/cjs/core/Alert/Alert.js +73 -21
- package/cjs/core/Avatar/Avatar.js +1 -1
- package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -4
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/cjs/core/Carousel/Carousel.d.ts +2 -2
- package/cjs/core/Carousel/Carousel.js +3 -5
- package/cjs/core/Carousel/CarouselDotsList.js +8 -10
- package/cjs/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/cjs/core/Carousel/CarouselNavigation.js +3 -5
- package/cjs/core/Carousel/CarouselSlider.js +10 -15
- package/cjs/core/ColorPicker/ColorBuilder.js +7 -10
- package/cjs/core/ColorPicker/ColorInputPanel.js +12 -15
- package/cjs/core/ColorPicker/ColorPalette.js +4 -6
- package/cjs/core/ColorPicker/ColorPicker.js +3 -3
- package/cjs/core/ComboBox/ComboBox.js +25 -32
- package/cjs/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/cjs/core/ComboBox/ComboBoxInput.js +21 -20
- package/cjs/core/ComboBox/ComboBoxMenu.js +3 -4
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/cjs/core/ComboBox/helpers.js +4 -5
- package/cjs/core/DatePicker/DatePicker.js +32 -32
- package/cjs/core/Dialog/Dialog.js +11 -4
- package/cjs/core/Dialog/DialogBackdrop.js +1 -1
- package/cjs/core/Dialog/DialogContext.d.ts +11 -0
- package/cjs/core/Dialog/DialogMain.js +16 -22
- package/cjs/core/DropdownMenu/DropdownMenu.js +6 -8
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/cjs/core/FileUpload/FileEmptyCard.js +1 -1
- package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
- package/cjs/core/FileUpload/FileUpload.js +5 -8
- package/cjs/core/FileUpload/FileUploadCard.js +9 -10
- package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
- package/cjs/core/InformationPanel/InformationPanel.js +1 -4
- package/cjs/core/LabeledInput/LabeledInput.js +1 -1
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/cjs/core/Menu/Menu.js +3 -4
- package/cjs/core/Menu/MenuItem.js +8 -11
- package/cjs/core/Modal/Modal.d.ts +8 -9
- package/cjs/core/Modal/Modal.js +7 -17
- package/cjs/core/SearchBox/SearchBox.js +12 -12
- package/cjs/core/Select/Select.js +12 -17
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Slider/Slider.js +16 -19
- package/cjs/core/Slider/Thumb.js +1 -1
- package/cjs/core/StatusMessage/StatusMessage.js +1 -1
- package/cjs/core/Stepper/Stepper.js +1 -1
- package/cjs/core/Stepper/StepperStep.js +1 -1
- package/cjs/core/Table/Table.js +15 -15
- package/cjs/core/Table/TablePaginator.js +2 -3
- package/cjs/core/Table/TableRowMemoized.js +38 -45
- package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
- package/cjs/core/Table/actionHandlers/filterHandler.js +4 -5
- package/cjs/core/Table/actionHandlers/selectHandler.js +6 -6
- package/cjs/core/Table/cells/DefaultCell.js +1 -1
- package/cjs/core/Table/cells/EditableCell.js +6 -12
- package/cjs/core/Table/columns/actionColumn.js +3 -6
- package/cjs/core/Table/columns/expanderColumn.js +3 -3
- package/cjs/core/Table/columns/selectionColumn.js +4 -4
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/cjs/core/Table/hooks/useResizeColumns.js +16 -22
- package/cjs/core/Table/hooks/useScrollToRow.js +1 -2
- package/cjs/core/Table/hooks/useStickyColumns.js +3 -5
- package/cjs/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/cjs/core/Tabs/Tabs.js +13 -16
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +14 -13
- package/cjs/core/Tile/Tile.js +2 -3
- package/cjs/core/TimePicker/TimePicker.js +13 -13
- package/cjs/core/Toast/Toast.d.ts +5 -10
- package/cjs/core/Toast/Toast.js +17 -16
- package/cjs/core/Toast/Toaster.d.ts +24 -26
- package/cjs/core/Toast/Toaster.js +91 -121
- package/cjs/core/Toast/index.d.ts +1 -4
- package/cjs/core/Toast/index.js +3 -6
- package/cjs/core/TransferList/TransferList.js +3 -4
- package/cjs/core/Tree/Tree.js +9 -13
- package/cjs/core/Tree/TreeNode.js +9 -10
- package/cjs/core/index.d.ts +1 -2
- package/cjs/core/index.js +2 -5
- package/cjs/core/utils/color/ColorValue.js +9 -15
- package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/cjs/core/utils/components/FocusTrap.js +4 -4
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -2
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/components/Popover.js +5 -8
- package/cjs/core/utils/components/Resizer.js +7 -6
- package/cjs/core/utils/components/VirtualScroll.js +14 -21
- package/cjs/core/utils/functions/dom.d.ts +0 -8
- package/cjs/core/utils/functions/dom.js +3 -26
- package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
- package/cjs/core/utils/functions/polymorphic.js +1 -1
- package/cjs/core/utils/functions/supports.js +1 -1
- package/cjs/core/utils/hooks/index.d.ts +0 -1
- package/cjs/core/utils/hooks/index.js +0 -1
- package/cjs/core/utils/hooks/useContainerWidth.js +1 -1
- package/cjs/core/utils/hooks/useDragAndDrop.js +8 -10
- package/cjs/core/utils/hooks/useEventListener.js +1 -1
- package/cjs/core/utils/hooks/useGlobals.d.ts +9 -2
- package/cjs/core/utils/hooks/useGlobals.js +6 -4
- package/cjs/core/utils/hooks/useId.js +1 -2
- package/cjs/core/utils/hooks/useIntersection.js +2 -3
- package/cjs/core/utils/hooks/useMediaQuery.js +6 -8
- package/cjs/core/utils/hooks/useOverflow.js +1 -2
- package/cjs/core/utils/hooks/useResizeObserver.js +3 -4
- package/cjs/styles.js +1 -4
- package/esm/core/Alert/Alert.d.ts +47 -28
- package/esm/core/Alert/Alert.js +74 -22
- package/esm/core/Avatar/Avatar.js +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -4
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/esm/core/Carousel/Carousel.d.ts +2 -2
- package/esm/core/Carousel/Carousel.js +3 -5
- package/esm/core/Carousel/CarouselDotsList.js +8 -10
- package/esm/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/esm/core/Carousel/CarouselNavigation.js +3 -5
- package/esm/core/Carousel/CarouselSlider.js +10 -15
- package/esm/core/ColorPicker/ColorBuilder.js +7 -10
- package/esm/core/ColorPicker/ColorInputPanel.js +12 -15
- package/esm/core/ColorPicker/ColorPalette.js +4 -6
- package/esm/core/ColorPicker/ColorPicker.js +3 -3
- package/esm/core/ComboBox/ComboBox.js +25 -32
- package/esm/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/esm/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/esm/core/ComboBox/ComboBoxInput.js +21 -20
- package/esm/core/ComboBox/ComboBoxMenu.js +3 -4
- package/esm/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/esm/core/ComboBox/helpers.js +4 -5
- package/esm/core/DatePicker/DatePicker.js +32 -32
- package/esm/core/Dialog/Dialog.js +12 -5
- package/esm/core/Dialog/DialogBackdrop.js +1 -1
- package/esm/core/Dialog/DialogContext.d.ts +11 -0
- package/esm/core/Dialog/DialogMain.js +16 -22
- package/esm/core/DropdownMenu/DropdownMenu.js +6 -8
- package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/esm/core/FileUpload/FileEmptyCard.js +1 -1
- package/esm/core/FileUpload/FileUpload.d.ts +3 -4
- package/esm/core/FileUpload/FileUpload.js +5 -8
- package/esm/core/FileUpload/FileUploadCard.js +9 -10
- package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
- package/esm/core/InformationPanel/InformationPanel.js +1 -4
- package/esm/core/LabeledInput/LabeledInput.js +1 -1
- package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/esm/core/Menu/Menu.js +3 -4
- package/esm/core/Menu/MenuItem.js +8 -11
- package/esm/core/Modal/Modal.d.ts +8 -9
- package/esm/core/Modal/Modal.js +3 -10
- package/esm/core/SearchBox/SearchBox.js +12 -12
- package/esm/core/Select/Select.js +12 -17
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Slider/Slider.js +16 -19
- package/esm/core/Slider/Thumb.js +1 -1
- package/esm/core/StatusMessage/StatusMessage.js +1 -1
- package/esm/core/Stepper/Stepper.js +1 -1
- package/esm/core/Stepper/StepperStep.js +1 -1
- package/esm/core/Table/Table.js +15 -15
- package/esm/core/Table/TablePaginator.js +2 -3
- package/esm/core/Table/TableRowMemoized.js +38 -45
- package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
- package/esm/core/Table/actionHandlers/filterHandler.js +4 -5
- package/esm/core/Table/actionHandlers/selectHandler.js +6 -6
- package/esm/core/Table/cells/DefaultCell.js +1 -1
- package/esm/core/Table/cells/EditableCell.js +6 -12
- package/esm/core/Table/columns/actionColumn.js +3 -6
- package/esm/core/Table/columns/expanderColumn.js +3 -3
- package/esm/core/Table/columns/selectionColumn.js +4 -4
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/esm/core/Table/hooks/useResizeColumns.js +16 -22
- package/esm/core/Table/hooks/useScrollToRow.js +1 -2
- package/esm/core/Table/hooks/useStickyColumns.js +3 -5
- package/esm/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/esm/core/Tabs/Tabs.js +13 -16
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +15 -14
- package/esm/core/Tile/Tile.js +2 -3
- package/esm/core/TimePicker/TimePicker.js +13 -13
- package/esm/core/Toast/Toast.d.ts +5 -10
- package/esm/core/Toast/Toast.js +18 -17
- package/esm/core/Toast/Toaster.d.ts +24 -26
- package/esm/core/Toast/Toaster.js +85 -121
- package/esm/core/Toast/index.d.ts +1 -4
- package/esm/core/Toast/index.js +1 -3
- package/esm/core/TransferList/TransferList.js +3 -4
- package/esm/core/Tree/Tree.js +9 -13
- package/esm/core/Tree/TreeNode.js +9 -10
- package/esm/core/index.d.ts +1 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/color/ColorValue.js +9 -15
- package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/esm/core/utils/components/FocusTrap.js +4 -4
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -2
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/components/Popover.js +5 -8
- package/esm/core/utils/components/Resizer.js +7 -6
- package/esm/core/utils/components/VirtualScroll.js +14 -21
- package/esm/core/utils/functions/dom.d.ts +0 -8
- package/esm/core/utils/functions/dom.js +2 -21
- package/esm/core/utils/functions/polymorphic.d.ts +1 -1
- package/esm/core/utils/functions/polymorphic.js +1 -1
- package/esm/core/utils/functions/supports.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +0 -1
- package/esm/core/utils/hooks/index.js +0 -1
- package/esm/core/utils/hooks/useContainerWidth.js +1 -1
- package/esm/core/utils/hooks/useDragAndDrop.js +8 -10
- package/esm/core/utils/hooks/useEventListener.js +1 -1
- package/esm/core/utils/hooks/useGlobals.d.ts +9 -2
- package/esm/core/utils/hooks/useGlobals.js +6 -4
- package/esm/core/utils/hooks/useId.js +1 -2
- package/esm/core/utils/hooks/useIntersection.js +2 -3
- package/esm/core/utils/hooks/useMediaQuery.js +6 -8
- package/esm/core/utils/hooks/useOverflow.js +1 -2
- package/esm/core/utils/hooks/useResizeObserver.js +3 -4
- package/esm/styles.js +1 -4
- package/package.json +2 -2
- package/styles.css +19 -20
- package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
- package/cjs/core/Toast/ToastWrapper.js +0 -49
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.js +0 -54
- package/esm/core/Toast/ToastWrapper.d.ts +0 -10
- package/esm/core/Toast/ToastWrapper.js +0 -20
- package/esm/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/esm/core/utils/hooks/useIsThemeAlreadySet.js +0 -27
|
@@ -22,137 +22,107 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ToasterStateContext = exports.ToastProvider = exports.Toaster = exports.useToaster = void 0;
|
|
26
30
|
/*---------------------------------------------------------------------------------------------
|
|
27
31
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
28
32
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
29
33
|
*--------------------------------------------------------------------------------------------*/
|
|
30
34
|
const React = __importStar(require("react"));
|
|
31
|
-
const
|
|
35
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
32
36
|
const index_js_1 = require("../utils/index.js");
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const Toast_js_1 = require("./Toast.js");
|
|
38
|
+
// ----------------------------------------------------------------------------
|
|
39
|
+
const useToaster = () => {
|
|
40
|
+
const dispatch = (0, index_js_1.useSafeContext)(ToasterDispatchContext);
|
|
41
|
+
const showToast = React.useCallback((category) => (content, options) => {
|
|
42
|
+
const id = nextId();
|
|
43
|
+
dispatch({
|
|
44
|
+
type: 'add',
|
|
45
|
+
toast: { ...options, id, content, category },
|
|
46
|
+
});
|
|
47
|
+
return { close: () => dispatch({ type: 'remove', id }) };
|
|
48
|
+
}, [dispatch]);
|
|
49
|
+
return {
|
|
50
|
+
positive: showToast('positive'),
|
|
51
|
+
informational: showToast('informational'),
|
|
52
|
+
negative: showToast('negative'),
|
|
53
|
+
warning: showToast('warning'),
|
|
54
|
+
closeAll: () => {
|
|
55
|
+
dispatch({ type: 'close-all' });
|
|
56
|
+
},
|
|
57
|
+
setSettings: (settings) => {
|
|
58
|
+
dispatch({ type: 'settings', settings });
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.useToaster = useToaster;
|
|
63
|
+
// ----------------------------------------------------------------------------
|
|
64
|
+
const Toaster = () => {
|
|
65
|
+
const { toasts, settings } = (0, index_js_1.useSafeContext)(exports.ToasterStateContext);
|
|
66
|
+
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)(`iui-toast-wrapper`, `iui-placement-${settings.placement}`) }, toasts.map((toastProps) => {
|
|
67
|
+
return React.createElement(Toast_js_1.Toast, { key: toastProps.id, ...toastProps });
|
|
68
|
+
})));
|
|
69
|
+
};
|
|
70
|
+
exports.Toaster = Toaster;
|
|
71
|
+
// ----------------------------------------------------------------------------
|
|
72
|
+
const ToastProvider = ({ children }) => {
|
|
73
|
+
const [toasterState, dispatch] = React.useReducer(toastReducer, {
|
|
74
|
+
toasts: [],
|
|
75
|
+
settings: {
|
|
76
|
+
order: 'auto',
|
|
41
77
|
placement: 'top',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return (React.createElement(ToasterDispatchContext.Provider, { value: dispatch },
|
|
81
|
+
React.createElement(exports.ToasterStateContext.Provider, { value: toasterState }, children)));
|
|
82
|
+
};
|
|
83
|
+
exports.ToastProvider = ToastProvider;
|
|
84
|
+
const toastReducer = (state, action) => {
|
|
85
|
+
if (action.type === 'add') {
|
|
86
|
+
let order = state.settings.order;
|
|
87
|
+
if (order === 'auto') {
|
|
88
|
+
order = state.settings.placement.startsWith('top')
|
|
89
|
+
? 'descending'
|
|
90
|
+
: 'ascending';
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...state,
|
|
94
|
+
toasts: [
|
|
95
|
+
...(order === 'ascending' ? state.toasts : []),
|
|
96
|
+
action.toast,
|
|
97
|
+
...(order === 'descending' ? state.toasts : []),
|
|
98
|
+
],
|
|
42
99
|
};
|
|
43
|
-
this.toastsRef = React.createRef();
|
|
44
|
-
this.isInitialized = false;
|
|
45
|
-
// Create container on demand.
|
|
46
|
-
// Cannot do it in constructor, because SSG/SSR apps would fail.
|
|
47
|
-
this.asyncInit = async () => {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
if (this.isInitialized) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const container = (_a = (0, index_js_1.getContainer)(TOASTS_CONTAINER_ID)) !== null && _a !== void 0 ? _a : (_b = (0, index_js_1.getDocument)()) === null || _b === void 0 ? void 0 : _b.body;
|
|
53
|
-
if (!container) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.isInitialized = true;
|
|
57
|
-
const toastWrapper = React.createElement(ToastWrapper_js_1.ToastWrapper, { ref: this.toastsRef });
|
|
58
|
-
const _ReactDOM = ReactDOM; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
59
|
-
// v18 mode
|
|
60
|
-
if (_ReactDOM.createRoot) {
|
|
61
|
-
const _ReactDOMInternals = _ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
62
|
-
// suppress warning about importing createRoot from react-dom/client
|
|
63
|
-
if (_ReactDOMInternals) {
|
|
64
|
-
_ReactDOMInternals.usingClientEntryPoint = true;
|
|
65
|
-
}
|
|
66
|
-
const root = _ReactDOM.createRoot(container);
|
|
67
|
-
root.render(toastWrapper);
|
|
68
|
-
// revert suppression, not to influence users app
|
|
69
|
-
if (_ReactDOMInternals) {
|
|
70
|
-
_ReactDOMInternals.usingClientEntryPoint = false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
// v17 and before
|
|
75
|
-
ReactDOM.render(toastWrapper, container);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Set global Toaster settings for toasts order and placement.
|
|
81
|
-
* Settings will be applied to new toasts on the page.
|
|
82
|
-
*/
|
|
83
|
-
setSettings(newSettings) {
|
|
84
|
-
var _a, _b, _c;
|
|
85
|
-
(_a = newSettings.placement) !== null && _a !== void 0 ? _a : (newSettings.placement = this.settings.placement);
|
|
86
|
-
(_b = newSettings.order) !== null && _b !== void 0 ? _b : (newSettings.order = ((_c = newSettings.placement) === null || _c === void 0 ? void 0 : _c.startsWith('bottom'))
|
|
87
|
-
? 'ascending'
|
|
88
|
-
: 'descending');
|
|
89
|
-
this.settings = newSettings;
|
|
90
|
-
this.asyncInit().then(() => {
|
|
91
|
-
var _a, _b;
|
|
92
|
-
(_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setPlacement((_b = this.settings.placement) !== null && _b !== void 0 ? _b : 'top');
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
positive(content, options) {
|
|
96
|
-
return this.createToast(content, 'positive', options);
|
|
97
|
-
}
|
|
98
|
-
informational(content, options) {
|
|
99
|
-
return this.createToast(content, 'informational', options);
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
createToast(content, category, options) {
|
|
108
|
-
++this.lastId;
|
|
109
|
-
const currentId = this.lastId;
|
|
110
|
-
this.toasts = [
|
|
111
|
-
...(this.settings.order === 'ascending' ? this.toasts : []),
|
|
112
|
-
{
|
|
113
|
-
...options,
|
|
114
|
-
content,
|
|
115
|
-
category,
|
|
116
|
-
onRemove: () => {
|
|
117
|
-
var _a;
|
|
118
|
-
this.removeToast(currentId);
|
|
119
|
-
(_a = options === null || options === void 0 ? void 0 : options.onRemove) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
120
|
-
},
|
|
121
|
-
id: currentId,
|
|
122
|
-
isVisible: true,
|
|
123
|
-
},
|
|
124
|
-
...(this.settings.order === 'descending' ? this.toasts : []),
|
|
125
|
-
];
|
|
126
|
-
this.updateView();
|
|
127
|
-
return { close: () => this.closeToast(currentId) };
|
|
128
|
-
}
|
|
129
|
-
removeToast(id) {
|
|
130
|
-
this.toasts = this.toasts.filter((toast) => toast.id !== id);
|
|
131
|
-
this.updateView();
|
|
132
|
-
}
|
|
133
|
-
updateView() {
|
|
134
|
-
this.asyncInit().then(() => {
|
|
135
|
-
var _a;
|
|
136
|
-
(_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(this.toasts);
|
|
137
|
-
});
|
|
101
|
+
if (action.type === 'remove') {
|
|
102
|
+
return {
|
|
103
|
+
...state,
|
|
104
|
+
toasts: state.toasts.filter((toast) => toast.id !== action.id),
|
|
105
|
+
};
|
|
138
106
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
this.updateView();
|
|
107
|
+
if (action.type === 'close-all') {
|
|
108
|
+
return {
|
|
109
|
+
...state,
|
|
110
|
+
toasts: state.toasts.map((toast) => ({ ...toast, isVisible: false })),
|
|
111
|
+
};
|
|
147
112
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
...toast,
|
|
152
|
-
isVisible: false,
|
|
153
|
-
};
|
|
154
|
-
});
|
|
155
|
-
this.updateView();
|
|
113
|
+
if (action.type === 'settings') {
|
|
114
|
+
return { ...state, settings: { ...state.settings, ...action.settings } };
|
|
156
115
|
}
|
|
157
|
-
|
|
158
|
-
|
|
116
|
+
return state;
|
|
117
|
+
};
|
|
118
|
+
// ----------------------------------------------------------------------------
|
|
119
|
+
exports.ToasterStateContext = React.createContext(undefined);
|
|
120
|
+
exports.ToasterStateContext.displayName = 'ToasterStateContext';
|
|
121
|
+
// ----------------------------------------------------------------------------
|
|
122
|
+
const ToasterDispatchContext = React.createContext(undefined);
|
|
123
|
+
ToasterDispatchContext.displayName = 'ToasterDispatchContext';
|
|
124
|
+
// ----------------------------------------------------------------------------
|
|
125
|
+
const nextId = (() => {
|
|
126
|
+
let count = 0;
|
|
127
|
+
return () => ++count;
|
|
128
|
+
})();
|
package/cjs/core/Toast/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToaster = void 0;
|
|
6
4
|
/*---------------------------------------------------------------------------------------------
|
|
7
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
8
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
9
7
|
*--------------------------------------------------------------------------------------------*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.default = toaster;
|
|
8
|
+
var Toaster_js_1 = require("./Toaster.js");
|
|
9
|
+
Object.defineProperty(exports, "useToaster", { enumerable: true, get: function () { return Toaster_js_1.useToaster; } });
|
|
@@ -36,10 +36,9 @@ const TransferListListbox = react_1.default.forwardRef((props, ref) => {
|
|
|
36
36
|
return focusableItems.filter((i) => !focusableItems.some((p) => p.contains(i.parentElement)));
|
|
37
37
|
}, []);
|
|
38
38
|
react_1.default.useEffect(() => {
|
|
39
|
-
var _a;
|
|
40
39
|
const items = getFocusableNodes();
|
|
41
40
|
if (focusedIndex != null) {
|
|
42
|
-
|
|
41
|
+
items?.[focusedIndex]?.focus();
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
}, [focusedIndex, getFocusableNodes]);
|
|
@@ -48,10 +47,10 @@ const TransferListListbox = react_1.default.forwardRef((props, ref) => {
|
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
49
|
const items = getFocusableNodes();
|
|
51
|
-
if (!
|
|
50
|
+
if (!items?.length) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
const currentIndex = focusedIndex
|
|
53
|
+
const currentIndex = focusedIndex ?? 0;
|
|
55
54
|
switch (event.key) {
|
|
56
55
|
case 'ArrowDown': {
|
|
57
56
|
setFocusedIndex(Math.min(currentIndex + 1, items.length - 1));
|
package/cjs/core/Tree/Tree.js
CHANGED
|
@@ -102,10 +102,10 @@ const Tree = (props) => {
|
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
const items = getFocusableNodes();
|
|
105
|
-
if (!
|
|
105
|
+
if (!items?.length) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
const activeIndex = items.findIndex((el) =>
|
|
108
|
+
const activeIndex = items.findIndex((el) => el.contains(treeRef.current?.ownerDocument.activeElement));
|
|
109
109
|
const currentIndex = activeIndex > -1 ? activeIndex : 0;
|
|
110
110
|
switch (event.key) {
|
|
111
111
|
case 'ArrowUp': {
|
|
@@ -155,20 +155,18 @@ const Tree = (props) => {
|
|
|
155
155
|
return [flatList, firstLevelNodes];
|
|
156
156
|
}, [data, getNode]);
|
|
157
157
|
const itemRenderer = React.useCallback((index) => {
|
|
158
|
-
var _a, _b, _c, _d;
|
|
159
158
|
const node = flatNodesList[index];
|
|
160
159
|
return (React.createElement(TreeContext_js_1.TreeContext.Provider, { key: node.nodeProps.nodeId, value: {
|
|
161
160
|
nodeDepth: node.depth,
|
|
162
161
|
subNodeIds: node.subNodeIds,
|
|
163
162
|
groupSize: node.depth === 0
|
|
164
163
|
? firstLevelNodesList.length
|
|
165
|
-
:
|
|
164
|
+
: node.parentNode?.subNodeIds?.length ?? 0,
|
|
166
165
|
indexInGroup: node.indexInGroup,
|
|
167
|
-
parentNodeId:
|
|
166
|
+
parentNodeId: node.parentNode?.nodeProps.nodeId,
|
|
168
167
|
scrollToParent: node.parentNode
|
|
169
168
|
? () => {
|
|
170
|
-
|
|
171
|
-
const parentNodeId = (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.nodeProps.nodeId;
|
|
169
|
+
const parentNodeId = node.parentNode?.nodeProps.nodeId;
|
|
172
170
|
const parentNodeIndex = flatNodesList.findIndex((n) => n.nodeProps.nodeId === parentNodeId);
|
|
173
171
|
setScrollToIndex(parentNodeIndex);
|
|
174
172
|
}
|
|
@@ -182,11 +180,10 @@ const Tree = (props) => {
|
|
|
182
180
|
}, [flatNodesList]);
|
|
183
181
|
React.useEffect(() => {
|
|
184
182
|
setTimeout(() => {
|
|
185
|
-
var _a;
|
|
186
183
|
if (scrollToIndex !== undefined) {
|
|
187
184
|
const nodeId = flatNodesListRef.current[scrollToIndex].nodeProps.nodeId;
|
|
188
|
-
const nodeElement =
|
|
189
|
-
nodeElement
|
|
185
|
+
const nodeElement = treeRef.current?.ownerDocument.querySelector(`#${nodeId}`);
|
|
186
|
+
nodeElement?.focus();
|
|
190
187
|
// Need to reset that if navigating with mouse and keyboard,
|
|
191
188
|
// e.g. pressing arrow left to go to parent node and then with mouse
|
|
192
189
|
// clicking some other child node and then pressing arrow left
|
|
@@ -195,13 +192,12 @@ const Tree = (props) => {
|
|
|
195
192
|
});
|
|
196
193
|
}, [scrollToIndex]);
|
|
197
194
|
const handleFocus = (event) => {
|
|
198
|
-
|
|
199
|
-
if ((_a = treeRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget)) {
|
|
195
|
+
if (treeRef.current?.contains(event.relatedTarget)) {
|
|
200
196
|
return;
|
|
201
197
|
}
|
|
202
198
|
const items = getFocusableNodes();
|
|
203
199
|
if (items.length > 0) {
|
|
204
|
-
|
|
200
|
+
items[focusedIndex.current]?.focus();
|
|
205
201
|
}
|
|
206
202
|
};
|
|
207
203
|
return (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualizedTree, { flatNodesList: flatNodesList, itemRenderer: itemRenderer, scrollToIndex: scrollToIndex, onFocus: handleFocus, onKeyDown: handleKeyDown, ref: treeRef, className: className, style: style, ...rest })) : (React.createElement(TreeElement, { onKeyDown: handleKeyDown, onFocus: handleFocus, className: className, style: style, ref: treeRef, ...rest }, flatNodesList.map((_, i) => itemRenderer(i))))));
|
|
@@ -61,11 +61,10 @@ const TreeNode = (props) => {
|
|
|
61
61
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
62
62
|
const nodeRef = React.useRef(null);
|
|
63
63
|
const onKeyDown = (event) => {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f;
|
|
65
64
|
if (event.altKey) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
|
-
const isNodeFocused = nodeRef.current ===
|
|
67
|
+
const isNodeFocused = nodeRef.current === nodeRef.current?.ownerDocument.activeElement;
|
|
69
68
|
switch (event.key) {
|
|
70
69
|
case 'ArrowLeft': {
|
|
71
70
|
event.preventDefault();
|
|
@@ -75,19 +74,19 @@ const TreeNode = (props) => {
|
|
|
75
74
|
break;
|
|
76
75
|
}
|
|
77
76
|
if (parentNodeId) {
|
|
78
|
-
scrollToParent
|
|
77
|
+
scrollToParent?.();
|
|
79
78
|
break;
|
|
80
79
|
}
|
|
81
80
|
// If it is top level node (doesn't have parent node), then do nothing.
|
|
82
81
|
break;
|
|
83
82
|
}
|
|
84
83
|
const focusableElements = (0, index_js_1.getFocusableElements)(nodeRef.current);
|
|
85
|
-
const currentIndex = focusableElements.indexOf(
|
|
84
|
+
const currentIndex = focusableElements.indexOf(nodeRef.current?.ownerDocument.activeElement);
|
|
86
85
|
if (currentIndex === 0) {
|
|
87
|
-
|
|
86
|
+
nodeRef.current?.focus();
|
|
88
87
|
}
|
|
89
88
|
else {
|
|
90
|
-
|
|
89
|
+
focusableElements[currentIndex - 1]?.focus();
|
|
91
90
|
}
|
|
92
91
|
break;
|
|
93
92
|
}
|
|
@@ -99,10 +98,10 @@ const TreeNode = (props) => {
|
|
|
99
98
|
onExpanded(nodeId, true);
|
|
100
99
|
break;
|
|
101
100
|
}
|
|
102
|
-
|
|
101
|
+
focusableElements[0]?.focus();
|
|
103
102
|
break;
|
|
104
103
|
}
|
|
105
|
-
const currentIndex = focusableElements.indexOf(
|
|
104
|
+
const currentIndex = focusableElements.indexOf(nodeRef.current?.ownerDocument.activeElement);
|
|
106
105
|
if (currentIndex < focusableElements.length - 1) {
|
|
107
106
|
focusableElements[currentIndex + 1].focus();
|
|
108
107
|
break;
|
|
@@ -118,7 +117,7 @@ const TreeNode = (props) => {
|
|
|
118
117
|
}
|
|
119
118
|
event.preventDefault();
|
|
120
119
|
if (!isDisabled) {
|
|
121
|
-
onSelected
|
|
120
|
+
onSelected?.(nodeId, !isSelected);
|
|
122
121
|
}
|
|
123
122
|
break;
|
|
124
123
|
}
|
|
@@ -140,7 +139,7 @@ const TreeNode = (props) => {
|
|
|
140
139
|
React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tree-node', {
|
|
141
140
|
'iui-active': isSelected,
|
|
142
141
|
'iui-disabled': isDisabled,
|
|
143
|
-
}), style: { '--level': nodeDepth }, onClick: () => !isDisabled &&
|
|
142
|
+
}), style: { '--level': nodeDepth }, onClick: () => !isDisabled && onSelected?.(nodeId, !isSelected) },
|
|
144
143
|
checkbox && (React.createElement(index_js_1.Box, { className: 'iui-tree-node-checkbox' }, React.isValidElement(checkbox)
|
|
145
144
|
? React.cloneElement(checkbox, {
|
|
146
145
|
tabIndex: isFocused ? 0 : -1,
|
package/cjs/core/index.d.ts
CHANGED
|
@@ -51,8 +51,7 @@ export { Textarea } from './Textarea/index.js';
|
|
|
51
51
|
export { Tile } from './Tile/index.js';
|
|
52
52
|
export { TimePicker } from './TimePicker/index.js';
|
|
53
53
|
export type { MeridiemType } from './TimePicker/index.js';
|
|
54
|
-
export {
|
|
55
|
-
export type { ToastOptions } from './Toast/index.js';
|
|
54
|
+
export { useToaster } from './Toast/index.js';
|
|
56
55
|
export { ThemeProvider } from './ThemeProvider/index.js';
|
|
57
56
|
export type { ThemeType } from './ThemeProvider/index.js';
|
|
58
57
|
export { ToggleSwitch } from './ToggleSwitch/index.js';
|
package/cjs/core/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = exports.HorizontalTabs = exports.Tab = exports.Tabs = exports.VerticalTabs = exports.TransferList = exports.ListItem = exports.List = exports.HeaderLogo = exports.HeaderButton = exports.HeaderBreadcrumbs = exports.Header = exports.defaultFooterElements = exports.Footer = exports.FileEmptyCard = exports.FileUploadCard = exports.FileUploadTemplate = exports.FileUpload = exports.Fieldset = exports.ExpandableBlock = exports.NonIdealState = exports.ErrorPage = exports.DropdownMenu = exports.Dialog = exports.generateLocalizedStrings = exports.DatePicker = exports.ComboBox = exports.ColorPalette = exports.ColorInputPanel = exports.ColorBuilder = exports.ColorSwatch = exports.ColorPicker = exports.Checkbox = exports.Carousel = exports.ButtonGroup = exports.SplitButton = exports.IdeasButton = exports.IconButton = exports.DropdownButton = exports.Button = exports.Breadcrumbs = exports.Badge = exports.Backdrop = exports.UserIconGroup = exports.AvatarGroup = exports.UserIcon = exports.Avatar = exports.Alert = void 0;
|
|
7
|
-
exports.Tooltip = exports.ToggleSwitch = exports.ThemeProvider = exports.
|
|
4
|
+
exports.Tooltip = exports.ToggleSwitch = exports.ThemeProvider = exports.useToaster = exports.TimePicker = exports.Tile = exports.Textarea = exports.TagContainer = exports.Tag = exports.SelectionColumn = exports.ExpanderColumn = exports.ActionColumn = exports.TablePaginator = exports.EditableCell = exports.DefaultCell = exports.FilterButtonBar = exports.BaseFilter = exports.tableFilters = exports.Table = exports.Surface = exports.StatusMessage = exports.Slider = exports.SkipToContentLink = exports.SidenavSubmenuHeader = exports.SidenavSubmenu = exports.SidenavButton = exports.SideNavigation = exports.Select = exports.RadioTileGroup = exports.RadioTile = exports.Radio = exports.ProgressRadial = exports.ProgressLinear = exports.NotificationMarker = exports.ModalContent = exports.ModalButtonBar = exports.Modal = exports.MenuItemSkeleton = exports.MenuExtraContent = exports.MenuDivider = exports.MenuItem = exports.Menu = exports.LabeledTextarea = exports.LabeledSelect = exports.InputGroup = exports.LabeledInput = exports.Label = exports.Input = exports.InformationPanelContent = exports.InformationPanelBody = void 0;
|
|
8
5
|
exports.Divider = exports.VisuallyHidden = exports.Flex = exports.Icon = exports.LinkAction = exports.LinkBox = exports.MiddleTextTruncation = exports.ColorValue = exports.getUserColor = exports.SearchBox = exports.WorkflowDiagram = exports.Stepper = exports.Wizard = exports.Text = exports.KbdKeys = exports.Kbd = exports.Code = exports.Blockquote = exports.Anchor = exports.TreeNodeExpander = exports.TreeNode = exports.Tree = void 0;
|
|
9
6
|
/*---------------------------------------------------------------------------------------------
|
|
10
7
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -155,7 +152,7 @@ Object.defineProperty(exports, "Tile", { enumerable: true, get: function () { re
|
|
|
155
152
|
var index_js_48 = require("./TimePicker/index.js");
|
|
156
153
|
Object.defineProperty(exports, "TimePicker", { enumerable: true, get: function () { return index_js_48.TimePicker; } });
|
|
157
154
|
var index_js_49 = require("./Toast/index.js");
|
|
158
|
-
Object.defineProperty(exports, "
|
|
155
|
+
Object.defineProperty(exports, "useToaster", { enumerable: true, get: function () { return index_js_49.useToaster; } });
|
|
159
156
|
var index_js_50 = require("./ThemeProvider/index.js");
|
|
160
157
|
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return index_js_50.ThemeProvider; } });
|
|
161
158
|
var index_js_51 = require("./ToggleSwitch/index.js");
|
|
@@ -116,27 +116,24 @@ class ColorValue {
|
|
|
116
116
|
* This allows component builders to know if they received bad input from user.
|
|
117
117
|
*/
|
|
118
118
|
static fromString(val, defaultColorIfNotParsed) {
|
|
119
|
-
const [tbgr, hue] = this.computeTbgrFromString(val, defaultColorIfNotParsed
|
|
119
|
+
const [tbgr, hue] = this.computeTbgrFromString(val, defaultColorIfNotParsed?.toTbgr());
|
|
120
120
|
return new ColorValue(tbgr, hue);
|
|
121
121
|
}
|
|
122
122
|
/** Create a ColorValue from hue, saturation, lightness values. */
|
|
123
123
|
static fromHSL(hsl) {
|
|
124
|
-
|
|
125
|
-
const alpha = (_a = hsl.a) !== null && _a !== void 0 ? _a : 1;
|
|
124
|
+
const alpha = hsl.a ?? 1;
|
|
126
125
|
return new ColorValue(this.computeTbgrFromHSL(hsl.h / 360, hsl.s / 100, hsl.l / 100, Math.round((1 - alpha) * 255)), hsl.h);
|
|
127
126
|
}
|
|
128
127
|
/** Create a ColorValue from an RgbColor */
|
|
129
128
|
static fromRGB(rgb) {
|
|
130
|
-
|
|
131
|
-
const alpha = (_a = rgb.a) !== null && _a !== void 0 ? _a : 1;
|
|
129
|
+
const alpha = rgb.a ?? 1;
|
|
132
130
|
return ColorValue.fromRgbt(rgb.r, rgb.g, rgb.b, Math.round((1 - alpha) * 255));
|
|
133
131
|
}
|
|
134
132
|
/**
|
|
135
133
|
* Create a ColorValue from an HsvColor
|
|
136
134
|
*/
|
|
137
135
|
static fromHSV(hsv) {
|
|
138
|
-
|
|
139
|
-
const alpha = (_a = hsv.a) !== null && _a !== void 0 ? _a : 1;
|
|
136
|
+
const alpha = hsv.a ?? 1;
|
|
140
137
|
const transparency = Math.round((1 - alpha) * 255);
|
|
141
138
|
// Check for simple case first.
|
|
142
139
|
if (!hsv.s || hsv.h === -1) {
|
|
@@ -487,33 +484,30 @@ class ColorValue {
|
|
|
487
484
|
}
|
|
488
485
|
/** Convert the 0xTTBBGGRR color to a string of the form "rgba(r,g,b,a)" where the color components are specified in decimal and the alpha component is a fraction. */
|
|
489
486
|
toRgbString(includeAlpha) {
|
|
490
|
-
var _a;
|
|
491
487
|
const rgb = this.toRgbColor();
|
|
492
488
|
const rgbString = `${rgb.r}, ${rgb.g}, ${rgb.b}`;
|
|
493
489
|
if (includeAlpha) {
|
|
494
|
-
const alpha =
|
|
490
|
+
const alpha = rgb.a ?? 1;
|
|
495
491
|
return `rgba(${rgbString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
|
|
496
492
|
}
|
|
497
493
|
return `rgb(${rgbString})`;
|
|
498
494
|
}
|
|
499
495
|
/** Convert this ColorValue to a string in the form "hsl(h,s,l) or hsla(h,s,l,a)" - i.e hsl(120,50%,50%). */
|
|
500
496
|
toHslString(includeAlpha) {
|
|
501
|
-
var _a, _b;
|
|
502
497
|
const hsl = this.toHslColor();
|
|
503
|
-
const hslString = `${ColorValue.getFormattedColorNumber(
|
|
498
|
+
const hslString = `${ColorValue.getFormattedColorNumber(this._hue ?? hsl.h)}, ${ColorValue.getFormattedColorNumber(hsl.s)}%, ${ColorValue.getFormattedColorNumber(hsl.l)}%`;
|
|
504
499
|
if (includeAlpha) {
|
|
505
|
-
const alpha =
|
|
500
|
+
const alpha = hsl.a ?? 1;
|
|
506
501
|
return `hsla(${hslString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
|
|
507
502
|
}
|
|
508
503
|
return `hsl(${hslString})`;
|
|
509
504
|
}
|
|
510
505
|
/** Convert this ColorValue to a string in the form "hsv(h,s,v) or hsva(h,s,v,a)" - i.e hsv(120,50%,50%). */
|
|
511
506
|
toHsvString(includeAlpha) {
|
|
512
|
-
var _a, _b;
|
|
513
507
|
const hsv = this.toHsvColor();
|
|
514
|
-
const hsvString = `${
|
|
508
|
+
const hsvString = `${this._hue ?? hsv.h}, ${hsv.s}%, ${hsv.v}%`;
|
|
515
509
|
if (includeAlpha) {
|
|
516
|
-
const alpha =
|
|
510
|
+
const alpha = hsv.a ?? 1;
|
|
517
511
|
return `hsva(${hsvString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
|
|
518
512
|
}
|
|
519
513
|
return `hsv(${hsvString})`;
|
|
@@ -42,10 +42,9 @@ const index_js_1 = require("../functions/index.js");
|
|
|
42
42
|
const AutoclearingHiddenLiveRegion = ({ text = '' }) => {
|
|
43
43
|
const [maybeText, setMaybeText] = React.useState(text);
|
|
44
44
|
React.useEffect(() => {
|
|
45
|
-
var _a;
|
|
46
45
|
setMaybeText(text);
|
|
47
|
-
const timeout = (
|
|
48
|
-
return () =>
|
|
46
|
+
const timeout = (0, index_js_1.getWindow)()?.setTimeout(() => setMaybeText(''), 5000);
|
|
47
|
+
return () => void (0, index_js_1.getWindow)()?.clearTimeout(timeout);
|
|
49
48
|
}, [text]);
|
|
50
49
|
return (React.createElement(VisuallyHidden_js_1.VisuallyHidden, { as: 'div', "aria-live": 'polite', "aria-atomic": 'true' }, maybeText));
|
|
51
50
|
};
|
|
@@ -47,19 +47,19 @@ const FocusTrap = (props) => {
|
|
|
47
47
|
const onFirstFocus = (event) => {
|
|
48
48
|
const [firstElement, lastElement] = getFirstLastFocusables();
|
|
49
49
|
if (event.relatedTarget === firstElement) {
|
|
50
|
-
lastElement
|
|
50
|
+
lastElement?.focus();
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
|
-
firstElement
|
|
53
|
+
firstElement?.focus();
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
const onLastFocus = (event) => {
|
|
57
57
|
const [firstElement, lastElement] = getFirstLastFocusables();
|
|
58
58
|
if (event.relatedTarget === lastElement) {
|
|
59
|
-
firstElement
|
|
59
|
+
firstElement?.focus();
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
lastElement
|
|
62
|
+
lastElement?.focus();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
return (React.createElement(React.Fragment, null,
|
|
@@ -48,7 +48,6 @@ const ELLIPSIS_CHAR = '…';
|
|
|
48
48
|
* />
|
|
49
49
|
*/
|
|
50
50
|
const MiddleTextTruncation = (props) => {
|
|
51
|
-
var _a;
|
|
52
51
|
const { text, endCharsCount = 6, textRenderer, style, ...rest } = props;
|
|
53
52
|
const [ref, visibleCount] = (0, useOverflow_js_1.useOverflow)(text);
|
|
54
53
|
const truncatedText = React.useMemo(() => {
|
|
@@ -65,7 +64,7 @@ const MiddleTextTruncation = (props) => {
|
|
|
65
64
|
flexGrow: 1,
|
|
66
65
|
whiteSpace: 'nowrap',
|
|
67
66
|
...style,
|
|
68
|
-
}, ref: ref, ...rest },
|
|
67
|
+
}, ref: ref, ...rest }, textRenderer?.(truncatedText, text) ?? truncatedText));
|
|
69
68
|
};
|
|
70
69
|
exports.MiddleTextTruncation = MiddleTextTruncation;
|
|
71
70
|
exports.default = exports.MiddleTextTruncation;
|
|
@@ -25,7 +25,7 @@ export declare type PopoverProps = {
|
|
|
25
25
|
* with pre-configured props and plugins (e.g. lazy mounting, focus, etc).
|
|
26
26
|
* @private
|
|
27
27
|
*/
|
|
28
|
-
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "className" | "role" | "offset" | "children" | "content" | "plugins" | "
|
|
28
|
+
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "className" | "role" | "offset" | "children" | "content" | "plugins" | "placement" | "trigger" | "visible" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "theme" | "zIndex" | "singleton" | "reference"> & React.RefAttributes<unknown>>;
|
|
29
29
|
/**
|
|
30
30
|
* Plugin to hide Popover when either Esc key is pressed,
|
|
31
31
|
* or when the content inside is not tabbable and Tab key is pressed.
|