@plesk/ui-library 3.44.0 → 3.45.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 +0 -6
- package/cjs/components/Alert/Alert.js +5 -1
- package/cjs/components/Button/Button.js +2 -0
- package/cjs/components/Carousel/Carousel.js +9 -4
- package/cjs/components/ComboBox/ComboBox.js +3 -0
- package/cjs/components/ComboBoxDropdown/ComboBoxDropdown.js +6 -2
- package/cjs/components/ComboBoxDropdown/index.js +6 -0
- package/cjs/components/Dialog/Dialog.js +3 -0
- package/cjs/components/Drawer/Header.js +5 -0
- package/cjs/components/Dropdown/Dropdown.js +3 -0
- package/cjs/components/Form/Form.js +3 -1
- package/cjs/components/FormField/FormField.js +9 -5
- package/cjs/components/FormFieldPassword/FormFieldPassword.js +9 -11
- package/cjs/components/InPlaceEdit/Editor.js +6 -7
- package/cjs/components/InPlaceEdit/InPlaceEdit.js +4 -4
- package/cjs/components/InputFile/InputFile.js +4 -4
- package/cjs/components/InputNumber/InputNumber.js +4 -0
- package/cjs/components/Layout/Layout.js +8 -0
- package/cjs/components/List/List.js +11 -6
- package/cjs/components/List/ListActions.js +5 -0
- package/cjs/components/LocaleProvider/LocaleProvider.js +13 -3
- package/cjs/components/Menu/MenuItem.js +4 -0
- package/cjs/components/Overlay/Overlay.js +1 -0
- package/cjs/components/Panel/Panel.js +3 -0
- package/cjs/components/Popover/Popover.js +3 -0
- package/cjs/components/Section/Section.js +4 -0
- package/cjs/components/Select/Select.js +12 -1
- package/cjs/components/Select/SelectControl.js +24 -7
- package/cjs/components/Spinner/Spinner.js +1 -0
- package/cjs/components/SwitchesPanelItem/SwitchesPanelItem.js +3 -0
- package/cjs/components/Tabs/SearchBar.js +7 -0
- package/cjs/components/Tabs/TabClose.js +3 -0
- package/cjs/components/Toast/Toast.js +3 -0
- package/cjs/components/Tooltip/Tooltip.js +92 -202
- package/cjs/components/Tooltip/TooltipContent.js +83 -0
- package/cjs/components/Tooltip/getA11yAttributes.js +30 -0
- package/cjs/components/Tooltip/useVirtualElement.js +35 -0
- package/cjs/components/utils.js +42 -2
- package/cjs/hooks/useEscapeKeydown.js +25 -0
- package/cjs/index.js +1 -1
- package/cjs/locales/ar.js +66 -4
- package/cjs/locales/ca-ES.js +66 -4
- package/cjs/locales/cs-CZ.js +66 -4
- package/cjs/locales/da-DK.js +66 -4
- package/cjs/locales/de-DE.js +66 -4
- package/cjs/locales/el-GR.js +66 -4
- package/cjs/locales/en-US.js +66 -4
- package/cjs/locales/es-ES.js +66 -4
- package/cjs/locales/fi-FI.js +66 -4
- package/cjs/locales/fr-FR.js +66 -4
- package/cjs/locales/he-IL.js +66 -4
- package/cjs/locales/hu-HU.js +66 -4
- package/cjs/locales/id-ID.js +66 -4
- package/cjs/locales/it-IT.js +66 -4
- package/cjs/locales/ja-JP.js +66 -4
- package/cjs/locales/ko-KR.js +66 -4
- package/cjs/locales/ms-MY.js +66 -4
- package/cjs/locales/nb-NO.js +66 -4
- package/cjs/locales/nl-NL.js +66 -4
- package/cjs/locales/pl-PL.js +66 -4
- package/cjs/locales/pt-BR.js +66 -4
- package/cjs/locales/pt-PT.js +66 -4
- package/cjs/locales/ro-RO.js +66 -4
- package/cjs/locales/ru-RU.js +66 -4
- package/cjs/locales/sv-SE.js +66 -4
- package/cjs/locales/th-TH.js +66 -4
- package/cjs/locales/tl-PH.js +66 -4
- package/cjs/locales/tr-TR.js +66 -4
- package/cjs/locales/uk-UA.js +66 -4
- package/cjs/locales/vi-VN.js +66 -4
- package/cjs/locales/zh-CN.js +66 -4
- package/cjs/locales/zh-TW.js +66 -4
- package/cjs/utils.js +2 -17
- 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 +7632 -3008
- 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 +0 -6
- package/esm/components/Alert/Alert.js +5 -1
- package/esm/components/Button/Button.js +2 -0
- package/esm/components/Carousel/Carousel.js +9 -4
- package/esm/components/ComboBox/ComboBox.js +3 -0
- package/esm/components/ComboBoxDropdown/ComboBoxDropdown.js +4 -1
- package/esm/components/ComboBoxDropdown/index.js +1 -1
- package/esm/components/Dialog/Dialog.js +3 -0
- package/esm/components/Drawer/Header.js +5 -0
- package/esm/components/Dropdown/Dropdown.js +3 -0
- package/esm/components/Form/Form.js +3 -1
- package/esm/components/FormField/FormField.js +9 -5
- package/esm/components/FormFieldPassword/FormFieldPassword.js +9 -11
- package/esm/components/InPlaceEdit/Editor.js +6 -7
- package/esm/components/InPlaceEdit/InPlaceEdit.js +4 -4
- package/esm/components/InputFile/InputFile.js +4 -4
- package/esm/components/InputNumber/InputNumber.js +4 -0
- package/esm/components/Layout/Layout.js +8 -0
- package/esm/components/List/List.js +11 -6
- package/esm/components/List/ListActions.js +5 -0
- package/esm/components/LocaleProvider/LocaleProvider.js +11 -2
- package/esm/components/Menu/MenuItem.js +5 -1
- package/esm/components/Overlay/Overlay.js +2 -1
- package/esm/components/Panel/Panel.js +3 -0
- package/esm/components/Popover/Popover.js +3 -0
- package/esm/components/Section/Section.js +4 -0
- package/esm/components/Select/Select.js +13 -2
- package/esm/components/Select/SelectControl.js +24 -7
- package/esm/components/Spinner/Spinner.js +1 -0
- package/esm/components/SwitchesPanelItem/SwitchesPanelItem.js +3 -0
- package/esm/components/Tabs/SearchBar.js +7 -0
- package/esm/components/Tabs/TabClose.js +3 -0
- package/esm/components/Toast/Toast.js +3 -0
- package/esm/components/Tooltip/Tooltip.js +94 -204
- package/esm/components/Tooltip/TooltipContent.js +75 -0
- package/esm/components/Tooltip/getA11yAttributes.js +23 -0
- package/esm/components/Tooltip/useVirtualElement.js +28 -0
- package/esm/components/utils.js +37 -1
- package/esm/hooks/useEscapeKeydown.js +18 -0
- package/esm/index.js +1 -1
- package/esm/locales/ar.js +66 -4
- package/esm/locales/ca-ES.js +66 -4
- package/esm/locales/cs-CZ.js +66 -4
- package/esm/locales/da-DK.js +66 -4
- package/esm/locales/de-DE.js +66 -4
- package/esm/locales/el-GR.js +66 -4
- package/esm/locales/en-US.js +66 -4
- package/esm/locales/es-ES.js +66 -4
- package/esm/locales/fi-FI.js +66 -4
- package/esm/locales/fr-FR.js +66 -4
- package/esm/locales/he-IL.js +66 -4
- package/esm/locales/hu-HU.js +66 -4
- package/esm/locales/id-ID.js +66 -4
- package/esm/locales/it-IT.js +66 -4
- package/esm/locales/ja-JP.js +66 -4
- package/esm/locales/ko-KR.js +66 -4
- package/esm/locales/ms-MY.js +66 -4
- package/esm/locales/nb-NO.js +66 -4
- package/esm/locales/nl-NL.js +66 -4
- package/esm/locales/pl-PL.js +66 -4
- package/esm/locales/pt-BR.js +66 -4
- package/esm/locales/pt-PT.js +66 -4
- package/esm/locales/ro-RO.js +66 -4
- package/esm/locales/ru-RU.js +66 -4
- package/esm/locales/sv-SE.js +66 -4
- package/esm/locales/th-TH.js +66 -4
- package/esm/locales/tl-PH.js +66 -4
- package/esm/locales/tr-TR.js +66 -4
- package/esm/locales/uk-UA.js +66 -4
- package/esm/locales/vi-VN.js +66 -4
- package/esm/locales/zh-CN.js +66 -4
- package/esm/locales/zh-TW.js +66 -4
- package/esm/utils.js +0 -14
- package/package.json +7 -6
- package/styleguide/build/bundle.1771d6b7.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/components/Button/Button.d.ts +6 -0
- package/types/components/ComboBoxDropdown/ComboBoxDropdown.d.ts +1 -0
- package/types/components/ComboBoxDropdown/index.d.ts +1 -1
- package/types/components/Dropdown/Dropdown.d.ts +5 -0
- package/types/components/Layout/Layout.d.ts +1 -0
- package/types/components/List/ListActions.d.ts +6 -1
- package/types/components/LocaleProvider/LocaleProvider.d.ts +3 -0
- package/types/components/Select/Select.d.ts +4 -0
- package/types/components/Select/SelectControl.d.ts +4 -0
- package/types/components/Tooltip/Tooltip.d.ts +15 -26
- package/types/components/Tooltip/TooltipContent.d.ts +11 -0
- package/types/components/Tooltip/getA11yAttributes.d.ts +19 -0
- package/types/components/Tooltip/useVirtualElement.d.ts +3 -0
- package/types/components/utils.d.ts +8 -1
- package/types/hooks/useEscapeKeydown.d.ts +1 -0
- package/types/utils.d.ts +0 -3
- package/styleguide/build/bundle.cf3363eb.js +0 -2
- /package/styleguide/build/{bundle.cf3363eb.js.LICENSE.txt → bundle.1771d6b7.js.LICENSE.txt} +0 -0
|
@@ -1,215 +1,105 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
3
2
|
|
|
4
|
-
import
|
|
3
|
+
import { useState, useId, useRef, useEffect, cloneElement } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
|
-
import { CLS_PREFIX
|
|
7
|
-
import { wrapFunction } from '../utils';
|
|
8
|
-
import {
|
|
5
|
+
import { CLS_PREFIX } from '../../constants';
|
|
6
|
+
import { wrapFunction, getFocusReturned, isFocusVisible } from '../utils';
|
|
7
|
+
import { TooltipContent } from './TooltipContent';
|
|
8
|
+
import { useVirtualElement } from './useVirtualElement';
|
|
9
|
+
import { getA11yAttributes } from './getA11yAttributes';
|
|
9
10
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const createRectFactory = (width, height) => (left, top) => ({
|
|
11
|
-
top,
|
|
12
|
-
left,
|
|
13
|
-
right: left + width,
|
|
14
|
-
bottom: top + height
|
|
15
|
-
});
|
|
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++}`;
|
|
19
|
-
const determinePosition = _ref => {
|
|
20
|
-
let {
|
|
21
|
-
clientX,
|
|
22
|
-
clientY,
|
|
23
|
-
tooltipWidth,
|
|
24
|
-
tooltipHeight,
|
|
25
|
-
targetRect
|
|
26
|
-
} = _ref;
|
|
27
|
-
const X_EXTRA_SPACE = 8;
|
|
28
|
-
const Y_BOTTOM_EXTRA_SPACE = 16;
|
|
29
|
-
const Y_TOP_EXTRA_SPACE = 8;
|
|
30
|
-
const createTooltipRect = createRectFactory(tooltipWidth, tooltipHeight);
|
|
31
|
-
const viewRect = {
|
|
32
|
-
top: 0,
|
|
33
|
-
left: 0,
|
|
34
|
-
right: document.documentElement.clientWidth,
|
|
35
|
-
bottom: document.documentElement.clientHeight
|
|
36
|
-
};
|
|
37
|
-
const positionFns = [
|
|
38
|
-
// right bottom
|
|
39
|
-
() => ({
|
|
40
|
-
left: clientX + X_EXTRA_SPACE,
|
|
41
|
-
top: clientY + Y_BOTTOM_EXTRA_SPACE
|
|
42
|
-
}),
|
|
43
|
-
// left bottom
|
|
44
|
-
() => ({
|
|
45
|
-
left: clientX - tooltipWidth - X_EXTRA_SPACE,
|
|
46
|
-
top: clientY + Y_BOTTOM_EXTRA_SPACE
|
|
47
|
-
}),
|
|
48
|
-
// center bottom
|
|
49
|
-
() => ({
|
|
50
|
-
left: targetRect.left + (targetRect.right - targetRect.left) / 2 - tooltipWidth / 2,
|
|
51
|
-
top: clientY + Y_BOTTOM_EXTRA_SPACE
|
|
52
|
-
}),
|
|
53
|
-
// right top
|
|
54
|
-
() => ({
|
|
55
|
-
left: clientX + X_EXTRA_SPACE,
|
|
56
|
-
top: clientY - tooltipHeight - Y_TOP_EXTRA_SPACE
|
|
57
|
-
}),
|
|
58
|
-
// left top
|
|
59
|
-
() => ({
|
|
60
|
-
left: clientX - tooltipWidth - Y_TOP_EXTRA_SPACE,
|
|
61
|
-
top: clientY - tooltipHeight - Y_TOP_EXTRA_SPACE
|
|
62
|
-
}),
|
|
63
|
-
// center top
|
|
64
|
-
() => ({
|
|
65
|
-
left: targetRect.left + (targetRect.right - targetRect.left) / 2 - tooltipWidth / 2,
|
|
66
|
-
top: clientY - tooltipHeight - Y_BOTTOM_EXTRA_SPACE
|
|
67
|
-
})];
|
|
68
|
-
for (let i = 0; i < positionFns.length; i++) {
|
|
69
|
-
const fn = positionFns[i];
|
|
70
|
-
const {
|
|
71
|
-
left,
|
|
72
|
-
top
|
|
73
|
-
} = fn();
|
|
74
|
-
const tooltipRect = createTooltipRect(left, top);
|
|
75
|
-
if (isInside(tooltipRect, viewRect)) {
|
|
76
|
-
return {
|
|
77
|
-
left: left + window.pageXOffset,
|
|
78
|
-
top: top + window.pageYOffset
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
top: targetRect.top + Y_BOTTOM_EXTRA_SPACE,
|
|
84
|
-
left: targetRect.left + X_EXTRA_SPACE
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
11
|
/**
|
|
88
12
|
* `Tooltip` component is used for providing information about an interface element
|
|
89
13
|
* while user hovers the pointer over the element.
|
|
90
14
|
* @since 0.0.35
|
|
91
15
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
style,
|
|
169
|
-
delay,
|
|
170
|
-
...props
|
|
171
|
-
} = this.props;
|
|
172
|
-
return /*#__PURE__*/_jsx(Layer, {
|
|
173
|
-
level: Z_INDEX_TOOLTIP,
|
|
174
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
175
|
-
ref: this.tooltipRef,
|
|
176
|
-
id: id,
|
|
177
|
-
className: classNames(baseClassName, className),
|
|
178
|
-
style: {
|
|
179
|
-
...style,
|
|
180
|
-
transform: `translate(${left}px, ${top}px)`,
|
|
181
|
-
visibility: visible ? 'visible' : 'hidden'
|
|
182
|
-
},
|
|
183
|
-
role: "tooltip",
|
|
184
|
-
...props,
|
|
185
|
-
children: title
|
|
16
|
+
const Tooltip = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
title,
|
|
19
|
+
children,
|
|
20
|
+
delay = 550,
|
|
21
|
+
asLabel = false,
|
|
22
|
+
className,
|
|
23
|
+
baseClassName = `${CLS_PREFIX}tooltip`,
|
|
24
|
+
...props
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [ready, setReady] = useState(false);
|
|
27
|
+
const [visible, setVisible] = useState(false);
|
|
28
|
+
const [trigger, setTrigger] = useState(null);
|
|
29
|
+
const id = useId();
|
|
30
|
+
const timer = useRef(null);
|
|
31
|
+
const isPointerDown = useRef(false);
|
|
32
|
+
const clearTimer = () => {
|
|
33
|
+
if (timer.current) {
|
|
34
|
+
clearTimeout(timer.current);
|
|
35
|
+
timer.current = null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
useEffect(() => () => clearTimer(), []);
|
|
39
|
+
const [virtualElement, createVirtualElement, resetVirtualElement] = useVirtualElement();
|
|
40
|
+
const handlePointerMove = e => {
|
|
41
|
+
createVirtualElement(e);
|
|
42
|
+
};
|
|
43
|
+
const handlePointerEnter = e => {
|
|
44
|
+
if (e.pointerType === 'touch') return;
|
|
45
|
+
createVirtualElement(e);
|
|
46
|
+
setReady(true);
|
|
47
|
+
timer.current = setTimeout(() => handleShow(), delay);
|
|
48
|
+
};
|
|
49
|
+
const handleShow = () => {
|
|
50
|
+
clearTimer();
|
|
51
|
+
setVisible(true);
|
|
52
|
+
};
|
|
53
|
+
const handleHide = () => {
|
|
54
|
+
clearTimer();
|
|
55
|
+
setVisible(false);
|
|
56
|
+
setReady(false);
|
|
57
|
+
resetVirtualElement();
|
|
58
|
+
};
|
|
59
|
+
const handlePointerDown = () => {
|
|
60
|
+
handleHide();
|
|
61
|
+
isPointerDown.current = true;
|
|
62
|
+
};
|
|
63
|
+
const handlePointerUp = () => {
|
|
64
|
+
isPointerDown.current = false;
|
|
65
|
+
};
|
|
66
|
+
const handleFocus = e => {
|
|
67
|
+
if (isPointerDown.current) return;
|
|
68
|
+
if (!isFocusVisible(e.target) && !isFocusVisible(e.currentTarget)) return;
|
|
69
|
+
setReady(true);
|
|
70
|
+
setTrigger(e.currentTarget);
|
|
71
|
+
const delay = getFocusReturned(e.target);
|
|
72
|
+
if (delay) {
|
|
73
|
+
timer.current = setTimeout(() => handleShow(), delay);
|
|
74
|
+
} else {
|
|
75
|
+
handleShow();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
79
|
+
children: [/*#__PURE__*/cloneElement(children, {
|
|
80
|
+
onPointerEnter: wrapFunction(children.props.onPointerEnter, handlePointerEnter),
|
|
81
|
+
onPointerMove: wrapFunction(children.props.onPointerMove, handlePointerMove),
|
|
82
|
+
onPointerLeave: wrapFunction(children.props.onPointerLeave, handleHide),
|
|
83
|
+
onPointerUp: wrapFunction(children.props.onPointerUp, handlePointerUp),
|
|
84
|
+
onPointerDown: wrapFunction(children.props.onPointerDown, handlePointerDown),
|
|
85
|
+
onFocus: wrapFunction(children.props.onFocus, handleFocus),
|
|
86
|
+
onBlur: wrapFunction(children.props.onBlur, handleHide),
|
|
87
|
+
...getA11yAttributes({
|
|
88
|
+
asLabel,
|
|
89
|
+
title,
|
|
90
|
+
ready,
|
|
91
|
+
id: props.id ?? id
|
|
186
92
|
})
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
onMouseEnter: wrapFunction(children.props.onMouseEnter, this.handleMouseEnter),
|
|
200
|
-
onMouseMove: wrapFunction(children.props.onMouseMove, this.handleMouseMove),
|
|
201
|
-
onMouseLeave: wrapFunction(children.props.onMouseLeave, this.handleHide),
|
|
202
|
-
onMouseDown: wrapFunction(children.props.onMouseDown, this.handleHide),
|
|
203
|
-
'aria-labelledby': id
|
|
204
|
-
}), ready && this.renderTooltip()]
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
_defineProperty(Tooltip, "defaultProps", {
|
|
209
|
-
// in ms.
|
|
210
|
-
delay: 550,
|
|
211
|
-
style: undefined,
|
|
212
|
-
className: undefined,
|
|
213
|
-
baseClassName: `${CLS_PREFIX}tooltip`
|
|
214
|
-
});
|
|
93
|
+
}), ready && /*#__PURE__*/_jsx(TooltipContent, {
|
|
94
|
+
title: title,
|
|
95
|
+
className: classNames(baseClassName, className),
|
|
96
|
+
...props,
|
|
97
|
+
id: props.id ?? id,
|
|
98
|
+
visible: visible,
|
|
99
|
+
virtualElement: virtualElement,
|
|
100
|
+
trigger: trigger,
|
|
101
|
+
onEscapeKeyDown: handleHide
|
|
102
|
+
})]
|
|
103
|
+
});
|
|
104
|
+
};
|
|
215
105
|
export default Tooltip;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import { useFloating, offset, flip } from '@floating-ui/react-dom';
|
|
4
|
+
import { Z_INDEX_TOOLTIP } from '../../constants';
|
|
5
|
+
import { useEscapeKeydown } from '../../hooks/useEscapeKeydown';
|
|
6
|
+
import Layer from '../Layer';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const isVirtualElement = element => element !== null && !(element instanceof HTMLElement);
|
|
9
|
+
export const TooltipContent = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
title,
|
|
12
|
+
visible,
|
|
13
|
+
virtualElement,
|
|
14
|
+
trigger,
|
|
15
|
+
onEscapeKeyDown,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
id,
|
|
19
|
+
...props
|
|
20
|
+
} = _ref;
|
|
21
|
+
useEscapeKeydown(onEscapeKeyDown);
|
|
22
|
+
const {
|
|
23
|
+
refs,
|
|
24
|
+
floatingStyles
|
|
25
|
+
} = useFloating({
|
|
26
|
+
middleware: [offset(_ref2 => {
|
|
27
|
+
let {
|
|
28
|
+
placement,
|
|
29
|
+
elements
|
|
30
|
+
} = _ref2;
|
|
31
|
+
if (!isVirtualElement(elements.reference)) {
|
|
32
|
+
return {
|
|
33
|
+
mainAxis: 8
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const [side] = placement.split('-');
|
|
37
|
+
return {
|
|
38
|
+
mainAxis: side === 'bottom' ? 16 : 8,
|
|
39
|
+
alignmentAxis: 8
|
|
40
|
+
};
|
|
41
|
+
}), flip(_ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
elements
|
|
44
|
+
} = _ref3;
|
|
45
|
+
let fallbackPlacements = ['bottom-end', 'bottom', 'top-start', 'top-end', 'top'];
|
|
46
|
+
if (!isVirtualElement(elements.reference)) {
|
|
47
|
+
fallbackPlacements = ['top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'right', 'left'];
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
padding: 5,
|
|
51
|
+
fallbackPlacements
|
|
52
|
+
};
|
|
53
|
+
})],
|
|
54
|
+
placement: virtualElement ? 'bottom-start' : 'top',
|
|
55
|
+
elements: {
|
|
56
|
+
reference: virtualElement ? virtualElement : trigger
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return /*#__PURE__*/_jsx(Layer, {
|
|
60
|
+
level: Z_INDEX_TOOLTIP,
|
|
61
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
62
|
+
ref: refs.setFloating,
|
|
63
|
+
id: id,
|
|
64
|
+
className: className,
|
|
65
|
+
style: {
|
|
66
|
+
...style,
|
|
67
|
+
visibility: visible ? 'visible' : 'hidden',
|
|
68
|
+
...floatingStyles
|
|
69
|
+
},
|
|
70
|
+
role: "tooltip",
|
|
71
|
+
...props,
|
|
72
|
+
children: title
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
|
+
|
|
3
|
+
export const getA11yAttributes = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
asLabel,
|
|
6
|
+
title,
|
|
7
|
+
ready,
|
|
8
|
+
id
|
|
9
|
+
} = _ref;
|
|
10
|
+
if (!asLabel) {
|
|
11
|
+
return {
|
|
12
|
+
'aria-describedby': ready ? id : undefined
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (typeof title === 'string') {
|
|
16
|
+
return {
|
|
17
|
+
'aria-label': title
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
'aria-labelledby': ready ? id : undefined
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
export const useVirtualElement = () => {
|
|
5
|
+
const [virtualElement, setVirtualElement] = useState(null);
|
|
6
|
+
const createVirtualElement = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
clientX,
|
|
9
|
+
clientY
|
|
10
|
+
} = _ref;
|
|
11
|
+
setVirtualElement({
|
|
12
|
+
getBoundingClientRect() {
|
|
13
|
+
return {
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0,
|
|
16
|
+
x: clientX,
|
|
17
|
+
y: clientY,
|
|
18
|
+
left: clientX,
|
|
19
|
+
right: clientX,
|
|
20
|
+
top: clientY,
|
|
21
|
+
bottom: clientY
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const resetVirtualElement = () => setVirtualElement(null);
|
|
27
|
+
return [virtualElement, createVirtualElement, resetVirtualElement];
|
|
28
|
+
};
|
package/esm/components/utils.js
CHANGED
|
@@ -199,4 +199,40 @@ export const mergeRefs = function () {
|
|
|
199
199
|
});
|
|
200
200
|
};
|
|
201
201
|
};
|
|
202
|
-
export const normalizeSize = value => String(Number(value)) === String(value) ? `${value}px` : value;
|
|
202
|
+
export const normalizeSize = value => String(Number(value)) === String(value) ? `${value}px` : value;
|
|
203
|
+
export const createKeyboardClickAdapter = function () {
|
|
204
|
+
let {
|
|
205
|
+
existingHandler,
|
|
206
|
+
disabled = false
|
|
207
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
208
|
+
const keyboardHandler = ev => {
|
|
209
|
+
if (disabled) return;
|
|
210
|
+
if (ev.key === 'Enter' || ev.key === ' ') {
|
|
211
|
+
ev.preventDefault();
|
|
212
|
+
ev.currentTarget.click();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
return wrapFunction(existingHandler, keyboardHandler);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/* Mark element as focus returned to avoid animation z-index collisions */
|
|
219
|
+
export const setFocusReturned = function (element) {
|
|
220
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
|
221
|
+
if (document.body === element) return;
|
|
222
|
+
element?.setAttribute('data-pul-focus-returned', duration.toString());
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
element?.removeAttribute('data-pul-focus-returned');
|
|
225
|
+
}, duration);
|
|
226
|
+
};
|
|
227
|
+
export const getFocusReturned = element => {
|
|
228
|
+
const duration = element.getAttribute('data-pul-focus-returned');
|
|
229
|
+
return duration ? parseInt(duration, 10) : 0;
|
|
230
|
+
};
|
|
231
|
+
export const isFocusVisible = element => {
|
|
232
|
+
try {
|
|
233
|
+
return element.matches(':focus-visible');
|
|
234
|
+
} catch {
|
|
235
|
+
/* empty */
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export const useEscapeKeydown = onEscapeKeyDown => {
|
|
3
|
+
const onEscapeKeyDownRef = useRef(onEscapeKeyDown);
|
|
4
|
+
onEscapeKeyDownRef.current = onEscapeKeyDown;
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const handleKeyDown = e => {
|
|
7
|
+
if (e.key === 'Escape') {
|
|
8
|
+
onEscapeKeyDownRef.current?.(e);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
document.addEventListener('keydown', handleKeyDown, {
|
|
12
|
+
capture: true
|
|
13
|
+
});
|
|
14
|
+
return () => document.removeEventListener('keydown', handleKeyDown, {
|
|
15
|
+
capture: true
|
|
16
|
+
});
|
|
17
|
+
}, []);
|
|
18
|
+
};
|
package/esm/index.js
CHANGED
package/esm/locales/ar.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
+
Alert: {
|
|
5
|
+
close: 'Close'
|
|
6
|
+
},
|
|
4
7
|
Card: {
|
|
5
8
|
select: 'تحديد',
|
|
6
9
|
titleLinkTooltip: 'الانتقال إلى الصفحة',
|
|
@@ -16,6 +19,15 @@ export default {
|
|
|
16
19
|
viewList: 'القائمة',
|
|
17
20
|
toolbarView: 'العرض'
|
|
18
21
|
},
|
|
22
|
+
Carousel: {
|
|
23
|
+
nextSlide: 'Next slide',
|
|
24
|
+
previousSlide: 'Previous slide',
|
|
25
|
+
viewSlide: 'View slide %%slideNumber%%'
|
|
26
|
+
},
|
|
27
|
+
ComboBox: {
|
|
28
|
+
close: 'Close',
|
|
29
|
+
open: 'Open'
|
|
30
|
+
},
|
|
19
31
|
ClosingConfirmation: {
|
|
20
32
|
confirm: 'المغادرة',
|
|
21
33
|
cancel: 'العودة',
|
|
@@ -26,8 +38,14 @@ export default {
|
|
|
26
38
|
showLess: 'إظهار أقل'
|
|
27
39
|
},
|
|
28
40
|
Dialog: {
|
|
41
|
+
closeButton: 'Close',
|
|
29
42
|
cancelButton: 'الإلغاء'
|
|
30
43
|
},
|
|
44
|
+
Drawer: {
|
|
45
|
+
backButton: 'Back',
|
|
46
|
+
closeButton: 'Close',
|
|
47
|
+
hideButton: 'Hide'
|
|
48
|
+
},
|
|
31
49
|
DrawerProgress: {
|
|
32
50
|
cancelButton: 'الإلغاء'
|
|
33
51
|
},
|
|
@@ -42,7 +60,8 @@ export default {
|
|
|
42
60
|
FormField: {
|
|
43
61
|
clear: 'مسح التحديد',
|
|
44
62
|
remove: 'الإزالة',
|
|
45
|
-
addMore: 'إضافة حقل إدخال آخر'
|
|
63
|
+
addMore: 'إضافة حقل إدخال آخر',
|
|
64
|
+
showDescription: 'Show description'
|
|
46
65
|
},
|
|
47
66
|
FormFieldPassword: {
|
|
48
67
|
improvePassword: 'لتحسين كلمة مرورك:',
|
|
@@ -71,22 +90,37 @@ export default {
|
|
|
71
90
|
generateButtonHint: 'إنشاء كلمة مرور قوية'
|
|
72
91
|
},
|
|
73
92
|
InPlaceEdit: {
|
|
93
|
+
cancelButtonHint: 'تجاهل التغييرات',
|
|
74
94
|
editButtonHint: 'تحرير القيمة',
|
|
75
|
-
okButtonHint: 'حفظ التغييرات'
|
|
76
|
-
|
|
95
|
+
okButtonHint: 'حفظ التغييرات'
|
|
96
|
+
},
|
|
97
|
+
InputNumber: {
|
|
98
|
+
decrement: 'Decrement',
|
|
99
|
+
increment: 'Increment'
|
|
77
100
|
},
|
|
78
101
|
InputFile: {
|
|
79
102
|
browseButton: 'اختيار ملف...'
|
|
80
103
|
},
|
|
104
|
+
Layout: {
|
|
105
|
+
openSidebar: 'Expand sidebar',
|
|
106
|
+
closeSidebar: 'Collapse sidebar'
|
|
107
|
+
},
|
|
81
108
|
List: {
|
|
82
109
|
totalRows: '%%totalRows%% عناصر إجمالًا',
|
|
110
|
+
toggleAllRows: 'Toggle all rows',
|
|
111
|
+
toggleRow: 'Toggle row',
|
|
83
112
|
selectedRows: 'تم تحديد %%selectedRows%% عناصر من أصل %%totalRows%%',
|
|
84
113
|
all: 'الكل',
|
|
85
114
|
allItemsOnPageSelected: 'تم تحديد جميع العناصر الموجودة في الصفحة',
|
|
86
115
|
allItemsSelected: 'تم تحديد جميع العناصر',
|
|
87
116
|
selectAllItems: 'تحديد جميع العناصر',
|
|
88
117
|
selectAllItemsOnPage: 'تحديد جميع العناصر الموجودة في الصفحة',
|
|
89
|
-
deselectAll: 'إلغاء التحديد'
|
|
118
|
+
deselectAll: 'إلغاء التحديد',
|
|
119
|
+
selectRow: 'Select row',
|
|
120
|
+
selectAllRows: 'Select all rows'
|
|
121
|
+
},
|
|
122
|
+
ListActions: {
|
|
123
|
+
menuButton: 'Open menu'
|
|
90
124
|
},
|
|
91
125
|
ListEmptyView: {
|
|
92
126
|
filteredTitle: 'تعذر العثور على أي عناصر مطابقة لعامل التصفية',
|
|
@@ -96,24 +130,52 @@ export default {
|
|
|
96
130
|
ListOperation: {
|
|
97
131
|
cancelButton: 'الإلغاء'
|
|
98
132
|
},
|
|
133
|
+
Panel: {
|
|
134
|
+
collapse: 'Collapse',
|
|
135
|
+
expand: 'Expand'
|
|
136
|
+
},
|
|
99
137
|
Pagination: {
|
|
100
138
|
totalShort: 'من %%total%%',
|
|
101
139
|
itemsPerPage: 'عدد العناصر في كل صفحة',
|
|
102
140
|
all: 'الكل',
|
|
103
141
|
total: 'صفحة %%current%% من %%total%%'
|
|
104
142
|
},
|
|
143
|
+
Popover: {
|
|
144
|
+
closeButton: 'Close'
|
|
145
|
+
},
|
|
105
146
|
ProgressDialog: {
|
|
106
147
|
closeButton: 'الإغلاق',
|
|
107
148
|
cancelButton: 'الإلغاء'
|
|
108
149
|
},
|
|
150
|
+
Section: {
|
|
151
|
+
collapse: 'Collapse',
|
|
152
|
+
closeButton: 'Close',
|
|
153
|
+
expand: 'Expand'
|
|
154
|
+
},
|
|
109
155
|
Select: {
|
|
156
|
+
clearButton: 'Clear',
|
|
110
157
|
noOptions: 'لا توجد خيارات',
|
|
111
158
|
placeholder: 'تحديد...'
|
|
112
159
|
},
|
|
160
|
+
SearchBar: {
|
|
161
|
+
clearButton: 'Clear',
|
|
162
|
+
searchButton: 'Search',
|
|
163
|
+
collapseSearch: 'Hide search input',
|
|
164
|
+
expandSearch: 'Show search input'
|
|
165
|
+
},
|
|
113
166
|
SpotPopup: {
|
|
114
167
|
total: '%%current%% من %%total%%'
|
|
115
168
|
},
|
|
169
|
+
SwitchesPanelItem: {
|
|
170
|
+
showDescription: 'Show description'
|
|
171
|
+
},
|
|
172
|
+
Tabs: {
|
|
173
|
+
closeButton: 'Close tab'
|
|
174
|
+
},
|
|
116
175
|
Toaster: {
|
|
117
176
|
closeGroup: 'إغلاق المجموعة'
|
|
177
|
+
},
|
|
178
|
+
Toast: {
|
|
179
|
+
closeButton: 'Close'
|
|
118
180
|
}
|
|
119
181
|
};
|