@itwin/itwinui-react 1.20.0 → 1.21.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 +7 -0
- package/cjs/core/Alert/Alert.d.ts +1 -1
- package/cjs/core/Alert/Alert.js +3 -4
- package/cjs/core/Badge/Badge.d.ts +1 -2
- package/cjs/core/Badge/Badge.js +4 -5
- package/cjs/core/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +4 -6
- package/cjs/core/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/cjs/core/ButtonGroup/ButtonGroup.js +3 -4
- package/cjs/core/Buttons/Button/Button.js +2 -2
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -4
- package/cjs/core/Buttons/IconButton/IconButton.js +2 -2
- package/cjs/core/Buttons/IdeasButton/IdeasButton.js +2 -2
- package/cjs/core/Buttons/SplitButton/SplitButton.js +2 -2
- package/cjs/core/Checkbox/Checkbox.js +3 -4
- package/cjs/core/ComboBox/ComboBox.d.ts +51 -0
- package/cjs/core/ComboBox/ComboBox.js +268 -0
- package/cjs/core/ComboBox/index.d.ts +4 -0
- package/cjs/core/ComboBox/index.js +10 -0
- package/cjs/core/DatePicker/DatePicker.js +2 -2
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -2
- package/cjs/core/DropdownMenu/DropdownMenu.js +4 -6
- package/cjs/core/ErrorPage/ErrorPage.js +2 -2
- package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +1 -1
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +3 -4
- package/cjs/core/Fieldset/Fieldset.js +2 -2
- package/cjs/core/FileUpload/FileUpload.d.ts +2 -2
- package/cjs/core/FileUpload/FileUpload.js +3 -4
- package/cjs/core/FileUpload/FileUploadTemplate.js +2 -2
- package/cjs/core/Footer/Footer.d.ts +1 -1
- package/cjs/core/Footer/Footer.js +2 -2
- package/cjs/core/Header/Header.d.ts +1 -1
- package/cjs/core/Header/Header.js +2 -2
- package/cjs/core/Header/HeaderBreadcrumbs.js +2 -2
- package/cjs/core/Header/HeaderButton.js +2 -2
- package/cjs/core/Header/HeaderLogo.d.ts +1 -1
- package/cjs/core/Header/HeaderLogo.js +2 -2
- package/cjs/core/Input/Input.js +3 -4
- package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
- package/cjs/core/InputGroup/InputGroup.js +4 -6
- package/cjs/core/LabeledInput/LabeledInput.js +4 -6
- package/cjs/core/LabeledSelect/LabeledSelect.js +4 -6
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +4 -6
- package/cjs/core/Menu/Menu.d.ts +11 -1
- package/cjs/core/Menu/Menu.js +11 -11
- package/cjs/core/Menu/MenuDivider.js +2 -2
- package/cjs/core/Menu/MenuItem.d.ts +2 -2
- package/cjs/core/Menu/MenuItem.js +5 -7
- package/cjs/core/Modal/Modal.d.ts +1 -1
- package/cjs/core/Modal/Modal.js +5 -7
- package/cjs/core/Modal/ModalButtonBar.js +2 -2
- package/cjs/core/ProgressIndicators/ProgressLinear/ProgressLinear.d.ts +1 -1
- package/cjs/core/ProgressIndicators/ProgressLinear/ProgressLinear.js +2 -2
- package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.d.ts +1 -1
- package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +2 -2
- package/cjs/core/Radio/Radio.js +3 -4
- package/cjs/core/RadioTiles/RadioTile.js +3 -4
- package/cjs/core/RadioTiles/RadioTileGroup.js +2 -2
- package/cjs/core/Select/Select.d.ts +1 -2
- package/cjs/core/Select/Select.js +4 -4
- package/cjs/core/SideNavigation/SideNavigation.d.ts +1 -1
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/SideNavigation/SidenavButton.js +2 -2
- package/cjs/core/Slider/Slider.d.ts +1 -1
- package/cjs/core/Slider/Slider.js +7 -9
- package/cjs/core/Table/Table.d.ts +1 -1
- package/cjs/core/Table/Table.js +4 -4
- package/cjs/core/Table/TableRowMemoized.js +3 -4
- package/cjs/core/Table/filters/BaseFilter.d.ts +1 -1
- package/cjs/core/Table/filters/BaseFilter.js +2 -2
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -2
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -2
- package/cjs/core/Table/filters/FilterButtonBar.d.ts +1 -1
- package/cjs/core/Table/filters/FilterButtonBar.js +2 -2
- package/cjs/core/Table/filters/FilterToggle.d.ts +1 -1
- package/cjs/core/Table/filters/FilterToggle.js +4 -6
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -2
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +2 -2
- package/cjs/core/Tabs/Tab.js +2 -2
- package/cjs/core/Tabs/Tabs.js +6 -9
- package/cjs/core/Tag/Tag.d.ts +1 -1
- package/cjs/core/Tag/Tag.js +2 -2
- package/cjs/core/Tag/TagContainer.d.ts +1 -1
- package/cjs/core/Tag/TagContainer.js +2 -2
- package/cjs/core/Textarea/Textarea.js +3 -4
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.js +2 -2
- package/cjs/core/Tile/Tile.d.ts +2 -2
- package/cjs/core/Tile/Tile.js +4 -4
- package/cjs/core/TimePicker/TimePicker.d.ts +1 -1
- package/cjs/core/TimePicker/TimePicker.js +2 -2
- package/cjs/core/Toast/Toast.d.ts +1 -1
- package/cjs/core/Toast/Toast.js +5 -6
- package/cjs/core/Toast/Toaster.js +2 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +1 -1
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +3 -4
- package/cjs/core/Tooltip/Tooltip.d.ts +1 -2
- package/cjs/core/Tooltip/Tooltip.js +3 -4
- package/cjs/core/Typography/Blockquote/Blockquote.js +2 -2
- package/cjs/core/Typography/Body/Body.js +2 -2
- package/cjs/core/Typography/Code/Code.d.ts +1 -1
- package/cjs/core/Typography/Code/Code.js +2 -2
- package/cjs/core/Typography/Headline/Headline.js +2 -2
- package/cjs/core/Typography/Kbd/Kbd.d.ts +1 -1
- package/cjs/core/Typography/Kbd/Kbd.js +2 -2
- package/cjs/core/Typography/Leading/Leading.js +2 -2
- package/cjs/core/Typography/Small/Small.js +2 -2
- package/cjs/core/Typography/Subheading/Subheading.js +2 -2
- package/cjs/core/Typography/Text/Text.d.ts +1 -1
- package/cjs/core/Typography/Text/Text.js +2 -2
- package/cjs/core/Typography/Title/Title.js +2 -2
- package/cjs/core/UserIcon/UserIcon.d.ts +1 -1
- package/cjs/core/UserIcon/UserIcon.js +2 -2
- package/cjs/core/UserIconGroup/UserIconGroup.d.ts +1 -1
- package/cjs/core/UserIconGroup/UserIconGroup.js +2 -2
- package/cjs/core/Wizard/Step.d.ts +1 -1
- package/cjs/core/Wizard/Wizard.js +2 -2
- package/cjs/core/index.d.ts +4 -3
- package/cjs/core/index.js +7 -6
- package/cjs/core/utils/{FocusTrap.d.ts → components/FocusTrap.d.ts} +0 -0
- package/cjs/core/utils/{FocusTrap.js → components/FocusTrap.js} +3 -3
- package/cjs/core/utils/{InputContainer.d.ts → components/InputContainer.d.ts} +0 -0
- package/cjs/core/utils/{InputContainer.js → components/InputContainer.js} +25 -3
- package/cjs/core/utils/{Popover.d.ts → components/Popover.d.ts} +1 -1
- package/cjs/core/utils/{Popover.js → components/Popover.js} +1 -1
- package/cjs/core/utils/components/icons.d.ts +8 -0
- package/cjs/core/utils/components/icons.js +32 -0
- package/cjs/core/utils/components/index.d.ts +4 -0
- package/cjs/core/utils/components/index.js +20 -0
- package/cjs/core/utils/functions/colors.d.ts +20 -0
- package/cjs/core/utils/functions/colors.js +52 -0
- package/cjs/core/utils/functions/dom.d.ts +18 -0
- package/cjs/core/utils/functions/dom.js +42 -0
- package/cjs/core/utils/functions/focusable.d.ts +8 -0
- package/cjs/core/utils/functions/focusable.js +34 -0
- package/cjs/core/utils/functions/index.d.ts +4 -0
- package/cjs/core/utils/functions/index.js +20 -0
- package/cjs/core/utils/functions/numbers.d.ts +8 -0
- package/cjs/core/utils/functions/numbers.js +27 -0
- package/cjs/core/utils/hooks/index.d.ts +6 -0
- package/cjs/core/utils/hooks/index.js +22 -0
- package/cjs/core/utils/hooks/useIntersection.js +2 -2
- package/cjs/core/utils/hooks/useResizeObserver.js +2 -2
- package/cjs/core/utils/hooks/useTheme.js +3 -3
- package/cjs/core/utils/index.d.ts +4 -0
- package/cjs/core/utils/index.js +20 -0
- package/esm/core/Alert/Alert.d.ts +1 -1
- package/esm/core/Alert/Alert.js +1 -2
- package/esm/core/Badge/Badge.d.ts +1 -2
- package/esm/core/Badge/Badge.js +1 -2
- package/esm/core/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.js +1 -3
- package/esm/core/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -2
- package/esm/core/Buttons/Button/Button.js +1 -1
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -2
- package/esm/core/Buttons/IconButton/IconButton.js +1 -1
- package/esm/core/Buttons/IdeasButton/IdeasButton.js +1 -1
- package/esm/core/Buttons/SplitButton/SplitButton.js +1 -1
- package/esm/core/Checkbox/Checkbox.js +1 -2
- package/esm/core/ComboBox/ComboBox.d.ts +51 -0
- package/esm/core/ComboBox/ComboBox.js +261 -0
- package/esm/core/ComboBox/index.d.ts +4 -0
- package/esm/core/ComboBox/index.js +6 -0
- package/esm/core/DatePicker/DatePicker.js +1 -1
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -2
- package/esm/core/DropdownMenu/DropdownMenu.js +1 -3
- package/esm/core/ErrorPage/ErrorPage.js +1 -1
- package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +1 -1
- package/esm/core/ExpandableBlock/ExpandableBlock.js +1 -2
- package/esm/core/Fieldset/Fieldset.js +1 -1
- package/esm/core/FileUpload/FileUpload.d.ts +2 -2
- package/esm/core/FileUpload/FileUpload.js +1 -2
- package/esm/core/FileUpload/FileUploadTemplate.js +1 -1
- package/esm/core/Footer/Footer.d.ts +1 -1
- package/esm/core/Footer/Footer.js +1 -1
- package/esm/core/Header/Header.d.ts +1 -1
- package/esm/core/Header/Header.js +1 -1
- package/esm/core/Header/HeaderBreadcrumbs.js +1 -1
- package/esm/core/Header/HeaderButton.js +1 -1
- package/esm/core/Header/HeaderLogo.d.ts +1 -1
- package/esm/core/Header/HeaderLogo.js +1 -1
- package/esm/core/Input/Input.js +1 -2
- package/esm/core/InputGroup/InputGroup.d.ts +1 -1
- package/esm/core/InputGroup/InputGroup.js +1 -3
- package/esm/core/LabeledInput/LabeledInput.js +1 -3
- package/esm/core/LabeledSelect/LabeledSelect.js +1 -3
- package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -3
- package/esm/core/Menu/Menu.d.ts +11 -1
- package/esm/core/Menu/Menu.js +7 -7
- package/esm/core/Menu/MenuDivider.js +1 -1
- package/esm/core/Menu/MenuItem.d.ts +2 -2
- package/esm/core/Menu/MenuItem.js +2 -4
- package/esm/core/Modal/Modal.d.ts +1 -1
- package/esm/core/Modal/Modal.js +1 -3
- package/esm/core/Modal/ModalButtonBar.js +1 -1
- package/esm/core/ProgressIndicators/ProgressLinear/ProgressLinear.d.ts +1 -1
- package/esm/core/ProgressIndicators/ProgressLinear/ProgressLinear.js +1 -1
- package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.d.ts +1 -1
- package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +1 -1
- package/esm/core/Radio/Radio.js +1 -2
- package/esm/core/RadioTiles/RadioTile.js +1 -2
- package/esm/core/RadioTiles/RadioTileGroup.js +1 -1
- package/esm/core/Select/Select.d.ts +1 -2
- package/esm/core/Select/Select.js +2 -2
- package/esm/core/SideNavigation/SideNavigation.d.ts +1 -1
- package/esm/core/SideNavigation/SideNavigation.js +1 -1
- package/esm/core/SideNavigation/SidenavButton.js +1 -1
- package/esm/core/Slider/Slider.d.ts +1 -1
- package/esm/core/Slider/Slider.js +1 -3
- package/esm/core/Table/Table.d.ts +1 -1
- package/esm/core/Table/Table.js +1 -1
- package/esm/core/Table/TableRowMemoized.js +1 -2
- package/esm/core/Table/filters/BaseFilter.d.ts +1 -1
- package/esm/core/Table/filters/BaseFilter.js +1 -1
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +1 -1
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +1 -1
- package/esm/core/Table/filters/FilterButtonBar.d.ts +1 -1
- package/esm/core/Table/filters/FilterButtonBar.js +1 -1
- package/esm/core/Table/filters/FilterToggle.d.ts +1 -1
- package/esm/core/Table/filters/FilterToggle.js +1 -3
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +1 -1
- package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -1
- package/esm/core/Tabs/Tab.js +1 -1
- package/esm/core/Tabs/Tabs.js +1 -4
- package/esm/core/Tag/Tag.d.ts +1 -1
- package/esm/core/Tag/Tag.js +1 -1
- package/esm/core/Tag/TagContainer.d.ts +1 -1
- package/esm/core/Tag/TagContainer.js +1 -1
- package/esm/core/Textarea/Textarea.js +1 -2
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.js +1 -1
- package/esm/core/Tile/Tile.d.ts +2 -2
- package/esm/core/Tile/Tile.js +3 -3
- package/esm/core/TimePicker/TimePicker.d.ts +1 -1
- package/esm/core/TimePicker/TimePicker.js +1 -1
- package/esm/core/Toast/Toast.d.ts +1 -1
- package/esm/core/Toast/Toast.js +1 -2
- package/esm/core/Toast/Toaster.js +1 -1
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +1 -1
- package/esm/core/ToggleSwitch/ToggleSwitch.js +1 -2
- package/esm/core/Tooltip/Tooltip.d.ts +1 -2
- package/esm/core/Tooltip/Tooltip.js +1 -2
- package/esm/core/Typography/Blockquote/Blockquote.js +1 -1
- package/esm/core/Typography/Body/Body.js +1 -1
- package/esm/core/Typography/Code/Code.d.ts +1 -1
- package/esm/core/Typography/Code/Code.js +1 -1
- package/esm/core/Typography/Headline/Headline.js +1 -1
- package/esm/core/Typography/Kbd/Kbd.d.ts +1 -1
- package/esm/core/Typography/Kbd/Kbd.js +1 -1
- package/esm/core/Typography/Leading/Leading.js +1 -1
- package/esm/core/Typography/Small/Small.js +1 -1
- package/esm/core/Typography/Subheading/Subheading.js +1 -1
- package/esm/core/Typography/Text/Text.d.ts +1 -1
- package/esm/core/Typography/Text/Text.js +1 -1
- package/esm/core/Typography/Title/Title.js +1 -1
- package/esm/core/UserIcon/UserIcon.d.ts +1 -1
- package/esm/core/UserIcon/UserIcon.js +1 -1
- package/esm/core/UserIconGroup/UserIconGroup.d.ts +1 -1
- package/esm/core/UserIconGroup/UserIconGroup.js +1 -1
- package/esm/core/Wizard/Step.d.ts +1 -1
- package/esm/core/Wizard/Wizard.js +1 -1
- package/esm/core/index.d.ts +4 -3
- package/esm/core/index.js +2 -2
- package/esm/core/utils/{FocusTrap.d.ts → components/FocusTrap.d.ts} +0 -0
- package/esm/core/utils/{FocusTrap.js → components/FocusTrap.js} +2 -2
- package/esm/core/utils/{InputContainer.d.ts → components/InputContainer.d.ts} +0 -0
- package/esm/core/utils/{InputContainer.js → components/InputContainer.js} +25 -3
- package/esm/core/utils/{Popover.d.ts → components/Popover.d.ts} +1 -1
- package/esm/core/utils/{Popover.js → components/Popover.js} +1 -1
- package/esm/core/utils/components/icons.d.ts +8 -0
- package/esm/core/utils/components/icons.js +26 -0
- package/esm/core/utils/components/index.d.ts +4 -0
- package/esm/core/utils/components/index.js +8 -0
- package/esm/core/utils/functions/colors.d.ts +20 -0
- package/esm/core/utils/functions/colors.js +47 -0
- package/esm/core/utils/functions/dom.d.ts +18 -0
- package/esm/core/utils/functions/dom.js +36 -0
- package/esm/core/utils/functions/focusable.d.ts +8 -0
- package/esm/core/utils/functions/focusable.js +29 -0
- package/esm/core/utils/functions/index.d.ts +4 -0
- package/esm/core/utils/functions/index.js +8 -0
- package/esm/core/utils/functions/numbers.d.ts +8 -0
- package/esm/core/utils/functions/numbers.js +22 -0
- package/esm/core/utils/hooks/index.d.ts +6 -0
- package/esm/core/utils/hooks/index.js +10 -0
- package/esm/core/utils/hooks/useIntersection.js +1 -1
- package/esm/core/utils/hooks/useResizeObserver.js +1 -1
- package/esm/core/utils/hooks/useTheme.js +1 -1
- package/esm/core/utils/index.d.ts +4 -0
- package/esm/core/utils/index.js +8 -0
- package/package.json +5 -3
- package/cjs/core/utils/common.d.ts +0 -58
- package/cjs/core/utils/common.js +0 -146
- package/esm/core/utils/common.d.ts +0 -58
- package/esm/core/utils/common.js +0 -132
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* Get the container as a child of body, or create one if it doesn't exist.
|
|
7
|
+
* Mostly used for dynamic components like Modal or Toast.
|
|
8
|
+
*
|
|
9
|
+
* @param containerId id of the container to find or create
|
|
10
|
+
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
11
|
+
*/
|
|
12
|
+
export var getContainer = function (containerId, ownerDocument) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (ownerDocument === void 0) { ownerDocument = getDocument(); }
|
|
15
|
+
var container = (_a = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.getElementById(containerId)) !== null && _a !== void 0 ? _a : undefined;
|
|
16
|
+
if (container == null && !!ownerDocument) {
|
|
17
|
+
container = ownerDocument.createElement('div');
|
|
18
|
+
container.setAttribute('id', containerId);
|
|
19
|
+
ownerDocument.body.appendChild(container);
|
|
20
|
+
}
|
|
21
|
+
return container;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Get document if it is defined.
|
|
25
|
+
* Used to support SSR/SSG applications.
|
|
26
|
+
*/
|
|
27
|
+
export var getDocument = function () {
|
|
28
|
+
return typeof document === 'undefined' ? undefined : document;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Get window if it is defined.
|
|
32
|
+
* Used to support SSR/SSG applications.
|
|
33
|
+
*/
|
|
34
|
+
export var getWindow = function () {
|
|
35
|
+
return typeof window === 'undefined' ? undefined : window;
|
|
36
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return array of tabbable elements in the container.
|
|
3
|
+
*/
|
|
4
|
+
export declare const getTabbableElements: (container: HTMLElement | undefined | null) => Element[];
|
|
5
|
+
/**
|
|
6
|
+
* Return array of focusable elements in the container.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getFocusableElements: (container: HTMLElement | undefined | null) => Element[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
var tabbableElementsSelector = 'a[href], button, input, textarea, select, details, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';
|
|
6
|
+
/**
|
|
7
|
+
* Return array of tabbable elements in the container.
|
|
8
|
+
*/
|
|
9
|
+
export var getTabbableElements = function (container) {
|
|
10
|
+
if (!container) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
var elements = container.querySelectorAll(tabbableElementsSelector);
|
|
14
|
+
return Array.from(elements).filter(function (el) {
|
|
15
|
+
return !el.hasAttribute('disabled') && !el.classList.contains('iui-disabled');
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Return array of focusable elements in the container.
|
|
20
|
+
*/
|
|
21
|
+
export var getFocusableElements = function (container) {
|
|
22
|
+
if (!container) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
var elements = container.querySelectorAll(tabbableElementsSelector + ", [tabindex=\"-1\"]");
|
|
26
|
+
return Array.from(elements).filter(function (el) {
|
|
27
|
+
return !el.hasAttribute('disabled') && !el.classList.contains('iui-disabled');
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export * from './dom';
|
|
6
|
+
export * from './colors';
|
|
7
|
+
export * from './numbers';
|
|
8
|
+
export * from './focusable';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return input value bounded by specified range.
|
|
3
|
+
*/
|
|
4
|
+
export declare const getBoundedValue: (val: number, min: number, max: number) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a random value of a given length containing `A-Za-z0-9_-` symbols.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getRandomValue: (length?: number) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* Return input value bounded by specified range.
|
|
7
|
+
*/
|
|
8
|
+
export var getBoundedValue = function (val, min, max) {
|
|
9
|
+
return Math.min(max, Math.max(min, val));
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Returns a random value of a given length containing `A-Za-z0-9_-` symbols.
|
|
13
|
+
*/
|
|
14
|
+
export var getRandomValue = function (length) {
|
|
15
|
+
if (length === void 0) { length = 21; }
|
|
16
|
+
var alphabet = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
17
|
+
var id = '';
|
|
18
|
+
for (var i = 0; i < length; i++) {
|
|
19
|
+
id += alphabet[(Math.random() * 64) | 0];
|
|
20
|
+
}
|
|
21
|
+
return id;
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export * from './useEventListener';
|
|
6
|
+
export * from './useMergedRefs';
|
|
7
|
+
export * from './useOverflow';
|
|
8
|
+
export * from './useResizeObserver';
|
|
9
|
+
export * from './useTheme';
|
|
10
|
+
export * from './useIntersection';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { getWindow } from '../
|
|
6
|
+
import { getWindow } from '../functions/dom';
|
|
7
7
|
/**
|
|
8
8
|
* Hook that uses `IntersectionObserver` to trigger `onIntersect` callback when element is in viewport.
|
|
9
9
|
* Callback is called only once.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { getWindow } from '../
|
|
6
|
+
import { getWindow } from '../functions/dom';
|
|
7
7
|
/**
|
|
8
8
|
* Hook that uses `ResizeObserver` to access an element's size every time it updates.
|
|
9
9
|
* @private
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import '@itwin/itwinui-css/css/global.css';
|
|
7
|
-
import { getDocument, getWindow } from '../
|
|
7
|
+
import { getDocument, getWindow } from '../functions/dom';
|
|
8
8
|
/**
|
|
9
9
|
* Hook that applies styling and theme to all components.
|
|
10
10
|
* Defaults to light theme if none provided or set elsewhere.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export * from './functions';
|
|
6
|
+
export * from './hooks';
|
|
7
|
+
export * from './components';
|
|
8
|
+
export * from './props';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"build-storybook": "build-storybook"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@itwin/itwinui-css": "^0.
|
|
43
|
+
"@itwin/itwinui-css": "^0.33.0",
|
|
44
44
|
"@itwin/itwinui-icons-react": "^1.1.1",
|
|
45
45
|
"@itwin/itwinui-illustrations-react": "^1.0.1",
|
|
46
46
|
"@tippyjs/react": "^4.2.5",
|
|
@@ -114,7 +114,9 @@
|
|
|
114
114
|
"immer": "^9.0.6",
|
|
115
115
|
"set-value": "^4.1.0",
|
|
116
116
|
"prismjs": "^1.25.0",
|
|
117
|
-
"nth-check": "^2.0.1"
|
|
117
|
+
"nth-check": "^2.0.1",
|
|
118
|
+
"ansi-regex": "^5.0.1",
|
|
119
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1"
|
|
118
120
|
},
|
|
119
121
|
"husky": {
|
|
120
122
|
"hooks": {
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CommonProps } from './props';
|
|
3
|
-
export declare const StatusIconMap: {
|
|
4
|
-
negative: (args?: CommonProps | undefined) => JSX.Element;
|
|
5
|
-
positive: (args?: CommonProps | undefined) => JSX.Element;
|
|
6
|
-
warning: (args?: CommonProps | undefined) => JSX.Element;
|
|
7
|
-
informational: (args?: CommonProps | undefined) => JSX.Element;
|
|
8
|
-
};
|
|
9
|
-
export declare const SoftBackgrounds: {
|
|
10
|
-
readonly skyblue: "hsl(197, 71%, 83%)";
|
|
11
|
-
readonly celery: "hsl(72, 51%, 66%)";
|
|
12
|
-
readonly froly: "hsl(2, 90%, 83%)";
|
|
13
|
-
readonly steelblue: "hsl(207, 44%, 73%)";
|
|
14
|
-
readonly sunglow: "hsl(42, 100%, 70%)";
|
|
15
|
-
readonly seabuckthorn: "hsl(29, 92%, 71%)";
|
|
16
|
-
readonly montecarlo: "hsl(176, 43%, 72%)";
|
|
17
|
-
readonly poloblue: "hsl(211, 44%, 77%)";
|
|
18
|
-
readonly bouquet: "hsl(305, 19%, 75%)";
|
|
19
|
-
readonly ash: "hsl(42, 15%, 85%)";
|
|
20
|
-
readonly oak: "hsl(27, 32%, 72%)";
|
|
21
|
-
};
|
|
22
|
-
/** Returns true if a string value is one of the SoftBackgrounds keys */
|
|
23
|
-
export declare const isSoftBackground: (value: string) => value is "skyblue" | "celery" | "froly" | "steelblue" | "sunglow" | "seabuckthorn" | "montecarlo" | "poloblue" | "bouquet" | "ash" | "oak";
|
|
24
|
-
/**
|
|
25
|
-
* Generate color from user name or email.
|
|
26
|
-
* Recommended to use for `backgroundColor` in `UserIcon` component.
|
|
27
|
-
*/
|
|
28
|
-
export declare const getUserColor: (emailOrName: string) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Get the container as a child of body, or create one if it doesn't exist.
|
|
31
|
-
* Mostly used for dynamic components like Modal or Toast.
|
|
32
|
-
*
|
|
33
|
-
* @param containerId id of the container to find or create
|
|
34
|
-
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
35
|
-
*/
|
|
36
|
-
export declare const getContainer: (containerId: string, ownerDocument?: Document | undefined) => HTMLElement | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Get document if it is defined.
|
|
39
|
-
* Used to support SSR/SSG applications.
|
|
40
|
-
*/
|
|
41
|
-
export declare const getDocument: () => Document | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Get window if it is defined.
|
|
44
|
-
* Used to support SSR/SSG applications.
|
|
45
|
-
*/
|
|
46
|
-
export declare const getWindow: () => (Window & typeof globalThis) | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Return input value bounded by specified range.
|
|
49
|
-
*/
|
|
50
|
-
export declare const getBoundedValue: (val: number, min: number, max: number) => number;
|
|
51
|
-
/**
|
|
52
|
-
* Return array of tabbable elements in the container.
|
|
53
|
-
*/
|
|
54
|
-
export declare const getTabbableElements: (container: HTMLElement | undefined | null) => Element[];
|
|
55
|
-
/**
|
|
56
|
-
* Return array of focusable elements in the container.
|
|
57
|
-
*/
|
|
58
|
-
export declare const getFocusableElements: (container: HTMLElement | undefined | null) => Element[];
|
package/cjs/core/utils/common.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getFocusableElements = exports.getTabbableElements = exports.getBoundedValue = exports.getWindow = exports.getDocument = exports.getContainer = exports.getUserColor = exports.isSoftBackground = exports.SoftBackgrounds = exports.StatusIconMap = void 0;
|
|
18
|
-
/*---------------------------------------------------------------------------------------------
|
|
19
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
20
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
21
|
-
*--------------------------------------------------------------------------------------------*/
|
|
22
|
-
var InfoCircular_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/InfoCircular"));
|
|
23
|
-
var StatusError_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/StatusError"));
|
|
24
|
-
var StatusSuccess_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/StatusSuccess"));
|
|
25
|
-
var StatusWarning_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/StatusWarning"));
|
|
26
|
-
var react_1 = __importDefault(require("react"));
|
|
27
|
-
exports.StatusIconMap = {
|
|
28
|
-
negative: function (args) { return react_1.default.createElement(StatusError_1.default, __assign({ "aria-hidden": true }, args)); },
|
|
29
|
-
positive: function (args) { return react_1.default.createElement(StatusSuccess_1.default, __assign({ "aria-hidden": true }, args)); },
|
|
30
|
-
warning: function (args) { return react_1.default.createElement(StatusWarning_1.default, __assign({ "aria-hidden": true }, args)); },
|
|
31
|
-
informational: function (args) { return (react_1.default.createElement(InfoCircular_1.default, __assign({ "aria-hidden": true }, args))); },
|
|
32
|
-
};
|
|
33
|
-
exports.SoftBackgrounds = {
|
|
34
|
-
skyblue: 'hsl(197, 71%, 83%)',
|
|
35
|
-
celery: 'hsl(72, 51%, 66%)',
|
|
36
|
-
froly: 'hsl(2, 90%, 83%)',
|
|
37
|
-
steelblue: 'hsl(207, 44%, 73%)',
|
|
38
|
-
sunglow: 'hsl(42, 100%, 70%)',
|
|
39
|
-
seabuckthorn: 'hsl(29, 92%, 71%)',
|
|
40
|
-
montecarlo: 'hsl(176, 43%, 72%)',
|
|
41
|
-
poloblue: 'hsl(211, 44%, 77%)',
|
|
42
|
-
bouquet: 'hsl(305, 19%, 75%)',
|
|
43
|
-
ash: 'hsl(42, 15%, 85%)',
|
|
44
|
-
oak: 'hsl(27, 32%, 72%)',
|
|
45
|
-
};
|
|
46
|
-
/** Returns true if a string value is one of the SoftBackgrounds keys */
|
|
47
|
-
var isSoftBackground = function (value) {
|
|
48
|
-
return Object.keys(exports.SoftBackgrounds).includes(value);
|
|
49
|
-
};
|
|
50
|
-
exports.isSoftBackground = isSoftBackground;
|
|
51
|
-
var USER_COLORS = [
|
|
52
|
-
'#6AB9EC',
|
|
53
|
-
'#B1C854',
|
|
54
|
-
'#F7706C',
|
|
55
|
-
'#4585A5',
|
|
56
|
-
'#FFC335',
|
|
57
|
-
'#F7963E',
|
|
58
|
-
'#73C7C1',
|
|
59
|
-
'#85A9CF',
|
|
60
|
-
'#A3779F',
|
|
61
|
-
'#C8C2B4',
|
|
62
|
-
'#A47854',
|
|
63
|
-
];
|
|
64
|
-
/**
|
|
65
|
-
* Generate color from user name or email.
|
|
66
|
-
* Recommended to use for `backgroundColor` in `UserIcon` component.
|
|
67
|
-
*/
|
|
68
|
-
var getUserColor = function (emailOrName) {
|
|
69
|
-
var normalizedString = emailOrName.trim().toLowerCase();
|
|
70
|
-
var hash = 0;
|
|
71
|
-
for (var i = 0; i < normalizedString.length; i++) {
|
|
72
|
-
var charCode = normalizedString.charCodeAt(i);
|
|
73
|
-
hash = (hash + charCode) % USER_COLORS.length;
|
|
74
|
-
}
|
|
75
|
-
return USER_COLORS[hash];
|
|
76
|
-
};
|
|
77
|
-
exports.getUserColor = getUserColor;
|
|
78
|
-
/**
|
|
79
|
-
* Get the container as a child of body, or create one if it doesn't exist.
|
|
80
|
-
* Mostly used for dynamic components like Modal or Toast.
|
|
81
|
-
*
|
|
82
|
-
* @param containerId id of the container to find or create
|
|
83
|
-
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
84
|
-
*/
|
|
85
|
-
var getContainer = function (containerId, ownerDocument) {
|
|
86
|
-
var _a;
|
|
87
|
-
if (ownerDocument === void 0) { ownerDocument = (0, exports.getDocument)(); }
|
|
88
|
-
var container = (_a = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.getElementById(containerId)) !== null && _a !== void 0 ? _a : undefined;
|
|
89
|
-
if (container == null && !!ownerDocument) {
|
|
90
|
-
container = ownerDocument.createElement('div');
|
|
91
|
-
container.setAttribute('id', containerId);
|
|
92
|
-
ownerDocument.body.appendChild(container);
|
|
93
|
-
}
|
|
94
|
-
return container;
|
|
95
|
-
};
|
|
96
|
-
exports.getContainer = getContainer;
|
|
97
|
-
/**
|
|
98
|
-
* Get document if it is defined.
|
|
99
|
-
* Used to support SSR/SSG applications.
|
|
100
|
-
*/
|
|
101
|
-
var getDocument = function () {
|
|
102
|
-
return typeof document === 'undefined' ? undefined : document;
|
|
103
|
-
};
|
|
104
|
-
exports.getDocument = getDocument;
|
|
105
|
-
/**
|
|
106
|
-
* Get window if it is defined.
|
|
107
|
-
* Used to support SSR/SSG applications.
|
|
108
|
-
*/
|
|
109
|
-
var getWindow = function () {
|
|
110
|
-
return typeof window === 'undefined' ? undefined : window;
|
|
111
|
-
};
|
|
112
|
-
exports.getWindow = getWindow;
|
|
113
|
-
/**
|
|
114
|
-
* Return input value bounded by specified range.
|
|
115
|
-
*/
|
|
116
|
-
var getBoundedValue = function (val, min, max) {
|
|
117
|
-
return Math.min(max, Math.max(min, val));
|
|
118
|
-
};
|
|
119
|
-
exports.getBoundedValue = getBoundedValue;
|
|
120
|
-
var tabbableElementsSelector = 'a[href], button, input, textarea, select, details, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';
|
|
121
|
-
/**
|
|
122
|
-
* Return array of tabbable elements in the container.
|
|
123
|
-
*/
|
|
124
|
-
var getTabbableElements = function (container) {
|
|
125
|
-
if (!container) {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
var elements = container.querySelectorAll(tabbableElementsSelector);
|
|
129
|
-
return Array.from(elements).filter(function (el) {
|
|
130
|
-
return !el.hasAttribute('disabled') && !el.classList.contains('iui-disabled');
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
exports.getTabbableElements = getTabbableElements;
|
|
134
|
-
/**
|
|
135
|
-
* Return array of focusable elements in the container.
|
|
136
|
-
*/
|
|
137
|
-
var getFocusableElements = function (container) {
|
|
138
|
-
if (!container) {
|
|
139
|
-
return [];
|
|
140
|
-
}
|
|
141
|
-
var elements = container.querySelectorAll(tabbableElementsSelector + ", [tabindex=\"-1\"]");
|
|
142
|
-
return Array.from(elements).filter(function (el) {
|
|
143
|
-
return !el.hasAttribute('disabled') && !el.classList.contains('iui-disabled');
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
exports.getFocusableElements = getFocusableElements;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CommonProps } from './props';
|
|
3
|
-
export declare const StatusIconMap: {
|
|
4
|
-
negative: (args?: CommonProps | undefined) => JSX.Element;
|
|
5
|
-
positive: (args?: CommonProps | undefined) => JSX.Element;
|
|
6
|
-
warning: (args?: CommonProps | undefined) => JSX.Element;
|
|
7
|
-
informational: (args?: CommonProps | undefined) => JSX.Element;
|
|
8
|
-
};
|
|
9
|
-
export declare const SoftBackgrounds: {
|
|
10
|
-
readonly skyblue: "hsl(197, 71%, 83%)";
|
|
11
|
-
readonly celery: "hsl(72, 51%, 66%)";
|
|
12
|
-
readonly froly: "hsl(2, 90%, 83%)";
|
|
13
|
-
readonly steelblue: "hsl(207, 44%, 73%)";
|
|
14
|
-
readonly sunglow: "hsl(42, 100%, 70%)";
|
|
15
|
-
readonly seabuckthorn: "hsl(29, 92%, 71%)";
|
|
16
|
-
readonly montecarlo: "hsl(176, 43%, 72%)";
|
|
17
|
-
readonly poloblue: "hsl(211, 44%, 77%)";
|
|
18
|
-
readonly bouquet: "hsl(305, 19%, 75%)";
|
|
19
|
-
readonly ash: "hsl(42, 15%, 85%)";
|
|
20
|
-
readonly oak: "hsl(27, 32%, 72%)";
|
|
21
|
-
};
|
|
22
|
-
/** Returns true if a string value is one of the SoftBackgrounds keys */
|
|
23
|
-
export declare const isSoftBackground: (value: string) => value is "skyblue" | "celery" | "froly" | "steelblue" | "sunglow" | "seabuckthorn" | "montecarlo" | "poloblue" | "bouquet" | "ash" | "oak";
|
|
24
|
-
/**
|
|
25
|
-
* Generate color from user name or email.
|
|
26
|
-
* Recommended to use for `backgroundColor` in `UserIcon` component.
|
|
27
|
-
*/
|
|
28
|
-
export declare const getUserColor: (emailOrName: string) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Get the container as a child of body, or create one if it doesn't exist.
|
|
31
|
-
* Mostly used for dynamic components like Modal or Toast.
|
|
32
|
-
*
|
|
33
|
-
* @param containerId id of the container to find or create
|
|
34
|
-
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
35
|
-
*/
|
|
36
|
-
export declare const getContainer: (containerId: string, ownerDocument?: Document | undefined) => HTMLElement | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Get document if it is defined.
|
|
39
|
-
* Used to support SSR/SSG applications.
|
|
40
|
-
*/
|
|
41
|
-
export declare const getDocument: () => Document | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Get window if it is defined.
|
|
44
|
-
* Used to support SSR/SSG applications.
|
|
45
|
-
*/
|
|
46
|
-
export declare const getWindow: () => (Window & typeof globalThis) | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Return input value bounded by specified range.
|
|
49
|
-
*/
|
|
50
|
-
export declare const getBoundedValue: (val: number, min: number, max: number) => number;
|
|
51
|
-
/**
|
|
52
|
-
* Return array of tabbable elements in the container.
|
|
53
|
-
*/
|
|
54
|
-
export declare const getTabbableElements: (container: HTMLElement | undefined | null) => Element[];
|
|
55
|
-
/**
|
|
56
|
-
* Return array of focusable elements in the container.
|
|
57
|
-
*/
|
|
58
|
-
export declare const getFocusableElements: (container: HTMLElement | undefined | null) => Element[];
|
package/esm/core/utils/common.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
/*---------------------------------------------------------------------------------------------
|
|
13
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
14
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
15
|
-
*--------------------------------------------------------------------------------------------*/
|
|
16
|
-
import SvgInfoCircular from '@itwin/itwinui-icons-react/cjs/icons/InfoCircular';
|
|
17
|
-
import SvgStatusError from '@itwin/itwinui-icons-react/cjs/icons/StatusError';
|
|
18
|
-
import SvgStatusSuccess from '@itwin/itwinui-icons-react/cjs/icons/StatusSuccess';
|
|
19
|
-
import SvgStatusWarning from '@itwin/itwinui-icons-react/cjs/icons/StatusWarning';
|
|
20
|
-
import React from 'react';
|
|
21
|
-
export var StatusIconMap = {
|
|
22
|
-
negative: function (args) { return React.createElement(SvgStatusError, __assign({ "aria-hidden": true }, args)); },
|
|
23
|
-
positive: function (args) { return React.createElement(SvgStatusSuccess, __assign({ "aria-hidden": true }, args)); },
|
|
24
|
-
warning: function (args) { return React.createElement(SvgStatusWarning, __assign({ "aria-hidden": true }, args)); },
|
|
25
|
-
informational: function (args) { return (React.createElement(SvgInfoCircular, __assign({ "aria-hidden": true }, args))); },
|
|
26
|
-
};
|
|
27
|
-
export var SoftBackgrounds = {
|
|
28
|
-
skyblue: 'hsl(197, 71%, 83%)',
|
|
29
|
-
celery: 'hsl(72, 51%, 66%)',
|
|
30
|
-
froly: 'hsl(2, 90%, 83%)',
|
|
31
|
-
steelblue: 'hsl(207, 44%, 73%)',
|
|
32
|
-
sunglow: 'hsl(42, 100%, 70%)',
|
|
33
|
-
seabuckthorn: 'hsl(29, 92%, 71%)',
|
|
34
|
-
montecarlo: 'hsl(176, 43%, 72%)',
|
|
35
|
-
poloblue: 'hsl(211, 44%, 77%)',
|
|
36
|
-
bouquet: 'hsl(305, 19%, 75%)',
|
|
37
|
-
ash: 'hsl(42, 15%, 85%)',
|
|
38
|
-
oak: 'hsl(27, 32%, 72%)',
|
|
39
|
-
};
|
|
40
|
-
/** Returns true if a string value is one of the SoftBackgrounds keys */
|
|
41
|
-
export var isSoftBackground = function (value) {
|
|
42
|
-
return Object.keys(SoftBackgrounds).includes(value);
|
|
43
|
-
};
|
|
44
|
-
var USER_COLORS = [
|
|
45
|
-
'#6AB9EC',
|
|
46
|
-
'#B1C854',
|
|
47
|
-
'#F7706C',
|
|
48
|
-
'#4585A5',
|
|
49
|
-
'#FFC335',
|
|
50
|
-
'#F7963E',
|
|
51
|
-
'#73C7C1',
|
|
52
|
-
'#85A9CF',
|
|
53
|
-
'#A3779F',
|
|
54
|
-
'#C8C2B4',
|
|
55
|
-
'#A47854',
|
|
56
|
-
];
|
|
57
|
-
/**
|
|
58
|
-
* Generate color from user name or email.
|
|
59
|
-
* Recommended to use for `backgroundColor` in `UserIcon` component.
|
|
60
|
-
*/
|
|
61
|
-
export var getUserColor = function (emailOrName) {
|
|
62
|
-
var normalizedString = emailOrName.trim().toLowerCase();
|
|
63
|
-
var hash = 0;
|
|
64
|
-
for (var i = 0; i < normalizedString.length; i++) {
|
|
65
|
-
var charCode = normalizedString.charCodeAt(i);
|
|
66
|
-
hash = (hash + charCode) % USER_COLORS.length;
|
|
67
|
-
}
|
|
68
|
-
return USER_COLORS[hash];
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Get the container as a child of body, or create one if it doesn't exist.
|
|
72
|
-
* Mostly used for dynamic components like Modal or Toast.
|
|
73
|
-
*
|
|
74
|
-
* @param containerId id of the container to find or create
|
|
75
|
-
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
76
|
-
*/
|
|
77
|
-
export var getContainer = function (containerId, ownerDocument) {
|
|
78
|
-
var _a;
|
|
79
|
-
if (ownerDocument === void 0) { ownerDocument = getDocument(); }
|
|
80
|
-
var container = (_a = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.getElementById(containerId)) !== null && _a !== void 0 ? _a : undefined;
|
|
81
|
-
if (container == null && !!ownerDocument) {
|
|
82
|
-
container = ownerDocument.createElement('div');
|
|
83
|
-
container.setAttribute('id', containerId);
|
|
84
|
-
ownerDocument.body.appendChild(container);
|
|
85
|
-
}
|
|
86
|
-
return container;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Get document if it is defined.
|
|
90
|
-
* Used to support SSR/SSG applications.
|
|
91
|
-
*/
|
|
92
|
-
export var getDocument = function () {
|
|
93
|
-
return typeof document === 'undefined' ? undefined : document;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Get window if it is defined.
|
|
97
|
-
* Used to support SSR/SSG applications.
|
|
98
|
-
*/
|
|
99
|
-
export var getWindow = function () {
|
|
100
|
-
return typeof window === 'undefined' ? undefined : window;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Return input value bounded by specified range.
|
|
104
|
-
*/
|
|
105
|
-
export var getBoundedValue = function (val, min, max) {
|
|
106
|
-
return Math.min(max, Math.max(min, val));
|
|
107
|
-
};
|
|
108
|
-
var tabbableElementsSelector = 'a[href], button, input, textarea, select, details, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';
|
|
109
|
-
/**
|
|
110
|
-
* Return array of tabbable elements in the container.
|
|
111
|
-
*/
|
|
112
|
-
export var getTabbableElements = function (container) {
|
|
113
|
-
if (!container) {
|
|
114
|
-
return [];
|
|
115
|
-
}
|
|
116
|
-
var elements = container.querySelectorAll(tabbableElementsSelector);
|
|
117
|
-
return Array.from(elements).filter(function (el) {
|
|
118
|
-
return !el.hasAttribute('disabled') && !el.classList.contains('iui-disabled');
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Return array of focusable elements in the container.
|
|
123
|
-
*/
|
|
124
|
-
export var getFocusableElements = function (container) {
|
|
125
|
-
if (!container) {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
var elements = container.querySelectorAll(tabbableElementsSelector + ", [tabindex=\"-1\"]");
|
|
129
|
-
return Array.from(elements).filter(function (el) {
|
|
130
|
-
return !el.hasAttribute('disabled') && !el.classList.contains('iui-disabled');
|
|
131
|
-
});
|
|
132
|
-
};
|