albinasoft-ui-package 1.0.32 → 1.0.34
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.
@@ -63,11 +63,13 @@ var react_1 = __importStar(require("react"));
|
|
63
63
|
var fa_1 = require("react-icons/fa");
|
64
64
|
var react_bootstrap_1 = require("react-bootstrap");
|
65
65
|
require("../assets/css/custom-autocomplete-input.css");
|
66
|
+
var CustomInput_1 = __importStar(require("./CustomInput"));
|
66
67
|
var CustomAutocompleteInput = function (_a) {
|
67
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, fetchOptions = _a.fetchOptions, onSelect = _a.onSelect;
|
68
69
|
var _e = (0, react_1.useState)(value || ''), inputValue = _e[0], setInputValue = _e[1];
|
69
|
-
var _f = (0, react_1.useState)(
|
70
|
-
var _g = (0, react_1.useState)(
|
70
|
+
var _f = (0, react_1.useState)(null), selectedValue = _f[0], setSelectedValue = _f[1];
|
71
|
+
var _g = (0, react_1.useState)([]), options = _g[0], setOptions = _g[1];
|
72
|
+
var _h = (0, react_1.useState)(false), isDropdownVisible = _h[0], setIsDropdownVisible = _h[1];
|
71
73
|
var dropdownRef = (0, react_1.useRef)(null);
|
72
74
|
// Input değiştiğinde fetchOptions çağır
|
73
75
|
var handleInputChange = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
@@ -77,6 +79,7 @@ var CustomAutocompleteInput = function (_a) {
|
|
77
79
|
case 0:
|
78
80
|
value = e.target.value;
|
79
81
|
setInputValue(value);
|
82
|
+
setSelectedValue(null);
|
80
83
|
if (!value) return [3 /*break*/, 5];
|
81
84
|
_a.label = 1;
|
82
85
|
case 1:
|
@@ -104,25 +107,32 @@ var CustomAutocompleteInput = function (_a) {
|
|
104
107
|
}); };
|
105
108
|
// Seçim yapıldığında onSelect çağır
|
106
109
|
var handleOptionClick = function (option) {
|
110
|
+
setSelectedValue(option);
|
107
111
|
onSelect(option);
|
112
|
+
//setIsDropdownVisible(false);
|
113
|
+
//setInputValue(option);
|
114
|
+
};
|
115
|
+
var handleReset = function () {
|
108
116
|
setIsDropdownVisible(false);
|
109
|
-
setInputValue(
|
117
|
+
setInputValue('');
|
118
|
+
setSelectedValue('');
|
110
119
|
};
|
111
120
|
// Dropdown dışında tıklanıldığında dropdown'u kapat
|
112
121
|
(0, react_1.useEffect)(function () {
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
};
|
118
|
-
document.addEventListener('mousedown', handleClickOutside);
|
119
|
-
return
|
120
|
-
|
121
|
-
};
|
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
|
+
// };
|
122
131
|
}, []);
|
123
|
-
// 🔍 Highlighting Function
|
124
132
|
var highlightMatch = function (option, query) {
|
125
|
-
|
133
|
+
// Kullanıcı girişini regex için güvenli hale getir
|
134
|
+
var escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
135
|
+
var regex = new RegExp("(".concat(escapedQuery, ")"), 'gi');
|
126
136
|
var highlighted = option.replace(regex, '<mark>$1</mark>');
|
127
137
|
return highlighted;
|
128
138
|
};
|
@@ -130,10 +140,10 @@ var CustomAutocompleteInput = function (_a) {
|
|
130
140
|
react_1.default.createElement("div", { className: "form-group" },
|
131
141
|
react_1.default.createElement("label", { htmlFor: id, className: "form-label" }, label),
|
132
142
|
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) },
|
133
|
-
react_1.default.createElement(
|
143
|
+
react_1.default.createElement(CustomInput_1.default, { id: id, name: name, 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 })),
|
134
144
|
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: {
|
135
|
-
__html: highlightMatch(option, inputValue),
|
136
|
-
} }
|
145
|
+
__html: highlightMatch(option, inputValue), // Highlighting
|
146
|
+
} })); }))),
|
137
147
|
errorMessage && (react_1.default.createElement("div", { className: "invalid-feedback text-danger mt-2" },
|
138
148
|
react_1.default.createElement(fa_1.FaExclamationTriangle, { className: "me-1" }),
|
139
149
|
errorMessage)),
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
var react_1 = __importDefault(require("react"));
|
7
7
|
var react_bootstrap_1 = require("react-bootstrap");
|
8
|
+
require("../assets/css/custom-autocomplete-input.css");
|
8
9
|
var CustomModal = function (_a) {
|
9
10
|
var show = _a.show, _b = _a.title, title = _b === void 0 ? 'Default Title' : _b, _c = _a.size, size = _c === void 0 ? 'lg' : _c, onHide = _a.onHide, children = _a.children, footer = _a.footer, style = _a.style, bodyStyle = _a.bodyStyle;
|
10
11
|
return (react_1.default.createElement(react_bootstrap_1.Modal, { show: show, onHide: onHide, size: size !== 'fullscreen' ? size : undefined, fullscreen: size === 'fullscreen' ? true : undefined, centered: size !== 'fullscreen', style: style },
|