@sydsoft/base 1.44.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/inputMask.js +2 -1
- package/dist/esm/_lib/storage/encData.js +1 -1
- 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/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
|
@@ -40,7 +40,8 @@ var createMaskCore = function () {
|
|
|
40
40
|
if (reverse === void 0) { reverse = false; }
|
|
41
41
|
if (!maskTokens.length)
|
|
42
42
|
return inputValue;
|
|
43
|
-
var
|
|
43
|
+
var normalizedValue = inputValue == null ? "" : String(inputValue);
|
|
44
|
+
var cleanValue = normalizedValue.replace(/[^\w\s]/g, "");
|
|
44
45
|
if (reverse) {
|
|
45
46
|
return applyReverseMask(cleanValue, maskTokens);
|
|
46
47
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
export type propsDialog = {
|
|
3
3
|
message: any;
|
|
4
4
|
acceptButtonShow?: boolean;
|
|
5
5
|
cancelButtonShow?: boolean;
|
|
6
6
|
acceptButtonText?: string | ReactNode;
|
|
7
7
|
cancelButtonText?: string | ReactNode;
|
|
8
|
-
acceptButtonClass?:
|
|
9
|
-
cancelButtonClass?:
|
|
10
|
-
vertialAlign?:
|
|
11
|
-
horizontalAlign?:
|
|
8
|
+
acceptButtonClass?: 'default' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'link';
|
|
9
|
+
cancelButtonClass?: 'default' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'link';
|
|
10
|
+
vertialAlign?: 'flex-start' | 'center' | 'flex-end';
|
|
11
|
+
horizontalAlign?: 'flex-start' | 'center' | 'flex-end';
|
|
12
12
|
hideBackdrop?: boolean;
|
|
13
13
|
hideEsc?: boolean;
|
|
14
14
|
styleMessage?: React.CSSProperties;
|
|
15
15
|
styleBox?: React.CSSProperties;
|
|
16
16
|
styleBoxFooter?: React.CSSProperties;
|
|
17
|
-
autoFocus?:
|
|
17
|
+
autoFocus?: 'accept' | 'cancel';
|
|
18
|
+
backdropStyle?: React.CSSProperties;
|
|
18
19
|
};
|
|
19
20
|
export declare const Dialog: (config: propsDialog) => Promise<unknown>;
|
package/dist/esm/form/Dialog.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Box, BoxFooter } from
|
|
4
|
-
import { createRoot } from
|
|
5
|
-
import { Modal } from
|
|
6
|
-
import { Button } from
|
|
3
|
+
import { Box, BoxFooter } from '../box';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { Modal } from '../modal';
|
|
6
|
+
import { Button } from './Button';
|
|
7
7
|
export var Dialog = function (config) {
|
|
8
8
|
return new Promise(function (resolve) {
|
|
9
|
-
if (typeof window ===
|
|
9
|
+
if (typeof window === 'undefined')
|
|
10
10
|
return false;
|
|
11
|
-
var mainDiv = document.getElementById(
|
|
11
|
+
var mainDiv = document.getElementById('sdialog');
|
|
12
12
|
if (!mainDiv) {
|
|
13
|
-
var createDiv = document.createElement(
|
|
14
|
-
createDiv.setAttribute(
|
|
13
|
+
var createDiv = document.createElement('div');
|
|
14
|
+
createDiv.setAttribute('id', 'sdialog');
|
|
15
15
|
document.body.appendChild(createDiv);
|
|
16
16
|
mainDiv = createDiv;
|
|
17
17
|
}
|
|
18
18
|
var root = createRoot(mainDiv);
|
|
19
|
-
var settings = __assign({ acceptButtonShow: true, cancelButtonShow: true, acceptButtonText:
|
|
20
|
-
fontSize:
|
|
21
|
-
padding:
|
|
22
|
-
}, styleBox: { padding: 0, margin: 0, minWidth: 250 }, styleBoxFooter: { padding:
|
|
19
|
+
var settings = __assign({ acceptButtonShow: true, cancelButtonShow: true, acceptButtonText: 'EVET', cancelButtonText: 'HAYIR', acceptButtonClass: 'danger', cancelButtonClass: 'secondary', vertialAlign: 'center', horizontalAlign: 'center', hideBackdrop: true, hideEsc: true, styleMessage: {
|
|
20
|
+
fontSize: '1.1rem',
|
|
21
|
+
padding: '10px 20px'
|
|
22
|
+
}, styleBox: { padding: 0, margin: 0, minWidth: 250 }, styleBoxFooter: { padding: '8px 5px' }, autoFocus: 'accept' }, config);
|
|
23
23
|
var close = function () {
|
|
24
24
|
if (mainDiv) {
|
|
25
25
|
root.unmount();
|
|
@@ -34,7 +34,7 @@ export var Dialog = function (config) {
|
|
|
34
34
|
resolve(true);
|
|
35
35
|
close();
|
|
36
36
|
};
|
|
37
|
-
var Component = (_jsx(Modal, { open: true, keepMounted: false, close: onCancel, hideBackdrop: settings.hideBackdrop, hideEsc: settings.hideEsc, hideCloseButton: true, vertialAlign: settings.vertialAlign, horizontalAlign: settings.horizontalAlign, children: _jsxs(Box, { style: settings.styleBox, children: [_jsx("div", { className: "sbox_content", style: settings.styleMessage, dangerouslySetInnerHTML: { __html: settings.message } }), (settings.acceptButtonShow || settings.cancelButtonShow) && (_jsxs(BoxFooter, { style: settings.styleBoxFooter, children: [settings.cancelButtonShow && (_jsx(Button, { autoFocus: settings.autoFocus ===
|
|
37
|
+
var Component = (_jsx(Modal, { open: true, keepMounted: false, close: onCancel, hideBackdrop: settings.hideBackdrop, hideEsc: settings.hideEsc, hideCloseButton: true, vertialAlign: settings.vertialAlign, horizontalAlign: settings.horizontalAlign, backdropStyle: settings.backdropStyle, children: _jsxs(Box, { style: settings.styleBox, children: [_jsx("div", { className: "sbox_content", style: settings.styleMessage, dangerouslySetInnerHTML: { __html: settings.message } }), (settings.acceptButtonShow || settings.cancelButtonShow) && (_jsxs(BoxFooter, { style: settings.styleBoxFooter, children: [settings.cancelButtonShow && (_jsx(Button, { autoFocus: settings.autoFocus === 'cancel', buttonClass: settings.cancelButtonClass, onClick: onCancel, children: settings.cancelButtonText })), settings.acceptButtonShow && (_jsx(Button, { autoFocus: settings.autoFocus === 'accept', buttonClass: settings.acceptButtonClass, onClick: onAccept, children: settings.acceptButtonText }))] }))] }) }));
|
|
38
38
|
root.render(Component);
|
|
39
39
|
});
|
|
40
40
|
};
|
package/dist/esm/form/Input.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author : izzetseydaoglu
|
|
3
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
4
|
+
* @version : 2026-01-21 21:35:48
|
|
5
|
+
*/
|
|
1
6
|
import React from 'react';
|
|
2
7
|
type maskSettingsTranslation = {
|
|
3
8
|
[key: string]: {
|
|
@@ -34,13 +39,13 @@ export interface PropsInput {
|
|
|
34
39
|
labelKey?: string;
|
|
35
40
|
multiline?: boolean;
|
|
36
41
|
rows?: number | undefined;
|
|
37
|
-
onChange?:
|
|
38
|
-
onFocus?:
|
|
39
|
-
onBlur?:
|
|
40
|
-
onClick?:
|
|
41
|
-
onKeyPress?:
|
|
42
|
-
onKeyUp?:
|
|
43
|
-
onKeyDown?:
|
|
42
|
+
onChange?: (e: any) => void;
|
|
43
|
+
onFocus?: (e: any) => void;
|
|
44
|
+
onBlur?: (e: any) => void;
|
|
45
|
+
onClick?: (e: any) => void;
|
|
46
|
+
onKeyPress?: (e: any) => void;
|
|
47
|
+
onKeyUp?: (e: any) => void;
|
|
48
|
+
onKeyDown?: (e: any) => void;
|
|
44
49
|
propsComponent?: object | any;
|
|
45
50
|
propsInput?: object;
|
|
46
51
|
startAdornment?: any;
|
package/dist/esm/form/Input.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* @author : izzetseydaoglu
|
|
5
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
6
|
+
* @version : 2026-01-21 21:35:48
|
|
7
|
+
*/
|
|
3
8
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
9
|
import { convertForSEO, inputTumuBuyukCevir, inputTumuKucukCevir } from '../_lib/baseFunctions';
|
|
5
|
-
import { Dialog } from './Dialog';
|
|
6
|
-
import { alert_add } from '../alert';
|
|
7
10
|
import { applyInputMask } from '../_lib/inputMask';
|
|
11
|
+
import { alert_add } from '../alert';
|
|
12
|
+
import { Dialog } from './Dialog';
|
|
8
13
|
import styles from './styles/Input.module.css';
|
|
9
14
|
export var Input = function (_a) {
|
|
10
|
-
var componentRef = _a.componentRef, inputRef = _a.inputRef, className = _a.className, propsComponent = _a.propsComponent, propsInput = _a.propsInput, id = _a.id, name = _a.name,
|
|
15
|
+
var componentRef = _a.componentRef, inputRef = _a.inputRef, className = _a.className, propsComponent = _a.propsComponent, propsInput = _a.propsInput, id = _a.id, name = _a.name, _b = _a.value, value = _b === void 0 ? '' : _b, type = _a.type, label = _a.label, startAdornment = _a.startAdornment, endAdornment = _a.endAdornment, placeholder = _a.placeholder, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, onClick = _a.onClick, onKeyPress = _a.onKeyPress, onKeyUp = _a.onKeyUp, onKeyDown = _a.onKeyDown, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.required, required = _d === void 0 ? false : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, select = _a.select, _g = _a.valueKey, valueKey = _g === void 0 ? 'value' : _g, _h = _a.labelKey, labelKey = _h === void 0 ? 'label' : _h, _j = _a.ilkSec, ilkSec = _j === void 0 ? false : _j, _k = _a.multiline, multiline = _k === void 0 ? false : _k, _l = _a.rows, rows = _l === void 0 ? 2 : _l, sadeceYazi = _a.sadeceYazi, sadeceSayi = _a.sadeceSayi, tumuBuyuk = _a.tumuBuyuk, tumuKucuk = _a.tumuKucuk, seoCevir = _a.seoCevir, dosyaNoGiris = _a.dosyaNoGiris, fileNameGiris = _a.fileNameGiris, dateGecmisKontrol = _a.dateGecmisKontrol, autoSelectText = _a.autoSelectText, _m = _a.mask, mask = _m === void 0 ? '' : _m, _o = _a.maskSettings, maskSettings = _o === void 0 ? {
|
|
11
16
|
clearIfNotMatch: true,
|
|
12
17
|
reverse: false, //Tersten doldurmaya başla, fiyatlar için geçerli
|
|
13
18
|
selectOnFocus: false
|
|
14
|
-
} :
|
|
19
|
+
} : _o;
|
|
15
20
|
var refMain = useRef(null);
|
|
16
21
|
var refInput = useRef(null);
|
|
17
22
|
var refLabel = useRef(null);
|
|
18
|
-
var
|
|
19
|
-
var
|
|
23
|
+
var _p = useState(value && value.toString().length > 0), inputFilled = _p[0], setInputFilled = _p[1];
|
|
24
|
+
var _q = useState(false), focus = _q[0], setFocus = _q[1];
|
|
20
25
|
useEffect(function () {
|
|
21
26
|
if (inputRef)
|
|
22
27
|
inputRef.current = refInput.current;
|
|
@@ -24,21 +29,17 @@ export var Input = function (_a) {
|
|
|
24
29
|
componentRef.current = refMain.current;
|
|
25
30
|
}, [componentRef, inputRef]);
|
|
26
31
|
useEffect(function () {
|
|
27
|
-
|
|
28
|
-
refInput.current.select();
|
|
29
|
-
}
|
|
32
|
+
autoSelectText && !select && (refInput === null || refInput === void 0 ? void 0 : refInput.current) && refInput.current.select();
|
|
30
33
|
}, [autoSelectText, select]);
|
|
31
34
|
useEffect(function () {
|
|
32
35
|
var _a, _b;
|
|
33
|
-
var filled =
|
|
36
|
+
var filled = String(value) && value.toString().length > 0 ? true : false;
|
|
34
37
|
setInputFilled(filled);
|
|
35
|
-
|
|
36
|
-
(_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(styles.error);
|
|
37
|
-
}
|
|
38
|
+
filled && ((_b = (_a = refMain === null || refMain === void 0 ? void 0 : refMain.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(styles.error));
|
|
38
39
|
}, [value]);
|
|
39
40
|
useEffect(function () {
|
|
40
41
|
// if (type === "number") sadeceSayi = true; //TODO: sadeceSayi burada değiştirelemez ki!!!
|
|
41
|
-
if (select && ilkSec && (value === '' ||
|
|
42
|
+
if (select && ilkSec && (value === '' || value === null || value === undefined)) {
|
|
42
43
|
if (select.length) {
|
|
43
44
|
var ilkItem = select[0][valueKey] ? select[0][valueKey] : '';
|
|
44
45
|
onChange && onChange({ target: { name: name, value: ilkItem } });
|
|
@@ -62,7 +63,6 @@ export var Input = function (_a) {
|
|
|
62
63
|
maskInstance_1 === null || maskInstance_1 === void 0 ? void 0 : maskInstance_1.setValue(value ? value : null);
|
|
63
64
|
return function () { return maskInstance_1 === null || maskInstance_1 === void 0 ? void 0 : maskInstance_1.destroy(); };
|
|
64
65
|
}
|
|
65
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
66
|
}, [mask]);
|
|
67
67
|
var Change = useCallback(function (e) {
|
|
68
68
|
if (tumuBuyuk)
|
|
@@ -174,7 +174,7 @@ export var Input = function (_a) {
|
|
|
174
174
|
else {
|
|
175
175
|
component = _jsx("input", __assign({ className: "".concat(styles.input), type: type }, ortakProps, propsInput));
|
|
176
176
|
}
|
|
177
|
-
var classList =
|
|
177
|
+
var classList = function () {
|
|
178
178
|
var list = ['sInputComponent', styles.component];
|
|
179
179
|
if (className)
|
|
180
180
|
list.push(className);
|
|
@@ -183,7 +183,7 @@ export var Input = function (_a) {
|
|
|
183
183
|
}
|
|
184
184
|
// if (props.required && (value.length === 0 || !value)) list.push("error");
|
|
185
185
|
return list.join(' ');
|
|
186
|
-
}
|
|
186
|
+
};
|
|
187
187
|
useEffect(function () {
|
|
188
188
|
if (propsComponent && propsComponent.hasOwnProperty('style')) {
|
|
189
189
|
var background = propsComponent.style.background ? propsComponent.style.background : propsComponent.style.backgroundColor ? propsComponent.style.backgroundColor : null;
|
|
@@ -194,13 +194,3 @@ export var Input = function (_a) {
|
|
|
194
194
|
}, [propsComponent]);
|
|
195
195
|
return (_jsxs("div", __assign({ ref: refMain, className: classList(), "data-disabled": disabled }, propsComponent, { children: [startAdornment && _jsx("div", { className: "adornment_start ".concat(styles.adornment, " ").concat(styles.start), children: startAdornment }), _jsxs("div", { className: "".concat(styles.inputBase, " ").concat(inputFilled || focus || type == 'date' ? styles.open : ''), children: [component, label && (_jsxs("div", { ref: refLabel, className: "label ".concat(styles.label), children: [label, required && _jsx("span", { className: styles.required, children: "*" })] }))] }), (endAdornment || loading) && (_jsxs("div", { className: "adornment_end ".concat(styles.adornment, " ").concat(styles.end), children: [endAdornment, loading && _jsx("div", { className: styles.loading })] }))] })));
|
|
196
196
|
};
|
|
197
|
-
Input.defaultProps = {
|
|
198
|
-
value: '',
|
|
199
|
-
disabled: false,
|
|
200
|
-
required: false,
|
|
201
|
-
ilkSec: false,
|
|
202
|
-
multiline: false,
|
|
203
|
-
rows: 2,
|
|
204
|
-
loading: false,
|
|
205
|
-
autoFocus: false
|
|
206
|
-
};
|
package/dist/esm/form/Label.d.ts
CHANGED
package/dist/esm/form/Label.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { memo } from
|
|
4
|
-
import { Tooltip } from
|
|
5
|
-
import styles from
|
|
6
|
-
export var Label = memo(function FMemo(
|
|
7
|
-
var
|
|
8
|
-
return (_jsxs("label", __assign({ className: styles.label }, other, { children: [children, _jsx(Tooltip, { title:
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { Tooltip } from '../tooltip';
|
|
5
|
+
import styles from './styles/Label.module.css';
|
|
6
|
+
export var Label = memo(function FMemo(_a) {
|
|
7
|
+
var _b = _a.required, required = _b === void 0 ? false : _b, children = _a.children, other = __rest(_a, ["required", "children"]);
|
|
8
|
+
return (_jsxs("label", __assign({ className: styles.label }, other, { children: [children, _jsx(Tooltip, { title: 'Zorunlu Alan', children: _jsx("span", { className: styles.required, children: required && '*' }) })] })));
|
|
9
9
|
});
|
|
10
|
-
Label.defaultProps = {
|
|
11
|
-
required: false
|
|
12
|
-
};
|
package/dist/esm/icon/index.js
CHANGED
|
@@ -6,18 +6,21 @@ var defaultIconStyle = {
|
|
|
6
6
|
userSelect: 'none',
|
|
7
7
|
width: '1em',
|
|
8
8
|
height: '1em',
|
|
9
|
-
display: 'inline-block',
|
|
9
|
+
// display: 'inline-block',
|
|
10
10
|
verticalAlign: 'middle',
|
|
11
|
-
flexShrink: 0
|
|
11
|
+
flexShrink: 0,
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
justifyContent: 'center'
|
|
12
15
|
};
|
|
13
16
|
export var Icon = function (_a) {
|
|
14
17
|
var name = _a.name, iconMui = _a.iconMui, customIcon = _a.customIcon, fontSize = _a.fontSize, color = _a.color, className = _a.className, style = _a.style, other = __rest(_a, ["name", "iconMui", "customIcon", "fontSize", "color", "className", "style"]);
|
|
15
18
|
if (iconMui) {
|
|
16
|
-
return (_jsx("span", __assign({ className: "material-icons ".concat(className || ''), style: __assign(__assign(__assign({}, defaultIconStyle), style), { fontSize: fontSize || '1.
|
|
19
|
+
return (_jsx("span", __assign({ className: "material-icons ".concat(className || ''), style: __assign(__assign(__assign({}, defaultIconStyle), style), { fontSize: fontSize || '1.3rem', color: color || 'inherit' }), "aria-hidden": "true" }, other, { children: iconMui })));
|
|
17
20
|
}
|
|
18
21
|
var iconComponent = name ? iconMap[name] : customIcon;
|
|
19
22
|
if (!iconComponent) {
|
|
20
23
|
return _jsx("span", { children: "\u26A0\uFE0F" });
|
|
21
24
|
}
|
|
22
|
-
return (_jsx("span", __assign({ className: className, style: __assign(__assign(__assign({}, defaultIconStyle), style), { fontSize: fontSize || '1.5rem', color: color || 'inherit' }) }, other, { children: _jsx("svg", { viewBox: iconComponent.viewBox, fill: 'currentColor',
|
|
25
|
+
return (_jsx("span", __assign({ className: className, style: __assign(__assign(__assign({}, defaultIconStyle), style), { fontSize: fontSize || '1.5rem', color: color || 'inherit' }) }, 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 }) })));
|
|
23
26
|
};
|
package/dist/esm/menu/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @author : izzetseydaoglu
|
|
3
|
+
* @copyright : sydSOFT Bilişim Hizmetleri (c) 2026
|
|
4
|
+
* @version : 2026-02-07 19:31:01
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { propsDialog } from '../form';
|
|
8
|
+
import { PopoverConfigBaseProps } from '../popover';
|
|
3
9
|
interface BaseProps {
|
|
4
10
|
style?: React.CSSProperties;
|
|
5
11
|
itemProps?: any;
|
|
@@ -26,18 +32,38 @@ interface FullComponentProps extends BaseProps {
|
|
|
26
32
|
interface ItemComponentProps extends BaseProps {
|
|
27
33
|
seperator?: false;
|
|
28
34
|
fullComponent?: never;
|
|
35
|
+
type?: never;
|
|
29
36
|
title: string;
|
|
30
37
|
icon?: React.ReactNode;
|
|
38
|
+
rightComponent?: React.ReactNode;
|
|
31
39
|
href?: string;
|
|
32
40
|
onClick?: (e: React.MouseEvent<HTMLLIElement>) => void;
|
|
33
41
|
dialog?: propsDialog;
|
|
34
42
|
}
|
|
35
|
-
|
|
43
|
+
interface SubMenuProps extends BaseProps {
|
|
44
|
+
type: 'submenu';
|
|
45
|
+
title: string;
|
|
46
|
+
items: typeMenu[];
|
|
47
|
+
icon?: React.ReactNode;
|
|
48
|
+
subMenuPopoverProps?: PopoverConfigBaseProps;
|
|
49
|
+
rightComponent?: React.ReactNode;
|
|
50
|
+
menuProps?: {
|
|
51
|
+
className?: string;
|
|
52
|
+
style?: React.CSSProperties;
|
|
53
|
+
withIcon?: boolean | 'auto';
|
|
54
|
+
};
|
|
55
|
+
seperator?: never;
|
|
56
|
+
fullComponent?: never;
|
|
57
|
+
href?: never;
|
|
58
|
+
onClick?: never;
|
|
59
|
+
dialog?: never;
|
|
60
|
+
}
|
|
61
|
+
export type typeMenu = SeperatorProps | FullComponentProps | ItemComponentProps | SubMenuProps;
|
|
36
62
|
interface Props {
|
|
37
63
|
menu: typeMenu[];
|
|
38
64
|
className?: string;
|
|
39
65
|
style?: React.CSSProperties;
|
|
40
|
-
withIcon?: boolean;
|
|
66
|
+
withIcon?: boolean | 'auto';
|
|
41
67
|
}
|
|
42
68
|
export declare const Menu: React.NamedExoticComponent<Props>;
|
|
43
69
|
export {};
|
package/dist/esm/menu/index.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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';
|
|
7
13
|
export var Menu = memo(function MemoFunction(_a) {
|
|
8
|
-
var menu = _a.menu, className = _a.className, style = _a.style, _b = _a.withIcon, withIcon = _b === void 0 ?
|
|
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]);
|
|
9
25
|
var handleClick = function (item, e) {
|
|
10
26
|
if (!item.onClick)
|
|
11
27
|
return;
|
|
@@ -20,13 +36,17 @@ export var Menu = memo(function MemoFunction(_a) {
|
|
|
20
36
|
item.onClick(e);
|
|
21
37
|
}
|
|
22
38
|
};
|
|
23
|
-
return (_jsx("ul", { className: "smenu ".concat(styles.ul, " ").concat(className ||
|
|
24
|
-
var fullComponent =
|
|
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;
|
|
25
42
|
if (fullComponent)
|
|
26
43
|
return React.cloneElement(fullComponent, { key: key });
|
|
27
44
|
if (seperator)
|
|
28
|
-
return _jsx("li", __assign({ className:
|
|
29
|
-
var Component = (_jsxs(_Fragment, { children: [
|
|
30
|
-
|
|
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));
|
|
31
51
|
}) }));
|
|
32
52
|
});
|
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
.ul {
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
|
-
|
|
5
|
-
box-shadow: 0 2px 4px rgb(0 0 0 / 40%), 0 8px 16px rgb(0 0 0 / 10%);
|
|
6
|
-
border-radius: 8px;
|
|
7
|
-
margin: 0;
|
|
8
|
-
padding: 4px 0;
|
|
4
|
+
max-height: calc(100vh - 94px);
|
|
9
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;
|
|
10
16
|
}
|
|
11
|
-
|
|
17
|
+
|
|
18
|
+
.ul > li {
|
|
12
19
|
cursor: pointer;
|
|
13
|
-
padding:
|
|
20
|
+
padding: 2px 6px;
|
|
14
21
|
min-height: 25px;
|
|
15
22
|
}
|
|
16
|
-
.li,
|
|
17
|
-
.li a {
|
|
23
|
+
.ul > li,
|
|
24
|
+
.ul > li a {
|
|
18
25
|
display: flex;
|
|
19
26
|
flex-direction: row;
|
|
20
27
|
flex-wrap: nowrap;
|
|
21
28
|
width: 100%;
|
|
22
29
|
}
|
|
23
|
-
.li a,
|
|
24
|
-
.li a:visited {
|
|
30
|
+
.ul > li a,
|
|
31
|
+
.ul > li a:visited {
|
|
25
32
|
color: inherit;
|
|
26
33
|
text-decoration: none;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
.li
|
|
30
|
-
display: block;
|
|
31
|
-
border-bottom: 1px #ced0d4 solid;
|
|
32
|
-
margin: 4px;
|
|
33
|
-
padding: 0;
|
|
34
|
-
cursor: default;
|
|
35
|
-
min-height: unset;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.li:first-child {
|
|
36
|
+
.ul > li:first-child {
|
|
39
37
|
margin-top: 5px;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
.li:last-child {
|
|
40
|
+
.ul > li:last-child {
|
|
43
41
|
margin-bottom: 5px;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
.li:hover {
|
|
44
|
+
.ul > li:hover {
|
|
47
45
|
background: #f0f2f5;
|
|
48
46
|
}
|
|
49
47
|
|
|
48
|
+
.ul > li:global(.spopover_active) {
|
|
49
|
+
background: #e8f0fe;
|
|
50
|
+
}
|
|
51
|
+
|
|
50
52
|
.menuicon {
|
|
51
53
|
display: inline-flex;
|
|
52
54
|
overflow: hidden;
|
|
53
|
-
width:
|
|
55
|
+
width: 30px;
|
|
54
56
|
flex: 0 0 auto;
|
|
55
57
|
align-items: center;
|
|
56
58
|
justify-content: center;
|
|
57
|
-
margin-right: 15px;
|
|
58
59
|
color: #606060;
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -63,5 +64,29 @@
|
|
|
63
64
|
flex: 1;
|
|
64
65
|
align-items: center;
|
|
65
66
|
justify-content: flex-start;
|
|
66
|
-
margin
|
|
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;
|
|
67
92
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
outline: none;
|
|
12
12
|
}
|
|
13
13
|
.backdrop_open {
|
|
14
|
-
display: flex !important;
|
|
14
|
+
display: flex !important;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.modal {
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
overflow-x: hidden;
|
|
23
23
|
border-radius: 8px;
|
|
24
24
|
background: transparent;
|
|
25
|
-
box-shadow:
|
|
25
|
+
box-shadow:
|
|
26
|
+
rgb(0 0 0 / 32%) 0 4px 8px,
|
|
27
|
+
rgb(0 0 0 / 40%) 0 8px 40px;
|
|
26
28
|
margin: 15px;
|
|
27
29
|
padding: 0;
|
|
28
30
|
z-index: 1;
|
|
@@ -38,8 +40,8 @@
|
|
|
38
40
|
}
|
|
39
41
|
.close_fixed {
|
|
40
42
|
position: absolute;
|
|
41
|
-
top:
|
|
42
|
-
right:
|
|
43
|
+
top: 2px;
|
|
44
|
+
right: 2px;
|
|
43
45
|
z-index: 1000;
|
|
44
46
|
text-align: right;
|
|
45
47
|
border-radius: inherit;
|
|
@@ -47,20 +49,19 @@
|
|
|
47
49
|
|
|
48
50
|
.close {
|
|
49
51
|
position: fixed;
|
|
50
|
-
background: #
|
|
52
|
+
background: linear-gradient(0deg, transparent, #00000026, transparent);
|
|
51
53
|
padding: 8px 10px;
|
|
52
54
|
font-size: 11px;
|
|
53
|
-
transform: translateX(-100%);
|
|
54
|
-
border-radius:
|
|
55
|
-
border-top-left-radius: 0;
|
|
56
|
-
border-bottom-right-radius: 0;
|
|
57
|
-
border-bottom-left-radius: 50%;
|
|
55
|
+
transform: scale(1) translateX(-100%);
|
|
56
|
+
border-radius: none;
|
|
58
57
|
cursor: pointer;
|
|
59
58
|
font-weight: bold;
|
|
60
59
|
text-shadow: 1px 0px 0px #000000;
|
|
60
|
+
transition: all 0.3s ease-in-out;
|
|
61
61
|
}
|
|
62
62
|
.close:hover {
|
|
63
|
-
|
|
63
|
+
transform: scale(1.3) translateX(-85%);
|
|
64
|
+
background: linear-gradient(180deg, transparent, #0000003a, transparent);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
.sbox_header {
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
7
11
|
removeWhenClickInside?: boolean;
|
|
12
|
+
hideBackdrop?: boolean;
|
|
8
13
|
arrow?: boolean;
|
|
9
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;
|
|
10
24
|
}
|
|
11
|
-
export declare const Popover: React.NamedExoticComponent<
|
|
25
|
+
export declare const Popover: React.NamedExoticComponent<PopoverProps>;
|
|
12
26
|
export {};
|
|
@@ -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
|
+
}
|