albinasoft-ui-package 1.0.62 → 1.0.64

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.
@@ -39,3 +39,11 @@ mark {
39
39
  color: black;
40
40
  font-weight: bold;
41
41
  }
42
+
43
+ .autocomplete-option.highlighted {
44
+ background-color: #e9ecef;
45
+ }
46
+
47
+ .dark .autocomplete-option.highlighted {
48
+ background-color: #949494;
49
+ }
@@ -16,7 +16,7 @@ interface CustomAutocompleteInputProps {
16
16
  className?: string;
17
17
  style?: React.CSSProperties;
18
18
  lang?: string;
19
- fetchOptions: (query: string) => string[];
19
+ fetchOptions: (query: string) => Promise<string[]>;
20
20
  onSelect: (value: string) => void;
21
21
  }
22
22
  declare const CustomAutocompleteInput: React.FC<CustomAutocompleteInputProps>;
@@ -67,11 +67,11 @@ var CustomInput_1 = __importStar(require("./CustomInput"));
67
67
  var CustomAutocompleteInput = function (_a) {
68
68
  var id = _a.id, name = _a.name, label = _a.label, value = _a.value, placeholder = _a.placeholder, _b = _a.required, required = _b === void 0 ? false : _b, description = _a.description, errorMessage = _a.errorMessage, conditionalErrorVisible = _a.conditionalErrorVisible, conditionalErrorMessage = _a.conditionalErrorMessage, _c = _a.disabled, disabled = _c === void 0 ? false : _c, tooltip = _a.tooltip, _d = _a.className, className = _d === void 0 ? '' : _d, style = _a.style, _e = _a.lang, lang = _e === void 0 ? 'tr-TR' : _e, fetchOptions = _a.fetchOptions, onSelect = _a.onSelect;
69
69
  var _f = (0, react_1.useState)(value || ''), inputValue = _f[0], setInputValue = _f[1];
70
- var _g = (0, react_1.useState)(null), selectedValue = _g[0], setSelectedValue = _g[1];
71
- var _h = (0, react_1.useState)([]), options = _h[0], setOptions = _h[1];
72
- var _j = (0, react_1.useState)(false), isDropdownVisible = _j[0], setIsDropdownVisible = _j[1];
70
+ var _g = (0, react_1.useState)([]), options = _g[0], setOptions = _g[1];
71
+ var _h = (0, react_1.useState)(false), isDropdownVisible = _h[0], setIsDropdownVisible = _h[1];
72
+ var _j = (0, react_1.useState)(-1), highlightedIndex = _j[0], setHighlightedIndex = _j[1];
73
73
  var dropdownRef = (0, react_1.useRef)(null);
74
- // Input değiştiğinde fetchOptions çağır
74
+ // Input değeri değişince fetchOptions ile seçenekleri getiriyoruz.
75
75
  var handleInputChange = function (e) { return __awaiter(void 0, void 0, void 0, function () {
76
76
  var value, fetchedOptions, error_1;
77
77
  return __generator(this, function (_a) {
@@ -79,7 +79,6 @@ var CustomAutocompleteInput = function (_a) {
79
79
  case 0:
80
80
  value = e.target.value;
81
81
  setInputValue(value);
82
- setSelectedValue(null);
83
82
  if (!value) return [3 /*break*/, 5];
84
83
  _a.label = 1;
85
84
  case 1:
@@ -89,6 +88,7 @@ var CustomAutocompleteInput = function (_a) {
89
88
  fetchedOptions = _a.sent();
90
89
  setOptions(fetchedOptions);
91
90
  setIsDropdownVisible(fetchedOptions.length > 0);
91
+ setHighlightedIndex(-1); // Her aramada highlight'ı resetliyoruz.
92
92
  return [3 /*break*/, 4];
93
93
  case 3:
94
94
  error_1 = _a.sent();
@@ -105,30 +105,46 @@ var CustomAutocompleteInput = function (_a) {
105
105
  }
106
106
  });
107
107
  }); };
108
- // Seçim yapıldığında onSelect çağır
108
+ // Bir seçenek tıklandığında
109
109
  var handleOptionClick = function (option) {
110
- setSelectedValue(option);
111
110
  onSelect(option);
112
- //setIsDropdownVisible(false);
113
- //setInputValue(option);
114
111
  };
115
112
  var handleReset = function () {
116
113
  setIsDropdownVisible(false);
117
114
  setInputValue('');
118
- setSelectedValue('');
119
115
  };
120
- // Dropdown dışında tıklanıldığında dropdown'u kapat
116
+ // Klavyeden gelen tuşlara tepki veren handler
117
+ var handleKeyDown = function (e) {
118
+ if (!isDropdownVisible)
119
+ return;
120
+ if (e.key === 'ArrowDown') {
121
+ e.preventDefault();
122
+ setHighlightedIndex(function (prev) { return (prev < options.length - 1 ? prev + 1 : 0); });
123
+ }
124
+ else if (e.key === 'ArrowUp') {
125
+ e.preventDefault();
126
+ setHighlightedIndex(function (prev) { return (prev > 0 ? prev - 1 : options.length - 1); });
127
+ }
128
+ else if (e.key === 'Enter') {
129
+ e.preventDefault();
130
+ if (highlightedIndex >= 0 && highlightedIndex < options.length) {
131
+ handleOptionClick(options[highlightedIndex]);
132
+ }
133
+ }
134
+ else if (e.key === 'Escape') {
135
+ setIsDropdownVisible(false);
136
+ }
137
+ };
138
+ // Vurgulanan öğenin görünür olmasını sağlamak için scrollIntoView kullanıyoruz.
121
139
  (0, react_1.useEffect)(function () {
122
- // const handleClickOutside = (event: MouseEvent) => {
123
- // if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
124
- // setIsDropdownVisible(false);
125
- // }
126
- // };
127
- // document.addEventListener('mousedown', handleClickOutside);
128
- // return () => {
129
- // document.removeEventListener('mousedown', handleClickOutside);
130
- // };
131
- }, []);
140
+ if (dropdownRef.current) {
141
+ var highlightedItem = dropdownRef.current.querySelector('.autocomplete-option.highlighted');
142
+ if (highlightedItem) {
143
+ highlightedItem.scrollIntoView({ block: 'nearest' });
144
+ }
145
+ }
146
+ }, [highlightedIndex]);
147
+ // Fonksiyon, eşleşen kısmı <mark> etiketiyle vurguluyor.
132
148
  var highlightMatch = function (option, query) {
133
149
  if (!query)
134
150
  return option;
@@ -152,9 +168,9 @@ var CustomAutocompleteInput = function (_a) {
152
168
  return (react_1.default.createElement("div", { className: "autocomplete-container ".concat(className), style: style },
153
169
  react_1.default.createElement("div", { className: "form-group" },
154
170
  react_1.default.createElement(react_bootstrap_1.OverlayTrigger, { placement: "bottom", overlay: tooltip ? react_1.default.createElement(react_bootstrap_1.Tooltip, { id: "tooltip-".concat(id) }, tooltip) : react_1.default.createElement(react_1.default.Fragment, null) },
155
- react_1.default.createElement(CustomInput_1.default, { id: id, name: name, label: label, inputType: CustomInput_1.InputType.TEXT, value: inputValue, onChange: handleInputChange, placeholder: placeholder, buttonIcon: react_1.default.createElement(fa_1.FaTimes, null), buttonClass: 'btn btn-danger bg-soft-danger', buttonOnClick: handleReset, className: "form-control", required: required, disabled: disabled })),
156
- isDropdownVisible && (react_1.default.createElement("div", { className: "autocomplete-dropdown", ref: dropdownRef }, options.map(function (option, index) { return (react_1.default.createElement("div", { key: index, className: "autocomplete-option", onClick: function () { return handleOptionClick(option); }, dangerouslySetInnerHTML: {
157
- __html: highlightMatch(option, inputValue), // Highlighting
171
+ react_1.default.createElement(CustomInput_1.default, { id: id, name: name, label: label, inputType: CustomInput_1.InputType.TEXT, value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, placeholder: placeholder, buttonIcon: react_1.default.createElement(fa_1.FaTimes, null), buttonClass: "btn btn-danger bg-soft-danger", buttonOnClick: handleReset, className: "form-control", required: required, disabled: disabled })),
172
+ isDropdownVisible && (react_1.default.createElement("div", { className: "autocomplete-dropdown", ref: dropdownRef }, options.map(function (option, index) { return (react_1.default.createElement("div", { key: index, className: "autocomplete-option ".concat(index === highlightedIndex ? 'highlighted' : ''), onClick: function () { return handleOptionClick(option); }, dangerouslySetInnerHTML: {
173
+ __html: highlightMatch(option, inputValue),
158
174
  } })); }))),
159
175
  errorMessage && (react_1.default.createElement("div", { className: "invalid-feedback text-danger mt-2" },
160
176
  react_1.default.createElement(fa_1.FaExclamationTriangle, { className: "me-1" }),
@@ -156,7 +156,7 @@ interface AutoCompleteInputElement {
156
156
  colId?: number;
157
157
  innerRowId?: number;
158
158
  colClass?: string;
159
- fetchOptions: (query: string) => string[];
159
+ fetchOptions: (query: string) => Promise<string[]>;
160
160
  onSelect: (value: string) => void;
161
161
  }
162
162
  interface FileUploaderElement {
@@ -30,6 +30,7 @@ interface CustomInputProps {
30
30
  className?: string;
31
31
  buttonOnClick?: () => void;
32
32
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
33
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
33
34
  }
34
35
  declare const CustomInput: React.FC<CustomInputProps>;
35
36
  export { CustomInput, InputType };
@@ -42,7 +42,7 @@ var InputType;
42
42
  })(InputType || (InputType = {}));
43
43
  exports.InputType = InputType;
44
44
  var CustomInput = function (_a) {
45
- var id = _a.id, name = _a.name, label = _a.label, _b = _a.inputType, inputType = _b === void 0 ? InputType.TEXT : _b, value = _a.value, placeholder = _a.placeholder, _c = _a.required, required = _c === void 0 ? false : _c, errorMessage = _a.errorMessage, _d = _a.conditionalErrorVisible, conditionalErrorVisible = _d === void 0 ? false : _d, conditionalErrorMessage = _a.conditionalErrorMessage, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, buttonIcon = _a.buttonIcon, buttonClass = _a.buttonClass, buttonTooltip = _a.buttonTooltip, description = _a.description, tooltip = _a.tooltip, style = _a.style, mainClass = _a.mainClass, className = _a.className, buttonOnClick = _a.buttonOnClick, onChange = _a.onChange;
45
+ var id = _a.id, name = _a.name, label = _a.label, _b = _a.inputType, inputType = _b === void 0 ? InputType.TEXT : _b, value = _a.value, placeholder = _a.placeholder, _c = _a.required, required = _c === void 0 ? false : _c, errorMessage = _a.errorMessage, _d = _a.conditionalErrorVisible, conditionalErrorVisible = _d === void 0 ? false : _d, conditionalErrorMessage = _a.conditionalErrorMessage, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, buttonIcon = _a.buttonIcon, buttonClass = _a.buttonClass, buttonTooltip = _a.buttonTooltip, description = _a.description, tooltip = _a.tooltip, style = _a.style, mainClass = _a.mainClass, className = _a.className, buttonOnClick = _a.buttonOnClick, onChange = _a.onChange, onKeyDown = _a.onKeyDown;
46
46
  var _g = (0, react_1.useState)(false), showPassword = _g[0], setShowPassword = _g[1];
47
47
  var handleType = inputType === InputType.PASSWORD && showPassword
48
48
  ? InputType.TEXT
@@ -53,10 +53,10 @@ var CustomInput = function (_a) {
53
53
  var renderInput = function () {
54
54
  // If inputType is TEL, use ReactInputMask
55
55
  if (inputType === InputType.TEL) {
56
- return (react_1.default.createElement(react_input_mask_1.default, { mask: "0(999) 999 99 99", value: value, onChange: onChange, className: "form-control ".concat(className), style: style, required: required, disabled: disabled, readOnly: readOnly, autoComplete: "new-password" }));
56
+ return (react_1.default.createElement(react_input_mask_1.default, { mask: "0(999) 999 99 99", value: value, onChange: onChange, onKeyDown: onKeyDown, className: "form-control ".concat(className), style: style, required: required, disabled: disabled, readOnly: readOnly, autoComplete: "new-password" }));
57
57
  }
58
58
  // Otherwise, return a normal input element
59
- return (react_1.default.createElement("input", { id: id, name: name, type: handleType, value: value, placeholder: placeholder, onChange: onChange, className: "form-control ".concat(className), style: style, required: required, disabled: disabled, readOnly: readOnly, autoComplete: "new-password" }));
59
+ return (react_1.default.createElement("input", { id: id, name: name, type: handleType, value: value, placeholder: placeholder, onChange: onChange, onKeyDown: onKeyDown, className: "form-control ".concat(className), style: style, required: required, disabled: disabled, readOnly: readOnly, autoComplete: "new-password" }));
60
60
  };
61
61
  return (react_1.default.createElement("div", { className: mainClass },
62
62
  react_1.default.createElement("div", { className: "form-group" },
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  declare enum TextType {
3
3
  BOLDHEAD = "boldhead",
4
4
  HEADING = "heading",
@@ -79,9 +79,7 @@ var Color;
79
79
  exports.Color = Color;
80
80
  var CustomText = function (_a) {
81
81
  var _b;
82
- var id = _a.id, value = _a.value, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.style, style = _d === void 0 ? {} : _d, _e = _a.textType, textType = _e === void 0 ? TextType.PARAGRAPH : _e, // Varsayılan olarak 'paragraph'
83
- color = _a.color, textAlign = _a.textAlign, fontSize = _a.fontSize, lineHeight = _a.lineHeight, fontWeight = _a.fontWeight, _f = _a.underline, underline = _f === void 0 ? false : _f, _g = _a.overline, overline = _g === void 0 ? false : _g, _h = _a.linethrough, linethrough = _h === void 0 ? false : _h, _j = _a.italic, italic = _j === void 0 ? false : _j, textAlignClass = _a.textAlignClass, linkText = _a.linkText;
84
- // Varsayılan stiller
82
+ var id = _a.id, value = _a.value, _c = _a.className, className = _c === void 0 ? "" : _c, _d = _a.style, style = _d === void 0 ? {} : _d, _e = _a.textType, textType = _e === void 0 ? TextType.PARAGRAPH : _e, color = _a.color, textAlign = _a.textAlign, fontSize = _a.fontSize, lineHeight = _a.lineHeight, fontWeight = _a.fontWeight, _f = _a.underline, underline = _f === void 0 ? false : _f, _g = _a.overline, overline = _g === void 0 ? false : _g, _h = _a.linethrough, linethrough = _h === void 0 ? false : _h, _j = _a.italic, italic = _j === void 0 ? false : _j, textAlignClass = _a.textAlignClass, linkText = _a.linkText;
85
83
  var defaultStyles = (_b = {},
86
84
  _b[TextType.BOLDHEAD] = {
87
85
  fontSize: FontSize.XL,
@@ -104,7 +102,6 @@ var CustomText = function (_a) {
104
102
  fontWeight: FontWeight.THIN,
105
103
  },
106
104
  _b);
107
- // Dinamik sınıf ekleme
108
105
  if (textType == TextType.BOLDHEAD && !color) {
109
106
  color = Color.DARK;
110
107
  }
@@ -126,31 +123,36 @@ var CustomText = function (_a) {
126
123
  else if (textAlign == TextAlign.END) {
127
124
  textAlignClass = "text-end";
128
125
  }
129
- // Text decoration birleştirme
130
126
  var textDecoration = [
131
- underline ? 'underline' : '',
132
- overline ? 'overline' : '',
133
- linethrough ? 'line-through' : '',
127
+ underline ? "underline" : "",
128
+ overline ? "overline" : "",
129
+ linethrough ? "line-through" : "",
134
130
  ]
135
131
  .filter(Boolean)
136
- .join(' ');
137
- // Varsayılan stil ile kullanıcı stilini birleştir
138
- var combinedStyle = __assign(__assign(__assign({}, defaultStyles[textType]), { textAlign: textAlign !== null && textAlign !== void 0 ? textAlign : defaultStyles[textType].textAlign, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : defaultStyles[textType].fontSize, lineHeight: lineHeight !== null && lineHeight !== void 0 ? lineHeight : defaultStyles[textType].lineHeight, fontWeight: fontWeight !== null && fontWeight !== void 0 ? fontWeight : defaultStyles[textType].fontWeight, textDecoration: textDecoration || undefined, fontStyle: italic ? 'italic' : undefined }), style);
132
+ .join(" ");
133
+ var combinedStyle = __assign(__assign(__assign({}, defaultStyles[textType]), { textAlign: textAlign !== null && textAlign !== void 0 ? textAlign : defaultStyles[textType].textAlign, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : defaultStyles[textType].fontSize, lineHeight: lineHeight !== null && lineHeight !== void 0 ? lineHeight : defaultStyles[textType].lineHeight, fontWeight: fontWeight !== null && fontWeight !== void 0 ? fontWeight : defaultStyles[textType].fontWeight, textDecoration: textDecoration || undefined, fontStyle: italic ? "italic" : undefined }), style);
139
134
  var combinedClassName = "".concat(color, " ").concat(className).trim();
140
- // URL'leri tıklanabilir hale getirme
141
- var renderWithLinks = function (text, linkText) {
142
- var urlRegex = /(https?:\/\/[^\s]+|www\.[^\s]+)/g; // URL'leri algılayan RegEx
143
- var parts = text.split(urlRegex);
144
- return parts.map(function (part, index) {
145
- return urlRegex.test(part) ? (react_1.default.createElement("a", { key: index, href: part.startsWith('http') ? part : "https://".concat(part), target: "_blank", rel: "noopener noreferrer", style: { wordBreak: 'break-all' } },
146
- linkText || part.replace(/https?:\/\/|www\.|\/$/g, ''),
147
- " ")) : (part);
135
+ /**
136
+ * Metindeki düz linkleri `<a>` etiketi ile sarmalar ve HTML olarak render eder.
137
+ */
138
+ var processTextWithLinks = function (text, linkText) {
139
+ if (typeof text !== "string")
140
+ return text;
141
+ // URL regex
142
+ var urlRegex = /(https?:\/\/[^\s]+|www\.[^\s]+)/g;
143
+ // Önce tüm satırları parçala (HTML olarak yazıldıysa çalışsın)
144
+ return text
145
+ .split("\n")
146
+ .map(function (line, lineIndex) {
147
+ // Metin içinde link var mı kontrol et
148
+ var parts = line.split(urlRegex);
149
+ return (react_1.default.createElement("p", { key: lineIndex, style: { margin: "0" } }, parts.map(function (part, index) {
150
+ return urlRegex.test(part) ? (react_1.default.createElement("a", { key: index, href: part.startsWith("http") ? part : "https://".concat(part), target: "_blank", rel: "noopener noreferrer", style: { wordBreak: "break-word", color: "#007bff" } }, linkText || part.replace(/https?:\/\/|www\.|\/$/g, ""))) : (react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: part }, key: index }));
151
+ })));
148
152
  });
149
153
  };
150
154
  return (react_1.default.createElement("div", { className: "".concat(textAlignClass) },
151
- react_1.default.createElement("span", { id: id || "custom-text-".concat(Date.now()), className: "custom-text ".concat(combinedClassName), style: combinedStyle },
152
- renderWithLinks(value, linkText),
153
- " ")));
155
+ react_1.default.createElement("span", { id: id || "custom-text-".concat(Date.now()), className: "custom-text ".concat(combinedClassName), style: combinedStyle }, processTextWithLinks(value, linkText))));
154
156
  };
155
157
  exports.CustomText = CustomText;
156
158
  exports.default = CustomText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "albinasoft-ui-package",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {