@sydsoft/base 1.47.0 → 1.49.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.
Files changed (151) hide show
  1. package/README.md +8 -1
  2. package/{dist/esm → _dist}/_lib/baseFunctions.d.ts +0 -1
  3. package/{dist/esm → _dist}/_lib/baseFunctions.js +25 -38
  4. package/{dist/esm → _dist}/_lib/inputMask.js +66 -69
  5. package/{dist/esm → _dist}/_lib/listFunctions.js +12 -13
  6. package/_dist/_lib/storage/cookies.d.ts +4 -0
  7. package/_dist/_lib/storage/cookies.js +33 -0
  8. package/_dist/_lib/storage/encData.js +41 -0
  9. package/{dist/esm → _dist}/_lib/storage/localStorage.js +10 -10
  10. package/{dist/esm → _dist}/_lib/storage/sessionStorage.js +10 -10
  11. package/{dist/esm → _dist}/_lib/useInterval.js +5 -5
  12. package/{dist/esm → _dist}/alert/index.js +28 -30
  13. package/_dist/box/Box.js +14 -0
  14. package/_dist/box/BoxContent.js +5 -0
  15. package/_dist/box/BoxFooter.js +10 -0
  16. package/_dist/box/BoxHeader.js +10 -0
  17. package/_dist/countDown/index.js +92 -0
  18. package/{dist/esm → _dist}/dateTime/index.js +25 -31
  19. package/_dist/form/Button.js +82 -0
  20. package/_dist/form/Checkbox.js +22 -0
  21. package/_dist/form/Dialog.js +53 -0
  22. package/_dist/form/Form.js +10 -0
  23. package/_dist/form/FormOlustur.js +50 -0
  24. package/{dist/esm → _dist}/form/Input.js +57 -56
  25. package/_dist/form/Label.js +7 -0
  26. package/{dist/esm → _dist}/form/SearchableInput.d.ts +0 -1
  27. package/_dist/form/SearchableInput.js +260 -0
  28. package/_dist/form/UploadBase.js +84 -0
  29. package/_dist/grid/index.js +96 -0
  30. package/{dist/esm → _dist}/icon/icons.js +1 -1
  31. package/{dist/esm → _dist}/icon/index.d.ts +1 -1
  32. package/_dist/icon/index.js +34 -0
  33. package/_dist/menu/index.js +50 -0
  34. package/_dist/modal/index.js +64 -0
  35. package/{dist/esm → _dist}/popover/index.js +100 -100
  36. package/_dist/tooltip/index.js +202 -0
  37. package/_lib/baseFunctions.ts +94 -0
  38. package/_lib/inputMask.ts +257 -0
  39. package/_lib/listFunctions.ts +106 -0
  40. package/_lib/storage/cookies.ts +39 -0
  41. package/_lib/storage/encData.ts +41 -0
  42. package/_lib/storage/localStorage.ts +67 -0
  43. package/_lib/storage/sessionStorage.ts +67 -0
  44. package/_lib/useInterval.ts +30 -0
  45. package/alert/index.module.css +119 -0
  46. package/alert/index.tsx +131 -0
  47. package/box/Box.module.css +153 -0
  48. package/box/Box.tsx +33 -0
  49. package/box/BoxContent.tsx +18 -0
  50. package/box/BoxFooter.tsx +25 -0
  51. package/box/BoxHeader.tsx +46 -0
  52. package/box/index.ts +10 -0
  53. package/countDown/index.tsx +116 -0
  54. package/dateTime/index.ts +79 -0
  55. package/form/Button.tsx +143 -0
  56. package/form/Checkbox.tsx +48 -0
  57. package/form/Dialog.tsx +109 -0
  58. package/form/Form.tsx +19 -0
  59. package/form/FormOlustur.tsx +105 -0
  60. package/form/Input.tsx +364 -0
  61. package/form/Label.tsx +20 -0
  62. package/form/SearchableInput.tsx +406 -0
  63. package/form/UploadBase.tsx +133 -0
  64. package/form/index.ts +10 -0
  65. package/form/styles/Button.module.css +145 -0
  66. package/form/styles/Input.module.css +221 -0
  67. package/form/styles/Label.module.css +31 -0
  68. package/form/styles/SearchableInput.module.css +80 -0
  69. package/global.d.ts +9 -0
  70. package/grid/index.module.css +805 -0
  71. package/grid/index.tsx +171 -0
  72. package/icon/icons.tsx +33 -0
  73. package/icon/index.tsx +95 -0
  74. package/icon/mui.tsx +5932 -0
  75. package/index.ts +21 -0
  76. package/menu/index.module.css +92 -0
  77. package/menu/index.tsx +143 -0
  78. package/modal/index.module.css +77 -0
  79. package/modal/index.tsx +106 -0
  80. package/npm_recovery_codes.txt +5 -0
  81. package/package.json +18 -11
  82. package/popover/index.module.css +89 -0
  83. package/popover/index.tsx +392 -0
  84. package/tooltip/index.tsx +216 -0
  85. package/tsconfig.json +24 -0
  86. package/dist/esm/_lib/storage/cookies.d.ts +0 -4
  87. package/dist/esm/_lib/storage/cookies.js +0 -34
  88. package/dist/esm/_lib/storage/encData.js +0 -43
  89. package/dist/esm/box/Box.js +0 -15
  90. package/dist/esm/box/BoxContent.js +0 -7
  91. package/dist/esm/box/BoxFooter.js +0 -8
  92. package/dist/esm/box/BoxHeader.js +0 -9
  93. package/dist/esm/countDown/index.js +0 -97
  94. package/dist/esm/form/Button.js +0 -76
  95. package/dist/esm/form/Checkbox.js +0 -23
  96. package/dist/esm/form/Dialog.js +0 -40
  97. package/dist/esm/form/Form.js +0 -12
  98. package/dist/esm/form/FormOlustur.js +0 -52
  99. package/dist/esm/form/Label.js +0 -9
  100. package/dist/esm/form/SearchableInput.js +0 -272
  101. package/dist/esm/form/UploadBase.js +0 -86
  102. package/dist/esm/grid/index.js +0 -97
  103. package/dist/esm/icon/index.js +0 -26
  104. package/dist/esm/menu/index.js +0 -52
  105. package/dist/esm/modal/index.js +0 -66
  106. package/dist/esm/tooltip/index.js +0 -119
  107. /package/{dist/esm → _dist}/_lib/inputMask.d.ts +0 -0
  108. /package/{dist/esm → _dist}/_lib/listFunctions.d.ts +0 -0
  109. /package/{dist/esm → _dist}/_lib/storage/encData.d.ts +0 -0
  110. /package/{dist/esm → _dist}/_lib/storage/localStorage.d.ts +0 -0
  111. /package/{dist/esm → _dist}/_lib/storage/sessionStorage.d.ts +0 -0
  112. /package/{dist/esm → _dist}/_lib/useInterval.d.ts +0 -0
  113. /package/{dist/esm → _dist}/alert/index.d.ts +0 -0
  114. /package/{dist/esm → _dist}/alert/index.module.css +0 -0
  115. /package/{dist/esm → _dist}/box/Box.d.ts +0 -0
  116. /package/{dist/esm → _dist}/box/Box.module.css +0 -0
  117. /package/{dist/esm → _dist}/box/BoxContent.d.ts +0 -0
  118. /package/{dist/esm → _dist}/box/BoxFooter.d.ts +0 -0
  119. /package/{dist/esm → _dist}/box/BoxHeader.d.ts +0 -0
  120. /package/{dist/esm → _dist}/box/index.d.ts +0 -0
  121. /package/{dist/esm → _dist}/box/index.js +0 -0
  122. /package/{dist/esm → _dist}/countDown/index.d.ts +0 -0
  123. /package/{dist/esm → _dist}/dateTime/index.d.ts +0 -0
  124. /package/{dist/esm → _dist}/form/Button.d.ts +0 -0
  125. /package/{dist/esm → _dist}/form/Checkbox.d.ts +0 -0
  126. /package/{dist/esm → _dist}/form/Dialog.d.ts +0 -0
  127. /package/{dist/esm → _dist}/form/Form.d.ts +0 -0
  128. /package/{dist/esm → _dist}/form/FormOlustur.d.ts +0 -0
  129. /package/{dist/esm → _dist}/form/Input.d.ts +0 -0
  130. /package/{dist/esm → _dist}/form/Label.d.ts +0 -0
  131. /package/{dist/esm → _dist}/form/UploadBase.d.ts +0 -0
  132. /package/{dist/esm → _dist}/form/index.d.ts +0 -0
  133. /package/{dist/esm → _dist}/form/index.js +0 -0
  134. /package/{dist/esm → _dist}/form/styles/Button.module.css +0 -0
  135. /package/{dist/esm → _dist}/form/styles/Input.module.css +0 -0
  136. /package/{dist/esm → _dist}/form/styles/Label.module.css +0 -0
  137. /package/{dist/esm → _dist}/form/styles/SearchableInput.module.css +0 -0
  138. /package/{dist/esm → _dist}/grid/index.d.ts +0 -0
  139. /package/{dist/esm → _dist}/grid/index.module.css +0 -0
  140. /package/{dist/esm → _dist}/icon/icons.d.ts +0 -0
  141. /package/{dist/esm → _dist}/icon/mui.d.ts +0 -0
  142. /package/{dist/esm → _dist}/icon/mui.js +0 -0
  143. /package/{dist/esm → _dist}/index.d.ts +0 -0
  144. /package/{dist/esm → _dist}/index.js +0 -0
  145. /package/{dist/esm → _dist}/menu/index.d.ts +0 -0
  146. /package/{dist/esm → _dist}/menu/index.module.css +0 -0
  147. /package/{dist/esm → _dist}/modal/index.d.ts +0 -0
  148. /package/{dist/esm → _dist}/modal/index.module.css +0 -0
  149. /package/{dist/esm → _dist}/popover/index.d.ts +0 -0
  150. /package/{dist/esm → _dist}/popover/index.module.css +0 -0
  151. /package/{dist/esm → _dist}/tooltip/index.d.ts +0 -0
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useState } from 'react';
3
+ import styles from './index.module.css';
4
+ export const Row = ({ children, className = '', style, flexDirection = 'row', flexWrap = 'wrap', justifyContent = 'flex-start', alignContent = 'center', alignItems = 'center', rowSpacing = 2, colSpacing = 2, ...other }) => {
5
+ const classes = [
6
+ styles.row,
7
+ rowSpacing !== undefined && styles[`row-spacing-${rowSpacing}`],
8
+ colSpacing !== undefined && styles[`col-spacing-${colSpacing}`],
9
+ flexDirection !== 'row' && styles[`flex-${flexDirection.replace('-', '-')}`],
10
+ flexWrap !== 'wrap' && styles[`flex-${flexWrap}`],
11
+ justifyContent !== 'flex-start' && styles[`justify-${justifyContent.replace('flex-', '').replace('space-', '')}`],
12
+ alignItems !== 'center' && styles[`align-items-${alignItems.replace('flex-', '')}`],
13
+ alignContent !== 'center' && styles[`align-content-${alignContent.replace('flex-', '')}`],
14
+ className
15
+ ]
16
+ .filter(Boolean)
17
+ .join(' ');
18
+ return (_jsx("div", { className: classes, style: style, ...other, children: children }));
19
+ };
20
+ export const Col = ({ children, className = '', style, xs, sm, md, lg, xl, xxl, ...other }) => {
21
+ // Cascading logic - aynı sizin component'inizdeki gibi
22
+ const classes = [
23
+ styles.col,
24
+ // Sadece belirtilen breakpoint'ler için class ekle
25
+ xs && styles[`col-xs-${xs}`],
26
+ sm && styles[`col-sm-${sm}`],
27
+ md && styles[`col-md-${md}`],
28
+ lg && styles[`col-lg-${lg}`],
29
+ xl && styles[`col-xl-${xl}`],
30
+ xxl && styles[`col-xxl-${xxl}`],
31
+ className
32
+ ]
33
+ .filter(Boolean)
34
+ .join(' ');
35
+ return (_jsx("div", { className: classes, style: style, ...other, children: children }));
36
+ };
37
+ export const Hidden = ({ children, hidden, onlyHidden, ...other }) => {
38
+ const existingClassName = children.props.className || '';
39
+ const hiddenClasses = [];
40
+ if (onlyHidden) {
41
+ onlyHidden.forEach((breakpoint) => {
42
+ hiddenClasses.push(styles[`hidden-${breakpoint}`]);
43
+ });
44
+ }
45
+ else if (hidden) {
46
+ // Orijinal mantık: seçilen breakpoint ve altındaki tüm breakpoint'ler gizlenir
47
+ const breakpoints = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
48
+ const targetIndex = breakpoints.indexOf(hidden);
49
+ if (targetIndex !== -1) {
50
+ for (let i = 0; i <= targetIndex; i++) {
51
+ hiddenClasses.push(styles[`hidden-${breakpoints[i]}`]);
52
+ }
53
+ }
54
+ }
55
+ const newClassName = [existingClassName, ...hiddenClasses].filter(Boolean).join(' ');
56
+ return React.cloneElement(children, {
57
+ className: newClassName,
58
+ ...other
59
+ });
60
+ };
61
+ export const DevelopGridComponent = () => {
62
+ const [currentBreakpoint, setCurrentBreakpoint] = useState('');
63
+ // Breakpoint detector
64
+ React.useEffect(() => {
65
+ const updateBreakpoint = () => {
66
+ const width = window.innerWidth;
67
+ let breakpoint = '';
68
+ if (width <= 576)
69
+ breakpoint = 'XS (≤576px)';
70
+ else if (width <= 768)
71
+ breakpoint = 'SM (577-768px)';
72
+ else if (width <= 992)
73
+ breakpoint = 'MD (769-992px)';
74
+ else if (width <= 1200)
75
+ breakpoint = 'LG (993-1200px)';
76
+ else if (width <= 1400)
77
+ breakpoint = 'XL (1201-1400px)';
78
+ else
79
+ breakpoint = 'XXL (≥1401px)';
80
+ setCurrentBreakpoint(breakpoint);
81
+ };
82
+ updateBreakpoint();
83
+ window.addEventListener('resize', updateBreakpoint);
84
+ return () => window.removeEventListener('resize', updateBreakpoint);
85
+ }, []);
86
+ return (_jsxs("div", { style: {
87
+ position: 'fixed',
88
+ bottom: '10px',
89
+ right: '10px',
90
+ background: '#333',
91
+ color: 'white',
92
+ padding: '10px',
93
+ borderRadius: '4px',
94
+ zIndex: 9999999
95
+ }, children: ["Current: ", currentBreakpoint] }));
96
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- export var iconMap = {
2
+ export const iconMap = {
3
3
  close: {
4
4
  viewBox: '0 -960 960 960',
5
5
  content: (_jsx(_Fragment, { children: _jsx("path", { d: "m336-280-56-56 144-144-144-143 56-56 144 144 143-144 56 56-144 143 144 144-56 56-143-144-144 144Z" }) }))
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { iconMap } from './icons';
3
3
  import { MaterialIconName } from './mui';
4
- export declare const iconList: ("search" | "close" | "edit" | "keyboard_arrow_down" | "keyboard_arrow_up")[];
4
+ export declare const iconList: IconName[];
5
5
  export type IconName = keyof typeof iconMap;
6
6
  interface BaseProps {
7
7
  color?: string;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { iconMap } from './icons';
3
+ export const iconList = Object.keys(iconMap);
4
+ const defaultIconStyle = {
5
+ userSelect: 'none',
6
+ width: '1em',
7
+ height: '1em',
8
+ // display: 'inline-block',
9
+ verticalAlign: 'middle',
10
+ flexShrink: 0,
11
+ display: 'flex',
12
+ alignItems: 'center',
13
+ justifyContent: 'center'
14
+ };
15
+ export const Icon = ({ name, iconMui, customIcon, fontSize, color, className, style, ...other }) => {
16
+ if (iconMui) {
17
+ return (_jsx("span", { className: `material-icons ${className || ''}`, style: {
18
+ ...defaultIconStyle,
19
+ ...style,
20
+ fontSize: fontSize || '1.3rem',
21
+ color: color || 'inherit'
22
+ }, "aria-hidden": "true", ...other, children: iconMui }));
23
+ }
24
+ const iconComponent = name ? iconMap[name] : customIcon;
25
+ if (!iconComponent) {
26
+ return _jsx("span", { children: "\u26A0\uFE0F" });
27
+ }
28
+ return (_jsx("span", { className: className, style: {
29
+ ...defaultIconStyle,
30
+ ...style,
31
+ fontSize: fontSize || '1.5rem',
32
+ color: color || 'inherit'
33
+ }, ...other, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: iconComponent.viewBox, fill: 'currentColor', width: "1em", height: "1em", style: { display: 'block', flexShrink: 0 }, children: iconComponent.content }) }));
34
+ };
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @author : izzetseydaoglu
4
+ * @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
5
+ * @version : 2026-02-07 19:31:01
6
+ */
7
+ import React, { memo, useMemo } from 'react';
8
+ import { Dialog } from '../form';
9
+ import { Popover } from '../popover';
10
+ import Link from 'next/link';
11
+ import styles from './index.module.css';
12
+ export const Menu = memo(function MemoFunction({ menu, className, style, withIcon = 'auto' }) {
13
+ const withIconComponent = useMemo(() => {
14
+ if (withIcon === true)
15
+ return true;
16
+ if (withIcon === false)
17
+ return false;
18
+ return Object.values(menu).some((item) => 'icon' in item && !!item.icon);
19
+ }, [menu, withIcon]);
20
+ const withRightComponent = useMemo(() => {
21
+ return Object.values(menu).some((item) => 'rightComponent' in item && !!item.rightComponent);
22
+ }, [menu]);
23
+ const handleClick = (item, e) => {
24
+ if (!item.onClick)
25
+ return;
26
+ if (item.dialog) {
27
+ Dialog({ ...item.dialog }).then((result) => {
28
+ if (result && item.onClick) {
29
+ item.onClick(e);
30
+ }
31
+ });
32
+ }
33
+ else {
34
+ item.onClick(e);
35
+ }
36
+ };
37
+ return (_jsx("ul", { className: `smenu ${styles.ul} ${className || ''}`, style: style, children: Object.values(menu).map((item, key) => {
38
+ const { fullComponent, icon, title, rightComponent, seperator, href, style, itemProps, type, items, menuProps, subMenuPopoverProps, ...other } = item;
39
+ const hasSubmenu = type === 'submenu' && Array.isArray(items) && items.length > 0;
40
+ if (fullComponent)
41
+ return React.cloneElement(fullComponent, { key: key });
42
+ if (seperator)
43
+ return _jsx("li", { className: styles.seperator, style: style, ...itemProps, ...other }, key);
44
+ const 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 })] }));
45
+ if (hasSubmenu) {
46
+ return (_jsx(Popover, { component: _jsx("li", { style: style, ...itemProps, ...other, children: Component }), position: "right-top", ...(subMenuPopoverProps || {}), children: _jsx(Menu, { menu: items, ...(menuProps || {}) }) }, key));
47
+ }
48
+ return (_jsx("li", { style: style, onClick: (e) => handleClick(item, e), ...itemProps, ...other, children: href ? _jsx(Link, { href: href, children: Component }) : Component }, key));
49
+ }) }));
50
+ });
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Copyright (c) 2023
4
+ * @author: izzetseydaoglu
5
+ * @last-modified: 9.02.2024 06:07
6
+ */
7
+ import { memo, useEffect, useRef, useState } from "react";
8
+ import ReactDOM from "react-dom";
9
+ import styles from "./index.module.css";
10
+ export const Modal = memo(function MemoFunction({ refModal = null, children, open = false, close, keepMounted = false, fullScreen = false, hideBackdrop = true, hideEsc = false, hideCloseButton = false, modalStyle, backdropStyle, vertialAlign = "center", horizontalAlign = "center" }) {
11
+ const [modalDiv, setModalDiv] = useState(null);
12
+ const ref = useRef(null);
13
+ useEffect(() => {
14
+ if (refModal)
15
+ refModal.current = ref.current;
16
+ }, [ref.current]);
17
+ const onClose = () => {
18
+ if (close)
19
+ close();
20
+ };
21
+ const checkHideBackDrop = (e) => {
22
+ if (open && ref.current && !ref.current.contains(e.target))
23
+ onClose();
24
+ };
25
+ const checkESC = (e) => {
26
+ if (e.keyCode === 27 || e.key === "Escape" || e.code === "Escape")
27
+ onClose();
28
+ };
29
+ useEffect(() => {
30
+ if (open) {
31
+ if (hideBackdrop)
32
+ window.addEventListener("mousedown", checkHideBackDrop);
33
+ if (hideEsc)
34
+ window.addEventListener("keydown", checkESC);
35
+ }
36
+ return () => {
37
+ if (hideBackdrop)
38
+ window.removeEventListener("mousedown", checkHideBackDrop);
39
+ if (hideEsc)
40
+ window.removeEventListener("keydown", checkESC);
41
+ };
42
+ });
43
+ useEffect(() => {
44
+ if (!modalDiv) {
45
+ const modalDivCheck = document.getElementById("smodal");
46
+ if (modalDivCheck) {
47
+ setModalDiv(modalDivCheck);
48
+ }
49
+ else {
50
+ const div = document.createElement("div");
51
+ div.setAttribute("id", "smodal");
52
+ document.body.appendChild(div);
53
+ setModalDiv(div);
54
+ }
55
+ }
56
+ return () => {
57
+ onClose();
58
+ };
59
+ }, []);
60
+ if ((!keepMounted && !open) || typeof window === "undefined")
61
+ return null;
62
+ const Component = (_jsx("div", { className: `${styles.backdrop} ${open ? styles.backdrop_open : ""}`, style: { alignItems: vertialAlign, justifyContent: horizontalAlign, ...backdropStyle }, children: _jsxs("div", { ref: ref, className: `smodal ${styles.modal} ${fullScreen ? styles.fullscreen : ""}`, style: modalStyle, children: [!hideCloseButton && (_jsx("div", { className: `close ${styles.close_fixed}`, children: _jsx("div", { className: styles.close, onClick: onClose, children: "\u2715" }) })), children] }) }));
63
+ return modalDiv ? ReactDOM.createPortal(Component, modalDiv) : null;
64
+ });
@@ -3,27 +3,25 @@
3
3
  * @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
