@plesk/ui-library 3.43.2 → 3.44.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/cjs/components/Action/Action.js +10 -3
- package/cjs/components/Alert/Alert.js +1 -0
- package/cjs/components/AutoClosable/AutoClosable.js +47 -61
- package/cjs/components/AuxiliaryActions/AuxiliaryActions.js +13 -4
- package/cjs/components/Button/Button.js +1 -0
- package/cjs/components/Card/Card.js +10 -15
- package/cjs/components/CardList/CardList.js +6 -9
- package/cjs/components/CardList/CardListToolbar.js +12 -18
- package/cjs/components/ClosingConfirmation/useClosingConfirmation.js +7 -11
- package/cjs/components/CodeEditor/CodeEditor.js +1 -2
- package/cjs/components/Columns/Columns.js +1 -2
- package/cjs/components/ComboBox/ComboBox.js +1 -2
- package/cjs/components/ComboBoxDropdown/ComboBoxDropdown.js +4 -2
- package/cjs/components/ComboBoxDropdown/index.js +1 -2
- package/cjs/components/Cuttable/Cuttable.js +6 -8
- package/cjs/components/Dialog/Dialog.js +17 -13
- package/cjs/components/Drawer/Drawer.js +14 -7
- package/cjs/components/Drawer/DrawerProgress.js +4 -6
- package/cjs/components/Dropdown/Dropdown.js +12 -9
- package/cjs/components/Dropdown/index.js +1 -2
- package/cjs/components/ExtendedStatusMessage/ExtendedStatusMessage.js +1 -0
- package/cjs/components/Figure/index.js +1 -2
- package/cjs/components/Form/Form.js +19 -20
- package/cjs/components/Form/index.js +1 -2
- package/cjs/components/FormField/FormField.js +77 -51
- package/cjs/components/FormField/index.js +1 -2
- package/cjs/components/FormFieldCheckbox/FormFieldCheckbox.js +6 -2
- package/cjs/components/FormFieldPassword/FormFieldPassword.js +18 -21
- package/cjs/components/FormFieldPassword/PasswordMeter.js +9 -15
- package/cjs/components/FormFieldPassword/estimatePassword.js +21 -33
- package/cjs/components/FormFieldRadioButtons/FormFieldRadioButtons.js +50 -44
- package/cjs/components/FormFieldSelect/FormFieldSelect.js +1 -1
- package/cjs/components/FormFieldText/FormFieldText.js +7 -1
- package/cjs/components/Heading/Heading.js +1 -2
- package/cjs/components/Hint/Hint.js +2 -1
- package/cjs/components/Icon/Icon.js +6 -0
- package/cjs/components/Icon/index.js +1 -2
- package/cjs/components/Icon/utils.js +17 -8
- package/cjs/components/InPlaceEdit/Editor.js +5 -8
- package/cjs/components/InPlaceEdit/InPlaceEdit.js +3 -5
- package/cjs/components/InputFile/InputFile.js +7 -9
- package/cjs/components/Item/Item.js +1 -2
- package/cjs/components/ItemList/ItemList.js +1 -2
- package/cjs/components/Layer/index.js +1 -2
- package/cjs/components/Layout/Layout.js +2 -2
- package/cjs/components/Link/Link.js +2 -0
- package/cjs/components/List/List.js +38 -45
- package/cjs/components/List/ListAction.js +1 -0
- package/cjs/components/List/ListActions.js +1 -0
- package/cjs/components/List/ListEmptyView.js +7 -10
- package/cjs/components/List/ListOperation.js +3 -12
- package/cjs/components/LocaleProvider/LocaleProvider.js +20 -12
- package/cjs/components/LocaleProvider/index.js +1 -2
- package/cjs/components/Media/Media.js +1 -2
- package/cjs/components/Menu/Menu.js +10 -8
- package/cjs/components/Menu/MenuBaseItem.js +1 -2
- package/cjs/components/Menu/MenuItem.js +2 -1
- package/cjs/components/Overlay/Overlay.js +2 -0
- package/cjs/components/Pagination/Pagination.js +6 -10
- package/cjs/components/Pagination/index.js +1 -2
- package/cjs/components/Popover/Popover.js +1 -1
- package/cjs/components/Popper/index.js +1 -2
- package/cjs/components/ProgressDialog/ProgressDialog.js +5 -7
- package/cjs/components/ProgressStep/ProgressStep.js +1 -2
- package/cjs/components/ProgressStep/index.js +1 -2
- package/cjs/components/Section/Section.js +87 -225
- package/cjs/components/{Dropdown/locale/en-US.js → Section/SectionContext.js} +4 -3
- package/cjs/components/Section/index.js +1 -2
- package/cjs/components/Section/useCollapsed.js +19 -0
- package/cjs/components/Section/useVertical.js +38 -0
- package/cjs/components/SegmentedControl/DropdownControl.js +1 -2
- package/cjs/components/SegmentedControl/SegmentedControl.js +1 -0
- package/cjs/components/SegmentedControl/index.js +1 -2
- package/cjs/components/Select/Select.js +10 -7
- package/cjs/components/Select/SelectControl.js +13 -3
- package/cjs/components/SplitButton/index.js +1 -2
- package/cjs/components/Spot/SpotPopup.js +3 -4
- package/cjs/components/Status/Status.js +1 -0
- package/cjs/components/Subnav/index.js +1 -2
- package/cjs/components/Tabs/SearchBar.js +1 -2
- package/cjs/components/Tabs/TabIcon.js +1 -2
- package/cjs/components/Tabs/TabList.js +30 -14
- package/cjs/components/Tabs/TabListItem.js +5 -1
- package/cjs/components/Tabs/Tabs.js +16 -12
- package/cjs/components/Tabs/useWidths.js +5 -5
- package/cjs/components/Toast/Toast.js +1 -0
- package/cjs/components/Toast/index.js +1 -2
- package/cjs/components/Toaster/GroupLabel.js +5 -3
- package/cjs/components/Toolbar/Toolbar.js +1 -2
- package/cjs/components/Toolbar/ToolbarGroup.js +1 -2
- package/cjs/components/Toolbar/ToolbarMenu.js +1 -2
- package/cjs/components/Tooltip/Tooltip.js +11 -4
- package/cjs/components/Translate/Translate.js +13 -3
- package/cjs/components/Translate/index.js +28 -3
- package/cjs/components/Translate/locale.js +25 -0
- package/cjs/components/VerticalContext/index.js +1 -2
- package/cjs/components/index.js +16 -3
- package/cjs/hooks/useResizeObserver.js +8 -2
- package/cjs/index.js +1 -1
- package/cjs/locales/ar.js +124 -0
- package/cjs/locales/ca-ES.js +124 -0
- package/cjs/locales/cs-CZ.js +124 -0
- package/cjs/locales/da-DK.js +124 -0
- package/cjs/locales/de-DE.js +124 -0
- package/cjs/locales/el-GR.js +124 -0
- package/cjs/locales/en-US.js +124 -0
- package/cjs/locales/es-ES.js +124 -0
- package/cjs/locales/fi-FI.js +124 -0
- package/cjs/locales/fr-FR.js +124 -0
- package/cjs/locales/he-IL.js +124 -0
- package/cjs/locales/hu-HU.js +124 -0
- package/cjs/locales/id-ID.js +124 -0
- package/cjs/locales/index.js +172 -0
- package/cjs/locales/it-IT.js +124 -0
- package/cjs/locales/ja-JP.js +124 -0
- package/cjs/locales/ko-KR.js +124 -0
- package/cjs/locales/ms-MY.js +124 -0
- package/cjs/locales/nb-NO.js +124 -0
- package/cjs/locales/nl-NL.js +124 -0
- package/cjs/locales/pl-PL.js +124 -0
- package/cjs/locales/pt-BR.js +124 -0
- package/cjs/locales/pt-PT.js +124 -0
- package/cjs/locales/ro-RO.js +124 -0
- package/cjs/locales/ru-RU.js +124 -0
- package/cjs/locales/sv-SE.js +124 -0
- package/cjs/locales/th-TH.js +124 -0
- package/cjs/locales/tl-PH.js +124 -0
- package/cjs/locales/tr-TR.js +124 -0
- package/cjs/locales/uk-UA.js +124 -0
- package/cjs/locales/vi-VN.js +124 -0
- package/cjs/locales/zh-CN.js +124 -0
- package/cjs/locales/zh-TW.js +124 -0
- package/cjs/utils.js +17 -2
- package/dist/plesk-ui-library-rtl.css +1 -1
- package/dist/plesk-ui-library-rtl.css.map +1 -1
- package/dist/plesk-ui-library.css +1 -1
- package/dist/plesk-ui-library.css.map +1 -1
- package/dist/plesk-ui-library.js +5517 -1054
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +6 -6
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Action/Action.js +9 -1
- package/esm/components/Alert/Alert.js +1 -0
- package/esm/components/AutoClosable/AutoClosable.js +48 -62
- package/esm/components/AuxiliaryActions/AuxiliaryActions.js +13 -4
- package/esm/components/Button/Button.js +1 -0
- package/esm/components/Card/Card.js +9 -13
- package/esm/components/CardList/CardList.js +5 -7
- package/esm/components/CardList/CardListToolbar.js +11 -16
- package/esm/components/ClosingConfirmation/useClosingConfirmation.js +7 -11
- package/esm/components/ComboBoxDropdown/ComboBoxDropdown.js +3 -0
- package/esm/components/Cuttable/Cuttable.js +6 -8
- package/esm/components/Dialog/Dialog.js +18 -12
- package/esm/components/Drawer/Drawer.js +15 -8
- package/esm/components/Drawer/DrawerProgress.js +3 -4
- package/esm/components/Dropdown/Dropdown.js +11 -9
- package/esm/components/ExtendedStatusMessage/ExtendedStatusMessage.js +1 -0
- package/esm/components/Form/Form.js +18 -18
- package/esm/components/FormField/FormField.js +77 -51
- package/esm/components/FormFieldCheckbox/FormFieldCheckbox.js +6 -2
- package/esm/components/FormFieldPassword/FormFieldPassword.js +18 -21
- package/esm/components/FormFieldPassword/PasswordMeter.js +8 -13
- package/esm/components/FormFieldPassword/estimatePassword.js +21 -32
- package/esm/components/FormFieldRadioButtons/FormFieldRadioButtons.js +49 -42
- package/esm/components/FormFieldSelect/FormFieldSelect.js +1 -1
- package/esm/components/FormFieldText/FormFieldText.js +7 -1
- package/esm/components/Hint/Hint.js +2 -1
- package/esm/components/Icon/Icon.js +6 -0
- package/esm/components/Icon/utils.js +16 -6
- package/esm/components/InPlaceEdit/Editor.js +5 -8
- package/esm/components/InPlaceEdit/InPlaceEdit.js +3 -5
- package/esm/components/InputFile/InputFile.js +7 -9
- package/esm/components/Layout/Layout.js +2 -2
- package/esm/components/Link/Link.js +2 -0
- package/esm/components/List/List.js +37 -43
- package/esm/components/List/ListAction.js +1 -0
- package/esm/components/List/ListActions.js +1 -0
- package/esm/components/List/ListEmptyView.js +7 -10
- package/esm/components/List/ListOperation.js +3 -12
- package/esm/components/LocaleProvider/LocaleProvider.js +18 -11
- package/esm/components/Menu/Menu.js +10 -8
- package/esm/components/Menu/MenuItem.js +2 -1
- package/esm/components/Overlay/Overlay.js +2 -0
- package/esm/components/Pagination/Pagination.js +6 -10
- package/esm/components/Popover/Popover.js +1 -1
- package/esm/components/ProgressDialog/ProgressDialog.js +5 -7
- package/esm/components/Section/Section.js +88 -224
- package/esm/components/Section/SectionContext.js +5 -0
- package/esm/components/Section/useCollapsed.js +12 -0
- package/esm/components/Section/useVertical.js +30 -0
- package/esm/components/SegmentedControl/SegmentedControl.js +1 -0
- package/esm/components/Select/Select.js +10 -6
- package/esm/components/Select/SelectControl.js +14 -4
- package/esm/components/Spot/SpotPopup.js +3 -4
- package/esm/components/Status/Status.js +1 -0
- package/esm/components/Tabs/TabList.js +29 -12
- package/esm/components/Tabs/TabListItem.js +5 -1
- package/esm/components/Tabs/Tabs.js +17 -13
- package/esm/components/Tabs/useWidths.js +5 -5
- package/esm/components/Toast/Toast.js +1 -0
- package/esm/components/Toaster/GroupLabel.js +5 -3
- package/esm/components/Tooltip/Tooltip.js +11 -4
- package/esm/components/Translate/Translate.js +11 -2
- package/esm/components/Translate/index.js +3 -2
- package/esm/components/Translate/locale.js +15 -0
- package/esm/components/index.js +1 -1
- package/esm/hooks/useResizeObserver.js +8 -2
- package/esm/index.js +1 -1
- package/esm/locales/ar.js +119 -0
- package/esm/locales/ca-ES.js +119 -0
- package/esm/locales/cs-CZ.js +119 -0
- package/esm/locales/da-DK.js +119 -0
- package/esm/locales/de-DE.js +119 -0
- package/esm/locales/el-GR.js +119 -0
- package/esm/locales/en-US.js +119 -0
- package/esm/locales/es-ES.js +119 -0
- package/esm/locales/fi-FI.js +119 -0
- package/esm/locales/fr-FR.js +119 -0
- package/esm/locales/he-IL.js +119 -0
- package/esm/locales/hu-HU.js +119 -0
- package/esm/locales/id-ID.js +119 -0
- package/esm/locales/index.js +165 -0
- package/esm/locales/it-IT.js +119 -0
- package/esm/locales/ja-JP.js +119 -0
- package/esm/locales/ko-KR.js +119 -0
- package/esm/locales/ms-MY.js +119 -0
- package/esm/locales/nb-NO.js +119 -0
- package/esm/locales/nl-NL.js +119 -0
- package/esm/locales/pl-PL.js +119 -0
- package/esm/locales/pt-BR.js +119 -0
- package/esm/locales/pt-PT.js +119 -0
- package/esm/locales/ro-RO.js +119 -0
- package/esm/locales/ru-RU.js +119 -0
- package/esm/locales/sv-SE.js +119 -0
- package/esm/locales/th-TH.js +119 -0
- package/esm/locales/tl-PH.js +119 -0
- package/esm/locales/tr-TR.js +119 -0
- package/esm/locales/uk-UA.js +119 -0
- package/esm/locales/vi-VN.js +119 -0
- package/esm/locales/zh-CN.js +119 -0
- package/esm/locales/zh-TW.js +119 -0
- package/esm/utils.js +14 -0
- package/package.json +4 -4
- package/styleguide/build/bundle.cf3363eb.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/components/AutoClosable/AutoClosable.d.ts +5 -37
- package/types/components/Button/Button.d.ts +2 -2
- package/types/components/ComboBoxDropdown/ComboBoxDropdown.d.ts +2 -1
- package/types/components/Form/types.d.ts +2 -0
- package/types/components/FormField/FormField.d.ts +6 -0
- package/types/components/FormFieldSelect/FormFieldSelect.d.ts +1 -1
- package/types/components/Hint/Hint.d.ts +11 -8
- package/types/components/Icon/Icon.d.ts +5 -0
- package/types/components/Input/Input.d.ts +2 -2
- package/types/components/LocaleProvider/LocaleProvider.d.ts +3 -2
- package/types/components/Menu/Menu.d.ts +5 -0
- package/types/components/Menu/MenuItem.d.ts +6 -1
- package/types/components/Overlay/Overlay.d.ts +4 -0
- package/types/components/Popover/Popover.d.ts +1 -1
- package/types/components/Section/Section.d.ts +3 -46
- package/types/components/Section/SectionContext.d.ts +5 -0
- package/types/components/Section/useCollapsed.d.ts +1 -0
- package/types/components/Section/useVertical.d.ts +2 -0
- package/types/components/Select/SelectControl.d.ts +2 -0
- package/types/components/Tabs/TabList.d.ts +3 -1
- package/types/components/Tabs/TabListItem.d.ts +4 -1
- package/types/components/Tabs/useWidths.d.ts +2 -2
- package/types/components/Tooltip/Tooltip.d.ts +1 -0
- package/types/components/Translate/Translate.d.ts +7 -1
- package/types/components/Translate/index.d.ts +2 -1
- package/types/components/Translate/locale.d.ts +4 -0
- package/types/components/index.d.ts +1 -1
- package/types/hooks/useResizeObserver.d.ts +2 -1
- package/types/locales/index.d.ts +10 -0
- package/types/utils.d.ts +3 -0
- package/cjs/components/ClosingConfirmation/locale/en-US.js +0 -12
- package/cjs/components/FormFieldPassword/locale/en-US.js +0 -33
- package/cjs/components/InPlaceEdit/locale/en-US.js +0 -12
- package/cjs/components/InputFile/locale/en-US.js +0 -10
- package/esm/components/ClosingConfirmation/locale/en-US.js +0 -7
- package/esm/components/Dropdown/locale/en-US.js +0 -5
- package/esm/components/FormFieldPassword/locale/en-US.js +0 -28
- package/esm/components/InPlaceEdit/locale/en-US.js +0 -7
- package/esm/components/InputFile/locale/en-US.js +0 -5
- package/styleguide/build/bundle.2360aa9e.js +0 -2
- package/types/components/InPlaceEdit/locale/en-US.d.ts +0 -6
- /package/styleguide/build/{bundle.2360aa9e.js.LICENSE.txt → bundle.cf3363eb.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import { useContext, useState, useLayoutEffect } from 'react';
|
|
4
|
+
import { useResizeObserver } from '../../hooks';
|
|
5
|
+
import VerticalContext, { VERTICAL_BREAKPOINT } from '../VerticalContext';
|
|
6
|
+
const isVertical = containerRef => {
|
|
7
|
+
if (!containerRef.current) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const {
|
|
11
|
+
width
|
|
12
|
+
} = containerRef.current.getBoundingClientRect();
|
|
13
|
+
return width < VERTICAL_BREAKPOINT;
|
|
14
|
+
};
|
|
15
|
+
export const useVertical = (externalVertical, containerRef) => {
|
|
16
|
+
const verticalContext = useContext(VerticalContext);
|
|
17
|
+
const [internalVertical, setInternalVertical] = useState(false);
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
setInternalVertical(isVertical(containerRef));
|
|
20
|
+
}, [containerRef]);
|
|
21
|
+
useResizeObserver({
|
|
22
|
+
ref: containerRef,
|
|
23
|
+
onResize: () => {
|
|
24
|
+
setInternalVertical(isVertical(containerRef));
|
|
25
|
+
},
|
|
26
|
+
callOnInit: false
|
|
27
|
+
});
|
|
28
|
+
const vertical = [externalVertical, verticalContext, internalVertical].find(v => typeof v === 'boolean');
|
|
29
|
+
return vertical;
|
|
30
|
+
};
|
|
@@ -80,6 +80,7 @@ const SegmentedControl = _ref => {
|
|
|
80
80
|
[`${baseClassName}--collapsed`]: isResponsive,
|
|
81
81
|
[`${baseClassName}--vertical`]: label && labelPlacement === 'top'
|
|
82
82
|
}, className),
|
|
83
|
+
role: "list",
|
|
83
84
|
...props,
|
|
84
85
|
children: [label && /*#__PURE__*/_jsx("div", {
|
|
85
86
|
className: `${baseClassName}__label`,
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
2
|
|
|
3
|
-
import { Children, useState, useRef, isValidElement } from 'react';
|
|
3
|
+
import { Children, useState, useRef, isValidElement, useId } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { safeInvoke, EventEmitter } from '../utils';
|
|
6
6
|
import { CLS_PREFIX } from '../../constants';
|
|
7
7
|
import ComboBoxDropdown, { findNextSafeIndex } from '../ComboBoxDropdown';
|
|
8
|
-
import
|
|
8
|
+
import { InternalTranslate } from '../Translate';
|
|
9
9
|
import SelectControl from './SelectControl';
|
|
10
10
|
import SelectOptionGroup from './SelectOptionGroup';
|
|
11
11
|
import SelectOption from './SelectOption';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
// eslint-disable-next-line default-param-last
|
|
14
13
|
const collect = function (children) {
|
|
15
14
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
16
15
|
let group = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -111,6 +110,8 @@ const Select = _ref => {
|
|
|
111
110
|
const [opened, setOpened] = useState(false);
|
|
112
111
|
const controlRef = useRef(null);
|
|
113
112
|
const emitterRef = useRef(new EventEmitter());
|
|
113
|
+
const uid = useId();
|
|
114
|
+
const listboxId = `${baseClassName}-listbox-${id || uid}`;
|
|
114
115
|
let [value, setValue] = useState(() => {
|
|
115
116
|
if (typeof defaultValue === 'undefined') {
|
|
116
117
|
return multiple ? [] : undefined;
|
|
@@ -143,6 +144,7 @@ const Select = _ref => {
|
|
|
143
144
|
}
|
|
144
145
|
const groupFns = [];
|
|
145
146
|
const optionFns = [];
|
|
147
|
+
|
|
146
148
|
// eslint-disable-next-line func-style
|
|
147
149
|
function createInclude(fns) {
|
|
148
150
|
return item => fns.every(fn => fn(item));
|
|
@@ -286,6 +288,8 @@ const Select = _ref => {
|
|
|
286
288
|
onClear: handleClear,
|
|
287
289
|
onValueRemove: handleValueRemove,
|
|
288
290
|
placeholder: placeholder,
|
|
291
|
+
opened: opened,
|
|
292
|
+
listboxId: listboxId,
|
|
289
293
|
ref: controlRef
|
|
290
294
|
});
|
|
291
295
|
return /*#__PURE__*/_jsx(ComboBoxDropdown, {
|
|
@@ -302,12 +306,12 @@ const Select = _ref => {
|
|
|
302
306
|
highlightedIndex: highlightedIndex,
|
|
303
307
|
onHighlightedIndexChange: handleHighlightedIndexChange,
|
|
304
308
|
onClose: handleClose,
|
|
305
|
-
noOptions: /*#__PURE__*/_jsx(
|
|
306
|
-
content: "Select.noOptions"
|
|
307
|
-
fallback: "No options"
|
|
309
|
+
noOptions: /*#__PURE__*/_jsx(InternalTranslate, {
|
|
310
|
+
content: "Select.noOptions"
|
|
308
311
|
}),
|
|
309
312
|
emitter: emitterRef.current,
|
|
310
313
|
value: value,
|
|
314
|
+
listboxId: listboxId,
|
|
311
315
|
...props
|
|
312
316
|
});
|
|
313
317
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { Fragment, useRef, useState, useLayoutEffect, forwardRef } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useInternalTranslate } from '../LocaleProvider';
|
|
6
6
|
import { CLS_PREFIX } from '../../constants';
|
|
7
7
|
import Icon from '../Icon';
|
|
8
8
|
import MultiValue from './MultiValue';
|
|
@@ -50,6 +50,8 @@ const SelectControl = /*#__PURE__*/forwardRef(function SelectControl(_ref, ref)
|
|
|
50
50
|
onClear,
|
|
51
51
|
onValueRemove,
|
|
52
52
|
placeholder,
|
|
53
|
+
opened = false,
|
|
54
|
+
listboxId,
|
|
53
55
|
...props
|
|
54
56
|
} = _ref;
|
|
55
57
|
const inputRef = useRef(null);
|
|
@@ -57,9 +59,9 @@ const SelectControl = /*#__PURE__*/forwardRef(function SelectControl(_ref, ref)
|
|
|
57
59
|
const searchBufferTimer = useRef(0);
|
|
58
60
|
const [inputWidth, setInputWidth] = useState(DEFAULT_INPUT_WIDTH);
|
|
59
61
|
const [focused, setFocused] = useState(false);
|
|
60
|
-
const translate =
|
|
62
|
+
const translate = useInternalTranslate('Select');
|
|
61
63
|
if (placeholder === undefined) {
|
|
62
|
-
placeholder = translate('
|
|
64
|
+
placeholder = translate('placeholder');
|
|
63
65
|
}
|
|
64
66
|
let values = [];
|
|
65
67
|
if (Array.isArray(current)) {
|
|
@@ -190,7 +192,13 @@ const SelectControl = /*#__PURE__*/forwardRef(function SelectControl(_ref, ref)
|
|
|
190
192
|
ref: inputRef,
|
|
191
193
|
style: {
|
|
192
194
|
width: inputWidth
|
|
193
|
-
}
|
|
195
|
+
},
|
|
196
|
+
role: searchable ? 'combobox' : undefined,
|
|
197
|
+
"aria-autocomplete": searchable ? 'list' : undefined,
|
|
198
|
+
"aria-haspopup": searchable ? 'listbox' : 'listbox',
|
|
199
|
+
"aria-expanded": opened,
|
|
200
|
+
"aria-controls": listboxId,
|
|
201
|
+
autoComplete: "off"
|
|
194
202
|
}), !filterValue && /*#__PURE__*/_jsxs(Fragment, {
|
|
195
203
|
children: [!Array.isArray(current) && current && /*#__PURE__*/_jsx("span", {
|
|
196
204
|
className: `${baseClassName}__value`,
|
|
@@ -227,6 +235,8 @@ const SelectControl = /*#__PURE__*/forwardRef(function SelectControl(_ref, ref)
|
|
|
227
235
|
type: "button",
|
|
228
236
|
className: classNames(`${baseClassName}__indicator`, `${baseClassName}__indicator--dropdown`),
|
|
229
237
|
tabIndex: -1,
|
|
238
|
+
"aria-haspopup": "listbox",
|
|
239
|
+
"aria-expanded": opened,
|
|
230
240
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
231
241
|
className: `${baseClassName}__indicator-icon`,
|
|
232
242
|
children: /*#__PURE__*/_jsx("svg", {
|
|
@@ -5,7 +5,7 @@ import { useEffect, useState, useRef } from 'react';
|
|
|
5
5
|
import { CLS_PREFIX } from '../../constants';
|
|
6
6
|
import Popover from '../Popover';
|
|
7
7
|
import Text from '../Text';
|
|
8
|
-
import
|
|
8
|
+
import { InternalTranslate } from '../Translate';
|
|
9
9
|
import Focuser from '../Overlay/Focuser';
|
|
10
10
|
import { safeInvoke } from '../utils';
|
|
11
11
|
|
|
@@ -70,15 +70,14 @@ const SpotPopup = _ref => {
|
|
|
70
70
|
children: [meta && meta.total > 1 ? /*#__PURE__*/_jsx(Text, {
|
|
71
71
|
intent: "muted",
|
|
72
72
|
fontSize: "sm",
|
|
73
|
-
children: /*#__PURE__*/_jsx(
|
|
73
|
+
children: /*#__PURE__*/_jsx(InternalTranslate, {
|
|
74
74
|
namespace: "SpotPopup",
|
|
75
75
|
content: "total",
|
|
76
76
|
params: {
|
|
77
77
|
current: meta.current + 1,
|
|
78
78
|
total: meta.total
|
|
79
79
|
},
|
|
80
|
-
translators: locale
|
|
81
|
-
fallback: "%%current%% of %%total%%"
|
|
80
|
+
translators: locale
|
|
82
81
|
})
|
|
83
82
|
}) : /*#__PURE__*/_jsx("span", {}), /*#__PURE__*/_jsx("div", {
|
|
84
83
|
className: `${baseClassName}__actions`,
|
|
@@ -47,6 +47,7 @@ const Status = _ref => {
|
|
|
47
47
|
[`${baseClassName}--${intent}`]: intent && !progress,
|
|
48
48
|
[`${baseClassName}--on-dark`]: useContext(OnDarkContext)
|
|
49
49
|
}, className),
|
|
50
|
+
role: intent === 'warning' || intent === 'danger' ? 'alert' : 'status',
|
|
50
51
|
outerProps: {
|
|
51
52
|
...outerProps,
|
|
52
53
|
className: classNames({
|
|
@@ -19,29 +19,46 @@ const TabList = _ref => {
|
|
|
19
19
|
onTabClick,
|
|
20
20
|
visibleLength,
|
|
21
21
|
monospacedWidth,
|
|
22
|
-
baseClassName
|
|
22
|
+
baseClassName,
|
|
23
|
+
tabPanelId,
|
|
24
|
+
idPrefix
|
|
23
25
|
} = _ref;
|
|
24
26
|
const handleTabClick = (tab, position) => {
|
|
25
27
|
onTabClick(position);
|
|
26
28
|
tab?.props?.onActivate?.();
|
|
27
29
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
const childArray = Children.map(children, (child, index) => ({
|
|
31
|
+
child,
|
|
32
|
+
position: index + 1
|
|
33
|
+
}));
|
|
34
|
+
const tabs = childArray.filter(_ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
child
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return child?.type === Tab;
|
|
39
|
+
});
|
|
30
40
|
const listChildren = tabs.slice(0, visibleLength);
|
|
31
41
|
const menuChildren = tabs.slice(visibleLength);
|
|
32
|
-
const listItems = listChildren.map(
|
|
33
|
-
|
|
42
|
+
const listItems = listChildren.map(_ref3 => {
|
|
43
|
+
let {
|
|
44
|
+
child: tab,
|
|
45
|
+
position
|
|
46
|
+
} = _ref3;
|
|
34
47
|
return /*#__PURE__*/_jsx(TabListItem, {
|
|
35
|
-
// eslint-disable-line react/no-array-index-key
|
|
36
48
|
tab: tab,
|
|
37
49
|
baseClassName: baseClassName,
|
|
38
50
|
selected: position === active,
|
|
39
51
|
onClick: () => handleTabClick(tab, position),
|
|
40
|
-
monospacedWidth: monospacedWidth
|
|
41
|
-
|
|
52
|
+
monospacedWidth: monospacedWidth,
|
|
53
|
+
tabPanelId: tabPanelId,
|
|
54
|
+
id: idPrefix ? `${idPrefix}-${position}` : undefined
|
|
55
|
+
}, position);
|
|
42
56
|
});
|
|
43
|
-
const menuItems = menuChildren.map(
|
|
44
|
-
|
|
57
|
+
const menuItems = menuChildren.map(_ref4 => {
|
|
58
|
+
let {
|
|
59
|
+
child: tab,
|
|
60
|
+
position
|
|
61
|
+
} = _ref4;
|
|
45
62
|
const {
|
|
46
63
|
title,
|
|
47
64
|
label,
|
|
@@ -52,7 +69,6 @@ const TabList = _ref => {
|
|
|
52
69
|
...tabProps
|
|
53
70
|
} = tab.props;
|
|
54
71
|
return /*#__PURE__*/_jsx(MenuItem, {
|
|
55
|
-
// eslint-disable-line react/no-array-index-key
|
|
56
72
|
icon: /*#__PURE__*/_jsx(TabIcon, {
|
|
57
73
|
icon: icon,
|
|
58
74
|
baseClassName: baseClassName
|
|
@@ -74,13 +90,14 @@ const TabList = _ref => {
|
|
|
74
90
|
component: Tag,
|
|
75
91
|
...tabProps,
|
|
76
92
|
children: title
|
|
77
|
-
},
|
|
93
|
+
}, position);
|
|
78
94
|
});
|
|
79
95
|
const moreSelected = active > listChildren.length;
|
|
80
96
|
return /*#__PURE__*/_jsxs("ul", {
|
|
81
97
|
ref: tabListRef,
|
|
82
98
|
className: `${baseClassName}__tab-list`,
|
|
83
99
|
role: "tablist",
|
|
100
|
+
"aria-labelledby": tabPanelId,
|
|
84
101
|
children: [listItems, menuItems.length > 0 && /*#__PURE__*/_jsx("li", {
|
|
85
102
|
className: classNames(`${baseClassName}__tab`, moreSelected && `${baseClassName}__tab--selected`, `${baseClassName}__tab--more`),
|
|
86
103
|
role: "presentation",
|
|
@@ -13,7 +13,9 @@ const TabListItem = _ref => {
|
|
|
13
13
|
onClick,
|
|
14
14
|
monospacedWidth,
|
|
15
15
|
baseClassName,
|
|
16
|
-
isFake = false
|
|
16
|
+
isFake = false,
|
|
17
|
+
tabPanelId,
|
|
18
|
+
id
|
|
17
19
|
} = _ref;
|
|
18
20
|
const {
|
|
19
21
|
title,
|
|
@@ -37,7 +39,9 @@ const TabListItem = _ref => {
|
|
|
37
39
|
}
|
|
38
40
|
}),
|
|
39
41
|
role: 'tab',
|
|
42
|
+
'aria-controls': selected ? tabPanelId : undefined,
|
|
40
43
|
'aria-selected': selected || undefined,
|
|
44
|
+
id,
|
|
41
45
|
...tabProps
|
|
42
46
|
};
|
|
43
47
|
const Tag = isFake ? 'a' : component;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { Children, cloneElement, useRef, useState } from 'react';
|
|
4
|
+
import { Children, cloneElement, useId, useRef, useState } from 'react';
|
|
5
5
|
import { CLS_PREFIX } from '../../constants';
|
|
6
6
|
import ResponsiveContext from '../ResponsiveContext';
|
|
7
7
|
import FakeTabs from './FakeTabs';
|
|
@@ -32,8 +32,12 @@ const Tabs = _ref => {
|
|
|
32
32
|
const addonElement = addon || placeholder;
|
|
33
33
|
const tabNavRef = useRef(null);
|
|
34
34
|
const tabListRef = useRef(null);
|
|
35
|
-
const
|
|
35
|
+
const addonRef = useRef(null);
|
|
36
36
|
const childrenCount = Children.toArray(children).length;
|
|
37
|
+
const wrappedAddonElement = addonElement ? /*#__PURE__*/_jsx("div", {
|
|
38
|
+
ref: addonRef,
|
|
39
|
+
children: addonElement
|
|
40
|
+
}) : null;
|
|
37
41
|
const [active, setActive] = useActive(externalActive);
|
|
38
42
|
const {
|
|
39
43
|
monospacedWidth,
|
|
@@ -44,11 +48,12 @@ const Tabs = _ref => {
|
|
|
44
48
|
monospaced,
|
|
45
49
|
tabNavRef,
|
|
46
50
|
tabListRef,
|
|
47
|
-
|
|
51
|
+
addonRef,
|
|
48
52
|
baseClassName,
|
|
49
53
|
childrenCount
|
|
50
54
|
});
|
|
51
55
|
const [searching, setSearching] = useState(false);
|
|
56
|
+
const id = useId();
|
|
52
57
|
if (!childrenCount) {
|
|
53
58
|
return null;
|
|
54
59
|
}
|
|
@@ -86,12 +91,13 @@ const Tabs = _ref => {
|
|
|
86
91
|
if (search && !compact) {
|
|
87
92
|
addonStyle.maxWidth = search.props.maxWidth;
|
|
88
93
|
}
|
|
94
|
+
const tabPanelId = `${id}-tabpanel`;
|
|
89
95
|
return /*#__PURE__*/_jsxs("div", {
|
|
90
96
|
className: classNames(baseClassName, className),
|
|
91
97
|
...props,
|
|
92
|
-
children: [compact &&
|
|
98
|
+
children: [compact && wrappedAddonElement && /*#__PURE__*/_jsx("div", {
|
|
93
99
|
className: `${baseClassName}__addon ${baseClassName}__addon--compact`,
|
|
94
|
-
children:
|
|
100
|
+
children: wrappedAddonElement
|
|
95
101
|
}), /*#__PURE__*/_jsxs("div", {
|
|
96
102
|
className: classNames(`${baseClassName}__nav`, compact && `${baseClassName}__nav--compact`, searching && `${baseClassName}__nav--searching`, search && `${baseClassName}__nav--search`),
|
|
97
103
|
ref: tabNavRef,
|
|
@@ -102,25 +108,23 @@ const Tabs = _ref => {
|
|
|
102
108
|
visibleLength: visibleLength,
|
|
103
109
|
monospacedWidth: monospacedWidth,
|
|
104
110
|
baseClassName: baseClassName,
|
|
111
|
+
tabPanelId: tabPanelId,
|
|
105
112
|
children: children
|
|
106
|
-
}), compact && renderSearchBar(), !compact && (
|
|
113
|
+
}), compact && renderSearchBar(), !compact && (wrappedAddonElement || search) && /*#__PURE__*/_jsxs("div", {
|
|
107
114
|
className: `${baseClassName}__addon`,
|
|
108
115
|
style: addonStyle,
|
|
109
|
-
children: [renderSearchBar(),
|
|
116
|
+
children: [renderSearchBar(), wrappedAddonElement]
|
|
110
117
|
}), /*#__PURE__*/_jsx(FakeTabs, {
|
|
111
118
|
onResize: recalculateWidths,
|
|
112
119
|
baseClassName: baseClassName,
|
|
113
120
|
children: children
|
|
114
|
-
}), addonElement && /*#__PURE__*/_jsx("div", {
|
|
115
|
-
ref: fakeAddonRef,
|
|
116
|
-
className: `${baseClassName}__addon-fake-wrapper`,
|
|
117
|
-
"aria-hidden": true,
|
|
118
|
-
children: addonElement
|
|
119
121
|
})]
|
|
120
122
|
}), /*#__PURE__*/_jsx("div", {
|
|
123
|
+
id: tabPanelId,
|
|
121
124
|
className: `${baseClassName}__tab-panel`,
|
|
122
125
|
role: "tabpanel",
|
|
123
|
-
|
|
126
|
+
"aria-labelledby": `${id}-${active}`,
|
|
127
|
+
children: Children.map(children, (tab, index) => index + 1 === active ? tab : null)
|
|
124
128
|
})]
|
|
125
129
|
});
|
|
126
130
|
};
|
|
@@ -6,7 +6,7 @@ export const useWidths = _ref => {
|
|
|
6
6
|
let {
|
|
7
7
|
tabNavRef,
|
|
8
8
|
tabListRef,
|
|
9
|
-
|
|
9
|
+
addonRef,
|
|
10
10
|
baseClassName,
|
|
11
11
|
monospaced = false,
|
|
12
12
|
childrenCount
|
|
@@ -39,8 +39,8 @@ export const useWidths = _ref => {
|
|
|
39
39
|
let availableSpace = tabNavWidth - addonWidth;
|
|
40
40
|
const allTabsFit = availableSpace >= tabsWidth;
|
|
41
41
|
const getContentKey = () => {
|
|
42
|
-
const
|
|
43
|
-
return `${fakeTabWidths.join('-')}-${tabNavWidth}-${
|
|
42
|
+
const addonWrapperWidth = addonRef.current?.getBoundingClientRect().width ?? 0;
|
|
43
|
+
return `${fakeTabWidths.join('-')}-${tabNavWidth}-${addonWrapperWidth}-${monospacedWidth}`;
|
|
44
44
|
};
|
|
45
45
|
if (allTabsFit) {
|
|
46
46
|
setVisibleLength(tabLength);
|
|
@@ -70,7 +70,7 @@ export const useWidths = _ref => {
|
|
|
70
70
|
return 0;
|
|
71
71
|
};
|
|
72
72
|
setVisibleLength(calculateVisibleLength());
|
|
73
|
-
}, [tabNavRef, tabListRef,
|
|
73
|
+
}, [tabNavRef, tabListRef, addonRef, baseClassName, monospaced, compact]);
|
|
74
74
|
useLayoutEffect(() => {
|
|
75
75
|
recalculateWidths();
|
|
76
76
|
}, [recalculateWidths]);
|
|
@@ -83,7 +83,7 @@ export const useWidths = _ref => {
|
|
|
83
83
|
onResize: recalculateWidths
|
|
84
84
|
});
|
|
85
85
|
useResizeObserver({
|
|
86
|
-
ref:
|
|
86
|
+
ref: addonRef,
|
|
87
87
|
onResize: recalculateWidths
|
|
88
88
|
});
|
|
89
89
|
return {
|
|
@@ -33,6 +33,7 @@ const Toast = _ref => {
|
|
|
33
33
|
});
|
|
34
34
|
const result = /*#__PURE__*/_jsxs("div", {
|
|
35
35
|
tabIndex: 0,
|
|
36
|
+
role: "status",
|
|
36
37
|
className: classNames(baseClassName, intent && `${baseClassName}--${intent}`, accent && `${baseClassName}--accent`, className),
|
|
37
38
|
...props,
|
|
38
39
|
ref: innerRef,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import Label from '../Label';
|
|
4
4
|
import Tooltip from '../Tooltip';
|
|
5
|
+
import { useInternalTranslate } from '../LocaleProvider';
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
const GroupLabel = _ref => {
|
|
7
8
|
let {
|
|
@@ -12,9 +13,10 @@ const GroupLabel = _ref => {
|
|
|
12
13
|
renderHeaderLabel,
|
|
13
14
|
renderHeaderLabelTitle,
|
|
14
15
|
closable = false,
|
|
15
|
-
renderHeaderLabelTooltip
|
|
16
|
+
renderHeaderLabelTooltip,
|
|
16
17
|
intent
|
|
17
18
|
} = group;
|
|
19
|
+
const translate = useInternalTranslate('Toaster');
|
|
18
20
|
if (!renderHeaderLabel && !renderHeaderLabelTitle) {
|
|
19
21
|
return null;
|
|
20
22
|
}
|
|
@@ -31,8 +33,8 @@ const GroupLabel = _ref => {
|
|
|
31
33
|
return renderHeaderLabel(group, labelProps);
|
|
32
34
|
}
|
|
33
35
|
const wrapInTooltip = content => {
|
|
34
|
-
if (!renderHeaderLabelTooltip) return content;
|
|
35
|
-
const title = renderHeaderLabelTooltip(group);
|
|
36
|
+
if (!renderHeaderLabelTooltip && !closable) return content;
|
|
37
|
+
const title = renderHeaderLabelTooltip?.(group) ?? translate('closeGroup');
|
|
36
38
|
if (!title) return content;
|
|
37
39
|
return /*#__PURE__*/_jsx(Tooltip, {
|
|
38
40
|
title: title,
|
|
@@ -14,6 +14,8 @@ const createRectFactory = (width, height) => (left, top) => ({
|
|
|
14
14
|
bottom: top + height
|
|
15
15
|
});
|
|
16
16
|
const isInside = (r1, r2) => r1.left >= r2.left && r1.right <= r2.right && r1.top >= r2.top && r1.bottom <= r2.bottom;
|
|
17
|
+
let tooltipId = 0;
|
|
18
|
+
const generateTooltipId = () => `tooltip-${tooltipId++}`;
|
|
17
19
|
const determinePosition = _ref => {
|
|
18
20
|
let {
|
|
19
21
|
clientX,
|
|
@@ -94,7 +96,8 @@ class Tooltip extends Component {
|
|
|
94
96
|
left: 0,
|
|
95
97
|
top: 0,
|
|
96
98
|
ready: false,
|
|
97
|
-
visible: false
|
|
99
|
+
visible: false,
|
|
100
|
+
id: generateTooltipId()
|
|
98
101
|
});
|
|
99
102
|
_defineProperty(this, "timer", null);
|
|
100
103
|
_defineProperty(this, "tooltipRef", /*#__PURE__*/createRef());
|
|
@@ -154,7 +157,8 @@ class Tooltip extends Component {
|
|
|
154
157
|
const {
|
|
155
158
|
left,
|
|
156
159
|
top,
|
|
157
|
-
visible
|
|
160
|
+
visible,
|
|
161
|
+
id
|
|
158
162
|
} = this.state;
|
|
159
163
|
const {
|
|
160
164
|
baseClassName,
|
|
@@ -169,6 +173,7 @@ class Tooltip extends Component {
|
|
|
169
173
|
level: Z_INDEX_TOOLTIP,
|
|
170
174
|
children: /*#__PURE__*/_jsx("span", {
|
|
171
175
|
ref: this.tooltipRef,
|
|
176
|
+
id: id,
|
|
172
177
|
className: classNames(baseClassName, className),
|
|
173
178
|
style: {
|
|
174
179
|
...style,
|
|
@@ -183,7 +188,8 @@ class Tooltip extends Component {
|
|
|
183
188
|
}
|
|
184
189
|
render() {
|
|
185
190
|
const {
|
|
186
|
-
ready
|
|
191
|
+
ready,
|
|
192
|
+
id
|
|
187
193
|
} = this.state;
|
|
188
194
|
const {
|
|
189
195
|
children
|
|
@@ -193,7 +199,8 @@ class Tooltip extends Component {
|
|
|
193
199
|
onMouseEnter: wrapFunction(children.props.onMouseEnter, this.handleMouseEnter),
|
|
194
200
|
onMouseMove: wrapFunction(children.props.onMouseMove, this.handleMouseMove),
|
|
195
201
|
onMouseLeave: wrapFunction(children.props.onMouseLeave, this.handleHide),
|
|
196
|
-
onMouseDown: wrapFunction(children.props.onMouseDown, this.handleHide)
|
|
202
|
+
onMouseDown: wrapFunction(children.props.onMouseDown, this.handleHide),
|
|
203
|
+
'aria-labelledby': id
|
|
197
204
|
}), ready && this.renderTooltip()]
|
|
198
205
|
});
|
|
199
206
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
2
|
|
|
3
3
|
import { useTranslate } from '../LocaleProvider';
|
|
4
|
+
import { getLocaleMessages } from './locale';
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
/**
|
|
6
7
|
* `Translate` component.
|
|
@@ -16,6 +17,7 @@ const Translate = _ref => {
|
|
|
16
17
|
fallback,
|
|
17
18
|
namespace,
|
|
18
19
|
translators,
|
|
20
|
+
defaultMessages,
|
|
19
21
|
...props
|
|
20
22
|
} = _ref;
|
|
21
23
|
const Tag = component || 'span';
|
|
@@ -28,7 +30,7 @@ const Translate = _ref => {
|
|
|
28
30
|
}
|
|
29
31
|
return translator;
|
|
30
32
|
}
|
|
31
|
-
const message = translate(key, params, fallback);
|
|
33
|
+
const message = translate(key, params, fallback, defaultMessages);
|
|
32
34
|
const tagProps = {
|
|
33
35
|
...props
|
|
34
36
|
};
|
|
@@ -43,4 +45,11 @@ const Translate = _ref => {
|
|
|
43
45
|
...tagProps
|
|
44
46
|
});
|
|
45
47
|
};
|
|
46
|
-
export default Translate;
|
|
48
|
+
export default Translate;
|
|
49
|
+
export const InternalTranslate = props => {
|
|
50
|
+
const defaultMessages = getLocaleMessages();
|
|
51
|
+
return /*#__PURE__*/_jsx(Translate, {
|
|
52
|
+
...props,
|
|
53
|
+
defaultMessages: defaultMessages
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
2
|
|
|
3
|
-
export { default } from './Translate';
|
|
4
|
-
export { isLikeText } from './isLikeText';
|
|
3
|
+
export { default, InternalTranslate } from './Translate';
|
|
4
|
+
export { isLikeText } from './isLikeText';
|
|
5
|
+
export { setLocale, getLocale, getLocaleMessages } from './locale';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import locales from '../../locales';
|
|
4
|
+
const DEFAULT_LOCALE = 'en-US';
|
|
5
|
+
let currenLocale = DEFAULT_LOCALE;
|
|
6
|
+
export const setLocale = locale => {
|
|
7
|
+
currenLocale = locale;
|
|
8
|
+
};
|
|
9
|
+
export const getLocale = () => currenLocale;
|
|
10
|
+
export const getLocaleMessages = () => (locales[currenLocale] ?? Object.values(locales).find(_ref => {
|
|
11
|
+
let {
|
|
12
|
+
language
|
|
13
|
+
} = _ref;
|
|
14
|
+
return language === `${currenLocale}`.toLocaleLowerCase();
|
|
15
|
+
}) ?? locales[DEFAULT_LOCALE])?.messages;
|
package/esm/components/index.js
CHANGED
|
@@ -88,7 +88,7 @@ export { default as Toaster } from './Toaster';
|
|
|
88
88
|
export { default as Toolbar, ToolbarGroup, ToolbarExpander } from './Toolbar';
|
|
89
89
|
export { default as Tooltip } from './Tooltip';
|
|
90
90
|
export { default as Tour } from './Tour';
|
|
91
|
-
export { default as Translate } from './Translate';
|
|
91
|
+
export { default as Translate, setLocale, getLocale } from './Translate';
|
|
92
92
|
export { default as Link } from './Link';
|
|
93
93
|
export { default as Skeleton, SkeletonTabs, SkeletonText } from './Skeleton';
|
|
94
94
|
export { default as Spinner } from './Spinner';
|
|
@@ -4,19 +4,25 @@ import { useEffect, useRef } from 'react';
|
|
|
4
4
|
export const useResizeObserver = _ref => {
|
|
5
5
|
let {
|
|
6
6
|
ref,
|
|
7
|
-
onResize
|
|
7
|
+
onResize,
|
|
8
|
+
callOnInit = true
|
|
8
9
|
} = _ref;
|
|
10
|
+
const isInitial = useRef(true);
|
|
9
11
|
const onResizeRef = useRef(undefined);
|
|
10
12
|
onResizeRef.current = onResize;
|
|
11
13
|
useEffect(() => {
|
|
12
14
|
if (!ref.current) return undefined;
|
|
13
15
|
if (typeof window === 'undefined' || !('ResizeObserver' in window)) return undefined;
|
|
14
16
|
const observer = new ResizeObserver(() => {
|
|
17
|
+
if (!callOnInit && isInitial.current) {
|
|
18
|
+
isInitial.current = false;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
15
21
|
onResizeRef.current?.();
|
|
16
22
|
});
|
|
17
23
|
observer.observe(ref.current);
|
|
18
24
|
return () => {
|
|
19
25
|
observer.disconnect();
|
|
20
26
|
};
|
|
21
|
-
}, [ref]);
|
|
27
|
+
}, [ref, callOnInit]);
|
|
22
28
|
};
|
package/esm/index.js
CHANGED