@sydsoft/base 1.43.0 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export declare const isDev: boolean;
3
3
  export declare const isServerReq: (context: any) => boolean;
4
+ export declare const sleep: (ms?: number) => Promise<unknown>;
4
5
  export declare const padNumber: (num: number, padLength?: number, padString?: string) => string;
5
6
  export declare function inputTumuBuyukCevir(e: React.ChangeEvent<HTMLInputElement>): void;
6
7
  export declare function inputTumuKucukCevir(e: React.ChangeEvent<HTMLInputElement>): void;
@@ -1,5 +1,9 @@
1
1
  export var isDev = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
2
2
  export var isServerReq = function (context) { var _a, _b; return !((_b = (_a = context === null || context === void 0 ? void 0 : context.req) === null || _a === void 0 ? void 0 : _a.url) === null || _b === void 0 ? void 0 : _b.startsWith('/_next')); };
3
+ export var sleep = function (ms) {
4
+ if (ms === void 0) { ms = 1000; }
5
+ return new Promise(function (resolve) { return setTimeout(resolve, ms); });
6
+ };
3
7
  export var padNumber = function (num, padLength, padString) {
4
8
  if (padLength === void 0) { padLength = 2; }
5
9
  if (padString === void 0) { padString = '0'; }
@@ -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 cleanValue = inputValue.replace(/[^\w\s]/g, "");
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,2 +1,2 @@
1
- export declare const encData: (data: any) => string;
2
- export declare const decData: (data: string) => any;
1
+ export declare const encData: (data: object | string | number, keys?: number[]) => string;
2
+ export declare const decData: (data: string, keys?: number[]) => any;
@@ -1,8 +1,10 @@
1
- import { isDev } from '../baseFunctions';
2
- var keys = [3, 5, 8, 11, 15, 22];
3
- export var encData = function (data) {
1
+ import { isDev } from "../baseFunctions";
2
+ var encDecDataKeys = [3, 5, 8, 11, 15, 22];
3
+ export var encData = function (data, keys) {
4
+ if (keys === void 0) { keys = encDecDataKeys; }
4
5
  try {
5
- var utf8Data = unescape(encodeURIComponent(JSON.stringify(data))); // Dizeyi UTF-8'e dönüştür
6
+ var newJSON = { data: data };
7
+ var utf8Data = unescape(encodeURIComponent(JSON.stringify(newJSON))); // Dizeyi UTF-8'e dönüştür
6
8
  var newData_1 = btoa(utf8Data);
7
9
  keys.map(function (value) {
8
10
  var randomChar = String.fromCharCode(Math.floor(Math.random() * (122 - 97 + 1)) + 97);
@@ -11,11 +13,13 @@ export var encData = function (data) {
11
13
  return newData_1;
12
14
  }
13
15
  catch (e) {
14
- isDev && console.log('ERROR => encData =>', e);
15
- return '';
16
+ isDev && console.log("ERROR => encData =>", e);
17
+ return "";
16
18
  }
17
19
  };
18
- export var decData = function (data) {
20
+ export var decData = function (data, keys) {
21
+ var _a;
22
+ if (keys === void 0) { keys = encDecDataKeys; }
19
23
  try {
20
24
  var decode_1 = data;
21
25
  keys.map(function (value, index) {
@@ -29,10 +33,11 @@ export var decData = function (data) {
29
33
  });
30
34
  var decodedString = atob(decode_1);
31
35
  var utf8DecodedString = decodeURIComponent(escape(decodedString));
32
- return JSON.parse(utf8DecodedString);
36
+ var parse = JSON.parse(utf8DecodedString);
37
+ return (_a = parse === null || parse === void 0 ? void 0 : parse.data) !== null && _a !== void 0 ? _a : "";
33
38
  }
34
39
  catch (e) {
35
- isDev && console.log('ERROR => decData =>', e);
36
- return '';
40
+ isDev && console.log("ERROR => decData =>", e);
41
+ return "";
37
42
  }
38
43
  };
@@ -1,19 +1,20 @@
1
- import React, { ReactNode } from "react";
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?: "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";
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?: "accept" | "cancel";
17
+ autoFocus?: 'accept' | 'cancel';
18
+ backdropStyle?: React.CSSProperties;
18
19
  };
19
20
  export declare const Dialog: (config: propsDialog) => Promise<unknown>;
@@ -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 "../box";
4
- import { createRoot } from "react-dom/client";
5
- import { Modal } from "../modal";
6
- import { Button } from "./Button";
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 === "undefined")
9
+ if (typeof window === 'undefined')
10
10
  return false;
11
- var mainDiv = document.getElementById("sdialog");
11
+ var mainDiv = document.getElementById('sdialog');
12
12
  if (!mainDiv) {
13
- var createDiv = document.createElement("div");
14
- createDiv.setAttribute("id", "sdialog");
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: "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);
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 === "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 }))] }))] }) }));
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
  };
@@ -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?: Function;
38
- onFocus?: Function;
39
- onBlur?: Function;
40
- onClick?: Function;
41
- onKeyPress?: Function;
42
- onKeyUp?: Function;
43
- onKeyDown?: Function;
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;
@@ -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, value = _a.value, 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, disabled = _a.disabled, required = _a.required, loading = _a.loading, autoFocus = _a.autoFocus, select = _a.select, _b = _a.valueKey, valueKey = _b === void 0 ? 'value' : _b, _c = _a.labelKey, labelKey = _c === void 0 ? 'label' : _c, ilkSec = _a.ilkSec, multiline = _a.multiline, rows = _a.rows, 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, _d = _a.mask, mask = _d === void 0 ? '' : _d, _e = _a.maskSettings, maskSettings = _e === void 0 ? {
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
- } : _e;
19
+ } : _o;
15
20
  var refMain = useRef(null);
16
21
  var refInput = useRef(null);
17
22
  var refLabel = useRef(null);
18
- var _f = useState(value && value.toString().length > 0), inputFilled = _f[0], setInputFilled = _f[1];
19
- var _g = useState(false), focus = _g[0], setFocus = _g[1];
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
- if (autoSelectText && !select && (refInput === null || refInput === void 0 ? void 0 : refInput.current)) {
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 = value && String(value) && value.toString().length > 0;
36
+ var filled = String(value) && value.toString().length > 0 ? true : false;
34
37
  setInputFilled(filled);
35
- if (filled) {
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 === '' || !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 = useCallback(function () {
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
- }, [value, className]);
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
- };
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
  interface Props {
3
3
  children: React.ReactNode;
4
4
  required?: boolean;
@@ -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 "react";
4
- import { Tooltip } from "../tooltip";
5
- import styles from "./styles/Label.module.css";
6
- export var Label = memo(function FMemo(props) {
7
- var required = props.required, children = props.children, other = __rest(props, ["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 && "*" }) })] })));
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
- };
@@ -6,7 +6,6 @@ type typeList = {
6
6
  [key: string]: any;
7
7
  };
8
8
  type typeValue = string | number | undefined;
9
- type typeVoidFunction = () => void;
10
9
  interface Props extends PropsInput {
11
10
  autoCompleteList?: typeList[];
12
11
  isDataFromApi: boolean;
@@ -18,6 +17,7 @@ interface Props extends PropsInput {
18
17
  onChange?: (e: any) => void;
19
18
  onText?: (text: string) => void;
20
19
  onSelect?: (item: any) => void;
20
+ onLoad?: (value: typeValue) => void;
21
21
  ilkSec?: boolean;
22
22
  newCreate?: boolean;
23
23
  style?: React.CSSProperties;
@@ -27,7 +27,7 @@ interface Props extends PropsInput {
27
27
  notFoundMessage?: string;
28
28
  }
29
29
  export interface SearchableInputRef {
30
- setAutoCompleteList: (list: typeList[], value?: typeValue, callback?: typeVoidFunction) => void;
30
+ setAutoCompleteList: (list: typeList[], value?: typeValue, callback?: () => void) => void;
31
31
  clear: (openList?: boolean, focusInput?: boolean) => void;
32
32
  open: () => void;
33
33
  close: () => void;
@@ -7,20 +7,20 @@ import { onKeyboardSelection, setScrollListPosition } from '../_lib/listFunction
7
7
  import { Icon } from '../icon';
8
8
  import styles from './styles/SearchableInput.module.css';
9
9
  export var SearchableInput = forwardRef(function (_a, ref) {
10
- var autoCompleteList = _a.autoCompleteList, isDataFromApi = _a.isDataFromApi, name = _a.name, value = _a.value, parentInputValue = _a.parentInputValue, disabled = _a.disabled, itemComponent = _a.itemComponent, _b = _a.valueKey, valueKey = _b === void 0 ? 'value' : _b, _c = _a.labelKey, labelKey = _c === void 0 ? 'label' : _c, onSelect = _a.onSelect, onChange = _a.onChange, onText = _a.onText, style = _a.style, _d = _a.listPositionRelative, listPositionRelative = _d === void 0 ? false : _d, _e = _a.loadingMessage, loadingMessage = _e === void 0 ? 'Lütfen bekleyiniz...' : _e, _f = _a.notFoundMessage, notFoundMessage = _f === void 0 ? 'Kayıt bulunamadı...' : _f, placeholder = _a.placeholder, endAdornment = _a.endAdornment, _g = _a.ilkSec, ilkSec = _g === void 0 ? false : _g, _h = _a.newCreate, newCreate = _h === void 0 ? false : _h, inputRef = _a.inputRef, other = __rest(_a, ["autoCompleteList", "isDataFromApi", "name", "value", "parentInputValue", "disabled", "itemComponent", "valueKey", "labelKey", "onSelect", "onChange", "onText", "style", "listPositionRelative", "loadingMessage", "notFoundMessage", "placeholder", "endAdornment", "ilkSec", "newCreate", "inputRef"]);
10
+ var _b = _a.autoCompleteList, autoCompleteList = _b === void 0 ? [] : _b, isDataFromApi = _a.isDataFromApi, name = _a.name, value = _a.value, parentInputValue = _a.parentInputValue, disabled = _a.disabled, itemComponent = _a.itemComponent, _c = _a.valueKey, valueKey = _c === void 0 ? 'value' : _c, _d = _a.labelKey, labelKey = _d === void 0 ? 'label' : _d, onSelect = _a.onSelect, onChange = _a.onChange, onText = _a.onText, onLoad = _a.onLoad, style = _a.style, _e = _a.listPositionRelative, listPositionRelative = _e === void 0 ? false : _e, _f = _a.loadingMessage, loadingMessage = _f === void 0 ? 'Lütfen bekleyiniz...' : _f, _g = _a.notFoundMessage, notFoundMessage = _g === void 0 ? 'Kayıt bulunamadı...' : _g, placeholder = _a.placeholder, endAdornment = _a.endAdornment, _h = _a.ilkSec, ilkSec = _h === void 0 ? false : _h, _j = _a.newCreate, newCreate = _j === void 0 ? false : _j, inputRef = _a.inputRef, other = __rest(_a, ["autoCompleteList", "isDataFromApi", "name", "value", "parentInputValue", "disabled", "itemComponent", "valueKey", "labelKey", "onSelect", "onChange", "onText", "onLoad", "style", "listPositionRelative", "loadingMessage", "notFoundMessage", "placeholder", "endAdornment", "ilkSec", "newCreate", "inputRef"]);
11
11
  var refMain = useRef(null);
12
12
  var refInput = useRef(null);
13
13
  var refList = useRef(null);
14
- var _j = useState(autoCompleteList !== null && autoCompleteList !== void 0 ? autoCompleteList : []), data = _j[0], setData = _j[1];
15
- var _k = useState(value !== null && value !== void 0 ? value : undefined), selectedValue = _k[0], setSelectedValue = _k[1];
16
- var _l = useState(parentInputValue !== null && parentInputValue !== void 0 ? parentInputValue : undefined), parentValue = _l[0], setParentValue = _l[1];
17
- var _m = useState(''), text = _m[0], setText = _m[1]; //Inputta görünen
18
- var _o = useState(''), filter = _o[0], setFilter = _o[1]; // Filtrelemeye tabi tutulan
19
- var _p = useState({ created: false }), newItemCreate = _p[0], setNewItemCreate = _p[1];
20
- var _q = useState(false), open = _q[0], setOpen = _q[1];
21
- var _r = useState(isDataFromApi && (!autoCompleteList || (autoCompleteList === null || autoCompleteList === void 0 ? void 0 : autoCompleteList.length) == 0)), loading = _r[0], setLoading = _r[1];
14
+ var _k = useState(autoCompleteList !== null && autoCompleteList !== void 0 ? autoCompleteList : []), data = _k[0], setData = _k[1];
15
+ var _l = useState(value !== null && value !== void 0 ? value : undefined), selectedValue = _l[0], setSelectedValue = _l[1];
16
+ var _m = useState(parentInputValue !== null && parentInputValue !== void 0 ? parentInputValue : undefined), parentValue = _m[0], setParentValue = _m[1];
17
+ var _o = useState(''), text = _o[0], setText = _o[1]; //Inputta görünen
18
+ var _p = useState(''), filter = _p[0], setFilter = _p[1]; // Filtrelemeye tabi tutulan
19
+ var _q = useState({ created: false }), newItemCreate = _q[0], setNewItemCreate = _q[1];
20
+ var _r = useState(false), open = _r[0], setOpen = _r[1];
21
+ var _s = useState(isDataFromApi && (!autoCompleteList || (autoCompleteList === null || autoCompleteList === void 0 ? void 0 : autoCompleteList.length) == 0)), loading = _s[0], setLoading = _s[1];
22
22
  useImperativeHandle(ref, function () { return ({
23
- setAutoCompleteList: function (list, value) {
23
+ setAutoCompleteList: function (list, value, callback) {
24
24
  if (value === void 0) { value = undefined; }
25
25
  if (autoCompleteList && (autoCompleteList === null || autoCompleteList === void 0 ? void 0 : autoCompleteList.length) > 0) {
26
26
  alert('AutoCompleteList zaten tanımlı olduğundan dışardan data seti değiştirilemez.');
@@ -29,7 +29,11 @@ export var SearchableInput = forwardRef(function (_a, ref) {
29
29
  setData(list);
30
30
  value && sendChange(value);
31
31
  setLoading(false);
32
- // isDev && console.log('setAutoCompleteList =>', name, value, list);
32
+ if (!Array.isArray(list) || list.length == 0) {
33
+ clear(false);
34
+ }
35
+ callback && callback();
36
+ // isDev && console.log("setAutoCompleteList =>", name, value, list);
33
37
  },
34
38
  clear: function (openList, focusInput) {
35
39
  if (openList === void 0) { openList = false; }
@@ -51,23 +55,39 @@ export var SearchableInput = forwardRef(function (_a, ref) {
51
55
  if (inputRef)
52
56
  inputRef.current = refInput.current;
53
57
  }, [refInput.current]);
58
+ useEffect(function () { return onLoad && onLoad(value); }, []);
54
59
  useEffect(function () {
55
- if (autoCompleteList && Array.isArray(autoCompleteList) && JSON.stringify(autoCompleteList) !== JSON.stringify(data) && autoCompleteList.length > 0) {
56
- setData(autoCompleteList);
57
- // isDev && console.log('autoCompleteList =>', name, autoCompleteList, data);
60
+ if (autoCompleteList && Array.isArray(autoCompleteList)) {
61
+ if (autoCompleteList.length > 0) {
62
+ // Sadece gerçekten farklıysa set et
63
+ if (JSON.stringify(autoCompleteList) !== JSON.stringify(data)) {
64
+ setData(autoCompleteList);
65
+ // isDev && console.log("autoCompleteList dolu =>", name, autoCompleteList);
66
+ }
67
+ }
68
+ else {
69
+ // Boş array geldi VE data zaten boş değilse
70
+ if (data.length > 0) {
71
+ setData([]);
72
+ // isDev && console.log("autoCompleteList boşaltıldı =>", name);
73
+ }
74
+ }
58
75
  }
59
76
  }, [autoCompleteList]);
60
77
  useEffect(function () {
61
78
  // isDev && console.log('data =>', name, data, 'selectedValue =>', selectedValue, 'value =>', value);
79
+ if (!Array.isArray(data)) {
80
+ setData([]);
81
+ }
62
82
  if (data.length > 0) {
63
83
  setLoading(false);
64
84
  checkByValue(selectedValue, open);
65
- if (!value) {
66
- ilkSec && checkByValue(data[0][valueKey], false);
85
+ if (!value && ilkSec) {
86
+ checkByValue(data[0][valueKey], false);
67
87
  }
68
88
  }
69
89
  else {
70
- !isDataFromApi && clear();
90
+ !isDataFromApi && clear(false);
71
91
  }
72
92
  }, [data]);
73
93
  // Seçim değişikliğinde parent'ı bilgilendir
@@ -82,7 +102,7 @@ export var SearchableInput = forwardRef(function (_a, ref) {
82
102
  if (parentInputValue !== parentValue) {
83
103
  setParentValue(parentInputValue);
84
104
  clear(false);
85
- // isDev && console.log(name, 'parentInputValueDeğişti =>', parentInputValue);
105
+ // isDev && console.log(name, "parentInputValueDeğişti =>", parentInputValue);
86
106
  }
87
107
  }, [parentInputValue]);
88
108
  useEffect(function () {
@@ -115,11 +135,12 @@ export var SearchableInput = forwardRef(function (_a, ref) {
115
135
  }, [open]);
116
136
  useLayoutEffect(function () { return handleUpdatePosition(); }, [open]);
117
137
  var setValue = useCallback(function (item, openList) {
118
- var newValue = item && item[valueKey] ? item[valueKey] : '';
119
- var newLabel = item && item[labelKey] ? item[labelKey] : '';
138
+ var _a, _b;
139
+ var newValue = (_a = item === null || item === void 0 ? void 0 : item[valueKey]) !== null && _a !== void 0 ? _a : '';
140
+ var newLabel = (_b = item === null || item === void 0 ? void 0 : item[labelKey]) !== null && _b !== void 0 ? _b : '';
120
141
  setOpen(openList);
121
142
  setText(newLabel);
122
- // isDev && console.log('setValue', newValue, 'item', item, 'value', value);
143
+ // isDev && console.log(name, "setValue", newValue, "item", item, "value", value);
123
144
  if (newValue === selectedValue)
124
145
  return;
125
146
  setFilter('');
@@ -158,7 +179,7 @@ export var SearchableInput = forwardRef(function (_a, ref) {
158
179
  if (onText)
159
180
  onText('');
160
181
  }
161
- }, [data, labelKey, value, valueKey, isDataFromApi, onText, setValue]);
182
+ }, [data, labelKey, value, valueKey, isDataFromApi, onText, setValue, refInput.current]);
162
183
  var clear = useCallback(function (openList, focusInput) {
163
184
  var _a;
164
185
  if (openList === void 0) { openList = true; }
@@ -170,6 +191,7 @@ export var SearchableInput = forwardRef(function (_a, ref) {
170
191
  focusInput && ((_a = refInput === null || refInput === void 0 ? void 0 : refInput.current) === null || _a === void 0 ? void 0 : _a.focus());
171
192
  }, [setValue, onText]);
172
193
  var sendChange = useCallback(function (value) {
194
+ // isDev && console.log(name, "sendChange", value, "selectedValue", selectedValue);
173
195
  if (onChange && value !== selectedValue) {
174
196
  onChange({ target: { name: name, value: value } });
175
197
  }
@@ -215,7 +237,7 @@ export var SearchableInput = forwardRef(function (_a, ref) {
215
237
  selectedClass: 'selected'
216
238
  });
217
239
  };
218
- return (_jsxs("div", { ref: refMain, className: styles.searchableInputComponent, onKeyDown: onKeyDown, style: style, children: [_jsx(Input, __assign({}, other, { inputRef: refInput, name: name, value: text, onFocus: function () { return !disabled && setOpen(true); }, onChange: textInputOnChange, endAdornment: !disabled && (_jsxs("div", { style: { marginRight: 5 }, tabIndex: -1, children: [_jsx(Button, { title: 'Temizle', tabIndex: -1, hidden: !(text && text.length > 0), onClick: function () { return clear(true, true); }, onlyIcon: _jsx(Icon, { name: 'close', style: { color: '#444' } }) }), endAdornment, _jsx(Button, { tabIndex: -1, hidden: !(data.length > 0), onClick: function () { return !disabled && setOpen(!open); }, onlyIcon: _jsx(Icon, { name: open ? 'keyboard_arrow_up' : 'keyboard_arrow_down', style: { color: '#444' } }) })] })), placeholder: loading ? 'Lütfen bekleyiniz...' : placeholder, loading: loading, disabled: disabled, propsInput: __assign(__assign({}, other === null || other === void 0 ? void 0 : other.propsInput), { autoComplete: 'off' }) })), open && (_jsx("div", { className: 'listDiv', "data-relative": listPositionRelative, children: _jsxs("ul", { ref: refList, className: "list ".concat(open ? 'open' : ''), children: [(filteredData.length === 0 || loading) && _jsx("div", { className: "message ".concat(loading ? 'loading' : ''), children: loading ? loadingMessage : notFoundMessage }), filteredData.map(function (item, key) {
240
+ return (_jsxs("div", { ref: refMain, className: styles.searchableInputComponent, onKeyDown: onKeyDown, style: style, children: [_jsx(Input, __assign({}, other, { inputRef: refInput, name: name, value: text, onFocus: function () { return !disabled && setOpen(true); }, onChange: textInputOnChange, endAdornment: !disabled && (_jsxs("div", { style: { marginRight: 5 }, tabIndex: -1, children: [_jsx(Button, { title: 'Temizle', tabIndex: -1, hidden: !(text && text.length > 0), onClick: function () { return clear(true, true); }, onlyIcon: _jsx(Icon, { name: 'close', style: { color: '#444' } }) }), endAdornment, _jsx(Button, { tabIndex: -1, hidden: !data || !(data.length > 0), onClick: function () { return !disabled && setOpen(!open); }, onlyIcon: _jsx(Icon, { name: open ? 'keyboard_arrow_up' : 'keyboard_arrow_down', style: { color: '#444' } }) })] })), placeholder: loading ? 'Lütfen bekleyiniz...' : placeholder, loading: loading, disabled: disabled, propsInput: __assign(__assign({}, other === null || other === void 0 ? void 0 : other.propsInput), { autoComplete: 'off' }) })), open && (_jsx("div", { className: 'listDiv', "data-relative": listPositionRelative, children: _jsxs("ul", { ref: refList, className: "list ".concat(open ? 'open' : ''), children: [(filteredData.length === 0 || loading) && _jsx("div", { className: "message ".concat(loading ? 'loading' : ''), children: loading ? loadingMessage : notFoundMessage }), filteredData.map(function (item, key) {
219
241
  var itemValue = item[valueKey];
220
242
  var itemLabel = item[labelKey];
221
243
  return (_jsxs("li", { className: "item ".concat(itemValue === selectedValue ? 'active' : ''), "data-value": itemValue, "data-label": itemLabel, onClick: function () { return setValue(item, false); }, children: [item.create && _jsx("span", { className: 'newCreate', children: "Yeni Olu\u015Ftur: " }), itemComponent ? itemComponent(item) : itemLabel] }, key));
@@ -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.5rem', color: color || 'inherit' }), "aria-hidden": "true" }, other, { children: iconMui })));
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', xmlns: "http://www.w3.org/2000/svg", children: iconComponent.content }) })));
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
  };
@@ -1,5 +1,11 @@
1
- import { propsDialog } from "../form";
2
- import React from "react";
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
- export type typeMenu = SeperatorProps | FullComponentProps | ItemComponentProps;
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 {};