4
4
  * @version : 2026-02-10 16:12:35
5
5
  */
6
- import { __assign, __rest } from "tslib";
7
6
  import { cloneElement, memo, useEffect, useRef } from 'react';
8
7
  import { createRoot } from 'react-dom/client';
9
8
  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 () {
9
+ export const Popover = memo(function MemoFunction({ children, component, position = 'top', arrow = false, distance = 5, removeWhenClickInside = false, hideBackdrop = true, fade = true, arrowColor = 'auto', hover = false, hoverCloseDelay = 120, keepMounted = false, ...other }) {
10
+ const refComponent = useRef(null);
11
+ const closeTimer = useRef(null);
12
+ const hoverCloseTimer = useRef(null);
13
+ const popoverRef = useRef(null);
14
+ const rootRef = useRef(null);
15
+ const zIndexRef = useRef(null);
16
+ useEffect(() => {
19
17
  if (typeof window === 'undefined')
20
18
  return;
21
- return function () {
19
+ return () => {
22
20
  popoverSil(false);
23
21
  };
24
22
  }, []);
25
- var checkHideBackDrop = function (e) {
26
- var spopover = popoverRef.current;
23
+ const checkHideBackDrop = (e) => {
24
+ const spopover = popoverRef.current;
27
25
  if (!spopover)
28
26
  return;
29
27
  if (!((e === null || e === void 0 ? void 0 : e.target) instanceof Node)) {
@@ -33,50 +31,50 @@ export var Popover = memo(function MemoFunction(_a) {
33
31
  if (!spopover.contains(e.target))
34
32
  popoverSil();
35
33
  };
36
- var popoverEkle = function (e) {
34
+ const popoverEkle = (e) => {
37
35
  var _a, _b;
38
36
  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);
37
+ const popover = popoverRef.current;
38
+ const target = e.currentTarget;
39
+ const wasVisible = popover.classList.contains(styles.visible);
42
40
  (_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);
41
+ applyArrowColor(popover);
42
+ popoverPosition({ target, position: position });
43
+ popover.style.zIndex = String(nextPopoverZIndex());
44
+ popover.classList.remove(styles.closing);
45
+ popover.classList.add(styles.visible);
48
46
  if (!wasVisible) {
49
47
  if (hideBackdrop) {
50
48
  window.addEventListener('mousedown', checkHideBackDrop);
51
49
  window.addEventListener('blur', checkHideBackDrop);
52
50
  }
53
51
  if (removeWhenClickInside)
54
- popover_1.addEventListener('mouseup', popoverGecikmeliSil);
52
+ popover.addEventListener('mouseup', popoverGecikmeliSil);
55
53
  if (hover) {
56
- popover_1.addEventListener('mouseenter', clearHoverClose);
57
- popover_1.addEventListener('mouseleave', scheduleHoverClose);
54
+ popover.addEventListener('mouseenter', clearHoverClose);
55
+ popover.addEventListener('mouseleave', scheduleHoverClose);
58
56
  }
59
57
  incrementBodyPopover();
60
58
  }
61
59
  return;
62
60
  }
63
61
  popoverSil(false);
64
- var popover = document.createElement('div');
62
+ const popover = document.createElement('div');
65
63
  popover.classList.add('spopover', styles.popover);
66
- var zIndex = nextPopoverZIndex();
64
+ const zIndex = nextPopoverZIndex();
67
65
  zIndexRef.current = zIndex;
68
66
  document.body.appendChild(popover);
69
67
  // ReactDOM.render(children, popover)
70
- var root = createRoot(popover);
68
+ const root = createRoot(popover);
71
69
  root.render(children);
72
70
  popoverRef.current = popover;
73
71
  rootRef.current = root;
74
- var target = e.currentTarget;
72
+ const target = e.currentTarget;
75
73
  refComponent.current && refComponent.current.classList.add('spopover_active');
76
- setTimeout(function () {
74
+ setTimeout(() => {
77
75
  var _a;
78
76
  applyArrowColor(popover);
79
- popoverPosition({ target: target, position: position });
77
+ popoverPosition({ target, position: position });
80
78
  popover.style.zIndex = String((_a = zIndexRef.current) !== null && _a !== void 0 ? _a : zIndex);
81
79
  popover.classList.add(styles.visible);
82
80
  }, 100);
@@ -92,11 +90,10 @@ export var Popover = memo(function MemoFunction(_a) {
92
90
  }
93
91
  incrementBodyPopover();
94
92
  };
95
- var popoverSil = function (animate) {
96
- if (animate === void 0) { animate = true; }
93
+ const popoverSil = (animate = true) => {
97
94
  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));
95
+ const check = popoverRef.current;
96
+ const wasVisible = !!(check === null || check === void 0 ? void 0 : check.classList.contains(styles.visible));
100
97
  if (check) {
101
98
  if (removeWhenClickInside)
102
99
  check.removeEventListener('mouseup', popoverGecikmeliSil);
@@ -110,10 +107,10 @@ export var Popover = memo(function MemoFunction(_a) {
110
107
  window.clearTimeout(hoverCloseTimer.current);
111
108
  if (!fade || !animate) {
112
109
  if (!keepMounted) {
113
- var root_1 = rootRef.current;
114
- window.setTimeout(function () {
110
+ const root = rootRef.current;
111
+ window.setTimeout(() => {
115
112
  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);
113
+ (_a = root === null || root === void 0 ? void 0 : root.unmount) === null || _a === void 0 ? void 0 : _a.call(root);
117
114
  }, 0);
118
115
  check.remove();
119
116
  popoverRef.current = null;
@@ -126,10 +123,10 @@ export var Popover = memo(function MemoFunction(_a) {
126
123
  }
127
124
  else if (!check.classList.contains(styles.closing)) {
128
125
  check.classList.add(styles.closing);
129
- closeTimer.current = window.setTimeout(function () {
126
+ closeTimer.current = window.setTimeout(() => {
130
127
  var _a;
131
128
  if (!keepMounted) {
132
- var root = rootRef.current;
129
+ const root = rootRef.current;
133
130
  (_a = root === null || root === void 0 ? void 0 : root.unmount) === null || _a === void 0 ? void 0 : _a.call(root);
134
131
  check.remove();
135
132
  popoverRef.current = null;
@@ -149,55 +146,54 @@ export var Popover = memo(function MemoFunction(_a) {
149
146
  if (wasVisible)
150
147
  decrementBodyPopover();
151
148
  };
152
- var popoverGecikmeliSil = function () { return setTimeout(function () { return popoverSil(); }, 100); };
153
- var clearHoverClose = function () {
149
+ const popoverGecikmeliSil = () => setTimeout(() => popoverSil(), 100);
150
+ const clearHoverClose = () => {
154
151
  if (hoverCloseTimer.current)
155
152
  window.clearTimeout(hoverCloseTimer.current);
156
153
  hoverCloseTimer.current = null;
157
154
  };
158
- var scheduleHoverClose = function () {
155
+ const scheduleHoverClose = () => {
159
156
  clearHoverClose();
160
- hoverCloseTimer.current = window.setTimeout(function () { return popoverSil(); }, hoverCloseDelay);
157
+ hoverCloseTimer.current = window.setTimeout(() => popoverSil(), hoverCloseDelay);
161
158
  };
162
- var popoverPosition = function (_a) {
163
- var target = _a.target, position = _a.position;
164
- var popover = popoverRef.current;
159
+ const popoverPosition = ({ target, position }) => {
160
+ const popover = popoverRef.current;
165
161
  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)
162
+ const arrowMargin = arrow ? 5 : 0;
163
+ const margin = distance + arrowMargin;
164
+ const { side: preferredSide, align: preferredAlign } = normalizePosition(position);
165
+ const targetPosition = target.getBoundingClientRect();
166
+ const popoverPosition = popover.getBoundingClientRect();
167
+ const style = [];
168
+ let side = preferredSide;
169
+ if (side === 'top' && targetPosition.top - popoverPosition.height - margin < 0)
174
170
  side = 'bottom';
175
- if (side === 'bottom' && targetPosition.bottom + popoverPosition_1.height + margin > window.innerHeight)
171
+ if (side === 'bottom' && targetPosition.bottom + popoverPosition.height + margin > window.innerHeight)
176
172
  side = 'top';
177
- if (side === 'left' && targetPosition.left - popoverPosition_1.width - margin < 0)
173
+ if (side === 'left' && targetPosition.left - popoverPosition.width - margin < 0)
178
174
  side = 'right';
179
- if (side === 'right' && targetPosition.right + popoverPosition_1.width + margin > window.innerWidth)
175
+ if (side === 'right' && targetPosition.right + popoverPosition.width + margin > window.innerWidth)
180
176
  side = 'left';
181
177
  if (side === 'top')
182
- style.push('top:' + (targetPosition.top - popoverPosition_1.height - margin) + 'px');
178
+ style.push('top:' + (targetPosition.top - popoverPosition.height - margin) + 'px');
183
179
  if (side === 'bottom')
184
180
  style.push('top:' + (targetPosition.bottom + margin) + 'px');
185
181
  if (side === 'left')
186
- style.push('left:' + (targetPosition.left - popoverPosition_1.width - margin) + 'px');
182
+ style.push('left:' + (targetPosition.left - popoverPosition.width - margin) + 'px');
187
183
  if (side === 'right')
188
184
  style.push('left:' + (targetPosition.right + margin) + 'px');
189
- var alignClass = 'center';
185
+ let alignClass = 'center';
190
186
  if (side === 'top' || side === 'bottom') {
191
- var _c = resolveHorizontalAlign(preferredAlign, targetPosition, popoverPosition_1), left = _c.left, resolvedAlign = _c.alignClass;
187
+ const { left, alignClass: resolvedAlign } = resolveHorizontalAlign(preferredAlign, targetPosition, popoverPosition);
192
188
  alignClass = resolvedAlign;
193
189
  style.push('left:' + left + 'px');
194
190
  }
195
191
  else {
196
- var _d = resolveVerticalAlign(preferredAlign, targetPosition, popoverPosition_1), top_1 = _d.top, resolvedAlign = _d.alignClass;
192
+ const { top, alignClass: resolvedAlign } = resolveVerticalAlign(preferredAlign, targetPosition, popoverPosition);
197
193
  alignClass = resolvedAlign;
198
- style.push('top:' + top_1 + 'px');
194
+ style.push('top:' + top + 'px');
199
195
  }
200
- var classNames = ['spopover', styles.popover, arrow ? styles.arrow : '', fade ? '' : styles.noFade, sideClass[side], alignClassMap[alignClass]].filter(Boolean);
196
+ const classNames = ['spopover', styles.popover, arrow ? styles.arrow : '', fade ? '' : styles.noFade, sideClass[side], alignClassMap[alignClass]].filter(Boolean);
201
197
  popover.className = classNames.join(' ');
202
198
  popover.setAttribute('style', style.join(';'));
203
199
  applyArrowColor(popover);
@@ -210,12 +206,12 @@ export var Popover = memo(function MemoFunction(_a) {
210
206
  return;
211
207
  }
212
208
  if (arrowColor === 'auto') {
213
- var targetEl = (_a = popoverEl.firstElementChild) !== null && _a !== void 0 ? _a : popoverEl;
214
- var bg = window.getComputedStyle(targetEl).backgroundColor;
209
+ const targetEl = (_a = popoverEl.firstElementChild) !== null && _a !== void 0 ? _a : popoverEl;
210
+ let bg = window.getComputedStyle(targetEl).backgroundColor;
215
211
  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;
212
+ const parent = targetEl.parentElement;
213
+ if (parent)
214
+ bg = window.getComputedStyle(parent).backgroundColor;
219
215
  }
220
216
  if (bg)
221
217
  popoverEl.style.setProperty('--popover-arrow-color', bg);
@@ -224,15 +220,15 @@ export var Popover = memo(function MemoFunction(_a) {
224
220
  popoverEl.style.setProperty('--popover-arrow-color', arrowColor);
225
221
  }
226
222
  function incrementBodyPopover() {
227
- var body = document.body;
228
- var count = Number(body.dataset.spopoverCount || '0') + 1;
223
+ const body = document.body;
224
+ const count = Number(body.dataset.spopoverCount || '0') + 1;
229
225
  body.dataset.spopoverCount = String(count);
230
226
  if (count > 0)
231
227
  body.classList.add('spopover_open');
232
228
  }
233
229
  function decrementBodyPopover() {
234
- var body = document.body;
235
- var count = Math.max(0, Number(body.dataset.spopoverCount || '0') - 1);
230
+ const body = document.body;
231
+ const count = Math.max(0, Number(body.dataset.spopoverCount || '0') - 1);
236
232
  if (count === 0) {
237
233
  delete body.dataset.spopoverCount;
238
234
  body.classList.remove('spopover_open');
@@ -242,25 +238,29 @@ export var Popover = memo(function MemoFunction(_a) {
242
238
  }
243
239
  }
244
240
  function nextPopoverZIndex() {
245
- var body = document.body;
246
- var current = Number(body.dataset.spopoverZIndex || '10000');
247
- var next = current + 1;
241
+ const body = document.body;
242
+ const current = Number(body.dataset.spopoverZIndex || '10000');
243
+ const next = current + 1;
248
244
  body.dataset.spopoverZIndex = String(next);
249
245
  return next;
250
246
  }
251
- var componentProps = __assign({ ref: refComponent, onClick: function (e) {
247
+ const componentProps = {
248
+ ref: refComponent,
249
+ onClick: (e) => {
252
250
  var _a, _b;
253
251
  (_b = (_a = component.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
254
252
  popoverEkle(e);
255
- } }, other);
253
+ },
254
+ ...other
255
+ };
256
256
  if (hover) {
257
- componentProps.onMouseEnter = function (e) {
257
+ componentProps.onMouseEnter = (e) => {
258
258
  var _a, _b;
259
259
  (_b = (_a = component.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
260
260
  clearHoverClose();
261
261
  popoverEkle(e);
262
262
  };
263
- componentProps.onMouseLeave = function (e) {
263
+ componentProps.onMouseLeave = (e) => {
264
264
  var _a, _b;
265
265
  (_b = (_a = component.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
266
266
  scheduleHoverClose();
@@ -268,31 +268,31 @@ export var Popover = memo(function MemoFunction(_a) {
268
268
  }
269
269
  return cloneElement(component, componentProps);
270
270
  });
271
- var sideClass = {
271
+ const sideClass = {
272
272
  top: styles.top,
273
273
  bottom: styles.bottom,
274
274
  left: styles.left,
275
275
  right: styles.right
276
276
  };
277
- var alignClassMap = {
277
+ const alignClassMap = {
278
278
  start: styles.alignStart,
279
279
  center: styles.alignCenter,
280
280
  end: styles.alignEnd
281
281
  };
282
- var FADE_DURATION = 160;
283
- var normalizePosition = function (position) {
284
- var _a = position.split('-'), side = _a[0], rawAlign = _a[1];
282
+ const FADE_DURATION = 160;
283
+ const normalizePosition = (position) => {
284
+ const [side, rawAlign] = position.split('-');
285
285
  if (side === 'top' || side === 'bottom') {
286
- var align_1 = rawAlign === 'left' || rawAlign === 'right' ? rawAlign : 'center';
287
- return { side: side, align: align_1 };
286
+ const align = rawAlign === 'left' || rawAlign === 'right' ? rawAlign : 'center';
287
+ return { side, align };
288
288
  }
289
- var align = rawAlign === 'top' || rawAlign === 'bottom' ? rawAlign : 'center';
290
- return { side: side, align: align };
289
+ const align = rawAlign === 'top' || rawAlign === 'bottom' ? rawAlign : 'center';
290
+ return { side, align };
291
291
  };
292
- var resolveHorizontalAlign = function (align, target, popover) {
293
- var clamp = 2;
294
- var left = 0;
295
- var alignClass = 'center';
292
+ const resolveHorizontalAlign = (align, target, popover) => {
293
+ const clamp = 2;
294
+ let left = 0;
295
+ let alignClass = 'center';
296
296
  if (align === 'left') {
297
297
  left = target.left;
298
298
  alignClass = 'start';
@@ -313,12 +313,12 @@ var resolveHorizontalAlign = function (align, target, popover) {
313
313
  left = window.innerWidth - popover.width - clamp;
314
314
  alignClass = 'end';
315
315
  }
316
- return { left: left, alignClass: alignClass };
316
+ return { left, alignClass };
317
317
  };
318
- var resolveVerticalAlign = function (align, target, popover) {
319
- var clamp = 2;
320
- var top = 0;
321
- var alignClass = 'center';
318
+ const resolveVerticalAlign = (align, target, popover) => {
319
+ const clamp = 2;
320
+ let top = 0;
321
+ let alignClass = 'center';
322
322
  if (align === 'top') {
323
323
  top = target.top;
324
324
  alignClass = 'start';
@@ -339,5 +339,5 @@ var resolveVerticalAlign = function (align, target, popover) {
339
339
  top = window.innerHeight - popover.height - clamp;
340
340
  alignClass = 'end';
341
341
  }
342
- return { top: top, alignClass: alignClass };
342
+ return { top, alignClass };
343
343
  };