@sydsoft/base 1.43.0 → 1.47.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/dist/esm/_lib/baseFunctions.d.ts +1 -0
- package/dist/esm/_lib/baseFunctions.js +4 -0
- package/dist/esm/_lib/inputMask.js +2 -1
- package/dist/esm/_lib/storage/encData.d.ts +2 -2
- package/dist/esm/_lib/storage/encData.js +15 -10
- package/dist/esm/form/Dialog.d.ts +7 -6
- package/dist/esm/form/Dialog.js +13 -13
- package/dist/esm/form/Input.d.ts +12 -7
- package/dist/esm/form/Input.js +17 -27
- package/dist/esm/form/Label.d.ts +1 -1
- package/dist/esm/form/Label.js +6 -9
- package/dist/esm/form/SearchableInput.d.ts +2 -2
- package/dist/esm/form/SearchableInput.js +45 -23
- package/dist/esm/icon/index.js +7 -4
- package/dist/esm/menu/index.d.ts +30 -4
- package/dist/esm/menu/index.js +30 -10
- package/dist/esm/menu/index.module.css +51 -26
- package/dist/esm/modal/index.module.css +12 -11
- package/dist/esm/popover/index.d.ts +21 -7
- package/dist/esm/popover/index.js +306 -105
- package/dist/esm/popover/index.module.css +89 -0
- package/package.json +1 -1
|
@@ -1,142 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author : izzetseydaoglu
|
|
3
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
4
|
+
* @version : 2026-02-10 16:12:35
|
|
5
|
+
*/
|
|
1
6
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import
|
|
3
|
-
import { createRoot } from
|
|
7
|
+
import { cloneElement, memo, useEffect, useRef } from 'react';
|
|
8
|
+
import { createRoot } from 'react-dom/client';
|
|
9
|
+
import styles from './index.module.css';
|
|
4
10
|
export var Popover = memo(function MemoFunction(_a) {
|
|
5
|
-
|
|
6
|
-
var
|
|
11
|
+
var children = _a.children, component = _a.component, _b = _a.position, position = _b === void 0 ? 'top' : _b, _c = _a.arrow, arrow = _c === void 0 ? false : _c, _d = _a.distance, distance = _d === void 0 ? 5 : _d, _e = _a.removeWhenClickInside, removeWhenClickInside = _e === void 0 ? false : _e, _f = _a.hideBackdrop, hideBackdrop = _f === void 0 ? true : _f, _g = _a.fade, fade = _g === void 0 ? true : _g, _h = _a.arrowColor, arrowColor = _h === void 0 ? 'auto' : _h, _j = _a.hover, hover = _j === void 0 ? false : _j, _k = _a.hoverCloseDelay, hoverCloseDelay = _k === void 0 ? 120 : _k, _l = _a.keepMounted, keepMounted = _l === void 0 ? false : _l, other = __rest(_a, ["children", "component", "position", "arrow", "distance", "removeWhenClickInside", "hideBackdrop", "fade", "arrowColor", "hover", "hoverCloseDelay", "keepMounted"]);
|
|
12
|
+
var refComponent = useRef(null);
|
|
13
|
+
var closeTimer = useRef(null);
|
|
14
|
+
var hoverCloseTimer = useRef(null);
|
|
15
|
+
var popoverRef = useRef(null);
|
|
16
|
+
var rootRef = useRef(null);
|
|
17
|
+
var zIndexRef = useRef(null);
|
|
7
18
|
useEffect(function () {
|
|
8
|
-
if (typeof window ===
|
|
9
|
-
return
|
|
10
|
-
var cssCheck = document.getElementsByClassName("spopover_css")[0];
|
|
11
|
-
if (!cssCheck) {
|
|
12
|
-
var head = document.getElementsByTagName("head")[0];
|
|
13
|
-
var s = document.createElement("style");
|
|
14
|
-
s.setAttribute("type", "text/css");
|
|
15
|
-
s.classList.add("spopover_css");
|
|
16
|
-
s.appendChild(document.createTextNode(popoverCss));
|
|
17
|
-
head.appendChild(s);
|
|
18
|
-
}
|
|
19
|
+
if (typeof window === 'undefined')
|
|
20
|
+
return;
|
|
19
21
|
return function () {
|
|
20
|
-
popoverSil();
|
|
22
|
+
popoverSil(false);
|
|
21
23
|
};
|
|
22
24
|
}, []);
|
|
23
25
|
var checkHideBackDrop = function (e) {
|
|
24
|
-
var spopover =
|
|
25
|
-
if (
|
|
26
|
+
var spopover = popoverRef.current;
|
|
27
|
+
if (!spopover)
|
|
28
|
+
return;
|
|
29
|
+
if (!((e === null || e === void 0 ? void 0 : e.target) instanceof Node)) {
|
|
30
|
+
popoverSil();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!spopover.contains(e.target))
|
|
26
34
|
popoverSil();
|
|
27
35
|
};
|
|
28
36
|
var popoverEkle = function (e) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (popoverRef.current && keepMounted) {
|
|
39
|
+
var popover_1 = popoverRef.current;
|
|
40
|
+
var target_1 = e.currentTarget;
|
|
41
|
+
var wasVisible = popover_1.classList.contains(styles.visible);
|
|
42
|
+
(_b = (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.render) === null || _b === void 0 ? void 0 : _b.call(_a, children);
|
|
43
|
+
applyArrowColor(popover_1);
|
|
44
|
+
popoverPosition({ target: target_1, position: position });
|
|
45
|
+
popover_1.style.zIndex = String(nextPopoverZIndex());
|
|
46
|
+
popover_1.classList.remove(styles.closing);
|
|
47
|
+
popover_1.classList.add(styles.visible);
|
|
48
|
+
if (!wasVisible) {
|
|
49
|
+
if (hideBackdrop) {
|
|
50
|
+
window.addEventListener('mousedown', checkHideBackDrop);
|
|
51
|
+
window.addEventListener('blur', checkHideBackDrop);
|
|
52
|
+
}
|
|
53
|
+
if (removeWhenClickInside)
|
|
54
|
+
popover_1.addEventListener('mouseup', popoverGecikmeliSil);
|
|
55
|
+
if (hover) {
|
|
56
|
+
popover_1.addEventListener('mouseenter', clearHoverClose);
|
|
57
|
+
popover_1.addEventListener('mouseleave', scheduleHoverClose);
|
|
58
|
+
}
|
|
59
|
+
incrementBodyPopover();
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
popoverSil(false);
|
|
64
|
+
var popover = document.createElement('div');
|
|
65
|
+
popover.classList.add('spopover', styles.popover);
|
|
66
|
+
var zIndex = nextPopoverZIndex();
|
|
67
|
+
zIndexRef.current = zIndex;
|
|
32
68
|
document.body.appendChild(popover);
|
|
33
69
|
// ReactDOM.render(children, popover)
|
|
34
|
-
var root = createRoot(popover);
|
|
70
|
+
var root = createRoot(popover);
|
|
35
71
|
root.render(children);
|
|
72
|
+
popoverRef.current = popover;
|
|
73
|
+
rootRef.current = root;
|
|
36
74
|
var target = e.currentTarget;
|
|
75
|
+
refComponent.current && refComponent.current.classList.add('spopover_active');
|
|
37
76
|
setTimeout(function () {
|
|
77
|
+
var _a;
|
|
78
|
+
applyArrowColor(popover);
|
|
38
79
|
popoverPosition({ target: target, position: position });
|
|
80
|
+
popover.style.zIndex = String((_a = zIndexRef.current) !== null && _a !== void 0 ? _a : zIndex);
|
|
81
|
+
popover.classList.add(styles.visible);
|
|
39
82
|
}, 100);
|
|
40
|
-
|
|
83
|
+
if (hideBackdrop) {
|
|
84
|
+
window.addEventListener('mousedown', checkHideBackDrop);
|
|
85
|
+
window.addEventListener('blur', checkHideBackDrop);
|
|
86
|
+
}
|
|
41
87
|
if (removeWhenClickInside)
|
|
42
|
-
popover.addEventListener(
|
|
43
|
-
|
|
88
|
+
popover.addEventListener('mouseup', popoverGecikmeliSil);
|
|
89
|
+
if (hover) {
|
|
90
|
+
popover.addEventListener('mouseenter', clearHoverClose);
|
|
91
|
+
popover.addEventListener('mouseleave', scheduleHoverClose);
|
|
92
|
+
}
|
|
93
|
+
incrementBodyPopover();
|
|
44
94
|
};
|
|
45
|
-
var popoverSil = function () {
|
|
46
|
-
|
|
95
|
+
var popoverSil = function (animate) {
|
|
96
|
+
if (animate === void 0) { animate = true; }
|
|
97
|
+
refComponent.current && refComponent.current.classList.remove('spopover_active');
|
|
98
|
+
var check = popoverRef.current;
|
|
99
|
+
var wasVisible = !!(check === null || check === void 0 ? void 0 : check.classList.contains(styles.visible));
|
|
47
100
|
if (check) {
|
|
48
101
|
if (removeWhenClickInside)
|
|
49
|
-
check.removeEventListener(
|
|
50
|
-
|
|
102
|
+
check.removeEventListener('mouseup', popoverGecikmeliSil);
|
|
103
|
+
if (hover) {
|
|
104
|
+
check.removeEventListener('mouseenter', clearHoverClose);
|
|
105
|
+
check.removeEventListener('mouseleave', scheduleHoverClose);
|
|
106
|
+
}
|
|
107
|
+
if (closeTimer.current)
|
|
108
|
+
window.clearTimeout(closeTimer.current);
|
|
109
|
+
if (hoverCloseTimer.current)
|
|
110
|
+
window.clearTimeout(hoverCloseTimer.current);
|
|
111
|
+
if (!fade || !animate) {
|
|
112
|
+
if (!keepMounted) {
|
|
113
|
+
var root_1 = rootRef.current;
|
|
114
|
+
window.setTimeout(function () {
|
|
115
|
+
var _a;
|
|
116
|
+
(_a = root_1 === null || root_1 === void 0 ? void 0 : root_1.unmount) === null || _a === void 0 ? void 0 : _a.call(root_1);
|
|
117
|
+
}, 0);
|
|
118
|
+
check.remove();
|
|
119
|
+
popoverRef.current = null;
|
|
120
|
+
rootRef.current = null;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
check.classList.remove(styles.visible);
|
|
124
|
+
check.classList.remove(styles.closing);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (!check.classList.contains(styles.closing)) {
|
|
128
|
+
check.classList.add(styles.closing);
|
|
129
|
+
closeTimer.current = window.setTimeout(function () {
|
|
130
|
+
var _a;
|
|
131
|
+
if (!keepMounted) {
|
|
132
|
+
var root = rootRef.current;
|
|
133
|
+
(_a = root === null || root === void 0 ? void 0 : root.unmount) === null || _a === void 0 ? void 0 : _a.call(root);
|
|
134
|
+
check.remove();
|
|
135
|
+
popoverRef.current = null;
|
|
136
|
+
rootRef.current = null;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
check.classList.remove(styles.visible);
|
|
140
|
+
check.classList.remove(styles.closing);
|
|
141
|
+
}
|
|
142
|
+
}, FADE_DURATION);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (hideBackdrop) {
|
|
146
|
+
window.removeEventListener('mousedown', checkHideBackDrop);
|
|
147
|
+
window.removeEventListener('blur', checkHideBackDrop);
|
|
51
148
|
}
|
|
52
|
-
|
|
53
|
-
|
|
149
|
+
if (wasVisible)
|
|
150
|
+
decrementBodyPopover();
|
|
54
151
|
};
|
|
55
152
|
var popoverGecikmeliSil = function () { return setTimeout(function () { return popoverSil(); }, 100); };
|
|
153
|
+
var clearHoverClose = function () {
|
|
154
|
+
if (hoverCloseTimer.current)
|
|
155
|
+
window.clearTimeout(hoverCloseTimer.current);
|
|
156
|
+
hoverCloseTimer.current = null;
|
|
157
|
+
};
|
|
158
|
+
var scheduleHoverClose = function () {
|
|
159
|
+
clearHoverClose();
|
|
160
|
+
hoverCloseTimer.current = window.setTimeout(function () { return popoverSil(); }, hoverCloseDelay);
|
|
161
|
+
};
|
|
56
162
|
var popoverPosition = function (_a) {
|
|
57
163
|
var target = _a.target, position = _a.position;
|
|
58
|
-
var popover =
|
|
164
|
+
var popover = popoverRef.current;
|
|
59
165
|
if (popover) {
|
|
60
166
|
var arrowMargin = arrow ? 5 : 0;
|
|
61
167
|
var margin = distance + arrowMargin;
|
|
62
|
-
|
|
63
|
-
popover.classList.add("arrow");
|
|
168
|
+
var _b = normalizePosition(position), preferredSide = _b.side, preferredAlign = _b.align;
|
|
64
169
|
var targetPosition = target.getBoundingClientRect();
|
|
65
170
|
var popoverPosition_1 = popover.getBoundingClientRect();
|
|
66
171
|
var style = [];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
style.push("left:2px");
|
|
90
|
-
popover.classList.add("start");
|
|
91
|
-
}
|
|
92
|
-
else if (targetPosition.left + targetPosition.width / 2 + popoverPosition_1.width > window.innerWidth) {
|
|
93
|
-
style.push("right:2px");
|
|
94
|
-
popover.classList.add("end");
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
style.push("left:" + (targetPosition.left + targetPosition.width / 2) + "px");
|
|
98
|
-
style.push("transform:translate(-50%,0)");
|
|
99
|
-
popover.classList.add("center");
|
|
100
|
-
}
|
|
172
|
+
var side = preferredSide;
|
|
173
|
+
if (side === 'top' && targetPosition.top - popoverPosition_1.height - margin < 0)
|
|
174
|
+
side = 'bottom';
|
|
175
|
+
if (side === 'bottom' && targetPosition.bottom + popoverPosition_1.height + margin > window.innerHeight)
|
|
176
|
+
side = 'top';
|
|
177
|
+
if (side === 'left' && targetPosition.left - popoverPosition_1.width - margin < 0)
|
|
178
|
+
side = 'right';
|
|
179
|
+
if (side === 'right' && targetPosition.right + popoverPosition_1.width + margin > window.innerWidth)
|
|
180
|
+
side = 'left';
|
|
181
|
+
if (side === 'top')
|
|
182
|
+
style.push('top:' + (targetPosition.top - popoverPosition_1.height - margin) + 'px');
|
|
183
|
+
if (side === 'bottom')
|
|
184
|
+
style.push('top:' + (targetPosition.bottom + margin) + 'px');
|
|
185
|
+
if (side === 'left')
|
|
186
|
+
style.push('left:' + (targetPosition.left - popoverPosition_1.width - margin) + 'px');
|
|
187
|
+
if (side === 'right')
|
|
188
|
+
style.push('left:' + (targetPosition.right + margin) + 'px');
|
|
189
|
+
var alignClass = 'center';
|
|
190
|
+
if (side === 'top' || side === 'bottom') {
|
|
191
|
+
var _c = resolveHorizontalAlign(preferredAlign, targetPosition, popoverPosition_1), left = _c.left, resolvedAlign = _c.alignClass;
|
|
192
|
+
alignClass = resolvedAlign;
|
|
193
|
+
style.push('left:' + left + 'px');
|
|
101
194
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
popover.classList.add("right");
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
style.push("left:" + (targetPosition.left - popoverPosition_1.width - margin) + "px");
|
|
110
|
-
popover.classList.add("left");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (position === "right") {
|
|
114
|
-
if (targetPosition.left + targetPosition.width / 2 + popoverPosition_1.width + margin > window.innerWidth) {
|
|
115
|
-
style.push("left:" + (targetPosition.left - popoverPosition_1.width - margin) + "px");
|
|
116
|
-
popover.classList.add("left");
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
style.push("left:" + (targetPosition.right + margin) + "px");
|
|
120
|
-
popover.classList.add("right");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (targetPosition.top + targetPosition.height / 2 - popoverPosition_1.height / 2 < 0) {
|
|
124
|
-
style.push("top:2px");
|
|
125
|
-
popover.classList.add("start");
|
|
126
|
-
}
|
|
127
|
-
else if (targetPosition.top + targetPosition.height / 2 + popoverPosition_1.height / 2 > window.innerHeight) {
|
|
128
|
-
style.push("bottom:2px");
|
|
129
|
-
popover.classList.add("end");
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
style.push("top:" + (targetPosition.top + targetPosition.height / 2) + "px");
|
|
133
|
-
style.push("transform:translate(0,-50%)");
|
|
134
|
-
popover.classList.add("center");
|
|
135
|
-
}
|
|
195
|
+
else {
|
|
196
|
+
var _d = resolveVerticalAlign(preferredAlign, targetPosition, popoverPosition_1), top_1 = _d.top, resolvedAlign = _d.alignClass;
|
|
197
|
+
alignClass = resolvedAlign;
|
|
198
|
+
style.push('top:' + top_1 + 'px');
|
|
136
199
|
}
|
|
137
|
-
popover.
|
|
200
|
+
var classNames = ['spopover', styles.popover, arrow ? styles.arrow : '', fade ? '' : styles.noFade, sideClass[side], alignClassMap[alignClass]].filter(Boolean);
|
|
201
|
+
popover.className = classNames.join(' ');
|
|
202
|
+
popover.setAttribute('style', style.join(';'));
|
|
203
|
+
applyArrowColor(popover);
|
|
138
204
|
}
|
|
139
205
|
};
|
|
140
|
-
|
|
206
|
+
function applyArrowColor(popoverEl) {
|
|
207
|
+
var _a;
|
|
208
|
+
if (!arrowColor) {
|
|
209
|
+
popoverEl.style.removeProperty('--popover-arrow-color');
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (arrowColor === 'auto') {
|
|
213
|
+
var targetEl = (_a = popoverEl.firstElementChild) !== null && _a !== void 0 ? _a : popoverEl;
|
|
214
|
+
var bg = window.getComputedStyle(targetEl).backgroundColor;
|
|
215
|
+
if (bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent') {
|
|
216
|
+
var parent_1 = targetEl.parentElement;
|
|
217
|
+
if (parent_1)
|
|
218
|
+
bg = window.getComputedStyle(parent_1).backgroundColor;
|
|
219
|
+
}
|
|
220
|
+
if (bg)
|
|
221
|
+
popoverEl.style.setProperty('--popover-arrow-color', bg);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
popoverEl.style.setProperty('--popover-arrow-color', arrowColor);
|
|
225
|
+
}
|
|
226
|
+
function incrementBodyPopover() {
|
|
227
|
+
var body = document.body;
|
|
228
|
+
var count = Number(body.dataset.spopoverCount || '0') + 1;
|
|
229
|
+
body.dataset.spopoverCount = String(count);
|
|
230
|
+
if (count > 0)
|
|
231
|
+
body.classList.add('spopover_open');
|
|
232
|
+
}
|
|
233
|
+
function decrementBodyPopover() {
|
|
234
|
+
var body = document.body;
|
|
235
|
+
var count = Math.max(0, Number(body.dataset.spopoverCount || '0') - 1);
|
|
236
|
+
if (count === 0) {
|
|
237
|
+
delete body.dataset.spopoverCount;
|
|
238
|
+
body.classList.remove('spopover_open');
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
body.dataset.spopoverCount = String(count);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function nextPopoverZIndex() {
|
|
245
|
+
var body = document.body;
|
|
246
|
+
var current = Number(body.dataset.spopoverZIndex || '10000');
|
|
247
|
+
var next = current + 1;
|
|
248
|
+
body.dataset.spopoverZIndex = String(next);
|
|
249
|
+
return next;
|
|
250
|
+
}
|
|
251
|
+
var componentProps = __assign({ ref: refComponent, onClick: function (e) {
|
|
252
|
+
var _a, _b;
|
|
253
|
+
(_b = (_a = component.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
254
|
+
popoverEkle(e);
|
|
255
|
+
} }, other);
|
|
256
|
+
if (hover) {
|
|
257
|
+
componentProps.onMouseEnter = function (e) {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
(_b = (_a = component.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
260
|
+
clearHoverClose();
|
|
261
|
+
popoverEkle(e);
|
|
262
|
+
};
|
|
263
|
+
componentProps.onMouseLeave = function (e) {
|
|
264
|
+
var _a, _b;
|
|
265
|
+
(_b = (_a = component.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
266
|
+
scheduleHoverClose();
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
return cloneElement(component, componentProps);
|
|
141
270
|
});
|
|
142
|
-
var
|
|
271
|
+
var sideClass = {
|
|
272
|
+
top: styles.top,
|
|
273
|
+
bottom: styles.bottom,
|
|
274
|
+
left: styles.left,
|
|
275
|
+
right: styles.right
|
|
276
|
+
};
|
|
277
|
+
var alignClassMap = {
|
|
278
|
+
start: styles.alignStart,
|
|
279
|
+
center: styles.alignCenter,
|
|
280
|
+
end: styles.alignEnd
|
|
281
|
+
};
|
|
282
|
+
var FADE_DURATION = 160;
|
|
283
|
+
var normalizePosition = function (position) {
|
|
284
|
+
var _a = position.split('-'), side = _a[0], rawAlign = _a[1];
|
|
285
|
+
if (side === 'top' || side === 'bottom') {
|
|
286
|
+
var align_1 = rawAlign === 'left' || rawAlign === 'right' ? rawAlign : 'center';
|
|
287
|
+
return { side: side, align: align_1 };
|
|
288
|
+
}
|
|
289
|
+
var align = rawAlign === 'top' || rawAlign === 'bottom' ? rawAlign : 'center';
|
|
290
|
+
return { side: side, align: align };
|
|
291
|
+
};
|
|
292
|
+
var resolveHorizontalAlign = function (align, target, popover) {
|
|
293
|
+
var clamp = 2;
|
|
294
|
+
var left = 0;
|
|
295
|
+
var alignClass = 'center';
|
|
296
|
+
if (align === 'left') {
|
|
297
|
+
left = target.left;
|
|
298
|
+
alignClass = 'start';
|
|
299
|
+
}
|
|
300
|
+
else if (align === 'right') {
|
|
301
|
+
left = target.right - popover.width;
|
|
302
|
+
alignClass = 'end';
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
left = target.left + target.width / 2 - popover.width / 2;
|
|
306
|
+
alignClass = 'center';
|
|
307
|
+
}
|
|
308
|
+
if (left < clamp) {
|
|
309
|
+
left = clamp;
|
|
310
|
+
alignClass = 'start';
|
|
311
|
+
}
|
|
312
|
+
else if (left + popover.width > window.innerWidth - clamp) {
|
|
313
|
+
left = window.innerWidth - popover.width - clamp;
|
|
314
|
+
alignClass = 'end';
|
|
315
|
+
}
|
|
316
|
+
return { left: left, alignClass: alignClass };
|
|
317
|
+
};
|
|
318
|
+
var resolveVerticalAlign = function (align, target, popover) {
|
|
319
|
+
var clamp = 2;
|
|
320
|
+
var top = 0;
|
|
321
|
+
var alignClass = 'center';
|
|
322
|
+
if (align === 'top') {
|
|
323
|
+
top = target.top;
|
|
324
|
+
alignClass = 'start';
|
|
325
|
+
}
|
|
326
|
+
else if (align === 'bottom') {
|
|
327
|
+
top = target.bottom - popover.height;
|
|
328
|
+
alignClass = 'end';
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
top = target.top + target.height / 2 - popover.height / 2;
|
|
332
|
+
alignClass = 'center';
|
|
333
|
+
}
|
|
334
|
+
if (top < clamp) {
|
|
335
|
+
top = clamp;
|
|
336
|
+
alignClass = 'start';
|
|
337
|
+
}
|
|
338
|
+
else if (top + popover.height > window.innerHeight - clamp) {
|
|
339
|
+
top = window.innerHeight - popover.height - clamp;
|
|
340
|
+
alignClass = 'end';
|
|
341
|
+
}
|
|
342
|
+
return { top: top, alignClass: alignClass };
|
|
343
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.popover {
|
|
2
|
+
position: fixed;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
z-index: 10000;
|
|
7
|
+
opacity: 0;
|
|
8
|
+
visibility: hidden;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
transition: opacity 160ms ease;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.noFade {
|
|
14
|
+
transition: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.visible {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
visibility: visible;
|
|
20
|
+
pointer-events: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.closing {
|
|
24
|
+
opacity: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.arrow::after {
|
|
28
|
+
content: "";
|
|
29
|
+
position: absolute;
|
|
30
|
+
border-width: 5px;
|
|
31
|
+
border-style: solid;
|
|
32
|
+
width: 0;
|
|
33
|
+
height: 0;
|
|
34
|
+
border-color: var(--popover-arrow-color, #757575);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.arrow.top::after {
|
|
38
|
+
top: 100%;
|
|
39
|
+
border-color: var(--popover-arrow-color, #757575) transparent transparent transparent;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.arrow.bottom::after {
|
|
43
|
+
bottom: 100%;
|
|
44
|
+
border-color: transparent transparent var(--popover-arrow-color, #757575) transparent;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.arrow.left::after {
|
|
48
|
+
left: 100%;
|
|
49
|
+
margin-left: -1px;
|
|
50
|
+
border-color: transparent transparent transparent var(--popover-arrow-color, #757575);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.arrow.right::after {
|
|
54
|
+
right: 100%;
|
|
55
|
+
margin-right: -1px;
|
|
56
|
+
border-color: transparent var(--popover-arrow-color, #757575) transparent transparent;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.arrow.top.alignStart::after,
|
|
60
|
+
.arrow.bottom.alignStart::after {
|
|
61
|
+
left: 12px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.arrow.top.alignCenter::after,
|
|
65
|
+
.arrow.bottom.alignCenter::after {
|
|
66
|
+
left: 50%;
|
|
67
|
+
transform: translateX(-50%);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.arrow.top.alignEnd::after,
|
|
71
|
+
.arrow.bottom.alignEnd::after {
|
|
72
|
+
right: 12px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.arrow.left.alignStart::after,
|
|
76
|
+
.arrow.right.alignStart::after {
|
|
77
|
+
top: 12px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.arrow.left.alignCenter::after,
|
|
81
|
+
.arrow.right.alignCenter::after {
|
|
82
|
+
top: 50%;
|
|
83
|
+
transform: translateY(-50%);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.arrow.left.alignEnd::after,
|
|
87
|
+
.arrow.right.alignEnd::after {
|
|
88
|
+
bottom: 12px;
|
|
89
|
+
}
|