@sydsoft/base 1.58.0 → 1.59.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 +11 -0
- package/dist/esm/_lib/baseFunctions.js +97 -0
- package/dist/esm/_lib/inputMask.d.ts +7 -0
- package/dist/esm/_lib/inputMask.js +229 -0
- package/dist/esm/_lib/listFunctions.d.ts +2 -0
- package/dist/esm/_lib/listFunctions.js +114 -0
- package/dist/esm/_lib/storage/cookies.d.ts +4 -0
- package/dist/esm/_lib/storage/cookies.js +34 -0
- package/dist/esm/_lib/storage/encData.d.ts +2 -0
- package/dist/esm/_lib/storage/encData.js +43 -0
- package/dist/esm/_lib/storage/localStorage.d.ts +6 -0
- package/dist/esm/_lib/storage/localStorage.js +69 -0
- package/dist/esm/_lib/storage/sessionStorage.d.ts +6 -0
- package/dist/esm/_lib/storage/sessionStorage.js +69 -0
- package/dist/esm/_lib/useInterval.d.ts +6 -0
- package/dist/esm/_lib/useInterval.js +24 -0
- package/dist/esm/alert/index.d.ts +18 -0
- package/dist/esm/alert/index.js +107 -0
- package/dist/esm/alert/index.module.css +119 -0
- package/dist/esm/box/Box.d.ts +9 -0
- package/dist/esm/box/Box.js +15 -0
- package/dist/esm/box/Box.module.css +153 -0
- package/dist/esm/box/BoxContent.d.ts +9 -0
- package/dist/esm/box/BoxContent.js +7 -0
- package/dist/esm/box/BoxFooter.d.ts +10 -0
- package/dist/esm/box/BoxFooter.js +8 -0
- package/dist/esm/box/BoxHeader.d.ts +16 -0
- package/dist/esm/box/BoxHeader.js +9 -0
- package/dist/esm/box/index.d.ts +9 -0
- package/dist/esm/box/index.js +9 -0
- package/dist/esm/countDown/index.d.ts +22 -0
- package/dist/esm/countDown/index.js +97 -0
- package/dist/esm/dateTime/index.d.ts +12 -0
- package/dist/esm/dateTime/index.js +76 -0
- package/dist/esm/form/Button.d.ts +27 -0
- package/dist/esm/form/Button.js +76 -0
- package/dist/esm/form/Checkbox.d.ts +23 -0
- package/dist/esm/form/Checkbox.js +23 -0
- package/dist/esm/form/Dialog.d.ts +20 -0
- package/dist/esm/form/Dialog.js +40 -0
- package/dist/esm/form/Form.d.ts +10 -0
- package/dist/esm/form/Form.js +12 -0
- package/dist/esm/form/FormOlustur.d.ts +39 -0
- package/dist/esm/form/FormOlustur.js +52 -0
- package/dist/esm/form/Input.d.ts +66 -0
- package/dist/esm/form/Input.js +196 -0
- package/dist/esm/form/Label.d.ts +7 -0
- package/dist/esm/form/Label.js +9 -0
- package/dist/esm/form/SearchableInput.d.ts +37 -0
- package/dist/esm/form/SearchableInput.js +272 -0
- package/dist/esm/form/UploadBase.d.ts +25 -0
- package/dist/esm/form/UploadBase.js +86 -0
- package/dist/esm/form/index.d.ts +9 -0
- package/dist/esm/form/index.js +9 -0
- package/dist/esm/form/styles/Button.module.css +145 -0
- package/dist/esm/form/styles/Input.module.css +221 -0
- package/dist/esm/form/styles/Label.module.css +31 -0
- package/dist/esm/form/styles/SearchableInput.module.css +80 -0
- package/dist/esm/grid/index.d.ts +38 -0
- package/dist/esm/grid/index.js +97 -0
- package/dist/esm/grid/index.module.css +805 -0
- package/dist/esm/icon/icons.d.ts +22 -0
- package/dist/esm/icon/icons.js +23 -0
- package/dist/esm/icon/index.d.ts +34 -0
- package/dist/esm/icon/index.js +26 -0
- package/dist/esm/icon/mui.d.ts +1 -0
- package/dist/esm/icon/mui.js +1 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/menu/index.d.ts +69 -0
- package/dist/esm/menu/index.js +52 -0
- package/dist/esm/menu/index.module.css +92 -0
- package/dist/esm/modal/index.d.ts +23 -0
- package/dist/esm/modal/index.js +66 -0
- package/dist/esm/modal/index.module.css +77 -0
- package/dist/esm/popover/index.d.ts +26 -0
- package/dist/esm/popover/index.js +343 -0
- package/dist/esm/popover/index.module.css +89 -0
- package/dist/esm/tooltip/index.d.ts +11 -0
- package/dist/esm/tooltip/index.js +119 -0
- package/package.json +7 -7
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* @author : izzetseydaoglu
|
|
5
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
6
|
+
* @version : 2026-02-07 19:31:01
|
|
7
|
+
*/
|
|
8
|
+
import React, { memo, useMemo } from 'react';
|
|
9
|
+
import { Dialog } from '../form';
|
|
10
|
+
import { Popover } from '../popover';
|
|
11
|
+
import Link from 'next/link';
|
|
12
|
+
import styles from './index.module.css';
|
|
13
|
+
export var Menu = memo(function MemoFunction(_a) {
|
|
14
|
+
var menu = _a.menu, className = _a.className, style = _a.style, _b = _a.withIcon, withIcon = _b === void 0 ? 'auto' : _b;
|
|
15
|
+
var withIconComponent = useMemo(function () {
|
|
16
|
+
if (withIcon === true)
|
|
17
|
+
return true;
|
|
18
|
+
if (withIcon === false)
|
|
19
|
+
return false;
|
|
20
|
+
return Object.values(menu).some(function (item) { return 'icon' in item && !!item.icon; });
|
|
21
|
+
}, [menu, withIcon]);
|
|
22
|
+
var withRightComponent = useMemo(function () {
|
|
23
|
+
return Object.values(menu).some(function (item) { return 'rightComponent' in item && !!item.rightComponent; });
|
|
24
|
+
}, [menu]);
|
|
25
|
+
var handleClick = function (item, e) {
|
|
26
|
+
if (!item.onClick)
|
|
27
|
+
return;
|
|
28
|
+
if (item.dialog) {
|
|
29
|
+
Dialog(__assign({}, item.dialog)).then(function (result) {
|
|
30
|
+
if (result && item.onClick) {
|
|
31
|
+
item.onClick(e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
item.onClick(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return (_jsx("ul", { className: "smenu ".concat(styles.ul, " ").concat(className || ''), style: style, children: Object.values(menu).map(function (item, key) {
|
|
40
|
+
var _a = item, fullComponent = _a.fullComponent, icon = _a.icon, title = _a.title, rightComponent = _a.rightComponent, seperator = _a.seperator, href = _a.href, style = _a.style, itemProps = _a.itemProps, type = _a.type, items = _a.items, menuProps = _a.menuProps, subMenuPopoverProps = _a.subMenuPopoverProps, other = __rest(_a, ["fullComponent", "icon", "title", "rightComponent", "seperator", "href", "style", "itemProps", "type", "items", "menuProps", "subMenuPopoverProps"]);
|
|
41
|
+
var hasSubmenu = type === 'submenu' && Array.isArray(items) && items.length > 0;
|
|
42
|
+
if (fullComponent)
|
|
43
|
+
return React.cloneElement(fullComponent, { key: key });
|
|
44
|
+
if (seperator)
|
|
45
|
+
return _jsx("li", __assign({ className: styles.seperator, style: style }, itemProps, other), key);
|
|
46
|
+
var Component = (_jsxs(_Fragment, { children: [withIconComponent && _jsx("div", { className: styles.menuicon, children: icon }), _jsx("div", { className: styles.menutitle, children: title }), withRightComponent && _jsx("div", { className: styles.rightmenu, children: rightComponent })] }));
|
|
47
|
+
if (hasSubmenu) {
|
|
48
|
+
return (_jsx(Popover, __assign({ component: _jsx("li", __assign({ style: style }, itemProps, other, { children: Component })), position: "right-top" }, (subMenuPopoverProps || {}), { children: _jsx(Menu, __assign({ menu: items }, (menuProps || {}))) }), key));
|
|
49
|
+
}
|
|
50
|
+
return (_jsx("li", __assign({ style: style, onClick: function (e) { return handleClick(item, e); } }, itemProps, other, { children: href ? _jsx(Link, { href: href, children: Component }) : Component }), key));
|
|
51
|
+
}) }));
|
|
52
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.ul {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
max-height: calc(100vh - 94px);
|
|
5
|
+
list-style: none;
|
|
6
|
+
padding: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
background: #fff;
|
|
9
|
+
letter-spacing: 0.2px;
|
|
10
|
+
outline: none;
|
|
11
|
+
border: 1px solid transparent;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
box-shadow: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
|
|
14
|
+
overflow-y: auto;
|
|
15
|
+
user-select: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ul > li {
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
padding: 2px 6px;
|
|
21
|
+
min-height: 25px;
|
|
22
|
+
}
|
|
23
|
+
.ul > li,
|
|
24
|
+
.ul > li a {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: row;
|
|
27
|
+
flex-wrap: nowrap;
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
.ul > li a,
|
|
31
|
+
.ul > li a:visited {
|
|
32
|
+
color: inherit;
|
|
33
|
+
text-decoration: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ul > li:first-child {
|
|
37
|
+
margin-top: 5px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ul > li:last-child {
|
|
41
|
+
margin-bottom: 5px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ul > li:hover {
|
|
45
|
+
background: #f0f2f5;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ul > li:global(.spopover_active) {
|
|
49
|
+
background: #e8f0fe;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.menuicon {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
width: 30px;
|
|
56
|
+
flex: 0 0 auto;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
color: #606060;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.menutitle {
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
flex: 1;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: flex-start;
|
|
67
|
+
margin: 0 10px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.rightmenu {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
flex: 0 0 auto;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
color: #909090;
|
|
76
|
+
font-size: 12px;
|
|
77
|
+
width: 50px;
|
|
78
|
+
}
|
|
79
|
+
.rightmenu span {
|
|
80
|
+
user-select: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.seperator {
|
|
84
|
+
cursor: default !important;
|
|
85
|
+
background: #00000014 !important;
|
|
86
|
+
border: 0;
|
|
87
|
+
height: 1px;
|
|
88
|
+
min-height: 1px !important;
|
|
89
|
+
margin: 4px 0;
|
|
90
|
+
padding: 0 !important;
|
|
91
|
+
display: block !important;
|
|
92
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023
|
|
3
|
+
* @author: izzetseydaoglu
|
|
4
|
+
* @last-modified: 9.02.2024 06:07
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
interface Props {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
open: boolean;
|
|
10
|
+
close?: Function;
|
|
11
|
+
keepMounted?: boolean;
|
|
12
|
+
hideBackdrop?: boolean;
|
|
13
|
+
hideEsc?: boolean;
|
|
14
|
+
hideCloseButton?: boolean;
|
|
15
|
+
fullScreen?: boolean;
|
|
16
|
+
modalStyle?: React.CSSProperties;
|
|
17
|
+
backdropStyle?: React.CSSProperties;
|
|
18
|
+
vertialAlign?: "flex-start" | "center" | "flex-end";
|
|
19
|
+
horizontalAlign?: "flex-start" | "center" | "flex-end";
|
|
20
|
+
refModal?: any;
|
|
21
|
+
}
|
|
22
|
+
export declare const Modal: React.NamedExoticComponent<Props>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2023
|
|
5
|
+
* @author: izzetseydaoglu
|
|
6
|
+
* @last-modified: 9.02.2024 06:07
|
|
7
|
+
*/
|
|
8
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
9
|
+
import ReactDOM from "react-dom";
|
|
10
|
+
import styles from "./index.module.css";
|
|
11
|
+
export var Modal = memo(function MemoFunction(_a) {
|
|
12
|
+
var _b = _a.refModal, refModal = _b === void 0 ? null : _b, children = _a.children, _c = _a.open, open = _c === void 0 ? false : _c, close = _a.close, _d = _a.keepMounted, keepMounted = _d === void 0 ? false : _d, _e = _a.fullScreen, fullScreen = _e === void 0 ? false : _e, _f = _a.hideBackdrop, hideBackdrop = _f === void 0 ? true : _f, _g = _a.hideEsc, hideEsc = _g === void 0 ? false : _g, _h = _a.hideCloseButton, hideCloseButton = _h === void 0 ? false : _h, modalStyle = _a.modalStyle, backdropStyle = _a.backdropStyle, _j = _a.vertialAlign, vertialAlign = _j === void 0 ? "center" : _j, _k = _a.horizontalAlign, horizontalAlign = _k === void 0 ? "center" : _k;
|
|
13
|
+
var _l = useState(null), modalDiv = _l[0], setModalDiv = _l[1];
|
|
14
|
+
var ref = useRef(null);
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
if (refModal)
|
|
17
|
+
refModal.current = ref.current;
|
|
18
|
+
}, [ref.current]);
|
|
19
|
+
var onClose = function () {
|
|
20
|
+
if (close)
|
|
21
|
+
close();
|
|
22
|
+
};
|
|
23
|
+
var checkHideBackDrop = function (e) {
|
|
24
|
+
if (open && ref.current && !ref.current.contains(e.target))
|
|
25
|
+
onClose();
|
|
26
|
+
};
|
|
27
|
+
var checkESC = function (e) {
|
|
28
|
+
if (e.keyCode === 27 || e.key === "Escape" || e.code === "Escape")
|
|
29
|
+
onClose();
|
|
30
|
+
};
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
if (open) {
|
|
33
|
+
if (hideBackdrop)
|
|
34
|
+
window.addEventListener("mousedown", checkHideBackDrop);
|
|
35
|
+
if (hideEsc)
|
|
36
|
+
window.addEventListener("keydown", checkESC);
|
|
37
|
+
}
|
|
38
|
+
return function () {
|
|
39
|
+
if (hideBackdrop)
|
|
40
|
+
window.removeEventListener("mousedown", checkHideBackDrop);
|
|
41
|
+
if (hideEsc)
|
|
42
|
+
window.removeEventListener("keydown", checkESC);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (!modalDiv) {
|
|
47
|
+
var modalDivCheck = document.getElementById("smodal");
|
|
48
|
+
if (modalDivCheck) {
|
|
49
|
+
setModalDiv(modalDivCheck);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
var div = document.createElement("div");
|
|
53
|
+
div.setAttribute("id", "smodal");
|
|
54
|
+
document.body.appendChild(div);
|
|
55
|
+
setModalDiv(div);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return function () {
|
|
59
|
+
onClose();
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
if ((!keepMounted && !open) || typeof window === "undefined")
|
|
63
|
+
return null;
|
|
64
|
+
var Component = (_jsx("div", { className: "".concat(styles.backdrop, " ").concat(open ? styles.backdrop_open : ""), style: __assign({ alignItems: vertialAlign, justifyContent: horizontalAlign }, backdropStyle), children: _jsxs("div", { ref: ref, className: "smodal ".concat(styles.modal, " ").concat(fullScreen ? styles.fullscreen : ""), style: modalStyle, children: [!hideCloseButton && (_jsx("div", { className: "close ".concat(styles.close_fixed), children: _jsx("div", { className: styles.close, onClick: onClose, children: "\u2715" }) })), children] }) }));
|
|
65
|
+
return modalDiv ? ReactDOM.createPortal(Component, modalDiv) : null;
|
|
66
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
.backdrop {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 1300;
|
|
4
|
+
inset: 0;
|
|
5
|
+
display: none;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
background: rgba(0, 0, 0, 0.23);
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
outline: none;
|
|
12
|
+
}
|
|
13
|
+
.backdrop_open {
|
|
14
|
+
display: flex !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.modal {
|
|
18
|
+
position: relative;
|
|
19
|
+
min-width: 200px;
|
|
20
|
+
max-width: 90%;
|
|
21
|
+
max-height: calc(100% - 64px);
|
|
22
|
+
overflow-x: hidden;
|
|
23
|
+
border-radius: 8px;
|
|
24
|
+
background: transparent;
|
|
25
|
+
box-shadow:
|
|
26
|
+
rgb(0 0 0 / 32%) 0 4px 8px,
|
|
27
|
+
rgb(0 0 0 / 40%) 0 8px 40px;
|
|
28
|
+
margin: 15px;
|
|
29
|
+
padding: 0;
|
|
30
|
+
z-index: 1;
|
|
31
|
+
outline: none;
|
|
32
|
+
}
|
|
33
|
+
.fullscreen {
|
|
34
|
+
width: 100vw;
|
|
35
|
+
max-width: 100vw;
|
|
36
|
+
height: 100vh;
|
|
37
|
+
max-height: 100vh;
|
|
38
|
+
border-radius: 0;
|
|
39
|
+
margin: 0;
|
|
40
|
+
}
|
|
41
|
+
.close_fixed {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 2px;
|
|
44
|
+
right: 2px;
|
|
45
|
+
z-index: 1000;
|
|
46
|
+
text-align: right;
|
|
47
|
+
border-radius: inherit;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.close {
|
|
51
|
+
position: fixed;
|
|
52
|
+
background: linear-gradient(0deg, transparent, #00000026, transparent);
|
|
53
|
+
padding: 8px 10px;
|
|
54
|
+
font-size: 11px;
|
|
55
|
+
transform: scale(1) translateX(-100%);
|
|
56
|
+
border-radius: none;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
font-weight: bold;
|
|
59
|
+
text-shadow: 1px 0px 0px #000000;
|
|
60
|
+
transition: all 0.3s ease-in-out;
|
|
61
|
+
}
|
|
62
|
+
.close:hover {
|
|
63
|
+
transform: scale(1.3) translateX(-85%);
|
|
64
|
+
background: linear-gradient(180deg, transparent, #0000003a, transparent);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sbox_header {
|
|
68
|
+
position: sticky;
|
|
69
|
+
top: 0;
|
|
70
|
+
z-index: 10;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sbox_footer {
|
|
74
|
+
position: sticky;
|
|
75
|
+
bottom: 0;
|
|
76
|
+
z-index: 10;
|
|
77
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author : izzetseydaoglu
|
|
3
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
4
|
+
* @version : 2026-02-10 16:12:35
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
type PopoverPosition = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-top' | 'left-center' | 'left-bottom' | 'right' | 'right-top' | 'right-center' | 'right-bottom';
|
|
8
|
+
type ArrowColor = 'auto' | string;
|
|
9
|
+
export interface PopoverConfigBaseProps {
|
|
10
|
+
position?: PopoverPosition;
|
|
11
|
+
removeWhenClickInside?: boolean;
|
|
12
|
+
hideBackdrop?: boolean;
|
|
13
|
+
arrow?: boolean;
|
|
14
|
+
distance?: number;
|
|
15
|
+
fade?: boolean;
|
|
16
|
+
arrowColor?: ArrowColor;
|
|
17
|
+
hover?: boolean;
|
|
18
|
+
hoverCloseDelay?: number;
|
|
19
|
+
keepMounted?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface PopoverProps extends PopoverConfigBaseProps {
|
|
22
|
+
component: any;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
export declare const Popover: React.NamedExoticComponent<PopoverProps>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author : izzetseydaoglu
|
|
3
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
4
|
+
* @version : 2026-02-10 16:12:35
|
|
5
|
+
*/
|
|
6
|
+
import { __assign, __rest } from "tslib";
|
|
7
|
+
import { cloneElement, memo, useEffect, useRef } from 'react';
|
|
8
|
+
import { createRoot } from 'react-dom/client';
|
|
9
|
+
import styles from './index.module.css';
|
|
10
|
+
export var Popover = memo(function MemoFunction(_a) {
|
|
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);
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
if (typeof window === 'undefined')
|
|
20
|
+
return;
|
|
21
|
+
return function () {
|
|
22
|
+
popoverSil(false);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
var checkHideBackDrop = function (e) {
|
|
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))
|
|
34
|
+
popoverSil();
|
|
35
|
+
};
|
|
36
|
+
var popoverEkle = function (e) {
|
|
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;
|
|
68
|
+
document.body.appendChild(popover);
|
|
69
|
+
// ReactDOM.render(children, popover)
|
|
70
|
+
var root = createRoot(popover);
|
|
71
|
+
root.render(children);
|
|
72
|
+
popoverRef.current = popover;
|
|
73
|
+
rootRef.current = root;
|
|
74
|
+
var target = e.currentTarget;
|
|
75
|
+
refComponent.current && refComponent.current.classList.add('spopover_active');
|
|
76
|
+
setTimeout(function () {
|
|
77
|
+
var _a;
|
|
78
|
+
applyArrowColor(popover);
|
|
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);
|
|
82
|
+
}, 100);
|
|
83
|
+
if (hideBackdrop) {
|
|
84
|
+
window.addEventListener('mousedown', checkHideBackDrop);
|
|
85
|
+
window.addEventListener('blur', checkHideBackDrop);
|
|
86
|
+
}
|
|
87
|
+
if (removeWhenClickInside)
|
|
88
|
+
popover.addEventListener('mouseup', popoverGecikmeliSil);
|
|
89
|
+
if (hover) {
|
|
90
|
+
popover.addEventListener('mouseenter', clearHoverClose);
|
|
91
|
+
popover.addEventListener('mouseleave', scheduleHoverClose);
|
|
92
|
+
}
|
|
93
|
+
incrementBodyPopover();
|
|
94
|
+
};
|
|
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));
|
|
100
|
+
if (check) {
|
|
101
|
+
if (removeWhenClickInside)
|
|
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);
|
|
148
|
+
}
|
|
149
|
+
if (wasVisible)
|
|
150
|
+
decrementBodyPopover();
|
|
151
|
+
};
|
|
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
|
+
};
|
|
162
|
+
var popoverPosition = function (_a) {
|
|
163
|
+
var target = _a.target, position = _a.position;
|
|
164
|
+
var popover = popoverRef.current;
|
|
165
|
+
if (popover) {
|
|
166
|
+
var arrowMargin = arrow ? 5 : 0;
|
|
167
|
+
var margin = distance + arrowMargin;
|
|
168
|
+
var _b = normalizePosition(position), preferredSide = _b.side, preferredAlign = _b.align;
|
|
169
|
+
var targetPosition = target.getBoundingClientRect();
|
|
170
|
+
var popoverPosition_1 = popover.getBoundingClientRect();
|
|
171
|
+
var style = [];
|
|
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');
|
|
194
|
+
}
|
|
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');
|
|
199
|
+
}
|
|
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);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
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);
|
|
270
|
+
});
|
|
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
|
+
};
|